|
|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM * O3 T @+ f6 h
- ; : F% r% P# H+ q6 c4 v; |# |
- ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01
2 y/ Z V x' ?- k" b: i" l - ; ml A20ON.asm
4 m8 `7 R4 ` L7 i% h0 J - ;
* V5 {( K$ a& c - .model tiny
+ W% j; \1 t) {/ T/ t7 |# L& P - .code) R! w$ T5 T1 g7 D" s6 ~
- .486
$ k0 `' F O2 J - .startup
' I% U5 U$ Y. a+ X* x - % b% I- m9 K/ a% R, Q
- mov dx, offset msg_author; Y) c! {7 B. m% V# e- C
- mov ah, 09h
{. S2 z9 Y5 @* Y" ~6 I$ c - int 21h2 T; G& @* S3 ^3 k* K( |4 k+ ?
- ! u. [- o6 d4 S
- mov dx, offset msg_fail 1 P. C% V' R# c4 h
- call A20_ENABLE
! u4 e2 t, V; C1 }7 M% G - jz exit1* n2 ?5 E, k1 ^0 i4 `; F( i
- mov dx, offset msg_ok 3 J3 {9 H6 Y: v- N5 J
- ]1 d/ Q9 @ \ r3 ]
- exit1: mov ah, 09h
( k F3 i0 F' {. N3 K - int 21h ! y2 P, j) B5 d: N* i+ [
- mov ax, 4C00h
% {( `' p4 u; _6 ~6 l, d - int 21h
6 U. \ I E+ o' ?( s o -
, N0 p7 ]5 N# C& ]4 R - msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,
( o1 n @ U/ q7 V8 c9 ^ - "2008-07-01",13, 10, "$" q2 ^7 T- a) B+ R
- msg_ok db "A20 Enable OK", 13, 10, "$"
. J$ f& l! y0 H8 J) S - msg_fail db "A20 Enable FAIL", 13, 10, "$" 1 S0 D Y# s: g. u, z" G
7 u h3 ]" Y; U' L, V- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
& D# m9 o: U+ F) S - A20_ENABLE:
% R: W# f* V0 y% J - call A20Write 2 T, j. S6 [+ m8 o$ ]
- jz exit_enable
( z4 n( N e$ g- \6 C% w+ |
6 l6 x \" E: ~$ H% _- cli ; Only need for reading value from KBC
: P6 J6 d, y1 K2 [4 G - mov al, 0D0h + t, p4 y, { f1 B' [; g
- out 64h, al ( e, A; a- z% m" w8 ?; S3 l" l; @5 ?
- call A20Read $ j+ O& ]. }5 x% g1 ?: D
- jz enable_int ) [: R$ |$ u3 z1 X$ t1 }+ D1 O' U1 ~/ S
7 T. D$ p2 o- X- in al, 60h ; Get current status
# u( E. m# l* d- A/ D; w - mov ah, al
$ ]" ?7 u: `$ R& T U - call A20Write
$ P( X% V1 i* r; B. F# Z - enable_int: sti & S# K* z) u- K$ K9 B! I
- jz exit_enable% q; o1 F# p, s0 c
0 J& ^& t O M1 U$ ^4 U( r' ?- mov al, 0D1h ; Tell the KBC , want to write to the
9 I+ L" e" m9 B3 G/ q - out 64h, al ; Out Put Port next ! e7 x% V* a5 G# e) `, n! n
- call A20Write
T0 Q$ u5 k, e8 m - jz exit_enable# D! o9 _; G2 [
- 7 F9 y7 S* m; ~' S4 x9 c
- mov al, ah 4 x5 n; x. N* @* z0 H* }/ {2 S
- or al, 2 ; Enable line A20
; o/ l0 \3 ?) R& O7 I - out 60h, al
8 N: N4 D# e& ]! R4 l! J4 c - call A20Write 2 a2 ^! P1 d) U2 _7 ~& A# O
- jz exit_enable
+ A4 D9 D9 I; p( ?1 B$ ~7 \
) ?' j$ p q4 d( h$ i) a( d8 T- mov al, 0FFh ; NOP
% N) ]4 V" ]! m1 p - out 64h, al ( [8 p* d5 c4 a9 _4 g3 Q. {
- call A20Write 3 A0 C) }) R. r- h
- 7 i. K; [" @- b+ M, g* P& F
- exit_enable: ret / L: c% P+ @4 B( P2 j
3 [& a' W7 N5 C+ N. w$ Y- A20Write: xor cx, cx ; Reasonable wait
# W2 L: @. n; O1 V: `' O2 [1 m - get_wirte: in al, 64h ; Get KBC read status
, |0 D2 Y8 Z& v- K0 k/ p - test al, 02 ; See if buffer empty, bit 1 clear
# u8 ~- H% M/ h - jz clear 5 H3 B6 Z# Q; ^, M8 V* E
- dec cx
+ ~% b8 n8 `' ?1 E - jz exit_write / s/ S t1 `. v& Q( D7 V( y9 T3 i. D
- jmp short get_wirte ' ^# s- Z8 U! e4 O& `( y: {
- clear: inc al ; Clear ZR
* H/ a9 K( i5 Q! p2 {) s# Y' Q! A - exit_write: ret
$ ?! @$ a9 j' y
+ D+ f6 a; |- F$ o: m; M
6 ~/ S3 [4 O0 T; f- A20Read: xor cx, cx + G7 `5 U6 f. D! ?3 J8 Y% w: |
- get_read: in al, 64h
1 s8 |( L4 O& n+ E4 P7 Z5 ]- S8 g - test al, 01 ; If the 'output buffer' is full, has
) t( y( g4 d. l2 N+ n# c( h - jnz exit4 ; ... 9 g7 o6 U+ q3 I0 P7 ]3 |) e
- dec cx
+ ? {+ y! c1 j) I. P! c/ Y - jnz get_read, S. z) o' @% o5 X N K2 f( e
- exit4: ret
/ \' p* [7 u2 l* f$ R5 y$ D - + F. W. E# \6 q9 [2 v& B
- end
复制代码- ;A200FF.ASM ; `; X# [5 m/ Q2 C8 \
- ;
8 [0 |! c: @" H1 M9 x - ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01
6 z6 c( @% n" K - ; ml A20ON.asm
- ^, W* d, C8 W% @8 t0 c% ] - ; 0 j7 I) n) O( p
- .model tiny( O ]9 r4 B) H, I5 _0 ?% E
- .code% [" t N+ c1 \3 i! ^; `
- .486
7 c1 f/ s0 k3 \- a - .startup
" k. l3 j2 ]* C
3 A4 q4 z" F, S- u$ p7 w: {- Y- mov dx, offset msg_author: z& R" ]' N2 D
- mov ah, 09h( }5 {& K- r. r$ H# \) Y/ q; G
- int 21h K* p% _" X5 F6 ^
- 2 [8 F9 M0 d+ E
- mov dx, offset msg_fail
/ W" ?. e9 T2 ? - call A20_DISABLE1 P Z2 S% Q6 f/ v, C
- jz exit1# G: e% I% f+ U. Q/ k
- mov dx, offset msg_ok , X2 g+ ]9 W9 }2 X4 d# b
& k& G! G" P5 H6 ]7 i- exit1: mov ah, 09h
4 h$ W. y9 @8 ^ - int 21h 2 |2 M% G5 k9 A# z
- mov ax, 4C00h
! }/ z9 } s; J t - int 21h : ~1 d! N) K3 s$ Q2 J
-
' p& t& W, a- i+ v# ?( h+ o3 H6 d9 \ - msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,
1 o1 h' y( K0 L& \7 S5 [9 k' `0 A - "2008-07-01",13, 10, "$" 6 D6 i! o7 O* x! i( K7 A
- msg_ok db "A20 Disable OK", 13, 10, "$" , d! x- `. ?$ O" {, F8 J) h
- msg_fail db "A20 Disable FAIL", 13, 10, "$" * s7 N/ O) j% W' s% m. e
- 7 N' q" K! y, |+ ^6 K
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------' Z+ d' O& H/ {% c% t! ]
- A20_DISABLE:
: ^! I0 @5 j) f, r8 Z1 `& v; r4 X - call A20Write
, t# q/ K v4 V+ N: |& C1 P, i - jz exit_disable0 f7 N; ? j/ G1 F. H8 Z O
. g( Y: ^" {3 t- cli ; Only need for reading value from KBC " A3 O8 q" d2 S: g# ?) r2 k
- mov al, 0D0h 6 k% l- D1 _8 V, [" h
- out 64h, al 6 _6 t0 s4 \6 Z+ P1 p
- call A20Read ! c& d2 u. j3 b$ R7 p$ F+ k8 ~
- jz Disable_int 9 C i9 c% U# ?2 P
- 5 F$ t0 \+ Y. S# E
- in al, 60h ; Get current status
' q7 l) _) O( p( W5 O9 ^+ d/ i - mov ah, al 4 m! D, `0 D) y9 R4 Y9 Y8 {
- call A20Write
2 A% |/ K# k) ~4 N/ e - Disable_int: sti
/ @5 L: Y2 \5 W( ~* p" ~7 j - jz exit_disable- }7 ^8 ~) ^% a* p- F5 q* d
1 W, M5 |- S1 Z+ E/ `- mov al, 0D1h ; Tell the KBC , want to write to the
3 |4 I0 n5 R4 Z9 w" Y - out 64h, al ; Out Put Port next
7 |. D1 V5 q s2 D/ m5 w* d& A - call A20Write
4 h& l( I/ F5 D) Q# ~ - jz exit_disable! I( y4 |7 T9 x
, L/ f& I' Q1 H- mov al, ah
& Q* x5 T' T7 a5 O/ q0 A; B - and al, not 2 ; Disable line A20 7 x/ y( M) U$ ~ W6 n
- out 60h, al : M8 f* |& Z9 D0 z* o. n: C2 Y
- call A20Write
: q2 c8 R/ _4 {3 ~2 R" X - jz exit_disable
. ?5 |/ } W# ]
: y& A ]7 i. p- mov al, 0FFh ; NOP
! L7 c9 f% O$ G! L - out 64h, al . f4 w5 M" h; ~' M1 ~- \. T3 a4 X* i
- call A20Write
) ]5 U' i, |+ j5 n5 X& \& |
& i( c5 ~& ^1 f2 p" p7 c- exit_disable: ret ) ~/ v* K. @$ H& y+ J
- 0 @7 K0 x+ A) ~" \2 _
- A20Write: xor cx, cx ; Reasonable wait
8 Y" I: d. \" A9 g - get_wirte: in al, 64h ; Get KBC read status
d# m; W- T! l: h& e& [ - test al, 02 ; See if buffer empty, bit 1 clear
+ F1 N0 R8 ^: h' N* {% k8 O9 A - jz clear 3 P8 j9 V' F D. R
- dec cx 5 S! f0 O) X, ]3 N
- jz exit_write & ^0 v0 h$ o$ K7 T8 t
- jmp short get_wirte
- J4 k' E: e. S" J M: i3 o - clear: inc al ; Clear ZR 5 b3 n5 E. ~" f- m
- exit_write: ret
, y2 ~( Z6 B$ l" q5 m9 P( Y6 Q9 b7 H - . w0 l4 i) O" J) s# B
- + T. J1 v9 q$ F& e5 X$ H, }) I
- A20Read: xor cx, cx 2 Z O* k$ X7 d3 W: P( B, S6 T+ x
- get_read: in al, 64h , V$ g% x; F) N* J& U+ I
- test al, 01 ; If the 'output buffer' is full, has
4 C% X2 p/ ?# k5 w - jnz exit4 ; ... , X# e2 [& T0 ?2 J9 s
- dec cx 7 x: ?3 n- k8 j5 n
- jnz get_read
4 q& B* m( {; @; p3 l - exit4: ret
. c i' n6 X; a9 k n - ( c# p, k O8 w! o
- end
复制代码- ;A20STATE.ASM 0 Q Z! s, B: Z6 m
- ; + l; a7 I* D. K$ @4 m0 M
- ; Returns the status of the line A20 through the KBC
1 r) i% R* M% I0 s3 N( X$ R! R - ; programming by bini for debug. 2008-07-01
) B R5 S' g) S: t/ R; Q - ; # r2 |0 j# s/ ^3 S, ^4 g, Z
- .model tiny) \- [+ F$ u6 K5 Z
- .code
. v0 e" [7 }& Y/ m - .486
8 c& R9 n* F' j6 {5 ^ - .startup
$ [( W4 `& s4 K+ s4 X! A9 H0 I - mov dx, offset msg_fail
, i7 q2 O+ Y3 d; u0 E - call _GET_A20_STATE_
" \8 G* g G, ?3 [: N4 v: J: A, a, N - jz exit1 ; was a problem
7 ^6 `4 x8 {9 j - push ax ; Save state, AH 8 y, A! ` T+ ]& R0 N
- mov dx, offset msg_ok ; There wasn't a problem
5 C8 B$ F5 @' i8 O) ` - mov ah, 09h
8 W! {5 j8 b- e; T; U5 h2 z - int 21h ; Print message
# A0 k( ^6 t4 X, O7 K; {% ? - pop ax ; retreve state
8 @% {' f+ B! \% b3 | - ) ?0 T; F) D" Q& i6 l7 k
- mov dx, offset msg_dis
! H! l- A- j, b v E' U - and ah, 00000010b ; bit 1, 2h, indicates state ; }% Y, ]2 h! K! _ i5 k6 Y
- jz exit1 + R! e0 G6 V* w
- mov dx, offset msg_en
9 G e- P/ g8 [
/ y" Y8 y' i! t- J2 y! ]- exit1: mov ah, 09h / S) \ K/ C3 }: G; ]6 C
- ; DX already contains address of string 2 e5 I1 O' ~* t6 d) b5 \# u
- int 21h . W2 y; v2 e( z: c
9 n6 z& `' i! ^8 U- mov ax, 4C00h
+ ~; V, x7 b1 {" N& {7 Z* L - int 21h
+ t% x0 r9 ^$ x8 v; P8 [5 ?# \
8 Z4 g; b$ U0 Q0 J7 @- z) O0 C+ ~- msg_ok db "OK", 13, 10, "A20 $"
' j0 c# B* i& g& i' I0 U1 ~% G - msg_fail db "FAIL", 13, 10, "$"
6 H6 }6 j" n. E @& J) C - msg_en db "ENABLED", 13, 10, "$" " A& G& W" W% N' ?9 A& {2 I c; U
- msg_dis db "DISABLED", 13, 10, "$"
' s* x" A- `4 P
1 p- h& J d. Z+ d4 \ Q-
9 b+ S) G0 |2 q - _GET_A20_STATE_:
: J& }* ]+ U" H" u7 a F0 Z - call A20Write ; Wait till the input register is empty 1 u9 l% u3 x. A# H/ ] h* H; w
- jz exit2+1 ; Bypas the reset int's ; P2 }, J0 x/ H4 E
- cli ; Disable ints so we'll get our value + t( ]' y1 f& F7 ?, `1 M/ `' M
: c3 b. z7 f: _7 K) Z3 J- mov al, 0D0h ; Send command to the 8042 command register 2 P8 l0 v& I4 z% X
- out 64h, al ; to tell it we want to Read the Output Port % K3 W- G( q' ^3 T
- call A20Read ; Wait till the 8042 output register $ b J2 ]% E* \$ b/ Z3 L
- jz exit2 ; has something in it's buffer * [9 }# f4 i+ \6 O9 r k/ N" `* n) v1 i
R: u5 P* f% J- @+ W# R: N- in al, 60h ; Get it . b# j4 M. I) W. A0 }
- mov ah, al
2 P) \+ S2 A* \ - call A20Write ; Make sure the input register is empty # i) y$ c' x# d
- jz exit2
; u' u( v4 S' I" i
8 ~, S* i+ \ ?8 G3 N% k( S* D- mov al, 0FFh ; KBC NOP command, does nothing ( {# G& W; o: H/ s8 d: h
- out 64h, al
+ c; w- ^) {- h4 w6 E; J - call A20Write
( O2 W/ G% ^7 o" b. ]5 ]0 } - 7 c7 U) d! `8 |
- exit2: sti
: o5 C' X) c! v5 R - ret( h# j1 ]9 k4 ?3 K1 U
$ B2 ~* j/ B; l: W- 6 G' V5 f' M0 D- Y3 X% Y( {
- A20Write: xor cx, cx ; Reasonable wait ' ]$ j: {! ~3 N- n) j4 {
- get1: in al, 64h ; Get KBC read status " N6 F5 i+ ]( n/ H7 @, o' m- j& d3 o' m2 W
- test al, 02 ; See if buffer empty, bit 1 clear
% |. l7 p* J# o - jz clear D* S: g2 m4 e; z' P0 S0 C8 k- T r
- dec cx 2 {* |2 Z5 _$ @: {6 H/ z
- jz exit3 / k/ ?: J2 j1 v
- jmp SHORT get1 ' O+ r9 I+ y! g4 c6 \
- clear: inc al ; Clear ZR / b6 r; @$ Q& t8 V: V- Z
- exit3: ret 6 N* b$ L; M/ r5 L# l- _% X3 s! L
$ y- ^; t' Y( \) f* D( Y2 `2 y- - H( t/ L/ w% c. t. ?* y
- A20Read: xor cx, cx ( t( c. t `8 S4 u
- get2: in al, 64h
3 Y9 |: Q }3 c: `$ B9 t - test al, 01 ; If the 'output buffer' is full, has 1 x' V: o1 k2 O
- jnz exit4 ; something for me 6 h8 |$ v& t @4 ]5 X z
- dec cx
" r" @$ U9 d/ @$ [1 |- ^! i+ H - jnz get2
0 l2 L0 J7 U0 @1 j% Y, q" B# H) u/ O - exit4: ret 5 [6 D3 `. {2 [& C4 ^* @. [+ W
- 2 P% y0 Y3 ^5 ?; a4 m e- y
- end
复制代码 |
|