Subversion Repositories HelenOS

Rev

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

Rev 1920 Rev 1921
Line 58... Line 58...
58
 */
58
 */
59
#define IGNORE_CODE 0x7f        /* all keys up */
59
#define IGNORE_CODE 0x7f        /* all keys up */
60
 
60
 
61
bool z8530_belongs_to_kernel = true;
61
bool z8530_belongs_to_kernel = true;
62
 
62
 
-
 
63
static z8530_t z8530;       /**< z8530 device structure. */
-
 
64
static irq_t z8530_irq;     /**< z8530's IRQ. */
-
 
65
 
63
static void z8530_suspend(chardev_t *);
66
static void z8530_suspend(chardev_t *);
64
static void z8530_resume(chardev_t *);
67
static void z8530_resume(chardev_t *);
65
 
68
 
66
static chardev_operations_t ops = {
69
static chardev_operations_t ops = {
67
    .suspend = z8530_suspend,
70
    .suspend = z8530_suspend,
Line 82... Line 85...
82
{
85
{
83
    z8530_belongs_to_kernel = false;
86
    z8530_belongs_to_kernel = false;
84
}
87
}
85
 
88
 
86
/** Initialize z8530. */
89
/** Initialize z8530. */
87
void z8530_init(void)
90
void z8530_init(devno_t devno, inr_t inr, uintptr_t vaddr)
88
{
91
{
89
    chardev_initialize("z8530_kbd", &kbrd, &ops);
92
    chardev_initialize("z8530_kbd", &kbrd, &ops);
90
    stdin = &kbrd;
93
    stdin = &kbrd;
91
 
94
 
-
 
95
    z8530.devno = devno;
-
 
96
    z8530.reg = (uint8_t *) vaddr;
-
 
97
 
-
 
98
    irq_initialize(&z8530_irq);
-
 
99
    z8530_irq.devno = devno;
-
 
100
    z8530_irq.inr = inr;
-
 
101
    z8530_irq.claim = z8530_claim;
-
 
102
    z8530_irq.handler = z8530_irq_handler;
-
 
103
    irq_register(&z8530_irq);
-
 
104
 
92
    sysinfo_set_item_val("kbd", NULL, true);
105
    sysinfo_set_item_val("kbd", NULL, true);
-
 
106
    sysinfo_set_item_val("kbd.devno", NULL, devno);
93
    sysinfo_set_item_val("kbd.irq", NULL, 0);
107
    sysinfo_set_item_val("kbd.inr", NULL, inr);
94
    sysinfo_set_item_val("kbd.address.virtual", NULL, (uintptr_t) kbd_virt_address);
108
    sysinfo_set_item_val("kbd.address.virtual", NULL, vaddr);
95
 
109
 
96
    (void) z8530_read_a(RR8);
110
    (void) z8530_read_a(&z8530, RR8);
97
 
111
 
98
    /*
112
    /*
99
     * Clear any pending TX interrupts or we never manage
113
     * Clear any pending TX interrupts or we never manage
100
     * to set FHC UART interrupt state to idle.
114
     * to set FHC UART interrupt state to idle.
101
     */
115
     */
102
    z8530_write_a(WR0, WR0_TX_IP_RST);
116
    z8530_write_a(&z8530, WR0, WR0_TX_IP_RST);
103
 
117
 
104
    z8530_write_a(WR1, WR1_IARCSC);     /* interrupt on all characters */
118
    z8530_write_a(&z8530, WR1, WR1_IARCSC);     /* interrupt on all characters */
105
 
119
 
106
    /* 8 bits per character and enable receiver */
120
    /* 8 bits per character and enable receiver */
107
    z8530_write_a(WR3, WR3_RX8BITSCH | WR3_RX_ENABLE);
121
    z8530_write_a(&z8530, WR3, WR3_RX8BITSCH | WR3_RX_ENABLE);
108
   
122
   
109
    z8530_write_a(WR9, WR9_MIE);        /* Master Interrupt Enable. */
123
    z8530_write_a(&z8530, WR9, WR9_MIE);        /* Master Interrupt Enable. */
110
}
124
}
111
 
125
 
112
/** Process z8530 interrupt.
126
/** Process z8530 interrupt.
113
 *
127
 *
114
 * @param n Interrupt vector.
128
 * @param n Interrupt vector.
Line 137... Line 151...
137
{
151
{
138
    char ch;   
152
    char ch;   
139
 
153
 
140
    while(!(ch = active_read_buff_read())) {
154
    while(!(ch = active_read_buff_read())) {
141
        uint8_t x;
155
        uint8_t x;
142
        while (!(z8530_read_a(RR0) & RR0_RCA))
156
        while (!(z8530_read_a(&z8530, RR0) & RR0_RCA))
143
            ;
157
            ;
144
        x = z8530_read_a(RR8);
158
        x = z8530_read_a(&z8530, RR8);
145
        if (x != IGNORE_CODE) {
159
        if (x != IGNORE_CODE) {
146
            if (x & KEY_RELEASE)
160
            if (x & KEY_RELEASE)
147
                key_released(x ^ KEY_RELEASE);
161
                key_released(x ^ KEY_RELEASE);
148
            else
162
            else
149
                active_read_key_pressed(x);
163
                active_read_key_pressed(x);
Line 158... Line 172...
158
 */
172
 */
159
void z8530_poll(void)
173
void z8530_poll(void)
160
{
174
{
161
    uint8_t x;
175
    uint8_t x;
162
 
176
 
163
    while (z8530_read_a(RR0) & RR0_RCA) {
177
    while (z8530_read_a(&z8530, RR0) & RR0_RCA) {
164
        x = z8530_read_a(RR8);
178
        x = z8530_read_a(&z8530, RR8);
165
        if (x != IGNORE_CODE) {
179
        if (x != IGNORE_CODE) {
166
            if (x & KEY_RELEASE)
180
            if (x & KEY_RELEASE)
167
                key_released(x ^ KEY_RELEASE);
181
                key_released(x ^ KEY_RELEASE);
168
            else
182
            else
169
                key_pressed(x);
183
                key_pressed(x);
Line 171... Line 185...
171
    }
185
    }
172
}
186
}
173
 
187
 
174
irq_ownership_t z8530_claim(void)
188
irq_ownership_t z8530_claim(void)
175
{
189
{
176
    return (z8530_read_a(RR0) & RR0_RCA);
190
    return (z8530_read_a(&z8530, RR0) & RR0_RCA);
177
}
191
}
178
 
192
 
179
void z8530_irq_handler(irq_t *irq, void *arg, ...)
193
void z8530_irq_handler(irq_t *irq, void *arg, ...)
180
{
194
{
181
    /*
195
    /*