Solaris Source Insight: PCI system implementation - Part 1

本文详细介绍了 Solaris/OpenSolaris 中 PCI 系统的实现方式,包括 PCI 模块介绍、配置空间初始化过程及枚举机制等关键技术点。

PCI implementation in Solaris/OpenSolaris

Author: baolu.lu@intel.com
Date: October 28th, 2009

On a typical x86 platfomr, the PCI system implementation in Solaris/OpenSolaris includes the following modules.

[root@blu-nhm-ep:~]modinfo | grep PCI
 15 fffffffffba46ce0   bfb0   -   1  pci_autoconfig (PCI BIOS interface)
 37 fffffffffbacd3f0   ce28 183   1  npe (Host to PCIe nexus driver)
 38 fffffffffbad95c8   5f50   -   1  pcihp (PCI nexus hotplug support)
 40 fffffffffbae14f0   bb00   -   1  pcie (PCIE: PCI framework)
 89 fffffffff7bff000   4c68 184   1  pcieb (PCIe to PCI nexus driver)
 90 fffffffff7999000   1d68  84   1  pci_pci (PCI to PCI bridge nexus driver)

1. misc/pci_autoconfig
Pci_autoconfig module is the interface between PCI system and the BIOS. It "Determines the PCI configuration mechanism recommended by the BIOS". It was implemented in the following files.

156 PCI_AUTOCONFIG_OBJS += pci_autoconfig.o pci_boot.o pcie_nvidia.o /
157                         pci_memlist.o pci_resource.o

The module itself only registers a bus probe function to the kernel.

intel/io/pci/pci_autoconfig.c
 62 int
 63 _init(void)
 64 {
 65         int     err;
 66
 67         if ((err = mod_install(&modlinkage)) != 0)
 68                 return (err);
 69
 70         impl_bus_add_probe(pci_enumerate);
 71         return (0);
 72 }       

i86pc/os/ddi_impl.c
2514 void
2515 impl_setup_ddi(void)
2516 {
... ...
2569 |_______/* do bus dependent probes. */
2570 |_______impl_bus_initialprobe();
2571 }

The first round of bus probe was called in impl_setup_ddi() during boot process. Bus reprober was called later in

