|
|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM
: }$ z: E- c- _6 R8 q) ^ - ;
+ D( b& m: m) Z* l+ d - ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01 [$ K, t& o9 w( W+ r# e
- ; ml A20ON.asm
; X# n' w, ~3 T, i - ; % w6 ^. F9 P2 Z- s0 ~
- .model tiny
0 R2 [5 y" D! t! w" }. y - .code
* l5 q2 L- G1 \7 `0 K# i - .486
: u6 L9 E, S& K: F' K3 T J - .startup
- ^( x, i' P' @' P! e - 8 U! f0 H& {$ Y4 A9 n, ~! Q. I, X
- mov dx, offset msg_author+ @/ R/ _4 u5 k7 e4 F- _2 a
- mov ah, 09h+ [' y9 l- V+ q( ^( u
- int 21h& v9 Z6 b j7 D( ~2 e
8 \! Y* @( `3 m Z$ w- mov dx, offset msg_fail ! ^, X+ N7 `$ f# F* u
- call A20_ENABLE' M' y- X' l2 N2 U6 M7 j$ Y3 Z
- jz exit1- l+ ] R- j& [$ j( l
- mov dx, offset msg_ok
7 f' E4 G& X$ n% ]0 X
: ~4 i) c* {& h; J$ |# H5 y- exit1: mov ah, 09h
9 x" Y1 j, Q! S6 \8 f* _ - int 21h + }+ e' ?' p( N+ _' J
- mov ax, 4C00h & V, e( N9 O+ Y* B9 k2 j) }5 M$ V
- int 21h
' @5 e( J( ?# D9 ?9 z$ t0 O -
4 e+ I; t1 H# w - msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,( p! c& l% p/ W% d
- "2008-07-01",13, 10, "$"
2 r! \& {4 |1 a$ _ p) \8 ~ - msg_ok db "A20 Enable OK", 13, 10, "$"
+ ], }3 N2 U% O3 I" | - msg_fail db "A20 Enable FAIL", 13, 10, "$"
1 V4 W* g% \; Q5 @( x( F: Q+ \! E
) O. p' Y1 B: R7 k$ r9 W. s- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
8 v2 Y: V4 |# B# |$ b" ~ - A20_ENABLE: 2 f4 G: j. B+ q' x- P, k+ I
- call A20Write 2 @# g0 U0 |! n' F+ Y% E2 M
- jz exit_enable
8 c% J7 ]: Y e6 Z6 O9 _
, Z9 Z. z& a; F5 L7 C- cli ; Only need for reading value from KBC
, v8 @" n- h n; ?- Y7 d - mov al, 0D0h ' J0 g6 P8 |* `/ @
- out 64h, al
/ b# Z0 B) t" d1 o) J/ ^ - call A20Read 2 W8 I8 q9 ?/ @. V
- jz enable_int P# h& W9 h% L0 v6 \
- s2 m# j5 T! M& h- in al, 60h ; Get current status 2 t o& i- k) Z
- mov ah, al 8 o+ ^6 g, h3 `1 e
- call A20Write # ]1 c C' p" s- P3 W: D- ~: N3 `
- enable_int: sti
8 `$ ]3 e1 z+ [; e - jz exit_enable8 p, k, T+ s% d
$ V, n7 t3 }( g- L0 d, O- mov al, 0D1h ; Tell the KBC , want to write to the 1 \5 ?5 ~' U% `/ Q- U8 ]" H5 \
- out 64h, al ; Out Put Port next ' D: p3 V1 ^4 i7 o: m7 F* V
- call A20Write
$ i9 `2 w& ]- I9 c* _0 s+ {, G - jz exit_enable* k5 }" w5 y& p; q# |
d# m' f# t/ r8 g, [: `! x: e# h- U- mov al, ah
+ v) Z! `0 u5 d# o - or al, 2 ; Enable line A20 8 K8 T+ A6 h1 B1 G: e+ i, k- d8 f0 K
- out 60h, al ( }5 x. W) L3 a* ^ V0 m
- call A20Write
) A# t- j; M9 r - jz exit_enable
0 _3 d v) O/ F: y% u; W5 W
9 h% b( u. f c) k- h6 r9 i5 d- mov al, 0FFh ; NOP
6 p2 q3 Q7 y5 _ T, Y; H4 {' b - out 64h, al
/ L/ r ?1 D3 A6 g9 z0 _1 W - call A20Write 5 j3 ]* K* y7 G/ l! @4 o
3 X$ e3 n4 W- \- w% |- exit_enable: ret 2 N; o* E! W' T8 }0 S4 U' m+ T% _
1 e& \& ~$ C+ @) i0 e- A20Write: xor cx, cx ; Reasonable wait
3 }" f' p, P' |2 C: q. J" X - get_wirte: in al, 64h ; Get KBC read status ; J1 ~4 j7 ?3 S; h
- test al, 02 ; See if buffer empty, bit 1 clear , |& D5 A, J* I( [! L3 ?
- jz clear ( Z0 D2 I0 Z& w
- dec cx 9 ?& v6 L- y/ x6 _( ~
- jz exit_write 1 r/ u1 r2 K% |+ y1 F- [
- jmp short get_wirte
/ x5 [& v$ Q$ J( n" W) H# t - clear: inc al ; Clear ZR
* {% T: l3 h$ e1 m: I: ^8 F h - exit_write: ret
; V% M. a6 y F, T M4 T
9 v" N/ ^" j8 l; T4 _# D- . g+ e! h& T& M0 F$ n! H t
- A20Read: xor cx, cx
9 W8 J1 O+ F2 \" b - get_read: in al, 64h 9 m& B1 g$ ]" [! b2 O$ `
- test al, 01 ; If the 'output buffer' is full, has . {1 M$ ~- g, M' d) Y5 E2 e
- jnz exit4 ; ... ; y) L; `5 Q1 H3 y
- dec cx ' D7 M7 S& M% F$ O5 ^
- jnz get_read+ O% _( U, |. O& L$ M2 |+ N
- exit4: ret ! B# n: S6 w9 l$ F0 o
-
4 k. { W/ `! t' f k: c - end
复制代码- ;A200FF.ASM
& ?! n. E& F' `2 b* p4 a( i$ X - ; ( c* e, x7 o; r0 H: V7 M/ g
- ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01
& e j5 _# t/ P' Y# E m - ; ml A20ON.asm
/ S3 N3 E+ W' |" s, Q1 E - ; 4 d7 |$ w# |* N6 R8 Y
- .model tiny
2 l9 }5 a7 _9 g; `2 ~" ` - .code
" B+ y3 p x* O$ ^ G; u, L0 i - .486
% U* \: Y7 s. C, d& M - .startup6 W- v* r" E( ?. M: W" U" Q
$ ?5 W7 v3 ~5 U! B- mov dx, offset msg_author
( L2 W. m& p9 e4 E) X' i" `0 M - mov ah, 09h3 t" L! F1 [7 H# |+ J, h+ j! @6 ?
- int 21h% |$ C/ x: H. b- |7 t9 I
- 4 }5 h% y! S3 b9 B# o" C
- mov dx, offset msg_fail
4 z# {/ B, s- Q6 M+ X" f4 w - call A20_DISABLE
) n+ S3 W) L1 F, |! i0 ^ - jz exit1
* r8 f9 `6 |* c B1 H( r& p8 j - mov dx, offset msg_ok % P8 T: E* X7 s- f7 w2 T$ G
$ I5 ~2 Q. }: J- exit1: mov ah, 09h / L* A; `+ e# s2 q. e1 ]- W
- int 21h : u- b1 ^8 X- |. J# e
- mov ax, 4C00h
6 D; x! X) G H X - int 21h 3 U. p" ^/ V' Y
-
) {* f! [1 B% x0 D) O6 o - msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,; S6 T+ P! J9 Y8 J- V
- "2008-07-01",13, 10, "$" * o1 q. L% {6 L. Q3 G0 d
- msg_ok db "A20 Disable OK", 13, 10, "$" W% g, g$ g% H9 I/ q
- msg_fail db "A20 Disable FAIL", 13, 10, "$"
4 d3 A' F1 S" ] - ! d5 c1 Y; M# W( L4 }( K" T2 Z
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
3 O+ d& N. H+ k$ r4 I% `, k - A20_DISABLE: 3 L1 ?8 J, h) p5 q) E0 A' y' N- z: ?
- call A20Write 4 N ?/ W, @ `% } U
- jz exit_disable8 c8 N% W. b6 n/ u. J7 b( _ G
- 1 \5 R8 C, p. L7 W- k! L* y
- cli ; Only need for reading value from KBC 7 j9 Y& f8 ]5 ~9 F) V9 p" I4 Z
- mov al, 0D0h
$ r; K9 N9 T& C8 i2 b2 G9 S, J% J - out 64h, al 7 p9 O. p9 d" y. Y
- call A20Read
2 s g! ?& a% c& J$ X% W+ O - jz Disable_int s) H L5 W. F; S; V" y
, C! L& s9 |" ?8 A2 r& c- in al, 60h ; Get current status
8 d5 F3 ~1 O& F - mov ah, al
5 H. H" Q! r! H5 i& S5 W. c9 ? - call A20Write
0 A/ p& ^- d# e% h - Disable_int: sti ) m+ {: `/ X0 E& x+ R
- jz exit_disable6 A' X" [% M! [1 R2 Z3 S3 A% Z
8 c. A8 G2 }1 I9 e- mov al, 0D1h ; Tell the KBC , want to write to the
( E6 @4 D* Y2 V4 t: [ - out 64h, al ; Out Put Port next
3 h- Q! h3 o8 { [& k6 y - call A20Write ' [+ Z. E% b( U# g
- jz exit_disable( D* _& X' K4 |8 F" k" X
2 o [' y. Q. t) S/ s( O0 c9 p- mov al, ah % X1 @" M: Z8 O. y8 ^* z
- and al, not 2 ; Disable line A20 7 J' B! ]( P s; [9 @- y
- out 60h, al - H9 g; l. q( k1 c, q; D2 L) d& G
- call A20Write 1 B* {3 l F4 F5 y
- jz exit_disable
. q6 q+ Q/ v8 i$ w9 n
5 k: p. E% X, R% \8 n9 E- mov al, 0FFh ; NOP
4 a) \2 c; D6 m0 |) @8 C - out 64h, al
, P/ _, z. L% C8 g+ R2 S2 m* w0 r - call A20Write 1 x( ]$ n n$ W3 a% m
. x/ [/ N T7 T, H3 Y L- exit_disable: ret
; h- K. h7 l) \& w: f
/ @ Y- \1 B; q& {" {- A20Write: xor cx, cx ; Reasonable wait
/ c% v, w$ c6 Y: G9 ~ - get_wirte: in al, 64h ; Get KBC read status ( P& ~! X; h. J( I M) `% s
- test al, 02 ; See if buffer empty, bit 1 clear 4 ?# b; K, L3 r7 I0 O' T) Q7 G- U' g
- jz clear & B, u( I% O8 |/ W( w; S
- dec cx
* U0 B: a& c2 s2 A2 i5 u6 w& z - jz exit_write
) A: T% f2 @6 \( R9 ~ - jmp short get_wirte 8 s: ]! d$ Q: `8 J
- clear: inc al ; Clear ZR
3 B- H- u0 _4 o2 H8 F, p8 } - exit_write: ret P; [& T+ t5 k5 h* Y
- 5 W8 s, _, J' G, Z h3 ?% ~
- 8 m3 U* v7 o3 J: \
- A20Read: xor cx, cx
7 x: `4 ]$ _- `% o$ ^% F% X' Y& H - get_read: in al, 64h
- K. i, X" S: B! N. T9 T - test al, 01 ; If the 'output buffer' is full, has
, g; b. Y8 a) ~8 L$ s - jnz exit4 ; ... ! ~+ F) v7 B% J
- dec cx , B0 \. e2 I8 f j! G; k( Y- j; Y' G
- jnz get_read; V' H1 I, T* C4 v
- exit4: ret
8 h* W; G9 m, L# r# I& w -
9 a( D/ N* F U& U% W7 b/ F - end
复制代码- ;A20STATE.ASM
; T- w: W" j2 L* r - ;
/ k. c @, K' ]" m - ; Returns the status of the line A20 through the KBC
* f" j$ `5 l9 O - ; programming by bini for debug. 2008-07-01/ x$ X$ {/ H5 N2 G% |8 I3 [# x' @1 y% y
- ; ) v" _8 E# `. |/ _0 e* h
- .model tiny' ?: g7 n3 H( v# n! K* l2 N) n8 d6 q9 y$ R
- .code
7 r: H2 U% c2 o - .486
: f0 P3 l5 s+ K, o+ O - .startup
8 A( H# r7 _5 p1 q+ E/ j - mov dx, offset msg_fail
8 b/ y3 C# N$ ^3 p) W - call _GET_A20_STATE_( p# K8 G0 r( g$ _7 ^. y
- jz exit1 ; was a problem
2 l3 C' x: l! k1 W0 B$ F3 o6 l - push ax ; Save state, AH ! G" K+ }% E6 J" A* s7 l! V
- mov dx, offset msg_ok ; There wasn't a problem
$ n% r& m- u' S/ i$ [ - mov ah, 09h 2 K& r/ Z9 t" K: x
- int 21h ; Print message ! t/ G1 ^+ a o
- pop ax ; retreve state 4 D g" s5 e9 o2 Z8 d
8 s9 p' R# \8 U! f- L. _" P7 x' T# d- mov dx, offset msg_dis $ T- S6 Y8 v2 l& n4 T$ P8 Z. M9 O
- and ah, 00000010b ; bit 1, 2h, indicates state
6 n) L9 O. b% A" M7 n - jz exit1 2 r; b9 `# A: _4 p! X a
- mov dx, offset msg_en
' c1 ]) U: H7 G* R: E$ n% B
1 d1 j! j6 _5 C' K- exit1: mov ah, 09h
: e! C9 [+ j7 a5 H - ; DX already contains address of string
6 w# k) A* W; c5 g2 O - int 21h
' S: `; l U% g2 \0 \. l
3 L- K3 `5 {1 O- mov ax, 4C00h 2 n h$ ^8 V* B* e
- int 21h
9 d3 H& @, s( e+ X - & `+ H' H0 h$ O( h6 |" V
- msg_ok db "OK", 13, 10, "A20 $" 3 T( v) v1 `* n
- msg_fail db "FAIL", 13, 10, "$" 5 u0 p& C+ r; Y! A5 ?- t
- msg_en db "ENABLED", 13, 10, "$"
# b3 m4 S% i. g l, [9 g2 ~ - msg_dis db "DISABLED", 13, 10, "$"9 i9 n2 f4 R# d R
# x/ I7 g, {% k- _3 B-
5 q. \; W% _" Y1 S - _GET_A20_STATE_: * H6 _7 D/ V0 L: s) A" a' ~% J
- call A20Write ; Wait till the input register is empty : v0 a8 m6 m% {1 [' W% D
- jz exit2+1 ; Bypas the reset int's
# |8 ~& _, X9 S# ` h - cli ; Disable ints so we'll get our value
2 H$ H9 B8 ]' S* B - * z! w% h" M; q6 y" n8 c2 X
- mov al, 0D0h ; Send command to the 8042 command register 1 ^7 x8 G7 Y: `+ S5 e
- out 64h, al ; to tell it we want to Read the Output Port
H! Q4 W/ x3 m0 E- u3 c2 R - call A20Read ; Wait till the 8042 output register
/ n& T0 _$ I& \5 w; m6 ]+ a0 S - jz exit2 ; has something in it's buffer
% y P+ N6 K* N1 p5 n
t- U% V4 V3 i! K2 @4 H- in al, 60h ; Get it ( ?( f" ]4 [- s* C$ Y* w6 c$ T9 f
- mov ah, al
. D( X8 {, \) J( E" `% w1 O5 f - call A20Write ; Make sure the input register is empty ' F0 X* W8 y, ?* S2 |9 k" Z
- jz exit2
! O& A- C. ^" n9 [6 o, ? - : J8 _. o8 |' X& V7 M; \. V/ ^
- mov al, 0FFh ; KBC NOP command, does nothing
+ z# w7 p4 _7 V3 n6 _ - out 64h, al ; z- [+ }) k2 f9 u! ^
- call A20Write
+ h# K2 E/ a1 U9 Q6 s5 r& W/ w* z- @
- d2 E" j2 U7 R' M- exit2: sti & B# {, ^, P7 H* B9 |8 @) }7 m* l
- ret
" _! J4 ]3 ], i _. j0 v
% [9 M3 h- A0 I2 O, y- 8 S5 N( A. E6 A! e4 p6 H
- A20Write: xor cx, cx ; Reasonable wait
& y% O q* r' O# U3 Q7 h; F - get1: in al, 64h ; Get KBC read status
9 K. O; ?5 V) V( T1 h |7 ?9 z1 p - test al, 02 ; See if buffer empty, bit 1 clear
: s5 C% K6 P R9 Y - jz clear
+ B8 y. F3 q1 L7 l6 O5 h3 c - dec cx $ c) w! `* t$ @* s2 I0 s( Q. v1 s& l
- jz exit3
4 i- T* F6 k4 T B) a% ?! I - jmp SHORT get1 4 z) _ E$ D# d9 G7 g7 S$ q
- clear: inc al ; Clear ZR $ n1 J, R7 r. ^) j* M# _: i( [
- exit3: ret
3 J+ }4 T) Y1 y - 1 t$ n% l, f, ]+ U( b
- 0 O# r4 w* S& s6 n" g9 l# a: w
- A20Read: xor cx, cx `0 y- D T. g7 [) _4 i. _
- get2: in al, 64h ! |8 y+ [; ~7 ]( ~
- test al, 01 ; If the 'output buffer' is full, has : O$ L4 X4 A7 A+ V
- jnz exit4 ; something for me
" L0 L0 K' D3 x" ]. d$ v - dec cx
9 @* S2 j& q$ T" m! A; X3 h" m0 J - jnz get2
% n( u$ L0 o( c5 A3 ` - exit4: ret
+ p. ~ e9 e" f -
% W+ V2 |8 n" |3 f! _+ { - end
复制代码 |
|