|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM
6 t7 K: _) k7 c% }8 e# F+ t - ; " ]! J- v7 `2 O8 _: Q
- ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01; u/ B" f9 N" w0 \/ t
- ; ml A20ON.asm 0 f; o: N8 H1 d, z8 L
- ;
9 J0 q+ a- W; l+ [$ ^9 R - .model tiny- O# N+ {; a- w8 O- d0 E0 }( O
- .code' v& {5 G8 K% F8 y5 C
- .486; r9 K4 B( k( I! p- i! |/ B
- .startup
+ I: j! G# W1 ?0 V
# Z* ]; V' R) k. k7 {- mov dx, offset msg_author7 b9 Z: @4 s6 [$ y9 ]1 S( c4 p
- mov ah, 09h2 Q* `' `3 J+ `- w
- int 21h( Y" M0 `* b8 [- E
" K2 ]& K, g- i' F% u& r* B( R( ~- mov dx, offset msg_fail - x! f/ \2 V9 y& E0 Q. ^
- call A20_ENABLE- o: z# q) U# W" s7 Q$ w
- jz exit1
( x6 _7 b9 m& p2 p* S8 H; \$ w - mov dx, offset msg_ok
7 _# N9 d! D4 V# j4 m - a% `) ]( T) I. V# Y: c5 J9 |( i m
- exit1: mov ah, 09h 0 ^, h0 g9 ?' o8 p* C1 X v0 K7 j
- int 21h
: x& g) Q6 U1 O- W - mov ax, 4C00h
7 p& F. S0 _2 g' q' B/ i - int 21h
3 P- a% S. }3 l" m0 Y; X9 P3 @+ U - - O( g; B3 l- Q1 [0 P
- msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,( j8 n/ S" T+ s! L# |
- "2008-07-01",13, 10, "$"
6 E1 U2 [0 x& B1 M0 W - msg_ok db "A20 Enable OK", 13, 10, "$"
: p$ |. y) q% i8 B( X4 L - msg_fail db "A20 Enable FAIL", 13, 10, "$"
5 m! z( ]* {/ Q' x1 u' s8 [
+ S4 P% U. ~0 Q+ r% Q! U- ;------------------------ follow code maybe make to lib, if you want...-------------------------------# _. k: o3 _5 e- J
- A20_ENABLE: ' C% P5 `' t+ H& { J3 R
- call A20Write 1 B4 g+ Q, z0 q) h1 W# y: L. Z
- jz exit_enable" T' `. [9 f0 w' w* h
q, o+ z4 f& V8 b1 F( V- cli ; Only need for reading value from KBC
! b5 n# J E2 |2 n - mov al, 0D0h
, P* Y3 o0 a& d4 ~7 g; }9 q - out 64h, al ' x0 z* G$ a+ N/ i# n& G
- call A20Read 5 ~2 k0 W1 [* L
- jz enable_int g3 U$ ?8 @0 X0 u2 b
- 3 D+ E) j- Q2 o4 ^ w
- in al, 60h ; Get current status
/ P" F0 P/ {: k8 K' H" I& A" W - mov ah, al - a% s( R- P* E% c8 _
- call A20Write
: S- z- {: _% o, e7 X - enable_int: sti 4 \2 d" J6 A1 l0 }5 T2 c
- jz exit_enable# J/ `5 ]7 C% Z% a8 m# ]
0 q0 \7 ?2 U6 \, | y7 R' E- mov al, 0D1h ; Tell the KBC , want to write to the
3 j+ v9 n: [4 j* r - out 64h, al ; Out Put Port next * @# @# `, F" }, A, e2 \& Q
- call A20Write ! R4 P3 ~( J: I* t
- jz exit_enable8 S) I6 M' p7 s' I) `# g) Z
- % K- ^7 u1 f2 B: \1 f
- mov al, ah # ~" A/ e3 ^5 x7 X$ ~; P# u
- or al, 2 ; Enable line A20 + o# f' A% |7 A2 W* n; s( M
- out 60h, al
' j1 `1 K6 n, T% H6 f/ u/ a) B: V5 ? - call A20Write
8 K N+ d4 s% E5 n" z - jz exit_enable3 H) i0 `7 [. C9 T' j0 R
3 S6 j) E( v( l, }9 F- mov al, 0FFh ; NOP 6 H+ m8 s2 F1 I
- out 64h, al & j# R% Q5 q+ \8 h9 R
- call A20Write & m7 \$ I7 O3 G0 ]' C9 B0 v
0 y. l5 ]1 N$ M8 B- exit_enable: ret ' ], `+ R3 X$ ]* V6 K$ p
, ?; X ?& K( T9 M- A20Write: xor cx, cx ; Reasonable wait z1 F: @. y/ Q, w
- get_wirte: in al, 64h ; Get KBC read status - P# ~/ _( `' L: a
- test al, 02 ; See if buffer empty, bit 1 clear
: j% f1 [4 [) t4 T# q - jz clear
! H& Q5 ^3 |8 M6 b4 m( e; o2 m - dec cx 5 @1 s" Q: @- a8 O/ U
- jz exit_write * w; L2 I' h2 v' k N/ C
- jmp short get_wirte , ]: _/ r! ?9 g( f: c* U
- clear: inc al ; Clear ZR / t' Y- X- q" U$ R @# O2 p
- exit_write: ret $ X' h6 ^7 _1 W/ `
- 2 x: U: G# a$ Q* c7 n* B; m" l
- % j- H1 I' w# ?6 ^- ~
- A20Read: xor cx, cx 1 [$ ?0 s0 y" |
- get_read: in al, 64h + I+ l- f; I/ P5 O7 D$ X
- test al, 01 ; If the 'output buffer' is full, has
. l% ?: Z1 o* _1 ~ - jnz exit4 ; ...
9 U u! C7 e% F7 o/ O& {8 c, Y" N - dec cx
5 T) |# Z, k Z( X G; r - jnz get_read
) G) ^/ _) _( \( U - exit4: ret
% [! J" p2 ~; ]4 D% o2 P4 \) o& b -
2 k$ k6 ^% I4 ^/ e$ v% u8 e6 l - end
复制代码- ;A200FF.ASM 9 J) U" B: j2 u$ k6 a' F* R
- ; : i$ D" `' c% L9 l
- ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01
" G- m7 @; g3 z0 Y% _- m$ B% r - ; ml A20ON.asm
* w; y; z8 r% ^4 `4 V5 g& ]0 n - ;
4 |# N. B- _+ K( a1 `2 P4 C' p - .model tiny- k$ v5 {/ L, W* k8 O, s j
- .code
) e+ R/ I6 @4 R0 N4 C! G - .486
+ v z# ^, r2 i' }" ^/ z; z5 b( r - .startup. l8 t+ O6 w* K( p* Y' w. {
- # z% a$ V" W# Q6 V0 G6 p( [! c t* r
- mov dx, offset msg_author. {6 o ^. {! I$ q8 B; V/ \
- mov ah, 09h
, U0 W' r7 E9 i7 L. ~: s9 `2 O - int 21h
6 s% O, G3 ]: E6 W; W" ], ?2 v1 _, x2 Z9 L
3 b) f; `5 J* A- mov dx, offset msg_fail 2 c( V0 u$ R7 a
- call A20_DISABLE M! o% I4 |) r& s/ y7 T# N
- jz exit13 n) F& i! p" U' R$ D0 T% u% ^
- mov dx, offset msg_ok 8 b; W( R; t1 s( n- `, i
% h8 z. H7 i, ?. ?: A5 @+ a6 ]* C- exit1: mov ah, 09h 1 Q: e. |6 g, G, X$ R) d
- int 21h $ p2 p- j- u7 ^* D0 P9 z6 ~
- mov ax, 4C00h ) @ v7 l0 {! d
- int 21h " X4 Q0 E) v, w0 P: i/ p7 X4 D+ [7 S; @
- + n6 k' t8 z; J1 y
- msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,
$ L* K" q/ U6 e3 N/ n/ C' G3 Q - "2008-07-01",13, 10, "$"
) t# g3 H, S1 d$ u n- }9 D5 J; c - msg_ok db "A20 Disable OK", 13, 10, "$" 0 r) ~1 k! X7 ~. o: \; M/ i
- msg_fail db "A20 Disable FAIL", 13, 10, "$"
- [5 f+ ^( O; U3 I2 i. C
4 U$ d4 x; Q! Z' U% O7 m- ;------------------------ follow code maybe make to lib, if you want...-------------------------------; L ?) T3 G. N, Z5 _ t5 n8 i8 u
- A20_DISABLE:
: j+ I f( c5 v - call A20Write
! S3 B3 k' o" j7 s - jz exit_disable
/ A8 E7 J5 U5 N. {# d# m
, Z7 O! A6 ~: p7 G. z- cli ; Only need for reading value from KBC c5 a" u- w$ S; o
- mov al, 0D0h / F$ X7 P7 \8 O0 [$ z
- out 64h, al
/ Q1 H- @( d6 G - call A20Read " X( d* C/ [3 |' }' l
- jz Disable_int
$ B2 D( f2 F# m) e! N$ m" Z - 8 f3 Y. N& V- Y# \
- in al, 60h ; Get current status 1 T5 k0 X$ a; L
- mov ah, al
+ a X" Q( ^* Y8 ^/ C& [9 a1 l. J A - call A20Write % d) Z) X. b% U M% U
- Disable_int: sti
/ u5 m! Q' ?6 {9 ^) G3 M - jz exit_disable2 R0 g4 n( d3 z3 c2 p4 u7 c2 I
- + E# T+ `& A9 j- r( V, n
- mov al, 0D1h ; Tell the KBC , want to write to the a4 t% P! _4 m: A/ H c
- out 64h, al ; Out Put Port next
+ G3 R1 h) N9 Q* y) @1 Q% ~ - call A20Write
+ b% h5 d3 p6 e( @ - jz exit_disable
2 l" D, y3 {! J
6 A' r( v7 d7 T# [$ t+ P+ t- mov al, ah . {5 G0 ~ j+ m
- and al, not 2 ; Disable line A20 9 w: Q- G+ D$ B' n b: M
- out 60h, al
$ `& d% v* I& ^, |% F6 n - call A20Write
% i2 P& u& c5 R/ p) O - jz exit_disable
1 i* A! Q# z7 t4 Q
, R8 Z( s$ a% L' X L- mov al, 0FFh ; NOP " @( D8 k- S5 L8 K' e
- out 64h, al 6 y4 A+ [/ f2 j+ j8 Z8 M" m$ N
- call A20Write # Z4 _3 z( d. q5 Q0 t$ `! T
# M3 L4 t' g- K6 A$ b' E7 G% s8 r- exit_disable: ret ' ^% ?9 b# d$ ]; P" w
- & J, S8 h5 F& {/ F6 H/ U
- A20Write: xor cx, cx ; Reasonable wait , l$ d3 a1 V7 h9 `7 s
- get_wirte: in al, 64h ; Get KBC read status 3 G: k$ T! t) z' U3 i* {/ w
- test al, 02 ; See if buffer empty, bit 1 clear
y9 x3 _: s. A0 b6 r+ R - jz clear 5 K; M8 Y0 z0 e, S/ ]! Y7 O U
- dec cx - q4 B: q; J$ f1 C2 J. S
- jz exit_write
% _) q. a7 H( e2 B4 S& \1 q. u - jmp short get_wirte 8 C4 W4 A- W: E! A# ^
- clear: inc al ; Clear ZR
7 T: j4 r, Y5 C! h - exit_write: ret 3 T5 l+ O2 r2 p3 b
- : S' |/ V3 I: k5 ^* Q) Y
- 9 @# U5 g4 g6 H
- A20Read: xor cx, cx
1 w9 A$ ^! g, U& W - get_read: in al, 64h % g1 X2 O9 k, q: s; q/ m
- test al, 01 ; If the 'output buffer' is full, has
/ }( Q; l( u9 K+ O - jnz exit4 ; ... " V6 C' E8 l _# i" S9 T5 i! c
- dec cx ) x/ i8 g e' n* ~
- jnz get_read
" d% i/ p% A/ e. F* s - exit4: ret 8 w0 S* ^( r& Z6 H& w- e! ?* h
-
, Q, W! I3 x( W* i; ?: v |; m$ `/ o - end
复制代码- ;A20STATE.ASM
$ ?) _3 y5 D5 ]1 I - ;
& r: m9 U. ?2 y, g) L6 ` - ; Returns the status of the line A20 through the KBC \% z+ l9 a8 Z0 G" @
- ; programming by bini for debug. 2008-07-010 W) z& f+ a% R* ?
- ;
F. _; i6 C* F1 I - .model tiny9 g. {: l2 }4 A. `& \/ n: F
- .code& f7 P3 W* q9 b$ n" m% ]8 [- s
- .486& J" r' @" O9 u1 j$ E S. z
- .startup$ U: W8 y' t0 w; L @8 D/ y- z
- mov dx, offset msg_fail
# n0 \! v$ b: v8 X - call _GET_A20_STATE_
4 j9 v: q0 U; }' Z% J% B( K - jz exit1 ; was a problem
8 \: U: X# r# I) p- a; t( V: o - push ax ; Save state, AH : G( v4 p: `% C( s+ [, _0 g" p
- mov dx, offset msg_ok ; There wasn't a problem ) w6 X O3 N: ]3 B$ F1 Y! D0 f8 W" r
- mov ah, 09h ) p" @! k* |4 V; u" a
- int 21h ; Print message % X# c- _' `% g
- pop ax ; retreve state 0 B) c4 Q/ l0 e: E$ ?
- ( c9 T3 t9 ~3 t
- mov dx, offset msg_dis
~% S n# E9 B6 x& A5 D - and ah, 00000010b ; bit 1, 2h, indicates state o$ ]; z4 G6 ^7 O
- jz exit1 }) l" C7 H& ?
- mov dx, offset msg_en 7 V, |/ _8 u2 u3 m" p. O
- / G' z# |$ h- A. Q
- exit1: mov ah, 09h ) z* S" a0 V* Y8 z
- ; DX already contains address of string
& o/ @8 R' E o2 {; ^2 ]0 R0 K1 X - int 21h 4 @# ?0 {- A3 ^) _1 a
- 5 M( ]) D# M9 I4 d
- mov ax, 4C00h " S7 p* O5 C: U! J; `
- int 21h 9 `! U7 z$ g" M
- ; K% X& L0 N, a( R
- msg_ok db "OK", 13, 10, "A20 $"
9 e2 M6 `: \+ Z+ b2 l! p9 z - msg_fail db "FAIL", 13, 10, "$"
) V3 U# ^2 e" Q1 }! Y0 l5 J - msg_en db "ENABLED", 13, 10, "$"
0 y- o4 K: G2 X0 M4 k, g0 v' y( r - msg_dis db "DISABLED", 13, 10, "$"
$ J- H) J0 T9 v$ S4 M
: X2 A4 b0 t) k6 S# ~3 @- 6 l. ]; e D; }
- _GET_A20_STATE_: $ ^1 N0 A1 T$ l, }
- call A20Write ; Wait till the input register is empty
6 m3 l0 ~8 _# i - jz exit2+1 ; Bypas the reset int's 7 K* f1 s: g$ x* f( A7 b
- cli ; Disable ints so we'll get our value
2 ^' N" M! F n2 P5 X/ O$ k5 x - ; {, L8 y+ C8 Q$ c. I0 o
- mov al, 0D0h ; Send command to the 8042 command register / J6 F- g1 l- h, \. _. I
- out 64h, al ; to tell it we want to Read the Output Port
' L7 D) K+ ^4 _) B, } - call A20Read ; Wait till the 8042 output register + e8 W$ d0 ]# T8 c
- jz exit2 ; has something in it's buffer
" [1 Q! r" |$ K0 b4 J - / |$ J8 P0 R/ e, J3 U+ }
- in al, 60h ; Get it
- X v2 s7 I7 D% r* I" U! g* Z* |0 n - mov ah, al
~+ S$ H- m' r* e! p: t& o1 R0 z - call A20Write ; Make sure the input register is empty ) a5 i% v3 X4 e# z9 r( n% `2 L
- jz exit2 ; Z7 Y& K. U/ C+ \
, w1 }! b1 k6 h' Z6 T- mov al, 0FFh ; KBC NOP command, does nothing
; E* C6 Z( u5 V: }6 |' ^: ^- ? - out 64h, al 9 P5 d2 x2 _9 I1 l" J" e
- call A20Write
7 ]* O3 p9 x" f/ w# C0 A3 b# D - : t5 G% c' l2 g
- exit2: sti
1 m5 d. ?; i9 t5 e# p - ret" p9 M2 o; }* |& x5 I0 N$ n
- " t9 c# m# @ K! o
0 R% g2 `% b. W, z, S: k- A20Write: xor cx, cx ; Reasonable wait
& _: D. l1 p6 G5 y7 h" H" m" U - get1: in al, 64h ; Get KBC read status # i( y0 ]9 ]6 w. i! F6 s# W
- test al, 02 ; See if buffer empty, bit 1 clear 1 k1 y! c2 ]. S, Y5 [# S0 T
- jz clear , i, v6 }2 G$ B( N. m S3 k$ u/ ~
- dec cx E, Y" T0 M7 J3 K
- jz exit3 4 u3 K6 I, }; C( r2 \3 [
- jmp SHORT get1 % ]8 [/ K. }2 q' c$ J+ d
- clear: inc al ; Clear ZR
2 w" o4 m: ]: ~) Y - exit3: ret
9 l/ F; K3 e( ?: _0 D( b - 7 x3 C, ]+ ?* q: m1 j
- / u. u; T( f, Z) c) m$ |& `# y
- A20Read: xor cx, cx $ @7 g1 M( F. y6 g, V0 \
- get2: in al, 64h
1 U0 H, H Y2 ?1 a- n1 p$ o - test al, 01 ; If the 'output buffer' is full, has 5 o2 C4 }/ p* Q
- jnz exit4 ; something for me
( f5 f) ^) S4 @8 c2 }' Y5 z+ L - dec cx
! U; q4 c5 R/ S# N" Z - jnz get2
) M) G# n% W |. t3 m0 N) Y - exit4: ret " O5 p, k6 `! c! F+ k
-
8 Z6 H9 p% `9 c, e g - end
复制代码 |
|