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

linld/iso2exe: remove non slitaz dos boot
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Aug 10 18:47:30 2019 +0200 (2019-08-10)
parents 2373992ff751
children 6e3d30b3031f
line source
1 ;***************************************************************
2 ;****** This file is distributed under GPL
3 ;***************************************************************
4 ideal
5 %crefref
6 %noincl
7 %nomacs
8 p8086
10 group DGROUP _TEXT,_DATA
11 assume cs:DGROUP,ds:DGROUP
13 segment _DATA byte public use16 'DATA'
15 global die:near
16 enable_a20_methods:
17 dw _enable_a20_fast, _enable_a20_kbd, _enable_a20_xmm, die
18 msg_a20 db "Can't use A20",0
19 overflow db "Loaded too close to 9000:0",0
20 global sssp:dword
21 global _initrd_desc:dword
22 _initrd_desc dd 90000218h
23 org $-4
24 sssp dd ?
26 ends _DATA
28 segment _TEXT byte public use16 'CODE'
30 global xmm_driver:near
31 global _enable_a20_xmm:near
33 ;***************************************************************
34 ;void enable_a20_kbd();
35 ;***************************************************************
36 proc _enable_a20_kbd near
38 call @@empty_8042
39 mov al,0D1h ; command write
40 out 64h,al
41 call @@empty_8042
42 mov al,0DFh ; A20 on
43 out 60h,al
45 ; This routine checks that the keyboard command queue is empty
46 ; (after emptying the output buffers)
47 ; Some machines have delusions that the keyboard buffer is always full
48 ; with no keyboard attached...
49 ; If there is no keyboard controller, we will usually get 0xff
50 ; to all the reads. With each IO taking a microsecond and
51 ; a timeout of 100,000 iterations, this can take about half a
52 ; second ("delay" == out to port 0x80). That should be ok,
53 ; and should also be plenty of time for a real keyboard controller
54 ; to empty.
56 @@empty_8042:
57 xor cx,cx ; 64K iterations
58 @@loop:
59 call @@delay ; 8042 status port
60 in al,64h
61 test al,3 ; is output or input full?
62 jz @@break ; no - break loop
63 test al,1 ;
64 jz @@no_output
65 call @@delay ; yes: read it
66 in al,60h ;
67 @@no_output:
68 loop @@loop
69 @@break:
70 ret
72 @@delay: out 80h,al
73 ret
75 endp _enable_a20_kbd
77 ;***************************************************************
78 ;void enable_a20_fast();
79 ;***************************************************************
80 proc _enable_a20_fast near
82 ; You must preserve the other bits here. Otherwise embarrasing things
83 ; like laptops powering off on boot happen. Corrected version by Kira
84 ; Brown from Linux 2.2
85 in al,92h ;
86 or al,02h ; "fast A20" version
87 out 92h,al ; some chips have only this
88 ret
90 endp _enable_a20_fast
92 ;***************************************************************
93 ;_fastcall void moverm(bx:struct himem *m);
94 ;***************************************************************
96 global @moverm$qp11image_himem:near
97 @moverm$qp11image_himem:
98 push si di
99 extrn _heap_top:word
100 ifdef NO386
101 extrn _topseg:near
102 call near _topseg
103 mov cl,4
104 mov [word sssp+2],ax
105 xchg ax,dx
106 mov ax,[_heap_top]
107 shr ax,cl
108 else
109 p386
110 mov ax,[_heap_top]
111 shr ax,4
112 mov dx,9000h
113 endif
114 mov es,dx
115 mov cx,cs
116 add ax,cx
117 cmp ax,dx
118 jb @@nooverflow
119 ; Oops! We can stomp on our toes... better stop now
120 mov bx,offset overflow
121 call near die
122 @@nooverflow:
123 mov cx,[bx-5] ; size
124 mov si,[bx-2] ; data
125 xor di,di
126 rep
127 movsb
128 ;push ds
129 ;pop es
130 ;pop di si
131 pop di
133 ;***************************************************************
134 ;void enable_a20_or_die();
135 ;***************************************************************
136 proc _enable_a20_or_die near
138 ;push si
139 mov si,offset enable_a20_methods
140 jmp @@check
141 @@loop:
142 lodsw
143 mov bx,offset msg_a20
144 call ax
145 @@check:
146 ;call _check_a20
147 ;***************************************************************
148 ;int check_a20();
149 ;***************************************************************
150 ;proc _check_a20 near
152 ; From linux kernel setup.S:
153 ; wait until a20 really *is* enabled; it can take a fair amount of
154 ; time on certain systems; Toshiba Tecras are known to have this
155 ; problem.
157 push ds
158 xor bx,bx
159 mov ds,bx
160 mov cx,0FFFFh
161 mov es,cx
162 a20lp:
163 cli
164 mov ax,0AA55h
165 xchg al,[bx]
166 xchg ah,[es:bx+10h]
167 xchg al,[bx]
168 xchg ah,[es:bx+10h]
169 cmp al,55h
170 sti
171 a20ko:
172 loopne a20lp
173 ;xchg ax,cx
174 pop ds
175 ;ret
177 ;endp _check_a20
179 jne @@loop
180 ;push ds
181 ;pop es
182 pop si
183 ret
185 endp _enable_a20_or_die
187 ends _TEXT
189 end
191 ;###### END OF FILE ############################################