]> git.dujemihanovic.xyz Git - nameless-os.git/blob - boot/x86/stage3/a20.s
FAT32 bootloader boots the kernel
[nameless-os.git] / boot / x86 / stage3 / a20.s
1 %macro in_wait 0
2 push ax
3 %%loop:
4 in al, 0x64
5 test al, 2
6 jnz %%loop
7 pop ax
8 %endmacro
9
10 %macro out_wait 0
11 push ax
12 %%loop:
13 in al, 0x64
14 test al, 1
15 jz %%loop
16 pop ax
17 %endmacro
18
19 ; CF set = A20 enabled
20 check_a20:
21 push esi
22 push edi
23 push ax
24 mov esi, 0x500
25 mov edi, 0x100500
26
27 mov al, [esi]
28 mov ah, [edi]
29
30 mov [esi], byte 0
31 mov [edi], byte 0xff
32 cmp [esi], byte 0xff
33
34 mov [esi], al
35 mov [edi], ah
36
37 pop ax
38 pop edi
39 pop esi
40 ret
41
42 enable_a20:
43 push ax
44 mov ax, 0x2401
45 int 0x15
46 jc .i8042_method
47 call check_a20
48 jnc .i8042_method
49 pop ax
50 ret
51 .i8042_method:
52 in_wait
53 mov al, 0xad
54 out 0x64, al
55 in_wait
56 mov al, 0xd0
57 out 0x64, al
58 out_wait
59 in al, 0x60
60 or al, 2
61 push ax
62 in_wait
63 mov al, 0xd1
64 out 0x64, al
65 in_wait
66 pop ax
67 out 0x60, al
68 in_wait
69 mov al, 0xae
70 out 0x60, al
71 call check_a20
72 pop ax
73 ret
74