|
|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM $ ?6 |6 f8 ]+ d7 I; }- T
- ; : o8 L. W$ Q( W/ v7 M& w* G. Y
- ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01
$ B: D A/ p T3 u9 ^& U - ; ml A20ON.asm
8 R' r: U' s2 a0 C - ;
5 @- E( _7 k% G8 ^' ]' l, I& n$ J - .model tiny3 d4 M$ d% b6 G4 ]+ C1 y9 X
- .code
0 }# T4 k9 T4 f4 ]0 F8 m C. D6 n - .486
# j" V8 `/ m0 [" A. I - .startup0 y; Y. z$ d; S+ p( g
* t$ E: k6 ~8 p. u( N" q% x- mov dx, offset msg_author
9 v% z7 |4 k$ n; J \# _( D* p# J - mov ah, 09h
, X! {: f ]& ]7 c F - int 21h
& E, |2 I& ?: N) _. O% Z: s3 y3 ^
" k0 x7 u P* e; \3 l4 r- mov dx, offset msg_fail 4 q8 Y* _% M: I# B. f2 q8 L. x
- call A20_ENABLE' o1 G2 K3 @: z5 A4 ]
- jz exit1
& n9 I9 U# ^4 x/ Y7 M% X - mov dx, offset msg_ok 1 d( n; U" V- n/ m
3 n6 P, r; v$ Q# R3 j! O- exit1: mov ah, 09h ' \& a! W U) r. a
- int 21h
. ~9 N6 B( N6 c5 t# h# X - mov ax, 4C00h ( u c3 I d" A- i
- int 21h . b1 }: i0 B: c$ g' X5 y
- ) a w9 |2 R4 Q% C8 Q( E
- msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,
, R- z- F5 p! U, q( E3 V' s" o - "2008-07-01",13, 10, "$"
! F6 u: H; r. y' s9 t. T - msg_ok db "A20 Enable OK", 13, 10, "$" : M' o$ N" x& ^& M
- msg_fail db "A20 Enable FAIL", 13, 10, "$" / U q1 w' N; g) i6 g* L
- - V- f8 ? n6 @! [2 G! z
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------8 x# ]8 D" U9 S1 Q
- A20_ENABLE:
, l) k/ [% ?1 v4 G6 w* D" } - call A20Write 2 M( [2 j, b; j$ g$ _8 |* i
- jz exit_enable
+ a4 d. a6 T& {5 ]5 M, m - / [* L9 E1 V- h) r7 c
- cli ; Only need for reading value from KBC
, A9 g }8 p# S - mov al, 0D0h $ L Q+ `6 ]$ ?; e
- out 64h, al / E" S& ?) l# L) q( C
- call A20Read
7 F" u! d+ _. ~8 }6 p( `& ` - jz enable_int * w3 x* u9 ]. I* }) X. H( h
$ \" P& a& D0 m% ~- in al, 60h ; Get current status
" I* F1 I- F7 F. [1 _ - mov ah, al
, j5 z o5 R/ `& t7 ]- E - call A20Write
3 e6 ?) m# ~4 r5 @; d, Z - enable_int: sti 1 g7 N# Z6 B) Q! ]
- jz exit_enable8 T7 Z1 C4 p+ c
- : [# h0 d) ]2 [; W
- mov al, 0D1h ; Tell the KBC , want to write to the 1 K+ A$ F/ E0 v" e' l
- out 64h, al ; Out Put Port next ^" w" @4 O( e: I0 c( A
- call A20Write / V) D9 V6 P3 n+ R
- jz exit_enable
; U" p1 i, B5 a, V) W" A8 \! R
% z* ] J9 w! f- mov al, ah
9 H& W) `7 ~4 x$ a, o" d% j3 A5 Z - or al, 2 ; Enable line A20 / Y& }! y6 r# M0 }$ e
- out 60h, al
4 X0 C6 ?; f; m - call A20Write
- r4 h6 j) U, g3 q; P9 n4 F - jz exit_enable
' X8 y* `2 [4 w/ v8 P+ e- I
! D6 B& \7 G. e: K& h1 |7 b1 R2 L- mov al, 0FFh ; NOP
$ n# [1 a3 I* ~; a; N) _ - out 64h, al
7 O7 S; W. u. B3 m" s - call A20Write
( I: [+ v) B ?7 _: i/ ^3 o - ; M6 X- D) J1 ]5 x
- exit_enable: ret m- f9 o% S( l: q0 q
- 6 R7 Q k( A" S6 F9 O# a) K
- A20Write: xor cx, cx ; Reasonable wait
" w6 a) i1 c- e* _! U7 F: M* t% F - get_wirte: in al, 64h ; Get KBC read status
2 h* O; p! m; l$ x" {& I: v/ ?4 i - test al, 02 ; See if buffer empty, bit 1 clear 2 t) r: ~1 q5 P/ v) h( a
- jz clear
! N+ [1 t+ }8 X% n# |, h - dec cx 0 w7 d }" z! D! ]8 `
- jz exit_write
" f3 v1 J' ?7 T - jmp short get_wirte
$ U {4 k% o' z: p A3 M: C - clear: inc al ; Clear ZR
7 P; J" Y) s+ r( x - exit_write: ret
5 {. \6 f1 Z- h; i e5 u) P2 B
2 Z* d$ n1 ~' x# `: y' q+ s
6 q6 E* S1 J( X8 k! }" W& T- A20Read: xor cx, cx , b1 y' Q2 x/ K0 M
- get_read: in al, 64h % i$ ~5 |; i" E$ H1 g! o
- test al, 01 ; If the 'output buffer' is full, has # n! d0 w V" E8 {
- jnz exit4 ; ... 5 ?& [1 D( O2 s& g4 d8 {
- dec cx
9 \. j8 ~7 z7 S/ B; W& I% {: {* } - jnz get_read
; s. q' D3 V# D* L. Y% ] - exit4: ret
1 P( u, Q! Z- @. n. ]7 `& t8 }) p -
* L& J4 D! J+ J6 f' d - end
复制代码- ;A200FF.ASM # Z( r7 D) C, O7 j/ X% j
- ; 7 l% C* X' p% X( g) }
- ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01
% X$ _9 c R5 @5 h# k - ; ml A20ON.asm
0 w, ^6 X5 w6 j+ r1 g# k - ;
2 \3 C1 C. J1 i. w( A - .model tiny9 M% P* Z' X. T/ T4 J/ r6 A0 F" h
- .code
' s- |+ w! ]9 r7 G* e( D7 M - .486
# n6 K, Y' D' t' `5 K3 E { - .startup$ a4 |, J5 I+ D$ D& F3 O
6 w' ] C8 c* n+ C- q9 i- mov dx, offset msg_author
7 ~8 k3 g( a, Q8 K- p - mov ah, 09h
6 p6 h; f: ^6 x - int 21h
, H: C( F6 P" e' w0 \
; f) g( ]! G8 J4 e# Z+ ?% H- mov dx, offset msg_fail
1 K7 s" H! p0 A - call A20_DISABLE+ T+ h7 V. S u$ l; X% K" G
- jz exit1" z5 q, j% O( E5 ^( P- O+ D0 r+ u
- mov dx, offset msg_ok " o( v; x% N2 R
/ W. }- J8 G, n- exit1: mov ah, 09h
3 a6 t0 U @9 m: i+ B - int 21h
; P2 S6 C. ?* ]& _9 @7 G - mov ax, 4C00h $ F3 k$ U- j/ M- O5 e6 H
- int 21h ' D' z1 a3 n! n
-
% T& E0 D' t1 ?9 A2 X) \ - msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,
8 Y" c4 i! G% V% Y - "2008-07-01",13, 10, "$" " ?8 z4 U( T: b6 n
- msg_ok db "A20 Disable OK", 13, 10, "$" 5 h% F% e, ?, i% E
- msg_fail db "A20 Disable FAIL", 13, 10, "$"
2 B) Y4 E) e5 | - ' Y/ W6 \4 q8 K5 T, L7 o$ V" k
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------' A" _- t: X, A$ S6 d0 m
- A20_DISABLE: - V9 t9 {" R) k& ? O
- call A20Write # @3 S5 ?. T [! o. t
- jz exit_disable
$ J. r" g0 A. ]3 d/ o2 U+ z
& ]* K# O# ~" N. }6 S% ?% m- cli ; Only need for reading value from KBC
- t, j6 |& G* `7 D m3 j - mov al, 0D0h
! |' M" a& q* U( \! C8 L7 k - out 64h, al $ G' u! L/ G. G' N4 g
- call A20Read
4 g+ E* P) l k2 O# ^7 ~ - jz Disable_int
, e! ~2 _2 C2 ` k, S - & G( M h! K+ }% j0 R5 Q* v
- in al, 60h ; Get current status
0 O1 M4 b+ E0 Q - mov ah, al 6 o' {& B {/ s. I+ l
- call A20Write
8 M, i* v( U( T9 |$ U0 A - Disable_int: sti 4 Z4 K4 G: G$ O; M0 E- V
- jz exit_disable7 d7 X: O" E, `1 N: o
' S! R0 Q3 A N1 i3 P7 w1 z8 l- mov al, 0D1h ; Tell the KBC , want to write to the
+ N6 P- M- l3 _) r7 Y7 }' I - out 64h, al ; Out Put Port next 1 [1 B* S. e* s; {0 w/ S
- call A20Write
* O9 z( V& v; E; B - jz exit_disable/ s. d! `' B4 G0 `0 p
- : J. M) l5 |6 j6 X b6 r% G
- mov al, ah
- y$ r4 \' U9 P' g/ { - and al, not 2 ; Disable line A20 ; e- J' R( M$ V% P) b- V
- out 60h, al
" Z- U/ ~( v& Z- ~# g; \ - call A20Write
3 l/ Z: m0 n8 h1 e |/ ^. q - jz exit_disable% @) ^% L) H% G- G( m
, z4 E( Y8 ^ P. n: W# C7 k) [7 R- mov al, 0FFh ; NOP
' [0 r0 E, @" |- P+ C+ L7 S - out 64h, al
/ N! g0 s! d, C+ V( N - call A20Write W6 k: }, s: P6 A$ F
/ r D" T" \% b- exit_disable: ret $ t5 K4 v7 t- p
- 0 n8 F7 ~' {0 f
- A20Write: xor cx, cx ; Reasonable wait
, i! z; M: u6 i d% y7 F6 I; r - get_wirte: in al, 64h ; Get KBC read status 3 A+ r3 z9 I( n' y8 h
- test al, 02 ; See if buffer empty, bit 1 clear 5 G% B6 S( g( V
- jz clear
, v) n* j! ?6 B: R - dec cx / y! K# v1 Z* x y1 @4 j- i
- jz exit_write 2 @" z( M1 o) f, S$ i7 \
- jmp short get_wirte 0 \1 B, G1 e2 h) \; c- B; L& {
- clear: inc al ; Clear ZR
% l' V1 f( }: t! a w0 | - exit_write: ret
1 a) W) W) r! i. u$ c+ G# g
/ w5 c6 l* ^* H: o3 @' v6 I* q x
' q/ N$ e' H7 l- w, ]6 ~- A20Read: xor cx, cx
! B/ M( `$ E5 s; r5 p, `5 Z( H& S - get_read: in al, 64h
% J4 Z: D' X. E0 S' \ J1 K1 ^; D! P - test al, 01 ; If the 'output buffer' is full, has M0 H# n+ x: D. k& M
- jnz exit4 ; ... 3 l* r$ \& R* H5 C- g: y
- dec cx - d% i" q6 Z( ?- R7 k- G
- jnz get_read
" r9 Q. z% y1 d" J2 K - exit4: ret ; S, d9 @! s. ?
- 8 _7 s, [1 E, g, g1 N, Y* W0 ~0 I
- end
复制代码- ;A20STATE.ASM
/ V# F' v5 v5 @3 `5 v8 _# Q1 q - ; * J9 s/ q1 T- ^' P
- ; Returns the status of the line A20 through the KBC
( b7 [/ {# I) M- l: M - ; programming by bini for debug. 2008-07-01: k( x. {) O+ v
- ; ( a: ~* t v6 q6 J/ Q
- .model tiny
) U% B3 v! [4 p. r- h# \. ]! n8 q$ k - .code
( n! ]' N8 s0 x) ^ - .486
& q( n* v b' F: z - .startup
/ c% \% U x! K: ~" q - mov dx, offset msg_fail % u* G5 ]. W+ Q
- call _GET_A20_STATE_
: s0 z# t1 B+ K( `2 m( e# q - jz exit1 ; was a problem
4 C8 |2 t( S' `/ F2 ]4 }9 N - push ax ; Save state, AH - h" |5 I$ {# r+ g4 }, f6 F- G% y
- mov dx, offset msg_ok ; There wasn't a problem
6 V9 m+ t% c0 j; _4 X; ]* @% L - mov ah, 09h
# g$ T( G0 V4 G( g H- R, c/ s - int 21h ; Print message
- h' c# W7 n7 u* O& y% K* Z. e3 T - pop ax ; retreve state
) V c$ q. O$ R7 i
% V9 P/ u; n) K( Q9 k4 h- mov dx, offset msg_dis
4 P1 j- E! _6 b3 x) Y& `/ j6 J9 a - and ah, 00000010b ; bit 1, 2h, indicates state
6 u# |' S0 F$ o# \/ u9 a* K5 j - jz exit1
8 Y: Z) E& m% b: @* T - mov dx, offset msg_en
, y _; d' n5 M3 N- W2 C6 b9 E
2 |4 Q8 |' m( j: I' c; W3 M- exit1: mov ah, 09h 9 o7 p+ X8 \3 g; q) L# | K
- ; DX already contains address of string
$ z V8 n) ~' P( A1 H1 z - int 21h
; ?5 L1 E6 ]2 z) G6 s8 ? - ' a0 R- j' E5 r, K1 [7 O
- mov ax, 4C00h
V6 {2 L- e5 L5 n - int 21h
; D: Q/ x( z. k1 @
9 U8 p3 q* m: B% ?6 C) f9 D" U7 j- F- msg_ok db "OK", 13, 10, "A20 $"
+ V4 j* I! w4 ~% N$ D - msg_fail db "FAIL", 13, 10, "$" 1 b! s, l; b* d( G
- msg_en db "ENABLED", 13, 10, "$"
8 L Y+ [/ l' a: j. u8 f9 [4 n* E4 H - msg_dis db "DISABLED", 13, 10, "$"
! b/ ^" H5 D3 z& q) X - 1 S& x+ x# S4 Y) S- o9 i
- 9 X/ K/ l1 k9 J% L- P
- _GET_A20_STATE_: * I0 V. A2 J9 O( l1 \* M1 n
- call A20Write ; Wait till the input register is empty
1 c/ [/ w# M2 B8 @. u) T+ f - jz exit2+1 ; Bypas the reset int's 7 Z% _8 Q& U$ n* ~) f$ c4 R
- cli ; Disable ints so we'll get our value 8 ^1 f3 n0 U' O* ^% v3 n0 n( w% d1 i
- 2 L# N' {% Z+ F# o+ j/ V
- mov al, 0D0h ; Send command to the 8042 command register
* ?2 Z( Y, q4 W: j8 m: J0 t! w: f) f - out 64h, al ; to tell it we want to Read the Output Port + G9 W/ ~& W5 u0 t- |9 n8 i; A
- call A20Read ; Wait till the 8042 output register
Z2 y* n. a0 E& ~1 V - jz exit2 ; has something in it's buffer
8 L- R" q/ f9 @. S7 [0 [& w
/ ^8 g( H' N; d, V4 e- in al, 60h ; Get it % E- U" W$ w$ J/ `7 z/ Q
- mov ah, al v* t9 z; F3 |+ S% F
- call A20Write ; Make sure the input register is empty
4 ~/ F8 J0 j: ~, \3 l5 G: x6 \ - jz exit2
* v% h( c4 J# g4 \1 P5 e
) U* [" y9 u0 W, m& j- mov al, 0FFh ; KBC NOP command, does nothing
0 Y7 c+ A: v5 t! X - out 64h, al
& Q4 d$ S* A1 z/ i4 g% Z - call A20Write
$ t& B" y$ K# k" g( F - % O4 i3 f5 _; ?1 M, H% O
- exit2: sti
6 H+ z$ m* D. X+ p- d1 F - ret) M4 K$ Q) A6 l* }9 P- x9 O
" @% x9 Z- x; \# m6 x- ~
- r7 d* Z8 l4 w) c" n- A20Write: xor cx, cx ; Reasonable wait
$ i: i3 [& H+ M. Q: _ - get1: in al, 64h ; Get KBC read status % S# \; `. v3 }& l
- test al, 02 ; See if buffer empty, bit 1 clear % l; @7 y( V( V% W- l7 Q
- jz clear 6 z2 K3 @ \* I! V) k
- dec cx 2 Z+ U, V3 B! i, q4 S( {; Y
- jz exit3 , ]& Y+ c* k6 L6 O. u/ V# x
- jmp SHORT get1
0 |# }+ k& B9 B0 R - clear: inc al ; Clear ZR
& a% g, B4 g7 F& C$ S3 Q% l, n/ B - exit3: ret
2 n- U# {3 f1 q( [3 C, ^ - : t r. D8 b9 R' L
- . @( ]4 H: r g& E
- A20Read: xor cx, cx
- f3 g" G- F; w$ e6 @* r: z" ]6 {$ ~ - get2: in al, 64h ! }0 N8 q4 v- j c% |6 L8 W
- test al, 01 ; If the 'output buffer' is full, has
& Q5 c: W8 i$ d; q+ I; r+ f7 b - jnz exit4 ; something for me ; n, |9 Q! n8 s! M1 b0 y0 ] G
- dec cx
' f0 Q, R2 ]% Z7 r - jnz get2. g. c5 ^, y3 F+ A2 x* B
- exit4: ret * n) o# V- t9 l" d
- 5 M( S' s" q& s$ O5 z, I/ a4 k2 L! x
- end
复制代码 |
|