|
|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM
& X9 b2 Y* }) J" e' k3 D! w! a - ;
3 [& }: [5 ~ t. O- C" x - ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01
, G4 w: E0 Q5 ]; U, q4 Z { - ; ml A20ON.asm " L; R6 m' i: M: O5 y# A0 s* Q+ D! k
- ; / m, O+ m$ N0 h' j; i9 A
- .model tiny
; Q' f5 u- _) i. _ - .code( N1 V/ ^: U% c9 W, L
- .486! y. ]2 R4 @4 X0 K/ r9 K& F# n
- .startup1 Q: _. z& I. P
' b' P" Q! m- O5 N; u# A- mov dx, offset msg_author
1 A! G6 C) q, x - mov ah, 09h
4 u3 f5 b! l/ T" l) G6 B! ~ - int 21h5 C8 l* r- D" I% |5 ~2 n
5 o* O! U+ I5 |- mov dx, offset msg_fail
4 U, h8 y T5 L3 c, W3 | - call A20_ENABLE
* e6 l# n: A# l - jz exit11 e/ C6 d, ]2 c1 L
- mov dx, offset msg_ok ! i, Z$ `2 _) W+ Z
- j! [5 ?3 F4 J# H; p/ f
- exit1: mov ah, 09h 6 V! `/ c5 e4 g' m, z
- int 21h . K8 x" A; N6 c" [0 K9 }
- mov ax, 4C00h
9 p, m2 b' ^( `0 t' D - int 21h
7 [$ Z3 W, A& c5 } -
4 m4 D( r6 c K( R0 {& [ Z Q - msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,
" D# Q6 K. {7 g( F% @: p4 v# s* U - "2008-07-01",13, 10, "$"
" ]7 D/ g U/ h. u& W3 ~ - msg_ok db "A20 Enable OK", 13, 10, "$" 9 ~' i4 ]4 k$ v5 k" k
- msg_fail db "A20 Enable FAIL", 13, 10, "$"
8 P! Z9 R8 s/ t0 Y
& D1 Q1 u5 E0 }- z7 F- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
$ E I% X# R! W6 k - A20_ENABLE:
) p% W" N6 W$ k. j/ I/ {3 V6 u - call A20Write + ~! f; f9 [, _
- jz exit_enable3 ?) `8 F3 g) I. n, t% r
- : U' n0 O& N% X$ C2 Q1 y! Y, Z! P
- cli ; Only need for reading value from KBC : z- @% x1 _) @/ u6 D$ G4 s/ q! l6 e
- mov al, 0D0h
& i! h/ k- X0 Y# I+ W* m* a) D. T- A - out 64h, al 8 u* E1 ?. w/ ?8 f Y3 Y
- call A20Read
5 X4 u6 Y. D% h. A - jz enable_int
5 m; D9 b E9 j" j5 x. M% p
* q+ z i& o# f' b) ]6 ~( \/ J% \- in al, 60h ; Get current status
: S7 X& C; S9 l% u7 e - mov ah, al & X) d$ x3 S8 u; z' W9 C
- call A20Write
8 S$ @4 h& o* r6 y+ z8 M - enable_int: sti 1 ~ P2 \6 o. M b/ v) K! C ]4 E
- jz exit_enable2 R" z' g1 @2 J: T/ i/ {" V% U3 u
- 8 e1 P6 y6 m2 O1 y
- mov al, 0D1h ; Tell the KBC , want to write to the $ ~+ |: d4 B2 @6 d- D1 s( F
- out 64h, al ; Out Put Port next
) ?) ~+ v( z* a" l2 D - call A20Write ( {1 y8 o7 t3 {4 Y. F
- jz exit_enable
: J" f4 ~ U" y - : W2 I$ c( n6 a' X' }! n
- mov al, ah
6 k8 J! ?4 ]/ Z - or al, 2 ; Enable line A20
8 ?0 }3 c( ? A# q3 n4 Z - out 60h, al
& Q) y8 |8 S" G - call A20Write 1 D7 a% Z2 x5 X3 l! d+ f
- jz exit_enable
: s+ e$ z+ n6 G0 p' S0 ?0 p1 p! R - 0 e; X) r9 R+ ]; Z4 k. Z, H
- mov al, 0FFh ; NOP
6 h: W- I* ^$ u - out 64h, al " d" I" X- s N) e0 [/ l
- call A20Write $ @/ U0 O" E4 e: D- c1 Y& z% ^
- 0 m! D$ s6 v r
- exit_enable: ret * y& c3 k: e/ ~$ D$ c
- ! ?% i) R% q) j' Y! a: ?
- A20Write: xor cx, cx ; Reasonable wait + h6 R1 }1 L- W2 l' X% x. t
- get_wirte: in al, 64h ; Get KBC read status " m3 s9 F4 d4 q/ l/ |0 W
- test al, 02 ; See if buffer empty, bit 1 clear
: u( y+ G% @. b& b; i - jz clear
6 b3 z1 M0 w4 m) S& E* J - dec cx
9 I( [8 ~6 r/ ~1 l7 R: l - jz exit_write ! j* N( ^. h# u5 b% o
- jmp short get_wirte , {& [. {/ B( I* K2 p/ d" ^
- clear: inc al ; Clear ZR , B7 A& {9 X5 q5 Q( O$ j" r, n9 \
- exit_write: ret
* U J. t( H8 {4 { - % ~; P' K1 W1 f& J
; |; Z, j" J/ h$ Q/ j- A20Read: xor cx, cx 1 w2 [) O- U4 c, [" s* d8 X o
- get_read: in al, 64h
: J" U4 b; a3 V# Q+ o1 g& ] - test al, 01 ; If the 'output buffer' is full, has
+ P) T% p+ G8 t$ I O - jnz exit4 ; ... $ v" Q7 c# F7 F) ~# b( e3 W; g
- dec cx 8 f: i y- [- z' [* H
- jnz get_read
3 c3 O5 |1 P( q2 m5 p2 t - exit4: ret * g* g- ]/ |+ m) i* |, {
-
% @, i3 Y2 m6 ` - end
复制代码- ;A200FF.ASM
, O& _1 e) f- W - ; ( Q, w+ I8 Q+ f
- ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01
t, G9 d% ^& j Q# K& A - ; ml A20ON.asm
6 x2 S+ d* L3 _ - ; # @0 W; z; n# o/ L9 f
- .model tiny6 M0 K9 r2 z; c5 G% q) m) S
- .code, B) s; w& e& [
- .486# H) Y. p% X$ k
- .startup
" p3 q( u8 q S: s+ X. g - 3 V/ f" q8 ~ O
- mov dx, offset msg_author6 ?4 W+ B/ ~6 S, `9 ]9 R
- mov ah, 09h
- p& a. [9 M) s - int 21h5 N* _: \& j) k8 v
7 r/ X& n7 F+ v9 N- mov dx, offset msg_fail
3 o1 e2 b1 I" Z. U - call A20_DISABLE
! ]- ?) M4 G8 A - jz exit10 q- z! \; I8 x1 |/ T
- mov dx, offset msg_ok
2 B, u/ X. |# p' v. p - ! a; M; D( ^! _" m
- exit1: mov ah, 09h
5 @$ ?- m1 T# W1 F- F - int 21h & Z' M7 J2 W* j6 x
- mov ax, 4C00h
, C w" z) a( N1 p - int 21h 1 U5 m8 X0 N3 U% [! p6 q( ~
-
9 j% T. |. P2 O - msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,! R& c% o' A' V; v- w
- "2008-07-01",13, 10, "$"
3 M- E# r7 L6 d2 } - msg_ok db "A20 Disable OK", 13, 10, "$" ( g- A; \% d+ |. i" y: c+ g# h
- msg_fail db "A20 Disable FAIL", 13, 10, "$" 0 A% T; c" e' @3 l$ b, y8 G6 G9 N2 B
- ( j& }+ V- J# Z" F' u5 Y6 _
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------+ ~# L0 t5 R) `% f/ f
- A20_DISABLE:
+ \2 j: W8 v) u/ ~ f# O0 {8 m) \# L - call A20Write 2 u" O' x0 w, Y$ [0 `2 H3 p
- jz exit_disable( V5 i. ]" c9 \1 N# E- I7 f }
- `% t$ b1 w0 }( ~6 M* N5 U8 {- P
- cli ; Only need for reading value from KBC 7 I8 l1 _5 `0 B5 l9 z7 T
- mov al, 0D0h & k- b5 _% P4 ~. z7 i
- out 64h, al 6 T% ]: H B/ f9 t% F% Z9 ?
- call A20Read f) L2 k, e0 J5 r5 E% q" ?
- jz Disable_int
" j$ b7 {1 l( Z+ Z$ w
- F' a2 s0 n" V2 W3 W- in al, 60h ; Get current status
/ r3 ~: h" L9 J ?/ i4 u - mov ah, al % B" O% [3 a2 I& d; h
- call A20Write
1 q+ A2 Z. I6 N5 v3 U - Disable_int: sti
$ L, R$ I3 A, R H$ d% n - jz exit_disable
3 ~' ]4 Y: Y9 U% E( w6 i - 8 J* j+ R8 z& X9 D
- mov al, 0D1h ; Tell the KBC , want to write to the
0 ^ w* v8 r, h) y - out 64h, al ; Out Put Port next . c. \: v% C& [$ X! U: B* K
- call A20Write 1 a: S( |( X0 h/ u
- jz exit_disable
, c! ^- T2 W/ c1 ~- s% p# f
5 ?0 ?; N' T7 o5 e( [- mov al, ah
1 _/ g9 x# \7 u& e2 I - and al, not 2 ; Disable line A20
% P: `. T- Y' D; @1 l: m - out 60h, al % g4 z- h0 I p; Q
- call A20Write
0 F* r! B+ J0 P3 O- x; J5 U - jz exit_disable
% S# W- r$ n" C4 H0 v
" h+ I) _, j, c' C, U- mov al, 0FFh ; NOP
) A: W( y3 x! e% O) d# | - out 64h, al ( M; O* S# b) |2 K
- call A20Write 6 Q+ t: g+ f) O
- 7 C9 T0 {5 P' o. [" d+ P# d8 N# p
- exit_disable: ret 5 \) S( c- K6 S. D8 y2 F
- + x& o) M3 x% g% Z* g
- A20Write: xor cx, cx ; Reasonable wait + E3 j8 C6 O1 k) S" E
- get_wirte: in al, 64h ; Get KBC read status 7 s: U+ ^9 _* S
- test al, 02 ; See if buffer empty, bit 1 clear ) R6 Q2 Q* v/ `4 W: E$ x* M
- jz clear 8 f/ l+ Q+ V: ^$ J" V
- dec cx f5 y% q. J- A% I
- jz exit_write ' a1 k. D& O) `) h: f: S
- jmp short get_wirte ! N& @5 S1 Z# k* X
- clear: inc al ; Clear ZR
7 E2 I) [5 R3 s* z4 Z4 j - exit_write: ret
9 O) J7 J/ ^3 N
+ |. i$ z& T# f3 Z# d8 G' X) [- ; p$ A2 F( D! ~
- A20Read: xor cx, cx
% S- j+ T9 k$ I! \+ S, r - get_read: in al, 64h % B/ v: o, M6 x" M# \1 r
- test al, 01 ; If the 'output buffer' is full, has . z& b4 V$ i3 y2 z0 w" x& Q
- jnz exit4 ; ...
, s. U& B* ~( J3 O - dec cx
: P0 T9 A( _, \) L0 {/ E: Z - jnz get_read6 X" d |7 U% p4 {. `0 _+ `: D$ N
- exit4: ret 9 A: ]3 B6 M; p- r5 c
-
2 {8 a; M l5 \ - end
复制代码- ;A20STATE.ASM ( X! D! |( W# @1 U7 g
- ; ' e6 \' P+ s, M3 u
- ; Returns the status of the line A20 through the KBC
" m: ]0 j; C y( H" o# [ - ; programming by bini for debug. 2008-07-01
& v8 L6 _7 `3 W2 R, V" V: D# R# v - ;
( V* X1 O8 Q9 Q) z' I2 M - .model tiny
) B' O. i5 B. j5 A& h; ~- S: \ - .code
. s* N& V& y& C: j5 z1 I; x; W - .4865 J# F* U& G3 `% n0 N6 [0 ]
- .startup
4 g" C' _7 x7 b \ - mov dx, offset msg_fail ( ^4 y0 u" B# `. Z! a, M! ?: v
- call _GET_A20_STATE_* g: w j: [ |* K, u/ p2 B' [
- jz exit1 ; was a problem
- T6 r' l }0 R# Y3 |) J8 E - push ax ; Save state, AH
( z) h6 [$ A* u - mov dx, offset msg_ok ; There wasn't a problem
w$ [1 i3 P# D3 S* ^ - mov ah, 09h ; ]) M1 U/ ?) s
- int 21h ; Print message # W* c* c: O1 o
- pop ax ; retreve state ' i1 T% \4 q* J- g
2 X$ }5 N$ r( ^2 s O t- mov dx, offset msg_dis
/ H R2 p. x/ q/ `2 e" q+ U - and ah, 00000010b ; bit 1, 2h, indicates state
- k% k1 e. t- {# B; t# ^ - jz exit1
# N4 {1 I0 ]7 v& p8 U: T - mov dx, offset msg_en
) Y$ R# f1 c% G0 P. W8 ^$ q
2 Z+ H. T' s1 c; j5 y: ]- exit1: mov ah, 09h
. M) I" D0 b& d2 c4 O7 U3 M - ; DX already contains address of string # k8 D- R8 h$ H. f+ p3 I
- int 21h # E( J+ c2 K3 L6 l3 v
* m7 p+ ^/ m# x& h- p, r2 H- mov ax, 4C00h 6 s/ @8 ~2 M( Q) r# Z. ?
- int 21h 1 P7 Z. b% z1 _! r4 A
- 7 X" _2 u' {3 k* {3 [4 D+ p/ w
- msg_ok db "OK", 13, 10, "A20 $" 0 J8 j- _8 l! t7 \, h/ c' P" ]) ~
- msg_fail db "FAIL", 13, 10, "$"
) D- }) v2 H. ?. U7 A - msg_en db "ENABLED", 13, 10, "$"
/ j" W6 t7 \. _( S9 e* a4 w - msg_dis db "DISABLED", 13, 10, "$"
' ?9 d* H8 |6 N7 `% ~9 J+ s
J! d5 J& I# z- b- ( ]( j7 d& Y' {3 a" A* F' n! b- K9 I
- _GET_A20_STATE_:
$ t7 h) i- K' p6 C/ U# A - call A20Write ; Wait till the input register is empty - U9 }2 \8 `! x* U- J
- jz exit2+1 ; Bypas the reset int's
9 Z8 _; r: T" N0 I$ | - cli ; Disable ints so we'll get our value % B, t4 g3 B" r8 ^& O3 k
- p6 [' s* l) W H6 B6 C: X5 N- mov al, 0D0h ; Send command to the 8042 command register
% Q7 u- y5 d- i y - out 64h, al ; to tell it we want to Read the Output Port
5 _6 ~! [% S2 ^1 y - call A20Read ; Wait till the 8042 output register * E. n% z% i" e7 y# T
- jz exit2 ; has something in it's buffer
& H* y9 E6 k0 N# k. `
: Q1 u! M) z& c% `% H+ R- in al, 60h ; Get it
4 v/ A7 x R$ l9 |0 ?( ^ - mov ah, al
: w5 k; i% b9 d2 C7 w q - call A20Write ; Make sure the input register is empty 5 }; S: S, C7 |( R& F" G2 A3 ]
- jz exit2
2 |$ _, {6 T) ^( v. R4 n8 _ - * q, T: v% z: O9 Q
- mov al, 0FFh ; KBC NOP command, does nothing ; S* S! w4 M4 b' v: j5 D- _& N6 F
- out 64h, al 1 m; O: `9 w! T7 K% [
- call A20Write * y; r, p1 n" K9 d
- 3 `9 Q1 p8 w Z& |% t ^' q5 F
- exit2: sti & N( z- R. K x$ A, z/ g
- ret+ q; H. ^! r V$ r
- - ^" |+ x1 G7 _# ^4 Z- c
- : q/ n s6 v3 s/ h& m/ Z$ u
- A20Write: xor cx, cx ; Reasonable wait
- O/ H, a `" V# O- j# m Q9 ^ - get1: in al, 64h ; Get KBC read status 1 V5 o4 w7 H& I1 V" _5 J
- test al, 02 ; See if buffer empty, bit 1 clear
& w4 t6 X: m2 C7 K9 [ I - jz clear # {. q; r. @, \: R2 I% B! p
- dec cx 1 B4 _1 p; Z# U: @
- jz exit3 4 k ?& z5 z: r4 J* C" H" |1 O
- jmp SHORT get1
9 l1 E6 [. T% J( A7 l - clear: inc al ; Clear ZR Y& u" s; i& V+ k: L$ p) y
- exit3: ret % Y0 W6 x9 @1 i( Y
- ( K' J+ @% |# R$ i& ?
+ b' A2 b. i# j7 D6 ]! i' H- A20Read: xor cx, cx ' g1 j; k2 n" y" D
- get2: in al, 64h
4 x! q6 h. x; J$ V6 h$ f! F - test al, 01 ; If the 'output buffer' is full, has
6 O! P0 m/ q( n2 a* ` - jnz exit4 ; something for me
* G4 y5 J+ u; e9 C/ T7 S' u - dec cx ! o( U' R' K9 `+ r' h5 g
- jnz get2
! e: t4 C+ S5 a/ @1 w - exit4: ret ! W8 L% l* L. v8 P( y" ~; x6 J2 l! @ O
- ; e4 _) B7 m* g2 l" [) H1 C" v2 v/ j
- end
复制代码 |
|