|
|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM 6 _ S- c k f. B g' b, @
- ;
$ {8 G Y* ^+ v% y- Z+ h - ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01
% V; y8 o; |* J$ k- l. x% y - ; ml A20ON.asm
) h6 P0 {0 ?$ q% @" T4 N2 L - ;
( m3 x' x/ |; m1 S- \# d - .model tiny
$ n5 Y" H4 A, r8 M3 n - .code
5 k" e* N5 c! M& \+ J- ]8 u - .4864 b8 M9 L' Q8 F! {. O8 D
- .startup
' C. [8 k$ i& A4 A) k
8 c% O0 X" c0 C+ u' a; H- mov dx, offset msg_author
% ^6 h( E+ ?8 A; A - mov ah, 09h
. ]: P4 q6 l* X+ {+ s+ W - int 21h
# U ] a3 g/ S$ I - 2 r9 _/ {; k& ~" j
- mov dx, offset msg_fail
2 `1 t) V6 w3 P1 A - call A20_ENABLE& g, U3 h0 n* Q
- jz exit1- {! [4 U/ p! t
- mov dx, offset msg_ok 0 Z. c- k& v. g# _2 c
- + w& ~2 s7 H3 a3 m6 N# f; ~
- exit1: mov ah, 09h ]3 M" e# R8 M. u" e, t3 |. u
- int 21h 5 b) W1 S0 X; t9 h- {+ Z4 b
- mov ax, 4C00h
/ ], S4 c/ N) {6 q, n/ Z$ C - int 21h 3 C. q2 E+ G/ p0 x$ b
-
. }0 d' A8 e, E# d - msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,6 Q( W- |' [0 I, m: M7 o
- "2008-07-01",13, 10, "$" 4 t5 }0 S) ^ ^5 E0 Q) b
- msg_ok db "A20 Enable OK", 13, 10, "$" ) d1 `6 [2 z5 t# c
- msg_fail db "A20 Enable FAIL", 13, 10, "$"
2 `8 G4 Y* I, I [ - 2 n9 H2 Z; K5 @ X, \2 L
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------% u y& |2 L; Q0 n/ X
- A20_ENABLE:
2 R8 M5 f( Y) P# ?" H3 L+ ? - call A20Write
" N3 O. [2 }! R' G" K7 J - jz exit_enable4 D; O1 R6 S, N0 j9 E) e
- ) |9 J' [: V3 P
- cli ; Only need for reading value from KBC & H3 d0 J) A2 ^7 y: F! a( e
- mov al, 0D0h
! i! k" d, [" {3 ]- c+ U/ ~ - out 64h, al % [- A: n4 U% R% U o4 d6 w
- call A20Read $ V/ g- B2 ]9 i* N) n, f
- jz enable_int
0 c3 Q) l$ B4 W" t
R) n9 g* W' _& i% \" `3 s8 \$ X/ i- in al, 60h ; Get current status ; e7 Y7 J5 y2 f; L4 N/ V O j
- mov ah, al
' o% Q$ _ @8 S1 g* x- @ - call A20Write
( G4 ] F1 r! g - enable_int: sti 8 ^( e/ L2 B( ^$ @) n5 o' Y. ?
- jz exit_enable" k v0 a/ ]$ c
- 0 K& c0 f) l& x2 Y& j
- mov al, 0D1h ; Tell the KBC , want to write to the % s- n, ~* H0 _9 D6 ?6 H
- out 64h, al ; Out Put Port next ' G% V9 }" l; q9 L- ^! ~
- call A20Write 4 s: A' ~" h: y
- jz exit_enable; {% F; A9 t0 T
- E/ h5 ^# u: r
- mov al, ah . y" Y; g5 A9 u
- or al, 2 ; Enable line A20
( M! _1 W0 `8 D - out 60h, al
/ l, d+ f! B9 r+ |0 t% W) w - call A20Write + H, Q5 d- t2 \ S
- jz exit_enable
" z& w0 Q; _+ C! q; C
5 N) Y' _+ f8 {* i0 S- mov al, 0FFh ; NOP
( B( w" T$ v8 w1 d( O4 \ - out 64h, al : y' R4 t: e: G9 p5 s4 ~
- call A20Write
; P' _) K! R, A' B6 r6 B% L$ L - 4 n+ b9 v$ J1 K1 \0 \& C# x
- exit_enable: ret ; h0 c) b$ ~+ y: R7 ]
- 4 J9 e0 f" n0 u/ u. t% a- X' M
- A20Write: xor cx, cx ; Reasonable wait
4 \( c. f3 M+ i% {3 o. T - get_wirte: in al, 64h ; Get KBC read status
; Z0 X1 c" o# A' c, ?1 n/ D - test al, 02 ; See if buffer empty, bit 1 clear
6 A: s' M; T) c1 |! y - jz clear
0 a& e' n. r4 ?0 ^; A7 i; J' y c - dec cx ( j) X6 o9 d; P
- jz exit_write " `, |% F. f' \
- jmp short get_wirte 9 h+ W9 d' H, n- h/ ]
- clear: inc al ; Clear ZR o# o) o, s$ p g) _% b9 X4 r/ a
- exit_write: ret - P8 T7 d7 d: v0 w( A
- 4 C1 Z6 x, f2 ?
- 4 {* d+ m3 T2 G0 ?1 H
- A20Read: xor cx, cx % X3 w4 v" b9 c; a- B2 d! t: H) _
- get_read: in al, 64h 2 u7 K, l/ \; o- S
- test al, 01 ; If the 'output buffer' is full, has - I1 J$ B; A9 [
- jnz exit4 ; ...
9 w- V/ K9 S6 a) f - dec cx 7 |" u4 P, }# O
- jnz get_read4 @2 M2 O) I- X$ m( h( l! J
- exit4: ret 0 h5 n1 w% ~4 X' Y5 [( b5 E
- 0 {* [' {0 |7 p0 b) F, e
- end
复制代码- ;A200FF.ASM 3 g9 |. w( i: W2 l5 ]9 S
- ;
# R# t g! D' U5 j- Y8 S% ] - ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01
9 R2 J2 i R! m: g/ Z - ; ml A20ON.asm ; b& x3 r3 c! N6 w; Y
- ; . K5 D6 R8 f5 S# V: K+ j
- .model tiny
$ s1 T5 B) f! K0 ^8 b - .code
$ ~4 P: K% ~/ ]" x, } - .486
+ G0 U# N9 C3 }( h/ I$ } - .startup
; f: P8 q% C$ x' _
2 }, ?0 ]; y$ @- mov dx, offset msg_author
2 J* P3 M+ }4 F: o - mov ah, 09h
4 `' P3 B9 z0 x. z - int 21h
$ m" o& H1 O4 }: ` - b7 T; B" n2 i3 ^- O8 i
- mov dx, offset msg_fail
$ N" {" a7 ?& K2 b1 N - call A20_DISABLE: V7 v; H5 ~$ r
- jz exit1
. G1 r8 ^$ ?( U# C: {8 t. a - mov dx, offset msg_ok
9 o0 o3 X6 Y" l
" r% B1 {$ x( @* W- exit1: mov ah, 09h
% ?& ^8 D/ n/ m* r$ p - int 21h ) n5 z4 p3 I! B$ ? o- A
- mov ax, 4C00h
! `/ i5 g6 s6 D0 b4 | - int 21h 4 V: m- O, ^$ V% v! ~/ p: g
- / R) N. S7 s: Z* _9 x
- msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,* T; ^) u& ^& C
- "2008-07-01",13, 10, "$" % R7 `9 d8 J' f3 T; ^
- msg_ok db "A20 Disable OK", 13, 10, "$"
% v8 H) @* M; t$ w0 k& Q0 ~' i - msg_fail db "A20 Disable FAIL", 13, 10, "$"
5 w! @$ r: e( T
8 d* [% Z5 g8 |1 G& B7 L- ;------------------------ follow code maybe make to lib, if you want...-------------------------------6 f; ^& Q) c1 F- j: Y! K
- A20_DISABLE:
4 W2 v7 Q) s: n$ D3 R - call A20Write . s% P1 S& h! j$ P% r* X
- jz exit_disable* F6 d0 `1 L/ Y6 h# G. [' `! ?) x
# {7 B; ^) r+ r- cli ; Only need for reading value from KBC 8 K$ {4 f0 B8 V
- mov al, 0D0h 9 _4 ~* z$ P# X1 J' b) Y
- out 64h, al 6 D5 `4 L q0 t y0 q4 Y1 B' O& _
- call A20Read
0 n, Z" r0 S' k0 n% A! d - jz Disable_int
2 P- m( }) S( Z
# F! x/ g5 {& `* G8 ^* r# \- in al, 60h ; Get current status
" x4 z" u- u' L4 a - mov ah, al 8 n3 g3 d+ B2 |
- call A20Write
& p, x4 H) M6 P0 Y' k: r - Disable_int: sti
$ r. f9 f3 S0 \- m4 [ - jz exit_disable& |' o8 n) }0 Q3 K5 F, x
# D% o% v R" U$ @- y% g- mov al, 0D1h ; Tell the KBC , want to write to the ) O" l9 n, z l/ Z! Z Q+ ?% ]
- out 64h, al ; Out Put Port next " i" ^3 M2 R/ S9 O& a8 G2 z: O
- call A20Write 2 d5 i( y* s5 l0 N7 l
- jz exit_disable
5 i( M5 n' z( Q% n# W" C) ? - + w3 C' Z; }# X2 i! `2 }2 u
- mov al, ah # g# r) c9 m7 C
- and al, not 2 ; Disable line A20 : H0 K$ e9 }! A/ F5 _
- out 60h, al % n% [& I9 K0 B" S% A
- call A20Write 4 Z, x1 P. J1 p; v. D
- jz exit_disable
& u9 Y5 D/ n6 P3 X% d% q
& D* {" c/ ?1 T) x& Y9 M- mov al, 0FFh ; NOP 6 Y6 [; S; d3 K% }$ C
- out 64h, al
9 w8 u# v7 h+ ]. c3 I1 g - call A20Write : d- F4 f/ M( O8 g4 x
- . _6 j+ c& ~3 E& W/ `$ T* O9 U
- exit_disable: ret
1 `, I4 `( y7 ^ h O# z - 4 ^* Y H; t5 U- Y R
- A20Write: xor cx, cx ; Reasonable wait - T- j8 s4 M1 Q7 d0 F+ M2 p
- get_wirte: in al, 64h ; Get KBC read status
; H4 P4 Q7 h9 q0 J - test al, 02 ; See if buffer empty, bit 1 clear
; u: k! k& [; P. E - jz clear
/ g+ X& v* f/ e - dec cx
! n3 y7 S9 w# p4 f, x# R - jz exit_write
1 s) n, p! h) V$ Q9 ?: _ - jmp short get_wirte
9 \( a5 o2 @+ x: K9 l - clear: inc al ; Clear ZR
1 l; j0 l' y8 t" m) l) @ - exit_write: ret
8 j4 M0 } R7 B0 G/ o2 P) k - S9 Z" o5 q6 w0 X
6 y( W( k) K' t( Z& O! i( Q* o4 ]- A20Read: xor cx, cx 2 X4 m, l$ I, p% ?$ |) Q, S
- get_read: in al, 64h - U! e5 ]+ E, B1 p
- test al, 01 ; If the 'output buffer' is full, has
- R+ e7 B. L: n - jnz exit4 ; ...
4 C3 g; Y' ^: M - dec cx
) }: W% Z' t8 E' K4 b - jnz get_read
. G+ d9 w- C5 L4 [" v - exit4: ret 9 \6 ^ \$ [: R2 L9 X" E' ^
-
3 w# O" E3 G; y8 n1 x4 M( e' q - end
复制代码- ;A20STATE.ASM $ U6 Z' R+ a: s- N4 |. O9 g
- ;
Y4 K9 F) W: R/ r9 d - ; Returns the status of the line A20 through the KBC 6 X X3 N: ^8 E w V+ }2 l. W
- ; programming by bini for debug. 2008-07-01
& }3 Y/ ^3 }# \6 w! m! u, l - ; & @: J! u4 Y* z: b) P: u
- .model tiny
0 _* e k, g+ G5 h6 V; q" j - .code$ b2 c2 e: }5 b9 [! a1 R
- .486
. t! g4 N& ~% o4 t$ C9 ^ - .startup0 E8 g5 \* z% J; ~0 E( c
- mov dx, offset msg_fail 0 g# [2 {9 k$ m5 v3 q$ b
- call _GET_A20_STATE_3 A* K' l( q+ F9 L6 H& [ _
- jz exit1 ; was a problem
- ~& ^/ m( {' d4 N2 B - push ax ; Save state, AH ; m7 f. D8 X; y( d& Q) O
- mov dx, offset msg_ok ; There wasn't a problem # U1 G1 |. u9 {7 C9 b) j
- mov ah, 09h
! s# h2 `% a4 n( a" C5 K - int 21h ; Print message
) q, O- {0 y% a3 `: g4 C - pop ax ; retreve state
" z& D, C4 |# D - - E2 n3 q5 a G9 v
- mov dx, offset msg_dis
$ T0 ^+ k4 Y: _! Y2 z3 s3 ?" h7 D2 y - and ah, 00000010b ; bit 1, 2h, indicates state
8 H* x9 p3 | n+ U8 u - jz exit1
5 f2 Y* x6 f1 _3 \: W" c. P - mov dx, offset msg_en
. q( N& f' Q( k6 W, D: g
4 u6 P5 A1 B* b- exit1: mov ah, 09h ( I1 z: v0 c& m. c" i8 T8 Q
- ; DX already contains address of string
& O% P2 p9 D# |6 a2 H# a$ F% h - int 21h
* p+ f8 x( d8 }: F2 b5 z' g - , a- a5 F6 j7 P1 ?# q1 k7 Z O* f
- mov ax, 4C00h
4 s$ f' [) v& _ - int 21h
9 c& f/ P& G; h# b* Z" o - # P' [8 u4 V: T* P7 g. ~
- msg_ok db "OK", 13, 10, "A20 $" v" K6 `5 X* J5 t" k
- msg_fail db "FAIL", 13, 10, "$" . p1 _0 o7 i% p. o( L7 x
- msg_en db "ENABLED", 13, 10, "$"
' ^" e, t* i/ n/ u - msg_dis db "DISABLED", 13, 10, "$"
" u! }, V3 n7 x
. U& H& e8 C, z# ?5 q( ^-
& P1 {% o4 Y: L" _ - _GET_A20_STATE_:
6 q7 j+ a* z" T* K* d; [( p - call A20Write ; Wait till the input register is empty & G! B( ?0 ~7 ~0 c
- jz exit2+1 ; Bypas the reset int's
* v% H$ X0 n+ |; B - cli ; Disable ints so we'll get our value
0 r! p" w. A1 N3 z! x
# h+ Z; V/ \& s2 U; O" z3 X- mov al, 0D0h ; Send command to the 8042 command register * F! m' c) z& b! y
- out 64h, al ; to tell it we want to Read the Output Port
1 A% i( b" [! v/ S5 d4 L# t - call A20Read ; Wait till the 8042 output register
" C$ V# E) @9 I - jz exit2 ; has something in it's buffer : P8 w+ _2 {+ F. M9 u4 @
- A8 Q8 F8 f" q/ L8 ?1 K. ^' A- in al, 60h ; Get it
7 Z) k+ Z3 f4 Y* {2 {: M8 Z% }+ S; R - mov ah, al ' ?2 C2 W7 u; c' u& X* t( w
- call A20Write ; Make sure the input register is empty 7 S$ M. z9 W$ r& q' Z
- jz exit2
6 f+ E8 y( d8 G
7 r- ^( p! P7 H- x- mov al, 0FFh ; KBC NOP command, does nothing 7 T6 j A5 o0 [ a/ ]
- out 64h, al : b4 h! P5 J% ~7 s$ _' J
- call A20Write
/ h% h) Z- P: U7 z" V$ ?. b0 U - ) b; T. ^1 m0 K: B# n- \2 M- H; k" m
- exit2: sti * R. g# f( ^3 R" `7 ]
- ret
0 e/ ~1 Z9 B- j$ m
) r/ F% ]' q0 w5 B$ {* s
& C$ W6 b9 U( f5 Y; }' d% t0 c+ a- A20Write: xor cx, cx ; Reasonable wait
9 K+ }1 S4 o4 ]# l - get1: in al, 64h ; Get KBC read status 8 `. R' H) ?8 Z0 n2 h, n
- test al, 02 ; See if buffer empty, bit 1 clear
U, i) n( V0 E+ {; G - jz clear
+ p! U* k2 H. ~4 u/ N5 M& m6 N - dec cx 1 ?* }' x6 J8 E) R
- jz exit3
" E& K' G& h. a/ g( ` - jmp SHORT get1
; U" e6 w# p7 w! N+ O2 F- v% J7 d# A - clear: inc al ; Clear ZR 6 N) Y+ F8 R5 V% O# A# {& w Y
- exit3: ret ! A' p3 L+ g: }4 P2 T
" M9 e/ ]6 @8 U- R) z7 R/ p9 H7 s
- A20Read: xor cx, cx
! v% n3 s) N4 b9 K- |. X - get2: in al, 64h 9 k9 g& a7 P/ h
- test al, 01 ; If the 'output buffer' is full, has
' u4 F2 l7 }8 B O - jnz exit4 ; something for me
3 K4 ^9 |: y$ }* q& e - dec cx
6 F- W# }1 e3 S0 \* ?# y - jnz get2
# e' ?7 I3 u0 o, M - exit4: ret
" ^$ h. M- f/ k - , C5 N! z, G& H( N" a) ^. K
- end
复制代码 |
|