|
|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM
) R/ j+ ~+ g, @1 r4 h - ;
2 ~# G! z! s9 F. Z0 e - ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01
4 \+ J4 ^2 h3 T2 c- z/ i" ~ - ; ml A20ON.asm ! \8 W! c- \' u
- ;
* j- b0 f3 x( e$ N s" F- `/ \ ` - .model tiny
! y4 m, E6 }% M- B% H7 Y - .code! g1 M2 V( u; r
- .486; S8 Y1 q+ p; i; c% G+ i
- .startup- F, o+ u" W9 F* A$ O3 s$ A6 H
- - e! s/ M4 [ A; J, e
- mov dx, offset msg_author
9 L1 i6 p. }3 i( K. M3 s - mov ah, 09h5 T8 q* V- @% `7 F" m7 l
- int 21h$ { f9 T- D8 g9 s, x
- * {$ E4 g S- N+ \4 s8 L
- mov dx, offset msg_fail 4 t( `( [4 v1 N3 r- ?. @
- call A20_ENABLE3 u5 w$ m7 L2 }/ r, L
- jz exit1
, K9 k [2 e2 f/ T+ T - mov dx, offset msg_ok ' d- w' e+ t# d- H& W5 ~# u) i$ z
- % ~; Q1 y9 r: f+ p# U8 t# P
- exit1: mov ah, 09h
' t+ G H+ F$ Z. L$ x6 C& Z - int 21h ' Y& G/ j5 R0 ?, a" x8 F
- mov ax, 4C00h % Z( P% E, A! g& g3 r
- int 21h - T: I: O' _$ p0 h- x9 y" E$ r e
- . v( o! ]# j+ H: S2 ?6 b5 Z6 ] w$ g
- msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,
/ [ P3 g3 c+ P P - "2008-07-01",13, 10, "$" 4 W' ^4 f* I \) o5 w! r9 i
- msg_ok db "A20 Enable OK", 13, 10, "$"
* G' n9 E2 W2 Y! S* N0 }1 @ - msg_fail db "A20 Enable FAIL", 13, 10, "$"
+ S h- z" t T( M/ W/ O' \# u
2 U& d9 m; F. J( K% X9 z" W- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
: g, h9 P" U* `' d - A20_ENABLE:
" a$ i3 o2 i8 t& }) ~ - call A20Write
2 s1 I( W7 {3 R - jz exit_enable8 k3 _ }" ]% n& P, N. @$ [" c5 Q
L( r1 u- h3 ~% a; U- cli ; Only need for reading value from KBC
8 h% X; J. t$ c - mov al, 0D0h 9 V A* m6 J5 |7 R1 P
- out 64h, al 8 _. O% z) D! _) T8 R u$ {$ e9 q& @
- call A20Read
$ g' U# _- G+ a- k) Y4 F2 e - jz enable_int
, ~& l# j! U3 b H5 _
& s% h. |- I, K$ G: ~/ u; ~- in al, 60h ; Get current status
$ Z t; c Y* `5 A - mov ah, al " ^& N! Z5 f! x. k
- call A20Write 7 ^5 N5 T$ h3 g; w* u
- enable_int: sti
, S$ y" d0 u0 ?4 ?$ [2 M& B - jz exit_enable4 u* w) w# F% V' h
- ! e9 Z! v( W4 B4 i/ U& T2 I
- mov al, 0D1h ; Tell the KBC , want to write to the ) Y s4 f: M3 \& k0 @
- out 64h, al ; Out Put Port next
2 F" t( ?/ G" ?' H+ L7 a- U - call A20Write + Q- H; A$ D& p( C" l0 P
- jz exit_enable
1 B( J o, A- W% X# Z% g0 q* |3 K
8 b9 v* Z* o& q" }- mov al, ah
1 `6 u' m2 Z7 X - or al, 2 ; Enable line A20
1 J. z: Q' z2 \3 b( n5 v) _ - out 60h, al
/ ~: O8 \ M4 g2 K" M6 [( F. F( Z - call A20Write ; w( F. j1 g3 C$ a: O: v. w
- jz exit_enable
; S/ \( @& c0 |/ e6 p0 P+ D) }$ [! Q - & T1 t9 T7 t, i, Y; V r
- mov al, 0FFh ; NOP
5 w3 F& |% ^7 l( `7 p6 G' n* T - out 64h, al / j( x i/ F: J
- call A20Write & X* j* _$ |" U, ~
( w, |/ K; O, k1 ?/ A- exit_enable: ret V8 ]; \2 x; _, f; r
+ `' W/ R8 b6 r( t) i6 S9 t- A20Write: xor cx, cx ; Reasonable wait + j' J# a. S" S) U
- get_wirte: in al, 64h ; Get KBC read status ! f+ D- {6 u9 u/ b. q5 i) U* S
- test al, 02 ; See if buffer empty, bit 1 clear ' C$ E% I* |1 r' h! k, \
- jz clear . D6 s( |. n. h( s5 Z% D& B" r3 j
- dec cx
( v; B# ]- s) g" Y P j% z: s - jz exit_write ; |1 Y8 Y0 W, i
- jmp short get_wirte
3 D- ]7 _5 ~8 y% T) J: L1 X# d- ? - clear: inc al ; Clear ZR # k* L0 C2 {3 p9 {5 \
- exit_write: ret : i* d2 B- ?, N! m- ~
1 F5 T3 A V8 W' f
$ i" m, x% w/ r6 e- A20Read: xor cx, cx
' Z7 a' N5 J; h; _4 Q2 W - get_read: in al, 64h / u2 r( b' k" a" w
- test al, 01 ; If the 'output buffer' is full, has + c9 E9 U2 V7 G+ ^; a
- jnz exit4 ; ...
; a- n& e5 `+ i% I1 a1 Y - dec cx 5 [+ I3 |" T. r {$ K
- jnz get_read" r2 H8 ]5 Q; _8 E, g3 D; ~. X
- exit4: ret
( d- f$ \9 G: X% V, Q8 O -
) e. Q! C/ c/ a1 c; |/ G7 R4 Q n - end
复制代码- ;A200FF.ASM 2 ~( [1 N s" S7 D( ^, _3 N
- ;
4 w, p2 S6 Z! }' T - ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01
" j; H+ A9 q( @( @2 T1 [- I - ; ml A20ON.asm ) y% b5 z9 r. H/ _% q
- ;
1 u! l* I% s# k: W8 u# n - .model tiny
6 w3 W" ^( B G( e7 a3 d$ `- j- j - .code0 v2 v- a6 W( w- v8 a
- .486
( E& e7 u5 N' T( ~" X2 w, b& K, Y - .startup; L2 }3 ~/ {) a2 y$ x8 @% J# ?
& v7 b# O0 c' d. J2 I& j; s3 ]: c- mov dx, offset msg_author
' ^5 [. B0 ~8 i- j* D" O' B* q" V i! a - mov ah, 09h! u, }6 o' t+ H* s% `
- int 21h; M6 | x3 x+ @' E
+ [$ N) }, e2 S2 N6 Y- mov dx, offset msg_fail
* i" }: v, ^5 v d+ l - call A20_DISABLE
! [1 D- O: R9 R2 {. ]" a - jz exit1
) }' L5 w+ l: y* |+ B0 U8 h' p - mov dx, offset msg_ok
0 O$ r& k+ }8 k7 P$ P
m' z8 V/ [% r- exit1: mov ah, 09h
9 l% H9 k' e3 I9 }) C - int 21h 7 p8 N+ H4 x+ Z7 l% [9 _
- mov ax, 4C00h $ E- Q4 c9 _. u* D0 j2 K) g
- int 21h
8 v3 h; {- p) ]% Y$ S -
1 X0 I" b t8 R9 D, f: X E: ?6 u" \1 q - msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,
) Q/ Y8 Z8 V: g g7 e - "2008-07-01",13, 10, "$" * I+ C# E9 U$ W1 r; G
- msg_ok db "A20 Disable OK", 13, 10, "$"
" X! C \; r1 d( S; F - msg_fail db "A20 Disable FAIL", 13, 10, "$" - S4 d/ m5 r: [' F, d$ u; Z7 C' C6 Q
/ P" g1 R. u2 |% O/ q' {- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
' Q7 E! E" `+ g- h; E - A20_DISABLE:
5 O: [- \7 H1 I r3 U0 I - call A20Write 4 ]; q9 u. ^4 m9 S( y) W9 R* q* |
- jz exit_disable- G# Q" o. n3 B e
( l; K, d! b1 T4 W- Y2 O- cli ; Only need for reading value from KBC # ?# j# U5 E# q1 Q0 O1 S
- mov al, 0D0h
& z$ b7 b# A9 a1 F* z - out 64h, al
1 q: j4 a4 D+ T+ P* p+ x - call A20Read
+ Z& K3 S/ e \! n - jz Disable_int
6 c/ Q% H c, ]% Q
# C! v6 D1 o$ z1 w7 Q- in al, 60h ; Get current status 6 ^4 _$ a; |9 U2 g4 }* G% s' I
- mov ah, al
0 L! Y. J! u! {7 s3 b: z/ k - call A20Write - [( u6 H4 G/ o
- Disable_int: sti ) z7 F, h" E* E9 J. i# d9 `* X
- jz exit_disable
; E# C+ Q. X6 b! c: R - 1 @: Z( J0 z5 k
- mov al, 0D1h ; Tell the KBC , want to write to the 0 ?/ E( f u4 Z# j
- out 64h, al ; Out Put Port next
& z: i1 |/ o+ N. E2 ]$ G - call A20Write 4 W- C" ^4 {) y1 N8 I3 e. K
- jz exit_disable3 w8 I% `# i+ _ y: I3 a! B
- & N- u* K2 n( A- D1 z* F! g+ I; t
- mov al, ah 5 H4 x8 }& w/ V9 |' \
- and al, not 2 ; Disable line A20 # N3 `( s" {8 m( F5 E( u
- out 60h, al
# V8 K6 D. \/ I& [* L5 M - call A20Write
& [ Q4 |% X6 ~) G - jz exit_disable
# w$ n* U9 w( a7 G, }" a) M% b - 6 |$ M: b! N$ p U
- mov al, 0FFh ; NOP ) o+ K3 K" P+ ]" }* o. d- d. w
- out 64h, al W: q: n+ U4 j S5 Z8 m
- call A20Write
) |$ x5 e" A8 z; d - ( M, z: H' G0 \, w' v+ G& Z
- exit_disable: ret 2 |: x4 |! i7 c
7 c% F+ S* ?* {7 z2 M- A20Write: xor cx, cx ; Reasonable wait
' V" _7 h4 h2 Z) ^8 a5 K9 E - get_wirte: in al, 64h ; Get KBC read status 7 p3 A! y8 |6 @2 r* @1 |9 S
- test al, 02 ; See if buffer empty, bit 1 clear * V1 ]9 b, c% l- O+ }
- jz clear , v* { {: E! e' Y
- dec cx # }4 ?+ a9 P" J1 |& i2 @/ Q6 y, Y
- jz exit_write 4 M6 K* ]$ D+ G9 z o2 I
- jmp short get_wirte , ^( X% V5 {1 X$ q( |! j j
- clear: inc al ; Clear ZR 4 b: x3 r9 m9 ?6 R& u; |; E
- exit_write: ret
0 O6 t4 e! q9 Y; O2 Q0 _4 c
7 H3 W- \( i6 S5 X
0 c, q+ I. g- z1 ]1 k- A20Read: xor cx, cx
" M8 H# Q" K' U9 [ - get_read: in al, 64h k8 _$ ]5 I2 `3 ~" P; `1 m
- test al, 01 ; If the 'output buffer' is full, has
* }! W& k N) R# S. Y* l4 ?; q - jnz exit4 ; ...
: A1 x b. Z" u - dec cx % C' J" D1 D; O9 h' d
- jnz get_read' R$ k3 B2 u. y
- exit4: ret
- v) ^- z& p' r* @3 D0 N - ' L, m, I: F: Q- c7 E$ e \
- end
复制代码- ;A20STATE.ASM
7 _+ B$ B# ]6 K - ;
0 n* X$ d$ S' Q* K: {. V0 D - ; Returns the status of the line A20 through the KBC - V. a8 A6 J4 Z2 W
- ; programming by bini for debug. 2008-07-01. q7 ` q4 q" O) d, @
- ; 5 e7 Z. x$ O8 q+ y1 t$ K
- .model tiny* U7 u8 Q" x- G, m$ ?* J
- .code2 Z. N% {5 o4 R7 ^- D
- .486
6 z. ^/ R# ]& M" h6 `- ?* {3 ]# }/ @ - .startup
) C1 ?7 I7 r. u a- s* S/ J4 j# _6 z - mov dx, offset msg_fail
# C( u0 T/ [/ m! v9 X! ]: ~' \ - call _GET_A20_STATE_
$ k) o1 v `/ L8 q& F - jz exit1 ; was a problem
4 h; D% S, K4 [5 ^ - push ax ; Save state, AH 3 X! l$ e3 w5 o
- mov dx, offset msg_ok ; There wasn't a problem
; d, F w' \4 A) F5 x - mov ah, 09h j* M, K& c3 g
- int 21h ; Print message
, o( e3 y. ]+ [" _ - pop ax ; retreve state ; o5 \1 l/ X6 }" @' z
- & ~- J V8 H5 n. P0 H/ E( ?
- mov dx, offset msg_dis 3 {1 Q8 b& Y3 A7 J" W
- and ah, 00000010b ; bit 1, 2h, indicates state ' ?) ^( e6 F) b; i- ~% v: S
- jz exit1
: c3 ]- E2 V5 x- g* M# v - mov dx, offset msg_en
& f }; a* y3 R& t9 x! N9 Y
$ n' U% f. S4 Y, k) K5 ]- exit1: mov ah, 09h ; O8 A$ a9 L) ~+ f1 K8 l5 d
- ; DX already contains address of string
' g. b7 S$ J6 q4 |8 { - int 21h : ^/ z) l. Q, `
' M6 @, v$ M; p5 }/ a( v+ ]- mov ax, 4C00h
$ E+ X, O) n N i+ c u - int 21h 6 X; Y- u+ X1 o! f5 m" Q2 c" ]
- 1 `' h8 R) ]0 Q5 k( V3 s& a9 E
- msg_ok db "OK", 13, 10, "A20 $"
& ~$ k6 |& G2 ]4 |$ y& [ - msg_fail db "FAIL", 13, 10, "$" , H0 [, @2 J' o0 }9 \
- msg_en db "ENABLED", 13, 10, "$"
1 k" g! U5 T b9 D - msg_dis db "DISABLED", 13, 10, "$"/ ?7 _, ^$ d0 f2 Q$ C2 D
- $ ~( @* U$ v( b2 Z' ?! ^! `: N5 ]
-
( l0 D6 R @( O - _GET_A20_STATE_:
5 A+ c1 P8 L' w; j. { - call A20Write ; Wait till the input register is empty 6 B# F$ C7 K% |! \, D
- jz exit2+1 ; Bypas the reset int's 2 \- @; f1 @8 G/ M' A
- cli ; Disable ints so we'll get our value
7 Z8 C/ W, @- A, Q+ B1 m% e - 4 E/ Y5 z$ j8 t+ H5 A
- mov al, 0D0h ; Send command to the 8042 command register 3 S$ \0 O8 m" y3 X6 o
- out 64h, al ; to tell it we want to Read the Output Port
m( p6 I& Y( U& {. y5 _0 s5 \ - call A20Read ; Wait till the 8042 output register
4 {1 k, i0 i- E4 [$ M2 X - jz exit2 ; has something in it's buffer
4 t6 u6 u, d/ ~ - & R; y" T. b5 e' m3 S, h6 f1 b l
- in al, 60h ; Get it & w( o- Z# w1 f8 ?' u1 C% ?
- mov ah, al ) e. D8 R+ ^, ?. ]+ a9 }9 W; C
- call A20Write ; Make sure the input register is empty
# c: R/ d* d- u# a" }' s; f - jz exit2
% @: N2 k7 w& v9 E: y `& S( G8 B
, M/ K/ V8 Q# H' ]: f- mov al, 0FFh ; KBC NOP command, does nothing 9 ~5 c9 y3 `1 I/ u+ y
- out 64h, al * h* Y9 M3 W4 _# K1 U$ g; E- H
- call A20Write
8 v6 A1 D ?: y( r' h
3 F+ m$ Y* N4 z( @) Y! @$ `% Q- c. ~- exit2: sti
6 i0 @4 }3 B7 l& o0 b - ret
4 l* g1 y; N+ s+ N- [! x0 ?
) I1 h1 B* c3 f9 |
) V2 x( z2 D; R: U- A20Write: xor cx, cx ; Reasonable wait . Y- e! R/ v* e7 T
- get1: in al, 64h ; Get KBC read status ) H6 B2 Q0 G# c N' j
- test al, 02 ; See if buffer empty, bit 1 clear
( u- u( {- l3 Q; @0 ] - jz clear + ~6 l* q* t$ T8 r3 y9 u& R
- dec cx
, Q( p! w" T3 }- q - jz exit3 8 {+ g& G7 O3 ]
- jmp SHORT get1 : E( {- [( y1 |9 h2 w) @. |
- clear: inc al ; Clear ZR / P. A/ e" M$ q& @9 L* k
- exit3: ret
3 `% s% }& D5 C/ ?9 r: W3 ~ - 2 O: D* I5 [. Z- n. u8 [& j
' u' }+ i& |, S& y: H1 P* q7 {- A20Read: xor cx, cx . @ Q0 X7 ^& C" F' w
- get2: in al, 64h ( D' R* M$ B. @0 ^
- test al, 01 ; If the 'output buffer' is full, has
' _ b0 T) l6 y* d8 W4 ^ - jnz exit4 ; something for me
, W0 `' \8 B5 r! A2 j8 X - dec cx 0 ?: i1 g2 s) d2 l
- jnz get2; o* ?* y! Y7 A, Y2 h8 j
- exit4: ret 0 x4 }# u5 t% B$ N% g
-
1 ~* Q+ V5 b( Z! E& T- T - end
复制代码 |
|