Wed Nov 11 13:41:56 CST
2009
driver operation
Driver operation is defined for leaf device drivers or bus nexus
drivers supporting
direct user process access (open/close/etc).
Driver operation for npe module is very simple.
[i86pc/io/pciex/npe.c]
120 struct cb_ops npe_cb_ops = {
121 |_______npe_open,|______|_______|_______/* open
*/
122 |_______npe_close,|_____|_______|_______/* close
*/
123 |_______nodev,|_|_______|_______|_______/*
strategy */
124 |_______nodev,|_|_______|_______|_______/* print
*/
125 |_______nodev,|_|_______|_______|_______/* dump
*/
126 |_______nodev,|_|_______|_______|_______/* read
*/
127 |_______nodev,|_|_______|_______|_______/* write
*/
128 |_______npe_ioctl,|_____|_______|_______/* ioctl
*/
129 |_______nodev,|_|_______|_______|_______/*
devmap */
130 |_______nodev,|_|_______|_______|_______/* mmap
*/
131 |_______nodev,|_|_______|_______|_______/*
segmap */
132 |_______nochpoll,|______|_______|_______/* poll
*/
133 |_______pcie_prop_op,|__|_______|_______/*
cb_prop_op */
134 |_______NULL,|__|_______|_______|_______/*
streamtab */
135 |_______D_NEW | D_MP | D_HOTPLUG,|______/*
Driver compatibility flag */
136 |_______CB_REV,||_______|_______|_______/* rev
*/
137 |_______nodev,|_|_______|_______|_______/* int
(*cb_aread)() */
138 |_______nodev|__|_______|_______|_______/* int
(*cb_awrite)() */
139 };
It defines a character driver interface. User level
applications can open/close the corresponding device file and issue
some ioctl command again it. In npe's open() and close() functions,
locks and state machine are used to serialize the controls. Two types
of ioctl controls are supported by now, one is for pci tool, which is
a common interface for user level applications to read/write pci
configure spaces, bind the interrupt and so on (we will come back to
the implementation later); another is for common device control,
which is routed to pcie_ioclt() for further action.
Bus operations
Npe is a nexus bus driver module, so the its sole is the bus
operations.
[i86pc/io/pciex/npe.c]
83 struct bus_ops npe_bus_ops = {
84 |_______BUSO_REV,
85 |_______npe_bus_map,
86 |_______NULL,
87 |_______NULL,
88 |_______NULL,
89 |_______i_ddi_map_fault,
90 |_______ddi_dma_map,
91 |_______ddi_dma_allochdl,
92 |_______ddi_dma_freehdl,
93 |_______ddi_dma_bindhdl,
94 |_______ddi_dma_unbindhdl,
95 |_______ddi_dma_flush,
96 |_______ddi_dma_win,
97 |_______ddi_dma_mctl,
98 |_______npe_ctlops,
99 |_______ddi_bus_prop_op,
100 |_______0,|_____|_______|_______/*
(*bus_get_eventcookie)();|___*/
101 |_______0,|_____|_______|_______/*
(*bus_add_eventcall)();|_____*/
102 |_______0,|_____|_______|_______/*
(*bus_remove_eventcall)();|__*/
103 |_______0,|_____|_______|_______/*
(*bus_post_event)();||_______*/
104 |_______0,|_____|_______|_______/*
(*bus_intr_ctl)(); */
105 |_______0,|_____|_______|_______/*
(*bus_config)(); */
106 |_______0,|_____|_______|_______/*
(*bus_unconfig)(); */
107 |_______npe_fm_init,|___|_______/*
(*bus_fm_init)(); */
108 |_______NULL,|__|_______|_______/*
(*bus_fm_fini)(); */
109 |_______NULL,|__|_______|_______/*
(*bus_fm_access_enter)(); */
110 |_______NULL,|__|_______|_______/*
(*bus_fm_access_exit)(); */
111 |_______NULL,|__|_______|_______/*
(*bus_power)(); */
112 |_______npe_intr_ops,|__|_______/*
(*bus_intr_op)(); */
113 |_______pcie_hp_common_ops|_____/*
(*bus_hp_op)(); */
114 };
The definition of “struct bus_ops” is in
common/sys/devops.h. Not all entries are valid for a specific bus
operation version. The comments along with the structure definition
is enough for understanding.
[common/sys/devops.h]
118 /*
119 * bus_ops:|____bus nexus drivers only.
120 *
121 * These functions are used to implement the Sun
DDI functions
122 * described elsewhere.
123 *
124 * Only nexus drivers support these entry
points.
125 *
126 * The following bus nexus functions are provided
in the bus nexus
127 * driver operations structure. Note that all
functions take both
128 * their dip and the requesters dip except for
the child functions since
129 * they will be called from outside the ddi.
130 *
131 *|_____bus_map||_______|_______-
Map/unmap/control IU -> device mappings.
132 *|_____bus_get_intrspec|_______- get interrupt
specification by number
133 *|_____bus_add_intrspec|_______- add interrupt
specification, return cookie
134 *|_____bus_remove_intrspec|____- remove
interrupt specification
135 *|_____bus_map_fault|__|_______- bus fault
handler
136 *|_____bus_dma_map|____|_______- setup dma
mapping
137 *|_____bus_dma_mapctl|_|_______- control (and
free) dma mapping
138 *|_____bus_ctl||_______|_______- generic
control operations
139 *|_____bus_prop_op|____|________ request for
property
140 */
We have looked at
npe_bus_map() when we tried to find the answer for how PCI leaf
drviers access the configure space. The address spaces for a device
were encoded in “reg” and “assigned-addresses” properties.
Below comments describe the decoding logic.
[common/sys/pci.h]
1100 /*
1101 * This structure
represents one entry of the 1275 "reg" property and
1102 *
"assigned-addresses" property for a PCI node. For the
"reg" property, it
1103 * may be one of an
arbitrary length array for devices with multiple address
1104 * windows. For the
"assigned-addresses" property, it denotes an assigned
1105 * physical address
on the PCI bus. It may be one entry of the six entries
1106 * for devices with
multiple base registers.
1107 *
1108 * The physical
address format is:
1109 *
1110 * Bit#:
33222222 22221111 11111100 00000000
1111 *
10987654 32109876 54321098 76543210
1112 *
1113 * pci_phys_hi cell:
npt000ss bbbbbbbb dddddfff rrrrrrrr
1114 * pci_phys_mid
cell: hhhhhhhh hhhhhhhh hhhhhhhh hhhhhhhh
1115 * pci_phys_low
cell: llllllll llllllll llllllll llllllll
1116 *
1117 * n is 0
if the address is relocatable, 1 otherwise
1118 * p is 1
if the addressable region is "prefetchable", 0 otherwise
1119 * t is 1
if the address is aliased (for non-relocatable I/O), below
1120 *|_____ 1MB
(for mem), or below 64 KB (for relocatable I/O).
1121 * ss is the
type code, denoting which address space
1122 * bbbbbbbb is the
8-bit bus number
1123 * ddddd is the
5-bit device number
1124 * fff is the
3-bit function number
1125 * rrrrrrrr is the
8-bit register number
1126 *|_____ should
be zero for non-relocatable, when ss is 01, or 10
1127 * hh...hhh is the
32-bit unsigned number
1128 * ll...lll is the
32-bit unsigned number
1129 *
1130 * The physical size
format is:
1131 *
1132 * pci_size_hi cell:
hhhhhhhh hhhhhhhh hhhhhhhh hhhhhhhh
1133 * pci_size_low
cell: llllllll llllllll llllllll llllllll
1134 *
1135 * hh...hhh is the
32-bit unsigned number
1136 * ll...lll is the
32-bit unsigned number
1137 */
1138 struct pci_phys_spec
{
1139 |_______uint_t
pci_phys_hi;|____|_______/* child's address, hi word */
1140 |_______uint_t
pci_phys_mid;|___|_______/* child's address, middle word */
1141 |_______uint_t
pci_phys_low;|___|_______/* child's address, low word */
1142 |_______uint_t
pci_size_hi;|____|_______/* high word of size field */
1143 |_______uint_t
pci_size_low;|___|_______/* low word of size field */
1144 };
1145
1146 typedef struct
pci_phys_spec pci_regspec_t;
The actual map operation
is passed to npe's parent (rootnex). However, pci system has
different “reg” and “assigned-addresses” encoding logic.
Hence, in this bus map function, most part is to convert the data
from “pci_regspec_t” to “struct regspec” according to the map
type and the encoding logic.
To be continued …
分享到:
相关推荐
**SourceInsight是一款强大的源代码阅读和编辑工具,尤其在编程和软件开发领域中被广泛使用。它提供了丰富的功能,包括语法高亮、代码跳转、自动完成等,极大地提升了程序员的工作效率。Monokai主题是其中一种广受...
3. 找到Source Insight的配置文件或插件目录,将解压后的文件复制或移动到对应位置。这可能需要查阅Source Insight的官方文档或用户指南来获取准确路径。 4. 重启Source Insight,打开包含中文字符的文件,检查是否...
Source Insight 3是一款广受欢迎的源代码阅读器和编辑器,尤其在软件开发领域中,它为程序员提供了强大的代码浏览、分析和编辑功能。对于处理各种编码格式的源代码文件,Source Insight 3表现出了良好的兼容性,其中...
2. **配置Source Insight**: 打开Source Insight,进入“Tools”菜单,选择“External Tools...”。在这里,我们需要新建一个工具配置,指定PC-lint的可执行文件路径,以及需要传递给PC-lint的参数,如输入文件、...
### Source Insight 中集成 PC-Lint 的详细步骤及注意事项 #### 一、概述 在软件开发过程中,静态代码分析工具能够帮助开发者发现潜在的错误和不规范的编程习惯,从而提高代码质量。PC-Lint 是一款知名的静态代码...
Source Insight是一款广受欢迎的源代码阅读和分析工具,尤其在软件开发领域中,它以其强大的代码导航、搜索和理解功能而备受赞誉。然而,对于处理包含非英文字符,特别是中文字符的UTF-8编码文件时,原生的Source ...
幸运的是,我们有了“sourceinsight-3.5-window7-64-汉化”这个资源,它为SourceInsight 3.5在Windows 7 64位系统上提供了汉化支持。 首先,我们需要了解SourceInsight 3.5的基本功能。它支持多种编程语言,包括C/...
Astyle集成到SourceInsight指导说明 Astyle是一个编码格式化程序,它可以将代码格式化成统一的风格,从而提高代码的可读性和维护性。本文将指导您如何将Astyle集成到SourceInsight中,以便更好地管理代码的风格。 ...
3. **修改Source Insight的配置文件**:通过修改Source Insight的配置文件(如*.prj或*.spp),添加特定的命令行参数来指定UTF-8编码。例如,可以添加`-fcharset=utf8`,但这需要对Source Insight的配置有深入理解。...
"Linux Ubuntu下安装Source Insight" Linux Ubuntu下安装Source Insight是指在Ubuntu操作系统下安装Source Insight软件,从而实现在Linux平台下使用Source Insight编辑和阅读源码。本文将详细介绍如何在Ubuntu下...
**Source Insight 4.0与Solarized-Dark主题详解** Source Insight是一款强大的源代码阅读、分析和编辑工具,尤其在编程领域中广受欢迎。它以其高效的语言智能、强大的搜索功能和自定义配置能力赢得了程序员的喜爱。...
《Source Insight 4.0.86.0 安装及使用详解》 Source Insight是一款深受程序员喜爱的源代码分析和编辑工具,以其强大的代码浏览、查找和智能提示功能著称。本文将详细介绍如何安装Source Insight 4.0.86.0版本,并...
在探讨“Source Insight 3.5 序列号”这一主题时,首先需要明确的是,序列号(serial number)通常是指软件开发商为了控制软件的分发与使用而提供的一种授权方式。通过序列号,可以验证用户是否拥有使用该软件的合法...
在IT行业,特别是在软件开发领域,Source Insight 是一个经常被使用到的源代码查看工具。它主要被软件开发者用于阅读、修改、重构代码以及查看定义和引用等功能。熟练使用 Source Insight 的快捷键能够显著提高开发...
3. **导入到Source Insight**: - 回到Source Insight的“Languages”设置界面,找到刚刚添加的语言“at&tasm”,并点击其右侧的“Edit”按钮。 - 在弹出的编辑窗口中选择“Keywords”选项卡,然后点击“Import”...
**SourceInsight_双语版(中文-英文)** SourceInsight是一款强大的源代码阅读和编辑工具,尤其适合程序员在开发C/C++、Java等编程语言项目时使用。这款软件以其高效、直观的特性,为程序员提供了深入理解代码结构、...
很好用的代码编辑工具,SourceInsight 版本号为3.5.0070,发布时间2012年6月20日 内附注册机 官方What's New: Version 3.50.0070 - June 20, 2012 Fix: Java: Generic functions with a type specifier before the ...
SourceInsight是一款强大的源代码分析和浏览工具,尤其在C/C++、Java和C#等编程语言中广泛应用。它提供了一种高效的方式来查看、搜索、理解和编辑源代码,深受程序员喜爱。版本4.0.86.0是SourceInsight的一个特定...
Source Insight 插件,解决SI UTF-8中文显示乱码问题。 Source Insight Patch File, solve display wrong code when using UTF-8 chinese charater
**Source Insight Theme 自用不刺眼舒适黑色主题** Source Insight是一款强大的源代码阅读和编辑工具,尤其受到程序员和软件开发者的喜爱。它以其强大的代码分析、查找和导航功能而著称。然而,长时间使用默认的...