luxos/SysCore/drivers/drivers.c

56 lines
1.0 KiB
C
Raw Normal View History

2021-09-14 15:46:50 +00:00
#include <system.h>
#include "cpu/cpu.h"
#include "clock/clock.h"
#include "floppy/floppy.h"
#include <drivers/keyboard.h>
//BSOD
extern void _STOP_ERROR_SCREEN(ISR_stack_regs *);
void DriversInstall()
{
// Initialize CPU stuff (GDT, IDT etc)
i86_CpuInitialize();
// Install default fault handler
int i;
for (i=0; i<32; i++)
i86_IsrsInstallHandler(i, _STOP_ERROR_SCREEN);
// Start installing keyboard
i86_IrqInstallHandler(1, i86_KeyboardHandler);
KeyboardInstallA();
// Install PIT
i86_PitInitialize(100);
i86_IrqInstallHandler(0, i86_PitHandler);
// Finish installing keyboard
KeyboardInstallB();
// Install floppy driver
asm volatile ("sti");
i86_IrqInstallHandler(6, i86_FloppyHandler);
FloppyInstall();
}
void SystemShutDown()
{
i86_CpuShutdown();
// TODO: real shutdown
}
void SystemReboot()
{
unsigned char good = 0x02;
while ((good & 0x02) != 0)
good = inportb(0x64);
outportb(0x64, 0xFE);
asm volatile ("cli");
asm volatile ("hlt");
}