Changeset 26e7d6d in mainline for uspace/srv/hw/bus/cuda_adb/cuda_adb.c
- Timestamp:
- 2011-09-19T16:31:00Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a347a11
- Parents:
- 3842a955 (diff), 086290d (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
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hw/bus/cuda_adb/cuda_adb.c
r3842a955 r26e7d6d 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> 48 48 #include <ipc/adb.h> 49 49 #include <async.h> 50 #include <async_obsolete.h>51 50 #include <assert.h> 52 51 #include "cuda_adb.h" 53 52 54 // FIXME: remove this header 55 #include <kernel/ipc/ipc_methods.h> 56 57 #define NAME "cuda_adb" 53 #define NAME "cuda_adb" 58 54 59 55 static void cuda_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg); … … 147 143 int main(int argc, char *argv[]) 148 144 { 149 devmap_handle_t devmap_handle;145 service_id_t service_id; 150 146 int rc; 151 147 int i; … … 154 150 155 151 for (i = 0; i < ADB_MAX_ADDR; ++i) { 156 adb_dev[i].client_ phone = -1;157 adb_dev[i]. devmap_handle= 0;158 } 159 160 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); 161 157 if (rc < 0) { 162 printf(NAME ": Unable to register driver.\n");158 printf(NAME ": Unable to register server.\n"); 163 159 return rc; 164 160 } 165 161 166 rc = devmap_device_register("adb/kbd", &devmap_handle);162 rc = loc_service_register("adb/kbd", &service_id); 167 163 if (rc != EOK) { 168 printf(NAME ": Unable to register device %s.\n", "adb/kdb");164 printf(NAME ": Unable to register service %s.\n", "adb/kdb"); 169 165 return rc; 170 166 } 171 167 172 adb_dev[2]. devmap_handle = devmap_handle;173 adb_dev[8]. devmap_handle = devmap_handle;174 175 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); 176 172 if (rc != EOK) { 177 printf(NAME ": Unable to register device %s.\n", "adb/mouse");173 printf(NAME ": Unable to register servise %s.\n", "adb/mouse"); 178 174 return rc; 179 175 } 180 176 181 adb_dev[9]. devmap_handle = devmap_handle;177 adb_dev[9].service_id = service_id; 182 178 183 179 if (cuda_init() < 0) { … … 198 194 ipc_call_t call; 199 195 sysarg_t method; 200 devmap_handle_t dh; 201 int retval; 196 service_id_t dsid; 202 197 int dev_addr, i; 203 198 204 199 /* Get the device handle. */ 205 d h= IPC_GET_ARG1(*icall);200 dsid = IPC_GET_ARG1(*icall); 206 201 207 202 /* Determine which disk device is the client connecting to. */ 208 203 dev_addr = -1; 209 204 for (i = 0; i < ADB_MAX_ADDR; i++) { 210 if (adb_dev[i]. devmap_handle == dh)205 if (adb_dev[i].service_id == dsid) 211 206 dev_addr = i; 212 207 } … … 220 215 async_answer_0(iid, EOK); 221 216 222 while ( 1) {217 while (true) { 223 218 callid = async_get_call(&call); 224 219 method = IPC_GET_IMETHOD(call); … … 230 225 } 231 226 232 switch (method) { 233 case IPC_M_CONNECT_TO_ME: 234 if (adb_dev[dev_addr].client_phone != -1) { 235 retval = ELIMIT; 236 break; 237 } 238 adb_dev[dev_addr].client_phone = IPC_GET_ARG5(call); 239 /* 240 * A hack so that we send the data to the phone 241 * regardless of which address the device is on. 242 */ 243 for (i = 0; i < ADB_MAX_ADDR; ++i) { 244 if (adb_dev[i].devmap_handle == dh) { 245 adb_dev[i].client_phone = IPC_GET_ARG5(call); 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; 246 240 } 247 } 248 retval = 0; 249 break; 250 default: 251 retval = EINVAL; 252 break; 253 } 254 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); 255 247 } 256 248 } … … 483 475 reg_val = ((uint16_t) data[1] << 8) | (uint16_t) data[2]; 484 476 485 if (adb_dev[dev_addr].client_phone == -1) 486 return; 487 488 async_obsolete_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); 489 484 } 490 485
Note:
See TracChangeset
for help on using the changeset viewer.