wok view linld/stuff/src/A20.ASM @ rev 23471

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