Import backup from 2004-08-19

This commit is contained in:
Josh Holtrop 2004-08-19 22:00:00 -04:00
parent 1bf14ddefa
commit 396d5015d2
5 changed files with 46 additions and 31 deletions

View File

@ -39,5 +39,5 @@ debug: action=ignore
pass: action=fatal pass: action=fatal
keyboard_mapping: enabled=0, map= keyboard_mapping: enabled=0, map=
keyboard_type: mf keyboard_type: mf
user_shortcut: keys=none user_shortcut: keys=ctrlaltdel
# no cmosimage # no cmosimage

View File

@ -17,7 +17,7 @@ LD_FLAGS=-nodefaultlibs -nostdlib --no-demangle -T link.ld
all: Asm_Kernel C_Kernel all: Asm_Kernel C_Kernel
$(LD) $(LD_FLAGS) -Map kernel.map boot.o kernel.o asmfuncs.o mm.o vmm.o parallel.o \ $(LD) $(LD_FLAGS) -Map kernel.map boot.o kernel.o asmfuncs.o mm.o vmm.o parallel.o \
conv.o kout.o vconsole.o console.o devices.o pic.o -o kernel.bin conv.o kout.o vconsole.o console.o devices.o pic.o keyboard.o -o kernel.bin
Asm_Kernel: Asm_Kernel:
$(NASM) $(NASM_FLAGS) -l boot.lst boot.asm -o boot.o $(NASM) $(NASM_FLAGS) -l boot.lst boot.asm -o boot.o
@ -34,6 +34,7 @@ C_Kernel:
$(CC) $(CC_FLAGS) -c fs/devices.c -o devices.o $(CC) $(CC_FLAGS) -c fs/devices.c -o devices.o
$(CC) $(CC_FLAGS) -c console.c -o console.o $(CC) $(CC_FLAGS) -c console.c -o console.o
$(CC) $(CC_FLAGS) -c sys/pic.c -o pic.o $(CC) $(CC_FLAGS) -c sys/pic.c -o pic.o
$(CC) $(CC_FLAGS) -c char/keyboard.c -o keyboard.o
################################################# #################################################
# Clean up the source directory of any binaries # # Clean up the source directory of any binaries #

View File

