Nucleus 实时操作系统中断(下)

Nucleus RTOS兼容性

由于中断在Nucleus SE中的实现方式与Nucleus rto截然不同,因此不应期望有特定的兼容性。Nucleus RTOS有一个本机/低级/高级中断方案,这在某种程度上类似于Nucleus SE中的本机中断和管理中断。

低级和高级ISR

低级ISR

低级中断服务程序(LISR)作为普通ISR执行,包括使用当前堆栈。Nucleus RTOS在调用LISR之前保存上下文,并在LISR返回后恢复上下文。因此,lisr可以用C编写,并且可以调用其他C例程。然而,只有少数Nucleus RTOS服务可用于LISR。如果中断处理需要额外的Nucleus RTOS服务,则必须激活高级中断服务程序(HISR)。Nucleus RTOS支持多个lisr的嵌套。

高级ISR

HISR是动态创建和删除的。每个HISR都有自己的堆栈空间和自己的控制块。每个内存都由应用程序提供。当然,HISR必须在LISR激活之前创建。

由于HISR有自己的堆栈和控制块,所以如果它试图访问已经被访问的Nucleus RTOS数据结构,则可以暂时阻止HISR。

HISR有三个优先级。如果在处理低优先级HISR期间激活了高优先级HISR,则低优先级HISR被抢占的方式与任务被抢占的方式大致相同。相同优先级的hisr按照它们最初激活的顺序执行。在恢复正常任务调度之前,将处理所有激活的HISR。

Nucleus RTOS中断API调用

Nucleus RTOS有许多API调用来支持其中断结构。这些都不是在Nucleus SE中实现的。

对于本机中断,API调用提供以下功能:

控制(启用/禁用)中断(本地和全局)

设置中断向量

对于低电平中断:

向内核注册一个低级ISR

对于高级中断:

创建/删除高级中断

激活高级中断

获取应用程序中(当前)的高级中断数

获取指向所有高级中断的控制块的指针

获取指向当前高级中断控制块的指针

获取有关高级中断的信息

全局控制中断

此服务以独立于任务的方式启用或禁用中断。因此,由该服务禁用的中断将保持禁用状态,直到随后对此服务的调用启用为止。

服务调用原型:

INT NU_Control_Interrupts(INT new_level);

参数:

new_level–系统的新中断级别。菜单禁用中断(禁用所有中断)和菜单启用中断(启用所有中断)选项始终可用。根据体系结构,还可以使用其他选项。

返回:

此服务返回以前级别的已启用中断。

本地控制中断

此服务以依赖于任务的方式启用或禁用中断。此服务将状态寄存器更改为指定的值。状态寄存器将被设置回下一个上下文开关上一次调用NU_Control_Interrupts()时设置的值。

服务调用原型:

INT NU_Local_Control_Interrupts(INT new_level);

参数:

new_level–当前任务的新中断级别。菜单禁用中断(禁用所有中断)和菜单启用中断(启用所有中断)选项始终可用。根据体系结构,还可以使用其他选项。

返回:

此服务返回以前级别的已启用中断。

设置中断向量

此服务用自定义中断服务例程(ISR)替换vector指定的中断向量。

服务调用原型:

VOID *NU_Setup_Vector(INT vector, VOID *new);

参数:

vector–用于注册中断的中断向量

新–ISR将在vector注册

返回:

此服务返回一个指向先前在中断向量上注册的ISR的指针。

注册LISR中断

此服务将LISR函数与中断向量相关联。系统上下文在调用指定的LISR之前自动保存,并在LISR返回后恢复。

服务调用原型:

STATUS NU_Register_LISR(INT vector, VOID(*lisr_entry)(INT), 

VOID (**old_lisr)(INT));

Parameters:

vector – the interrupt vector at which to register the interrupt

lisr_entry – the function to
register at the vector; a value of NU_NULL clears
the vector

old_lisr – the subroutine
previously registered at the specified vector

Returns:

NU_SUCCESS – successful completion of the service

NU_INVALID_VECTOR – the specified
vector is invalid

NU_NOT_REGISTERED – the vector is
not currently registered as de-registration was specified by lisr_entry 

NU_NO_MORE_LISRS – the maximum
number of registered LISRs has been exceeded

Create
a HISR

This service creates a High-Level Interrupt Service Routine
(HISR).

Service call prototype:

STATUS
NU_Create_HISR(NU_HISR *hisr, CHAR *name, 

VOID (*hisr_entry)(VOID), OPTION priority, VOID  *stack_pointer, UNSIGNED
stack_size);

Parameters:

hisr – pointer to a user-supplied HISR control block

name – pointer to a 7-character,
null-terminated name for the HISR

