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