Subversion Repositories HelenOS

Rev

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

Rev 4343 Rev 4344
Line 31... Line 31...
31
 */
31
 */
32
/** @file
32
/** @file
33
 */
33
 */
34
 
34
 
35
#include <arch/drivers/cuda.h>
35
#include <arch/drivers/cuda.h>
36
#include <ipc/irq.h>
-
 
37
#include <arch/asm.h>
36
#include <arch/asm.h>
38
#include <console/console.h>
37
#include <console/console.h>
39
#include <console/chardev.h>
38
#include <console/chardev.h>
40
#include <arch/drivers/pic.h>
39
#include <arch/drivers/pic.h>
41
#include <sysinfo/sysinfo.h>
40
#include <sysinfo/sysinfo.h>
Line 249... Line 248...
249
    return -1;
248
    return -1;
250
}
249
}
251
 
250
 
252
static void cuda_irq_handler(irq_t *irq)
251
static void cuda_irq_handler(irq_t *irq)
253
{
252
{
254
    if ((irq->notif_cfg.notify) && (irq->notif_cfg.answerbox))
-
 
255
        ipc_irq_send_notif(irq);
-
 
256
    else {
-
 
257
        int scan_code = cuda_get_scancode();
253
    int scan_code = cuda_get_scancode();
258
       
254
       
259
        if (scan_code != -1) {
255
    if (scan_code != -1) {
260
            uint8_t scancode = (uint8_t) scan_code;
256
        uint8_t scancode = (uint8_t) scan_code;
261
            if ((scancode & 0x80) != 0x80)
257
        if ((scancode & 0x80) != 0x80)
262
                chardev_push_character(&kbrd, lchars[scancode & 0x7f]);
258
            chardev_push_character(&kbrd, lchars[scancode & 0x7f]);
263
        }
-
 
264
    }
259
    }
265
}
260
}
266
 
261
 
267
static irq_ownership_t cuda_claim(void *instance)
262
static irq_ownership_t cuda_claim(irq_t *irq)
268
{
263
{
269
    return IRQ_ACCEPT;
264
    return IRQ_ACCEPT;
270
}
265
}
271
 
266
 
272
 
-
 
273
/** Initialize keyboard and service interrupts using kernel routine */
-
 
274
void cuda_grab(void)
-
 
275
{
-
 
276
    if (cuda) {
-
 
277
        ipl_t ipl = interrupts_disable();
-
 
278
        spinlock_lock(&cuda_irq.lock);
-
 
279
        cuda_irq.notif_cfg.notify = false;
-
 
280
        spinlock_unlock(&cuda_irq.lock);
-
 
281
        interrupts_restore(ipl);
-
 
282
    }
-
 
283
}
-
 
284
 
-
 
285
 
-
 
286
/** Resume the former interrupt vector */
-
 
287
void cuda_release(void)
-
 
288
{
-
 
289
    if (cuda) {
-
 
290
        ipl_t ipl = interrupts_disable();
-
 
291
        spinlock_lock(&cuda_irq.lock);
-
 
292
        if (cuda_irq.notif_cfg.answerbox)
-
 
293
            cuda_irq.notif_cfg.notify = true;
-
 
294
        spinlock_unlock(&cuda_irq.unlock);
-
 
295
        interrupts_restore(ipl);
-
 
296
    }
-
 
297
}
-
 
298
 
-
 
299
 
-
 
300
void cuda_init(devno_t devno, uintptr_t base, size_t size)
267
void cuda_init(devno_t devno, uintptr_t base, size_t size)
301
{
268
{
302
    cuda = (uint8_t *) hw_map(base, size);
269
    cuda = (uint8_t *) hw_map(base, size);
303
   
270
   
304
    chardev_initialize("cuda_kbd", &kbrd, &ops);
271
    chardev_initialize("cuda_kbd", &kbrd, &ops);