summaryrefslogtreecommitdiff
path: root/kernel/traps.s
AgeCommit message (Collapse)Author
2018-06-25Added the header asm/interrupt.h which includes a prototype for theJake Mannens
assembly function register_isr making it usable within the C portions of the source. Added a new file panic.s with the function panic that will print a panic message, disable interrupts and halt the system. Created the skeleton framework for paging in the new file page.s. The new function paging_init (called in kboot) will setup a simple page directory with two tables covering all addresses 0-8MB. It will also mark pages from 0-1MB as 'supervisor-only' to protect the kernel. NOTE: The function paging_init must be called before initialising the IDT as it does not disable interrupts! Modified the page fault handler to print the offending linear address along with the supplied error code. Following that, the handler will initiate a kernel panic. This function (along with panic) assumes console I/O to be operational. Modified the userspace test code to deliberately intiate a page fault by accessing an unmapped page.
2018-06-24Modified makefiles to use the more appropriate variable $(MAKE) whenJake Mannens
invoking the tool recursively. Disabled GCC's position-independent-code generation in makefiles. Modified makefile for kernel/usrbin so that it now compiles and links C code into the userspace test. Created errno.h and populated it with standard error definitions. Replaced the va_list based system call handlers with a system call table defined in the header kernel/sys.h. NOTE: This header is included in kmain.c and should ONLY be included there! Do NOT include this header in sys.c. Rather than fetching the user's stack pointer and using it to initialize a va_list, parameters are now passed to the call handlers via the general purpose registers EAX, EBX, ECX and EDX where EAX contains the requested call number and conveys the return value. Setup macros in unistd.h to aid to making system calls from userspace. Implemented two basic system calls; sys_print and sys_dummy. The former takes a single char* argument and displays it on screen whilst the latter is used to populate otherwise empty entries of the system call table. sys_dummy returns the error ENOSYS whenever it is called.
2018-06-23Re-wrote interrupt handling. Now, flush_idt only initializes IDT entriesJake Mannens
32-255. A separate routine in the new file traps.s initializes the first 32 entries with addresses pointing to exception handlers within said file. Modified the register_isr function to now accept a descriptor privilege level which it will assign to the modified IDT entry. Added a task state segment and corresponding entry to the GDT. The TSS will store the kernel's stack pointer and stack segment when switching to userspace. NOTE: The stack pointer MUST be saved manually before switching to userspace! Added the framework for a system call interface at interrupt vector 0x80 (128).