
/***********************/
/* Declaration Section */
/***********************/

VERSION {
   KOIL = "2.1";
   OSSEMANTICS = "ORTI", "2.1";
};   /* VERSION */


IMPLEMENTATION VendorX_ORTI_2_1 {
   OS {
      TOTRACE ENUM "unsigned short" [
         "NO_TASK" = 0xFFFF,
         "extendedTaskFirst" = 0,
         "extendedTaskSecond" = 1,
         "basicTaskThird" = 2,
         "basicTaskSecond" = 3,
         "basicTaskFirst" = 4
      ] RUNNINGTASK, "Running Task Identification";
      TOTRACE ENUM "unsigned char" [
         "NO_SERVICE"               =  0,
         "ActivateTask"             =  2,
         "TerminateTask"            =  4,
         "ChainTask"                =  6,
         "Schedule"                 =  8,
         "GetTaskID"                =  10,
         "GetTaskState"             =  12,
         "ResumeAllInterrupts"      =  14,
         "SuspendAllInterrupts"     =  16,
         "EnableAllInterrupts"      =  24,
         "DisableAllInterrupts"     =  26,
         "ResumeOSInterrupts"       =  28,
         "SuspendOSInterrupts"      =  30,
         "GetResource"              =  32,
         "ReleaseResource"          =  34,
         "SetEvent"                 =  36,
         "ClearEvent"               =  38,
         "GetEvent"                 =  40,
         "WaitEvent"                =  42,
         "GetAlarmBase"             =  44,
         "GetAlarm"                 =  46,
         "SetRelAlarm"              =  48,
         "SetAbsAlarm"              =  50,
         "CancelAlarm"              =  52,
         "GetActiveApplicationMode" =  54,
         "StartOS"                  =  56,
         "ShutdownOS"               =  58,
         "ErrorHook"                =  60,
         "PreTaskHook"              =  62,
         "PostTaskHook"             =  64,
         "StartupHook"              =  66,
         "ShutdownHook"             =  68,
         "StartCOM"                 =  70,
         "StopCOM"                  =  72,
         "SendMessage"              =  74,
         "ReceiveMessage"           =  76,
         "GetMessageResource"       =  78,
         "ReleaseMessageResource"   =  80,
         "GetMessageStatus"         =  82,
         "ReadFlag"                 =  84,
         "ResetFlag"                =  86
      ] SERVICETRACE, "OS Services Watch";
      TOTRACE ENUM "unsigned short" [
         "NO_ISR" = 0xFFFF,
         "osTimerInterrupt" = 2
      ] RUNNINGISR2, "ISR Identification";

      ENUM "unsigned short" [
         "-" = 0xFFFF,
         "RES_SCHEDULER" = 0,
         "12" = 1,
         "10" = 2,
         "8" = 3,
         "2" = 4,
         "2" = 5,
         "1" = 6
      ] RUNNINGTASKPRIORITY, "Priority of Running Task";

      ENUM "unsigned char" [
         "E_OK"                      =  0,
         "E_OS_ACCESS"               =  1,
         "E_OS_CALLEVEL"             =  2,
         "E_OS_ID"                   =  3,
         "E_OS_LIMIT"                =  4,
         "E_OS_NOFUNC"               =  5,
         "E_OS_RESOURCE"             =  6,
         "E_OS_STATE"                =  7,
         "E_OS_VALUE"                =  8,
         "E_OS_SYS_ASSERTION"        =  9,
         "E_OS_SYS_ABORT"            = 10,
         "E_OS_SYS_DIS_INT"          = 11,
         "E_OS_SYS_API_ERROR"        = 12,
         "E_OS_SYS_ALARM_MANAGEMENT" = 13,
         "E_OS_SYS_WARNING"          = 14,
         "E_COM_BUSY"                = 32,
         "E_COM_ID"                  = 33,
         "E_COM_LIMIT"               = 34,
         "E_COM_LOCKED"              = 35,
         "E_COM_NOMSG"               = 36,
         "E_COM_RX_ON"               = 37,
         "E_COM_SYS_NOT_SUPPORTED"   = 48,
         "E_COM_SYS_NOTIFY_FAILED"   = 49,
         "E_COM_SYS_QUEUE_NOT_FOUND" = 50
      ] LASTERROR, "Last OSEK Error";

      ENUM "unsigned short" [
         "-" = 0,
         "ActivateTask: Called with invalid task ID                                           "   = 0x1101,
         "ActivateTask: Task has wrong priority level                                         "   = 0x1102,
         "ActivateTask: Number of activation exceeds limit                                    "   = 0x1103,
         "ActivateTask: Interrupts are disabled with functions provided by OSEK               "   = 0x1104,
         "ActivateTask: Number of activation exceeds limit (task activation is performed by alarm-expiration)         "   = 0x1105,
         "TerminateTask: Called with disabled interrupts                                     "   = 0x1201,
         "TerminateTask: Called with occupied resources                                      "   = 0x1202,
         "TerminateTask: Attempted for a task with activation counter == 0 (not activated)   "   = 0x1203,
         "TerminateTask: Called from an interrupt service routine                            "   = 0x1204,
         "ChainTask: Called with disabled interrupts                                         "   = 0x1301,
         "ChainTask: Called with occupied resources                                          "   = 0x1302,
         "ChainTask: New task has invalid ID                                                 "   = 0x1303,
         "ChainTask: Tried to terminate a task which have an activation counter which is zero"   = 0x1304,
         "ChainTask: Number of activation of new task exceeds limit                          "   = 0x1305,
         "ChainTask: Called on interrupt level                                               "   = 0x1306,
         "ChainTask: Task has wrong priority level                                           "   = 0x1307,
         "Schedule: Called with disabled interrupts                                          "   = 0x1401,
         "Schedule: Called on interrupt level                                                "   = 0x1402,
         "Schedule: Called from task with enabled stack sharing by setting NotUsingSchedule in the OIL-configurator   "   = 0x1403,
         "Schedule: Called inside a procedure                                                "   = 0x1404,
         "Schedule: Called with an occupied resource                                         "   = 0x1405,
         "GetTaskState: Called with invalid task ID                                          "   = 0x1501,
         "GetTaskState: Interrupts are disabled with functions provided by OSEK              "   = 0x1502,
         "GetTaskID: Interrupts are disabled with functions provided by OSEK                 "   = 0x1601,
         "Exit of task without the call of TerminateTask or ChainTask                        "   = 0x1701,
         "EnableAllInterrupts: DisableAllInterrupts not called before                        "   = 0x2401,
         "DisableAllInterrupts: Interrupts are disabled with functions provided by OSEK      "   = 0x2501,
         "ResumeOSInterrupts: SuspendOSInterrupts not called before                          "   = 0x2601,
         "SuspendOSInterrupts: Interrupts are disabled with functions provided by OSEK       "   = 0x2701,
         "An unhandled exception or interrupt was detected                                   "   = 0x2801,
         "osSaveDisableLevelNested: Wrong counter value detected                             "   = 0x2901,
         "osRestoreEnableLevelNested: Wrong counter value detected                           "   = 0x2A01,
         "osSaveDisableGlobalNested: Wrong counter value detected                            "   = 0x2B01,
         "osRestoreEnableGlobalNested: Wrong counter value detected                          "   = 0x2C01,
         "GetResource: Invalid resource ID                                                   "   = 0x3101,
         "GetResource: Ceiling priority of the specified resource already in use             "   = 0x3102,
         "GetResource: Resource already occupied                                             "   = 0x3103,
         "GetResource: Task has no access to the specified resource                          "   = 0x3104,
         "GetResource: Specified resource has a wrong priority. Possible reason: The task has no access rights to this resource" = 0x3105,
         "GetResource: Interrupts are disabled with functions provided by OSEK               "   = 0x3106,
         "ReleaseResource: Invalid resource ID                                               "   = 0x3201,
         "ReleaseResource: Ceiling priority of the resource not found in the ready bit field "   = 0x3202,
         "ReleaseResource: Resource occupied by a different task                             "   = 0x3203,
         "ReleaseResource: Specified resource has a wrong priority. Possible reason: The task has no access rights to this resource" = 0x3204,
         "ReleaseResource: Task has no access to the specified resource                      "   = 0x3205,
         "ReleaseResource: The specified resource is not occupied by the task                "   = 0x3206,
         "ReleaseResource: At least one other resource must be released before               "   = 0x3207,
         "ReleaseResource: Interrupts are disabled with functions provided by OSEK           "   = 0x3208,
         "SetEvent: Invalid task ID                                                          "   = 0x4101,
         "SetEvent: Cannot call SetEvent to basic task                                       "   = 0x4102,
         "SetEvent: Cannot SetEvent to task in SUSPENDED state                               "   = 0x4103,
         "SetEvent: Wrong task priority detected                                             "   = 0x4104,
         "SetEvent: Interrupts are disabled with functions provided by OSEK                  "   = 0x4105,
         "ClearEvent: A basic task cannot clear an event                                     "   = 0x4201,
         "ClearEvent Called on interrupt level                                               "   = 0x4202,
         "ClearEvent: Interrupts are disabled with functions provided by OSEK                "   = 0x4203,
         "GetEvent: Invalid task ID                                                          "   = 0x4301,
         "GetEvent: Cannot GetEvent from basic task                                          "   = 0x4302,
         "GetEvent: Cannot GetEvent from a task in SUSPENDED state                           "   = 0x4303,
         "GetEvent: Interrupts are disabled with functions provided by OSEK                  "   = 0x4304,
         "WaitEvent: Called by basic task                                                    "   = 0x4401,
         "WaitEvent: Called with occupied resources                                          "   = 0x4402,
         "WaitEvent: Called with disabled interrupts                                         "   = 0x4403,
         "WaitEvent: Called on interrupt level                                               "   = 0x4404,
         "WaitEvent: Called inside procedure                                                 "   = 0x4405,
         "GetAlarmBase: Invalid alarm ID                                                     "   = 0x5101,
         "GetAlarmBase: Interrupts are disabled with functions provided by OSEK              "   = 0x5102,
         "GetAlarm: Invalid alarm ID                                                         "   = 0x5201,
         "GetAlarm: Alarm not active                                                         "   = 0x5202,
         "GetAlarm: Interrupts are disabled with functions provided by OSEK                  "   = 0x5203,
         "SetRelAlarm: Invalid alarm id                                                      "   = 0x5301,
         "SetRelAlarm: Alarm already active                                                  "   = 0x5302,
         "SetRelAlarm: Specified cycle is out of range                                       "   = 0x5303,
         "SetRelAlarm: Specified delta is out of range                                       "   = 0x5304,
         "SetRelAlarm: Interrupts are disabled with functions provided by OSEK               "   = 0x5305,
         "SetAbsAlarm: Invalid alarm ID                                                      "   = 0x5401,
         "SetAbsAlarm: Alarm already active                                                  "   = 0x5402,
         "SetAbsAlarm: Specified cycle is out of range                                       "   = 0x5403,
         "SetAbsAlarm: Specified start is out of range                                       "   = 0x5404,
         "SetAbsAlarm: Interrupts are disabled with functions provided by OSEK               "   = 0x5405,
         "CancelAlarm: Invalid alarm ID                                                      "   = 0x5501,
         "CancelAlarm: Alarm not active                                                      "   = 0x5502,
         "CancelAlarm: Interrupts are disabled with functions provided by OSEK               "   = 0x5503,
         "CancelAlarm: Internal error detected while alarm was canceled                      "   = 0x5504,
         "osWorkAlarms: SetEvent in alarm of BCC1 or BCC2                                    "   = 0x5601,
         "Task stack overflow detected                                                       "   = 0x6101,
         "Scheduler called with enabled interrupts                                           "   = 0x6201,
         "Called with invalid task ID                                                        "   = 0x6301,
         "Wrong library linked to application                                                "   = 0x6401,
         "ErrorHook called with enabled interrupts                                           "   = 0x6501
      ] vs_osLastError, "Last Error";

      ENUM "unsigned char" [
         "OSDEFAULTAPPMODE"   = 0x01
      ] CURRENTAPPMODE, "Current application mode";
   }, "OS";   /* OS */


   TASK {
      ENUM "unsigned short" [
         "RES_SCHEDULER" = 0,
         "12" = 1,
         "10" = 2,
         "8" = 3,
         "2" = 4,
         "2" = 5,
         "1" = 6
      ] PRIORITY, "Actual Prio";
      STRING vs_HomePriority, "Home Prio";
      ENUM "unsigned char" [
         "READY"=0,
         "RUNNING"=1,
         "WAITING"=2,
         "READY"=3,
          "SUSPENDED"=4,
          "WAIT_SEMAPHORE"=5
      ] STATE, "State";
      ENUM "void*" [
         "osTaskStack0" : osTaskStack0 = "osTaskStack0",
         "osTaskStack1" : osTaskStack1 = "osTaskStack1",
         "osTaskStack2" : osTaskStack2 = "osTaskStack2",
         "osTaskStack3" : osTaskStack3 = "osTaskStack3",
         "osTaskStack4" : osTaskStack4 = "osTaskStack4"
      ] STACK, "Task Stack";
      STRING vs_TaskType, "Task Type";
      STRING vs_Schedule, "Schedule";
      CTYPE "unsigned char" vs_WaitMask, "Wait Mask";

      CTYPE "unsigned char" vs_EventFlag, "Event Flag";

      CTYPE "unsigned char" CURRENTACTIVATIONS, "Activations";
      STRING vs_MaxActivations, "max. Activations";
      ENUM "unsigned short" [
         "Context_extendedTaskFirst" : Context_extendedTaskFirst = 0,
         "Context_extendedTaskSecond" : Context_extendedTaskSecond = 1,
         "Context_basicTaskThird" : Context_basicTaskThird = 2,
         "Context_basicTaskSecond" : Context_basicTaskSecond = 3,
         "Context_basicTaskFirst" : Context_basicTaskFirst = 4
      ] CONTEXT, "Task Context";

   }, "Tasks";   /* TASK */


   CONTEXT {
      CTYPE "unsigned char" VALID;
   }, "Task Context";   /* CONTEXT */


   STACK {
      CTYPE "unsigned short" SIZE, "Stack Size (Byte)";
      CTYPE "unsigned short*" BASEADDRESS, "Stack Start Address";
      STRING STACKDIRECTION, "Stack Direction";
   }, "Stacks";   /* STACK */


   vs_Event {
      STRING vs_EventMask, "Event Mask";
   }, "Events";   /* Events */


   ALARM {
      ENUM "unsigned char" [
         "STOPPED" = 0,
         "RUNNING" = 1
      ] STATE, "Alarm State";
      CTYPE "unsigned long" CYCLETIME, "Cycle Time (Ticks)";
      CTYPE "unsigned long" vs_CycleTime_ms, "Cycle Time (ms)";
      CTYPE "unsigned long" ALARMTIME, "Alarm Time (Ticks)";
      CTYPE "unsigned long" vs_AlarmTime_ms, "Alarm Time (ms)";
      STRING ACTION, "Action";
      STRING COUNTER, "Counter";
   }, "Alarms";   /* Alarms */

   RESOURCE {
      ENUM "unsigned char" [
         "LOCKED"=1,
         "UNLOCKED"=0
      ] STATE, "Resource State";
      ENUM "unsigned short" [
         "ISR"=0xFFFF,
         "basicTaskThird" = 0,
         "extendedTaskFirst" = 1,
         "extendedTaskSecond" = 2,
         "basicTaskSecond" = 3,
         "basicTaskFirst" = 4,
         "-" = 0xFFFE
      ] LOCKER, "Resource Locker";
      STRING PRIORITY, "Ceiling priority";
   }, "Resources";   /* Resources */

   vs_OS_Config {
      ENUM "unsigned short" [
         "BCC1" = 0,
         "BCC2" = 1,
         "ECC1" = 2,
         "ECC2" = 3
      ] vs_CC,"Conformance Class";
      ENUM "unsigned short" [
         "STANDARD" = 0,
         "EXTENDED" = 1
      ] vs_STATUS_LEVEL, "Status Level";
      ENUM "unsigned short" [
         "NON-Preempt" = 0,
         "FULL-Preempt" = 1,
         "MIXED-Preempt" = 2
      ] vs_SCHEDULE, "Schedule";
      CTYPE "unsigned char" vs_OS_MAJ_VERSION, "OS Major-Release (OS)";
      CTYPE "unsigned char" vs_OS_MIN_VERSION, "OS Minor-Release (OS)";
      CTYPE "unsigned char" vs_GEN_MAJ_VERSION, "Generator Major-Release";
      CTYPE "unsigned char" vs_GEN_MIN_VERSION, "Generator Minor-Release";
   }, "OS Configuration"; /* OS Configuration */

}; /* END OF IMPLEMENTATION */


