[117] | 1 | /*
|
---|
| 2 | * TOPPERS ATK2
|
---|
| 3 | * Toyohashi Open Platform for Embedded Real-Time Systems
|
---|
| 4 | * Automotive Kernel Version 2
|
---|
| 5 | *
|
---|
| 6 | * Copyright (C) 2011-2015 by Center for Embedded Computing Systems
|
---|
| 7 | * Graduate School of Information Science, Nagoya Univ., JAPAN
|
---|
| 8 | * Copyright (C) 2011-2015 by FUJI SOFT INCORPORATED, JAPAN
|
---|
| 9 | * Copyright (C) 2011-2013 by Spansion LLC, USA
|
---|
| 10 | * Copyright (C) 2011-2015 by NEC Communication Systems, Ltd., JAPAN
|
---|
| 11 | * Copyright (C) 2011-2015 by Panasonic Advanced Technology Development Co., Ltd., JAPAN
|
---|
| 12 | * Copyright (C) 2011-2014 by Renesas Electronics Corporation, JAPAN
|
---|
| 13 | * Copyright (C) 2011-2015 by Sunny Giken Inc., JAPAN
|
---|
| 14 | * Copyright (C) 2011-2015 by TOSHIBA CORPORATION, JAPAN
|
---|
| 15 | * Copyright (C) 2011-2015 by Witz Corporation
|
---|
| 16 | * Copyright (C) 2014-2015 by AISIN COMCRUISE Co., Ltd., JAPAN
|
---|
| 17 | * Copyright (C) 2014-2015 by eSOL Co.,Ltd., JAPAN
|
---|
| 18 | * Copyright (C) 2014-2015 by SCSK Corporation, JAPAN
|
---|
| 19 | *
|
---|
| 20 | * 上記著作権者は,以下の(1)〜(4)の条件を満たす場合に限り,本ソフトウェ
|
---|
| 21 | * ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
|
---|
| 22 | * 変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
|
---|
| 23 | * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
|
---|
| 24 | * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
|
---|
| 25 | * スコード中に含まれていること.
|
---|
| 26 | * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
|
---|
| 27 | * 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
|
---|
| 28 | * 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
|
---|
| 29 | * の無保証規定を掲載すること.
|
---|
| 30 | * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
|
---|
| 31 | * 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
|
---|
| 32 | * と.
|
---|
| 33 | * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
|
---|
| 34 | * 作権表示,この利用条件および下記の無保証規定を掲載すること.
|
---|
| 35 | * (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
|
---|
| 36 | * 報告すること.
|
---|
| 37 | * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
|
---|
| 38 | * 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
|
---|
| 39 | * また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
|
---|
| 40 | * 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
|
---|
| 41 | * 免責すること.
|
---|
| 42 | *
|
---|
| 43 | * 本ソフトウェアは,AUTOSAR(AUTomotive Open System ARchitecture)仕
|
---|
| 44 | * 様に基づいている.上記の許諾は,AUTOSARの知的財産権を許諾するもので
|
---|
| 45 | * はない.AUTOSARは,AUTOSAR仕様に基づいたソフトウェアを商用目的で利
|
---|
| 46 | * 用する者に対して,AUTOSARパートナーになることを求めている.
|
---|
| 47 | *
|
---|
| 48 | * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
|
---|
| 49 | * よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
|
---|
| 50 | * に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
|
---|
| 51 | * アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
|
---|
| 52 | * の責任を負わない.
|
---|
| 53 | *
|
---|
| 54 | * $Id: Os.h 187 2015-06-25 03:39:04Z t_ishikawa $
|
---|
| 55 | */
|
---|
| 56 |
|
---|
| 57 | /*
|
---|
| 58 | * ATK2 OSヘッダファイル
|
---|
| 59 | *
|
---|
| 60 | * ATK2がサポートするシステムサービスの宣言と,必要なデー
|
---|
| 61 | * タ型,定数,マクロの定義を含むヘッダファイル
|
---|
| 62 | *
|
---|
| 63 | * アセンブリ言語のソースファイルからこのファイルをインクルードする時
|
---|
| 64 | * は,TOPPERS_MACRO_ONLYを定義しておく
|
---|
| 65 | * これにより,マクロ定義以外を除くようになっている
|
---|
| 66 | *
|
---|
| 67 | * このファイルをインクルードする前にインクルードしておくべきファイル
|
---|
| 68 | * はない
|
---|
| 69 | */
|
---|
| 70 |
|
---|
| 71 | #ifndef TOPPERS_OS_H
|
---|
| 72 | #define TOPPERS_OS_H
|
---|
| 73 |
|
---|
| 74 | #ifdef TOPPERS_TRUSTED
|
---|
| 75 | #define TOPPERS_SVC_FUNCCALL
|
---|
| 76 | #endif
|
---|
| 77 |
|
---|
| 78 | #if defined(TOPPERS_TRUSTED) && defined(TOPPERS_NON_TRUSTED)
|
---|
| 79 | #error "both TOPPERS_TRUSTED and TOPPERS_NON_TRUSTED are defined!"
|
---|
| 80 | #endif
|
---|
| 81 |
|
---|
| 82 | /*
|
---|
| 83 | * 共通のデータ型・定数・マクロ
|
---|
| 84 | */
|
---|
| 85 | #include "Std_Types.h"
|
---|
| 86 | #include "MemMap.h"
|
---|
| 87 | #include "Rte_Os_Type.h"
|
---|
| 88 |
|
---|
| 89 | #if !defined(TOPPERS_CFG1_OUT) && !defined(OMIT_INCLUDE_OS_CFG)
|
---|
| 90 | #include "Os_Cfg.h"
|
---|
| 91 | #endif
|
---|
| 92 |
|
---|
| 93 | /*
|
---|
| 94 | * ターゲット依存部
|
---|
| 95 | */
|
---|
| 96 | #include "target_kernel.h"
|
---|
| 97 |
|
---|
| 98 | #ifndef TOPPERS_MACRO_ONLY
|
---|
| 99 |
|
---|
| 100 | /*
|
---|
| 101 | * データ型の定義
|
---|
| 102 | */
|
---|
| 103 |
|
---|
| 104 | /*
|
---|
| 105 | * オブジェクト番号の型定義
|
---|
| 106 | */
|
---|
| 107 | typedef uint8 TaskStateType; /* タスク状態 */
|
---|
| 108 | typedef uint32 EventMaskType; /* イベントマスク */
|
---|
| 109 | typedef uint32 TickType; /* カウンタ値(ティック)*/
|
---|
| 110 | typedef uint32 AppModeType; /* アプリケーションモード */
|
---|
| 111 | typedef uint8 OSServiceIdType; /* システムサービスID */
|
---|
| 112 | typedef uint8 ScheduleTableStatusType; /* スケジュールテーブル状態 */
|
---|
| 113 | typedef uint8 ProtectionReturnType; /* プロテクションフックからの返り値 */
|
---|
| 114 | typedef uintptr MemorySizeType; /* メモリ領域サイズ */
|
---|
| 115 | typedef uint8 ApplicationType; /* OSアプリケーションID */
|
---|
| 116 | typedef uint8 ObjectTypeType; /* OSオブジェクト種別 */
|
---|
| 117 | typedef uint8 ApplicationStateType; /* OSアプリケーション状態 */
|
---|
| 118 | typedef uint8 AccessType; /* メモリ領域アクセス権 */
|
---|
| 119 | typedef boolean ObjectAccessType; /* OSオブジェクトアクセス権 */
|
---|
| 120 | typedef uint8 RestartType; /* OSAPリスタート属性 */
|
---|
| 121 |
|
---|
| 122 | typedef struct {
|
---|
| 123 | TickType maxallowedvalue; /* カウンタ指定の最大値 */
|
---|
| 124 | TickType ticksperbase; /* OSでは使用せず,ユーザが自由に使用する値 */
|
---|
| 125 | TickType mincycle; /* サイクル指定の最小値 */
|
---|
| 126 | } AlarmBaseType;
|
---|
| 127 |
|
---|
| 128 | /*
|
---|
| 129 | * 最適化するため,依存部再定義できる型
|
---|
| 130 | */
|
---|
| 131 | #ifndef OMIT_DATA_TYPE
|
---|
| 132 | typedef uint32 TimeType; /* 時間 */
|
---|
| 133 | typedef uint32 AlarmType; /* アラームID */
|
---|
| 134 | typedef uint32 ResourceType; /* リソースID */
|
---|
| 135 | typedef uint32 TaskType; /* タスクID */
|
---|
| 136 | typedef uint32 ISRType; /* ISR ID */
|
---|
| 137 | typedef uint32 CounterType; /* カウンタID */
|
---|
| 138 | typedef uint32 ScheduleTableType; /* スケジュールテーブルID */
|
---|
| 139 | typedef float32 PhysicalTimeType; /* (ティックから時間に換算用)時間 */
|
---|
| 140 | typedef uint32 IocType; /* IOC ID */
|
---|
| 141 | typedef uint8 SenderIdType; /* Sender ID */
|
---|
| 142 | typedef uint32 TrustedFunctionIndexType; /* Trusted Function Index */
|
---|
| 143 | #endif /* OMIT_DATA_TYPE */
|
---|
| 144 |
|
---|
| 145 | typedef AlarmBaseType * AlarmBaseRefType;
|
---|
| 146 | typedef TaskType * TaskRefType;
|
---|
| 147 | typedef TaskStateType * TaskStateRefType;
|
---|
| 148 | typedef EventMaskType * EventMaskRefType;
|
---|
| 149 | typedef TickType * TickRefType;
|
---|
| 150 | typedef ScheduleTableStatusType * ScheduleTableStatusRefType;
|
---|
| 151 | typedef ApplicationStateType * ApplicationStateRefType;
|
---|
| 152 | typedef void * MemoryStartAddressType; /* メモリ領域先頭 */
|
---|
| 153 | typedef void * TrustedFunctionParameterRefType; /* Trusted Function Parameter */
|
---|
| 154 |
|
---|
| 155 | /*
|
---|
| 156 | * 保護違反を起こした処理単位の型
|
---|
| 157 | */
|
---|
| 158 | typedef uint8 FaultyContextType;
|
---|
| 159 |
|
---|
| 160 | /*
|
---|
| 161 | * OSオブジェクト宣言用のマクロ
|
---|
| 162 | */
|
---|
| 163 | #define DeclareTask(TaskIdentifier)
|
---|
| 164 | #define DeclareResource(ResourceIdentifier)
|
---|
| 165 | #define DeclareEvent(EventIdentifier)
|
---|
| 166 | #define DeclareAlarm(AlarmIdentifier)
|
---|
| 167 |
|
---|
| 168 | /*
|
---|
| 169 | * メインルーチン定義用のマクロ
|
---|
| 170 | */
|
---|
| 171 | #define TASK(TaskName) void TaskMain ## TaskName(void)
|
---|
| 172 | #define ISR(ISRName) void ISRMain ## ISRName(void)
|
---|
| 173 | #ifndef C1ISR
|
---|
| 174 | #define C1ISR(ISRName) void C1ISRMain ## ISRName(void)
|
---|
| 175 | #endif /* C1ISR */
|
---|
| 176 |
|
---|
| 177 | #define TRUSTEDFUNCTION(TrustedFunctionName, FunctionIndex, FunctionParams) \
|
---|
| 178 | StatusType TrustedFunctionName( \
|
---|
| 179 | TrustedFunctionIndexType FunctionIndex, \
|
---|
| 180 | TrustedFunctionParameterRefType FunctionParams \
|
---|
| 181 | )
|
---|
| 182 |
|
---|
| 183 | /*
|
---|
| 184 | * メモリ領域確保のための型定義
|
---|
| 185 | */
|
---|
| 186 | #ifndef TOPPERS_STK_T
|
---|
| 187 | #define TOPPERS_STK_T sintptr
|
---|
| 188 | #endif /* TOPPERS_STK_T */
|
---|
| 189 | typedef TOPPERS_STK_T StackType; /* スタック領域を確保するための型 */
|
---|
| 190 |
|
---|
| 191 | /*
|
---|
| 192 | * システムサービスパラメータ取得のための定義
|
---|
| 193 | */
|
---|
| 194 | typedef union {
|
---|
| 195 | TaskType tskid;
|
---|
| 196 | TaskRefType p_tskid;
|
---|
| 197 | TaskStateRefType p_stat;
|
---|
| 198 | ResourceType resid;
|
---|
| 199 | EventMaskType mask;
|
---|
| 200 | EventMaskRefType p_mask;
|
---|
| 201 | AlarmType almid;
|
---|
| 202 | AlarmBaseRefType p_info;
|
---|
| 203 | TickRefType p_tick;
|
---|
| 204 | TickRefType p_val;
|
---|
| 205 | TickRefType p_eval;
|
---|
| 206 | TickType incr;
|
---|
| 207 | TickType cycle;
|
---|
| 208 | TickType start;
|
---|
| 209 | AppModeType mode;
|
---|
| 210 | CounterType cntid;
|
---|
| 211 | ScheduleTableType schtblid;
|
---|
| 212 | TickType offset;
|
---|
| 213 | ScheduleTableType schtblid_from;
|
---|
| 214 | ScheduleTableType schtblid_to;
|
---|
| 215 | ScheduleTableStatusRefType p_schtblstate;
|
---|
| 216 | StatusType error;
|
---|
| 217 | ISRType isrid;
|
---|
| 218 | IocType iocid;
|
---|
| 219 | SenderIdType senderid;
|
---|
| 220 | TrustedFunctionIndexType tfnid;
|
---|
| 221 | TrustedFunctionParameterRefType tfnpr;
|
---|
| 222 | MemoryStartAddressType adr;
|
---|
| 223 | MemorySizeType sz;
|
---|
| 224 | ApplicationType applid;
|
---|
| 225 | ApplicationStateRefType p_appstat;
|
---|
| 226 | RestartType restartoption;
|
---|
| 227 | } _ErrorHook_Par;
|
---|
| 228 |
|
---|
| 229 |
|
---|
| 230 | /*
|
---|
| 231 | * メモリ領域確保のためのマクロ
|
---|
| 232 | *
|
---|
| 233 | * 以下のTOPPERS_COUNT_SZとTOPPERS_ROUND_SZの定義は,unitが2の巾乗であ
|
---|
| 234 | * ることを仮定している.
|
---|
| 235 | */
|
---|
| 236 | #ifndef TOPPERS_COUNT_SZ
|
---|
| 237 | #define TOPPERS_COUNT_SZ(sz, unit) (((sz) + (unit) - (1U)) / (unit))
|
---|
| 238 | #endif /* TOPPERS_COUNT_SZ */
|
---|
| 239 | #ifndef TOPPERS_ROUND_SZ
|
---|
| 240 | #define TOPPERS_ROUND_SZ(sz, unit) (((sz) + (unit) - (1U)) & (~((unit) - (1U))))
|
---|
| 241 | #endif /* TOPPERS_ROUND_SZ */
|
---|
| 242 |
|
---|
| 243 | #define COUNT_STK_T(sz) (TOPPERS_COUNT_SZ((sz), sizeof(StackType)))
|
---|
| 244 | #define ROUND_STK_T(sz) (TOPPERS_ROUND_SZ((sz), sizeof(StackType)))
|
---|
| 245 |
|
---|
| 246 | /*
|
---|
| 247 | * フックルーチン
|
---|
| 248 | */
|
---|
| 249 | #ifdef CFG_USE_SYSTEM_ERRORHOOK
|
---|
| 250 | extern void ErrorHook(StatusType Error);
|
---|
| 251 | #endif /* CFG_USE_SYSTEM_ERRORHOOK */
|
---|
| 252 |
|
---|
| 253 | #ifdef CFG_USE_PRETASKHOOK
|
---|
| 254 | extern void PreTaskHook(void);
|
---|
| 255 | #endif /* CFG_USE_PRETASKHOOK */
|
---|
| 256 |
|
---|
| 257 | #ifdef CFG_USE_POSTTASKHOOK
|
---|
| 258 | extern void PostTaskHook(void);
|
---|
| 259 | #endif /* CFG_USE_POSTTASKHOOK */
|
---|
| 260 |
|
---|
| 261 | #ifdef CFG_USE_SYSTEM_STARTUPHOOK
|
---|
| 262 | extern void StartupHook(void);
|
---|
| 263 | #endif /* CFG_USE_SYSTEM_STARTUPHOOK */
|
---|
| 264 |
|
---|
| 265 | #ifdef CFG_USE_SYSTEM_SHUTDOWNHOOK
|
---|
| 266 | extern void ShutdownHook(StatusType Error);
|
---|
| 267 | #endif /* CFG_USE_SYSTEM_SHUTDOWNHOOK */
|
---|
| 268 |
|
---|
| 269 | #ifdef CFG_USE_PROTECTIONHOOK
|
---|
| 270 | extern ProtectionReturnType ProtectionHook(StatusType FatalError);
|
---|
| 271 | #endif /* CFG_USE_PROTECTIONHOOK */
|
---|
| 272 |
|
---|
| 273 | /*
|
---|
| 274 | * ライブラリで提供するシステムサービス
|
---|
| 275 | */
|
---|
| 276 | extern ObjectAccessType CheckObjectAccess(ApplicationType ApplID, ObjectTypeType ObjectType, ...);
|
---|
| 277 | extern ApplicationType CheckObjectOwnership(ObjectTypeType ObjectType, ...);
|
---|
| 278 |
|
---|
| 279 | /*
|
---|
| 280 | * ファイル名,行番号の参照用の変数
|
---|
| 281 | */
|
---|
| 282 | extern const char8 *fatal_file_name; /* ファイル名 */
|
---|
| 283 | extern sint32 fatal_line_num; /* 行番号 */
|
---|
| 284 |
|
---|
| 285 | #endif /* TOPPERS_MACRO_ONLY */
|
---|
| 286 |
|
---|
| 287 | /*
|
---|
| 288 | * システムサービス呼出しのための定義と宣言
|
---|
| 289 | */
|
---|
| 290 | #include "kernel_fncode.h" /* 機能コードの定義 */
|
---|
| 291 | #include "svc_funccall.h" /* 関数呼出しによる呼出し */
|
---|
| 292 | #include "target_svc.h" /* ソフトウェア割込みによる呼出し */
|
---|
| 293 |
|
---|
| 294 | #if !defined(TOPPERS_CFG1_OUT) && !defined(OMIT_INCLUDE_OS_CFG) && !defined(OMIT_INCLUDE_OS_LCFG)
|
---|
| 295 | #include "Os_Lcfg.h"
|
---|
| 296 | #endif
|
---|
| 297 |
|
---|
| 298 | /*
|
---|
| 299 | * OSのエラーコード
|
---|
| 300 | */
|
---|
| 301 | #define E_OS_ACCESS UINT_C(1)
|
---|
| 302 | #define E_OS_CALLEVEL UINT_C(2)
|
---|
| 303 | #define E_OS_ID UINT_C(3)
|
---|
| 304 | #define E_OS_LIMIT UINT_C(4)
|
---|
| 305 | #define E_OS_NOFUNC UINT_C(5)
|
---|
| 306 | #define E_OS_RESOURCE UINT_C(6)
|
---|
| 307 | #define E_OS_STATE UINT_C(7)
|
---|
| 308 | #define E_OS_VALUE UINT_C(8)
|
---|
| 309 | #define E_OS_SERVICEID UINT_C(9)
|
---|
| 310 | #define E_OS_ILLEGAL_ADDRESS UINT_C(10)
|
---|
| 311 | #define E_OS_MISSINGEND UINT_C(11)
|
---|
| 312 | #define E_OS_DISABLEDINT UINT_C(12)
|
---|
| 313 | #define E_OS_STACKFAULT UINT_C(13)
|
---|
| 314 | #define E_OS_PROTECTION_MEMORY UINT_C(14)
|
---|
| 315 | #define E_OS_PROTECTION_TIME_TASK UINT_C(15)
|
---|
| 316 | #define E_OS_PROTECTION_TIME_ISR UINT_C(16)
|
---|
| 317 | #define E_OS_PROTECTION_ARRIVAL_TASK UINT_C(17)
|
---|
| 318 | #define E_OS_PROTECTION_ARRIVAL_ISR UINT_C(18)
|
---|
| 319 | #define E_OS_PROTECTION_LOCKED_RESOURCE UINT_C(19)
|
---|
| 320 | #define E_OS_PROTECTION_LOCKED_OSINT UINT_C(20)
|
---|
| 321 | #define E_OS_PROTECTION_LOCKED_ALLINT UINT_C(21)
|
---|
| 322 | #define E_OS_PROTECTION_EXCEPTION UINT_C(22)
|
---|
| 323 | #define E_OS_PROTECTION_FATAL UINT_C(23)
|
---|
| 324 | #define E_OS_MODE UINT_C(24)
|
---|
| 325 | #define E_OS_SHUTDOWN_FATAL UINT_C(25)
|
---|
| 326 | #define E_OS_PARAM_POINTER UINT_C(26)
|
---|
| 327 | #define E_OS_SYS_ASSERT_FATAL UINT_C(27)
|
---|
| 328 | #define E_OS_STACKINSUFFICIENT UINT_C(28)
|
---|
| 329 |
|
---|
| 330 | /* AUTOSAR仕様R4.0.3との互換性考慮 */
|
---|
| 331 | #define OS_E_PARAM_POINTER E_OS_PARAM_POINTER
|
---|
| 332 |
|
---|
| 333 | #define ERRCODE_NUM UINT_C(28) /* エラーコード数 */
|
---|
| 334 | /*
|
---|
| 335 | * IOCのエラーコード
|
---|
| 336 | */
|
---|
| 337 | #define IOC_E_OK UINT_C(0)
|
---|
| 338 | #define IOC_E_NOK UINT_C(1)
|
---|
| 339 | #define IOC_E_LIMIT UINT_C(130)
|
---|
| 340 | #define IOC_E_LOST_DATA UINT_C(64)
|
---|
| 341 | #define IOC_E_NO_DATA UINT_C(131)
|
---|
| 342 |
|
---|
| 343 | /*
|
---|
| 344 | * その他の定数値
|
---|
| 345 | */
|
---|
| 346 | #define UINT32_INVALID UINT_C(0xffffffff)
|
---|
| 347 | #define UINT8_INVALID UINT_C(0xff)
|
---|
| 348 |
|
---|
| 349 | #define SUSPENDED ((TaskStateType) 0) /* 休止状態 */
|
---|
| 350 | #define RUNNING ((TaskStateType) 1) /* 実行状態 */
|
---|
| 351 | #define READY ((TaskStateType) 2) /* 実行可能状態 */
|
---|
| 352 | #define WAITING ((TaskStateType) 3) /* 待ち状態 */
|
---|
| 353 |
|
---|
| 354 | /*
|
---|
| 355 | * 最適化するため,依存部での再定義が必要
|
---|
| 356 | */
|
---|
| 357 | #ifndef OMIT_DATA_TYPE
|
---|
| 358 | #define INVALID_TASK ((TaskType) UINT32_INVALID)
|
---|
| 359 | #define INVALID_ISR ((ISRType) UINT32_INVALID)
|
---|
| 360 | #endif /* OMIT_DATA_TYPE */
|
---|
| 361 | #define INVALID_APPMODETYPE ((AppModeType) UINT32_INVALID)
|
---|
| 362 | #define INVALID_OSAPPLICATION ((ApplicationType) UINT8_INVALID)
|
---|
| 363 |
|
---|
| 364 | /*
|
---|
| 365 | * スケジュールテーブルのステータス定義
|
---|
| 366 | */
|
---|
| 367 | #define SCHEDULETABLE_STOPPED ((ScheduleTableStatusType) 0x01)
|
---|
| 368 | #define SCHEDULETABLE_NEXT ((ScheduleTableStatusType) 0x02)
|
---|
| 369 | #define SCHEDULETABLE_WAITING ((ScheduleTableStatusType) 0x04)
|
---|
| 370 | #define SCHEDULETABLE_RUNNING ((ScheduleTableStatusType) 0x08)
|
---|
| 371 | #define SCHEDULETABLE_RUNNING_AND_SYNCHRONOUS ((ScheduleTableStatusType) 0x10)
|
---|
| 372 |
|
---|
| 373 | /*
|
---|
| 374 | * OSアプリケーションの状態
|
---|
| 375 | */
|
---|
| 376 | #define APPLICATION_ACCESSIBLE ((ApplicationStateType) 0) /* 利用可能状態 */
|
---|
| 377 | #define APPLICATION_RESTARTING ((ApplicationStateType) 1) /* 再起動状態 */
|
---|
| 378 | #define APPLICATION_TERMINATED ((ApplicationStateType) 2) /* アプリケーション終了状態 */
|
---|
| 379 |
|
---|
| 380 | /*
|
---|
| 381 | * アクセス情報
|
---|
| 382 | */
|
---|
| 383 | #define ACCESS (TRUE)
|
---|
| 384 | #define NO_ACCESS (FALSE)
|
---|
| 385 |
|
---|
| 386 | /*
|
---|
| 387 | * システムサービスID
|
---|
| 388 | */
|
---|
| 389 | #define OSServiceId_GetApplicationID ((OSServiceIdType) 0x00)
|
---|
| 390 | #define OSServiceId_GetISRID ((OSServiceIdType) 0x01)
|
---|
| 391 | #define OSServiceId_CallTrustedFunction ((OSServiceIdType) 0x02)
|
---|
| 392 | #define OSServiceId_CheckISRMemoryAccess ((OSServiceIdType) 0x03)
|
---|
| 393 | #define OSServiceId_CheckTaskMemoryAccess ((OSServiceIdType) 0x04)
|
---|
| 394 | #define OSServiceId_StartScheduleTableRel ((OSServiceIdType) 0x07)
|
---|
| 395 | #define OSServiceId_StartScheduleTableAbs ((OSServiceIdType) 0x08)
|
---|
| 396 | #define OSServiceId_StopScheduleTable ((OSServiceIdType) 0x09)
|
---|
| 397 | #define OSServiceId_NextScheduleTable ((OSServiceIdType) 0x0a)
|
---|
| 398 | #define OSServiceId_GetScheduleTableStatus ((OSServiceIdType) 0x0e)
|
---|
| 399 | #define OSServiceId_IncrementCounter ((OSServiceIdType) 0x0f)
|
---|
| 400 | #define OSServiceId_GetCounterValue ((OSServiceIdType) 0x10)
|
---|
| 401 | #define OSServiceId_GetElapsedValue ((OSServiceIdType) 0x11)
|
---|
| 402 | #define OSServiceId_TerminateApplication ((OSServiceIdType) 0x12)
|
---|
| 403 | #define OSServiceId_AllowAccess ((OSServiceIdType) 0x13)
|
---|
| 404 | #define OSServiceId_GetApplicationState ((OSServiceIdType) 0x14)
|
---|
| 405 | #define IOCServiceId_IOC_Send ((OSServiceIdType) 0x1e)
|
---|
| 406 | #define IOCServiceId_IOC_Write ((OSServiceIdType) 0x1f)
|
---|
| 407 | #define IOCServiceId_IOC_SendGroup ((OSServiceIdType) 0x20)
|
---|
| 408 | #define IOCServiceId_IOC_WriteGroup ((OSServiceIdType) 0x21)
|
---|
| 409 | #define IOCServiceId_IOC_Receive ((OSServiceIdType) 0x22)
|
---|
| 410 | #define IOCServiceId_IOC_Read ((OSServiceIdType) 0x23)
|
---|
| 411 | #define IOCServiceId_IOC_ReceiveGroup ((OSServiceIdType) 0x24)
|
---|
| 412 | #define IOCServiceId_IOC_ReadGroup ((OSServiceIdType) 0x25)
|
---|
| 413 | #define IOCServiceId_IOC_EmptyQueue ((OSServiceIdType) 0x26)
|
---|
| 414 |
|
---|
| 415 | #define OSServiceId_EnableInterruptSource ((OSServiceIdType) 0xa0)
|
---|
| 416 | #define OSServiceId_DisableInterruptSource ((OSServiceIdType) 0xa1)
|
---|
| 417 | #define OSServiceId_CheckTaskAccess ((OSServiceIdType) 0xa2)
|
---|
| 418 | #define OSServiceId_CheckISRAccess ((OSServiceIdType) 0xa3)
|
---|
| 419 | #define OSServiceId_CheckAlarmAccess ((OSServiceIdType) 0xa4)
|
---|
| 420 | #define OSServiceId_CheckResourceAccess ((OSServiceIdType) 0xa5)
|
---|
| 421 | #define OSServiceId_CheckCounterAccess ((OSServiceIdType) 0xa6)
|
---|
| 422 | #define OSServiceId_CheckScheduleTableAccess ((OSServiceIdType) 0xa7)
|
---|
| 423 | #define OSServiceId_CheckTaskOwnership ((OSServiceIdType) 0xa9)
|
---|
| 424 | #define OSServiceId_CheckISROwnership ((OSServiceIdType) 0xaa)
|
---|
| 425 | #define OSServiceId_CheckAlarmOwnership ((OSServiceIdType) 0xab)
|
---|
| 426 | #define OSServiceId_CheckCounterOwnership ((OSServiceIdType) 0xac)
|
---|
| 427 | #define OSServiceId_CheckScheduleTableOwnership ((OSServiceIdType) 0xad)
|
---|
| 428 | #define OSServiceId_TaskMissingEnd ((OSServiceIdType) 0xaf)
|
---|
| 429 | #define OSServiceId_ISRMissingEnd ((OSServiceIdType) 0xb0)
|
---|
| 430 | #define OSServiceId_HookMissingEnd ((OSServiceIdType) 0xb1)
|
---|
| 431 |
|
---|
| 432 | #define OSServiceId_ActivateTask ((OSServiceIdType) 0xe0)
|
---|
| 433 | #define OSServiceId_TerminateTask ((OSServiceIdType) 0xe1)
|
---|
| 434 | #define OSServiceId_ChainTask ((OSServiceIdType) 0xe2)
|
---|
| 435 | #define OSServiceId_Schedule ((OSServiceIdType) 0xe3)
|
---|
| 436 | #define OSServiceId_GetTaskID ((OSServiceIdType) 0xe4)
|
---|
| 437 | #define OSServiceId_GetTaskState ((OSServiceIdType) 0xe5)
|
---|
| 438 | #define OSServiceId_EnableAllInterrupts ((OSServiceIdType) 0xe6)
|
---|
| 439 | #define OSServiceId_DisableAllInterrupts ((OSServiceIdType) 0xe7)
|
---|
| 440 | #define OSServiceId_ResumeAllInterrupts ((OSServiceIdType) 0xe8)
|
---|
| 441 | #define OSServiceId_SuspendAllInterrupts ((OSServiceIdType) 0xe9)
|
---|
| 442 | #define OSServiceId_ResumeOSInterrupts ((OSServiceIdType) 0xea)
|
---|
| 443 | #define OSServiceId_SuspendOSInterrupts ((OSServiceIdType) 0xeb)
|
---|
| 444 | #define OSServiceId_GetResource ((OSServiceIdType) 0xec)
|
---|
| 445 | #define OSServiceId_ReleaseResource ((OSServiceIdType) 0xed)
|
---|
| 446 | #define OSServiceId_SetEvent ((OSServiceIdType) 0xee)
|
---|
| 447 | #define OSServiceId_ClearEvent ((OSServiceIdType) 0xef)
|
---|
| 448 | #define OSServiceId_GetEvent ((OSServiceIdType) 0xf0)
|
---|
| 449 | #define OSServiceId_WaitEvent ((OSServiceIdType) 0xf1)
|
---|
| 450 | #define OSServiceId_GetAlarmBase ((OSServiceIdType) 0xf2)
|
---|
| 451 | #define OSServiceId_GetAlarm ((OSServiceIdType) 0xf3)
|
---|
| 452 | #define OSServiceId_SetRelAlarm ((OSServiceIdType) 0xf4)
|
---|
| 453 | #define OSServiceId_SetAbsAlarm ((OSServiceIdType) 0xf5)
|
---|
| 454 | #define OSServiceId_CancelAlarm ((OSServiceIdType) 0xf6)
|
---|
| 455 | #define OSServiceId_GetActiveApplicationMode ((OSServiceIdType) 0xf7)
|
---|
| 456 | #define OSServiceId_StartOS ((OSServiceIdType) 0xf8)
|
---|
| 457 | #define OSServiceId_ShutdownOS ((OSServiceIdType) 0xf9)
|
---|
| 458 |
|
---|
| 459 | #define OSServiceId_INVALID ((OSServiceIdType) 0xff) /* 無効なシステムサービスID */
|
---|
| 460 |
|
---|
| 461 | /*
|
---|
| 462 | * 保護違反を起こした処理単位の定義
|
---|
| 463 | */
|
---|
| 464 | #define FC_INVALID UINT_C(0x00) /* 保護違反を起こした処理単位が特定できない */
|
---|
| 465 | #define FC_TASK UINT_C(0x01) /* 保護違反を起こした処理単位がタスク */
|
---|
| 466 | #define FC_C2ISR UINT_C(0x02) /* 保護違反を起こした処理単位がC2ISR */
|
---|
| 467 | #define FC_SYSTEM_HOOK UINT_C(0x03) /* 保護違反を起こした処理単位がシステム定義のフック */
|
---|
| 468 | #define FC_OSAP_HOOK UINT_C(0x04) /* 保護違反を起こした処理単位がOSAP固有のフック */
|
---|
| 469 | #define FC_TRUSTED_FUNC UINT_C(0x05) /* 保護違反を起こした処理単位が信頼関数 */
|
---|
| 470 |
|
---|
| 471 | /*
|
---|
| 472 | * システムサービスパラメータ取得のための定義
|
---|
| 473 | */
|
---|
| 474 | #ifndef TOPPERS_MACRO_ONLY
|
---|
| 475 |
|
---|
| 476 | /*
|
---|
| 477 | * エラーフックOFF時,サービスID取得とパラメータ取得もOFFになる
|
---|
| 478 | */
|
---|
| 479 | #ifdef CFG_USE_ERRORHOOK
|
---|
| 480 |
|
---|
| 481 | #ifdef CFG_USE_GETSERVICEID
|
---|
| 482 | extern OSServiceIdType _errorhook_svcid;
|
---|
| 483 | #endif /* CFG_USE_GETSERVICEID */
|
---|
| 484 |
|
---|
| 485 | #ifdef CFG_USE_PARAMETERACCESS
|
---|
| 486 | extern _ErrorHook_Par errorhook_par1;
|
---|
| 487 | extern _ErrorHook_Par errorhook_par2;
|
---|
| 488 | extern _ErrorHook_Par errorhook_par3;
|
---|
| 489 | #endif /* CFG_USE_PARAMETERACCESS */
|
---|
| 490 |
|
---|
| 491 | #endif /* CFG_USE_ERRORHOOK */
|
---|
| 492 |
|
---|
| 493 | #endif /* TOPPERS_MACRO_ONLY */
|
---|
| 494 |
|
---|
| 495 | /*
|
---|
| 496 | * エラーフックOFF時,サービスID取得とパラメータ取得もOFFになる
|
---|
| 497 | */
|
---|
| 498 | #ifdef CFG_USE_ERRORHOOK
|
---|
| 499 |
|
---|
| 500 | /*
|
---|
| 501 | * マクロの定義
|
---|
| 502 | */
|
---|
| 503 | #ifdef CFG_USE_GETSERVICEID
|
---|
| 504 | #define OSErrorGetServiceId() (_errorhook_svcid)
|
---|
| 505 | #endif /* CFG_USE_GETSERVICEID */
|
---|
| 506 |
|
---|
| 507 | /*
|
---|
| 508 | * エラーを引き起こしたシステムサービスID
|
---|
| 509 | */
|
---|
| 510 | #ifdef CFG_USE_PARAMETERACCESS
|
---|
| 511 | #define OSError_StartOS_Mode() (errorhook_par1.mode)
|
---|
| 512 | #define OSError_ActivateTask_TaskID() (errorhook_par1.tskid)
|
---|
| 513 | #define OSError_ChainTask_TaskID() (errorhook_par1.tskid)
|
---|
| 514 | #define OSError_GetTaskID_TaskID() (errorhook_par1.p_tskid)
|
---|
| 515 | #define OSError_GetTaskState_TaskID() (errorhook_par1.tskid)
|
---|
| 516 | #define OSError_GetTaskState_State() (errorhook_par2.p_stat)
|
---|
| 517 | #define OSError_GetResource_ResID() (errorhook_par1.resid)
|
---|
| 518 | #define OSError_ReleaseResource_ResID() (errorhook_par1.resid)
|
---|
| 519 | #define OSError_SetEvent_TaskID() (errorhook_par1.tskid)
|
---|
| 520 | #define OSError_SetEvent_Mask() (errorhook_par2.mask)
|
---|
| 521 | #define OSError_ClearEvent_Mask() (errorhook_par1.mask)
|
---|
| 522 | #define OSError_GetEvent_TaskID() (errorhook_par1.tskid)
|
---|
| 523 | #define OSError_GetEvent_Event() (errorhook_par2.p_mask)
|
---|
| 524 | #define OSError_WaitEvent_Mask() (errorhook_par1.mask)
|
---|
| 525 | #define OSError_GetAlarmBase_AlarmID() (errorhook_par1.almid)
|
---|
| 526 | #define OSError_GetAlarmBase_Info() (errorhook_par2.p_info)
|
---|
| 527 | #define OSError_GetAlarm_AlarmID() (errorhook_par1.almid)
|
---|
| 528 | #define OSError_GetAlarm_Tick() (errorhook_par2.p_tick)
|
---|
| 529 | #define OSError_SetRelAlarm_AlarmID() (errorhook_par1.almid)
|
---|
| 530 | #define OSError_SetRelAlarm_increment() (errorhook_par2.incr)
|
---|
| 531 | #define OSError_SetRelAlarm_cycle() (errorhook_par3.cycle)
|
---|
| 532 | #define OSError_SetAbsAlarm_AlarmID() (errorhook_par1.almid)
|
---|
| 533 | #define OSError_SetAbsAlarm_start() (errorhook_par2.start)
|
---|
| 534 | #define OSError_SetAbsAlarm_cycle() (errorhook_par3.cycle)
|
---|
| 535 | #define OSError_CancelAlarm_AlarmID() (errorhook_par1.almid)
|
---|
| 536 | #define OSError_IncrementCounter_CounterID() (errorhook_par1.cntid)
|
---|
| 537 | #define OSError_GetCounterValue_CounterID() (errorhook_par1.cntid)
|
---|
| 538 | #define OSError_GetCounterValue_Value() (errorhook_par2.p_val)
|
---|
| 539 | #define OSError_GetElapsedValue_CounterID() (errorhook_par1.cntid)
|
---|
| 540 | #define OSError_GetElapsedValue_Value() (errorhook_par2.p_val)
|
---|
| 541 | #define OSError_GetElapsedValue_ElapsedValue() (errorhook_par3.p_eval)
|
---|
| 542 | #define OSError_StartScheduleTableRel_ScheduleTableID() (errorhook_par1.schtblid)
|
---|
| 543 | #define OSError_StartScheduleTableRel_Offset() (errorhook_par2.offset)
|
---|
| 544 | #define OSError_StartScheduleTableAbs_ScheduleTableID() (errorhook_par1.schtblid)
|
---|
| 545 | #define OSError_StartScheduleTableAbs_Start() (errorhook_par2.start)
|
---|
| 546 | #define OSError_StopScheduleTable_ScheduleTableID() (errorhook_par1.schtblid)
|
---|
| 547 | #define OSError_NextScheduleTable_ScheduleTableID_From() (errorhook_par1.schtblid_from)
|
---|
| 548 | #define OSError_NextScheduleTable_ScheduleTableID_To() (errorhook_par2.schtblid_to)
|
---|
| 549 | #define OSError_GetScheduleTableStatus_ScheduleTableID() (errorhook_par1.schtblid)
|
---|
| 550 | #define OSError_GetScheduleTableStatus_ScheduleStatus() (errorhook_par2.p_schtblstate)
|
---|
| 551 | #define OSError_ShutdownOS_Error() (errorhook_par1.error)
|
---|
| 552 | #define OSError_DisableInterruptSource_DisableISR() (errorhook_par1.isrid)
|
---|
| 553 | #define OSError_EnableInterruptSource_EnableISR() (errorhook_par1.isrid)
|
---|
| 554 | #define OSError_GetApplicationState_Application() (errorhook_par1.applid)
|
---|
| 555 | #define OSError_GetApplicationState_Value() (errorhook_par2.p_appstat)
|
---|
| 556 | #define OSError_CallTrustedFunction_FunctionIndex() (errorhook_par1.tfnid)
|
---|
| 557 | #define OSError_CallTrustedFunction_FunctionParams() (errorhook_par2.tfnpr)
|
---|
| 558 | #define OSError_CheckISRMemoryAccess_ISRID() (errorhook_par1.isrid)
|
---|
| 559 | #define OSError_CheckISRMemoryAccess_Address() (errorhook_par2.adr)
|
---|
| 560 | #define OSError_CheckISRMemoryAccess_Size() (errorhook_par3.sz)
|
---|
| 561 | #define OSError_CheckTaskMemoryAccess_TaskID() (errorhook_par1.tskid)
|
---|
| 562 | #define OSError_CheckTaskMemoryAccess_Address() (errorhook_par2.adr)
|
---|
| 563 | #define OSError_CheckTaskMemoryAccess_Size() (errorhook_par3.sz)
|
---|
| 564 | #define OSError_CheckTaskAccess_ApplID() (errorhook_par1.applid)
|
---|
| 565 | #define OSError_CheckTaskAccess_TaskID() (errorhook_par2.tskid)
|
---|
| 566 | #define OSError_CheckISRAccess_ApplID() (errorhook_par1.applid)
|
---|
| 567 | #define OSError_CheckISRAccess_ISRID() (errorhook_par2.isrid)
|
---|
| 568 | #define OSError_CheckAlarmAccess_ApplID() (errorhook_par1.applid)
|
---|
| 569 | #define OSError_CheckAlarmAccess_AlarmID() (errorhook_par2.almid)
|
---|
| 570 | #define OSError_CheckResourceAccess_ApplID() (errorhook_par1.applid)
|
---|
| 571 | #define OSError_CheckResourceAccess_ResID() (errorhook_par2.resid)
|
---|
| 572 | #define OSError_CheckCounterAccess_ApplID() (errorhook_par1.applid)
|
---|
| 573 | #define OSError_CheckCounterAccess_CounterID() (errorhook_par2.cntid)
|
---|
| 574 | #define OSError_CheckScheduleTableAccess_ApplID() (errorhook_par1.applid)
|
---|
| 575 | #define OSError_CheckScheduleTableAccess_ScheduleTableID() (errorhook_par2.schtblid)
|
---|
| 576 | #define OSError_CheckTaskOwnership_TaskID() (errorhook_par1.tskid)
|
---|
| 577 | #define OSError_CheckISROwnership_ISRID() (errorhook_par1.isrid)
|
---|
| 578 | #define OSError_CheckAlarmOwnership_AlarmID() (errorhook_par1.almid)
|
---|
| 579 | #define OSError_CheckCounterOwnership_CounterID() (errorhook_par1.cntid)
|
---|
| 580 | #define OSError_CheckScheduleTableOwnership_ScheduleTableID() (errorhook_par1.schtblid)
|
---|
| 581 | #define OSError_IocSend_IocId() (errorhook_par1.iocid)
|
---|
| 582 | #define OSError_IocSend_SenderId() (errorhook_par2.senderid)
|
---|
| 583 | #define OSError_IocWrite_IocId() (errorhook_par1.iocid)
|
---|
| 584 | #define OSError_IocWrite_SenderId() (errorhook_par2.senderid)
|
---|
| 585 | #define OSError_IocReceive_IocId() (errorhook_par1.iocid)
|
---|
| 586 | #define OSError_IocRead_IocId() (errorhook_par1.iocid)
|
---|
| 587 | #define OSError_IocEmptyQueue_IocId() (errorhook_par1.iocid)
|
---|
| 588 | #define OSError_TerminateApplication_Application() (errorhook_par1.applid)
|
---|
| 589 | #define OSError_TerminateApplication_RestartOption() (errorhook_par2.restartoption)
|
---|
| 590 |
|
---|
| 591 | #endif /* CFG_USE_PARAMETERACCESS */
|
---|
| 592 |
|
---|
| 593 | #endif /* CFG_USE_ERRORHOOK */
|
---|
| 594 |
|
---|
| 595 | /*
|
---|
| 596 | * プロテクションフック関係のマクロ
|
---|
| 597 | */
|
---|
| 598 | #define PRO_IGNORE UINT_C(0x00)
|
---|
| 599 | #define PRO_SHUTDOWN UINT_C(0x01)
|
---|
| 600 | #define PRO_TERMINATETASKISR UINT_C(0x02)
|
---|
| 601 | #define PRO_TERMINATEAPPL UINT_C(0x03)
|
---|
| 602 | #define PRO_TERMINATEAPPL_RESTART UINT_C(0x04)
|
---|
| 603 |
|
---|
| 604 | /*
|
---|
| 605 | * OSAP終了/再起動関係のマクロ
|
---|
| 606 | */
|
---|
| 607 | #define NO_RESTART UINT_C(0x00)
|
---|
| 608 | #define RESTART UINT_C(0x01)
|
---|
| 609 |
|
---|
| 610 | /*
|
---|
| 611 | * メモリアクセス権限チェックのためのマクロ
|
---|
| 612 | */
|
---|
| 613 |
|
---|
| 614 | /*
|
---|
| 615 | * メモリ領域 権限
|
---|
| 616 | */
|
---|
| 617 |
|
---|
| 618 | #define AP_NoAccess UINT_C(0x0)
|
---|
| 619 | #define AP_Executable UINT_C(0x1)
|
---|
| 620 | #define AP_Readable UINT_C(0x2)
|
---|
| 621 | #define AP_Writable UINT_C(0x4)
|
---|
| 622 | #define AP_StackSpace UINT_C(0x8)
|
---|
| 623 |
|
---|
| 624 | /*
|
---|
| 625 | * アクセスチェックマクロ
|
---|
| 626 | */
|
---|
| 627 | #define OSMEMORY_IS_READABLE(AccessType) ((AccessType) & AP_Readable)
|
---|
| 628 | #define OSMEMORY_IS_WRITEABLE(AccessType) ((AccessType) & AP_Writable)
|
---|
| 629 | #define OSMEMORY_IS_EXECUTABLE(AccessType) ((AccessType) & AP_Executable)
|
---|
| 630 | #define OSMEMORY_IS_STACKSPACE(AccessType) ((AccessType) & AP_StackSpace)
|
---|
| 631 |
|
---|
| 632 | /*
|
---|
| 633 | * オブジェクトタイプ
|
---|
| 634 | */
|
---|
| 635 | #define OBJECT_TASK UINT_C(0x01)
|
---|
| 636 | #define OBJECT_ISR UINT_C(0x02)
|
---|
| 637 | #define OBJECT_ALARM UINT_C(0x03)
|
---|
| 638 | #define OBJECT_RESOURCE UINT_C(0x04)
|
---|
| 639 | #define OBJECT_COUNTER UINT_C(0x05)
|
---|
| 640 | #define OBJECT_SCHEDULETABLE UINT_C(0x06)
|
---|
| 641 |
|
---|
| 642 | /*
|
---|
| 643 | * バージョン情報
|
---|
| 644 | */
|
---|
| 645 | #define OS_SW_MAJOR_VERSION UINT_C(1) /* サプライヤーバージョン */
|
---|
| 646 | #define OS_SW_MINOR_VERSION UINT_C(3)
|
---|
| 647 | #define OS_SW_PATCH_VERSION UINT_C(2)
|
---|
| 648 |
|
---|
| 649 | #define OS_AR_RELEASE_MAJOR_VERSION UINT_C(4) /* AUTOSARリリースバージョン */
|
---|
| 650 | #define OS_AR_RELEASE_MINOR_VERSION UINT_C(0)
|
---|
| 651 | #define OS_AR_RELEASE_REVISION_VERSION UINT_C(3)
|
---|
| 652 |
|
---|
| 653 | #define TKERNEL_NAME "TOPPERS/ATK2-SC3" /* カーネル名称(独自仕様) */
|
---|
| 654 |
|
---|
| 655 | #endif /* TOPPERS_OS_H */
|
---|