Import backup from 2004-08-16
This commit is contained in:
parent
8a8f56decb
commit
c0dd3b529e
@ -16,10 +16,8 @@ LD=ld
|
||||
LD_FLAGS=-nodefaultlibs -nostdlib --no-demangle -T link.ld
|
||||
|
||||
all: Asm_Kernel C_Kernel
|
||||
$(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 \
|
||||
-o kernel.bin
|
||||
$(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
|
||||
|
||||
Asm_Kernel:
|
||||
$(NASM) $(NASM_FLAGS) -l boot.lst boot.asm -o boot.o
|
||||
@ -35,6 +33,7 @@ C_Kernel:
|
||||
$(CC) $(CC_FLAGS) -c char/vconsole.c -o vconsole.o
|
||||
$(CC) $(CC_FLAGS) -c fs/devices.c -o devices.o
|
||||
$(CC) $(CC_FLAGS) -c console.c -o console.o
|
||||
$(CC) $(CC_FLAGS) -c sys/pic.c -o pic.o
|
||||
|
||||
#################################################
|
||||
# Clean up the source directory of any binaries #
|
||||
|
@ -1,33 +1,32 @@
|
||||
// keyboard.c
|
||||
// Author: Josh Holtrop
|
||||
// Created: 04/17/03
|
||||
// Modified: 08/02/04
|
||||
// Modified: 08/16/04
|
||||
|
||||
#include "hos_defines.h"
|
||||
#include "char/keyboard.h"
|
||||
#include "sys/io.h"
|
||||
#include "sys/pic.h"
|
||||
#include "functions.h"
|
||||
#include "kio.h"
|
||||
|
||||
#define KBD_BUFFER_LENGTH 64
|
||||
|
||||
byte kbdFlags = 0; //holds current keyboard flags - caps/num/scroll/shift/ctrl/alt
|
||||
byte kbdAscii = 0; //holds ASCII value of a key pressed
|
||||
byte kbdScan = 0; //holds the keyboard scan code of a key pressed
|
||||
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
|
||||
u8_t kbdScan = 0; //holds the keyboard scan code of a key pressed
|
||||
|
||||
dword 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 kbdBufferLen = 0; //number of keys left in the buffer
|
||||
byte kbdExt = 0; //# of extended key codes left to input
|
||||
byte kbdExt2 = 0; //# of 2nd-set-extended key codes left to input
|
||||
byte ackReason = 0; //used to record the reason why we would get an acknowledge byte (0xFA)
|
||||
u8_t kbdExt = 0; //# of extended key codes left to input
|
||||
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 u8_t (0xFA)
|
||||
|
||||
|
||||
//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 byte 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";
|
||||
const byte 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";
|
||||
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";
|
||||
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";
|
||||
|
||||
//====FUNCTIONS:
|
||||
// The Keyboard Interrupt Service Routine
|
||||
@ -35,7 +34,7 @@ void isr_keyboard()
|
||||
{
|
||||
kbdScan = inportb(0x60);
|
||||
//printf("\nKEYBOARD INTERRUPT: 0x%x", kbdScan);
|
||||
byte inState = inportb(0x61);
|
||||
u8_t inState = inportb(0x61);
|
||||
outportb(0x61, inState|0x80);
|
||||
outportb(0x61, inState);
|
||||
|
||||
@ -198,7 +197,7 @@ void isr_keyboard()
|
||||
}
|
||||
else
|
||||
{
|
||||
kbdBuffer[(kbdBufferStart+kbdBufferLen++)%KBD_BUFFER_LENGTH] = (dword) ((kbdFlags << 16) | (kbdScan << 8) | kbdAscii);
|
||||
kbdBuffer[(kbdBufferStart+kbdBufferLen++)%KBD_BUFFER_LENGTH] = (u32_t) ((kbdFlags << 16) | (kbdScan << 8) | kbdAscii);
|
||||
// printf("S:%d\tL:%d\tR:%x\n", kbdBufferStart, kbdBufferLen, kbdBuffer[kbdBufferStart]);
|
||||
}
|
||||
}
|
||||
@ -208,11 +207,11 @@ void isr_keyboard()
|
||||
}
|
||||
|
||||
//Gets a key from the buffer, returns 0 if no keys available, returns immediately
|
||||
dword kbdGetKey()
|
||||
u32_t kbdGetKey()
|
||||
{
|
||||
if (kbdBufferLen == 0) //buffer empty
|
||||
return 0;
|
||||
dword retVal = kbdBuffer[kbdBufferStart];
|
||||
u32_t retVal = kbdBuffer[kbdBufferStart];
|
||||
kbdBufferStart++;
|
||||
kbdBufferLen--;
|
||||
if (kbdBufferStart >= KBD_BUFFER_LENGTH)
|
||||
@ -221,14 +220,14 @@ dword kbdGetKey()
|
||||
}
|
||||
|
||||
//Gets a key from the buffer, if no keys available, waits for one to be entered
|
||||
dword kbdWaitKey()
|
||||
u32_t kbdWaitKey()
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
if (kbdBufferLen != 0) //buffer empty
|
||||
break;
|
||||
}
|
||||
dword retVal = kbdBuffer[kbdBufferStart];
|
||||
u32_t retVal = kbdBuffer[kbdBufferStart];
|
||||
kbdBufferStart++;
|
||||
kbdBufferLen--;
|
||||
if (kbdBufferStart >= KBD_BUFFER_LENGTH)
|
||||
@ -245,3 +244,4 @@ void kbd_resetLEDs()
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -17,6 +17,7 @@ int parallel_init(major_t major)
|
||||
{
|
||||
parallel_driver->char_write = parallel_char_write;
|
||||
devices_register_major('c', major, parallel_driver);
|
||||
// register parallel devices as /dev/lp0, etc...
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
|
@ -1,7 +1,7 @@
|
||||
// vconsole.c
|
||||
// Author: Josh Holtrop
|
||||
// Date: 08/02/04
|
||||
// Modified: 08/07/04
|
||||
// Modified: 08/16/04
|
||||
|
||||
#include "char/vconsole.h"
|
||||
#include "hos_defines.h"
|
||||
|
@ -1,6 +1,7 @@
|
||||
// console.c
|
||||
// Author: Josh Holtrop
|
||||
// Date: 08/07/04
|
||||
// Modified: 08/16/04
|
||||
|
||||
#include "fs/devices.h"
|
||||
#include "char/vconsole.h"
|
||||
|
@ -1,7 +1,7 @@
|
||||
// devices.c
|
||||
// Author: Josh Holtrop
|
||||
// Date: 08/02/04
|
||||
// Modified: 08/07/04
|
||||
// Modified: 08/16/04
|
||||
|
||||
|
||||
#include "fs/devices.h"
|
||||
|
@ -1,7 +1,7 @@
|
||||
// devices.h
|
||||
// Author: Josh Holtrop
|
||||
// Date: 08/02/04
|
||||
// Modified: 08/07/04
|
||||
// Modified: 08/16/04
|
||||
|
||||
#ifndef __HOS_DEVICES_H__
|
||||
#define __HOS_DEVICES_H__ __HOS_DEVICES_H__
|
||||
@ -10,6 +10,7 @@
|
||||
|
||||
#define MAJORC_VCONSOLE 4
|
||||
#define MAJORC_PARALLEL 6
|
||||
#define MAJORC_KEYBOARD 11
|
||||
|
||||
typedef unsigned char major_t;
|
||||
typedef unsigned char minor_t;
|
||||
|
@ -51,12 +51,12 @@ static inline void halt()
|
||||
}
|
||||
|
||||
//Initializes 8253 Programmable Interrupt Timer
|
||||
static inline void timer_init()
|
||||
static inline void timer_init(u32_t freq)
|
||||
{
|
||||
//set timer : 2e9c = 100hz
|
||||
u32_t wait = 1193180 / freq; //how many ticks the PIT must wait before issuing an interrupt
|
||||
outportb(0x43, 0x34);
|
||||
outportb(0x40, 0x9c); //lsb
|
||||
outportb(0x40, 0x2e); //msb
|
||||
outportb(0x40, freq); //lsb
|
||||
outportb(0x40, freq >> 8); //msb
|
||||
}
|
||||
|
||||
//Returns the size of the kernel (code & data)
|
||||
|
@ -1,3 +1,7 @@
|
||||
// hos_defines.h
|
||||
// Author: Josh Holtrop
|
||||
// Date: 08/15/04
|
||||
// Modified: 08/16/04
|
||||
|
||||
#ifndef __HOS_DEFINES_H__
|
||||
#define __HOS_DEFINES_H__ __HOS_DEFINES_H__
|
||||
|
@ -1,3 +1,7 @@
|
||||
// kernel.h
|
||||
// Author: Josh Holtrop
|
||||
// Date: 08/16/04
|
||||
// This is the main kernel initialization and boot-strapping file
|
||||
|
||||
#include "kernel.h"
|
||||
#include "multiboot.h"
|
||||
@ -12,6 +16,8 @@
|
||||
#include "char/vconsole.h"
|
||||
#include "fs/devices.h"
|
||||
#include "console.h"
|
||||
#include "sys/io.h"
|
||||
#include "sys/pic.h"
|
||||
|
||||
mb_info_t mb_info_block;
|
||||
mb_mmap_t mb_mmap[MAX_MMAP];
|
||||
@ -87,6 +93,10 @@ int k_mbsave(mb_info_t *mbinfo, unsigned int mb_magic)
|
||||
void k_init()
|
||||
{
|
||||
criticalCounter++;
|
||||
pic_remap(0x20, 0x28);
|
||||
pic_mask1(0); //unmask IRQ's 0-7
|
||||
pic_mask2(0); //unmask IRQ's 8-15
|
||||
timer_init(100);
|
||||
mm_init();
|
||||
vmm_init();
|
||||
// test the memory manager
|
||||
|
@ -1,6 +1,7 @@
|
||||
// kout.c
|
||||
// Author: Josh Holtrop
|
||||
// Date: 08/02/04
|
||||
// Modified: 08/16/04
|
||||
|
||||
#include "hos_defines.h"
|
||||
#include "char/parallel.h"
|
||||
|
@ -1,8 +0,0 @@
|
||||
// io.c
|
||||
// Author: Josh Holtrop
|
||||
// Created: 02/26/04
|
||||
// Implements basic port input/output functions
|
||||
|
||||
#include "sys/io.h"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user