From 486425ed00acec134f8799bdde64bfd093c5fb55 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Thu, 26 Dec 2024 21:19:14 +0100 Subject: IMPL: A lot of new changes, see details. Signed-off-by: Amlal El Mahrouss --- dev/Boot/src/HEL/AMD64/BootAPI.S | 60 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 dev/Boot/src/HEL/AMD64/BootAPI.S (limited to 'dev/Boot/src/HEL/AMD64/BootAPI.S') 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 -- cgit v1.2.3