|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM % X# `) ^, z8 L, M$ F! `9 e
- ;
" Y& ~$ x' m' ?% b* I - ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01- k0 d1 C; d% ^5 K2 j9 r. w
- ; ml A20ON.asm : H; w1 P0 y# p6 H; u
- ; + o: h$ A9 @0 \! ^; E3 w/ l) R y
- .model tiny
$ e( Y; H& S: o4 r$ N - .code
4 ]+ |' @; o" x - .486
7 J) O/ T0 W" ~ - .startup
7 ^5 h$ _% t3 {8 ^ - F2 Z; D- Y# R0 L5 N8 F! C, t. i
- mov dx, offset msg_author
! A l3 B2 K5 Z$ Y: t* b8 e9 E/ E - mov ah, 09h
; h# `0 b9 Q. v- C$ V - int 21h
4 Y o0 e4 u! m3 Z w0 E) V - ) |$ a- L K" ?4 M* K( X
- mov dx, offset msg_fail : g9 s2 K% z) i ^& ?
- call A20_ENABLE, E% ]9 y n. y
- jz exit1. |7 c" p. H- G! P; K/ Y/ Z5 T0 u$ V
- mov dx, offset msg_ok
1 y+ [: L5 ~$ ?7 Y - 9 l, [2 W' W% ]% I
- exit1: mov ah, 09h $ Y) s! y: k C5 O9 j3 m
- int 21h
: _* t; E0 Y1 y. N( R8 K, { - mov ax, 4C00h
9 R% T# p9 K, p) j - int 21h * c. e- j, O: i0 j: y. U4 @
-
4 b$ l( w X+ {) v3 A - msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,. N5 R5 c0 b4 }3 d6 t
- "2008-07-01",13, 10, "$" ) p# B/ t6 e8 x; \, |) p
- msg_ok db "A20 Enable OK", 13, 10, "$"
/ m" ^( E2 Z* }4 U3 l) g. K - msg_fail db "A20 Enable FAIL", 13, 10, "$" * f: _+ V9 w8 r; b7 i* E2 ]5 m) m
- 3 |7 D* q- K, V3 ^2 `
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------0 H* T% c g: g. B/ Z- Z; N# J
- A20_ENABLE: 1 K& ?9 G+ u8 T+ k; `4 s/ m6 B0 f
- call A20Write 1 f: ]: v' a4 x
- jz exit_enable
& F; i! I k) L' s# g; _: n - 9 L! W, Q8 |6 M W
- cli ; Only need for reading value from KBC
8 a. N! j* t5 A; d6 U - mov al, 0D0h 2 }( ~- T. C# P! j
- out 64h, al & R8 Q4 Q0 Y$ K$ h- b3 w, W8 ?
- call A20Read
1 g1 r9 u; w* b1 T' x# i( r$ b - jz enable_int
* {$ D4 O: U' j8 x8 C Q
* c. |6 c3 M" ~1 `0 S- in al, 60h ; Get current status 2 l* n+ I3 h# n3 [
- mov ah, al * y; f% [- Y% s! y$ I
- call A20Write 9 ^& N! E0 v# `
- enable_int: sti
' ^3 z {* m& t - jz exit_enable
. h) u) i7 p7 ~( N5 E( f
& C3 Q( P1 U |7 p4 g0 h* H- mov al, 0D1h ; Tell the KBC , want to write to the
% {6 K' y Y* ]; @1 I7 ] - out 64h, al ; Out Put Port next
8 M) h% `% \4 L; b1 V - call A20Write 4 V6 s: U" l0 x5 ~
- jz exit_enable
5 w' S6 `" J2 D6 Z2 W
5 S3 u8 y+ X2 u% k- mov al, ah 7 G! k& ]2 t& W' P
- or al, 2 ; Enable line A20 4 _- m4 ?# p: H/ Z, S$ B
- out 60h, al
; G+ Y' W) T/ T, y* [ - call A20Write 3 H; i0 \* L7 R- j& I$ _; s
- jz exit_enable) W5 F3 d9 U1 D9 |
- 3 a# t$ r' K3 a
- mov al, 0FFh ; NOP
1 T. Y: D1 X V1 P - out 64h, al
8 f3 O) [: ?' @3 z3 Y - call A20Write
1 Q& O- n8 W/ r
* ]7 ]; ~0 A5 E5 Q5 J- exit_enable: ret
! c) W' U# {* \. O& x* L - 1 @% F3 I3 h+ A7 U- l5 B+ o& v
- A20Write: xor cx, cx ; Reasonable wait
- z- b3 P8 e# N. u( S! v - get_wirte: in al, 64h ; Get KBC read status j& _$ _- k$ ?/ C5 V2 O4 v) Z) @' ^
- test al, 02 ; See if buffer empty, bit 1 clear + Z7 m+ I+ W/ M; D0 x; ~
- jz clear & X# ~ s2 c V( e; u2 V$ n0 |; I
- dec cx
( v- n2 }1 ?: V% r' v9 f9 M - jz exit_write / L2 [8 A' k+ f9 H+ s* P9 L
- jmp short get_wirte ) ^. T6 S- K4 Y! _6 N0 N
- clear: inc al ; Clear ZR
8 _& \8 R, _- q - exit_write: ret $ u8 P: V3 \: ?
; I3 g1 i d3 e+ ]# z y6 Z
( i8 ]8 Z K$ W5 n+ n- A20Read: xor cx, cx
; x* J# ?: p: G - get_read: in al, 64h ) x4 W O1 h) ?, K7 C. z
- test al, 01 ; If the 'output buffer' is full, has
W0 K) G3 M# O9 ` ] - jnz exit4 ; ... * _4 ^4 u7 Z8 e4 u1 r8 D7 H2 q
- dec cx ! p! h3 L, h" t
- jnz get_read: q. Q5 J+ F7 h* w
- exit4: ret 3 V( y. H; c' [
- * @; d2 c$ u& }$ P* K8 q8 i
- end
复制代码- ;A200FF.ASM
9 W4 v. Q7 Z' J" n& J - ;
9 K5 l3 C& L' ]* a& G3 S - ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01* i) J9 z- `( K* m& N3 T9 K+ ]
- ; ml A20ON.asm
0 o, o7 E) P0 e3 h- C1 O: a - ;
: s9 G4 ?" Q# {. e0 `1 D' N& O - .model tiny5 d1 W4 E+ t" @7 n& b. Z
- .code3 d K( n" \" n
- .486
. f+ z! B* O9 ?& J, \! @8 T3 i - .startup
/ b8 w$ T% \% H- @4 w0 v. |; p' Y - ! q% G# y0 ]5 }7 C! Q
- mov dx, offset msg_author J' K2 D: w6 e. x
- mov ah, 09h
% ~8 o" `/ T/ P$ r) R - int 21h
3 ~% B7 c! G( K
9 z6 Y% ^0 _! D- mov dx, offset msg_fail
$ W( u$ W$ S! a! T# }. L - call A20_DISABLE
& q/ ` C/ c9 \1 j$ p! V1 F& i - jz exit15 I& s" P" L; a/ f
- mov dx, offset msg_ok
" ~3 L/ t3 l/ I
& a' y; M4 I( n. P9 e7 Z) }- exit1: mov ah, 09h
) [; y; l* |7 H9 @ b" _, [ - int 21h
1 I6 u: w: k2 g/ T% K+ L3 o) z - mov ax, 4C00h - _; b Z8 D4 c, ~
- int 21h
8 E, _! L, ^. K; f -
! U+ [* K$ Y1 l - msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,
" A# _6 F' @2 \9 R( v7 z - "2008-07-01",13, 10, "$"
( G% u4 J4 [; q6 U - msg_ok db "A20 Disable OK", 13, 10, "$" , Q+ h8 i6 x1 N* s4 b& z
- msg_fail db "A20 Disable FAIL", 13, 10, "$"
" O$ ^6 N# l1 c, | - - x6 a1 k( v# N1 {
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------9 e' C) j7 J# l5 }$ d3 J6 W9 q* X
- A20_DISABLE: 6 `( N0 C# X! P+ V. T. s: R
- call A20Write - r$ r n: H) A5 P0 q' M
- jz exit_disable$ o* |+ L' a6 [# Q8 J/ |
- " X# [' F$ |1 \. h
- cli ; Only need for reading value from KBC 0 M0 B) a6 j3 `/ L; F" l
- mov al, 0D0h , {- [2 K8 t) _) p5 g; N/ ?
- out 64h, al & I7 G; S+ @! R/ k9 \+ C3 U' b: j
- call A20Read V; L+ f: u) ?- w
- jz Disable_int
1 z k, e4 M: n9 Y - ; ~. X; f( ?- q. P a' \- ]( g
- in al, 60h ; Get current status
5 O& ^* @$ [, o7 K - mov ah, al
3 r$ e0 L& u( Z2 N' @4 o - call A20Write . D$ F7 |# Y+ N# d7 M
- Disable_int: sti
/ v- J1 m* F" _& d) q9 B+ M9 g - jz exit_disable
' O; Z/ F: L/ F; w( H$ D9 s! M - + K% b, ~# L: M. ^
- mov al, 0D1h ; Tell the KBC , want to write to the 1 _! y& }6 w$ O9 s% o8 t7 F9 t6 J- m
- out 64h, al ; Out Put Port next $ m. ^$ C4 F* i4 c
- call A20Write 0 \+ H" S/ ]- c: W) T2 M* n( e
- jz exit_disable0 R& k# n0 y' w) C" u4 h
- ) j; K! S+ p3 s* J, A, [$ d
- mov al, ah
8 d2 W4 B9 I3 N; x4 a3 U! H# I - and al, not 2 ; Disable line A20 ; Z, f9 s5 Q* O! H9 B0 Y" Q4 {8 G
- out 60h, al
$ R% J4 v) r& y$ }( h4 v - call A20Write * Q) |+ ~# t8 s X+ e2 _4 |
- jz exit_disable
% p/ D% I+ A/ ]$ N/ ~
' B% w+ A; i2 t+ f: R- mov al, 0FFh ; NOP
1 L- r0 j. Y4 t: j6 s& m% ^ - out 64h, al
& D# w. Q$ o3 _3 }/ n3 j - call A20Write
0 W/ z2 ^* ^! o5 A - # S; y, t, a# Q( E( [
- exit_disable: ret
+ J y9 K5 J: q h
' u$ y! P5 t" V+ \' \" g' K5 ?" [: R- A20Write: xor cx, cx ; Reasonable wait
+ @8 i; P( I6 x/ f - get_wirte: in al, 64h ; Get KBC read status
( T. M' R; z) t4 W: ]3 x4 M5 t - test al, 02 ; See if buffer empty, bit 1 clear
e' \" k) }! U2 A2 V9 ? - jz clear
+ K& Z$ r8 C: q) P+ y# ] - dec cx
/ g1 ? E8 t( ~6 ~+ Z) C - jz exit_write
+ M: g v( b7 K+ g5 z5 k - jmp short get_wirte % x( j3 q4 F! P j
- clear: inc al ; Clear ZR
7 _" A- V# X3 g - exit_write: ret
5 l5 B& X" E; A# G
: X' [: n C, }& Y. p( q: }- l
0 W+ d) L& m& T9 T8 ?- E6 D+ q- A20Read: xor cx, cx # c" J n2 L* f
- get_read: in al, 64h 8 d9 z7 I2 V& E( T7 N& @" S8 B
- test al, 01 ; If the 'output buffer' is full, has 3 R* L1 R; E$ x5 m! j
- jnz exit4 ; ...
2 i3 y0 K/ t! X/ H% |6 [ - dec cx 2 w; T% y* x' [4 v& Q
- jnz get_read" t: R" }9 z0 i8 _
- exit4: ret . S/ [6 L" p! M$ C) ?
-
" r9 T7 h& l2 K' H+ U7 w. x - end
复制代码- ;A20STATE.ASM
/ T5 u f$ o* u4 [ - ;
" v' K9 z+ u- T! \" j3 y - ; Returns the status of the line A20 through the KBC
" |- v- s: i3 U& E* I+ r - ; programming by bini for debug. 2008-07-01
, i V8 T. C- u! ~/ c4 n" } - ; / K" d* F; }0 G7 |- H z
- .model tiny" v6 m9 C2 N' L: Q5 {* Q N: c
- .code
/ P7 c; @6 E9 R% ] - .486
& q( p6 g0 c& R7 W - .startup- W7 p- v# E* |/ M* n) g
- mov dx, offset msg_fail & ?5 [0 d3 S Z% r: x/ T
- call _GET_A20_STATE_6 [' ^8 L4 {$ E' H2 D
- jz exit1 ; was a problem6 K5 K* j4 r. O# K# W
- push ax ; Save state, AH
: o% j9 a0 M3 s$ W/ Q6 S; J - mov dx, offset msg_ok ; There wasn't a problem , M) L1 g7 _9 \, v" ~( M
- mov ah, 09h
$ a2 i* m7 P$ w+ R2 T - int 21h ; Print message
2 w: O) k# Z9 B# u d. h - pop ax ; retreve state 0 [: |3 x! |5 l6 |3 q
* `- {5 A1 e/ n- O4 G8 ?, y- R- mov dx, offset msg_dis
! w* p w6 R- E% x- |$ T. F$ X! Y - and ah, 00000010b ; bit 1, 2h, indicates state
' A, ]: E- k0 S. u9 |% B. n8 {2 ~ - jz exit1
' t- ]8 D, F" n2 H3 v - mov dx, offset msg_en
) Q, c% |5 K6 n1 j" m9 d
$ R. Z$ q) @" K9 b% C) k- exit1: mov ah, 09h 9 R, B! _6 A( @7 s
- ; DX already contains address of string
6 A, T! L' {) l$ B: Q* i6 T% K. D0 w - int 21h 1 l4 Z' n8 B$ O1 F
- & n# a; C# M- h' n; W: U
- mov ax, 4C00h 5 c6 W( @: k8 g1 m! B
- int 21h
3 W( b( Z2 p& v' ] }; t! R - 8 O2 u1 a* I! c0 H/ Y
- msg_ok db "OK", 13, 10, "A20 $"
, i- p. z" B3 E6 p% X, O - msg_fail db "FAIL", 13, 10, "$" . v) o" Z7 @7 D% T
- msg_en db "ENABLED", 13, 10, "$" : j0 N- {( H0 H6 `* C
- msg_dis db "DISABLED", 13, 10, "$"
( x% k) j1 q8 l" h4 q I - / B" m0 F4 _/ v
- 9 x% `2 l+ ?; q& W' S
- _GET_A20_STATE_:
9 g0 V% N9 J' f - call A20Write ; Wait till the input register is empty , M8 `; {' |( ~$ h3 s" ^6 }$ u4 _
- jz exit2+1 ; Bypas the reset int's 3 U7 ^. w# Q5 d4 Q8 e7 n) V
- cli ; Disable ints so we'll get our value t( c1 c) d, \+ m4 u2 E8 G
. J. j3 @$ w* O5 ^4 @% [2 M+ F- mov al, 0D0h ; Send command to the 8042 command register
# ]- L: _$ U6 v4 T1 K - out 64h, al ; to tell it we want to Read the Output Port
2 I; `& w4 C' `/ j! j+ a3 n - call A20Read ; Wait till the 8042 output register ; ~* |7 I5 b+ U5 ^) x1 q
- jz exit2 ; has something in it's buffer
; `4 ^. a2 f2 ^- H0 T
% }. g; u, _, Y5 |5 H- in al, 60h ; Get it
8 L0 S1 m: l$ n' o - mov ah, al / D6 K0 R2 Z& B4 }7 Y7 @
- call A20Write ; Make sure the input register is empty , h+ Q( d- L8 B/ t# T
- jz exit2
7 T- b$ k, `1 z$ x - $ O0 `* L. D }
- mov al, 0FFh ; KBC NOP command, does nothing 1 I+ b7 m( x# A6 M
- out 64h, al % C0 q! J$ x8 G/ e5 W- g, ]
- call A20Write
3 m, W4 r; j0 F; u2 A! d6 M( z - 6 Z5 u8 f1 X; n$ c& U- g: s' U
- exit2: sti
1 G* ~2 n) t5 T8 {: `! T! h/ H - ret
1 I5 E* {: ]& j3 I! i
& r; f$ x" R" F) Q4 y3 }; k' ]- % F3 [' {5 v3 F& }" h; T
- A20Write: xor cx, cx ; Reasonable wait
* G1 W$ V3 S3 I6 K - get1: in al, 64h ; Get KBC read status ' J1 H# d. [. }7 n1 \7 H0 b: u
- test al, 02 ; See if buffer empty, bit 1 clear 8 Q1 x( U# n# u3 b J& J
- jz clear ; i3 Y0 E/ n' U- j, M* q
- dec cx
3 o' q7 `' d. U% {$ l1 Y - jz exit3
7 L+ m9 @) o/ c- v2 Y - jmp SHORT get1
1 x' x. s7 M; R( Z s - clear: inc al ; Clear ZR # w" e X$ Y1 u" ^0 ]1 S3 g
- exit3: ret 9 {, ~, l0 x. g: \: B" a& ?+ K
" S0 T6 M$ k' I- 6 ], j8 ~ g* r$ H
- A20Read: xor cx, cx
* H2 X* }" l) l( @0 s6 \ - get2: in al, 64h # O. G0 N6 }3 J* I
- test al, 01 ; If the 'output buffer' is full, has
" x8 J: h3 ?7 k# ` u- ?; C c, W D3 K - jnz exit4 ; something for me 4 g7 H0 {. B' N& Q- ~
- dec cx
4 ?6 C' `! K4 I# n; Q - jnz get2
' J7 a, ~) e. t, E! z" S - exit4: ret # _% K V" {3 k' d/ @, K* F. |: D- o
- 7 i% Y; \2 C! Z' o" T
- end
复制代码 |
|