2021-04-07 03:10:28 +03:00
|
|
|
section .bss
|
|
|
|
|
|
|
|
user_stack:
|
|
|
|
resq 1
|
|
|
|
|
2021-04-13 22:48:09 +03:00
|
|
|
user_cs: resq 1
|
|
|
|
user_ds: resq 1
|
|
|
|
user_es: resq 1
|
|
|
|
user_ss: resq 1
|
|
|
|
|
2021-04-07 03:10:28 +03:00
|
|
|
section .text
|
|
|
|
|
|
|
|
extern term_write
|
2022-06-14 04:56:30 +03:00
|
|
|
extern limine_rt_stack
|
|
|
|
extern limine_term_callback_ptr
|
|
|
|
extern limine_term_write_ptr
|
2021-08-16 19:02:28 +03:00
|
|
|
|
2022-06-14 04:56:30 +03:00
|
|
|
global limine_term_callback
|
|
|
|
limine_term_callback:
|
2021-08-16 19:02:28 +03:00
|
|
|
bits 32
|
|
|
|
push ebp
|
|
|
|
mov ebp, esp
|
|
|
|
|
|
|
|
push ebx
|
|
|
|
push esi
|
|
|
|
push edi
|
2021-04-07 03:10:28 +03:00
|
|
|
|
2021-08-16 19:02:28 +03:00
|
|
|
; Go 64
|
|
|
|
push 0x28
|
|
|
|
push .mode64
|
|
|
|
retfd
|
2021-04-07 03:10:28 +03:00
|
|
|
bits 64
|
2021-08-16 19:02:28 +03:00
|
|
|
.mode64:
|
|
|
|
mov eax, 0x30
|
|
|
|
mov ds, ax
|
|
|
|
mov es, ax
|
|
|
|
mov ss, ax
|
|
|
|
|
|
|
|
mov rdi, [rbp + 8]
|
|
|
|
mov rsi, [rbp + 16]
|
|
|
|
mov rdx, [rbp + 24]
|
|
|
|
mov rcx, [rbp + 32]
|
2022-04-01 11:00:36 +03:00
|
|
|
mov r8, [rbp + 40]
|
2021-08-16 19:02:28 +03:00
|
|
|
|
|
|
|
mov rbx, rsp
|
|
|
|
mov rsp, [user_stack]
|
2022-06-14 04:56:30 +03:00
|
|
|
call [limine_term_callback_ptr]
|
2021-08-16 19:02:28 +03:00
|
|
|
mov rsp, rbx
|
|
|
|
|
|
|
|
; Go 32
|
|
|
|
push 0x18
|
|
|
|
push .mode32
|
|
|
|
retfq
|
|
|
|
bits 32
|
|
|
|
.mode32:
|
|
|
|
mov eax, 0x20
|
|
|
|
mov ds, ax
|
|
|
|
mov es, ax
|
|
|
|
mov ss, ax
|
|
|
|
|
|
|
|
pop edi
|
|
|
|
pop esi
|
|
|
|
pop ebx
|
|
|
|
pop ebp
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
2022-06-14 04:56:30 +03:00
|
|
|
global limine_term_write_entry
|
|
|
|
limine_term_write_entry:
|
2021-08-16 19:02:28 +03:00
|
|
|
bits 64
|
2021-04-07 03:10:28 +03:00
|
|
|
push rbx
|
|
|
|
push rbp
|
|
|
|
push r12
|
|
|
|
push r13
|
|
|
|
push r14
|
|
|
|
push r15
|
|
|
|
|
|
|
|
mov [user_stack], rsp
|
2022-06-14 04:56:30 +03:00
|
|
|
mov esp, [limine_rt_stack]
|
2021-04-07 03:10:28 +03:00
|
|
|
|
2021-04-13 22:48:09 +03:00
|
|
|
mov word [user_cs], cs
|
|
|
|
mov word [user_ds], ds
|
|
|
|
mov word [user_es], es
|
|
|
|
mov word [user_ss], ss
|
|
|
|
|
2022-04-02 11:05:14 +03:00
|
|
|
push rdx
|
2021-04-07 03:10:28 +03:00
|
|
|
push rsi
|
2021-08-16 19:02:28 +03:00
|
|
|
push rdi
|
2021-04-07 03:10:28 +03:00
|
|
|
|
|
|
|
push 0x18
|
|
|
|
push .mode32
|
|
|
|
retfq
|
|
|
|
bits 32
|
|
|
|
.mode32:
|
|
|
|
mov eax, 0x20
|
|
|
|
mov ds, ax
|
|
|
|
mov es, ax
|
|
|
|
mov ss, ax
|
2021-08-16 19:02:28 +03:00
|
|
|
|
2022-06-14 04:56:30 +03:00
|
|
|
call [limine_term_write_ptr]
|
2022-04-02 11:05:14 +03:00
|
|
|
add esp, 24
|
2021-08-16 19:02:28 +03:00
|
|
|
|
2021-04-13 22:48:09 +03:00
|
|
|
push dword [user_cs]
|
2021-04-07 03:10:28 +03:00
|
|
|
push .mode64
|
|
|
|
retfd
|
|
|
|
bits 64
|
|
|
|
.mode64:
|
2021-04-13 22:48:09 +03:00
|
|
|
mov ds, word [user_ds]
|
|
|
|
mov es, word [user_es]
|
|
|
|
mov ss, word [user_ss]
|
2021-04-07 03:10:28 +03:00
|
|
|
mov rsp, [user_stack]
|
|
|
|
|
|
|
|
pop r15
|
|
|
|
pop r14
|
|
|
|
pop r13
|
|
|
|
pop r12
|
|
|
|
pop rbp
|
|
|
|
pop rbx
|
|
|
|
|
|
|
|
ret
|