summaryrefslogtreecommitdiff
path: root/src/kernel/isrs.asm
diff options
context:
space:
mode:
authorBenji Dial <benji6283@gmail.com>2020-09-06 00:48:07 -0400
committerBenji Dial <benji6283@gmail.com>2020-09-06 00:48:07 -0400
commite8c6577617bffa4402c07c7aa20e3c24f03c1c20 (patch)
tree2fb9230b62d2344a44453117de9e656892219788 /src/kernel/isrs.asm
parent7ff724fe8f709440da9c730fdb8dcbaa4f989ed5 (diff)
downloadportland-os-e8c6577617bffa4402c07c7aa20e3c24f03c1c20.tar.gz
program loading, others
big kernel additions: paging, elf loading, separate kernel and user page allocation it now properly loads and runs sd0:bin/init.elf still need to determine which disk was booted from, and start the init on that disk
Diffstat (limited to 'src/kernel/isrs.asm')
-rw-r--r--src/kernel/isrs.asm94
1 files changed, 94 insertions, 0 deletions
diff --git a/src/kernel/isrs.asm b/src/kernel/isrs.asm
new file mode 100644
index 0000000..163ddbe
--- /dev/null
+++ b/src/kernel/isrs.asm
@@ -0,0 +1,94 @@
+bits 32
+
+global syscall_isr
+global quit_isr
+global yield_isr
+global _start_user_mode
+
+extern syscall_table
+extern active_task
+
+extern delete_task
+extern advance_active_task
+
+n_syscalls equ 8
+
+section .text
+syscall_isr:
+ cmp eax, n_syscalls
+ jge .bad
+
+ mov eax, dword [syscall_table + eax * 4]
+
+ push edi
+ push esi
+ push edx
+ push ecx
+ push ebx
+
+ call eax
+
+ add esp, 20
+
+ iret
+
+.bad:
+ mov eax, -1
+ iret
+
+quit_isr:
+ push dword [active_task]
+ call delete_task
+ push yield_isr.return_to_task
+ jmp advance_active_task
+
+yield_isr:
+ mov eax, dword [active_task]
+
+ mov dword [eax + 8], ebx
+ mov dword [eax + 12], ecx
+ mov dword [eax + 16], edx
+ mov dword [eax + 20], esi
+ mov dword [eax + 24], edi
+ mov dword [eax + 28], ebp
+
+ mov edx, dword [esp]
+ mov dword [eax], edx
+
+ mov edx, cr3
+ mov dword [eax + 4], edx
+
+ mov edx, dword [esp + 12]
+ mov dword [eax + 4], edx
+
+ call advance_active_task
+
+.return_to_task:
+ mov eax, dword [active_task]
+
+ mov edx, dword [eax]
+ mov dword [esp], edx
+
+ mov edx, dword [eax + 4]
+ mov cr3, edx
+
+ mov edx, dword [eax + 4]
+ mov dword [esp + 24], edx
+
+ mov ebx, dword [eax + 8]
+ mov ecx, dword [eax + 12]
+ mov edx, dword [eax + 16]
+ mov esi, dword [eax + 20]
+ mov edi, dword [eax + 24]
+ mov ebp, dword [eax + 28]
+
+_before_start_task:
+ iret
+
+_start_user_mode:
+ push dword 0x2b
+ sub esp, 4
+ push dword 0x00000200;interrupt flag
+ push dword 0x23
+ sub esp, 4
+ jmp yield_isr.return_to_task \ No newline at end of file