`
javasee
  • 浏览: 977441 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

Solaris Source Insight: PCI bus driver moduls - npe Part 5

阅读更多

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

    Fri Nov 13 14:19:32 CST 2009

  • DDI_INTROP_NAVAIL/DDI_INTROP_NINTRS

Return the number of supported interrupt number. If MSI/X supported, the responding capability registers will tell the number. Otherwise, the interrupt number was saved in parent private data of devinfo node.

[i86pc/os/ddi_impl.c]

925 int

926 i_ddi_get_intx_nintrs(dev_info_t *dip)

927 {

928 |_______struct ddi_parent_private_data *pdp;

929

930 |_______if ((pdp = ddi_get_parent_data(dip)) == NULL)

931 |_______|_______return (0);

932

933 |_______return (pdp->par_nintr);

934 }

Let's roll back to check what kind of things passed to npe_intr_ops().

[i86pc/io/pciex/npe.c]

829 /*

830 * npe_intr_ops

831 */

832 static int

833 npe_intr_ops(dev_info_t *pdip, dev_info_t *rdip, ddi_intr_op_t intr_op,

834 ddi_intr_handle_impl_t *hdlp, void *result)

835 {

836 |_______return (pci_common_intr_ops(pdip, rdip, intr_op, hdlp, result));

837 }

pdip – the bus devinfo node

rdip – the leaf devinfo node which issued the request

intr_op – interrupt ops, following operations supported

[common/sys/ddi_intr_impl.h]

42 /*

43 * Typedef for interrupt ops

44 */

45 typedef enum {

46 |_______DDI_INTROP_SUPPORTED_TYPES = 1,|/* 1 get supported interrupts types */

47 |_______DDI_INTROP_NINTRS,|_____|_______/* 2 get num of interrupts supported */

48 |_______DDI_INTROP_ALLOC,|______|_______/* 3 allocate interrupt handle */

49 |_______DDI_INTROP_GETPRI,|_____|_______/* 4 get priority */

50 |_______DDI_INTROP_SETPRI,|_____|_______/* 5 set priority */

51 |_______DDI_INTROP_ADDISR,|_____|_______/* 6 add interrupt handler */

52 |_______DDI_INTROP_DUPVEC,|_____|_______/* 7 duplicate interrupt handler */

53 |_______DDI_INTROP_ENABLE,|_____|_______/* 8 enable interrupt */

54 |_______DDI_INTROP_BLOCKENABLE,||_______/* 9 block enable interrupts */

55 |_______DDI_INTROP_BLOCKDISABLE,|_______/* 10 block disable interrupts */

56 |_______DDI_INTROP_DISABLE,|____|_______/* 11 disable interrupt */

57 |_______DDI_INTROP_REMISR,|_____|_______/* 12 remove interrupt handler */

58 |_______DDI_INTROP_FREE,|_______|_______/* 13 free interrupt handle */

59 |_______DDI_INTROP_GETCAP,|_____|_______/* 14 get capacity */

60 |_______DDI_INTROP_SETCAP,|_____|_______/* 15 set capacity */

61 |_______DDI_INTROP_SETMASK,|____|_______/* 16 set mask */

62 |_______DDI_INTROP_CLRMASK,|____|_______/* 17 clear mask */

63 |_______DDI_INTROP_GETPENDING,|_|_______/* 18 get pending interrupt */

64 |_______DDI_INTROP_NAVAIL,|_____|_______/* 19 get num of available interrupts */

65 |_______DDI_INTROP_GETPOOL,|____|_______/* 20 get resource management pool */

66 |_______DDI_INTROP_GETTARGET,|__|_______/* 21 get target for a given intr(s) */

67 |_______DDI_INTROP_SETTARGET|___|_______/* 22 set target for a given intr(s) */

68 } ddi_intr_op_t;

hdlp – the implementation structure for DDI interrupt handling

result – the returned result data

[common/sys/ddi_intr_impl.h]

74 /*

75 * One such data structure is allocated per ddi_intr_handle_t

76 * This is the incore copy of the regular interrupt info.

77 */

78 typedef struct ddi_intr_handle_impl {

79 |_______dev_info_t|_____|_______*ih_dip;|_______/* dip associated with handle */

80 |_______uint16_t|_______|_______ih_type;|_______/* interrupt type being used */

81 |_______ushort_t|_______|_______ih_inum;|_______/* interrupt number */

82 |_______uint32_t|_______|_______ih_vector;|_____/* vector number */

83 |_______uint16_t|_______|_______ih_ver;||_______/* Version */

84 |_______uint_t|_|_______|_______ih_state;|______/* interrupt handle state */

85 |_______uint_t|_|_______|_______ih_cap;||_______/* interrupt capabilities */

86 |_______uint_t|_|_______|_______ih_pri;||_______/* priority - bus dependent */

87 |_______krwlock_t|______|_______ih_rwlock;|_____/* read/write lock per handle */

… …

125 } ddi_intr_handle_impl_t;

This structure will be passed through different functions for DDI interrupt handling. Type, inum, vector are basic to understand the implementation. Specific interrupts are always specified by the combination of interrupt type and inum. For legacy devices, inum refers to the nth interrupt, typically as defined by the devices interrupts property. For PCI fixed interrupts, inum refers to the interrupt number. The inum is the relative interrupt vector number, from 0 to 31 for MSI, from 0 to 2047 for MSI-X. The first interrupt vector is 0. The last relative vector is 31 for MSI or 2047 for MSI-X. Three interrupt types are defined in Solaris DDI.

[common/sys/ddi_intr.h]

61 /* Hardware interrupt types */

62 #define|DDI_INTR_TYPE_FIXED|____0x1

63 #define|DDI_INTR_TYPE_MSI|______0x2

64 #define|DDI_INTR_TYPE_MSIX|_____0x4

The second piece of interrupt data is stored as ddi parent private data. It's created for both fixed interrupt and MSI/X interrupt types.

[i86pc/io/pci/pci_common.c]

134 /*

135 * Create the ddi_parent_private_data for a pseudo child.

136 */

137 void

138 pci_common_set_parent_private_data(dev_info_t *dip)

139 {

140 |_______struct ddi_parent_private_data *pdptr;

141

142 |_______pdptr = (struct ddi_parent_private_data *)kmem_zalloc(

143 |_______ (sizeof (struct ddi_parent_private_data) +

144 |_______ sizeof (struct intrspec)), KM_SLEEP);

145 |_______pdptr->par_intr = (struct intrspec *)(pdptr + 1);

146 |_______pdptr->par_nintr = 1;

147 |_______ddi_set_parent_data(dip, pdptr);

148 }

[common/sys/ddi_impldefs.h]

735 /*

736 * parent private data structure contains register, interrupt, property

737 * and range information.

738 */

739 struct ddi_parent_private_data {

740 |_______int par_nreg;|__|_______|_______/* number of regs */

741 |_______struct regspec *par_reg;|_______/* array of regs */

742 |_______int par_nintr;|_|_______|_______/* number of interrupts */

743 |_______struct intrspec *par_intr;|_____/* array of possible interrupts */

744 |_______int par_nrng;|__|_______|_______/* number of ranges */

745 |_______struct rangespec *par_rng;|_____/* array of ranges */

746 };

747 #define|DEVI_PD(d)|_____\

748 |_______((struct ddi_parent_private_data *)DEVI((d))->devi_parent_data)

[common/sys/ddi_intr_impl.h]

390 /*

391 * This structure represents one interrupt possible from the given

392 * device. It is used in an array for devices with multiple interrupts.

393 */

394 struct intrspec {

395 |_______uint_t intrspec_pri;|___|_______/* interrupt priority */

396 |_______uint_t intrspec_vec;|___|_______/* vector # (0 if none) */

397 |_______uint_t (*intrspec_func)();|_____/* function to call for interrupt, */

398 |_______|_______|_______|_______|_______/* If (uint_t (*)()) 0, none. */

399 |_______|_______|_______|_______|_______/* If (uint_t (*)()) 1, then */

400 };

The third piece of data related to ddi interrupt is stored in devinfo structure.

126 struct dev_info {

...

237 |_______/* Owned by DDI interrupt framework */

238 |_______devinfo_intr_t|_*devi_intr_p;

… …

276 };

[common/sys/ddi_intr_impl.h]

273 /*

274 * One such data structure is allocated for each dip.

275 * It has interrupt related information that can be

276 * stored/retrieved for convenience.

277 */

278 typedef struct devinfo_intr {

279 |_______/* These three fields show what the device is capable of */

280 |_______uint_t|_|_______devi_intr_sup_types;|___/* Intrs supported by device */

281

282 |_______ddi_intr_msix_t|*devi_msix_p;|__|_______/* MSI-X info, if supported */

283

284 |_______/* Next three fields show current status for the device */

285 |_______uint_t|_|_______devi_intr_curr_type;|___/* Interrupt type being used */

286 |_______uint_t|_|_______devi_intr_sup_nintrs;|__/* #intr supported */

287 |_______uint_t|_|_______devi_intr_curr_nintrs;|_/* #intr currently being used */

288 |_______/*

289 |_______ * #intr currently being enabled

290 |_______ * (for MSI block enable, the valuse is either 1 or 0.)

291 |_______ */

292 |_______uint_t|_|_______devi_intr_curr_nenables;

293

294 |_______ddi_intr_handle_t *devi_intr_handle_p;|_/* Hdl for legacy intr APIs */

295

296 #if defined(__i386) || defined(__amd64)

297 |_______/* Save the PCI config space handle */

298 |_______ddi_acc_handle_t devi_cfg_handle;

299 |_______int|____|_______ devi_cap_ptr;|_|_______/* MSI or MSI-X cap pointer */

300 #endif

301

302 |_______ddi_irm_req_t|__*devi_irm_req_p;|_______/* IRM request information */

303 } devinfo_intr_t;

  • DDI_INTROP_ALLOC/DDI_INTROP_FREE

Allocate and free the interrupt vectors. Allocate interrupts of the interrupt type beginning at the interrupt number inum. ddi_intr_alloc(9F) will call this function for purpose. If MSI/X is supported, the actual operation is accomplished through psm_intr_ops() which is specified in psm module.

[i86pc/io/pci/pci_common.c]

359 |_______|_______|_______/*

360 |_______|_______|_______ * Allocate interrupt vectors

361 |_______|_______|_______ */

362 |_______|_______|_______(void) (*psm_intr_ops)(rdip, hdlp,

363 |_______|_______|_______ PSM_INTR_OP_ALLOC_VECTORS, result);

  • DDI_INTROP_GETPRI/DDI_INTROP_SETPRI

Interrupt priority is stored at DEVI(dip)->devi_parent_data->par_intr->intrspec_pri. To set/change the interrupt priority, platform level psm_intr_ops() must be called. Two broad classes of interrupt: High-level and normal interrupts are defined. Most interrupts on the system are normal interrupts. Seldom must a device be configured to a high-level interrupt .

[i86pc/io/pci/pci_common.c]

459 |_______case DDI_INTROP_SETPRI:

460 |_______|_______/* Validate the interrupt priority passed */

461 |_______|_______if (*(int *)result > LOCK_LEVEL)

462 |_______|_______|_______return (DDI_FAILURE);

High-level interrupts are handled much like traditional UNIX interrupts . A high-level interrupt has no process or thread context of its own . A high-level interrupt may not block for any reason . A high-level ISR may only call mutex_enter(9F), the associated mutex_exit(9F), and ddi_trigger_softintr(9F)

  • DDI_INTROP_ADDISR/DDI_INTROP_REMISR

    Add and remove ispec.

  • DDI_INTROP_GETCAP/DDI_INTROP_SETCAP

  • DDI_INTROP_ENABLE/DDI_INTROP_DISABLE

  • DDI_INTROP_BLOCKDISABLE/DDI_INTROP_BLOCKENABLE

    Rely on pcplusmp psm_intr_ops().

To be continued …

分享到:
评论

相关推荐

    SourceInsight 完美的配色方案 theme-Monokai 主题

    5. **保存设置**:最后,别忘了点击“OK”保存你的设置,以便下次启动SourceInsight时能自动应用Monokai主题。 值得注意的是,不同的编程语言可能需要不同的配色方案来优化可读性。Monokai主题虽然通用性很强,但你...

    source insight 3.5 UTF-8中文乱码插件_sourceinsight3.5_utf-8_插件补丁_中文乱码_

    源洞察(Source Insight)是一款广泛使用的源代码阅读和分析工具,尤其受到程序员和软件开发者们的喜爱。它提供了强大的代码导航、查找、语法高亮等功能,帮助用户理解和探索复杂的代码库。然而,在处理UTF-8编码的...

    pc-lint用于sourceinsight上静态代码检测

    2. **配置Source Insight**: 打开Source Insight,进入“Tools”菜单,选择“External Tools...”。在这里,我们需要新建一个工具配置,指定PC-lint的可执行文件路径,以及需要传递给PC-lint的参数,如输入文件、...

    source insight 中集成pclint

    ### Source Insight 中集成 PC-Lint 的详细步骤及注意事项 #### 一、概述 在软件开发过程中,静态代码分析工具能够帮助开发者发现潜在的错误和不规范的编程习惯,从而提高代码质量。PC-Lint 是一款知名的静态代码...

    source insight UTF-8插件

    Source Insight是一款广受欢迎的源代码阅读和分析工具,尤其在软件开发领域中,它以其强大的代码导航、搜索和理解功能而备受赞誉。然而,对于处理包含非英文字符,特别是中文字符的UTF-8编码文件时,原生的Source ...

    sourceinsight-3.5-window7-64-汉化

    幸运的是,我们有了“sourceinsight-3.5-window7-64-汉化”这个资源,它为SourceInsight 3.5在Windows 7 64位系统上提供了汉化支持。 首先,我们需要了解SourceInsight 3.5的基本功能。它支持多种编程语言,包括C/...

    Source Insight 3支持Utf-8

    5. 接下来,找到“Encoding”(编码)设置,确保其设置为“Auto Detect”(自动检测),这样Source Insight 3会尝试根据文件内容自动识别编码。 6. 如果“Auto Detect”未能正确识别UTF-8编码,你可以手动选择“UTF-...

    Astyle集成到sourceinsight指导说明

    Astyle集成到SourceInsight指导说明 Astyle是一个编码格式化程序,它可以将代码格式化成统一的风格,从而提高代码的可读性和维护性。本文将指导您如何将Astyle集成到SourceInsight中,以便更好地管理代码的风格。 ...

    解决source insight3.5不支持中文utf8问题

    5. **升级到新版本**:如果可能,升级到Source Insight的最新版本,如4.0,因为新版本通常会修复旧版本存在的问题,包括对UTF-8的支持。 在提供的压缩包"sourceinght3.5解决中文不支持utf8问题"中,可能包含了上述...

    linux Ubuntu下安装 Source insight

    "Linux Ubuntu下安装Source Insight" Linux Ubuntu下安装Source Insight是指在Ubuntu操作系统下安装Source Insight软件,从而实现在Linux平台下使用Source Insight编辑和阅读源码。本文将详细介绍如何在Ubuntu下...

    Source Insight 4.0仿Boxy的Solarized-Dark主题

    **Source Insight 4.0与Solarized-Dark主题详解** Source Insight是一款强大的源代码阅读、分析和编辑工具,尤其在编程领域中广受欢迎。它以其高效的语言智能、强大的搜索功能和自定义配置能力赢得了程序员的喜爱。...

    sourceinsight_4.0.86.0-setup.zip

    《Source Insight 4.0.86.0 安装及使用详解》 Source Insight是一款深受程序员喜爱的源代码分析和编辑工具,以其强大的代码浏览、查找和智能提示功能著称。本文将详细介绍如何安装Source Insight 4.0.86.0版本,并...

    sourceinsight的快捷键总结.pdf

    在IT行业,特别是在软件开发领域,Source Insight 是一个经常被使用到的源代码查看工具。它主要被软件开发者用于阅读、修改、重构代码以及查看定义和引用等功能。熟练使用 Source Insight 的快捷键能够显著提高开发...

    Source Insight 3.5 序列号

    在探讨“Source Insight 3.5 序列号”这一主题时,首先需要明确的是,序列号(serial number)通常是指软件开发商为了控制软件的分发与使用而提供的一种授权方式。通过序列号,可以验证用户是否拥有使用该软件的合法...

    让source insight支持AT&T汇编语法高亮

    ### 让Source Insight支持AT&T汇编语法高亮 #### 背景介绍 Source Insight是一款功能强大的编辑器,能够帮助开发者高效地进行代码编写、分析及管理等工作。它不仅支持多种编程语言,还能通过自定义配置来扩展对特定...

    SourceInsight_双语版(中文-英文)

    **SourceInsight_双语版(中文-英文)** SourceInsight是一款强大的源代码阅读和编辑工具,尤其适合程序员在开发C/C++、Java等编程语言项目时使用。这款软件以其高效、直观的特性,为程序员提供了深入理解代码结构、...

    SourceInsight 3.5.0070(2012-06-20发布)+注册机

    很好用的代码编辑工具,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-4.0.86.0-密码123.zip

    5. **符号索引**:SourceInsight会建立一个完整的符号索引,使用户能迅速查找和理解代码结构。 6. **代码分析**:对源代码进行静态分析,帮助识别潜在的编程错误和不规范的编程习惯。 7. **多语言支持**:除了C/...

    Source Insight 插件 UTF-8

    Source Insight 插件,解决SI UTF-8中文显示乱码问题。 Source Insight Patch File, solve display wrong code when using UTF-8 chinese charater

Global site tag (gtag.js) - Google Analytics