|
根据bios代码写了个SPD读取,就是不出结果,每次调试输出host status register都是FF,代码基本和bios一样,机器也是ICH9的机器,代码如下:
- p/ c0 {5 P$ D0 q2 X O
8 [; O! A, M& e .model small: \* a& g) y5 A; }7 h, b& R' T8 N
.386, B/ J L" i O9 Y
CFG_ADDR EQU 0CF8h
/ D# K& L" q W( s2 L2 c0 L CFG_DATA EQU 0CFCh0 T( c: N/ G. D8 H" C7 ~3 P2 C
SMBUS_BUS EQU 0
9 c9 l$ N d! ^8 F& J$ G$ q+ r SMBUS_DEVICE EQU 31
# l8 n X* Y: \& Y* r SMBUS_FUNC EQU 3
~ _. w. `; d; d9 K J 7 [& r2 U# ]# L: E+ c
.stack 100h
$ }8 n' d9 a' A( ^/ I .data4 Z p- _+ s7 X" J& b
base dw ? ;smbus I/O space
, c0 N' ^( S7 Lnum db 0 ;byte select3 | T& t- { x
SmbStatus db ?
1 n) o5 z; P0 V3 p) a) G8 l# ^$ Y9 ]$ J, A1 }( D
.code
, d# Y4 T& y3 J( n7 E! T9 A" r: | @) @ ; O4 X: A4 Z, v) V& \
LF_CR MACRO
+ y& U' b+ h; l8 G e+ Z! N. `1 U! G pusha1 Q3 V' C$ v9 V: R' c! V* j8 D- S
mov dl,0dh 7 e! e- ]/ L* f! w+ [: C7 D+ j
mov ah,2' k8 b, Z& P0 }7 L
int 21h
( t9 ~% j: c5 f. M0 _ mov dl,0ah ;next line 6 [6 c2 ?, \& s% l- t: E: S
mov ah,2
`" k5 Q4 ?( s1 L int 21h
8 C3 a# |" [0 ]7 S popa
$ j2 M# H4 Z3 H2 b ENDM
$ u' Z( o) w% m1 u. l2 p" E8 i8 R. V
4 N7 R, L" L0 Q, \8 Xmain proc far5 D" m. c0 w5 J5 e+ \
mov ax,@data8 V1 [* d2 ]8 z
mov ds,ax
2 \ R( C5 @" I
6 v. C2 h/ I/ S) I8 S. {* ` mov eax,8000FB20h ;Bus 0,Device 32,Function 3,20h
, m; L- O7 D' B: d1 c mov dx,CFG_ADDR
1 t5 h' w% Q; A* V0 N+ q out dx,eax- ]) v, a* p- u7 j$ x) |' H& y) B
mov dx,CFG_DATA
! D7 }! Y" R+ M% D3 e- S- E in eax,dx
9 b. {% x' G: I6 j& W: M, Q
% O- P$ P- q" u! F- i) B shr ax,5 ;bit 15-5,the base address
9 U3 U0 A# h- }) W1 b1 } and ax,0000011111111111b+ f) ^6 o! M" N# ] k; C
mov base,ax
2 i, i/ G P7 z ! G1 B+ v& J9 G. J$ |: \
call ReadSpd4 v3 E; |5 i- l, I
exit:: h0 p1 H2 X0 u' N
mov ax,4c00h
* h- A, ^( c$ |9 g1 S) e8 J9 \ int 21h. [! J! O8 B c; B
main endp
" p3 W2 C, r4 [$ \: H; i. \5 l" C% D7 V( r! X0 t
4 {2 z6 X7 c" D3 e$ v/ o5 S8 w$ \
6 G5 S4 D# L+ yReadSpd proc$ L, V$ S6 M2 R8 K
pusha. i! A& o! M2 w) h* x
Again:( h7 b8 G" S$ O1 l0 f2 p
mov ah,num. p) N# E8 \$ n7 G2 C( w& p
and ah,00001111b; d+ e$ u+ z% M) N
.if(ah==15d) ;CR_LF, X3 o, P6 v. r% Z
LF_CR8 r3 {7 M! ^9 R: @: x
.endif
3 C z1 k- \9 w* ~( Y$ x
, ?$ {8 N2 _8 z9 W! ^ .repeat& t6 A0 l }# ~( l; K) b
mov dx,base ;reset host,claim host in use
6 s& }5 B3 f9 w1 N, F) A2 S( G add dx,0
* C( s2 R8 W! a* _) L8 X7 c+ M. S mov al,40h
& I* a! Y* f! p0 y- T% J7 ^; T* Y out dx,al
/ B" ~0 K6 Q2 X
% D) K# x/ q9 A5 d: `3 v6 X mov dx,base
6 B4 ]4 W' i! Y" l# R in al,dx' ` y6 o2 e% _3 I; _" y7 c& O
mov SmbStatus,al$ ?* o; o% y$ ~9 C: @ @* N
& f% J( F4 `8 J1 L mov dx,base ;clear all status bits3 r3 P6 D- u* T/ H
mov al,1Eh ;host status register, W/ P! U( H& f+ b" F* o# H" p
out dx,al- U7 R8 B' E+ O- m
4 w' Z: u5 C( B8 A7 P4 b mov dx,base ;set offset to read : L1 }- L& F2 D5 }- k& L' a
add dx,3 ;host command register2 G$ v- x1 z4 F3 i- k
mov al,num
) M0 M( J8 w- O5 |8 v6 l; ? out dx,al6 j+ K' _* W/ i9 M6 X( E
1 M. p$ E) L M2 ^" S+ a2 w mov dx,base ;Transimit Slave Address register
; X6 R8 j& u+ X, A4 t N add dx,4
" u f# U0 w* z8 x; e( R" { mov al,0a1h# N. }6 z/ Q! |' T5 C; |
out dx,al
7 t, [; w7 ]' y# o1 u* }' }
( E" b( b: }% m, M mov dx,base ;set "Read Word" protocol and start bit
A" q8 N2 C( {- s add dx,2 ;Host Control register
1 P: Q! O2 [) e' `0 u2 U' {: d mov al,48h
: S! R1 c, I/ ~* _$ @ out dx,al# k0 `, r [+ V
& H2 I6 _% m# E* }, m! J
4 F6 U! K2 [; E
/ B H! U+ M6 X$ }" T! f$ L mov dx,base; |9 h* w4 u1 ^4 a$ m4 X$ M) S, V
in al,dx6 |' \% d) }( h) K. M% \$ v( N0 {3 k
mov SmbStatus,al& |1 S9 ?) d: P2 s
and al,1Eh0 k& M6 L* X+ E( B! u x
.while (al==0) ;check repeatly until any of' Q9 I [* @; s: ?8 Q" t3 Y
mov dx,base ;FAIL,BERR,DERR,INTR
# r8 P$ |( A! d+ a" i5 o3 z& s4 a in al,dx* [3 \( \) X. f+ H
mov SmbStatus,al
9 a. C7 }3 M6 r7 S and al,1Eh ' W4 P4 u2 M# E
.ENDW
8 i D2 h$ j+ c/ A0 A # s% ^' Q, `$ T1 k
mov al,SmbStatus ' A1 D1 v6 K7 b5 m1 I
and al,1Ch/ |3 C4 y6 t) m4 i- L. t
.if (al!=0) ;check for errors ! I H$ `8 p$ u6 y' \
mov al,SmbStatus
% @4 V+ P. w6 t and al,08h + P' y, o* a s
.continue .if (al!=0)
3 [1 i/ N' Q, X i jmp @F
( c! S' V4 Z. n/ M9 Y0 |7 k9 n .else/ Z1 x+ [# |3 C i2 x$ E. n5 c; k
mov dx,base
) A+ d4 Z0 T! ?! Z: m add dx,5h
1 p: [' G7 F9 N0 P6 C in al,dx $ [& Y+ F B T* R! P" b" K
call binhex
7 {% {6 G8 g; N; _ .break
/ \% l# i( D7 s {$ H3 c3 K9 o .endif5 I( H$ k) ]) f7 H
* b9 H1 m/ b A, i& Q
.until (0)
/ O: }' H+ v% I5 I" U4 a" d
3 i e$ g5 y! c% h2 k! q; g 5 z# m! B2 J) ~
0 M! F; s6 D( ? mov dl,20h ;output a space: |6 r) S& t! s+ K& ~. I8 f
mov ah,2% ~0 u$ {5 ^( P
pusha
* p# q' L: Z' `, _: N3 w' S int 21h
. w- y& K9 v( k8 L- c/ p- X popa' ?5 P$ t2 c) S* t' r' _
inc num
! `* M2 M! @2 m9 S- i( q. x6 i7 g6 v
cmp num,80h ;get first spd 128 bytes % i# K6 E2 O, v: E. g% T! n
jnz Again& k8 M c0 i- c* }) y/ ~
" C9 k% h) _; {. |% r% _
@@:
2 K' t% D' U) o; M4 f) F3 l popa4 Q3 }; ?0 t% ^# N6 w% y
ret
7 K% y& y8 M1 k, Q8 |# kReadSpd endp
$ |) ~5 R! D6 q" e* M- J- D6 o' D( z3 s' K/ o( C
" J: I& w+ ?2 y5 C( {0 k# v- J3 |8 ], ]) e) D
binhex proc 8 k7 ?. a+ j0 v! P0 G
pusha - r0 d& Z3 x: y( Y' |
) J: {% }* _; d9 ^
mov ch,2 ;2 hexadecimal digits to be printed
2 D, o* v2 u; E8 _: u8 n8 oloop3:
: x/ D" R/ ]3 \# w" T a) M; \* ^ mov cl,4 ;bits to be shifted/ O1 `1 e; J& }3 e0 F% S
rol al,cl- R; \3 k- S: z1 Y+ P
mov bl,al4 {( ]: f" i8 l# E' m6 |
and bl,0fh ;mask the 4-bit Msb
, [( _8 ?& {' ~) _0 p/ T add bl,30h- w; j, p7 ~0 V9 R+ ^
cmp bl,3ah
. @, t6 ]& y- p; x! d jl next1 ;number or alpha?
% t# }" Y' b4 b$ i add bl,7
4 T/ |% Z; A/ Snext1:
5 {8 z+ g. T* r( U7 z2 G mov ah,2 ;print one hexadecimal digit
* ]4 H! s; {/ J6 b# i4 L+ H6 x: j mov dl,bl
& ^7 C3 d! h# K; A pusha
& B! A$ u& d( o* R2 o. ` int 21h
- Q l: s0 l0 f' d& G* |& A$ C popa& u& s+ d- U$ g4 H# o
dec ch
1 Z6 c& R% l; g, \/ f7 | jnz loop3
$ @& J0 n" t" s. ~ popa, q" F q8 ~9 T) `& u: K: h
ret
, i% m2 O0 B4 r5 A0 v: O* Sbinhex endp
" O* Q3 l3 S% ^$ J end main |
|