More more stuff in arch subdir
This commit is contained in:
parent
9e2a1a73a9
commit
c65c7bb7b0
2
Makefile
2
Makefile
@ -13,7 +13,7 @@ SUBDIRS := core drivers tests arch/$(ARCH)
|
|||||||
|
|
||||||
CPPFLAGS += $(foreach dir, $(SUBDIRS), -I$(dir))
|
CPPFLAGS += $(foreach dir, $(SUBDIRS), -I$(dir))
|
||||||
|
|
||||||
asmsrc=$(wildcard *.asm)
|
asmsrc=$(wildcard arch/$(ARCH)/boot/*.asm)
|
||||||
asmobj=$(asmsrc:%.asm=%.o)
|
asmobj=$(asmsrc:%.asm=%.o)
|
||||||
csrc=$(shell find $(SUBDIRS) -type f -name "*.c")# $(wildcard *.c)
|
csrc=$(shell find $(SUBDIRS) -type f -name "*.c")# $(wildcard *.c)
|
||||||
cobj=$(csrc:%.c=%.o) arch/$(ARCH)/cpu_context_switch.o arch/$(ARCH)/irq_pit.o
|
cobj=$(csrc:%.c=%.o) arch/$(ARCH)/cpu_context_switch.o arch/$(ARCH)/irq_pit.o
|
||||||
|
@ -21,3 +21,50 @@ int exceptionSetRoutine(int exception, exception_handler handler)
|
|||||||
restore_IRQs(flags);
|
restore_IRQs(flags);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int exceptionSetup()
|
||||||
|
{
|
||||||
|
exceptionSetRoutine(EXCEPTION_DOUBLE_FAULT, ACCESS_INTERRUPT(EXCEPTION_DOUBLE_FAULT));
|
||||||
|
exceptionSetRoutine(EXCEPTION_DIVIDE_ZERO, ACCESS_INTERRUPT(EXCEPTION_DIVIDE_ZERO));
|
||||||
|
// Used by the DBG
|
||||||
|
// exceptionSetRoutine(EXCEPTION_DEBUG, ACCESS_INTERRUPT(EXCEPTION_DEBUG));
|
||||||
|
exceptionSetRoutine(EXCEPTION_NMI, ACCESS_INTERRUPT(EXCEPTION_NMI));
|
||||||
|
exceptionSetRoutine(EXCEPTION_BREAKPOINT, ACCESS_INTERRUPT(EXCEPTION_BREAKPOINT));
|
||||||
|
exceptionSetRoutine(EXCEPTION_OVERFLOW, ACCESS_INTERRUPT(EXCEPTION_OVERFLOW));
|
||||||
|
exceptionSetRoutine(EXCEPTION_BOUND_RANGE_EXCEEDED,
|
||||||
|
ACCESS_INTERRUPT(EXCEPTION_BOUND_RANGE_EXCEEDED));
|
||||||
|
exceptionSetRoutine(EXCEPTION_INVALID_OPCODE, ACCESS_INTERRUPT(EXCEPTION_INVALID_OPCODE));
|
||||||
|
exceptionSetRoutine(EXCEPTION_DEVICE_NOT_AVAILABLE,
|
||||||
|
ACCESS_INTERRUPT(EXCEPTION_DEVICE_NOT_AVAILABLE));
|
||||||
|
exceptionSetRoutine(EXCEPTION_COPRO_OVERRUN, ACCESS_INTERRUPT(EXCEPTION_COPRO_OVERRUN));
|
||||||
|
exceptionSetRoutine(EXCEPTION_INVALID_TSS, ACCESS_INTERRUPT(EXCEPTION_INVALID_TSS));
|
||||||
|
exceptionSetRoutine(EXCEPTION_SEGMENT_NOT_PRESENT,
|
||||||
|
ACCESS_INTERRUPT(EXCEPTION_SEGMENT_NOT_PRESENT));
|
||||||
|
exceptionSetRoutine(EXCEPTION_STACK_SEGMENT_FAULT,
|
||||||
|
ACCESS_INTERRUPT(EXCEPTION_STACK_SEGMENT_FAULT));
|
||||||
|
exceptionSetRoutine(EXCEPTION_GENERAL_PROTECTION_FAULT,
|
||||||
|
ACCESS_INTERRUPT(EXCEPTION_GENERAL_PROTECTION_FAULT));
|
||||||
|
exceptionSetRoutine(EXCEPTION_PAGE_FAULT, ACCESS_INTERRUPT(EXCEPTION_PAGE_FAULT));
|
||||||
|
exceptionSetRoutine(EXCEPTION_RESERVED_1, ACCESS_INTERRUPT(EXCEPTION_RESERVED_1));
|
||||||
|
exceptionSetRoutine(EXCEPTION_X87_FP_EXCEPTION,
|
||||||
|
ACCESS_INTERRUPT(EXCEPTION_X87_FP_EXCEPTION));
|
||||||
|
exceptionSetRoutine(EXCEPTION_ALIGNMENT_CHECK,
|
||||||
|
ACCESS_INTERRUPT(EXCEPTION_ALIGNMENT_CHECK));
|
||||||
|
exceptionSetRoutine(EXCEPTION_MACHINE_CHECK, ACCESS_INTERRUPT(EXCEPTION_MACHINE_CHECK));
|
||||||
|
exceptionSetRoutine(EXCEPTION_SIMD_FP, ACCESS_INTERRUPT(EXCEPTION_SIMD_FP));
|
||||||
|
exceptionSetRoutine(EXCEPTION_VIRTUALIZATION, ACCESS_INTERRUPT(EXCEPTION_VIRTUALIZATION));
|
||||||
|
exceptionSetRoutine(EXCEPTION_RESERVED_2, ACCESS_INTERRUPT(EXCEPTION_RESERVED_2));
|
||||||
|
exceptionSetRoutine(EXCEPTION_RESERVED_3, ACCESS_INTERRUPT(EXCEPTION_RESERVED_3));
|
||||||
|
exceptionSetRoutine(EXCEPTION_RESERVED_4, ACCESS_INTERRUPT(EXCEPTION_RESERVED_4));
|
||||||
|
exceptionSetRoutine(EXCEPTION_RESERVED_5, ACCESS_INTERRUPT(EXCEPTION_RESERVED_5));
|
||||||
|
exceptionSetRoutine(EXCEPTION_RESERVED_6, ACCESS_INTERRUPT(EXCEPTION_RESERVED_6));
|
||||||
|
exceptionSetRoutine(EXCEPTION_RESERVED_7, ACCESS_INTERRUPT(EXCEPTION_RESERVED_7));
|
||||||
|
exceptionSetRoutine(EXCEPTION_RESERVED_8, ACCESS_INTERRUPT(EXCEPTION_RESERVED_8));
|
||||||
|
exceptionSetRoutine(EXCEPTION_RESERVED_9, ACCESS_INTERRUPT(EXCEPTION_RESERVED_9));
|
||||||
|
exceptionSetRoutine(EXCEPTION_RESERVED_10, ACCESS_INTERRUPT(EXCEPTION_RESERVED_10));
|
||||||
|
exceptionSetRoutine(EXCEPTION_SECURITY, ACCESS_INTERRUPT(EXCEPTION_SECURITY));
|
||||||
|
exceptionSetRoutine(EXCEPTION_RESERVED_11, ACCESS_INTERRUPT(EXCEPTION_RESERVED_11));
|
||||||
|
|
||||||
|
exceptionSetRoutine(EXCEPTION_PAGE_FAULT, pagefault_handler);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@ -43,3 +43,4 @@
|
|||||||
|
|
||||||
typedef void (*exception_handler)(struct interrupt_frame *frame, ulong error_code);
|
typedef void (*exception_handler)(struct interrupt_frame *frame, ulong error_code);
|
||||||
int exceptionSetRoutine(int exception, exception_handler handler);
|
int exceptionSetRoutine(int exception, exception_handler handler);
|
||||||
|
int exceptionSetup();
|
||||||
|
14
arch/x86/processor.h
Normal file
14
arch/x86/processor.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
static void cpuid(unsigned int *eax, unsigned int *ebx,
|
||||||
|
unsigned int *ecx, unsigned int *edx)
|
||||||
|
{
|
||||||
|
/* ecx is often an input as well as an output. */
|
||||||
|
asm volatile("cpuid"
|
||||||
|
: "=a" (*eax),
|
||||||
|
"=b" (*ebx),
|
||||||
|
"=c" (*ecx),
|
||||||
|
"=d" (*edx)
|
||||||
|
: "0" (*eax), "2" (*ecx)
|
||||||
|
: "memory");
|
||||||
|
}
|
@ -16,7 +16,7 @@ int allocSlab(struct slabDesc **desc, size_t size, int self_containing);
|
|||||||
int allocSlabEntry(struct slabEntry **desc, size_t size, int selfContained);
|
int allocSlabEntry(struct slabEntry **desc, size_t size, int selfContained);
|
||||||
static int formatPage(struct slabEntry *desc, size_t size, int selfContained);
|
static int formatPage(struct slabEntry *desc, size_t size, int selfContained);
|
||||||
|
|
||||||
int allocInit(void)
|
int allocSetup(void)
|
||||||
{
|
{
|
||||||
uint start = log2(sizeof(void *));
|
uint start = log2(sizeof(void *));
|
||||||
list_init(slub);
|
list_init(slub);
|
||||||
|
@ -16,7 +16,7 @@ struct slabDesc {
|
|||||||
struct slabDesc *next;
|
struct slabDesc *next;
|
||||||
struct slabDesc *prev;
|
struct slabDesc *prev;
|
||||||
};
|
};
|
||||||
int allocInit(void);
|
int allocSetup(void);
|
||||||
int allocBookSlab(size_t size, int selfContained);
|
int allocBookSlab(size_t size, int selfContained);
|
||||||
|
|
||||||
void *malloc(size_t size);
|
void *malloc(size_t size);
|
||||||
|
49
core/main.c
49
core/main.c
@ -22,10 +22,6 @@
|
|||||||
#include "vga.h"
|
#include "vga.h"
|
||||||
|
|
||||||
#define CHECK_FLAG(flags, bit) ((flags) & (1 << (bit)))
|
#define CHECK_FLAG(flags, bit) ((flags) & (1 << (bit)))
|
||||||
void cpuid(int code, uint32_t *a, uint32_t *d)
|
|
||||||
{
|
|
||||||
asm volatile("cpuid" : "=a"(*a), "=d"(*d) : "0"(code) : "ebx", "ecx");
|
|
||||||
}
|
|
||||||
|
|
||||||
void idleThread(void *arg)
|
void idleThread(void *arg)
|
||||||
{
|
{
|
||||||
@ -110,54 +106,13 @@ void kmain(unsigned long magic, unsigned long addr)
|
|||||||
irqSetRoutine(IRQ_KEYBOARD, keyboard_handler);
|
irqSetRoutine(IRQ_KEYBOARD, keyboard_handler);
|
||||||
|
|
||||||
printf("Enabling HW interrupts\n");
|
printf("Enabling HW interrupts\n");
|
||||||
exceptionSetRoutine(EXCEPTION_DOUBLE_FAULT, ACCESS_INTERRUPT(EXCEPTION_DOUBLE_FAULT));
|
|
||||||
exceptionSetRoutine(EXCEPTION_DIVIDE_ZERO, ACCESS_INTERRUPT(EXCEPTION_DIVIDE_ZERO));
|
|
||||||
// Used by the DBG
|
|
||||||
// exceptionSetRoutine(EXCEPTION_DEBUG, ACCESS_INTERRUPT(EXCEPTION_DEBUG));
|
|
||||||
exceptionSetRoutine(EXCEPTION_NMI, ACCESS_INTERRUPT(EXCEPTION_NMI));
|
|
||||||
exceptionSetRoutine(EXCEPTION_BREAKPOINT, ACCESS_INTERRUPT(EXCEPTION_BREAKPOINT));
|
|
||||||
exceptionSetRoutine(EXCEPTION_OVERFLOW, ACCESS_INTERRUPT(EXCEPTION_OVERFLOW));
|
|
||||||
exceptionSetRoutine(EXCEPTION_BOUND_RANGE_EXCEEDED,
|
|
||||||
ACCESS_INTERRUPT(EXCEPTION_BOUND_RANGE_EXCEEDED));
|
|
||||||
exceptionSetRoutine(EXCEPTION_INVALID_OPCODE, ACCESS_INTERRUPT(EXCEPTION_INVALID_OPCODE));
|
|
||||||
exceptionSetRoutine(EXCEPTION_DEVICE_NOT_AVAILABLE,
|
|
||||||
ACCESS_INTERRUPT(EXCEPTION_DEVICE_NOT_AVAILABLE));
|
|
||||||
exceptionSetRoutine(EXCEPTION_COPRO_OVERRUN, ACCESS_INTERRUPT(EXCEPTION_COPRO_OVERRUN));
|
|
||||||
exceptionSetRoutine(EXCEPTION_INVALID_TSS, ACCESS_INTERRUPT(EXCEPTION_INVALID_TSS));
|
|
||||||
exceptionSetRoutine(EXCEPTION_SEGMENT_NOT_PRESENT,
|
|
||||||
ACCESS_INTERRUPT(EXCEPTION_SEGMENT_NOT_PRESENT));
|
|
||||||
exceptionSetRoutine(EXCEPTION_STACK_SEGMENT_FAULT,
|
|
||||||
ACCESS_INTERRUPT(EXCEPTION_STACK_SEGMENT_FAULT));
|
|
||||||
exceptionSetRoutine(EXCEPTION_GENERAL_PROTECTION_FAULT,
|
|
||||||
ACCESS_INTERRUPT(EXCEPTION_GENERAL_PROTECTION_FAULT));
|
|
||||||
exceptionSetRoutine(EXCEPTION_PAGE_FAULT, ACCESS_INTERRUPT(EXCEPTION_PAGE_FAULT));
|
|
||||||
exceptionSetRoutine(EXCEPTION_RESERVED_1, ACCESS_INTERRUPT(EXCEPTION_RESERVED_1));
|
|
||||||
exceptionSetRoutine(EXCEPTION_X87_FP_EXCEPTION,
|
|
||||||
ACCESS_INTERRUPT(EXCEPTION_X87_FP_EXCEPTION));
|
|
||||||
exceptionSetRoutine(EXCEPTION_ALIGNMENT_CHECK,
|
|
||||||
ACCESS_INTERRUPT(EXCEPTION_ALIGNMENT_CHECK));
|
|
||||||
exceptionSetRoutine(EXCEPTION_MACHINE_CHECK, ACCESS_INTERRUPT(EXCEPTION_MACHINE_CHECK));
|
|
||||||
exceptionSetRoutine(EXCEPTION_SIMD_FP, ACCESS_INTERRUPT(EXCEPTION_SIMD_FP));
|
|
||||||
exceptionSetRoutine(EXCEPTION_VIRTUALIZATION, ACCESS_INTERRUPT(EXCEPTION_VIRTUALIZATION));
|
|
||||||
exceptionSetRoutine(EXCEPTION_RESERVED_2, ACCESS_INTERRUPT(EXCEPTION_RESERVED_2));
|
|
||||||
exceptionSetRoutine(EXCEPTION_RESERVED_3, ACCESS_INTERRUPT(EXCEPTION_RESERVED_3));
|
|
||||||
exceptionSetRoutine(EXCEPTION_RESERVED_4, ACCESS_INTERRUPT(EXCEPTION_RESERVED_4));
|
|
||||||
exceptionSetRoutine(EXCEPTION_RESERVED_5, ACCESS_INTERRUPT(EXCEPTION_RESERVED_5));
|
|
||||||
exceptionSetRoutine(EXCEPTION_RESERVED_6, ACCESS_INTERRUPT(EXCEPTION_RESERVED_6));
|
|
||||||
exceptionSetRoutine(EXCEPTION_RESERVED_7, ACCESS_INTERRUPT(EXCEPTION_RESERVED_7));
|
|
||||||
exceptionSetRoutine(EXCEPTION_RESERVED_8, ACCESS_INTERRUPT(EXCEPTION_RESERVED_8));
|
|
||||||
exceptionSetRoutine(EXCEPTION_RESERVED_9, ACCESS_INTERRUPT(EXCEPTION_RESERVED_9));
|
|
||||||
exceptionSetRoutine(EXCEPTION_RESERVED_10, ACCESS_INTERRUPT(EXCEPTION_RESERVED_10));
|
|
||||||
exceptionSetRoutine(EXCEPTION_SECURITY, ACCESS_INTERRUPT(EXCEPTION_SECURITY));
|
|
||||||
exceptionSetRoutine(EXCEPTION_RESERVED_11, ACCESS_INTERRUPT(EXCEPTION_RESERVED_11));
|
|
||||||
|
|
||||||
exceptionSetRoutine(EXCEPTION_PAGE_FAULT, pagefault_handler);
|
|
||||||
// Enabling the HW interrupts
|
// Enabling the HW interrupts
|
||||||
|
exceptionSetup();
|
||||||
asm volatile("sti\n");
|
asm volatile("sti\n");
|
||||||
|
|
||||||
printf("Setting up Serial link (115200)\n");
|
printf("Setting up Serial link (115200)\n");
|
||||||
serialSetup(115200);
|
serialSetup(115200);
|
||||||
allocInit();
|
allocSetup();
|
||||||
kthreadSetup(_stack_bottom, (_stack_top - _stack_bottom + 1));
|
kthreadSetup(_stack_bottom, (_stack_top - _stack_bottom + 1));
|
||||||
kthreadCreate("idle", idleThread, NULL);
|
kthreadCreate("idle", idleThread, NULL);
|
||||||
irqSetRoutine(IRQ_TIMER, pit_handler);
|
irqSetRoutine(IRQ_TIMER, pit_handler);
|
||||||
|
Loading…
Reference in New Issue
Block a user