我参考了SMBUS2.0的SPEC,里面只有一些保留的SLAVE ADDRESS,还说其他的地址由SMBUS WORKING GROUP来进行分配,通过地址来标志不同类别的设备,可是我不知道去哪里能找到这些标记设备类别的地址,所以哪位有这样的资料,麻烦给我份,或者下载地址。
看到有说SMBUS2.0的设备可以numeric,那是什么意思,如何做啊?
//byte0: the size of SPD used
bool SPD_BYTE0(DWORD base,BYTE DEVID)
{
DWORD RetVal=0;
RetVal=ReadSPD(base,0,DEVID);
if(RetVal>=128)
{
printf("The size of SPD used: %dbytes\n",RetVal);
return TRUE;
}
else
return FALSE;
}
//byte1: total size of SPD
void SPD_BYTE1(DWORD base,BYTE DEVID)
{
DWORD RetVal=0;
RetVal=ReadSPD(base,1,DEVID);
printf("Total size of SPD: %dbytes\n",(1<
}
//byte2: Memory Type
void SPD_BYTE2(DWORD base,BYTE DEVID)
{
DWORD RetVal=0;
RetVal=ReadSPD(base,2,DEVID);
//printf("TYPE Value: %d\n",RetVal);
switch(RetVal)
{
case 0x04:
printf("Memory Type is: SDRAM\n");
break;
case 0x07:
printf("Memory Type is: SDRAM DDR\n");
break;
default:
printf("Memory Type is: Other\n");
break;
}
}
//byte9: Cycle time
void SPD_BYTE9(DWORD base,BYTE DEVID)
{
DWORD RetVal=0;
float CylTime=0;
int temp;
RetVal=ReadSPD(base,9,DEVID);
//printf("Cycle time value: %dbytes\n",RetVal);
temp=(int)RetVal&0x0F;
if(temp<=9)
CylTime=(RetVal&0x0F)/10;
else
printf("Read Cycle time error!\n");
temp=(int)((RetVal&0x0F0)/16);
if(temp!=0)
CylTime=CylTime+temp;
else
printf("Read Cycle time error!\n");
//printf("Cyle Time is: %fns\n",CylTime);
temp=(int)2000/CylTime;
printf("RAM FSB=%dMHz\n",temp);
}
//byte31: Memory size
int SPD_BYTE1F(DWORD base,BYTE DEVID)
{
DWORD RetVal=0;
int RAMSZ=0;
RetVal=ReadSPD(base,0x1f,DEVID);
//printf("TYPE Value: %d\n",RetVal);
switch(RetVal)
{
case 0x04:RAMSZ=16;break;
case 0x08:RAMSZ=32;break;
case 0x10:RAMSZ=64;break;
case 0x20:RAMSZ=128;break;
case 0x40:RAMSZ=256;break;
case 0x80:RAMSZ=512;break;
case 0x01:RAMSZ=1024;break;
case 0x02:RAMSZ=2048;break;
default:RAMSZ=0;
}
return RAMSZ;
}
int main(int argc, char* argv[])
{
DWORD dataddr;
DWORD baseddr;
DWORD dwPortVal;
bool bResult;
int busID=0;
int deviceID=0;
int funID=0;
BYTE offset=0;
busID=strtoul(argv[1],NULL,16);
deviceID=strtoul(argv[2],NULL,16);
funID=strtoul(argv[3],NULL,16);
//ChkSMbus();
// get SMbus base address
dataddr=BASEADDRESS+(busID<<16)+(deviceID<<11)+(funID<<8);
// Call InitializeWinIo to initialize the WinIo library.
bResult = InitializeWinIo();
if(bResult)
{
//Get SMBus base address
SetPortVal(IO_SC,dataddr+0x20,4);
GetPortVal(IO_DA,&dwPortVal,4);
baseddr=dwPortVal&0x0FFFFFFF0;
printf("SMBus base address=%08X\n",baseddr);
if(WaitReady(baseddr))
{//read SPD info
//read Slot0 memory info
if(SPD_BYTE0(baseddr,DIMM0)==TRUE)
{
//SPD_BYTE1(baseddr,DIMM0);
SPD_BYTE2(baseddr,DIMM0);
SPD_BYTE9(baseddr,DIMM0);
printf("RAMSZ=%dMB\n",SPD_BYTE1F(baseddr,DIMM0));
}
else
{
printf("DIMM0: Read error!\n");
}
//read Slot1 memory info
if(SPD_BYTE0(baseddr,DIMM1)==TRUE)
{
//SPD_BYTE1(baseddr,DIMM0);
SPD_BYTE2(baseddr,DIMM1);
SPD_BYTE9(baseddr,DIMM1);
printf("RAMSZ=%dMB\n",SPD_BYTE1F(baseddr,DIMM1));
}
else
{
printf("DIMM1: Read error!\n");
}
}
}
else
{
printf("Error during initialization of WinIo.\n");
exit(1);
}
// When you're done using WinIo, call ShutdownWinIo
ShutdownWinIo();
return 0;
}