|
根据bios代码写了个SPD读取,就是不出结果,每次调试输出host status register都是FF,代码基本和bios一样,机器也是ICH9的机器,代码如下: 8 H2 P) l* e4 t4 [+ A3 U. V
: c8 S5 K7 u0 Y7 l4 |; v& A: c .model small7 E: B/ L1 |7 U) `
.386
* T8 o& a) Q. v# a; ]" d CFG_ADDR EQU 0CF8h4 S2 X" ^3 F0 D) t7 f
CFG_DATA EQU 0CFCh; e) U, Z4 f- { C/ [/ @0 R
SMBUS_BUS EQU 0
6 Y" C7 K2 L! E1 t" F- ], p; ]& V SMBUS_DEVICE EQU 31
$ M3 q( K% F' F SMBUS_FUNC EQU 3
2 ]! E) s! w5 G5 H# A, f1 x+ c+ q 1 z+ ]7 K* F- U
.stack 100h7 I7 M( N: R4 S" r. Q$ W
.data
; m: @# k) G8 K$ c/ vbase dw ? ;smbus I/O space
4 W* u) `3 {* X' q% x) c( `num db 0 ;byte select
$ P! G6 ~) M J! l0 E, i$ }* dSmbStatus db ?5 z. @4 v% L: s/ Y6 F8 Q+ @$ `
9 i* _" |: j! i4 h2 z .code" v+ x P G8 e6 W6 V* r
, b2 |) ]8 M8 S' s" k# eLF_CR MACRO" g( n' Y6 {3 K
pusha/ ]5 z e/ R; U
mov dl,0dh - ^- ?! V; C+ A/ G0 o' ~% c
mov ah,2
) p, w1 c( B# [7 `8 c+ q( H% l& N int 21h9 X$ t& @$ l! }. w' f
mov dl,0ah ;next line 2 w! o$ q2 }: F! b; l3 T1 v
mov ah,2
/ q! { O" @: w1 d) W) f6 s" @! r* @- d int 21h" w6 b2 b. i" L/ a) y
popa
4 t* }7 q9 h; m; V& q ENDM7 r% d3 S) J, ?; P) }7 P$ u- {
A' U, T1 |. L! a$ J5 x E0 z" C' G6 `# Z/ a" [
main proc far
. M3 g9 H0 [: l1 J mov ax,@data: c/ s/ E0 k6 h, Y7 [0 H7 O
mov ds,ax; \/ g2 D |* F# b) L
; J! X% i, W" s- Q6 g mov eax,8000FB20h ;Bus 0,Device 32,Function 3,20h! k$ U3 v* Z A' ~3 P0 Q
mov dx,CFG_ADDR
$ y; s4 R p5 e, A& R* v out dx,eax
5 j- k1 g6 Q; Y) Q mov dx,CFG_DATA* l6 t0 Q$ X- o) k7 q3 p2 W2 P
in eax,dx
9 e3 W4 ?7 W8 k 3 P ~) d' n& u U* b
shr ax,5 ;bit 15-5,the base address
. J8 p: R! H$ Z/ I and ax,0000011111111111b
; I) n. N" x. c0 { mov base,ax# ?- i) Z8 [: Y3 O# l
0 M7 W: L0 _) N/ n/ a
call ReadSpd
. J; `# P0 C1 o Sexit:
8 ^" k, l. {2 \8 E9 } mov ax,4c00h [! T$ V7 m; I1 t2 @
int 21h3 H/ h6 N5 ]% W5 v
main endp
& V& b; q% o3 r0 f5 i) b4 b8 s- C7 K+ L3 z
; J: o3 e" C% E; c! I) Q. i% K1 H, l2 I( ^2 }8 v1 e& L
ReadSpd proc/ g O" b2 @9 x
pusha' s# Y3 F6 @/ o
Again:
; W- J5 L8 e. U, k: c% Y mov ah,num
8 P/ j- Q. ~! B) H6 H# `% A# O; { and ah,00001111b4 a: u$ X! P7 p3 `9 }
.if(ah==15d) ;CR_LF7 L' o D% o. z7 T. }
LF_CR8 V2 I: H) G) w4 r2 V4 Q5 L0 C
.endif
2 ~# h1 V% o4 _4 H, f0 Y6 c, X8 ?6 g " ^$ w! t( c7 {8 W$ @
.repeat( y0 v, {( T* ]
mov dx,base ;reset host,claim host in use0 e5 L8 T4 f P3 p1 w, a
add dx,0( K4 b7 F% d5 T: B
mov al,40h: ^. j7 |, l* Y! w0 B, h1 N7 T
out dx,al6 G' q1 k( D' |1 v. V6 @% w6 @
6 ~) m$ k% z; K9 x6 H
mov dx,base
: ]7 h/ l1 h) ?9 P0 K0 ^# M* j, T in al,dx: A( X. x9 r: }1 t. B
mov SmbStatus,al1 \# _5 D( g2 z( [) _! p! F+ z. r
5 k! ]" j; b3 y. j# X i( T' W
mov dx,base ;clear all status bits! O. p( o v) j
mov al,1Eh ;host status register( B: M @ e: ?! e- l2 i+ S8 A
out dx,al3 z8 q |7 h% @
; a* _8 f$ o8 S9 t6 M8 ? mov dx,base ;set offset to read ! n8 \ ]' j6 G% q
add dx,3 ;host command register
4 I; l9 Y# v. B2 R( k+ Q$ E mov al,num# d% r, a u- n4 x+ {
out dx,al: L+ J+ V- W/ G6 e: ]
$ X, P9 [% ^: y6 Z2 p mov dx,base ;Transimit Slave Address register* a$ l# u" n# @
add dx,4, c1 E8 H6 `. Y" S$ \. u
mov al,0a1h, H3 [$ r0 m, Z5 ] g; p
out dx,al' C8 t$ N; X9 P% j4 n( }
9 \8 N) ]4 }/ [6 v0 x0 E+ s9 y' D# J1 f
mov dx,base ;set "Read Word" protocol and start bit& J; T2 H8 D) O4 Z
add dx,2 ;Host Control register* ~0 d- @2 t7 h8 z% F
mov al,48h
7 U. L- f. c- U7 |+ A out dx,al
' n, b6 i7 g) M- s, \- u
R! X! s8 r/ b9 j
) Y' N2 _8 b/ G: }+ i ' Y8 c% {7 `( m' J) Q
mov dx,base# [% Q, ?5 o5 R0 O" M
in al,dx( b' h- z8 Y9 }4 p( T, k
mov SmbStatus,al( n4 z+ G. @% }; h0 q. O. X5 j$ {* ^
and al,1Eh$ `$ F* P9 F: D# A2 t& o, F
.while (al==0) ;check repeatly until any of3 r2 ]6 r) `4 Z6 N+ C+ c
mov dx,base ;FAIL,BERR,DERR,INTR
' E# h& i; v: Q2 c# Z' |: _1 v. J8 h in al,dx
4 ~$ W) B$ e! Z g6 S( `' S' R mov SmbStatus,al/ U7 c3 r' `/ R- P) N2 L3 ^7 B
and al,1Eh 6 n& K) k1 k! J5 ?$ v* P0 z
.ENDW5 K- `2 }$ _5 D# H3 X- T: w
Y. \3 Z, F. V9 w mov al,SmbStatus 4 _1 \9 w) M; t0 r) M4 l- ]( b
and al,1Ch: B/ \( m. T* m% f9 W
.if (al!=0) ;check for errors
3 @: F7 |5 _/ B, Q. O" b- X mov al,SmbStatus* C. h6 c9 S0 _5 o# g8 ]7 r% X
and al,08h
) ?6 t: v4 X3 y3 q! g' ? .continue .if (al!=0) 9 q# v1 r2 b/ f7 l* ?' S- P( w
jmp @F , ~ u! }6 E% x& K' y
.else+ Z8 c/ f+ A, l. Q+ O
mov dx,base
3 W v: \ C; d) u4 j add dx,5h1 M- Q9 X$ x. o$ E8 c) v
in al,dx
) i( _2 x( R. H. \ call binhex , z. ]6 L- K1 ]+ D. d2 B& m
.break* W- @9 X2 s6 O0 z. @8 u
.endif# c4 D& h. |) w
. |- u3 f$ w6 O8 C- Y. ~
.until (0)
; ]! f' u! C( {( _- q) z- B/ M , w) _3 l9 B" j
5 _6 r. ]# a# M" J ; ^$ c) i* a- G. S& L8 T7 f1 s" ?' g
mov dl,20h ;output a space/ W6 Y8 @! `7 x' ~0 ^
mov ah,2& E3 E! [$ C% @+ h2 [& N9 H
pusha
u% F+ U4 k w2 v8 U int 21h" [! x" i& v9 \7 i$ E" J
popa B9 E/ R& y0 A8 S: f2 M
inc num
! u# |( {" q$ G# V0 d7 Z' R9 j. h
cmp num,80h ;get first spd 128 bytes
* \' ?3 A2 e) n1 _! P( c jnz Again
2 L& o9 V; F, l. f9 d8 O3 {
, O U2 y t4 T8 _( [@@:
9 J" m) G/ h5 s( \ popa6 s& R4 `5 j, `! ^' Q m, Y' e, h6 t
ret
0 }2 s4 D. ~' J+ K F/ \$ `ReadSpd endp1 O* Y7 A% E H" F9 R
+ J2 K" v' p! k. I% ` O# W) D6 K! }! v `
: b3 T \; ~# f" b9 o
binhex proc " ?* f, m# F+ _# J S
pusha 1 D% u! R" z" E& N8 k& m
$ ?( Y! P5 |0 K! W2 T$ M9 K/ M* N
mov ch,2 ;2 hexadecimal digits to be printed
7 r' @! p6 v# }& m# kloop3:
: g0 T; C$ l5 Y mov cl,4 ;bits to be shifted
. l7 W; h+ X2 _5 `, h& h, E$ e rol al,cl, H* Z3 S5 N/ C1 B4 U
mov bl,al
' q, A0 q5 p, \9 g, h and bl,0fh ;mask the 4-bit Msb6 A5 P+ Y, @$ v v& |3 e! X. ]3 Q3 t" S
add bl,30h
( u, i9 F7 Z% i2 m+ h# q6 G cmp bl,3ah8 b% R# v& U4 P0 D# @ D# k; T
jl next1 ;number or alpha?
: E8 ^2 t6 ^3 x- B( } add bl,7
* J$ |: w. T8 j" z- `5 H( ynext1: * N( A1 V/ _" w: L4 m7 A8 d3 d2 E
mov ah,2 ;print one hexadecimal digit
# s! ~ a3 V' [( V/ \; T mov dl,bl
$ i: v, v3 U% L% r- c1 z. Z pusha! w1 p# N3 F7 `9 c& H
int 21h8 s: u1 n, O! Q
popa7 E) d. n" P/ N7 f6 h
dec ch
" S! D* M& \; ~4 w% Z& H/ G" W: a8 i0 c jnz loop3% W2 h; @+ h p) P' r- Q
popa
- P6 o4 h5 u7 d* b ret
2 w* Q/ G2 z2 t- |: f* [, ^9 abinhex endp' _5 Y9 P' C" r$ `- E: x9 w
end main |
|