【我所認知的BIOS】—>PCI 配置空間拾趣-2

目录(?)[-]

        文章結構安排
        PCI配置空間介紹
            1 configuration space的面貌
            2 configuration space存在的原因
        幾個重點關注的register
            1 Device ID and Vendor IDoffset 00H03H
            2 Class Codeoffset 09H0BH
            3 Header Typeoffset 0EH
            4 Base Address RegisterBAR
            5 Interrupt Pinoffset 3CH


转自: http://blog.csdn.net/lightseed/article/details/4227299

LightSeed     

2009-5-13     

1、文章結構安排


上一篇有專門對PCI device的configuration space提法。那麼在這一節中我先做一個大?
w介紹,然後再對於一些特殊的比較有用的register做比較詳細的理解總結。

2、PCI配置空間介紹

2.1 configuration space的面貌


正如截圖1.1所示,這裡就是configuration space的面貌。

 

圖1.1 PCI配置空間的map

2.2 configuration space存在的原因


為了不產生歧義,我copy了spec里的原文,後面加上我自己的翻譯。“The intent of
the PCI Configuration Space definition is to provide an appropriate set of
configuration "hooks" which satisfies the needs of current and anticipated
system configuration mechanisms, without specifying those mechanisms or
otherwise placing constraints on their use. The criteria for these
configuration "hooks" are:

? Sufficient support to allow future configuration mechanisms to provide:

  ? Full device relocation, including interrupt binding

  ? Installation, configuration, and booting without user intervention

  ? System address map construction by device independent software

? Minimize the silicon burden created by required functions

? Leverage commonality with a template approach to common functions, without
precluding devices with unique requirements”

本PCI
配置空间的定义是為了提供一系列合适的配置“鉤子”,它們可以满足现有的和预期的系?
撑渲没频男枨螅恍柚付ㄟ@些机制,并且在它们的使用上也沒
有作限定。这些配置“鉤子”的要点:

为将来的配置机制提供充分支持:

  全部设备重定位,包括中断绑定

  安装、配置和開機无需用户干預

  系统地址映射是由与设备独立的软件來构造的

  在所需的功能下創建最小化的硅组件(這裡我也沒有懂啥意思>.<)

  平衡共用和特殊,对共同的功能使用模板方式实现,同时也不排除有独特需求的设备

(發覺真想直譯過來還挺麻煩的 ^.^)有點辭不達意,如果不是外行人我建議
還是看英文原文比較好。起碼我是這麼想。

文字那麼一大堆,看的煩也煩死了。直接點,PCI設備要正常運作,那麼
配置這些寄存器是必要條件。反之,沒有配置他們,PCI設備肯定是不能正常運作的啦。

3、幾個重點關注的register

3.1 Device ID and Vendor ID(offset 00H~03H)


之前有說明他們標誌了這個PCI設備的設備號,廠商代碼。具體
要去查的話可以去查相應的組織。

3.2 Class Code(offset 09H~0BH)


這個寄存器是爲了標誌 PCI設備用途的。分為這三個byte分別有各自的意義
,詳細可以查一下spec。它是read only的。

3.3 Header Type(offset 0EH)


這個字節里的各個bit都有相應的用處,只是為了提高PCI scan才在這裡
提一下,如果不用這個方法以現在的計算機速度,只用3個loops來PCI scan
也不會有很大的延時的。

3.4 Base Address Register(BAR)


3.4.1寄存器作用


這些寄存器是重中之重。這次我懶得翻譯了,引用一下原文spec 2.3 page 205“One of
the most important functions for enabling superior configurability and ease
of use is the ability to relocate PCI devices in the address spaces. At
system power-up, device independent software must be able to determine what
devices are present, build a consistent address map, and determine if a
device has an expansion ROM.”我想過了四級的人應該都能看的懂的。

3.4.2怎麼讀取BAR標誌的空間大小


那麼在build的過程中,BIOS怎麼才能知道pci設備需要多大的空間呢?在做PCI設備的時
候,人們很聰明。 當往BAR中寫0xFFFFFFFFH的后,再讀取BAR數值就會得到一個double
word的數值。若返回是全“F”說明該BAR是不需要空間的
,若返回非全F那麼從低位開
始數,遇到第一個非“0”的bit時為止, 從bit0~這位bitn(n<31)代表的大小就是PCI設
備需要的空間大小了。


舉個例子:

當讀回來的數值是0xFFFFFC00H時,0xFFFFFC00H=1111 1111 1111 1111 1100 0000 0000B
相信應該容易算出來了。

3.4.3BAR標誌的空間是memory還是IO?


細心的人會發覺在讀回來的數值中最低bit位有的是“0”,有的是“1
”。他們究竟有什麽區別?簡而言之,“0”表示需要的是memory空間,“1”表示的是IO
空間。詳細可以去看spec,他們都各自有各自的最小單位。

3.5 Interrupt Pin(offset 3CH)


引用一下Spec原文,因為我覺得他們說的比我說的清楚多了“The Interrupt Pin
register tells which interrupt pin the device (or device function) uses. A
value of 1 corresponds to INTA#. A value of 2 corresponds to INTB#. A value
of 3 corresponds to INTC#. A value of 4 corresponds to INTD#. Devices (or
device functions) that do not use an interrupt pin must put a 0 in this
register. The values 05h through FFh are reserved. This register is read-only
. Refer to Section 2.2.6. for further description of the usage of the INTx#
pins.”PCI設備要處理數據,它的數據也肯定最終是要讓CPU來處理的,與CPU的通信的話
PCI設備是通過中斷來實現的。而Interrupt Pin只是標誌了HW上用了INTx
中的哪一個。這個與PCI IRQ routing table有關係了。後續篇章里我會繼續談到。

至此,configuration space中我覺得重要點的寄存器就算講的差不多了。以上均是我在?
W習的過程中都遇到過問題的,再次做一次小結。不對之處在所難免,望各位指正。這篇?
v概念性的東西比較多,但是卻都是必備的東東。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值