|
|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM ; r. T+ i( n$ R$ K' m
- ;
8 I' ]0 v) s* P: A3 B# x. q! o8 u - ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-011 L6 ^1 H* l b/ |
- ; ml A20ON.asm ?6 t& N' p' I, P5 g
- ; , w5 S0 r$ K$ Z& }' L4 ]
- .model tiny
, p+ R9 K4 }$ {1 c - .code
/ g) G* r' g6 |4 I/ r" z, P - .486( b' [& T2 l1 ]) c, t' b
- .startup
+ T& q& E# u0 [$ |: L% M+ z - & V- o e3 H! v' z. Y
- mov dx, offset msg_author0 p% E# O$ Y; A' i3 [# c4 ?: t+ H
- mov ah, 09h
( x. c/ ?$ t% \4 J m$ @4 F+ b% |- ?; r - int 21h/ W. }0 N$ H& T+ U+ r
/ }+ ]9 a4 f" U' a3 P- mov dx, offset msg_fail 1 O/ v5 O3 h" u8 X
- call A20_ENABLE$ Y$ {: Q' N7 y/ m3 |7 ]7 L" ~
- jz exit1
! ?+ O& a( i, N& B5 [8 R8 @" r' U: V/ n - mov dx, offset msg_ok ! B. y7 Q7 k2 b) y/ c2 B, e
- 5 Q6 c0 R. l0 V1 s+ @9 H% R+ ~2 V
- exit1: mov ah, 09h
1 g& K9 s2 t) j% i2 v- V, I - int 21h
4 G) V" U+ W& u6 J m - mov ax, 4C00h 5 N% q. b9 c/ [0 C% [) L& F
- int 21h 3 ?8 t; i3 X' N8 ]- _
- 1 j3 r3 ]9 }) ~
- msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,
" t' L# p! D4 o- v) t - "2008-07-01",13, 10, "$" 7 h8 y. v7 k8 E* ^9 C. d. j
- msg_ok db "A20 Enable OK", 13, 10, "$" % l% D# Y: f- G& p" \) M5 Q8 E
- msg_fail db "A20 Enable FAIL", 13, 10, "$" / q/ E: t- u4 E# b
- : J' c1 ~: C ?- k. }
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
, h8 J5 a) P+ h2 A) K- H - A20_ENABLE: : U; a! ]8 [% i W
- call A20Write
$ {; Z+ d; o: _6 M - jz exit_enable+ }- ~6 f/ v/ T8 q
7 L( u8 [* m1 T" s- cli ; Only need for reading value from KBC
4 `. ]7 M. x! ~2 W9 o: \. L0 ] - mov al, 0D0h
. k* ?7 Y7 B; J; r% @( W' P1 P - out 64h, al
; L& a0 s6 J4 d8 u: Y$ r3 \5 u* {" } - call A20Read t V) L' Z: w ]5 @
- jz enable_int
+ W, e. x, D* r$ b8 Y3 ?( w+ G, J a - * b+ P& B& X( j. e Q# |9 q7 _
- in al, 60h ; Get current status
( [, y- n" B7 I2 x+ u& ?9 P - mov ah, al
, a p; ~: T: K, S - call A20Write ! m' } a1 z6 Y( d
- enable_int: sti
( ^5 r, b( {* L$ \8 z" p( F& _" h - jz exit_enable
8 g5 }$ n+ {2 E, b1 m- s+ H# J& \ - 6 H# @9 C6 i" ?) O4 Q' Z9 m- e
- mov al, 0D1h ; Tell the KBC , want to write to the
: T3 o4 I( F8 g. ?7 n* p - out 64h, al ; Out Put Port next E8 j& r0 ]3 N, O ?! R
- call A20Write 8 p) _5 _% y+ u4 E/ C
- jz exit_enable
: n ~( w) n! }
$ z$ ]$ F1 j+ z" m- mov al, ah
/ ~5 E O, H. R o - or al, 2 ; Enable line A20 & z1 a% r5 O$ f) h9 w
- out 60h, al 4 H3 `7 X) a4 P* u% P
- call A20Write ' x% h; s# K. M8 x. y/ i
- jz exit_enable
( s8 _* _6 |$ A' A
3 X5 p+ _; W! M6 M- |% O% y- mov al, 0FFh ; NOP 1 M* p1 ~' R8 b& \$ [5 m
- out 64h, al 9 k! M# i( }- U9 O% T
- call A20Write + n% n8 r' ^" j4 [5 Q7 b- M
5 |, R. J$ a* o0 s( U) E- exit_enable: ret
3 n+ V; e/ X+ {8 C9 v& V" p0 | - , u+ h* W6 E2 D; b( A
- A20Write: xor cx, cx ; Reasonable wait
9 }& g* j1 Z' f - get_wirte: in al, 64h ; Get KBC read status
% z- S8 i% x* Z - test al, 02 ; See if buffer empty, bit 1 clear
( r3 {6 h# B+ I - jz clear
* N% j+ C- Z$ l - dec cx ! }# X% M$ J Y. Q- U- O! u
- jz exit_write + F5 N! `2 j0 k+ B4 M6 v
- jmp short get_wirte
! G. z5 u, W# `. ^2 O6 [$ D - clear: inc al ; Clear ZR
7 _" `7 y3 w1 g5 ]9 f - exit_write: ret " y) q1 D* }* d: ~$ p
% G, E' S, B9 M$ P @. h- + C6 b% Z9 Z% @3 `% J; N$ c
- A20Read: xor cx, cx
2 u3 }6 D ?/ `* a - get_read: in al, 64h
3 n }3 _1 t- d - test al, 01 ; If the 'output buffer' is full, has
* s" b: O* `2 f - jnz exit4 ; ...
6 w: I1 f3 z$ M( ?+ A - dec cx 6 ]4 u( [ b0 j7 T0 d
- jnz get_read
6 y# _- B2 K8 w$ e8 S - exit4: ret / K1 l6 U0 y1 L
-
@! }" \+ B, K8 | - end
复制代码- ;A200FF.ASM / e9 I4 {. c- {, J4 p
- ;
4 f- v% h- i6 {) O) p% y a - ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01
% O, n- Q- W u% c m& c - ; ml A20ON.asm
2 R0 H' _; y* s7 Z! d0 m4 _ - ; * v7 E* h* \" L
- .model tiny- I8 [) D0 e5 `) G3 C
- .code3 p: x; a7 ^1 V( ~' A
- .4862 o. }- a! J2 [8 V
- .startup7 w- O, `) f3 D, Y# {3 k
5 A! m% w4 C% O. O' A( b; {- mov dx, offset msg_author# z5 Z1 z. h7 B/ D0 M- {( g
- mov ah, 09h0 g' @1 K6 D) O q' I7 [
- int 21h
* u+ j; r, g1 f/ A# l. _
. v/ x5 w3 g6 F& ? X( L3 h8 o/ @: p- mov dx, offset msg_fail 6 _$ }5 [! ^9 h* C" B+ c0 [5 p8 `2 C
- call A20_DISABLE
* f R. u# |7 I7 i% v - jz exit1
& H: D; q) A, e) V. G - mov dx, offset msg_ok
8 K9 U" z& B, H7 k! t5 a& k8 \
+ a" @0 A# m+ H, r) h- exit1: mov ah, 09h 1 G' n0 g/ I+ R" |9 P) l
- int 21h
3 \9 G) m) Z$ Z2 P: ~4 l - mov ax, 4C00h
. L: z* }7 }% A1 `' Y+ p0 j - int 21h # U. f X' L/ A/ i' A$ r
- 3 A7 _8 R' k4 Y v6 z7 ?/ I
- msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,
, Q. v. H/ o' _" D6 s: z) t - "2008-07-01",13, 10, "$" 1 Q# e$ f# g v
- msg_ok db "A20 Disable OK", 13, 10, "$"
% O$ z6 \' j; ?/ N0 L3 C0 M Z; E - msg_fail db "A20 Disable FAIL", 13, 10, "$"
. s) [5 g5 h% a - , c: I5 Y+ h8 U& D/ ]8 W( q! ~3 B
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
9 R$ d+ |- W# ] - A20_DISABLE:
1 u8 s. X* k3 T/ W: F- Q- e - call A20Write 9 `% F% B1 `( b
- jz exit_disable9 j( [, m" L( x% y0 v
- 8 ?# _, w: n# b, N
- cli ; Only need for reading value from KBC 7 k/ J5 r: i+ l
- mov al, 0D0h
5 w. U6 M4 C* |8 W - out 64h, al " ]( Q" H3 [- j5 J; C$ ^' S, m
- call A20Read 9 [) F6 m- ?+ x/ h2 ~" b2 }
- jz Disable_int 5 Q- h+ S4 @$ O8 S3 W5 }
- : z1 l) S) O7 u ~, b8 j" t" ^- o
- in al, 60h ; Get current status 6 ~. l7 R! ^& \/ q0 P
- mov ah, al
1 s2 {1 k' v: k) [$ O5 @ - call A20Write ' ]* ^7 b, G) R
- Disable_int: sti
7 a: g: v) o1 |# p3 C! W2 G* u - jz exit_disable
: }8 M1 N& |5 H% H5 \* r. F - 4 ]7 Y* O* T7 _: O
- mov al, 0D1h ; Tell the KBC , want to write to the . S6 j# l: Y1 g% @
- out 64h, al ; Out Put Port next
' m3 p! @1 u9 k. \/ c8 z; L, J - call A20Write & ^: D! o) [2 F# x
- jz exit_disable: I) {2 {# j1 j [
, z. r" M6 r1 z' }- mov al, ah / h0 E) y) k; O. h, N9 G; d
- and al, not 2 ; Disable line A20 8 j a+ Y k, L: A* O3 b
- out 60h, al 0 t9 O2 z: ~3 K; }3 h, @
- call A20Write W: O% V- B$ y
- jz exit_disable
8 U2 X6 O% G: V+ f/ q! E$ y - ' m5 {9 ~9 J. O4 }, v9 ~1 _
- mov al, 0FFh ; NOP # w5 k& D u. G q, Y9 N
- out 64h, al 1 p9 C& [! z( F/ c
- call A20Write + q# G2 s/ x# ^3 j
- , V3 V2 P- z, `/ g5 L7 X
- exit_disable: ret ; @# p: k; A# U8 b4 U7 D
. Q L% I9 P# J# Z, {6 B' ^+ p- A20Write: xor cx, cx ; Reasonable wait 3 i: F# v6 z* b4 p
- get_wirte: in al, 64h ; Get KBC read status
& d: Q9 F6 m- p& M7 n: U - test al, 02 ; See if buffer empty, bit 1 clear
; l% D# n8 b4 p" X3 r8 g- i( [( r - jz clear * {* O# l/ [/ e; h. g
- dec cx 8 m, }/ Q$ W5 c$ x7 V
- jz exit_write * G4 Y1 H6 J4 c
- jmp short get_wirte ! e3 r9 f+ Z/ s- E( ]
- clear: inc al ; Clear ZR
; x( ?( d- G# [8 ~ - exit_write: ret
* l/ A) X- e, M. K - $ y6 ?7 b. M' G7 n& Z& Q
: I: e |. i# ]0 m% Y7 s% ~3 f- A20Read: xor cx, cx
; ]$ m* O3 c! W" X$ n0 o - get_read: in al, 64h 7 L& k7 J! P1 V0 B; x# O# Z
- test al, 01 ; If the 'output buffer' is full, has
( T0 {0 n" r, B; M2 E - jnz exit4 ; ...
. w; q/ ?" C) j6 c( A - dec cx
- F( W9 ?9 y# ~6 h0 C9 o+ { - jnz get_read# C' a- T% ^9 d+ I9 v
- exit4: ret
& }7 }% h9 r! S! ` - / J% w$ |3 P& ^& [2 j8 L
- end
复制代码- ;A20STATE.ASM
" D. |3 k& k. @5 D - ; % j7 L: m- ]6 m! F
- ; Returns the status of the line A20 through the KBC # u* M+ G, Y7 n4 t$ h# t
- ; programming by bini for debug. 2008-07-01
# S" B! M! {/ b! n- I0 y/ E - ; 4 k+ T) c8 T( C1 ~9 f I5 c& \
- .model tiny+ x8 _( j( l) N! I* {4 s
- .code. d& S3 F2 }1 s4 Z
- .486# N; Z }# F9 L
- .startup
# o* N9 t8 k9 x6 R, S8 s- o - mov dx, offset msg_fail & {6 _2 o( G% X3 Q6 \3 s3 M' y
- call _GET_A20_STATE_% J5 Y& a% D7 h6 v/ J3 [
- jz exit1 ; was a problem; N" C/ l" F# T' Q2 X
- push ax ; Save state, AH 9 f; B% F7 v0 w8 U( s( T# a/ t/ p
- mov dx, offset msg_ok ; There wasn't a problem * R. M% n) s2 ]! S7 t% t
- mov ah, 09h , x; l7 X! o; l! L- n
- int 21h ; Print message # W4 n6 Q C; G" N
- pop ax ; retreve state " [+ }0 B. e, H
- # o, x& X, r3 \, e0 x0 J2 E! s
- mov dx, offset msg_dis
8 c. u* k: c/ a8 L O; B - and ah, 00000010b ; bit 1, 2h, indicates state
6 Z% w% n0 a1 j$ p - jz exit1 [$ `# a, } u
- mov dx, offset msg_en
. _( m o! ~3 O; ? - D! S$ s6 A4 m6 K7 a- M; C
- exit1: mov ah, 09h
9 E5 u% c% Q7 E% H3 p, k - ; DX already contains address of string
, _6 r# L) _$ d( r. Z* y - int 21h $ ], n$ I. O, {+ s" H
8 j, s. k* t% O& u- mov ax, 4C00h 2 E, b# x* B! {6 F9 G: V
- int 21h + c6 ?) P) f+ B( F! K6 D' l
* v, j$ O, @! o" Z1 U8 z- msg_ok db "OK", 13, 10, "A20 $" Z- x! G$ {1 P
- msg_fail db "FAIL", 13, 10, "$"
, X( c: T* ^7 x* M$ N7 @ - msg_en db "ENABLED", 13, 10, "$"
7 ~7 Z( J$ H" u; U3 f0 D$ {0 G - msg_dis db "DISABLED", 13, 10, "$", T. {: ~" K+ m/ i K
' B7 W' e* T9 Q6 S" E- P-
0 z: E7 k* w* o+ @ - _GET_A20_STATE_:
. o; ?& g! F9 w P8 D. e( ~ - call A20Write ; Wait till the input register is empty
) m# L- R7 y" Q# P% u - jz exit2+1 ; Bypas the reset int's ' b4 J8 V5 R, X6 a9 p
- cli ; Disable ints so we'll get our value
9 D# h; U/ E3 ^# ]/ q - 6 G1 c3 J; p, v
- mov al, 0D0h ; Send command to the 8042 command register " v# q- S$ |7 r+ }1 Y! Z2 c5 _8 p
- out 64h, al ; to tell it we want to Read the Output Port
( d& e+ F& f* c0 @- @0 y - call A20Read ; Wait till the 8042 output register
/ C. d. N, N+ b- g: u6 B: |% ~ - jz exit2 ; has something in it's buffer
) |7 R' F$ w" ^. B - 0 h- b% u0 E' h' L" G
- in al, 60h ; Get it 5 @3 x2 g0 W- T& s w5 H! A
- mov ah, al & a# q: m6 _- X% C% n/ P
- call A20Write ; Make sure the input register is empty
3 j5 l4 G$ f, @; z. \; t9 y - jz exit2 . R7 I# \7 P# Z; u# v
- * i8 v2 @, b' h7 E" T. U
- mov al, 0FFh ; KBC NOP command, does nothing 6 d9 n2 z( C3 G. \. |. o7 B
- out 64h, al * c' V2 ~0 H5 q* D" |; d* L
- call A20Write
( O% V- l9 v1 N+ z* `
* u: ]. I7 s5 _3 b! E# y0 n. y# q- exit2: sti 5 u: H- o7 S5 S2 I3 E
- ret
' c* E% U' c! c: n5 k' ~2 A$ w
1 H, C& s- E- {7 E- 6 `( Q7 T2 j) }2 G$ O8 X
- A20Write: xor cx, cx ; Reasonable wait ! `' i! q3 `: h$ @! p1 d- _* r
- get1: in al, 64h ; Get KBC read status ' y3 r6 R' u( U, b5 T3 y, O
- test al, 02 ; See if buffer empty, bit 1 clear
0 F' Z, @' X5 }% w' K' H3 A - jz clear : L# F& n! g6 P$ v6 m+ ^% q% P; G
- dec cx 6 y" V) a4 @. C
- jz exit3 " v2 ]9 m! c5 a8 a/ B- f
- jmp SHORT get1 - ]/ |* m* i0 R
- clear: inc al ; Clear ZR
7 `8 ?8 e* i ~ - exit3: ret
$ J# h) V& T4 x4 [" B9 ^4 E4 ] - ) _7 e0 y8 }% E
- " P3 W# Q$ d# G
- A20Read: xor cx, cx 1 H9 v& E; n" A! P! Y) [( i
- get2: in al, 64h 8 m+ o! s7 `6 J" r- O) R
- test al, 01 ; If the 'output buffer' is full, has
4 E9 m- F/ ~+ G' ^9 T3 `+ j - jnz exit4 ; something for me . t" {! g. \! l0 t& c( @
- dec cx
& F6 W% e6 ^0 R& n$ ` - jnz get2 D: f! M7 p$ o d5 P
- exit4: ret # x% h4 V6 v5 l( ]* _
-
1 H$ W6 {4 {7 N2 V - end
复制代码 |
|