mirror of
https://github.com/gbowne1/ClassicOS.git
synced 2024-11-22 06:06:52 -08:00
fixing more of the mess
This commit is contained in:
parent
e99a09639d
commit
4b0bd4d133
@ -68,6 +68,7 @@ target_link_libraries(ClassicOS PRIVATE)
|
|||||||
set(CMAKE_C_COMPILER gcc)
|
set(CMAKE_C_COMPILER gcc)
|
||||||
set(CMAKE_LINKER ld)
|
set(CMAKE_LINKER ld)
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "-g -s")
|
set(CMAKE_EXE_LINKER_FLAGS "-g -s")
|
||||||
|
set(CMAKE_LINK_FLAGS "${CMAKE_LINK_FLAGS} -e kernel_main")
|
||||||
set(CMAKE_CXX_FLAGS "-g -Wall")
|
set(CMAKE_CXX_FLAGS "-g -Wall")
|
||||||
set(CMAKE_C_FLAGS "-g -Wall -m32")
|
set(CMAKE_C_FLAGS "-g -Wall -m32")
|
||||||
set(CMAKE_BUILD_TYPE Debug)
|
set(CMAKE_BUILD_TYPE Debug)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
ENTRY(_start)
|
ENTRY(kernel_main)
|
||||||
|
|
||||||
SECTIONS {
|
SECTIONS {
|
||||||
. = 0x100000;
|
. = 0x100000;
|
||||||
@ -7,6 +7,10 @@ SECTIONS {
|
|||||||
*(.text)
|
*(.text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.rodata : {
|
||||||
|
*(.rodata)
|
||||||
|
}
|
||||||
|
|
||||||
.data : {
|
.data : {
|
||||||
*(.data)
|
*(.data)
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ void gdt_init()
|
|||||||
|
|
||||||
// Exception handlers
|
// Exception handlers
|
||||||
extern void divide_error();
|
extern void divide_error();
|
||||||
extern void page_fault();
|
extern void page_fault(struct idt_regs *regs);
|
||||||
extern void general_protection_fault();
|
extern void general_protection_fault();
|
||||||
extern void double_fault();
|
extern void double_fault();
|
||||||
|
|
||||||
@ -91,27 +91,12 @@ extern void timer();
|
|||||||
extern void keyboard();
|
extern void keyboard();
|
||||||
extern void device();
|
extern void device();
|
||||||
|
|
||||||
// ISR table
|
|
||||||
void (*isr_table[ISR_TABLE_SIZE])(void) = {0};
|
|
||||||
|
|
||||||
// Register an ISR
|
// Register an ISR
|
||||||
void isr_register(uint8_t num, void (*handler)(void))
|
void isr_register(uint8_t num, void (*handler)(struct idt_regs *))
|
||||||
{
|
{
|
||||||
isr_table[num] = handler;
|
isr_table[num] = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ISR handler
|
|
||||||
void isr_handler(struct idt_regs *regs)
|
|
||||||
{
|
|
||||||
void (*handler)(void) = isr_table[regs->int_no];
|
|
||||||
|
|
||||||
handler = isr_table[regs->int_no];
|
|
||||||
if (handler)
|
|
||||||
{
|
|
||||||
handler();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize the ISR
|
// Initialize the ISR
|
||||||
void isr_init()
|
void isr_init()
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "idt.h"
|
#include "idt.h"
|
||||||
|
#include "isr.h"
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@ -21,7 +22,7 @@ const struct idt_ptr idtp = {sizeof(idt) - 1, idt};
|
|||||||
|
|
||||||
// Exception handlers
|
// Exception handlers
|
||||||
extern void divide_error_handler();
|
extern void divide_error_handler();
|
||||||
extern void page_fault_handler();
|
extern void page_fault(struct idt_regs *regs);
|
||||||
extern void general_protection_fault_handler();
|
extern void general_protection_fault_handler();
|
||||||
extern void double_fault_handler();
|
extern void double_fault_handler();
|
||||||
|
|
||||||
@ -57,7 +58,7 @@ void idt_init()
|
|||||||
|
|
||||||
// Set up exception handlers
|
// Set up exception handlers
|
||||||
idt_set_gate(0, divide_error_handler, 0x08, 0x8E);
|
idt_set_gate(0, divide_error_handler, 0x08, 0x8E);
|
||||||
idt_set_gate(14, page_fault_handler, 0x08, 0x8E);
|
idt_set_gate(14, page_fault, 0x08, 0x8E);
|
||||||
idt_set_gate(13, general_protection_fault_handler, 0x08, 0x8E);
|
idt_set_gate(13, general_protection_fault_handler, 0x08, 0x8E);
|
||||||
idt_set_gate(8, double_fault_handler, 0x08, 0x8E);
|
idt_set_gate(8, double_fault_handler, 0x08, 0x8E);
|
||||||
|
|
||||||
|
@ -18,17 +18,10 @@ void dummy_isr(struct isr_regs *regs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ISR table
|
// ISR table
|
||||||
void (*isr_table[256])(struct isr_regs *regs) = {
|
extern void (*isr_table[256])(struct isr_regs *regs);
|
||||||
// initialize the dummy isr_table
|
|
||||||
[TIMER_INTERRUPT] = dummy_isr, // Timer interrupt
|
|
||||||
[KEYBOARD_INTERRUPT] = dummy_isr, // Keyboard interrupt
|
|
||||||
[NETWORK_INTERRUPT] = dummy_isr, // Network interrupt
|
|
||||||
[DISK_INTERRUPT] = dummy_isr, // Disk interrupt
|
|
||||||
[SERIAL_PORT_INTERRUPT] = dummy_isr // Serial port interrupt
|
|
||||||
};
|
|
||||||
|
|
||||||
// Register an ISR
|
// Register an ISR
|
||||||
void isr_register(uint8_t num, void (*handler)(struct isr_regs *regs))
|
extern void isr_register(uint8_t num, void (*handler)(struct isr_regs *regs))
|
||||||
{
|
{
|
||||||
isr_table[num] = handler;
|
isr_table[num] = handler;
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,13 @@
|
|||||||
|
|
||||||
struct isr_regs
|
struct isr_regs
|
||||||
{
|
{
|
||||||
uint32_t gs, fs, es, ds; // Segment selectors
|
uint32_t gs, fs, es, ds; // Segment selectors
|
||||||
uint32_t edi, esi, ebp, esp; // Pushed by pusha instruction
|
uint32_t edi, esi, ebp, esp; // Pushed by pusha instruction
|
||||||
uint32_t ebx, edx, ecx, eax; // Pushed by the interrupt handler
|
uint32_t ebx, edx, ecx, eax; // Pushed by the interrupt handler
|
||||||
uint32_t int_no, err_code; // Interrupt number and error code (if applicable)
|
uint32_t int_no,
|
||||||
uint32_t eip, cs, eflags, esp_at_signal; // Pushed by the processor automatically
|
err_code; // Interrupt number and error code (if applicable)
|
||||||
|
uint32_t eip, cs, eflags,
|
||||||
|
esp_at_signal; // Pushed by the processor automatically
|
||||||
};
|
};
|
||||||
|
|
||||||
// Structure for storing register values during an ISR
|
// Structure for storing register values during an ISR
|
||||||
|
Loading…
Reference in New Issue
Block a user