|
|
根据bios代码写了个SPD读取,就是不出结果,每次调试输出host status register都是FF,代码基本和bios一样,机器也是ICH9的机器,代码如下: # S, M: l. W$ X6 x# c
+ S& ]7 y i9 D, y1 P' o. s .model small/ g' R4 E; U5 ] u6 G |
.386& A. j8 s6 T" u
CFG_ADDR EQU 0CF8h- x% P( |# l2 ~, x) O
CFG_DATA EQU 0CFCh7 P' c9 W! k1 z; ]
SMBUS_BUS EQU 0
^( u9 o4 K$ P) {0 G! c# { | SMBUS_DEVICE EQU 31
) G% I$ A( `9 y+ X% p" t* B SMBUS_FUNC EQU 32 ?- _- {+ s: z; Q
0 f- U |; ~% O Y .stack 100h- V7 M; }( K9 j- n2 H
.data
1 l. o( I. c2 r9 r8 o) h3 Fbase dw ? ;smbus I/O space2 V$ V |+ p, i5 h
num db 0 ;byte select& s4 H" y. V' t9 ], `8 _, O
SmbStatus db ?6 q" b. X3 t& X- b
+ u/ e% ^7 w2 m .code \- u J# d: o1 q: T
$ j# x! [6 K7 @) Y( z3 n3 t+ |
LF_CR MACRO
9 i" {# T m# K7 l- C) [( }7 z9 S; y pusha
0 a; A L1 [4 T0 \/ {. z$ K6 j( ` mov dl,0dh
. R9 x6 }( k, @8 w9 S mov ah,2: j: F: r7 J0 I p+ @; a) B
int 21h
- k0 p8 i: ]' Y mov dl,0ah ;next line
' F% }2 N' H; q6 Z mov ah,2# g7 ~, ~: [, x$ b0 _! W* ]$ N: E
int 21h$ F3 T2 R. C1 b
popa 2 \: C* ~1 W7 n" u: j# `. E
ENDM! h {. I3 }* m1 _# ]: p$ ]
8 g) k+ ^/ ^# m: L% Y+ Y: h1 S) y, k. u/ ~' m0 d) U0 R
main proc far
5 x; x! q6 K9 t mov ax,@data
" d4 [, D# Z d# ?9 A mov ds,ax, A& r2 w) F3 Q [9 n4 J
% d7 {# }+ M7 V9 [ c/ | mov eax,8000FB20h ;Bus 0,Device 32,Function 3,20h
% G( r E& w8 L& J% L mov dx,CFG_ADDR
3 a0 h. ^# i7 X out dx,eax# M- V `# T5 r0 x* D2 x0 `0 O% d
mov dx,CFG_DATA# E4 v4 y0 H( ^2 ?# _& E4 }
in eax,dx
; Z8 l3 v& b+ Z+ F, ?
7 c& j' `) d2 \7 \6 T& ^ shr ax,5 ;bit 15-5,the base address( E" r$ u/ o$ k) n L! D' E0 ~
and ax,0000011111111111b
' \) Y% U3 A( k4 ^3 Z/ Y2 d mov base,ax
5 P9 l$ W" T Q7 i2 f: e. n 8 I7 x& w4 F, j) i
call ReadSpd9 u% u& R, d% H( r0 w3 K; b
exit:
; O1 O; [, y, o, S mov ax,4c00h
; V+ B9 i2 f# ^6 o7 D. \4 P int 21h
9 \1 @6 D4 P5 I8 D/ D6 Umain endp. w _6 M$ t- m1 Q" ^# D" y
9 V2 s0 b D) Y$ D4 i; I
9 ^9 L8 m- ]( O) b7 c% ]
/ P1 I2 j+ l" q; F$ `5 ?9 RReadSpd proc
# U. L* K( |7 @! Z0 N8 `& F pusha
! b3 Q, Y1 R) h9 ?2 B; h5 OAgain:
1 `9 q& Q u; K t8 g* Z9 ?) |# e9 R mov ah,num' ?& ]8 r) k1 h6 E$ ?4 ^( Y
and ah,00001111b
Q# m: N! W" z9 R- ] .if(ah==15d) ;CR_LF: R3 e5 D1 o8 C0 n
LF_CR
/ R3 z/ b. {# a8 h- m- u0 Q0 R. Z .endif
W2 M9 ^3 M" t
0 e! d% r7 D9 a8 U% @0 J9 M; \ .repeat
! C5 ]# }% r. U+ Z mov dx,base ;reset host,claim host in use) D5 }9 q! k+ ^& [$ q4 U
add dx,0. J9 f# D" Q0 D( b5 s7 y2 ~
mov al,40h
8 P& {& q* y4 d out dx,al/ d1 O j/ x- ?1 T1 I3 C$ `
' E" e. ]7 w e9 _: f2 m7 V( w5 k
mov dx,base
/ O+ A: c% G6 G9 l/ r# c in al,dx
) g" f8 }# }& B: n& |9 K mov SmbStatus,al6 [, P. P" Q" R5 Q
4 v' o% L2 \8 f4 ?8 n$ a4 M/ Z
mov dx,base ;clear all status bits6 p* u) a' O: H9 T4 w4 L
mov al,1Eh ;host status register
0 N6 X1 U+ [4 v5 J" Z out dx,al
" o! v n( Z0 A% N$ L6 T' G: Z 1 |) c$ d% z+ m2 G
mov dx,base ;set offset to read r7 t8 S( D. o+ T) ~6 q( K$ {
add dx,3 ;host command register
4 j9 x! l7 q+ p4 M% y) r! e- B; X; R% z mov al,num
& x) t8 a( k5 E2 t& A$ Y out dx,al
: r6 a# Y+ X% g9 v1 A4 e+ G/ k& M* N" h 1 ]. M9 z5 D' Z/ L% k
mov dx,base ;Transimit Slave Address register
9 {) P2 W! c+ h1 d0 k add dx,4
7 s+ x" r% V: q* v3 m0 S mov al,0a1h
6 C' q" U( d8 N. \8 E m+ U out dx,al* E$ E8 _% z$ e& U
) g N1 V6 b, n
mov dx,base ;set "Read Word" protocol and start bit* l% Z4 Z7 h, L' d6 s) Z4 X
add dx,2 ;Host Control register0 w; ? j) q% j' G- O9 u) @; U
mov al,48h ' e5 X; v d. K% L- {
out dx,al
: w0 {6 ?8 T* C3 ]5 L0 ~( Y. ?. T ! L1 f/ z$ J5 R! L1 \9 V% b
8 \: f& A j; a# m
3 c8 I( J, I, q mov dx,base
* f0 N, i: ]3 z- {! U in al,dx
, k& ~; Q: z) m mov SmbStatus,al+ ], n2 d2 X+ w
and al,1Eh* d3 y* T; o$ i2 N
.while (al==0) ;check repeatly until any of
. Q/ C. h$ u& H' ?2 R- y mov dx,base ;FAIL,BERR,DERR,INTR
, i; l4 ?2 o. ~* H, q in al,dx; x( N( |! a0 e0 }
mov SmbStatus,al
5 Z+ E' J1 v& `' v8 C2 D, ^1 Z% O3 ?" H and al,1Eh 5 R# V) [3 w: }% ]$ n
.ENDW
0 r/ s2 |& b7 v5 P. Y( a 4 A* ^2 A4 b! \) Z, g
mov al,SmbStatus
! ?6 C; T& b, M( W8 J and al,1Ch$ h2 X6 Z/ N( F/ N
.if (al!=0) ;check for errors
. z3 X4 _/ @0 J0 ~" B1 k mov al,SmbStatus
! u. l q, ^9 s8 w% }+ e and al,08h ! @7 z+ I; E% }1 s/ o7 ~( ?
.continue .if (al!=0)
h0 R b7 b' N% S jmp @F ! o1 @2 |% l: [) n
.else
' J' C& y" b# O mov dx,base
: ]7 }) [ ^% F add dx,5h& C, o/ A5 o$ B4 f3 k, D
in al,dx 5 T- D9 v+ b/ N
call binhex
0 g1 e0 W: p6 F" I e# V .break$ r8 t+ _- `; }4 V' q8 m2 j
.endif1 Y* v$ ]8 T+ L( y
$ d4 n. k6 W& g) z .until (0) $ J; T0 L4 r5 d) P, R; _
v$ ?' H7 a' X5 h2 W% a 7 q P" B. W3 L' X
1 O1 }3 j" b7 i3 f" M K( u5 m mov dl,20h ;output a space
1 ~. P+ t3 ?$ b& x, D mov ah,2
5 ^* s% |4 d4 o, D pusha! J% D6 X9 Y3 T" }4 Z; `; Q4 y
int 21h' c: J f9 V; B, Y- f0 J+ p8 |; ] B
popa. i4 z* u3 S; g$ E' R2 \% d
inc num
3 c; U4 N! t/ } Z" }2 k* g5 `% n5 k' S
cmp num,80h ;get first spd 128 bytes
" N- e: ~2 L% M/ m jnz Again
1 ~+ _: k/ `7 A- s7 V0 A7 L! H4 g ) f1 ~* \% _2 T
@@:! b6 @+ p+ A* ^& R- w
popa. p7 j- w) Y4 X& h
ret) M d5 _8 @' D5 Y+ H
ReadSpd endp' y% @9 M `$ V- O- N0 c5 U3 b
- R8 t% {, q8 g
~) }/ X' b4 `' O0 C& K" f) p8 P% c" Q+ y7 c
binhex proc
9 d) Z" @5 t) n: S pusha 9 Y1 f, @2 r; `) S* P% b |8 Y) \
+ B k0 x. F9 i2 R. r& E' L
mov ch,2 ;2 hexadecimal digits to be printed
2 \. M4 V3 f+ i' ~2 K Cloop3:, e2 k; h- d/ ^ V d
mov cl,4 ;bits to be shifted, K. P9 f/ q% m- u, C
rol al,cl; h9 i+ k0 L- B. w6 R
mov bl,al/ {+ A6 u3 o4 R0 X& o# U) `0 v) ?
and bl,0fh ;mask the 4-bit Msb
+ l4 e0 n' c( [+ Q4 N add bl,30h' ~9 Q/ `4 ~, D; v
cmp bl,3ah
6 D/ ]8 R, m: g3 H% a) b jl next1 ;number or alpha?
; y& d& k5 }# v2 Y! l add bl,7 % _0 @' \" D: H
next1: ' f8 W/ c% I; J4 T, o. v
mov ah,2 ;print one hexadecimal digit2 Q4 X0 r b; z
mov dl,bl+ ]) ?9 e2 g0 K, N
pusha
+ Y+ r1 b7 l1 F: l int 21h2 Y& q" {$ M* W
popa% W9 s- d4 P! e1 K: m: }
dec ch8 ^) f, Z+ ^, Y- M# X$ G) p
jnz loop3
( w& v9 g' r' _ j* y popa
8 _% I2 A4 b) r( K ret7 a/ ]5 |9 V" J
binhex endp
; V; L3 H2 l# n3 \ end main |
|