Compare commits

..

No commits in common. "f0ca9de14b36c75830926cda1d6b47a3b313b8b5" and "a5ce202055980850fd8413ed1a4dbc759f77db7a" have entirely different histories.

4 changed files with 16 additions and 84 deletions

6
.gitignore vendored
View File

@ -57,9 +57,3 @@ 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

View File

@ -686,8 +686,6 @@ 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);

View File

@ -44,20 +44,12 @@ 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();
@ -98,6 +90,8 @@ void PrepareSystem(FILELOADER_PARAMS* FLOP) {
}
// Set up memory management
InstallGDT();
InstallIDT();
InstallMemoryMap();
InstallPaging();
@ -110,54 +104,6 @@ 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() {

View File

@ -50,7 +50,6 @@ 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]);
@ -90,26 +89,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, 1);
WritePort(0xA0, 0x20, 8);
/* In either case, we tell the Master PIC it's been read to receive any IRQ. */
WritePort(0x20, 0x20, 1);
WritePort(0x20, 0x20, 8);
}
/* 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, 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);
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);
}
/* In order to actually handle the IRQs, though, we need to tell the kernel *where* the handlers are. */
@ -151,11 +150,6 @@ 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) {