Subversion Repositories HelenOS-historic

Rev

Rev 1734 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1734 Rev 1780
Line 57... Line 57...
57
#define SR_OUT 0x10
57
#define SR_OUT 0x10
58
#define TACK 0x10
58
#define TACK 0x10
59
#define TIP 0x20
59
#define TIP 0x20
60
 
60
 
61
 
61
 
62
static volatile __u8 *cuda = NULL;
62
static volatile uint8_t *cuda = NULL;
63
static iroutine vector;
63
static iroutine vector;
64
 
64
 
65
 
65
 
66
static char lchars[0x80] = {
66
static char lchars[0x80] = {
67
    'a',
67
    'a',
Line 188... Line 188...
188
    SPECIAL, /* PageDown */
188
    SPECIAL, /* PageDown */
189
    SPECIAL  /* F1 */
189
    SPECIAL  /* F1 */
190
};
190
};
191
 
191
 
192
 
192
 
193
void send_packet(const __u8 kind, index_t count, ...);
193
void send_packet(const uint8_t kind, index_t count, ...);
194
 
194
 
195
 
195
 
196
static void receive_packet(__u8 *kind, index_t count, __u8 data[])
196
static void receive_packet(uint8_t *kind, index_t count, uint8_t data[])
197
{
197
{
198
    cuda[B] = cuda[B] & ~TIP;
198
    cuda[B] = cuda[B] & ~TIP;
199
    *kind = cuda[SR];
199
    *kind = cuda[SR];
200
   
200
   
201
    index_t i;
201
    index_t i;
Line 235... Line 235...
235
};
235
};
236
 
236
 
237
 
237
 
238
int cuda_get_scancode(void)
238
int cuda_get_scancode(void)
239
{
239
{
240
    __u8 kind;
240
    uint8_t kind;
241
    __u8 data[4];
241
    uint8_t data[4];
242
   
242
   
243
    receive_packet(&kind, 4, data);
243
    receive_packet(&kind, 4, data);
244
   
244
   
245
    if ((kind == PACKET_ADB) && (data[0] == 0x40) && (data[1] == 0x2c))
245
    if ((kind == PACKET_ADB) && (data[0] == 0x40) && (data[1] == 0x2c))
246
        return data[2];
246
        return data[2];
Line 251... Line 251...
251
static void cuda_irq(int n, istate_t *istate)
251
static void cuda_irq(int n, istate_t *istate)
252
{
252
{
253
    int scan_code = cuda_get_scancode();
253
    int scan_code = cuda_get_scancode();
254
   
254
   
255
    if (scan_code != -1) {
255
    if (scan_code != -1) {
256
        __u8 scancode = (__u8) scan_code;
256
        uint8_t scancode = (uint8_t) scan_code;
257
        if ((scancode & 0x80) != 0x80)
257
        if ((scancode & 0x80) != 0x80)
258
            chardev_push_character(&kbrd, lchars[scancode & 0x7f]);
258
            chardev_push_character(&kbrd, lchars[scancode & 0x7f]);
259
    }
259
    }
260
}
260
}
261
 
261
 
Line 273... Line 273...
273
    if (vector)
273
    if (vector)
274
        int_register(CUDA_IRQ, "user_interrupt", vector);
274
        int_register(CUDA_IRQ, "user_interrupt", vector);
275
}
275
}
276
 
276
 
277
 
277
 
278
void cuda_init(__address base, size_t size)
278
void cuda_init(uintptr_t base, size_t size)
279
{
279
{
280
    cuda = (__u8 *) hw_map(base, size);
280
    cuda = (uint8_t *) hw_map(base, size);
281
   
281
   
282
    int_register(CUDA_IRQ, "cuda", cuda_irq);
282
    int_register(CUDA_IRQ, "cuda", cuda_irq);
283
    pic_enable_interrupt(CUDA_IRQ);
283
    pic_enable_interrupt(CUDA_IRQ);
284
   
284
   
285
    chardev_initialize("cuda_kbd", &kbrd, &ops);
285
    chardev_initialize("cuda_kbd", &kbrd, &ops);
Line 288... Line 288...
288
    sysinfo_set_item_val("cuda", NULL, true);
288
    sysinfo_set_item_val("cuda", NULL, true);
289
    sysinfo_set_item_val("cuda.irq", NULL, CUDA_IRQ);
289
    sysinfo_set_item_val("cuda.irq", NULL, CUDA_IRQ);
290
}
290
}
291
 
291
 
292
 
292
 
293
void send_packet(const __u8 kind, index_t count, ...)
293
void send_packet(const uint8_t kind, index_t count, ...)
294
{
294
{
295
    index_t i;
295
    index_t i;
296
    va_list va;
296
    va_list va;
297
   
297
   
298
    cuda[B] = cuda[B] | TIP;
298
    cuda[B] = cuda[B] | TIP;