6 BOOT_GET_MEMORY_MAP equ 56
7 BOOT_EXIT_BOOT_SERVICES equ 232
14 ; args: RCX, RDX, R8, and R9.
19 lea rax, [mmap_descver]
23 mov rbx, [rax + BOOT_SERVICES]
24 call [rbx + BOOT_GET_MEMORY_MAP]
30 mov rbx, [rax + BOOT_SERVICES]
31 call [rbx + BOOT_EXIT_BOOT_SERVICES]
33 ; move code to absolute 1000h
36 sub rax, .after_call - start
37 mov rsi, rax ; source address
38 mov rdi, start ; destination
42 rep movsd ; copy code to make it absolute
49 ; switch to 32-bit compatibility long mode
70 DIV_9600 equ 115200 / 9600
73 FIFO_ENABLE_CLEAR equ 0x07
74 MCTL_DTR_RTS_OUT2 equ 0x0b
75 LST_TREG_EMPTY equ 0x20
93 ; clear and enable fifo
94 mov al, FIFO_ENABLE_CLEAR
98 mov al, MCTL_DTR_RTS_OUT2
114 mmapbuf: times 4096 db 0
116 str_hello db 'hello!',13,10,0
123 gdt: ; 0: null segment
125 ; 1: code - base:0, lim:4g, G:4k, 32bit, avl, pres|app, dpl:0, type:code/non-conf/rd
128 ; 2: data - base:0, lim:4g, G:4k, 32bit, avl, pres|app, dpl:0, type:data/rw
142 ; disable paging to deactivate long mode
147 ; disable long mode (EFER.LME = 0)
148 ; TODO: EFER is MSR c0000080, LME is bit 8
168 ; wait until transmit register is empty
171 and al, LST_TREG_EMPTY