|
|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM
7 H3 K/ Y3 n) W e( `0 x2 c - ;
1 G, ^8 C v7 ^% E, C( q V B, e - ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01
" K& Y% P+ t9 H) f% n7 o - ; ml A20ON.asm 1 m7 i; S" @( ~$ t+ M
- ; : P6 c( {. X; c; V* D& @/ \
- .model tiny
/ @- ?) I+ w0 U9 @( T6 W2 L) c - .code
; D x# E- [) a& `7 U7 N - .486
6 i( ]) U2 p( j! @9 W# n0 J5 O) D - .startup
' K% f! s) S: g% B% o9 P5 s' B
0 C% V" U6 R, L- mov dx, offset msg_author1 b0 C( y- l3 x( e8 J* C4 ]
- mov ah, 09h
/ O, ~2 ~' P' s - int 21h
2 N6 B$ E4 a4 @ - ' R: V0 K3 v' L
- mov dx, offset msg_fail $ {, p3 B. a7 z( q7 `
- call A20_ENABLE
5 f7 Z+ F$ ?; ~( T M8 d$ } - jz exit1
. u; J) l, t! ]+ Z; m! F - mov dx, offset msg_ok ; c& u9 F" X( G% ^
- ' J/ Z7 V- l% T* }6 t9 t
- exit1: mov ah, 09h
0 E/ `% h& x1 {6 M - int 21h
0 o4 a8 z0 k1 J$ h( S* b4 U - mov ax, 4C00h
) S5 ]6 L+ R4 k, m# c- w6 N# { - int 21h 8 L0 W W: }/ G' e' D2 [# }
- 1 k2 j) t# s- I( Y
- msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,
0 ?) z% x% \" n# [! ]& Y8 G& `1 |; J - "2008-07-01",13, 10, "$" 1 X7 s) ~% E9 r# y0 q* r8 Y3 y
- msg_ok db "A20 Enable OK", 13, 10, "$" 9 X# C9 W5 S- e9 P" [7 }
- msg_fail db "A20 Enable FAIL", 13, 10, "$"
* {" u3 `: @+ z6 x - ( j# b0 h& o' {, s" u O+ N
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
1 u! j Z9 M' Z% D9 w$ X" s - A20_ENABLE:
1 b% m! P1 u" A+ N - call A20Write
# }( t" X& s9 ~" n - jz exit_enable
; F4 T: u6 X' f - 2 u' Y q# ~# n# w; Z
- cli ; Only need for reading value from KBC
1 V# u8 v" Z( n7 i- O4 J. `+ d - mov al, 0D0h
" e! V) C( g- V2 Q! L - out 64h, al
$ T# |: v6 F0 T1 U$ ~0 M$ E - call A20Read ; A" L( d0 o6 ]0 S2 }' q5 }
- jz enable_int
& [4 v" z( L6 G" e: x1 e5 t! P& @ - ( ~3 J) U1 M) p
- in al, 60h ; Get current status
/ B. b1 ^4 B0 N' r' p - mov ah, al $ u$ b" c& n& D! f: @6 F
- call A20Write " @# W5 q3 B- c( n
- enable_int: sti 5 O4 \" A, d5 Q$ p1 J4 Z6 {5 s! N
- jz exit_enable o5 F6 T: n* m5 g. A
- 6 _. n# f$ L! Z+ |8 k5 p
- mov al, 0D1h ; Tell the KBC , want to write to the " G7 H, v3 f0 ^8 p
- out 64h, al ; Out Put Port next 7 c9 h2 {5 E y V
- call A20Write - y! v; l" F8 W; _ {! ?
- jz exit_enable
: X& x5 d9 X% v5 X, v: E. ~
9 y/ ^5 V8 p; D# \- mov al, ah 7 r* k- Z9 g9 l% ~
- or al, 2 ; Enable line A20
) Y0 O7 k. o5 l' ?+ j( U) n% q) J0 n - out 60h, al 3 N- J. M* a, {
- call A20Write 4 F* i- T% _: W( {4 X) b4 F' i% D
- jz exit_enable
& \2 r4 |* e6 [/ c3 ?1 @1 m% j
" t% e7 A/ X: ^) K0 F4 _# Y- mov al, 0FFh ; NOP * P$ n; V3 w+ F5 R5 H' B u
- out 64h, al
# ?" h9 H* c0 [, x% z - call A20Write ' i) S+ }/ |9 ?+ y; Y
- * W) J# }6 j L/ m9 _+ c8 z# I
- exit_enable: ret 3 ~6 _5 y& O. h$ ^* N# s8 b& @
; S! _6 Z& o! a- T# J4 s- A20Write: xor cx, cx ; Reasonable wait
- k" K3 Z& B) X8 }, r+ `' ` - get_wirte: in al, 64h ; Get KBC read status
& [" d, ^3 I- j! [* U( q- m - test al, 02 ; See if buffer empty, bit 1 clear & p& Q9 n" x6 C3 G7 B7 v
- jz clear
! i4 Z6 y6 s( y- n& @7 _ - dec cx 5 C. T6 p& M! u% a! c/ M) G+ B) D. G
- jz exit_write + f9 w6 E+ @) \7 \& @. ?% S0 G
- jmp short get_wirte 8 [" t7 e5 b- u3 D/ R9 Z8 i2 f& R
- clear: inc al ; Clear ZR
# I) u1 V! u* k2 |& N - exit_write: ret 8 y1 t0 X2 {7 @1 w
- / u7 q9 n8 D/ J" `2 }! ]
- % O- B! }2 K7 {9 f7 z0 z
- A20Read: xor cx, cx 3 y3 p0 e6 ^& h. S
- get_read: in al, 64h 7 a. L- M5 V1 p) p
- test al, 01 ; If the 'output buffer' is full, has 6 k; F3 L" K+ x; k
- jnz exit4 ; ...
( ]; O% k& Q% p' Q6 U( A - dec cx 9 W* @- p3 m2 h2 \4 [ s9 I
- jnz get_read) s% R, U! i9 |+ s" U
- exit4: ret
* R+ n; M2 C! j; F - ^# w: Y: N, b& D! q9 d6 {: }* X
- end
复制代码- ;A200FF.ASM
0 `4 Z6 A }! c2 E! J: r4 r - ; * x3 V3 \0 X4 `" T. M, A/ d6 y0 Y
- ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-011 y# D2 H) F# r7 l2 s1 V7 q: }
- ; ml A20ON.asm 0 X( F ]: w% Y; Q9 U o1 d' `# o
- ; ! y. h3 c4 V; L( Q6 }7 ]
- .model tiny
5 `( `1 \6 a* [' I - .code+ Z1 y9 }8 W5 e( }2 O5 a
- .486 i2 x+ I. ]1 O. X( x
- .startup& }0 M" a7 ?' [4 x- F
6 }& ~6 |# ^& _- mov dx, offset msg_author8 X% z. T* |* c$ n, p
- mov ah, 09h
; R) v+ O# X L4 l# n' V - int 21h1 r2 [9 r; r9 f1 W0 J- i3 n% \
* w6 j1 ~! A J, f5 ]6 ~7 h0 v1 U- mov dx, offset msg_fail ( L9 M/ z' F+ _. p% T8 z8 Z1 K, \
- call A20_DISABLE
+ ^# }3 z1 ^3 y6 o4 @2 k8 K$ G - jz exit1
8 J- d0 p, W1 F4 s M+ i8 T3 A' Q - mov dx, offset msg_ok
" w, e6 ^9 J6 @2 h - ! l( D" B# o8 W5 e
- exit1: mov ah, 09h
2 s5 J' c' y- y- X: X: y4 G - int 21h
; T) k2 f( z; }+ L - mov ax, 4C00h
3 ~4 W- S, o: m8 _, E - int 21h $ ^2 |) O% b2 I/ ]1 a+ }+ X
- , Y* c8 [* q+ F+ A3 R) q$ C- h4 m
- msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,
, {- u# z/ L% ^2 I - "2008-07-01",13, 10, "$"
( C/ u& }2 ?- N4 Q: x - msg_ok db "A20 Disable OK", 13, 10, "$" 6 }7 Z4 ^ Q& ^ t; `8 g
- msg_fail db "A20 Disable FAIL", 13, 10, "$"
- b2 T% c6 L3 V
, @( o6 X" Y0 R6 X- Q# O; O- ;------------------------ follow code maybe make to lib, if you want...------------------------------- Z8 j( U% U3 J6 _$ r4 Q
- A20_DISABLE: 4 r5 E$ w2 V: V3 x
- call A20Write 4 r1 k. x( Y( n n4 @
- jz exit_disable
) v4 U# Q1 g) I( p& O - & a, x( J5 w6 T. }
- cli ; Only need for reading value from KBC
3 s! `# g$ W1 A5 C' \( M - mov al, 0D0h
. `. j O3 Q+ P5 h7 b t3 d/ F - out 64h, al & E/ l, T0 h) Z4 V
- call A20Read
8 F9 l$ G# }. q( M8 p - jz Disable_int 0 s: K% b0 L6 s" w- b- m2 ]* E
" c5 a: _0 {4 P0 Y- in al, 60h ; Get current status
2 d& l& `7 R( z# [. x H3 k- K$ o - mov ah, al
% Y- w5 K& S5 a+ J# C8 i* X - call A20Write ' z/ o2 c0 K" }3 k
- Disable_int: sti
+ }! n' G e* n/ |2 i; f/ j' P - jz exit_disable
- V, x/ n( k9 k* D9 Y
~; M0 O9 S: z1 o- mov al, 0D1h ; Tell the KBC , want to write to the
- R4 Q. ?+ c1 p+ y+ ]7 G8 K - out 64h, al ; Out Put Port next " R+ p ]% J* r) ~
- call A20Write
; ^4 g7 d& [; t. C) y# l - jz exit_disable
3 l& P7 B: h; ~8 U7 N1 d - ! q- }3 |8 a2 y# y- ?4 H/ m* n
- mov al, ah ! B; K8 ^& S6 {# ^, C# \
- and al, not 2 ; Disable line A20
% k/ y, a' W7 g4 P* U - out 60h, al # n& B9 \+ R# D7 d9 e
- call A20Write $ }' K" ^: H+ v* g, C/ R
- jz exit_disable
) g1 x" ` u- Y - " S/ C5 E1 A; i( \
- mov al, 0FFh ; NOP
( V+ ^+ m9 z, Z6 k/ y6 [( Y - out 64h, al
q2 `& h9 M% E/ ^) A* O - call A20Write
+ Z# \% `# m2 E3 n. j' d& z
% V2 W& X) g; @& o! N- exit_disable: ret + ~/ V. \0 D" Z$ B7 o6 j7 F
, J( F# t3 |; S- A20Write: xor cx, cx ; Reasonable wait
( i ?/ i$ t) u4 l9 Y( E9 l - get_wirte: in al, 64h ; Get KBC read status / o9 A# J$ H9 T/ j9 {/ X% f- p/ [( q
- test al, 02 ; See if buffer empty, bit 1 clear
; o0 U7 g* x% |* h - jz clear 6 _4 ?8 g! o1 e2 z2 r h
- dec cx 3 G5 f) d1 ~1 y
- jz exit_write & e. n! U5 K, S' B, N6 n
- jmp short get_wirte
}5 A# p. ?# y/ s% [$ d$ G - clear: inc al ; Clear ZR
6 ^& X( [* v; y% x - exit_write: ret " ^. D- c& J+ q( `6 O+ K$ e/ O: M
- m' W+ ~; w* {4 I+ W ^+ Y) N- 1 y* ?# J3 g/ o, T% w# q8 z
- A20Read: xor cx, cx 4 c8 ] J. ^( D6 g
- get_read: in al, 64h : j* r2 q4 v. }2 i% \+ M" s
- test al, 01 ; If the 'output buffer' is full, has ( Z3 G' T8 b/ d. V* n1 I9 ` q
- jnz exit4 ; ... 7 [/ V% W' u' _
- dec cx
' ~! c P5 G: c Q - jnz get_read" ~2 T @% W+ x
- exit4: ret
; c) \6 T; ] O' i - ( e3 X. I6 Z7 e7 ~
- end
复制代码- ;A20STATE.ASM
, O6 w9 c7 s5 r4 _# R1 S - ;
' j3 x: }( q9 ]% l4 t& s( i$ s5 B - ; Returns the status of the line A20 through the KBC ' V' f2 Z' h( S- Z. J. g
- ; programming by bini for debug. 2008-07-01
: {+ B* ^5 p7 H - ;
$ D! T9 }2 N ^% k" a: ] - .model tiny
% Z6 r/ L' _) @3 x) U( ? - .code
2 o/ K8 R4 W @9 d h5 ?" i+ @% t - .486
7 a5 m/ E9 ]9 ^2 B - .startup
5 L3 u7 M5 e8 g" x8 s - mov dx, offset msg_fail
! ` O. V1 Y+ Q% W% m - call _GET_A20_STATE_
# u* O. W9 H' [# n! W - jz exit1 ; was a problem
' ?& o) R% r3 x. u% e. y - push ax ; Save state, AH $ Y& D- m' w+ g" N3 @0 n
- mov dx, offset msg_ok ; There wasn't a problem + V, o/ z0 B( V: ?$ {5 c; {) S- |
- mov ah, 09h , x: Z6 K4 t/ F W. V4 {
- int 21h ; Print message 9 `4 R4 d7 o$ v1 C1 Y
- pop ax ; retreve state
6 x: V; F x8 W8 [( L
. n7 S- z- _0 D4 _0 b* a( g- mov dx, offset msg_dis 3 ]$ ]1 Q* d {5 t
- and ah, 00000010b ; bit 1, 2h, indicates state , b# _" i- P- K0 H
- jz exit1
' [- b) b$ l4 D0 r - mov dx, offset msg_en - V& _" m' D) ?' T) r! ~
a& H6 ^& O: c/ g- exit1: mov ah, 09h 6 d/ L% f5 y* T& H+ B
- ; DX already contains address of string , K6 X+ ]2 h( W8 S0 B2 F$ S6 v
- int 21h 5 D: J: i8 E6 o1 N% m
- + E" c# D& r( b8 K+ i4 k# _6 ~
- mov ax, 4C00h * A0 q( A- C8 M
- int 21h % s" _" @: H$ ^ v$ l- k
, g. |6 w3 S8 D* W, g3 N9 a4 A6 D- msg_ok db "OK", 13, 10, "A20 $"
, {* |, t& \1 O8 ] - msg_fail db "FAIL", 13, 10, "$"
V7 _+ q3 ?% `& q9 s0 z7 L - msg_en db "ENABLED", 13, 10, "$"
# c! ^0 n; ?( W8 D7 E7 D7 _* a - msg_dis db "DISABLED", 13, 10, "$"% V6 T$ [" Y: Q0 ~8 P# Z
3 _! n# R2 e! O0 j+ p/ K- ' \/ e+ r2 I; u, Y/ Y" j, n
- _GET_A20_STATE_: ( q, _* _% N I! H U9 r: X0 N
- call A20Write ; Wait till the input register is empty ' i. Q0 x' B. O. X- e2 t
- jz exit2+1 ; Bypas the reset int's
4 l: y- q9 l( b; p$ w2 j - cli ; Disable ints so we'll get our value
- Y! r* y% u" l; Z6 `( a - % P' B9 k" ^3 q3 h* X1 i$ H
- mov al, 0D0h ; Send command to the 8042 command register ' j' c9 _! Q/ X, v# \* x: I9 @+ Q9 d
- out 64h, al ; to tell it we want to Read the Output Port 4 t; c; z8 b8 g' _7 `) S! F& O
- call A20Read ; Wait till the 8042 output register % b( P8 r! q9 z8 l! ^
- jz exit2 ; has something in it's buffer ; _& G" e$ } s: i3 d
- 2 u% K1 \) D8 H( M; u# X
- in al, 60h ; Get it , G7 V( Q. I. J
- mov ah, al : T% Y; x4 E' t/ C/ Q6 Q6 ]
- call A20Write ; Make sure the input register is empty
9 k$ S3 Z8 s) ]" [! @/ d - jz exit2
& e4 S* a5 C3 c, n6 ^ - - R( ]# s2 w& X! S& l& Y
- mov al, 0FFh ; KBC NOP command, does nothing ! s9 K! x" Y1 B) r0 H% J
- out 64h, al
8 [1 G( c- V+ U- @& M1 m# ^$ O - call A20Write
4 Z' E8 ~# s& E6 r9 S, J+ { - + F2 S! s% \- G( @5 K6 ?
- exit2: sti 4 r5 H4 y% c: s, A, S' A! u
- ret
7 t/ z M& T: r6 Q0 E - , E% U! @/ l5 W7 k
T: S" L: |& ? J6 u1 K$ u- A20Write: xor cx, cx ; Reasonable wait . }7 K9 |; v5 @( o( x) }! K. s
- get1: in al, 64h ; Get KBC read status 2 P! m ?( o/ o
- test al, 02 ; See if buffer empty, bit 1 clear
: d, [+ J9 U D. ?$ t- ?" \. \ - jz clear / G8 u, g* k, |4 v1 A) J D6 ^8 s8 Q
- dec cx
- b& v3 E& P( F9 J( N0 `. r0 O - jz exit3 E" I+ s9 s* h3 o2 ?" p+ V0 {4 J
- jmp SHORT get1
' U1 {$ J- F* x3 U& \$ y* x S - clear: inc al ; Clear ZR , H6 s2 `$ K+ D. ]" M! P7 N
- exit3: ret ) Y+ [, d/ W8 v$ J Z* y
6 E6 O* l' {$ T- & \; Y1 P* P4 H4 i2 `; P' o
- A20Read: xor cx, cx 6 U, A/ d6 m' l$ n" P/ Q
- get2: in al, 64h 0 |4 \0 ?( Z1 O B* E1 o
- test al, 01 ; If the 'output buffer' is full, has
! |3 g- {1 I! m5 l - jnz exit4 ; something for me 2 g/ ~- [; B0 I/ z: j
- dec cx
k% E8 _7 w9 q0 @2 m - jnz get2
" G" k6 q5 c& t: I - exit4: ret 7 M9 y0 G. q( i0 p, l& G1 T
-
2 b& O h6 h" C. j2 H - end
复制代码 |
|