|
|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM
/ g6 D) J% m! }3 a0 O8 R8 A( b% p - ; 2 @) E F/ p/ T, O
- ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-012 b2 B4 i0 u; g6 i2 b. ~
- ; ml A20ON.asm 9 k8 n9 `" J8 l1 S3 E6 _+ O
- ;
6 G5 V* S9 R {, P( X - .model tiny) C8 N) @0 G/ I. X
- .code
7 I; D/ {, [ d; U* l" o - .4866 L4 O' |4 L/ d+ R% A
- .startup; S& ]6 v9 I1 ~
- 6 R+ ]4 o2 T& \+ ]8 b e9 t) b
- mov dx, offset msg_author
; x. O8 U. l. Q2 c1 X2 ? - mov ah, 09h
4 I. U) S' x3 q* d - int 21h
, d3 |9 u) ~3 }' K% S1 l& A - . z3 n$ f# z: _3 D% k
- mov dx, offset msg_fail ! m4 I* ^ Z5 d; G; i# E% X+ m) \
- call A20_ENABLE6 u% O+ Z7 o. G# l6 D# A, y
- jz exit11 ?! }. D3 c2 T. Z3 e+ N5 [
- mov dx, offset msg_ok 7 l7 G( J5 n7 u+ z+ `
% Z; H) e, z; ^# O- exit1: mov ah, 09h 7 q' d! y6 a1 ~ ~
- int 21h & j$ b) r& A4 Q T2 A1 p/ m) r" ~
- mov ax, 4C00h " v0 F8 q( ?) C1 K- f/ C* {( K
- int 21h
' ?0 N; N& x6 x6 J6 f - 4 I( U6 u+ i$ j1 `
- msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,
5 B6 k( _4 h# n4 Z/ j: | - "2008-07-01",13, 10, "$"
* x7 Q; M* e9 ]) n. o - msg_ok db "A20 Enable OK", 13, 10, "$" 0 _3 n' a# L7 C
- msg_fail db "A20 Enable FAIL", 13, 10, "$"
. p9 o$ M5 p/ a, N/ m
' @- E4 B- t/ _' t- ;------------------------ follow code maybe make to lib, if you want...-------------------------------1 s# @. K5 i7 \3 r% g
- A20_ENABLE:
: A9 I5 E! p2 Y, n- c/ D - call A20Write 6 Y6 ?4 n) V X/ {( {8 k
- jz exit_enable3 `7 ]! c/ c8 I {- x
4 R$ L3 m- A* Q- cli ; Only need for reading value from KBC 5 B6 G: X6 N' r: J+ s
- mov al, 0D0h
+ m& @" r) i& [" o/ r - out 64h, al - q7 t; z* m0 v D v: ~
- call A20Read
8 H! | O: r* H - jz enable_int & @$ z, h3 m6 W/ E1 D# k( y( M
- 4 b6 ~* E# j7 |9 M7 ?
- in al, 60h ; Get current status
) Y) q+ `) P% A0 i* k* h - mov ah, al 9 d X4 a, J* z G3 d; `& U
- call A20Write
! a* l! q1 }* o" K I4 x - enable_int: sti " J. J7 N/ j( V3 W9 P* x- d$ w
- jz exit_enable
% G2 |, `6 X1 W/ b; y C! i
1 [$ e, g+ X+ s7 d3 |0 G- l, N- mov al, 0D1h ; Tell the KBC , want to write to the
7 i1 @, V* g0 x# {3 O) z) t2 S - out 64h, al ; Out Put Port next
7 V9 W; _3 Q% s% l2 M7 [6 ], ?3 m - call A20Write & \$ H6 O9 N* P( m1 }& M
- jz exit_enable
F) @: T+ U W% Y( Y0 D - " g2 N8 h3 k7 x& v9 ]& K( {
- mov al, ah
' l7 f4 B- i% e6 }% X - or al, 2 ; Enable line A20 / Y1 z+ D$ g8 C$ E! b2 A- o
- out 60h, al
- i* Q1 G! E9 U0 c2 E3 g - call A20Write 8 [) H+ G' u$ e/ ^ d W
- jz exit_enable
" ], m9 y% C# A3 j d
* q9 W; U6 u l# u s. l- mov al, 0FFh ; NOP
, I: |" ^' B" v4 o, ? - out 64h, al 7 y4 I# y/ d1 D% q. x5 [
- call A20Write
, W9 p4 {+ L% J/ c- O2 p$ P$ A
" L( n, s$ Y# }0 W& i; C- exit_enable: ret . \1 ^* A4 R, k' A( E: u+ _
# h# W2 b/ x: t& Q' T- A20Write: xor cx, cx ; Reasonable wait
3 g! }8 T( F! d! v0 V4 d6 D - get_wirte: in al, 64h ; Get KBC read status 6 t+ W: Z- o7 t/ L7 K2 G5 [
- test al, 02 ; See if buffer empty, bit 1 clear
8 G9 D. x9 E" I5 ?$ p1 `" U/ X: D - jz clear
2 t1 f7 q! ~- n3 N6 @ - dec cx
4 |0 T/ u% z$ s7 i8 }3 | - jz exit_write # W1 r2 @/ H3 A; Y% _8 c% v
- jmp short get_wirte * d* c" J5 ^* ~$ @( \" V4 |
- clear: inc al ; Clear ZR * ^0 v1 q# K- i6 Y& @
- exit_write: ret
$ Y) s6 b$ T! `0 j" ]! ~ - : w4 Y ~3 F& l
6 j Y3 v# q- T$ X! Y- A20Read: xor cx, cx / l: X' m4 R K5 l6 P
- get_read: in al, 64h 5 h7 I) i# A. {! R" i, X5 ` b5 T
- test al, 01 ; If the 'output buffer' is full, has
% G! W/ G2 ]9 k6 U* S/ J7 K$ `( q - jnz exit4 ; ...
( h( D$ Z/ e8 Y1 {5 Q - dec cx
7 c! D2 y* i0 ?+ f k# D1 H5 i6 l. S - jnz get_read
1 A4 ]9 @! f4 r- s - exit4: ret
2 v) F3 W; W8 Z- z. x -
; f" c5 H, R+ i: Y% h - end
复制代码- ;A200FF.ASM / Y1 m' f% T( ? u7 n+ T
- ; + N z4 T( _1 P& v" E& C% H4 H
- ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01
; D% ~ s$ ]/ B/ K+ \: D- B' m - ; ml A20ON.asm
( E4 D+ I7 B9 A) C - ;
# l f+ E2 [9 o# w6 L7 S- ~ - .model tiny" n( ]+ q' c* C; z4 E1 L
- .code8 F/ q5 g% @3 c, r
- .486 }3 |* R/ t3 m* F+ Y7 c+ o0 m0 E) b2 G
- .startup
" v) r4 z- k* k0 V2 o, L( S - & B2 ~4 p& u5 s, f) @$ Z
- mov dx, offset msg_author2 A# N# y8 N7 a, g" L& F, O
- mov ah, 09h# Q8 A. n& {0 f6 t
- int 21h
( S/ a: k% e- U1 {- @
" i; J/ T) q& \* {; L. c: x# L$ [+ M- mov dx, offset msg_fail
) {$ u5 U& S3 |' z9 J2 K - call A20_DISABLE( z, U* L+ {$ ]) Y3 T) u) i
- jz exit1/ t+ K8 h8 P7 V; E; [' p L L
- mov dx, offset msg_ok ) x# {6 _# {, Z! f/ f
- c+ W) e2 Y( ~: Z% S2 e
- exit1: mov ah, 09h
& B6 s* k& Z+ { - int 21h L' j$ @: `% C! k- `
- mov ax, 4C00h : S# N$ j' N& o8 e
- int 21h R( V& x/ n+ X. F0 C' j
- * l! v M$ f* v
- msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,
" S; [" R( _+ T3 W/ y/ c - "2008-07-01",13, 10, "$"
k$ m3 I t) z' k - msg_ok db "A20 Disable OK", 13, 10, "$"
; F6 o U3 t) k9 f, E- g( x - msg_fail db "A20 Disable FAIL", 13, 10, "$"
8 ?. T- f2 E+ e4 n% C
6 |& [. b; O2 C0 ^' ], x- ;------------------------ follow code maybe make to lib, if you want...-------------------------------5 k( Z- d- z5 b$ _( ~$ o: X8 f
- A20_DISABLE: . c" M$ O8 G+ E: N2 ?
- call A20Write ) e& z2 L3 _3 q2 H2 ^
- jz exit_disable
4 f$ m0 G: o9 D, X5 B9 ?/ ^4 |
3 L0 r0 Z# z: w' `3 \# g6 ?/ R/ p- cli ; Only need for reading value from KBC 5 g4 x( x; I# a/ r: _1 c% m
- mov al, 0D0h
% X; g1 W' l* j$ | v2 Z - out 64h, al
6 ?6 B# ~4 o, F9 h3 C# h - call A20Read ( v4 N: Z+ e; q9 b2 s
- jz Disable_int
/ b/ d }$ ?1 _; ]2 w
2 E* }0 R, o- k$ v5 l/ R- in al, 60h ; Get current status
5 q& _" n2 w7 p, b- Q, u* M& w - mov ah, al ' m- p5 A0 Z" p
- call A20Write 2 ^( g4 |0 B: |( @4 a- a
- Disable_int: sti
7 k( ]/ T3 d( A( C& f1 D+ r - jz exit_disable
7 [$ h* R; X$ |; U2 U
' [1 h* z* W K& I. Y+ U6 w- mov al, 0D1h ; Tell the KBC , want to write to the
; ?7 P# J, \. m5 J& K - out 64h, al ; Out Put Port next
. ^7 C" {9 W0 ?- E5 j - call A20Write
4 c9 f. i5 c1 r, K - jz exit_disable& R/ C- r3 O2 z# K: _" W2 t( ]0 y2 X, }
4 P$ g: |4 U2 f( Z5 G5 B- mov al, ah
( s# U% c( [1 G* \1 C' @ - and al, not 2 ; Disable line A20
7 K1 I8 N/ |8 ^* f0 Y- V1 G - out 60h, al " W1 `% l6 I( Z V& I
- call A20Write 9 l# d( [+ q c+ y) A! I1 A
- jz exit_disable7 G& N, _" O# A, G8 v
6 a9 m( b; F/ f- mov al, 0FFh ; NOP 2 q# X, ~( E! p* z3 x/ }( e
- out 64h, al
4 ]5 t' _" n! E) b m - call A20Write ( J0 {4 g8 R8 s' F6 E* K
- . V& }$ R6 c: c9 E+ @# G
- exit_disable: ret
# f$ }7 A+ t- Y - ; D, A8 ^ j b9 e2 q7 L
- A20Write: xor cx, cx ; Reasonable wait
" T" b0 u9 ]# ?% S - get_wirte: in al, 64h ; Get KBC read status
, i. w+ q/ Y# ~* u3 @3 M$ } - test al, 02 ; See if buffer empty, bit 1 clear
! E' S& s2 g" U' h( {4 o - jz clear
, r7 w. E$ {) S2 ^' k6 k - dec cx 6 m' V6 m) @5 k% B3 @3 E; S) z# P
- jz exit_write 5 O; d8 m# u, m e
- jmp short get_wirte
; Q( |! I' r3 c. o( K$ s - clear: inc al ; Clear ZR $ O: C+ s5 n. i; k" D
- exit_write: ret % F+ s$ n* { Q9 X
- 3 a5 t' h, e3 S" A x' x
- # i, G; t0 c. G- P# O6 A. n
- A20Read: xor cx, cx 7 F" m' z$ Q5 R" z
- get_read: in al, 64h
2 C! a. x+ O# t2 Y+ t g - test al, 01 ; If the 'output buffer' is full, has
! I, |0 h3 P) J6 v9 Y' ~ - jnz exit4 ; ... ' {3 e" {! M" } E6 d; f- V" [+ i1 G
- dec cx
$ P/ ?5 H; _, |; U' g - jnz get_read
# z6 n. U% k! C# B - exit4: ret % N- i, _: @( e1 Z% E) w9 ~. [
-
7 D9 V: F1 V1 N% X( } t, O - end
复制代码- ;A20STATE.ASM
" z* y& q+ @4 ~ - ; 8 | _3 X$ ^8 T0 G8 Y6 O4 k8 P4 Z7 c+ V
- ; Returns the status of the line A20 through the KBC
. g, o# A; {% w- |+ b9 h% d - ; programming by bini for debug. 2008-07-01
6 @2 g" q" l% {0 p! ~; p - ;
) x3 l# k$ B* B# e - .model tiny9 w) P# `: h7 t L
- .code
1 H' N8 u4 v- V! V) | - .486
S; B$ X E( T/ B - .startup
# w2 ?. g( u! n; ` - mov dx, offset msg_fail
1 O/ E- G8 V8 [6 F: W - call _GET_A20_STATE_& j7 z7 Z4 C$ \/ t3 ~5 k
- jz exit1 ; was a problem5 ^! u& ~6 a- h
- push ax ; Save state, AH # B2 S! t8 H% T# j9 d
- mov dx, offset msg_ok ; There wasn't a problem
9 w* o* z5 Z) R* @' Y2 h. }. ?: B - mov ah, 09h / u v0 k" w, x2 w# b
- int 21h ; Print message
! ?' }; _( N, k3 x6 ~ - pop ax ; retreve state * v9 V8 h! d; i
. E; ^; V9 E# c, n( F! w5 \- mov dx, offset msg_dis
. [% a& p8 Q( r! _ k - and ah, 00000010b ; bit 1, 2h, indicates state 3 f, d1 P& A" n$ N
- jz exit1
( p8 x1 A9 p6 j; k* z6 a/ D - mov dx, offset msg_en ) {: E# o; n% L$ `% `
5 ^5 D" ?( Z' Y- N4 Y* }; ~- exit1: mov ah, 09h k1 k+ l8 n, d/ V# R8 m0 o# S
- ; DX already contains address of string
. X+ r `( j' [0 ?: n - int 21h
5 ^$ j% V6 H! V9 l8 N& e9 ? - % ]5 [" O5 m5 |) _, i4 v
- mov ax, 4C00h
4 D; K0 C- S' `* P2 ~: Z2 b# K - int 21h
~' _5 D; t, K# w! n1 e
0 T2 s: k% p2 J- F; W9 t$ w- msg_ok db "OK", 13, 10, "A20 $"
% e) `) q. ~, P5 D$ M1 V8 c+ d - msg_fail db "FAIL", 13, 10, "$"
: E: |# N- S- v5 j( I' s - msg_en db "ENABLED", 13, 10, "$" / U$ [3 P- J: ^) a
- msg_dis db "DISABLED", 13, 10, "$"
5 E2 d! s/ n' L
6 Q4 F8 o7 I) x' |4 N! w$ s( o! A$ X- ' c" d% u: f% v" `! z9 t
- _GET_A20_STATE_: % \( @+ [% |' T$ x. p: u7 \
- call A20Write ; Wait till the input register is empty
v/ V s4 k9 L7 `# f" I* X# l - jz exit2+1 ; Bypas the reset int's
0 s% S- K9 n" t! v* N7 E - cli ; Disable ints so we'll get our value 4 U, b$ ?- e F' z2 n/ t
- G" \2 ^2 V, }! O- mov al, 0D0h ; Send command to the 8042 command register
: P" Q0 U; E6 y- ?) d1 R# q0 C - out 64h, al ; to tell it we want to Read the Output Port
7 [7 A2 G) _3 J' v/ L) H! {: P - call A20Read ; Wait till the 8042 output register
" N. P/ S" j5 e8 L5 {3 N* d - jz exit2 ; has something in it's buffer 3 r* ]8 E8 t- Z, T2 H
; G2 o. Q9 F( J! J6 V3 Y- in al, 60h ; Get it 4 b4 V! j/ U# r; ~/ z
- mov ah, al
+ D4 k8 k* K# V; A2 r( R# J# h3 ` - call A20Write ; Make sure the input register is empty ) [! i/ R( j0 j0 w; r) \
- jz exit2
% e9 p2 n+ x4 @8 \, i - " @- s0 R: g1 f! _, R; j
- mov al, 0FFh ; KBC NOP command, does nothing
6 A6 x k0 H( q @ - out 64h, al 2 _; Q" W' \8 \8 {) w4 v
- call A20Write
% _& ]- h! r2 ~4 w, r& k! t5 i% f
( d- f+ [+ `8 f& w- exit2: sti
: w5 ]7 U9 y0 x9 Q - ret0 J0 R k/ p: E
3 \/ x& o1 J; r! F8 c8 Z3 G
! }% q1 b+ T4 Y4 q0 y0 m2 }: j- A20Write: xor cx, cx ; Reasonable wait
$ U2 C' ~% v# ]6 s! e - get1: in al, 64h ; Get KBC read status 1 P r# p& |% D; G/ v7 m
- test al, 02 ; See if buffer empty, bit 1 clear
; F* V7 c3 P2 B. v( E' _ - jz clear
! B7 I. L1 \! \ r - dec cx 0 h$ o) ~/ h7 n1 E
- jz exit3 : i+ h q, {" W9 {
- jmp SHORT get1 ( i' A: L& m& ~+ o7 k6 ?9 w6 _
- clear: inc al ; Clear ZR
* a% ^+ B) ~, K- S - exit3: ret , {& U7 D! E2 J9 ^
: ` o7 K! M$ e1 D& }$ U1 S8 f- m- ! ], l6 b+ a. I( V5 S3 _1 y0 S/ s- v
- A20Read: xor cx, cx
$ m; q p( s6 s8 q - get2: in al, 64h - R7 ^# D; B B4 E' M& {2 Q% u9 ~
- test al, 01 ; If the 'output buffer' is full, has
' E. W# w, i) r m - jnz exit4 ; something for me
( i6 ^0 G" ]& j8 o/ E0 e5 K" Y$ [' y0 a - dec cx & \4 _# }' A( m% y% d. w6 l$ X
- jnz get2 W+ z7 \$ K9 I- o( }1 A
- exit4: ret
' Y7 z* F2 w, a7 L - : l6 ~# a3 s6 c5 r4 u
- end
复制代码 |
|