|
|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM % z2 K# i! }/ l1 }4 h
- ; ' V% v; N, I& z- P' M0 k4 v
- ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01
/ B6 j/ q. v+ x4 t - ; ml A20ON.asm ) W$ f0 d+ d% i4 @
- ; ) Y; L+ W, W' o, O: B5 b
- .model tiny
+ X# b. x0 _. V. ^4 k$ t - .code; A! {! N9 h/ C, H
- .4861 t+ A. b9 ?/ S7 R
- .startup
: M" K/ I8 L6 n$ a" T - ) B( h0 c4 t; e* q3 V3 `
- mov dx, offset msg_author- d( ? I D! U# ^& x% l
- mov ah, 09h
) S0 a0 i* p: {$ Y& y+ J1 z) h - int 21h- N) L1 M: B% y% d. x$ A: n" G& F
: o) G/ j3 F' l- mov dx, offset msg_fail ' K2 `' U) |: X3 q4 ^+ b4 B* w3 a7 k3 w' z
- call A20_ENABLE/ q' q: ~1 U; n
- jz exit12 }/ _- ^, d$ n* z7 ^4 ?( A0 U; k
- mov dx, offset msg_ok - g d6 \8 S* R/ n1 R7 V
- ; H, U7 }/ g ^, M( r0 a( E
- exit1: mov ah, 09h }6 Q) P) r' P8 H' ?( O
- int 21h
" l. a& ?0 O" o5 F' U# o - mov ax, 4C00h 1 U6 d7 B; r0 d$ ?
- int 21h ( t2 @9 z! s, j1 G% `
- ( ~; p9 V+ O3 [# E
- msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,
5 ~) I0 Q2 A0 s - "2008-07-01",13, 10, "$"
# |" t S2 ?, Z& X$ L - msg_ok db "A20 Enable OK", 13, 10, "$"
- y2 _% h% g$ o8 S( U - msg_fail db "A20 Enable FAIL", 13, 10, "$" 0 M m$ s; B5 j \3 b
- % m& E: g5 x( s! l1 d% N1 Y
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
# l9 V8 d! M* G) U - A20_ENABLE:
; C& k. h v1 D& ]4 S w - call A20Write
' A, e4 m8 L% ` b' D - jz exit_enable
) x2 Q! B4 B; s1 k4 J - & \ G7 ]" d: _- e0 _
- cli ; Only need for reading value from KBC
4 A' c& `* X0 B# r4 j) P' Y - mov al, 0D0h
M1 y# v# r2 H* e4 K, ? - out 64h, al * e9 d5 B* O% N4 ~" Y# U9 O
- call A20Read 3 w( z/ s* o. k0 p5 ?6 O
- jz enable_int 1 \# k2 x, q- I# M `1 _7 u) E
" Q/ k4 P, b1 G% C) {& S# Q3 {- in al, 60h ; Get current status : N! Z) [. d0 `) v% y
- mov ah, al 5 h5 {, {; E$ h) v! ]6 P: Y
- call A20Write 4 Q" `; D- n4 n
- enable_int: sti
. [9 }: M/ b6 `# q) Y! ]& | - jz exit_enable
) G9 L# L( y6 f6 g2 X
( W8 c& ?4 X0 d- W% W! S9 s, R- mov al, 0D1h ; Tell the KBC , want to write to the
& ?% X. Y: s/ A) ^ - out 64h, al ; Out Put Port next
9 Y, g6 ^ K/ Y" [+ r, Y - call A20Write
7 N r# k; v4 }- Y( `* y5 G - jz exit_enable
$ l: U: e+ b- S' w: M - 0 a, ~' v1 \. t* n. `! v
- mov al, ah 2 a- g/ W I& \4 j2 O! R( C
- or al, 2 ; Enable line A20 ' t+ N8 P/ q. B
- out 60h, al 1 I: I$ d% Z+ h% i K# L) ^
- call A20Write
% L. b7 @" y8 b* M/ E1 P' g - jz exit_enable
( u, r B% ?2 D( p
" V; l$ f* x& O! m1 e- mov al, 0FFh ; NOP 1 c p2 |( W2 ^6 s1 U9 c7 p
- out 64h, al ( b9 @6 w' L; e( d
- call A20Write
$ [+ f' z$ w! { - ( Y$ H: ^$ b2 e. }
- exit_enable: ret * t$ A2 b/ V) Q
4 ^1 T1 g- J# g3 y/ S- A20Write: xor cx, cx ; Reasonable wait
, v# q. k8 e& |' }# s. Y; d% B - get_wirte: in al, 64h ; Get KBC read status
8 m- U8 ~& |* \# _ - test al, 02 ; See if buffer empty, bit 1 clear ; u: w' ?5 f) h+ s# @
- jz clear
& t2 {+ i/ r6 G c+ q. b5 g, _ - dec cx - u+ g" R+ F( D. y' v# P: k1 D
- jz exit_write + ^% S1 k' F7 A$ \' e) p L/ n
- jmp short get_wirte
' R- d, b( F1 @/ @$ J - clear: inc al ; Clear ZR % x# k) Q" A" }
- exit_write: ret 2 G" Q, W2 _0 _5 |# |1 N
9 p$ {3 U% R7 F i( x0 m% b
7 k% E7 D7 j4 M7 q, v& R- A20Read: xor cx, cx
/ l* d" U! K1 a; ^1 z0 F- |/ {: F2 j - get_read: in al, 64h
0 e5 w1 c* z" ]4 K - test al, 01 ; If the 'output buffer' is full, has
, K+ R( v9 S4 B% I5 t: y - jnz exit4 ; ...
+ S+ r# ~9 ?& ~$ Q+ A4 a - dec cx ! q, g3 E' Q% V: y5 G# [
- jnz get_read% Y$ k( o( b3 S; x2 t
- exit4: ret
- r' x3 ?2 s* P5 @2 _4 b7 a -
% m9 \! @9 C! g. M - end
复制代码- ;A200FF.ASM
/ ?, S' s- m& t2 N# j7 L - ; ! n6 C4 z: Q$ S3 q6 t
- ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01
0 P' o8 K) V& @- t' B8 J - ; ml A20ON.asm
; ]4 J% g0 {1 H - ;
; e& V: l& j4 b: y+ s - .model tiny8 f; t) `5 _9 m* D( E% K! X
- .code
- ]3 k* F R; C: I0 Z/ ~0 p5 _ - .486' L, m' ^% v6 P) J% w7 e
- .startup
' k; T0 ]* }! I% z1 S# \) f2 J! p. M - . x9 R- _* }. o0 n4 V
- mov dx, offset msg_author. P7 D+ I4 o: j" P9 i0 T: H" w
- mov ah, 09h4 a% ^* s& I+ Q3 t- {, T
- int 21h9 K4 j9 |( P0 k: m
- + }" I; O# C. e) \ e$ u
- mov dx, offset msg_fail
! o" R: [1 w2 q6 G; t - call A20_DISABLE
8 H5 i7 Z. x$ ^4 J) K - jz exit1
# q' k+ R8 {/ G- k& ]2 P - mov dx, offset msg_ok
) n, Y0 n7 g8 d2 S/ v, H - & o5 g2 V. A- ~* T, p
- exit1: mov ah, 09h
5 N* z9 l/ V N& f; ] - int 21h
- r/ o7 Z0 ^7 f: a. e' D* p - mov ax, 4C00h
: M; }! Q& U3 G' ~6 h, z) t' I x - int 21h 3 s! [: D' J1 c* q
-
7 ]* e: k8 _; O/ V* @* Y - msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,/ a; G T# K5 V- t, C
- "2008-07-01",13, 10, "$"
l' p, d4 H0 r7 X8 n - msg_ok db "A20 Disable OK", 13, 10, "$"
9 w4 F+ w. v6 e/ I( T8 K2 M9 O6 { - msg_fail db "A20 Disable FAIL", 13, 10, "$"
& }" @1 s. o" j1 l" W. e - " x5 t0 s# w/ ]: W- a4 H+ ~* D
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------( B, `5 U9 C+ m6 g; j
- A20_DISABLE:
6 Q- Q6 b( r* k& S - call A20Write
" m v) Y& c2 _& ]" `$ U, d - jz exit_disable
5 X |9 @0 r1 X4 G4 u1 H- n9 L1 ^ - + N2 I$ [% s8 `2 A
- cli ; Only need for reading value from KBC
: T1 S R0 H7 i - mov al, 0D0h
4 ?; X6 G' t/ ]& |( \2 q/ ]" { - out 64h, al
) ^4 `+ L5 G) B0 c% t - call A20Read [$ m4 B8 }+ ^- u
- jz Disable_int
Z0 v& J: @& I; R } - & W6 o% i" F. m w9 T8 Z1 w
- in al, 60h ; Get current status $ F3 A# m$ x# u6 Z9 z
- mov ah, al
$ _: J: s' k2 a$ T4 a5 i R3 n - call A20Write 6 ~+ ? o! R) X9 D" e
- Disable_int: sti
( Q, b2 ^1 H9 _; e' E - jz exit_disable3 Y+ R; ]9 S' f* l) _+ }7 X
) |% O( L6 k/ i8 ]6 A$ q! A- e, ]! F- mov al, 0D1h ; Tell the KBC , want to write to the 7 d; v5 @$ _* R% \% T" F8 |
- out 64h, al ; Out Put Port next
# j$ a h5 C h w$ m( z; h - call A20Write - @8 ~' g5 x5 X$ _: u
- jz exit_disable
. C9 G- w( _, u, p' ^ - ( a5 o6 o _! G+ W
- mov al, ah 2 c# f* F7 B: t# ], b
- and al, not 2 ; Disable line A20 / O% @- n- d. T8 E
- out 60h, al
4 _2 R# I9 I4 M - call A20Write
, f. _3 n8 d4 C4 @9 o* w$ h4 R - jz exit_disable
0 D* P) v% r" L3 q5 }* E/ s% O4 N
) {: w$ T( Q% w& P' S7 W- mov al, 0FFh ; NOP
7 D2 F. X/ F3 I( ]) W - out 64h, al
- c" \; L$ z! h' [( z0 p. ]/ Q" A - call A20Write
" T; D* m) M) w5 C
; f: N7 B9 q8 ~' n- exit_disable: ret
* y, C+ t7 ]6 j9 w" \4 A - 1 x; B+ N7 `- w2 Q+ {
- A20Write: xor cx, cx ; Reasonable wait
! R" S% ]- M8 a2 |# r - get_wirte: in al, 64h ; Get KBC read status
7 l) z) k& o& R# M' }4 N% f. l7 n9 A - test al, 02 ; See if buffer empty, bit 1 clear
! Y9 H' ~8 l0 k0 D4 R" x n* E+ y, p G - jz clear
) ~0 k% |, j) \& f' x- c" u - dec cx
" p9 y# r6 m* O+ |) T/ E - jz exit_write - m" [, e) a( C4 c `9 g, Q
- jmp short get_wirte , o$ t* |0 U, K" O- _! v
- clear: inc al ; Clear ZR
7 @& |% l& N/ `% \, y! J - exit_write: ret ! T6 F2 L# A' g
- ) Y+ y6 P0 }: F6 B" R. d
. Q) t) L0 C1 S5 Z& b& h- A20Read: xor cx, cx
. [: V' t/ @2 E% I, e: S& q - get_read: in al, 64h # u% b @. R& f. v0 Y( `
- test al, 01 ; If the 'output buffer' is full, has ( ?+ Q a, a7 J1 y9 \) E
- jnz exit4 ; ...
) V. ?8 i( C5 Y4 f: w - dec cx
" m) d+ D7 b& c2 u, v' c% m - jnz get_read: o" E) n" w1 G+ @% x: D% U
- exit4: ret
$ p$ l- K0 d3 s/ G# T* b, d -
" |7 N+ H! x% \9 d( V) R - end
复制代码- ;A20STATE.ASM
! ]$ r. H8 W& t - ;
6 r7 B; e8 {% n - ; Returns the status of the line A20 through the KBC
& L. J d; I0 ~2 ? - ; programming by bini for debug. 2008-07-019 n3 |! r% P2 C" D( `/ a
- ;
% Q3 A) K* I- B. }/ V: q. s - .model tiny% n/ [7 y6 A |' F' P. C7 V! q
- .code
+ B# Q1 v1 a; Z! w+ X0 Z( a - .486
% L. d8 v8 ]; v2 D3 d' F, Z - .startup
; r5 ?" N+ k |5 y6 {' d - mov dx, offset msg_fail 5 X7 T. }/ q" I/ U3 S$ {
- call _GET_A20_STATE_8 u* `6 O d$ }* n/ y0 F
- jz exit1 ; was a problem
* \/ j7 o9 w! v, w - push ax ; Save state, AH 0 a% B0 k4 }$ y& [1 R
- mov dx, offset msg_ok ; There wasn't a problem
x& U$ U; t+ X' t: [ - mov ah, 09h
! N" J& I: j& k( j4 t - int 21h ; Print message 2 g$ Z) A( P: \
- pop ax ; retreve state 3 y: @2 N/ U/ j+ ^1 I; N$ s4 h% W
- ; n. c: O/ F4 ~$ O( o
- mov dx, offset msg_dis % C7 N% m+ Q& X* |
- and ah, 00000010b ; bit 1, 2h, indicates state : V: D1 S0 U/ a0 r0 C8 ?1 y7 e; J
- jz exit1
6 U, ?* b9 X6 m" y1 X% z2 b - mov dx, offset msg_en & \1 Z7 V% M2 K* c6 t
! @: K5 N/ u1 \, p& M+ t7 L: d6 ~) z- exit1: mov ah, 09h * Y* w) V2 E- B/ V* a+ i- H
- ; DX already contains address of string
3 o2 W: z& S' t% z - int 21h ( {$ l2 J0 Q8 X' z+ Z% m6 Y3 Q+ ]8 M
- 9 @, m* V! j' l- t
- mov ax, 4C00h ) d2 o1 j- n9 L" l5 |% G# b& G
- int 21h
5 _' j3 i, C6 ~% X# g) Q$ }6 J L
6 d& r0 V% n& F2 |% X- msg_ok db "OK", 13, 10, "A20 $"
( h4 _ G& f: E) T- B - msg_fail db "FAIL", 13, 10, "$"
6 v5 i6 f: ?* D$ R/ q- Q2 H - msg_en db "ENABLED", 13, 10, "$" 8 @0 G* [: Z' c7 u1 x& \' p
- msg_dis db "DISABLED", 13, 10, "$"
0 _0 a; U& h, | |( B5 ~4 d
! y, C B( a0 T# y3 x# G" W1 t-
( z+ x! z0 } G& t - _GET_A20_STATE_:
$ m9 v3 P2 G* s' A - call A20Write ; Wait till the input register is empty 1 B8 C5 q, Z- r7 O9 y
- jz exit2+1 ; Bypas the reset int's ' q+ }; t) H3 \
- cli ; Disable ints so we'll get our value ! j7 f9 r- n+ ?6 d0 b. }2 h: R
- C) F% U" Q$ |( S
- mov al, 0D0h ; Send command to the 8042 command register
" {3 v3 S$ p$ C; q' K - out 64h, al ; to tell it we want to Read the Output Port $ R# I( u! P1 u, \0 N M1 O
- call A20Read ; Wait till the 8042 output register
+ U* l7 }- b$ r. U# W* `+ z - jz exit2 ; has something in it's buffer
' T3 }6 ^4 j v
) T7 l" _5 J3 `3 }: W8 P3 a8 L- in al, 60h ; Get it ; z2 A3 [0 \( z; P- S7 Q; e
- mov ah, al
8 _4 i5 ?1 J5 V - call A20Write ; Make sure the input register is empty / _. n, X, B( S/ k/ r
- jz exit2
3 h! @& l M7 e: A; n
, N( y: I: a' W( V+ t3 m' i- mov al, 0FFh ; KBC NOP command, does nothing ! M- U, K, u. \; V- @
- out 64h, al - u7 Z! @$ f# f/ k/ B
- call A20Write
' J: J0 ~& S4 I1 I - - _( l* s: ]* a1 r, x8 ]
- exit2: sti # D9 Q$ e& e7 D4 a5 o
- ret0 o6 S T! v/ k+ E6 \1 _
D& X2 P( i) L, M7 y- Z" y( G2 S+ M- d0 ~1 i$ [' ~% h
- A20Write: xor cx, cx ; Reasonable wait
+ s% Z8 B; `# o9 j: [8 t5 q4 @ - get1: in al, 64h ; Get KBC read status 4 w" Y$ H7 z* Z5 J8 j5 c
- test al, 02 ; See if buffer empty, bit 1 clear # ? C' \) @ m: L
- jz clear
* @' S( U8 i5 @" f - dec cx 9 _- m" `4 ]/ h2 \& q3 |/ A
- jz exit3
( w, F+ M1 z6 [2 s2 s7 @ - jmp SHORT get1
! K1 l9 m9 { Y, Y - clear: inc al ; Clear ZR 5 l) m7 u8 b! b8 ^( }
- exit3: ret / s# z# P/ U: C9 z; `
/ e- L7 j* l$ }, A
5 o* c0 e/ P K! G- A20Read: xor cx, cx 3 L5 c* ?& V; g S [% H9 n
- get2: in al, 64h
e2 G& }1 k- s6 i3 b8 H - test al, 01 ; If the 'output buffer' is full, has , ~" `2 O! @3 S& y1 }: \ b
- jnz exit4 ; something for me
& B5 }! i- @: o - dec cx
! U2 G( y0 k {# Q - jnz get2 J. g5 X# l! T( E
- exit4: ret ' _# A7 a5 G4 l0 W+ n
- 5 o0 v0 h3 r6 Z1 a
- end
复制代码 |
|