|
根据bios代码写了个SPD读取,就是不出结果,每次调试输出host status register都是FF,代码基本和bios一样,机器也是ICH9的机器,代码如下:
6 D: Y5 u9 Y5 L: k4 O
. @5 g9 c8 G6 I2 @' Z/ f .model small* B$ r& `4 f* L! r `. D; U) B
.386
6 V' O3 U* F" ~5 r CFG_ADDR EQU 0CF8h7 H. O7 Z# Y H4 U9 W* E
CFG_DATA EQU 0CFCh
! l O1 h W0 F' P! b( l3 C SMBUS_BUS EQU 0
# C" P7 v, B0 {* w/ V) _" d SMBUS_DEVICE EQU 316 G6 T: H8 _5 x: v
SMBUS_FUNC EQU 3% F. P' v1 }# ~0 u$ G/ |
5 L1 p: Q! x: N! d
.stack 100h
* s2 _/ N+ L+ L0 |/ m* B/ ~ .data' z0 }& h; h& O5 p5 ]. {2 M
base dw ? ;smbus I/O space
$ m2 r$ S; i5 `/ T; m2 @num db 0 ;byte select5 C4 H. R9 K7 n7 f8 |! K+ @8 q) B
SmbStatus db ?
' r3 r7 d( E- U O1 r3 T( L6 P2 H, M" G0 J$ A0 R% k* @
.code
+ T! X' ]7 P% |1 v* n$ Q9 { ; l4 u5 f6 Z8 X4 m4 K, T
LF_CR MACRO
+ L6 `/ g* m. i1 C# m pusha5 M# U0 e6 m7 `
mov dl,0dh
2 ^# o% h' f1 y7 V9 V, e mov ah,2
+ D5 k6 R8 {. {. G$ u int 21h$ z! Y% W% V5 }2 W3 i
mov dl,0ah ;next line 5 T" u0 H0 O0 \ n
mov ah,2
8 Z+ f6 N* S$ u) f1 Q1 ?( V int 21h* r7 J: @3 v% a
popa : t) a. J5 e7 ?: a+ I1 {
ENDM
5 p: k$ }" I/ a1 b: X$ t% _: `& r; `4 Y) ?3 v- Y
0 x0 x r9 f0 q. q7 bmain proc far
- C" \ x9 o! y' K$ p9 N3 K1 F* I mov ax,@data' p9 q4 x: h S7 A1 R
mov ds,ax. q6 T! K3 O8 w* m5 `4 ], E
1 z# X) X5 k% g9 |
mov eax,8000FB20h ;Bus 0,Device 32,Function 3,20h# O; N, o5 L# k, b
mov dx,CFG_ADDR: \% v& ?# b; B' B, k6 @
out dx,eax
. a$ i5 F1 O- |" u; W! b mov dx,CFG_DATA
) U! S* O2 T% g6 O8 H in eax,dx
1 p+ w2 g5 Z' m
" N+ O2 p4 x3 Y- P3 @' N, S/ s- F' T shr ax,5 ;bit 15-5,the base address- W7 M7 `( N) f. u! Q; A
and ax,0000011111111111b
( h$ f$ _2 R- S' D mov base,ax
9 P6 @/ C7 T# K
# F f8 G$ Q K call ReadSpd
9 A: G/ v5 _ p/ N6 }# s& A% qexit: B5 a- @. Y' V* F3 T4 s; S0 P* ? {
mov ax,4c00h
" }) v* }! q! o Z2 ] int 21h$ T7 Z7 J/ l, s! q# x# |3 Q$ Z% Q7 {
main endp
" |, e* H' G5 Q3 h4 }. q$ q8 C5 T' _; f1 G) {4 p
+ z6 {( a5 X& J& O' L' Q4 v# j' G/ ]$ e
ReadSpd proc! y* {* H* S1 d4 n2 P$ }
pusha
( f' J! L0 x+ s; n7 EAgain:7 d0 O7 \ ~! B' @ e
mov ah,num& P7 O" M5 G: b3 `$ M1 O' x% v
and ah,00001111b' x8 k6 [2 P% w. j, N/ \
.if(ah==15d) ;CR_LF! r) X. H$ f7 @4 E
LF_CR
$ [: M, C' v' M .endif2 U, n% M3 n7 R- E. W
7 m: X, y/ z% {
.repeat' ^- ^9 u0 w5 n# p$ l3 C
mov dx,base ;reset host,claim host in use' q. e4 X2 g2 C. w: q- Z
add dx,0, C+ g. |' W$ J$ R. Q- I, ]0 B% J
mov al,40h( S% Q2 ^/ a0 w4 Q
out dx,al
7 P# }, y( G0 r8 r5 k
) |' V6 ]: {; C$ }! N mov dx,base
7 @: K: H) ?6 \) m8 M in al,dx
2 Q: H5 k& K9 y" R7 X mov SmbStatus,al
. j- E: I3 s9 R0 D3 D
& X' t5 l! _7 N mov dx,base ;clear all status bits3 _; R; `5 x0 u! e- G
mov al,1Eh ;host status register: ?5 \$ B/ ~" }
out dx,al
k+ e! d8 I+ m: p `0 w! {: x . K0 ^* i+ F9 S' \* c" I
mov dx,base ;set offset to read
2 G; I5 ?6 u1 j9 l% ~2 a7 C0 `* ?5 p add dx,3 ;host command register1 {& V( _. r+ T1 I4 ]8 q6 B
mov al,num& w' @0 v8 R0 t, y3 c
out dx,al' Z3 \9 @' [2 x, ~
8 ?9 v5 x/ `2 w' A
mov dx,base ;Transimit Slave Address register+ ?9 p+ c/ i7 A' z) j* P
add dx,4
! k+ X3 Q l ?5 u% P) X9 ]. G3 G! L mov al,0a1h- C) z f/ f `+ i" E8 w
out dx,al
: O3 ? e2 \9 L4 @ ' c, N) L; ]8 B% M* z, e; o3 l$ U
mov dx,base ;set "Read Word" protocol and start bit U/ w6 |4 g( ~0 u0 A
add dx,2 ;Host Control register
2 L' \% c9 {- x2 r mov al,48h
) s3 R4 i( R8 w. U" Z out dx,al1 m: V" R$ d7 K. u5 g
) l4 P _0 @5 Q" l& d% Q! Q
S% o7 g6 \8 H5 C 1 W0 C* K4 K9 i% g$ Z
mov dx,base
- e0 C) V# U. T$ { in al,dx
1 s( M4 Z! V" r mov SmbStatus,al
8 V" s6 ` U1 b, G% _! I, ` and al,1Eh
4 Y- `" _+ _7 t, [) |( | .while (al==0) ;check repeatly until any of
7 @( \/ L9 {$ }/ ~6 _$ n mov dx,base ;FAIL,BERR,DERR,INTR% l5 k" g1 a' g* @* o/ J1 G2 }
in al,dx% s9 A2 j9 ^7 g& M0 u
mov SmbStatus,al$ J* R# u7 l' s7 ^* M) f7 c
and al,1Eh
" I- V0 j1 v U e .ENDW
* Z: u" Y# ^; m2 m6 H* b/ J
$ Z/ M: L( x- G1 I; I& X mov al,SmbStatus : g+ g" _" e6 q8 }0 N Z) U
and al,1Ch
# s! B, v* b7 }: L9 ^/ l .if (al!=0) ;check for errors
) D3 @9 b5 R; C mov al,SmbStatus
% w# G# B% j4 e. ? and al,08h
! D! T% i) B6 P) o .continue .if (al!=0) # x/ Q3 e# e) m; _
jmp @F
/ S' m# Z% u* E+ s' A! }, O6 [7 G .else
$ c3 g# A) D# ^4 o mov dx,base
& h; z& M$ Q' O! W2 d2 f+ d add dx,5h, G4 s4 F" [& j& k
in al,dx % G, k: h1 ]) g0 }/ a
call binhex
# {) T( _$ Y6 k/ ?1 l. W# A .break
, K6 N9 X! |# c" y" k1 E .endif
' k* y3 g, W* y: \5 J& Z9 K 1 V' ]: Y# k |7 U
.until (0)
/ X- ^) [; y! L: Z + J7 q3 ^8 ~% z' P0 y3 J8 f' L# b
1 H+ ?& P! ]/ b/ Y% P
* z( S7 K9 t6 l( T) t$ u
mov dl,20h ;output a space
: s( u2 H# i! P4 ^ mov ah,2
$ C- I3 {0 O/ a3 }- l pusha& j- n$ `$ t9 S, f. x
int 21h+ M5 z( O& v" n; n* N" M
popa8 M, E5 e. F, ?3 [8 g' p: a! g
inc num" u# o0 N9 `! R9 U- l; h( B! {
1 e& a' K4 U: L/ i, g
cmp num,80h ;get first spd 128 bytes $ x: Y- E- e* m) A' N. ~
jnz Again, g |+ x, i- A/ R! k( k! c
0 f+ H2 j8 U3 f e/ p& }@@:
/ ^- t# h' y+ K W. j- } popa; @& E: P! t+ E- A
ret' V F3 ], O4 z
ReadSpd endp; i9 A2 ]0 O% q: q! S
A v$ S Z, o3 d' p! h# E) d! r0 K, o$ O1 p F w
$ `3 o% a0 q5 i+ W8 H* j9 b/ Q
binhex proc $ \! z$ X8 @ D3 \! g/ I6 f4 S5 O
pusha ) s% t9 v: O* P" X, K
1 _- Y8 K5 S0 @( R, _9 D
mov ch,2 ;2 hexadecimal digits to be printed
9 q h+ H$ [" P5 C) u X" \! x$ Mloop3:
0 e; ]: T; }# c0 f( |1 t$ p mov cl,4 ;bits to be shifted
2 Z; c2 k2 L- L& b) y rol al,cl+ U. a: t) l; S9 M% A
mov bl,al
) j9 R' P* G' J8 f% X% ]& j/ Z/ V and bl,0fh ;mask the 4-bit Msb( o- \7 J+ J" ]' }
add bl,30h
+ k# ]3 s3 J7 ^5 c. O8 i. `# f0 p t cmp bl,3ah
8 ^; Q1 v) i. y; G5 F2 d jl next1 ;number or alpha?
9 Y. m$ [/ L% h( n add bl,7
# c$ A5 J1 p1 z* cnext1:
1 G3 f" S6 b0 p: {8 r7 k mov ah,2 ;print one hexadecimal digit
. o' s; y& d/ a) a. k- t mov dl,bl
' z1 e7 A1 ~5 _ pusha
% S V/ o) S, i- [6 C. W$ K7 ~ int 21h* ?" O; \+ ]0 a
popa
& Y3 V/ X- ~; s$ H( ^3 A' z H dec ch
3 u, Q+ _: T& ~ jnz loop36 G" c; ]: T6 S8 ?* k& S' L
popa, g" X8 d: j' g
ret
1 y, q: @& a n9 j! {+ u8 gbinhex endp
4 S1 d# \+ c5 l1 [; [9 J$ K end main |
|