|
|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM
: i& y0 ^. y0 m- N. f$ @# o ] - ;
$ u) |2 Z, N. F - ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01
; K4 M) _; t6 ]* m. u; \ - ; ml A20ON.asm # H7 d+ C6 Q/ N, s5 f1 H9 l
- ;
. H A1 s. D- O | - .model tiny; B: u8 v1 X/ A' ^
- .code
- w$ I7 ^( l) B# v - .486
" E4 j6 }1 f: C - .startup
' ]( h- }0 y8 ~, j5 i8 Q0 u' P) l# a
+ s! F6 d) x: x( R! o, T+ r" g- mov dx, offset msg_author
0 @ q/ H3 E2 W, r2 I - mov ah, 09h. }2 v! N$ Z& C& s; o1 y: q
- int 21h
v, H2 O5 d5 r( s9 K9 Q4 i5 M
8 c, _9 H( e7 s( R0 _4 O- mov dx, offset msg_fail
$ r( `) W( B( i7 K) U* F - call A20_ENABLE
# g9 l6 z7 L/ K, D - jz exit1- f/ F. z- u. c" T! Z" D
- mov dx, offset msg_ok ) _; A W' F4 V! v& C6 t
/ ~% g P1 \; h- H- exit1: mov ah, 09h
# v; n6 v8 D# l0 N; t( V1 F( I - int 21h
5 n% m# d* I6 r* ~ w; |. Z - mov ax, 4C00h - O4 Z* F( O0 _( l6 [6 t' Y
- int 21h # Q4 X o/ J1 h4 {4 g; J% d3 {+ p
-
0 \6 N$ S4 ]9 D8 i" a) M3 F; I - msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,
! @6 @! E' g8 n: I0 W* B& _" M - "2008-07-01",13, 10, "$" 3 C* n/ R( y" F s
- msg_ok db "A20 Enable OK", 13, 10, "$" ! L( ~, k) t: i" k* y/ H1 F; u
- msg_fail db "A20 Enable FAIL", 13, 10, "$" / f) l, b: w7 a: Q% i
. j3 y& k. O2 D: f4 H8 r+ b- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
7 t, @7 T; w$ _8 G% ~# u - A20_ENABLE: 7 w4 E0 |! ?9 `' ^
- call A20Write , C+ I# N- h( ^ g0 U
- jz exit_enable
1 a9 z7 U9 b1 f0 M- U/ ~
2 T2 F( ~, T9 w! A4 {/ _, u- cli ; Only need for reading value from KBC
* k& U E' L! Y! u: r5 V - mov al, 0D0h " D2 i1 W% q$ I0 q0 ~! T' p# e
- out 64h, al
( x3 r4 j& |3 X - call A20Read - U- k" s( y' ]% a4 b' r
- jz enable_int
3 s( o- n. K: p% I: u/ p& F w5 \ - / G5 V$ \5 q* Y1 H9 b' J- z# w" D5 _
- in al, 60h ; Get current status
& m( h8 S+ M7 ] - mov ah, al 7 f- T; V9 J' ~
- call A20Write
4 x" ?$ b# D& S - enable_int: sti 9 R% H8 o# j! p7 ]0 G
- jz exit_enable6 X5 h, J3 a8 t, [ Q. j
- ! b$ {) R; `3 m) o
- mov al, 0D1h ; Tell the KBC , want to write to the % }5 `! a4 g0 M9 z& d
- out 64h, al ; Out Put Port next
+ p, Z6 @5 d8 Z& q+ ~6 I$ Q9 d# Q - call A20Write
- v2 f3 a/ j8 `9 B7 j! Y - jz exit_enable% i% _! `' z$ c2 r& K7 F" n
- ( p3 X7 u+ \" S
- mov al, ah " ~, F5 A6 \3 g' L. k
- or al, 2 ; Enable line A20 " i2 K3 d! n- `$ N0 p- x8 B* x7 K
- out 60h, al
( h5 c; M7 J3 _# r6 X - call A20Write : b, l# j0 z/ k; t
- jz exit_enable% o" N; a# `0 E: a( c6 w
- * y }# x' O4 Z; Y
- mov al, 0FFh ; NOP
; C* v8 L. z& w' Z; I7 p7 k - out 64h, al
% N% u0 Y+ n' Y - call A20Write ; V3 h3 ^6 t" ?6 |" Y# J% h, w0 X2 e
- 0 J6 j3 W- \ C" E d i! g
- exit_enable: ret + n% K: G1 Y. D+ i' [
- $ V0 k$ q; `* N
- A20Write: xor cx, cx ; Reasonable wait * o" _# [5 }# w1 P$ o" u
- get_wirte: in al, 64h ; Get KBC read status ' M! _7 \9 r- M- `
- test al, 02 ; See if buffer empty, bit 1 clear & t/ @, P( W7 g7 s: i; i5 j
- jz clear , G! f7 M1 \8 a2 S( C
- dec cx # p1 n$ n- c" e2 Q, J' \ r# X5 d0 ]! e
- jz exit_write $ a0 K" T8 @+ X; R# {
- jmp short get_wirte $ R% f% N8 T8 x6 Z7 C+ t
- clear: inc al ; Clear ZR
- I( L y. V, Q8 ^( e* W7 z - exit_write: ret
9 _7 h: h, p3 W, @# F l - A; ] i2 E/ r) H2 ~: S, f3 y
- - p0 L. G6 T0 I7 d" Q* h
- A20Read: xor cx, cx 2 P( E. J) j5 d. \# |
- get_read: in al, 64h 9 _" [- ^1 ?1 P: X5 ?+ F0 q( y
- test al, 01 ; If the 'output buffer' is full, has
* ]! j' `0 n, q9 M - jnz exit4 ; ...
5 e2 H9 W) i. D; |5 [4 B) l - dec cx ~! V7 e. }2 m% z
- jnz get_read* T7 h& g' P8 o( E5 u5 r' R( |
- exit4: ret
* x! p) l+ m; z2 J* G -
( X7 h' |) n' _" r. F6 N& p - end
复制代码- ;A200FF.ASM
: Q+ Y F& S7 D5 [7 @* r( G0 N - ; 1 `& c2 L! Z3 W6 a4 d3 e# K* {
- ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01" x! z6 \9 X. R) Z* T& K
- ; ml A20ON.asm
- x5 `% V4 h- v$ M6 R4 L% ]4 q& ~ - ;
8 C! M. P' q" a0 c - .model tiny# @6 p3 v0 y j
- .code: C: m4 ]+ x! p* q% C
- .486 h) x, k; @2 a! K
- .startup
4 x6 ], ]7 `0 Z* h
! k& J1 f# ?. o# z- V0 T: D- mov dx, offset msg_author
0 o% O( ?6 V0 u% X2 c - mov ah, 09h
5 W K4 a1 r( B: \) B! w0 R - int 21h) q7 Y7 `! |0 v1 J5 o
( m- h* b' s* s w- mov dx, offset msg_fail
% J! X! H. z' s& F4 O0 n - call A20_DISABLE
- r/ O$ ` f7 C% j) G' p4 W7 U+ Q - jz exit1# O( \$ @+ V: i+ v+ ] r9 Z" I
- mov dx, offset msg_ok
( g& c# K8 O+ j7 k5 [+ w
3 |. T( |7 m' S6 C9 w5 P0 l8 P' p- exit1: mov ah, 09h
7 a5 Q% U9 `- g# R - int 21h ) P# P5 t S, m
- mov ax, 4C00h
% v/ m4 b4 g6 i0 _ - int 21h
% u% v$ B# c h2 a7 z - $ r2 n* G6 C+ [: j: V0 L' S/ u
- msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,) a3 v) ^) H5 t7 B
- "2008-07-01",13, 10, "$"
: l$ Z/ l7 g, h; Q, m. e - msg_ok db "A20 Disable OK", 13, 10, "$"
8 L8 ]% `8 j6 e - msg_fail db "A20 Disable FAIL", 13, 10, "$" - c: y+ f) f6 w3 u
* d, ?$ r7 m+ n& `- ;------------------------ follow code maybe make to lib, if you want...-------------------------------( }: V. V) f2 q) g# \& x9 `
- A20_DISABLE:
2 z4 ^1 }$ J& {" ~4 G9 f - call A20Write
% N6 _8 T5 T/ K) J( L/ F2 H9 b - jz exit_disable2 S0 T3 t- l6 f* P$ t
- 3 D" @; C z- g; l# Y
- cli ; Only need for reading value from KBC * q) A6 u- S- Y! h
- mov al, 0D0h
( f: g& V4 `! {$ D9 ~1 }4 n3 f - out 64h, al ' [/ B1 D: d/ @. N: u
- call A20Read " e: t" `2 K" m- j
- jz Disable_int
8 Y) C& c1 X# ]4 g
. Q4 D2 _) N. i0 H0 |- c- l- in al, 60h ; Get current status
4 z" y' E1 Z/ H; T3 ^1 D! e3 N) X - mov ah, al
& M) E% E- Y3 a) Q: q, L2 t - call A20Write
8 k% M. G' O2 H" ^ a) x. E' j9 D - Disable_int: sti
$ Z$ a$ F( l, @5 b - jz exit_disable" `* b$ R: z3 A e! n; R
- ) \; L4 Y) F1 S! y1 T, X1 b
- mov al, 0D1h ; Tell the KBC , want to write to the . f: e+ r6 ~) g4 y) g( `* Q1 d) p
- out 64h, al ; Out Put Port next
3 P1 X5 C2 o& P: R) H- i- O - call A20Write
* \0 x2 O( @6 S7 G: d; x$ |& N - jz exit_disable
3 _! n1 i' {+ ?3 {# R4 w# Z0 N
, ^4 k% s5 B, m N1 ^9 M- n- mov al, ah
2 I6 ]: S' G% b: L: D0 \, [ - and al, not 2 ; Disable line A20 ( L6 r& Z5 X% X8 ^* |% D4 w
- out 60h, al
& R$ w* o* C% V, H$ P5 w4 A& r8 l - call A20Write
1 R) Z+ `5 l* n7 x; z - jz exit_disable7 e% \$ ^' `8 c+ i# e4 F
( M/ P$ }, D5 A+ o. Z' S: Z- D- mov al, 0FFh ; NOP
+ W& a; c1 u) V/ ?. S3 a - out 64h, al
, j, [3 |1 P2 B/ z! O* G - call A20Write ( g P. d) K. N+ J8 I( Q( l
. W7 J: M+ z) l% L- exit_disable: ret
+ c( N- v. o5 l9 v) a( o
. }. y$ m& V. t- A20Write: xor cx, cx ; Reasonable wait
; q6 B+ J* q; Z6 \% [1 z6 r - get_wirte: in al, 64h ; Get KBC read status 2 y: d+ `! K0 F7 V/ N
- test al, 02 ; See if buffer empty, bit 1 clear , v8 ]# Q9 t4 H% N
- jz clear 5 M3 I, {) |$ A+ T+ ^
- dec cx
. a% [ w4 V! w - jz exit_write * l3 {) N1 I* t* X/ B @; {
- jmp short get_wirte
) D" D* y; e$ S& O - clear: inc al ; Clear ZR
8 \( T1 B& z3 F- {8 ?; [2 U( x - exit_write: ret
( S. l s4 S, u - 9 g7 h' R; W0 J" m* O0 U9 o7 K2 j+ U
- + ~+ z: b; ]* g; L+ y y9 d
- A20Read: xor cx, cx
8 {( ~, [0 ~! }9 c: H+ C - get_read: in al, 64h
! P; z: j3 o" m; U' i5 p% G - test al, 01 ; If the 'output buffer' is full, has
" U7 `& h7 [3 l) Q3 G5 {: ] - jnz exit4 ; ... + A- t3 O" ~6 c" v
- dec cx 3 _9 O# }& f9 x, }, ?) U- T
- jnz get_read
! S# ]" I/ Y E- E% ~( v8 \ - exit4: ret - n' ]1 Y2 g; a) t
- * \4 Q+ O& i5 S
- end
复制代码- ;A20STATE.ASM W( v/ _9 B2 R: e% ^/ o
- ;
) o; m1 ~. I; w7 } - ; Returns the status of the line A20 through the KBC 2 [# F1 f8 a5 ^# v1 B5 S! w
- ; programming by bini for debug. 2008-07-013 j9 P6 y" e7 R& U1 q0 w% {3 S9 ?" e
- ;
! i) v5 w! H8 ^: g- e" C - .model tiny: R: j. ~% _: D5 y0 H" ]
- .code
) W1 ^, c: J$ X! D" _: q$ { y( [ - .486
0 T7 k5 g4 ~# [/ Z - .startup! ]7 I z/ N& G* H
- mov dx, offset msg_fail 4 P" i" S3 E( I8 Q! T- I. e
- call _GET_A20_STATE_9 o' v5 g+ b, Y* u5 Q' w) H
- jz exit1 ; was a problem
# r. t$ F U) y; ?) j. c1 ?0 n - push ax ; Save state, AH
* ^2 T4 j# Y5 G, f1 P2 } - mov dx, offset msg_ok ; There wasn't a problem & e |- e% G# [3 k4 d
- mov ah, 09h
4 ]. U/ t, T3 C. i7 r - int 21h ; Print message " ^# I5 g5 m8 q0 h
- pop ax ; retreve state
& n* y0 Y0 m) l9 g
- ~5 ^* L5 X/ C- e4 s& s- y6 y- mov dx, offset msg_dis * \5 N/ Q7 M& E2 h
- and ah, 00000010b ; bit 1, 2h, indicates state
1 B; H+ e9 Q* `' n1 j' l5 C8 }+ k - jz exit1 : r% f( A5 |4 T: Q% D6 L6 ~
- mov dx, offset msg_en 1 E/ b, V9 @. U
- ; d6 ~6 i% X9 a. g7 [0 P
- exit1: mov ah, 09h 5 Y8 b7 S8 ] @3 s8 [6 R
- ; DX already contains address of string
! n) h9 W/ [5 h! w - int 21h ) D+ H6 D" i! U" p
- 1 v" J. d* Z. Q; k
- mov ax, 4C00h 5 ?& W2 T+ c1 F
- int 21h / c! Q. p8 S6 g' g0 R- \
* l; z6 ?8 h; t x) B- msg_ok db "OK", 13, 10, "A20 $"
0 \3 j) H/ y' r - msg_fail db "FAIL", 13, 10, "$"
6 b9 V* h* r6 k2 D - msg_en db "ENABLED", 13, 10, "$"
/ n! W- B+ p* ^& R2 O8 o- R% ` - msg_dis db "DISABLED", 13, 10, "$"
1 {4 ?# Z2 X# i# n7 h
; [; t5 ?; F" z Q) Y-
" R4 A+ `8 h# ~ - _GET_A20_STATE_:
w6 b& A# k, O - call A20Write ; Wait till the input register is empty
) p/ Z- p7 ?+ @' b: P2 B2 m' v - jz exit2+1 ; Bypas the reset int's % U# g; w; L$ O& R
- cli ; Disable ints so we'll get our value * e ?& G9 \- C( y. s( I: N5 D
- 3 F$ _, C0 V- Y R: ]2 U4 g
- mov al, 0D0h ; Send command to the 8042 command register
+ S( D+ G) W7 ?" G# j; Z - out 64h, al ; to tell it we want to Read the Output Port 0 z& d9 o8 `4 H' o* {
- call A20Read ; Wait till the 8042 output register # O: d& z& f7 ?# [* A
- jz exit2 ; has something in it's buffer
$ U9 k, q+ ? O8 F
+ p; @, H; y, v) H- in al, 60h ; Get it ( H8 u, ?* O. }. v
- mov ah, al
4 q7 M, x) O5 _& ~* z - call A20Write ; Make sure the input register is empty 8 D3 _# E* q) W7 Z
- jz exit2 - d. B O' O/ S. r0 P( E
7 V. o! K- T- V% X. f- mov al, 0FFh ; KBC NOP command, does nothing 7 i+ e1 h2 N! }6 O5 A
- out 64h, al 2 H1 D* W8 n* W0 b# o$ _
- call A20Write 4 y# f( l/ E6 _$ c& M+ `- Q6 Z
- 3 T- {& D! v' i j% p+ J! {' \
- exit2: sti
: s0 w2 _0 n* T, t - ret2 C5 B7 N2 Z7 J0 F6 d0 E
- ) ?; L4 X3 p7 f9 U% q- T3 b9 }
8 Z% j2 S! h; e% A* a- A20Write: xor cx, cx ; Reasonable wait % o+ s; z! R: X$ r, Q; R
- get1: in al, 64h ; Get KBC read status 0 \/ o9 _5 C( q/ e
- test al, 02 ; See if buffer empty, bit 1 clear % h7 }2 Y$ d4 l. ], R( m
- jz clear
+ z3 U. [1 U( o5 ?+ v# X7 D - dec cx 3 t! O2 @' o2 p- Z* |
- jz exit3
# b# V2 ^, r) ~$ b; @$ a6 D1 l' O - jmp SHORT get1
- _) k4 `% h: K# S: S - clear: inc al ; Clear ZR 1 Y( o) O. o0 ^
- exit3: ret + G4 g( E5 Z6 i/ i9 y
- & F4 B$ y9 R \8 C% w4 ?' ]4 I
# t) o" a# B4 a5 E- A20Read: xor cx, cx
+ ~2 h4 [- t6 o% }! ^ - get2: in al, 64h
! |; N" G8 X% k5 K. c( f$ U - test al, 01 ; If the 'output buffer' is full, has
. j& v$ B6 ?) ^. R. s - jnz exit4 ; something for me
N; g" g9 l, M' H - dec cx
8 Z; d9 w: w' O' Z% N - jnz get2
; o7 d1 O# f! L! J% A2 j - exit4: ret 8 n) U. a7 U; A$ r$ H$ l
- / m8 p, \! }# }
- end
复制代码 |
|