|
|
根据bios代码写了个SPD读取,就是不出结果,每次调试输出host status register都是FF,代码基本和bios一样,机器也是ICH9的机器,代码如下:
) l. F" r8 [: `3 W
) t9 i5 G& m* [4 D, V .model small
# x+ f( M0 P' t, A9 w2 c .386
5 C% i3 a% G2 {' P8 L CFG_ADDR EQU 0CF8h$ d7 t8 ~8 f6 L+ o H
CFG_DATA EQU 0CFCh, }$ i/ o/ ~3 s
SMBUS_BUS EQU 05 u6 d% C1 h* X* g+ A
SMBUS_DEVICE EQU 31 Q9 _. D/ m4 i% e
SMBUS_FUNC EQU 3
7 n# c0 L/ B8 B Y' S G 4 M) T# g4 _, C3 f0 u. ?5 L6 [6 i5 }* _
.stack 100h! v5 L# d' h2 O( {; a
.data
" a' h& a! o$ _% n3 W6 F3 nbase dw ? ;smbus I/O space$ w7 q8 |4 S* d# i$ p5 t
num db 0 ;byte select
7 }1 {9 U V* e) ~3 ^SmbStatus db ?! k( S9 `1 E# t
* a, [7 O! v) ^2 L9 z/ \ .code% u; w+ O4 q9 I% y- T
7 g. L5 y/ c: g, hLF_CR MACRO8 y3 z9 O, g2 |$ P) s, Q
pusha R8 N; n: L% v2 }& h
mov dl,0dh
' [ W% t7 D0 \- o2 Q- y7 _2 z6 W) D mov ah,2
4 n; x1 }+ \6 } m, x) Y int 21h
5 a" p z' Q; B7 y+ c; @ mov dl,0ah ;next line
2 M. F+ }0 e0 o$ s+ U7 E8 _ mov ah,2
5 h# ^0 K: q! L3 @- k+ f int 21h
* Q+ g1 `- S5 @* I$ R6 C5 B popa 2 _$ |. d& \2 F* \
ENDM
! E8 b( {) a. M, {0 ]3 Q' V0 z6 O% `3 R4 u1 Y' B6 w
! H6 Q, V3 p3 g6 f. h& Y, ^main proc far
# { N' k8 z( e$ o6 y) L; O Q3 }+ R mov ax,@data7 x- P) ^8 R1 i; N
mov ds,ax
! i0 ?" f$ K& j+ d4 z, u 0 i, V. |# z$ f$ g/ u. R
mov eax,8000FB20h ;Bus 0,Device 32,Function 3,20h
8 `% e) B/ O5 K, y" f8 W mov dx,CFG_ADDR
P1 o: X6 L! J* E1 I# \. e out dx,eax
$ v/ X# _; [. |0 c! t. n mov dx,CFG_DATA) z, K: |6 H; z: G+ u
in eax,dx
! z& T6 G% r; f" w( u 8 ^1 r0 e0 b2 V1 N+ m B) ]
shr ax,5 ;bit 15-5,the base address% O5 n z! q% @8 |+ |
and ax,0000011111111111b
6 G' b& w: O# R* Y9 @7 Y mov base,ax7 a3 j: a" e; }1 a% H* n
2 e+ {6 I# z$ r1 c$ C k& K8 Z
call ReadSpd/ g7 A) O+ C) _% ^- |# \
exit:
! W. n, J8 F3 o5 J mov ax,4c00h! ]( X. z% @9 J: }0 Q0 c
int 21h b5 \. g; F) D5 U1 [: `4 S4 Q
main endp% W1 P1 c% y0 p, D# ~
# f O$ D. A- j1 x
3 c0 }- i0 S$ S5 |! O& s
: `, M2 O% K* P9 }* f* ZReadSpd proc
3 X) f; w6 L: ^& K" g pusha
L2 b1 e2 f4 y5 \8 FAgain:6 J3 B, J! N' T7 r) R
mov ah,num4 o+ }. e0 Z8 n) P' `4 V
and ah,00001111b8 Q7 t& N: I: B0 ]6 S
.if(ah==15d) ;CR_LF
# h5 J9 b7 n$ K& E4 _- V LF_CR
& U6 \4 \! Y7 B7 _ .endif
! K+ [; ]6 `$ A3 c# H3 \* o
& |* m. a; Z5 a0 T% f9 o, J .repeat0 b5 U, N, j! z1 S5 j5 |$ p
mov dx,base ;reset host,claim host in use
4 w5 k+ K, `# m* C7 u add dx,0
O0 W* J; `- d: U- {, C mov al,40h
2 b4 ^6 a9 H3 t8 |; @ out dx,al
5 ~ }* D' `* y1 C$ A- z5 ^; p0 u% i
|/ J! K3 \+ ]4 K# S2 y2 { mov dx,base
4 Y- f; Y2 B' ^% T t% V in al,dx) h. Y2 m6 t) X4 V( h6 t- @
mov SmbStatus,al& |/ r& n: g# w, o, U0 t
8 K0 N. q* c( ^3 Z mov dx,base ;clear all status bits1 |3 Y" _) P9 A# Q
mov al,1Eh ;host status register5 J0 s, ~5 }/ F( M* Q- o9 h
out dx,al7 H+ R- @& E B& z2 d
@ I, D" y/ \2 U5 e
mov dx,base ;set offset to read / F( ^9 K- _- |& D3 K, X5 c" Z
add dx,3 ;host command register9 Z' W2 b" L! s/ y( T: \
mov al,num
4 b) @# y; Y% Z& D2 z1 Q out dx,al7 R- D& [7 ], M3 G; Z% [0 i! A
% u& \: x2 S& d6 I) ~! M
mov dx,base ;Transimit Slave Address register
( F! q1 \$ x6 _ C; ` add dx,4
/ ?5 c7 o" S/ F+ P6 M: M# Q mov al,0a1h
w/ s4 f0 W+ F( l5 I. y2 O* `* ^ out dx,al
+ c9 K y+ z+ H2 E& `' i7 M2 W e5 n 1 d. c5 z1 R% q
mov dx,base ;set "Read Word" protocol and start bit
( k* {3 a' Z8 O) ^( b5 u add dx,2 ;Host Control register$ m/ v5 o( _- A! N3 m2 |
mov al,48h - o* T6 T7 X2 g e* s
out dx,al
5 {( }5 q8 |( w. \3 D2 Z $ J# i+ I" Y# H y4 ~
8 u2 {" x/ W- f% u) e, R( r$ d
$ A% Y4 w, @+ a* Z
mov dx,base
9 c" B$ J1 L! ]" e9 Z V5 _+ g in al,dx
, ? r1 [5 O& @) ?* ~7 T9 S8 R mov SmbStatus,al
2 k: B* g, ~' q and al,1Eh* t8 u2 Y; @) T9 K. p( y) t
.while (al==0) ;check repeatly until any of% ^9 ?% o. f- y3 x
mov dx,base ;FAIL,BERR,DERR,INTR
: N+ t8 v: m/ E d in al,dx
- \, s. K, }% Q9 l% P5 p mov SmbStatus,al
: S: @4 Z8 E4 A and al,1Eh
1 k; ]4 z, M* J6 x& |. K .ENDW
* z6 i) O( t0 w" E0 y4 l ( G4 ] w7 J2 {# w* @, G
mov al,SmbStatus
' z6 H" G. i0 r# ] and al,1Ch z! [; K, s- ]% N
.if (al!=0) ;check for errors 2 Y4 m x" A5 t$ m7 H6 X
mov al,SmbStatus/ ^- _# D% s I6 ^6 m: \5 e; S
and al,08h & q9 j/ ]3 t8 j, q5 q$ m" V, d
.continue .if (al!=0) + P- b5 A0 D3 V, F! E. ]# R4 O
jmp @F " b% ~* u$ _% t6 L
.else" w1 y% ?+ u' ~
mov dx,base( [/ {% v* P$ T# G, G
add dx,5h' U# z) u, d1 q$ b
in al,dx
' k9 J1 E' O/ L$ \! P call binhex
4 s7 K% ]' Y* U: ~( R+ Y .break$ V9 D' l2 e. v, r( d0 Q4 k$ T
.endif# a: h. u9 A$ Z6 I. V1 Z* Y! G
% g/ L. ~7 K# X
.until (0)
5 q+ C5 V# Q7 {5 h1 N& _4 }5 Z
+ P7 |1 o* B2 y% W- l# e
, R5 B" q. l8 h* C , f e" S$ ?% [
mov dl,20h ;output a space3 b* [& ?$ l6 s c8 t- p3 T7 A1 o
mov ah,2
5 |6 A1 ^( Q+ @8 h) H! Y% W0 n pusha; l& g+ j3 t B; C% Z, Z
int 21h/ B; X1 t6 o4 r- ~6 \; l
popa
1 h, D' o9 n I3 H# T0 E- |! e inc num
2 {# r7 |% z" e; G# v! A1 B( E4 `
' {, f; ]; V2 q" C6 b( d$ W ~ cmp num,80h ;get first spd 128 bytes
3 W$ u# } n4 h! n% p jnz Again
" K( t/ @" j) Q, s
+ ~/ }* m \/ g' Y! D@@:* o5 e0 v5 D" f! _
popa
# u$ ?/ N$ F" l$ q5 E& n ret1 B: ^ G" i2 r* S1 P5 x
ReadSpd endp! p2 K5 N9 z# i6 a; [% }1 W
# S0 s8 B% t6 t* p, t
; h. N: \; d2 n0 ^4 |8 m
% {6 C+ M) W/ Y7 g. M! U. Gbinhex proc ; E1 R4 d* g) f* L, e
pusha
; d0 I/ `8 [0 p/ g - ^, S: |6 b& Z+ t3 _3 I
mov ch,2 ;2 hexadecimal digits to be printed, {; o: y- H, H* Q" [
loop3:1 R2 A! N3 ?. g- o6 q$ Z
mov cl,4 ;bits to be shifted
6 }8 i' p" i2 w9 Q9 ?5 b" L& E; q rol al,cl
+ o( N }: S$ x+ ?8 U' a% I3 K mov bl,al
2 W8 ]( w- Q0 I) w and bl,0fh ;mask the 4-bit Msb
- ^2 v/ i- h( v6 K) [( j3 i add bl,30h
& Q3 s8 v3 B& d3 i& H cmp bl,3ah, o$ O: K$ M$ ]: v8 ?: G% W0 m. o
jl next1 ;number or alpha?
% m$ L7 e3 o: _/ s5 T% s, J0 N& c add bl,7
# m `. U! X4 x Rnext1:
) l- a" }$ W5 t R mov ah,2 ;print one hexadecimal digit
- `! {* v$ x k+ V% } L8 i; l mov dl,bl1 q, K; T7 l. Q) v _7 c
pusha
3 @* ~* R, D0 o( Y int 21h" D* }& `; m$ c: |! [" X- D
popa
6 R- c+ j2 b# e; s dec ch
6 i# A% f* Y: w+ M, d& y jnz loop34 C. z! [' i" v
popa
2 J1 f4 A8 Z0 z: V ret
" p3 K, D( ?9 H9 \5 S* d1 jbinhex endp
. U- D9 p6 p: ^. s end main |
|