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