|
|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM 4 u0 v4 _1 P5 n3 V
- ; / d$ w n6 ~( u6 G/ G$ m
- ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01- A4 l8 l0 |8 C- J: k R
- ; ml A20ON.asm ( }* F" f4 K# N+ |( m) z& a+ }* @" o
- ; : r _% ]/ `" A, o8 R/ {" D. d5 u
- .model tiny3 F4 P4 E0 M! M9 d
- .code
8 p" P( T" h; Q+ k5 Y - .486; K$ f7 ~% e6 \/ v8 N, E+ g
- .startup& ]& _* f0 e, n# y4 F
) G" }. S" ?9 M0 F) Y6 X0 B# u- mov dx, offset msg_author
8 O$ |% Y+ M8 s6 v; h/ T - mov ah, 09h+ z ^8 n" @4 I9 u# y( W% S2 U8 ?
- int 21h
, Q4 Y& b3 r& h9 Z; t" e
' q4 m1 [# h- b* h- y6 o. E- mov dx, offset msg_fail 8 k4 ~1 ~! l" e; t! D$ u
- call A20_ENABLE( h7 v7 C+ \* u3 b d, }7 ~
- jz exit15 ]* y" `& M% t3 r: r, ]( E
- mov dx, offset msg_ok 5 j5 @: u) U( L* [7 E/ Q% q
( [. _" ] Q/ ~1 j, U- exit1: mov ah, 09h ) H" R M! s T B6 ^5 y
- int 21h 7 E. r$ \! v7 T; C" K
- mov ax, 4C00h
: l1 O' N' c3 d: Q% q' a( d - int 21h
C! I% q% m0 x6 ]/ w7 m+ p - 4 C/ ^# R' E8 I8 e( ^# i. W- M+ K
- msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,& M9 z% _5 {. h% V. w2 J% |
- "2008-07-01",13, 10, "$"
; G; B3 l* {) h3 |* T" v8 v - msg_ok db "A20 Enable OK", 13, 10, "$"
5 }9 z6 {' c g3 R - msg_fail db "A20 Enable FAIL", 13, 10, "$" , N7 T# I% d; m
9 S5 }# S# D- g- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
# R. a6 P" X2 `* L6 S - A20_ENABLE: ! a; v3 i) [! B R% N
- call A20Write
* u, g! V1 {* T" H% V$ I - jz exit_enable0 Q6 G: J2 p( g/ n% C% @1 \ X
- U g, |8 Y. @; G+ ~- cli ; Only need for reading value from KBC
/ r* w! O. R# b- M - mov al, 0D0h $ \6 u, P/ Z' A" _
- out 64h, al
1 r& D8 A7 @! D( c - call A20Read 1 p0 v/ x8 @9 l& ?' Q9 w$ d
- jz enable_int
5 k/ N1 i( S3 [# m
: M/ E" n5 N0 [: G- in al, 60h ; Get current status
' U ?2 M* e! i( f# ~; R - mov ah, al
' w( |2 ~3 a7 R3 Q$ K& |1 _9 M4 e# ` - call A20Write
9 w3 N+ P0 N, ]3 N - enable_int: sti & P8 e- J5 c: s' Y, b; g
- jz exit_enable y) `# U* A) D+ I" V. T/ b( X
- ]3 [, c8 y6 V( b5 o
- mov al, 0D1h ; Tell the KBC , want to write to the
% j- [) G4 g( C$ {& `! X; c - out 64h, al ; Out Put Port next - Z# {& s8 M# e; k* a8 Q' X
- call A20Write / s# p z' C: s* }
- jz exit_enable
' F7 V! O! q A( i" F
/ c; |/ i. B. A( R3 W- mov al, ah
' ^* O' w: u+ A7 @ - or al, 2 ; Enable line A20 * a9 H* S0 ~! Q h
- out 60h, al
8 X' k1 ~/ c0 }& j3 U - call A20Write
" ?/ X: R- x( Q( M5 |- r9 c4 W - jz exit_enable; I3 [5 ?% ]! Q& y
- 0 I' n6 _, ~: b7 X7 O
- mov al, 0FFh ; NOP
& G3 ~9 f7 p/ \$ R$ |+ E$ V - out 64h, al
7 Y# K" k, ^$ s* W( V0 z7 K - call A20Write % t! ^( G1 |0 P( S7 M* B
, k5 R b! u& } `5 s `- exit_enable: ret % b" D8 J5 Z: }3 Y+ L, H; T
7 G; J. E1 c- E- N- A20Write: xor cx, cx ; Reasonable wait
2 E+ X! g( j: [1 T& |% M! ?& r& u; e - get_wirte: in al, 64h ; Get KBC read status
; r+ W! j# h5 t2 X( R8 b - test al, 02 ; See if buffer empty, bit 1 clear . x9 `, T& V& L
- jz clear 4 Q3 Z: w: K6 o6 j
- dec cx
' D/ ^: C N9 M) ]+ z, L0 }' _ - jz exit_write 1 h a% Q- o0 N: @' v5 p2 V
- jmp short get_wirte
$ i1 X/ D- p3 Y: G - clear: inc al ; Clear ZR $ L5 r$ X0 l( @$ d" L2 s
- exit_write: ret ' \6 g& j' h$ m/ v7 ?4 {* U: n
- & ~( {" l1 c9 v; H! L; [
- 9 |! Q, k3 r: P
- A20Read: xor cx, cx 8 u$ J/ h1 a6 j/ O7 ^! a2 Z: t
- get_read: in al, 64h
7 Z% j J7 O6 F% K( l m z - test al, 01 ; If the 'output buffer' is full, has
5 P. e7 i' z, |9 {% U$ A - jnz exit4 ; ...
3 Z. \8 {6 a- h - dec cx
2 x$ k4 U/ y4 [8 C1 r& n6 W5 \% c - jnz get_read
1 Y' _/ _. c0 b6 q - exit4: ret
' I/ v1 |# m j1 N" u$ I - 0 O1 M7 Z! L) v! y; z7 l! N2 ]
- end
复制代码- ;A200FF.ASM 2 C& S% z0 ~/ a* x* _1 A4 f$ E
- ; " J9 O* k4 A. ^% A! H, f
- ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01
2 u8 F. D4 a" R1 x - ; ml A20ON.asm 7 Z( [4 }; _0 ?& S) U o7 u7 `/ T
- ; 5 [/ r. j( R; M5 ]: o" |* Z7 |! F
- .model tiny
" Z+ o% W3 P7 K+ w1 |" O3 L - .code
6 p5 x7 ~: L; X3 J, `) w t - .486
8 I* C% \' E9 A" H0 u% w - .startup1 Q0 S- y0 m: y4 u4 K% V
- * t8 M) ] y5 J; a; y1 _7 T7 D, {
- mov dx, offset msg_author6 J$ j1 L* @& q5 t; F. [% Q
- mov ah, 09h8 I1 r0 T3 f7 ?, v# o# ?3 q3 M( Q
- int 21h
: _0 [6 ?: q# {) _& x: B: t
8 ~5 ]- ]3 u" W- mov dx, offset msg_fail
) v: \/ A- X/ F0 W: u - call A20_DISABLE% x+ k4 c2 P7 c, w- Z3 K, Q
- jz exit1' @4 D8 |- s, L0 N M7 f7 _/ X
- mov dx, offset msg_ok
) U* T& @' @2 K0 i. e& i, b
5 \- s! `1 W$ @- |- exit1: mov ah, 09h
: r% `/ g |6 c: k0 h# V. y - int 21h " x9 N6 _1 g+ @6 N) R; j1 K/ T
- mov ax, 4C00h # w ~" d" a6 E0 y
- int 21h ; }$ @, c0 l6 z- R" ^: r6 Z- Q+ p
-
; \4 [( a1 v n, G4 H+ [ - msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,3 x! E& }5 e/ Y* b4 y
- "2008-07-01",13, 10, "$" ! ]2 X9 S9 D! R) n/ _
- msg_ok db "A20 Disable OK", 13, 10, "$"
: G; U2 j; U* N2 q' _. ^ - msg_fail db "A20 Disable FAIL", 13, 10, "$"
?; Q$ h& {& S/ x - & @9 ?$ g. o: _2 X9 C1 k
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
9 K3 @: ?& q( P, O: b1 j - A20_DISABLE:
$ P( n2 X) V9 Y8 k% x* }$ _ - call A20Write
- ?% h& M/ N1 w# c+ I - jz exit_disable1 A2 ?! a/ e% v, F7 Y
6 t* s. h( z E- B4 j1 q- cli ; Only need for reading value from KBC 7 f9 w ~" | t3 c3 c$ E$ Y
- mov al, 0D0h * n( k: g R' B6 I- T* }+ X9 Q- p8 B
- out 64h, al - i8 T6 R2 p% E7 X) Q
- call A20Read
1 m [# X4 h2 p- J+ { - jz Disable_int ) S" f- ]* H# ?5 z/ `
) i! L# o7 ?1 H+ O o: l- in al, 60h ; Get current status - b. H% u+ @! q5 H, k
- mov ah, al
* `/ e* I3 w: [% u, Q% Q- _ - call A20Write
1 b0 V; F7 k6 w; y' \ - Disable_int: sti & R9 t( `2 c" L8 Z. t/ W
- jz exit_disable
s' J7 f6 |( f# a/ ] - ! v8 J2 ~! k% v! f% p
- mov al, 0D1h ; Tell the KBC , want to write to the
- `' A/ L- l, U# D# V. I - out 64h, al ; Out Put Port next ( o9 D2 N( |. Q0 b& u6 @3 ` J
- call A20Write
( \7 e: `7 A! \/ w - jz exit_disable& T! ^& H2 `( b, F" M2 V
$ z5 C" `: Q9 Z4 ]8 S- mov al, ah 3 q0 H# o' |4 H b$ Z6 {
- and al, not 2 ; Disable line A20 5 u" {$ w3 D9 g: h
- out 60h, al
( l9 o2 C2 `: e! H - call A20Write
- N; D6 u2 \) m% | - jz exit_disable0 N) H, a. I) L& L# w& N5 B& F
3 k" o G& F" c+ k* l- mov al, 0FFh ; NOP - N3 w6 L3 u$ [
- out 64h, al
) O8 I3 I* I- a8 |1 D. [7 G. c - call A20Write
# T( }" ?% a4 K; G7 m3 R0 Z - 0 P/ p- c6 H; {7 T- ~! t1 i- X( D3 a
- exit_disable: ret
9 v. L4 y0 ?, a3 l4 x4 q - / m# h- o8 K2 V
- A20Write: xor cx, cx ; Reasonable wait
9 R! a7 ]: d) }1 w - get_wirte: in al, 64h ; Get KBC read status
" H# f S6 O% X+ k* U, F$ z" D - test al, 02 ; See if buffer empty, bit 1 clear ! I* Z3 j2 y' y1 Z. t$ ?! P
- jz clear ) a1 T( ]. f4 p% e* j# f
- dec cx
8 C+ ?- W: X3 x3 k2 W - jz exit_write
' u% {+ }# _& I' j6 q/ o - jmp short get_wirte 1 k( h7 q' N4 l+ r( w9 u6 s9 |2 t/ T
- clear: inc al ; Clear ZR
# ^5 e" z) e! U - exit_write: ret ( i. f: F4 {6 o' {8 j7 z2 m& A" ?
) e3 I6 Z# c$ y3 O
5 S" \# `4 y. w' p* ]2 R5 {- A20Read: xor cx, cx
4 H2 w7 L- d3 w: s9 R - get_read: in al, 64h
! D: u1 \& H( Y. k9 D, L5 a - test al, 01 ; If the 'output buffer' is full, has : K7 @, Z9 e" H# i
- jnz exit4 ; ... - T' A$ J5 T, C Y K7 D
- dec cx - K" m1 Q9 }1 L4 G: M; ^, z4 F
- jnz get_read6 o5 g0 o( P) t/ y" g
- exit4: ret 6 a- h) J ]" k0 K" N$ b$ Y. @
- 6 }% i) l$ x6 F/ A" J
- end
复制代码- ;A20STATE.ASM
2 q- y& W8 X( r+ A - ; " L+ L0 R! ] n* f* T1 t
- ; Returns the status of the line A20 through the KBC $ ~0 u; t4 S' E$ g1 X5 C! s d
- ; programming by bini for debug. 2008-07-01/ p2 y0 i( [- J9 k6 J5 U
- ;
\6 n: k/ h+ I( I6 o - .model tiny/ i8 K9 \ }- \0 |5 V( \' J
- .code
6 r# {3 |7 \ f& H0 y7 v& U8 q - .486
9 W6 C: z1 s3 y9 r - .startup
2 q( }& D. h9 D2 o& G8 C - mov dx, offset msg_fail : m8 a. ~# m! z w- a" h
- call _GET_A20_STATE_1 Y1 t1 w4 v) A" l
- jz exit1 ; was a problem
: M& w$ v3 a7 n3 y - push ax ; Save state, AH - |1 `, a4 E( U3 x
- mov dx, offset msg_ok ; There wasn't a problem
) U. X. L& n2 U" V - mov ah, 09h
) Q' n4 s1 m2 D - int 21h ; Print message
; e6 K3 O( W0 \; ^ - pop ax ; retreve state : u5 F" o5 W o& y' ^
1 |+ z/ |' \9 H6 d' J6 F9 M- mov dx, offset msg_dis
# s1 w. x1 A9 F# t8 H5 J7 e - and ah, 00000010b ; bit 1, 2h, indicates state
$ \7 P* w0 K3 Y7 b7 Y' W - jz exit1
`: A9 J9 k! U( d1 c/ D' r' ~$ p - mov dx, offset msg_en
: Q2 } A3 u% w$ _+ S- ` - ) F/ C. Y' Z3 w5 \" V
- exit1: mov ah, 09h - c) r0 a7 ~: o& J
- ; DX already contains address of string 0 p/ _4 f$ [ u3 d
- int 21h
' ], t* W! v9 z- r( a9 f
6 u8 R6 o& G1 t- n8 w5 {' s- mov ax, 4C00h
- T" y# y( A0 H" ~ - int 21h
! S2 @9 u5 S1 d: P5 N - ; s5 M9 s3 D% K9 _# r4 A+ P3 }5 R
- msg_ok db "OK", 13, 10, "A20 $"
@1 _$ F- H( x$ s5 q% j8 R - msg_fail db "FAIL", 13, 10, "$"
. T$ C4 l- `8 `$ B# \ - msg_en db "ENABLED", 13, 10, "$"
& [, c, n; s4 i7 Z+ ^ - msg_dis db "DISABLED", 13, 10, "$"
3 `$ F0 y: ~" ]! L
/ v+ t/ X f) b. J! |-
F c8 L3 J$ g' U, J: ~- A- G - _GET_A20_STATE_:
+ f: T. r+ D" N: ^4 T h - call A20Write ; Wait till the input register is empty * h7 c$ [# ]* u& G* \
- jz exit2+1 ; Bypas the reset int's
: ~' \5 K+ ?3 w; s' T' y$ K - cli ; Disable ints so we'll get our value : M: r% J2 I4 v4 z: H
- + T5 p: }0 F, H0 k% Y% V& N
- mov al, 0D0h ; Send command to the 8042 command register ( i8 w V8 v7 }: L
- out 64h, al ; to tell it we want to Read the Output Port
& Y6 {( [( m" V) a - call A20Read ; Wait till the 8042 output register 3 g5 p. h& f4 y
- jz exit2 ; has something in it's buffer 6 p% o# W$ {% Q2 f0 ^0 V% Q5 q
. V( v! u- q" j: |- in al, 60h ; Get it ' c/ O2 C+ |' f7 B( {. D
- mov ah, al ( l. U5 X. ?$ l' J
- call A20Write ; Make sure the input register is empty
( H% b% M8 w6 s8 W A - jz exit2
' g1 g p. n, P" v( ^5 n3 J
* A! \$ g9 ^: ~$ ]8 B/ `; j% s- mov al, 0FFh ; KBC NOP command, does nothing D/ a; Q0 O5 k* {8 |/ _1 G% I
- out 64h, al
$ f( x/ H+ Q3 H ?1 } - call A20Write 0 A% d5 d# M+ p A( ~
- : y4 @4 |. O4 G3 k
- exit2: sti 8 d- R+ Q# b8 y) H* m
- ret# @7 j" i5 j" q! s2 k
- 7 h* z6 W1 p, z
6 ^5 Y5 }. g" v" M. s% {- A20Write: xor cx, cx ; Reasonable wait
, i+ H. z5 s1 h9 O( f - get1: in al, 64h ; Get KBC read status
7 Z" g8 f. W' }& j* v0 Q: A0 P - test al, 02 ; See if buffer empty, bit 1 clear , X% p! q' c* P! u. E% D
- jz clear
( a) U: l( F, b' u; S - dec cx
& ~ [7 @+ c. `7 n; e1 _ - jz exit3 0 c1 q* M! t2 D+ f4 l4 m
- jmp SHORT get1
- c# Y% ?( R" I$ l* h - clear: inc al ; Clear ZR , V0 `( |& A: s% B m3 k+ Q2 N
- exit3: ret 3 `$ X/ b r5 A
- & x( j. M7 V" m8 P" d
- ! e8 O6 w0 R# W6 W/ w5 T: }$ v
- A20Read: xor cx, cx
1 C7 s& T- Q+ F& H' E - get2: in al, 64h
" B e# ?! X8 w* k% U1 T1 e) A - test al, 01 ; If the 'output buffer' is full, has ) a, K; K6 y3 i* ^- I
- jnz exit4 ; something for me } P C7 ^5 I7 u1 R
- dec cx
, H0 `' @7 @7 U - jnz get28 h3 h- `- X( a8 w1 U; Z
- exit4: ret
; L4 N t% b7 \ o- h0 c! n" s% Q - 1 F$ R2 [/ Z1 s e) j
- end
复制代码 |
|