long mode achieved, starting rust

This commit is contained in:
Jack Halford 2018-02-04 18:51:25 +01:00
parent 6411831e67
commit 687b609244
2 changed files with 31 additions and 0 deletions

View file

@ -1,4 +1,5 @@
global start global start
extern long_mode_start
section .text section .text
bits 32 bits 32
@ -12,6 +13,11 @@ start:
call set_up_page_tables call set_up_page_tables
call enable_paging call enable_paging
; load the 64-bit GDT
lgdt [gdt64.pointer]
jmp gdt64.code:long_mode_start
; print 'OK' to screen ; print 'OK' to screen
mov dword [0xb8000], 0x2f4b2f4f mov dword [0xb8000], 0x2f4b2f4f
hlt hlt
@ -138,3 +144,12 @@ p2_table:
stack_bottom: stack_bottom:
resb 64 resb 64
stack_top: stack_top:
section .rodata
gdt64:
dq 0 ; zero entry
.code: equ $ - gdt64
dq (1<<43) | (1<<44) | (1<<47) | (1<<53) ; code segment
.pointer:
dw $ - gdt64 - 1
dq gdt64

View file

@ -0,0 +1,16 @@
global long_mode_start
section .text
bits 64
long_mode_start:
; load 0 into all data segment registers
mov ax, 0
mov ss, ax
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
;print 'OKAY' to screen
mov rax, 0x2f592f412f4b2f4f
mov qword [0xb8000], rax
hlt