Changeset 2300b9d in mainline
- Timestamp:
- 2010-04-30T08:29:42Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- dafe675
- Parents:
- 7f8b581
- Location:
- uspace
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libdrv/generic/driver.c
r7f8b581 r2300b9d 81 81 82 82 static void driver_irq_handler(ipc_callid_t iid, ipc_call_t *icall) 83 { 83 { 84 84 int id = (int)IPC_GET_METHOD(*icall); 85 85 interrupt_context_t *ctx = find_interrupt_context_by_id(&interrupt_contexts, id); 86 (*ctx->handler)(ctx->dev, iid, icall); 86 if (NULL != ctx && NULL != ctx->handler) { 87 (*ctx->handler)(ctx->dev, iid, icall); 88 } 87 89 } 88 90 -
uspace/srv/drivers/serial/serial.c
r7f8b581 r2300b9d 242 242 serial_dev_data_t *data = (serial_dev_data_t *)dev->driver_data; 243 243 244 int res; 244 245 // enable interrupt globally 245 enable_interrupt(data->irq); 246 printf(NAME ": call enable_interrupt\n"); 247 if (EOK != (res = interrupt_enable(data->irq))) { 248 return res; 249 } 246 250 247 251 // enable interrupt on the serial port 248 252 pio_write_8(data->port + 1 , 0x01); // Interrupt when data received 249 pio_write_8(data->port + 4, 0x0B); 253 pio_write_8(data->port + 4, 0x0B); 250 254 251 255 return EOK; … … 267 271 } 268 272 269 static void serial_interrupt_handler(device_t *dev, ipc_callid_t iid, ipc_call_t *icall) 270 { 271 // TODO 273 static void serial_read_from_device(device_t *dev) 274 { 275 // TODO 276 } 277 278 static inline void serial_interrupt_handler(device_t *dev, ipc_callid_t iid, ipc_call_t *icall) 279 { 280 printf(NAME ": interrupt received.\n"); 281 serial_read_from_device(dev); 272 282 } 273 283 … … 276 286 serial_dev_data_t *data = (serial_dev_data_t *)dev->driver_data; 277 287 278 return register_interrupt_handler(dev, data->irq, serial_interrupt_handler, NULL); 279 288 return register_interrupt_handler(dev, data->irq, serial_interrupt_handler, NULL); 289 } 290 291 static inline int serial_unregister_interrupt_handler(device_t *dev) 292 { 293 serial_dev_data_t *data = (serial_dev_data_t *)dev->driver_data; 294 295 return unregister_interrupt_handler(dev, data->irq); 280 296 } 281 297 … … 304 320 305 321 // register interrupt handler 306 if (0 != serial_register_interrupt_handler(dev)) { 307 308 } 309 310 // enable interrupt 311 if (0 != (res = serial_interrupt_enable(dev))) { 322 if (EOK != serial_register_interrupt_handler(dev)) { 323 printf(NAME ": failed to register interrupt handler.\n"); 312 324 serial_dev_cleanup(dev); 313 325 return res; 326 } 327 328 // enable interrupt 329 if (EOK != (res = serial_interrupt_enable(dev))) { 330 printf(NAME ": failed to enable the interrupt. Error code = %d.\n", res); 331 serial_dev_cleanup(dev); 332 serial_unregister_interrupt_handler(dev); 333 return res; 314 334 } 335 336 printf(NAME ": the %s device has been successfully initialized.\n", dev->name); 315 337 316 338 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.