Compare commits
5 Commits
a5ce202055
...
f0ca9de14b
Author | SHA1 | Date | |
---|---|---|---|
f0ca9de14b | |||
2691c1e30e | |||
437e10e86c | |||
24aad1e4a5 | |||
bec10bcee8 |
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -57,3 +57,9 @@ Mkfile.old
|
|||
dkms.conf
|
||||
|
||||
# End of https://www.gitignore.io/api/c
|
||||
/.vs
|
||||
/Sync-OS
|
||||
/Sync-OS.sln
|
||||
/Sync-OS.vcxproj
|
||||
/Sync-OS.vcxproj.user
|
||||
/Sync-OS.vcxproj.filters
|
||||
|
|
|
@ -686,6 +686,8 @@ void ScanCPUFeatures(size_t RAX, size_t RCX);
|
|||
|
||||
/* ==================== Interrupts ==================== */
|
||||
|
||||
uint64_t time;
|
||||
|
||||
void IRQ_Common(INTERRUPT_FRAME* Frame, size_t Interupt);
|
||||
void ISR_Common(INTERRUPT_FRAME* Frame, size_t Interrupt);
|
||||
void ISR_Error_Common(EXCEPTION_FRAME* Frame, size_t Exception);
|
||||
|
|
|
@ -44,12 +44,20 @@ void PrepareSystem(FILELOADER_PARAMS* FLOP) {
|
|||
Memory_Info.MemoryMapDescriptorSize = FLOP->MemoryMapDescriptorSize;
|
||||
Memory_Info.MemoryMapDescriptorVersion = FLOP->MemoryMapDescriptorVersion;
|
||||
|
||||
|
||||
SetupPrinting(FLOP->GPU_Info->GPUs[0]);
|
||||
/* All print functions are now available. */
|
||||
printf("ready!");
|
||||
|
||||
InstallGDT();
|
||||
InstallIDT();
|
||||
|
||||
beep();
|
||||
|
||||
if(SetIdentityMap(FLOP->RTServices) == NULL) {
|
||||
Memory_Info.MemoryMap = FLOP->MemoryMap;
|
||||
}
|
||||
|
||||
SetupPrinting(FLOP->GPU_Info->GPUs[0]);
|
||||
/* All print functions are now available. */
|
||||
|
||||
PrepareAVX();
|
||||
|
||||
|
@ -90,8 +98,6 @@ void PrepareSystem(FILELOADER_PARAMS* FLOP) {
|
|||
}
|
||||
|
||||
// Set up memory management
|
||||
InstallGDT();
|
||||
InstallIDT();
|
||||
InstallMemoryMap();
|
||||
InstallPaging();
|
||||
|
||||
|
@ -104,6 +110,54 @@ void PrepareSystem(FILELOADER_PARAMS* FLOP) {
|
|||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Following section is taken from the OSDev Wiki page on PC Speaker.
|
||||
* This is beeped first, before *anything* else.
|
||||
* This way, we know that at least *something* works.
|
||||
*/
|
||||
|
||||
//Play sound using built in speaker
|
||||
static void play_sound(uint32_t nFrequence) {
|
||||
uint32_t Div;
|
||||
uint8_t tmp;
|
||||
|
||||
//Set the PIT to the desired frequency
|
||||
Div = 1193180 / nFrequence;
|
||||
WritePort(0x0043, 0xb6, 1);
|
||||
WritePort(0x0042, (uint8_t) (Div), 1);
|
||||
WritePort(0x0042, (uint8_t) (Div >> 8), 1);
|
||||
|
||||
//And play the sound using the PC speaker
|
||||
tmp = ReadPort(0x0061, 1);
|
||||
if (tmp != (tmp | 3)) {
|
||||
WritePort(0x0061, tmp | 3, 1);
|
||||
}
|
||||
}
|
||||
|
||||
//make it shutup
|
||||
static void nosound() {
|
||||
uint8_t tmp = ReadPort(0x0061, 1) & 0xFC;
|
||||
|
||||
WritePort(0x0061, tmp, 1);
|
||||
}
|
||||
|
||||
//Make a beep
|
||||
void beep() {
|
||||
play_sound(1000);
|
||||
timer_wait(10);
|
||||
nosound();
|
||||
//set_PIT_2(old_frequency);
|
||||
}
|
||||
|
||||
|
||||
void timer_wait(int ticks){
|
||||
uint64_t FinalTick = time + ticks;
|
||||
|
||||
while(time < FinalTick);
|
||||
}
|
||||
|
||||
|
||||
/* A temporary system for keeping track of system performance. */
|
||||
|
||||
size_t ClockTick() {
|
||||
|
|
|
@ -50,6 +50,7 @@ void ISR_Common(INTERRUPT_FRAME* Frame, size_t Exception) {
|
|||
if(Exception < 32) {
|
||||
/* exception_messages is an array of c-strings defined in kernel.h */
|
||||
// TODO: Serial!
|
||||
|
||||
//serial_print(0x3F8, exception_messages[Exception]);
|
||||
//serial_print(0x3F8, " Exception.\r\n");
|
||||
printf("%s exception!", ExceptionStrings[Exception]);
|
||||
|
@ -89,26 +90,26 @@ void IRQ_Common(INTERRUPT_FRAME* Frame, size_t Interrupt) {
|
|||
|
||||
/* The Slave PIC must be told it's been read in order to receive another 8+ IRQ. */
|
||||
if(Interrupt > 7)
|
||||
WritePort(0xA0, 0x20, 8);
|
||||
WritePort(0xA0, 0x20, 1);
|
||||
|
||||
/* In either case, we tell the Master PIC it's been read to receive any IRQ. */
|
||||
WritePort(0x20, 0x20, 8);
|
||||
WritePort(0x20, 0x20, 1);
|
||||
}
|
||||
|
||||
/* However, in order to actually be able to receive IRQs, we need to remap the PICs. */
|
||||
void RemapIRQControllers() {
|
||||
/* 0x20 is the Master PIC,
|
||||
0xA0 is the Slave PIC. */
|
||||
WritePort(0x20, 0x11, 8);
|
||||
WritePort(0xA0, 0x11, 8);
|
||||
WritePort(0x21, 0x20, 8);
|
||||
WritePort(0xA1, 0x28, 8);
|
||||
WritePort(0x21, 0x04, 8);
|
||||
WritePort(0xA1, 0x02, 8);
|
||||
WritePort(0x21, 0x01, 8);
|
||||
WritePort(0xA1, 0x01, 8);
|
||||
WritePort(0x21, 0x0, 8);
|
||||
WritePort(0xA1, 0x0, 8);
|
||||
WritePort(0x20, 0x11, 1);
|
||||
WritePort(0xA0, 0x11, 1);
|
||||
WritePort(0x21, 0x20, 1);
|
||||
WritePort(0xA1, 0x28, 1);
|
||||
WritePort(0x21, 0x04, 1);
|
||||
WritePort(0xA1, 0x02, 1);
|
||||
WritePort(0x21, 0x01, 1);
|
||||
WritePort(0xA1, 0x01, 1);
|
||||
WritePort(0x21, 0x0, 1);
|
||||
WritePort(0xA1, 0x0, 1);
|
||||
}
|
||||
|
||||
/* In order to actually handle the IRQs, though, we need to tell the kernel *where* the handlers are. */
|
||||
|
@ -150,6 +151,11 @@ void UninstallIRQHandler(int IRQ) {
|
|||
*/
|
||||
|
||||
__attribute__((interrupt)) void ISR0Handler(INTERRUPT_FRAME* Frame) {
|
||||
// This baby is the timer.
|
||||
// TODO: Change ISR0Handler to TimerHandler.
|
||||
// Here, we can do some timer related stuff.
|
||||
// For starts, we just tick a timer that tells us how long the program has been running.
|
||||
time++;
|
||||
ISR_Common(Frame, 0);
|
||||
}
|
||||
__attribute__((interrupt)) void ISR1Handler(INTERRUPT_FRAME* Frame) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user