|
|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM 7 K \" _; A X7 m
- ;
+ W5 [* h2 Q1 ~3 R% L2 r - ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01
# |7 L0 R, K7 }" h0 j* {8 R( y - ; ml A20ON.asm
1 p1 N1 V [0 v" b - ;
- j: B) a' ^) K' y* b - .model tiny/ b( Q; ~3 E" \, b
- .code
5 z2 e5 H8 r% j* v& H% D0 E. s - .486
( o. Q9 M) Q; b! g- |+ c - .startup* V% u. \ J0 |' T" k1 s
- 7 s' `5 h" k, s* @
- mov dx, offset msg_author3 v. T5 B1 A9 B8 B
- mov ah, 09h
' F. _6 [! ~* Q* B - int 21h- e5 T/ v! z1 t& p1 n8 N5 c9 M9 \
$ A5 ~- g: `5 }' S( ?3 h; ^- mov dx, offset msg_fail
+ a' ~0 o% y1 f8 s$ _ - call A20_ENABLE" V" s7 \/ E! l. e7 k6 U
- jz exit15 r; J5 X% Q) n, Y
- mov dx, offset msg_ok 5 @% V. f2 j8 a2 b/ Y7 y& Z
) ~1 R7 [, `6 K9 t0 N R- exit1: mov ah, 09h 1 Z' x- C5 F8 ]$ I
- int 21h 1 x; f* D' `' Q2 u. x9 A J
- mov ax, 4C00h % c. I" F2 ]7 h) a6 K0 E3 y: r' i
- int 21h
2 u+ J9 m/ e1 ~" n, R( R$ ]" n1 k - 6 d) y" q* L: `, y% ^! q% T/ \
- msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,
5 q q0 j4 U# \3 `$ K - "2008-07-01",13, 10, "$" & g7 w: @, u4 I. o
- msg_ok db "A20 Enable OK", 13, 10, "$" + L/ @! V7 l' W% r H) Z# Z
- msg_fail db "A20 Enable FAIL", 13, 10, "$"
1 t/ y+ V/ `: p7 V$ L - 0 J Q9 |8 W$ k: ]3 F' w& O& P7 @
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------6 j: U7 H- P8 U3 m* s
- A20_ENABLE:
$ T8 t. T: l0 {& \" J# V4 \ - call A20Write
' W; U1 i, ~, d - jz exit_enable
& c. j3 n% X% U
! H* E1 k1 E8 w7 ~- cli ; Only need for reading value from KBC ' R T+ S( n, K9 }# m* s' z
- mov al, 0D0h
/ b( q3 A7 ]+ \5 C! l - out 64h, al 2 q' @9 w3 T6 i- f" m
- call A20Read 1 r/ j3 J! h+ Y
- jz enable_int 4 d$ \ |& x; T7 Q3 m( C6 O. s
- 6 y2 Z: V( b. L* U+ v
- in al, 60h ; Get current status % D' n5 m" P4 v( y7 T" A* }, f
- mov ah, al
+ K, m3 g! O/ }# f9 A0 g! z* Q - call A20Write , O" H3 m8 b/ g( ?2 ? F
- enable_int: sti 5 }4 a% D+ D' T" X
- jz exit_enable
) T1 {1 `( K; I
# g' |7 ]/ A' P/ y3 L. _- mov al, 0D1h ; Tell the KBC , want to write to the 1 g* T- t, S0 [, T
- out 64h, al ; Out Put Port next , k8 |( x1 t7 n5 ]' c
- call A20Write " `1 W5 p( A: G
- jz exit_enable
5 [4 B4 P& F9 @0 }
5 |8 D7 Y6 ]5 {9 o6 w) s2 P0 c$ T- mov al, ah " R5 `( M. N/ C8 S2 J: k
- or al, 2 ; Enable line A20 + N9 d* `- P5 m' ]7 w9 @! r; B
- out 60h, al 4 E' `( h8 P, t! f! F8 ~
- call A20Write
" ^( }. X* |9 s4 }( v( B1 r - jz exit_enable
! k5 q( O. f5 a6 w/ M( c
# l1 W4 ?, p" |8 y6 ]- mov al, 0FFh ; NOP 5 ^3 ]' e+ P& q
- out 64h, al . m/ X0 P0 P, c2 L: q" s
- call A20Write 8 `' T9 J& Q$ l
8 H6 g8 N6 T- H! b- exit_enable: ret @$ U& I1 d0 F% k$ }& ]5 Q
! j+ ~% F% f! [- A20Write: xor cx, cx ; Reasonable wait - F/ A1 [( q" T e
- get_wirte: in al, 64h ; Get KBC read status 1 }4 w" |- ?* T% }3 D* I1 p
- test al, 02 ; See if buffer empty, bit 1 clear 4 D) D) K, V' ^& Z$ [
- jz clear
W3 M# ]+ N% r; ~6 g - dec cx
7 E7 @( x3 _: C! J+ K5 N - jz exit_write ) k( d R6 L* b2 d3 s! V- [: P
- jmp short get_wirte
) K) d8 {+ \3 Q \3 R) I - clear: inc al ; Clear ZR D7 d1 B6 P& Z* ^8 s
- exit_write: ret
+ p) \/ |* ~ q2 u - 9 a: y2 y% u7 n5 o# Q# j
- ' |9 e% R0 f& w, }
- A20Read: xor cx, cx
2 V) J: M9 n" S; v( b - get_read: in al, 64h 1 l- p3 [0 ?3 q: b! G, a$ J
- test al, 01 ; If the 'output buffer' is full, has
- f ^3 n' M0 f. l - jnz exit4 ; ... / S, Z% W5 A5 ]7 n. P6 X) R3 }
- dec cx 2 S; g% I5 o- ~4 Z1 X/ Z X" `
- jnz get_read
& q" F" J9 d) J/ C, G7 S$ g7 h - exit4: ret
0 E s' h4 ]$ }. h8 { -
/ S5 s3 _7 D( O5 \& |) ~; n - end
复制代码- ;A200FF.ASM 9 ~2 R. G4 ?5 ?2 R
- ; . \& n. x8 T! T( a T- R8 q: j
- ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01. V2 P8 M, r% Q$ _' Q5 G7 G
- ; ml A20ON.asm 7 W2 X9 I* z* |/ A
- ;
8 M/ h0 @' d. o& _& j4 {5 } - .model tiny; ~# r# X& W, H7 {6 Q& S/ y% p
- .code
6 F8 m; G& Z0 m% D+ r - .486
6 S# v+ V8 i9 E7 s1 [9 Q - .startup, l: E/ k1 ^/ J, D& a l6 U6 P
6 o5 h. ^7 b. B/ Y( V4 i9 w- mov dx, offset msg_author
$ d2 d! S( {& B7 }" r/ | - mov ah, 09h q9 n5 `5 H4 |% H
- int 21h7 h1 i, b1 `# F1 |6 V
- 6 d7 ~9 R2 T+ |- Q0 t
- mov dx, offset msg_fail
6 X1 _$ E3 \- q" Q% }4 C' w7 r - call A20_DISABLE
0 t! s, M# @6 W7 _! A$ ?# ]4 |, ? - jz exit1
" Y( q; L, L( A# y- o& a - mov dx, offset msg_ok & m3 H$ r; J8 N H% C( {
- / J3 {" v% r; [5 ]5 K
- exit1: mov ah, 09h # J4 b: N u! n7 B4 P2 J" d
- int 21h : x$ w4 m9 j# i4 U& S
- mov ax, 4C00h 0 L+ E: `1 p6 d! q1 o$ p. U1 Q
- int 21h 5 S8 ~, Z, n3 M2 s# T6 D Y
-
& n# ~" ]3 d$ T: ? U - msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,
9 i) ^. H8 k C; X) y. h5 M - "2008-07-01",13, 10, "$" 1 l. x$ H/ Q! A; k5 |8 B( w
- msg_ok db "A20 Disable OK", 13, 10, "$"
" ^. {3 Q& ^/ G) i - msg_fail db "A20 Disable FAIL", 13, 10, "$"
0 W$ a$ U W) `/ W' c
/ |* O G/ ^1 j" k# v7 ?- ;------------------------ follow code maybe make to lib, if you want...-------------------------------9 l% r3 ~; N* ?) ]! k2 U- p
- A20_DISABLE: m' g# C- j- ~
- call A20Write 4 }5 `) {7 R9 ?" t) W* \
- jz exit_disable% H! Q& ?# [/ Q4 J
- ) `* a" q* s4 d( O9 v& y7 B) u
- cli ; Only need for reading value from KBC * t: I3 O+ w2 X, w" ~
- mov al, 0D0h
+ w1 A' l# T1 T) K* _ - out 64h, al
8 Z% z+ M+ y/ V+ u - call A20Read
* F& s9 n6 h; w - jz Disable_int ! s' I9 p7 o4 I( x2 f
- ; k" k; K" m! W( w# T: _# ~: j
- in al, 60h ; Get current status
$ \; P. a9 F& @0 A5 r - mov ah, al
' L1 w" u6 @1 g% v0 X0 y& x - call A20Write & K& N" M- O. S, H5 N
- Disable_int: sti
% p/ b8 D# V/ T% _) ~; g3 F& u! K5 l, F - jz exit_disable
8 v5 R" D- g: E/ z - 8 x D9 |6 v; s1 Z# X/ K
- mov al, 0D1h ; Tell the KBC , want to write to the 0 C# W0 f3 Z" K
- out 64h, al ; Out Put Port next
2 o9 X3 i0 f# L: V. R - call A20Write
' ?3 W/ r) \! z; O: K - jz exit_disable# o& U( J& v* l" \) f1 S* \, k
- 2 v2 m4 P. P _" t A9 v8 E
- mov al, ah
/ j, O3 p. b. P* ?* Z - and al, not 2 ; Disable line A20 - `/ }& @ ]' z+ N( p5 f1 R v
- out 60h, al
' e" z7 ~4 W. }2 }0 E& t, Z# _/ E6 @ - call A20Write {4 n/ e- h5 x) W* r4 |8 [+ Q% Q
- jz exit_disable9 R; t: n. A$ M& k
- ; f/ j5 L& o6 F* k$ X; ~
- mov al, 0FFh ; NOP
1 J6 O. t! ?1 e$ g/ i; c( l3 {& B6 _ - out 64h, al
: I$ B1 A8 ]$ E7 n9 V* ], B% T - call A20Write
! r5 G4 W! @/ R" R - $ a! Z' _4 j$ y+ ?7 r
- exit_disable: ret
% f# D5 Z6 ^2 i4 S9 A! H4 C- U4 Y
7 J. s; ]% n# Y# q- A20Write: xor cx, cx ; Reasonable wait ( r) }5 D! c0 `
- get_wirte: in al, 64h ; Get KBC read status
+ Q8 z: `4 |' q! y1 ? - test al, 02 ; See if buffer empty, bit 1 clear & J2 B& w$ m8 ]* G4 s
- jz clear ; ^2 V- V/ ^6 g4 f5 F3 U% l, F
- dec cx 9 F* ^8 Q8 v3 Z w
- jz exit_write
$ C3 P% _; R; m' @ A - jmp short get_wirte
( }4 I' D# K, h, v4 N' l - clear: inc al ; Clear ZR
9 n. J. y( ]! v d% _2 ` - exit_write: ret . |3 z4 V v/ l
- # M$ `" c, g2 n! N; M( G+ S
$ X0 z# x) {, J. H$ v5 Y" j* ^- A20Read: xor cx, cx
; I- Z6 K! j! _ K - get_read: in al, 64h 4 y9 A. Z) w- B: C H9 ^, U3 r
- test al, 01 ; If the 'output buffer' is full, has
/ e1 u, \& q) `/ F4 { - jnz exit4 ; ... - V1 P1 V% ? m5 \9 b
- dec cx ) ^# H8 [/ V' I0 y/ N% f
- jnz get_read
2 g3 ?9 _5 [! o - exit4: ret . U3 j( ^) e; v. ^
- & \! L" O! ^( J, g8 R, l
- end
复制代码- ;A20STATE.ASM 1 g) h2 D3 @/ ?" m8 M
- ; / h+ |/ _. x% ~/ \) {) h
- ; Returns the status of the line A20 through the KBC 5 N4 f6 S. a/ V$ r- [! Z
- ; programming by bini for debug. 2008-07-01
- z( p- y' E8 i( J% J: }# [5 W* r - ;
; D5 l# y" e! F( S0 D: A3 K$ g - .model tiny
% r% g5 l8 T! z - .code
& G5 O) M1 v" g8 X. p0 k - .486
* R/ n. E% _7 M5 Y, w, X, u - .startup! Q* @( g. l# {) E
- mov dx, offset msg_fail
* z/ T) X& h6 n* S) q- r# |1 i, x - call _GET_A20_STATE_
6 Z" s- P2 M# w4 Q - jz exit1 ; was a problem
/ v5 R2 u* b) ~+ o6 v d }* W - push ax ; Save state, AH " W8 z+ t8 \! U' o6 [
- mov dx, offset msg_ok ; There wasn't a problem
& ?8 H' q2 S- m) e - mov ah, 09h 0 b" T# ~2 [4 B, S8 _
- int 21h ; Print message : z& K# p9 C+ l4 h* A2 k
- pop ax ; retreve state
# c- v" E' N+ f& ^9 N0 e - N+ e; G8 i9 v1 k) l7 ^/ R
- mov dx, offset msg_dis $ O2 y: G7 C1 R
- and ah, 00000010b ; bit 1, 2h, indicates state
. D5 h. _+ b6 W! ^ - jz exit1 ! w) A/ t& _6 n" c* Y5 h5 N
- mov dx, offset msg_en ) R/ Y2 h; L1 `/ O- ?& p; s
+ R" y4 x) d8 H0 e2 v- exit1: mov ah, 09h 3 ]- R' c* F% E1 }0 y+ M
- ; DX already contains address of string
. U; h( ?& M6 y+ _6 g, o - int 21h $ H, P# R6 q8 j" c+ s, a \. e
- & n4 y6 F5 L7 [0 [
- mov ax, 4C00h
/ ]2 a1 Y' H" w4 X. t& Z; w; t - int 21h D- G }' S* z3 V j# s
- ) g; E) E5 R& O& P" r; _. v$ t \
- msg_ok db "OK", 13, 10, "A20 $"
e- o) W" [! m h `! T - msg_fail db "FAIL", 13, 10, "$" 3 W4 z& g: [ Q
- msg_en db "ENABLED", 13, 10, "$" 4 v2 Q# F. p$ r9 a7 }; z: [2 {5 D
- msg_dis db "DISABLED", 13, 10, "$"
* U- h- U$ Q+ n5 w4 w1 V2 Q - 9 k# x% P5 [! U% l# X( q+ ~! {
-
- |' V7 g% l( X" Z% F! ?7 Z* z - _GET_A20_STATE_:
0 w0 j/ h0 P( |& s1 v% ` - call A20Write ; Wait till the input register is empty
( b$ F' K0 j. Q0 Y9 a1 c - jz exit2+1 ; Bypas the reset int's
& l$ W4 H1 Y2 j" o! U - cli ; Disable ints so we'll get our value
y; N3 ~- q, |* z5 B - 3 M- v2 p0 f* b. R. l# m, I
- mov al, 0D0h ; Send command to the 8042 command register 5 q% T( J, A7 Y* q0 ^( X
- out 64h, al ; to tell it we want to Read the Output Port
% @0 M/ s. i8 s; j - call A20Read ; Wait till the 8042 output register
/ B' i1 _6 K) S& Q( J - jz exit2 ; has something in it's buffer
0 s/ Y+ w- o3 N/ Y
1 w) G9 {0 I9 j$ p R- N/ C- in al, 60h ; Get it & c1 B$ y/ }" m
- mov ah, al 2 w9 F/ c- S" [% n( C
- call A20Write ; Make sure the input register is empty ( R3 g$ V# M; Y6 E5 w: t; t
- jz exit2
) a# |! k; i( b- y# k# N2 M( d - 4 `* m; V h( ?- b) ]3 B
- mov al, 0FFh ; KBC NOP command, does nothing 5 Z4 w b. ?/ ~! U6 v: `0 ~' j
- out 64h, al 2 ^6 V& x5 r' D7 H
- call A20Write
: Z3 P/ _8 ~- O& x( S" F$ @) u - 3 j5 f4 ^: S) o( {$ C: [
- exit2: sti h6 e# w8 k+ `2 O' w
- ret
6 u+ F# z+ j' \, _0 W - 3 z: f9 S4 ?0 y+ m
- - w: R8 ]( F7 r! I, Q
- A20Write: xor cx, cx ; Reasonable wait : z4 t# A) h& E& ]
- get1: in al, 64h ; Get KBC read status
! Q8 ?+ a9 W0 Y* h0 f- |% X - test al, 02 ; See if buffer empty, bit 1 clear 1 |6 U# \, _: K: G* D+ f1 p
- jz clear
% G& x& X' E3 r" V; k* |. ]1 I- g - dec cx
3 B- O- Q8 ~; t7 u - jz exit3
; p9 Q4 b; J$ V/ h E - jmp SHORT get1
( D8 c N$ B) f0 R% w G9 I - clear: inc al ; Clear ZR
3 ^( z# F+ Z9 c6 g - exit3: ret
( M' z& s( K# j - ' D2 f# d* c2 \* N2 h
, b* s; m x, S# o7 Q- A20Read: xor cx, cx
, s4 K2 e8 o- @0 O/ A& p - get2: in al, 64h * T, p: R. {* A4 I5 _) W
- test al, 01 ; If the 'output buffer' is full, has - N7 e3 T) u4 p6 _, M# I8 M5 c2 V9 E
- jnz exit4 ; something for me # b5 z6 X$ t1 |( u) @
- dec cx ! N" H6 [) ?! r* I1 Q
- jnz get2
/ ]9 P' E1 I6 L - exit4: ret
7 F5 l0 g$ }' ~$ w4 |% \ - 7 ~8 L* D4 |1 h4 x
- end
复制代码 |
|