|
|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM 7 J0 X( T; Q" v4 m! n0 J
- ;
7 N/ ]0 i; z A ^& M- v( [* R - ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01
. y% N0 j2 ?# v/ l1 _2 u- a - ; ml A20ON.asm 3 P6 i; d5 j4 c9 p
- ; 6 L( `4 j' g8 `. o" H
- .model tiny% p# g* m4 C4 {( C) b
- .code9 C" n, p3 d% m4 {3 f% {
- .486" H" D0 I% b$ S, s( N' I6 X5 y
- .startup; |* o9 L9 ]+ S$ @7 `$ s
- + E% l: p3 @. ~6 s
- mov dx, offset msg_author
6 x8 z" h- R9 w( ~* d% ] - mov ah, 09h; c5 G4 H0 \5 I! W6 E
- int 21h4 N( g; }6 ^. w. E7 x: i" @
- * q! g7 f, G1 B- g1 m
- mov dx, offset msg_fail 6 C& z+ X* T" v' {# [1 ~/ S4 \
- call A20_ENABLE
% I) ]0 }" y' E" h6 D - jz exit13 \0 W) g1 S# y
- mov dx, offset msg_ok 6 e( z2 C; i8 F+ M7 x. P0 N- _
- # N- ~4 `0 K/ M! T# z# Q. ?4 ]- r8 k
- exit1: mov ah, 09h . p1 \5 ^ L) S5 y# ^# v+ n$ c
- int 21h " o" q6 o& Z/ h% K8 \
- mov ax, 4C00h
, O. e1 N9 t8 R/ a3 _4 Y& E - int 21h
4 i' A k8 N) F- t( b - 6 q! `, w0 ^1 I3 w! T: t4 c9 X
- msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,( @% U; a) A3 J/ G) {4 a2 `
- "2008-07-01",13, 10, "$"
f- R; A9 C" F& ?3 T - msg_ok db "A20 Enable OK", 13, 10, "$"
9 p9 Y0 h/ c0 Y; q1 z/ o: d - msg_fail db "A20 Enable FAIL", 13, 10, "$"
8 p3 s3 s! R& U+ x6 T( B* t - ' z ?; |! B9 q9 {) \) J
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
, e3 ^/ M: \7 d5 ?; \ - A20_ENABLE:
; I4 p2 K" A( Q( I- {# d: P - call A20Write
. R7 s. A+ {$ I - jz exit_enable
- u: i. d, p( C3 y* l. G& t
# o0 j( E2 @% F- cli ; Only need for reading value from KBC 3 j! k, r! t, Z
- mov al, 0D0h
$ {: o# |" }" x4 h: D - out 64h, al 4 Q5 |5 l) M% U, e
- call A20Read
0 l3 p1 K1 y7 |( Y% h( i - jz enable_int 7 e, I0 w0 r3 k. d
1 V2 b/ r4 X# F! x- in al, 60h ; Get current status 9 E" v2 s# l% N/ ?- @7 j* k
- mov ah, al
" A) |5 R* K+ Q: u( M - call A20Write ) K7 ?. F0 Q2 B `
- enable_int: sti
3 }+ q1 o+ N' Q - jz exit_enable
9 ~( O4 b) N2 c; c4 M( v# R$ @3 e - $ H" c" s0 k9 H' h2 r
- mov al, 0D1h ; Tell the KBC , want to write to the 3 t4 J9 ?3 s6 ~9 u9 Y4 [' S
- out 64h, al ; Out Put Port next / ^ { d5 q" H: X/ K7 P
- call A20Write 4 p. Z& o; t1 ?6 u( i0 V# U7 B6 Y
- jz exit_enable: V0 S/ h8 ?$ [& _6 t2 ?
9 _% ~4 j9 x0 g, p- mov al, ah 0 B2 N8 L7 `' m6 { i8 _% O8 ?
- or al, 2 ; Enable line A20
# C u1 W5 P% W0 c - out 60h, al
' d9 i. {! q+ u/ [3 I - call A20Write
; [0 N! |$ ?; T5 F3 [* C' m8 d - jz exit_enable
. \" w4 f5 P. y' @. }
" @2 d! e9 L5 w$ y- mov al, 0FFh ; NOP
0 P: N' T: f0 g1 B - out 64h, al
/ Z0 a& K5 D6 P6 c* I - call A20Write ' I, y( O: c5 q! A1 ~
- 8 w2 o/ d" S( V# ], F: c3 q( c' W' L
- exit_enable: ret * p% `* I _8 H0 r1 p* r
! N5 @) U& k% N- A20Write: xor cx, cx ; Reasonable wait
! Y) ]/ [/ `, C2 Y+ a/ q O - get_wirte: in al, 64h ; Get KBC read status
0 ^- @. y, j8 ?+ j1 |" ], k) e - test al, 02 ; See if buffer empty, bit 1 clear : P" p" A+ J. V O- A( w. ?
- jz clear : k8 d ~) s" H6 d. `
- dec cx
% P* z2 H Y$ \4 ^ - jz exit_write
& @7 p$ v% t' S. P; T# t - jmp short get_wirte
4 h7 g+ n( E3 R. ?7 k4 P# p, ^ - clear: inc al ; Clear ZR
/ ~) V9 w' U% `2 c) m - exit_write: ret & m# d) `9 _5 U9 p# F, t
7 `, K/ G1 q C5 _1 u
: D( x! g% h K T( e$ M3 ~) O {- A20Read: xor cx, cx * A' Y7 g9 L( _/ U6 {" ]
- get_read: in al, 64h . G. z: O8 c6 q! \' w B5 H& Q
- test al, 01 ; If the 'output buffer' is full, has " B9 }+ _( f$ N0 Z
- jnz exit4 ; ... 0 _2 P" V6 ]2 V
- dec cx + U$ X+ ]( e9 @! H2 G7 \; p; n
- jnz get_read
% w( U2 C: z+ S: P! \. O - exit4: ret
7 {$ U* o: Z* N -
7 l+ M l n+ s" q - end
复制代码- ;A200FF.ASM
9 g: Z6 d( J" K/ h' ? - ;
; I6 Q7 Y: e( m9 k2 b! W - ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01: @7 r* U" L* A b) J. w
- ; ml A20ON.asm ; w4 R0 q. `* t6 Y a
- ; , z, n* j+ X1 ? r3 r
- .model tiny
i a' U) B2 f- I+ g3 X. M, q - .code' F9 k: l, d* S# G2 E
- .486
2 X3 O* M# B% a8 _ - .startup
, Z% ~: V% `! ^- e' s# \* E
7 W- d! U/ d) H9 Q- mov dx, offset msg_author( k* e* [! g+ E) ]
- mov ah, 09h2 K% ? u% V$ `% o
- int 21h
5 L h& f, Q& R) S - 8 |0 `$ L/ Z! ]$ R% X7 n0 L8 r
- mov dx, offset msg_fail
# H3 P6 O) | V0 j7 b - call A20_DISABLE+ e4 [* U* ~1 k. K7 R9 ~$ T9 R4 o
- jz exit1, _3 r) I q/ M' e
- mov dx, offset msg_ok
! D5 Z5 p. r# w6 x0 h
; @' m6 l; Y3 E' X0 r% h' F- exit1: mov ah, 09h
( x! U2 `- ]* ]6 ~+ c! g - int 21h
- j, c5 @6 v- Q w; X1 b - mov ax, 4C00h
9 \: v( e3 C6 g7 I6 | - int 21h
N$ R+ j/ j9 x5 e$ |4 X- u# x - 6 C! t( [" h# ^, w, C2 ?4 e, l
- msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,# g$ J3 }$ F, d4 s; I
- "2008-07-01",13, 10, "$" ; q G+ q, `8 b6 r
- msg_ok db "A20 Disable OK", 13, 10, "$" ; C/ `. Q' z: K2 }
- msg_fail db "A20 Disable FAIL", 13, 10, "$"
) ]4 `& }7 \0 G5 ^' V" [4 d
' ?, J9 l* v- G! p0 {- ;------------------------ follow code maybe make to lib, if you want...-------------------------------. J6 l( {+ Z7 C8 m) ~0 D
- A20_DISABLE:
. R# u1 a3 y9 w( P1 e4 ?/ B - call A20Write 2 x! v ~% y( S* g. Q
- jz exit_disable
) b# v4 P8 j* E
0 O! |) B& T8 A7 u3 e2 P% m- cli ; Only need for reading value from KBC
$ D- a5 g) g9 d/ E) Q S7 Q) @ - mov al, 0D0h
; H+ m" W* |2 ~ - out 64h, al
* C2 B" W+ d& E - call A20Read
4 a' t9 J; ]! D: G: ^9 ? - jz Disable_int ; Z: ~9 F8 W Q7 Y5 j
\+ H' F, P; y# f4 |! ~* `* s8 F- in al, 60h ; Get current status 5 w/ r& N6 I! x b# m- r, S; b! v& Y
- mov ah, al : k; O2 D8 m+ T
- call A20Write
2 D* J3 r- V. T' K a, \. o" `- Q - Disable_int: sti * Y2 h( Q5 P, C# ~
- jz exit_disable
7 Q7 b0 k& t8 q# i - 7 U6 o6 \- T& `# O; r6 L5 R" ^" K
- mov al, 0D1h ; Tell the KBC , want to write to the % ]6 e. V: Q8 z; _
- out 64h, al ; Out Put Port next 5 p- N& S* z" R, L
- call A20Write 4 Z' u6 K* O- O! [! [3 Q4 Z+ F
- jz exit_disable
+ _) T5 {" S& B6 a - % \8 i# O2 a/ H% N7 |' V
- mov al, ah - }* W4 H$ Z+ w' B
- and al, not 2 ; Disable line A20
+ B5 b" r* M+ F/ h0 J - out 60h, al
9 R( H6 l, _, G. v - call A20Write
% Y, F4 R a! Y8 b - jz exit_disable
: G1 Z2 `6 v2 B6 {. c1 R
6 e8 l# E% D& L1 B0 B/ }- mov al, 0FFh ; NOP
$ a) M: X* Z; r+ A! O - out 64h, al ( w# d9 v5 j% A' U
- call A20Write G& \6 F' G4 W
- 8 w3 ~# y) \- ]& T( }8 { z
- exit_disable: ret
3 S/ ~ q. E1 {, ^4 v* v7 M7 p. P
# W% {+ b" T. Z7 I- A20Write: xor cx, cx ; Reasonable wait
1 w9 n# S! [9 s - get_wirte: in al, 64h ; Get KBC read status j2 V! ]* t. h% S& c
- test al, 02 ; See if buffer empty, bit 1 clear
0 z+ \5 R. N8 P- |7 H+ B) B7 U' W - jz clear ) l6 V* D# C6 X& e
- dec cx
( N, @8 T$ q" A; |7 ] - jz exit_write # F5 J: ` ]! B( ?; x; c, R" B
- jmp short get_wirte
6 q2 K( A1 Y+ L$ E - clear: inc al ; Clear ZR
( l5 C: C. n" q* m5 `* g6 f5 J - exit_write: ret
2 h/ O8 e1 e+ o6 K1 G0 o' g6 U5 | - * b2 ]' B$ B( Y; Q
- 7 r) s0 R- z7 ?+ l' r/ t
- A20Read: xor cx, cx
8 C% [ x+ w8 a" ?- |: W - get_read: in al, 64h ) b1 S5 n% u5 D0 Y5 ]
- test al, 01 ; If the 'output buffer' is full, has
( N2 S* `4 i; {7 Y$ o/ l - jnz exit4 ; ...
" V) y/ N6 `2 Y& E+ K- M) a2 m7 u - dec cx ( ^6 l7 l! F$ @9 a0 ]
- jnz get_read
2 R8 I" a! }, ~ S! h9 G4 ] - exit4: ret 9 t. B8 E& y* y4 \
- 3 V* l x. p; o
- end
复制代码- ;A20STATE.ASM
% z9 U& q8 o. D/ q - ; * A+ z9 P% K/ S! k6 Q+ U" S
- ; Returns the status of the line A20 through the KBC 8 n0 F1 W, U, c; E1 y
- ; programming by bini for debug. 2008-07-01
' P- [: z4 H1 Z9 |( k+ [+ C - ; * h/ `6 v* j) r: g5 \$ B8 N1 T
- .model tiny6 Q% v+ e# [5 `0 Y9 q s' S
- .code
( [& L2 ?9 z. {7 d) V - .486: m. D3 Y" l( d& ~9 I# f$ L
- .startup
" H, c2 ~2 P: R$ e" y1 N$ v3 ~& c - mov dx, offset msg_fail
3 O8 B0 s+ |' U# {9 v( S - call _GET_A20_STATE_: x, w4 y; g F) B* F
- jz exit1 ; was a problem
- M/ _) }1 n1 h - push ax ; Save state, AH . _1 _1 M* z7 L" A; q: q
- mov dx, offset msg_ok ; There wasn't a problem
6 o3 [# D3 J. ]8 S1 b4 |) Z - mov ah, 09h 2 w7 T+ e- ?8 r! M2 `
- int 21h ; Print message 7 U3 L5 I# w3 `) M' H" n: x
- pop ax ; retreve state . ^" t f8 m u
3 J: X+ X, G+ H: r# D6 r1 g& w- mov dx, offset msg_dis
/ H, I$ n( d6 e* [, { - and ah, 00000010b ; bit 1, 2h, indicates state
1 i5 C' S7 G9 q/ A2 ^4 T - jz exit1 ! A$ s9 s3 Y# C- e2 S d- w
- mov dx, offset msg_en ) q3 ?, x' ]! ]4 x' N
: c2 ?! [0 o, G; m) }( N5 [7 @- exit1: mov ah, 09h
1 [& E9 A Z* \+ n9 I2 |0 W - ; DX already contains address of string 2 `. H9 q0 g- i: A" @4 E% i
- int 21h
9 D# c6 d3 D0 i. {' e e; F, ] - % X$ G9 V2 ^$ B D- [2 c; E! J9 X# S" [
- mov ax, 4C00h 6 ^+ Y9 I {' Y9 o3 e7 |3 e
- int 21h # t+ [3 }' N9 i E
- 3 X0 Y! N9 u. K5 d1 B4 i* t
- msg_ok db "OK", 13, 10, "A20 $" 5 V, l( q. c2 T# Z w
- msg_fail db "FAIL", 13, 10, "$"
0 ?5 P; v V7 S - msg_en db "ENABLED", 13, 10, "$"
- c6 e- R; p8 Z* F# s - msg_dis db "DISABLED", 13, 10, "$"" r" K' B r7 a* Z+ \
- : R& s2 s: O$ j4 D
- 1 s, T: _4 h5 x5 |4 B4 n
- _GET_A20_STATE_:
; e- j- k" S q5 d* ] - call A20Write ; Wait till the input register is empty
' Z" F9 g' F$ ~- Y8 O. N - jz exit2+1 ; Bypas the reset int's 3 a- ^" k, G( o" F+ t/ `6 u
- cli ; Disable ints so we'll get our value & n( Z1 {7 C' f. x" l
- 4 W6 G) n; q8 Q7 \
- mov al, 0D0h ; Send command to the 8042 command register + f' L% r( i7 B: V4 b: I
- out 64h, al ; to tell it we want to Read the Output Port , P4 j% L$ L+ ^# {) a' y" G+ w# g
- call A20Read ; Wait till the 8042 output register ( D9 D9 h5 c' K: f A( s
- jz exit2 ; has something in it's buffer $ i: X/ ~: }3 X' \- b7 b3 `7 k% t% c
, U" L4 G; B# Q! x- _) d4 I& f K @! Y- in al, 60h ; Get it
% d+ i. \& [$ ?4 u* X3 A5 d - mov ah, al . k0 d3 p0 y( E) X3 G5 c
- call A20Write ; Make sure the input register is empty 2 O& f. \. q! O* l0 i4 j
- jz exit2
$ f) \6 S7 L0 I - . R" x, Q# X( g( l$ S/ S5 Q0 c8 n) _
- mov al, 0FFh ; KBC NOP command, does nothing ' {. J3 E! h a% g% u0 r% M5 k
- out 64h, al * m9 }7 X) {, ^' O0 D2 ~, o: s
- call A20Write , T- d Z! d* G" G
9 o; w9 n' K9 e5 o- exit2: sti 3 I$ _+ X5 F3 R& t1 G$ j/ I
- ret! I" E9 Q( x/ Q. `; Z
: H( X" E8 j9 a7 C6 b1 E
. i8 ?, O8 q. ^9 \( I- A20Write: xor cx, cx ; Reasonable wait 2 y2 O3 _' t- i& }
- get1: in al, 64h ; Get KBC read status
0 M. v N0 Z1 e# O, a9 x" \4 C - test al, 02 ; See if buffer empty, bit 1 clear
" i3 C& H0 O; p& _, X - jz clear 8 J+ {6 X( J$ m1 y0 [: Q; P6 `: ~
- dec cx
( l/ r$ T0 m9 t. F. V( Q% K o - jz exit3
1 s1 E+ s2 ]' {- B - jmp SHORT get1 * U% n: d$ j. Z5 W
- clear: inc al ; Clear ZR 1 M0 s6 D5 u% h; [. j# w8 g
- exit3: ret 7 M( Z. a( ^" \4 E2 N# r0 j
' v7 R, C5 O" O+ d! o: W- ) n5 `- e1 m8 j
- A20Read: xor cx, cx
8 G1 }% c. [: x; w - get2: in al, 64h
. m1 L5 K! R3 ?* @- ?% u7 S - test al, 01 ; If the 'output buffer' is full, has ( g0 @# e# ?$ m% u3 U7 t' M2 l# F% r6 z5 O
- jnz exit4 ; something for me / m0 x4 s; C1 e' Q
- dec cx
! ?$ S* p- z" u* _ - jnz get28 O" J1 k0 @! r$ G. l
- exit4: ret
) k$ s$ @5 {0 L! x -
% X1 B+ Q5 z- O6 [* I0 @ u- K - end
复制代码 |
|