Fix remaining text file line endings in the tree. (#18)
[reactos.git] / boot / freeldr / freeldr / arch / realmode / helpers.inc
1
2 Empty8042:
3 .word HEX(00eb), HEX(00eb) // jmp $+2, jmp $+2
4 in al, HEX(64)
5 cmp al, HEX(0ff) // legacy-free machine without keyboard
6 jz Empty8042_ret // controllers on Intel Macs read back 0xFF
7 test al, 2
8 jnz Empty8042
9 Empty8042_ret:
10 ret
11
12 EnableA20:
13 pusha
14 call Empty8042
15 mov al, HEX(0D1) // command write
16 out HEX(064), al
17 call Empty8042
18 mov al, HEX(0DF) // A20 on
19 out HEX(060), 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, HEX(0E)
50 xor bx, bx
51 int HEX(10)
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 Reboot:
96 cli
97
98 /* Set the word at location 40h:72h to 0 (cold reboot) */
99 mov word ptr ds:[HEX(0472)], HEX(0)
100
101 /* and jump to location F000h:FFF0h in ROM */
102 ljmp16 HEX(0F000), HEX(0FFF0)
103
104
105 ChainLoadBiosBootSectorCode:
106 /* Load segment registers */
107 cli
108 xor ax, ax
109 mov ds, ax
110 mov es, ax
111 mov fs, ax
112 mov gs, ax
113 mov ss, ax
114 mov esp, HEX(7C00)
115
116 /* Jump to the bootsector code */
117 ljmp16 HEX(0000), HEX(7C00)