[CMAKE]
[reactos.git] / reactos / boot / freeldr / freeldr / arch / realmode / helpers.inc
1
2 Empty8042:
3 .word 0x00eb,0x00eb // jmp $+2, jmp $+2
4 in al, 0x64
5 cmp al, 0xff // legacy-free machine without keyboard
6 jz Empty8042_ret // controllers on Intel Macs read back 0xFF
7 test al, 0x02
8 jnz Empty8042
9 Empty8042_ret:
10 ret
11
12 EnableA20:
13 pusha
14 call Empty8042
15 mov al, 0xD1 // command write
16 out 0x64, al
17 call Empty8042
18 mov al, 0xDF // A20 on
19 out 0x60, al
20 call Empty8042
21 popa
22 ret
23
24 /*
25 * writestr
26 * si = pointer to zero terminated string
27 */
28 writestr:
29 pushfd
30 pushad
31 writestr_top:
32 lodsb
33 and al, al
34 jz writestr_end
35 call writechr
36 jmp short writestr_top
37 writestr_end:
38 popad
39 popfd
40 ret
41
42 /*
43 * writechr
44 * al = character to output
45 */
46 writechr:
47 pushf
48 pusha
49 mov ah, 0x0E
50 xor bx, bx
51 int 0x10
52 popa
53 popf
54 ret
55
56 //
57 // writehex[248]: Write a hex number in (AL, AX, EAX) to the console
58 //
59 writehex2:
60 pushfd
61 pushad
62 shl eax, 24
63 mov cx, 2
64 jmp short writehex_common
65 writehex4:
66 pushfd
67 pushad
68 shl eax, 16
69 mov cx, 4
70 jmp short writehex_common
71 writehex8:
72 pushfd
73 pushad
74 mov cx, 8
75 writehex_common:
76 .loop:
77 rol eax, 4
78 push eax
79 and al, HEX(0F)
80 cmp al, 10
81 jae .high
82 .low:
83 add al, '0'
84 jmp short .ischar
85 .high:
86 add al, 'A'-10
87 .ischar:
88 call writechr
89 pop eax
90 loop .loop
91 popad
92 popfd
93 ret
94
95 SoftReboot:
96 mov ax, HEX(40)
97 mov ds, ax
98 mov si, HEX(72)
99
100 /* Set the word at location 40:72 to 1234h */
101 mov word ptr [si], HEX(1234)
102
103 /* and jump to location FFFF:0 in ROM */
104 ljmp16 HEX(0FFFF), HEX(0000)