Here is the source code of the keyboard driver
Code: Select all
/*========================================================================================
Odyssey Diclonius Kernel Sources
(C) 2008 Odyssey Technologies
IMPORTANT: This Odyssey software is supplied to you by Odyssey Technologies.
("Odyssey") in consideration of your agreement to the following
terms, and your use, installation, modification or redistribution of this
Odyssey software constitutes acceptance of these terms. If you do not agree
with these terms, please do not use, install, modify or redistribute this Odyssey software.
The Odyssey Software is provided by Odyssey on an "AS IS" basis. Odyssey MAKES NO
WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES
OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING
THE Odyssey SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
IN NO EVENT SHALL Odyssey BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT
OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE Odyssey SOFTWARE, HOWEVER
CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY
OR OTHERWISE, EVEN IF Odyssey HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
s========================================================================================*/
// keyboard.c -- Keyboard Driver
#include <keyboard.h>
#include <isr.h>
#include <syscall.h>
s8int lowercase[256] = { 0, 27, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '\b', '\t', 'q', 'w', 'e', 'r',
't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', 0, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`', 0, '\\', 'z',
'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', 0, '*', 0, ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '-', 0, 0, 0,
'+', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
s8int uppercase[256] = { 0, 27, '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '\b', '\t', 'Q', 'W', 'E', 'R',
'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', '\n', 0, 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"', '"', 0, '|', 'Z',
'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?', 0, '*', 0, ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '-', 0, 0, 0,
'+', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
unsigned shift_state = 0;
static void do_kb(registers_t *regs)
{
serial_write("****\n\r");
u8int new_char;
s32int new_scan_code = inb(0x60);
switch(new_scan_code) {
case 0x2a:
shift_state = 1;
break;
case 0xaa:
shift_state = 0;
break;
case 0x1c:
if (console == 1) {
execute_command();
monitor_write("nyu: $>\n");
}
else {
new_char =(shift_state ? uppercase:lowercase)[new_scan_code];
monitor_put(new_char);
}
break;
default:
if (new_scan_code & 0x80) {
/* Ignore the break code */
} else {
new_char =(shift_state ? uppercase:lowercase)[new_scan_code];
monitor_put(new_char);
}
break;
}
outb(0x20,0x20);
}
void init_keyboard()
{
register_interrupt_handler(IRQ1, &do_kb);
}