hisr_entry – the function entry
point of the HISR

priority – there are three HISR
priorities (0-2); priority 0 is the highest

stack_pointer – pointer to the
HISR’s stack area

stack_size – number of bytes in
the HISR stack

Returns:

NU_SUCCESS – successful completion of the service

NU_INVALID_HISR – the HISR
control block pointer is NULL or
is already in use

NU_INVALID_ENTRY – the HISR entry
pointer is NULL 

NU_INVALID_PRIORITY – the HISR
priority is invalid

NU_INVALID_MEMORY – the stack
pointer is NULL 

NU_INVALID_SIZE – the stack size
is too small

Delete
a HISR

This service deletes a previously created HISR.

Service call prototype:

STATUS
NU_Delete_HISR(NU_HISR *hisr);

Parameters:

hisr – pointer to a user-supplied HISR control block

Returns:

NU_SUCCESS – successful completion of the service

NU_INVALID_HISR – the HISR
pointer is invalid

激活HISR

此服务将激活HISR。如果指定的HISR当前正在执行,则在当前执行完成之前不会处理此激活请求。每个激活请求执行一次HISR。

服务调用原型:

TATUS NU_Activate_HISR (NU_HISR
*hisr);

Parameters:

hisr – pointer to the HISR control block

Returns:

NU_SUCCESS – successful completion of the service

NU_INVALID_HISR – the HISR
control block pointer is not valid

Obtain
the Number of HISRs in a System

This service returns the number of established HISRs. All
created HISRs are considered established. Deleted HISRs are no longer
considered established.

Service call prototype:

UNSIGNED
NU_Established_HISRs(VOID);

Parameters:

none

Returns:

This service call returns the number of established HISRs in the
system

Obtain
Pointers to HISR Control Blocks

This service builds a sequential list of pointers to all
established HISRs in the system.

Service call prototype:

UNSIGNED 
NU_HISR_Pointers(NU_HISR  **pointer_list, 

UNSIGNED maximum_pointers);

Parameters:

pointer_list – pointer to an array of NU_HISR pointers;
this array will be filled with pointers of established HISRs in the system

maximum_pointers – the maximum
number of NU_HISR pointers
to place into the array; typically, this will be the size of the pointer_list array

Returns:

This service call returns the number of HISRS that are active in
the system

Obtain
a Pointer to the Current HISR

This service returns the currently executing HISR’s pointer.

Service call prototype:

NU_HISR
*NU_Current_HISR_Pointer(VOID);

Parameters:

none

Returns:

This service call returns a pointer the currently executing
HISR’s control block. If the caller is not an HISR, the value returned is NU_NULL .

Obtain
Information About a HISR

This service returns various information about the specified
HISR.

Service call prototype:

STATUS
NU_HISR_Information(NU_HISR *hisr, char *name, 

UNSIGNED  *scheduled_count, DATA_ELEMENT  *priority, 

VOID  **stack_base, UNSIGNED *stack_size, 

UNSIGNED *minimum_stack);

Parameters:

hisr – pointer to the HISR

name – pointer to an 8-character
destination area for the HISR’s name; this includes space for the null
terminator

scheduled_count – pointer to a variable
for holding the total number of times this HISR has been scheduled

priority – pointer to a variable
for holding the HISR’s priority

stack_base – pointer to a pointer
for holding the original stack pointer; this is the same pointer supplied
during creation of the HISR

stack_size – pointer to a
variable for holding the total size of the HISR’s stack

minimum_stack – pointer to a
variable for holding the minimum amount of available stack space detected
during HISR execution

Returns:

NU_SUCCESS – successful completion of the service

NU_INVALID_HISR – the HISR
pointer is invalid

API
Calls from ISRs

API
Calls from LISRs

A LISR may only make use of the following Nucleus RTOS services:

NU_Activate_HISR()

NU_Local_Control_Interrupts()

NU_Current_HISR_Pointer()

NU_Current_Task_Pointer()

NU_Retrieve_Clock()

API
Calls from HISRs

HISRs are allowed access to most Nucleus RTOS services, with the
exception of self-suspension services. Additionally, since an HISR cannot
suspend on a Nucleus RTOS service, the “suspend” parameter must always be set
to NU_NO_SUSPEND .

