00001 /* 00002 * Copyright (c) 2006 Martin Decky 00003 * Copyright (c) 2010 Jiri Svoboda 00004 * All rights reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions 00008 * are met: 00009 * 00010 * - Redistributions of source code must retain the above copyright 00011 * notice, this list of conditions and the following disclaimer. 00012 * - Redistributions in binary form must reproduce the above copyright 00013 * notice, this list of conditions and the following disclaimer in the 00014 * documentation and/or other materials provided with the distribution. 00015 * - The name of the author may not be used to endorse or promote products 00016 * derived from this software without specific prior written permission. 00017 * 00018 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 00019 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00020 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 00021 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 00022 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 00023 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00024 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00025 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00026 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 00027 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00028 */ 00029 00036 #ifndef CUDA_ADB_H_ 00037 #define CUDA_ADB_H_ 00038 00039 #include <sys/types.h> 00040 #include <ipc/devmap.h> 00041 #include <fibril_synch.h> 00042 00043 typedef struct { 00044 uint8_t b; 00045 uint8_t pad0[0x1ff]; 00046 00047 uint8_t a; 00048 uint8_t pad1[0x1ff]; 00049 00050 uint8_t dirb; 00051 uint8_t pad2[0x1ff]; 00052 00053 uint8_t dira; 00054 uint8_t pad3[0x1ff]; 00055 00056 uint8_t t1cl; 00057 uint8_t pad4[0x1ff]; 00058 00059 uint8_t t1ch; 00060 uint8_t pad5[0x1ff]; 00061 00062 uint8_t t1ll; 00063 uint8_t pad6[0x1ff]; 00064 00065 uint8_t t1lh; 00066 uint8_t pad7[0x1ff]; 00067 00068 uint8_t t2cl; 00069 uint8_t pad8[0x1ff]; 00070 00071 uint8_t t2ch; 00072 uint8_t pad9[0x1ff]; 00073 00074 uint8_t sr; 00075 uint8_t pad10[0x1ff]; 00076 00077 uint8_t acr; 00078 uint8_t pad11[0x1ff]; 00079 00080 uint8_t pcr; 00081 uint8_t pad12[0x1ff]; 00082 00083 uint8_t ifr; 00084 uint8_t pad13[0x1ff]; 00085 00086 uint8_t ier; 00087 uint8_t pad14[0x1ff]; 00088 00089 uint8_t anh; 00090 uint8_t pad15[0x1ff]; 00091 } cuda_t; 00092 00093 enum { 00094 CUDA_RCV_BUF_SIZE = 5 00095 }; 00096 00097 enum cuda_xfer_state { 00098 cx_listen, 00099 cx_receive, 00100 cx_rcv_end, 00101 cx_send_start, 00102 cx_send 00103 }; 00104 00105 typedef struct { 00106 devmap_handle_t devmap_handle; 00107 int client_phone; 00108 } adb_dev_t; 00109 00110 typedef struct { 00111 cuda_t *cuda; 00112 uintptr_t cuda_physical; 00113 uintptr_t cuda_kernel; 00114 00115 uint8_t rcv_buf[CUDA_RCV_BUF_SIZE]; 00116 uint8_t snd_buf[CUDA_RCV_BUF_SIZE]; 00117 size_t bidx; 00118 size_t snd_bytes; 00119 enum cuda_xfer_state xstate; 00120 fibril_mutex_t dev_lock; 00121 } cuda_instance_t; 00122 00123 #endif 00124