/***********************/
/* Information Section */
/***********************/

OS PPC_563x {
   RUNNINGTASK = "osCtrlVars.ossActiveTaskIndex";
   RUNNINGISR2 = "osORTICurrentIsrId";
   SERVICETRACE = "osORTICurrentServiceId";
   RUNNINGTASKPRIORITY = "osCtrlVars.ossActiveTaskPrio";
   LASTERROR = "osLastErrorCode";
   vs_osLastError = "osLastError";
   CURRENTAPPMODE = "1";
};   /* OS */

TASK extendedTaskFirst {
   PRIORITY = "osTcbActualPrio[0]";
   vs_HomePriority = "10";
   STATE = "osTcbTaskState[0]";
   STACK = "osTaskStack1";
   vs_Schedule = "FULL-Preempt";
   vs_TaskType = "EXTENDED";
   vs_WaitMask = "osTcbWaitEventMask[0]";
   vs_EventFlag = "osTcbSetEventMask[0]";
   CURRENTACTIVATIONS = "osTcbTaskState[0] != 4";
   vs_MaxActivations = "1";
   CONTEXT="0";
};   /* extendedTaskFirst*/

TASK extendedTaskSecond {
   PRIORITY = "osTcbActualPrio[1]";
   vs_HomePriority = "8";
   STATE = "osTcbTaskState[1]";
   STACK = "osTaskStack2";
   vs_Schedule = "FULL-Preempt";
   vs_TaskType = "EXTENDED";
   vs_WaitMask = "osTcbWaitEventMask[1]";
   vs_EventFlag = "osTcbSetEventMask[1]";
   CURRENTACTIVATIONS = "osTcbTaskState[1] != 4";
   vs_MaxActivations = "1";
   CONTEXT="1";
};   /* extendedTaskSecond*/

