|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM
5 C4 `3 `$ U2 j! Z$ ~: Z. w - ; 6 j; T1 ^8 G8 [7 _$ @+ s
- ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01
8 Z( d7 Z2 N, \% Q - ; ml A20ON.asm % f9 ?+ ?0 G7 L8 e0 T
- ;
& Z3 b) k& E7 y5 `, s' m* t# t5 n* C. Q - .model tiny
. P4 R: N- v! U B% l' w - .code
# D0 c# j; p A9 R8 J2 F7 k - .486
. T& k; T2 Z/ ~4 Y z6 I# I5 o8 I - .startup' H6 M6 u4 D7 b
- ' y) ]: Y" `4 _* o( h
- mov dx, offset msg_author
* P5 w8 [% p& D: { ^ - mov ah, 09h
; G# |4 v+ R/ M0 a" i) X/ Q - int 21h
! D/ T6 j) F( [8 X+ n - 1 r# f! Q) y! m3 b2 m9 Q
- mov dx, offset msg_fail
8 Y5 b. D, H% G7 P6 S& w' O5 L - call A20_ENABLE
! K/ K3 ~+ j+ P* h! @& ~ - jz exit1
- l* ?: {5 }8 t - mov dx, offset msg_ok
+ {! B) ~7 e2 H) k - . V2 g x, S9 c$ J, u4 c* v
- exit1: mov ah, 09h
- N9 x4 q/ u5 ~" X2 A$ K0 M/ o* J - int 21h / R, Y! h7 c. T9 ]2 O5 H9 l3 P
- mov ax, 4C00h
% w, ]* a$ u& _ - int 21h
; v" h" U0 N4 w( Y- O/ s -
) U$ N0 I* i1 \4 u% d/ r - msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,- L/ A8 u) L! _, b) }0 {8 G
- "2008-07-01",13, 10, "$" 0 u6 n% P: ?. E& O# U, ]; ~5 y6 f# W
- msg_ok db "A20 Enable OK", 13, 10, "$" # f" q J3 m% g' i u7 t
- msg_fail db "A20 Enable FAIL", 13, 10, "$" ! v/ Z* B9 n$ n/ w- u
- 7 ~: |0 ?9 P3 l! I8 K4 e" {
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------/ a' i3 G8 H3 P% g7 O
- A20_ENABLE:
0 o$ i8 d; C4 l7 g: v7 d& E - call A20Write
& y' k" H& a% h0 Y3 c; K - jz exit_enable
# Y8 b* L5 [- O% r Q - 2 B) m- C. O% a4 r* t9 n
- cli ; Only need for reading value from KBC 2 C- a8 l6 x+ I. ^
- mov al, 0D0h " \" O; E8 |4 ~+ g# ~
- out 64h, al
2 t7 \8 D% j! U$ U( H0 ~ - call A20Read
% B( f. R C4 F- ^. z# ~: O - jz enable_int $ L+ w, h9 Z- B) V; q9 C
- 9 n" W- L) k( k O
- in al, 60h ; Get current status * A' X* E+ s* f3 l C9 B# u
- mov ah, al ; ~( |* G# K/ \0 J$ b9 b. V
- call A20Write % g% s% i$ o4 R, o; Q. X) k3 J, y
- enable_int: sti
`( R9 R, P' ?2 J" e - jz exit_enable
# W1 `) h2 ?- n! V, K9 E9 V - * I% _# H/ J! J. f) V7 e/ c
- mov al, 0D1h ; Tell the KBC , want to write to the & x, _2 j: ?& {3 u6 j
- out 64h, al ; Out Put Port next
* p2 r% G( g; o4 k$ c+ z - call A20Write
4 U! V4 J# V' s- }1 g0 C/ M1 Z f - jz exit_enable, G* |' ~3 Z, E9 k! p* d8 @& V
- . P2 U7 }: Z: c9 r0 f4 \7 K
- mov al, ah 3 [4 N4 \5 f2 M; O+ q
- or al, 2 ; Enable line A20 6 P6 @- h) D- P" F* u
- out 60h, al
& a4 c; I [& V& C - call A20Write
& u" w3 Y# z# L - jz exit_enable t9 L0 A! u: E
- * a9 f: V& f/ z) a- w. |. G
- mov al, 0FFh ; NOP $ F# N- ^8 [1 m+ A; g% x! N/ w4 ^% }
- out 64h, al
5 J5 T& }( i* Z! L5 K% L l, R - call A20Write
4 i0 F5 N' E- F; ~% @ u - : o9 e, Q7 l3 e" n
- exit_enable: ret
3 [4 \' ~$ j* C. A8 Q: T0 c( j - 2 v3 O1 i# K5 Y- R) g
- A20Write: xor cx, cx ; Reasonable wait
9 G, h- j7 _- B' g( x) P* o - get_wirte: in al, 64h ; Get KBC read status 3 s7 W& I1 L( @5 l+ y
- test al, 02 ; See if buffer empty, bit 1 clear , m T* {% G4 l. W) f
- jz clear
$ T; F2 i* l( t" t6 x+ [0 r - dec cx 8 B$ k( ^+ G0 u( X9 D3 q9 X) I
- jz exit_write
3 J9 t3 R, a: \) ^. @ - jmp short get_wirte
% I- M( J* a3 v4 }) ^4 I6 @ - clear: inc al ; Clear ZR
8 @5 G3 E6 X. a' f# b - exit_write: ret
$ W! @- u. a/ L+ p+ F - * |+ T) @4 {% a7 f) ?$ L, x! H
+ z: D8 _, U8 t4 X/ X0 }6 z3 C- A20Read: xor cx, cx
& O% g6 C9 V9 b5 _! e0 \ - get_read: in al, 64h
d+ e9 x9 e! H. B. a - test al, 01 ; If the 'output buffer' is full, has
1 j: c: r+ {9 f3 K" n( Q. I - jnz exit4 ; ... 6 H! \* U; g3 H' R: `8 D
- dec cx % f/ I* V( d* w3 ]8 q2 @; K2 S4 v
- jnz get_read
; J& `6 o: l) C/ U: l - exit4: ret
3 l# v0 ?; j3 t. ~9 k -
, [" k2 I2 f6 ^# T8 k5 Q+ x6 {- }* N - end
复制代码- ;A200FF.ASM
9 A6 \9 c7 i* k/ `# J7 ~( u% Y - ;
+ Z- O5 |8 W# D1 J0 Q+ [0 O - ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01( J% U" `0 s. c% }6 F! K
- ; ml A20ON.asm
, y$ w: o7 w0 f - ;
& v8 B: K, u# R$ U/ u! l - .model tiny8 f {& f$ |0 [; `( S- A, e
- .code
" e" Y _) g$ t/ ^- N! w - .486
$ J; g8 \; k. I - .startup4 b6 y M; F d1 P( @3 g
% O- ^* u- d$ q% L0 A- mov dx, offset msg_author3 W" k: }0 B( E- F
- mov ah, 09h
3 Y5 W4 _' _+ A+ d: J: _ - int 21h8 K1 b2 S: p/ V. c& }
/ c+ Z' L) b# Y$ M- mov dx, offset msg_fail
9 E2 ]& c, x% Z0 s0 r - call A20_DISABLE
9 F0 Y: l& a1 M x4 O" |3 n - jz exit1. X5 f$ @- v7 M$ d' |, u' _) e+ J
- mov dx, offset msg_ok
; m, r, \8 j1 A; P; I. |
2 l+ u8 E3 C6 z, ?8 H% F; K: Q- exit1: mov ah, 09h
M& [3 u( k5 {7 ?$ F) @5 a - int 21h
* B4 t5 b. ]" s0 c - mov ax, 4C00h 3 n; |4 V& S1 [+ V1 E
- int 21h
7 H3 t/ X! v0 g( o: j$ _$ |: g# r5 ~ - , ^. ?3 U8 W9 c, W' M' k
- msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,
0 ~- o3 t7 E/ w8 A8 r - "2008-07-01",13, 10, "$"
4 g8 y; U/ J' t! @3 X- {8 d6 } - msg_ok db "A20 Disable OK", 13, 10, "$" . b9 T$ T, R0 c7 C4 `- Z+ W
- msg_fail db "A20 Disable FAIL", 13, 10, "$"
; P" c9 ^) F! j( S% B- E
y/ y7 P" I$ V* ?" B: c* q- ;------------------------ follow code maybe make to lib, if you want...-------------------------------5 U/ \) A9 k: F4 m- Y1 @- _$ m
- A20_DISABLE: 7 f, ?8 `9 A2 @9 i
- call A20Write
2 D9 c) n1 T/ y- U - jz exit_disable& [& z8 v; u7 U4 i
4 s' e) |* i f; X$ C; l- cli ; Only need for reading value from KBC ! w" S% J# E* `" x2 b- p
- mov al, 0D0h
$ k- e" i; G) a1 w4 `7 O* [ - out 64h, al
. c# @% g# }+ h/ @$ d4 y( m - call A20Read
4 P6 [1 G. u3 A - jz Disable_int
9 N- f; t" b7 |/ L' C - 1 M. s9 ?0 h5 |; z; `
- in al, 60h ; Get current status
2 C, f2 z2 {* k% C- g! P g' _ - mov ah, al ! ^6 v; x3 V2 D- T7 |3 ^
- call A20Write ' V) z# @+ J$ v u
- Disable_int: sti
|7 r* k5 n, E& i! N/ ? - jz exit_disable! O8 `0 u1 W; ?- r7 [6 s
- 7 N' O0 D0 M: h
- mov al, 0D1h ; Tell the KBC , want to write to the
- M. m% t. A# h1 F4 p% ]6 B8 H1 S - out 64h, al ; Out Put Port next A5 m) l- g4 z) U* U: m! V8 X$ @
- call A20Write . Q |/ p/ w" s/ R. M
- jz exit_disable
& j3 j9 O9 k" w0 C+ W r9 s+ m
. F! L: I" e7 ~) a+ c/ B- mov al, ah
4 y. t5 s) `0 A8 M+ ? - and al, not 2 ; Disable line A20 5 }! v( {& a) \6 }8 e
- out 60h, al 9 N$ _( l4 B" e9 i2 I
- call A20Write
' l* g0 ~1 q) U* {" f4 c1 Z) A0 f - jz exit_disable$ T7 B t; S6 j0 [ B# t
- * R8 `$ v5 N/ R
- mov al, 0FFh ; NOP
5 Q7 C: _1 F! h0 z3 d - out 64h, al + }: w( c( ]$ D" ?
- call A20Write / e& M' y9 G1 D: s3 J# R# z
' S4 e. k" S& G( C# B- a: o& r- exit_disable: ret 3 Q0 y0 P& Q) v6 {* ~1 r3 m4 x* d
- k$ ?4 G; Y4 f$ Q D! L
- A20Write: xor cx, cx ; Reasonable wait
5 A3 y( ?3 C; c; [. X( q - get_wirte: in al, 64h ; Get KBC read status " v0 M! ~/ A; ?; S) b- r/ c
- test al, 02 ; See if buffer empty, bit 1 clear
$ x- q) q7 g0 _: M. x# N - jz clear " e" D. N) z/ c+ n* e
- dec cx 7 {7 {' g g) ~
- jz exit_write
9 l( N- B% |, X, \ - jmp short get_wirte : N4 [! _, t8 {; l; u
- clear: inc al ; Clear ZR
, |: e* f% y% P/ z( V% N# R' { - exit_write: ret M. z( z3 q5 u5 ~8 a
- ) Z! T i! k& K- x1 ]
( L. d; X1 t* M$ r- y% p- ?- A20Read: xor cx, cx
5 D- ~ S4 y) k" [% W - get_read: in al, 64h 3 B* Y3 c- m' c6 C
- test al, 01 ; If the 'output buffer' is full, has ( F3 N- G+ `1 e% Y
- jnz exit4 ; ... " O, e: z5 _% u N& a+ p
- dec cx J4 |3 L2 o+ p- B6 w! F& D% D1 S. @
- jnz get_read' q1 L/ ]3 Y A9 _
- exit4: ret ' E& R9 P) y" E/ ` B+ F P
-
- g' S, w& c% R9 }& g8 B - end
复制代码- ;A20STATE.ASM 3 N( L4 K) ~: O$ W$ p9 ^4 `
- ;
0 x0 s! K% p9 f4 H* I9 \4 E6 I - ; Returns the status of the line A20 through the KBC
, D6 j4 [$ u. h) K! n: U# p$ C - ; programming by bini for debug. 2008-07-013 k1 c& R. G7 ]+ K Z8 q
- ; 4 O- I& U9 K* ^; D7 G
- .model tiny& D4 B9 X- R9 z9 Y0 O/ k
- .code
3 N6 _: G9 _: ]" q- Q- Z - .486
% r0 B' g$ u4 b1 v5 L7 |, Z - .startup* S; {7 r/ \8 l3 a G
- mov dx, offset msg_fail
, M9 p, d8 W- C - call _GET_A20_STATE_
+ C* \3 \; X% D% ~- J - jz exit1 ; was a problem: K* k, D. J$ S$ d4 X% j
- push ax ; Save state, AH
! R$ r6 ?" @/ x1 m - mov dx, offset msg_ok ; There wasn't a problem 4 v: x- F- b4 n3 R
- mov ah, 09h
! e, n N+ q# C( B5 y - int 21h ; Print message
H, S- q! ~. D5 b, m - pop ax ; retreve state
. z* c x ~+ o - 1 p5 W& ?* s$ e {9 L9 f& Y2 Z
- mov dx, offset msg_dis
3 k$ F$ B# ?6 {/ F0 L* w3 v - and ah, 00000010b ; bit 1, 2h, indicates state - o' \. m5 s5 k2 C. `. M' }
- jz exit1
7 s" o, k) h E- u3 o - mov dx, offset msg_en 3 {9 Q' w9 v6 D9 j+ b3 n
- " e6 `# H7 M" M( _2 e& o; r! }7 |
- exit1: mov ah, 09h ( V. z2 C, ]+ K- U5 N4 W8 a
- ; DX already contains address of string ; b/ }' E& C( j% J- I
- int 21h 5 L9 }; A9 H8 M! I9 d
. E8 Q& `, N, L! K/ {- mov ax, 4C00h
. b; |. j3 g# F1 F5 ^8 {/ Q5 R - int 21h
% i1 F0 d5 k( D% o - ! S. y$ U/ E" d1 x6 W# u
- msg_ok db "OK", 13, 10, "A20 $"
/ ^- o/ x, Q: y( E - msg_fail db "FAIL", 13, 10, "$" $ W" c7 `8 L6 t& @% u# S
- msg_en db "ENABLED", 13, 10, "$"
8 H% O% h& E; R7 \ v9 q - msg_dis db "DISABLED", 13, 10, "$"2 T8 H3 c* B0 d3 t3 p
- * j8 W5 P% N' b/ p/ N2 M$ f# {
-
8 S' d: H9 U! Y - _GET_A20_STATE_:
% s. A) ?8 |* x( L; l - call A20Write ; Wait till the input register is empty
+ c t. j; D; l5 e' H: R - jz exit2+1 ; Bypas the reset int's ?% B: C5 k& t8 {% `& |
- cli ; Disable ints so we'll get our value / V% s; k+ l0 s1 z1 Q" |- o
- ! W. D' |7 h9 J' R7 j6 _
- mov al, 0D0h ; Send command to the 8042 command register # D6 p( J! y0 H! E7 z
- out 64h, al ; to tell it we want to Read the Output Port
% y& ?2 Y4 a( P - call A20Read ; Wait till the 8042 output register N- W3 J6 H5 L3 L
- jz exit2 ; has something in it's buffer
9 p( a9 F1 p; l4 E: t7 L& r
* w* Q# g0 L/ u' t- F4 ^) Y- in al, 60h ; Get it
( J& j2 q& m# |1 I5 b; ] - mov ah, al
& L+ r& _/ S% [ - call A20Write ; Make sure the input register is empty + W) ~" a3 V# s
- jz exit2
4 o1 h0 S0 A) g# W1 P }
6 j3 W6 @ x1 N/ Y7 F' f* R- mov al, 0FFh ; KBC NOP command, does nothing
' {8 Z* _# }+ }9 g - out 64h, al . M3 R/ I" o! z
- call A20Write
# \( a6 |; Q# n
) u* v" ]/ H/ i+ @3 e- exit2: sti * ~8 r w |- d9 ]0 M
- ret3 E- V1 p+ T z5 ]1 x
- # x& M# }. I& S3 ?
$ c: S$ a( ]+ }% {* Y% A- A20Write: xor cx, cx ; Reasonable wait 7 s% \: t2 |+ k3 T
- get1: in al, 64h ; Get KBC read status 4 e- E) @$ j4 Z+ Z3 P$ }: s# ?
- test al, 02 ; See if buffer empty, bit 1 clear
2 [+ |2 {* E* j1 m - jz clear " K9 p9 @ ]9 t- [7 Q
- dec cx
- A# g4 D8 n) H1 K5 H - jz exit3
) p! w/ \! L. c* |0 x: O/ w* S% a1 f - jmp SHORT get1
) }4 e- P+ i2 g8 T! j" ~& |9 R - clear: inc al ; Clear ZR 3 |; }: ?; t5 E+ R- K
- exit3: ret
' D/ y' I! J I0 G# F - 8 z" O/ T+ }- c
- * q4 ]5 A: F2 I3 ^9 V" ^' K& v9 K
- A20Read: xor cx, cx
$ e% a: Z/ p) t6 ^ - get2: in al, 64h , N5 O; e" M4 i0 x. w
- test al, 01 ; If the 'output buffer' is full, has
9 u5 g+ K2 D$ {* ?% _ - jnz exit4 ; something for me
' B' k$ |4 Q+ a$ {# x, G9 o, d - dec cx 5 r ^- P- F0 {* n; T5 D Y; d
- jnz get2
* K5 H, @2 q! V" V4 M! \ - exit4: ret , l, [/ O4 f! I! G& @+ E! h' R
- ' l# m3 \6 H z( T; d! `
- end
复制代码 |
|