wok-6.x view linld/stuff/src/A20.ASM @ rev 20528
linld: pascal convention calls
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Fri Nov 09 16:37:55 2018 +0100 (2018-11-09) |
parents | 23fc786c04e8 |
children | 2373992ff751 |
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
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
55 test al,3 ; is output or input full?
56 jz @@break ; no - break loop
57 test al,1 ;
58 jz @@no_output
59 call @@delay ; yes: read it
60 in al,60h ;
61 @@no_output:
62 loop @@loop
63 @@break:
64 ret
66 @@delay: out 80h,al
67 ret
69 endp _enable_a20_kbd
71 ;***************************************************************
72 ;void enable_a20_fast();
73 ;***************************************************************
74 proc _enable_a20_fast near
76 ; You must preserve the other bits here. Otherwise embarrasing things
77 ; like laptops powering off on boot happen. Corrected version by Kira
78 ; Brown from Linux 2.2
79 in al,92h ;
80 or al,02h ; "fast A20" version
81 out 92h,al ; some chips have only this
82 ret
84 endp _enable_a20_fast
86 ;***************************************************************
87 ;void enable_a20_or_die();
88 ;***************************************************************
89 global _enable_a20_or_die:near
90 proc _enable_a20_or_die near
92 push si
93 mov si,offset enable_a20_methods
94 jmp @@check
95 @@loop:
96 lodsw
97 mov bx,offset msg_a20
98 call ax
99 @@check:
100 ;call _check_a20
101 ;***************************************************************
102 ;int check_a20();
103 ;***************************************************************
104 ;proc _check_a20 near
106 ; From linux kernel setup.S:
107 ; wait until a20 really *is* enabled; it can take a fair amount of
108 ; time on certain systems; Toshiba Tecras are known to have this
109 ; problem.
111 push ds es
112 xor bx,bx
113 mov ds,bx
114 mov cx,0FFFFh
115 mov es,cx
116 a20lp:
117 cli
118 mov ax,0AA55h
119 xchg al,[bx]
120 xchg ah,[es:bx+10h]
121 xchg al,[bx]
122 xchg ah,[es:bx+10h]
123 cmp al,55h
124 sti
125 a20ko:
126 loopne a20lp
127 xchg ax,cx
128 pop es ds
129 ;ret
131 ;endp _check_a20
133 jne @@loop
134 pop si
135 ret
137 endp _enable_a20_or_die
139 ends _TEXT
141 end
143 ;###### END OF FILE ############################################