TASK basicTaskThird {
   PRIORITY = "osTcbActualPrio[2]";
   vs_HomePriority = "12";
   STATE = "osTcbTaskState[2]";
   STACK = "osTaskStack0";
   vs_Schedule = "FULL-Preempt";
   vs_TaskType = "BASIC";
   vs_WaitMask = "0";
   vs_EventFlag = "0";
   CURRENTACTIVATIONS = "osTcbTaskState[2] != 4";
   vs_MaxActivations = "1";
   CONTEXT="2";
};   /* basicTaskThird*/

TASK basicTaskSecond {
   PRIORITY = "osTcbActualPrio[3]";
   vs_HomePriority = "2";
   STATE = "osTcbTaskState[3]";
   STACK = "osTaskStack3";
   vs_Schedule = "FULL-Preempt";
   vs_TaskType = "BASIC";
   vs_WaitMask = "0";
   vs_EventFlag = "0";
   CURRENTACTIVATIONS = "osTcbTaskState[3] != 4";
   vs_MaxActivations = "1";
   CONTEXT="3";
};   /* basicTaskSecond*/

TASK basicTaskFirst {
   PRIORITY = "osTcbActualPrio[4]";
   vs_HomePriority = "1";
   STATE = "osTcbTaskState[4]";
   STACK = "osTaskStack4";
   vs_Schedule = "FULL-Preempt";
   vs_TaskType = "BASIC";
   vs_WaitMask = "0";
   vs_EventFlag = "0";
   CURRENTACTIVATIONS = "osTcbTaskState[4] != 4";
   vs_MaxActivations = "1";
   CONTEXT="4";
};   /* basicTaskFirst*/

