|
|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM
! @8 b% c% T9 Z! c - ;
0 u7 H" `$ U3 b: r9 x$ l* P1 F3 A - ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01
$ m7 ~: g. e+ o- K - ; ml A20ON.asm " m- j) l# t. f5 \
- ; 9 \6 a6 |' [2 m6 z8 {
- .model tiny! ]. a- [5 Z4 x" T3 G9 F
- .code
p% L, @" L5 _1 K5 }( W - .486) C6 r% x) M$ _6 A# f0 v6 A
- .startup" x* A6 C, t5 @6 X" E% k- t
- ' m0 W0 S+ y/ Q2 k, b6 S) F0 ]& }
- mov dx, offset msg_author
6 E* r+ q* s: ^4 f7 e. j - mov ah, 09h% H0 m5 }5 m, _" R/ I2 M/ x0 w
- int 21h/ ?' n( S6 `3 A7 p5 R: F7 {0 Z* \: M
- # _, |9 O/ Y6 `8 ^" @# Y
- mov dx, offset msg_fail 9 o# L: {! s7 g4 M! j
- call A20_ENABLE
4 a4 m7 D, z5 ?2 ` - jz exit1
3 ^3 P: N. o/ R& Q$ m0 Y - mov dx, offset msg_ok * D0 t$ e1 q- n, r& _6 S* l
- * [5 v9 ]) D! L/ {( }/ M6 Q+ e( j
- exit1: mov ah, 09h
; P! N2 A5 m( Q+ e3 w; r& H - int 21h
' P7 r1 A& h/ M* V4 K - mov ax, 4C00h
* T( K2 W2 ~! k `- F2 f" u - int 21h ) u" P- g, c( C1 C
- 9 ~- c( e" G7 |" {
- msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,; J. f9 U+ _! e+ {) ^
- "2008-07-01",13, 10, "$"
" p8 K: i+ B+ K/ h - msg_ok db "A20 Enable OK", 13, 10, "$"
4 ~3 I: H) @6 C7 x/ J$ L - msg_fail db "A20 Enable FAIL", 13, 10, "$"
: W6 P; |8 G* r4 t: `2 j
. o$ V1 y5 O b" M" R- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
( u8 E+ e3 T' u' D - A20_ENABLE:
; I1 F! ?; i6 l4 U. p- k - call A20Write
1 G/ R" ^- F$ ~; v" X( ^ - jz exit_enable g. ~: C# e" d/ u' }
3 s, C0 i# [* t$ ^$ @4 F' B- cli ; Only need for reading value from KBC
8 l( c4 @+ F$ L9 ]( c - mov al, 0D0h
. `" A! M. {" d. E4 I' u - out 64h, al $ G0 m. [' Z7 R$ }
- call A20Read
0 s9 L% L5 C! D% f- x4 f! c7 H, X8 B - jz enable_int 2 H# |6 a. K( y8 ?
( P \& b9 R( Y s- in al, 60h ; Get current status
3 \! P7 U% ~- Q4 b! ]. `( X - mov ah, al
1 h/ r3 ]. b O x2 W0 }' q" N - call A20Write 9 v$ C6 c; b8 U S% h2 o
- enable_int: sti
) ]) b4 U4 E% t: m" U9 b7 w - jz exit_enable
& A1 U0 x8 ~! _2 q - % N8 ? c( ^; I, ~8 U
- mov al, 0D1h ; Tell the KBC , want to write to the
) Y6 G! D- A" F# t) s# m1 h - out 64h, al ; Out Put Port next
3 ^; ^+ G8 [# C# v5 h - call A20Write
( r2 b# D+ t; f - jz exit_enable, w0 @5 Z {. z) n/ N: |. u. ]
- 5 d* ^, g* D( k7 n) L# z3 `
- mov al, ah
, a4 z9 s1 ]% j, H; z7 N. Y2 \. I5 R - or al, 2 ; Enable line A20
5 d( d( y$ P3 q7 B - out 60h, al
( f( k" G* i- r# p, @ - call A20Write " k" M9 V! E5 I/ R, t% }; i" c: \
- jz exit_enable9 C* Z5 C* a- h+ J' k/ x+ y
- 2 y0 ^5 e9 V# o% o' y
- mov al, 0FFh ; NOP % T: n2 S% H$ I) I4 b( U) o' A4 Q; U
- out 64h, al * G- {2 L. _2 C+ `. t/ M
- call A20Write 6 b! n; V) L/ M8 s
- , m$ a, W- R+ G! N, A. L* g4 {
- exit_enable: ret 0 S# S9 s1 p% m2 i2 P6 E
. o7 s. ^. w9 V! j7 O& b- A20Write: xor cx, cx ; Reasonable wait
. {) Y0 i; |9 _, U9 S - get_wirte: in al, 64h ; Get KBC read status
8 m& z7 q" n. z! [6 C - test al, 02 ; See if buffer empty, bit 1 clear
* r ~, X) M, N+ @+ ] - jz clear
0 b! e, I+ n% \7 V: D - dec cx
. Y1 [' ~/ O5 K0 E X' a6 v - jz exit_write 9 U- x1 g( _! R! d) v9 i
- jmp short get_wirte
+ x3 {( k& j2 R- B5 i* a" @ - clear: inc al ; Clear ZR 9 l8 E( G( e9 ?0 z$ b0 M$ I* R5 ~
- exit_write: ret 6 [ M' M! W& V1 G, @+ m% c6 a
' b, U' w/ u u% B+ }$ O3 J- 2 F) [' U: O* w) E7 p
- A20Read: xor cx, cx " ~2 p* }5 }2 D$ t6 v, G) P/ @- W3 b. n
- get_read: in al, 64h
# S* _; ]& x: Z3 V/ }% D$ b - test al, 01 ; If the 'output buffer' is full, has 2 L& N* f& G, E" j( g; G2 A
- jnz exit4 ; ... # V! p! x5 ?, b
- dec cx - r: v% H; u6 ?1 L( a2 P- {
- jnz get_read% }9 Z; r. T; ]1 `$ }( d
- exit4: ret 6 c1 _6 a; Y0 D6 I: D
- , n1 M% {7 C8 t! I' E1 N$ [. m& U
- end
复制代码- ;A200FF.ASM - S! y4 ?! D) M
- ; , c) Q7 j# _1 k, [: U" \
- ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01
" X" S* W! m# f+ H0 Z7 ~/ {/ G - ; ml A20ON.asm 6 f5 N2 H8 s. X
- ;
! i1 a* ], E7 D2 y - .model tiny
1 [' @& _% U4 Z: J - .code1 i/ {, G2 z+ O
- .486$ W8 g$ V8 {- _8 k3 r$ H
- .startup; x2 v4 {4 |4 ^% t
) p! l7 ~8 K6 r5 c- w+ N: H0 D- mov dx, offset msg_author! Z6 d9 E( G5 ^: u8 K
- mov ah, 09h
9 @1 H& {8 i' m - int 21h- R+ ~9 | ~, M% j/ _7 w- Y* i! P
- m* A- J" _ q$ |- mov dx, offset msg_fail 2 B: E$ e3 t; m5 G1 q0 p8 s
- call A20_DISABLE
, [" o( S# |5 e5 A - jz exit13 q4 }( h! w$ I
- mov dx, offset msg_ok
7 d$ @$ M/ J! b: {% _ - ' o. q! } |9 `9 y
- exit1: mov ah, 09h 1 S, Q" W7 e6 n& w
- int 21h
, [/ H; ]- c! I. [0 D; @ - mov ax, 4C00h 4 ~; e, q5 ^4 y A* ~1 j! I
- int 21h
0 [5 v" j, v; `+ s; P8 } -
J1 b- Q2 l& H - msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,
& ~8 s7 P3 @7 y5 {9 b9 {; e - "2008-07-01",13, 10, "$" * q# R& _' h" H8 _0 K
- msg_ok db "A20 Disable OK", 13, 10, "$" , E5 F3 G- }; j4 E$ {
- msg_fail db "A20 Disable FAIL", 13, 10, "$"
2 E1 C' e. h; Y - $ s! r. g; c& J! L5 C& T
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------; U# z2 `" o2 [ g# g( `/ Z
- A20_DISABLE: 4 K6 m% j E' s2 v5 Q8 v
- call A20Write : |3 H, n$ _* d* } t
- jz exit_disable8 Y5 L! }0 m: e# E
# w5 @% o+ D, j- cli ; Only need for reading value from KBC
R7 _4 m6 V+ j. l - mov al, 0D0h 3 [/ ~' |- V r$ v5 s7 |9 k8 {% _
- out 64h, al 9 T# G+ s! W+ V* m8 X; R; @4 j
- call A20Read
9 m2 l8 ~( M& V7 m4 r& B1 r- X# ^# C# ` - jz Disable_int
5 R& h. ]1 J' p& a" k+ z: U3 |8 ~ - - W ?# j1 q& g7 A
- in al, 60h ; Get current status & J9 u, O" t0 \; `4 G" I# X
- mov ah, al
* o" d- [! @' L6 a6 N' J - call A20Write
7 U" y4 N, m0 J- r+ O - Disable_int: sti : U! V7 o' J/ d S
- jz exit_disable
$ y- o- J$ \/ [
9 v. `& ?% { _/ |+ |7 a/ Q C- mov al, 0D1h ; Tell the KBC , want to write to the
0 K+ f& f' y# e0 n - out 64h, al ; Out Put Port next 6 c: i+ k8 s0 w7 C* o8 P3 B3 n2 @
- call A20Write
' \! G+ M' {$ C/ L - jz exit_disable2 J0 Y; X2 Q7 t8 \1 c" R& t2 [
- 5 x" @$ g) y+ }; p, A q6 a
- mov al, ah , G, {4 V3 O9 Q7 I* _
- and al, not 2 ; Disable line A20 0 x( g& H/ P% K: @
- out 60h, al
( C. k% g$ u) F5 @9 S - call A20Write
" x5 @, v+ h- z3 N+ S$ ]8 g - jz exit_disable# m. ~6 l3 _9 r; J/ M/ t
- % J. M! e) G' i$ F1 f
- mov al, 0FFh ; NOP 0 L F1 ]' x* j$ c( a& E. m
- out 64h, al
; C- i4 t8 ] r& ^ f( P - call A20Write
$ R8 j0 L# U z6 W; I2 P# e - ! L _# W9 g$ \" s4 E
- exit_disable: ret
& m2 V Z+ D5 d C$ g
$ F7 j: L7 ^% \1 C$ I- A20Write: xor cx, cx ; Reasonable wait 2 l% E* |% j4 w. O* J3 {) K
- get_wirte: in al, 64h ; Get KBC read status 8 y) I/ [$ c% \$ @5 u$ j, q
- test al, 02 ; See if buffer empty, bit 1 clear
5 J- X4 h }5 }; G7 R5 e( ]! Y - jz clear
( Q8 C. n# x' q% z0 P - dec cx
0 d2 _5 Z" K. h& s6 f- c - jz exit_write
! P5 I0 Z' R0 y4 w4 y - jmp short get_wirte
, o" B, m( `9 B- |* F - clear: inc al ; Clear ZR
8 Q Q. i" ?1 O1 _2 B# S6 V - exit_write: ret
- X4 Y. Y* e4 `3 M" I9 }$ s - 5 Z. i# e5 @% w2 I( E( A$ s7 N
; I) y- }3 U# {$ l* T( i- A20Read: xor cx, cx ' A4 X' |! Q: Q/ \9 N, e4 J( Y) d
- get_read: in al, 64h
, G) Y7 W$ F" o- o - test al, 01 ; If the 'output buffer' is full, has ! a4 q0 v2 P% Q ?6 z+ @; z
- jnz exit4 ; ...
6 k3 d" t C; o6 \- i& u$ w2 x - dec cx
4 E: W* P9 h# K( T+ m - jnz get_read
9 v" c- B$ l8 |! H4 G! y1 v/ f - exit4: ret
0 }+ k v& [/ d, g - ) h! n& T2 x, f# K7 j$ D8 l& X
- end
复制代码- ;A20STATE.ASM
1 a* o3 F8 M: a5 } b- u- |' ` - ; ) Q! O a5 S7 ]6 [
- ; Returns the status of the line A20 through the KBC
) Z/ W1 L3 y( b$ Q( y* U - ; programming by bini for debug. 2008-07-01# _" T4 D' J/ V" H
- ; * S+ j! }1 r2 k8 [
- .model tiny% R6 j! \7 ]/ g4 o2 u+ C8 X
- .code, ]) N P# v* @ l
- .486
2 P# I+ u0 k. N! d2 r( u - .startup
- G% \( ~. E& h$ ~/ S - mov dx, offset msg_fail ; {; K5 g$ b; x B* P T
- call _GET_A20_STATE_; ?; }$ \5 D+ h9 n& o
- jz exit1 ; was a problem" e' I* ?' W' \- j8 H
- push ax ; Save state, AH ; P# h" A1 X+ i e
- mov dx, offset msg_ok ; There wasn't a problem
7 P# L2 P9 E- F/ ~ - mov ah, 09h $ e4 t- e+ S8 j& W
- int 21h ; Print message 1 f# m9 |6 C7 J" J+ o
- pop ax ; retreve state 9 E3 l7 w2 A5 u+ ]0 u
- ? m/ }# M- @9 k, f3 z9 w
- mov dx, offset msg_dis
( y) o8 A% |" _7 I+ T# J- W - and ah, 00000010b ; bit 1, 2h, indicates state . D z5 b1 O' D0 n5 x" S8 }0 H( u
- jz exit1 b* W0 W/ a a5 |2 P
- mov dx, offset msg_en ( Z* C, p! e6 N; U8 m( e, N
- % s8 d( j. G; d6 ?
- exit1: mov ah, 09h ( [. H! R6 d+ v
- ; DX already contains address of string : p C7 y5 K4 E, y+ m$ P
- int 21h
" G3 y, T9 w5 G+ v - ; k$ }3 k: [$ k8 a* _! `# y
- mov ax, 4C00h
o5 H5 w2 b0 W% v1 I1 K, u, | - int 21h * p: z+ t1 U4 h* N1 H: c V
5 ` E& \/ X+ z; q- msg_ok db "OK", 13, 10, "A20 $"
+ |; B1 s, h# K$ |* e* B* M - msg_fail db "FAIL", 13, 10, "$"
' n$ P& _# o9 L2 q; k+ G, t% n( G - msg_en db "ENABLED", 13, 10, "$"
( k+ h& v2 w3 q" @ - msg_dis db "DISABLED", 13, 10, "$"' A! [& F1 v S3 |
- . z- u; C" S4 b2 J. ?# i1 ]
-
% A7 z: E- G9 G7 m - _GET_A20_STATE_:
7 e9 a E9 Y% `: P1 l; n: R6 G. \ - call A20Write ; Wait till the input register is empty # {2 X: U8 [7 M+ o* O$ Q5 F
- jz exit2+1 ; Bypas the reset int's
) ]+ z% r1 O8 | - cli ; Disable ints so we'll get our value / x4 S4 Y! V1 e* b0 ~( e
- {) W% W4 w: R: R* \
- mov al, 0D0h ; Send command to the 8042 command register $ u1 |4 n3 W, B7 ^! s0 {5 n
- out 64h, al ; to tell it we want to Read the Output Port
$ w/ T7 f. \* Z) Q+ z - call A20Read ; Wait till the 8042 output register
: l3 }% }3 J+ ~' Z - jz exit2 ; has something in it's buffer
) t3 A( I- F, C; D
' d1 @% H, @+ M( K2 H& \1 t, q- in al, 60h ; Get it
+ D& G0 o/ t, r2 B' _- K - mov ah, al
9 M% ]8 T8 ~) n1 | - call A20Write ; Make sure the input register is empty 6 A. n4 G, o/ f8 M* K e
- jz exit2
) e% k @7 `0 U1 W; G. A9 t
W9 F# I% }+ J# l9 I- mov al, 0FFh ; KBC NOP command, does nothing
8 z4 ?7 Z9 @6 W! P4 l9 [ - out 64h, al ; \$ Y9 l |$ w. _: M
- call A20Write
& I+ M) W( `1 x9 Q - ! }- T0 u/ f% D* @
- exit2: sti
0 |8 @ R6 f% j5 h - ret
4 v8 T3 A+ i% @+ P) x" v8 B - 1 J, q3 I* }8 r) v
- 9 C/ I) E0 K; l$ Z
- A20Write: xor cx, cx ; Reasonable wait
4 U" [+ Y9 k9 U" D. ~ - get1: in al, 64h ; Get KBC read status
1 Q$ D( V% H' p4 F3 B - test al, 02 ; See if buffer empty, bit 1 clear 2 A/ G3 d3 w3 t7 r
- jz clear
) {' a0 J! C& r1 ]7 {1 }) ^ - dec cx 1 x X0 L* B( }9 G& `2 H8 t
- jz exit3 ) g: [# t z5 D
- jmp SHORT get1 , H1 ]: Z$ ^9 C; I* u# R
- clear: inc al ; Clear ZR
$ M% R" s0 F1 X- ] - exit3: ret + l/ N& S/ T6 j8 y8 |' H2 z6 Z
" o4 v5 |" b N6 G( r3 [3 d# J
; }5 d6 ]4 ~; N1 v) a/ T) k- A20Read: xor cx, cx % w8 @ j1 C- y `' F9 B: L' k
- get2: in al, 64h 2 y8 h4 a( }( I+ A. }7 u
- test al, 01 ; If the 'output buffer' is full, has - H3 P! c6 u; c
- jnz exit4 ; something for me ; p: k2 A) i: y6 i
- dec cx # _. r+ P o a/ i. B! P7 K# p
- jnz get2: j5 K- I! Q0 N3 f& B
- exit4: ret
9 Z3 a3 }8 N( }/ Z6 `" E& O - $ Z) j F- p O1 ^; v
- end
复制代码 |
|