Changeset ff685c9 in mainline


Ignore:
Timestamp:
2009-03-03T23:00:33Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
150385b9
Parents:
9cd98796
Message:

Make the kbd port drivers platform neutral by using PIO functions.
The kernel now supplies the physical address and the kernel virtual address.

Files:
8 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/amd64/src/amd64.c

    r9cd98796 rff685c9  
    200200        sysinfo_set_item_val("kbd.devno", NULL, devno);
    201201        sysinfo_set_item_val("kbd.inr", NULL, IRQ_KBD);
     202        sysinfo_set_item_val("kbd.address.physical", NULL,
     203            (uintptr_t) I8042_BASE);
     204        sysinfo_set_item_val("kbd.address.kernel", NULL,
     205            (uintptr_t) I8042_BASE);
    202206}
    203207
  • kernel/arch/ia32/src/ia32.c

    r9cd98796 rff685c9  
    158158        sysinfo_set_item_val("kbd.devno", NULL, devno);
    159159        sysinfo_set_item_val("kbd.inr", NULL, IRQ_KBD);
     160        sysinfo_set_item_val("kbd.address.physical", NULL,
     161            (uintptr_t) I8042_BASE);
     162        sysinfo_set_item_val("kbd.address.kernel", NULL,
     163            (uintptr_t) I8042_BASE);
    160164}
    161165
  • kernel/arch/ia64/src/ia64.c

    r9cd98796 rff685c9  
    169169        (void) ns16550_init((ns16550_t *)NS16550_BASE, devno, inr, NULL, NULL);
    170170        sysinfo_set_item_val("kbd.type", NULL, KBD_NS16550);
    171         sysinfo_set_item_val("kbd.port", NULL, (uintptr_t)NS16550_BASE);
     171        sysinfo_set_item_val("kbd.address.physical", NULL,
     172            (uintptr_t) NS16550_BASE);
     173        sysinfo_set_item_val("kbd.address.kernel", NULL,
     174            (uintptr_t) NS16550_BASE);
    172175#else
    173176        inr = IRQ_KBD;
    174177        (void) i8042_init((i8042_t *)I8042_BASE, devno, inr);
    175178        sysinfo_set_item_val("kbd.type", NULL, KBD_LEGACY);
     179        sysinfo_set_item_val("kbd.address.physical", NULL,
     180            (uintptr_t) I8042_BASE);
     181        sysinfo_set_item_val("kbd.address.kernel", NULL,
     182            (uintptr_t) I8042_BASE);
    176183#endif
    177184        sysinfo_set_item_val("kbd", NULL, true);
  • kernel/arch/sparc64/src/drivers/kbd.c

    r9cd98796 rff685c9  
    170170                sysinfo_set_item_val("kbd.devno", NULL, devno);
    171171                sysinfo_set_item_val("kbd.inr", NULL, inr);
    172                 sysinfo_set_item_val("kbd.address.virtual", NULL,
     172                sysinfo_set_item_val("kbd.address.kernel", NULL,
    173173                    (uintptr_t) z8530);
    174174                sysinfo_set_item_val("kbd.address.physical", NULL, pa);
     
    190190                sysinfo_set_item_val("kbd.devno", NULL, devno);
    191191                sysinfo_set_item_val("kbd.inr", NULL, inr);
    192                 sysinfo_set_item_val("kbd.address.virtual", NULL,
     192                sysinfo_set_item_val("kbd.address.kernel", NULL,
    193193                    (uintptr_t) ns16550);
    194194                sysinfo_set_item_val("kbd.address.physical", NULL, pa);
  • uspace/srv/kbd/port/i8042.c

    r9cd98796 rff685c9  
    3636 */
    3737
     38#include <ddi.h>
     39#include <libarch/ddi.h>
    3840#include <ipc/ipc.h>
    3941#include <async.h>
     
    6769        {
    6870                .cmd = CMD_PIO_READ_8,
    69                 .addr = (void *) 0x64,
     71                .addr = NULL,   /* will be patched in run-time */
    7072                .dstarg = 1
    7173        },
     
    8385        {
    8486                .cmd = CMD_PIO_READ_8,
    85                 .addr = (void *) 0x60,
     87                .addr = NULL,   /* will be patched in run-time */
    8688                .dstarg = 2
    8789        },
     
    9698};
    9799
     100static uintptr_t i8042_physical;
     101static uintptr_t i8042_kernel;
     102static i8042_t * i8042;
     103
    98104static void wait_ready(void) {
    99         while (i8042_status_read() & i8042_INPUT_FULL)
    100             ;
     105        while (pio_read_8(&i8042->status) & i8042_INPUT_FULL)
     106                ;
    101107}
    102108
     
    105111int kbd_port_init(void)
    106112{
    107 //      int i;
    108113        int mouseenabled = 0;
     114        void *vaddr;
     115
     116        i8042_physical = sysinfo_value("kbd.address.physical");
     117        i8042_kernel = sysinfo_value("kbd.address.kernel");
     118        if (pio_enable((void *) i8042_physical, sizeof(i8042_t), &vaddr) != 0)
     119                return -1;
     120        i8042 = vaddr;
    109121
    110122        async_set_interrupt_received(i8042_irq_handler);
    111         iospace_enable(task_get_id(), (void *) i8042_DATA, 5);
    112123
    113124        /* Disable kbd, enable mouse */
    114         i8042_command_write(i8042_CMD_KBD);
     125        pio_write_8(&i8042->status, i8042_CMD_KBD);
    115126        wait_ready();
    116         i8042_command_write(i8042_CMD_KBD);
     127        pio_write_8(&i8042->status, i8042_CMD_KBD);
    117128        wait_ready();
    118         i8042_data_write(i8042_KBD_DISABLE);
     129        pio_write_8(&i8042->data, i8042_KBD_DISABLE);
    119130        wait_ready();
    120131
    121132        /* Flush all current IO */
    122         while (i8042_status_read() & i8042_OUTPUT_FULL)
    123                 i8042_data_read();
     133        while (pio_read_8(&i8042->status) & i8042_OUTPUT_FULL)
     134                (void) pio_read_8(&i8042->data);
    124135       
    125         /* Initialize mouse */
    126 /*      i8042_command_write(i8042_CMD_MOUSE);
    127         wait_ready();
    128         i8042_data_write(MOUSE_OUT_INIT);
    129         wait_ready();
    130        
    131         int mouseanswer = 0;
    132         for (i=0;i < 1000; i++) {
    133                 int status = i8042_status_read();
    134                 if (status & i8042_OUTPUT_FULL) {
    135                         int data = i8042_data_read();
    136                         if (status & i8042_MOUSE_DATA) {
    137                                 mouseanswer = data;
    138                                 break;
    139                         }
    140                 }
    141                 usleep(1000);
    142         }*/
    143 //      if (mouseanswer == MOUSE_ACK) {
    144 //              /* enable mouse */
    145 //              mouseenabled = 1;
    146 //             
    147 //              ipc_register_irq(sysinfo_value("mouse.inr"), sysinfo_value("mouse.devno"), 0, &i8042_kbd);
    148 //      }
    149 
    150136        /* Enable kbd */
     137        i8042_kbd.cmds[0].addr = &((i8042_t *) i8042_kernel)->status;
     138        i8042_kbd.cmds[3].addr = &((i8042_t *) i8042_kernel)->data;
    151139        ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"), 0, &i8042_kbd);
    152140
     
    155143                newcontrol |= i8042_MOUSE_IE;
    156144       
    157         i8042_command_write(i8042_CMD_KBD);
     145        pio_write_8(&i8042->status, i8042_CMD_KBD);
    158146        wait_ready();
    159         i8042_data_write(newcontrol);
     147        pio_write_8(&i8042->data, newcontrol);
    160148        wait_ready();
    161149       
     
    168156
    169157        if ((status & i8042_MOUSE_DATA))
    170                 return 0;
     158                return;
    171159
    172160        int scan_code = IPC_GET_ARG2(*call);
    173161
    174162        kbd_push_scancode(scan_code);
    175         return 1;
     163        return;
    176164}
    177165
  • uspace/srv/kbd/port/i8042.h

    r9cd98796 rff685c9  
    3939#define KBD_PORT_i8042_H_
    4040
    41 #include <ddi.h>
    4241#include <libarch/ddi.h>
     42#include <libarch/types.h>
    4343
    44 #define i8042_DATA      0x60
    45 #define i8042_STATUS    0X64
    46 
    47 
    48 typedef unsigned char u8;
    49 typedef short u16;
    50 
    51 static inline void i8042_data_write(u8 data)
    52 {
    53         outb(i8042_DATA, data);
    54 }
    55 
    56 static inline u8 i8042_data_read(void)
    57 {
    58         return inb(i8042_DATA);
    59 }
    60 
    61 static inline u8 i8042_status_read(void)
    62 {
    63         return inb(i8042_STATUS);
    64 }
    65 
    66 static inline void i8042_command_write(u8 command)
    67 {
    68         outb(i8042_STATUS, command);
    69 }
     44struct i8042 {
     45        ioport8_t data;
     46        uint8_t pad[3];
     47        ioport8_t status;
     48} __attribute__ ((packed));
     49typedef struct i8042 i8042_t;
    7050
    7151#endif
  • uspace/srv/kbd/port/ns16550.c

    r9cd98796 rff685c9  
    8787static void ns16550_irq_handler(ipc_callid_t iid, ipc_call_t *call);
    8888
    89 uint16_t ns16550_port;
     89static uintptr_t ns16550_physical;
     90static uintptr_t ns16550_kernel;
    9091
    9192int kbd_port_init(void)
    9293{
     94        void *vaddr;
     95
    9396        async_set_interrupt_received(ns16550_irq_handler);
    9497
    95         ns16550_port = sysinfo_value("kbd.port");
    96         ns16550_kbd.cmds[0].addr = (void *) (ns16550_port + LSR_REG);
    97         ns16550_kbd.cmds[3].addr = (void *) (ns16550_port + RBR_REG);
     98        ns16550_physical = sysinfo_value("kbd.address.physical");
     99        ns16550_kernel = sysinfo_value("kbd.address.kernel");
     100        ns16550_kbd.cmds[0].addr = (void *) (ns16550_kernel + LSR_REG);
     101        ns16550_kbd.cmds[3].addr = (void *) (ns16550_kernel + RBR_REG);
    98102        ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"),
    99103            0, &ns16550_kbd);
    100         iospace_enable(task_get_id(), ns16550_port, 8);
    101 
    102         return 0;
     104        return pio_enable((void *) ns16550_physical, 8, &vaddr);
    103105}
    104106
  • uspace/srv/kbd/port/z8530.c

    r9cd98796 rff685c9  
    4242#include <kbd_port.h>
    4343#include <sys/types.h>
     44#include <ddi.h>
    4445
    4546#define CHAN_A_STATUS   4
     
    8586{
    8687        async_set_interrupt_received(z8530_irq_handler);
    87         z8530_cmds[0].addr = (void *) sysinfo_value("kbd.address.virtual") +
     88        z8530_cmds[0].addr = (void *) sysinfo_value("kbd.address.kernel") +
    8889            CHAN_A_STATUS;
    89         z8530_cmds[3].addr = (void *) sysinfo_value("kbd.address.virtual") +
     90        z8530_cmds[3].addr = (void *) sysinfo_value("kbd.address.kernel") +
    9091            CHAN_A_DATA;
    9192        ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"),
Note: See TracChangeset for help on using the changeset viewer.