以byte方式讀取SPD的數據(SMBus Controller在PCH中)
Reading A Byte of SMBus EEPROM Data
The following steps have to be followed for the System BIOS to read a byte of the Serial Presence Detect (SPD) data from the DIMM.
1.Program the SMBus Base Address Register, D31:F3:20h.
2.Set the I/O Space enable bit, D31:F3:04h[0].
3.Set the HST_EN bit, D31:F3:40h[0].
4.Clear the status bits by programming SMBBASE 00h to 1Eh.
5.Program the SMBus Transmit Slave Address Register with the DIMM SMBus address, SMBBASE 04h. For example: If the DIMM address is A2h and a byte is to be read from the DIMM, program SMBBASE 04h to A3h (A2h OR’ed with 1 (Read/Write bit)).
6.Program the SMBus Host Command Register with the DIMM’s SPD data offset to be read, SMBBASE 03h. For example: If reading from offset 04h in the DIMM’s SPD, this register will have a value of 04h (Offset of SPD data to be read).
7.Program the SMBus Host Control Register, SMBBASE 02h[7:0] to 48h.
8.Wait on the Host Busy (HOST_BUSY) bit to be clear in the Host Status Register, SMBBASE 00h[0]. The System BIOS should use the INTR bit, SMBBASE 00h[1] and the other error indicator bits in the SMBus Host Status Register to indicate the end of the operation before reading the SMBus data register.
9.After the HOST_BUSY bit is clear, check the DEV_ERR bit in the Host Status Register, SMBBASE 00h[2] = 0, if the HOST_BUSY bit is clear and the DEV_ERR bit is clear the BIOS can read the byte value from the SMBus Data 0 Register, SMBBASE 05h.
Step #1 to Step #3 will be programmed only once. The BIOS can follow Step #4 through Step#9 multiple times to get all the necessary EEPROM data from the SMBus devices.
源码(WIN-TC编译通过):
#include
#include
unsigned SearchBAR(unsigned long address_s)
{
unsigned long int val;
asm mov dx,0xcf8
asm db 0x66
asm mov ax,address_s
asm db 0x66
asm out dx,ax
asm mov dx,0xcfc
asm db 0x66
asm in ax,dx
asm db 0x66
asm mov val,ax
return val;
}
void WriteFlags(unsigned long pci_addr,unsigned data)
{
asm mov dx,0xcf8
asm db 0x66
asm mov ax,pci_addr
asm db 0x66
asm out dx,ax
asm mov dx,0xcfc
asm mov al,data
asm out dx,al
}
unsigned ReadByte(unsigned SMBase_addr,unsigned i)
{
unsigned val;
outportb(SMBase_addr,0x1e);
outportb(SMBase_addr 0x04,0xa7);
outportb(SMBase_addr 0x03,i);
outportb(SMBase_addr 0x02,0x48);
while((inportb(SMBase_addr))&0x01){
delay();
}
val=inportb(SMBase_addr 0x05);
return val;
}
void main()
{
unsigned long pci_addr,SMBase_addr,bus,dev,func,offset;
unsigned i,data;
bus=0x00;
dev=0x1f;
func=0x03;
pci_addr=) (dev<<) (func<<);
WriteFlags(pci_addr 0x04,0x03);
WriteFlags(pci_addr 0x40,0x11);
SMBase_addr=SearchBAR(pci_addr 0x20)&0xffe0;
printf("PCI Address:%x",pci_addr>>);
printf("%x\n",pci_addr);
printf("use IO :%x\n",SMBase_addr);
printf("Read Byte:\n");
for(i=;i<</SPAN>;i ){
data=ReadByte(SMBase_addr,i);
printf("%4x",data);
if(i%==)
printf("\n");
}
getchar();
}
转载:http://blog.sina.com.cn/s/blog_870045320102v60u.html
以byte方式讀取SPD的數據(SMBus Controller在PCH中)的更多相关文章
- 在Android中afinal框架下實現sqlite數據庫版本升級的辦法
public abstract void onUpgrade(SQLiteDatabase db,int oldVersion,int new Version) 這個方法在實現時需要重寫. pub ...
- ionic 向後台請求json 數據 在頁面上的顯示問題
我向服務器請求數據,獲取到的數據竟然不能顯示在頁面上 我那個氣啊..... <ul> <!-- <li ng-repeat="phone in phones&quo ...
- Grafana展示報表數據的配置(二)
一.Grafana以圖表的形式展示KPI報表的結果數據1.按照日期顯示數據達標量與未達標量2.顯示當前報表的最大值.最小值.平均值.總量3.報表結果數據的鏈接分享與頁面嵌入,用戶無需登錄直接訪問報表統 ...
- Scrapy——將數據保存到MySQL數據庫
Scrapy--將數據保存到MySQL數據庫 1. 在MySQL中創建數據庫表job_inf: 1 Create table job_inf( 2 id int(11) not null auto_i ...
- PHPExcel讀取excel數據
require_once 'PHPExcel.php'; $PHPReader = new PHPExcel_Reader_Excel2007(); $filePath = 'wjyl.xlsx'; ...
- 設定 gpio 為 讀取用途,需注意的參數
Schematic 解說 上面的 線路圖, R1 R2 只能有一個被接上, R3 R4 只能有一個被接上, 是使用 gpio 讀取 電壓 判斷為0 或是 1 這時的 gpio 設定,其中一個參數需設為 ...
- C#、VSTO讀取Excel類
之前寫的類存在Excel進程不能結束的Bug,重寫ExcelReader類,類實例清理時Excel進程自動結束. class ExcelReader { // Excel Object public ...
- Android Training精要(五)讀取Bitmap對象實際的尺寸和類型
讀取Bitmap對象實際的尺寸和類型 BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecode ...
- 【转载】ASP.NET以Post方式抓取远程网页内容类似爬虫功能
使用HttpWebRequest等Http相关类,可以在应用程序中或者网站中模拟浏览器发送Post请求,在请求带入相应的Post参数值,而后请求回远程网页信息.实现这一功能也很简单,主要是依靠Http ...
随机推荐
- appium+python自动化26-模拟手势点击坐标(tap)
# 前言: 有时候定位元素的时候,你使出了十八班武艺还是定位不到,怎么办呢?(面试经常会问) 那就拿出绝招:点元素所在位置的坐标 tap用法 1.tap是模拟手指点击,一般页面上元素 的语法有两个参 ...
- Appium+python自动化13-native和webview切换
前言 现在大部分app都是混合式的native+webview,对应native上的元素通过uiautomatorviewer很容易定位到,webview上的元素就无法识别了. 一.识别webview ...
- C#方法中的ref和out
ref 通常我们向方法中传递的是值.方法获得的是这些值的一个拷贝,然后使用这些拷贝,当方法运行完毕后,这些拷贝将被丢弃,而原来的值不将受到影响.此外我们还有其他向方法传递参数的形式,引用 ...
- C#模拟MSN窗体抖动
C#模拟MSN窗体抖动 窗体抖动是件很有意思的事情,就让我们看看一起来看看它的原理吧. 其实是生成随机数,然后改变Form的左上角的坐标.我用的是循环来弄得,其实可以用timer来控制. 我把抖动分成 ...
- [Functional Programming] Working with two functors(Applicative Functors)-- Part1 --.ap
What is applicative functor: the ability to apply functors to each other. For example we have tow fu ...
- Android 中的长度单位具体解释
一.介绍一下 dp 和 sp. dp 也就是 dip.这个和 sp 基本类似.假设设置表示长度.高度等属性时能够使用 dp 或 sp.但假设设置字体,须要使用 sp. dp 是与密度无关,sp除了与密 ...
- 免费资源:Bootstrap开发的创意模板
在线演示 免费下载 一套免费的Bootstrap网站模板,使用现代的布局并支持响应式.拥有非常棒的CSS3动画效果及其滚动效果.
- C#返回多个参数 ref及out
out 关键字会导致参数通过引用来传递.这与 ref 关键字类似,不同之处在于 ref 要求变量必须在传递之前进行初始化.若要使用 out 参数,方法定义和调用方法都必须显式使用 out 关键字.例如 ...
- cocos2d-x 音乐与音效
1.背景音乐 要使用一个音乐,首先要预加载这个音乐,预加载的方法如下 SimpleAudioEngine::sharedEngine()->preloadBackgroundMusic( CCF ...
- ADexplorer - 用来查看AD的工具
ADExplorer是一款可以帮助查看和编辑数据库的软件.该数据库查看编辑器使用方便,操作简单,用户可通过该软件进行浏览AD数据库.自定义快速入口.查看对象属性.编辑权限.精确搜索等操作,还可以保存数 ...