Subversion Repositories HelenOS

Rev

Rev 4343 | Rev 4345 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4343 Rev 4344
Line 33... Line 33...
33
/** @file
33
/** @file
34
 * @brief   Z8530 keyboard port driver.
34
 * @brief   Z8530 keyboard port driver.
35
 */
35
 */
36
 
36
 
37
#include <ipc/ipc.h>
37
#include <ipc/ipc.h>
-
 
38
#include <ipc/bus.h>
38
#include <async.h>
39
#include <async.h>
39
#include <sysinfo.h>
40
#include <sysinfo.h>
40
#include <kbd.h>
41
#include <kbd.h>
41
#include <kbd_port.h>
42
#include <kbd_port.h>
42
#include <sys/types.h>
43
#include <sys/types.h>
43
 
44
 
44
/** Top-half pseudocode for z8530. */
45
#define CHAN_A_STATUS   4
-
 
46
#define CHAN_A_DATA 6
-
 
47
 
-
 
48
#define RR0_RCA 1
-
 
49
 
45
irq_cmd_t z8530_cmds[] = {
50
static irq_cmd_t z8530_cmds[] = {
-
 
51
    {
-
 
52
        .cmd = CMD_PIO_READ_8,
-
 
53
        .addr = (void *) 0, /* will be patched in run-time */
-
 
54
        .dstarg = 1
-
 
55
    },
-
 
56
    {
-
 
57
        .cmd = CMD_BTEST,
-
 
58
        .value = RR0_RCA,
-
 
59
        .srcarg = 1,
-
 
60
        .dstarg = 3
-
 
61
    },
46
    {
62
    {
-
 
63
        .cmd = CMD_PREDICATE,
-
 
64
        .value = 2,
-
 
65
        .srcarg = 3
-
 
66
    },
-
 
67
    {
47
        CMD_MEM_READ_1,
68
        .cmd = CMD_PIO_READ_8,
48
        0,      /**< Address. Will be patched in run-time. */
69
        .addr = (void *) 0, /* will be patched in run-time */
49
        0,      /**< Value. Not used. */
70
        .dstarg = 2
-
 
71
    },
-
 
72
    {
50
        1       /**< Arg 1 will contain the result. */
73
        .cmd = CMD_ACCEPT
51
    }
74
    }
52
};
75
};
53
 
-
 
54
   
76
   
55
irq_code_t z8530_kbd = {
77
irq_code_t z8530_kbd = {
56
    1,
-
 
-
 
78
    sizeof(z8530_cmds) / sizeof(irq_cmd_t),
57
    z8530_cmds
79
    z8530_cmds
58
};
80
};
59
 
81
 
60
static void z8530_irq_handler(ipc_callid_t iid, ipc_call_t *call);
82
static void z8530_irq_handler(ipc_callid_t iid, ipc_call_t *call);
61
 
83
 
62
int kbd_port_init(void)
84
int kbd_port_init(void)
63
{
85
{
64
    async_set_interrupt_received(z8530_irq_handler);
86
    async_set_interrupt_received(z8530_irq_handler);
65
    z8530_cmds[0].addr = (void *) sysinfo_value("kbd.address.virtual") + 6;
87
    z8530_cmds[0].addr = (void *) sysinfo_value("kbd.address.virtual") +
-
 
88
        CHAN_A_STATUS;
-
 
89
    z8530_cmds[3].addr = (void *) sysinfo_value("kbd.address.virtual") +
-
 
90
        CHAN_A_DATA;
66
    ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"),
91
    ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"),
67
        0, &z8530_kbd);
92
        sysinfo_value("kbd.inr"), &z8530_kbd);
68
    return 0;
93
    return 0;
69
}
94
}
70
 
95
 
71
static void z8530_irq_handler(ipc_callid_t iid, ipc_call_t *call)
96
static void z8530_irq_handler(ipc_callid_t iid, ipc_call_t *call)
72
{
97
{
73
    int scan_code = IPC_GET_ARG1(*call);
98
    int scan_code = IPC_GET_ARG2(*call);
74
    kbd_push_scancode(scan_code);
99
    kbd_push_scancode(scan_code);
-
 
100
   
-
 
101
    if (cir_service)
-
 
102
        async_msg_1(cir_phone, BUS_CLEAR_INTERRUPT,
-
 
103
            IPC_GET_METHOD(*call));
75
}
104
}
76
 
105
 
77
/** @}
106
/** @}
78
 */
107
 */