Changeset 24ff4df in mainline for uspace/srv/kbd/port/ns16550.c


Ignore:
Timestamp:
2009-02-18T21:47:05Z (15 years ago)
Author:
Jiri Svoboda <jirik.svoboda@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
96f392c
Parents:
f89979b
Message:

Add some missing ports and controllers (untested). Remove old parts of keyboard driver.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/srv/kbd/port/ns16550.c

    rf89979b r24ff4df  
    2727 */
    2828
    29 /** @addtogroup kbdamd64 amd64
    30  * @brief       HelenOS ia32 / amd64 arch dependent parts of uspace keyboard and mouse handler.
     29/** @addtogroup kbd_port
    3130 * @ingroup  kbd
    3231 * @{
     32 */
     33/** @file
     34 * @brief       NS16550 port driver.
    3335 */
    3436
    35 /** @file
    36  * @ingroup kbdia32
    37  */
     37#include <ipc/ipc.h>
     38#include <async.h>
     39#include <sysinfo.h>
     40#include <kbd.h>
     41#include <kbd_port.h>
     42#include <ddi.h>
    3843
    39 #ifndef KBD_ia32_KBD_H_
    40 #define KBD_ia32_KBD_H_
     44/* NS16550 registers */
     45#define RBR_REG         0       /** Receiver Buffer Register. */
     46#define IER_REG         1       /** Interrupt Enable Register. */
     47#define IIR_REG         2       /** Interrupt Ident Register (read). */
     48#define FCR_REG         2       /** FIFO control register (write). */
     49#define LCR_REG         3       /** Line Control register. */
     50#define MCR_REG         4       /** Modem Control Register. */
     51#define LSR_REG         5       /** Line Status Register. */
    4152
    42 #include <ddi.h>
    43 #include <libarch/ddi.h>
     53irq_cmd_t ns16550_cmds[1] = {
     54        { CMD_PORT_READ_1, 0, 0, 2 },
     55};
    4456
    45 #define i8042_DATA      0x60
    46 #define i8042_STATUS    0X64
     57irq_code_t ns16550_kbd = {
     58        1,
     59        ns16550_cmds
     60};
    4761
     62static void ns16550_irq_handler(ipc_callid_t iid, ipc_call_t *call);
    4863
    49 typedef unsigned char u8;
    50 typedef short u16;
     64uint16_t ns16550_port;
    5165
    52 static inline void i8042_data_write(u8 data)
     66int kbd_port_init(void)
    5367{
    54         outb(i8042_DATA, data);
     68        async_set_interrupt_received(ns16550_irq_handler);
     69
     70        ns16550_port = sysinfo_value("kbd.port");
     71        ns16550_kbd.cmds[0].addr = (void *) (ns16550_port + RBR_REG);
     72        ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"),
     73            0, &ns16550_kbd);
     74        iospace_enable(task_get_id(), ns16550_port, 8);
     75
     76        return 0;
    5577}
    5678
    57 static inline u8 i8042_data_read(void)
     79#define LSR_DATA_READY  0x01
     80
     81static void ns16550_irq_handler(ipc_callid_t iid, ipc_call_t *call)
    5882{
    59         return inb(i8042_DATA);
     83        int scan_code = IPC_GET_ARG2(*call);
     84        kbd_push_scancode(scan_code);
    6085}
    61 
    62 static inline u8 i8042_status_read(void)
    63 {
    64         return inb(i8042_STATUS);
    65 }
    66 
    67 static inline void i8042_command_write(u8 command)
    68 {
    69         outb(i8042_STATUS, command);
    70 }
    71 
    72 #endif
    7386
    7487/**
    7588 * @}
    76  */ 
     89 */
Note: See TracChangeset for help on using the changeset viewer.