|
|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM
1 @. `- z- }6 R: D1 h - ;
1 Y4 f; n+ A/ H: I2 ` - ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01
, ?# B6 j, }8 g - ; ml A20ON.asm 0 ?. G2 m9 \) `# y4 Z
- ; . u* |8 y6 k) f h7 r
- .model tiny8 h1 d0 W# ?, u7 G9 C/ E9 k. ?
- .code& `- Q' I$ Z9 p1 x5 X- A1 {5 ~
- .486
b# Y( A9 i; q1 b y - .startup
" r; @5 M8 }2 d5 T" | - 2 z# R6 F' T- M5 d
- mov dx, offset msg_author. |1 a2 Z j6 g4 \8 @: L2 G, V
- mov ah, 09h$ P- u! e# x# [* y9 C
- int 21h r" l4 i4 \& W. Q! [4 i4 s
2 f: m6 Z c& x3 v9 E% V2 ^) u! }7 X" I- mov dx, offset msg_fail + y" _/ R$ V( B }
- call A20_ENABLE
/ t6 C( j% i7 ~' J - jz exit1
& X' M' F, Z5 R# [3 L - mov dx, offset msg_ok # l" |9 D% i; A* O R! \6 b/ d
. Z. _$ L; o. ?! n8 }- k3 C; W& |! f- exit1: mov ah, 09h 9 d( }) Y. Z% q5 O
- int 21h
) w0 Z% T1 |! V1 O5 K% v - mov ax, 4C00h ' S8 v8 I- @0 [5 F3 u' P3 {
- int 21h
" d) M& t1 D8 N& @7 Q6 Z! ?! H: k# h - 7 |" k* W( L; Y; K: }4 G. q8 ^% a) f& _
- msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,, v' E3 ~( L: j$ x
- "2008-07-01",13, 10, "$"
* m$ L: b$ y" s; x/ n6 h - msg_ok db "A20 Enable OK", 13, 10, "$" ; S G7 h) @6 f- |! p
- msg_fail db "A20 Enable FAIL", 13, 10, "$"
0 V0 U7 S* I8 }$ n' `4 w( ^' L - 4 c0 d* @5 X# K$ Y7 v. N9 E; H
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------8 ^& H3 H* ]* c0 u# R& l
- A20_ENABLE: , g" h2 [ s: ]
- call A20Write : H7 d9 A J% W) v
- jz exit_enable
+ f3 }4 J3 M% w# K4 z, X, w
$ \5 O: f* E6 |" y1 Q4 X$ {: M9 N- cli ; Only need for reading value from KBC
& b& r c. c- Z: F! Q - mov al, 0D0h
9 c# B8 g. A# s - out 64h, al
N7 }8 i6 g6 O1 u( ? - call A20Read : Y* G5 l6 {( W3 u1 g3 H$ G! @
- jz enable_int * L4 v I! N6 c$ v4 G
: \! I9 `/ }6 W' o1 w D8 {- in al, 60h ; Get current status
. G) l" Z ]5 b* F; ] - mov ah, al
5 u( d. a/ k3 c3 s: v6 q5 p4 u o - call A20Write
" S3 p+ y" b& n" P( N- r+ | - enable_int: sti
+ u9 f1 b* a* w8 } - jz exit_enable
9 F3 l# w8 H: ~+ C# D
" H, {) L7 O; ]7 @9 J- mov al, 0D1h ; Tell the KBC , want to write to the ; c f7 K$ S% Q S
- out 64h, al ; Out Put Port next
$ ~: s$ R L: m' ] - call A20Write
! ~1 a9 i# L% S3 g! X+ L1 e - jz exit_enable; h; X8 T& D- M- [" C
. p8 }) L- ?% k9 y5 P- mov al, ah 2 l% r' N% M4 W& v* P' h1 V
- or al, 2 ; Enable line A20
0 v" `$ {! Q/ W - out 60h, al . N2 C0 n2 O" L" t* k; l
- call A20Write * z7 _9 K" ~# ?8 ^) P) m& B5 D
- jz exit_enable0 j; c$ U, i9 u9 q/ h0 a
8 H) l3 }6 H8 K Q- mov al, 0FFh ; NOP 9 s* p H6 Y) o9 L# z" P
- out 64h, al
2 d9 j K- t7 U+ t - call A20Write # h- A$ Q- j7 R9 Q
- 7 ?8 O+ w0 e$ J& U. Y- _
- exit_enable: ret
: X1 e4 s+ K- a+ q, h3 D - " S* b1 u% |6 A- ~
- A20Write: xor cx, cx ; Reasonable wait & j4 i% |) W# Q
- get_wirte: in al, 64h ; Get KBC read status
9 u" ^5 ?2 a; W/ t- h0 R0 O1 c' x - test al, 02 ; See if buffer empty, bit 1 clear ) I* r/ O: }" `' A/ C
- jz clear
8 l( {9 w& p- w; a G* s - dec cx
' ]+ ~' }; B2 g. |( G - jz exit_write 8 A9 ~; ?# T% a% r9 ^, i
- jmp short get_wirte
% k# a8 Z# n1 o% V - clear: inc al ; Clear ZR ( f8 C+ p( D1 h8 C, j- L
- exit_write: ret
: }( W x" K% P2 G" j4 `9 F! M# f* f7 [
7 W. s# Z9 I( ~8 m# n- % D' _4 J- t# K9 A1 O3 i2 l
- A20Read: xor cx, cx : j! {* t. r+ x$ G9 ]6 o7 u
- get_read: in al, 64h 4 _( ^( { T* N3 b! C
- test al, 01 ; If the 'output buffer' is full, has % m \9 s3 }3 j1 _1 {$ r# t
- jnz exit4 ; ...
) z& J% j4 C0 G b4 n" J4 } - dec cx , [, f* U! R$ q; N: D
- jnz get_read
5 K. r2 r& G h2 }# ~( Z0 w2 @ - exit4: ret
4 L, A" r- k) C. \ S: v f -
& [: t% n6 X' G1 b+ m& e - end
复制代码- ;A200FF.ASM 6 J1 H6 ?0 l: f; j
- ; 1 }- n, i; e2 a
- ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01% s, ]: ?8 Z( D& j0 t2 N3 l6 N, j0 Q
- ; ml A20ON.asm
3 B2 r! e) _" y' j; G% \3 ]( f( p - ; ) Q6 V9 x8 d" [) f& f* c
- .model tiny p# D \% ~2 D5 T5 g
- .code' ]* p3 d& e& T
- .486( S& d+ P; b5 z0 U! H
- .startup3 p# f+ ~% F6 @7 Q; o5 |
5 ?; k1 }, r! F& C H+ I- mov dx, offset msg_author& P# W, s3 |6 e6 F
- mov ah, 09h
6 D( h6 | K6 g1 Q7 A# ]+ l& w - int 21h
; O/ p9 A9 ]" R. N& u" k: {, o
3 M6 _) T9 S$ h, C2 O9 Q5 m. A' U- mov dx, offset msg_fail
" G1 Z6 R" l6 v3 B" j5 r- f+ f' d - call A20_DISABLE9 y5 `5 s% B: @. o- l! F: D5 v5 ]5 ?
- jz exit1
. v$ L5 g, j0 r e) n - mov dx, offset msg_ok + W& Z- Y" P' u, ]5 M* C2 ]9 H
* a( V* o! F+ Y1 J7 x) b8 _" B- exit1: mov ah, 09h
9 c* ^7 z) G0 p- ]2 e' Q/ v - int 21h 7 E/ x4 ~% n+ s( q2 D
- mov ax, 4C00h ! r$ g1 z2 F) H2 w/ b
- int 21h - j4 _9 V1 d ~/ k+ r
- 9 h- Y8 _( m" r, V1 a
- msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,! v) u- G0 J9 Y4 z
- "2008-07-01",13, 10, "$" 7 D0 b" w' {7 Z
- msg_ok db "A20 Disable OK", 13, 10, "$"
* w3 `7 g$ [$ o/ T% k - msg_fail db "A20 Disable FAIL", 13, 10, "$"
x% [# s+ K. z+ @7 j
5 Q9 p- Y# ^% |$ J- ;------------------------ follow code maybe make to lib, if you want...-------------------------------* C6 U1 g0 v: D: \8 w5 @! m* [) Q
- A20_DISABLE: ) ]$ H- L& w* K" B/ _
- call A20Write 1 _ a6 x- O/ @; |7 ?
- jz exit_disable
' C& J% e0 [( {7 ~: h" h
4 n6 h/ F; Q: v& _+ k- A- cli ; Only need for reading value from KBC ( m- `; X: z4 V' U: u4 L& J
- mov al, 0D0h
. L9 \( q% ]' K4 I0 T0 i - out 64h, al 1 u! g; L" f8 Y" K- x" z8 b
- call A20Read
, f$ u* W. C+ S2 y - jz Disable_int
, T3 B/ f+ N4 k+ B* c* |, F2 q
7 e Y1 V! V# y H- in al, 60h ; Get current status
% t; t0 D- h$ T' R0 x# Q - mov ah, al
: ?5 K' k5 b# x# w# X - call A20Write
6 e& m/ ~9 ]9 @+ w# C - Disable_int: sti
9 H" p% |/ t: ]" A6 P) M. ]$ ^& q - jz exit_disable+ Q0 }8 n' h% z$ ]" e0 U ?
' Y" \) p" l3 R9 p- \( h- mov al, 0D1h ; Tell the KBC , want to write to the # C1 S8 f9 E3 c" L
- out 64h, al ; Out Put Port next
3 f( N' {2 B6 p1 p8 K& X - call A20Write & ?; {/ U$ X% E' e/ t q4 P' v
- jz exit_disable
3 ?- W- y0 C8 J9 y5 s - 0 n' f1 V, r1 {# `2 V
- mov al, ah " C% [( E" e2 R- g2 o+ L
- and al, not 2 ; Disable line A20
7 j9 T6 U3 R2 m% l - out 60h, al * k# Y) V* u# e: R5 X, _
- call A20Write
4 M, T Z& X! k& a - jz exit_disable
" ^8 m, Y# Z/ O
* b$ n4 W% ^7 } {# \3 k( F3 h* k- mov al, 0FFh ; NOP
5 }' M8 |! Z0 u r - out 64h, al
7 N8 j/ t+ f! U0 x% [# | - call A20Write
( U" e3 _- `0 T! s2 y+ e% b( X - * e6 z7 k5 Q% Q+ C- f: U6 L
- exit_disable: ret
7 z) _8 V$ _, U/ V( Q; `* F
! w! [0 C: X! G# ~+ O7 K- A20Write: xor cx, cx ; Reasonable wait / k1 F" K* K; ]
- get_wirte: in al, 64h ; Get KBC read status
( z* L, ~) L2 G9 w) H$ f, M) d - test al, 02 ; See if buffer empty, bit 1 clear 3 e) P# `4 e2 {; R
- jz clear
+ ^0 ~% a' C* {* g7 Y$ Y - dec cx 8 w; z0 i! M: {) w% T
- jz exit_write 4 `" g/ t! Z1 Q& t( Y
- jmp short get_wirte
7 Y! ?9 Z* V- f - clear: inc al ; Clear ZR 4 p0 k/ l ?6 Z; ?4 R/ X: h8 w
- exit_write: ret
4 i/ k: K, y( ]( [% h' g4 Y# K) _ - , F @ ^9 b; i
& E" q' _) @$ ~' w7 F- A20Read: xor cx, cx
8 N. Q1 d9 j3 F - get_read: in al, 64h ) m' ]3 w' R9 i% g# ~5 L5 [
- test al, 01 ; If the 'output buffer' is full, has
: ]* k. u: O; [0 j' q - jnz exit4 ; ...
& W# O! n: a/ u7 L - dec cx
& A5 M& c/ z& W* F3 q - jnz get_read
( F3 f' T5 K' | R7 D - exit4: ret % p( Z8 Q' v- m. Z% \" E; r
-
: H) D4 ]) A! `8 J - end
复制代码- ;A20STATE.ASM / B0 z, e, g+ I" K/ F
- ; . {! z" K4 d! b$ ~ e% Y4 Y" {% I9 `
- ; Returns the status of the line A20 through the KBC 0 O% N% n) P' n* D) n
- ; programming by bini for debug. 2008-07-01
, T0 l( N$ q" x0 |9 R* Z - ; : @% |' N G5 Q4 K3 l3 k4 ]# P% P
- .model tiny# ]" U7 h0 H5 |& o8 U
- .code# {/ {8 B! M$ k3 y( R* u9 S
- .486
1 f4 @- S$ @ h- q- ]8 ?% d( [3 u0 {- p - .startup; ?, {/ d. O9 a& S8 j, t
- mov dx, offset msg_fail 7 U; D, a& w+ c4 J5 i
- call _GET_A20_STATE_
0 Z4 l2 f' i+ p1 { - jz exit1 ; was a problem; o( R: L* a- }
- push ax ; Save state, AH % J# J1 D P2 c
- mov dx, offset msg_ok ; There wasn't a problem * k; u2 P, W4 h7 U$ }
- mov ah, 09h 5 o/ l R! @6 g* \" W) E
- int 21h ; Print message
7 K% i$ w/ d: P6 R* B K - pop ax ; retreve state
9 {8 j7 F9 _7 ?6 P1 S6 a
* E1 `* t8 F+ f. v7 ~- mov dx, offset msg_dis 8 T( U* A8 i8 r/ c! Q
- and ah, 00000010b ; bit 1, 2h, indicates state 5 u+ v& t2 `+ G7 z* f- p5 e
- jz exit1 / U$ v) m" f9 ]4 a7 b& }! P( O
- mov dx, offset msg_en
: b) Y. b/ W; t' h( r" Z$ }
: {6 B# @0 M% @9 a7 z- exit1: mov ah, 09h ! a, R& O8 Z4 }; H* U" `
- ; DX already contains address of string
- [8 `1 s8 y% O: A8 o - int 21h
1 [( @) }1 `% D' L4 w, _
8 `# a- n% d) b. m5 H3 K& `- mov ax, 4C00h 5 m3 m: u7 p$ W
- int 21h - U( i7 v3 b1 A
) W+ b6 `8 I- H- msg_ok db "OK", 13, 10, "A20 $" - q5 b! n- T% X/ \3 I$ e* K
- msg_fail db "FAIL", 13, 10, "$"
9 |$ W! e( o( Z, B - msg_en db "ENABLED", 13, 10, "$" 4 _! y2 i% d0 r/ l1 J
- msg_dis db "DISABLED", 13, 10, "$"
# _5 l6 b* `0 `4 K$ ]( `% I - 4 H# ?3 V* ?+ ` h. T1 ?1 L
- {1 J& e. |7 ^5 n$ ^: d# b
- _GET_A20_STATE_: 7 V" Z C9 n/ `
- call A20Write ; Wait till the input register is empty % m. I, j2 D1 P; `! q
- jz exit2+1 ; Bypas the reset int's 8 G @! s3 J: A7 B
- cli ; Disable ints so we'll get our value , i" t" H ]2 ]) H8 s
- # n8 l: H$ y0 N# X
- mov al, 0D0h ; Send command to the 8042 command register
& M. O/ h" y& ]: r - out 64h, al ; to tell it we want to Read the Output Port
! |3 N8 J$ v9 { - call A20Read ; Wait till the 8042 output register % A4 d/ U, h$ p% D
- jz exit2 ; has something in it's buffer
' L# `( ^& @+ f( _
$ D5 D, a) @0 \# q( F9 E0 C, ]2 v- in al, 60h ; Get it
! O( h9 L9 e! S - mov ah, al
8 U1 p5 X5 x* ?* B - call A20Write ; Make sure the input register is empty ' k% R! f& C& Y9 I9 n& g
- jz exit2
* V/ j0 i& T7 v1 j/ V
2 t3 E2 {6 O. V- d- mov al, 0FFh ; KBC NOP command, does nothing + ^- f- w2 j, l) g9 A O, D8 S
- out 64h, al
. ~+ ]$ a& Z$ A4 ]8 m" { - call A20Write " |/ q) E, [8 U& e" j: K
% m i6 a6 B) R- exit2: sti ) @. F0 H. R& e6 n
- ret8 {$ f3 q6 Q" ~% n" `
3 `0 i4 E# f @6 s$ W
+ H% t8 m; u9 s8 i- J0 k- A20Write: xor cx, cx ; Reasonable wait / s1 K% h1 z& J% _: g
- get1: in al, 64h ; Get KBC read status , s: P* n0 M) a; g2 Q: m# ~2 o
- test al, 02 ; See if buffer empty, bit 1 clear ' _ \8 S0 P1 Y5 O1 a+ l1 a5 @
- jz clear " H- }6 Y3 a, e& l" ?- M/ j+ b9 d; q* h
- dec cx
7 G0 E, r" R K$ P' i" ^ - jz exit3
0 H( g% S5 r* V( N) \1 @ - jmp SHORT get1
2 E4 G W4 m* Z: L - clear: inc al ; Clear ZR 2 v6 A0 { d" g
- exit3: ret , t: P4 Z% F& s! w
- 5 \/ Y2 j- b( F, Q4 Z9 K! @ i
- - O: h# Q3 D' S: e
- A20Read: xor cx, cx % n+ |9 L8 D/ Y
- get2: in al, 64h
8 {) r k. T; X0 E; r3 c* o - test al, 01 ; If the 'output buffer' is full, has ; Z d0 |8 V, ?; N6 W" S- v
- jnz exit4 ; something for me . j. z& x; Y3 I" t! T' D3 j
- dec cx & Y) j! a2 j0 ?' h6 D2 X/ C4 V
- jnz get2/ Q9 B: o5 h6 p
- exit4: ret ; W% ^/ U P, n6 I; |& Y% u
-
$ {! [$ m0 j* Y9 Q1 ^4 M3 Z: K - end
复制代码 |
|