|
|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM 9 g' C9 `, Z. @1 j6 M. H
- ;
- c, V' K( f' C: N9 [ @ - ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-010 R! O8 S9 A; J3 ]
- ; ml A20ON.asm ( X$ D7 M1 B# h) r9 S
- ;
" F! A3 f* y( q& g" M) {8 F - .model tiny
; Z; m4 J; F5 f7 N" z( I - .code( ]- P7 f/ J) A
- .486
& r7 H7 _2 _4 D! k - .startup- i1 l2 F4 ?0 K* ~
: E1 v& d' d o; C, ]! b- mov dx, offset msg_author
& Q1 ~' }1 F9 t0 _ - mov ah, 09h! S! T$ k) L, P% x Z% y
- int 21h x+ r& p9 B, Q6 J" e: x
$ S, V# Y5 k) V# t- mov dx, offset msg_fail
7 o3 ?/ d O6 B: q9 v6 ^ - call A20_ENABLE
/ f% q- w6 p- {9 c$ Z4 E) U - jz exit1
; {( @: x- [! z" `3 T5 Y - mov dx, offset msg_ok
2 a- }1 {5 ~( T7 E2 `0 ~, J/ B* F
% t1 q0 ^' S! _- exit1: mov ah, 09h
4 T4 v3 u2 w# W; J& R4 u K) w - int 21h / p+ s. d# l- a1 M3 w
- mov ax, 4C00h ( a* t+ V# {4 u7 q- Q
- int 21h
; B- q4 p7 @3 t4 s T - ( Z. \, X; w% S* ]4 H P2 _
- msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,
2 n6 }! ]! Z4 ^$ V: S" N) W4 g* B4 [ - "2008-07-01",13, 10, "$"
, t3 a' d; \7 ~9 n1 k - msg_ok db "A20 Enable OK", 13, 10, "$"
* ^% i& ~% b& F; n& @ - msg_fail db "A20 Enable FAIL", 13, 10, "$"
) k) D" v! ^3 H0 t V) s4 X3 C1 L! S
, |' S# X3 V8 {6 g( S# c7 E- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
p, a9 d p$ i& ~7 d1 R- t& A - A20_ENABLE:
8 H& g- c: ` I4 q: M" m - call A20Write $ x) ^: `% m. E9 Z4 k5 t
- jz exit_enable
" [( {2 c: B9 p; d( o6 I# U L - + @) ? O! g: y0 E
- cli ; Only need for reading value from KBC
* L/ D5 o8 l: X! R3 O+ z% @( ~ - mov al, 0D0h
! l9 E" L9 z9 S$ h2 X8 m' A - out 64h, al : _; g6 U; }1 r
- call A20Read
" ^6 }$ o5 o- ^ - jz enable_int 9 [; s( z- f& W- K$ o& V9 {
: [6 M( B% v0 q7 C! H2 |0 A- b6 P- in al, 60h ; Get current status
* [# j% @. F* F - mov ah, al : i( y" U* e. L! Z: o' O7 i( N
- call A20Write
; s7 b. K2 c# k - enable_int: sti
/ Q+ d/ P2 N: @; J6 L: v# b1 H7 r0 D - jz exit_enable: t3 t0 z, w2 g* n; `% c1 [/ @3 d
- 6 ?1 D: m8 Y' n8 t/ T8 j1 U
- mov al, 0D1h ; Tell the KBC , want to write to the ; |( T {2 I( c( {
- out 64h, al ; Out Put Port next
4 L1 y2 D/ Y9 f) o - call A20Write
1 A; L9 D7 v" W; A/ A$ [ - jz exit_enable
2 i- v' d6 v* `; k. H S" H - + q) e' N- K" l! P) I8 B3 I: @
- mov al, ah
, t9 p% Y c- u0 Z! c: u - or al, 2 ; Enable line A20
5 _2 A! q& N; e, a. b' R - out 60h, al ! P: ?" b. Y# w3 P
- call A20Write & X5 X9 h8 p5 }2 G9 Y ?% v
- jz exit_enable n& `' M/ Z3 W4 Y4 n$ Z
- " A. f# S% m" Y- {7 ]/ [. a) o9 d l
- mov al, 0FFh ; NOP * z( @$ Q, A& \9 l: ~& |
- out 64h, al % e/ G8 ^4 Q" x" d3 X$ g8 j8 b* `+ ~
- call A20Write
1 [9 F2 a X8 D/ T9 {" @ - 8 s- F$ z! s6 h/ W" U, ~/ V( P0 T
- exit_enable: ret ) }0 D: S! b( g" @* @* u( v
- 5 q w4 E8 C, k) P9 [
- A20Write: xor cx, cx ; Reasonable wait
7 M6 h5 N: L9 _5 I - get_wirte: in al, 64h ; Get KBC read status
7 y" \9 ~7 x& Q+ p8 @3 B' c - test al, 02 ; See if buffer empty, bit 1 clear + W/ ]+ F, C- v# Z. N4 \3 ~( A0 f
- jz clear
4 T+ m( \) v0 p! R# P1 i# y, D3 X# a - dec cx
% _+ Y/ D5 n" q. l' T6 T - jz exit_write ) y; k& o; }* ]# C
- jmp short get_wirte
8 W$ L5 a. t2 [8 S$ P2 \ - clear: inc al ; Clear ZR 1 u. D) X- G* Z( {2 E
- exit_write: ret 8 Q! ]. p6 E/ q8 z/ T4 u K
- + }, J/ a- h- q+ O: k8 p' [
- & p9 F( |$ [7 z* F
- A20Read: xor cx, cx . B+ K- Y: R% ^) j% g+ p$ E* s$ r
- get_read: in al, 64h 2 @7 M3 F( O9 E- x' K6 a" n4 s, C
- test al, 01 ; If the 'output buffer' is full, has
6 `/ U, ~% m7 K - jnz exit4 ; ... 7 w9 ?- `& b+ O0 k& z/ u9 w
- dec cx
6 J4 p, _5 g3 e2 Y2 E - jnz get_read: b9 J7 P# }% B/ G9 n
- exit4: ret
- x$ Y* ~0 d) {% m% u& l0 i -
1 }- u3 z( P$ { i% U/ C8 ]1 | - end
复制代码- ;A200FF.ASM
# Z4 z$ o" H+ q5 z8 @2 U - ;
8 @$ f& o$ E0 [- s - ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01
* m: N' A" Z, k' a2 a; I( t - ; ml A20ON.asm
- K0 M2 `- T( Y2 t - ; ( R# N& s" W( b. Q
- .model tiny) I# o; R6 z) r# S6 |
- .code
8 D$ K% V$ Q2 L( w9 _, v/ K2 f" y - .486! d& ~, A; i% S S! v
- .startup
3 F9 k9 v9 C* V- x# ]4 Q6 a
. s$ M8 A# g6 V/ ?" `$ i4 C- mov dx, offset msg_author# @. V+ p& Y) B0 `2 P' [9 P
- mov ah, 09h4 K& h8 i; U0 V! x
- int 21h
G) R( A: a. N& r" ~# f - 0 ] W# J6 d5 n
- mov dx, offset msg_fail 2 b% q6 z1 _/ D. f r# y
- call A20_DISABLE
8 T1 N/ R7 Q0 x3 n( P/ E - jz exit1
7 e$ Q# O9 _2 V1 P+ R - mov dx, offset msg_ok 6 k7 [" E# N5 q ` a% g, n
) Y8 r8 d: s% f' k% D* G& y9 I- exit1: mov ah, 09h & i, t# f. ]% e" Y, m
- int 21h . \8 x4 W5 Z" r4 G6 s9 [7 h
- mov ax, 4C00h 2 d1 G) A2 y, M! t) g$ @: U8 F
- int 21h . Q$ |* I2 p/ G |
- / M* ^; T: R2 y, a, p- X7 Q$ y( I
- msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,$ _2 Y: | v% G1 x% v& N0 }) e
- "2008-07-01",13, 10, "$" 9 k T- r( M2 {. G: w* ]+ |+ O5 l8 _& {
- msg_ok db "A20 Disable OK", 13, 10, "$" - n) D4 b6 B) H6 [; O0 j" A2 G5 V* \
- msg_fail db "A20 Disable FAIL", 13, 10, "$" 2 Y; N0 f6 F# B1 g
+ h2 s$ s5 g4 T/ L4 C" S- ;------------------------ follow code maybe make to lib, if you want...-------------------------------4 k. ?- M3 f1 i3 K
- A20_DISABLE: # X& h3 B( N" Z$ \7 c4 E5 f1 ~
- call A20Write 5 u( }! D* `7 w( s9 h
- jz exit_disable
' |: s4 R5 e W4 T6 N2 y! o& E - V- R" q& q3 a6 ^3 F
- cli ; Only need for reading value from KBC
: y7 d: k5 F3 { - mov al, 0D0h 5 M3 U1 g* K: [ X+ K$ P/ J" v
- out 64h, al
) J) W l1 d8 a - call A20Read
5 e6 Y6 t: I' ~2 Z/ a) R5 d - jz Disable_int ! P1 \8 z( X% t: X' S! y
- 5 q7 F) o- N' P5 }) N E1 L, J
- in al, 60h ; Get current status , Z: d4 C" U) h/ |8 s3 H. R U
- mov ah, al ' }" p7 h2 V. }6 d- Y8 [1 {; k
- call A20Write
; O- f* d0 X, h L* a3 K - Disable_int: sti
/ p9 u" \9 [0 @" q* }, s - jz exit_disable* s% k# e' }! k% h
5 m# y! `/ U4 r* }. U. A- mov al, 0D1h ; Tell the KBC , want to write to the & C8 S1 [1 T9 x' g( U% z: p
- out 64h, al ; Out Put Port next
& i, C) @/ \ _ ?# A8 ?, { - call A20Write 1 K0 E2 v6 C$ l! W8 p/ N5 s) @& \
- jz exit_disable5 Z' y! m, r" o5 ?, ^- n
: o2 d2 Y5 \/ K# k$ A ?# t- mov al, ah
+ o, u2 h0 {5 T - and al, not 2 ; Disable line A20
2 z9 }$ r% k- X ? - out 60h, al
1 u2 |$ {0 M2 s: T - call A20Write
7 z- n" N5 }- {) v' E% O - jz exit_disable
2 L9 _" F i0 E2 r - . C1 o3 W" ?! D( Y$ s8 v3 ^
- mov al, 0FFh ; NOP
8 |% q' Q6 V7 e8 w4 _1 {. x - out 64h, al " W0 z, g- b1 T" M' {- r
- call A20Write ! I0 U0 r7 e) m/ }
3 C, }, n7 R" [6 H9 [2 v" J- exit_disable: ret
: Q, A+ W! j# ` `7 |" B0 n$ ?( ? - 5 M. e( ?, z$ [. M: B1 N. p% s
- A20Write: xor cx, cx ; Reasonable wait
2 V& E/ A# x" s+ d( @9 P% | - get_wirte: in al, 64h ; Get KBC read status 9 H) M. J5 b7 t0 Y9 _8 c
- test al, 02 ; See if buffer empty, bit 1 clear
' |+ e# O3 S7 T- u+ l - jz clear b& U6 d( z# [* b: f( H1 h
- dec cx 4 d! Y# f5 g8 `$ \/ p; S
- jz exit_write # B$ [8 y6 h+ Z, |* X
- jmp short get_wirte , x" c$ L3 \7 a* g4 s
- clear: inc al ; Clear ZR
0 B! S; `% j& O+ O/ a; W - exit_write: ret
8 D. b- c+ L1 Q - 3 r; V, x F9 N d: V
- : y5 [% s) p, V: k
- A20Read: xor cx, cx
# z4 G/ t5 h* M: I o& p - get_read: in al, 64h
. l4 `9 ~# g( q' A - test al, 01 ; If the 'output buffer' is full, has
& _9 j( Y& `+ K L - jnz exit4 ; ... }( p0 g3 s9 Z0 b m7 v& B; O
- dec cx * [, J# a1 Z" P
- jnz get_read2 m M! a* y4 j, r. @/ P
- exit4: ret
5 K' R3 I! b9 r$ }9 j, F$ W - 8 K! c( N# I7 p5 P g
- end
复制代码- ;A20STATE.ASM # e& j7 a0 z& U) q
- ; 4 F: f$ b( F g6 T
- ; Returns the status of the line A20 through the KBC ! h3 r* o0 G8 U3 H1 P2 B3 t
- ; programming by bini for debug. 2008-07-01' a$ \+ f8 a) I
- ;
% _( P3 @8 Q) Z0 Q5 S/ n8 A - .model tiny
8 C L: |! O' {9 M6 e - .code
) y0 R- B5 T' T, b' v - .486& U o# l" q7 F1 Y
- .startup
8 h0 f0 t' p# o3 t8 D- w9 w9 H. j - mov dx, offset msg_fail 1 t5 b0 x. I0 _, X* F% h+ F3 Y
- call _GET_A20_STATE_4 P9 D; R1 U6 c# z. `. W1 F
- jz exit1 ; was a problem: p, W' M9 `0 x! z$ @3 F! Z: F6 d
- push ax ; Save state, AH , {% S$ C% R7 W9 f
- mov dx, offset msg_ok ; There wasn't a problem
$ }0 G- N" D; [1 Z" Z - mov ah, 09h
. w& l/ [- m. V& L/ Y - int 21h ; Print message + h7 [! C e( z
- pop ax ; retreve state 7 G1 A1 z y5 }; f# i6 _7 J. a+ Q
5 }3 U/ [1 O9 z- mov dx, offset msg_dis ! w# U4 v8 h" k R+ h. x5 E! f& J. X
- and ah, 00000010b ; bit 1, 2h, indicates state * n; ?$ U* F( a* c O% V$ G" ^' d2 Q' O
- jz exit1
. j* u! b( |" ]& `! C" W - mov dx, offset msg_en
9 h: K0 T' d" T. {9 Y x - ; K) Q5 K3 `# V2 F' B/ ~4 N
- exit1: mov ah, 09h 0 N \: V1 D# t j
- ; DX already contains address of string " y8 b; `$ W# _6 r# ^) T7 ?
- int 21h
) g! a+ q2 i# i# z2 Y* K; l$ j
7 D2 c7 Q. T2 w% T, B5 @8 B- mov ax, 4C00h
; o8 d# v4 K N) q) z9 R7 t2 \ - int 21h # A+ [3 C; t* g
- 7 C; ^' e5 K% r( b1 r
- msg_ok db "OK", 13, 10, "A20 $"
9 |! M, X+ h* g# b3 s& B2 V - msg_fail db "FAIL", 13, 10, "$" ' S( y4 G4 ]- y- }: h
- msg_en db "ENABLED", 13, 10, "$" ( u; l% M4 h X3 ]- o8 {3 O
- msg_dis db "DISABLED", 13, 10, "$"
j# [* [4 v a$ ^7 o" \
) |9 }: w. P3 l% i-
S. h3 L! A. a6 V- O - _GET_A20_STATE_:
9 K3 v# Q. J- Q! x- W - call A20Write ; Wait till the input register is empty
5 p1 D% K; E; s - jz exit2+1 ; Bypas the reset int's
+ L; d# u6 Q; l7 ^ - cli ; Disable ints so we'll get our value
; Q% n8 I2 Y/ g4 c% q( i; G/ S - 8 p- D( o) P/ I. _8 j8 {/ r2 {: d: K
- mov al, 0D0h ; Send command to the 8042 command register 2 Q' a1 w. N, H2 E3 j
- out 64h, al ; to tell it we want to Read the Output Port ! \( Z4 n! Y, w6 p0 V J
- call A20Read ; Wait till the 8042 output register @# I( e% |; `7 Z! t: p& `
- jz exit2 ; has something in it's buffer
! N7 v0 c0 f, @ g - 7 t7 c- g4 T% P0 u3 Q5 u
- in al, 60h ; Get it 6 j+ S$ ]) H' B8 ]% V0 H0 ?0 y
- mov ah, al & h1 f; t" u$ E( B# e" w# S G- R& b
- call A20Write ; Make sure the input register is empty 4 Z0 G. X3 Y, f4 ?: q
- jz exit2
m s' K& M- u6 }
8 X ~/ p- k0 J. N U- mov al, 0FFh ; KBC NOP command, does nothing
- M" y- s4 q+ B" u- ^- E3 H+ B. v - out 64h, al
8 ~$ e4 P+ j% z. ~% J( c2 @* t - call A20Write / y* f8 l' a9 A/ t+ f/ p3 U1 P
- ) K1 ]' H$ d( e; }0 g
- exit2: sti
, f/ V' f7 h' f8 Y6 `7 |7 g, W1 j - ret
: t/ A) x; P! H1 f
* k) l3 Y/ {% k- k- " M+ \+ g* i; S: `
- A20Write: xor cx, cx ; Reasonable wait
& e! Q e2 g A. E1 }: `8 e - get1: in al, 64h ; Get KBC read status - Q3 i/ B }$ }: q. D6 K F
- test al, 02 ; See if buffer empty, bit 1 clear
2 e/ {5 {+ ~, }" `: ^# A - jz clear
+ h* f$ j# c0 O. D/ e7 P5 L2 ?" l6 A$ s - dec cx
. m& z2 Q- ^( w1 T: u4 a- h$ F% S6 h - jz exit3
8 L8 n) Z+ S' {6 S7 l! h" \ - jmp SHORT get1
* d# ]$ L% @+ d - clear: inc al ; Clear ZR ; h9 N# [$ Q; d I5 z: p; c
- exit3: ret ( ?4 [" w# y$ m" I7 Q
- ! W0 F* r, A5 g' m
- ; C0 q2 }' m/ d8 l. ^' P! p9 p
- A20Read: xor cx, cx
0 r9 ?, M5 X O) B8 C - get2: in al, 64h 0 k2 m1 \8 _8 v0 m5 Q
- test al, 01 ; If the 'output buffer' is full, has & p9 K( O; g% {% q* r9 h1 p8 _2 S
- jnz exit4 ; something for me
8 ~, j1 A! }4 q$ v; @ - dec cx : o' _: N# F' z2 \) P* b' K
- jnz get2& {, d1 g4 k5 W! {) }- u
- exit4: ret 1 t' I- h; Y* ?) [) {" o2 L$ W
- d6 H4 G* @$ f7 j$ X0 o7 @4 u
- end
复制代码 |
|