Changeset bd87ae0 in mainline


Ignore:
Timestamp:
2012-01-04T00:50:07Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
41c9a22
Parents:
2f79a38
Message:

i8042, xtkbd: Switch keyboard away from DDF provided interface.

Location:
uspace/drv/char
Files:
2 added
3 edited

Legend:

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

    r2f79a38 rbd87ae0  
    4747#include <ddf/log.h>
    4848#include <ddf/interrupt.h>
    49 #include <ops/char_dev.h>
    5049
    5150#include "i8042.h"
     
    5352#define NAME       "i8042"
    5453
    55 static int i8042_write_kbd(ddf_fun_t *, char *, size_t);
    56 static int i8042_read_kbd(ddf_fun_t *, char *, size_t);
    57 
    58 /** Primary port interface structure. */
    59 static char_dev_ops_t kbd_iface = {
    60     .read = i8042_read_kbd,
    61     .write = i8042_write_kbd,
    62 };
    63 
    6454void default_handler(ddf_fun_t *, ipc_callid_t, ipc_call_t *);
    6555
    66 /** Primary port function operations. */
    67 static ddf_dev_ops_t kbd_ops = {
    68         .interfaces[CHAR_DEV_IFACE] = &kbd_iface,
    69         .default_handler = default_handler,
    70 };
    71 
    72 /** Auxiliary port function operations. */
     56/** Port function operations. */
    7357static ddf_dev_ops_t ops = {
    7458        .default_handler = default_handler,
     
    189173        }
    190174
    191         dev->kbd_fun->ops = &kbd_ops;
     175        dev->kbd_fun->ops = &ops;
    192176        dev->aux_fun->ops = &ops;
    193177        dev->kbd_fun->driver_data = dev;
     
    283267}
    284268
    285 /** Write data to i8042 primary port.
    286  * @param fun DDF function.
    287  * @param buffer Data source.
    288  * @param size Data size.
    289  * @return Bytes written.
    290  */
    291 static int i8042_write_kbd(ddf_fun_t *fun, char *buffer, size_t size)
    292 {
    293         assert(fun);
    294         assert(fun->driver_data);
    295         i8042_t *controller = fun->driver_data;
    296         fibril_mutex_lock(&controller->write_guard);
    297         for (size_t i = 0; i < size; ++i) {
    298                 wait_ready(controller);
    299                 pio_write_8(&controller->regs->data, buffer[i]);
    300         }
    301         fibril_mutex_unlock(&controller->write_guard);
    302         return size;
    303 }
    304 
    305 /** Read data from i8042 primary port.
    306  * @param fun DDF function.
    307  * @param buffer Data place.
    308  * @param size Data place size.
    309  * @return Bytes read.
    310  */
    311 static int i8042_read_kbd(ddf_fun_t *fun, char *buffer, size_t size)
    312 {
    313         assert(fun);
    314         assert(fun->driver_data);
    315         bzero(buffer, size);
    316 
    317         i8042_t *controller = fun->driver_data;
    318 
    319         for (size_t i = 0; i < size; ++i) {
    320                 *buffer++ = buffer_read(&controller->kbd_buffer);
    321         }
    322         return size;
    323 }
    324 
    325 // TODO use shared instead of own copy
     269// TODO use shared instead this
    326270enum {
    327271        IPC_CHAR_READ = DEV_FIRST_CUSTOM_METHOD,
     
    372316}
    373317
     318/** Handle data requests.
     319 * @param fun ddf_fun_t function.
     320 * @param id callid
     321 * @param call IPC request.
     322 */
    374323void default_handler(ddf_fun_t *fun, ipc_callid_t id, ipc_call_t *call)
    375324{
  • uspace/drv/char/xtkbd/Makefile

    r2f79a38 rbd87ae0  
    3333
    3434SOURCES = \
     35        chardev.c \
    3536        main.c \
    3637        xtkbd.c
  • uspace/drv/char/xtkbd/xtkbd.c

    r2f79a38 rbd87ae0  
    3535#include <errno.h>
    3636#include <devman.h>
    37 #include <device/char_dev.h>
    3837#include <ddf/log.h>
    3938#include <io/keycode.h>
     
    4241#include <abi/ipc/methods.h>
    4342
     43#include "chardev.h"
    4444#include "xtkbd.h"
    4545
     
    259259
    260260        assert(kbd->parent_sess);
     261        async_exch_t *parent_exch = async_exchange_begin(kbd->parent_sess);
    261262        while (1) {
     263                if (!parent_exch)
     264                        parent_exch = async_exchange_begin(kbd->parent_sess);
     265
    262266                const int *map = scanmap_simple;
    263267                size_t map_size = sizeof(scanmap_simple) / sizeof(int);
    264268
    265269                uint8_t code = 0;
    266                 ssize_t size = char_dev_read(kbd->parent_sess, &code, 1);
     270                ssize_t size = chardev_read(parent_exch, &code, 1);
    267271
    268272                /** Ignore AT command reply */
     
    274278                        map = scanmap_e0;
    275279                        map_size = sizeof(scanmap_e0) / sizeof(int);
    276                         size = char_dev_read(kbd->parent_sess, &code, 1);
     280                        size = chardev_read(parent_exch, &code, 1);
    277281                        // TODO handle print screen
    278282                }
     
    334338                    ((mods & KM_SCROLL_LOCK) ? LI_SCROLL : 0);
    335339                uint8_t cmds[] = { KBD_CMD_SET_LEDS, status };
    336                 const ssize_t size =
    337                      char_dev_write(kbd->parent_sess, cmds, sizeof(cmds));
     340                async_exch_t *exch = async_exchange_begin(kbd->parent_sess);
     341                const ssize_t size = chardev_write(exch, cmds, sizeof(cmds));
     342                async_exchange_end(exch);
    338343                async_answer_0(icallid, size < 0 ? size : EOK);
    339344                break;
Note: See TracChangeset for help on using the changeset viewer.