From ec4f58e8e362e371718f656923c2d234f8ac215c Mon Sep 17 00:00:00 2001 From: Jake Mannens Date: Sat, 7 Jul 2018 20:19:23 +1000 Subject: Added '-g' flag for GCC to all makefiles to ensure debugging information is produced. This may change later. Added the new directory 'lib' to the source tree which build lib.a, an archive containing common library routines for both the kernel and userspace code to use. Added the file string.c to the lib directory (as well as the appropriate headers in /include) which provides some basic functions from the standard C string library. Added a physical memory manager which is now located in memory.c. This memory manager tracks free pages from 1MB-8MB with a simple table and allocates memory in blocks of 4KB pages. Multiple pages can be allocated in which they are returned as a linked list. Added a 'page window' in memory.c which allows the temporary mapping of a single page at a time into the current address space. Moved all paging routines that were previously located in page.s over to memory.c where they have been re-implemented as a mixture of C and inline assembly. Moved the primative userspace routines from usrspace.s over to the new sched.c. The only remaining routine, usrcall is now located in asm.s as 'switch_to' which takes two arguments, pointers to the task structure and task state structure of the new task which is being switched to. Pages for userspace are now allocated dynamically. The user binary is loaded in at 1GB upwards. The user stack is located at the end of the 4GB address space with the lower 1GB being reserved for the kernel. Updated the link.ld file for the userspace binary to include the new starting address 0x40000000 (1GB). Renamed the symbols for the user binary blob to make them shorter. --- kernel/page.s | 55 ------------------------------------------------------- 1 file changed, 55 deletions(-) delete mode 100644 kernel/page.s (limited to 'kernel/page.s') diff --git a/kernel/page.s b/kernel/page.s deleted file mode 100644 index 4e40822..0000000 --- a/kernel/page.s +++ /dev/null @@ -1,55 +0,0 @@ -global paging_init - -align 4096 -page_dir: - times 4096 db 0 - -align 4096 -page_tables: - ; two page tables - times 4096 db 0 - times 4096 db 0 -.end: - -; here, we initialize paging. since the IDT -; has yet to be populated, we must take extra -; care as we can't afford to trigger a page -; fault. -paging_init: - push ebp - mov ebp, esp - push ebx - ; populate the page directory - mov eax, page_tables - or eax, 0x007 - mov [page_dir], eax - mov eax, (page_tables+4096) - or eax, 0x007 - mov [page_dir+4], eax - ; populate the page tables - mov ebx, page_tables - mov ecx, ((page_tables.end-page_tables)/4) - mov edx, 0 -.loop: - mov eax, edx - or eax, 0x003 - cmp edx, 0x100000 - jb .skip - or eax, 0x004 -.skip: - mov [ebx], eax - dec ecx - jz .end - add ebx, 4 - add edx, 4096 - jmp .loop -.end: - ; load the page directory and enable paging - mov eax, page_dir - mov cr3, eax - mov eax, cr0 - or eax, 0x80000000 - mov cr0, eax - pop ebx - pop ebp - ret -- cgit v1.3