|
|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM ! }% M7 M6 \" y- U' F
- ;
6 B7 x7 U# k$ g5 ]7 ^# J - ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01
; P3 _2 k" q- ?7 H - ; ml A20ON.asm " j4 U& P8 i8 m7 Y9 ^0 {- L+ B
- ; 1 M% p8 B m5 V' N( ^6 e' n6 f. y
- .model tiny: e( t/ H+ p; Z8 ]
- .code
3 _" h' G/ W- A' L - .4860 r! o* M: d0 {5 W: K
- .startup
7 ]7 F- [6 O2 Y3 \( s9 w: W - 0 H3 \5 E2 w! Z: a
- mov dx, offset msg_author8 o- ]# u2 `! `- ?( y3 ]2 g
- mov ah, 09h3 J( @- {( O5 U, h J
- int 21h7 [- G7 w" S: `" ~9 v% f, M
- ' }+ ~" y) l x2 ?
- mov dx, offset msg_fail
0 Y/ ~9 _0 `' G1 \ - call A20_ENABLE
: t0 I4 P8 x4 p/ R7 z* {; L - jz exit1; O- \" S6 j! a: _0 M- {6 A
- mov dx, offset msg_ok : X4 J6 X0 ?/ n; O
- / }4 N% Q8 t+ s- W
- exit1: mov ah, 09h
5 p* L# h9 n8 n6 A5 b+ Q - int 21h $ Y$ V1 l0 M$ \" b
- mov ax, 4C00h ; E8 M' |6 q E @& I6 p
- int 21h
" n T6 M* {& D4 g, ^0 a3 u -
* v3 P$ e- I, O. L# j3 h0 T$ O5 T - msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,
7 I8 X: ?4 e- V - "2008-07-01",13, 10, "$"
2 o; W5 P7 R" n4 H; v* D9 B - msg_ok db "A20 Enable OK", 13, 10, "$"
4 @! b7 r; l. s0 H) u - msg_fail db "A20 Enable FAIL", 13, 10, "$"
b5 W ?6 G: e. b5 g - 1 @0 j3 |: A! I. S z+ N7 H
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
- w9 n4 H, L8 e: O0 a - A20_ENABLE: # K' ]5 S7 j( H" A$ D2 C
- call A20Write , \: `: t: \4 E3 O$ E* j* T
- jz exit_enable J* A5 \0 Q4 k d
- ) d: L. f W1 E
- cli ; Only need for reading value from KBC D$ q/ _ e8 s# \
- mov al, 0D0h S4 k& w# N( T/ o6 z
- out 64h, al 0 g9 b& Q& c! C4 ^" Y# B
- call A20Read - I, K9 Q7 V& J6 k6 o2 ^# E5 S7 Z
- jz enable_int , |9 U6 R/ t' R3 r* ]- d
+ h d) P( j- L; l$ ^' f$ I: |- in al, 60h ; Get current status & s, H9 F4 ^( Z) I0 D
- mov ah, al
) b7 e9 z, L: N; m! K - call A20Write # L6 h% y E* A2 u1 n
- enable_int: sti
! ^. U& w5 G/ o4 l0 ]: c2 W - jz exit_enable# u6 Q5 h. H" s
, g; @3 y+ U' P! m: I$ p! D8 W/ M- mov al, 0D1h ; Tell the KBC , want to write to the
T1 C1 \ O! _" V ~) C1 d - out 64h, al ; Out Put Port next + G& _$ E6 v W+ H
- call A20Write
5 D; k- V2 E8 _) s" y - jz exit_enable2 Z+ Z' D$ w2 P# _
- 5 d3 I7 a' d& O- r6 x
- mov al, ah / L1 p9 I k1 O" a
- or al, 2 ; Enable line A20
, r! f9 T! j9 A! o1 A9 V6 F - out 60h, al & ^! A+ V+ {0 B* [9 G
- call A20Write
- s" u3 }$ W. E& \5 W - jz exit_enable
! E: q- ] v- D. |9 J - 2 O0 ^, I' p0 b8 l/ B8 a5 z
- mov al, 0FFh ; NOP ; n- m4 l6 o& s3 t) {6 h) c
- out 64h, al % _1 y' K# Q8 D
- call A20Write
/ M5 \" C) E7 O O, ~/ t - " k, T! q$ c0 }; p7 j; `9 G
- exit_enable: ret
# O+ M; c {7 ?8 p! c
- Y* `7 n+ m/ a- A20Write: xor cx, cx ; Reasonable wait 2 c4 b" ]0 m# o P6 f0 M N- o
- get_wirte: in al, 64h ; Get KBC read status / H4 a& ~: o0 m. P- w3 E/ r2 c
- test al, 02 ; See if buffer empty, bit 1 clear
, U! T; T6 S( A* q. p - jz clear
' S, X* b* ]$ K5 }! p7 j - dec cx
0 r, H. t s- L - jz exit_write
5 [# P2 a! q4 C& f6 _! q0 H - jmp short get_wirte
: O. Y- N" c, K3 I9 F( J: _ - clear: inc al ; Clear ZR
# k- X+ m6 n4 [) x4 p - exit_write: ret 0 U: ]1 z3 ^) ]$ ~. ~
- ( T n, R# P% k& B# [6 z2 R
- , h8 t @" I m7 R0 ~
- A20Read: xor cx, cx 8 v# Q; `& u' S
- get_read: in al, 64h
: V/ P! Y5 r1 t9 {$ |. r - test al, 01 ; If the 'output buffer' is full, has 9 U1 }. l+ o2 Q1 v4 X" }: e- _
- jnz exit4 ; ... 9 R. b+ `! g) k. Z; q
- dec cx
0 B6 X- o0 G+ |5 G - jnz get_read# x- i2 ]. m+ p/ a1 e
- exit4: ret 1 h9 N# W- L, W
- - c0 |! K# w* I; z. z" L( ` t
- end
复制代码- ;A200FF.ASM
8 N m7 m3 R2 z6 X5 e' ]$ | - ;
, [' }+ I; V0 d, H - ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01; t0 P& ]/ K1 b7 Z: m, p% a0 c
- ; ml A20ON.asm 8 `' y- P* b ?. S, o) V, u8 U$ d+ n
- ;
6 |0 `' F) H1 l9 Q7 x0 {5 i& V2 A - .model tiny- o5 M3 b- Z6 q) y
- .code$ l L9 n4 r4 |. d# V9 ^
- .4861 K: J. q, B! A/ i
- .startup
3 ~9 Q5 a1 d# z8 l3 `& _
+ }, C% N7 w: b+ Z- mov dx, offset msg_author
" x( j; u0 _ q6 A l9 l# U" H. W - mov ah, 09h& D: A- v4 p( u: E, a4 g- e
- int 21h- }& P$ O* z& s9 t5 }
- * J' U8 V8 v6 \6 k3 e: p/ \
- mov dx, offset msg_fail
! `9 m: }( R. s \! t - call A20_DISABLE
3 t+ J: V7 Q$ O5 {% m. ` - jz exit1
" W7 j6 I- p/ r; R* s - mov dx, offset msg_ok
5 B; X0 o; n( g) {3 t
' |2 b7 {& m# C5 z0 o4 P0 R; g- exit1: mov ah, 09h 7 b; V/ ?7 e% Z0 r W4 {- |$ R% }
- int 21h $ X' B6 _9 v: P- Q" }
- mov ax, 4C00h
; B* T# ^' m8 D4 ^ - int 21h
+ A7 P% X9 d, @. u2 H4 i -
* b+ `4 k& \0 P" q/ ?4 N- K - msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,
2 n' f8 c/ E. ~, W" J - "2008-07-01",13, 10, "$"
; {" l& U$ U. w! F - msg_ok db "A20 Disable OK", 13, 10, "$" ?# w* E9 N* ], c* O! L6 [0 f
- msg_fail db "A20 Disable FAIL", 13, 10, "$"
- e, e5 V9 c: R8 }4 K - 1 B# z9 |9 `& e! C/ q
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------5 I/ l& P0 Y* T. C/ J
- A20_DISABLE:
( X+ q8 `8 s0 [6 f+ D% P' k - call A20Write
- Z! i& c) C" A; [/ m9 u' A - jz exit_disable+ }. i \2 B/ Y9 C, M' q9 y
2 W1 {; N1 f7 V9 z t- Q, U+ u- cli ; Only need for reading value from KBC 1 Q" E& z! e1 ?/ A$ g9 W
- mov al, 0D0h 3 Z9 C3 ^' b: Y/ u5 g1 i- g
- out 64h, al 1 g2 _8 Z1 G& s: j# e" w
- call A20Read
- L$ }( y9 A2 o1 ^- V/ c7 z - jz Disable_int
: ^0 G* z- B! B1 g( D
~4 e' L4 K1 u* y3 `& N- in al, 60h ; Get current status
9 U' ?8 @, N" j - mov ah, al
1 ]; m# j0 b9 @& D0 y, } - call A20Write ' w1 |- H) {% Z7 ]
- Disable_int: sti # ]4 C- x+ G' [8 t
- jz exit_disable; y( d1 o1 n/ _2 _+ m* H0 T4 \
2 l; n4 F" M B: w- mov al, 0D1h ; Tell the KBC , want to write to the : |- ^7 D; t; ]& h2 z. B
- out 64h, al ; Out Put Port next . A1 v/ B. a: s: v: a
- call A20Write / M! {' ?$ m& p: G
- jz exit_disable
) ~; j7 Z! b: x2 ~( H+ j
. y- l. x# V9 g, _0 c- mov al, ah
9 n4 x+ C8 l; Z* {' { - and al, not 2 ; Disable line A20 , D, F5 R* w9 t: X1 Y
- out 60h, al 1 j* V6 T( Z: B0 Y
- call A20Write 8 b4 _( }; @7 n7 Q$ A
- jz exit_disable7 f8 j2 j2 |7 h5 m% k/ e7 p
% W' [9 p- d2 |, H- N u; [/ V6 m- mov al, 0FFh ; NOP ^6 {- h! d) a( u
- out 64h, al
9 v- t" Z. S# s2 V6 P - call A20Write
& m4 V& {3 }: j9 q# q4 X/ D# Z9 Z* N - 2 { V1 _5 N1 z4 a$ @5 D
- exit_disable: ret 7 {5 i t, D: R; ~
_0 g% ]' G7 }9 h- A20Write: xor cx, cx ; Reasonable wait
( \& H O7 e! v5 | - get_wirte: in al, 64h ; Get KBC read status * T& i% l8 z9 n1 I
- test al, 02 ; See if buffer empty, bit 1 clear 1 j5 _. G8 ?# C/ ]: ^# |
- jz clear
1 F, D1 O( _# j - dec cx
2 Z! I+ h c8 N/ e% A4 i - jz exit_write
* g9 B2 @8 Z6 Y - jmp short get_wirte " y5 s1 e- h- o7 P$ ], F. J' V- Z
- clear: inc al ; Clear ZR ; n# u l- }6 a8 D4 y8 z4 b4 p3 G
- exit_write: ret
9 B$ U8 L+ P& G- g2 M
1 F9 B/ X/ _) a6 m
0 X# U! T6 \+ K' E6 R4 k- A20Read: xor cx, cx
/ I' f5 P+ ~6 a/ o+ a - get_read: in al, 64h # ~4 ^6 v6 N5 a, L0 Z/ g
- test al, 01 ; If the 'output buffer' is full, has 6 w: U' s" N j, _6 C; o- N
- jnz exit4 ; ...
/ A9 V4 X( t" S) F) _5 f+ S% c - dec cx
' A" `- h, B& ]8 A2 ^3 T - jnz get_read
# i3 j5 M' @5 h. L - exit4: ret ( d, ~# }4 Z9 D6 d( l
-
* _. X# v" w c7 M" o; P0 O - end
复制代码- ;A20STATE.ASM + f: K- [; a" ]4 M; ~( d( ~' v
- ; % V1 w. N I- ~ p4 W. W
- ; Returns the status of the line A20 through the KBC
6 z5 J4 F( Y# o) U) K - ; programming by bini for debug. 2008-07-018 }! P8 L4 R: `6 U5 s6 `
- ; ( l! g- ~8 h m8 H2 Z: h
- .model tiny
, e6 Z7 h! o" C+ I$ N, r0 ^; _ A - .code% ~' [2 O- W m, g. _
- .486
) W- G) l/ t1 m8 K - .startup W! F- }( Z' Y' l" t% w' h+ [3 N8 |
- mov dx, offset msg_fail ; [/ Y( C4 a- S; q, K7 }6 g, P7 D Q
- call _GET_A20_STATE_
" s$ ]/ O* {8 `% D' a6 p8 g( @ - jz exit1 ; was a problem
/ Q& z4 a( V3 k. ^- b' K - push ax ; Save state, AH , Q& D" }' Z* W8 _) K! C! f5 j5 i% l$ u
- mov dx, offset msg_ok ; There wasn't a problem
% s! v2 ^$ O9 r - mov ah, 09h ( a7 Z6 j3 X6 X4 L
- int 21h ; Print message - F+ r* b$ p- m/ b5 y- K3 P
- pop ax ; retreve state
, d9 i8 o; h: x g8 r - ; ~; H5 ^1 d V. `3 g' x/ U
- mov dx, offset msg_dis
* V, M) t2 t5 x, T - and ah, 00000010b ; bit 1, 2h, indicates state
9 D0 E( M, D+ [4 R! k - jz exit1 ) l; [ a$ F! m! O; D& y
- mov dx, offset msg_en
+ i$ p0 o: l. s+ E/ J4 \ - " ^3 k7 X" Q. c% {/ k
- exit1: mov ah, 09h
; B2 i% L' {! Q3 o - ; DX already contains address of string ! ` X# R& N- \! m
- int 21h
3 K! |- l" k, a! ?& z
5 c) l; f9 B/ t% M. n- mov ax, 4C00h
. C$ K. J( s) R% D. ? - int 21h
7 v" G) H; a$ m# G - 8 H1 y' i1 u/ B- D
- msg_ok db "OK", 13, 10, "A20 $"
. O, `1 u- p! w- n5 C ` - msg_fail db "FAIL", 13, 10, "$"
( ] V" V" ]. z7 ^/ G# X# H7 i0 o8 Q) K - msg_en db "ENABLED", 13, 10, "$" 4 l; l5 }/ D: b1 C9 F
- msg_dis db "DISABLED", 13, 10, "$"- C; _8 `3 g! f3 Z' `; L M
5 a. \! \9 M" X1 P4 l1 L0 W-
& _% n( u" q# o8 k( C- x$ H7 F - _GET_A20_STATE_:
8 A# M7 z7 D; d! N. t - call A20Write ; Wait till the input register is empty
& N! y9 r# X8 l: n8 L - jz exit2+1 ; Bypas the reset int's % P" I. j! J* ?
- cli ; Disable ints so we'll get our value ; q: ?0 T+ a8 A: L0 \- E! y
- / m6 }" Y+ H1 Y% x( x) Z* j& F
- mov al, 0D0h ; Send command to the 8042 command register
$ f$ s; M( j: H7 U; J - out 64h, al ; to tell it we want to Read the Output Port 8 N% Z- O2 I1 q, I: d
- call A20Read ; Wait till the 8042 output register
3 o# D* F+ [, D9 L0 } - jz exit2 ; has something in it's buffer
8 v( Q' m8 ?& k/ f - 1 o: m' s, ^- x' q/ A
- in al, 60h ; Get it
7 z/ K5 X" A4 w* w7 H! | - mov ah, al
. c4 ], V4 B! h, H! Y - call A20Write ; Make sure the input register is empty ! l* ^1 y M* ^: w: q) ^2 k/ o5 e
- jz exit2
4 J; G8 t& h4 U: v! S m - 0 z; O3 o. \5 Q& A; q% |$ z
- mov al, 0FFh ; KBC NOP command, does nothing
, \4 W5 }* f8 I6 L- U: V - out 64h, al 5 E) a" j' J' W L) m
- call A20Write
, o1 {, l- |3 w3 ]5 J+ z6 a( \* v- L
! W7 q0 ~: q3 Y- exit2: sti 9 ^# Y8 R, m# F
- ret0 c4 `' b' X- Q
- ) S: p% g9 ]3 Y0 s
- # y* R9 O2 {/ d% J2 w x' X1 _1 }( o
- A20Write: xor cx, cx ; Reasonable wait 5 r3 N" X& D/ V7 M4 Y& V: t
- get1: in al, 64h ; Get KBC read status
# H# q, r+ d6 q: r - test al, 02 ; See if buffer empty, bit 1 clear 6 M" B7 a' Q- e% v( H4 w
- jz clear ! U; _! \7 p' j: b& _& m9 B
- dec cx 5 b9 A% b3 L; f8 A, x+ p* s
- jz exit3 * R3 A! H2 \, X# e5 z. i- u
- jmp SHORT get1 l; y. W; E; c
- clear: inc al ; Clear ZR 1 n. ~( \( V3 {0 L8 r
- exit3: ret
2 Z7 [6 F: ]. r/ Y: J1 ^( B1 g7 f
) u# n" e" p$ Y4 p# s- 9 E8 J" G; @& e" d( v5 h
- A20Read: xor cx, cx
+ n. A* ~* [- N2 T4 w - get2: in al, 64h : x/ o; w) u9 A7 T" G
- test al, 01 ; If the 'output buffer' is full, has
3 @$ v7 N' v X5 W i# X% T/ Y3 \ - jnz exit4 ; something for me 4 d% t7 H9 w# x* Z1 X
- dec cx
9 p% e$ A( m& ~- q# S - jnz get2
7 q- h/ h7 j4 O9 E - exit4: ret 6 u$ E# Y3 f$ H1 ]3 q+ W3 u, E. g5 x
- - F8 D5 f4 z7 N4 u9 ~
- end
复制代码 |
|