PCIE设备操作的简单说明
- 格式:pdf
- 大小:168.68 KB
- 文档页数:13
pcie 设备在位检测机理-回复PCIE设备在位检测机理随着计算机技术的不断发展,PCI Express(Peripheral Component Interconnect Express,简称PCIE)作为一种高速串行总线接口标准,已成为现代系统中主要的外围设备连接接口。
而在PCIE设备的使用中,快速而准确地检测这些设备的位置和状态非常重要。
本文将详细介绍PCIE 设备在位检测的机理,并逐步回答相关问题。
第一部分:什么是PCIE设备在位检测PCIE设备在位检测是指操作系统(OS)和主板固件能够准确识别和定位插入到主机插槽中的PCIE设备。
通过实时检测PCIE设备的状态和位置,OS和主板固件能够正确配置和管理这些设备,保证系统的正常运行。
第二部分:PCIE设备在位检测的基本机理PCIE设备在位检测的基本机理主要涉及以下几个方面:PCIE设备寻址、主板固件初始化和设备驱动加载。
1. PCIE设备寻址当PCIE设备插入主机插槽时,主板固件会扫描总线上的设备并建立设备树。
这个过程中,固件会通过查询PCIE配置空间寻址的方式,扫描设备,获取设备的Vendor ID和Device ID等信息。
2. 主板固件初始化在设备寻址的基础上,主板固件会根据设备树中的配置信息初始化PCIE 设备。
这个过程中,固件会设置设备的中断号、内存映射、总线宽度等参数,以便后续系统的正确识别和使用。
3. 设备驱动加载当设备初始化完成后,操作系统会根据设备的Vendor ID和Device ID匹配相应的设备驱动程序,并加载到系统中。
设备驱动程序是操作系统与PCIE设备进行通信和管理的关键。
第三部分:PCIE设备在位检测的具体实现过程PCIE设备在位检测的具体实现过程可以分为以下几个步骤:固件初始化、PCIE设备寻址和设备驱动加载。
1. 固件初始化当主机启动时,主板固件会启动并进行初始化,包括建立设备树、设置中断控制器、加载驱动等。
PCIScope操作过程PCIScope是一种软件工具,可以在Windows和Linux操作系统上运行。
它能够对PCI总线上的读写访问进行捕获和分析,提供详细的数据统计和可视化图表,让用户能够更好地理解和分析PCI总线上发生的事情。
下面是PCIScope操作过程的详细步骤:2. 连接PCI总线适配器。
PCIScope操作需要使用特殊的硬件适配器,该适配器允许PCIScope连接到PCI总线并捕获数据。
将适配器插入计算机主板上的PCI插槽,并连接适配器与计算机的接口线。
3. 启动PCIScope软件。
在安装完成后,可以在开始菜单或桌面上找到PCIScope的快捷方式,并双击运行软件。
在用户界面中,可以看到相关的控制按钮和数据显示区域。
4. 配置PCIScope参数。
在使用PCIScope之前,需要配置一些参数,以便适应特定的应用场景和需求。
参数配置主要包括选择PCI总线适配器、设置捕获模式和过滤选项等。
根据需要进行相应的设置,并保存配置文件以备将来使用。
5. 开始数据捕获。
通过点击相应的按钮或命令,可以启动PCIScope的数据捕获功能。
PCIScope会开始监听PCI总线上的读写访问,并将捕获到的数据保存在本地磁盘上的文件中。
6. 分析和观察数据。
在数据捕获结束后,可以通过PCIScope提供的显示和分析功能来查看和理解数据。
PCIScope支持以图表和表格的形式显示各种统计信息,包括总线带宽、传输延迟、访问类型等。
7. 导出和保存数据。
PCIScope还提供了将数据导出到文件或其他外部工具的功能。
用户可以选择将捕获到的数据保存为CSV、XML或其他格式的文件,以便在其他工具中进行进一步的分析和处理。
8. 结束操作和清理工作。
在使用PCIScope之后,可以通过关闭软件和断开适配器与计算机的连接来结束操作。
同时,还可以对PCIScope的捕获文件和配置文件进行清理和整理,以便下次使用。
总的来说,PCIScope操作过程包括安装软件、连接适配器、配置参数、启动捕获、分析数据、导出保存和清理工作等步骤。
pcie基本原理PCIe基本原理PCIe(Peripheral Component Interconnect Express)是一种高速、点对点的串行总线标准,用于连接计算机内部的外部设备。
它是目前最流行的计算机总线标准之一,被广泛用于连接各种设备,如显卡、网卡、存储控制器等。
本文将介绍PCIe的基本原理,以帮助读者更好地理解这一技术。
PCIe采用串行传输方式,相比传统的并行总线,具有更高的带宽和更低的延迟。
它采用差分信号传输,即同时传输正负两路信号,以减少信号干扰和提高传输速度。
PCIe总线的带宽通常用“xN”来表示,其中“x”表示总线的通道数,而“N”表示每个通道的数据传输速率。
例如,PCIe 3.0 x16表示具有16个通道,每个通道的传输速率为PCIe 3.0规范下的速率。
PCIe总线采用多通道的方式来提高数据传输速度。
每个通道都有自己的发送和接收端口,可以同时进行数据传输。
此外,PCIe还支持多路复用技术,即将多个数据流通过同一物理通道传输,以提高总线的利用率。
这种设计使PCIe具有更高的带宽和更好的扩展性,可以满足不同设备对数据传输速度的需求。
PCIe总线还采用了“插槽”和“连接器”的设计,以便用户可以方便地连接和更换设备。
每个PCIe插槽都有一定数量的针脚,用于传输数据、电源和地线。
连接器则负责将插槽与设备连接起来,保证信号传输的可靠性和稳定性。
PCIe插槽通常分为不同的规格,如PCIe x1、PCIe x4、PCIe x8和PCIe x16等,以适应不同设备的需求。
PCIe总线还具有“热插拔”和“热插拔”功能,用户可以在计算机运行时插入或拔出设备,而无需重新启动计算机。
这使得设备的更换和升级变得更加方便快捷。
此外,PCIe还支持“链路层发现”和“链路层训练”功能,用于自动检测和优化总线的性能,以提高数据传输的稳定性和可靠性。
总的来说,PCIe是一种高速、灵活、可靠的计算机总线标准,被广泛应用于各种设备之间的连接。
pcie 设备在位检测机理 PCIe(Peripheral Component Interconnect Express)是一种高速串行总线标准,广泛应用于计算机系统的扩展插槽中。作为一种常见的硬件接口,PCie设备的在位检测机制对于确保设备的正确连接至关重要。本文将详细介绍PCie设备的在位检测机理,并探讨其在实际应用中的指导意义。
在位检测是一种通过插槽上的信号和电气特性来确定设备是否正确连接的检测机制。当PCie设备插入到主板的扩展槽中时,系统会自动对其进行检测,以确保通信的可靠性和一致性。在位检测通常包括以下几个方面:
首先,PCie设备在插入扩展槽时,与PCie插槽上的接触点进行物理接触。这些接触点由导电材料制成,当设备插入槽时,它们会与设备上的金属接触点相连接。通过测量接触电阻和电压等参数,系统可以判断设备是否正确连接。
其次,PCie设备在插入槽后,会通过配置空间进行身份标识和初始化。每个PCie设备都有一个唯一的设备ID,通过配置空间,主机可以读取设备ID并与预期的设备进行匹配。如果设备ID与预期不符,那么可能是设备没有正确插入或者设备与插槽不兼容。
此外,PCie设备还会发送特定的电信号来表示存在并准备好与主机进行通信。这些信号包括电压、电流和时钟等,通过测量这些信号的参数,可以确定设备是否正常工作。 PCie设备的在位检测机理对于计算机系统的稳定运行至关重要。它可以确保设备正确连接,避免不必要的通信错误和系统故障。通过在位检测,系统可以自动识别设备,并根据需要进行适当的配置和初始化。这大大简化了设备的部署和管理,并提高了系统的可靠性和稳定性。
在实际应用中,了解PCie设备的在位检测机理对于正确安装和配置设备非常重要。首先,在安装PCie设备时,要确保设备与插槽完全对齐,并轻轻插入直到底部。插入后,检查设备是否牢固固定且没有松动。其次,在启动计算机时,注意观察系统是否检测到了新设备,并通过设备管理器等工具验证设备的连接和工作状态。如果发现异常情况,如设备未被识别或驱动程序无法加载,请检查设备插槽是否有损坏或者设备与插槽不兼容等问题。
pcie接⼝介绍注:以下内容主要参考《PCI Express System Architecture》⽂档,下载地址:⼀、PCIe接⼝的发展历程(peripheral component interconnect express)是⼀种⾼速串⾏计算机扩展总线标准,它原来的名称为“3GIO”,是由在2001年提出的,旨在替代旧的PCI,PCI-X和AGP总线标准。
pci或pcie接⼝在pc机上很常见,显卡、⽹卡、声卡都是通过pci或在pcie接⼝跟cpu连接的。
PCIe是有PCI和PCI-X发展⽽来,如下表所⽰:PCIe的发展历程如下图所⽰:⼆、PCIe 通讯协议2.1 PCIe层划分PCIe总线的层次组成结构与⽹络中的层次结构有类似之处,但是PCIe总线的各个层次都是使⽤硬件逻辑实现的。
在PCIe体系结构中,数据报⽂⾸先在设备的核⼼层(Device Core)中产⽣,然后再经过该设备的事务层(Transaction Layer)、数据链路层(Data Link Layer)和物理层(Physical Layer),最终发送出去。
⽽接收端的数据也需要通过物理层、数据链路和事务层,并最终到达Device Core。
1 事务层事务层定义了PCIe总线使⽤总线事务,其中多数总线事务与PCI总线兼容。
这些总线事务可以通过Switch等设备传送到其他PCIe设备或者RC。
RC也可以使⽤这些总线事务访问PCIe设备。
事务层接收来⾃PCIe设备核⼼层的数据,并将其封装为TLP(Transaction Layer Packet)后,发向数据链路层。
此外事务层还可以从数据链路层中接收数据报⽂,然后转发⾄PCIe设备的核⼼层。
事务层的⼀个重要⼯作是处理PCIe总线的“序”。
在PCIe总线中,“序”的概念⾮常重要,也较难理解。
在PCIe总线中,事务层传递报⽂时可以乱序,这为PCIe设备的设计制造了不⼩的⿇烦。
事务层还使⽤流量控制机制保证PCIe链路的使⽤效率。
PCIe总线概述随着现代处理器技术的发展,在互连领域中,使用高速差分总线替代并行总线是大势所趋。
与单端并行信号相比,高速差分信号可以使用更高的时钟频率,从而使用更少的信号线,完成之前需要许多单端并行数据信号才能达到的总线带宽。
PCI总线使用并行总线结构,在同一条总线上的所有外部设备共享总线带宽,而PCIe 总线使用了高速差分总线,并采用端到端的连接方式,因此在每一条PCIe链路中只能连接两个设备.这使得PCIe与PCI总线采用的拓扑结构有所不同。
PCIe总线除了在连接方式上与PCI总线不同之外,还使用了一些在网络通信中使用的技术,如支持多种数据路由方式,基于多通路的数据传递方式,和基于报文的数据传送方式,并充分考虑了在数据传送中出现服务质量QoS (Quality of Service)问题。
PCIe总线的基础知识与PCI总线不同,PCIe总线使用端到端的连接方式,在一条PCIe链路的两端只能各连接一个设备,这两个设备互为是数据发送端和数据接收端。
PCIe总线除了总线链路外,还具有多个层次,发送端发送数据时将通过这些层次,而接收端接收数据时也使用这些层次.PCIe总线使用的层次结构与网络协议栈较为类似.1。
1 端到端的数据传递PCIe链路使用“端到端的数据传送方式”,发送端和接收端中都含有TX(发送逻辑)和RX(接收逻辑),其结构如图4-1所示。
由上图所示,在PCIe总线的物理链路的一个数据通路(Lane)中,由两组差分信号,共4根信号线组成.其中发送端的TX部件与接收端的RX部件使用一组差分信号连接,该链路也被称为发送端的发送链路,也是接收端的接收链路;而发送端的RX部件与接收端的TX部件使用另一组差分信号连接,该链路也被称为发送端的接收链路,也是接收端的发送链路。
一个PCIe链路可以由多个Lane组成.高速差分信号电气规范要求其发送端串接一个电容,以进行AC耦合.该电容也被称为AC耦合电容。
linux一.对设备配置寄存器的设置1.获得PCIE设备的物理地址和大小,转换为内核虚拟地址,内核可以用专用的IO端口操作函数操作ioread/iowrite.linuxwindows2.往配置空间写数据,配置寄存器,设备的工作模式。
二.将内核申请的虚拟内存转换为物理地址,将此地址写到DMA控制器的寄存器中,作为目的值。
$ DPC 的执行在硬件中断处理的最后,会调用HalEndSystemInterrupt。
HalEndSystemInterrupt中,会将IRQL 降低,然后检查是否有DPC pending,有的话,会调用KiDispatchInterrupt处理dpc。
KiDispatchInterrupt中调用KiRetireDpcList处理dpc。
也就是说,当在硬件中断处理中加入一个dpc,那么当这个硬件中断处理结束的时候,就会调用这个被加入的DPC。
a:所有处理都放在isr中b:处理分两部分,必须要做的放在isr中,剩下的放在dpc中,isr中使用dpca的处理代码一直执行下来,只可能被irql比它高的硬件中断中断。
b的isr一直执行下来,紧接着执行dpc。
isr部分只能被irql比它高的硬件中断中断。
dpc部分可被任何硬件中断中断。
Pcie可以用DAM传输,也可以不用,在驱动中的内存和设备的内存间复制传输。
1.在EvtDevicePrepareHardware(),获得设备配置空间基地址和长度,以便往这个空间内的中断寄存器和DMA传输寄存器赋值。
2.在IORead()调用EvtProgramDma(),①允许DMA终端②写驱动内存地址和大小到DMA寄存器③启动DMA传输3.DMA传输完成后,引起中断,进入中断服务函数EvtInterruptIsr(),判断是本设备引起的中断,则进入中断延迟函数EvtInterruptDpc(),进行数据处理,将驱动内存数据复制到用户内存pci。
pcie工作原理PCIE(Peripheral Component Interconnect Express)是一种计算机总线标准,用于连接计算机的主板和扩展卡,提供高速数据传输和通信能力。
PCIE采用串行通信方式,通过差分信号传输数据,具有高带宽、低延迟和稳定性强等特点。
PCIE工作的基本原理是通过发送和接收数据包来实现设备之间的通信。
PCIE总线由一个或多个通道组成,每个通道都由一个发送端和一个接收端组成。
发送端将数据包分为多个数据包,添加控制信息和错误检测信息,然后将它们转换成差分信号通过传输线发送到接收端。
接收端接收到差分信号后,将其转换为数字信号,然后还原为原始数据包。
在PCIE总线中,每个设备都有一个唯一的设备号和功能号。
当计算机启动时,主板上的PCIE根端口会扫描所有连接的设备,为每个设备分配一个资源配置空间(Configuration Space),并为其分配一个唯一的设备号和功能号。
这样,计算机可以通过设备号和功能号来识别和访问各个设备。
PCIE总线支持多种数据传输方式,包括可靠的无连接传输(Reliable Datagram)和可靠的有连接传输(Reliable Transaction)。
无连接传输适用于对延迟要求较高的应用,如数据流传输。
有连接传输适用于对可靠性要求较高的应用,如存储器读写操作。
PCIE还支持虚拟化技术,可以将一个物理设备虚拟为多个逻辑设备,每个逻辑设备都具有独立的设备号和功能号。
虚拟化技术使得多个操作系统可以同时访问同一个物理设备,提高了系统的利用率和灵活性。
PCIE总线的速度通常用一个数字来表示,例如PCIE 3.0和PCIE 4.0。
PCIE 3.0的速度为8GT/s(Gigatransfers per second),即每秒传输8亿次数据。
PCIE 4.0的速度为16GT/s,是PCIE 3.0的两倍。
随着技术的发展,PCIE的速度还会不断提升。
PCIE总线在计算机领域有着广泛的应用。
linux中pcie设备初始化流程PCIe(Peripheral Component Interconnect Express)是一种高速串行总线接口,用于连接计算机主板和外部设备。
在Linux系统中,PCIe设备的初始化是一个重要的过程,它确保设备能够正常工作并与系统进行通信。
本文将介绍Linux中PCIe设备初始化的流程。
1. 设备检测与识别在Linux系统启动时,内核会进行设备检测与识别的过程。
对于PCIe设备,内核会扫描PCIe总线,识别连接在总线上的设备。
这个过程是通过读取PCIe设备的配置空间来完成的。
配置空间是一块特殊的内存区域,包含了设备的各种信息,如设备ID、厂商ID、设备类别等。
2. 分配资源一旦设备被识别,内核会为其分配必要的资源,如内存空间、中断线等。
这些资源的分配是通过解析设备的配置空间来完成的。
内核会根据设备的需求和系统的可用资源进行分配,以确保设备能够正常工作。
3. 驱动加载设备的驱动程序是用来控制和管理设备的软件模块。
在Linux系统中,驱动程序是以内核模块的形式存在的。
一旦设备被识别并分配了资源,内核会加载与之对应的驱动程序。
驱动程序会与设备进行通信,配置设备的寄存器、中断等,并提供相应的接口供用户空间程序使用。
4. 设备初始化设备初始化是指对设备进行一系列的配置和初始化操作,以使其能够正常工作。
设备初始化的具体过程是由设备的驱动程序来完成的。
驱动程序会根据设备的特性和需求,对设备进行相应的配置和初始化。
这包括设置设备的工作模式、参数、中断处理等。
5. 设备注册设备注册是将设备与系统进行关联的过程。
在Linux系统中,设备注册是通过设备模型来完成的。
设备模型是一种用于描述和管理设备的框架,它提供了一套标准的接口和方法,用于设备的注册、管理和访问。
设备注册的过程包括将设备添加到设备模型中,并分配设备号等。
6. 设备启动设备启动是指设备开始正常工作的过程。
在Linux系统中,设备启动是由设备的驱动程序来完成的。
pcie加密卡工作原理
PCIE加密卡是一种可插入式设备,通过其与计算机的PCI Express(PCIe)插槽相连接,来提供硬件加密的功能。
PCIE加密卡的工作原理如下:
1. 数据传输
在使用PCIE加密卡进行数据加密操作之前,需要将需要加密的数据发送给加密卡。
通过其他硬件设备或网络通信,将需要加密的数据传输到PCIE加密卡上。
2. 硬件加密处理
在PCIE加密卡上,数据传输到达后,PCIE加密卡内部的加密处理器开始对数据进行加密处理。
加密处理器使用先进的加密算法,将需要加密的数据进行加密处理,以保证数据的安全性和私密性。
当数据加密处理完成后,PCIE加密卡将加密后的数据返回到计算机内部。
返回的数据可以被其他程序或设备继续处理,但该数据已被加密处理,只有经过解密才能得到原始数据。
4. 加密密钥保护
在加密处理过程中,PCIE加密卡使用的加密密钥起着至关重要的作用。
为保证加密密钥的安全性,PCIE加密卡将加密密钥保护在内部存储器中,并采用多种保护措施来保护密钥不被非法获取或破解。
5. 维护和管理
为了保证PCIE加密卡能够保持高效的加密操作,其需要得到适时的维护和管理。
管理员可以使用特定的软件来监控加密卡的状态和性能,以便在必要时进行维护和调整。
6. 兼容性
总之,PCIE加密卡是一种高效的数据加密设备,可提供强大的硬件加密能力。
它的工作原理简单、易于理解,并具有良好的兼容性和可扩展性,是保护数据安全的重要手段之一。
321090Accessing PCI Express* Configuration Registers Using Intel ® ChipsetsDecember 2008White Paper Sam Fleming Technical Marketing EngineerIntel CorporationAccessing the Real Time Clock Registers and NMI Enable BitExecutive SummaryThere are two different methods that can be used to access PCI Express*(PCIe*) configuration registers of devices in systems based on Intelsilicon. The first method involves setting the desired Bus, Device,Function, and Register values in I/O register CF8h and then reading orwriting the desired value via an access to I/O register CFCh. Theseregisters are located in the memory controller component of most Intelchipsets (typically the “North Bridge” or MCH/GMCH component). The actof reading/writing to I/O register CFCh causes this component to generatedownstream PCIe configuration bus cycles. This is the original “legacy”PCI method of accessing the configuration registers and is limited toaccessing only the first 255 configuration registers of any PCIe device.The second method that can be used to access PCIe* configurationregisters involves standard memory read/write accesses to a reservedblock of memory space. Intel® silicon is designed to convert thesememory cycles into downstream PCIe configuration read and write cycles.This permits access to the full 4096 configuration register range in eachPCIe device.The second method can be a bit tricky for softwareprogrammers to implement.This second method can be a bit a tricky for software programmers toimplement, especially considering that some of the details vary fromchipset to chipset. This paper will examine the exact formulas andprocesses that software developers need to implement in order tosuccessfully read and write to these PCIe* registers.§2321090Accessing the Real Time Clock Registers and NMI Enable Bit321090 3ContentsBusiness Challenge .................................................................................................4 PCIe* Configuration Register Access – Method 1: I/O CF8h and CFCh ...........................4 PCIe* Configuration Register Access – Method 2: Memory Mapped . (6)Conversion Formulas.............................................................................8 Chipset Variance...................................................................................9 PCIe* Memory Range and How It Impacts Available DRAM in 4GB SystemsRunning 32-bit Operating Systems (9)Conversion Formulas – Code ..................................................................................10 Conclusion.. (11)Business ChallengeThe methodology used in accessing the PCIe* configuration registers goesback to the original PCI specification. Intel's first implementation of thisspecification used I/O locations CF8h and CFCh in an index/data fashion inorder to create the PCI configuration cycles. This method can successfullyaccess any of the 255 PCI configuration registers in any PCI device. Intelchipsets still support this configuration method.The PCIe* specification built on the PCI foundation by allowing each PCIedevice/function to have up to 4096 configuration registers. Although the oldCF8h/CFCh method can still be used to access the first 255 registers in eachPCIe device, a different method had to be introduced to allow accesses to thefull 4KB range of configuration registers. Intel chipsets solve this problem bymoving the PCIe configuration registers into the memory address space.PCIe configuration registers can now be accessed by performing memoryreads and writes to a very specific range in memory.The specific range of memory is controlled by the piece of Intel silicon thatcontains the memory controller. Typically, this is the “North Bridge”component. However, details of the implementation vary from chipset tochipset. Understanding the exact process in creating software to access thePCIe* configuration registers using this range of memory is the purpose ofthis paper.PCIe* Configuration Register Access – Method 1: I/O CF8h and CFChTo access PCI configuration registers, Intel® chipsets use I/O locations CF8hand CFCh to access the configuration registers in a PCI device. This methodcan also be used to access the first 255 configuration registers in PCIe*devices.321090Accessing the Real Time Clock Registers and NMI Enable Bit321090 5Figure 1. I/O Registers CF8h and CFCh DetailsIn order to create a PCI Configuration Cycle to a given device, software must perform the following steps:1. The device’s bus number must be written into bits [23:16] of I/Olocation CF8h 2. The device’s “PCI device number” must be written into bits [15:11] ofI/O location CF8h 3. The device’s function must be written into bits [10:8] of I/O locationCF8hNote: The Dword address of the desired PCI configuration must bewritten into bits [7:2] of I/O location CF8hIt is important to realize that all PCI configuration cycles are 4 byte (1 Dword) read/write routines. Since bits [1:0] are reserved, thissimplifies things a bit since the actual register address can be written into the full 8 bits of [7:0] (data written to bits [1:0] has no affect on the created PCI configuration cycle).4. The configuration bit in I/O location CF8h[31] must be set to 1b.5. For writes, the specific data to be written out during the configurationcycle is written into I/O location CFCh. For reads, software must perform a read to I/O location CFCh.When I/O location CFCh is accessed, the corresponding read or writeAccessing the Real Time Clock Registers and NMI Enable Bit6321090PCI configuration cycle is created by the Intel ® silicon and propagated throughout the system as necessary.PCIe* Configuration Register Access – Method 2: Memory MappedThe PCIe* specification added more configuration registers possible for each PCIe device. Each PCIe device can now have up to 4096 bytes ofconfiguration registers. Although the method described above using I/O locations CF8h and CFCh to create configuration cycles still works foraccessing the lower 255 registers, a new method must be used to access configuration registers to the rest of the 4096 (4K) range.The solution involves reserving a 256MB block of memory address space. Any accesses to this region of memory address space will cause the Intel silicon to create a PCIe configuration cycle to be propagated throughout the system.Since the registers are mapped directly into memory, the memory address space that needs to be reserved must include all 4096 registers for everypossible function of every possible device on every possible bus that could be present in the system. This calculates out to 256MB of memory address space being required to “fit” all of the possible configuration registers:256 Possible Busses32 Possible Devices per Bus8 Possible Functions Per Device 4096 Registers per Device/Function======================== 256 x 32 x 8 x 4096 = 256MBytesDepending on the specific Intel ® chipset, this block of memory can be moved anywhere within the system memory map. In the Intel ® Q45 and Intel ® PM965 Express Chipsets, for example, a register in the GMCH (or“Northbridge”) called the PCI Express* Configuration Register Base Address Register (BAR) located in PCI configuration space at B0:D0:F0-60h performs this function. This is shown in Figure 2 below.Accessing the Real Time Clock Registers and NMI Enable Bit321090 7Figure 2. Memory Mapped PCIe* Configuration RegistersWhen software wants to access a specific configuration register in a given device, it must calculate exactly where this register resides in the PCIe* configuration memory map and perform a simple memory read/write to this location.Accessing the Real Time Clock Registers and NMI Enable Bit8321090Conversion FormulasFigure 3 provides the formula used to calculate the desired memory location needed to access a PCIe* configuration register given the device’s bus number, device number, function number, and register offset.Figure 3. Formula to Calculate Memory Address Given the Bus, Device,Function, and Register OffsetMemory Address = PCI Express* Configuration Space Base Address + (Bus Number x 100000h) + (Device Number x 8000h) + (Function Number x 1000h) +(Register Offset)For example, to access the following configuration register:• PCI Express Configuration Register F 0000000h • Bus Number15h• Device Number 00h • Function Number05h•Register Offset 84hSoftware would access this register by performing a memory read/write toaddress F1505084h.Calculating the Bus, Device, Function, and Register offset given an actual address is a little bit more complex. The formula shown in Figure 4 can be used when given just an address.Figure 4. Formula to Calculate Bus, Device, Function, and Register OffsetGiven a Memory AddressBus Number = (Memory Address - PCI Express* Configuration Space Base Address) / (100000h)Device Number = (Memory Address - PCI Express Configuration Space Base Address - (Bus Number x 100000h)) / (8000h)Function Number = (Memory Address - PCI Express Configuration Space Base Address - (Bus Number x 100000h) - (Device Number x 8000h)) / (1000h)Accessing the Real Time Clock Registers and NMI Enable Bit3210909Register Offset = (Memory Address) & (00000FFFh)Chipset VarianceThe memory address range containing the PCIe* configuration registers is implemented differently between different Intel chipsets. In Intel’s olderchipsets, the PCI Express* Configuration Base Address Register is contained inside the memory controller portion of the chipset (MCH and GMCH). The location of this register varies between chipsets. For the Intel ® Q45 and PM965 Express chipsets, for example, this register is located in PCI space at B0:D0:F0-60h. In the Intel ® EP80579 Integrated Processor (“Silicon onChip”) however, this register is called the HECBASE register and is located in at B0:D0:F0-CEh. Programmers must be aware that the memory range and its control registers change between chipsets.Additionally, since the memory address range occupied by the PCIeconfiguration registers will mask any DRAM located at the same address range (see the section below for more details), most Intel ® chipsets permit the memory address range occupied by the PCIe configuration registers to consume less than the full 256MB range. These chipsets permit BIOS to program the PCIe* configuration register memory range to occupy 256MB, 128MB, or 64MB of memory address space. This is done by simply limiting the number of PCIe busses allowable in a given system.For example, in the Intel ® PM965 chipset, if configuration software detects less than 64 PCI/PCIe busses within the system (very common), then the software can program the chipset to only allow 64MB of PCIe Configuration memory space. Accesses above 64MB will be sent to DRAM.PCIe* Memory Range and How It Impacts Available DRAM in 4GB Systems Running 32-bit Operating SystemsIt is important to realize that since the PCIe* configuration register memory space occupies a chunk of the memory address map, any DRAM located in this space will essentially be lost to the system. This often happens in systems with 4GB of DRAM running 32 bit Operating Systems.For example, Windows* XP uses only 32 bits when accessing memory space. This permits accesses to memory address region from 0-4GB. If the system is fully populated with 4GB of DRAM, Windows XP* could theoretically access all of the 4GB of DRAM. However, since the PCIe* configuration registersrequires some of this memory address space, up to 256MB of DRAM will be “lost” to the operating system since the PCIe configuration register address space overlaps the same memory region used by the DRAM. This is why most Intel ® chipsets contain a register to change the memory address space used by the PCIe configuration registers to something smaller than 256MB (typically 128MB or 64MB).Note that 64 bit operating systems do not have this problem. Since they use 64 bits for addresses, they can access memory ranges above 4GB. IntelAccessing the Real Time Clock Registers and NMI Enable Bit10321090chipsets typically contain logic that can “remap” the DRAM overlapping the PCIe configuration register space to memory addresses above 4GB. Details of this are beyond the scope of this paper.Conversion Formulas – CodeThe code in Figure 5 written in C shows how to:•Create the Memory Address needed to access a PCIe* configuration register given the Bus Number, Device Number, Function, and Register Offset•Calculate the Bus Number, Device Number, Function, and Register offset when provided with a memory address.Figure 5. Sample Code Demonstrating How to Access PCIe* ConfigurationRegisters//***********************************************************************unsigned long PCIeBase = 0xF0000000UL; unsigned long FinalAddress; unsigned long Bus = 0; unsigned long Device = 0; unsigned long Function = 0; unsigned long Register = 0;//*********************************************************************** void Convert_to_Memory() {FinalAddress = PCIeBase + (Bus*0x100000UL) + (Device*0x8000) + (Function*0x1000) + Register; }//*********************************************************************** void Convert_to_Register() {Bus = (FinalAddress-PCIeBase) / (0x100000UL);Device = (FinalAddress-PCIeBase - (Bus*0x100000UL)) / (0x8000); Function = (FinalAddress-PCIeBase - (Bus*0x100000UL) - (Device*0x8000)) / (0x1000);Register = (FinalAddress) & (0x00000FFFUL); }//***********************************************************************Accessing the Real Time Clock Registers and NMI Enable BitConclusionSince most modern computers implement PCI Express* devices, it isimperative for programmers to understand how to access the PCIe*configuration registers contained within these devices. Although the originalaccess method using I/O locations CF8h and CFCh will still work, that methodwill only access the first 255 configuration registers of a device. To accessthe remaining 4096 registers, memory accesses must be made to the PCIExpress* Configuration Register memory block that is contained in memoryaddress space. The Convert_to_Memory routine shown in Figure 5 can beused to calculate the final memory address to be used when given a device’sbus number, device number, function number, and register offset. TheConvert_to_Register routine can be used to calculate the bus, device,function and register offset when provided with a memory address within thePCI Express* Configuration Register memory range.AuthorsSam Fleming is a Technical Marketing Engineer with the Applications Design-In Center at Intel in Folsom, California.AcronymsMCH: Memory Controller Hub. This is the generic name given to the specific integrated circuit that contains the memory interface in a given chipset.GMCH: Graphics Memory Controller Hub. Same definition as above, but applied to MCH’s that also contain an integrated graphics controller.North Bridge: A generic term that refers to the MCH or GMCH. PCI: Peripheral Component Interconnect. A standardized bus specification. See /specifications/ for more details.PCIe*: PCI Express*. Another standardized bus. Although the hardware interface is completely different from PCI, the configuration register implementation is very similar.INFORMATION IN THIS DOCUMENT IS PROVIDED IN CONNECTION WITH INTEL® PRODUCTS.NO LICENSE, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, TO ANY INTELLECTUAL PROPERTY RIGHTS IS GRANTED BY THIS DOCUMENT. EXCEPT AS PROVIDED IN INTEL’S TERMS AND CONDITIONS OF SALE FOR SUCH PRODUCTS, INTEL ASSUMES NO LIABILITY WHATSOEVER, AND INTEL DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY, RELATING TOSALE AND/OR USE OF INTEL PRODUCTS INCLUDING LIABILITY OR WARRANTIES RELATING TO FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT. Intel products are not intended for usein medical, life saving, or life sustaining applications.Intel may make changes to specifications and product descriptions at any time, without notice.This paper is for informational purposes only. THIS DOCUMENT IS PROVIDED "AS IS" WITH NO WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR ANY PARTICULAR PURPOSE, OR ANY WARRANTY OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. Intel disclaims all liability, including liability for infringement of any proprietary rights, relating to use of information in this specification. No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted herein.Intel, the Intel logo, Intel leap ahead, the Intel Leap ahead logo, the Intel EP80579 Integrated Processor and the Intel Express Chipset Family are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States and other countries.*Other names and brands may be claimed as the property of others.Copyright © 2008 Intel Corporation. All rights reserved.。