|
|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM
/ t0 x7 l2 E/ P4 J { - ; 7 |6 h) z# t: @2 h$ G5 {6 i* ^
- ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01
9 p/ k/ L d8 [! k a- M - ; ml A20ON.asm 0 ]1 g- ]" U5 f% v
- ;
& }7 }3 d; A* A7 G( i - .model tiny) ^1 x' z0 b# }$ |* Y; Q. V
- .code
; N0 Y W/ Q8 {$ M! p4 e( x - .486+ h B4 Y, S( }+ A
- .startup
/ e2 w: G8 q Y
1 j! H8 l$ }2 p- T) q. d- mov dx, offset msg_author# B3 Q% ~' j+ e% U0 I+ n4 Q. c9 z
- mov ah, 09h4 Z# M0 t6 @# U% ~
- int 21h
* m0 X5 w9 y9 a9 c
, y W; c& [" H; I- mov dx, offset msg_fail ( R. a* q, p* L2 ^
- call A20_ENABLE
- N- W3 G* J" f - jz exit19 R: d" n* R7 T) y, J+ i
- mov dx, offset msg_ok
+ ^: D6 S* W0 q$ V; Z X - 4 s! V/ C. k" ]* v9 S9 K
- exit1: mov ah, 09h
9 C2 Z' J8 a8 S4 t - int 21h - j& M$ O( g E7 \
- mov ax, 4C00h 3 J/ m4 D; g1 \
- int 21h
" g0 {3 L9 r& ?6 P' }8 d+ s$ k - : t+ n% Z$ b, n
- msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,2 {) _: K4 s$ A) ?- H# I
- "2008-07-01",13, 10, "$" : P6 b p! x" X& c9 q" P; m; m" m
- msg_ok db "A20 Enable OK", 13, 10, "$" % I2 k9 Z, c) L4 w
- msg_fail db "A20 Enable FAIL", 13, 10, "$" * ~) Z" T j+ n' U5 |6 Z
- 2 p6 s1 G; Q) p2 f
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------8 T [. T3 S0 L4 E" M5 o+ {
- A20_ENABLE:
8 ~8 b% v# [- f - call A20Write
- j3 @* a! e" ] - jz exit_enable
+ A: P0 h; S* X5 A8 E) j6 | - : M# t5 ]" d% A8 ^4 R
- cli ; Only need for reading value from KBC * }3 `# d& c& [
- mov al, 0D0h
. p$ k9 P1 u2 @& p8 ] - out 64h, al
$ [# s8 [; E! @4 i' K/ H - call A20Read
# ^- ]% [+ B7 U. s6 s - jz enable_int
+ |2 I" u3 a4 D: \( K8 H5 X - {% B1 f, F7 j$ V" _- t* y3 w
- in al, 60h ; Get current status
8 D B9 C( c6 ]! r9 ? - mov ah, al
4 O1 ^) u. Y4 m2 }3 q - call A20Write 1 r3 W- h2 U" p7 u. c5 I4 ^
- enable_int: sti - |0 C9 S0 h3 a) e3 ^3 p
- jz exit_enable
- w1 E6 A8 C, [ [$ t- r1 \2 @! D - 0 m& l' p( N+ | g
- mov al, 0D1h ; Tell the KBC , want to write to the
, g- l3 ^7 Y x( }! x+ u - out 64h, al ; Out Put Port next
: V4 M* l5 ?. f1 _2 r - call A20Write * F. P. B6 f2 g# A3 ^
- jz exit_enable' E% o. u9 ]7 P4 }
- , X1 e6 K5 C' H8 B9 M/ F+ x3 f
- mov al, ah
" R( f$ K7 e! J0 x/ U9 v0 T - or al, 2 ; Enable line A20
+ {6 W% h5 o( r) S# H" Z, e# o, R - out 60h, al
8 x- d5 W7 ?% O" t1 G - call A20Write
& b9 `/ s9 ~6 ^+ f: z: r: K - jz exit_enable
& w/ x6 s' F) O) d" q
$ f7 v2 i8 D- f% u8 {$ {# Y- mov al, 0FFh ; NOP
* |1 L" w' R' G; b2 D, L - out 64h, al
6 {9 T$ V' d8 {. b" [ G2 |( v/ P. L - call A20Write 1 W. k& \3 d$ n# C: L6 o( g4 F
- % M- ~' o* u4 N+ F y8 ~' x
- exit_enable: ret
8 d8 a$ w6 x O - $ f' g: s2 t& w: r* |2 ?
- A20Write: xor cx, cx ; Reasonable wait
6 G2 w+ s8 u9 G) D$ k0 Z: P# h5 W - get_wirte: in al, 64h ; Get KBC read status
- g# }. _& g' i9 M - test al, 02 ; See if buffer empty, bit 1 clear
0 K$ N* u/ v2 |1 ` - jz clear ! X4 i' W7 J2 b' e
- dec cx * F( Z# @$ @, P6 C% n$ s; ?/ g4 }
- jz exit_write % j% c5 a+ ]: d
- jmp short get_wirte
" h* F" l3 b/ O - clear: inc al ; Clear ZR
+ V# q$ S8 r8 o5 ~; q - exit_write: ret 7 y! r+ p; T2 n, |% t
- 3 B/ l+ o9 j! u! Q% x1 c8 s" |0 `
- + F5 I* i0 r0 g4 E+ D
- A20Read: xor cx, cx
* i( U& C( j& p9 ] - get_read: in al, 64h
, c u3 m- O; O, w5 J$ |1 a( [- v - test al, 01 ; If the 'output buffer' is full, has
0 u3 g: f l6 k0 W. I - jnz exit4 ; ... b/ X( s* [, P: s D
- dec cx
4 d1 m9 ^. S$ W1 l& C" ], Y - jnz get_read
1 o3 ^/ V3 e- ^, k& H6 G - exit4: ret
3 r6 v2 J2 u# e -
2 {- q& }' |( L+ e - end
复制代码- ;A200FF.ASM ( R1 J' M0 y. p- K
- ;
, m5 ~# x5 \7 m' z - ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01
, v; p1 H5 e: o$ G& R5 j R - ; ml A20ON.asm 8 M. _+ N* N" X1 g
- ;
* P; A1 h1 L1 C+ K - .model tiny
+ Z8 Q7 g/ Z4 w# W1 @& R9 `0 w - .code
/ q! X! f) e7 c7 N - .486 h+ ]- g$ S. |; l; V) K
- .startup
& E, |3 m M: Y - ! G' y; a: U( G1 p) [ ]
- mov dx, offset msg_author
9 d5 z6 X8 z4 Q4 a) J1 D ^6 K/ n' G - mov ah, 09h5 H; N7 D: c Q. s2 j% D( j
- int 21h
8 o7 }' z! V# ` }. C - * H G) t) g3 N1 I- @
- mov dx, offset msg_fail 5 o- W8 A! Q. e
- call A20_DISABLE9 T$ P$ D3 T1 n" T
- jz exit1
9 z' r3 l' s* H! l: g* X - mov dx, offset msg_ok
& U8 a- G; m, z1 @
+ ~) w* `; r- G Q2 m- exit1: mov ah, 09h
: L$ K& Y) ]4 K. n" i. j) B6 }5 O - int 21h 0 f, _3 W C8 G
- mov ax, 4C00h
% ^, `8 G+ V5 Q3 S& @9 C - int 21h
" }; b2 g) u- p+ h ~3 i0 k D8 Y% W -
: e/ {5 r' w' e% p - msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,
5 v% l# A) ]3 R( Q$ O - "2008-07-01",13, 10, "$"
9 f0 ]- o. p5 Q, t8 D \ - msg_ok db "A20 Disable OK", 13, 10, "$"
8 ~4 b$ ~8 N& t0 f/ _1 x - msg_fail db "A20 Disable FAIL", 13, 10, "$" * z! y8 y- R" O& n4 n
- + j* n, M$ \4 o' U
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
4 p! {5 k+ x. x$ \7 ] - A20_DISABLE: ' R1 q. O" B, `. \- k6 e# u
- call A20Write % v" j" m s: L" _0 m# E2 @' @
- jz exit_disable
+ T$ t1 W* e) D- P
8 Z, `4 M1 D6 n( @! ^" D) V- {- cli ; Only need for reading value from KBC ' @7 s+ z/ S; ]3 Z
- mov al, 0D0h & g2 t1 o, F9 H, L+ a
- out 64h, al 7 l* F( b% Q& j- Z l
- call A20Read
0 u; ^# z+ p4 Z! I1 } - jz Disable_int
* N: X0 T) k$ v6 I; Q - + g: V' L: Y; b
- in al, 60h ; Get current status
; T" u& V' h2 g0 L& a$ v/ r - mov ah, al
1 @- y$ o% l7 T3 J& I: l - call A20Write
2 I6 `: ?/ }; R9 q9 ^8 e - Disable_int: sti
, X/ Y: c& |: V& g9 K2 s( M( ~ c' M N - jz exit_disable/ s" V0 Y! ?/ y+ l/ V
8 w/ R( l, P" h9 {- V* n7 Z- mov al, 0D1h ; Tell the KBC , want to write to the * J# o/ z) j! B" A: V. Z# |
- out 64h, al ; Out Put Port next
% d* s! _4 g- Z" B( h - call A20Write
& Y* z0 n( t: j& U- H4 ~, `2 s - jz exit_disable
/ G% l2 H6 `% B( X3 H1 x4 p5 J
1 O. ]( Z$ H& W5 h" y. z$ ?- mov al, ah 9 l. w% V# j$ ]1 b& `
- and al, not 2 ; Disable line A20
; _1 N1 e$ N5 v* q1 |4 W' I- {) l - out 60h, al
^% g& Z( _. e2 r/ J. L - call A20Write 1 B8 s7 s/ N: \ `3 X! m
- jz exit_disable
, M% ?6 M8 W$ ^) @( p F - 3 ]( T: M/ e8 n7 L% o' j
- mov al, 0FFh ; NOP ( k" |% d3 ?1 G& k' A
- out 64h, al
$ N+ Z U8 Z' t5 e2 e9 X9 v! a - call A20Write 7 c) s0 t5 r/ N, S
- + p$ p" u' |* w
- exit_disable: ret
B9 i9 \9 Q1 |1 @ - 7 j/ E5 ]7 T0 T; S2 j4 J x9 U, @9 Z
- A20Write: xor cx, cx ; Reasonable wait
# ^* u& M; t9 C# p- E5 L - get_wirte: in al, 64h ; Get KBC read status 2 ^% c d, T- l1 Q, P
- test al, 02 ; See if buffer empty, bit 1 clear : J+ D1 Q) Z% a% R' S4 y* [5 Z- ]
- jz clear ' e8 l3 y- ~1 K+ w2 p
- dec cx
& l- w6 I6 c _" M - jz exit_write ) ]" D& s6 v7 X+ @
- jmp short get_wirte 8 x! ?& L1 ? r! [' W5 N
- clear: inc al ; Clear ZR : b$ n+ z( z, W4 a7 _
- exit_write: ret
, ?/ I" I O7 G) M; m! U" {
* H4 i% A O$ L& Y
b t5 Z! @- E2 I- A20Read: xor cx, cx
& R; V7 @) B8 h$ j5 { - get_read: in al, 64h 2 v: D6 H9 M& M" m! O
- test al, 01 ; If the 'output buffer' is full, has : W3 i0 |, {2 L& v5 b7 O+ ]
- jnz exit4 ; ...
% t. L) l% z+ M8 d% l9 } - dec cx 2 Q9 y. h- c' ]; }$ V
- jnz get_read% E7 y( }% y& a' _6 f! D
- exit4: ret
. O! p5 a: b( L$ _5 Z) j1 j- j -
; O& M% E& q" S+ ]2 W. T3 Y - end
复制代码- ;A20STATE.ASM
7 R- u5 a+ s/ N2 X, O5 \ - ; & u( R9 g" O7 i* t
- ; Returns the status of the line A20 through the KBC
# a) x" @1 } D+ v; `8 J - ; programming by bini for debug. 2008-07-01
* V$ ?1 ^- ?! A - ;
7 V8 c# R$ I, K0 k2 | - .model tiny3 s5 d- ~ Y; [; q
- .code L& R5 b; }6 x
- .486( ?6 K* r, n. [1 ]0 g
- .startup+ j: g- F8 Y0 S' d z+ x
- mov dx, offset msg_fail
( i$ H! P5 z$ x% X - call _GET_A20_STATE_$ T! d1 ^6 S2 K: {7 L- f! a
- jz exit1 ; was a problem8 k6 o0 c. m* [% O+ A+ _7 T+ X
- push ax ; Save state, AH - K! h% |$ i, a5 f: `
- mov dx, offset msg_ok ; There wasn't a problem
' T) Q9 x' c3 C - mov ah, 09h
! J& E# w$ }; ] d - int 21h ; Print message
; u, @. U- Q# e( y - pop ax ; retreve state
+ @, P# r9 y; M2 M5 [
) z6 L1 o& {+ g) y3 P( z: B0 u- mov dx, offset msg_dis
+ l6 b3 R& T% d2 q - and ah, 00000010b ; bit 1, 2h, indicates state
# H- S; G4 U( ^ - jz exit1 / Y9 \4 t9 }* w' W6 d/ C$ k
- mov dx, offset msg_en
- r7 f; Q% g/ k1 g: l) Y+ d& B
( x( N, j/ H( }$ C0 p- exit1: mov ah, 09h
( X- j$ g" ?( s - ; DX already contains address of string
8 D j9 x* ^ d - int 21h * V6 x% @& C5 c2 u8 t
$ D# c9 P& g5 ^: n8 i8 E- mov ax, 4C00h 9 q/ Q# U4 O, E' m- c6 k
- int 21h
& p1 f# h H$ ^. U+ e
0 m, S$ ?- C$ K# u. v! c- msg_ok db "OK", 13, 10, "A20 $" m4 Q% v2 s$ ?2 e; n7 }4 B' ?3 b; D
- msg_fail db "FAIL", 13, 10, "$"
4 ^# N& ]8 `2 K l ?0 D D - msg_en db "ENABLED", 13, 10, "$"
# D- r7 }7 y N, u, |: } - msg_dis db "DISABLED", 13, 10, "$"
1 C/ Q8 s5 t& O - 7 g: k2 N( `4 M0 l; {/ q( p0 y
-
0 c* l2 w$ i g" T - _GET_A20_STATE_: 3 G `0 g6 W6 k" |
- call A20Write ; Wait till the input register is empty 7 _. r* t. g9 J/ m8 |% W9 v
- jz exit2+1 ; Bypas the reset int's
, T% N3 \3 v* m5 C8 q7 G - cli ; Disable ints so we'll get our value 9 J- S7 f3 d1 Q4 N: G8 ?+ i
- 3 Y5 S C. O, c6 y& V8 {: K; H
- mov al, 0D0h ; Send command to the 8042 command register $ J3 [2 g" \( E
- out 64h, al ; to tell it we want to Read the Output Port
% T2 [, b9 ]( o - call A20Read ; Wait till the 8042 output register $ U. @- n$ b3 f- t0 V
- jz exit2 ; has something in it's buffer
% V/ P* J5 ~" ` ~4 J% ?
+ x. x8 z2 z) U. z$ R' d- in al, 60h ; Get it
6 g; [0 k! I: ^6 K - mov ah, al 3 U5 `9 M4 {/ ]! K2 `7 n4 G
- call A20Write ; Make sure the input register is empty ; G9 \/ J& ?8 v! {- _7 C3 h
- jz exit2
: w& W. u! a' L - ) B$ C; j% `5 c7 X
- mov al, 0FFh ; KBC NOP command, does nothing 2 h8 Z1 l9 @" E, ?8 k
- out 64h, al
& M$ S. V9 w+ b B, `# g - call A20Write
2 _+ L- }. V+ r. J
2 @1 J$ z. [. c' J- exit2: sti 8 i) N }) R2 w, L* T
- ret+ K# D" N# }4 T i: N1 p: D; h
, f( A! p! x* q' k1 S
" W: N ]- I: u6 X5 a4 Q5 E- A20Write: xor cx, cx ; Reasonable wait
& @# t9 {: H# k% S: m - get1: in al, 64h ; Get KBC read status
. `. b7 o# t y( Q2 y1 P) P( r: J - test al, 02 ; See if buffer empty, bit 1 clear K2 F; h! c- Y, V8 B& }
- jz clear w l; s( B: m, J2 h0 {7 H
- dec cx . o, Z. d' d# G2 U1 l" i6 {
- jz exit3 / _/ y/ A6 v: }. s3 M6 Y) ?
- jmp SHORT get1 ! n5 r2 Q `4 @4 s% U
- clear: inc al ; Clear ZR . e; Q+ e4 P3 x3 D% w L( N' r% i2 N
- exit3: ret
, ~" P3 |/ c6 C) h' P; Y* H+ I - # A4 A2 x+ G: S5 D" _2 W* {
- S4 w. v7 l2 D3 r+ a) m5 D9 w- A20Read: xor cx, cx
4 @* p4 X( ?: e# E, F. L - get2: in al, 64h * r/ r: Q+ P$ P2 v- a8 y, g
- test al, 01 ; If the 'output buffer' is full, has
; G6 J' h$ |: o) G9 _- k - jnz exit4 ; something for me
: S9 G( L( \; n( F9 `# V - dec cx . U/ V) J& @, @- f$ j( B3 p- N
- jnz get2* [8 v+ I/ ~4 W+ j& p( c
- exit4: ret
) u. }& S3 O: z) A6 C, i8 D4 l& c: J1 g -
5 g% h' i4 @- o+ e- r k - end
复制代码 |
|