|
|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM 5 V( ^- o; }) V5 ?$ ?
- ;
% {5 s7 Z( G( h - ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01
B( ]4 t) Q: E5 y. S! Z& y - ; ml A20ON.asm - l1 v" _& S7 A% s: ?
- ; $ R" B8 I. E, K5 U, U7 b2 T
- .model tiny
/ s; T/ s6 @5 \ - .code
" i1 ? W* V' o1 e - .486
5 g, `1 D7 Z/ {) x - .startup3 ?$ `& n4 l9 B/ z- ^0 d" P
- 4 f$ x! V: E$ ?. ?4 c
- mov dx, offset msg_author
, i; ~% \" [$ @- I - mov ah, 09h
: J& B Y+ d, h7 b' m/ V) K2 H - int 21h
0 o6 l" {8 t3 G
! Y! f8 F b* r# }- mov dx, offset msg_fail
; e3 J. B, b8 x2 L3 I; h - call A20_ENABLE& N/ J8 Z) l5 x" r8 N
- jz exit1
5 B% ^' N% O+ o. l: O3 e. c - mov dx, offset msg_ok
, s2 y" Y F; [, a* ]4 K# g
1 \5 \8 ^2 ]: P! o- exit1: mov ah, 09h 5 X' T1 U# W. Z. y
- int 21h
2 R* i2 F' V2 R/ | - mov ax, 4C00h - g- f! V; K/ X9 h/ E8 y
- int 21h
% t& t) d" {! b; c - / s# l7 |# K4 V: x- B- r
- msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,8 `6 H7 s$ K7 N# T) \+ Z5 h$ s
- "2008-07-01",13, 10, "$"
0 `. i8 k/ r" A% w$ A - msg_ok db "A20 Enable OK", 13, 10, "$"
% {7 I5 A$ B- w - msg_fail db "A20 Enable FAIL", 13, 10, "$" & M) t3 B. v. E; m3 z' K
- ( m" ?! J6 M/ K8 }; R% x+ U
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
3 g; v$ J. O+ s' U. X6 b8 V - A20_ENABLE:
* Y" f) b; e% R" S2 P" ~, B. n - call A20Write : L, R( e4 U) [1 T! D
- jz exit_enable
5 k! I6 m* J) W - " V8 @) g; a5 ?. @; c- C
- cli ; Only need for reading value from KBC ; |% A3 A8 t. Y
- mov al, 0D0h
/ ]9 ]. T" \; q' ], E) e6 ~ - out 64h, al
) v: h) J/ U8 h2 \. P3 e. } - call A20Read
5 ]& w+ i' |6 F- U8 ~ - jz enable_int
0 ^8 k6 H; ^' B% `5 f6 e# w
" ~& u# G! a$ b$ ^- in al, 60h ; Get current status
' r# S( q1 E3 o8 K( s; C$ e( v1 \) g - mov ah, al
; c- m* ]$ X% x l; g) ~5 e - call A20Write 2 h( j' L' Q) z2 _
- enable_int: sti
u7 P# E& ^( B8 G; Q- k' m1 | - jz exit_enable
( o d! P2 A# u5 l- V- v6 A9 E
# U. N# _) U7 w: s- mov al, 0D1h ; Tell the KBC , want to write to the 9 ]/ O# c& M! M6 ]) n- M* @2 L
- out 64h, al ; Out Put Port next
; j+ v4 \( M6 a. U( ] - call A20Write
; c6 p; i+ P% W0 X) ^' n( ? - jz exit_enable7 h1 s0 D$ I1 M% h7 v0 ~
$ y& I0 d0 |- p$ u. B1 I$ o3 n- mov al, ah ; U* }- m; ?; Z. ^8 Q/ ^! S
- or al, 2 ; Enable line A20 6 Y# ^) t, _$ E$ o# R# z! M V
- out 60h, al
( \8 ~# G5 a6 s - call A20Write
2 p% K6 E) f) s: b! B0 d - jz exit_enable
" G6 {, y5 T& w8 A
q' i% W6 E0 j3 y k/ C- mov al, 0FFh ; NOP
9 {, l# P& e3 k0 ^2 x! } - out 64h, al
8 Q/ o0 }3 l3 _- t8 ~3 |: ?; o5 b - call A20Write 5 w, b" e' o3 u0 A3 b( c
! Q; @1 X. F$ c8 s# F* S( @- exit_enable: ret
q- |% ~- k* F$ ~
1 y( u3 r* s3 K, q' ?1 K# T- A20Write: xor cx, cx ; Reasonable wait
0 l s: R. S- p - get_wirte: in al, 64h ; Get KBC read status
4 n0 E5 H; F. c! v - test al, 02 ; See if buffer empty, bit 1 clear
! u$ e5 u- ^4 { - jz clear
/ X$ C5 `! c: D# B% o3 [ - dec cx ' x7 x6 N3 l P% S1 u S$ c# T/ }
- jz exit_write
% `( j- {6 l% @$ e - jmp short get_wirte
( h" G' M! ?9 P ?! s9 E - clear: inc al ; Clear ZR
# \& ?; M; n" Z$ R i$ y% a - exit_write: ret ; O) W0 j3 g5 q7 p( v1 i+ i$ J
8 C$ x% N& M E4 q3 K' j* `7 O
% h' C! V" E0 F, g- A20Read: xor cx, cx
9 X( p6 }3 Y; c/ ]' H, \+ `5 n: f - get_read: in al, 64h : E& Z5 f3 L% l' ]1 n$ H5 c5 S( ~3 ~
- test al, 01 ; If the 'output buffer' is full, has : @, J' N& o _: Q
- jnz exit4 ; ...
% K+ {- `9 `" R/ I - dec cx 3 @3 E3 j7 Q1 ]) t- K" V
- jnz get_read2 M1 C2 c5 a6 r* j8 t1 j% v7 y
- exit4: ret
6 v* {% G& ~% N- C -
" M3 D$ R8 ]7 E1 r) }+ `' [ F - end
复制代码- ;A200FF.ASM 4 s! |- |$ ^7 Y9 ]: ?; e$ D
- ;
, ?7 D4 X" I0 ]6 c* v2 b0 o - ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01
7 y+ x2 e2 Y: }% A - ; ml A20ON.asm " [4 f; `7 V0 @* I8 U0 s
- ; * Q( M- e* Y# t6 k/ @9 U( x2 C
- .model tiny
* ]' @6 h$ h! X' g( T% k( N - .code
2 q( M; ^" W( z ]& \6 f - .4862 @6 O1 @6 J8 T9 Y
- .startup
: F0 `) J6 X) x0 f
( J0 `/ D( p5 `: B& t3 i- mov dx, offset msg_author
# ~9 D1 [2 |- n - mov ah, 09h, A8 T g, k+ o, s! c* G
- int 21h2 }9 H1 B$ l* G* ~0 l
- , W0 | `8 O5 J S
- mov dx, offset msg_fail + O- C" w; q" s& T: a7 ~' z
- call A20_DISABLE+ u4 F" O9 ^& J3 {8 C" v
- jz exit1
0 e5 |# F- O2 z; G% \8 D# u- s - mov dx, offset msg_ok 2 x( }6 j! }2 F
4 f+ W3 ?! i1 @- exit1: mov ah, 09h 8 `/ c& W: c2 J: g9 c
- int 21h
* E' G; r: _8 x. h - mov ax, 4C00h
V; f9 k$ i }$ p+ ~ - int 21h
- f8 z. j5 c* T1 K' F8 s" v. a - Q6 s* R4 [' B3 l8 t& K* j2 j/ B
- msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,' ]3 j. P- _" M
- "2008-07-01",13, 10, "$"
9 A. W& z' L8 T/ f+ D- Y% l$ S) } - msg_ok db "A20 Disable OK", 13, 10, "$"
/ y% s m N# Y! _ a, t, q - msg_fail db "A20 Disable FAIL", 13, 10, "$" # P' Q1 I: ?1 i7 A9 N! S
- 8 X# l" s: r/ j h+ o4 l+ v& b6 \
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------% g1 T0 y% W3 s" w+ F
- A20_DISABLE: % f0 V! ?, l2 g2 ^: Q
- call A20Write
$ w: l7 Y: T, P; n4 a: E* H - jz exit_disable: j T" g P* e8 h9 N g
- 0 V6 V# s- U4 C
- cli ; Only need for reading value from KBC ' r1 l2 A$ z @' |3 H7 b/ O& N( |
- mov al, 0D0h + {- I7 `, J3 s' M' R. e' i
- out 64h, al
y1 r8 d$ c( s# \$ L2 p - call A20Read 7 O) s1 z& _$ ^) }* C" F+ [9 ?
- jz Disable_int
a6 K* X# q$ m4 H/ @ - 9 i) L% k2 |5 }/ L: L! D- q/ K
- in al, 60h ; Get current status
# C; J# g& _7 r; I. s; e1 | m' n' j - mov ah, al
( L/ a' w4 l. B ^. q( w - call A20Write
* o/ m$ C9 Y6 C - Disable_int: sti 7 }! [0 X( a4 q# _0 `# n1 ^7 N
- jz exit_disable
% Z9 A% e( A( f8 C - }) N. h' h. X3 f8 O& V
- mov al, 0D1h ; Tell the KBC , want to write to the ' c8 _( i9 R0 F" m3 o5 P( R
- out 64h, al ; Out Put Port next
8 ?9 m3 k. {2 J; X# g - call A20Write 7 G+ X5 I( b2 O. v& ~1 O
- jz exit_disable, X: y7 y. p: @( [- q0 y, y# v( r- u/ v
6 Y1 w6 ~% ?4 z" Q8 C& q! N% X- mov al, ah
( c! N; Y5 L$ m7 _. ] - and al, not 2 ; Disable line A20
6 U# _% |7 E/ o* \ - out 60h, al * \; d2 u0 `+ ~! c! X+ S
- call A20Write ) C6 p' v3 }" [& L5 J/ m" `' O
- jz exit_disable: d) y2 n& L6 K8 _! d% o. C* w3 ?
- 8 n6 a: m1 q- q6 @9 z
- mov al, 0FFh ; NOP ' D, ]. Y2 N9 N8 N, C
- out 64h, al
! r d0 P+ Q: R6 C - call A20Write 8 A0 ^' B) P8 W
# t$ S9 c$ _8 l) I7 F: `- exit_disable: ret 2 n. x3 U! j- M# ?
4 v2 s6 V- M( H$ x2 d5 |+ B- A20Write: xor cx, cx ; Reasonable wait
# ~) }1 s T% A: Y6 i" } - get_wirte: in al, 64h ; Get KBC read status
- E0 [; G: m0 E8 C& K - test al, 02 ; See if buffer empty, bit 1 clear
# G0 f, |. y' T; {: Y: j1 ~ - jz clear
! I: |0 v1 y! e- } - dec cx
0 j0 c: g9 ~1 A" F& Y8 F2 c - jz exit_write ; y5 Q) M5 R/ t$ E
- jmp short get_wirte
0 v o& b$ H! J! c- g - clear: inc al ; Clear ZR ~6 I. i) p; r/ \ v! {, [
- exit_write: ret 7 T" S5 n' ?1 a# d$ b7 L8 k
- 6 w% p0 n1 z: q7 L% ~. l9 B* G
1 K8 Y; V7 C# b4 `- A20Read: xor cx, cx
: N7 |7 ~& ?9 l8 X - get_read: in al, 64h
4 z$ r3 y9 h: u0 n - test al, 01 ; If the 'output buffer' is full, has 5 _/ c8 ?. ~3 J( J9 L& E
- jnz exit4 ; ... . ?! v& e2 G, J) G: K7 v5 q3 o$ L
- dec cx
3 d/ @) e0 H; n( Q - jnz get_read' ^( T# o5 C. o$ C2 a5 q
- exit4: ret - y: z( q3 Y2 F6 m9 v
-
9 V1 k6 `/ @# m' o - end
复制代码- ;A20STATE.ASM
4 h i6 j0 L ]1 F: S0 I - ; ' t a2 t% r1 A5 c/ G6 b! U9 I2 D. k
- ; Returns the status of the line A20 through the KBC
5 t8 p9 B, F# D8 J) j2 p - ; programming by bini for debug. 2008-07-01
, N* x/ k2 |. _) i" p3 o. m - ;
# n7 n& X% p3 D5 G - .model tiny5 A$ H# P. o. {* m7 ~/ U2 K. w
- .code3 _5 Z6 u% _0 N1 P7 }2 \' L
- .486
9 Y3 D" S5 [1 ? - .startup4 T0 v, c9 N9 {7 o( U, V9 Z; g4 P
- mov dx, offset msg_fail
2 K, B9 g2 b0 S( _ - call _GET_A20_STATE_( J) B5 D9 k7 c( X
- jz exit1 ; was a problem% y0 A0 m, }7 j
- push ax ; Save state, AH , o! v2 Y/ O) G! f9 u2 i
- mov dx, offset msg_ok ; There wasn't a problem
* u, c$ L) U: d! a- X& E' U0 v - mov ah, 09h
9 Y# o0 {& l% ?) y' j( G0 Z - int 21h ; Print message
: i+ w1 e: Y. l# Y - pop ax ; retreve state 7 ~+ w; \ {% E3 m; Y
- 6 \/ T, w5 f. ?
- mov dx, offset msg_dis $ z0 d% q+ i1 O# m8 @* n1 [
- and ah, 00000010b ; bit 1, 2h, indicates state
& g h6 A9 w: G( d- G2 Z - jz exit1
4 r5 _0 ^* T- |' v/ r1 ~ - mov dx, offset msg_en
3 K, f- L n! r0 \7 o8 f0 g/ i- R
3 g' y M4 P6 ~! b- exit1: mov ah, 09h # B1 _7 e: t- g; |7 M2 c% x0 g
- ; DX already contains address of string 6 J+ ~" Z- o& T1 V
- int 21h
- X! S& _ u( P ~
& Y1 J4 d9 s2 g. S, W2 G- mov ax, 4C00h
. f" v1 a5 ^. d( B4 @) w7 [- U - int 21h 4 e$ g" J+ e2 A r# O" p1 I5 a
# _4 u& |* w: o) V# T- msg_ok db "OK", 13, 10, "A20 $" ) }3 U% D6 r: x! i. V
- msg_fail db "FAIL", 13, 10, "$"
+ P' t6 N7 w8 O/ b) \9 \ - msg_en db "ENABLED", 13, 10, "$"
* O: a2 i6 o" r) S" { - msg_dis db "DISABLED", 13, 10, "$"
4 X5 }1 N& U" k3 m' H - / l5 x2 n- ?+ d3 ?. A
-
6 J# |# }1 P' U7 Q( g - _GET_A20_STATE_: * c" q8 b' H' \1 m* d
- call A20Write ; Wait till the input register is empty * J* I1 \/ y, L. h+ f! H% U
- jz exit2+1 ; Bypas the reset int's
3 t7 t/ t m: r6 U" c - cli ; Disable ints so we'll get our value 6 q) p( q- c# q% V% ?+ A% w
- ! w- R# ~. l/ o, B% u# W
- mov al, 0D0h ; Send command to the 8042 command register ' Q& n. Z4 M) j `: Y3 }9 L1 z3 X0 h
- out 64h, al ; to tell it we want to Read the Output Port @$ o( i0 B+ M- a
- call A20Read ; Wait till the 8042 output register
M0 `' ?9 N) D8 B6 i6 ^ - jz exit2 ; has something in it's buffer
7 F; [5 H7 d% }' Y
- p! a9 t0 b1 r# n0 ]! }- in al, 60h ; Get it
3 X- T" F4 H4 G+ g% s% m; [ - mov ah, al ' k/ C* V- F$ y7 G2 y
- call A20Write ; Make sure the input register is empty
+ d3 m3 }* i( I e1 | - jz exit2
# _2 |" `7 z+ m/ m8 C+ k - , [: y: y) f$ y" d3 G1 @4 V
- mov al, 0FFh ; KBC NOP command, does nothing ; m, \2 ^2 m% u6 L+ T- b/ b
- out 64h, al
. o) j5 c3 q: y; p - call A20Write + V8 D/ Y: L, K# j/ h1 L
- 5 K9 M- j7 o. h5 o0 ?, R L
- exit2: sti 9 ?0 k8 d& f- x8 O- O7 D
- ret
% {1 g3 {8 S1 a0 G# j" A
0 J, _4 Y" A0 B) X
; R k/ c, L% t7 p- A20Write: xor cx, cx ; Reasonable wait
1 r0 \' i1 f3 u- C4 z - get1: in al, 64h ; Get KBC read status
) S, m) [2 t, J8 t+ H+ l+ k - test al, 02 ; See if buffer empty, bit 1 clear
O, m% c; V* u2 }# u' h - jz clear 8 m2 T9 B8 z0 Y- T! Y3 J k
- dec cx / m" k5 F4 Q" b+ O$ c3 e" ^
- jz exit3
! S6 q9 n3 v& X( m* v2 s6 n+ E8 p - jmp SHORT get1 8 O$ E$ N: d% ^4 c+ n: ~4 _
- clear: inc al ; Clear ZR : q( O1 A0 k9 C" O
- exit3: ret 3 [4 l* M7 I% [1 W; Q
- " ~2 C8 o# T( r B) y
- 0 [& ?1 V+ H$ V6 w8 f7 i1 `. X! ]
- A20Read: xor cx, cx
6 B: ^" t; o: x0 t - get2: in al, 64h 1 i- B( C* V$ I! K0 t5 Y
- test al, 01 ; If the 'output buffer' is full, has & s5 I- k$ R3 e# y( a: \+ x" S
- jnz exit4 ; something for me
$ u! A! }, Q/ T& e/ E - dec cx
5 n4 P7 X7 x2 n- i$ L' w* D - jnz get2
* K, I! o6 z5 t3 e. m% E - exit4: ret a8 {5 K L( ]1 Q; |
-
0 w& d, y i1 ]) ?/ |9 L! {& i - end
复制代码 |
|