|
|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM ' ?6 @8 H& B/ M1 \
- ; ' `+ p; @5 ~" s( s" P2 v
- ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01
. A" C: ~. o$ U2 V5 \/ n - ; ml A20ON.asm & I- [8 P& w. Q! L( l0 u- D" I
- ;
# o3 k) |1 U& f) e% h* E4 S: B! b7 n - .model tiny
, N& k. p. E- c - .code
6 v' q$ s/ f3 V! I - .486# X! W! E2 }+ g4 Y/ R
- .startup
; ]7 \/ j l4 ^: D
3 M# L- z& P9 \& w9 z6 ]* K- mov dx, offset msg_author0 i3 O2 G0 h) }. W
- mov ah, 09h
4 D$ F. H1 O4 m. K9 p5 J - int 21h
: a" @* f& Q3 d7 |6 o. ?' K7 Y9 ^ - , [/ Z4 k& c" ?$ O3 {0 m9 ?
- mov dx, offset msg_fail
4 \6 @% h- p0 w3 W6 _3 J, X$ ` - call A20_ENABLE
- n& m& d! W% Y4 ^- M$ Q c# b - jz exit1: j) d7 B% ?' P% W( n. s
- mov dx, offset msg_ok # q5 B3 c& ]0 r/ G u8 S' q- a9 U
1 T' e5 z4 k/ F# t# N$ a- exit1: mov ah, 09h 1 I/ L3 B( T: k }" F
- int 21h ! d; \0 [, h$ {% x. e; X8 k) ^% g7 N
- mov ax, 4C00h
* U* {- `; D8 q5 I - int 21h % j3 U+ ]/ D( ?( @' F
- ; \0 t, G4 |- M
- msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,
5 f3 n1 V: Z' j; q) ?8 O - "2008-07-01",13, 10, "$" & q9 x& \& g0 ^1 k. W: F$ E0 G
- msg_ok db "A20 Enable OK", 13, 10, "$" ( Z& B* ~( m+ ^. E3 @! L, `) O
- msg_fail db "A20 Enable FAIL", 13, 10, "$"
5 o# S1 Q7 |( n: T" v
1 [8 a+ K% H+ }- ;------------------------ follow code maybe make to lib, if you want...-------------------------------/ `) H1 Q6 B) N z1 R Z" Y0 }: n' x- U
- A20_ENABLE: 6 S" T* a* O7 f- j
- call A20Write
4 ]0 V" o5 l6 @ - jz exit_enable
- n* u+ T& x1 Z& @7 _1 ]
0 b' U' Y" M& b: a- H+ I- cli ; Only need for reading value from KBC 1 e) O* B$ ?+ H' l* w% t& ^
- mov al, 0D0h % T& D& M- Q# L: u6 R+ T
- out 64h, al
; `; M* g" ^ s5 j+ Q5 d/ V - call A20Read - r7 n) }$ T8 Q. q
- jz enable_int . g4 h; D! r+ p7 \3 t: g1 l
- . g0 u) I0 Z. b( e. [
- in al, 60h ; Get current status " a E0 g6 J, T; X; U
- mov ah, al
8 h) r+ s$ Z; t+ m. \ - call A20Write
3 \" n# Y# B4 P6 Z4 o) J! B2 W - enable_int: sti / e2 @( T! _( Y, Q
- jz exit_enable; e& t* b: k4 G
- , j8 T0 e- z+ H
- mov al, 0D1h ; Tell the KBC , want to write to the
+ A# f+ y( z, i& X - out 64h, al ; Out Put Port next
3 h$ E7 v9 a0 R, |5 s9 H - call A20Write 5 \/ j) u# v. C! i, j: c' K
- jz exit_enable4 p. j0 ^+ x& G
! ?! s0 H. i2 u- mov al, ah
$ R8 L5 h! L! l- r8 i" n - or al, 2 ; Enable line A20 / w7 t. ]. I! I5 l" `, ?
- out 60h, al
: p' B7 }5 `! G! M4 L6 v' T - call A20Write 4 m/ |: F5 B! W
- jz exit_enable8 R! o3 E. [ d. g: L! t
4 D- c3 L4 I# {! V ~' {- I- mov al, 0FFh ; NOP 9 I! G5 q: G& v$ _) v3 h
- out 64h, al
+ T% W. U8 W8 O! T3 S6 D! c - call A20Write
# M# k! B7 R; U8 Z) D, ~/ |4 V
) j& V w: a2 R# g7 w, B7 |- exit_enable: ret
' N' {1 P+ V- N, t" o
- T4 W# C: w! w, K- A20Write: xor cx, cx ; Reasonable wait
9 ]. Y' L% ` M - get_wirte: in al, 64h ; Get KBC read status , I% L. c' R' z5 [- H) [
- test al, 02 ; See if buffer empty, bit 1 clear # s$ _! j O1 ~
- jz clear 3 j9 l: R8 @, f, L% P; Q" R
- dec cx / K& U, {$ F' h" z. b" h- G
- jz exit_write
: U* l1 Q: E! K S - jmp short get_wirte
: B4 E- k r) E1 ] - clear: inc al ; Clear ZR
* o# e+ k5 v5 m% O- v j - exit_write: ret ?: u3 g2 T$ ?9 |0 Z n
" u0 n1 Y% @# t" N+ v7 A) f- 4 w1 I3 l" m% c2 p' g
- A20Read: xor cx, cx ( t* D1 U- n" s9 P
- get_read: in al, 64h ) D! T) ?' h# B: C: C7 N! k
- test al, 01 ; If the 'output buffer' is full, has
( w6 S2 A2 g) T4 D; e/ [ - jnz exit4 ; ...
/ ]# d# V6 a/ M" S% B - dec cx
6 q3 R1 Y3 f! V. B- M+ ^/ B - jnz get_read
4 |7 y; w! I' q% F* [ - exit4: ret 6 B/ p; [1 B3 H# {$ F8 x4 l
- " @+ j. ~- h7 _
- end
复制代码- ;A200FF.ASM 7 S7 B" n2 l1 c0 p; x1 {
- ;
/ r' D4 v" c6 n$ O4 w5 L- U) m - ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01# e0 c* r2 O" n7 H( M/ B
- ; ml A20ON.asm ' E" a3 I% u# t( k+ _7 g3 K, e) k
- ;
3 w3 S) l+ I' ^9 B - .model tiny
# P' e' o7 k* q% s - .code9 X I0 W. |9 B& H0 _
- .4861 p+ i" f9 \5 g3 x! I
- .startup) I4 m+ H4 x, G$ w4 \! f- I
; O1 d: }! V6 m; E3 H& J# K- mov dx, offset msg_author
* L- \2 x- m/ C6 g; P. h - mov ah, 09h
|0 p" T/ q" l$ U0 F+ d, s2 R - int 21h
+ Q' v i8 J3 N' m' _2 P- P
( O5 E1 t) e1 X% q- mov dx, offset msg_fail
! V8 m3 z. O" l# K, D* E9 y" m - call A20_DISABLE& `$ v) P9 n6 w3 u1 Q0 @
- jz exit1. O% ^3 a2 K$ Z
- mov dx, offset msg_ok 9 _# X1 p1 K G6 u
$ B1 \. g! M( Q7 T& T' J( U2 X+ U- exit1: mov ah, 09h ! h2 x3 z1 P8 _2 ?) D
- int 21h
" r4 q3 _0 U! Z2 ?" ]6 Q6 } - mov ax, 4C00h
5 C# \0 @ p( S1 | - int 21h
" J/ @; I0 f5 u8 Z X* A - 9 r" S3 w& U8 U4 A1 J3 k7 ~2 p
- msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,
4 \0 u/ \ g1 y2 B - "2008-07-01",13, 10, "$" # z8 O) S/ c& v/ D
- msg_ok db "A20 Disable OK", 13, 10, "$"
2 ]- ~+ w/ \5 R( U: U) l- S3 n - msg_fail db "A20 Disable FAIL", 13, 10, "$" |1 Z& k* X" R5 y: {
- + u8 M7 W, T& r0 D
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
, S6 ]' Z1 d: s5 _2 K. h) k - A20_DISABLE:
% a$ U1 e( [8 M ^- O - call A20Write
- D8 K) x/ P' B$ m - jz exit_disable+ m! V* Y1 q; Z9 D: x$ E
7 X! x6 b c( [6 Y- cli ; Only need for reading value from KBC
/ i/ `8 O( r" l; s - mov al, 0D0h
( x5 p! b9 O; O o) e - out 64h, al
: l* A! ~: K& h2 F: p. u2 G& _ - call A20Read / _ x$ d+ L, v3 v5 q
- jz Disable_int 6 q8 M2 h k( `* H; i$ U
' b. o: Z" l% e' {; j6 @ N- in al, 60h ; Get current status
: {- {1 b' V* k0 T; Y9 y* n1 _% t - mov ah, al
! B% R1 H0 _" a9 P6 L& O: w! d( A - call A20Write
5 m1 i- j+ T$ ]- |; I - Disable_int: sti
/ l* w3 _6 \! `, S - jz exit_disable+ W+ K( [' \% K. p+ p
- # d! m4 C9 C9 f
- mov al, 0D1h ; Tell the KBC , want to write to the
# ~& Y) S _6 `1 I. g - out 64h, al ; Out Put Port next 1 X! @' f6 t8 c3 X: q6 [8 g
- call A20Write ' g" E$ I! g( _
- jz exit_disable; |3 D) [7 X( M
- 3 e0 E# W4 Y* I& a9 C3 I
- mov al, ah 8 X, D+ M: T) T. w; h! m9 T
- and al, not 2 ; Disable line A20
0 |7 } T( X {6 b: S6 b1 p - out 60h, al
4 N2 D* t( h, t - call A20Write 4 f" S5 E' n0 ^ L( g) `8 m
- jz exit_disable
7 i. m! F- A% Z
8 \: z! L H+ p/ A- mov al, 0FFh ; NOP
% `/ ~# y/ u- g, s - out 64h, al - |- |; N. t% R% d0 T
- call A20Write 7 @1 \* U' a* y2 Q) _% J: ]" O* l1 ?5 H
+ K M- K4 y0 Z! N9 @$ y8 y( T- q- exit_disable: ret
: a3 n1 X5 _* M9 U - . k( v+ q8 e" x
- A20Write: xor cx, cx ; Reasonable wait : u l0 r& W3 m( M
- get_wirte: in al, 64h ; Get KBC read status
! l% I; Z9 g) t( t, ?2 }' k - test al, 02 ; See if buffer empty, bit 1 clear - N# W6 E& o; n# v& M2 b4 M( V
- jz clear
_7 t; w4 k5 D3 o- P2 x! o' P7 O% y - dec cx
& A2 v7 Q+ A# L4 B1 d7 d9 U. g- Q8 ? - jz exit_write
6 \. h; z: p1 y- f - jmp short get_wirte
% K+ B0 W+ N! s9 U1 b7 c, B - clear: inc al ; Clear ZR
0 q) r1 _4 R! F3 W7 Z - exit_write: ret
& J1 D' i4 F: j+ y! y
: n% j: v3 J3 E6 A5 O$ @! k( p
- D0 Z/ b, _# F3 G9 r3 K- A20Read: xor cx, cx
% U* |: s/ D4 { - get_read: in al, 64h 9 K2 v: h1 }! j- J0 W% u( I9 ?+ ?4 {
- test al, 01 ; If the 'output buffer' is full, has " J4 T" ^& X) Z l
- jnz exit4 ; ...
+ P) u4 v+ r; e+ ` - dec cx
: i- s& E6 k/ h! Y+ H+ w8 a" e) D- T - jnz get_read+ ~# ^1 K2 r" ]3 I4 [- g
- exit4: ret
6 u) L. v$ P" z: x$ n) l% ?7 [: d -
7 s- V) q" l& I: [- p' O - end
复制代码- ;A20STATE.ASM
: t0 f2 ?" Y: O0 f - ; ! N5 J8 v9 U: y( z
- ; Returns the status of the line A20 through the KBC - f }1 v1 @1 l/ V7 h: G( }
- ; programming by bini for debug. 2008-07-01+ J* s" c8 g( U
- ; 5 e" r$ u% K$ t) f# d
- .model tiny% m, o# Q" n% V' V6 S: D1 p
- .code9 Z4 ^5 @0 _2 H* z: I
- .486
0 J( r4 ?& n; w! q M* I- _2 s9 S8 n - .startup
5 b: Z5 ~3 E: G3 K! c - mov dx, offset msg_fail 9 \0 M* F( S7 t8 A: c0 K
- call _GET_A20_STATE_* I% L( M D n3 N) j3 g
- jz exit1 ; was a problem
, o9 w. ~$ Z' j' Y9 w4 G8 c) w% y - push ax ; Save state, AH 1 n/ s2 i3 |5 J- u" M, x
- mov dx, offset msg_ok ; There wasn't a problem
- X* A& d$ k r9 ^/ G, q* T - mov ah, 09h % v) d3 y' w* ?3 r) J
- int 21h ; Print message
$ z. t4 y# w U& L - pop ax ; retreve state
" d% N( o- K' F- R! w
3 i+ ]. t8 a- Y) B( y/ s- mov dx, offset msg_dis + P( P8 v0 j, N- b0 _4 z I$ p
- and ah, 00000010b ; bit 1, 2h, indicates state
: f, f) G N) T* H+ y+ v4 o" | - jz exit1
8 Q; f& B! i1 w8 I$ j - mov dx, offset msg_en 2 J0 v. d4 E. w; `6 ?' ^: N. [
- 1 f) c' o# z! w1 D5 L
- exit1: mov ah, 09h
2 I5 B) a. {/ J$ N) e! c' ]1 B - ; DX already contains address of string
/ Q$ M f+ b- H d - int 21h
$ V5 `! Z0 q1 J6 I
7 E" z# s4 n% x6 Y( e" L) q0 s- mov ax, 4C00h . N' Z$ |8 ~4 l. S
- int 21h
$ h- n1 V) Y6 R4 V% V9 T# ?9 l" `6 Q
8 A& P J/ ~7 q! U- msg_ok db "OK", 13, 10, "A20 $" # r3 D6 u! ?7 `7 q3 n
- msg_fail db "FAIL", 13, 10, "$" + ?+ A1 {3 l% i. u9 `
- msg_en db "ENABLED", 13, 10, "$" ; T! L; O* n% O$ K( a
- msg_dis db "DISABLED", 13, 10, "$"' L/ y+ y' ^6 R% p* Q
& e w9 l& t* O) [; \$ Q7 H-
3 X: K' a$ z+ x5 k - _GET_A20_STATE_: 1 s3 {* M) n' t5 u1 G7 L
- call A20Write ; Wait till the input register is empty ( X2 Y. ~8 B( i% L2 [3 ?4 O2 x. f
- jz exit2+1 ; Bypas the reset int's
9 e! @' l, h2 o+ H( A! g - cli ; Disable ints so we'll get our value 6 V7 y, N" ]8 U' p! U
; v6 ?" J8 {, K, k$ A- mov al, 0D0h ; Send command to the 8042 command register
. v4 Q, V- u# g" b. E - out 64h, al ; to tell it we want to Read the Output Port ; I! J; E t$ l/ H4 Q, S
- call A20Read ; Wait till the 8042 output register ( R" X$ j3 ^8 e# T+ e
- jz exit2 ; has something in it's buffer
! a* L$ J" N9 o# z/ B/ n$ Z - ) ~# C. T& F. N/ p2 D8 d
- in al, 60h ; Get it
8 m0 g3 c+ v9 H& H. B5 i" x8 ` - mov ah, al
1 V2 G) Y2 B/ T - call A20Write ; Make sure the input register is empty
' [( j& X$ F; M. E. V7 N) ` - jz exit2 1 e; ]8 @3 Y! R: ~
. l6 c- k" v( x: H& O1 b. {- mov al, 0FFh ; KBC NOP command, does nothing - o! Z; n2 w9 T& ^' c: o7 r
- out 64h, al
9 e' g% j$ f: E6 q! {: Q - call A20Write
7 I0 R: I; N- p/ X) _# X% y/ }; V% G0 z - , Y: i# Z# K. v7 n% L2 a
- exit2: sti ' ^8 Y3 `/ ` f" O Y$ [
- ret
8 V9 [% M( ?( ^3 U - # h! d+ F5 L" M# \$ [7 |1 s
+ C, l' l+ H* i- A20Write: xor cx, cx ; Reasonable wait
6 h* a8 J1 M: R+ K5 K) X - get1: in al, 64h ; Get KBC read status
# T) L1 X8 w9 H - test al, 02 ; See if buffer empty, bit 1 clear 3 x; d( ^& }- j% k) ^4 b; R5 h% q# C
- jz clear
1 I/ Y$ W, ~& S' G+ x% e - dec cx
/ z- r+ p) K9 P' @6 x - jz exit3
* v4 W1 J! H: L% K0 ] - jmp SHORT get1 / r$ H! F. R U7 ? T0 n
- clear: inc al ; Clear ZR . c* `( a) k( j) n& S: [1 d
- exit3: ret
; g/ D( J1 Y9 _+ H; s( ^" R/ m - $ R3 E$ T& T1 L5 R" |- ?# N. E
. x/ i1 ^# D7 _8 l' i$ C- A20Read: xor cx, cx ( {$ L, l9 s4 b5 ^
- get2: in al, 64h
. r- t/ q( ?$ a/ C6 ~2 I3 L3 B - test al, 01 ; If the 'output buffer' is full, has
# B: W% B4 X* F& d - jnz exit4 ; something for me * o& ^1 H2 j m. j6 ^
- dec cx
' ^) u3 x7 O* O% S& W: M% l- w8 V k, r9 u - jnz get2
- F4 `6 m9 |5 ^2 C - exit4: ret + ~6 I( v6 [ N1 \
- 4 d1 }% ?; Q; A: o+ h' H! i
- end
复制代码 |
|