Solaris Source Insight: PCI bus driver moduls - misc/pcicfg module

本文介绍了一个用于配置和取消配置PCI设备的模块。该模块提供了两个主要接口:`pcicfg_configure`用于配置设备及其子设备,并创建设备树及编程设备寄存器;`pcicfg_unconfigure`用于释放由`pcicfg_configure`分配的资源并移除设备树。

<!-- @page { margin: 0.79in } P { margin-bottom: 0.08in } -->

Implementation of misc/pcicfg

 

This module provids below two interfaces to configure/unconfigure pci devices (include the children).

 

540 /*

541 * This entry point is called to configure a device (and

542 * all its children) on the given bus. It is called when

543 * a new device is added to the PCI domain. This routine

544 * will create the device tree and program the devices

545 * registers.

546 */

547 int

548 pcicfg_configure(dev_info_t *devi, uint_t device, uint_t function,

549 pcicfg_flags_t flags)

 

In pcicfg_configure(), the following procedures followed:

  1. probe the device (include children), create devinfo node for each PCI device, and bind it to driver if below configuration is successful.

  2. Allocate and program the resourses for both bridges and leaf devices.

  3. Update standard and specific properties.

 

1422 /*

1423 * This will turn resources allocated by pcicfg_configure()

1424 * and remove the device tree from the Hotplug Connection (CN)

1425 * and below. The routine assumes the devices have their

1426 * drivers detached.

1427 */

1428 int

1429 pcicfg_unconfigure(dev_info_t *devi, uint_t device, uint_t function,

1430 pcicfg_flags_t flags)

 

In pcicfg_unconfigure(), the following procedures followed:

  1. Offline the devinfo nodes, that means detaching the device driver and preventing it from reattaching.

  2. Free up resources the devices consumed, disable the device and tear down the devinfo node (include children).

 

By the way, this should be a bug in code.

code review comments:

 

585 |_______|_______if ((function != PCICFG_ALL_FUNC) && (function != func))

586 |_______|_______|_______goto next;

...

657 next:

658 |_______|_______/*

659 |_______|_______ * Determine if ARI Forwarding should be enabled.

660 |_______|_______ */

661 |_______|_______if (func == 0) {

662 |_______|_______|_______if ((pcie_ari_supported(devi)

663 |_______|_______|_______ == PCIE_ARI_FORW_SUPPORTED) &&

664 |_______|_______|_______ (pcie_ari_device(new_device) == PCIE_ARI_DEVICE)) {

 

new_device could be used here before initialized.

在使用 Rollup 构建项目时,如果遇到错误提示 `fileName` 或 `name` 属性不能是绝对或相对路径,通常是因为插件配置中使用了非法的路径字符串。Rollup 要求这些属性必须是标识符字符串(非路径形式),用于模块标识而非文件系统路径。 ### 错误原因 该错误通常出现在使用 `rollup-plugin-node-resolve`、`rollup-plugin-commonjs` 或其他第三方插件时,错误地将路径作为 `fileName` 或 `name` 传入了插件配置中。例如,在配置 UMD 或 AMD 构建时,`output.name` 被误设为文件路径而非模块标识符。 ### 解决方案 1. **确保 `output.name` 是模块标识符而非路径** 在 `rollup.config.js` 中,`output.name` 应该是一个合法的 JavaScript 标识符(如 `'MyModule'`),而不是文件路径(如 `'./dist/bundle.js'`): ```javascript export default { input: 'src/main.js', output: { file: 'dist/bundle.js', format: 'umd', name: 'MyModule' // 正确:非路径标识符 } }; ``` 2. **检查插件配置是否使用了非法路径** 某些插件可能要求 `name` 或 `fileName` 属性不能包含路径信息。例如在使用 `rollup-plugin-vue` 或 `rollup-plugin-postcss` 时,应确保配置中未将路径作为模块名使用。 3. **避免在 `external` 或 `globals` 中使用路径** 如果在 `external` 或 `globals` 中引用模块,应使用模块名而非路径: ```javascript export default { // ... external: ['lodash'], // 正确 // external: ['./node_modules/lodash'], // 错误 globals: { lodash: '_' // 正确映射 } }; ``` 4. **使用 `path` 模块处理路径拼接** 如果需要动态生成路径,应使用 `path` 模块确保路径拼接正确,并仅用于 `file` 或 `dir` 等允许路径的字段: ```javascript import path from 'path'; export default { output: { file: path.resolve('dist', 'bundle.js'), format: 'iife', name: 'MyApp' } }; ``` ### 示例修复后的配置 ```javascript import resolve from '@rollup/plugin-node-resolve'; import commonjs from '@rollup/plugin-commonjs'; export default { input: 'src/index.js', output: { file: 'dist/bundle.js', format: 'umd', name: 'MyLibrary' }, plugins: [ resolve(), commonjs() ] }; ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值