OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [uclinux/] [uClinux-2.0.x/] [drivers/] [char/] [keyboard.c] - Diff between revs 199 and 685

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 199 Rev 685
Line 15... Line 15...
 * dynamic function/string keys, led setting,  Sept 1994
 * dynamic function/string keys, led setting,  Sept 1994
 * `Sticky' modifier keys, 951006.
 * `Sticky' modifier keys, 951006.
 *
 *
 */
 */
 
 
#define KEYBOARD_IRQ 1
#define KEYBOARD_IRQ 21
#define DISABLE_KBD_DURING_INTERRUPTS 0
#define DISABLE_KBD_DURING_INTERRUPTS 0
 
 
#include <linux/sched.h>
#include <linux/sched.h>
#include <linux/interrupt.h>
#include <linux/interrupt.h>
#include <linux/tty.h>
#include <linux/tty.h>
Line 162... Line 162...
static inline void kb_wait(void)
static inline void kb_wait(void)
{
{
        int i;
        int i;
 
 
        for (i=0; i<0x100000; i++)
        for (i=0; i<0x100000; i++)
                if ((inb_p(0x64) & 0x02) == 0)
                if ((inb_p(KBD_BASE_ADD+0x4) & 0x02) == 0)
                        return;
                        return;
        printk(KERN_WARNING "Keyboard timed out\n");
        printk(KERN_WARNING "Keyboard timed out\n");
}
}
 
 
static inline void send_cmd(unsigned char c)
static inline void send_cmd(unsigned char c)
{
{
        kb_wait();
        kb_wait();
        outb(c,0x64);
        outb(c,KBD_BASE_ADD+0x4);
}
}
 
 
/*
/*
 * Many other routines do put_queue, but I think either
 * Many other routines do put_queue, but I think either
 * they produce ASCII, or they produce some user-assigned
 * they produce ASCII, or they produce some user-assigned
Line 580... Line 580...
        unsigned char status;
        unsigned char status;
 
 
        pt_regs = regs;
        pt_regs = regs;
        disable_keyboard();
        disable_keyboard();
 
 
        status = inb_p(0x64);
        status = inb_p(KBD_BASE_ADD+0x4);
        do {
        do {
                unsigned char scancode;
                unsigned char scancode;
 
 
                /* mouse data? */
                /* mouse data? */
                if (status & kbd_read_mask & 0x20)
                if (status & kbd_read_mask & 0x20)
                        break;
                        break;
 
 
                scancode = inb(0x60);
                scancode = inb(KBD_BASE_ADD+0x0);
                if (status & 0x01)
                if (status & 0x01)
                        handle_scancode(scancode);
                        handle_scancode(scancode);
 
 
                status = inb(0x64);
                status = inb(KBD_BASE_ADD+0x4);
        } while (status & 0x01);
        } while (status & 0x01);
 
 
        mark_bh(KEYBOARD_BH);
        mark_bh(KEYBOARD_BH);
        enable_keyboard();
        enable_keyboard();
}
}
Line 1079... Line 1079...
        do {
        do {
                kb_wait();
                kb_wait();
                acknowledge = 0;
                acknowledge = 0;
                resend = 0;
                resend = 0;
                reply_expected = 1;
                reply_expected = 1;
                outb_p(data, 0x60);
 
 
                outb_p(data, KBD_BASE_ADD+0x0);
                for(i=0; i<0x200000; i++) {
                for(i=0; i<0x200000; i++) {
                        extern void allow_interrupts(void);
                        extern void allow_interrupts(void);
                        allow_interrupts();
                        allow_interrupts();
                        inb_p(0x64);            /* just as a delay */
                        inb_p(KBD_BASE_ADD+0x4);                /* just as a delay */
                        if (acknowledge)
                        if (acknowledge)
                                return 1;
                                return 1;
                        if (resend)
                        if (resend)
                                break;
                                break;
                }
                }
Line 1208... Line 1209...
                kbd_table[i] = kbd0;
                kbd_table[i] = kbd0;
 
 
        ttytab = console_driver.table;
        ttytab = console_driver.table;
 
 
        request_irq(KEYBOARD_IRQ, keyboard_interrupt, 0, "keyboard", NULL);
        request_irq(KEYBOARD_IRQ, keyboard_interrupt, 0, "keyboard", NULL);
        request_region(0x60,16,"keyboard");
        request_region(KBD_BASE_ADD+0x0,16,"keyboard");
#ifdef INIT_KBD
#ifdef INIT_KBD
        initialize_kbd();
        initialize_kbd();
#endif
#endif
        init_bh(KEYBOARD_BH, kbd_bh);
        init_bh(KEYBOARD_BH, kbd_bh);
        mark_bh(KEYBOARD_BH);
        mark_bh(KEYBOARD_BH);
Line 1221... Line 1222...
 
 
#ifdef INIT_KBD
#ifdef INIT_KBD
/*
/*
 * keyboard controller registers
 * keyboard controller registers
 */
 */
#define KBD_STATUS_REG      (unsigned int) 0x64
#define KBD_STATUS_REG      (unsigned int) KBD_BASE_ADD+0x4
#define KBD_CNTL_REG        (unsigned int) 0x64
#define KBD_CNTL_REG        (unsigned int) KBD_BASE_ADD+0x4
#define KBD_DATA_REG        (unsigned int) 0x60
#define KBD_DATA_REG        (unsigned int) KBD_BASE_ADD+0x0
/*
/*
 * controller commands
 * controller commands
 */
 */
#define KBD_READ_MODE       (unsigned int) 0x20
#define KBD_READ_MODE       (unsigned int) 0x20
#define KBD_WRITE_MODE      (unsigned int) 0x60
#define KBD_WRITE_MODE      (unsigned int) 0x60
Line 1395... Line 1396...
                return(-1);
                return(-1);
        }
        }
 
 
        restore_flags(flags);
        restore_flags(flags);
 
 
 
        printk("PS/2 Keyboard initialized.\n");
        return (1);
        return (1);
}
}
#endif /* INIT_KBD */
#endif /* INIT_KBD */
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.