summaryrefslogtreecommitdiffhomepage
path: root/dev/boot/src/HEL/AMD64/BootAPI.S
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2025-03-23 19:13:48 +0100
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2025-03-23 19:15:17 +0100
commita13e1c0911c0627184bc38f18c7fdda64447b3ad (patch)
tree073a62c09bf216e85a3f310376640fa1805147f9 /dev/boot/src/HEL/AMD64/BootAPI.S
parent149fa096eb306d03686b3b67e813cf1a78e08cd0 (diff)
meta(kernel): Reworked repository's filesystem structure.
Removing useless parts of the project too. Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/boot/src/HEL/AMD64/BootAPI.S')
-rw-r--r--dev/boot/src/HEL/AMD64/BootAPI.S60
1 files changed, 60 insertions, 0 deletions
diff --git a/dev/boot/src/HEL/AMD64/BootAPI.S b/dev/boot/src/HEL/AMD64/BootAPI.S
new file mode 100644
index 00000000..963ef46a
--- /dev/null
+++ b/dev/boot/src/HEL/AMD64/BootAPI.S
@@ -0,0 +1,60 @@
+.global rt_jump_to_address
+.global rt_reset_hardware
+
+.text
+
+.intel_syntax noprefix
+
+/**
+ @brief this function setups a stack and then jumps to
+ a function */
+rt_jump_to_address:
+ mov rbx, rcx
+ mov rcx, rdx
+ push rbx
+ push rdx
+ mov rsp, r8
+ push rax
+ jmp rbx
+
+ pop rdx
+ pop rbx
+ pop rax
+
+ ret
+
+rt_reset_hardware:
+ /* dont raise any interrupts. (except ofc NMIs.) */
+ cli
+ /* remap PIC */
+wait_gate1:
+ in al,0x64
+ and al,2
+ jnz wait_gate1
+ mov al,0x0D1
+ out 0x64,al
+wait_gate2:
+ in al,0x64
+ and al,2
+ jnz wait_gate2
+ mov al,0x0FE
+ out 0x60,al
+
+ /* trigger triple fault, by writing to cr4 */
+
+ mov rax, 0
+ lidt [rax]
+
+reset_wait:
+ jmp reset_wait
+
+.global boot_write_cr3
+.global boot_read_cr3
+
+boot_read_cr3:
+ mov rax, rax
+ ret
+
+boot_write_cr3:
+ mov cr3, rcx
+ ret