|
|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM
: e1 y5 b' H) ]8 O; a* o6 c - ;
2 |# `" {3 x3 v) n* S" ?$ i - ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-010 j& A+ H" I4 x0 s g, ]
- ; ml A20ON.asm
6 M, l/ G0 a& A& H - ; & Z0 u+ E7 h/ d5 @0 v$ L
- .model tiny! t9 j/ D) b7 _4 U( h7 q9 |
- .code8 W: E& [/ v# C$ ?- Z; a* j; N
- .486) @3 L: }5 b" r: A
- .startup0 c$ U2 L7 o6 W' M# h! k
* b, o+ G) ~8 f8 Q6 @, a- mov dx, offset msg_author
7 W& S' Q4 t; a: \& `. c - mov ah, 09h; j8 R" ?/ Q/ t2 x' N9 V
- int 21h
6 Y c# D, v1 b& l' p Q - + ?: h# F# v1 |& c" H
- mov dx, offset msg_fail 0 N. O9 z! k) }' a* r
- call A20_ENABLE
5 w- c2 I B! h* k - jz exit1 q1 ?" q2 |9 U, }4 j; _
- mov dx, offset msg_ok
- q6 y/ k8 K3 k \4 n - 2 c$ I5 Z8 j# V* S9 s' R7 \3 [
- exit1: mov ah, 09h
5 @- P: M# i& g- K! A - int 21h
. k1 V% ^3 E w6 E% T% Z; ~ - mov ax, 4C00h $ w5 a+ B8 G6 }8 @( i' v* z5 n' }4 o
- int 21h 9 ]" P2 n" H5 t8 [
- ; ^4 T J7 c" l
- msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,
q9 m+ N0 ^' [; n: \ - "2008-07-01",13, 10, "$"
6 ^8 L& Q I6 P' Q - msg_ok db "A20 Enable OK", 13, 10, "$"
* z3 ^7 |7 V! n9 a F# l0 ? - msg_fail db "A20 Enable FAIL", 13, 10, "$" & U F4 l. P3 b7 T: e3 V, V, k
5 o" j b4 E% z+ Q- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
7 t6 n' ^! b H1 G- l" j) V5 Q - A20_ENABLE:
: Q- _* h+ C$ g8 `: u - call A20Write
4 S7 s' j! H) f# r" ~ - jz exit_enable
/ i: V7 v2 U7 A - - E- q& g$ q6 n% z( {; L. O
- cli ; Only need for reading value from KBC
6 B/ }6 z7 y! p; Y" Y) W - mov al, 0D0h
# A. a- n0 V/ Q - out 64h, al
* v' u9 Z3 X6 U; V& D0 p2 C: F - call A20Read + J3 c$ Y( c+ i4 i
- jz enable_int - @: s' t. q& a$ n& Z9 e
9 I- m% L6 S0 Z, V! p' R8 k- in al, 60h ; Get current status
# u$ C4 l# b: H. \2 J. u4 v - mov ah, al
: z ^, r- j; F4 d$ T, w - call A20Write
1 C4 S) I1 z8 C9 o8 v1 {6 x# _% ~ - enable_int: sti u# L) X' ? j% X: j: T
- jz exit_enable
3 p! J0 P/ U4 j1 \: D( S S; a) c - 6 k0 O5 k! y2 T7 R! P
- mov al, 0D1h ; Tell the KBC , want to write to the 9 B5 c5 f+ G6 t* Q; S0 [1 a) V) K
- out 64h, al ; Out Put Port next : I$ G" N1 X' r9 L: k( P& Z% ^
- call A20Write
" j3 m% V' L7 u6 t9 z - jz exit_enable; I9 ~* P$ B+ f0 X: n! _7 r
- " X3 B. }: Z% i z5 T$ p; I
- mov al, ah : i: ~( ^& e g, f1 l
- or al, 2 ; Enable line A20
9 P0 h8 O/ s% u" F' t - out 60h, al
o& k* F) p' G1 x# r7 s; s' A1 U0 L - call A20Write , u3 u5 T& k7 @% u, |% E* B, X7 p
- jz exit_enable, S: v! N3 c5 ?" u6 P& X6 p8 U0 Q
7 V$ ~' s `' A& U6 [0 m" S9 ?- mov al, 0FFh ; NOP
7 N, S2 l6 n8 z; H3 I' n* p - out 64h, al
; E6 q" p6 j7 M* _ - call A20Write % i( Q0 v4 T+ }& w
* L3 P ?8 |2 X- }: o- exit_enable: ret
& o, j3 P# O% P9 _0 u - 7 D4 g8 l6 a C. S5 n. {, ^% d) i
- A20Write: xor cx, cx ; Reasonable wait
9 q8 B, i" x3 E' X0 n - get_wirte: in al, 64h ; Get KBC read status , B! J/ p! B9 M' L, e( I
- test al, 02 ; See if buffer empty, bit 1 clear ! X7 M/ S. u/ n& g' `5 c
- jz clear & B+ f6 M4 A8 h8 A( G; ^
- dec cx
8 g6 o) \1 B$ L# l - jz exit_write
. X$ @2 D: P. r( ?, p% H: M5 j& V - jmp short get_wirte
1 T8 p2 s, l7 g9 i7 I: X9 S - clear: inc al ; Clear ZR + J" i# U3 b- _7 z1 t h
- exit_write: ret $ R: N/ w! r# ]; e \8 m
% [2 H* l/ J% P3 G; D: s% ^! T
: e' U1 w a7 {- A20Read: xor cx, cx 4 K( m4 X1 c( w. V& R( Z8 K7 W
- get_read: in al, 64h
2 E% w) ]5 P9 U, @2 Q - test al, 01 ; If the 'output buffer' is full, has % Q0 p" M+ y" x7 j( i( S
- jnz exit4 ; ...
" G5 n, n7 N; F# a - dec cx q$ ^, c4 T! @; M
- jnz get_read4 z* `& q; A! B; V3 B6 V
- exit4: ret
% |# ^2 x% b1 F - % \6 d! y5 q$ @/ ?
- end
复制代码- ;A200FF.ASM
) ~$ ] g/ | h - ; 3 e4 i1 \, J& n3 ^" }- q
- ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01 |; T" T) u% z
- ; ml A20ON.asm 0 T R% g# L) @8 K' M1 l3 v* y& H
- ;
: l4 Z1 c9 J( \4 k - .model tiny" _# Y S& B4 ]/ [' ~8 K/ B
- .code: y9 c% `: [ R( J9 j
- .4861 t, R9 g( q& k) [
- .startup
$ o. s5 [9 d# `5 `1 h - 6 k! r5 Q- ?9 P
- mov dx, offset msg_author
7 A+ l7 a" E& n7 D7 G4 T - mov ah, 09h
- s2 W. q% E6 _: }3 M- H3 g6 B1 R% H/ ^ - int 21h; [- x$ w: i. \8 _
( ?9 ?, x% ?. Y0 F. B, |- mov dx, offset msg_fail
; o0 I! u) M, U - call A20_DISABLE
2 T4 k6 b. q9 | Q( s' L- e - jz exit1
" i$ `9 v4 R4 e9 J! C$ B) W+ z$ c - mov dx, offset msg_ok
6 o$ U9 k% n, ]- b
( x S. a- B2 ~* i- exit1: mov ah, 09h
1 {4 ^& r* E( K! q& W2 T - int 21h : Y N7 K4 [ r# q) X( J7 i: h: S
- mov ax, 4C00h " i& B2 d* b+ \' e; t$ b
- int 21h - ?+ Z/ T6 U8 s
- , f2 W2 T: @' a' M5 j! o5 {
- msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,
* \! [) t- }& e. V% t - "2008-07-01",13, 10, "$"
" g2 z6 s4 S* n; Q+ q6 S0 a4 i - msg_ok db "A20 Disable OK", 13, 10, "$"
+ a- @* A8 Q m- s' @2 U8 e) ` - msg_fail db "A20 Disable FAIL", 13, 10, "$" 2 Y- I4 p, F: E8 ^- Y
, k9 Y" F# H3 g- ;------------------------ follow code maybe make to lib, if you want...-------------------------------5 T1 S2 r* u, F
- A20_DISABLE: , o3 b/ o6 K3 D6 m
- call A20Write
0 K# o: {9 m5 U/ ? - jz exit_disable" W3 K p; P5 M/ u6 u W4 @, M& l
& F/ u' r# |6 U- cli ; Only need for reading value from KBC 8 a3 F" d$ Y+ Y) R; Z* c' Q
- mov al, 0D0h
% E6 r# r6 v# U& a8 K - out 64h, al 3 k8 Y6 `" T d
- call A20Read
6 m. E& O, J2 ?7 Y" E - jz Disable_int
! h( v7 x' f' P8 u& v+ A! G0 e
/ ~/ {9 Z! p, E* Y& E g1 y- in al, 60h ; Get current status 9 C- f$ h ?1 P7 r& C
- mov ah, al ; p% b* o# H( [: P% R
- call A20Write + A8 M- x) J. R/ v$ X5 K# l0 x
- Disable_int: sti ! g2 U6 Y2 ]8 O
- jz exit_disable8 U; W+ ^; p1 N3 M& K8 @- n% J
- : t7 v! q5 p4 F& D
- mov al, 0D1h ; Tell the KBC , want to write to the : v; W [, o$ i$ u( _
- out 64h, al ; Out Put Port next
8 l! o# \" |* \) ? - call A20Write A' t) ? x1 O* ]- U7 Q- B0 a( [
- jz exit_disable5 A3 z3 R) \4 e8 l: t
. S- F2 _; i9 b0 i/ n5 C- mov al, ah
/ P G& p: q" S - and al, not 2 ; Disable line A20
" n# ~, n$ a. ^1 j) A4 q - out 60h, al 1 w) {0 I- j7 x" ^, G
- call A20Write ( b; ^ ~$ z" p
- jz exit_disable+ X, a p, k$ h
0 z$ L8 p; l) @7 w1 y- mov al, 0FFh ; NOP
& A7 h! s: H" k* d. B - out 64h, al " d" t. u& g. c* M# K4 H$ o; e
- call A20Write
& A1 t2 a/ \3 i% l4 o
& ]$ |; O D2 N6 B: I l) l- exit_disable: ret
. W+ k2 r( q# q - " d, |: K/ @/ W% U0 ~6 g) T
- A20Write: xor cx, cx ; Reasonable wait ! u6 |' E5 F" F. I/ Y; N
- get_wirte: in al, 64h ; Get KBC read status . @0 v' F2 c% \3 j" G- q; l
- test al, 02 ; See if buffer empty, bit 1 clear
0 k# p0 I. [ M& {8 h* O - jz clear
5 g/ k/ V# g1 f& f% r" c% f - dec cx
8 q7 D! ^5 \/ g9 Y4 f+ h8 j0 h' { - jz exit_write
5 q3 I0 c8 B0 V! _- p - jmp short get_wirte
7 G! s7 [1 k1 s6 Q; F) b! ~) D5 F - clear: inc al ; Clear ZR 5 P d0 [2 i* ]( i
- exit_write: ret ! A) _. ?1 M6 d! C9 o; i; t" i
) P# Y2 D, v2 n0 n' L6 k# G" [
8 u5 t2 K7 D; m( O5 C6 C- A20Read: xor cx, cx
3 ^4 \! b- a$ Z9 E x - get_read: in al, 64h ( ~4 E7 F2 C* w- z" c! }0 ]; a: J- u
- test al, 01 ; If the 'output buffer' is full, has $ z. M! t3 B" W1 k _8 z) ~" A: J- m
- jnz exit4 ; ...
( M# N" _& r2 N! Z P1 _- ]7 R - dec cx 0 i7 E j2 S+ H: T' h
- jnz get_read6 E, d, y$ |9 \3 h# }( J5 O
- exit4: ret
! t: N0 u* l! T' U - 3 `/ w/ x L) V
- end
复制代码- ;A20STATE.ASM 9 a8 F& G$ h" o6 D/ j" b/ l+ b5 m/ V0 @* |
- ;
: y; z8 f; |# d7 d7 c - ; Returns the status of the line A20 through the KBC % S! a) M/ E7 k
- ; programming by bini for debug. 2008-07-01
% S0 p1 a9 K2 W, i$ r! o9 s3 F - ; ; _0 ]! {( V& ^+ C9 G1 I' l
- .model tiny
% K6 x1 q9 X( g0 q- ? - .code& l3 c' q- ^; o! m! t
- .4869 R3 g( C S! _$ j6 E- m* F
- .startup
$ x9 O* D* M& t8 Q - mov dx, offset msg_fail 8 r) w1 Y Q* y e
- call _GET_A20_STATE_0 D1 g7 e% f. h) @& n# V
- jz exit1 ; was a problem
7 ]0 q7 t G6 B" n5 C" Z - push ax ; Save state, AH / n2 M. u- q2 M1 ^
- mov dx, offset msg_ok ; There wasn't a problem
' S7 Y# R& Q7 l) ]. z: j+ @/ X" \ - mov ah, 09h - C: O) A6 n- K& F# c& ^6 U
- int 21h ; Print message 3 J( N: t- B8 z& u' c
- pop ax ; retreve state
/ w5 l. S0 A8 |
; F4 {2 j9 j) g! u/ x8 k/ S0 k" ~5 k- mov dx, offset msg_dis 4 D; O8 q, N* p0 s5 h- M* e
- and ah, 00000010b ; bit 1, 2h, indicates state
' z$ C: k/ E' Z% F |! q1 f# H - jz exit1
. I5 f2 X7 o. R# ~! q - mov dx, offset msg_en
5 p p$ D) `" w1 c( V' b1 N1 x - ' p/ t' j ~# }3 v. |# S, A6 N$ l4 u
- exit1: mov ah, 09h , _9 \) J7 m2 H8 N" Y# Q' e
- ; DX already contains address of string ) E \7 o* F* Z9 Q; f% \/ r
- int 21h ; F C' K, K( {6 G) h* l( Q, N
- 4 P* z% l! Q2 d+ j( ^& s
- mov ax, 4C00h
" P) w. y1 R4 r) C. h7 ] - int 21h
, Y1 b& `4 d* e+ p+ { - ; w( n, C9 P% o2 |
- msg_ok db "OK", 13, 10, "A20 $"
. y& _1 V# _2 P( _1 l - msg_fail db "FAIL", 13, 10, "$" & H' H, Z# {$ v6 ~* R5 I
- msg_en db "ENABLED", 13, 10, "$" 0 w/ C' {1 `/ h1 q
- msg_dis db "DISABLED", 13, 10, "$"
, y+ r9 D1 U( H - 7 Z. `$ K) r1 r7 H, G; t0 s* |
- , p5 L$ | Z- Q7 E( `
- _GET_A20_STATE_: 2 Z8 T; U2 q0 H+ W- ^/ Q
- call A20Write ; Wait till the input register is empty
' f" U. L& |5 c$ t- J - jz exit2+1 ; Bypas the reset int's
1 d. q8 k' G8 R& s P j - cli ; Disable ints so we'll get our value # z, U4 M' R( O$ t& W9 k
5 C$ g5 h& S+ S- mov al, 0D0h ; Send command to the 8042 command register
5 m& i1 R \8 _$ |$ s - out 64h, al ; to tell it we want to Read the Output Port
8 n2 T2 y# G2 H - call A20Read ; Wait till the 8042 output register ( h# R* s+ }! h }# n9 p ?
- jz exit2 ; has something in it's buffer
: f" A7 R8 ]5 {) s - 2 | P3 n" _3 o" b) H' l, R: s2 U
- in al, 60h ; Get it
% | F: v; l8 l - mov ah, al - j9 Y0 `" {# ]
- call A20Write ; Make sure the input register is empty * K- h& Q0 a' X5 `$ Q* W2 a. J5 T3 ^0 `
- jz exit2
7 ~3 K- d2 F! J5 z( a+ {) O2 G - 8 g/ i/ s, G9 o% s& ~
- mov al, 0FFh ; KBC NOP command, does nothing ( N# x; \3 ?7 i3 w8 `$ b. ~
- out 64h, al
6 [: J5 j2 s2 P e' u - call A20Write
5 E, G5 A# ^ f, y. K; p& n% d5 d
. i' t- v* Y3 | c- exit2: sti
2 W# w* {+ n1 {/ i5 y* c" o - ret& p% X+ e' Z% H5 \
; P1 B& |% C3 n
7 W! e& O4 Z: j, O+ [. a2 Q& `- A20Write: xor cx, cx ; Reasonable wait - K2 h2 c# O* |, u( _
- get1: in al, 64h ; Get KBC read status
, X" }2 Y* |# B9 T1 n* T1 b - test al, 02 ; See if buffer empty, bit 1 clear ' Z& n0 q/ g1 q7 X2 U- s
- jz clear + G, X z- h- v) H+ a3 s
- dec cx
% @- H* z2 { \ - jz exit3 / w9 z3 x- ~/ Q" l8 j' B3 i
- jmp SHORT get1
6 F6 h2 I# o. X, b+ u& }9 ]9 i - clear: inc al ; Clear ZR - @. W/ w: w" U4 I
- exit3: ret 5 O7 t5 C" t4 n+ |5 T
' K# W" f5 s( X7 Q- 5 p+ J. z% o6 r) }# E
- A20Read: xor cx, cx 2 U0 W. w5 n0 z
- get2: in al, 64h ; x. X6 w* d# F; Z$ W+ g* c
- test al, 01 ; If the 'output buffer' is full, has
P, ^9 f# T9 ]9 l3 [ - jnz exit4 ; something for me
$ j4 X* Y1 ^3 [! ^ - dec cx , l6 ^1 W; H; Z: G7 d. b
- jnz get2
) k [( L% m( n - exit4: ret
3 C( w# m) Q. N t -
& V5 r9 O N& O# ]: A - end
复制代码 |
|