Ignore:
Timestamp:
2009-03-12T17:54:24Z (16 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3a1c048
Parents:
a0e1b48
Message:

update for the new scheme of wiring device drivers to keyboard/serial modules

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/genarch/src/drivers/i8042/i8042.c

    ra0e1b48 r3c79afe  
    2727 */
    2828
    29 /** @addtogroup genarch 
     29/** @addtogroup genarch
    3030 * @{
    3131 */
    3232/**
    3333 * @file
    34  * @brief       i8042 processor driver
     34 * @brief i8042 processor driver
    3535 *
    3636 * It takes care of the i8042 serial communication.
     
    4343#include <mm/slab.h>
    4444
    45 #define i8042_SET_COMMAND       0x60
    46 #define i8042_COMMAND           0x69
     45indev_operations_t kbrdin_ops = {
     46        .poll = NULL
     47};
    4748
    48 #define i8042_BUFFER_FULL_MASK  0x01
    49 #define i8042_WAIT_MASK         0x02
     49#define i8042_SET_COMMAND  0x60
     50#define i8042_COMMAND      0x69
     51
     52#define i8042_BUFFER_FULL_MASK  0x01
     53#define i8042_WAIT_MASK         0x02
    5054
    5155static irq_ownership_t i8042_claim(irq_t *irq)
     
    5357        i8042_instance_t *i8042_instance = irq->instance;
    5458        i8042_t *dev = i8042_instance->i8042;
     59       
    5560        if (pio_read_8(&dev->status) & i8042_BUFFER_FULL_MASK)
    5661                return IRQ_ACCEPT;
     
    6368        i8042_instance_t *instance = irq->instance;
    6469        i8042_t *dev = instance->i8042;
    65 
    66         uint8_t data;
    6770        uint8_t status;
    68                
     71       
    6972        if (((status = pio_read_8(&dev->status)) & i8042_BUFFER_FULL_MASK)) {
    70                 data = pio_read_8(&dev->data);
    71                        
    72                 if (instance->devout)
    73                         chardev_push_character(instance->devout, data);
     73                uint8_t data = pio_read_8(&dev->data);
     74                indev_push_character(&instance->kbrdin, data);
    7475        }
    7576}
    7677
    7778/** Initialize i8042. */
    78 bool
    79 i8042_init(i8042_t *dev, devno_t devno, inr_t inr, chardev_t *devout)
     79indev_t *i8042_init(i8042_t *dev, devno_t devno, inr_t inr)
    8080{
    81         i8042_instance_t *instance;
    82 
    83         instance = malloc(sizeof(i8042_instance_t), FRAME_ATOMIC);
     81        i8042_instance_t *instance
     82            = malloc(sizeof(i8042_instance_t), FRAME_ATOMIC);
    8483        if (!instance)
    85                 return false;
     84                return NULL;
     85       
     86        indev_initialize("i8042", &instance->kbrdin, &kbrdin_ops);
    8687       
    8788        instance->devno = devno;
    8889        instance->i8042 = dev;
    89         instance->devout = devout;
    9090       
    9191        irq_initialize(&instance->irq);
     
    103103                (void) pio_read_8(&dev->data);
    104104       
    105         return true;
     105        return &instance->kbrdin;
    106106}
    107107
Note: See TracChangeset for help on using the changeset viewer.