rev |
line source |
pascal@19515
|
1 ;***************************************************************
|
pascal@19515
|
2 ;****** This file is distributed under GPL
|
pascal@19515
|
3 ;***************************************************************
|
pascal@19515
|
4 ideal
|
pascal@21984
|
5 %PAGESIZE 1000
|
pascal@19515
|
6 %crefref
|
pascal@19515
|
7 %noincl
|
pascal@19515
|
8 %nomacs
|
pascal@19636
|
9 p8086
|
pascal@19515
|
10
|
pascal@24019
|
11 include "common.inc"
|
pascal@24019
|
12
|
pascal@19515
|
13 group DGROUP _TEXT,_DATA
|
pascal@19515
|
14 assume cs:DGROUP,ds:DGROUP
|
pascal@19515
|
15
|
pascal@19515
|
16 segment _DATA byte public use16 'DATA'
|
pascal@19515
|
17
|
pascal@19515
|
18 global die:near
|
pascal@19515
|
19 enable_a20_methods:
|
pascal@19515
|
20 dw _enable_a20_fast, _enable_a20_kbd, _enable_a20_xmm, die
|
pascal@23996
|
21 msg_a20 db "A20 broken",0
|
pascal@22668
|
22 extrn overflow:byte
|
pascal@22183
|
23 ifdef NO386
|
pascal@23996
|
24 bzimage86 db "8086 "
|
pascal@22183
|
25 endif
|
pascal@23996
|
26 global _bzimagestr:byte
|
pascal@23996
|
27 _bzimagestr db "bzImage",0
|
pascal@21758
|
28 global sssp:dword
|
pascal@21758
|
29 global _initrd_desc:dword
|
pascal@21758
|
30 _initrd_desc dd 90000218h
|
pascal@21758
|
31 org $-4
|
pascal@21758
|
32 sssp dd ?
|
pascal@19515
|
33
|
pascal@19515
|
34 ends _DATA
|
pascal@19515
|
35
|
pascal@19515
|
36 segment _TEXT byte public use16 'CODE'
|
pascal@19515
|
37
|
pascal@19515
|
38 global xmm_driver:near
|
pascal@19515
|
39 global _enable_a20_xmm:near
|
pascal@19515
|
40
|
pascal@19515
|
41 ;***************************************************************
|
pascal@19515
|
42 ;void enable_a20_kbd();
|
pascal@19515
|
43 ;***************************************************************
|
pascal@19515
|
44 proc _enable_a20_kbd near
|
pascal@19515
|
45
|
pascal@19515
|
46 call @@empty_8042
|
pascal@19515
|
47 mov al,0D1h ; command write
|
pascal@19515
|
48 out 64h,al
|
pascal@19515
|
49 call @@empty_8042
|
pascal@19515
|
50 mov al,0DFh ; A20 on
|
pascal@19515
|
51 out 60h,al
|
pascal@19515
|
52
|
pascal@19515
|
53 ; This routine checks that the keyboard command queue is empty
|
pascal@19515
|
54 ; (after emptying the output buffers)
|
pascal@19515
|
55 ; Some machines have delusions that the keyboard buffer is always full
|
pascal@19515
|
56 ; with no keyboard attached...
|
pascal@19515
|
57 ; If there is no keyboard controller, we will usually get 0xff
|
pascal@19515
|
58 ; to all the reads. With each IO taking a microsecond and
|
pascal@19515
|
59 ; a timeout of 100,000 iterations, this can take about half a
|
pascal@19515
|
60 ; second ("delay" == out to port 0x80). That should be ok,
|
pascal@19515
|
61 ; and should also be plenty of time for a real keyboard controller
|
pascal@19515
|
62 ; to empty.
|
pascal@19515
|
63
|
pascal@19515
|
64 @@empty_8042:
|
pascal@19515
|
65 xor cx,cx ; 64K iterations
|
pascal@19515
|
66 @@loop:
|
pascal@19515
|
67 call @@delay ; 8042 status port
|
pascal@19580
|
68 in al,64h
|
pascal@19580
|
69 test al,3 ; is output or input full?
|
pascal@19580
|
70 jz @@break ; no - break loop
|
pascal@19515
|
71 test al,1 ;
|
pascal@19515
|
72 jz @@no_output
|
pascal@19515
|
73 call @@delay ; yes: read it
|
pascal@19515
|
74 in al,60h ;
|
pascal@19515
|
75 @@no_output:
|
pascal@19515
|
76 loop @@loop
|
pascal@19515
|
77 @@break:
|
pascal@19515
|
78 ret
|
pascal@19515
|
79
|
pascal@19515
|
80 @@delay: out 80h,al
|
pascal@19515
|
81 ret
|
pascal@19515
|
82
|
pascal@19515
|
83 endp _enable_a20_kbd
|
pascal@19515
|
84
|
pascal@19515
|
85 ;***************************************************************
|
pascal@19515
|
86 ;void enable_a20_fast();
|
pascal@19515
|
87 ;***************************************************************
|
pascal@19515
|
88 proc _enable_a20_fast near
|
pascal@19515
|
89
|
pascal@19515
|
90 ; You must preserve the other bits here. Otherwise embarrasing things
|
pascal@19515
|
91 ; like laptops powering off on boot happen. Corrected version by Kira
|
pascal@19515
|
92 ; Brown from Linux 2.2
|
pascal@19515
|
93 in al,92h ;
|
pascal@19515
|
94 or al,02h ; "fast A20" version
|
pascal@19515
|
95 out 92h,al ; some chips have only this
|
pascal@19515
|
96 ret
|
pascal@19515
|
97
|
pascal@19515
|
98 endp _enable_a20_fast
|
pascal@19515
|
99
|
pascal@22180
|
100 include "himem.inc"
|
pascal@22180
|
101
|
pascal@19515
|
102 ;***************************************************************
|
pascal@22312
|
103 ;_fastcall void moverm(bx:u16 *p);
|
pascal@21757
|
104 ;***************************************************************
|
pascal@21757
|
105
|
pascal@22312
|
106 global @moverm$qpus:near
|
pascal@22312
|
107 @moverm$qpus:
|
pascal@21757
|
108 push si di
|
pascal@24013
|
109 xor di,di ; default setup 9000:0000
|
pascal@21757
|
110 extrn _heap_top:word
|
pascal@21757
|
111 ifdef NO386
|
pascal@22176
|
112 mov ax,[_heap_top]
|
pascal@22176
|
113 mov cl,4
|
pascal@22176
|
114 shr ax,cl
|
pascal@22176
|
115 mov dx,cs
|
pascal@23996
|
116 add dx,ax ; last used segment
|
pascal@22180
|
117 mov cx,0fffh
|
pascal@22288
|
118 extrn _pm_low:byte
|
pascal@22288
|
119 test [_pm_low],cl
|
pascal@22288
|
120 jne @zimage
|
pascal@22183
|
121 extrn _cpu386:byte
|
pascal@22183
|
122 test [_cpu386],cl
|
pascal@22180
|
123 jne @bzimage
|
pascal@24013
|
124 mov bx,offset bzimage86 ; no himem with 8086 !
|
pascal@22229
|
125 @godie:
|
pascal@22229
|
126 call near die
|
pascal@22183
|
127 @zimage:
|
pascal@22180
|
128 xchg ax,dx
|
pascal@22180
|
129 cmp ax,cx
|
pascal@22180
|
130 jae @sys@ok
|
pascal@23996
|
131 xchg ax,cx ; segment min 1000h
|
pascal@22180
|
132 @sys@ok:
|
pascal@24013
|
133 inc ax ; first free segment
|
pascal@22180
|
134 extrn N_LXLSH@4:near
|
pascal@22180
|
135 call N_LXLSH@4
|
pascal@22312
|
136 mov [word ((image_himem bx+4).fallback)],ax
|
pascal@22312
|
137 mov [word ((image_himem bx+4).fallback)+2],dx
|
pascal@22312
|
138 add ax,[word ((image_himem bx+4).size)]
|
pascal@22312
|
139 adc dx,[word ((image_himem bx+4).size)+2]
|
pascal@22180
|
140 ifdef MOVE_SETUP
|
pascal@22181
|
141 mov di,8000h
|
pascal@24013
|
142 sub di,[bx] ; rm_size
|
pascal@22181
|
143 extrn _rm_offset:word
|
pascal@22181
|
144 mov [_rm_offset],di
|
pascal@24013
|
145 sub ax,di ; -rm_offset
|
pascal@22180
|
146 sbb dx,cx
|
pascal@22180
|
147 endif
|
pascal@22180
|
148 mov cl,12
|
pascal@24013
|
149 shl dx,cl ; last sys segment
|
pascal@24013
|
150 ifndef LARGE_ZIMAGE
|
pascal@24013
|
151 ;jc @jbe_overflow ; >= 1Mb ???
|
pascal@24013
|
152 else
|
pascal@24013
|
153 ;jnc @bzimage ; < 1Mb
|
pascal@24013
|
154 ;mov dh,-1
|
pascal@24013
|
155 endif
|
pascal@22180
|
156 @bzimage:
|
pascal@21757
|
157 extrn _topseg:near
|
pascal@21757
|
158 call near _topseg
|
pascal@21757
|
159 mov [word sssp+2],ax
|
pascal@24019
|
160 ifdef VCPI
|
pascal@24013
|
161 and ch,0 ; vcpi flag
|
pascal@22183
|
162 org $-1
|
pascal@22183
|
163 global _vcpi:byte
|
pascal@22183
|
164 _vcpi db ?
|
pascal@24019
|
165 endif
|
pascal@21757
|
166 else
|
pascal@21757
|
167 p386
|
pascal@22180
|
168 movzx eax,[word _heap_top]
|
pascal@21757
|
169 shr ax,4
|
pascal@22176
|
170 mov dx,cs
|
pascal@23996
|
171 add ax,dx ; last used segment
|
pascal@22180
|
172 mov cx,0fffh
|
pascal@22288
|
173 extrn _pm_low:byte
|
pascal@22288
|
174 test [_pm_low],cl
|
pascal@22288
|
175 je @bzimage
|
pascal@22180
|
176 cmp ax,cx
|
pascal@22180
|
177 jae @sys@ok
|
pascal@23996
|
178 xchg ax,cx ; segment min 1000h
|
pascal@22180
|
179 @sys@ok:
|
pascal@24013
|
180 inc ax ; first free segment
|
pascal@22180
|
181 shl eax,4
|
pascal@22312
|
182 mov [(image_himem bx+4).fallback],eax
|
pascal@22312
|
183 add eax,[(image_himem bx+4).size]
|
pascal@22180
|
184 ifdef MOVE_SETUP
|
pascal@22181
|
185 mov di,8000h
|
pascal@24013
|
186 sub di,[bx] ; rm_size
|
pascal@22180
|
187 extrn _rm_offset:word
|
pascal@22181
|
188 mov [_rm_offset],di
|
pascal@24013
|
189 movzx ecx,di ; -rm_offset
|
pascal@22180
|
190 sub eax,ecx
|
pascal@22180
|
191 endif
|
pascal@24013
|
192 shr eax,4
|
pascal@24019
|
193 ifdef VCPI
|
pascal@22181
|
194 mov ch,0
|
pascal@24019
|
195 endif
|
pascal@22180
|
196 @bzimage:
|
pascal@22180
|
197 xchg ax,dx
|
pascal@22176
|
198 mov ax,9000h
|
pascal@24019
|
199 ifdef VCPI
|
pascal@22183
|
200 extrn _vcpi:byte
|
pascal@22183
|
201 and ch,[_vcpi]
|
pascal@21757
|
202 endif
|
pascal@24019
|
203 endif
|
pascal@24019
|
204 ifdef VCPI
|
pascal@23996
|
205 add dh,ch ; 60k room for malloc_bufv_or_die
|
pascal@24019
|
206 endif
|
pascal@22229
|
207 cmp ax,dx
|
pascal@24013
|
208 ifdef LARGE_ZIMAGE
|
pascal@24013
|
209 ja @nooverflow0
|
pascal@24013
|
210 extrn _cmdnum:dword
|
pascal@24013
|
211 base_himem = (dword _cmdnum+12)
|
pascal@24013
|
212 ifdef NO386
|
pascal@24013
|
213 les cx,[base_himem]
|
pascal@24013
|
214 mov [word ((image_himem bx+4).fallback)],cx
|
pascal@24013
|
215 mov [word ((image_himem bx+4).fallback)+2],es
|
pascal@24013
|
216 else
|
pascal@24013
|
217 mov ecx,[base_himem]
|
pascal@24013
|
218 mov [(image_himem bx+4).fallback],ecx
|
pascal@24013
|
219 endif
|
pascal@24013
|
220 @nooverflow0:
|
pascal@24013
|
221 endif
|
pascal@22312
|
222 les cx,[bx] ; rm_size
|
pascal@22312
|
223 mov si,es ; rm_buf
|
pascal@24013
|
224 ifndef LARGE_ZIMAGE
|
pascal@22229
|
225 @jbe_overflow:
|
pascal@21757
|
226 ; Oops! We can stomp on our toes... better stop now
|
pascal@21757
|
227 mov bx,offset overflow
|
pascal@22229
|
228 ifdef NO386
|
pascal@22229
|
229 jbe @godie
|
pascal@22229
|
230 else
|
pascal@22229
|
231 ja @nooverflow
|
pascal@21757
|
232 call near die
|
pascal@22180
|
233 @nooverflow:
|
pascal@22229
|
234 endif
|
pascal@24013
|
235 endif
|
pascal@22181
|
236 mov es,ax
|
pascal@22170
|
237 @@move_clear:
|
pascal@22170
|
238 movsb
|
pascal@22176
|
239 mov [byte si-1],al
|
pascal@22170
|
240 loop @@move_clear
|
pascal@21757
|
241 ;push ds
|
pascal@21757
|
242 ;pop es
|
pascal@21757
|
243 ;pop di si
|
pascal@21757
|
244 pop di
|
pascal@21757
|
245
|
pascal@21757
|
246 ;***************************************************************
|
pascal@19580
|
247 ;void enable_a20_or_die();
|
pascal@19580
|
248 ;***************************************************************
|
pascal@19580
|
249 proc _enable_a20_or_die near
|
pascal@19580
|
250
|
pascal@21757
|
251 ;push si
|
pascal@19580
|
252 mov si,offset enable_a20_methods
|
pascal@19580
|
253 jmp @@check
|
pascal@19580
|
254 @@loop:
|
pascal@19580
|
255 lodsw
|
pascal@19580
|
256 mov bx,offset msg_a20
|
pascal@19580
|
257 call ax
|
pascal@19580
|
258 @@check:
|
pascal@19580
|
259 ;call _check_a20
|
pascal@19580
|
260 ;***************************************************************
|
pascal@19515
|
261 ;int check_a20();
|
pascal@19515
|
262 ;***************************************************************
|
pascal@19580
|
263 ;proc _check_a20 near
|
pascal@19515
|
264
|
pascal@19515
|
265 ; From linux kernel setup.S:
|
pascal@19515
|
266 ; wait until a20 really *is* enabled; it can take a fair amount of
|
pascal@19515
|
267 ; time on certain systems; Toshiba Tecras are known to have this
|
pascal@19515
|
268 ; problem.
|
pascal@19515
|
269
|
pascal@21757
|
270 push ds
|
pascal@19515
|
271 xor bx,bx
|
pascal@19515
|
272 mov ds,bx
|
pascal@19515
|
273 mov cx,0FFFFh
|
pascal@19515
|
274 mov es,cx
|
pascal@19515
|
275 a20lp:
|
pascal@23996
|
276 cli ; A20 off A20 on
|
pascal@23996
|
277 mov ax,0AA55h ; al ah [bx] al ah [bx] es:[bx+10h]
|
pascal@23996
|
278 xchg al,[bx] ; ?? AA 55 ?1 AA 55 ?2
|
pascal@23996
|
279 xchg ah,[es:bx+10h] ; ?? 55 AA ?1 ?2 55 AA
|
pascal@23996
|
280 xchg al,[bx] ; AA 55 ?? 55 ?2 ?1 AA
|
pascal@19515
|
281 cmp al,55h
|
pascal@19515
|
282 sti
|
pascal@23996
|
283 loopne a20lp
|
pascal@23996
|
284 jne a20ko
|
pascal@23996
|
285 xchg ah,[es:bx+10h] ; AA ?? 55 55 AA ?1 ?2
|
pascal@19515
|
286 a20ko:
|
pascal@21757
|
287 ;xchg ax,cx
|
pascal@21757
|
288 pop ds
|
pascal@19580
|
289 ;ret
|
pascal@19515
|
290
|
pascal@19580
|
291 ;endp _check_a20
|
pascal@19515
|
292
|
pascal@19515
|
293 jne @@loop
|
pascal@21757
|
294 ;push ds
|
pascal@21757
|
295 ;pop es
|
pascal@19515
|
296 pop si
|
pascal@19515
|
297 ret
|
pascal@19515
|
298
|
pascal@19515
|
299 endp _enable_a20_or_die
|
pascal@19515
|
300
|
pascal@19515
|
301 ends _TEXT
|
pascal@19515
|
302
|
pascal@19515
|
303 end
|
pascal@19515
|
304
|
pascal@19515
|
305 ;###### END OF FILE ############################################
|