Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 2300b9d in mainline


Ignore:
Timestamp:
2010-04-30T08:29:42Z (11 years ago)
Author:
Lenka Trochtova <trochtova.lenka@…>
Branches:
lfn, master
Children:
dafe675
Parents:
7f8b581
Message:

Fixed a bug.

Location:
uspace
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libdrv/generic/driver.c

    r7f8b581 r2300b9d  
    8181
    8282static void driver_irq_handler(ipc_callid_t iid, ipc_call_t *icall)
    83 {
     83{       
    8484        int id = (int)IPC_GET_METHOD(*icall);
    8585        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        }
    8789}
    8890
  • uspace/srv/drivers/serial/serial.c

    r7f8b581 r2300b9d  
    242242        serial_dev_data_t *data = (serial_dev_data_t *)dev->driver_data;
    243243       
     244        int res;
    244245        // 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        }
    246250       
    247251        // enable interrupt on the serial port
    248252        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);     
    250254       
    251255        return EOK;
     
    267271}
    268272
    269 static void serial_interrupt_handler(device_t *dev, ipc_callid_t iid, ipc_call_t *icall)
    270 {
    271         // TODO
     273static void serial_read_from_device(device_t *dev)
     274{
     275        // TODO
     276}
     277
     278static 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);
    272282}
    273283
     
    276286        serial_dev_data_t *data = (serial_dev_data_t *)dev->driver_data;
    277287       
    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
     291static 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);   
    280296}
    281297
     
    304320       
    305321        // 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");
    312324                serial_dev_cleanup(dev);
    313325                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;
    314334        }               
     335       
     336        printf(NAME ": the %s device has been successfully initialized.\n", dev->name);
    315337       
    316338        return EOK;
Note: See TracChangeset for help on using the changeset viewer.