diff options
| author | Jake Mannens <jake72360@gmail.com> | 2018-07-07 20:19:23 +1000 |
|---|---|---|
| committer | Jake Mannens <jake72360@gmail.com> | 2018-07-07 20:19:23 +1000 |
| commit | ec4f58e8e362e371718f656923c2d234f8ac215c (patch) | |
| tree | b84655b06de314c13007382b53a0f624cef2df6b /kernel/asm.s | |
| parent | fbbcb04f9e3197976d6ab4a79c45aa0a84e39aba (diff) | |
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.
Diffstat (limited to 'kernel/asm.s')
| -rw-r--r-- | kernel/asm.s | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/kernel/asm.s b/kernel/asm.s new file mode 100644 index 0000000..4abe607 --- /dev/null +++ b/kernel/asm.s @@ -0,0 +1,60 @@ +global switch_to +extern ctask +extern tss + +switch_to: + push ebp + mov ebp, esp + mov eax, [ebp+8] + mov [ctask], eax + mov esi, [ebp+12] + mov ecx, 13 +.loop: + lodsd + push eax + dec ecx + jz .end + jmp .loop +.end: + mov ax, 0x23 + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + popa + iret + +; uint32_t ss; +; uint32_t esp; +; uint32_t eflags; +; uint32_t cs; +; uint32_t eip; +; uint32_t eax; +; uint32_t ecx; +; uint32_t edx; +; uint32_t ebx; +; uint32_t esp_garbage; +; uint32_t ebp; +; uint32_t esi; +; uint32_t edi; + +; switch_to: + ; push ebp + ; mov ebp, esp + ; cli + ; mov ax, 0x23 + ; mov ds, ax + ; mov es, ax + ; mov fs, ax + ; mov gs, ax + ; mov eax, esp + ; ; save ESP in the TSS + ; mov [tss+4], eax + ; push dword 0x23 + ; push dword 0x00180000 + ; pushf + ; push dword 0x1B + ; push dword 0x00100000 + ; iret + ; pop ebp + ; ret |
