op_intrpt_ici()
摘要
获取与当前中断相关联的 ICI。
语法
op_intrpt_ici ()
| 参数 | 类型 | 说明 |
|---|---|---|
| 无参数 |
返回类型
Ici*
指向与当前中断相关联的 ICI 的指针。
当调用进程的当前中断没有相关联的 ICI 时,返回符号常量 OPC_NIL。
示例
摘自:示例模型(models/std/eth_net);进程模型(eth_mac);函数块;函数 eth_mac_llc_pk_accept()。
/* get a handle on the ICI associated with this mac invocation */
iciptr = op_intrpt_ici ();
/* from the ICI, obtain the intended destination address */
op_ici_attr_get (iciptr, “dst_addr”, &dest_addr);
/* create an ethernet frame in which to encapsulate the llc data */
eth_pkptr = op_pk_create_fmt (“ethernet”);
op_pk_nfd_set (eth_pkptr, “data”, llc_pkptr);
/* assign the destination address of the new frame */
op_pk_nfd_set (eth_pkptr, “dst_addr”, dest_addr);
/* assign this station’s address to the source address field */
op_pk_nfd_set (eth_pkptr, “src_addr”, my_address);
详情
进程中断携带多种类型的信息:中断的类型、与中断相关联的标志或代码,以及可选的 ICI。获取 ICI 的指针使接收进程能够提取其内容。如果 ICI 的内容已被完全“处理”(即该 ICI 对接收进程已无用处),则可以通过原语 op_ici_destroy() 回收该 ICI。但是,只有当发起进程为每个传出中断都创建全新的 ICI 时,才应该销毁 ICI;与之相反的做法有时会被采用,即一次性安装单个 ICI 并持续重复使用。
用途
提供了一种让进程获取与当前中断相关联的已接收 ICI 指针的机制。一旦获得该指针,便可通过 op_ici_attr_get_dbl() 之类的内核过程提取 ICI 的内容。
错误
不会捕获任何错误。
参考
- 使用内核过程 op_ici_create() 创建 ICI
- 使用内核过程 op_ici_install() 为传出中断安装 ICI
- 使用内核过程 op_ici_destroy() 释放已处理完毕的 ICI
- 使用内核过程 op_intrpt_type() 确定当前中断的类型
- 使用内核过程 op_ici_attr_get_dbl()、op_ici_attr_get_int32()、op_ici_attr_get_int64() 和 op_ici_attr_get_ptr()获取 ICI 属性的值
- 使用内核过程 op_ici_attr_exists() 确定 ICI 是否包含某个特定属性