|
|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM
- w( G: O/ S8 T: ~. ~ - ; : h' H' a0 z6 W) @+ N5 F
- ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-016 t9 T J) o- y
- ; ml A20ON.asm
: |) b4 k) g+ w7 R" M! d) |/ z - ; 0 m" F M/ | `" R4 [
- .model tiny
# `2 T' n7 `" T D+ c, K& M- h - .code% H A% O6 Q, G' j5 |
- .486
+ y+ P& V+ f* f4 d - .startup
5 R2 h. T l) _
2 z! j$ e6 w, }2 F- mov dx, offset msg_author' L2 \2 F1 Q% J& v/ w
- mov ah, 09h
. D. j$ C4 A5 o4 S5 W - int 21h
* ~: c6 N5 v- U& H' D) V, Q - . f, m$ G1 J+ _' j) g5 f
- mov dx, offset msg_fail 8 H0 F. ^+ @( z7 o
- call A20_ENABLE
1 M5 O0 g5 t$ ? - jz exit13 p( U% g5 A3 m5 F7 p# U+ h
- mov dx, offset msg_ok * B- @5 W1 S D3 ~
- ( }3 B5 ]% L$ u
- exit1: mov ah, 09h . Z, }. n1 V- U. `5 [
- int 21h $ t% B% G, X) I4 r% k" q2 n
- mov ax, 4C00h " X- y: v: l: _7 j8 {
- int 21h
5 `9 g/ w$ t1 r$ a -
- x5 W) z+ M n- R- [" K - msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,
& R( V2 H }0 P* |) i$ L0 y - "2008-07-01",13, 10, "$" ; R i$ n7 H B2 C3 v
- msg_ok db "A20 Enable OK", 13, 10, "$" ) S, k! D [6 P8 e- N
- msg_fail db "A20 Enable FAIL", 13, 10, "$"
; j% ]% ~# j- W6 U+ l" P9 v8 ^
2 M; l" I2 Z* j2 }- ;------------------------ follow code maybe make to lib, if you want...-------------------------------7 R0 y2 U: e0 k) \: T3 `
- A20_ENABLE: ' ^' p' c! s5 T8 [1 s+ `
- call A20Write
& {0 ^( @1 x4 ]" Y3 D, } - jz exit_enable& m( m" C5 n! v+ @
) G# Z8 J$ H1 r6 h- cli ; Only need for reading value from KBC 9 N: o9 Q( f3 T
- mov al, 0D0h
0 T2 n+ n. \, Y: O& z - out 64h, al
8 Y* \7 T: u2 C" d& o2 L - call A20Read 9 `' T2 ]- B/ \7 [
- jz enable_int 0 n$ l: k' E% p2 C
- - l; o0 S# |: z5 m" y! R
- in al, 60h ; Get current status 3 ?2 z. w. \6 @0 L- J& \
- mov ah, al
/ e( e! m& W: E: b. O/ }; z - call A20Write
# I* E2 ~$ @* o. {2 K! C - enable_int: sti
. i/ x- X E/ t+ g1 d - jz exit_enable9 ^3 C% A3 ]8 T* O
+ i8 r$ j" n# {6 m5 R( I; e3 Z. r R& {- mov al, 0D1h ; Tell the KBC , want to write to the & s, V) V' \* E" N, ]5 y( r: U' L$ P
- out 64h, al ; Out Put Port next 3 q2 @: b5 ?6 B
- call A20Write
! l5 E! p9 s4 s, T - jz exit_enable
! x' G: l( L& _: j6 a) H" G - ) F$ v% ]9 b3 r+ r6 ~
- mov al, ah
" Q4 m2 \5 |! y6 j9 f - or al, 2 ; Enable line A20
4 R; n" Y, \. ` - out 60h, al 1 T; ~* g0 N* a; X7 r$ n
- call A20Write " m( y- T! `4 U
- jz exit_enable
6 Q3 U4 C' \# d3 H, Q# U - + k( b6 s2 b' R0 y& c" K
- mov al, 0FFh ; NOP
5 d9 p# W7 D6 m! a4 D: `8 Q( } - out 64h, al
4 ^6 E: H9 @% @4 K - call A20Write
' U% ^- c' J0 I3 R7 f
0 l1 Q% u, i# h1 G5 f4 U* Y8 Q( Q- exit_enable: ret / V* I% x F5 x
2 L0 M4 A# i+ f& t# J9 m1 T" t- A20Write: xor cx, cx ; Reasonable wait ; {" e5 s; K# i
- get_wirte: in al, 64h ; Get KBC read status
, y7 E/ K' u, d3 g; ?6 _2 G - test al, 02 ; See if buffer empty, bit 1 clear 2 D0 s! c6 C$ }- ?# W1 C
- jz clear
7 C$ S9 T' E: h9 C - dec cx 3 a1 f' ^( T0 Q5 J
- jz exit_write
: d) {$ u% R' v" m" `, m - jmp short get_wirte ' b" a8 q% @( H3 U
- clear: inc al ; Clear ZR ( t2 o) N7 C0 ~3 q$ D' h
- exit_write: ret
, Y/ U* a, O- b$ K! [- W1 e/ Z - 0 P& y& V9 F1 a" K4 F" H
2 l9 r6 V# _9 d+ y. r: ?$ o$ Y" ^1 i- A20Read: xor cx, cx
' W' h% B/ L8 x% g - get_read: in al, 64h
- b) K+ g" V& g S+ l - test al, 01 ; If the 'output buffer' is full, has ' w- C* b( j7 l3 I
- jnz exit4 ; ... . ]/ p x5 T' L2 y- S
- dec cx
' M1 m5 \$ G# y# P2 v8 L# U - jnz get_read9 O4 U, l. Z7 b. @$ I+ T" x3 @
- exit4: ret
0 p9 Q8 u2 T0 p( f |& H - # a9 Y( u; F* D/ \- f
- end
复制代码- ;A200FF.ASM ) N" }( S: J* I
- ; : w9 X" f1 E. P9 K, p7 |
- ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-011 f% r' a# ^$ c# r
- ; ml A20ON.asm + d' k' O$ I8 H' Z( I: m& N
- ; # l, z e) {1 D V
- .model tiny
3 _8 Q: z. o: a4 K6 O - .code
$ i6 p$ B2 s0 M/ A) P$ b5 q: c - .486
8 S6 s! u* e( X# \9 q) Y9 W; J5 L9 S - .startup
! G. c2 O+ @6 J: ~; H - 4 }3 d' j% e3 U: r2 [, d
- mov dx, offset msg_author, } Z( G& S. W
- mov ah, 09h
! B5 l0 w7 J2 C1 u$ U - int 21h) k) u& m a7 g! z
, N! Y, w. e2 [, ^0 N# N& y5 m; @- mov dx, offset msg_fail
7 e( [$ C0 }- O# i6 Z* I - call A20_DISABLE" a( a- F; \3 H
- jz exit15 H; j* v) e4 c2 W. {5 H
- mov dx, offset msg_ok - u. x% s3 n2 O1 k
' o$ g# E1 ?- R& F0 W+ s- t- exit1: mov ah, 09h
* r. u; ?. }) Z g) j m - int 21h / r# N2 ^* M: m9 @# C
- mov ax, 4C00h " w5 T4 C; z" y+ y+ o
- int 21h 3 y" [& N7 j& L$ [0 Q; k+ j
- % S" {5 \& W5 P
- msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,
; j d% r l* A4 C% M - "2008-07-01",13, 10, "$" : ?8 h) e# R" g) X: ~$ \0 S
- msg_ok db "A20 Disable OK", 13, 10, "$" & b/ o N, b$ \9 }) O3 Y7 @
- msg_fail db "A20 Disable FAIL", 13, 10, "$"
' e8 L7 I. M0 j3 L
2 T v( h3 p' F1 J- ;------------------------ follow code maybe make to lib, if you want...-------------------------------; Z8 D5 b8 D- T3 S" u
- A20_DISABLE: 2 B. J) Z7 [' t6 s7 I
- call A20Write
; b0 A$ v6 l/ b - jz exit_disable
0 \! U1 i! h2 M) D" A( c - 4 h y3 b; O7 p5 m$ e
- cli ; Only need for reading value from KBC
' v( @9 h2 R' W6 e: l - mov al, 0D0h ; ^( {, F- t/ Q) h1 n
- out 64h, al 8 w5 ~& D* T3 N# k. l g
- call A20Read : S9 r' u7 E& B
- jz Disable_int 5 I- D. R. ^% W( ~
- # D: L S, i' p* d! o" h8 O
- in al, 60h ; Get current status
+ H# h+ A" |% V3 O1 j - mov ah, al
& F$ U0 h2 _% K/ m: e+ G5 ^. M3 d - call A20Write - o% |6 Z$ a5 X: i" D5 [
- Disable_int: sti 5 k' `0 R' `: Z0 X+ v, T9 T& u
- jz exit_disable
! E, p; A% f/ }- S, G; E7 O$ W! q - " D6 D5 o6 O O
- mov al, 0D1h ; Tell the KBC , want to write to the 4 T" a) V6 L2 L0 U: l( S
- out 64h, al ; Out Put Port next
( Z; i# E8 |# Z5 E' U- q& @ - call A20Write
8 K4 E; x$ ^8 a, c ?0 a* u# i - jz exit_disable
. Y5 t) V& |2 `& Y
! }( U; T$ z2 E$ h8 d- mov al, ah
+ G$ h" }# E1 E, Y - and al, not 2 ; Disable line A20 & \# |# q! H& [. ~8 F/ `& z2 x
- out 60h, al
" t1 G8 r# q0 h1 g3 r - call A20Write
+ p4 X9 W# B, u( j - jz exit_disable
- b' Q j8 G8 N) M( { |' I2 }6 R
# N/ X9 ^ ~/ A4 A6 l9 }! G! P- mov al, 0FFh ; NOP + T9 J0 V% j4 p. a3 W
- out 64h, al
/ y7 I& ^- U' U - call A20Write - N$ \2 q1 E5 G" Q4 }" i3 H
8 T" j: Y! t# Z0 u5 l- exit_disable: ret 2 g4 B" C( X( ^2 r: _2 q8 X% S
) i# ^& s6 n/ q. \6 }" \- A20Write: xor cx, cx ; Reasonable wait
( H3 j" v# C P7 k! Y" I - get_wirte: in al, 64h ; Get KBC read status
7 o+ R/ f+ O) K7 b - test al, 02 ; See if buffer empty, bit 1 clear 6 r. ?0 R# i5 P
- jz clear ! E: D- {! ?3 Q" T# _3 w, d3 {
- dec cx
8 P! N6 Z" q: d+ [. F7 C8 w" d - jz exit_write $ Z2 T; S4 _6 ~9 T( K
- jmp short get_wirte 8 v1 Y( |$ w, E ?0 e
- clear: inc al ; Clear ZR
4 e) h0 W/ o6 p% v* P1 @! `. s - exit_write: ret
' ]4 l" |5 p3 B# s y2 K4 H0 g
/ i; M) e% |$ R* b& u& Q- - j4 D+ v6 z1 X
- A20Read: xor cx, cx
, ^8 D1 `* p+ y2 y# m" ] - get_read: in al, 64h 2 f) a. S+ [. O8 s
- test al, 01 ; If the 'output buffer' is full, has
! E; p" D. K k! k - jnz exit4 ; ... \2 D# R* p( N" ]
- dec cx ) {& V7 a( x: L; S) d9 p& n7 Z
- jnz get_read' a- p! I C/ j# u1 T
- exit4: ret + a5 ^& S# y2 R2 c4 e4 K; A5 C. g
- 4 M4 ^9 l. k5 g0 v4 s
- end
复制代码- ;A20STATE.ASM
/ K% {1 p9 h( w/ }: k6 n" D - ;
2 n5 x# r4 a7 j+ {2 F) [# ^( t" k - ; Returns the status of the line A20 through the KBC - v6 z" w% f& f, }6 C
- ; programming by bini for debug. 2008-07-01& E( o6 R# n$ r& g+ d- y
- ; 2 T" D- k4 ~! Z: v; m8 T) h) Y
- .model tiny% S& h: X# j; O0 E
- .code, y$ ^" H/ p7 i. e5 S# d
- .486 V4 v4 E% {7 F8 ^6 x3 c2 C F" I
- .startup3 e% w% m/ r$ r0 V
- mov dx, offset msg_fail
7 w$ N! F3 _1 v" C$ E5 F: H - call _GET_A20_STATE_" N8 k: z: {! g H4 K2 p( T( H
- jz exit1 ; was a problem
j9 v) i2 S* k2 \' k* ` - push ax ; Save state, AH
( |* r3 y# W) P' ]2 d, q; N. h - mov dx, offset msg_ok ; There wasn't a problem ( n* G9 Q- H! ]3 I
- mov ah, 09h + b( e3 y/ }- Q& P; E, P6 G
- int 21h ; Print message ; T$ J4 T3 F; Z8 B' p3 K0 }9 d
- pop ax ; retreve state 5 q+ H {& `" i- N2 ?
- # V# ]; ^& X2 u# ~, \7 q, w
- mov dx, offset msg_dis
1 k* a1 N4 H6 q6 | - and ah, 00000010b ; bit 1, 2h, indicates state 8 @5 G3 g8 g* |- H2 M$ `: t0 r
- jz exit1 q& }. m9 Q3 k! }+ h
- mov dx, offset msg_en 8 B* z1 x# h! C% E z4 i
1 Y' m/ W L# Q4 z$ F' E- exit1: mov ah, 09h
# t2 [' h/ t. F$ o - ; DX already contains address of string ; b4 D+ w* ?8 Z. t% X
- int 21h
$ _3 O. K" F/ ? - ' X( }* s& k: g1 H6 x1 s+ E
- mov ax, 4C00h , u! d) Q2 h0 g1 b7 |$ ^1 L5 d
- int 21h
) s, K) I0 {/ S2 L - 7 ~/ P: O9 _3 R: z) I$ F* K6 i
- msg_ok db "OK", 13, 10, "A20 $" / c* [. j# ~ g- t) j. n
- msg_fail db "FAIL", 13, 10, "$"
' Z, G; [5 s# f - msg_en db "ENABLED", 13, 10, "$"
; ~3 y6 x1 [5 e; `4 f - msg_dis db "DISABLED", 13, 10, "$"& K a: {9 ~) o; q) H8 ^; S
- y+ [' f" L5 E% A+ T
- W1 `( x0 P# M' M" y4 g7 H3 j; h- f
- _GET_A20_STATE_:
8 e) h2 k$ |/ |- G$ c" y - call A20Write ; Wait till the input register is empty
. e* c; z) c: t2 S# J! d - jz exit2+1 ; Bypas the reset int's
6 C! C4 @' H) T& Y - cli ; Disable ints so we'll get our value
2 g3 ]# l6 u6 ]% _1 r5 w: @! T) {% [
; x& X' r8 o6 s' E( M8 n- mov al, 0D0h ; Send command to the 8042 command register ) Z* O( j5 X! @8 p6 W
- out 64h, al ; to tell it we want to Read the Output Port 1 D/ q$ R5 P& \- F
- call A20Read ; Wait till the 8042 output register / l3 w& `+ U7 [# c7 Q
- jz exit2 ; has something in it's buffer
3 |3 s( ?4 x5 {9 j- z! U1 b
2 E# r+ k: [ F9 P+ n3 F- in al, 60h ; Get it ) M9 \0 O8 L' g1 p
- mov ah, al
$ S$ ]6 I' e- E. @' c- V& D - call A20Write ; Make sure the input register is empty 8 n( t" O! i2 I3 l( F. V4 r( m
- jz exit2
d4 I2 _ ]& R
} D3 G5 W$ r4 v- c% q- mov al, 0FFh ; KBC NOP command, does nothing : J( L# i4 _; B8 P; b2 S, R
- out 64h, al ; a0 O2 W. o! r8 r+ C
- call A20Write : F2 ^0 V t6 r
- ?' z: k3 |4 U$ b( Q( p& _
- exit2: sti
& r( L/ \% u* e2 J$ o9 h7 a% c - ret& N( p5 Z- l- f- d1 ^/ v* v9 ~1 O
4 N! g) q5 }4 m# L$ }5 n/ k+ _9 S- 4 O j! ~ H8 F" ?( Y5 H+ A9 A8 D
- A20Write: xor cx, cx ; Reasonable wait $ }5 p! H3 g& o9 P( Q# F
- get1: in al, 64h ; Get KBC read status $ P# X0 r2 q1 \% D, L* y0 A
- test al, 02 ; See if buffer empty, bit 1 clear
% I2 s- V* _1 r. M' T - jz clear
5 [9 j" `( Q# ^5 S) ~) i( C - dec cx
. \, C8 Q% u8 f4 P% s% U' F - jz exit3
% k* [4 s. F8 {5 G# w* y - jmp SHORT get1 ' _1 u5 H: j; g' C h
- clear: inc al ; Clear ZR 1 W* n: K* R$ o/ ~% G1 Z3 `
- exit3: ret
1 ~( M4 H! q( q/ p1 z0 a6 [
! O9 \. T7 G- f- u' `& v4 b9 D" Z3 |. T7 x9 z
- A20Read: xor cx, cx
/ H4 }8 D) w9 ~! S. n - get2: in al, 64h
2 P+ p' X) f& B( z1 S2 v7 u3 _* H - test al, 01 ; If the 'output buffer' is full, has 4 c, n2 V) A, J6 p/ D$ ]; h
- jnz exit4 ; something for me
5 Y4 F" K) ?) V5 _0 l3 ?( g2 o - dec cx % e5 Z; ^, z! K' Q2 L
- jnz get2
" }# {2 \9 l) ]8 a* K& w2 \* d - exit4: ret
5 X& ?) v. g+ y0 K4 e0 x - % F9 W* k! `+ s. l
- end
复制代码 |
|