[SHELL32]
[reactos.git] / reactos / 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 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)
105
106
107 ChainLoadBiosBootSectorCode:
108
109 /* Load segment registers */
110 cli
111 xor ax, ax
112 mov ds, ax
113 mov es, ax
114 mov fs, ax
115 mov gs, ax
116 mov ss, ax
117 mov esp, HEX(7C00)
118
119 /* Jump to the bootsector code */
120 ljmp16 HEX(0000), HEX(7C00)