uhh stuff or something
This commit is contained in:
parent
8a2cb7168f
commit
795a2428da
2
build.sh
2
build.sh
@ -38,7 +38,7 @@ case $yn in
|
|||||||
echo -------------
|
echo -------------
|
||||||
echo STARTING QEMU
|
echo STARTING QEMU
|
||||||
echo -------------
|
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 --------
|
||||||
echo Finshed!
|
echo Finshed!
|
||||||
echo --------
|
echo --------
|
||||||
|
|||||||
11
src/kernel/arch/i686/basicdri.asm
Normal file
11
src/kernel/arch/i686/basicdri.asm
Normal 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
|
||||||
6
src/kernel/arch/i686/basicdri.c
Normal file
6
src/kernel/arch/i686/basicdri.c
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
/*----------------*\
|
||||||
|
|Nanite OS |
|
||||||
|
|Copyright (C) 2024|
|
||||||
|
|Tyler McGurrin |
|
||||||
|
\*----------------*/
|
||||||
|
#include "basicdri.h"
|
||||||
8
src/kernel/arch/i686/basicdri.h
Normal file
8
src/kernel/arch/i686/basicdri.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/*----------------*\
|
||||||
|
|Nanite OS |
|
||||||
|
|Copyright (C) 2024|
|
||||||
|
|Tyler McGurrin |
|
||||||
|
\*----------------*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
void __attribute__((cdecl)) reboot();
|
||||||
@ -4,18 +4,23 @@
|
|||||||
;Tyler McGurrin ;
|
;Tyler McGurrin ;
|
||||||
;/////////////////////;
|
;/////////////////////;
|
||||||
|
|
||||||
global x86_outb
|
global outb
|
||||||
x86_outb:
|
outb:
|
||||||
[bits 32]
|
[bits 32]
|
||||||
mov dx, [esp + 4]
|
mov dx, [esp + 4]
|
||||||
mov al, [esp + 8]
|
mov al, [esp + 8]
|
||||||
out dx, al
|
out dx, al
|
||||||
ret
|
ret
|
||||||
|
|
||||||
global x86_inb
|
global inb
|
||||||
x86_inb:
|
inb:
|
||||||
[bits 32]
|
[bits 32]
|
||||||
mov dx, [esp + 4]
|
mov dx, [esp + 4]
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
in al, dx
|
in al, dx
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
global i686_panic
|
||||||
|
i686_panic:
|
||||||
|
cli
|
||||||
|
hlt
|
||||||
|
|||||||
5
src/kernel/arch/i686/io.c
Normal file
5
src/kernel/arch/i686/io.c
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
/*----------------*\
|
||||||
|
|Nanite OS |
|
||||||
|
|Copyright (C) 2024|
|
||||||
|
|Tyler McGurrin |
|
||||||
|
\*----------------*/
|
||||||
@ -7,5 +7,8 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
void __attribute__((cdecl)) x86_outb(uint16_t port, uint8_t value);
|
void __attribute__((cdecl)) outb(uint16_t port, uint8_t value);
|
||||||
uint8_t __attribute__((cdecl)) x86_inb(uint16_t port);
|
uint8_t __attribute__((cdecl)) inb(uint16_t port);
|
||||||
|
|
||||||
|
void i686_iowait();
|
||||||
|
void __attribute__((cdecl)) i686_panic();
|
||||||
|
|||||||
@ -8,6 +8,44 @@
|
|||||||
#include "gdt.h"
|
#include "gdt.h"
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
#include <stdio.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();
|
void i686_ISR_InitializeGates();
|
||||||
|
|
||||||
@ -15,8 +53,23 @@ void i686_ISR_Initialize() {
|
|||||||
i686_ISR_InitializeGates();
|
i686_ISR_InitializeGates();
|
||||||
for (int i = 0; i < 256; i++)
|
for (int i = 0; i < 256; i++)
|
||||||
i686_IDT_EnableGate(i);
|
i686_IDT_EnableGate(i);
|
||||||
|
|
||||||
|
// i686_IDT_DisableGate(50);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __attribute__((cdecl)) i686_ISR_Handler(Registers* regs) {
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -18,4 +18,5 @@ typedef struct
|
|||||||
|
|
||||||
typedef void (*ISRHandler)(Registers* regs);
|
typedef void (*ISRHandler)(Registers* regs);
|
||||||
|
|
||||||
void i686_ISR_Initialize();
|
void i686_ISR_Initialize();
|
||||||
|
void i686_ISR_RegisterHandler(int interrupt);
|
||||||
@ -7,6 +7,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <hal/hal.h>
|
#include <hal/hal.h>
|
||||||
|
#include <arch/i686/io.h>
|
||||||
|
#include <arch/i686/basicdri.h>
|
||||||
#include "../version.h"
|
#include "../version.h"
|
||||||
|
|
||||||
extern uint8_t __bss_start;
|
extern uint8_t __bss_start;
|
||||||
@ -26,12 +28,7 @@ extern uint8_t __end;
|
|||||||
HAL_Initialize();
|
HAL_Initialize();
|
||||||
movecursorpos(19, 8);
|
movecursorpos(19, 8);
|
||||||
printf("Done!\n\n\n\n");
|
printf("Done!\n\n\n\n");
|
||||||
printf("Testing Interrupts...\n");
|
beep();
|
||||||
__asm("int $0x2");
|
|
||||||
printf("Testing Interrupts...\n");
|
|
||||||
__asm("int $0x3");
|
|
||||||
printf("Testing Interrupts...\n");
|
|
||||||
__asm("int $0x4");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -51,10 +51,10 @@ void setcursor(int x, int y)
|
|||||||
{
|
{
|
||||||
int pos = y * SCREEN_WIDTH + x;
|
int pos = y * SCREEN_WIDTH + x;
|
||||||
|
|
||||||
x86_outb(0x3D4, 0x0F);
|
outb(0x3D4, 0x0F);
|
||||||
x86_outb(0x3D5, (uint8_t)(pos & 0xFF));
|
outb(0x3D5, (uint8_t)(pos & 0xFF));
|
||||||
x86_outb(0x3D4, 0x0E);
|
outb(0x3D4, 0x0E);
|
||||||
x86_outb(0x3D5, (uint8_t)((pos >> 8) & 0xFF));
|
outb(0x3D5, (uint8_t)((pos >> 8) & 0xFF));
|
||||||
}
|
}
|
||||||
|
|
||||||
void clrscr()
|
void clrscr()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user