CONTEXT Context_extendedTaskFirst {
   VALID = "((osTcbTaskState[0] == 2) || (osTcbTaskState[0] == 3))";
};   /* Context for Task: extendedTaskFirst*/

CONTEXT Context_extendedTaskSecond {
   VALID = "((osTcbTaskState[1] == 2) || (osTcbTaskState[1] == 3))";
};   /* Context for Task: extendedTaskSecond*/

CONTEXT Context_basicTaskThird {
   VALID = "((osTcbTaskState[2] == 2) || (osTcbTaskState[2] == 3))";
};   /* Context for Task: basicTaskThird*/

CONTEXT Context_basicTaskSecond {
   VALID = "((osTcbTaskState[3] == 2) || (osTcbTaskState[3] == 3))";
};   /* Context for Task: basicTaskSecond*/

CONTEXT Context_basicTaskFirst {
   VALID = "((osTcbTaskState[4] == 2) || (osTcbTaskState[4] == 3))";
};   /* Context for Task: basicTaskFirst*/

STACK osSystemStack {
   SIZE = "504";
   BASEADDRESS = "osSystemStackTop+4";
   STACKDIRECTION = "DOWN";
};

STACK osTaskStack0 {
   SIZE = "400";
   BASEADDRESS = "osTaskStack0+1";
   STACKDIRECTION = "DOWN";
};

