|
|
根据bios代码写了个SPD读取,就是不出结果,每次调试输出host status register都是FF,代码基本和bios一样,机器也是ICH9的机器,代码如下: 3 p9 \ F' l: G% f6 V6 @9 n
' B0 A L% }; T. ?. ^& ~0 y& d+ V5 C7 p .model small
0 U% A+ Y; T5 y3 K5 x4 S$ } .386
/ @3 J8 ~5 r7 a CFG_ADDR EQU 0CF8h0 L' y( W2 C/ I# p
CFG_DATA EQU 0CFCh3 C3 y" J9 a; R7 F$ S: `( i! t
SMBUS_BUS EQU 0# r; [4 O& O/ _+ F i
SMBUS_DEVICE EQU 31% @% T+ q+ m' S5 E
SMBUS_FUNC EQU 3
& h; f# E* y6 L; l! _( \ m+ O ^$ ~! n. t: U1 _9 L6 s
.stack 100h( q7 m) ^3 b3 z+ k A
.data
* Q+ u, q3 f. \# I s, Mbase dw ? ;smbus I/O space
+ u' w) W1 b7 k; Gnum db 0 ;byte select, W% Z! C& I* p9 e
SmbStatus db ?
$ _! W9 M2 }( O' V) U/ R3 ?
/ V; A7 P1 i* L .code" [3 g2 [) e$ d3 R3 `3 n+ y4 S
2 J" Q7 N1 p4 u) Q8 HLF_CR MACRO# `; y, F/ i5 H4 Q! c" h( d
pusha
$ z( ?! e2 o+ G mov dl,0dh
0 T0 s1 S* B F% P mov ah,2
* D1 T: Z5 K8 n4 [" z$ r) b, x int 21h- p4 N$ z% @* O6 `7 S
mov dl,0ah ;next line . w. x% B' M9 s A2 g, N
mov ah,26 E4 l; z+ U) |0 W* v
int 21h
; b! e& _/ L- R. k* k popa $ Q! g! J* _3 x! s8 T
ENDM: @' N+ z2 d- H" ?$ K% o* W
7 y; M# M# i7 v9 R$ j% }
- \" X0 A- U; G% xmain proc far
7 R1 ^0 w; Y | mov ax,@data
5 d; T& r* f1 b mov ds,ax- B) N! @3 O# q+ y
( Z" N: C; m/ r6 ^+ z* ~5 L' H
mov eax,8000FB20h ;Bus 0,Device 32,Function 3,20h
& U; O5 v9 O H5 i6 D0 s8 g mov dx,CFG_ADDR. {! ?- T" e. z& O/ k
out dx,eax" a+ g2 i! `2 p8 L
mov dx,CFG_DATA
. f! p0 ?# H% r" G in eax,dx4 _7 w- }0 ` @4 [8 k! S1 N1 f; f
2 A0 a% r4 J# F% u
shr ax,5 ;bit 15-5,the base address+ H% {: f5 o. }* z
and ax,0000011111111111b: x+ e1 V( \5 D) _
mov base,ax- a4 A- l5 l$ j
$ a8 N- J% v/ b R
call ReadSpd
9 p- A: f; ?- i! m& O/ dexit:$ m R* b, ^5 H: r' |4 c/ c1 |. l
mov ax,4c00h: N! [( u/ C4 Q/ N4 y5 K
int 21h
2 a( t" s( Y6 u, B/ N+ l% T. O& `main endp
# W" J" O, U' M' N: F* j: P! `4 R' C0 s7 c* L. J6 O
" r* B% F# ~7 Q7 R/ T7 \; M9 p( Z+ k% k9 S* Q b
ReadSpd proc) s, |7 D O" Z- V6 H3 c7 l0 i; x9 i
pusha8 h. e- @) L3 B
Again:+ t' H' |& y) Z2 X7 W
mov ah,num
# _0 a8 F7 d" a. u8 k/ E and ah,00001111b
" b; y' ^( q7 ~" ^' D .if(ah==15d) ;CR_LF
- \( }$ ?4 Q) p; h LF_CR
: j* e8 F5 p7 V2 D! d .endif; {: X! c5 Y l% C( ]9 W
3 |! u" Y6 O" \
.repeat. M# f+ r7 w( |: H) v# b" b
mov dx,base ;reset host,claim host in use- I" t5 z. r9 A! C$ U* U
add dx,0
$ }9 d$ f- [4 G- r' m& E mov al,40h1 Z7 O8 x" F4 W
out dx,al+ N* D. A! \; d) J2 |
5 m. j g* |$ J. g3 o mov dx,base
0 Y0 p( A1 q) ?; Z in al,dx
4 F& d# \7 r4 M mov SmbStatus,al! X/ [7 A; y/ |
; f& Y4 {1 A# l V mov dx,base ;clear all status bits: a+ l0 b+ V6 }5 p) _
mov al,1Eh ;host status register: T& Q/ U0 d9 o% T# _: J
out dx,al* I6 ~3 |2 C6 g3 u
7 w# e) g4 u2 G9 d mov dx,base ;set offset to read 1 P6 L5 C( R: c% k+ y# G. X: p
add dx,3 ;host command register8 }1 u% ~) w% ^" g, @! q5 k; l
mov al,num
) d" S+ I6 X' u# j3 ? out dx,al5 N' V% |! {) }( d" `* a/ x* |
; _7 D4 |$ u' A mov dx,base ;Transimit Slave Address register! Y. A o8 ?- g! P2 A3 |2 L7 h
add dx,4& ]7 ]: t4 Y" L# J P
mov al,0a1h+ F, x1 W. y0 b# J% |* J' ]: U$ v% J- ~
out dx,al: l8 H/ A0 y7 K& x( H0 ~8 c8 S
- E Y( X0 L, X; p0 I! u+ f2 |' G( V mov dx,base ;set "Read Word" protocol and start bit
4 l6 ^8 @4 @# m* v8 q+ C add dx,2 ;Host Control register
+ G3 ^( h0 u1 B4 f) o mov al,48h
! u, v; B- V/ B" [* S. s2 | out dx,al
- u; G7 G0 ?2 a: N, [4 M # r- |6 |0 Y# }* T
6 g- [1 r% k- D
( `, ~2 H- X, H/ r3 `/ Q- [ g mov dx,base
0 M3 }7 d! T$ u' |& ^0 q/ u in al,dx
3 n/ ]& @1 ~( Z; s mov SmbStatus,al: v/ a5 ]$ P) ?) N4 E1 D
and al,1Eh3 L3 O8 w4 p) ]$ x& e
.while (al==0) ;check repeatly until any of
0 S2 Q, O' J- q! m( l% W mov dx,base ;FAIL,BERR,DERR,INTR
- ?, _' T2 p7 b in al,dx1 l9 p' A2 F' _. |3 X; C! {
mov SmbStatus,al; \( N6 J4 d5 j" V* g$ L$ G7 D
and al,1Eh ) R+ F! K# V8 G+ F9 L
.ENDW
2 u2 F2 F' @6 K9 c9 o( m
" @6 e5 ~& R& ], W mov al,SmbStatus
. t. t* _7 Y: X and al,1Ch1 J1 T/ t. @$ j5 z4 w. l1 ~
.if (al!=0) ;check for errors 9 B9 ^! b* S) E% C- i) m x) |& e5 t
mov al,SmbStatus
' a1 G) P1 z$ [& K4 e0 |9 A and al,08h / U' }, Z, ~' o0 O: c5 c7 Y
.continue .if (al!=0)
5 q9 v7 w" e( ~; s0 d- I. q) ?4 m$ z F jmp @F ; t- K( b7 J' s" J: i' L) B
.else, D2 f0 D1 | t8 |% R, |, H) P
mov dx,base* @ {2 X& `, U& Q5 O t) a b) y
add dx,5h% m( l! e9 O8 F9 \" @
in al,dx ! g. U7 v' L |; ?, u% p. J
call binhex 0 U5 A! {1 t2 X. a+ J
.break4 {. h( t3 v. M- X( u
.endif
. N8 V- J/ F8 U' U8 j # S% O( r8 m- @1 J& m0 h! M
.until (0)
3 I, ]+ \+ R9 V% O, F m( a$ W
1 ^$ O. i1 H J4 H9 s! y, l- n
/ N' p' T3 \# S/ a# c" ~: v; m
( T6 J8 _3 Q' z" n mov dl,20h ;output a space
* X, |2 _ Y+ ?' N ~2 ]; v mov ah,25 B+ k4 b- N: |- M
pusha
+ }4 `3 M' f } int 21h
9 c( e0 r7 @# t/ h/ H popa
) n0 {. Y& c$ @0 T5 `- N inc num- k3 C8 J, K: c1 c. c& g3 L7 b! h
( Y! }0 S# U% U2 ~! Z. c4 W5 J cmp num,80h ;get first spd 128 bytes % z8 n: [( X$ ]- ~) }' ]" x3 Q
jnz Again: c3 H5 Y) G F; N' s% o
3 M% ]" @, f) a4 V4 o
@@:
5 V0 H+ b. m8 j; m o, _( Y popa' {+ @( Y+ x! S
ret
* ^7 u) o& }0 T0 ]6 j6 @ReadSpd endp4 C) `9 _2 g0 E% n d$ h1 I$ `! C
& T+ v2 \, f5 m6 d& G2 C: {9 A Z/ ]
+ W6 t! o0 y! _1 y
binhex proc " v. r. U3 B: K" A! j+ x
pusha 9 U% c9 ? J% l2 L$ j$ ?" N
! ?, j/ W K9 l Y! a7 `
mov ch,2 ;2 hexadecimal digits to be printed4 c9 w1 _/ H& a
loop3:
9 M) B( `. o0 i: E/ s- G9 q+ X, i mov cl,4 ;bits to be shifted* c: A# E" K2 |8 x* r
rol al,cl
3 `3 z6 Q F0 U mov bl,al
4 T7 m8 ~4 B7 y* h% x and bl,0fh ;mask the 4-bit Msb J7 F" X3 i9 G" H) y9 n6 m
add bl,30h
7 S; I5 B! H9 z& g. Q; O0 i5 O cmp bl,3ah# ]( }) n2 P! I
jl next1 ;number or alpha?
& s& |7 t' z% ] add bl,7 / I: m- k6 C2 _4 I' y8 i
next1:
5 c, Y, s7 L2 L* @/ \6 \ mov ah,2 ;print one hexadecimal digit( L+ H+ B) ] d1 |$ D' U2 ?
mov dl,bl
% V1 L+ A+ i: n pusha
5 X$ G% B0 k, D int 21h8 x, W; j- P6 t9 t" I2 i# u
popa! D- \" x9 V: q1 U
dec ch8 R B4 d0 G. r* w
jnz loop3+ y3 Q8 h# Y- @0 z9 N3 W" B
popa
4 H% j3 {" D5 Z6 [+ c ret' F8 B. Z0 `$ j q% P L8 n* H1 C
binhex endp7 J3 M( ?) b* W/ a) Q H4 B
end main |
|