aboutsummaryrefslogtreecommitdiff
path: root/boot.s
blob: 3f3457a002d0177004572428e1147ca65ca4d861 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
bits 64

section .text
    org 0x0

_start:
    ; EFI System Table magic
    mov rax, 0x5453595320494249
    cmp rax, [rdx]

    mov rdi, 0x1
    jne fail			; Invalid magic

;    mov r8, rax
;    add r8, 0x1c
;    mov word [rax+0x10], 0xfff
;    mov qword [rax+0x12], r8
;
;    xor rcx, rcx
;zero:
;    mov qword [r8+rcx], 0x0
;    add rcx, 0x8
;    cmp rcx, 0xfff
;    jle zero
;
;    lea r8, [rel int]
;    mov word [rax+0x1c], r8w  ; offset_1
;    shr r8, 16
;    mov word [rax+0x1e], 0    ; selector
;    mov byte [rax+0x20], 0    ; ist
;    mov byte [rax+0x21], 0xff ; type_attr
;    mov word [rax+0x22], r8w  ; offset_2
;    shr r8, 16
;    mov dword [rax+0x24], r8d ; offset_3
;    mov dword [rax+0x28], 0   ; reserved, SBZ
;
;    cli
;    lidt [rax+16]
;    sti

    ;int 0x0

    push rbp
    mov rbp, rsp
    sub rsp, 0x30

    mov rbx, rdx

hello:
    mov rcx, qword [rdx+0x40]	; arg0=ConOut
    lea rdx, [rel msg]		; arg1=msg
    call qword [rcx+0x8]	; OutputString

    mov rdi, 0x0		; EFI_SUCCESS

fail: ; error in rdi
    mov rax, rdi
    mov rsp, rbp
    pop rbp
    retn

msg: db __utf16__ 'Hello, World',0xd,0,0xa,0,0,0

; int:
;     lea rax, [rel end]
;     mov rdx, qword [rax+8]
; 
;     mov rcx, qword [rdx+0x40]	; arg0=ConOut
;     lea rdx, [rel err]		; arg1=err
;     call qword [rcx+0x8]	; OutputString
; 
;     iretq

align 0x20

end: