uhh stuff or something

This commit is contained in:
Tyler McGurrin 2024-12-25 23:40:05 -05:00
parent 8a2cb7168f
commit 795a2428da
11 changed files with 108 additions and 19 deletions

View File

@ -38,7 +38,7 @@ case $yn in
echo -------------
echo STARTING QEMU
echo -------------
qemu-system-i386 -fda build/main_floppy.img
qemu-system-i386 -audiodev pa,id=speaker -machine pcspk-audiodev=speaker -fda build/main_floppy.img
echo --------
echo Finshed!
echo --------

View File

@ -0,0 +1,11 @@
[bits 32]
global reboot
reboot:
XOR AL, AL
IN AL, 0x64
TEST AL, 0x02
JNZ reboot
MOV AL, 0xFC
OUT 0x64, AL

View File

@ -0,0 +1,6 @@
/*----------------*\
|Nanite OS |
|Copyright (C) 2024|
|Tyler McGurrin |
\*----------------*/
#include "basicdri.h"

View File

@ -0,0 +1,8 @@
/*----------------*\
|Nanite OS |
|Copyright (C) 2024|
|Tyler McGurrin |
\*----------------*/
#pragma once
void __attribute__((cdecl)) reboot();

View File

@ -4,18 +4,23 @@
;Tyler McGurrin ;
;/////////////////////;
global x86_outb
x86_outb:
global outb
outb:
[bits 32]
mov dx, [esp + 4]
mov al, [esp + 8]
out dx, al
ret
global x86_inb
x86_inb:
global inb
inb:
[bits 32]
mov dx, [esp + 4]
xor eax, eax
in al, dx
ret
global i686_panic
i686_panic:
cli
hlt

View File

@ -0,0 +1,5 @@
/*----------------*\
|Nanite OS |
|Copyright (C) 2024|
|Tyler McGurrin |
\*----------------*/

View File

@ -7,5 +7,8 @@
#include <stdint.h>
#include <stdbool.h>
void __attribute__((cdecl)) x86_outb(uint16_t port, uint8_t value);
uint8_t __attribute__((cdecl)) x86_inb(uint16_t port);
void __attribute__((cdecl)) outb(uint16_t port, uint8_t value);
uint8_t __attribute__((cdecl)) inb(uint16_t port);
void i686_iowait();
void __attribute__((cdecl)) i686_panic();

View File

@ -8,6 +8,44 @@
#include "gdt.h"
#include "io.h"
#include <stdio.h>
#include <stddef.h>
ISRHandler g_ISRHandlers[256];
static const char* const g_Exceptions[] = {
"Divide by zero error",
"Debug",
"Non-maskable Interrupt",
"Breakpoint",
"Overflow",
"Bound Range Exceeded",
"Invalid Opcode",
"Device Not Available",
"Double Fault",
"Coprocessor Segment Overrun",
"Invalid TSS",
"Segment Not Present",
"Stack-Segment Fault",
"General Protection Fault",
"Page Fault",
"",
"x87 Floating-Point Exception",
"Alignment Check",
"Machine Check",
"SIMD Floating-Point Exception",
"Virtualization Exception",
"Control Protection Exception ",
"",
"",
"",
"",
"",
"",
"Hypervisor Injection Exception",
"VMM Communication Exception",
"Security Exception",
""
};
void i686_ISR_InitializeGates();
@ -15,8 +53,23 @@ void i686_ISR_Initialize() {
i686_ISR_InitializeGates();
for (int i = 0; i < 256; i++)
i686_IDT_EnableGate(i);
// i686_IDT_DisableGate(50);
}
void __attribute__((cdecl)) i686_ISR_Handler(Registers* regs) {
printf("Interrupt %d\n", regs->interrupt);
if (g_ISRHandlers[regs->interrupt] != NULL)
g_ISRHandlers[regs->interrupt](regs);
else if (regs->interrupt >= 32)
printf("Unhandled Interrupt %d\n", regs->interrupt);
else {
printf("Unhandled Exception %d %s\n", regs->interrupt, g_Exceptions[regs->interrupt]);
printf(" EAX=%x EBX=%x ECX=%x EDX=%x ESI=%x EDI=%x\n", regs->eax, regs->ebx, regs->ecx, regs->edx, regs->esi, regs->edi);
printf(" ESP=%x EBP=%x EIP=%x EFLAGS=%x CS=%x DS=%x SS=%x\n", regs->esp, regs->ebp, regs->eip, regs->eflags, regs->cs, regs->ds, regs->ss);
printf(" INTERRUPT=%x ERRORCODE=%x\n", regs->interrupt, regs->error);
printf("KERNEL PANIC!\n");
i686_panic();
}
}

View File

@ -18,4 +18,5 @@ typedef struct
typedef void (*ISRHandler)(Registers* regs);
void i686_ISR_Initialize();
void i686_ISR_Initialize();
void i686_ISR_RegisterHandler(int interrupt);

View File

@ -7,6 +7,8 @@
#include <stdio.h>
#include <memory.h>
#include <hal/hal.h>
#include <arch/i686/io.h>
#include <arch/i686/basicdri.h>
#include "../version.h"
extern uint8_t __bss_start;
@ -26,12 +28,7 @@ extern uint8_t __end;
HAL_Initialize();
movecursorpos(19, 8);
printf("Done!\n\n\n\n");
printf("Testing Interrupts...\n");
__asm("int $0x2");
printf("Testing Interrupts...\n");
__asm("int $0x3");
printf("Testing Interrupts...\n");
__asm("int $0x4");
beep();

View File

@ -51,10 +51,10 @@ void setcursor(int x, int y)
{
int pos = y * SCREEN_WIDTH + x;
x86_outb(0x3D4, 0x0F);
x86_outb(0x3D5, (uint8_t)(pos & 0xFF));
x86_outb(0x3D4, 0x0E);
x86_outb(0x3D5, (uint8_t)((pos >> 8) & 0xFF));
outb(0x3D4, 0x0F);
outb(0x3D5, (uint8_t)(pos & 0xFF));
outb(0x3D4, 0x0E);
outb(0x3D5, (uint8_t)((pos >> 8) & 0xFF));
}
void clrscr()