|
|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM $ v }3 x2 r/ R8 o" V) T0 I6 Q
- ;
% f# t! G8 f j - ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01 q' s6 @. m5 l3 J: e; i
- ; ml A20ON.asm
+ E3 c( i* |+ Z5 x f S - ;
* M( z5 I7 G( `# T! c* X( ? - .model tiny* J* |( }7 L4 ]% C+ u9 F) Q; _
- .code
6 d, i. r' ?8 m6 T7 a6 W- h% Q* O2 f - .4862 b5 z+ m4 ]' ^& w9 S
- .startup
- c+ A0 L" l5 d1 @1 ]% l$ z
% B) a+ {* b9 o4 S7 E3 [" }- mov dx, offset msg_author. b s4 y( c# \7 ]3 [# G9 Z8 B
- mov ah, 09h
) ?7 h' Z/ p" k. ~4 y - int 21h
9 F( C. {. U) l. W" N: a% n3 t - 7 ?, N' m, h6 W5 a r. H
- mov dx, offset msg_fail + F& k- I% w: P( M; {! `* n
- call A20_ENABLE8 {' L5 a. H- b/ D$ e
- jz exit1( T5 J- D* N7 h4 K( Z+ w$ S& C
- mov dx, offset msg_ok
- f& O3 v" _) N: u* E q$ h - 9 d, C1 N E# h& i0 k
- exit1: mov ah, 09h
+ F5 |# r4 x) D- S" G5 ?" ?3 c% b; I) B - int 21h / i' S, K' Q5 q2 m( K2 u/ C
- mov ax, 4C00h
: c' `2 w# j3 T7 S- f - int 21h - n# l$ C+ M- c+ r* V, y
- 6 v" Z+ X9 P( ^8 v! a3 C- W0 a6 a
- msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,$ T2 ]" c! n5 M3 Y5 T. I& L o
- "2008-07-01",13, 10, "$" & ]! ~& d, M# K: \7 c
- msg_ok db "A20 Enable OK", 13, 10, "$" : D. G1 B, z& @" W9 h
- msg_fail db "A20 Enable FAIL", 13, 10, "$" ( E8 A" k X3 ]( c2 w ^5 l' L; M
$ `9 q, Z; n8 H6 r. [! [, h- ;------------------------ follow code maybe make to lib, if you want...-------------------------------: H* t# [+ M+ ^+ j0 g
- A20_ENABLE:
S7 b' [# P) b - call A20Write 4 l- Q5 ? Q5 r. O3 C2 J. Y
- jz exit_enable
0 J" h' @5 T; t& J( b, Y9 b, B s- d( i - - o( _7 J, y' W: ^! S3 _- }
- cli ; Only need for reading value from KBC / r5 B3 M, y7 Z9 l+ ]
- mov al, 0D0h
! q# `2 w% f2 I1 U+ t& b - out 64h, al
: I; u6 ~- O" K; |$ T - call A20Read
4 H5 ~. d) Y/ p: T8 G - jz enable_int
5 B- H$ @, M% {& n5 n y" O
; t- f4 C* U3 _- in al, 60h ; Get current status
" b+ u8 M! p4 n' m! g& I - mov ah, al
$ @8 B6 U# V0 P& E - call A20Write
) J0 A; V; _! A t- N& } - enable_int: sti
3 D2 z# r i9 G$ g - jz exit_enable6 G& ^5 \1 H; | b% @. _
8 ~) U& C$ @8 N3 K4 A* s, c- mov al, 0D1h ; Tell the KBC , want to write to the # `) |2 M: n! O9 D E( |
- out 64h, al ; Out Put Port next / h6 ^& W, T, m9 ^) Y$ [; g! H! q
- call A20Write 7 Y3 G2 L" U* Q* z+ q/ [
- jz exit_enable; Z$ ~: N& j$ w" U4 I0 E' c/ B0 M0 T
- t, Q7 r4 J0 T. h7 D; U3 D/ Z! a4 y- mov al, ah ' _4 @' V1 M. W
- or al, 2 ; Enable line A20 # s, O" r+ ?# D
- out 60h, al , A. `* r7 k% @( [5 N! G2 Y
- call A20Write - c! y/ p) S# R
- jz exit_enable5 l6 ~$ \& q) b0 S" D1 N: T
) r4 G I4 y) _5 d$ c& V- mov al, 0FFh ; NOP
2 f0 A: J5 @9 p* [- f - out 64h, al ( t! i: \2 G. ^* F
- call A20Write
' H% B9 @; H9 e0 {1 M - 2 s4 p3 @# P$ E8 A! q
- exit_enable: ret
; r" X& k! a4 a z - ( e( ^, N/ S# r
- A20Write: xor cx, cx ; Reasonable wait
( n9 g" N7 y8 v9 K5 K( l - get_wirte: in al, 64h ; Get KBC read status " c/ z" U2 T; V( Y. ?2 }
- test al, 02 ; See if buffer empty, bit 1 clear
$ W. e. M/ C7 a4 Z+ g) m) s - jz clear
3 @- M& u4 m# j4 W* O2 K% { - dec cx 9 N8 E1 C& k' C7 P
- jz exit_write 1 w* Z9 L9 x/ H
- jmp short get_wirte
0 R. ^; z$ Z* c6 _" q$ W - clear: inc al ; Clear ZR 8 I) P! W; h" M* l$ p4 f' O. u
- exit_write: ret 2 i" y/ `8 d: w/ c9 A; D
, Q) A: z6 L: e
0 G# ^. ]6 i: P' k- A20Read: xor cx, cx
6 ?) `. g4 y T0 ?9 q9 y( n7 Q; Q* I - get_read: in al, 64h
5 y, o1 O- w) r& K2 c; n - test al, 01 ; If the 'output buffer' is full, has
- V" h3 G1 ^6 s0 u: d - jnz exit4 ; ... ; z3 l* v4 N0 l+ _4 ~1 ?) E
- dec cx
! S3 G! ?9 D- }" a, g - jnz get_read& V9 R' j, Z, m0 ]9 N, Z
- exit4: ret
$ z# I' H8 y0 |- z3 o9 w3 G- s - - N. I! t4 m' h, E
- end
复制代码- ;A200FF.ASM $ L1 v% q) v2 K. p
- ; + `$ D: F1 ]2 k7 Q8 @* y
- ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01& L K2 e6 G, r [2 l+ j! P
- ; ml A20ON.asm ; k# \! m5 ?. I
- ; 9 z$ [/ A! D. {( W$ ~
- .model tiny
0 Q H: U' n/ I5 `( B* T2 P - .code2 h9 _" M/ P1 I
- .486
) {! U" `$ S+ I0 V3 R! u - .startup
/ K2 p. u& E, y2 P! |( n0 x/ y: h
( I1 f! d. h3 g9 N6 r9 }- ~- mov dx, offset msg_author$ V/ G0 w+ S" M$ q0 {5 _
- mov ah, 09h
6 ^. V7 t+ |- | K5 }0 I - int 21h. O/ N; o6 v- Q! W- G% @
- 8 l5 ^' w% `5 v- B4 D9 | c
- mov dx, offset msg_fail
$ X4 G6 ]8 L: D+ S2 e - call A20_DISABLE
& W2 Z3 Q5 X' w, P/ l - jz exit1
3 I+ Q2 v3 ^/ s% P0 t$ T - mov dx, offset msg_ok e- j, Q( S/ g$ F; S
. R$ S6 d$ U: T& Q- \; i1 V- exit1: mov ah, 09h $ e4 \" J& x' e/ s/ h
- int 21h : @0 K) c" P; j" w1 l/ M" u& k
- mov ax, 4C00h & h" ~% p3 z/ _& U6 Z
- int 21h
6 k0 w2 x' N! n0 ?0 s -
' i- }' x X# C1 J8 t! w; S8 @% n - msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,
% q+ h' s1 e; j - "2008-07-01",13, 10, "$" $ R) N# p6 Z8 k6 I
- msg_ok db "A20 Disable OK", 13, 10, "$"
6 x& x1 F9 c5 T - msg_fail db "A20 Disable FAIL", 13, 10, "$"
0 N& ]- e' m) u% R) O, Q2 d( o& z - * }5 F* X8 O1 Y' J9 H
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------5 h. i9 A7 {' ]6 r. H0 n
- A20_DISABLE: $ e: R9 h; W- l3 i- h! y: w
- call A20Write
# a [: s" B& U- w2 h) C3 g/ p; a - jz exit_disable
" n+ t* J% }3 F8 d9 R- H8 \: e - 8 y6 `4 ~# |) w6 a) d
- cli ; Only need for reading value from KBC ) Q. ^! U2 z: h# T' x6 X; K# t D) \! X P
- mov al, 0D0h ) f6 R' K2 E1 e/ V' t1 v& z( B- W) B2 D
- out 64h, al
3 I5 t6 \. ^* {& o; K6 J% [0 W6 N0 ~ - call A20Read
1 z4 X" H# }* w' n - jz Disable_int : M( x d' P. J
1 p% R' L0 _( c% u% U, ]! `* c5 ? }- in al, 60h ; Get current status 4 f V. f: f4 k2 [( F
- mov ah, al
, c8 }) d1 E( R - call A20Write
( [5 ]; i8 C2 s# d: \ - Disable_int: sti ( c G9 h$ T& d2 i2 R( ?8 U1 z
- jz exit_disable R- c' ?- r" B0 Q
- + R: E" m4 y! N j2 Q
- mov al, 0D1h ; Tell the KBC , want to write to the ! N6 g2 e1 [1 Z" |6 t: ^
- out 64h, al ; Out Put Port next
?: T4 Q. W0 r, A$ W0 `* { - call A20Write * `9 K7 D X5 L9 \0 ]* I# P& F$ [
- jz exit_disable# b B8 U0 p" l, g+ I2 i1 g
1 r2 z4 J( \* |3 X- mov al, ah
& Y9 G1 ]4 Q# q% Y/ [ - and al, not 2 ; Disable line A20
, D r9 @7 e/ N# p - out 60h, al
9 b) X9 N- O" w, U - call A20Write
: q7 g/ D$ x8 D8 j0 P) D4 ^ - jz exit_disable! [* c% O9 e, l
0 P. X" w: {( M2 G- mov al, 0FFh ; NOP
9 Y# u& C( n" t" c- r - out 64h, al
, B i4 T3 {* B1 H5 ~& Y+ E - call A20Write
6 s8 I4 w6 @3 P* ^6 [ - ' i; p5 \) Q8 r
- exit_disable: ret
7 Y8 {# w! c' v' J
/ h# [ h" y6 B* m9 `0 x7 i p- A20Write: xor cx, cx ; Reasonable wait
& \2 B& ]. ?6 o; A7 l - get_wirte: in al, 64h ; Get KBC read status
* H! @2 U- r, v( l% z H' \# K0 v' l - test al, 02 ; See if buffer empty, bit 1 clear
. F5 {+ J# P. r4 K/ Z$ O4 A0 a - jz clear 0 D7 m, c, c2 z3 k
- dec cx & H: k! f6 J# F3 a$ ~
- jz exit_write 4 w$ ~* C x* E0 [1 v
- jmp short get_wirte ; i: l/ {4 S( m6 H( ?: k
- clear: inc al ; Clear ZR
) R$ J. G' w" t( A# S - exit_write: ret 5 p$ |) L, n: I, F, u( V
5 L. G* s: q! j* D, k8 D$ i; |
2 B3 f1 ?3 [ Z. W- A20Read: xor cx, cx
0 M8 |# _5 c, u* V - get_read: in al, 64h
z+ B$ w2 q- v8 b - test al, 01 ; If the 'output buffer' is full, has # V2 `# m- m# ^" B6 _
- jnz exit4 ; ... 2 m5 ]% S- F; ^3 y3 S3 i
- dec cx
1 z w6 O) O5 u0 r4 N3 J - jnz get_read
6 P/ H4 o9 u- A* X6 M& E( ]/ r: l% u - exit4: ret , c* O6 M- I( U0 c7 B
-
" M; z2 S8 E% }1 r: M - end
复制代码- ;A20STATE.ASM % y; p- J1 X, X' {
- ; 8 c/ N& v0 O1 M ] x; f
- ; Returns the status of the line A20 through the KBC
. i9 i( G+ |& t! k; a - ; programming by bini for debug. 2008-07-018 y- w/ M9 D* u6 x6 ~' q
- ;
f9 v% p3 ?' B- t5 K - .model tiny! Q' ~4 r B0 F; {
- .code6 W2 ]3 J4 Y) P- _6 O
- .486
: e+ j' g$ ` u. A - .startup
( T8 X: t( v" G8 T2 L3 ^ - mov dx, offset msg_fail % x! \# q5 O( o5 y* @
- call _GET_A20_STATE_
4 H0 W6 D8 i ?. W - jz exit1 ; was a problem
- b" A2 r; W2 L - push ax ; Save state, AH
2 Y7 @2 M, {1 I8 @) e' t - mov dx, offset msg_ok ; There wasn't a problem
# `0 y( g8 X0 ?6 F! _1 w# k - mov ah, 09h
, Q3 J- `1 A' Z8 Y2 { - int 21h ; Print message % c0 {+ T V7 q, B7 R* S4 n( Z& {8 n
- pop ax ; retreve state
# g8 d" M7 a, e6 E p - & c& W/ }* @- \. ]: Z4 w" W
- mov dx, offset msg_dis
: k' i- H5 O8 K9 h - and ah, 00000010b ; bit 1, 2h, indicates state
( o7 o9 K- h+ D, V8 ^ - jz exit1
5 ?) J- [. i1 _( B/ k( i; T - mov dx, offset msg_en
: [ Q3 s' G: w" l
, r$ ]9 T% z4 C; m! E- exit1: mov ah, 09h / S0 z7 V0 i" Q* h- k
- ; DX already contains address of string " X/ o! a9 c8 d1 B" a" L
- int 21h
3 R; g( F. `" W0 ~ Y# O - 4 v5 @" _+ f9 }6 G! S ^
- mov ax, 4C00h
) I7 x. H9 `; I+ ]6 U1 s - int 21h # K7 v! ^; j% G
- 4 x: P) k6 o" G$ n2 y
- msg_ok db "OK", 13, 10, "A20 $" 8 @3 A4 e8 u! @5 |5 W- ~
- msg_fail db "FAIL", 13, 10, "$"
# P! b# i8 `) \% q" A4 U% r# j2 [ - msg_en db "ENABLED", 13, 10, "$"
! ]% d: C! H. {1 G: l; N - msg_dis db "DISABLED", 13, 10, "$"
4 g9 ]' x' s3 O
: F" V6 o6 }+ O-
" D0 @# n6 p9 ], r' Z2 | - _GET_A20_STATE_: / `/ z! y3 r. a: z) O, `
- call A20Write ; Wait till the input register is empty
; k* I2 L3 E2 v4 ^ - jz exit2+1 ; Bypas the reset int's
) q7 n7 F" |1 Y( o3 c - cli ; Disable ints so we'll get our value
. _" a- z$ `) v: i, r
* F, j2 x. l! o" O- q: b+ R! T- mov al, 0D0h ; Send command to the 8042 command register
7 `0 E7 F7 L$ y) F - out 64h, al ; to tell it we want to Read the Output Port
! _% C2 b8 N" _$ F - call A20Read ; Wait till the 8042 output register
; T1 D$ n! L, ^ b - jz exit2 ; has something in it's buffer 2 {* h3 t- g+ F; _# m1 x
9 q5 x. i+ V! ^1 y. ^3 x- _- in al, 60h ; Get it
+ B8 h/ [4 F4 } - mov ah, al & W7 b" o5 u/ j Q3 A
- call A20Write ; Make sure the input register is empty
8 ^# I/ ^/ \% u' o- H1 j - jz exit2
7 X& [/ {3 Y# B2 T - + L- H6 X% Y( x# @( u1 ^+ X
- mov al, 0FFh ; KBC NOP command, does nothing
! Z2 x4 w. b8 t0 i - out 64h, al & N+ o z4 l7 |8 I4 F4 ^+ _
- call A20Write
$ `2 c1 u9 V4 ~: r, a2 d0 j; z - " \! M, O0 h; A* Y( U
- exit2: sti 3 h: P" M% c0 @
- ret1 d: H! t" I. i) S2 c8 t+ W
8 B9 o+ j+ Q1 w$ C- ( q# P2 a1 l1 E% e* q
- A20Write: xor cx, cx ; Reasonable wait
" l5 r4 Q3 G, y6 c) J8 ^ - get1: in al, 64h ; Get KBC read status 4 j( C' I9 T: N. V* t1 J# T
- test al, 02 ; See if buffer empty, bit 1 clear , B9 Z0 O4 [- G" Z6 [( K' i) \7 w
- jz clear
8 q# j }* Y# q5 A) f+ h - dec cx 8 y. C: U. _7 n5 W/ O# r9 `
- jz exit3 ( r5 g$ G8 R- t9 c `1 \0 ?9 Z" ?4 P
- jmp SHORT get1 " b' m5 T% G; R; I7 I
- clear: inc al ; Clear ZR
- X, T9 r/ k7 x - exit3: ret
9 }' ^$ b( Y& \ - ) h" ~7 k( ~0 o
$ Q. {9 H; y8 E, r- A20Read: xor cx, cx
7 T. P5 V) Z4 x* f8 T - get2: in al, 64h 7 W" p; R! C4 I$ W0 z
- test al, 01 ; If the 'output buffer' is full, has ! c6 Y; @/ x9 D' V
- jnz exit4 ; something for me ) c0 j* l) u( A. U
- dec cx
" C; i, b5 Z: e6 N, a- C - jnz get2) _$ o- h- j1 t& y: F$ M+ `$ R
- exit4: ret ! r+ x7 ^( Z; x' ]3 p0 _
- - \3 {, B$ p F; _' I' B
- end
复制代码 |
|