|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM
% M' _8 b K6 }/ x$ j( [ - ;
+ n# y' h$ x8 z( d" u - ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01$ _7 Y/ L) f6 @/ C
- ; ml A20ON.asm
, q6 n( }) R+ n8 R& t+ R - ;
7 T! L9 n; d" \2 y# l% O" z$ Z* @5 d - .model tiny$ K. t* b' m) a- S
- .code' k+ {- f, t- I. m5 a
- .486$ f! b3 S9 x' L. J7 Y3 e! N: x
- .startup. L4 Q) @# a. S w: k
- : E& w J- p. }, [ w
- mov dx, offset msg_author4 M$ L0 L" k& A2 [
- mov ah, 09h
) F' ?" l1 f1 e4 N - int 21h2 A& z+ i! T$ ^5 V
- 4 L8 P- ~, ~7 p2 i* U9 D# j5 @' p- {
- mov dx, offset msg_fail
/ G: f. D1 D2 r: _: | - call A20_ENABLE2 P7 ~3 N; ^ W! i( ?
- jz exit1
o5 G/ N( H, M7 H+ Z# q - mov dx, offset msg_ok % P3 d, _" k* v, G5 Y; `8 E
e( N6 w) f/ o3 r- exit1: mov ah, 09h * d5 G, Q4 I7 [ S: k
- int 21h & m9 x1 J& U, z) D" h2 {
- mov ax, 4C00h
7 \) t9 v/ z% @* z3 h2 J - int 21h & H/ D* l, l! s8 [ O
-
5 d3 e8 j4 }/ H9 { - msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,; e% m, X0 y5 e* @
- "2008-07-01",13, 10, "$" % A1 p5 M5 ^2 T# K% a) m
- msg_ok db "A20 Enable OK", 13, 10, "$"
3 T, i- P( w, u, M - msg_fail db "A20 Enable FAIL", 13, 10, "$" . F- l! f! e2 d6 B
0 P5 n9 i# H6 G8 X' _ t) m$ H! `6 k- ;------------------------ follow code maybe make to lib, if you want...-------------------------------. {# D' W( U; u2 Z1 d, P
- A20_ENABLE: 2 q7 ?7 L5 c9 O% i! _ P: e; m
- call A20Write
$ C! m0 x/ p' c }( G! E - jz exit_enable/ {. e g2 i; ^
* W- A `" c: [! Y9 Y! P' R- cli ; Only need for reading value from KBC
- x4 l4 E# k3 c r* p+ L - mov al, 0D0h
) g6 k* ~, A+ P5 a6 @ - out 64h, al # o0 B0 d: }: r' J
- call A20Read
; F& Y7 z0 \, Q& B, R - jz enable_int % o g p9 p4 ~/ ~% d8 e5 [+ H
6 d: z! ?/ s! a3 E0 l9 |- in al, 60h ; Get current status
+ z4 d# B- N. \6 W% f - mov ah, al
7 x# [0 c5 H& a$ A - call A20Write R) m1 q, R$ y* x `' D* l! n8 J
- enable_int: sti
8 I: C' [, O# X - jz exit_enable9 |0 l" k& a1 v# I$ V4 I' b
- / U- ]% g- K' p) s. c
- mov al, 0D1h ; Tell the KBC , want to write to the
% [* d* }/ H( n( Q7 e. G) h - out 64h, al ; Out Put Port next
) f1 h, d/ [8 b; [7 B# L - call A20Write
) ?! o$ |$ B; V5 e - jz exit_enable
8 y. Y: f- ^$ A) R' r. D0 K
# J2 R8 O* i5 |, }% f" s* c, y- mov al, ah
7 u1 X2 T1 n/ j7 W4 z - or al, 2 ; Enable line A20 ! z6 T M' u. h* Q0 L! Q
- out 60h, al
6 W9 m1 A& \4 {, L3 Y3 ~ - call A20Write 0 L# U1 K3 l0 C" H
- jz exit_enable
0 Z) y; V( r0 x4 E& q
' H7 z; S+ n3 R" D; |1 y& C- mov al, 0FFh ; NOP l( U! Q% A$ x' i
- out 64h, al
$ i1 V* V. e' Z4 v, ^ - call A20Write 2 g- f. v! m3 S- I; m/ R5 u7 `9 d
- : A, L8 Z# x1 R6 C% n
- exit_enable: ret 3 k. a: _& \9 C0 M
- 6 k! u0 W3 h- a0 R+ a
- A20Write: xor cx, cx ; Reasonable wait
. k; `& |4 M; L/ ~$ ~: q - get_wirte: in al, 64h ; Get KBC read status 8 a0 s& m$ l3 q4 c& Y8 C+ C/ I
- test al, 02 ; See if buffer empty, bit 1 clear ( n7 _: w# q) b8 i ^( [: B6 Z+ c
- jz clear % e- F1 w9 F5 g. B
- dec cx
, |) R5 \9 @, W# L: x7 w - jz exit_write
# R! m7 I$ T7 I7 {- H3 A5 s7 L1 v+ Z+ k" K - jmp short get_wirte
) b& W+ Z% }; ^5 H! n) Z - clear: inc al ; Clear ZR $ C: o$ `9 M$ c
- exit_write: ret ' \0 [8 [: o; u1 x! j7 y" [
1 W6 V0 I+ c3 w* V G- ' F' {5 v! |0 K/ v) G; S
- A20Read: xor cx, cx 7 Y3 D% R, M/ S) L
- get_read: in al, 64h 4 l% i/ e/ L% {- X
- test al, 01 ; If the 'output buffer' is full, has ! [0 \+ `; `( {( D: m6 ?
- jnz exit4 ; ...
* H9 ~! W$ x7 ?3 W2 H9 y s' X% T - dec cx
& v6 P1 P2 i; |: w$ j+ u2 X - jnz get_read
1 D( r4 a1 x* z2 B+ `2 m. ?! [) x - exit4: ret , F* a7 f; V. `1 Z2 h$ Q a$ v
- 4 F+ w1 i$ [3 b
- end
复制代码- ;A200FF.ASM ' m9 C7 a/ n1 q: c
- ;
& G4 r7 y$ i# S( g+ v - ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01* n1 K% K+ T0 E
- ; ml A20ON.asm
0 ^ L! U8 T! r1 x - ;
) W8 J" R' m) f - .model tiny
/ C! m' m+ P! q5 r1 ]0 A7 M, Q - .code
3 D" Q7 Z$ r: o0 W5 \4 j. J3 \" j - .4866 u, D* K7 O+ g1 C) v
- .startup
$ d, K: O1 z5 r7 C
H) t" z. Q* h6 m- mov dx, offset msg_author0 q) L5 C! p& K4 V
- mov ah, 09h
6 F0 a! Y. |& j5 q9 @- w+ m - int 21h7 E; a$ @7 o+ [. J+ A% ^; Z
( T6 X6 `( h* F* e k- mov dx, offset msg_fail
* j* E I( H6 j; }% j" k: Y2 R' W - call A20_DISABLE
@, ]4 ~+ E/ Z: F8 W - jz exit1) T9 ]4 f" J3 [: R& K, W* G
- mov dx, offset msg_ok
* W* ]# Z; p& d# D - 4 X+ U- A3 x o: D/ `+ B1 y% o. q8 V
- exit1: mov ah, 09h ! K9 _3 t3 v! c- p- Q m7 J
- int 21h
& s: g* W7 |! H& D" s* `% ? - mov ax, 4C00h ! G. Z& S% N3 p- m: p6 D. e1 ]3 |
- int 21h ' @: s4 M. j0 B/ u
- ; F( d5 F8 z& j$ g. H. m! ~
- msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,
0 p) P+ p" v- }" O+ x - "2008-07-01",13, 10, "$"
& N: }6 h( q* b# A6 l# q - msg_ok db "A20 Disable OK", 13, 10, "$"
0 r2 i1 B0 R# P) H+ [ - msg_fail db "A20 Disable FAIL", 13, 10, "$"
: {1 j! P- u- B8 \( K3 w* d+ o - : W) y/ S6 p: [) M
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------& b9 z4 I0 _' @ p* k' `0 ^
- A20_DISABLE:
9 F' u+ M5 n( d2 L6 O - call A20Write
/ g0 I- b' i, ^" [ - jz exit_disable9 j/ Z7 ~% }9 {4 [
- / ^6 P( J3 ^9 ?/ H# a
- cli ; Only need for reading value from KBC . w& g! h$ I I4 W" p
- mov al, 0D0h - L. a! R+ Y3 v( |5 Z k
- out 64h, al
! P+ y9 g: ~: b, u2 o - call A20Read
0 f4 a, H3 f% s5 o& } - jz Disable_int . d8 c) v6 _3 z# T. o/ k% Q( @. l
- ( {& d* h3 O4 Y7 ?( |6 [) q
- in al, 60h ; Get current status 7 i% q% a/ ], i: Y# M0 Q( j. p
- mov ah, al : n( J6 n0 P- y. ~' M( K/ P" `' _
- call A20Write + i) c, f, K) r# Q2 Z! K6 {, i/ e1 [
- Disable_int: sti : n2 q$ m& D$ X9 R8 l8 M [# A6 O
- jz exit_disable3 h1 J9 c/ [7 y' f: C7 ?6 k
% i ?6 l1 \# K* D- mov al, 0D1h ; Tell the KBC , want to write to the
+ c8 V- n9 H+ K# k+ J2 d) @7 f, t - out 64h, al ; Out Put Port next - @9 Q! Y, R. E8 h) u
- call A20Write
1 E7 `( w8 `8 E. Z2 x3 a8 _& v - jz exit_disable/ h+ e! Q8 A" d; ^+ s" u1 I
: Z% y4 Y6 J! e4 k: i3 m- mov al, ah & l$ s j6 J$ M9 x& k1 ~ M$ Y
- and al, not 2 ; Disable line A20
) M4 _$ M/ P8 y' E; M1 | - out 60h, al
" }. h! d% U" { - call A20Write
' ^ H/ |- E, m) R, L. N F+ c - jz exit_disable
$ i8 j( a0 r5 x' u
: s: G) W5 R% J8 d- mov al, 0FFh ; NOP
& h! Q- |% D8 i2 l% x- l2 f# y; n - out 64h, al ' {0 _& g0 y6 g, }5 B+ J" f
- call A20Write 0 f8 p5 x" i0 s1 h( B- a
- / p1 Y3 I" x5 O( W! i
- exit_disable: ret 8 q( E, Q, M z/ G% s7 [
7 U- B4 a8 q/ y- A20Write: xor cx, cx ; Reasonable wait
. r a. Y1 l0 a - get_wirte: in al, 64h ; Get KBC read status ( j# }" f/ {0 x3 V g7 ?( w
- test al, 02 ; See if buffer empty, bit 1 clear ( E% K) ^. Z: R" [) |/ T6 u! ?
- jz clear
! B2 i$ |5 Q2 ^3 i! k% F - dec cx 8 F2 U( }6 a5 a9 P5 n
- jz exit_write 7 D8 W$ z4 a; L, C
- jmp short get_wirte : y( X1 }8 X. m, ^/ v
- clear: inc al ; Clear ZR ( Y' W7 N* ?& j) I
- exit_write: ret 1 {0 c# j7 c9 H( |
- 0 J# b) I0 Y3 H5 H" ]0 J
& A K9 Y, W0 ^ y" i1 b1 ]- A20Read: xor cx, cx
' f# C: X5 w. l+ p- f# `% r H" ^ - get_read: in al, 64h 1 g |& I& g v* Z4 \9 ]
- test al, 01 ; If the 'output buffer' is full, has
( Y# g x) \) H: |; E- \- m6 [' J - jnz exit4 ; ... 3 q8 B' z R$ Y2 h) {
- dec cx
9 o+ T4 G6 r) x! J! c$ ^& ^ - jnz get_read
; o: O8 c- j* P" j% }" O, r8 n - exit4: ret
- x! O2 P7 T+ Y& X! K - ' \) o2 F R6 v6 s8 ~4 C& P
- end
复制代码- ;A20STATE.ASM
5 P- Y6 w2 j7 V1 _ C - ; $ z5 k+ h" D/ ?) c0 X
- ; Returns the status of the line A20 through the KBC 8 j7 C5 G! F6 G1 \. ~9 d+ a4 @+ l
- ; programming by bini for debug. 2008-07-01# }) H6 h Z' b( m' B: y7 M1 _1 w
- ;
) O r6 O4 u2 `+ ] - .model tiny
# Q. N3 J# S5 x: \ - .code
! ?( K* U3 g1 a) Q |0 L - .486% p8 s, f; n; @
- .startup. A' m4 c$ T; ^% R
- mov dx, offset msg_fail
. [ [ \5 \% P. i - call _GET_A20_STATE_
, ?; y; L+ {5 Z1 B$ T - jz exit1 ; was a problem
% }+ E/ Q, I+ u2 }% }9 D- [7 @& @ - push ax ; Save state, AH / |$ O5 U `0 ]$ s2 T4 _$ | m* U+ k
- mov dx, offset msg_ok ; There wasn't a problem ' v# W% b0 l! f; P8 P8 N1 p5 V
- mov ah, 09h
- V* P) U W! H8 `1 j0 p- l( L2 ~ - int 21h ; Print message - t1 S0 a& w M" O5 H
- pop ax ; retreve state
# M8 T8 R: L, D - 0 R1 R: K8 H$ q. P* \
- mov dx, offset msg_dis
; v8 j2 S+ I* k8 N+ y# q - and ah, 00000010b ; bit 1, 2h, indicates state : j0 g7 y7 G5 ^$ @9 e
- jz exit1 , |8 ~7 x0 H& ~, I, n3 F C+ W
- mov dx, offset msg_en ' t# X/ w$ w p' n; h/ u" B. A
- 0 @8 F% j# |& k5 J# H
- exit1: mov ah, 09h
+ \7 K3 X. u" g6 K - ; DX already contains address of string , O g* k! X+ A5 |* u/ q
- int 21h
. B, G2 Q6 A: z! |7 h - " p2 `& f3 D2 V2 z2 G
- mov ax, 4C00h
4 K( Z8 M; {" k j( P3 z; f$ c, ] - int 21h
* K0 I- r' X) e3 m* g8 b
) V4 d+ [" ?) K& W3 J- msg_ok db "OK", 13, 10, "A20 $" 8 T7 T5 Z2 K, E& `. |* k0 t3 g
- msg_fail db "FAIL", 13, 10, "$" 8 A0 e0 U5 e7 b6 p9 L
- msg_en db "ENABLED", 13, 10, "$"
( u2 S2 A1 {0 M/ P1 d - msg_dis db "DISABLED", 13, 10, "$", H }5 u, x8 _, }' o
# N9 K) p2 j1 [/ }- , C: `) g7 L; O& ~# ^1 j/ c9 B
- _GET_A20_STATE_: 9 \. C% j! H9 G5 X6 i K
- call A20Write ; Wait till the input register is empty " c+ i) j4 t; e% N
- jz exit2+1 ; Bypas the reset int's 7 A8 r8 \+ c( f# B3 r
- cli ; Disable ints so we'll get our value ( B7 g& U- m/ ?2 x5 r) E2 W
$ N7 |. J: X) g0 r9 T- mov al, 0D0h ; Send command to the 8042 command register 6 r2 i7 V+ o) J
- out 64h, al ; to tell it we want to Read the Output Port
! L8 ~4 S% F8 Z7 H# _7 I( i5 R - call A20Read ; Wait till the 8042 output register
9 ? A. K7 j/ W& r$ {* k - jz exit2 ; has something in it's buffer
' ^" O8 A0 F8 v z& B
8 J1 q9 R* k6 U- in al, 60h ; Get it
' @# t2 [1 d* e6 M - mov ah, al
3 n9 ]1 y6 M* W# P" u - call A20Write ; Make sure the input register is empty 4 P2 [/ h- |5 u W/ I
- jz exit2
! J& l+ _! k' f, T, C - 3 f7 j; h# D2 a) r8 U7 U
- mov al, 0FFh ; KBC NOP command, does nothing $ ]" J; M& y% q" ?! d& D w5 L
- out 64h, al
, ~3 n8 `$ B% T5 V. z0 [# q: T - call A20Write $ J5 G" J: s2 y9 K! }
. I7 J: O) C+ }9 M* ^" G- exit2: sti
* }9 Y6 |: _( f `/ J$ V7 {; Z& A - ret# z R2 ~/ ^% @
- & B% E% ?6 L# u
0 b/ b- R4 z" x5 k; o3 e- A20Write: xor cx, cx ; Reasonable wait " O! [: T6 ]8 p7 _
- get1: in al, 64h ; Get KBC read status
- t. ~$ `+ W" u- C. q - test al, 02 ; See if buffer empty, bit 1 clear
3 E H! B3 s6 h8 C& ~4 ~* g. R - jz clear
, P6 S& n+ I7 n0 y - dec cx
3 x) G4 J" S' { - jz exit3 4 E2 }4 I7 D6 k# b& [& c8 T$ J
- jmp SHORT get1 4 p. [: E% h, y, |8 a
- clear: inc al ; Clear ZR
$ B( H3 G! q% A - exit3: ret
2 \' r$ _5 P+ D - + ]% y4 t4 L& L2 y) q
" C: u% e2 I& ?: u+ d4 _. j& w- T- A20Read: xor cx, cx
$ c* X! h! I" K. F2 } - get2: in al, 64h
$ i0 J2 `4 h" `7 ~ - test al, 01 ; If the 'output buffer' is full, has
3 B# M7 r, q) k, ]2 _) o, _ - jnz exit4 ; something for me
8 k( n; {1 t9 r9 k, R; {" x - dec cx : U# E3 q# J0 C% @
- jnz get2! n( n* q- X" n7 H8 i; Y$ }( K
- exit4: ret
1 E% Y1 }5 d$ ~8 Z: J -
3 a& b# Z7 G/ y: l3 B: } D6 t - end
复制代码 |
|