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

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