@ -8,35 +8,49 @@
#include "sys/io.h" #include "sys/io.h"
#include "sys/pic.h" #include "sys/pic.h"
#include "functions.h" #include "functions.h"
#include "kout.h"
#define KBD_BUFFER_LENGTH 64 #define KBD_BUFFER_LENGTH 64
u8_t kbdFlags = 0; // holds current keyboard flags - caps/num/scroll/shift/ctrl/alt u8_t kbdFlags = 0; // holds current keyboard flags - caps/num/scroll/shift/ctrl/alt
u8_t kbdAscii = 0; //holds ASCII value of a key pressed char lastWasE0 = 0; // was the last byte 0x0E ?
u8_t kbdScan = 0; //holds the keyboard scan code of a key pressed
u32_t kbdBuffer[KBD_BUFFER_LENGTH]; // a buffer for all keypresses u32_t kbdBuffer[KBD_BUFFER_LENGTH]; // a buffer for all keypresses
int kbdBufferStart = 0; // position of next key in buffer int kbdBufferStart = 0; // position of next key in buffer
int kbdBufferLen = 0; // number of keys left in the buffer int kbdBufferLen = 0; // number of keys left in the buffer
u8_t kbdExt = 0; //# of extended key codes left to input u8_t rawIgnore = 0; // how many signals to blatantly ignore
u8_t kbdExt2 = 0; //# of 2nd-set-extended key codes left to input u8_t ackReason = 0; // used to record the reason why we would get an acknowledge byte (0xFA)
u8_t ackReason = 0; //used to record the reason why we would get an acknowledge u8_t (0xFA)
//these arrays convert a keyboard scan code to an ASCII character value //these arrays convert a keyboard scan code to an ASCII character value
//nul esc bksp tab lctl lsft rsft lalt caps F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 numScrlNumPad------- unknown---- F11 F12 unknown.... const u8_t SCAN2ASCII[129] =
const u8_t SCAN2ASCII[129] = "\000\0331234567890-=\010\011qwertyuiop[]\n\001asdfghjkl;'`\001\\zxcvbnm,./\001*\001 \001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001-\001\001\001+\001\001\001\001\001\002\002\002\001\001\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002"; "\000\0331234567890-=\010\011" // null,esc,1234567890-=,bksp,tab
const u8_t SCAN2ASCIISHIFT[129] = "\000\033!@#$%^&*()_+\010\011QWERTYUIOP{}\n\001ASDFGHJKL:\"~\001|ZXCVBNM<>?\001*\001 \001\001\001\001\001\001\001\001\001\001\001\001\001789-456+1230.\002\002\002\001\001\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002"; "qwertyuiop[]\n\000as" // qwertyuiop[],enter,lctrl,as
"dfghjkl;'`\000\\zxcv" // dfghjkl;'`,lshift,\zxcv
"bnm,./\000*\000 \000\000\000\000\000\000" // bnm,./,rshift,*,alt,space,caps,f1,f2,f3,f4,f5
"\000\000\000\000\000\000\000\000\000\000-\000\000\000+\000" // f6,f7,f8,f9,f10,num,scrl,home,up,pgup,dash,left,center,right,plus,end
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" // down,pgdn,ins,del,?,?,?,f11,f12,?,?,winL,winR,menu,?,?
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" // ?
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"; // ?
const u8_t SCAN2ASCII2[129] =
"\000\033!@#$%^&*()_+\010\011"
"QWERTYUIOP{}\n\000AS"
"DFGHJKL:\"~\000|ZXCV"
"BNM<>?\000*\000 \000\000\000\000\000\000"
"\000\000\000\000\000\000\000789-456+1"
"230.\000\000\000\000\000\000\000\000\000\000\000\000"
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000";
//====FUNCTIONS: //====FUNCTIONS:
// The Keyboard Interrupt Service Routine // The Keyboard Interrupt Service Routine
void isr_keyboard() void isr_keyboard()
{ {
kbdScan = inportb(0x60); kbdScan = inportb(0x60);
//printf("\nKEYBOARD INTERRUPT: 0x%x", kbdScan); kprintf("KEYBOARD INTERRUPT: 0x%x\n", kbdScan);
u8_t inState = inportb(0x61); u8_t inState = inportb(0x61);
outportb(0x61, inState|0x80); outportb(0x61, inState|0x80);
outportb(0x61, inState); outportb(0x61, inState);
return;
//printf("IRQ 1: %x\n", kbdScan); //printf("IRQ 1: %x\n", kbdScan);
@ -49,13 +63,13 @@ void isr_keyboard()
} }
ackReason = 0; ackReason = 0;
} }
if (kbdScan == 224) //extended key if (kbdScan == 224) // 0xE0 == extended key
{ {
kbdExt = 1; kbdExt = 1;
pic_eoi(); pic_eoi();
return; return;
} }
if (kbdScan == 225) //2nd-set-extended key if (kbdScan == 225) // 0xE1 == 2nd-set-extended key
{ {
kbdExt2 = 2; kbdExt2 = 2;
pic_eoi(); pic_eoi();
@ -180,7 +194,7 @@ void isr_keyboard()
// printf("kbdScan == %d\nkbdAscii == %d\nkbdFlags == %d\n", kbdScan, kbdAscii, kbdFlags); // printf("kbdScan == %d\nkbdAscii == %d\nkbdFlags == %d\n", kbdScan, kbdAscii, kbdFlags);
if ((kbdScan == 83) && (kbdFlags & KBD_CTRL) && (kbdFlags & KBD_ALT)) if ((kbdScan == 83) && (kbdFlags & KBD_CTRL) && (kbdFlags & KBD_ALT))
{ {
printf("Initiating reboot."); kprintf("Initiating reboot.");
restart(); restart();
} }
if (kbdAscii == 2) //unknown key / ignore key if (kbdAscii == 2) //unknown key / ignore key

View File

@ -8,12 +8,12 @@
#ifndef __HOS_KEYBOARD__ #ifndef __HOS_KEYBOARD__
#define __HOS_KEYBOARD__ __HOS_KEYBOARD__ #define __HOS_KEYBOARD__ __HOS_KEYBOARD__
#define KBD_SCROLL 0x01 #define KBDF_SCROLL 0x01
#define KBD_NUM 0x02 #define KBDF_NUM 0x02
#define KBD_CAPS 0x04 #define KBDF_CAPS 0x04
#define KBD_SHIFT 0x10 #define KBDF_SHIFT 0x10
#define KBD_CTRL 0x20 #define KBDF_CTRL 0x20
#define KBD_ALT 0x40 #define KBDF_ALT 0x40
#define KBD_SCAN_RELEASED 128 #define KBD_SCAN_RELEASED 128

View File

@ -141,13 +141,13 @@ void isr(u32_t num)
criticalCounter++; criticalCounter++;
switch (num) switch (num)
{ {
case 0x20: // timer interrupt case 0x20: // timer
(*(u16_t *)CONSOLE_MEMORY)++; (*(u16_t *)CONSOLE_MEMORY)++;
timer++; timer++;
if (!(timer % (HOS_TIMER_FREQ / 4))) pic_eoi();
{ break;
kprintf("Timer int "); case 0x21: // keyboard
} isr_keyboard();
pic_eoi(); pic_eoi();
break; break;
default: default: