|
根据bios代码写了个SPD读取,就是不出结果,每次调试输出host status register都是FF,代码基本和bios一样,机器也是ICH9的机器,代码如下: x) R1 K# g, A
0 \+ V4 V4 ]( ~$ H: _9 i .model small+ u4 l% { w& G" |4 Y! y& E' e
.386
/ B: n7 X5 h8 ^/ |, A. N CFG_ADDR EQU 0CF8h
# B2 a: M9 e2 B CFG_DATA EQU 0CFCh
\$ m6 k1 m* G: P SMBUS_BUS EQU 0; k$ M, D7 {$ R
SMBUS_DEVICE EQU 316 L( r4 m: h7 @2 k+ }
SMBUS_FUNC EQU 38 `% V4 V ?: y0 d; ~0 x3 l
6 z7 o7 C: o, h* b* |) S
.stack 100h
) Q, m0 A, M1 E# c% {8 V7 B `% h$ T6 ] .data4 O0 N) x: }- @; Z* n
base dw ? ;smbus I/O space6 ?- a9 ]* W: _: e+ r) f
num db 0 ;byte select
0 R# Y1 f8 l# n( q- tSmbStatus db ?2 P" O! O5 N& {1 e$ c8 Q( f
D' t- i6 G& a+ R" M* H
.code r! h# m+ }8 _1 \3 Y; a
2 A x. Y0 w- e1 oLF_CR MACRO% R+ X! Z) }. H% g& B
pusha) ?( E( S( k' d3 n5 s: x9 _ K6 h
mov dl,0dh
7 C: j2 j9 {, o! E mov ah,23 n- r, y4 A" Y4 R/ N
int 21h) [, \, y ~. ~( d9 [
mov dl,0ah ;next line
1 |9 a! C' V- |. }' i( X mov ah,20 q% i! L6 d0 ^8 F8 v
int 21h: n+ s3 ?8 k* w: u" }# j! d6 a
popa 1 M& ~( v; q, o2 K8 b
ENDM
z/ c, L( M% ^
5 V- O$ \9 C* C( C% |+ ^0 y ^" d Z; y3 w. g3 C
main proc far
& c' \: W5 n# _5 S mov ax,@data! U: R3 @9 P% n6 L" d! ?
mov ds,ax" J+ D3 b9 p( _4 Q9 m
8 Z* f' I/ p- l3 M. y$ k3 J% t! r
mov eax,8000FB20h ;Bus 0,Device 32,Function 3,20h
! W( q1 l, b0 [ mov dx,CFG_ADDR3 t! g2 h" Z9 N( @& E7 [
out dx,eax
% p1 B. k6 p5 C5 g mov dx,CFG_DATA
( L D$ D; V) h1 D* ?- Q in eax,dx" F. {2 x2 f# X7 o
1 ^: i! ?. \- X& r) {+ ^+ c% w shr ax,5 ;bit 15-5,the base address. l) }' [# y! G E2 }
and ax,0000011111111111b
6 X3 ]/ g. l9 I2 L' w8 A mov base,ax
0 f1 d: t7 A; Z" t2 P 5 D+ |1 q; a: r8 I/ |
call ReadSpd1 G m# C, B% J/ a& R. i
exit:# v1 H( r( R; b1 r
mov ax,4c00h6 v& |$ e" `( Q
int 21h) ` h* n) t3 h
main endp
e1 ^# i. Y& `. k% V3 u, X: W) q. w3 `% m
7 h: H4 U, p4 Q1 x! V
( e5 x6 H W0 k6 K# e; cReadSpd proc3 M7 a9 y/ O; a8 o: [$ R
pusha# `, V) t/ [$ o% }
Again:
3 k8 M N6 e9 D" E0 h+ R7 N mov ah,num6 m3 [; N' R5 ?* q; O0 u- \
and ah,00001111b M1 W# B8 K/ d3 f% }$ d
.if(ah==15d) ;CR_LF
3 W' x: y; C, `: e8 D LF_CR
. A r% T9 g" U .endif# X k8 h: K: I) z$ R% X4 R
0 G I% U2 `9 L/ q .repeat
, c9 I; P5 S' w/ s" t0 O4 d mov dx,base ;reset host,claim host in use
. F- l- O. A4 B6 _4 ~' X add dx,0: I- Q% m9 G6 s! g7 z
mov al,40h! [1 M$ o3 |: A' F4 S6 y5 D4 L+ S
out dx,al l3 X$ a/ P2 Q8 L% Q0 c7 F q" @( v2 \0 F
& D9 j6 X' w( s4 B& p
mov dx,base : v7 t# m0 M. H' H5 Z4 M
in al,dx, }) P# e2 V) n ]
mov SmbStatus,al
3 y: K* m. N5 F" h
- ? ^! N2 r3 T: W3 Z mov dx,base ;clear all status bits. o# _& ?2 q5 h, b& D4 ]0 `9 r1 O
mov al,1Eh ;host status register
: ?! |. z K8 h0 Q: o3 [ out dx,al
: \- l9 q5 w' c& G2 h/ [
, t/ ~! f7 t8 G2 f+ U0 j" a# O mov dx,base ;set offset to read
0 U4 b4 F4 O# \9 o5 X9 i) N add dx,3 ;host command register
& S9 J5 ^5 X6 F) ^. X mov al,num
! \: m3 J" E( U out dx,al% `! O% S4 a0 Q/ U
- {) @; K; g0 A9 p; { mov dx,base ;Transimit Slave Address register
# p% {1 {& r8 f7 B# M add dx,4 t; w( b8 E1 s" d( p% j- [
mov al,0a1h
& A7 X( e4 _: K. S out dx,al* u" U$ o; K& z1 A% d% e9 V! x
4 O, B! g7 K" v+ t+ I! j1 ?; b
mov dx,base ;set "Read Word" protocol and start bit
! b0 X* W2 m3 M; _3 f; i" t! s add dx,2 ;Host Control register
6 E- ~6 u4 X% w2 y mov al,48h
M9 s3 j& @, O' H8 H' P' l out dx,al& _ s" q1 ]+ z2 h0 K" ]
@2 J9 L$ Y+ ^( {+ p- m8 G. e [# m/ a; R, n7 j H, s4 |
4 ~8 S* d+ ~8 R( J8 s) V$ [ mov dx,base6 Y4 k( C3 S7 Y* a$ f% Q& ~
in al,dx
& u4 ~6 l0 E! Q5 S+ S mov SmbStatus,al
7 l# l' N* P% F; W% v/ O and al,1Eh
7 B5 l3 }. L. L+ s) b' [+ \" q& I .while (al==0) ;check repeatly until any of
. R$ Q3 x7 v' ` mov dx,base ;FAIL,BERR,DERR,INTR1 e% z1 `7 L5 _
in al,dx
% G7 s* t2 | L mov SmbStatus,al
; H* G9 ]. i, A6 [ and al,1Eh
( L2 p/ L* w) q' u) J$ i .ENDW$ Y( b/ Y+ g/ G0 [( T
& w6 X$ `* C" E8 v" L
mov al,SmbStatus # W& W; K: N* _( c
and al,1Ch
/ l- H& P9 h8 g9 H* ] .if (al!=0) ;check for errors
* q; Z- a, G$ g+ h, _+ X# w. f mov al,SmbStatus7 s6 N. v9 }7 F3 Z, z: t& n
and al,08h ( q3 J }( I$ ?# M& e5 k
.continue .if (al!=0)
2 n. C5 I3 R' A# k6 } jmp @F
! Q1 J' t- Y* }& D* H5 B: E .else. w3 w4 {- S9 q
mov dx,base
! n( G) |7 T* n* H' a add dx,5h3 z1 l0 _, x0 N) c$ d/ D
in al,dx 3 K, }# Z1 I; D* g
call binhex
1 ^; E1 C& o9 _ .break
2 d9 D5 v- {. F/ B8 P7 @7 ], q: H .endif% G5 O+ Z' Q. g* N9 z6 Z
* V" h& o. S( r) n) J .until (0) $ c; Y1 i3 F; T9 i% g: l2 g/ s
! n8 Q& s% N/ U: J2 g7 S/ O 9 x. g" \* L, \$ u0 ?5 ~& O
0 O1 ]/ T- O- b+ n7 i
mov dl,20h ;output a space: o3 Z) E% J- l% _
mov ah,2! V8 j7 a" z0 n% t; u4 d1 o# ]
pusha
8 G/ }, X& e! P/ t5 g/ p int 21h* q) ^* w2 W- y- P, v
popa
, @; U5 ?# E4 x inc num
2 N5 z! R+ i2 m; b# y' o" e* e% |( D
cmp num,80h ;get first spd 128 bytes
2 l, B) A- w/ k9 C# r0 T8 t jnz Again$ c7 ^; |" W: N- K1 o. _; A
* B+ Q) V" E+ D7 M) D@@:
5 c0 C4 ?/ T" l/ U3 I popa
$ `: _3 c# O& U y$ d ret
1 X) Q5 X# C+ F( nReadSpd endp
5 k$ p) u4 t7 D; J
$ t. M8 a* A3 V- N; n; H, C9 K( H- g' v8 Q) R
% c7 r- t5 Q' ~$ x: g u4 H
binhex proc
4 u5 I4 K R4 j% E- g5 ? pusha
5 z" Y* S% v' ]4 [% t* y5 U 6 ^ s4 T) |1 d" s' x1 h7 {" E( A
mov ch,2 ;2 hexadecimal digits to be printed4 P& R% O! j' w3 \- d
loop3:
6 w7 z7 o* Y+ C- T mov cl,4 ;bits to be shifted
$ d* |/ u+ y7 m4 l# _) v3 v- J4 o rol al,cl
/ U( e: p: y5 L/ C mov bl,al
# A6 W! |: E0 k4 I) t3 O and bl,0fh ;mask the 4-bit Msb2 q X' X# @$ h8 O
add bl,30h
: k5 y1 m' n( z7 e1 W cmp bl,3ah3 Q+ r7 G/ w5 x$ j% Y
jl next1 ;number or alpha?
2 O2 b% t- W- W: ?$ s5 {8 b1 \3 N add bl,7
; T' a5 c9 m0 \- ]- k. R+ znext1:
* y9 g) a6 y/ ~( _+ e/ u% X mov ah,2 ;print one hexadecimal digit0 e. s4 J' Q# G: X) f( c2 ~6 l; m
mov dl,bl; L. \, @+ R' o/ I9 C3 \, L
pusha8 e$ N+ _5 l' y- f5 B
int 21h6 ]+ _" R1 b* N4 c7 w" S
popa
d5 O1 {% g J: R dec ch
/ M# h& b ~1 d" M' X jnz loop3
. j* n# W) n3 P* f$ L popa
$ D8 j1 o8 o2 P( l ret! ?! A8 [- s$ j9 Q& s
binhex endp) i* s2 a+ o+ a* `0 q4 V( y* h3 @% t2 ]
end main |
|