Changeset b0f00a9 in mainline for uspace/srv/hw/bus/cuda_adb/cuda_adb.c
- Timestamp:
- 2011-11-06T22:21:05Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/fix-logger-deadlock, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 898e847
- Parents:
- 2bdf8313 (diff), 7b5f4c9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - File:
-
- 1 edited
-
uspace/srv/hw/bus/cuda_adb/cuda_adb.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hw/bus/cuda_adb/cuda_adb.c
r2bdf8313 rb0f00a9 43 43 #include <ddi.h> 44 44 #include <libarch/ddi.h> 45 #include < devmap.h>45 #include <loc.h> 46 46 #include <sysinfo.h> 47 47 #include <errno.h> … … 51 51 #include "cuda_adb.h" 52 52 53 #define NAME "cuda_adb"54 55 static void cuda_connection(ipc_callid_t iid, ipc_call_t *icall );53 #define NAME "cuda_adb" 54 55 static void cuda_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg); 56 56 static int cuda_init(void); 57 57 static void cuda_irq_handler(ipc_callid_t iid, ipc_call_t *call); … … 143 143 int main(int argc, char *argv[]) 144 144 { 145 devmap_handle_t devmap_handle;145 service_id_t service_id; 146 146 int rc; 147 147 int i; … … 150 150 151 151 for (i = 0; i < ADB_MAX_ADDR; ++i) { 152 adb_dev[i].client_ phone = -1;153 adb_dev[i]. devmap_handle= 0;154 } 155 156 rc = devmap_driver_register(NAME, cuda_connection);152 adb_dev[i].client_sess = NULL; 153 adb_dev[i].service_id = 0; 154 } 155 156 rc = loc_server_register(NAME, cuda_connection); 157 157 if (rc < 0) { 158 printf(NAME ": Unable to register driver.\n");158 printf(NAME ": Unable to register server.\n"); 159 159 return rc; 160 160 } 161 161 162 rc = devmap_device_register("adb/kbd", &devmap_handle);162 rc = loc_service_register("adb/kbd", &service_id); 163 163 if (rc != EOK) { 164 printf(NAME ": Unable to register device %s.\n", "adb/kdb");164 printf(NAME ": Unable to register service %s.\n", "adb/kdb"); 165 165 return rc; 166 166 } 167 167 168 adb_dev[2]. devmap_handle = devmap_handle;169 adb_dev[8]. devmap_handle = devmap_handle;170 171 rc = devmap_device_register("adb/mouse", &devmap_handle);168 adb_dev[2].service_id = service_id; 169 adb_dev[8].service_id = service_id; 170 171 rc = loc_service_register("adb/mouse", &service_id); 172 172 if (rc != EOK) { 173 printf(NAME ": Unable to register device %s.\n", "adb/mouse");173 printf(NAME ": Unable to register servise %s.\n", "adb/mouse"); 174 174 return rc; 175 175 } 176 176 177 adb_dev[9]. devmap_handle = devmap_handle;177 adb_dev[9].service_id = service_id; 178 178 179 179 if (cuda_init() < 0) { … … 189 189 190 190 /** Character device connection handler */ 191 static void cuda_connection(ipc_callid_t iid, ipc_call_t *icall )191 static void cuda_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg) 192 192 { 193 193 ipc_callid_t callid; 194 194 ipc_call_t call; 195 195 sysarg_t method; 196 devmap_handle_t dh; 197 int retval; 196 service_id_t dsid; 198 197 int dev_addr, i; 199 198 200 199 /* Get the device handle. */ 201 d h= IPC_GET_ARG1(*icall);200 dsid = IPC_GET_ARG1(*icall); 202 201 203 202 /* Determine which disk device is the client connecting to. */ 204 203 dev_addr = -1; 205 204 for (i = 0; i < ADB_MAX_ADDR; i++) { 206 if (adb_dev[i]. devmap_handle == dh)205 if (adb_dev[i].service_id == dsid) 207 206 dev_addr = i; 208 207 } … … 216 215 async_answer_0(iid, EOK); 217 216 218 while ( 1) {217 while (true) { 219 218 callid = async_get_call(&call); 220 219 method = IPC_GET_IMETHOD(call); 221 switch (method) {222 case IPC_M_PHONE_HUNGUP:220 221 if (!method) { 223 222 /* The other side has hung up. */ 224 223 async_answer_0(callid, EOK); 225 224 return; 226 case IPC_M_CONNECT_TO_ME: 227 if (adb_dev[dev_addr].client_phone != -1) { 228 retval = ELIMIT; 229 break; 230 } 231 adb_dev[dev_addr].client_phone = IPC_GET_ARG5(call); 232 /* 233 * A hack so that we send the data to the phone 234 * regardless of which address the device is on. 235 */ 236 for (i = 0; i < ADB_MAX_ADDR; ++i) { 237 if (adb_dev[i].devmap_handle == dh) { 238 adb_dev[i].client_phone = IPC_GET_ARG5(call); 225 } 226 227 async_sess_t *sess = 228 async_callback_receive_start(EXCHANGE_SERIALIZE, &call); 229 if (sess != NULL) { 230 if (adb_dev[dev_addr].client_sess == NULL) { 231 adb_dev[dev_addr].client_sess = sess; 232 233 /* 234 * A hack so that we send the data to the session 235 * regardless of which address the device is on. 236 */ 237 for (i = 0; i < ADB_MAX_ADDR; ++i) { 238 if (adb_dev[i].service_id == dsid) 239 adb_dev[i].client_sess = sess; 239 240 } 240 } 241 retval = 0; 242 break; 243 default: 244 retval = EINVAL; 245 break; 246 } 247 async_answer_0(callid, retval); 241 242 async_answer_0(callid, EOK); 243 } else 244 async_answer_0(callid, ELIMIT); 245 } else 246 async_answer_0(callid, EINVAL); 248 247 } 249 248 } … … 476 475 reg_val = ((uint16_t) data[1] << 8) | (uint16_t) data[2]; 477 476 478 if (adb_dev[dev_addr].client_phone == -1) 479 return; 480 481 async_msg_1(adb_dev[dev_addr].client_phone, ADB_REG_NOTIF, reg_val); 477 if (adb_dev[dev_addr].client_sess == NULL) 478 return; 479 480 async_exch_t *exch = 481 async_exchange_begin(adb_dev[dev_addr].client_sess); 482 async_msg_1(exch, ADB_REG_NOTIF, reg_val); 483 async_exchange_end(exch); 482 484 } 483 485
Note:
See TracChangeset
for help on using the changeset viewer.
