|
|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM
5 f% F, I) }" B" b C& t - ;
+ p1 y2 Q |0 @8 `, A* m - ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01, t, a+ v: B8 C8 h4 r3 `3 @4 T
- ; ml A20ON.asm - b" @/ d M; f/ I* M
- ; 8 w& E. r- B% v/ e+ O
- .model tiny0 J( u2 u3 }3 G+ x- Y1 W
- .code. P- c4 A. {+ l3 w) s8 e
- .486! x/ U. E' C8 `& M
- .startup
% x& q. b8 U, C4 V6 _; p - 7 _7 l; u( T, S1 I& D {
- mov dx, offset msg_author: g# k! K1 C# v9 E
- mov ah, 09h
$ I* m: p0 }1 g; K - int 21h, p* K$ Y# i6 v3 l3 k( P
- . B) D5 o! |0 z! y5 l( b
- mov dx, offset msg_fail
" G' G F2 P# C0 e0 v - call A20_ENABLE4 r+ u* U3 W2 ^: ?: H' }
- jz exit1
; ~2 E- Y w3 w* K* G2 u# f2 X9 z - mov dx, offset msg_ok 3 ?1 Q& T$ b, U
! z4 J. H2 _9 \4 m% B- exit1: mov ah, 09h
7 y# W L8 i0 k! d5 h - int 21h / Z2 g6 I4 G- Y a+ p
- mov ax, 4C00h
! ?+ R/ {2 E* a, ? - int 21h * I; Z' o3 b+ Z& T3 G# q) X
-
0 z; K8 O, C9 {+ N" D - msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,# n$ b+ ?: m+ }
- "2008-07-01",13, 10, "$" 8 x: p& P, N# d5 \1 G4 U
- msg_ok db "A20 Enable OK", 13, 10, "$"
# s8 m- T- h% k7 H+ C7 B' j - msg_fail db "A20 Enable FAIL", 13, 10, "$" # V h& u, D9 E7 N3 Y' T
4 e) ?; @! ~) |0 g; ^% c- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
, A( n2 a0 M: W+ W4 W# f/ A - A20_ENABLE:
+ F; u( P2 B }$ }2 k. ?+ M: h - call A20Write . ?) X3 g/ Z0 y9 S$ C' D/ s/ i
- jz exit_enable
2 D8 t- l) g4 o/ K - : \0 Q$ M. r$ K4 ^. }* @
- cli ; Only need for reading value from KBC
2 z. t. d( s6 i - mov al, 0D0h
1 ]% V( J& {/ F" F - out 64h, al Q1 N6 t/ b+ d
- call A20Read
7 R" y/ c* |; q' V" P$ Y# M - jz enable_int ! O- m# N' o* `" u7 e4 Z" j$ }8 B
- $ D! Q! h1 ?# H! n' C& k
- in al, 60h ; Get current status , ~% t1 l8 _: w
- mov ah, al * V& X& Y& I m6 N: `
- call A20Write / c3 `$ G2 P( z/ V+ ?
- enable_int: sti ; G% p" \6 `2 V( N( p( S/ W8 A/ E
- jz exit_enable
' W$ Q/ H% h" C1 g- w5 x2 F& F - ( h# l" t" K. i/ {1 E
- mov al, 0D1h ; Tell the KBC , want to write to the . `7 m3 `: [, ^/ w% p
- out 64h, al ; Out Put Port next
; q' w( `& d8 c* Y4 ?4 O2 e - call A20Write
% f5 P" D5 k: n8 A8 N* s( v4 W v - jz exit_enable6 ]# S2 Y9 n' Z q( T" [) l I3 X
- * h8 J/ v# X9 z* Y4 a
- mov al, ah ) i f, d& ^) S7 {* s
- or al, 2 ; Enable line A20
& M9 g E$ W. H5 n - out 60h, al & u) \& g9 J$ e! | H% a0 O7 |+ o
- call A20Write 7 f- T- S* B7 r1 W
- jz exit_enable' d& v. ?& O: I* w
' D, k- D2 R% @% A2 o, t3 U) o1 F/ p0 y: f- mov al, 0FFh ; NOP 3 J2 j, e2 p5 W& [& \. I
- out 64h, al # n% X% Q6 b# h/ o
- call A20Write ; y6 a4 @; M4 @0 A
- 7 L0 O$ ^$ l2 F# ]
- exit_enable: ret ( K: ~2 Q6 k Z/ z% a
- 5 M$ H+ [& n' Y: w' n3 n, T
- A20Write: xor cx, cx ; Reasonable wait : t1 I' r0 w3 F$ V P8 X
- get_wirte: in al, 64h ; Get KBC read status
% x, ^* k# Z- |( R, u3 D - test al, 02 ; See if buffer empty, bit 1 clear 6 \9 ?7 F2 g: w5 n5 C) s, V/ l$ W
- jz clear / z% S' C, t+ I6 A5 q' k, H
- dec cx * _; i- v: e( n0 {
- jz exit_write
. J' I: m5 M. l, y4 z/ N" B2 K - jmp short get_wirte : G% E7 u' i# M2 V1 r
- clear: inc al ; Clear ZR
7 W9 j& w3 Y i$ ~* k, G* l) ^ - exit_write: ret # p# _8 D8 q& I/ y
" t4 ?+ v" E8 S/ B) L4 z4 T- ' i1 X0 @+ M0 A& B$ ?1 ]$ A
- A20Read: xor cx, cx
7 N h$ v' a* B, _1 A - get_read: in al, 64h . ^" m+ R' w) E) J1 G" E
- test al, 01 ; If the 'output buffer' is full, has
6 a# T/ e) _$ A; G0 u& S H - jnz exit4 ; ...
9 ~6 W2 B: F$ a d$ Q, n7 ^: ? - dec cx
# x- H: h9 A) S$ R - jnz get_read1 T, S+ o8 g8 K7 P: k$ P
- exit4: ret 5 g1 L/ z; q8 @9 X: h
- + P p: \- {/ j9 y8 A5 {
- end
复制代码- ;A200FF.ASM # a' Y: T# o2 c
- ; 3 W/ I; d) Y" t1 U
- ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01# h( c* N/ ~( w. l7 O4 g2 P& N
- ; ml A20ON.asm S& o3 j; H' ^' u9 c9 k- _9 E
- ; * ^5 w7 s4 h- Y; q! W
- .model tiny; g" W! {6 P5 k
- .code
1 u& i, e- u8 ~, P3 } } - .486
) }( x$ P# S% K - .startup/ o0 {) n% }/ Y- ]. |
( [! {, M4 }2 t7 ?" x5 K0 [0 T4 u- |- mov dx, offset msg_author
& b- B, l" u: r: G5 n - mov ah, 09h; O/ c+ y B( G3 x2 |2 U0 ?5 b
- int 21h
$ M) z* u {1 l% m& l - F, F* a& `$ S
- mov dx, offset msg_fail . ` o2 J' X5 y7 P6 w [3 @' Y( {
- call A20_DISABLE4 {1 v1 i1 _3 k' l" d' z3 G. ?. L5 N
- jz exit14 z3 _" H8 F, ?1 F$ K* n$ Y2 z$ D6 x2 d
- mov dx, offset msg_ok ! Q1 m/ `0 M: c, z* a- L$ s7 s' M
- * y( T3 s6 W: P- f0 E1 d
- exit1: mov ah, 09h
% q5 Y; u3 z# o- Y- D8 `4 ?" W - int 21h 6 c/ K6 ~9 c7 g: ~
- mov ax, 4C00h
9 x' K9 r7 K8 j/ p' I! e - int 21h ( Q9 h- ^+ ]! [6 V8 e
-
. P% A; ]6 i2 b5 S - msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,% m! u4 i c6 S% T, D% N" A o5 X
- "2008-07-01",13, 10, "$"
4 ^. }( |4 U' ]; k9 M - msg_ok db "A20 Disable OK", 13, 10, "$"
7 A" ^' c0 J7 n4 V - msg_fail db "A20 Disable FAIL", 13, 10, "$"
9 @' M" Q9 ?8 m6 Y - ( _" c& n3 u* `, E: j5 e& n$ s1 _" G
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------" Q& S8 D4 v, P9 d: O" S
- A20_DISABLE:
7 Z9 k9 V* W6 v2 i - call A20Write
# V6 O! M% Z) v! o$ q - jz exit_disable0 I0 h% Q0 F, g# i3 `' ^
- & o, [( U% u0 B8 {, ~
- cli ; Only need for reading value from KBC
8 @, O+ x& w. P! @& Z& V4 l w# O - mov al, 0D0h
3 z* ?* m/ S8 O; K - out 64h, al
' T, T3 Y/ W8 W# B/ O \3 Y - call A20Read
4 a1 [6 j6 \: o5 I& }$ H - jz Disable_int
: p/ x' A9 J9 ]3 p) W
1 L& ~0 u; V) @- in al, 60h ; Get current status 3 z# r: C5 g+ E: l9 l3 ~0 y% X
- mov ah, al % O5 f& u9 f2 R. u# c
- call A20Write
/ A! |- P F! D9 G V - Disable_int: sti m( m, ^4 n" d+ E1 H$ [: v* T
- jz exit_disable
+ ^: p3 Z+ N8 N! B
6 X; ?8 ^$ j# [9 o0 Y- mov al, 0D1h ; Tell the KBC , want to write to the
/ i) B* i, u! i" ^2 u/ r. v) G4 ~ - out 64h, al ; Out Put Port next J8 ]/ X5 }* Y: {9 P
- call A20Write
7 O b* R9 ~9 }$ ~: ? - jz exit_disable- Y8 [9 k; k& E0 f: d
- 4 |, [6 ?7 B! W
- mov al, ah
% I0 t* f6 j# Y% b. {7 X6 z8 H - and al, not 2 ; Disable line A20 0 O" c' K% h" x. X+ @
- out 60h, al
# C0 A. f& F. g; Q G - call A20Write . v7 p. ?, z8 b" `
- jz exit_disable
: s7 w4 m9 O2 { - " e; } j3 ~/ ^9 ^! `, [9 H7 A7 n% L
- mov al, 0FFh ; NOP , D: l5 Y& {- x6 d2 u4 J
- out 64h, al & _6 J5 v# G$ T, e8 h7 n
- call A20Write
* D- S! F4 }6 ?, }
' e) s# c1 s* @5 N6 I% N- exit_disable: ret % j5 q; V% l$ a% R) D5 h6 e; P
- 5 W+ _+ O% i) ] |
- A20Write: xor cx, cx ; Reasonable wait ' s! I0 D0 m2 ~( `2 w) p/ C; ]
- get_wirte: in al, 64h ; Get KBC read status ' R5 r& H1 N/ c; W7 X% s( Q* R
- test al, 02 ; See if buffer empty, bit 1 clear
, ^# D! A7 h0 o8 e1 q - jz clear ( C) V" }% O ]/ u4 I, ^
- dec cx
5 @+ r$ T; Z$ P4 T5 o. c L - jz exit_write + M6 i8 @" }* T( p8 X
- jmp short get_wirte
7 H# u) b; B( S& ?& I/ p) v$ L" M - clear: inc al ; Clear ZR
7 J, \% v( I ^ F$ c - exit_write: ret
* _* {+ M0 W8 S - 1 ]: K0 B% R. C& s
- # l9 h0 p, N! Z' g+ c2 Q
- A20Read: xor cx, cx
8 h) \2 N" c n& a* f; ~: e - get_read: in al, 64h
' V1 p9 @4 s6 c' T' @ - test al, 01 ; If the 'output buffer' is full, has + M" Y# k+ d! }: V1 e
- jnz exit4 ; ...
) u# b5 X3 s4 @* f& S4 y: g( l1 U4 _ - dec cx
' `6 N, `& Q/ r- |! s" w - jnz get_read6 j5 R8 Q+ u j1 g' F! t3 W; y8 {
- exit4: ret
: @" Y% M5 l7 ?) X+ s - - F: H# ^5 z3 x+ Y
- end
复制代码- ;A20STATE.ASM
" h8 a: l+ v6 E+ U7 S+ c( T) f' Z - ; " V5 S% V1 G* D3 _) a0 N, Z
- ; Returns the status of the line A20 through the KBC " F$ w( {% i! ^4 @( `2 |
- ; programming by bini for debug. 2008-07-01; n8 k8 H! ~3 o9 u( R7 ~9 @$ o
- ; & n0 d; ]8 |9 n7 g& D0 Y$ @2 B0 t
- .model tiny, X$ X$ a- E; K3 F. {- |
- .code9 s! e1 M: {1 Y
- .486& q5 ?4 N% f6 s1 r4 g7 j: R
- .startup5 ]+ Z- K$ j! G, l) s& I, K
- mov dx, offset msg_fail
' z. X- N# X1 Q5 m$ y - call _GET_A20_STATE_) `( b4 o/ B2 x+ y- i: ^4 ~ `6 ^0 w5 c
- jz exit1 ; was a problem% K/ }5 s' L* X* v
- push ax ; Save state, AH 0 }! y/ W1 q0 C( ?1 g0 V
- mov dx, offset msg_ok ; There wasn't a problem # g1 C$ Q( c7 m
- mov ah, 09h ; y( A! F5 @' h- a+ J. \! F
- int 21h ; Print message
) Q/ m3 Y. U* X4 R* E9 \ - pop ax ; retreve state
0 }: }0 q0 {, g- n
- I: \: B% Y- L- mov dx, offset msg_dis 8 {/ Q* X: o7 x
- and ah, 00000010b ; bit 1, 2h, indicates state
: X* h. Q' E3 T* m3 |% W0 h+ Q - jz exit1
( `+ {; z$ L3 y1 E7 W/ g - mov dx, offset msg_en & M. m% t7 s7 @. W3 h
- 0 o9 \4 Y5 Q) g$ R# c
- exit1: mov ah, 09h . o/ n* _$ i/ g j
- ; DX already contains address of string
* s1 ~' E0 T5 I7 ^6 H$ q& @ - int 21h % q) `- ^. {# @$ n3 j
- % X" o. u! l9 Q' h7 `
- mov ax, 4C00h
6 T0 Q9 h4 c7 d$ W3 C- X - int 21h 0 ]/ m/ Y# y5 r& L! p% }
. U" x( W4 w* ^3 Y' B9 r/ O2 I- msg_ok db "OK", 13, 10, "A20 $"
! L8 m' d/ Q3 } t* {3 O7 L1 T - msg_fail db "FAIL", 13, 10, "$" - m; }% E- n' S6 |0 W, u: C9 X, M
- msg_en db "ENABLED", 13, 10, "$" ; o5 X. ]2 |1 K7 S
- msg_dis db "DISABLED", 13, 10, "$"8 w# { g. Y2 _1 R4 N
- ' O8 {& n( z4 P% Q; k3 q3 d" T, V
-
% E' R C s0 v, I - _GET_A20_STATE_:
/ c$ x6 b! c8 F+ F6 h4 M, ~ - call A20Write ; Wait till the input register is empty ! i/ {1 S) |6 \8 _# n- R
- jz exit2+1 ; Bypas the reset int's
- Q; \3 J/ ^1 |$ X* T; x L% L: k - cli ; Disable ints so we'll get our value
) H% Y( C& i, t2 ~" @" y
% E$ p/ v- K) W" l S5 `% a; N- mov al, 0D0h ; Send command to the 8042 command register
$ n1 ~% ]$ M; W5 x, }2 k; N - out 64h, al ; to tell it we want to Read the Output Port
: E. I& \4 d, S! ^ - call A20Read ; Wait till the 8042 output register
6 X- I+ B+ t: } v' `2 o- W - jz exit2 ; has something in it's buffer
4 C N5 V; ^6 D G& M+ W6 y
3 F! i& O2 j0 I, O+ T& {0 m" F N- in al, 60h ; Get it
1 z6 d6 z- b4 Y1 T O U9 n - mov ah, al 9 C0 z2 }0 D/ [- i
- call A20Write ; Make sure the input register is empty
) ]4 e9 n! h3 }3 a - jz exit2 9 S7 D- `0 \$ H% ]
0 a: C; D- S0 |0 E# i4 b' ^2 V4 _- mov al, 0FFh ; KBC NOP command, does nothing
" D$ _8 c- J& [/ g - out 64h, al
) R2 P' n% t; B - call A20Write
( b2 r" f6 h/ w8 g' j0 ]2 j
6 h h: S0 F8 l, Q- exit2: sti
% q, Z: L! \. y- t% Y* P - ret' V/ N) f# W- }5 J5 E( A
- & @/ W5 U% G) e/ r# X v( \
- " o' f4 w5 P) x |5 l4 j- o8 T
- A20Write: xor cx, cx ; Reasonable wait
" D4 H/ [9 A. d1 R0 a# A - get1: in al, 64h ; Get KBC read status
% P& a$ M0 D! G; O: ^# d - test al, 02 ; See if buffer empty, bit 1 clear " O% W: u- p `- {" R
- jz clear * A7 T; N( b. ?$ U* Z! b h* O# d2 {
- dec cx
8 ]& [! E* V% L+ t) r - jz exit3 " d9 \) Z$ a o+ K- m+ j
- jmp SHORT get1 8 x: W, [) U0 Q6 n0 x
- clear: inc al ; Clear ZR
: s3 R& c( t0 n+ C( S - exit3: ret 2 R: ^" @2 l6 V. j- o! y# O
& R+ u, X# _$ b, r& ^6 @' l" \- , T& S- o# b6 p" L' g5 X3 E
- A20Read: xor cx, cx " Q8 c! t, m' I, L2 R; T5 @' @
- get2: in al, 64h 1 m0 a8 y' N. J5 _. q& r
- test al, 01 ; If the 'output buffer' is full, has * N" V- M" s4 f( I! Q1 B% V
- jnz exit4 ; something for me
0 Q8 V$ I" `6 ]* Y% f. c& h, { - dec cx
8 w1 c O+ ?, i; r - jnz get2
6 u, _4 W; e2 h9 r+ u" g! N- u5 | - exit4: ret $ E* V2 v1 h& S: W* f: X
-
# y! {% U9 T! ?- R8 g - end
复制代码 |
|