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

linld/tazboot: default conf in tazboot.cmd
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Dec 06 18:49:44 2016 +0100 (2016-12-06)
parents
children 23fc786c04e8
line source
1 ;***************************************************************
2 ;****** This file is distributed under GPL
3 ;***************************************************************
4 ideal
5 %crefref
6 %noincl
7 %nomacs
8 p386
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 enable A20",0
20 ends _DATA
22 segment _TEXT byte public use16 'CODE'
24 global xmm_driver:near
25 global _enable_a20_xmm:near
27 ;***************************************************************
28 ;void enable_a20_kbd();
29 ;***************************************************************
30 proc _enable_a20_kbd near
32 call @@empty_8042
33 mov al,0D1h ; command write
34 out 64h,al
35 call @@empty_8042
36 mov al,0DFh ; A20 on
37 out 60h,al
39 ; This routine checks that the keyboard command queue is empty
40 ; (after emptying the output buffers)
41 ; Some machines have delusions that the keyboard buffer is always full
42 ; with no keyboard attached...
43 ; If there is no keyboard controller, we will usually get 0xff
44 ; to all the reads. With each IO taking a microsecond and
45 ; a timeout of 100,000 iterations, this can take about half a
46 ; second ("delay" == out to port 0x80). That should be ok,
47 ; and should also be plenty of time for a real keyboard controller
48 ; to empty.
50 @@empty_8042:
51 xor cx,cx ; 64K iterations
52 @@loop:
53 call @@delay ; 8042 status port
54 in al,64h ; output buffer?
55 test al,1 ;
56 jz @@no_output
57 call @@delay ; yes: read it
58 in al,60h ;
59 jmp @@cont ;
60 @@no_output:
61 test al,2 ; is input buffer full?
62 jz @@break ; no - break loop
63 @@cont:
64 loop @@loop
65 @@break:
66 ret
68 @@delay: out 80h,al
69 ret
71 endp _enable_a20_kbd
73 ;***************************************************************
74 ;void enable_a20_fast();
75 ;***************************************************************
76 proc _enable_a20_fast near
78 ; You must preserve the other bits here. Otherwise embarrasing things
79 ; like laptops powering off on boot happen. Corrected version by Kira
80 ; Brown from Linux 2.2
81 in al,92h ;
82 or al,02h ; "fast A20" version
83 out 92h,al ; some chips have only this
84 ret
86 endp _enable_a20_fast
88 ;***************************************************************
89 ;int check_a20();
90 ;***************************************************************
91 proc _check_a20 near
93 ; From linux kernel setup.S:
94 ; wait until a20 really *is* enabled; it can take a fair amount of
95 ; time on certain systems; Toshiba Tecras are known to have this
96 ; problem.
98 push ds es
99 xor bx,bx
100 mov ds,bx
101 mov cx,0FFFFh
102 mov es,cx
103 a20lp:
104 cli
105 mov ax,0AA55h
106 xchg al,[bx]
107 xchg ah,[es:bx+10h]
108 xchg al,[bx]
109 xchg ah,[es:bx+10h]
110 cmp al,55h
111 sti
112 a20ko:
113 loopne a20lp
114 xchg ax,cx
115 pop es ds
116 ret
118 endp _check_a20
120 ;***************************************************************
121 ;void enable_a20_or_die();
122 ;***************************************************************
123 global _enable_a20_or_die:near
124 proc _enable_a20_or_die near
126 push si
127 mov si,offset enable_a20_methods
128 jmp @@check
129 @@loop:
130 lodsw
131 mov bx,offset msg_a20
132 call ax
133 @@check:
134 call _check_a20
135 jne @@loop
136 pop si
137 ret
139 endp _enable_a20_or_die
141 ends _TEXT
143 end
145 ;###### END OF FILE ############################################