Changeset ff685c9 in mainline for uspace/srv/kbd/port/i8042.c


Ignore:
Timestamp:
2009-03-03T23:00:33Z (16 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.