summaryrefslogtreecommitdiffhomepage
path: root/dev/ZBA/Sources/HEL/AMD64/BootAPI.S
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-09-04 12:56:23 +0200
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-09-04 12:56:23 +0200
commita0a90c80e5dd17df8f609aebc253b4bf9147f90f (patch)
tree459f98ea125db490e887bd85b38fd9165a9491b4 /dev/ZBA/Sources/HEL/AMD64/BootAPI.S
parentcc9ce57cac59bd443e2319e3b8f427172b93f7da (diff)
Created a new branch for the overhaul project.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/ZBA/Sources/HEL/AMD64/BootAPI.S')
-rw-r--r--dev/ZBA/Sources/HEL/AMD64/BootAPI.S47
1 files changed, 47 insertions, 0 deletions
diff --git a/dev/ZBA/Sources/HEL/AMD64/BootAPI.S b/dev/ZBA/Sources/HEL/AMD64/BootAPI.S
new file mode 100644
index 00000000..e391351d
--- /dev/null
+++ b/dev/ZBA/Sources/HEL/AMD64/BootAPI.S
@@ -0,0 +1,47 @@
+.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
+wait_gate1:
+ /* wait for gate 1 to be ready? */
+ in al,0x64
+ and al,2
+ jnz wait_gate1
+ mov al,0x0D1
+ out 0x64,al
+wait_gate2:
+ /* wait for gate 2 to be ready? */
+ in al,0x64
+ and al,2
+ jnz wait_gate2
+ mov al,0x0FE
+ out 0x60,al
+
+ /* trigger triple fault, by writing to cr4 */
+
+ xor rax,rax
+ mov cr4,rax
+reset_wait:
+ jmp reset_wait
+
+.global write_cr3
+
+write_cr3:
+ mov cr3, rcx
+ ret \ No newline at end of file