|
|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM 5 B0 ]& W. ^1 }/ ~* @: c* x& N J
- ;
& K; K* n4 ]: c" `9 v - ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01 l; l8 x2 _ C5 m% L* X- @; L
- ; ml A20ON.asm
5 v6 L& T6 F, b* P - ;
0 U3 w6 w5 c* F9 x5 R - .model tiny+ A- \# }6 H* q8 i
- .code" Z: R) J0 W) m% j" l: |7 S
- .4864 |/ W9 d( j7 ?) e& D
- .startup6 q0 j- B- ?; L
9 j8 E$ c; B |- mov dx, offset msg_author
; R2 {3 u3 T6 w5 F8 {% b( Q! v0 X N - mov ah, 09h
6 I7 z& z) L4 ~" d& _ - int 21h
/ W8 P! k* l4 V% X9 l# Q
* z# r3 F2 n7 a8 W8 ]- mov dx, offset msg_fail 5 R7 L+ y5 f7 A
- call A20_ENABLE* _; {* g7 `+ x8 l2 `
- jz exit18 a- G" a. l2 J9 h& v
- mov dx, offset msg_ok - q0 X" {# ]+ N# Z
- 4 n) y; W; D% ` P& |6 \
- exit1: mov ah, 09h 4 J) ?5 y) {4 r. y0 J
- int 21h 5 R! R% A- v+ x. j1 _& \# [+ v
- mov ax, 4C00h
7 s3 }0 [& O2 K3 \1 K - int 21h
: U$ T9 M( b! M% ^ - 7 X1 v7 j4 }) j# p- W
- msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,! B: n3 w% S% Q2 R
- "2008-07-01",13, 10, "$"
+ o5 z! U- {9 x3 y$ e - msg_ok db "A20 Enable OK", 13, 10, "$"
* Y1 U1 P# ~3 |0 Z y - msg_fail db "A20 Enable FAIL", 13, 10, "$" j+ B0 ^- W, {6 \# h
) S7 }7 |6 H) H- ;------------------------ follow code maybe make to lib, if you want...-------------------------------: ?1 w/ g2 t; a1 g0 ^( U
- A20_ENABLE: 3 Q, x) ^7 |: J4 r
- call A20Write
/ Q! W& W; h, F p - jz exit_enable* ?) T E S$ _$ J, \- N) Z. d
- % ]7 c/ [3 Y$ i) ^ A
- cli ; Only need for reading value from KBC
, r# @& b, T0 t3 k - mov al, 0D0h
; C0 Q, E: P$ ^7 i ?! L- O' k2 y4 A - out 64h, al
/ B; G0 [* n, A# u- } ^% Q - call A20Read
6 b+ r5 j R" k - jz enable_int
% R4 F& U. z* p' p: A6 d0 ?+ f. Y5 [
: H: W$ f3 V" W0 `6 j- in al, 60h ; Get current status $ ~6 h2 A8 L3 F1 [/ D% K O J
- mov ah, al 0 P: E, h) o+ {. V
- call A20Write
" @4 R( I" T9 m1 V - enable_int: sti 2 x- D0 ~9 u3 }5 O
- jz exit_enable
9 k: {/ w/ w" M2 F, ]# M! b
- L; b# x4 z: S5 I! G- i$ w- mov al, 0D1h ; Tell the KBC , want to write to the
, Y/ W& w, ~4 B6 z0 `: t: q x - out 64h, al ; Out Put Port next
7 @+ B$ x1 b: e5 }- W! v# i - call A20Write 3 s& U6 a( E! x, t0 ]
- jz exit_enable1 x* n3 p1 P$ o, b9 H0 u; Q+ S
0 v7 T) E, r$ S" ]* |% Q, q# C1 c- mov al, ah # X; t5 s6 }7 L6 Z
- or al, 2 ; Enable line A20 - v( ~& V a( g2 y& ~1 Y; {2 v
- out 60h, al
7 L9 `, K* T" [6 a) [( ~ f - call A20Write 9 u, \3 z4 H6 M) b Y) i
- jz exit_enable( Z: D# Q" q8 g, D2 I7 R
& E8 R) @& M9 }" i; n5 Q7 h; S- mov al, 0FFh ; NOP ( O. c. A( q" x8 e3 B0 H/ J
- out 64h, al / m9 S7 G3 H6 c, T8 i0 X
- call A20Write
+ r/ p8 t/ I: a% u. B$ O
) ~1 } ]0 }% X3 D9 W% Q- exit_enable: ret % w* h3 S. J$ S6 R* J3 E$ e
- 6 ^- Z: O! q+ S. Z
- A20Write: xor cx, cx ; Reasonable wait
" E0 q1 ^1 q3 T& q- i+ u5 b - get_wirte: in al, 64h ; Get KBC read status ( c4 ]$ I, E! i8 g, u" [
- test al, 02 ; See if buffer empty, bit 1 clear
- Z7 N: i" k, n - jz clear
) G5 U) V+ r7 Y( ` - dec cx
9 w" R1 [) M! z! C7 y- |9 |( j# T - jz exit_write $ _1 [9 p9 K9 i! ~$ W
- jmp short get_wirte , T4 X4 C z. x4 [! T/ w( p
- clear: inc al ; Clear ZR
/ X2 ?; `+ @: ~0 | - exit_write: ret $ Y9 v0 R0 ]6 Z! v+ E, g
) H& u! z) P q9 H$ Z% ~3 w
2 U4 N ^( L: Z. l3 n- }- A20Read: xor cx, cx
+ y4 ]9 Y0 y& b0 l - get_read: in al, 64h % b5 I: ]- ^. Y1 C& l% x% E( T$ L
- test al, 01 ; If the 'output buffer' is full, has
+ T, |9 ?# I& A1 F6 n: h - jnz exit4 ; ...
B7 U6 f5 J! R/ m - dec cx 7 F. s1 F* g0 z+ ^! e( C& w9 V8 v
- jnz get_read* |. k+ o+ y2 B- m8 v
- exit4: ret 2 T$ m* m' @: E5 m0 g
- $ p. s) B+ |/ _: [
- end
复制代码- ;A200FF.ASM 9 F( y; B4 d* a* s8 O# j
- ;
, y( J7 }. B, N2 P; H, E6 m3 ~ - ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01
5 K2 i- S8 o# F - ; ml A20ON.asm
' W2 b8 B/ z( [4 I5 P6 u' ]. s - ; $ c; ]9 Q8 s* A+ Q. d0 T, m4 Q
- .model tiny
9 F, B1 i7 z, e8 X - .code( _# }* I+ P6 f: V5 t# o- V. \
- .486
3 e2 A5 }. s* o( ~ - .startup1 P# J# H6 ?4 b$ j9 L+ E
- ) ?$ w8 s6 C5 c
- mov dx, offset msg_author4 b, B8 k0 M2 n" S. u
- mov ah, 09h4 Y! K( I8 _4 S3 J
- int 21h
4 V, {/ n/ s9 | - + Y( J5 H1 D0 x+ U6 S
- mov dx, offset msg_fail
6 i2 c! x0 Y& W. r6 P - call A20_DISABLE3 h; Q5 B; X3 Q4 g8 C4 A
- jz exit1* w0 o# ?* l! y9 b% X
- mov dx, offset msg_ok 9 b. {0 F; X y3 k" P
1 C! K) C( F2 s& t$ y) F- exit1: mov ah, 09h
' ]0 V# k; Y4 r, a9 O - int 21h
[/ m) a' `/ w+ j( m! [1 y - mov ax, 4C00h
9 j0 A; H4 C3 b$ B& C. @( Q. d- I - int 21h
% m1 F. {6 V! `& u" x -
6 U& n8 g+ |, P# I6 e) h0 R& f. w - msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,4 Q" h2 z* ?9 I, k8 u8 i: G
- "2008-07-01",13, 10, "$"
' N( b4 Q G2 V& i - msg_ok db "A20 Disable OK", 13, 10, "$"
- p5 G: o4 [- B9 v - msg_fail db "A20 Disable FAIL", 13, 10, "$" $ c" W9 x: E; x3 h+ d7 Z" |
# K! |; u0 m% F8 c! ]* l3 @- ;------------------------ follow code maybe make to lib, if you want...------------------------------- i/ b0 z. |7 h- J: Z5 s
- A20_DISABLE:
) |0 I$ S* D% Z7 i. a) _4 I - call A20Write 5 q5 R5 v" _3 h* y3 L
- jz exit_disable. W/ d+ P" R" o* D8 {4 W
1 `& T8 R" ?1 ?- cli ; Only need for reading value from KBC ( `: B1 t1 m0 d' ~& c/ s7 d
- mov al, 0D0h
% {% [* g: z9 r( C5 ~ - out 64h, al & J$ t3 ]4 Z4 X7 K
- call A20Read ! y3 O) j6 H0 n* J( M4 r
- jz Disable_int
3 g% {) _( S* q3 J. g - : I6 b1 A; p# J4 l1 x$ C8 N
- in al, 60h ; Get current status - y5 o' B6 p* y6 s* R
- mov ah, al
; y) I4 K6 u3 b1 v; p - call A20Write 4 W: s7 V( j w1 h9 C* h9 C) h* O0 `
- Disable_int: sti
0 n) p) C4 g; b, O3 u [3 Y' D9 L. b - jz exit_disable' ^6 x$ w5 z2 K5 y, d* P
1 F: e1 |. W8 A% r- mov al, 0D1h ; Tell the KBC , want to write to the ( y2 o7 j. o* O- `3 B6 m `5 c- Y, g
- out 64h, al ; Out Put Port next
' _3 g# c7 Y* S0 C - call A20Write ; k! i8 J6 V2 r% I1 }& O5 y
- jz exit_disable5 _; _4 F1 V+ _
- - \. e, b5 l4 C1 @4 Q
- mov al, ah ! v! J# q* v8 A4 E- @& J4 C
- and al, not 2 ; Disable line A20
- \ E! |6 v; O' j8 y - out 60h, al
# p4 Z1 p; Y# e4 i; i- e - call A20Write 4 @- h2 R# t* @+ o/ A: }2 D( h
- jz exit_disable
: P2 B& Q& ]* B/ y) o' t- H) g
5 K1 J* h r9 B- mov al, 0FFh ; NOP
B6 D+ `' D o9 B/ o' c - out 64h, al
3 {% Z& [- g) o* y% y3 L - call A20Write 6 u5 ^, ]8 Z; `! p# | V& t% d
T; C( [) A1 k6 I3 Q1 \- exit_disable: ret 4 D$ A$ q* n8 _. X4 P$ f, F
- d* t. u. \8 z, w% s- A20Write: xor cx, cx ; Reasonable wait
2 C' p7 B( n0 {* n - get_wirte: in al, 64h ; Get KBC read status w9 T7 K( m4 R3 N' s7 c2 n% j
- test al, 02 ; See if buffer empty, bit 1 clear
4 W X( Y$ m7 o/ U' {- c2 d# Y - jz clear " R( R: Z8 w4 h* m9 C7 e& b
- dec cx
8 M* E& N0 W+ ?) G; ~ o - jz exit_write
" v% ~, ?, ~, q! v4 K* c' u* S$ N3 b - jmp short get_wirte
' k6 O) D4 I# v. } - clear: inc al ; Clear ZR
% T- P* u' b' m! N& b - exit_write: ret 2 o: q" p4 L% i$ v
- # p" u6 l. F, b. b L8 J. u N
+ w* U$ B2 t0 V- A20Read: xor cx, cx
0 x1 I. O( P8 d& |2 w; X - get_read: in al, 64h ( W) C% Y) |& I
- test al, 01 ; If the 'output buffer' is full, has ! q+ r: |, Z% Y0 g5 |( J6 V1 _% v
- jnz exit4 ; ... 5 V8 y& Y2 Y* p! N9 D8 }
- dec cx
7 w, r. c1 _+ B4 U9 A# E - jnz get_read! J2 ~9 n+ [/ {
- exit4: ret 7 _+ ~. ^7 O/ `7 e% d7 S6 u
- 1 U5 z @0 [( e" \! |" O
- end
复制代码- ;A20STATE.ASM 9 k; R; Z1 P5 Q1 q% V4 ~% k; ^: ~
- ;
8 j" g+ ~" r- [* \: T+ r2 ^ - ; Returns the status of the line A20 through the KBC
+ }) S. D+ f/ B6 Y - ; programming by bini for debug. 2008-07-01
& t% @0 p- H2 O+ d* ~; I% Z - ; + h! ]" [, w2 [
- .model tiny6 t& g) R1 z4 ~; B, t# p
- .code
: ?: o- }) w4 A2 z, c8 A O6 a5 j - .486) s( t% }" [" m& v9 x
- .startup
# `. Z0 Q+ y, i# u. S - mov dx, offset msg_fail : M# I0 l$ S9 D0 b! \3 P3 _
- call _GET_A20_STATE_
, ?; b7 r3 t$ A+ R! E5 V' w# ] - jz exit1 ; was a problem
. H9 L/ G" Y2 J- r) }+ }2 B% ]. y, E- T9 \ - push ax ; Save state, AH
2 ~$ x$ ~0 e4 U U3 g1 M* p1 [ - mov dx, offset msg_ok ; There wasn't a problem ( W; ^. O% Z$ P
- mov ah, 09h - ^2 K3 z- @* [$ `5 A/ x
- int 21h ; Print message + X E* F( l* W; |0 V
- pop ax ; retreve state . f( ?5 }% z: h3 P8 {6 v
- 2 O/ b5 A/ w( \$ z, N5 q; J
- mov dx, offset msg_dis
$ ]7 x) s/ _6 F$ N' q8 v" |7 d - and ah, 00000010b ; bit 1, 2h, indicates state 4 {4 T# u. J5 q3 y9 O( {" N$ |
- jz exit1
9 i% c8 L; ^% h c6 Q9 a: X$ O - mov dx, offset msg_en ) J; r) Q% A% g% Y" a$ u5 F; g
2 ^5 R# m2 e" e) l H& w' V- exit1: mov ah, 09h
, X$ Y4 E: `/ h7 A - ; DX already contains address of string . o1 d: @6 i2 d! A9 x5 r
- int 21h
9 @6 v! b) J; R9 z; [- g5 y0 T/ t" R - + I. s' ~% L# U! T+ j& }
- mov ax, 4C00h & P* e6 |3 n. J0 k
- int 21h 5 Q# g; U% ` }& X+ w. M" i
- 5 q w3 b8 A, c# Z
- msg_ok db "OK", 13, 10, "A20 $" ( m+ v3 f* O6 t) w) K# Z
- msg_fail db "FAIL", 13, 10, "$"
. e8 t9 t( \( H - msg_en db "ENABLED", 13, 10, "$" 7 \$ G! G) f) s' N
- msg_dis db "DISABLED", 13, 10, "$"
7 g3 X5 ?3 c g! `! V
2 ]4 F: _6 a0 `3 Y* x-
7 ]/ q3 U; g" l; }" J$ x: N4 h" _ - _GET_A20_STATE_:
- R! R8 a* V5 ?/ _3 { - call A20Write ; Wait till the input register is empty + I6 |+ i6 Q1 \/ n) ?3 z, L( g
- jz exit2+1 ; Bypas the reset int's * b; t* D0 P l9 ?
- cli ; Disable ints so we'll get our value ' c5 r7 ~5 H9 H& l" B/ R
7 `8 V0 n% _( i% ?7 R4 u6 v- mov al, 0D0h ; Send command to the 8042 command register 3 W8 s, }( e( c- O. t* B [
- out 64h, al ; to tell it we want to Read the Output Port
3 f& |* r# \7 s! r0 h - call A20Read ; Wait till the 8042 output register : b0 \7 ]: p# D* E j1 S
- jz exit2 ; has something in it's buffer
6 t$ `+ J( i$ x# I
* w" Z( G& H( H- @, C5 w+ `$ t- in al, 60h ; Get it 6 X5 x, ]7 p9 q. \$ G2 Z
- mov ah, al 4 }# E" p: @! |" J- T
- call A20Write ; Make sure the input register is empty 7 Z M' \ J1 L5 A/ B
- jz exit2
- Z, z2 x$ a8 m2 m6 ^6 j
: ~4 Q6 a6 l! c2 z; K) s- mov al, 0FFh ; KBC NOP command, does nothing 1 [* e& J, E+ m( R! p+ r y; x& T3 _
- out 64h, al
6 s* l! ?% r! e% V/ e - call A20Write 4 @% f9 B' I) {. E' l @
r0 O3 g7 B# C0 m! Y- exit2: sti
7 Z$ O- E8 M& S; ~ - ret
5 t6 U3 _; R1 _& e5 c- l - , i$ \% }0 A4 J/ [8 s2 k9 |( C
5 q) o6 _) `/ U: n- A20Write: xor cx, cx ; Reasonable wait
; ~ Z! `3 ?& p# l7 H5 T - get1: in al, 64h ; Get KBC read status
' \9 f9 `7 s3 h& |% f3 r - test al, 02 ; See if buffer empty, bit 1 clear
1 \# I, |+ A& {5 Q. \0 |* L - jz clear : @0 \9 S1 L2 i9 e
- dec cx - @+ @" V& W! Q8 V# l( I
- jz exit3
0 p1 H2 L7 N. g1 E, V7 g - jmp SHORT get1
/ C' ?0 T' _, @ - clear: inc al ; Clear ZR * l4 m' w) J" _6 E4 c5 @; S/ A0 W* w
- exit3: ret
+ M5 n$ b/ S g6 s+ }: F) D! p3 L* Z
2 c% m, U+ F; L! b8 l! ` A
1 v* g4 `+ {/ ]; ]$ v8 D- A20Read: xor cx, cx ! x9 l& x" z3 t0 g" t F; R
- get2: in al, 64h
j1 C4 Z5 N0 X8 r! j8 ] - test al, 01 ; If the 'output buffer' is full, has 9 c6 l$ @4 T9 H
- jnz exit4 ; something for me 0 g' U2 V+ B j
- dec cx 3 l6 n, o( I9 S# e
- jnz get24 o- h( q, \, H c8 w/ \) I
- exit4: ret # K. Q4 Y% Q5 N) z& ~& p. g$ I
-
# O( X$ h3 t( _" E: o+ r - end
复制代码 |
|