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

updated xorg-libXrender and xorg-libXrender-dev (0.9.8 -> 0.9.10)
author Hans-G?nter Theisgen
date Mon Nov 11 17:24:23 2019 +0100 (2019-11-11)
parents f25cb816bdd9
children e7373d3e0818
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 overflow db "Out of memory",0
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:struct himem *m);
100 ;***************************************************************
102 global @moverm$qp11image_himem:near
103 @moverm$qp11image_himem:
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_high:byte
115 test [_pm_high],cl
116 je @zimage
117 extrn _cpu386:byte
118 test [_cpu386],cl
119 jne @bzimage
120 mov bx,offset bzimage86
121 jmp godie
122 @zimage:
123 xchg ax,dx
124 cmp ax,cx
125 jae @sys@ok
126 xchg ax,cx
127 @sys@ok:
128 inc ax
129 extrn N_LXLSH@4:near
130 call N_LXLSH@4
131 mov [word ((image_himem bx).fallback)],ax
132 mov [word ((image_himem bx).fallback)+2],dx
133 add ax,[word ((image_himem bx).size)]
134 adc dx,[word ((image_himem bx).size)+2]
135 ifdef MOVE_SETUP
136 mov di,8000h
137 sub di,[bx-4] ; rm size
138 extrn _rm_offset:word
139 mov [_rm_offset],di
140 sub ax,di ; -rm_offset
141 sbb dx,cx
142 endif
143 mov cl,12
144 shl dx,cl
145 jc @overflow
146 @bzimage:
147 extrn _topseg:near
148 call near _topseg
149 mov [word sssp+2],ax
150 and ch,0
151 org $-1
152 global _vcpi:byte
153 _vcpi db ?
154 else
155 p386
156 movzx eax,[word _heap_top]
157 shr ax,4
158 mov dx,cs
159 add ax,dx
160 mov cx,0fffh
161 extrn _pm_high:byte
162 test [_pm_high],cl
163 jne @bzimage
164 cmp ax,cx
165 jae @sys@ok
166 xchg ax,cx
167 @sys@ok:
168 inc ax
169 shl eax,4
170 mov [(image_himem bx).fallback],eax
171 add eax,[(image_himem bx).size]
172 ifdef MOVE_SETUP
173 mov di,8000h
174 sub di,[bx-4] ; rm size
175 extrn _rm_offset:word
176 mov [_rm_offset],di
177 movzx ecx,di ; -rm_offset
178 sub eax,ecx
179 endif
180 shl eax,4
181 mov ch,0
182 @bzimage:
183 xchg ax,dx
184 mov ax,9000h
185 extrn _vcpi:byte
186 and ch,[_vcpi]
187 endif
188 add dh,ch ; room for malloc_bufv_or_die
189 cmp dx,ax
190 jb @nooverflow
191 @overflow:
192 ; Oops! We can stomp on our toes... better stop now
193 mov bx,offset overflow
194 godie:
195 call near die
196 @nooverflow:
197 les cx,[bx-4] ; rm size
198 mov si,es ; rm data
199 mov es,ax
200 @@move_clear:
201 movsb
202 mov [byte si-1],al
203 loop @@move_clear
204 ;push ds
205 ;pop es
206 ;pop di si
207 pop di
209 ;***************************************************************
210 ;void enable_a20_or_die();
211 ;***************************************************************
212 proc _enable_a20_or_die near
214 ;push si
215 mov si,offset enable_a20_methods
216 jmp @@check
217 @@loop:
218 lodsw
219 mov bx,offset msg_a20
220 call ax
221 @@check:
222 ;call _check_a20
223 ;***************************************************************
224 ;int check_a20();
225 ;***************************************************************
226 ;proc _check_a20 near
228 ; From linux kernel setup.S:
229 ; wait until a20 really *is* enabled; it can take a fair amount of
230 ; time on certain systems; Toshiba Tecras are known to have this
231 ; problem.
233 push ds
234 xor bx,bx
235 mov ds,bx
236 mov cx,0FFFFh
237 mov es,cx
238 a20lp:
239 cli
240 mov ax,0AA55h
241 xchg al,[bx]
242 xchg ah,[es:bx+10h]
243 xchg al,[bx]
244 xchg ah,[es:bx+10h]
245 cmp al,55h
246 sti
247 a20ko:
248 loopne a20lp
249 ;xchg ax,cx
250 pop ds
251 ;ret
253 ;endp _check_a20
255 jne @@loop
256 ;push ds
257 ;pop es
258 pop si
259 ret
261 endp _enable_a20_or_die
263 ends _TEXT
265 end
267 ;###### END OF FILE ############################################