STACK osTaskStack1 {
   SIZE = "400";
   BASEADDRESS = "osTaskStack1+1";
   STACKDIRECTION = "DOWN";
};

STACK osTaskStack2 {
   SIZE = "400";
   BASEADDRESS = "osTaskStack2+1";
   STACKDIRECTION = "DOWN";
};

STACK osTaskStack3 {
   SIZE = "400";
   BASEADDRESS = "osTaskStack3+1";
   STACKDIRECTION = "DOWN";
};

STACK osTaskStack4 {
   SIZE = "400";
   BASEADDRESS = "osTaskStack4+1";
   STACKDIRECTION = "DOWN";
};

vs_Event evExT1_1 {
   vs_EventMask = "0x01";
};

vs_Event evExT2_1 {
   vs_EventMask = "0x01";
};

ALARM myFirstAlarm {
   CYCLETIME = "osAlarmCycleTime[0]";
   vs_CycleTime_ms = "(osAlarmCycleTime[0]*1)/1";
   ALARMTIME =  "(osAlarmTime[0]>osSystemCounter) ?    ((osAlarmTime[0]-osSystemCounter) *osAlarmActivated[0]) :    ((oskCounterMaxAllowedValue[0]-osAlarmTime[0]+osSystemCounter) *osAlarmActivated[0]) ";
   vs_AlarmTime_ms = "(((osAlarmTime[0]-osSystemCounter)*1)/1)*osAlarmActivated[0]";
   ACTION = "ActivateTask basicTaskThird";
   COUNTER = "SystemTimer";
   STATE = "(osAlarmActivated[0] == 0) ? 0 : 1";

};   /* myFirstAlarm*/

