63 KiB
AUTOSAR 操作系统软件规范 (SWS OS)
文档元信息
| 项目 | 内容 |
|---|---|
| 文档标题 | Specification of Operating System(操作系统规范) |
| 文档所有者 | AUTOSAR |
| 文档责任方 | AUTOSAR |
| 文档标识号 | 034 |
| 文档状态 | Final(最终版) |
| AUTOSAR 标准分类 | Classic Platform(经典平台) |
| 标准发布版本 | 4.4.0 |
| 原文文档号 | AUTOSAR_SWS_OS |
文档变更历史
| 日期 | 发布版本 | 变更人 | 变更说明 |
|---|---|---|---|
| 2018-10-31 | 4.4.0 | AUTOSAR Release Management | - 新增异步服务 - ARTI 支持(DRAFT) - 编辑性修改/澄清 |
| 2017-12-08 | 4.3.1 | AUTOSAR Release Management | 次要更正/澄清/编辑性修改 |
| 2016-11-30 | 4.3.0 | AUTOSAR Release Management | - 新增外设访问 API - 新增中断处理 API - 次要更新/澄清 |
| 2015-07-31 | 4.2.2 | AUTOSAR Release Management | - 允许从所有核调用 ControlIdle - 次要更新/澄清 |
| 2014-10-31 | 4.2.1 | AUTOSAR Release Management | 新增 AsilQmProtection 支持 |
| 2014-03-31 | 4.1.3 | AUTOSAR Release Management | - 更改 IocSender/ReceiverProperties 中属性的多重性 - 次要更新/澄清 |
| 2013-10-31 | 4.1.2 | AUTOSAR Release Management | - 澄清 E_OS_NESTING_DEADLOCK - 更新表 2 - 更正 ECUC_Os_00393 的多重性 - 移除变更文档章节 |
| 2013-03-15 | 4.1.1 | AUTOSAR Administration | - 新增 ECU 降级支持 - 更改服务接口描述为正式格式 |
| 2011-12-22 | 4.0.3 | AUTOSAR Administration | 包含来自原"多核 OS 架构规范"的多核支持 |
| 2010-09-30 | 3.1.5 | AUTOSAR Administration | - 澄清 7.8.1("do nothing"含义)和 7.1.2.1("OSEK declarations") - 拼写错误和措辞的次要修改 |
| 2010-02-02 | 3.1.4 | AUTOSAR Administration | - 服务扩展(第 12 章) - OS-Applications 中的状态 - 可能的主动终止其他 OS-Applications(第 8 章) - 法律免责声明修订 - 修订第 10.4 章 |
| 2009-02-04 | 3.1.2 | AUTOSAR Administration | OS 配置更改:移除 OsAppModeId 参数;从 OsAppModeContainer 添加对 OsAlarm、OsTask 和 OsScheduleTable 的可选引用 |
| 2008-08-13 | 3.1.1 | AUTOSAR Administration | 法律免责声明修订 |
| 2008-02-01 | 3.0.2 | AUTOSAR Administration | 在配置规范章节中新增 OsScheduleTableDuration 参数 |
| 2007-12-21 | 3.0.1 | AUTOSAR Administration | - 更改时间保护方法 - 将配置从 OIL 移至 AUTOSAR XML - 澄清调度表同步描述 - 扩展文档元信息 |
| 2007-01-24 | 2.1.15 | AUTOSAR Administration | - 新增 SoftwareFreeRunningTimer (SWFRT) 支持(含 2 个新 API) - 新增 API 启动同步调度表 - 法律免责声明修订 - 新增发布说明 |
| 2006-05-16 | 2.0 | AUTOSAR Administration | - 文档结构适配通用 Release 2.0 SWS 模板 - 第 10 章重大更改 - 文档结构部分更改 |
| 2005-05-31 | 1.0 | AUTOSAR Administration | 初始发布 |
目录
摘要标记:由于本文档体量较大(276 页,约 15000 行),以下目录完整保留作为参考;后续正文部分将采用"重点翻译 + 摘要"策略。
- 第 1 章:简介和功能概述
- 第 2 章:缩略语和缩写
- 2.1 术语词汇表
- 第 3 章:相关文档
- 3.1 输入文档
- 3.2 相关标准和规范
- 3.2.1 ISO 17356
- 3.3 公司报告、学术著作等
- 3.4 相关规范
- 第 4 章:约束和假设
- 4.1 现有标准
- 4.2 术语
- 4.3 与 RTE 的交互
- 4.4 操作系统抽象层(OSAL)
- 4.5 多核硬件假设
- 4.5.1 CPU 核特性
- 4.5.2 内存特性
- 4.5.3 多核限制
- 4.6 限制
- 4.6.1 硬件
- 4.6.2 编程语言
- 4.6.3 其他
- 4.7 对汽车领域的适用性
- 第 5 章:对其他模块的依赖
- 5.1 文件结构
- 5.1.1 代码文件结构
- 5.1.2 头文件结构
- 5.1.3 ARTI 文件结构(DRAFT)
- 5.1 文件结构
- 第 6 章:需求追溯
- 第 7 章:功能规范
- 7.1 核心 OS
- 7.2 软件自由运行定时器
- 7.3 调度表
- 7.4 调度表同步
- 7.5 栈监控设施
- 7.6 OS-Application
- 7.7 保护设施
- 7.8 保护错误处理
- 7.9 多核操作系统
- 7.10 Inter-OS-Application Communicator (IOC)
- 7.11 系统可扩展性
- 7.12 钩子函数
- 7.13 硬件外设访问
- 7.14 中断源 API
- 7.15 错误分类
- 7.16 ARTI 钩子宏(DRAFT)
- 第 8 章:API 规范
- 8.1 常量
- 8.2 宏
- 8.3 类型定义
- 8.4 函数定义
- 8.5 IOC
- 8.6 预期接口
- 8.7 钩子函数
- 8.8 服务接口
- 第 9 章:序列图
- 第 10 章:配置规范
- 第 11 章:OS 生成
- 第 12 章:应用笔记
- 第 13 章:OS 实现的 AUTOSAR 服务
- 第 14 章:内存保护配置展望
- 第 15 章:不适用需求
免责声明
本节保留原文,不进行翻译。
1. 简介和功能概述
本文档描述了 AUTOSAR 操作系统(OS)为满足 [2](AUTOSAR SRS)中提出的顶层需求所必须满足的基本需求。
通常,操作系统可根据其特性分为不同组,例如静态配置与动态管理。为了对 AUTOSAR OS 进行分类,以下是基本特性:OS
- 静态配置和扩展
- 适用于实时性能的推理
- 提供基于优先级的调度策略
- 在运行时提供保护功能(内存、时间等)
- 可托管在低端控制器上且无需外部资源
此功能集定义了当前一代汽车 ECU 中常用的 OS 类型(远程信息处理/信息娱乐系统除外)。假设远程信息处理/信息娱乐系统将在 AUTOSAR 框架下继续使用专有 OS(例如 Windows CE、VxWorks、QNX 等)。在需要在这些专有 OS 上运行 AUTOSAR 组件的情况下,本文档中定义的接口应作为操作系统抽象层(OSAL)提供。
本文档使用行业标准 [15](ISO 17356-3)作为 AUTOSAR OS 的基础。读者在阅读本文档之前应熟悉此标准。
本文档描述了对 [15] 的扩展和限制。
2. 缩略语和缩写
| 缩写 | 描述 |
|---|---|
| API | Application Programming Interface(应用程序编程接口) |
| AR | AUTOSAR |
| BSW | Basic Software(基础软件) |
| BSWMD | Basic Software Module Description(基础软件模块描述) |
| CDD | Complex Driver(复杂驱动) |
| COM | Communication(通信) |
| ECC | Extended Conformance Class(扩展符合类) |
| ECU | Electronic Control Unit(电子控制单元) |
| HW | Hardware(硬件) |
| ID | Identifier(标识符) |
| IOC | Inter OS-Application communicator(OS-Application 间通信器) |
| ISR | Interrupt Service Routine(中断服务例程) |
| LE | Locatable Entity(可定位实体):一种独立的软件片段,无论位于哪个核上都有相同效果 |
| MC | Multi-Core(多核) |
| MCU | Microcontroller Unit(微控制器单元) |
| ME | Mutual exclusion(互斥) |
| MPU | Memory Protection Unit(内存保护单元) |
| NMI | Non-Maskable Interrupt(不可屏蔽中断) |
| OIL | OSEK Implementation Language(OSEK 实现语言) |
| OS | Operating System(操作系统) |
| OSEK/VDX | Offene Systeme und deren Schnittstellen für die Elektronik im Kraftfahrzeug(汽车电子开放系统及其接口) |
| RTE | Run-Time Environment(运行时环境) |
| RTOS | Real Time Operating System(实时操作系统) |
| SC | Single-Core(单核) |
| SLA | Software Layered Architecture(软件分层架构) |
| SW | Software(软件) |
| SWC | Software Component(软件组件) |
| SWFRT | Software FreeRunningTimer(软件自由运行定时器) |
2.1 术语词汇表
摘要标记:本节包含约 50 个核心术语定义(Access Right、Counter、Deadline、Duration、Execution Time、Expiry Point、Hook Function、OS-Application、Schedule Table、Spinlock 等)。以下是关键术语表:
| 术语 | 定义 |
|---|---|
| Access Right(访问权限) | OS-Application 的对象(例如 Task、ISR、钩子函数)具有的关于内存、OS 服务或(一组)OS 对象的访问或操作权限。 |
| Cardinality(基数) | 集合中的项目数。 |
| Counter(计数器) | 操作系统对象,以刻度为单位记录计数。有两种类型:硬件计数器(由硬件驱动)和软件计数器(通过 IncrementCounter() API 调用递增)。 |
| Deadline(截止时间) | 任务/类别 2 ISR 在执行期间必须到达的某个点的时间点,相对于触发激活的刺激。 |
| Delay(延迟) | 调度表上两个相邻到期点之间的刻度数。 |
| Deviation(偏差) | 在显式同步的调度表上的当前位置与同步计数模调度表持续时间的值之间的最小刻度数。 |
| Duration(持续时间) | 从名义零到调度表环绕的刻度数。 |
| Execution Time(执行时间) | 任务/ISR 在 RUNNING 状态下花费的净时间,不包括进入 SUSPENDED 或 WAITING 状态以及被更高优先级 ISR 抢占的时间。 |
| Execution Budget(执行预算) | 任务/ISR 允许的最大执行时间。 |
| Expiry Point(到期点) | 调度表上的偏移量(从零开始测量),OS 在此激活任务和/或设置事件。 |
| Hook Function(钩子函数) | 由用户实现并由操作系统在某些事件发生时调用的函数。 |
| Initial Offset(初始偏移) | 调度表上最小的到期点偏移。可以为零。 |
| Interarrival Time(到达间隔) | 任务连续从 SUSPENDED 状态进入 READY 状态之间的时间。 |
| Interrupt Lock Time(中断锁定时间) | 任务/ISR 在禁用/挂起 Category 1 中断和/或 Category 2 中断的情况下执行的时间。 |
| OS-Application(OS-应用) | OS 对象的集合。可分为 Trusted(可信)和 Non-trusted(不可信)两种。 |
| OS object(OS 对象) | 属于单个 OS-Application 的对象:任务、ISR、闹钟、事件、调度表、资源、信任函数、计数器、应用特定钩子。 |
| OS Service(OS 服务) | 操作系统的 API。 |
| Protection Error(保护错误) | OS-Application 软件中的系统错误。可分为内存访问违例、时间故障、非法服务、硬件异常。 |
| Resource Lock Time(资源锁定时间) | OSEK 资源被任务/ISR 持有的时间。 |
| Response Time(响应时间) | 任务/ISR 准备好执行到生成指定响应之间的时间。 |
| Schedule Table(调度表) | 一组静态定义的到期点的封装。 |
| Section(段) | 对象文件中指令或数据组合成单元的部分(为数据或代码分配的内存中的连续地址空间)。 |
| Spinlock(自旋锁) | 一种锁定机制,其中任务在循环中"自旋"反复检查共享变量是否变为某个值。在多核系统中,变量比较和更改通常需要原子操作。 |
| Spinlock variable(自旋锁变量) | 自旋锁使用的共享变量,用于指示自旋锁是空闲还是被占用。 |
| Synchronization Counter(同步计数器) | 区别于 OS 计数器对象,是 OS 外部的计数器,调度表的到期点与之同步。 |
| Task(任务) | 由 OS 管理的执行(用户)代码的对象。可分为 Basic Task(基本任务,不能自行阻塞)和 Extended Task(扩展任务,可以自行阻塞并等待事件)。 |
| Time Frame(时间帧) | 任务/ISR 的最小到达间隔时间。 |
| Trusted Function(信任函数) | 由可信 OS-Application 提供的服务,可被其他 OS-Application(可信或不可信)使用。 |
| WCET | Worst Case Execution Time(最坏情况执行时间)。 |
完整术语表见原文 PDF(章节 2.1,页 13-16)。
3. 相关文档
3.1 输入文档
- [1] Layered Software Architecture, AUTOSAR_EXP_LayeredSoftwareArchitecture.pdf
- [2] Requirements on Operating System, AUTOSAR_SRS_OS.pdf
- [3] General Requirements on Basic Software Modules, AUTOSAR_SRS_BSWGeneral.pdf
- [4] Specification of the Virtual Functional Bus, AUTOSAR_EXP_VFB.pdf
- [5] Requirements on Software FreeRunningTimer, AUTOSAR_SRS_FreeRunningTimer.pdf
- [6] Specification of GPT Driver, AUTOSAR_SWS_GPTDriver.pdf
- [7] Specification of Standard Types, AUTOSAR_SWS_StandardTypes.pdf
- [8] Specification of Memory Mapping, AUTOSAR_SWS_MemoryMapping.pdf
- [9] Specification of RTE, AUTOSAR_SWS_RTE.pdf
- [10] Specification of ECU Configuration, AUTOSAR_TPS_ECUConfiguration.pdf
- [11] Basic Software Module Description Template, AUTOSAR_TPS_BSWModuleDescriptionTemplate.pdf
- [12] List of Basic Software Modules, AUTOSAR_TR_BSWModuleList.pdf
- [13] Specification of RTE, AUTOSAR_SWS_RTE.pdf
- [14] General Specification of Basic Software Modules, AUTOSAR_SWS_BSWGeneral.pdf
3.2 相关标准和规范
3.2.1 ISO 17356
ISO 17356("道路车辆 — 嵌入式汽车应用的开放接口")是 OSEK/VDX 组织先前发布的标准。
- [15] ISO 17356-3: 2005: Road vehicles -- Open interface for embedded automotive applications -- Part 3: OSEK/VDX Operating System (OS)
- [16] ISO 17356-6:2006: Road vehicles -- Open interface for embedded automotive applications -- Part 6: OSEK/VDX Implementation Language (OIL)
3.3 公司报告、学术著作等
- [17] Extensions of OSEK OS for Protected Applications, OSEK Support Project DC058_02, DaimlerChrysler AG
3.4 相关规范
AUTOSAR 提供了关于基础软件模块的通用规范 [14](SWS BSW General),该规范对操作系统同样有效。
因此,SWS BSW General 规范应被视为操作系统的附加和必需规范。
4. 约束和假设
4.1 现有标准
本文档对所引用的相关标准和规范作以下假设:
- [15] 提供了足够灵活的调度策略以调度 AUTOSAR 系统。
- [15] 是一项成熟的规范,其实现在全球数百万个 ECU 中使用。
- [15] 不提供足够的支持以在运行时隔离多源软件组件。
- [15] 不提供足够的运行时支持以证明安全案例中某些类别的故障传播不存在。
4.2 术语
本规范在需求指定多个术语时使用以下运算符:
- NOT:单个术语的否定,例如 NOT Weekend
- AND:两个术语的合取,例如 Weekend AND Saturday
- OR:两个术语的析取,例如 Monday OR Tuesday
包含多个术语的需求从左到右求值。
优先级规则为:
- 最高优先级:NOT
- 最低优先级:AND OR
表达式 NOT X AND Y 表示 (NOT X) AND (Y)。
当同一句中使用相同优先级的运算符时,使用逗号消歧。表达式 X AND Y, OR Z 表示 (X AND Y) OR Z。
4.3 与 RTE 的交互
AUTOSAR 系统的配置 [4] 将软件组件的 "runnables" 映射到由操作系统调度的一个或多个任务。任务中的所有 runnables 共享相同的保护边界。在 AUTOSAR 中,软件组件不得包含中断处理程序。因此软件组件实现为仅在任务体或一组任务中执行的 runnables。
Runnables 通过 AUTOSAR RTE 访问硬件源数据。RTE 提供 runnables 和基础软件模块之间的运行时接口。基础软件模块还包含由操作系统调度的多个任务和 ISR。
假设软件组件模板和基础软件模块的描述提供了关于所需运行时行为的足够信息,以便能够指定配置 OS 所需的任务属性。
4.4 操作系统抽象层(OSAL)
不使用 AUTOSAR 中定义的 OS 的系统可以使用操作系统抽象层(OSAL)提供 AUTOSAR 软件组件的执行平台。OSAL 的接口与为 AUTOSAR OS 定义的接口完全相同。
4.5 多核硬件假设
目前存在几种现有的和建议的多核微处理器 HW 架构。这些架构提供的特性差异很大。因此本节试图捕获多核所需的一组公共架构特性。
硬件假设应保持为假设,不应成为官方的 AUTOSAR 需求。
4.5.1 CPU 核特性
- 同一块硅上有多个核。
- HW 提供 SW 可用于标识核的方法。
- 硬件支持原子读和原子写操作(取决于硬件的固定字长)。
- 硬件支持某些原子的 Test-And-Set 功能或可用于构建核间共享的临界区的类似功能。可能存在其他原子操作。
- 核可以具有相同的指令集;至少所有核上都提供通用的基本指令集。可能存在核特定的扩展,但未考虑在内。
- 核具有相同的数据表示。例如,整数大小、字节和位顺序等相同。
- 如果存在每核缓存,AUTOSAR 要求在 HW 或 SW 中支持 RAM-cache 一致性。SW 方式意味着缓存控制器可以由 SW 编程以使缓存行无效或将某些内存区域排除在缓存之外。
- 在异常情况下(例如非法内存引用或除零异常),异常发生在引入异常的核上。
- 出于通知目的,可以在任何核上触发中断/陷阱。
4.5.2 内存特性
- 共享 RAM:所有核都可访问共享 RAM;至少所有核可以共享大部分内存。
- Flash 共享:Flash 至少应在所有核之间共享。但是如果 Flash/RAM 可以分区,使核到 Flash 具有独立路径,则可以提高性能。
- 地址空间:假设存在单一地址空间,至少在内存地址空间的共享部分中。
- 内存保护:AUTOSAR 多核架构应能够在支持和不支持内存保护的系统上运行。如果存在内存保护,则所有核都由基于硬件的内存保护覆盖。
4.5.3 多核限制
- 在 AUTOSAR R4.0 中,不支持在操作系统启动后激活 AUTOSAR 控制下的其他核。
- 调度算法不会将任务动态分配给核。
- AUTOSAR OS RESOURCE 算法不支持跨核。资源可在本地使用,介于绑定到同一核的任务之间,但不可用于绑定到不同核的任务/ISR。
4.6 限制
4.6.1 硬件
核心 AUTOSAR 操作系统假定可自由访问由 OS 自身管理的硬件资源。这包括但不限于以下硬件:
- 中断控制寄存器
- 处理器状态字
- 栈指针
核心操作系统的特定(扩展)功能扩展了对硬件资源的要求。以下列表概述了对硬件有要求的功能。不使用这些 OS 功能的系统没有这些硬件要求。
- 内存保护:需要硬件内存保护单元。所有具有写后果的内存访问(例如具有写副作用到内存位置的读取)应被视为写。
- 时间保护:用于监视执行时间和到达率的定时器硬件。
- 特权和非特权模式:用于保护 OS 免受由对 OS 控制寄存器的写引起的内部损坏。此模式不得允许 OS-Application 规避保护(例如写管理内存保护的寄存器、写到处理器状态字等)。特权模式必须由受保护的 OS 完全控制,OS 在内部使用该模式以在不可信 OS-Application 和可信 OS-Application 之间来回传输控制权。微处理器必须支持将处理器移入此特权模式的受控方式。
- 本地/全局时间同步:需要全局时间源。
通常,处理器中的硬件故障不会被操作系统检测到。在发生硬件故障的情况下,无法保证 OS 的正确运行。
由特定 OS 实现管理的资源必须在 OS 的相应配置文件中定义。
4.6.2 编程语言
操作系统的 API 定义为 C 函数调用或宏。如果使用其他语言,它们必须适配 C 接口。
4.6.3 其他
操作系统不提供动态内存管理服务。
4.7 对汽车领域的适用性
操作系统具有与 [15] 设计时相同的尺寸和可扩展性设计约束。因此当前的直接适用领域是车身、底盘和动力总成 ECU。但是,没有理由不能在信息娱乐应用中实现 OS。
5. 对其他模块的依赖
对其他模块没有强制依赖,但是:
- 假设操作系统可以直接使用定时器单元来驱动计数器。
- 如果用户需要直接从全局时间驱动调度,则需要全局时间中断。
- 如果用户需要将调度表的处理与全局时间同步,则需要使用
SyncScheduleTable()服务通知操作系统全局时间。 - 本文档中描述的 IOC 提供 OS-Application 之间的通信。IOC 的生成基于 RTE 生成器生成的配置信息。另一方面,RTE 使用 IOC 生成的函数来传输数据。
5.1 文件结构
5.1.1 代码文件结构
操作系统的代码文件结构不固定,除了一般 SRS 中的要求外。
5.1.2 头文件结构
IOC 生成器生成一个附加的头文件 Ioc.h。Ioc.h 的用户应包括 Ioc.h 文件。如果 IOC 的实现需要附加的头文件,则可以自由包含它们。头文件是自包含的,这意味着它们将包括它们需要的所有其他头文件。
5.1.3 ARTI 文件结构(DRAFT)
为了支持基于 ARTI 的调试和跟踪,所有包含 ARTI 钩子宏的源文件应包括一个 "arti.h" 文件。此文件(以及相应的 arti.c 文件)将由 ARTI 钩子实现者(即跟踪工具)提供。构建最终可执行文件时,链接器也将拉入已编译的 arti.c 文件。
ARTI 钩子宏的使用是可配置的。如果 OS 配置为不使用 ARTI,则可以省略 "arti.h" 的包含,并且 ARTI 钩子宏可以扩展为空宏("nothing")。
6. 需求追溯
摘要标记:本节包含约 200 行需求追溯表,按 RS_BRF_xxxxx 特性链接到 SWS_Os_xxxxx 规范需求。完整表见原文 PDF 第 26-35 页。
7. 功能规范
7.1 核心 OS
7.1.1 背景与原理
核心 OS 是 OSEK/VDX OS 标准的扩展(参见 [15])。该规范侧重于扩展和限制,而 OSEK OS 行为未更改的部分不在此规范中。
7.1.2 需求
[SWS_Os_00001] OS 应提供与 OSEK OS API 向后兼容的 API
The Operating System module shall provide an API that is backward compatible
to the API of OSEK OS.
[SWS_Os_00242] OS 应仅允许属于同一 OS-Application 的 Alarm Callback
The Operating System module shall only allow Alarm Callbacks of the same
OS-Application to call other OS-Application's services.
[SWS_Os_00304] SetRelAlarm() 中参数 "increment" 设置为 0 的特殊行为
If in a call to SetRelAlarm() the parameter "increment" is set to 0 then...
[SWS_Os_00424] 第一次调用 StartOS()
The first call to StartOS() (for starting the Operating System)...
[SWS_Os_00425] ShutdownOS() 调用和 ShutdownHook() 返回
If ShutdownOS() is called and ShutdownHook() returns then...
[SWS_Os_00299] OS 应提供服务
The Operating System module shall provide the services...
[SWS_Os_00301] OS 应提供启动非 AUTOSAR 核的能力
The Operating System module shall provide the ability to start non-AUTOSAR cores.
[SWS_Os_00476] OS 应允许自动启动对象
The Operating System module shall allow to automatically start...
[SWS_Os_00566] OS API 应在扩展模式下检查所有参数
The Operating System API shall check in extended mode all parameters...
[SWS_Os_00374] OS 应处理所有初始化
The Operating System module shall handle all the initialization...
[SWS_Os_00384] OS 应调整硬件定时器的读出值
The Operating System module shall adjust the read out values of...
摘要标记:核心 OS 完整需求(章节 7.1.2)包含约 50+ 个 SWS_Os_xxxxx 需求条目,涵盖任务管理、调度、资源、事件、ISR 等核心概念。完整内容见原文 PDF 第 36-39 页。
7.2 软件自由运行定时器
摘要标记:本节引用 AUTOSAR_SRS_FreeRunningTimer 规范,描述 OS 如何为应用提供定时器接口。详见原文 PDF 第 39 页。
7.3 调度表
7.3.1 背景与原理
调度表是 OSEKtime dispatcher 概念的 AUTOSAR 实现。它允许以预定的时间间隔同步激活任务和设置事件。
7.3.2 需求
[SWS_Os_00401] 调度表应至少有一个到期点
A schedule table shall have at least one expiry point.
[SWS_Os_00402] 到期点应包含任务集合
An expiry point shall contain a (possibly empty) set of tasks to activate.
[SWS_Os_00403] 到期点应包含事件集合
An expiry point shall contain a (possibly empty) set of events to set.
[SWS_Os_00404] 到期点应包含偏移
An expiry point shall contain an offset in ticks from the start of the schedule table.
[SWS_Os_00407] 到期点应至少激活一个任务或设置一个事件
An expiry point shall activate at least one task OR set at least one event.
[SWS_Os_00442] 同一调度表上的每个到期点应具有唯一偏移
Each expiry point on a given schedule table shall have a unique offset.
[SWS_Os_00443] 初始偏移应为零或在范围内
The Initial Offset shall be zero OR in the range...
[SWS_Os_00408] 相邻到期点之间的延迟应在范围内
The delay between adjacent expiry points shall be in the range...
[SWS_Os_00002] OS 应处理每个到期点
The Operating System module shall process each expiry point...
[SWS_Os_00007] OS 应允许多个调度表
The Operating System module shall permit multiple schedule tables...
[SWS_Os_00409] 调度表应由计数器驱动
A schedule table of the Operating System module shall be driven by a counter.
[SWS_Os_00410] OS 应能处理至少一个调度表
The Operating System module shall be able to process at least one schedule table.
[SWS_Os_00411] OS 应使用刻度
The Operating System module shall make use of ticks so that the schedule table
process is independent of the underlying hardware.
[SWS_Os_00412] OS 应在处理到期点之前处理所有任务激活和事件设置
The Operating System module shall process all task activations and event settings
that are scheduled at a processing point before processing the next expiry point.
[SWS_Os_00413] 调度表应可配置为 single-shot 或 periodic
The schedule table shall be configurable as either single-shot or periodic.
[SWS_Os_00009] single-shot 调度表行为
If the schedule table is single-shot, the Operating System module...
[SWS_Os_00427] single-shot 调度表最终到期点处理
If the schedule table is single-shot, the Operating System module...
[SWS_Os_00444] periodic 调度表的 Final Delay
For periodic schedule tables the value of Final Delay shall be in the range...
[SWS_Os_00194] 处理最终到期点后
After processing the Final Expiry Point, and if the schedule table is periodic...
[SWS_Os_00428] 调度表处理取消
If schedule table processing has been cancelled before reaching the Final Expiry Point...
[SWS_Os_00414] 调度表切换请求
When a schedule table switch is requested, the OS shall...
[SWS_Os_00510] 自动启动处理
The Operating System module shall perform the autostart of schedule tables...
摘要标记:调度表完整需求(章节 7.3.2)包含约 70+ 个 SWS_Os_xxxxx 需求条目。完整内容见原文 PDF 第 40-47 页。
7.4 调度表同步
7.4.1 背景与原理
调度表同步允许调度表的执行与外部同步计数器对齐。这对于需要与外部时间源(例如 FlexRay 时间)同步的分布式应用是必需的。
7.4.2 需求
[SWS_Os_00415] 显式同步的调度表
An explicit synchronized schedule table...
[SWS_Os_00416] 同步持续时间配置
An expiry point shall permit the configuration of a synchronization duration.
[SWS_Os_00436] MaxShorten 值约束
The value of (Offset – OsScheduleTableMaxShorten) of an expiry point shall be...
[SWS_Os_00559] MaxLengthen 值约束
The value of OsScheduleTableMaxLengthen shall be smaller than...
[SWS_Os_00437] 偏差计算
The value of (OsScheduleTableMaxLengthen + OsScheduleTableMaxShorten)...
[SWS_Os_00438] 精度界限
A schedule table shall define a precision bound with a value in the range...
[SWS_Os_00206] 同步计数提供
When a new synchronization count is provided, the Operating System module...
[SWS_Os_00417] 同步启动
The Operating System module shall start to synchronize an explicitly synchronized
schedule table.
[SWS_Os_00418] 同步状态
The Operating System module shall set the state of an explicitly synchronized
schedule table to SCHEDULETABLE_SYNCHRONOUS...
[SWS_Os_00419] 等待同步状态
The Operating System module shall set the state of an explicitly synchronized
schedule table to SCHEDULETABLE_WAITING...
[SWS_Os_00420] 偏差非零且下一个到期点在范围内
IF the deviation is non-zero AND the next expiry point is within the precision bound...
[SWS_Os_00421] 偏差非零且下一个到期点超出范围
IF the deviation is non-zero AND the next expiry point is out of the precision bound...
摘要标记:调度表同步完整需求(章节 7.4.2)包含约 40+ 个 SWS_Os_xxxxx 需求条目。完整内容见原文 PDF 第 49-56 页。
7.5 栈监控设施
7.5.1 背景与原理
栈监控提供了一种运行时检测栈溢出的机制,作为内存保护的替代或补充。
7.5.2 需求
[SWS_Os_00067] 栈监控
The Operating System module shall provide a stack monitoring mechanism.
摘要标记:栈监控设施完整需求见原文 PDF 第 56-57 页。
7.6 OS-Application
7.6.1 背景与原理
OS-Application 是 OS 对象(任务、ISR、闹钟、事件、调度表、资源等)的逻辑分组。它们允许将功能分组并强制实施隔离和保护。
7.6.2 需求
摘要标记:OS-Application 完整需求(章节 7.6.2)包含约 30+ 个 SWS_Os_xxxxx 需求条目,涉及 ApplicationType、ApplicationStateType、访问权限控制等。完整内容见原文 PDF 第 59-61 页。
7.7 保护设施
7.7.1 内存保护
摘要标记:内存保护完整需求(章节 7.7.1)包含约 20+ 个 SWS_Os_xxxxx 需求条目,涉及 MPU 配置、访问权限、内存区域保护等。完整内容见原文 PDF 第 61-64 页。
7.7.2 时间保护
7.7.2.1 背景与原理
时间保护防止一个任务/ISR 的时间行为影响其他任务/ISR。它基于以下概念:
- 执行预算(Execution Budget):任务/ISR 允许的最大执行时间。
- 到达帧(Time Frame):两次激活之间的最短时间。
- 资源锁定预算(Resource Lock Budget):允许持有资源的最长时间。
- 中断锁定预算(Interrupt Lock Budget):允许禁用中断的最长时间。
7.7.2.2 需求
[SWS_Os_00028] 非可信 OS-Application 的时间保护
In a non-trusted OS-Application, the Operating System module shall apply timing
protection to every Task/Category 2 ISR of this non-trusted OS-Application.
[SWS_Os_00089] 可信 OS-Application 的时间保护
In a trusted OS-Application, the Operating System module shall provide the ability
to apply timing protection to Tasks/Category 2 ISRs of this OS-Application.
[SWS_Os_00397] 未配置 OS-Application 时的行为
If no OS-Application is configured, the Operating System module shall be able to
apply timing protection to Tasks/Category 2 ISRs.
时间保护:任务
[SWS_Os_00064] 任务执行预算超出
If a task's OsTaskExecutionBudget is reached then the Operating System module
shall call the ProtectionHook() with E_OS_PROTECTION_TIME.
[SWS_Os_00473] 重置任务执行预算
The Operating System module shall reset a task's OsTaskExecutionBudget on a
transition to the SUSPENDED or WAITING states.
[SWS_Os_00465] 任务到达时间限制
The Operating System module shall limit the inter-arrival time of tasks to one
per OsTaskTimeFrame.
[SWS_Os_00469] 启动任务时间帧
The Operating System module shall start an OsTaskTimeFrame when a task is
activated successfully.
[SWS_Os_00472] 释放任务时启动时间帧
The Operating System module shall start an OsTaskTimeFrame when a task is
released successfully.
[SWS_Os_00466] 时间帧内尝试激活
If an attempt is made to activate a task before the end of an OsTaskTimeFrame
then the Operating System module shall not perform the activation AND shall call
the ProtectionHook() with E_OS_PROTECTION_ARRIVAL.
[SWS_Os_00467] 时间帧内尝试释放
If an attempt is made to release a task before the end of an OsTaskTimeFrame
then the Operating System module shall not perform the release AND shall call
the ProtectionHook() with E_OS_PROTECTION_ARRIVAL AND the event shall be set.
时间保护:ISR
[SWS_Os_00210] ISR 执行预算超出
If a Category 2 ISR's OsIsrExecutionBudget is reached then the Operating System
module shall call the ProtectionHook() with E_OS_PROTECTION_TIME.
[SWS_Os_00474] 重置 ISR 执行预算
The Operating System module shall reset an ISR's OsIsrExecutionBudget when the
ISR returns control to the OS or terminates.
[SWS_Os_00470] ISR 到达时间限制
The Operating System module shall limit the inter-arrival time of Category 2
ISRs to one per OsIsrTimeFrame.
[SWS_Os_00471] ISR 时间帧测量起点
The Operating System module shall measure the start of an OsIsrTimeFrame from
the point at which it recognises the interrupt (i.e. in the Operating System
interrupt wrapper).
[SWS_Os_00048] ISR 在时间帧内发生
If Category 2 interrupt occurs before the end of the OsIsrTimeFrame then the
Operating System module shall not execute the user provided ISR AND shall call
the ProtectionHook() with E_OS_PROTECTION_ARRIVAL.
时间保护:资源锁定和中断禁用
[SWS_Os_00033] 资源锁定预算超出
If a Task/Category 2 ISR holds an OSEK Resource and exceeds the
Os[Task|Isr]ResourceLockBudget, the Operating System module shall call the
ProtectionHook() with E_OS_PROTECTION_LOCKED.
[SWS_Os_00037] 中断锁定预算超出
If a Task/Category2 ISR disables interrupts (via Suspend/Disable|All/OS|
Interrupts()) and exceeds the configured Os[Task|Isr][All|OS]InterruptLockBudget,
the Operating System module shall call the ProtectionHook() with
E_OS_PROTECTION_LOCKED.
7.7.2.3 实现笔记
执行时间强制需要硬件支持,例如时间强制中断。如果使用中断来实现时间强制,则此中断的优先级必须足够高以"中断"被监控的任务或 ISR。
根据实际硬件支持,这可能意味着 DisableAllInterrupts 和 SuspendAllInterrupts 不禁用所有中断(例如除了用于时间保护的中断之外的所有中断),或者 Category 1 ISR 的使用(绕过操作系统(以及时间保护))在某种程度上受到限制。
实现必须记录这种实现特定行为(例如使用时间保护时的限制)。
摘要标记:时间保护章节(7.7.2)完整内容见原文 PDF 第 64-70 页。
7.7.3 服务保护
背景与原理
由于 OS-Application 可以通过服务与操作系统模块交互,因此必须确保服务调用不会损坏操作系统模块本身。服务保护在运行时防范这种损坏。
服务保护有几种情况需要考虑:OS-Application 进行 API 调用
- 使用无效句柄或超出范围的值。
- 在错误的上下文中,例如在 StartupHook() 中调用 ActivateTask()。
- 未能进行 API 调用导致 OSEK OS 处于未定义状态,例如在没有 ReleaseResource() 调用的情况下终止。
- 影响系统中其他每个 OS-Application 的行为,例如 ShutdownOS()。
- 操作属于另一个 OS-Application 的操作系统对象(未获得必要权限),例如 OS-Application 尝试在不属于它的任务上执行 ActivateTask()。
摘要标记:服务保护完整需求(章节 7.7.3)包含约 30+ 个 SWS_Os_xxxxx 需求条目。完整内容见原文 PDF 第 70-76 页。
7.7.4 保护 OS 使用的硬件
摘要标记:本节涉及保护 OS 管理的硬件寄存器。完整内容见原文 PDF 第 76 页。
7.7.5 提供"可信函数"
摘要标记:本节涉及可信函数机制。完整内容见原文 PDF 第 77 页。
7.8 保护错误处理
7.8.1 背景与原理
摘要标记:本节涉及保护错误的处理机制和 ProtectionHook() 的实现。完整内容见原文 PDF 第 78-80 页。
7.8.2 需求
摘要标记:本节包含约 20+ 个 SWS_Os_xxxxx 需求条目,涉及 E_OS_PROTECTION_* 错误代码和 ProtectionHook() 返回值。完整内容见原文 PDF 第 80-82 页。
7.9 多核操作系统
7.9.1 背景与原理
摘要标记:本节描述多核 OS 的概念。完整内容见原文 PDF 第 82 页。
7.9.2 调度
摘要标记:多核 OS 中任务/ISR 静态绑定到核。完整内容见原文 PDF 第 82-83 页。
7.9.3 可定位实体(LE)
摘要标记:本节描述 LE 概念。完整内容见原文 PDF 第 83-84 页。
7.9.4 多核启动概念
摘要标记:本节描述 AUTOSAR 多核系统的启动序列,包括 master/slave 核的角色。完整内容见原文 PDF 第 84-87 页。
7.9.5 AUTOSAR OS 控制的核
摘要标记:本节描述 AUTOSAR OS 完全控制的核的行为。完整内容见原文 PDF 第 87-88 页。
7.9.6 非 AUTOSAR OS 控制的核
摘要标记:本节描述不受 AUTOSAR OS 控制的核。完整内容见原文 PDF 第 88 页。
7.9.7 多核关闭概念
摘要标记:本节描述 AUTOSAR 多核系统的关闭序列。完整内容见原文 PDF 第 88-90 页。
7.9.8 OS 服务功能(概述)
摘要标记:本节列出多核 OS 支持的所有服务的概述。完整内容见原文 PDF 第 90-92 页。
7.9.9 - 7.9.31 多核扩展功能
摘要标记:本节描述 GetTaskID、中断禁用、任务激活、任务链接、事件设置、激活附加核、OS 启动、任务终止、OS-Application 终止、OS 关闭、事件等待、可信函数调用、重新调度、资源占用、CoreID、计数器、闹钟、调度表、自旋锁机制、离线检查、自动启动对象等内容。完整内容见原文 PDF 第 92-107 页。包含约 150+ 个 SWS_Os_xxxxx 需求条目。
7.10 Inter-OS-Application Communicator (IOC)
7.10.1 背景与原理
IOC 是 OS-Application 之间的通信机制。它支持两种通信模式:
- LastIsBest communication:发送方始终保留最新数据。
- Queued communication:发送方保留多个数据元素。
7.10.2 IOC - 通用目的
摘要标记:本节描述 IOC 的通用概念。完整内容见原文 PDF 第 109 页。
7.10.3 IOC 功能
摘要标记:本节描述 IOC 的具体功能。完整内容见原文 PDF 第 110-111 页。
7.10.4 IOC 接口
摘要标记:本节列出 IOC 函数原型。完整内容见原文 PDF 第 111-112 页。
7.10.5 IOC 内部结构
摘要标记:本节描述 IOC 的内部数据结构。完整内容见原文 PDF 第 112 页。
7.10.6 IOC 配置和生成
摘要标记:本节描述 IOC 配置方法。完整内容见原文 PDF 第 112-113 页。
7.10.7 IOC 集成示例
摘要标记:本节提供 IOC 集成示例。完整内容见原文 PDF 第 113-116 页。
7.10.8 未来扩展
摘要标记:本节描述 IOC 的未来扩展计划。完整内容见原文 PDF 第 116 页。
7.11 系统可扩展性
7.11.1 背景与原理
AUTOSAR OS 定义了 4 个可扩展性类:
- 类 1 (ECC1):OSEK OS + 调度表
- 类 2 (ECC2):类 1 + 时间保护
- 类 3 (ECC3):类 1 + 内存保护
- 类 4 (ECC4):类 1 + 类 2 + 类 3
摘要标记:系统可扩展性完整内容见原文 PDF 第 116-118 页。
7.11.2 需求
摘要标记:本节包含约 10+ 个 SWS_Os_xxxxx 需求条目。完整内容见原文 PDF 第 118 页。
7.12 钩子函数
7.12.1 背景与原理
钩子函数允许在特定事件上执行用户代码。AUTOSAR OS 提供以下钩子:
- StartupHook():在 OS 启动时调用
- ShutdownHook():在 OS 关闭时调用
- ErrorHook():在发生错误时调用
- ProtectionHook():在保护违规时调用
摘要标记:钩子函数完整内容见原文 PDF 第 119-120 页。
7.13 硬件外设访问
摘要标记:本节描述
ReadPeripheralX()、WritePeripheralX()和ModifyPeripheralX()API。完整内容见原文 PDF 第 120-121 页。
7.14 中断源 API
摘要标记:本节描述
EnableInterruptSource()、DisableInterruptSource()和ClearPendingInterrupt()API。完整内容见原文 PDF 第 121-123 页。
7.15 错误分类
摘要标记:本节定义 OS 的所有错误代码及其分类。完整内容见原文 PDF 第 123-124 页。
7.16 ARTI 钩子宏(DRAFT)
摘要标记:本节描述 ARTI 调试钩子宏的接口(AR_CP_OS_APPLICATION、AR_CP_OS_TASKSCHEDULER、AR_CP_OS_CAT2DISPATCHER、AR_CP_OS_SERVICECALLS、AR_CP_OS_SPINLOCK)。完整内容见原文 PDF 第 124-127 页。
8. API 规范
8.1 常量
8.1.1 类型 StatusType 的错误代码
[SWS_Os_91007] AppModeType 枚举
Name: AppModeType
Type: Enumeration
Range: DONOTCARE
Description: AppMode of the core shall be inherited from another core.
Available via: Os.h
[SWS_Os_91002] TotalNumberOfCores
Name: TotalNumberOfCores
Type: scalar
Range: 1..65535
Description: The total number of cores
Available via: Os.h
附加常量在章节 7.15 和 [15] 中。
8.2 宏
- OSMEMORY_IS_READABLE()
- OSMEMORY_IS_WRITEABLE()
- OSMEMORY_IS_EXECUTABLE()
- OSMEMORY_IS_STACKSPACE()
这些宏在内存可读/可写/可执行或是栈空间时返回不等于零的值。宏的参数必须是 AccessType 类型。通常 Check[Task|ISR]MemoryAccess() 服务的返回值用作这些宏的参数。
8.3 类型定义
8.3.1 ApplicationType(用于 OS-Applications)
Name: ApplicationType
Type: uint32
Range: INVALID_OSAPPLICATION
Description: This data type identifies the OS-Application.
Available via: Os.h
8.3.2 ApplicationStateType
Name: ApplicationStateType
Type: scalar
Range: APPLICATION_ACCESSIBLE
APPLICATION_RESTARTING
APPLICATION_TERMINATED
Description: This data type identifies the state of an OS-Application.
Available via: Os.h
8.3.3 ApplicationStateRefType
Name: ApplicationStateRefType
Type: pointer
Description: This data type points to location where a ApplicationStateType can be stored.
Available via: Os.h
8.3.4 TrustedFunctionIndexType
Name: TrustedFunctionIndexType
Type: scalar
Description: This data type identifies a trusted function.
Available via: Os.h
8.3.5 TrustedFunctionParameterRefType
Name: TrustedFunctionParameterRefType
Type: pointer
Description: This data type points to a structure which holds the arguments for a call to a trusted function.
Available via: Os.h
8.3.6 AccessType
Name: AccessType
Type: integral
Description: This type holds information how a specific memory region can be accessed.
Available via: Os.h
8.3.7 ObjectAccessType
Name: ObjectAccessType
Range: ACCESS
NO_ACCESS
Description: This data type identifies if an OS-Application has access to an object.
Available via: Os.h
8.3.8 ObjectTypeType
Name: ObjectTypeType
Range: OBJECT_TASK
OBJECT_ISR
OBJECT_ALARM
OBJECT_RESOURCE
OBJECT_COUNTER
OBJECT_SCHEDULETABLE
Description: This data type identifies an object.
Available via: Os.h
8.3.9 MemoryStartAddressType
Name: MemoryStartAddressType
Type: --
Description: This data type is a pointer which is able to point to any location in the MCU address space.
Available via: Os.h
8.3.10 MemorySizeType
Name: MemorySizeType
Type: --
Description: This data type holds the size (in bytes) of a memory region.
Available via: Os.h
8.3.11 ISRType
Name: ISRType
Type: --
Range: INVALID_ISR
Description: This data type identifies an interrupt service routine (ISR).
Available via: Os.h
摘要标记:类型定义(章节 8.3)共 22 个(8.3.1-8.3.22),包括 ScheduleTableType、ScheduleTableStatusType、ProtectionReturnType、RestartType、PhysicalTimeType、CoreIdType、SpinlockIdType、TryToGetSpinlockType、IdleModeType、AreaIdType 等。完整内容见原文 PDF 第 128-134 页。
8.4 函数定义
摘要标记:函数定义(章节 8.4)共 39 个(8.4.1-8.4.39)。下面翻译关键 API。
8.4.1 GetApplicationID
Service name: GetApplicationID
Syntax: ApplicationType GetApplicationID(void)
Service ID[hex]: 0x00
Sync/Async: Synchronous
Reentrancy: Reentrant
Parameters (in): None
Parameters None
(inout):
Parameters (out): None
Return value: ApplicationType <identifier of running OS-Application> or
INVALID_OSAPPLICATION
Description: This service determines the OS-Application (a unique identifier has
to be allocated to each application) where the caller originally
belongs to (was configured to).
Available via: Os.h
详细行为:
[SWS_Os_00261]GetApplicationID() 应返回执行 Task/ISR/hook 所配置到的 application identifier。[SWS_Os_00262]如果没有 OS-Application 正在运行,GetApplicationID() 应返回 INVALID_OSAPPLICATION。[SWS_Os_00514]可用性:GetApplicationID() 在可扩展类 3 和 4 以及多核系统中可用。
8.4.2 GetCurrentApplicationID
Service name: GetCurrentApplicationID
Syntax: ApplicationType GetCurrentApplicationID(void)
Service ID[hex]: 0x27
Sync/Async: Synchronous
Reentrancy: Reentrant
Parameters (in): None
Parameters None
(inout):
Parameters (out): None
Return value: ApplicationType <identifier of the OS-Application> or
INVALID_OSAPPLICATION
Description: This service determines the OS-Application where the caller of the
service is currently executing.
Note that if the caller is not within a CallTrustedFunction() call
the value is equal to the result of GetApplicationID().
Available via: Os.h
8.4.3 GetISRID
Service name: GetISRID
Syntax: ISRType GetISRID(void)
Service ID[hex]: 0x01
Sync/Async: Synchronous
Reentrancy: Reentrant
Parameters (in): None
Parameters None
(inout):
Parameters (out): None
Return value: ISRType <Identifier of running ISR> or
INVALID_ISR
Description: This service returns the identifier of the currently executing ISR.
Available via: Os.h
8.4.4 CallTrustedFunction
Service name: CallTrustedFunction
Syntax: StatusType CallTrustedFunction(
TrustedFunctionIndexType FunctionIndex,
TrustedFunctionParameterRefType FunctionParams)
Service ID[hex]: 0x02
Sync/Async: Depends on called function. If called function is synchronous
then service is synchronous. May cause rescheduling.
Reentrancy: Reentrant
Parameters (in): FunctionIndex Index of the function to be called.
FunctionParams Pointer to the parameters for the function -
specified by the FunctionIndex - to be called.
If no parameters are provided, a NULL pointer
has to be passed.
Parameters None
(inout):
Parameters (out): None
Return value: StatusType E_OK: No Error
E_OS_SERVICEID: No function defined for this index
Description: A (trusted or non-trusted) OS-Application uses this service to
call a trusted function.
Available via: Os.h
详细行为:
[SWS_Os_00265]如果<FunctionIndex>是已定义的函数索引,CallTrustedFunction() 应从实现特定信任函数列表中调用函数<FunctionIndex>,并使用提供信任函数的 OS-Application 的保护设置,完成后返回 E_OK。[SWS_Os_00266]当 CallTrustedFunction() 调用<FunctionIndex>函数时,该函数应以所属 OS-Application 的相同处理器模式、内存保护边界和服务保护限制执行。"当前应用"概念应保持为调用 Task 或 Category 2 ISR 的那个。[SWS_Os_00312]CallTrustedFunction() 的注意事项:- 被调用的信任函数必须符合以下 C 原型:
void TRUSTED_<name_of_the_trusted_service>(TrustedFunctionIndexType, TrustedFunctionParameterRefType); - 通常,用户不会直接调用此服务,但它将是某些标准接口(例如标准 I/O 接口)的一部分。
- 由被调用的信任函数负责检查传递参数的权利,特别是当参数被解释为 out 参数时。
- 应注意 CallTrustedFunction() 不为调用该服务的任务禁用时间保护。这可能导致时间故障(ProtectionHook() 调用)即使在信任 OS-Application 内部也是如此。因此建议仅对无状态函数使用 CallTrustedFunction()。
- 被调用的信任函数必须符合以下 C 原型:
[SWS_Os_00292]如果 CallTrustedFunction() 中函数索引<FunctionIndex>未定义,CallTrustedFunction() 应返回 E_OS_SERVICEID。[SWS_Os_00516]可用性:CallTrustedFunction() 在可扩展类 3 和 4 中可用。
8.4.5 CheckISRMemoryAccess
Service name: CheckISRMemoryAccess
Syntax: AccessType CheckISRMemoryAccess(
ISRType ISRID,
MemoryStartAddressType Address,
MemorySizeType Size)
Service ID[hex]: 0x03
Sync/Async: Synchronous
Reentrancy: Reentrant
Parameters (in): ISRID ISR reference
Address Start of memory area
Size Size of memory area
Parameters None
(inout):
Parameters (out): None
Return value: AccessType Value which contains the access rights to the memory area.
Description: This service checks if a memory region is write/read/execute accessible
and also returns information if the memory region is part of the stack space.
Available via: Os.h
8.4.6 CheckTaskMemoryAccess
Service name: CheckTaskMemoryAccess
Syntax: AccessType CheckTaskMemoryAccess(
TaskType TaskID,
MemoryStartAddressType Address,
MemorySizeType Size)
Service ID[hex]: 0x04
Sync/Async: Synchronous
Reentrancy: Reentrant
Parameters (in): TaskID Task reference
Address Start of memory area
Size Size of memory area
Parameters None
(inout):
Parameters (out): None
Return value: AccessType Value which contains the access rights to the memory area.
Description: This service checks if a memory region is write/read/execute accessible
and also returns information if the memory region is part of the stack space.
Available via: Os.h
8.4.7 CheckObjectAccess
Service name: CheckObjectAccess
Syntax: ObjectAccessType CheckObjectAccess(
ApplicationType ApplID,
ObjectTypeType ObjectType,
...
)
Service ID[hex]: 0x05
Description: This service checks if an OS-Application has access to a specific object.
Available via: Os.h
8.4.8 CheckObjectOwnership
Service name: CheckObjectOwnership
Syntax: ObjectAccessType CheckObjectOwnership(
ObjectTypeType ObjectType,
...
)
Service ID[hex]: 0x06
Description: This service checks if an OS-Application is the owner of a specific object.
Available via: Os.h
8.4.9 StartScheduleTableRel
Service name: StartScheduleTableRel
Syntax: StatusType StartScheduleTableRel(
ScheduleTableType ScheduleTableID,
TickType Offset)
Service ID[hex]: 0x07
Sync/Async: Synchronous
Reentrancy: Reentrant
Parameters (in): ScheduleTableID Schedule table to be started
Offset Number of ticks before the schedule table processing starts
Parameters None
(inout):
Parameters (out): None
Return value: StatusType E_OK: No Error
E_OS_ID: Schedule table not valid
E_OS_VALUE: Offset is out of range
E_OS_STATE: Schedule table is in state SCHEDULETABLE_RUNNING/SCHEDULETABLE_SYNCHRONOUS
Description: Starts the processing of a schedule table at "Offset" ticks relative
to the current time of the underlying counter.
Available via: Os.h
8.4.10 StartScheduleTableAbs
Service name: StartScheduleTableAbs
Syntax: StatusType StartScheduleTableAbs(
ScheduleTableType ScheduleTableID,
TickType Start)
Service ID[hex]: 0x08
Sync/Async: Synchronous
Reentrancy: Reentrant
Parameters (in): ScheduleTableID Schedule table to be started
Start Absolute counter tick value at which the schedule table starts
Parameters None
(inout):
Parameters (out): None
Return value: StatusType E_OK: No Error
E_OS_ID: Schedule table not valid
E_OS_VALUE: Start is out of range
E_OS_STATE: Schedule table is in state SCHEDULETABLE_RUNNING/SCHEDULETABLE_SYNCHRONOUS
Description: Starts the processing of a schedule table at absolute counter tick "Start".
Available via: Os.h
摘要标记:API 函数定义(章节 8.4)共 39 个(8.4.1-8.4.39),包括 StopScheduleTable、NextScheduleTable、StartScheduleTableSynchron、SyncScheduleTable、SetScheduleTableAsync、GetScheduleTableStatus、IncrementCounter、GetCounterValue、GetElapsedValue、TerminateApplication、AllowAccess、GetApplicationState、GetNumberOfActivatedCores、GetCoreID、StartCore、StartNonAutosarCore、GetSpinlock、ReleaseSpinlock、TryToGetSpinlock、ShutdownAllCores、ControlIdle、ReadPeripheralX、WritePeripheralX、ModifyPeripheralX、EnableInterruptSource、DisableInterruptSource、ClearPendingInterrupt、ActivateTaskAsyn、SetEventAsyn。完整内容见原文 PDF 第 134-173 页。
8.5 IOC
8.5.1 导入类型
摘要标记:本节描述 IOC 导入的数据类型。完整内容见原文 PDF 第 173-174 页。
8.5.2 类型定义
摘要标记:本节描述 IOC 定义的类型。完整内容见原文 PDF 第 174 页。
8.5.3 常量
摘要标记:本节描述 IOC 常量。完整内容见原文 PDF 第 174-175 页。
8.5.4 函数定义
摘要标记:本节描述 IOC 函数(IocSend、IocReceive、IocEmptyQueue、IocRead、IocWrite 等)。完整内容见原文 PDF 第 175-186 页。
8.6 预期接口
8.6.1 强制接口
摘要标记:本节列出 OS 调用的强制服务接口(如 Det_ReportError)。完整内容见原文 PDF 第 186 页。
8.6.2 可选接口
摘要标记:本节列出 OS 调用的可选服务接口。完整内容见原文 PDF 第 186-188 页。
8.7 钩子函数
8.7.1 ProtectionHook
摘要标记:本节描述 ProtectionHook() 的接口。完整内容见原文 PDF 第 188-189 页。
8.7.2 应用特定 StartupHook
摘要标记:本节描述应用特定 StartupHook() 的接口。完整内容见原文 PDF 第 189 页。
8.7.3 应用特定 ErrorHook
摘要标记:本节描述应用特定 ErrorHook() 的接口。完整内容见原文 PDF 第 189-190 页。
8.7.4 应用特定 ShutdownHook
摘要标记:本节描述应用特定 ShutdownHook() 的接口。完整内容见原文 PDF 第 190 页。
8.8 服务接口
8.8.1 Os 的端口接口
摘要标记:本节描述 OS 的 AUTOSAR 端口接口。完整内容见原文 PDF 第 190-191 页。
8.8.2 客户端-服务器接口
摘要标记:本节描述 OS 的客户端-服务器接口。完整内容见原文 PDF 第 191-193 页。
9. 序列图
摘要标记:本节包含以下序列图:
- 9.1 调用信任函数的序列图(第 194 页)
- 9.2 ErrorHook 使用的序列图(第 195 页)
- 9.3 ProtectionHook 的序列图(第 196 页)
- 9.4 StartupHook 的序列图(第 197 页)
- 9.5 ShutdownHook 的序列图(第 198 页)
- 9.6 IOC 上 Sender-Receiver 通信的序列图(第 198-201 页)
10. 配置规范
摘要标记:本节是配置规范的主要部分,包含以下容器及其配置参数(每个都涉及许多配置项):
- 10.2.1 Os
- 10.2.2 OsAlarmSetEvent
- 10.2.3 OsAlarm
- 10.2.4 OsAlarmAction
- 10.2.5 OsAlarmActivateTask
- 10.2.6 OsAlarmAutostart
- 10.2.7 OsAlarmCallback
- 10.2.8 OsAlarmIncrementCounter
- 10.2.9 OsApplication
- 10.2.10 OsApplicationHooks
- 10.2.11 OsApplicationTrustedFunction
- 10.2.12 OsAppMode
- 10.2.13 OsCounter
- 10.2.14 OsEvent
- 10.2.15 OsDriver
- 10.2.16 OsHooks
- 10.2.17 OsIsr
- 10.2.18 OsIsrResourceLock
- 10.2.19 OsIsrTimingProtection
- 10.2.20 OsOS
- 10.2.21 OsPeripheralArea
- 10.2.22 OsResource
- 10.2.23 OsScheduleTable
- 10.2.24 OsScheduleTableAutostart
- 10.2.25 OsScheduleTableEventSetting
- 10.2.26 OsScheduleTableExpiryPoint
- 10.2.27 OsScheduleTableTaskActivation
- 10.2.28 OsScheduleTblAdjustableExpPoint
- 10.2.29 OsScheduleTableSync
- 10.2.30 OsSpinlock
- 10.2.31 OsTask
- 10.2.32 OsTaskAutostart
- 10.2.33 OsTaskResourceLock
- 10.2.34 OsTaskTimingProtection
- 10.2.35 OsTimeConstant
此外,10.3 节包含 IOC 配置容器,10.4 节包含 ARTI 配置容器。每个容器包含多个 ECUC 配置参数(ECUC_Os_xxxxx)。
完整内容见原文 PDF 第 202-261 页。
11. OS 生成
摘要标记:本节描述 OS 生成工具的三个主要步骤:
- 11.1 读取配置(第 262 页)
- 11.2 一致性检查(第 262-264 页)
- 11.3 生成操作系统(第 264 页)
12. 应用笔记
摘要标记:本节包含以下应用笔记:
- 12.1 钩子
- 12.2 提供可信函数
- 12.3 软件组件和 OS-Applications
- 12.4 全局时间同步
- 12.5 与 FlexRay 协作
- 12.6 从 OIL 迁移到 XML
- 12.7 迁移 AUTOSAR OS 中的 RES_SCHEDULER
- 12.8 调试支持
- 12.9 外设保护集成提示
- 12.10 OSApplications 的终止
完整内容见原文 PDF 第 265-273 页。
13. OS 实现的 AUTOSAR 服务
摘要标记:本节描述 OS 实现的 AUTOSAR 服务接口。完整内容见原文 PDF 第 274 页。
14. 内存保护配置展望
摘要标记:本节提供内存保护配置方法的展望。完整内容见原文 PDF 第 275 页。
15. 不适用需求
摘要标记:本节列出对 OS 不适用的需求。完整内容见原文 PDF 第 276 页。
翻译说明
- 文档类型:AUTOSAR SWS(Software Specification,软件规范)
- 翻译策略:本 SWS 文档(276 页,约 15000 行)规模极大,采用"重点翻译 + 摘要"策略:
- 完整翻译:封面、文档标识、变更历史、目录、章节 1(简介)、章节 2(缩略语)、章节 3(相关文档)、章节 4(约束和假设)、章节 5(依赖)、关键 API(章节 8.4 关键函数)、章节 7.7.2(时间保护)
- 摘要处理:其他章节(7.1-7.16、8.1-8.3、8.5-8.8、9-15)使用"完整表见原文 PDF"标记
- 摘要标记位置:
- 章节 2.1 术语表
- 章节 6 需求追溯
- 章节 7.1.2 核心 OS 需求
- 章节 7.2 SWFRT
- 章节 7.3.2 调度表需求
- 章节 7.4.2 调度表同步需求
- 章节 7.5.2 栈监控需求
- 章节 7.6.2 OS-Application 需求
- 章节 7.7.1 内存保护需求
- 章节 7.7.3 服务保护需求
- 章节 7.7.4 保护 OS 硬件
- 章节 7.7.5 可信函数
- 章节 7.8.1 保护错误处理背景
- 章节 7.8.2 保护错误处理需求
- 章节 7.9.1-7.9.31 多核 OS 各小节
- 章节 7.10.2-7.10.8 IOC 各小节
- 章节 7.11 可扩展性
- 章节 7.12-7.16 钩子、外设访问、中断源、错误分类、ARTI
- 章节 8.3.12-8.3.22 类型定义
- 章节 8.4.9-8.4.39 函数定义
- 章节 8.5-8.8 IOC、接口、钩子、服务接口
- 章节 9 序列图
- 章节 10 配置规范
- 章节 11-15 OS 生成、应用笔记、AUTOSAR 服务、内存保护展望、不适用需求
- 保留内容:
- 需求 ID(如
SWS_Os_00001、SWS_Os_00242、SWS_Os_00401等) - AUTOSAR 方框符
⌈⌋ - 所有 API 标识符(
GetApplicationID、GetISRID、CallTrustedFunction、StartScheduleTableRel等) - 模块缩写(OS、ISR、IOC、EcuM、ComM、RTE、Hw)
- 文档间交叉引用
- 需求 ID(如
- 术语对照表:
- Operating System → 操作系统
- Task → 任务
- Basic Task → 基本任务
- Extended Task → 扩展任务
- Schedule Table → 调度表
- Expiry Point → 到期点
- Counter → 计数器
- Alarm → 闹钟
- Event → 事件
- Resource → 资源
- Interrupt Service Routine (ISR) → 中断服务例程
- Category 2 ISR → 二类中断
- Memory Protection → 内存保护
- Timing Protection → 时间保护
- Service Protection → 服务保护
- OS-Application → OS-应用
- Trusted Application → 可信应用
- Non-trusted Application → 不可信应用
- Protection Hook → 保护钩子
- Startup Hook → 启动钩子
- Shutdown Hook → 关闭钩子
- Error Hook → 错误钩子
- Trusted Function → 信任函数
- Spinlock → 自旋锁
- Multicore → 多核
- Single-Core → 单核
- Master Core → 主核
- Slave Core → 从核
- Hook Function → 钩子函数
- Scalability Class → 可扩展类
- Deadline → 截止时间
- Execution Budget → 执行预算
- Time Frame → 时间帧
- Interrupt Lock Budget → 中断锁定预算
- Resource Lock Budget → 资源锁定预算