|
|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM
8 ?( s) j1 ]! u' k - ; / L- _4 |# Q, X) J0 {4 K
- ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01
! |4 r& A& Y, v. W- y+ d4 P - ; ml A20ON.asm
1 r; T. t1 f' B: v8 h+ [) k - ;
3 }- K+ b z! @3 D4 S1 p - .model tiny
! W: j' w9 X2 W* X2 I- J/ L4 T - .code9 r3 A7 E9 U% G. P$ S, Z1 [) r: f
- .486* o: g. ~- r3 o+ ^" c
- .startup
0 p0 V2 S5 \. P/ M8 @ - 8 M7 h* J1 d. G6 P; i1 n! W
- mov dx, offset msg_author
# k- M% D7 w9 Q& Z9 u - mov ah, 09h$ _4 ?4 ]. I ^$ b, x0 Z
- int 21h1 k7 S! G. l9 n9 k9 B
- 9 u. \# S- r9 d- o7 a' Q) W
- mov dx, offset msg_fail
- U% k; j+ T/ T7 Y9 Y) @& d - call A20_ENABLE
; r1 ~ I, L i) L1 B' l( k - jz exit1
$ V/ ~- a. F% ^& n1 ? - mov dx, offset msg_ok
/ c# W& ^. N1 l# t) H - 0 _0 f; h8 J8 _# d7 U6 _
- exit1: mov ah, 09h # l; ], D9 k$ W" V. n1 Y4 b; S. x
- int 21h
/ C3 b' v; X* q - mov ax, 4C00h
9 w8 n0 v: A3 c w; l0 f - int 21h
1 K* g* P+ `$ [' Q& h+ O; f -
+ Q p1 r* Z& s+ b, [, N1 A& J - msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,
8 I8 _1 f2 n, x# a+ F1 | - "2008-07-01",13, 10, "$" 6 y' Z$ |$ m. R2 n
- msg_ok db "A20 Enable OK", 13, 10, "$"
5 h8 U G5 j3 b6 i+ @5 g - msg_fail db "A20 Enable FAIL", 13, 10, "$" + h, i% _6 _: H' j0 a* |
( \4 F' ` F! X$ ?: j6 f- ;------------------------ follow code maybe make to lib, if you want...-------------------------------' H8 n- W2 p4 ?; z/ |2 Y
- A20_ENABLE: 1 T0 u9 S3 R0 j. F" ~
- call A20Write
, [2 W- w- S; Y) D - jz exit_enable( E N6 A" v+ {
0 f1 H2 |' d$ U, b- cli ; Only need for reading value from KBC
& `0 t8 p, N5 R8 S1 u - mov al, 0D0h : {: X* X0 U2 }9 S! _
- out 64h, al
- L, {+ R( F v) w" K/ \+ ]6 p - call A20Read
; A1 i2 [3 Y) k/ n6 R - jz enable_int : e! r5 v4 D! F# h0 J, e4 g
- % F+ T* @) ]8 T7 x! @% b
- in al, 60h ; Get current status , S5 Y1 r* W( w
- mov ah, al - g/ _5 C' l& E! ^; |* v/ v
- call A20Write
} F. `( o: t4 K9 X, b5 y - enable_int: sti ( u/ ]0 r. u N. Y
- jz exit_enable: Y) k% E3 G M- X) n( A4 B
3 F* S, O' O, q5 n- mov al, 0D1h ; Tell the KBC , want to write to the $ f& B" E7 G) G* O
- out 64h, al ; Out Put Port next 5 O' x) T) v$ p: _; H2 k
- call A20Write
* j1 U! j% `. V. c" H# Q - jz exit_enable
% s8 k5 q- K& `8 x6 G" [ - 3 e v& h$ n' V4 Y; \& K
- mov al, ah
5 a. _' I$ w R4 B4 h+ M ]3 [5 X - or al, 2 ; Enable line A20 ; Q K" h- G2 q5 ?2 n8 O& Y
- out 60h, al
2 ~+ ?* _1 m/ L3 O$ L' x4 o. Q - call A20Write
: a" b# I a: p) F! L6 Y* c8 V6 C - jz exit_enable4 K& l D/ a n! `5 w: A% t
- ! A* q* }8 D e1 I" W
- mov al, 0FFh ; NOP
3 F* Y# B: G/ Y$ v8 M% A; m - out 64h, al
- `8 B# c( Z. O ~5 a; g" E - call A20Write
" d3 _2 w9 G( |' J3 ^! ~
( C) h2 k" u( d: K! b- exit_enable: ret
6 @1 I4 [$ w. H
3 Y+ N5 I% Z9 j7 P% _9 c! E- A20Write: xor cx, cx ; Reasonable wait
0 d- q$ K( h3 Z% h0 \1 H3 g" V! ` - get_wirte: in al, 64h ; Get KBC read status
, r" d& [% \4 ~. _ - test al, 02 ; See if buffer empty, bit 1 clear
* G) C$ O4 @, U- D+ G - jz clear " q! P% K& `! G
- dec cx - X8 O" J; ^3 P7 i! T
- jz exit_write ; u5 K* v* H$ x3 x) z* V
- jmp short get_wirte
Y g( Z `! a, j; J2 R4 T0 p - clear: inc al ; Clear ZR
$ s2 O6 E% R6 d* A: r* n1 K0 m - exit_write: ret 5 [9 }0 t& ]% e2 r5 Q8 F
. |% c' i3 L5 A8 U, `
. e1 v$ Y* r% _- A20Read: xor cx, cx
: x" p) f' {$ w, @9 | - get_read: in al, 64h 2 Z1 s- r( j9 S* @1 o& k. ~% r: B5 e
- test al, 01 ; If the 'output buffer' is full, has " I5 g0 m2 R" g) d# L5 V
- jnz exit4 ; ...
& o* y9 x) K% g1 V% ^- M5 \4 b - dec cx ! L' X9 V+ t1 i7 w6 z6 c0 |: o
- jnz get_read
# ?4 D; F6 h B8 t; p - exit4: ret
7 Q( P2 D9 P; ?3 Z- Z - 7 {, }5 }5 s/ y& e8 M" {0 W
- end
复制代码- ;A200FF.ASM ) d; p, L' C E* c" f* @
- ;
/ I" i! n6 [* w4 s; I d - ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01! W9 }3 u9 y$ n' D% t3 g
- ; ml A20ON.asm ) _" [; H) J5 I5 s3 ]4 e
- ;
3 \1 C2 v' @7 L' R - .model tiny3 V! L3 L7 u8 a/ }
- .code7 p: r- E( B8 }" ~/ E8 C7 v
- .486
% T! d4 z% ~- ? - .startup
" X( }4 ?: b6 ?; E
2 @( x+ I. C |5 D# d- mov dx, offset msg_author1 _' d0 g& c& D" U! N' y
- mov ah, 09h
4 b* W3 d: w. L* D/ z - int 21h
- V& U( C: M' X, `: Z - . A' N3 y1 ?# H7 ?' b
- mov dx, offset msg_fail / ~- f/ X% k l# `- n- r
- call A20_DISABLE
$ t- T1 r: K' _! J. p - jz exit1; L* W" `* E' V0 Z% b
- mov dx, offset msg_ok
3 \, C C; h. ]1 s - 6 L8 \" D) e* ?
- exit1: mov ah, 09h
3 e+ X- R" G$ R; c - int 21h K- f- D+ B0 B4 Q# u4 W
- mov ax, 4C00h
8 i9 K! z( G! J8 ^0 O - int 21h
$ \4 c3 D; D2 N5 O -
2 Z6 ^0 F. R+ m. l* f - msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,
! P! F& a% I. E7 `# d - "2008-07-01",13, 10, "$"
- F4 F! u3 Y) L& s* R2 u9 }5 _ - msg_ok db "A20 Disable OK", 13, 10, "$" , G% ], O ^% e/ Y2 E ~
- msg_fail db "A20 Disable FAIL", 13, 10, "$"
* w0 ?, ^$ x2 Z4 O - % F$ ^2 `. ~" l6 V. }0 V' F% x8 @) |* a
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------. E/ j0 m# A4 D& \5 V/ W, L
- A20_DISABLE:
9 d8 E) T# _" b0 j - call A20Write 8 ^$ D' ~8 ~7 \' m# [
- jz exit_disable
" G" r. G, t, p& l% k
4 E( M8 W! Q: k% q& U7 M! N% s" j- cli ; Only need for reading value from KBC
5 ^9 `9 D5 P6 q - mov al, 0D0h
, [" ^6 R8 L$ x: X - out 64h, al 2 E1 Y$ x, K+ f# p: i+ x
- call A20Read
5 j0 M4 a) ]* T5 U1 F$ C2 u - jz Disable_int ; d* Y3 | f* d3 _1 }
- 8 N& j3 E( ~: s D1 m1 ]! d
- in al, 60h ; Get current status ( o3 d6 { V) ], s5 h
- mov ah, al T* x: x, i* y' ? n7 P) [2 u- B
- call A20Write : a4 E( `+ P5 N
- Disable_int: sti 0 s0 z3 g1 p4 s/ j0 [5 E4 B
- jz exit_disable$ r) r8 I( ~+ E( b4 I0 M
- ) k; C( z8 e/ { @( b2 C8 C
- mov al, 0D1h ; Tell the KBC , want to write to the 9 [; R, N$ g3 m) `
- out 64h, al ; Out Put Port next
3 o7 q: }/ M! r6 X& A9 }! N' s - call A20Write
9 P, U+ r K2 g- ?; H. U. E - jz exit_disable
/ o& [9 z' m1 n+ F
0 V2 U. Q; P z+ z/ @, f- mov al, ah
2 o: ]$ J3 \! A6 U1 ?, C - and al, not 2 ; Disable line A20
% N* m, X( ~/ T/ a h+ |! Y h - out 60h, al * L; s8 F2 R' V* a: }' F p, P
- call A20Write
U3 i/ d- w. Z; g' h* f - jz exit_disable
L* m2 s0 I# q
+ E3 A: V' _% F8 u. Y6 v- mov al, 0FFh ; NOP 7 W# ~/ _& ]+ c$ I/ B
- out 64h, al
( p$ _! h2 K) \7 K$ V. F - call A20Write ; D% O7 M9 r0 J# v q
- ! j) v% ?3 E+ P$ E
- exit_disable: ret
2 w5 d' a) @ E: z* ?6 v& A - + h& j* T( _1 n: n/ p
- A20Write: xor cx, cx ; Reasonable wait
$ S5 |; l0 ?3 u - get_wirte: in al, 64h ; Get KBC read status 4 s) U2 ^" a7 f3 c4 ~, c2 W6 ~6 a; q
- test al, 02 ; See if buffer empty, bit 1 clear
+ Z0 S2 ]: O0 j6 e+ _7 n - jz clear 8 T; P# L/ @' |9 E. W& t( y/ j
- dec cx
6 W0 k/ G- k: o3 E: @0 \! u - jz exit_write 9 k: b ]3 h* j* B5 F( S
- jmp short get_wirte
! g' z. n. m& a4 T$ t- i% G - clear: inc al ; Clear ZR
& B8 m: i2 C% g8 D. w* J% q+ s4 P3 ~ - exit_write: ret 8 d4 J9 X4 Z$ M2 J
- 3 r Z: I4 U; @) x6 E
- + x* ?+ n; X* m, _$ L a4 {
- A20Read: xor cx, cx . i; s9 a- O Q& Y7 y0 d. @/ h
- get_read: in al, 64h
7 @' I$ e% t# L p2 N& k2 K2 S9 ~ - test al, 01 ; If the 'output buffer' is full, has
& R! ^+ C: K/ Y7 k% k+ N - jnz exit4 ; ...
$ O3 C1 ^4 l! U! M" Q - dec cx
1 M8 l& m+ _6 o) {% @; X - jnz get_read/ T# a7 f% V6 @4 U8 Y; L, l H. N
- exit4: ret 3 o$ a5 P" X3 K% f9 m7 a
- 9 W# _- E W- g6 c5 n
- end
复制代码- ;A20STATE.ASM
+ I- V' m* ?" ^ - ; 3 r' w* b2 {) a7 L! W
- ; Returns the status of the line A20 through the KBC 9 W( X. t4 ]* i. m! z, F
- ; programming by bini for debug. 2008-07-01+ r3 s, X5 h3 t- E% }
- ;
# K' l. V* Y' L6 w2 w, s - .model tiny& B O: r& R a4 Y5 R+ r! x$ e' g
- .code
# U4 H& z+ S6 @$ }8 v3 Q! X4 U - .486
& S2 Q6 _% ~8 u( Q - .startup
. V0 k# m8 c, ? - mov dx, offset msg_fail
( `8 ^' l, ~: I( A$ O- { - call _GET_A20_STATE_5 z+ P- ^' b/ {* g$ B& {
- jz exit1 ; was a problem' n: j0 L/ L/ Q( C4 ^) L+ J
- push ax ; Save state, AH / {% q3 S. b7 X, O
- mov dx, offset msg_ok ; There wasn't a problem
. ]. [; l/ I2 {$ Q - mov ah, 09h
% H) I& P: z9 G. f0 H; Z* w - int 21h ; Print message / e- H. E; i+ n G
- pop ax ; retreve state
0 H" e9 h# q* n; |( S5 f; V
8 O& @! O# y& n: c# H- mov dx, offset msg_dis
3 R8 M8 f h" {$ M: M - and ah, 00000010b ; bit 1, 2h, indicates state
- ~* \8 O, V1 R/ ? t- u2 g - jz exit1 1 W) r8 z3 v5 x1 x# b8 D
- mov dx, offset msg_en
. {& ~/ ~) L6 Q" B9 w$ a1 e - + k3 ?( M4 A% ?
- exit1: mov ah, 09h
" q# z6 J% Z4 m a: m8 V1 ^9 V - ; DX already contains address of string
; G, O3 I6 a( o - int 21h
& U: [& g' B( Z7 f - ) P4 T1 n& K: q0 [5 c1 F1 l+ f
- mov ax, 4C00h , U7 t% N: T- o' N3 V1 I& }1 C
- int 21h % r9 F+ G( }+ ~4 S7 i6 t% T
+ G) t9 b0 G/ G* \- msg_ok db "OK", 13, 10, "A20 $"
) W# _; [+ e0 I3 s# L - msg_fail db "FAIL", 13, 10, "$" " v7 p. [+ H$ N
- msg_en db "ENABLED", 13, 10, "$"
4 j* U- n) [6 x/ v; l& R+ G - msg_dis db "DISABLED", 13, 10, "$"
9 E& Z' `/ i# x; a5 o# E - + Z. G' H$ Y0 C; h) H$ ~
-
, ? r% u- Y. a- @5 Y7 l3 X - _GET_A20_STATE_:
2 i. ~; i5 M, H, s, h* z7 P - call A20Write ; Wait till the input register is empty
$ U% ~6 Z+ T+ v' B M. c - jz exit2+1 ; Bypas the reset int's , O5 W& L: ] O8 b! S! i. a
- cli ; Disable ints so we'll get our value
- l7 `3 m/ j2 f& ]2 {/ F
1 N9 w: a) R* U0 i7 U- mov al, 0D0h ; Send command to the 8042 command register 4 D5 i1 p+ ^) ^ d% o8 ]4 e
- out 64h, al ; to tell it we want to Read the Output Port & F% e, F8 S/ J* Y+ j9 W- T
- call A20Read ; Wait till the 8042 output register 8 [2 t7 i7 a" V1 ?3 B# u
- jz exit2 ; has something in it's buffer
0 {* |3 ^8 X; f' \ - 6 p+ a* ^' C7 h0 u# f% x
- in al, 60h ; Get it 7 @# `0 t: E' b# H" j, l2 H+ y6 a9 Y
- mov ah, al $ P! p' `8 U d6 Y; e E2 ~2 c
- call A20Write ; Make sure the input register is empty
. @. L/ _8 g' l+ k0 p) W5 O- A - jz exit2 g+ C1 k( w7 X$ V8 V
5 J+ a' C+ q D6 H: x- mov al, 0FFh ; KBC NOP command, does nothing , k* K# V; d5 b* n7 H" B3 |
- out 64h, al
; z% S b- A% u: r0 \# D9 q - call A20Write * u1 b' p- c/ o! A
- - s& { |5 U6 x! }$ h7 u
- exit2: sti ) Z% O1 A2 [, N3 E) ~8 O1 J
- ret# V3 p$ {4 ^" l3 q/ t" k4 f
- ' e7 \) [8 H% r" N. N( f) q
- 9 h5 B" y. ^' `" l
- A20Write: xor cx, cx ; Reasonable wait
7 P# S/ M9 D7 B) e" Z! w3 R5 g) ^0 R L - get1: in al, 64h ; Get KBC read status
2 q7 }; J) v% D0 {) \# P - test al, 02 ; See if buffer empty, bit 1 clear
' T" y F% }+ Y! l! ^ I& g9 y - jz clear
/ g4 X0 Z0 n$ |2 j, `, g/ d - dec cx 1 Y/ N G, r+ [* E/ t
- jz exit3
) x, E7 ~3 K6 p2 R% M' Z b& u: R - jmp SHORT get1 * p( m" F t4 F/ Z* |% U) P5 C
- clear: inc al ; Clear ZR L$ J' I/ f$ w6 q& Z
- exit3: ret
! I* y! }6 b6 w- I( G2 g - . _5 g# l7 c. y
- 2 e7 _, X6 |! K
- A20Read: xor cx, cx
: {: q. R* k( h; w! H7 e U4 B - get2: in al, 64h
0 ?- A) o5 w5 X7 e; Z3 j - test al, 01 ; If the 'output buffer' is full, has 3 s8 v5 ?! q/ J1 e" D$ E1 N* h
- jnz exit4 ; something for me + p' Q5 i5 o1 a% U2 p$ I; |
- dec cx
4 u& @8 _5 D+ B" E! x - jnz get2+ d, T* k; A) I- F+ g0 o
- exit4: ret
- x0 Q0 _2 G& J, y* ^3 } - & ^/ M- i$ h" ?
- end
复制代码 |
|