Nucleus 实时操作系统中断(下)的更多相关文章

  1. Nucleus 实时操作系统中断(上)

    Nucleus 实时操作系统中断(上) Interrupts in the Nucleus SE RTOS 所有现代微处理器和微控制器都有某种中断设施.这种能力对于提供许多应用程序所需的响应能力是必不 ...

  2. dsp5509的中断系统

    1. DSP5509有32个中断,中断分为软件中断和硬件中断,同时软件中断不可以屏蔽.软件中断由指令触发.55x在中断时DSP会自动保存ST0_55.ST1_55.ST2_55三个寄存器. 2. 其中 ...

  3. C++程序结构---1

    C++ 基础教程Beta 版 原作:Juan Soulié 翻译:Jing Xu (aqua) 英文原版 本教程根据Juan Soulie的英文版C++教程翻译并改编. 本版为最新校对版,尚未定稿.如 ...

  4. Linux下的系统调用

    张雨梅   原创作品转载请注明出处 <Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-10000 1.linux的的用户态与内核 ...

  5. 机器学习之神经网络模型-下(Neural Networks: Representation)

    3. Model Representation I 1 神经网络是在模仿大脑中的神经元或者神经网络时发明的.因此,要解释如何表示模型假设,我们不妨先来看单个神经元在大脑中是什么样的. 我们的大脑中充满 ...

  6. Windows xp下IDT Hook和GDT的学习

    一.前言   对于IDT第一次的认知是int 2e ,在系统调用的时候原来R3进入R0的方式就是通过int 2e自陷进入内核,然后进入KiSystemService函数,在根据系统服务调用号调用系统服 ...

  7. MCS-51系统中断优先级的软扩展

    摘要:鉴于MCS-51系统只提供“二级中断嵌套”,提出扩展51系统中断优先级的纯软件方法.其利用51系统内建的中断允许寄存器IE和中断优先级寄存器IP,通过屏蔽字机制来实现:以C51的形式,给出这种扩 ...

  8. 在ASP.NET Core下使用SignalR技术

    一.前言 上次我们讲到过如何在ASP.NET Core中使用WebSocket,没有阅读过的朋友请参考 WebSocket in ASP.NET Core 文章 .这次的主角是SignalR它为我们提 ...

  9. 二、Windows 下 ShellCode 编写初步

    第二章.Windows 下 ShellCode 编写初步 (一)shellcode 定义:最先的 Shell 指的是人机交互界面,ShellCode 是一组能完成我们想要的功能的机器代码,通常以十六进 ...

随机推荐

  1. 路由器逆向分析------MIPS系统网络的配置(QEMU)

    本文博客地址:http://blog.csdn.net/qq1084283172/article/details/69378333 MIPS系统网络的配置  使用QEMU 模拟正在运行的MIPS系统并 ...

  2. Linux中的防火墙(Netfilter、Iptables、Firewalld)

    目录 Netfilter Iptables iptables做本地端口转发 Firewalld Netfilter Netfilter是Linux 2.4内核引入的全新的包过滤引擎,位于Linux内核 ...

  3. WSL2+Ubuntu配置Java Maven Hadoop Spark环境

    所需文件: 更新日期为2021/5/8: Linux 内核更新包 JDK1.8 maven3.8.1 hadoop3.3.0 spark3.1.1 WSL?WSL2? WSL是适用于 Linux 的 ...

  4. 【python】Leetcode每日一题-不同的子序列

    [python]Leetcode每日一题-不同的子序列 [题目描述] 给定一个字符串 s 和一个字符串 t ,计算在 s 的子序列中 t 出现的个数. 字符串的一个 子序列 是指,通过删除一些(也可以 ...

  5. 学javaweb 先学Servlet 应用理论很重要

    package cn.Reapsun.servlet; import java.io.IOException; import java.io.PrintWriter; import javax.ser ...

  6. vue 访问页面时报错 Failed to compile

    这个是因为node-sass没安装好,所以要重新安装 windows下运行命令:npm install node-sass --registry=https://registry.npm.taobao ...

  7. JSX语法详解

    一.基础1.JSX是什么JSX是一种像下面这样的语法: const element = <h1>Hello, world!</h1>;1它是一种JavaScript语法扩展,在 ...

  8. JAVA基础——标识符和数据类型

    注释 单行注释 // 多行注释 /* */ 文档注释 /***/ 标识符和关键字 所有的标识符都应该以字母(A-Z或者a-z),美元符号($),或者下划线(_)开始 首字符之后可以时字母(A-Z或者a ...

  9. [web] 虚拟机网络设置

    三种模式 桥接(Bridged):主机网卡--虚拟网桥--虚拟机网卡,把主机虚拟为交换机,虚拟机ip需与主机设置在同一网段,网关与DNS与主机网卡一致 地址转换(NAT):主机网卡--虚拟NAT设备- ...

  10. 华为eNSP模拟器— telnet实验

    华为eNSP模拟器-telnet实验 一.实验一 路由交换之间实现telnet登陆 实验拓扑 实验目的: 路由器作为 telnet 服务器 交换机作为客户端去连接路由器 实验步骤: 路由器配置 < ...