|
|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM
% @6 ~# r; c {: t. p/ n, s - ; 1 v) d/ ?# y: m) q
- ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01
0 N6 o! s4 ^, O* T4 V4 | - ; ml A20ON.asm
- {) j- b# N+ m! b" d. O$ T - ;
% m3 J+ U6 E2 O7 O - .model tiny
( E2 g1 q- _- A" n \8 S - .code0 f$ c1 x9 e& N1 z7 B
- .486
$ [/ r3 R) O% M5 W: C, a- k - .startup+ L# b9 Q( n4 v. N3 y% W( }
" Q) e& N- w! J3 h: s- mov dx, offset msg_author* A* e9 {# H" }
- mov ah, 09h
1 d W5 q0 Z& g - int 21h4 U! ^9 N0 `" ]( @, @3 g: A
9 z6 r& T! D; X6 ?4 O: A6 w1 K; C$ T) q- mov dx, offset msg_fail
" J B- N* [: } - call A20_ENABLE4 o! f5 [ @8 J* o; s& f, x
- jz exit1
5 y) O9 Z* {6 D. d4 D - mov dx, offset msg_ok
5 R j6 ^$ v2 i s& c - ; L* v# Q4 c) V# x n* L
- exit1: mov ah, 09h
$ e' d6 O$ L& _3 f - int 21h
. O4 A$ c% \2 X+ S) ?- w - mov ax, 4C00h
- v9 w- L7 e+ q# F0 f4 \# n - int 21h v8 s! z9 S* `$ X, \" i
- : S6 B) N, ]' C9 W$ b) Z3 A2 ?6 Q
- msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,) E5 m( V, x' k) x2 G) F7 l# u
- "2008-07-01",13, 10, "$"
' Z" U; |# y. c W9 _7 E - msg_ok db "A20 Enable OK", 13, 10, "$" 8 y/ t% h. e4 U6 f6 F' x' I3 U
- msg_fail db "A20 Enable FAIL", 13, 10, "$" 4 {0 I4 ]' v5 P
- 2 _* i4 |6 z+ H7 r" f- s
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------4 T `. G9 k3 ~4 |! f* t) \- k- Z
- A20_ENABLE:
" X% b) n" W' O7 k4 A - call A20Write
+ j7 w1 F: K/ N3 ^2 p7 D - jz exit_enable2 ?. s; \& N+ [, ]
- 0 L3 a2 d+ u+ V7 A1 ~, ^2 n
- cli ; Only need for reading value from KBC
* G* Y A# E! E, u% M2 d; ]# Q4 B - mov al, 0D0h 7 m) X# c/ P% Z5 L9 w3 o
- out 64h, al 3 d X" y: o0 [: L0 I! m1 @
- call A20Read
! S& c$ l1 u, s3 ]# S' r% Q - jz enable_int # q6 g( P. g7 q/ n7 A$ `* l9 L/ w0 q7 u
- + l/ n# C4 _4 \ b6 d- I
- in al, 60h ; Get current status
7 ^6 G) _ G9 K, _* x E# I - mov ah, al : ?- j+ m% C/ L! ?0 ?
- call A20Write
. r% [5 I; t ^8 A - enable_int: sti 9 {* [$ r8 U- q: f7 T! O2 T
- jz exit_enable: Z- r& t) B+ |( f; n
- 0 I$ Z' [2 [9 L5 w; d2 Y
- mov al, 0D1h ; Tell the KBC , want to write to the
+ i4 y- h! V; w4 F* Y$ j - out 64h, al ; Out Put Port next
' ~! q0 g6 d: Z b5 N - call A20Write 0 ~4 t) `! x T2 Z
- jz exit_enable
- ?" F4 m; {8 k% K' z
+ d7 o+ n- M9 o, ^- q- n7 r- mov al, ah + l. \- D: f' }# _- g
- or al, 2 ; Enable line A20
( ~: ?1 A1 p5 P1 o - out 60h, al
; s0 b6 n4 l9 b) C - call A20Write ( g* K$ Y, t6 M4 s! z+ R' B
- jz exit_enable: J: T( H9 a$ A
- , a2 e0 V ]% H9 d9 K% }3 {; y! w4 |
- mov al, 0FFh ; NOP
% ?$ y" ~/ N3 L. x* T - out 64h, al ) ~+ v# y8 ~- @8 }' Q7 f
- call A20Write , Z7 `. v0 K) }
2 {& H+ T/ J2 N3 l/ q9 @' M- exit_enable: ret 4 z2 n7 `. C1 ^8 S+ K- v" c2 p
- 2 W2 S6 j+ F2 B
- A20Write: xor cx, cx ; Reasonable wait
9 ]- E& w& h( ^/ B8 B0 }' k - get_wirte: in al, 64h ; Get KBC read status - F0 ~0 g/ e% j. i3 y' B! T/ B: U
- test al, 02 ; See if buffer empty, bit 1 clear . V% `5 W% L- C
- jz clear 3 o* i7 d* G. m
- dec cx - x. q2 y+ ~( [: |
- jz exit_write 6 \ p2 `' [+ F2 E$ I, H
- jmp short get_wirte : Q& D% w |3 c/ m5 q# U6 b
- clear: inc al ; Clear ZR
7 P' X: Q# J9 [4 v3 M+ a3 [! j - exit_write: ret
7 R2 X' g0 k2 m4 j0 D" x6 s1 d
$ n: B) | g! b/ K" @( v- 6 O6 g" M: l' N- y. Q6 |7 \
- A20Read: xor cx, cx
$ h+ [0 U1 c2 Y0 @ - get_read: in al, 64h
/ _/ U9 ?7 H* a: }: H @* D# v6 ? - test al, 01 ; If the 'output buffer' is full, has
6 {% ]8 D. ~4 ? - jnz exit4 ; ... 3 r; @6 O9 q2 _! v0 R/ @4 y
- dec cx & k+ r+ |# Z5 _$ b
- jnz get_read% K) Z# @" P1 Q% o$ z
- exit4: ret
3 o$ m: ]$ R8 j; }- U -
7 Y) J+ a4 _" B& Z9 ~ - end
复制代码- ;A200FF.ASM 3 |6 y- \, s! U/ \) F
- ;
7 _) z- |7 E5 k8 f" u5 ] - ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01/ H8 E6 |6 j& ^& U- c M1 U
- ; ml A20ON.asm 8 M) v. K$ c4 J: Y d
- ; / D" p& \6 W( z* U5 A' s
- .model tiny
) ^, H& y4 ~+ G" E& \. E4 @ - .code
- [* W0 |0 u: ? P6 ] - .486
4 D5 S& U; w) T$ C' p- m7 h - .startup
. b- O% ~0 P" D- }
! ^4 y7 L5 z: S! \0 O3 s- mov dx, offset msg_author
( a- c' k/ c) J- d% L( H - mov ah, 09h
) V& y$ Z8 H# G - int 21h
8 M. ]! K6 `5 ^5 j, i) B& t9 x; z - ! e/ a: a' U. P& g: g+ Y
- mov dx, offset msg_fail
@- D# @" S3 p$ _3 P4 \ - call A20_DISABLE
; Y; [+ y# C$ j( l- E - jz exit1# ]* B8 T K, L6 a
- mov dx, offset msg_ok
5 R8 R3 ?; ^$ x: s) K9 Z4 ?
: ]5 k6 V5 g! D8 [3 B5 f7 v- exit1: mov ah, 09h 1 s' x) S; x* A; X* p$ J7 A6 R
- int 21h
. x5 t) X# Q. k" i - mov ax, 4C00h ! ^( ?3 r" D0 \# \* O
- int 21h 5 t) h& G- Y2 H4 I8 h/ [6 M
- % [5 \7 _) V1 @7 R1 Z, w" a
- msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,
, b" L6 U: S3 s8 Y: g - "2008-07-01",13, 10, "$"
# q7 y! O1 P* n; D1 H, ?1 O6 i/ g - msg_ok db "A20 Disable OK", 13, 10, "$"
6 q4 k4 K7 P. A) ^! x& T - msg_fail db "A20 Disable FAIL", 13, 10, "$" . C8 {. ?4 i) l4 r# m
. y" W+ t0 h* X/ \/ o- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
# e8 a. F) a# l! T/ m1 e, }7 m - A20_DISABLE: ^/ [0 _( }9 `" V/ P
- call A20Write ; ]& Y; {3 v1 T: ]
- jz exit_disable
$ F, W% @9 N* d0 d! D7 y' u
7 ~- ?5 a6 ?' S! e1 S- cli ; Only need for reading value from KBC
. e0 O! d9 Y6 H/ M! ?+ @* u - mov al, 0D0h
/ u( y* x8 Z. [( ~0 j2 n - out 64h, al % }! r% D/ @1 r. |$ a' B( C @
- call A20Read % C8 b2 v9 A$ P) R
- jz Disable_int
4 Y! Q5 Z2 @! a; ]7 s - % b1 D( X; Y7 C8 o# H: C
- in al, 60h ; Get current status
$ K% V- ^1 [* P* k) _7 p& @$ w - mov ah, al
4 x. P: \/ F! \ - call A20Write
% [" i- C( y0 ^; C2 N/ I+ | - Disable_int: sti 3 B$ n' N' n y ]7 ?/ s' Y2 w
- jz exit_disable0 c. B3 y0 h+ P
6 G1 N, ?2 H A r1 c4 T- mov al, 0D1h ; Tell the KBC , want to write to the 7 V8 k5 a) f5 k C2 ^2 G
- out 64h, al ; Out Put Port next
7 k; O: V' v% G" ] - call A20Write
: K7 u2 t2 F; f: Q - jz exit_disable
" K z4 D( e/ \( m, S
5 f3 I" ]) @" |- mov al, ah
1 N% n6 ~ _6 ^7 d. d+ \ - and al, not 2 ; Disable line A20 9 X; s; q# a" s+ ^
- out 60h, al ; g8 c. r" Z' f; w9 c2 i
- call A20Write
" y9 O6 ~4 t3 b3 O& j3 b) x: c - jz exit_disable6 E( J3 S# ?3 ]
# l& j7 Z+ ] |$ _1 y- mov al, 0FFh ; NOP & h% B6 F1 k. Z# v, Y5 v
- out 64h, al
! r$ O. f) U- A - call A20Write 6 q8 O8 B- E1 ^0 l: T4 u
- 1 y4 f; n1 P3 ?; F! r, g! o" u4 T
- exit_disable: ret
3 u" i& L# H- F3 \2 O
& O' p9 D! y$ b2 G6 X* \- A20Write: xor cx, cx ; Reasonable wait
5 k5 v$ i* z; k; M$ e - get_wirte: in al, 64h ; Get KBC read status
( t( t- U2 b& U - test al, 02 ; See if buffer empty, bit 1 clear ; o5 z, o8 j8 V3 j, Z9 y) a
- jz clear 6 g! u+ f, h6 G1 ?+ ]
- dec cx
3 d7 p6 }: D+ q9 F - jz exit_write
) j* j) N }. w! g. e0 _ - jmp short get_wirte ; A5 m8 R' G" m& H! h
- clear: inc al ; Clear ZR
- w4 }8 l7 `! y$ `1 ]7 a - exit_write: ret
, T- h7 }" |8 f& r0 n2 T
/ m0 T6 k% x6 v7 a, c) L+ t- 7 @! m5 C; i$ f0 S+ p$ }2 b3 [2 ]
- A20Read: xor cx, cx - e' Q4 p/ x& M( t3 N: I) h' m
- get_read: in al, 64h ' P* v7 n+ T) h0 Q# V+ }1 r
- test al, 01 ; If the 'output buffer' is full, has
2 P* K2 @! F5 d9 V) U! ]. E& k& Z - jnz exit4 ; ...
( M2 i8 K4 W) s( s4 h! S - dec cx ( N" J; X- p4 q- @# D& F
- jnz get_read
8 d3 e* m3 B1 o& k H - exit4: ret - z6 c$ A9 b( A, N. f+ z# L! Q
-
( ]4 h, }1 C# Y! f - end
复制代码- ;A20STATE.ASM 8 ^+ S+ F' w6 S" e8 W6 Y- D
- ;
! p- V- o8 P' V! O% N - ; Returns the status of the line A20 through the KBC 0 p, ?- ~+ E9 A8 R2 A" i
- ; programming by bini for debug. 2008-07-01% |0 T4 G ^7 ]; ~2 ~& \
- ; + _' |( p! c, _* W, Q3 Y/ v# x6 j6 v
- .model tiny
: w6 Y- k2 u* O, M4 |! ^+ K - .code
0 V: u5 v/ }9 L5 }7 o - .486
( e+ j5 |. {' U+ Q" ^6 P: h0 C - .startup6 Q. l; |. O( P$ G0 t
- mov dx, offset msg_fail
- `' ~$ a9 J' z& {5 r9 ~ - call _GET_A20_STATE_
) w+ ?) f" B& k+ X; @ - jz exit1 ; was a problem0 I& N6 m8 x6 m2 v0 u3 }
- push ax ; Save state, AH " O7 ~, N; J# S, }6 S
- mov dx, offset msg_ok ; There wasn't a problem u' f, _ L/ l" E0 }2 _! b
- mov ah, 09h $ y* t5 m* j6 l! T
- int 21h ; Print message & l# _, L+ t% |* Y2 s
- pop ax ; retreve state 6 m6 t+ K& D0 s: ~- ?0 O
- 6 t* ~2 ~3 a" ?: _& Q
- mov dx, offset msg_dis ) ^; x: z" _% g. {% Z- c: _; h
- and ah, 00000010b ; bit 1, 2h, indicates state
: D S# S! A. K0 v6 z - jz exit1
" y" F( r' ~0 ~8 g+ \ - mov dx, offset msg_en * q( Q# O* r9 ~+ ?. k m& v
- 9 D2 {2 M+ Z% b5 y
- exit1: mov ah, 09h 1 A% I/ M& H2 D5 P" [
- ; DX already contains address of string
& q, G" W% o/ n, @ - int 21h
( V3 u( M4 x# r0 d p
! R2 U- o9 g6 l/ U( K- mov ax, 4C00h 5 B3 |2 I' p) n
- int 21h
3 Q' a0 p( l8 `) f% T/ Q$ t - ) I n5 P0 ~9 Q: K C
- msg_ok db "OK", 13, 10, "A20 $" 5 x b* w* F0 K: [
- msg_fail db "FAIL", 13, 10, "$" 5 O- d! Y/ z( |' s. z& r& S
- msg_en db "ENABLED", 13, 10, "$"
0 m* P& T5 T4 [# n - msg_dis db "DISABLED", 13, 10, "$"8 m# u+ W$ \3 }8 t0 J
- : G" Z! c- u% B# |
- / o; O5 R8 X {! P- e7 _
- _GET_A20_STATE_:
4 K3 n1 t n" t& d- y' C - call A20Write ; Wait till the input register is empty 5 |/ m; S2 \" f0 {9 w2 h7 n
- jz exit2+1 ; Bypas the reset int's ! q1 |7 v! M m) F
- cli ; Disable ints so we'll get our value # H9 J4 B; k$ x! P
& k$ l% w! Q- d8 r5 n- mov al, 0D0h ; Send command to the 8042 command register 4 s& J5 N# m$ H* \! i0 {: W
- out 64h, al ; to tell it we want to Read the Output Port : A0 r. U6 [/ o) J' @! }4 F; L5 W
- call A20Read ; Wait till the 8042 output register 3 `( c! \- D& X* k5 b5 A. l
- jz exit2 ; has something in it's buffer * f' A+ G r1 r* a
- ; z D6 R S' q; {# f
- in al, 60h ; Get it * g9 w T# u5 K9 A% S( V# G
- mov ah, al
3 l- }* o2 ~1 s* y4 y7 z - call A20Write ; Make sure the input register is empty - i8 Q* P! @7 F
- jz exit2 % N; C, D$ i2 d. U" ?' G: P
- 3 ~: y1 b3 |7 C0 \: b2 K& e
- mov al, 0FFh ; KBC NOP command, does nothing
" I, d$ R0 r# l, T4 m1 I3 y - out 64h, al q% U8 U( R( |" F- S
- call A20Write
1 \: ~) @5 r! M6 p% G
3 _. m& {: i5 W- G# S7 i) v# f- exit2: sti
?0 _, T$ X# t8 q# N5 |; }; E - ret
: k7 ^8 E: h# T9 n/ i# A
5 _1 c/ ?8 d( v, c0 Q9 n
. a' t2 j" N0 z% I( o! F- A20Write: xor cx, cx ; Reasonable wait * |$ c& J: l1 ]/ n& ]6 a
- get1: in al, 64h ; Get KBC read status 7 H: e) R, C, f* e
- test al, 02 ; See if buffer empty, bit 1 clear % B1 x# F, w. g) J9 @! m
- jz clear
" ?* o: \. F+ e8 s - dec cx , Z. s, u7 ]* E, G: U
- jz exit3
) J/ }6 ~5 w/ s# C4 [1 @/ _3 a - jmp SHORT get1
. u9 Z- a0 i8 {# y - clear: inc al ; Clear ZR
s6 w! b) `9 x6 I - exit3: ret
0 H+ _4 a; P8 G' L0 P
9 \1 K8 O) i+ T3 R: R+ R' W- 7 s4 A- {1 J' V' Z7 A4 T. P
- A20Read: xor cx, cx $ ]" x& V L, V& e) ^( ?
- get2: in al, 64h & `* l! v2 |) G2 b( c) ^ }9 {
- test al, 01 ; If the 'output buffer' is full, has
: \! R3 d% Q2 ]3 W- x. [7 I- A - jnz exit4 ; something for me 2 E# M# P6 y9 E, ~8 N% x
- dec cx
' M1 g1 o+ x0 z4 U: J' S - jnz get2
" n; c. S- N2 p. `& S - exit4: ret
1 ~4 L* `1 z$ l* G$ u3 S -
. n6 A6 J; Z7 d- |+ C- A3 H K - end
复制代码 |
|