Changeset 336f03b in mainline


Ignore:
Timestamp:
2011-12-27T10:53:46Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a84ddf0
Parents:
9ff60d1
Message:

Doxygen. Fix checking incorrect flag in port write functions.

Decrease debug level.

Location:
uspace/drv/char/i8042
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/char/i8042/i8042.c

    r9ff60d1 r336f03b  
    5757static int i8042_write_aux(ddf_fun_t *, char *, size_t);
    5858static int i8042_read_aux(ddf_fun_t *, char *, size_t);
    59 
     59/*----------------------------------------------------------------------------*/
     60/** Primary port interface structure. */
    6061static char_dev_ops_t kbd_iface = {
    6162    .read = i8042_read_kbd,
    6263    .write = i8042_write_kbd,
    6364};
    64 
     65/*----------------------------------------------------------------------------*/
     66/** Auxiliary port interface structure. */
    6567static char_dev_ops_t aux_iface = {
    6668    .read = i8042_read_aux,
    6769    .write = i8042_write_aux,
    6870};
    69 
     71/*----------------------------------------------------------------------------*/
     72/** Primary port function operations. */
    7073static ddf_dev_ops_t kbd_ops = {
    7174        .interfaces[CHAR_DEV_IFACE] = &kbd_iface
    7275};
    73 
     76/*----------------------------------------------------------------------------*/
     77/** Auxiliary port function operations. */
    7478static ddf_dev_ops_t aux_ops = {
    7579        .interfaces[CHAR_DEV_IFACE] = &aux_iface
     
    9296#define i8042_KBD_TRANSLATE     0x40 /* Use this to switch to XT scancodes */
    9397
     98/** i8042 Interrupt pseudo-code. */
    9499static const irq_cmd_t i8042_cmds[] = {
    95100        {
     
    119124};
    120125/*----------------------------------------------------------------------------*/
     126/** Wait until it is safe to write to the device. */
    121127static void wait_ready(i8042_t *dev)
    122128{
     
    125131}
    126132/*----------------------------------------------------------------------------*/
    127 static void wait_ready_write(i8042_t *dev)
    128 {
    129         assert(dev);
    130         while (pio_read_8(&dev->regs->status) & i8042_OUTPUT_FULL);
    131 }
    132 /*----------------------------------------------------------------------------*/
     133/** Interrupt handler routine.
     134 * Writes new data to the corresponding buffer.
     135 * @param dev Device that caued the interrupt.
     136 * @param iid Call id.
     137 * @param call pointerr to call data.
     138 */
    133139static void i8042_irq_handler(
    134140    ddf_dev_t *dev, ipc_callid_t iid, ipc_call_t *call)
     
    145151}
    146152/*----------------------------------------------------------------------------*/
     153/** Initialize i8042 driver structure.
     154 * @param dev Driver structure to initialize.
     155 * @param regs I/O address of registers.
     156 * @param reg_size size of the reserved I/O address space.
     157 * @param irq_kbd IRQ for primary port.
     158 * @param irq_mouse IRQ for aux port.
     159 * @param ddf_dev DDF device structure of the device.
     160 * @return Error code.
     161 */
    147162int i8042_init(i8042_t *dev, void *regs, size_t reg_size, int irq_kbd,
    148163    int irq_mouse, ddf_dev_t *ddf_dev)
     
    273288}
    274289/*----------------------------------------------------------------------------*/
     290/** Write data to i8042 primary port.
     291 * @param fun DDF function.
     292 * @param buffer Data source.
     293 * @param size Data size.
     294 * @return Bytes written.
     295 */
    275296static int i8042_write_kbd(ddf_fun_t *fun, char *buffer, size_t size)
    276297{
     
    280301        fibril_mutex_lock(&controller->write_guard);
    281302        for (size_t i = 0; i < size; ++i) {
    282                 wait_ready_write(controller);
     303                wait_ready(controller);
    283304                pio_write_8(&controller->regs->data, buffer[i]);
    284305        }
     
    287308}
    288309/*----------------------------------------------------------------------------*/
     310/** Read data from i8042 primary port.
     311 * @param fun DDF function.
     312 * @param buffer Data place.
     313 * @param size Data place size.
     314 * @return Bytes read.
     315 */
    289316static int i8042_read_kbd(ddf_fun_t *fun, char *buffer, size_t size)
    290317{
     
    301328}
    302329/*----------------------------------------------------------------------------*/
     330/** Write data to i8042 auxiliary port.
     331 * @param fun DDF function.
     332 * @param buffer Data source.
     333 * @param size Data size.
     334 * @return Bytes written.
     335 */
    303336static int i8042_write_aux(ddf_fun_t *fun, char *buffer, size_t size)
    304337{
     
    308341        fibril_mutex_lock(&controller->write_guard);
    309342        for (size_t i = 0; i < size; ++i) {
    310                 wait_ready_write(controller);
     343                wait_ready(controller);
    311344                pio_write_8(&controller->regs->status, i8042_CMD_WRITE_AUX);
    312345                pio_write_8(&controller->regs->data, buffer[i]);
     
    316349}
    317350/*----------------------------------------------------------------------------*/
     351/** Read data from i8042 auxiliary port.
     352 * @param fun DDF function.
     353 * @param buffer Data place.
     354 * @param size Data place size.
     355 * @return Bytes read.
     356 */
    318357static int i8042_read_aux(ddf_fun_t *fun, char *buffer, size_t size)
    319358{
  • uspace/drv/char/i8042/i8042.h

    r9ff60d1 r336f03b  
    5353} __attribute__ ((packed)) i8042_regs_t;
    5454
    55 typedef struct i8042 i8042_t;
    56 
    57 struct i8042 {
    58         i8042_regs_t *regs;
    59         ddf_fun_t *kbd_fun;
    60         ddf_fun_t *mouse_fun;
    61         buffer_t aux_buffer;
    62         buffer_t kbd_buffer;
    63         uint8_t aux_data[BUFFER_SIZE];
    64         uint8_t kbd_data[BUFFER_SIZE];
    65         fibril_mutex_t write_guard;
    66 };
     55/** i8042 driver structure. */
     56typedef struct i8042 {
     57        i8042_regs_t *regs;    /**< I/O registers. */
     58        ddf_fun_t *kbd_fun;    /**< Pirmary port device function. */
     59        ddf_fun_t *mouse_fun;  /**< Auxiliary port device function. */
     60        buffer_t kbd_buffer;   /**< Primary port buffer. */
     61        buffer_t aux_buffer;   /**< Aux. port buffer. */
     62        uint8_t aux_data[BUFFER_SIZE];  /**< Primary port buffer space. */
     63        uint8_t kbd_data[BUFFER_SIZE];  /**< Aux. port buffer space. */
     64        fibril_mutex_t write_guard;     /**< Prevents simultanous port writes.*/
     65} i8042_t;
    6766
    6867int i8042_init(i8042_t *, void *, size_t, int, int, ddf_dev_t *);
  • uspace/drv/char/i8042/main.c

    r9ff60d1 r336f03b  
    4848static int get_my_registers(const ddf_dev_t *dev,
    4949    uintptr_t *io_reg_address, size_t *io_reg_size, int *kbd, int *mouse);
    50 
    5150static int i8042_dev_add(ddf_dev_t *device);
    52 
     51/*----------------------------------------------------------------------------*/
     52/** DDF driver operations. */
    5353static driver_ops_t i8042_driver_ops = {
    5454        .dev_add = i8042_dev_add,
    5555};
    56 
     56/*----------------------------------------------------------------------------*/
     57/** DDF driver. */
    5758static driver_t i8042_driver = {
    5859        .name = NAME,
    5960        .driver_ops = &i8042_driver_ops
    6061};
    61 
     62/*----------------------------------------------------------------------------*/
    6263/** Initialize global driver structures (NONE).
    6364 *
     
    7172{
    7273        printf(NAME ": HelenOS ps/2 driver.\n");
    73         ddf_log_init(NAME, LVL_DEBUG2);
     74        ddf_log_init(NAME, LVL_NOTE);
    7475        return ddf_driver_main(&i8042_driver);
    7576}
    76 
     77/*----------------------------------------------------------------------------*/
    7778/** Initialize a new ddf driver instance of i8042 driver
    7879 *
     
    120121 * @param[out] io_reg_address Base address of the memory range.
    121122 * @param[out] io_reg_size Size of the memory range.
     123 * @param[out] kbd_irq Primary port IRQ.
     124 * @param[out] mouse_irq Auxiliary port IRQ.
    122125 * @return Error code.
    123126 */
Note: See TracChangeset for help on using the changeset viewer.