|
|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM
8 l: L( u% t t; @. Z5 `& }: `+ i - ; p0 Q' H) h$ b0 K" q+ @
- ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01
8 S. Z% L' e3 `3 _; {4 K) f) U - ; ml A20ON.asm
# _7 a/ x: f- h" S) O" I6 n - ;
# _0 @5 K7 u0 @0 ^- H - .model tiny, i* S# x$ i0 F3 p/ ]7 [7 c
- .code
8 j/ K2 |0 f: \ V6 @: Q6 ` - .486* W: y2 n6 G# [! P; F
- .startup
- z% s Y' V4 X
: n% x9 U5 ]+ D; [ N, W, j- mov dx, offset msg_author% U. U+ y* i4 |6 J; ^* [
- mov ah, 09h5 \2 u9 J" r, z4 Z6 O# Y9 C- N
- int 21h
% X' l m% q1 n% X: V% \+ O - + e0 s {3 K3 `, J! F
- mov dx, offset msg_fail 3 p \( W2 W, M) P
- call A20_ENABLE4 G+ l$ Y4 @# ~2 C
- jz exit11 b D2 y# u6 l" f/ g% G# ~+ R
- mov dx, offset msg_ok ! H* H& g* U+ ?2 A3 _
- $ E# R! Y- g$ z
- exit1: mov ah, 09h
4 U- G8 r9 J6 o7 j# Q. L0 c( ] - int 21h + [9 r# F/ G. j, s: s1 N
- mov ax, 4C00h 9 v, ~8 s% O- O% X. l4 Y
- int 21h 1 M: j# \* P' Z: G r
-
4 \% B: u! u: S3 Q# i - msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,: v9 b: ?0 S3 V1 u0 f1 D2 g
- "2008-07-01",13, 10, "$"
+ P( [ B6 o* Z) M3 A0 R1 f1 x - msg_ok db "A20 Enable OK", 13, 10, "$" . n, ^6 N0 {' G8 A+ Y
- msg_fail db "A20 Enable FAIL", 13, 10, "$"
- Y, U( v" o$ w' z0 P - / u2 }) X! R+ j0 ^- _3 n' a
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------7 c6 J! s# Z4 q3 s6 u
- A20_ENABLE:
" W) h- x7 v$ P" d - call A20Write
' d7 S8 m, n( f - jz exit_enable0 a `% T* j# X+ S. L) J' j7 U
- + X' H/ l/ s# D# J5 ]4 s: U
- cli ; Only need for reading value from KBC
1 i+ C& [! H# h$ w+ N - mov al, 0D0h
7 T- C* V; a; } - out 64h, al
9 r7 N! A/ v: ~; m, t, K, [* f - call A20Read 3 V8 b9 ~: \7 s
- jz enable_int 3 o! J1 G0 i2 \; `
/ d9 ?) L3 _3 V3 }+ f. V- in al, 60h ; Get current status
. r2 p! z) X8 P& H+ \0 O - mov ah, al
. \; ?6 V p/ t - call A20Write ( ~' l% d' {- k' n9 F! \
- enable_int: sti
- n4 Q0 Y a5 D a3 M3 b$ } - jz exit_enable4 \8 P% J3 F Q/ x/ a8 A a
7 S1 @9 v- k c1 [- mov al, 0D1h ; Tell the KBC , want to write to the / l) Y ^7 V# d: l, p' R7 I
- out 64h, al ; Out Put Port next ; A& b' _& ]4 U! {, D
- call A20Write
, z2 B; l h) b+ S - jz exit_enable; H; B; L+ p* y1 @, j, N
5 C) A. L* `% N" j- mov al, ah
9 f) B5 j" i2 {" T6 m ^ - or al, 2 ; Enable line A20 1 i+ V# c/ r |0 j( H; N* A" [
- out 60h, al ' v; D& _' S1 e+ _: {
- call A20Write
5 Z% l8 o1 l4 H0 ^6 ?/ S& g! H - jz exit_enable
" e% L A) [- @) j. R - - K* K. X, d# \2 J, F+ v P
- mov al, 0FFh ; NOP
6 a! |6 H( J' V3 w8 f8 r" L7 _6 U - out 64h, al
. @. l; S O$ o/ g. u" G( c$ {' |7 U - call A20Write
+ b# c; E' v+ z
; Y% u }" G# C2 s" ?" c- exit_enable: ret
' r- @3 z5 N7 D5 v - 1 q. W$ Z1 U; z' X3 |
- A20Write: xor cx, cx ; Reasonable wait 2 D' M, \+ B! t; i* ]: g( g. @
- get_wirte: in al, 64h ; Get KBC read status ) y! }3 i+ I7 c/ R# Q& ]0 T* L1 s; t
- test al, 02 ; See if buffer empty, bit 1 clear
5 }$ N, n( f9 M - jz clear
$ ^# U/ b/ H6 }8 a( @3 b - dec cx
: U3 L# y9 G3 b$ T4 p/ A! f$ [# ] - jz exit_write 7 o0 y/ l) K. o# c. s; h G; |
- jmp short get_wirte L' U4 _! N: H3 I) ]
- clear: inc al ; Clear ZR $ ?- \: Z; V" s6 C4 y6 @# s: g/ h
- exit_write: ret
3 b; R! Z6 m0 x% h8 {) o) ? - . t/ B: h6 C/ v% \
- ) M; f, M5 `$ J) K1 u9 M7 T
- A20Read: xor cx, cx
" Z* W4 F* A# f! Z& Z/ Z2 C8 i - get_read: in al, 64h
9 ^- V, q' t+ q/ Y/ R6 h$ a - test al, 01 ; If the 'output buffer' is full, has 6 c: G3 {) ]" I$ L% O9 t8 V1 k( t
- jnz exit4 ; ... + j' ]) U6 k1 T+ D2 c
- dec cx $ l( C9 K+ h6 w* f, ?
- jnz get_read
! x" A! O9 |9 }" h& E7 l5 y - exit4: ret / |' I; A6 b: a, G0 z' E! m, f" |
- 7 w& ]. y! O7 O
- end
复制代码- ;A200FF.ASM
( h2 q$ @8 X, f0 t2 c - ;
3 {2 Z' I. s$ R9 D! G/ [- y" T# L - ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01. l# [6 F, l$ H! B o4 M4 g
- ; ml A20ON.asm 6 |* H9 J) m- d; ^+ x6 w) g7 x
- ;
- n( }8 N" G, @ - .model tiny
* E, e8 N% ?4 l - .code
# U8 ~* j- j* D0 H! y - .486/ d5 A4 V; M; I; g) k, I7 N
- .startup2 Z7 _. E# P/ c
- 3 z" L3 W: ?2 x6 K; A% k
- mov dx, offset msg_author* G0 P; _% [: u7 p7 j8 E. x
- mov ah, 09h4 ~( j) N6 A$ q! i6 L0 i
- int 21h# o0 \. x; p; M7 b
- : Q/ U. Q, }2 |& |
- mov dx, offset msg_fail
2 O3 I3 B$ k8 b- @( N8 Q - call A20_DISABLE
, B, @: v$ b6 S8 j% s7 Q* p - jz exit1
7 `' B. u" g2 ` - mov dx, offset msg_ok
; A4 T( |, v; G! I( [2 k
: M; I+ w. L8 O& F0 \- exit1: mov ah, 09h
+ K! z) L! v% E8 L+ ?- v( ~0 o! ` - int 21h : j. r/ Q5 c5 i2 Y
- mov ax, 4C00h ! h# W6 `' \6 T# U* j5 \
- int 21h : ]; t8 |5 y5 u: z' ^
- " I4 F0 G) j$ t' `& ~5 \
- msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,
/ H) }1 U; `, Q% T p! |$ T( A - "2008-07-01",13, 10, "$"
0 N. J( S9 \0 N5 {' I8 ^ - msg_ok db "A20 Disable OK", 13, 10, "$"
5 r# \) V% J7 e( @" \3 @: r' A - msg_fail db "A20 Disable FAIL", 13, 10, "$" & e( e* L+ [% J, C. O& {; f
- % M# l" [1 j+ K# t: V
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------( x: G1 ^* z% k2 S7 q+ ]; o1 e& V$ N
- A20_DISABLE: ! N6 C& P. U& H2 w. \
- call A20Write 0 {% b* ]9 l8 {4 H
- jz exit_disable& c+ g* K0 y. l& o
3 a) K$ I. a P5 i4 g- cli ; Only need for reading value from KBC
. W+ _, A) P$ n- E9 o' k - mov al, 0D0h
?9 W3 Y- M3 _0 j - out 64h, al 8 @4 [! N6 T' h' L, [
- call A20Read
7 }# X: Z3 T3 y, R9 b' [; t - jz Disable_int
' Z1 ]. s$ y& ^ - * n# Y7 u, q9 J% U! c6 [4 c
- in al, 60h ; Get current status
$ H! k7 x. z" g2 r: P) ], e - mov ah, al
! o/ g" t' @) ^) p5 m - call A20Write . {0 r0 M q; n! {$ r) a& i9 i
- Disable_int: sti
! B. k3 D: T6 Z# ]/ _+ R2 E - jz exit_disable7 R+ `) {3 A2 {# l7 Y
. G. g0 x! [: s& J4 R Y- mov al, 0D1h ; Tell the KBC , want to write to the
4 G+ C( B( i9 m2 q: v+ I - out 64h, al ; Out Put Port next 4 N4 p; L0 b" E" L* T
- call A20Write
( X0 I$ N4 g' `# U9 ] - jz exit_disable% ?9 j4 N) `4 X+ P y* Q" j5 Q( y) Q
- $ o) ~8 J: i+ A5 i2 w) K, r' r# t
- mov al, ah
; f: C3 _$ M/ }! d0 U - and al, not 2 ; Disable line A20
/ L& o6 Q4 b; g' @, A. @; U - out 60h, al * u+ t( [- |" @$ q+ ?
- call A20Write 8 i$ ^0 g$ V4 L
- jz exit_disable0 b) Q; @/ d& T6 Z# _) v
0 a& t2 k% s/ X$ A9 D- mov al, 0FFh ; NOP ! r. R6 t4 F4 R9 J2 N! V
- out 64h, al
; r" N) k# d, `; s* o* r5 v - call A20Write 5 o8 ?* F9 U; R& s& T! D
- # G. k0 Z' x& G0 h5 V
- exit_disable: ret
4 G. j1 Q3 }& b4 ?" F- v! g) B3 G - # o1 |* j- j. B6 H& Q2 q
- A20Write: xor cx, cx ; Reasonable wait
6 i8 G% b! I+ A- j5 j1 Q - get_wirte: in al, 64h ; Get KBC read status
1 b5 ?" i9 ?$ R$ L7 `) A - test al, 02 ; See if buffer empty, bit 1 clear
: {! _( |! L3 a3 r0 ~ - jz clear 0 O& n$ q& r+ l% ^! b
- dec cx & U- n) d# C% V; n; c9 s: |
- jz exit_write
1 v- X; q/ ^$ r$ t( V. l% E/ q; H - jmp short get_wirte / i6 x7 z: }. F2 k# D- x3 n
- clear: inc al ; Clear ZR 2 o( b) J# g" N
- exit_write: ret & w% o: G: q3 e
- 6 d5 K7 e! o/ m! l: D
- ( T( d* ]1 K8 W% j3 D
- A20Read: xor cx, cx 0 b2 y4 \" G/ |9 d7 U8 S" \7 D
- get_read: in al, 64h , I( H+ T m! _7 h5 x' v" C5 }
- test al, 01 ; If the 'output buffer' is full, has
7 j2 x1 T! o6 ~; ]* z) @ - jnz exit4 ; ...
" q* E" q$ ~; K& ^+ w5 @$ m; } - dec cx 6 W; J( d2 ^8 h, b
- jnz get_read
1 `7 m, K) @; k+ \6 n - exit4: ret : { o+ O% z5 a" w4 ]* Z
-
1 w ^: F* v; U$ h - end
复制代码- ;A20STATE.ASM * H/ q8 i# x) N8 I
- ;
* K+ L) ]5 `5 e% J - ; Returns the status of the line A20 through the KBC
' w* |1 B) X8 O7 A - ; programming by bini for debug. 2008-07-010 q' z N7 O# F* T( J0 ~0 n
- ; 6 @ F& @4 u9 L( ?- M" @, S( r1 z
- .model tiny
2 ]! R5 [' \( `; f- D - .code0 |. C1 V4 e$ P% l0 U
- .486: r* D& ^$ g8 _+ ^3 `, L& s) F
- .startup
d7 V& \/ x+ c - mov dx, offset msg_fail
- X. t2 B* v" Q* a8 J - call _GET_A20_STATE_
" o; \* j. i) Q8 Y/ M/ q0 B) Z+ H - jz exit1 ; was a problem5 I: L( C1 @& x% j4 \! [
- push ax ; Save state, AH
8 d+ b7 g6 D+ b1 f' a. }' | - mov dx, offset msg_ok ; There wasn't a problem
3 ^& B3 d+ P6 g - mov ah, 09h + Z5 ~, t" g; A; m0 }
- int 21h ; Print message + e7 M& r( V& j' g; V
- pop ax ; retreve state
: I! _; Z, N5 l7 Z3 S# { - . T X, k6 J# }' s
- mov dx, offset msg_dis , t1 Q1 g( C" A0 [0 _9 _% M
- and ah, 00000010b ; bit 1, 2h, indicates state 3 c! E. t/ |- `( a! }# j
- jz exit1 ) a. r1 N0 C% y& B8 K
- mov dx, offset msg_en - h. l' l! c) P
- 9 r, s; L5 e" U) ^8 X
- exit1: mov ah, 09h 4 T# E6 C- l6 Z7 H' o
- ; DX already contains address of string 4 s$ \* k( p$ @% C# }5 C. r) ?
- int 21h
- d4 q5 f1 @) K' p
& x1 H9 ~8 K0 W+ [9 m5 t$ j! L- mov ax, 4C00h
/ `6 ?9 V3 P% M1 r, Z9 Z) \ - int 21h
' d5 k$ s: E6 |3 {' B$ |% k. E: ~
. f0 k1 {0 R- E5 L- n3 H: ^- msg_ok db "OK", 13, 10, "A20 $" 3 d7 ~# {! g9 z& ^1 U
- msg_fail db "FAIL", 13, 10, "$" - D+ P3 m6 |! J! E( F( ]" b# h2 H
- msg_en db "ENABLED", 13, 10, "$" / w" I6 B$ x/ V6 ^+ O0 r% J
- msg_dis db "DISABLED", 13, 10, "$"
$ m% Z/ D) H( p- L2 K1 k* o
) U5 ]5 S$ I$ o. M% S$ X- / F8 p2 b- z" r/ ^% U
- _GET_A20_STATE_: + X" i p V5 d7 v! X* G
- call A20Write ; Wait till the input register is empty # [$ L! S, c8 a3 r/ u
- jz exit2+1 ; Bypas the reset int's
8 d. n% K0 Y; G/ f - cli ; Disable ints so we'll get our value & X- |5 ~& I# o' ~4 J
7 `; {! U3 s+ |$ ^8 r- mov al, 0D0h ; Send command to the 8042 command register
% G' |9 M6 u# b' y$ {: `3 O: \$ i( p* _ - out 64h, al ; to tell it we want to Read the Output Port " p/ K% c6 T2 A* A3 M5 I
- call A20Read ; Wait till the 8042 output register
% ?& P% g3 S: Q+ y - jz exit2 ; has something in it's buffer 7 C. v% X. `4 {+ t
* r( a( J5 T! J- in al, 60h ; Get it
" Q: A: N3 E% S* n, R% | - mov ah, al . y* T5 V7 r( R: C
- call A20Write ; Make sure the input register is empty
5 g+ M* v, o- v, |- K+ W' S - jz exit2
' D2 p0 Z/ L. i3 G( u1 p
3 R- D, r- o) Y- mov al, 0FFh ; KBC NOP command, does nothing $ k% G D' X( V" I8 s2 `
- out 64h, al ! l1 e, G4 R: q& T0 |* {- |7 W% o
- call A20Write
$ j& f* `! A# t( B* x b; ~
7 K7 w2 x$ i1 h! K0 \6 C- exit2: sti 7 e& v P: N, p! J6 W
- ret/ ~7 u d3 K' x; W0 ?2 N
- 9 d0 Z9 Y: f R. W7 T' a8 A
8 U8 w9 g( u+ d* {# R- A20Write: xor cx, cx ; Reasonable wait
2 t2 C* X3 l7 \3 x - get1: in al, 64h ; Get KBC read status : L" a6 y8 Q; W+ h/ a) n8 D
- test al, 02 ; See if buffer empty, bit 1 clear
, [: X: m5 g5 j! p& g3 E - jz clear ; E" M1 g/ ~" F/ j% i; w+ Q1 c9 j1 Z# K
- dec cx % F7 n) @: }) w
- jz exit3 & q0 g3 R+ |3 ]8 y! b$ `
- jmp SHORT get1 9 [4 F) E) J: q- ^# ` d% c
- clear: inc al ; Clear ZR
; I$ n( i0 a, c( J+ h; o - exit3: ret
! G4 j0 ?8 j _. X6 c$ ^: @& c - * v+ d9 C4 n0 P2 F( t
- * P I }& w* W& k4 q" Y3 {8 }
- A20Read: xor cx, cx
2 g! g7 q; e+ d2 y0 K+ ~: ?% @ - get2: in al, 64h 7 F. C) @; C, T6 j' d" r8 Z
- test al, 01 ; If the 'output buffer' is full, has
( a* d/ a. y+ ^8 w2 D l' l. T( C - jnz exit4 ; something for me
9 M7 N9 x) F2 a: l' |0 ]+ p1 t - dec cx 8 c3 ]) l3 U; ~5 o0 ^) f+ H- [# S. c$ I
- jnz get23 B" L. b# g- e) [
- exit4: ret / y2 n0 g6 r5 `8 C; Y
- # i$ y5 }' F" b6 E
- end
复制代码 |
|