summaryrefslogtreecommitdiffhomepage
path: root/dev/ZBAKit/src/HEL/AMD64/BootAPI.S
diff options
context:
space:
mode:
authorAmlal <amlal.elmahrouss@icloud.com>2024-10-28 07:01:58 +0100
committerAmlal <amlal.elmahrouss@icloud.com>2024-10-28 07:01:58 +0100
commite0024d9ea688ee91a77abc0e28c5ea24b13ca67d (patch)
treea4e29bd919cbeccf2689e81a5d52bfc02f2a8b77 /dev/ZBAKit/src/HEL/AMD64/BootAPI.S
parent36a3600ff7fc65a63b7386b7a680dbe8e647bd8f (diff)
IMP: Refactor whole source code to make it even.
- That is because previously the source was both in lowercase and lettercase. Signed-off-by: Amlal <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/ZBAKit/src/HEL/AMD64/BootAPI.S')
-rw-r--r--dev/ZBAKit/src/HEL/AMD64/BootAPI.S52
1 files changed, 52 insertions, 0 deletions
diff --git a/dev/ZBAKit/src/HEL/AMD64/BootAPI.S b/dev/ZBAKit/src/HEL/AMD64/BootAPI.S
new file mode 100644
index 00000000..47f250f1
--- /dev/null
+++ b/dev/ZBAKit/src/HEL/AMD64/BootAPI.S
@@ -0,0 +1,52 @@
+.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
+ jmp rbx
+
+ 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