Changes in uspace/srv/hw/char/i8042/i8042.c [ffa2c8ef:5da7199] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hw/char/i8042/i8042.c
rffa2c8ef r5da7199 32 32 * @ingroup kbd 33 33 * @{ 34 */ 34 */ 35 35 /** @file 36 36 * @brief i8042 PS/2 port driver. … … 39 39 #include <ddi.h> 40 40 #include <libarch/ddi.h> 41 #include < devmap.h>41 #include <loc.h> 42 42 #include <async.h> 43 43 #include <unistd.h> … … 46 46 #include <errno.h> 47 47 #include <inttypes.h> 48 49 48 #include "i8042.h" 50 49 51 #define NAME "i8042"52 #define NAMESPACE "char"50 #define NAME "i8042" 51 #define NAMESPACE "char" 53 52 54 53 /* Interesting bits for status register */ … … 119 118 120 119 static void i8042_irq_handler(ipc_callid_t iid, ipc_call_t *call); 121 static void i8042_connection(ipc_callid_t iid, ipc_call_t *icall );120 static void i8042_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg); 122 121 static int i8042_init(void); 123 122 static void i8042_port_write(int devid, uint8_t data); … … 132 131 printf(NAME ": i8042 PS/2 port driver\n"); 133 132 134 rc = devmap_driver_register(NAME, i8042_connection);133 rc = loc_server_register(NAME, i8042_connection); 135 134 if (rc < 0) { 136 printf(NAME ": Unable to register driver.\n");135 printf(NAME ": Unable to register server.\n"); 137 136 return rc; 138 137 } … … 142 141 143 142 for (i = 0; i < MAX_DEVS; i++) { 144 i8042_port[i].client_ phone = -1;143 i8042_port[i].client_sess = NULL; 145 144 146 145 snprintf(name, 16, "%s/ps2%c", NAMESPACE, dchar[i]); 147 rc = devmap_device_register(name, &i8042_port[i].devmap_handle);146 rc = loc_service_register(name, &i8042_port[i].service_id); 148 147 if (rc != EOK) { 149 148 printf(NAME ": Unable to register device %s.\n", name); … … 213 212 214 213 /** Character device connection handler */ 215 static void i8042_connection(ipc_callid_t iid, ipc_call_t *icall )214 static void i8042_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg) 216 215 { 217 216 ipc_callid_t callid; 218 217 ipc_call_t call; 219 218 sysarg_t method; 220 devmap_handle_t dh;219 service_id_t dsid; 221 220 int retval; 222 221 int dev_id, i; … … 225 224 226 225 /* Get the device handle. */ 227 d h= IPC_GET_ARG1(*icall);226 dsid = IPC_GET_ARG1(*icall); 228 227 229 228 /* Determine which disk device is the client connecting to. */ 230 229 dev_id = -1; 231 230 for (i = 0; i < MAX_DEVS; i++) { 232 if (i8042_port[i]. devmap_handle == dh)231 if (i8042_port[i].service_id == dsid) 233 232 dev_id = i; 234 233 } … … 247 246 callid = async_get_call(&call); 248 247 method = IPC_GET_IMETHOD(call); 249 switch (method) {250 case IPC_M_PHONE_HUNGUP:248 249 if (!method) { 251 250 /* The other side has hung up. */ 252 251 async_answer_0(callid, EOK); 253 252 return; 254 case IPC_M_CONNECT_TO_ME: 255 printf(NAME ": creating callback connection\n"); 256 if (i8042_port[dev_id].client_phone != -1) { 253 } 254 255 async_sess_t *sess = 256 async_callback_receive_start(EXCHANGE_SERIALIZE, &call); 257 if (sess != NULL) { 258 if (i8042_port[dev_id].client_sess == NULL) { 259 i8042_port[dev_id].client_sess = sess; 260 retval = EOK; 261 } else 257 262 retval = ELIMIT; 263 } else { 264 switch (method) { 265 case IPC_FIRST_USER_METHOD: 266 printf(NAME ": write %" PRIun " to devid %d\n", 267 IPC_GET_ARG1(call), dev_id); 268 i8042_port_write(dev_id, IPC_GET_ARG1(call)); 269 retval = 0; 270 break; 271 default: 272 retval = EINVAL; 258 273 break; 259 274 } 260 i8042_port[dev_id].client_phone = IPC_GET_ARG5(call);261 retval = 0;262 break;263 case IPC_FIRST_USER_METHOD:264 printf(NAME ": write %" PRIun " to devid %d\n",265 IPC_GET_ARG1(call), dev_id);266 i8042_port_write(dev_id, IPC_GET_ARG1(call));267 retval = 0;268 break;269 default:270 retval = EINVAL;271 break;272 275 } 276 273 277 async_answer_0(callid, retval); 274 278 } … … 299 303 } 300 304 301 if (i8042_port[devid].client_phone != -1) { 302 async_msg_1(i8042_port[devid].client_phone, 303 IPC_FIRST_USER_METHOD, data); 305 if (i8042_port[devid].client_sess != NULL) { 306 async_exch_t *exch = 307 async_exchange_begin(i8042_port[devid].client_sess); 308 async_msg_1(exch, IPC_FIRST_USER_METHOD, data); 309 async_exchange_end(exch); 304 310 } 305 311 }
Note:
See TracChangeset
for help on using the changeset viewer.