PCI不同的地址域

Pci的地址域

PCI总线协议中定义了三个不同的地址空间:1、PCI配置空间;2、PCI memory空间;3、PCI的IO空间。如果对PCI没有形成一点感念的初学者,很难理解这几个空间的区别。

简单的说,PCI配置空间是PCI设备的内部属性,设备内部保存了256bytes的空间作为内部register定义该设备的属性。访问配置空间使用IO读写(X86架构中使用CF8h/CFCh端口);而PCI设备的memory/IO空间则是映射到CPU地址域中,需要占用的memory/IO地址空间。访问这部分地址域只要使用简单直接的memory、IO访问方式就可以实现。

 

A、 PCI配置空间

 

每个PCI设备的配置空间数据都不一样。基本上都是以固定的形式。每个外围设备在其 PCI 配置空间中都包含一组明确定义的配置寄存器。这些寄存器不仅用于标识设备,还用于提供设备配置信息。生成配置周期的方法取决于主机架构,x86 计算机中使用的是特殊的 I/O 端口(CF8h/CFCh端口)。在其他平台上,可以将 PCI 配置空间内存映射到对应于主机地址域中 PCI 主桥 (host bridge) 的某些地址位置,比如MIPS架构中。

针对不同类型的pci设备,配置空间可以归纳为两种,type0、type1,基本上两种byte是一致的,type0表示一般类型的pci设备,type1则是pci bridge。

下图即为PCI定义的type0的配置空间头部

Type0的配置空间header部分

 

B、 PCI memory空间

PCI设备为了能正常使用,需要分配内存空间,以便Driver来控制操作pci设备。这些动作是有BIOS来在scan pci总线并初始化的时候完成的,依据该pci设备的属性:需要多大的内存空间(BAR0/BAR1,etc),bios将按照一定的算法,给予所有需要memory空间的pci设备分配内存空间。并将分配内存段的基地址填入到配置空间中的BAR0/BAR1寄存器.

看下图,PCI设备所占用的memory空间是在4G总线(32bit cpu的memory地址域)的高端部分。

Pci内存空间在cpu地址域中的映射

C、 PCI IO 空间

对于IO空间,和memory空间是一个道理,只是有些pci设备需要分配IO空间;有些设备需要分配memory空间而已,当然还有设备比较复杂,会同时需要分配memory、io空间。IO空间的分配也是从cpu 的IO空间高端部分开始分配的,即64K Byte的IO空间。

 

最直接的方式看memory io 空间的分配情况,可以在xp系统下的‘设备管理器’中查看到。

设备管理器中查看memory分配情况

设备管理器中查看IO分配情况

 

Rebuild started: Project: Project *** Using Compiler 'V6.22', folder: 'E:\Keil_v5\ARM\ARMCLANG\Bin' Rebuild target 'Target 1' assembling startup_stm32f10x_md.s... Start/core_cm3.c(445): error: non-ASM statement in naked function is not supported 445 | uint32_t result=0; | ^ Start/core_cm3.c(442): note: attribute is here 442 | uint32_t __get_PSP(void) __attribute__( ( naked ) ); | ^ Start/core_cm3.c(465): error: parameter references not allowed in naked functions 465 | "BX lr \n\t" : : "r" (topOfProcStack) ); | ^ Start/core_cm3.c(461): note: attribute is here 461 | void __set_PSP(uint32_t topOfProcStack) __attribute__( ( naked ) ); | ^ Start/core_cm3.c(479): error: non-ASM statement in naked function is not supported 479 | uint32_t result=0; | ^ Start/core_cm3.c(476): note: attribute is here 476 | uint32_t __get_MSP(void) __attribute__( ( naked ) ); | ^ Start/core_cm3.c(499): error: parameter references not allowed in naked functions 499 | "BX lr \n\t" : : "r" (topOfMainStack) ); | ^ Start/core_cm3.c(495): note: attribute is here 495 | void __set_MSP(uint32_t topOfMainStack) __attribute__( ( naked ) ); | ^ 4 errors generated. compiling core_cm3.c... compiling misc.c... compiling system_stm32f10x.c... compiling stm32f10x_adc.c... compiling stm32f10x_dac.c... compiling stm32f10x_exti.c... compiling stm32f10x_dbgmcu.c... compiling stm32f10x_dma.c... compiling stm32f10x_crc.c... compiling stm32f10x_cec.c... compiling stm32f10x_bkp.c... compiling stm32f10x_can.c... compiling stm32f10x_flash.c... compiling stm32f10x_pwr.c... compiling stm32f10x_fsmc.c... compiling stm32f10x_
03-31
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值