|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM ' o+ I* B# s9 w5 u
- ; 6 w! q; U+ I+ V/ n4 e) C
- ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01$ b: s0 w N/ j$ X0 }
- ; ml A20ON.asm / O o3 h) R& F" }9 n
- ; 0 _% @. ^0 P8 |; S2 f& l! J6 N9 g
- .model tiny/ |$ Q# X3 q! ]
- .code9 \( x4 Q! O2 S' |
- .486
: d" `3 Z4 S7 u' p+ W. k4 c% O - .startup8 t$ V& _7 ]7 Q+ }8 b4 t
- 6 i4 l0 }- C i7 p H$ [; h6 T
- mov dx, offset msg_author* ^1 ?( q% t# h: D% H% B" L, K
- mov ah, 09h
* l# a+ M6 ?! ~$ C1 B/ ~ - int 21h7 d$ r5 w+ c; V5 f1 k1 R
h3 [2 w5 B" A) Q% a5 H- mov dx, offset msg_fail . i N+ u0 y$ Z7 j3 y. o
- call A20_ENABLE
9 I! g3 r* g. t# g* s - jz exit1
E( M, T! Q. C N - mov dx, offset msg_ok
' r b, m0 v/ Q( W7 R6 Q; Y9 i
+ n8 |6 o; \5 q% G1 L6 o! I, ]- exit1: mov ah, 09h
8 ]6 S/ @3 T. n: g/ h6 r2 A& x - int 21h 7 ?7 W9 c& {% d; g( ?; Z% ^; e
- mov ax, 4C00h 0 E4 X: b( b2 t% E+ H9 B
- int 21h $ t! @/ A5 h' @! \6 J% S u
-
- n1 k$ N" b2 }+ q; ~ - msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,
# A2 K. d1 ?6 {- |) V - "2008-07-01",13, 10, "$" / h- X$ I2 \# r2 J4 T2 }/ ^
- msg_ok db "A20 Enable OK", 13, 10, "$"
3 q; A- K# X( g0 a+ p5 _ - msg_fail db "A20 Enable FAIL", 13, 10, "$"
$ L( F5 Q1 {# y+ ?
7 c, d4 [' N4 _, J- ;------------------------ follow code maybe make to lib, if you want...-------------------------------% X* S, b5 |2 N4 Y! I, E# J
- A20_ENABLE: 9 Y* S2 j! z8 n0 A' }; m: q
- call A20Write & n8 R6 u' g" V0 T/ k' Y& |0 D
- jz exit_enable
6 i8 T/ f) R4 o. @5 T
6 e7 c9 N. U: [' J* Z7 Y' ?- cli ; Only need for reading value from KBC
/ J- H/ {6 R4 c; S; a - mov al, 0D0h 3 l& l0 n% h+ a
- out 64h, al
8 Q. h4 F, r7 } - call A20Read
, J, |( F5 ^ q- ]( V4 \. P - jz enable_int
6 O! ^8 p b8 p& b
6 ~9 ~- p2 _8 `8 d( e- in al, 60h ; Get current status
( x- B: [$ _; l- y% e1 t0 K - mov ah, al
3 V, g8 p7 f2 x+ f5 s% P - call A20Write
& D# u' `8 o: Z/ c B - enable_int: sti ' r1 L4 L4 U7 i- C! j2 K' B
- jz exit_enable+ M2 g, E' h7 ~0 `3 H* z7 H
- 7 t" X5 C4 q9 I9 {) w
- mov al, 0D1h ; Tell the KBC , want to write to the " H/ s3 r& C9 v. E
- out 64h, al ; Out Put Port next
+ h' [) P0 G) z8 j! W, s - call A20Write
% Z/ |: D! F9 e6 q1 }8 `8 {+ L# A - jz exit_enable
0 C! ]! d3 }% e. ]9 X" V) x& a - % Z' h" Q4 D9 S1 x2 V& l8 d
- mov al, ah
# i( m0 ^, V2 U7 F7 N5 Y - or al, 2 ; Enable line A20 " i- P6 L8 d3 ~& B% \* @+ i
- out 60h, al
- T4 [3 ?' ?' p( e2 Y - call A20Write
3 i6 D \$ s# Y( e - jz exit_enable0 Z4 _" b4 N$ K" q, P
- " h9 V9 x2 P7 a1 G: M8 Q( P
- mov al, 0FFh ; NOP 5 g( X4 ]% N/ }; M: Q' b- b$ i
- out 64h, al ' D- M. N7 X6 S6 J1 x6 M: k( H
- call A20Write 9 K9 {( m" }5 u* R: g4 J' o
- 0 e4 l7 \) y. ^$ v, S/ b$ b
- exit_enable: ret 5 A i f5 w8 v1 J1 O6 s- Y
- ( }% B( o; I$ l% F3 U
- A20Write: xor cx, cx ; Reasonable wait 3 P6 w5 v8 a% l
- get_wirte: in al, 64h ; Get KBC read status 8 W4 r0 ^, f. ~1 k: }! b, u0 \
- test al, 02 ; See if buffer empty, bit 1 clear 8 ^! @2 r% C& d- F9 }$ k9 z
- jz clear
+ Z; P5 d2 i6 V% y - dec cx
, b l' s9 v3 N; h6 C5 T3 ` - jz exit_write 1 D( o1 R0 f+ x- h K: W3 u6 U4 [
- jmp short get_wirte : w- q" o% u1 P& h2 N
- clear: inc al ; Clear ZR - R6 w. W# G1 s ^$ A
- exit_write: ret
_) n# U6 P0 |& t! P8 w8 T - $ _' ]6 _& Q# F% \
1 y6 E5 l1 t( r/ h6 |5 q. r7 h- A20Read: xor cx, cx * ~! i7 A1 Q5 j0 j4 O; n
- get_read: in al, 64h
2 C, y* L5 [7 U# i) w - test al, 01 ; If the 'output buffer' is full, has
' {/ L/ e# n Q' l$ C6 c - jnz exit4 ; ...
* p0 a3 }. O2 ?' A: T - dec cx
E7 B3 o! W" G3 j4 L6 ` - jnz get_read
& u7 ?- W* J+ E A - exit4: ret
) Q, d# j/ W* O0 i! Y9 v - / K+ w3 v2 |8 ]
- end
复制代码- ;A200FF.ASM
! p/ g; P0 ^* q) M - ;
2 r1 ^$ d: B5 q* o0 \9 @5 E - ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01/ }* x! c# n2 q! t
- ; ml A20ON.asm $ \6 o3 D$ T! K7 n a
- ; % d t7 m" B+ e/ H4 Q
- .model tiny
4 r, A" o7 @- W1 O/ D* }* y. _7 p - .code# z' o5 J* ^. c) P, _$ Q
- .486& _* X/ D/ d5 u1 U$ @+ S
- .startup
( C8 g) m# s# k9 J( ~4 H+ \
, Z$ G0 `/ \7 _" G& r3 M3 y- mov dx, offset msg_author Z1 s9 f# S9 v( E1 s# g9 i
- mov ah, 09h
% Q# h1 w6 I# m - int 21h" ?) g! k; ~' _
" C* M) R; ~ a0 F4 M. H3 `+ z- mov dx, offset msg_fail
; `" @1 a6 M: _$ W1 n+ ^' k" c, o - call A20_DISABLE; h# q8 X- \* T% F$ e1 V
- jz exit1. D A; X4 e2 I9 d6 ~
- mov dx, offset msg_ok
5 w3 O7 b. T; i/ t8 W9 [ - . H0 P5 q9 S* U* _, T; h$ u6 ~, S
- exit1: mov ah, 09h # B6 T4 a- @- r
- int 21h 3 S9 y& }' Y) [3 E A8 D$ f
- mov ax, 4C00h
9 F. {$ m, o* R4 {/ K8 y5 b4 c - int 21h $ Y- H. h& H, `( u3 w. `2 C
- # G& a) a. [7 r# r4 x9 t
- msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,
1 t& `. {- t6 A j3 ]: { s - "2008-07-01",13, 10, "$" 7 J# ^4 G! ]; j% r8 D( ?
- msg_ok db "A20 Disable OK", 13, 10, "$" 3 |& C: V- @5 A
- msg_fail db "A20 Disable FAIL", 13, 10, "$"
}. ^& ]) g+ q' M0 V: } - % T( i5 o( c0 J
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------! L' X' d9 }6 j( D& U- e( Z
- A20_DISABLE:
8 `; b5 C$ s+ V7 r+ C0 r - call A20Write # {# I7 F2 p% U, t" e y
- jz exit_disable7 Q& j8 } ^ l" m, t s6 o+ ^
- $ ^7 q0 Y2 E/ ?$ i/ S- l1 t
- cli ; Only need for reading value from KBC 5 V& [0 W1 D$ d/ y7 h- \5 H0 w
- mov al, 0D0h ; {' a: q3 X- ?* w8 N1 w
- out 64h, al
& N/ }# x6 Y$ M - call A20Read
" X' k4 |& ~7 [ @+ h# J - jz Disable_int 5 M& m2 h( x% Z6 I; P
- , k6 ^ D/ e0 C% l0 Y8 |
- in al, 60h ; Get current status
) d( u' _; ^5 B: o# d$ F, L - mov ah, al 5 o) m) Y0 \1 _7 h$ b
- call A20Write % i' m$ ^4 l( F" J
- Disable_int: sti 6 {/ l& [6 L' X! ~* _+ H! j! ]
- jz exit_disable
; S8 h& ^9 e* C0 g* }$ b - * x- W6 h( V- b! S7 q4 W3 g+ B
- mov al, 0D1h ; Tell the KBC , want to write to the 3 W0 C4 C8 R P/ G
- out 64h, al ; Out Put Port next ( Z; S. S9 Y7 i
- call A20Write # t2 ?. R, X, ~ z" R
- jz exit_disable+ m l! c- P; h7 Z8 ~; O; |) d. b5 h
- ) w# |$ v/ G/ l6 ?
- mov al, ah _* T) |: b$ ]
- and al, not 2 ; Disable line A20
) r- p7 z! C3 |& N - out 60h, al - b0 l T1 S: t8 v! @! g& ]
- call A20Write
2 l% K0 w3 n( o t& W" O - jz exit_disable
% D" A; `" s8 I0 H' [
2 ^2 q$ ^2 c: `1 {) r- mov al, 0FFh ; NOP
! R7 y4 h. O& v) {: q2 x - out 64h, al 5 U; B$ r9 d' p6 m# `+ [
- call A20Write
, ?: H+ O& ~6 k/ |6 I
" `( h9 f8 P x4 H/ y- exit_disable: ret ( n D" m! m1 l0 c' h
- u+ M- o0 y( Y2 ^: ?2 G- }) I
- A20Write: xor cx, cx ; Reasonable wait 5 r, n0 Q3 N$ n# a) p" O$ B, |0 o
- get_wirte: in al, 64h ; Get KBC read status
* P5 ]7 S9 t" p$ L5 z# D+ u - test al, 02 ; See if buffer empty, bit 1 clear
6 o+ v+ C X7 ~) V) s - jz clear
4 `! _7 c" N5 s1 q - dec cx
6 h* T2 p& z) o/ v( d' j - jz exit_write
9 o' J# ]+ |9 y- r& ?. H3 A( Y - jmp short get_wirte ; Z, m+ c" e c& C+ t8 g
- clear: inc al ; Clear ZR ' u& c1 Y% [4 t4 n
- exit_write: ret
* t; N+ T, B7 _# A - X( Z) a# m. I' U! A# O$ W: k
- V% h7 S4 A3 z$ D2 L; e: R# ^$ ]9 \" e- A20Read: xor cx, cx 0 [. X8 T2 e7 }. p
- get_read: in al, 64h
' _/ `) R, L' u& u7 J; d - test al, 01 ; If the 'output buffer' is full, has ' ^# s! W! E9 K
- jnz exit4 ; ... . Z) G r: t+ x8 P" o8 V9 `& G1 R
- dec cx
8 d* }2 D7 m; {7 I1 B - jnz get_read
' B ~; v4 `: O3 m/ e - exit4: ret . g9 D& l5 p* t: s/ a" z
-
2 M* m4 ]1 K4 ?/ h) |" a" w - end
复制代码- ;A20STATE.ASM + w$ c! v* f( c9 h* { y
- ; _# t: v, A, {- T Y/ m9 P
- ; Returns the status of the line A20 through the KBC
! ~( @8 ]" k4 v% v* M1 L9 E - ; programming by bini for debug. 2008-07-01+ F* `: V8 J7 W7 A# S6 q
- ; ) U6 m* _4 W# |
- .model tiny
4 x% _; v, q. Z0 h* q. v - .code
2 v% F5 I# x: P$ j - .486
8 |: B6 c! t& n - .startup
5 \( e' W6 i8 o! f) { - mov dx, offset msg_fail 0 m7 o. `& K' x
- call _GET_A20_STATE_
! N2 @# T3 D% K @: U& N: ^ - jz exit1 ; was a problem
7 L& v9 q$ R( w% d - push ax ; Save state, AH
$ T" e! N& `; \ - mov dx, offset msg_ok ; There wasn't a problem
, {! |0 L, @ w0 H! O( s; Q0 r% \ - mov ah, 09h
; Y/ a+ @0 C8 U$ { - int 21h ; Print message + Q2 X1 D, ?+ ?7 Y% E
- pop ax ; retreve state
4 Z( M6 V2 J- r9 V' \+ x6 v- m
" @8 G! m7 A2 C6 v- mov dx, offset msg_dis ( M' g. u) f# o+ [ R
- and ah, 00000010b ; bit 1, 2h, indicates state 6 z: |2 M) z" J5 F; n" T
- jz exit1
: b& z0 u2 z( c7 p& L! w6 R - mov dx, offset msg_en * c8 C1 B7 U/ r3 a. r
- / P9 f: q' U! f; I
- exit1: mov ah, 09h
8 _& O: U1 c: ^0 F1 m - ; DX already contains address of string ( W6 P' y& J* H- i
- int 21h % m x* H7 _6 `% n
( y; p# F0 k/ R/ ?6 F+ d s- mov ax, 4C00h / F( y/ g8 W) ?+ Q5 ^+ I
- int 21h 4 l8 {: U4 V, S2 x! ^# Y1 n$ k
+ D1 S+ Y6 ?7 R. i& \- msg_ok db "OK", 13, 10, "A20 $" / `) c* C' D$ V2 t/ N8 L
- msg_fail db "FAIL", 13, 10, "$" ( [ @0 o: v, E9 e9 u1 y1 Y, B# G
- msg_en db "ENABLED", 13, 10, "$"
0 u4 r' ^: ]0 `+ B - msg_dis db "DISABLED", 13, 10, "$"
2 G; B8 P" e. O y! ?6 n. q5 v8 V* s - Z, n8 a, U4 y
- & q% M% V4 x2 _2 p* m2 T
- _GET_A20_STATE_:
0 F, \& u: A* H9 }0 t - call A20Write ; Wait till the input register is empty 5 @4 E7 @6 \. Q7 L9 D2 J* f
- jz exit2+1 ; Bypas the reset int's
: n& ], L/ I: J. e, v - cli ; Disable ints so we'll get our value : N3 j ]$ g4 c6 n
- ' b: Z1 U7 X8 z! K+ b
- mov al, 0D0h ; Send command to the 8042 command register & E8 B' d9 W; g, x# Y
- out 64h, al ; to tell it we want to Read the Output Port
% L0 a8 r1 Y) Q4 d Q" G! C - call A20Read ; Wait till the 8042 output register 1 i$ K4 ?+ |; M1 h% y% [; J
- jz exit2 ; has something in it's buffer
. W+ F4 V% [2 O/ V - 1 V3 Q) N, g) |$ n1 M/ G
- in al, 60h ; Get it 2 m+ ^ H# ]# ^$ e( |9 [+ A4 o0 {
- mov ah, al
6 F) Q/ E7 h* f$ z - call A20Write ; Make sure the input register is empty
7 \" c" u) z* g$ { - jz exit2
- b$ Z% N8 R; l' e5 J7 [) x
, @6 ]& R: B5 V5 C+ I- mov al, 0FFh ; KBC NOP command, does nothing
* Y5 \' ]' P8 l - out 64h, al + q7 V4 T* P' Z/ {6 x: X/ U3 d* H+ T
- call A20Write . o4 C: [/ h4 e' T+ Y' b
0 R) u( N9 R% d, K$ \% x+ t- exit2: sti
9 `4 _" D7 n! Q - ret
& v. G( R1 H1 x5 q- x7 I - ' M5 w9 S/ R4 W' f9 r* u
0 K/ @- D2 T I- A20Write: xor cx, cx ; Reasonable wait n" p, u- b [% G2 Q5 l4 j, G
- get1: in al, 64h ; Get KBC read status * ^4 B6 q3 [4 U4 M
- test al, 02 ; See if buffer empty, bit 1 clear ( _& m! z- I2 e$ H' ~
- jz clear
' a# @- y( J9 p p: x- f7 p - dec cx & @2 t9 `& E, W- J
- jz exit3
4 s% `2 j {( y - jmp SHORT get1
5 A, u! N& r! y - clear: inc al ; Clear ZR # i% s% d E& I9 z% F% W. j% g
- exit3: ret
4 e( y2 S# f$ \/ X - , H1 [. V) M* i( h
0 e& b' F _9 a5 n" q: W: j" u- A20Read: xor cx, cx " g( L1 K- _9 }4 `; K2 E8 |
- get2: in al, 64h 0 l) X+ J7 m# G7 l: i; t. U- ~6 c
- test al, 01 ; If the 'output buffer' is full, has
+ Q4 e: m1 b' D+ q: y& Q - jnz exit4 ; something for me
& G8 u( c7 A7 B9 v; E; w - dec cx ! b* Q' i4 \; P& ?* Y( }9 A* A
- jnz get2
/ D. }4 g; Y x, e- h( Y - exit4: ret
/ s; O8 Y) ]! `% M& ^, u1 u* W( p2 ^* g -
" J& R4 o; g6 P% j$ ?, A" B - end
复制代码 |
|