RESOURCE resBasic {
   STATE = "(osResOccupationCounter[0] != 0) ? 1 : 0";
   LOCKER  = "(osResOccupationCounter[0] != 0) ? osResActualTask[0] : 0xFFFE";
   PRIORITY = "TASK: 2";
};

RESOURCE RES_SCHEDULER {
   STATE = "(osResOccupationCounter[1] != 0) ? 1 : 0";
   LOCKER  = "(osResOccupationCounter[1] != 0) ? osResActualTask[1] : 0xFFFE";
   PRIORITY = "SCHEDULER";
};

vs_OS_Config PPC_563x {
   vs_CC = "oskVersionVariant.ucSysVariant & 0x0003";
   vs_STATUS_LEVEL = "(oskVersionVariant.ucSysVariant & 0x0004) >>2";
   vs_SCHEDULE = "(oskVersionVariant.ucSysVariant & 0x0018) >>3";
   vs_OS_MAJ_VERSION = "oskVersionVariant.ucSysVersionMaj";
   vs_OS_MIN_VERSION = "oskVersionVariant.ucSysVersionMin";
   vs_GEN_MAJ_VERSION = "oskVersionVariant.ucGenVersionMaj";
   vs_GEN_MIN_VERSION = "oskVersionVariant.ucGenVersionMin";
};


/* END OF gen.ORT */