i86pc/os/ddi_impl.c
 157 /*
 158  * Configure the hardware on the system.
 159  * Called before the rootfs is mounted
 160  */
 161 void
 162 configure(void)
 163 {
... ...
 203 |_______/* reprogram devices not set up by firmware (BIOS) */
 204 |_______impl_bus_reprobe();

The bus probes in the linked list are executed in Last In First Service mode. If you have any dependency between the probes, you need to take care about this.

Let's pull the topic back by diving into the implementation of pci bus prober.

intel/io/pci/pci_autoconfig.c
 94 /*
 95  * This function is invoked twice: first time, with reprogram=0 to
 96  * set up the PCI portion of the device tree. The second time is
 97  * for reprogramming devices not set up by the BIOS.
 98  */
 99 void
100 pci_enumerate(int reprogram)
101 {
102 |_______extern void add_pci_fixes(void);
103 |_______extern void undo_pci_fixes(void);
104
105 |_______add_pci_fixes();
106
107 |_______if (reprogram) {
108 |_______|_______pci_reprogram();
109 |_______|_______undo_pci_fixes();
110 |_______|_______return;
111 |_______}
112
113 |_______/* setup device tree */
114 |_______pci_setup_tree();
115 |_______undo_pci_fixes();
116 }

add_pci_fixes()/undo_pci_fixes()
================================
Fix some hardware specific issues before enumerating or reprogramming the pci system, and undo the fix afterward. Currently, only fix for AMD-8111 LPC device is in the list.

pci_setup_tree()
================
This function was called to enumerate the pci system handed over by BIOS. Solaris kernel maintains a global variable in i86pc/os/pci_cfgspace.c

int pci_bios_maxbus;

It records the maximum number of pci bus on this hardware platform. During boot process, when mlsetup() got called,

i86pc/os/mlsetup.c
 97 /*
 98  * Setup routine called right before main(). Interposing this function
 99  * before main() allows us to call it in a machine-independent fashion.
100  */
101 void
102 mlsetup(struct regs *rp)
103 {
... ...
162 |_______/*
163 |_______ * lgrp_init() and possibly cpuid_pass1() need PCI config
164 |_______ * space access
165 |_______ */
166 #if defined(__xpv)
167 |_______if (DOMAIN_IS_INITDOMAIN(xen_info))
168 |_______|_______pci_cfgspace_init();
169 #else
170 |_______pci_cfgspace_init();
171 #endif

pci_cfgspace_init() will prepare the pci system for configuration space access. The call stack is:

i86pc/os/pci_cfgspace.c
 85 void
 86 pci_cfgspace_init(void)
 87 {
 88 |_______mutex_init(&pcicfg_mutex, NULL, MUTEX_SPIN,
 89 |_______    (ddi_iblock_cookie_t)ipltospl(15));
 90 |_______mutex_init(&pcicfg_chipset_mutex, NULL, MUTEX_SPIN,
 91 |_______    (ddi_iblock_cookie_t)ipltospl(15));
 92 |_______if (!pci_check()) {
 93 |_______|_______mutex_destroy(&pcicfg_mutex);
 94 |_______|_______mutex_destroy(&pcicfg_chipset_mutex);
 95 |_______}
 96 }

i86pc/os/pci_cfgspace.c
 98 /*
 99  * This code determines if this system supports PCI and which
100  * type of configuration access method is used
101  */
102
103 static int
104 pci_check(void)
105 {
... ...
142 |_______pci_bios_cfg_type = pci_check_bios();
... ...

i86pc/os/pci_cfgspace.c
202 static int
203 pci_check_bios(void)
204 {
... ...
228 |_______pci_bios_mech = (ax & 0x3);
229 |_______pci_bios_vers = regs.ebx.word.bx;
230 |_______pci_bios_maxbus = (regs.ecx.word.cx & 0xff);

pci_bios_maxbus is retrieved from bios here! The logic described here are compiled into CORE_OBJ, and will be called before main() during system boot up.

To be continue ...

基于遗传算法的新的异构分布式系统任务调度算法研究(Matlab代码实现)内容概要:本文档围绕基于遗传算法的异构分布式系统任务调度算法展开研究,重点介绍了一种结合遗传算法的新颖优化方法,并通过Matlab代码实现验证其在复杂调度问题中的有效性。文中还涵盖了多种智能优化算法在生产调度、经济调度、车间调度、无人机路径规划、微电网优化等领域的应用案例,展示了从理论建模到仿真实现的完整流程。此外,文档系统梳理了智能优化、机器学习、路径规划、电力系统管理等多个科研方向的技术体系与实际应用场景,强调“借力”工具与创新思维在科研中的重要性。; 适合人群:具备一定Matlab编程基础,从事智能优化、自动化、电力系统、控制工程等相关领域研究的研究生及科研人员,尤其适合正在开展调度优化、路径规划或算法改进类课题的研究者; 使用场景及目标:①学习遗传算法及其他智能优化算法(如粒子群、蜣螂优化、NSGA等)在任务调度中的设计与实现;②掌握Matlab/Simulink在科研仿真中的综合应用;③获取多领域(如微电网、无人机、车间调度)的算法复现与创新思路; 阅读建议:建议按目录顺序系统浏览,重点关注算法原理与代码实现的对应关系,结合提供的网盘资源下载完整代码进行调试与复现,同时注重从已有案例中提炼可迁移的科研方法与创新路径。
【微电网】【创新点】基于非支配排序的蜣螂优化算法NSDBO求解微电网多目标优化调度研究(Matlab代码实现)内容概要:本文提出了一种基于非支配排序的蜣螂优化算法(NSDBO),用于求解微电网多目标优化调度问题。该方法结合非支配排序机制,提升了传统蜣螂优化算法在处理多目标问题时的收敛性和分布性,有效解决了微电网调度中经济成本、碳排放、能源利用率等多个相互冲突目标的优化难题。研究构建了包含风、光、储能等多种分布式能源的微电网模型,并通过Matlab代码实现算法仿真,验证了NSDBO在寻找帕累托最优解集方面的优越性能,相较于其他多目标优化算法表现出更强的搜索能力和稳定性。; 适合人群:具备一定电力系统或优化算法基础,从事新能源、微电网、智能优化等相关领域研究的研究生、科研人员及工程技术人员。; 使用场景及目标:①应用于微电网能量管理系统的多目标优化调度设计;②作为新型智能优化算法的研究与改进基础,用于解决复杂的多目标工程优化问题;③帮助理解非支配排序机制在进化算法中的集成方法及其在实际系统中的仿真实现。; 阅读建议:建议读者结合Matlab代码深入理解算法实现细节,重点关注非支配排序、拥挤度计算和蜣螂行为模拟的结合方式,并可通过替换目标函数或系统参数进行扩展实验,以掌握算法的适应性与调参技巧。
本项目是一个以经典51系列单片机——STC89C52为核心,设计实现的一款高性价比数字频率计。它集成了信号输入处理、频率测量及直观显示的功能,专为电子爱好者、学生及工程师设计,旨在提供一种简单高效的频率测量解决方案。 系统组成 核心控制器:STC89C52单片机,负责整体的运算和控制。 信号输入:兼容多种波形(如正弦波、三角波、方波)的输入接口。 整形电路:采用74HC14施密特触发器,确保输入信号的稳定性和精确性。 分频电路:利用74HC390双十进制计数器/分频器,帮助进行频率的准确测量。 显示模块:LCD1602液晶显示屏,清晰展示当前测量的频率值(单位:Hz)。 电源:支持标准电源输入,保证系统的稳定运行。 功能特点 宽频率测量范围:1Hz至12MHz,覆盖了从低频到高频的广泛需求。 高灵敏度:能够识别并测量幅度小至1Vpp的信号,适合各类微弱信号的频率测试。 直观显示:通过LCD1602液晶屏实时显示频率值,最多显示8位数字,便于读取。 扩展性设计:基础版本提供了丰富的可能性,用户可根据需要添加更多功能,如数据记录、报警提示等。 资源包含 原理图:详细的电路连接示意图,帮助快速理解系统架构。 PCB设计文件:用于制作电路板。 单片机程序源码:用C语言编写,适用于Keil等开发环境。 使用说明:指导如何搭建系统,以及基本的操作方法。 设计报告:分析设计思路,性能评估和技术细节。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值