code
stringlengths 1
1.05M
| repo_name
stringlengths 6
83
| path
stringlengths 3
242
| language
stringclasses 222
values | license
stringclasses 20
values | size
int64 1
1.05M
|
|---|---|---|---|---|---|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/** @reqSettings DEFAULT_SPECIFICATION_REVISION=4.3.0 */
#include "os_i.h"
/**
* The state of the calling task is set to waiting, unless at least one
* of the events specified in <Mask> has already been set.
*
* This call enforces rescheduling, if the wait condition occurs. If
* rescheduling takes place, the internal resource of the task is
* released while the task is in the waiting state.
* This service shall only be called from the extended task owning
* the event.
*
* From 7.6.1 in Autosar OS 4.0
* An event is accessible if the task for which the event can be set
* is accessible. Access means that these Operating System objects are
* allowed as parameters to API services.
*
* @param Mask Mask of the events waited for
* @return
*/
/* @req OSEK_SWS_EV_00001 */
StatusType WaitEvent( EventMaskType Mask ) {
OsTaskVarType *curr_pcb = Os_SysTaskGetCurr();
StatusType rv = E_OK;
imask_t state;
OS_DEBUG(D_EVENT,"# WaitEvent %s\n",Os_SysTaskGetCurr()->constPtr->name);
/* Validation of parameters, if failure, function will return */
/* This is not inline with Table 8, ISO26262-6:2011, Req 1a and 1h */
OS_VALIDATE_STD_1((Os_SysIntAnyDisabled() == FALSE) , E_OS_DISABLEDINT,
OSServiceId_WaitEvent,Mask); /* @req SWS_Os_00093 */
OS_VALIDATE_STD_1(OS_SYS_PTR->intNestCnt == 0, E_OS_CALLEVEL,
OSServiceId_WaitEvent,Mask); /* @req OSEK_SWS_EV_00004 */
OS_VALIDATE_STD_1(curr_pcb->constPtr->proc_type == PROC_EXTENDED,E_OS_ACCESS,
OSServiceId_WaitEvent,Mask); /* @req OSEK_SWS_EV_00002 */
OS_VALIDATE_STD_1(!Os_TaskOccupiesResources(curr_pcb),E_OS_RESOURCE,
OSServiceId_WaitEvent,Mask); /* @req OSEK_SWS_EV_00003 */
#if (OS_NUM_CORES > 1)
OS_VALIDATE_STD_1(!Os_TaskOccupiesSpinlocks(curr_pcb) != 0,E_OS_SPINLOCK,
OSServiceId_WaitEvent,Mask); /* SWS_Os_00622 */
#endif
/* Remove from ready queue */
Irq_Save(state);
// OSEK/VDX footnote 5. The call of WaitEvent does not lead to a waiting state if one of the events passed in the event mask to
// WaitEvent is already set. In this case WaitEvent does not lead to a rescheduling.
/* @req OSEK_SWS_EV_00004 */
if( (curr_pcb->ev_set & Mask) == 0 ) {
curr_pcb->ev_wait = Mask;
Os_Dispatch(OP_WAIT_EVENT);
ASSERT( curr_pcb->state & ST_RUNNING );
}
Irq_Restore(state);
return rv;
}
/**
* The events of task <TaskID> are set according to the event
* mask <Mask>. Calling SetEvent causes the task <TaskID> to
* be transferred to the ready state, if it was waiting for at least
* one of the events specified in <Mask>.
*
* @param TaskID - Reference to the task for which one or several events are to be set.
* @param Mask - Mask of the events to be set
* @return
*/
StatusType SetEvent( TaskType TaskID, EventMaskType Mask ) {
StatusType rv = E_OK;
OsTaskVarType *destPcbPtr;
const OsTaskVarType *currPcbPtr;
imask_t flags;
OS_DEBUG(D_EVENT,"# SetEvent %s\n",Os_SysTaskGetCurr()->constPtr->name);
/* Validation of parameters, if failure, function will return */
/* This is not inline with Table 8, ISO26262-6:2011, Req 1a and 1h */
OS_VALIDATE_STD_2( TASK_CHECK_ID(TaskID) , E_OS_ID,
OSServiceId_SetEvent,TaskID, Mask); /*@req OSEK_SWS_EV_00007 */
destPcbPtr = Os_TaskGet(TaskID);
currPcbPtr = Os_SysTaskGetCurr();
#if (OS_SC3==STD_ON) || (OS_SC4==STD_ON)
if( destPcbPtr->constPtr->applOwnerId != OS_SYS_PTR->currApplId ) {
ApplicationType appId;
/* If the application state is not APPLICATION_ACCESSIBLE then control flow will
* reach in OS_STD_ERR_2 and ErrorHook will be called */
OS_VALIDATE_STD_2( (Os_ApplCheckState(destPcbPtr->constPtr->applOwnerId) != E_OS_ACCESS) , E_OS_ACCESS,
OSServiceId_SetEvent,TaskID, Mask);
/* getting the OwnerId of Task/ISR */
appId = Os_GetCurrTaskISROwnerId();
/* Do we have access to the task we are activating */
/* If the application does not have access then control flow will
* reach in OS_STD_ERR_2 and ErrorHook will be called */
OS_VALIDATE_STD_2( (Os_ApplCheckAccess(appId , destPcbPtr->constPtr->accessingApplMask) != E_OS_ACCESS) , E_OS_ACCESS,
OSServiceId_SetEvent,TaskID, Mask);
#if (OS_NUM_CORES > 1)
if (Os_ApplGetCore(destPcbPtr->constPtr->applOwnerId) != GetCoreID()) {
StatusType status = Os_NotifyCore(Os_ApplGetCore(destPcbPtr->constPtr->applOwnerId),
OSServiceId_SetEvent,
TaskID,
Mask,
0);
return status;
#endif
}
#endif
OS_VALIDATE_STD_2(destPcbPtr->constPtr->proc_type == PROC_EXTENDED, E_OS_ACCESS,
OSServiceId_SetEvent,TaskID, Mask); /*@req OSEK_SWS_EV_00008 */
OS_VALIDATE_STD_2((destPcbPtr->state & ST_SUSPENDED) == 0, E_OS_STATE,
OSServiceId_SetEvent,TaskID, Mask); /*@req OSEK_SWS_EV_00009 */
Irq_Save(flags);
/* Calling SetEvent causes the task <TaskID> to be transferred
* to the ready state, if it was waiting for at least one of the
* events specified in <Mask>.
*
* OSEK/VDX 4.6.1, rescheduling is performed in all of the following cases:
* ..
* Setting an event to a waiting task at task level (e.g. system service SetEvent,
* see chapter 13.5.3.1, message notification mechanism, alarm expiration, if event setting
* defined, see chapter 9.2)
* ... */
destPcbPtr->ev_set |= Mask;
if( (Mask & destPcbPtr->ev_wait) != 0) {
/* We have an event match */
/*lint -e{9036} MISRA:OTHER: bit level comparison is required:[MISRA 2012 Rule 14.4, required]*/
if( destPcbPtr->state & ST_WAIT_EVENT){
#if defined(CFG_T1_ENABLE)
Os_ReleaseEventHook(destPcbPtr->constPtr->pid);
#endif
Os_TaskMakeReady(destPcbPtr);
currPcbPtr = Os_SysTaskGetCurr();
/* Checking "4.6.2 Non preemptive scheduling" it does not dispatch if NON */
if( (OS_SYS_PTR->intNestCnt == 0) &&
(currPcbPtr->constPtr->scheduling == FULL) &&
(destPcbPtr->activePriority > currPcbPtr->activePriority) &&
(Os_SysIntAnyDisabled() == FALSE ) ) /*lint !e9007, OK side effects */
{
Os_Dispatch(OP_SET_EVENT); /* @req OSEK_SWS_EV_00018 */
}
/*lint -e{9036} MISRA:OTHER: bit level comparison is required:[MISRA 2012 Rule 14.4, required]*/
__CODE_COVERAGE_IGNORE__
} else if(destPcbPtr->state & (ST_READY | ST_RUNNING | ST_SLEEPING | ST_WAIT_SEM) ) {
/* Do nothing */
} else {
/* @CODECOV:DEFAULT_CASE: Default statement is required for defensive programming. See above...*/
ASSERT( 0 );
}
}
Irq_Restore(flags);
return rv;
}
/**
* This service returns the current state of all event bits of the task
* <TaskID>, not the events that the task is waiting for.
* The service may be called from interrupt service routines, task
* level and some hook routines (see Figure 12-1).
* The current status of the event mask of task <TaskID> is copied
* to <Event>.
*
* @param TaskId Task whose event mask is to be returned.
* @param Mask Reference to the memory of the return data.
* @return
*/
StatusType GetEvent( TaskType TaskId, EventMaskRefType Mask) {
const OsTaskVarType *destPcbPtr;
StatusType rv = E_OK;
#if (OS_SC1==STD_ON) || (OS_SC2==STD_ON)
imask_t flags;
#endif
/* Validation of parameters, if failure, function will return */
/* This is not inline with Table 8, ISO26262-6:2011, Req 1a and 1h */
OS_VALIDATE_STD_2( (Mask != NULL), E_OS_PARAM_POINTER,
OSServiceId_GetEvent,TaskId, Mask); /* @req SWS_Os_00566 */
#if (OS_SC3==STD_ON) || (OS_SC4==STD_ON)
OS_VALIDATE_STD_2( (OS_VALIDATE_ADDRESS_RANGE(Mask,sizeof(EventMaskType)) == TRUE ) , E_OS_ILLEGAL_ADDRESS ,
OSServiceId_GetEvent,TaskId, Mask);/*@req SWS_Os_00051 */
#endif
OS_VALIDATE_STD_2( (Os_SysIntAnyDisabled() == FALSE) , E_OS_DISABLEDINT,
OSServiceId_GetEvent,TaskId, Mask); /* @req SWS_Os_00093 */
OS_VALIDATE_STD_2( TASK_CHECK_ID(TaskId) , E_OS_ID,
OSServiceId_GetEvent,TaskId, Mask); /* @req OSEK_SWS_EV_00011 */
/* @req OSEK_SWS_EV_00020 */
destPcbPtr = Os_TaskGet(TaskId); /* @req OSEK_SWS_EV_00014 */
OS_VALIDATE_STD_2( (destPcbPtr->constPtr->proc_type == PROC_EXTENDED), E_OS_ACCESS,
OSServiceId_GetEvent,TaskId, Mask); /* @req OSEK_SWS_EV_00012 */
OS_VALIDATE_STD_2( (destPcbPtr->state & ST_SUSPENDED) == 0, E_OS_STATE,
OSServiceId_GetEvent,TaskId, Mask); /* @req OSEK_SWS_EV_00013 */
/* @req OSEK_SWS_EV_00021 */
#if (OS_SC1==STD_ON) || (OS_SC2==STD_ON)
/* For SC1 and SC2 EventMaskType is 64bit,
* the atomicity of read operation is depends on compiler (even though arch's ISR has load double inst)
* and in most case this 64bit operation is not atomic. Hence making this as atomic.
*/
Irq_Save(flags);
*Mask = destPcbPtr->ev_set;
Irq_Restore(flags);
#else
*Mask = destPcbPtr->ev_set;
#endif
return rv;
}
/**
* The events of the extended task calling ClearEvent are cleared
* according to the event mask <Mask>.
*
*
* @param Mask
* @return
*/
StatusType ClearEvent( EventMaskType Mask) {
StatusType rv = E_OK;
OsTaskVarType *pcb = Os_SysTaskGetCurr();
imask_t flags;
/* Validation of parameters, if failure, function will return */
/* This is not inline with Table 8, ISO26262-6:2011, Req 1a and 1h */
OS_VALIDATE_STD_1((Os_SysIntAnyDisabled() == FALSE) , E_OS_DISABLEDINT,
OSServiceId_ClearEvent,Mask); /* @req SWS_Os_00093 */
OS_VALIDATE_STD_1(OS_SYS_PTR->intNestCnt == 0,E_OS_CALLEVEL,
OSServiceId_ClearEvent,Mask); /* @req OSEK_SWS_EV_00016 */
OS_VALIDATE_STD_1(pcb->constPtr->proc_type == PROC_EXTENDED,E_OS_ACCESS,
OSServiceId_ClearEvent,Mask); /* @req OSEK_SWS_EV_00015 */
Irq_Save(flags);
pcb->ev_set &= ~Mask; /* @req OSEK_SWS_EV_00017 */
Irq_Restore(flags);
return rv;
}
|
2301_81045437/classic-platform
|
system/Os/rtos/src/os_event.c
|
C
|
unknown
| 11,540
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/** @reqSettings DEFAULT_SPECIFICATION_REVISION=4.3.0 */
/* Generic Requirements */
/** @req SWS_BSW_00004 The code file structure shall contain one or more files for the implementation of
* the provided BSW Module functionality: the Implementation source files
*/
/** @req SWS_Os_00328
* If OsStatus is STANDARD and OsScalabilityClass is SC3 or SC4 the consistency check shall issue an error.
* Note: This requirement is implemented in Os.chk (as requirement tagging in .chk file is not parsed, tagging is done here) */
/* ----------------------------[includes]------------------------------------*/
#include "os_i.h"
/* ----------------------------[private define]------------------------------*/
/* ----------------------------[private macro]-------------------------------*/
/* Count to avoid irq enable before os_start*/
#define INITIAL_DISABLE_COUNT 100
/* ----------------------------[private typedef]-----------------------------*/
/* ----------------------------[private function prototypes]-----------------*/
/* ----------------------------[private variables]---------------------------*/
Os_SysType Os_Sys[OS_NUM_CORES];
Os_IntCounterType Os_IntDisableAllCnt;
Os_IntCounterType Os_IntSuspendAllCnt;
Os_IntCounterType Os_IntSuspendOsCnt;
OsErrorType os_error;
#if (OS_NUM_CORES > 1)
volatile boolean beforeStartHooks[OS_NUM_CORES] = {FALSE};
volatile boolean afterStartHooks[OS_NUM_CORES] = {FALSE};
volatile boolean afterIsrSetup[OS_NUM_CORES] = {FALSE};
#endif
/* ----------------------------[extern]--------------------------------------*/
extern void EcuM_Init(void);
#if !defined(CFG_OS_SYSTICK2)
extern uint32 Mcu_Arc_GetSystemClock( void );
#endif
/* ----------------------------[private functions]---------------------------*/
/**
* Copy rom pcb data(r_pcb) to ram data
*
* @param pcb ram data
* @param r_pcb rom data
*/
static void copyPcbParts( OsTaskVarType *pcb, const OsTaskConstType *r_pcb ) {
pcb->activePriority = r_pcb->prio;
pcb->stack= r_pcb->stack;
pcb->constPtr = r_pcb;
}
#if (OS_NUM_CORES > 1)
/**
* This will not work in a cached system.
*/
static void syncCores(volatile boolean syncedCores[]) {
CoreIDType coreId = GetCoreID();
ASSERT(coreId < OS_NUM_CORES && coreId >= 0);
boolean syncOk = false;
ASSERT(syncedCores[coreId] == false);
syncedCores[coreId] = true;
while (!syncOk) {
syncOk = true;
for (int i = 0; i < OS_NUM_CORES; i++) {
if (syncedCores[i] == false) {
syncOk = false;
}
}
}
}
#endif
/* ----------------------------[public functions]----------------------------*/
/**
* Initialization of kernel structures and start of the first
* task.
*/
void InitOS( void ) {
uint32 i;
OsTaskVarType *tmpPcbPtr;
OsIsrStackType intStack;
uint8 *stackTop;
uint8 *stackBottom;
DEBUG(DEBUG_LOW,"os_init");
/* Clear sys */
memset(OS_SYS_PTR,0,sizeof(Os_SysType));
OS_SYS_PTR->status.init_os_called = TRUE; /** @req SWS_BSW_00071 */
OS_SYS_PTR->resScheduler = &resScheduler;
// Initialize suspend and disable count with higher value to avoid irq enable before os_start
Os_IntSuspendAllCnt = INITIAL_DISABLE_COUNT;
Os_IntDisableAllCnt = INITIAL_DISABLE_COUNT;
Os_ArchInit();
/* Get the numbers defined in the editor */
OS_SYS_PTR->isrCnt = OS_ISR_CNT;
OS_SYS_PTR->currApplId = INVALID_OSAPPLICATION;
// Assign pcb list and init ready queue
OS_SYS_PTR->pcb_list = Os_TaskVarList;
/*lint -e{9036} MISRA:EXTERNAL_FILE::[MISRA 2012 Rule 14.4, required] */
TAILQ_INIT(& (OS_SYS_PTR->ready_head));
#if defined(CFG_KERNEL_EXTRA)
TAILQ_INIT(& OS_SYS_PTR->timerHead);
#endif
// Calc interrupt stack
Os_IsrGetStackInfo(&intStack);
// Calculate interrupt stack, ARCH_BACKCHAIN_SIZE is common for all arch(16byes)
/*lint -e{923} MISRA:FALSE_POSITIVE:Pointer conversion and arithmetic operation for Stack calculation:[MISRA 2012 Rule 11.1, required] */
/*lint -e{9033} MISRA:FALSE_POSITIVE:Pointer conversion and arithmetic operation for Stack calculation:[MISRA 2012 Rule 10.8, required] */
OS_SYS_PTR->intStack = (void *)((size_t)intStack.top + (size_t)intStack.size - ARCH_BACKCHAIN_SIZE);
/* Set stack pattern */
stackTop = (uint8 *)intStack.top;
*stackTop = STACK_PATTERN;
/*lint -e{9016} -e{926} MISRA:PERFORMANCE:pointer arithmetic other than array indexing used, working with pointer in a controlled way results more simplified and readable code:[MISRA 2012 Rule 18.4, advisory] [MISRA 2012 Rule 11.5, advisory]*/
stackBottom = (uint8*) ((uint8 *)intStack.top + intStack.size);
*(stackBottom - 1UL) = STACK_PATTERN;
// Init counter.. with alarms and schedule tables
// Master core will initialize for all cores
/*lint -e774 MISRA:FALSE_POSITIVE:Multicore check:[MISRA 2012 Rule 14.3, required] */
if (OS_CORE_IS_ID_MASTER(GetCoreID())) {
#if OS_COUNTER_CNT!=0
Os_CounterInit();
#endif
#if OS_SCHTBL_CNT!=0
Os_SchTblInit();
#endif
#if (OS_NUM_CORES > 1)
IocInit();
#endif
}
// Put all tasks in the pcb list
// Put the one that belong in the ready queue there
for( i=0; i < OS_TASK_CNT; i++) {
tmpPcbPtr = Os_TaskGet((TaskType)i);
#if (OS_NUM_CORES > 1)
if (Os_OnRunningCore(OBJECT_TASK,i)) {
TAILQ_INIT(&tmpPcbPtr->spinlockHead);
#endif
copyPcbParts(tmpPcbPtr,&Os_TaskConstList[i]);
Os_TaskContextInit(tmpPcbPtr);
/*lint -e{9036} MISRA:EXTERNAL_FILE::[MISRA 2012 Rule 14.4, required] */
TAILQ_INIT(&tmpPcbPtr->resourceHead);
DEBUG(DEBUG_LOW,"pid:%d name:%s prio:%d\n",tmpPcbPtr->constPtr->pid,tmpPcbPtr->constPtr->name,tmpPcbPtr->activePriority);
#if (OS_NUM_CORES > 1)
}
#endif
DEBUG(DEBUG_LOW,"pid:%d name:%s prio:%d\n",tmpPcbPtr->constPtr->pid,tmpPcbPtr->constPtr->name,tmpPcbPtr->activePriority);
}
Os_ResourceInit();
// Now all tasks should be created.
}
static void os_start( void ) {
uint16 i;
OsTaskVarType *tmpPcbPtr = NULL_PTR; /*lint -e838, OK redefinition */
/* We will be setting up interrupts, but shall not be triggered until the Os starts */
Irq_Disable();
ASSERT(OS_SYS_PTR->status.init_os_called);
/* Call the startup hook */
#if (OS_NUM_CORES > 1)
syncCores(beforeStartHooks);
#endif
/** @req SWS_Os_00236 */ /** @req SWS_Os_00539 */ /* System specific startup hook called before application specific startup hook (see Os_ApplStart()) */
Os_CallStartupHook();
#if (OS_NUM_CORES > 1)
syncCores(afterStartHooks);
#endif
#if (OS_USE_APPLICATIONS == STD_ON)
/* Start applications */
Os_ApplStart();
#endif
/* Alarm autostart */
#if OS_ALARM_CNT!=0
Os_AlarmAutostart();
#endif
#if OS_SCHTBL_CNT!=0
/** @req SWS_Os_00510 */ /* Autostart of schedule tables after autostart of Tasks and Alarms */
Os_SchTblAutostart();
#endif
// Set up the systick interrupt
{
Os_SysTickInit();
#if (OS_NUM_CORES > 1)
Os_CoreNotificationInit();
#endif
if (OS_CORE_IS_ID_MASTER(GetCoreID())) {
#if defined(CFG_OS_SYSTICK2)
Os_SysTickStart2(OsTickFreq);
#else
uint32 sys_freq = Mcu_Arc_GetSystemClock();
Os_SysTickStart((TickType)(sys_freq/(uint32)OsTickFreq));
#endif
}
}
#if (OS_NUM_CORES > 1)
/* This is not an autosar req, but cores need to be synchronnized here because
* the isr handler uses shared data*/
syncCores(afterIsrSetup);
#endif
/* Find highest Autostart task */
{
OsTaskVarType *iterPcbPtr;
OsPriorityType topPrio;
// NOTE: only the master core has one idle task, we need one for each core
ASSERT(OS_TASK_CNT > 0u);
/* Assign Idle task first */
tmpPcbPtr = Os_TaskGet(0u);
topPrio = tmpPcbPtr->activePriority;
for(i=1;i<OS_TASK_CNT;i++) {
iterPcbPtr = Os_TaskGet(i);
#if (OS_NUM_CORES > 1)
if (Os_OnRunningCore(OBJECT_TASK,iterPcbPtr->constPtr->pid))
#endif
{
if( iterPcbPtr->constPtr->autostart != FALSE ) {
/* @CODECOV:OTHER_TEST_EXIST: Order is not set in the xml model so this may or may not be taken */
__CODE_COVERAGE_IGNORE__
if( (iterPcbPtr->activePriority > topPrio) ) {
tmpPcbPtr = iterPcbPtr;
topPrio = iterPcbPtr->activePriority;
}
}
}
}
}
OS_SYS_PTR->currTaskPtr = tmpPcbPtr;
#if (OS_USE_APPLICATIONS == STD_ON)
/* Set current application */
OS_SYS_PTR->currApplId = tmpPcbPtr->constPtr->applOwnerId;
#endif
// reset the suspend and disable count (which was set in os_init) to enable resume interrupt.
Os_SysIntClearAll();
// register this auto-start activation
ASSERT(tmpPcbPtr->activations <= tmpPcbPtr->constPtr->activationLimit);
#if (OS_STACK_MONITORING == 1)
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
/* check init stack */
/* @CODECOV:OTHER_TEST_EXIST: Tested in SIL */
__CODE_COVERAGE_IGNORE__
if( Os_ArchCheckStartStackMarker() != E_OK ) {
Os_CallProtectionHook(E_OS_STACKFAULT);
}
#endif
#endif
Os_TaskSwapContextTo(NULL_PTR,tmpPcbPtr);
// We should not return here
ASSERT(0);
}
/**
* Main function of the system
*/
/*lint -e970 MISRA:FALSE_POSITIVE:Return of main shall be int type:[MISRA 2012 Directive 4.6, advisory] */
int main( void )
{
EcuM_Init();
/* control will not come here */
return TRUE;
}
/**
* Starts the OS
*
* @param Mode - Application mode to start in
*
*/
/* @req OSEK_SWS_SS_00002 */
void StartOS(AppModeType Mode) {
OS_SYS_PTR->status.os_started = TRUE;
OS_SYS_PTR->appMode = Mode;
os_start();
/* Control shall not return here after os_start() */
/** @req SWS_Os_00424 */
ASSERT(0);
}
/**
* OS shutdown
*
* @param Error - Reason for shutdown
*/
/** @req SWS_Os_00071 */
/* @req OSEK_SWS_SS_00003 */
/* @CODECOV:OTHER_TEST_EXIST: Tested in SIL */
__CODE_COVERAGE_IGNORE__
void ShutdownOS( StatusType Error ) {
(void)Os_SystemFlagsSave(SYSTEM_FLAGS_IN_OS);
Irq_Disable();
Os_CallShutdownHook(Error);
/** @req SWS_Os_00425 */
/*lint -e716 MISRA:FALSE_POSITIVE:Infinite loop:[MISRA 2004 Info, advisory] */
/*lint -e9036 MISRA:FALSE_POSITIVE:Conditional expression not required for this while loop:[MISRA 2012 Rule 14.4, required] */
while(TRUE) { }
} /*lint !e715, OK reference */
|
2301_81045437/classic-platform
|
system/Os/rtos/src/os_init.c
|
C
|
unknown
| 11,738
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/** @reqSettings DEFAULT_SPECIFICATION_REVISION=4.3.0 */
#ifndef INTERNAL_H_
#define INTERNAL_H_
/*
* debug settings for os_debug_mask
*
*/
// print to STDOUT. If not set it prints to ramlog
#define D_STDOUT 0
#define D_RAMLOG 0
#define D_MASTER_PRINT 0
#define D_ISR_MASTER_PRINT 0
#define D_ISR_RAMLOG 0
#define D_TASK (1<<0)
#define D_ALARM (1<<1)
#define D_RESOURCE (1<<2)
#define D_SCHTBL (1<<3)
#define D_EVENT (1<<4)
#define D_MESSAGE (1<<5)
/*
* Configuration tree:
* USE_OS_DEBUG - Turn on/off all Os_DbgPrintf()
* SELECT_OS_CONSOLE - Select console
* USE_RAMLOG - Compile ramlog code...
*
*
* Default is to print to RAMLOG.
*
*
* Use cases:
* 1. We don't have a RAMLOG (low on RAM) so we want to print to serial console:
* #define CFG_OS_DEBUG = STD_ON
* #define USE_SERIAL_PORT
* #define SELECT_OS_CONSOLE=TTY_SERIAL0
* 2. We have a RAMLOG but we have a debugger connected and want the OS debug
* to go there instead:
* #define CFG_OS_DEBUG = STD_ON
* #define USE_RAMLOG
* #define USE_TTY_T32
* #define SELECT_OS_CONSOLE=TTY_T32
* 3. We have only the ramlog:
* #define CFG_OS_DEBUG = STD_ON
* #define USE_RAMLOG
* #define SELECT_OS_CONSOLE=TTY_RAMLOG
* 4. We use no debug.
* <empty>
*
*/
#if (CFG_OS_DEBUG == STD_ON)
# if (SELECT_OS_CONSOLE==RAMLOG)
# ifndef USE_RAMLOG
# error USE_RAMLOG must be defined.
# endif
# define OS_DEBUG(_mask,...) \
do { \
if( os_dbg_mask & (_mask) ) { \
ramlog_printf("[%08u] : ",(unsigned)GetOsTick()); \
ramlog_printf(__VA_ARGS__ ); \
}; \
} while(0);
# elif (SELECT_OS_CONSOLE==TTY_NONE)
# define OS_DEBUG(_mask,...)
# else
# define OS_DEBUG(_mask,...) \
do { \
if( os_dbg_mask & (_mask) ) { \
printf("[%08u] : %s %d ",(unsigned)GetOsTick(), __FUNCTION__, __LINE__ ); \
printf(__VA_ARGS__ ); \
}; \
} while(0);
# endif
#else
# define OS_DEBUG(_mask,...)
#endif
extern uint32 os_dbg_mask;
/* Error handling and hooks are implemented as Macros for readability and easy expansion */
/*
* Macros for error handling
* Registers service id of the erroneous function and the applicable parameters
* to os_error. Functions that have less than three parameters do not touch
* os_error.param3. Same rule follows for other parameter counts.
*/
/*lint -emacro(506, OS_STD_ERR_1, OS_STD_ERR_2, OS_STD_ERR_3) MISRA:FALSE_POSITIVE:"err" case is not evaluated at macro "call" Constant value Boolean:[MISRA 2012 Rule 2.1, required] */
/*lint -emacro(774, OS_STD_ERR_1, OS_STD_ERR_2, OS_STD_ERR_3) MISRA:FALSE_POSITIVE:"err" case is not evaluated at macro "call" Constant value Boolean:[MISRA 2012 Rule 14.3, required] */
/*lint -emacro(904, OS_STD_ERR, OS_STD_ERR_1, OS_STD_ERR_2, OS_STD_ERR_3) MISRA:FALSE_POSITIVE:Function returns to handle error condition:[MISRA 2012 Rule 15.5, advisory]*/
/* Error handling for functions that take no arguments */
#define OS_STD_ERR(_service_id) \
os_error.serviceId=_service_id;\
Os_CallErrorHook(rv); \
return rv // Expecting calling function to provide the ending semicolon
/* Error handling for functions that take one argument */
/*lint -emacro(923, OS_STD_ERR_1) MISRA:FALSE_POSITIVE:Allow any pointer type to integer type conversion used for error handling in this macro:[MISRA 2012 Rule 11.6, required]*/
#define OS_STD_ERR_1(_service_id, _p1) \
os_error.serviceId=_service_id;\
os_error.param1 = (uint32_t) _p1; \
Os_CallErrorHook(rv); \
return rv // Expecting calling function to provide the ending semicolon
/*lint -e{9036} MISRA:EXTERNAL_FILE::[MISRA 2012 Rule 14.4, required] */
/* Error handling for functions that take two arguments */
/*lint -emacro(923, OS_STD_ERR_2) MISRA:FALSE_POSITIVE:Allow any pointer type to integer type conversion used for error handling in this macro:[MISRA 2012 Rule 11.6, required]*/
#define OS_STD_ERR_2(_service_id, _p1,_p2) \
os_error.serviceId=_service_id;\
os_error.param1 = (uint32_t) _p1; \
os_error.param2 = (uint32_t) _p2; \
Os_CallErrorHook(rv); \
return rv // Expecting calling function to provide the ending semicolon
/* Error handling for functions that take three arguments */
/*lint -emacro(923, OS_STD_ERR_3) MISRA:FALSE_POSITIVE:Allow any pointer type to integer type conversion used for error handling in this macro:[MISRA 2012 Rule 11.6, required]*/
#define OS_STD_ERR_3(_service_id,_p1,_p2,_p3) \
os_error.serviceId=_service_id;\
os_error.param1 = (uint32_t) _p1; \
os_error.param2 = (uint32_t) _p2; \
os_error.param3 = (uint32_t) _p3; \
Os_CallErrorHook(rv); \
return rv // Expecting calling function to provide the ending semicolon
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
/*lint -emacro(923, OS_VALIDATE_ADDRESS_RANGE) MISRA:FALSE_POSITIVE:Allow any pointer type to integer type conversion used for error handling in this macro:[MISRA 2012 Rule 11.6, required]*/
#define OS_VALIDATE_ADDRESS_RANGE(_outParam,_size) Os_ValidAddressRange((uint32)_outParam,(uint32)_size)
#endif
#endif /*INTERNAL_H_*/
|
2301_81045437/classic-platform
|
system/Os/rtos/src/os_internal.h
|
C
|
unknown
| 6,160
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/** @reqSettings DEFAULT_SPECIFICATION_REVISION=4.3.0 */
/* ----------------------------[includes]------------------------------------*/
#include "irq.h"
#include "irq_types.h"
#include "os_i.h"
#if defined(CFG_TC2XX) || defined(CFG_TC3XX)
#include "IfxCpu.h"
#endif
/* ----------------------------[private define]------------------------------*/
#define ACK_INTERRUPT(_x) Irq_EOI(_x);
#if defined(CFG_LOG) && defined(LOG_OS_ISR)
#define _LOG_NAME_ "Os_Isr"
#endif
#include "log.h"
/* ----------------------------[private macro]-------------------------------*/
/* ----------------------------[private typedef]-----------------------------*/
/* ----------------------------[private function prototypes]-----------------*/
#if defined(CFG_OS_ISR_HOOKS)
static inline void Os_PreIsrHookStartI( OsIsrVarType *isrP );
static inline void Os_PreIsrHookStartPreemptI( OsIsrVarType *isrP );
static inline void Os_PostIsrHookPreemptI( OsIsrVarType *isrP );
static inline void Os_PostIsrHookTerminateI( OsIsrVarType *isrP );
#endif
static inline ISRType Os_CheckISRinstalled( const OsIsrConstType * isrPtr );
/* ----------------------------[private variables]---------------------------*/
#if (!defined(CFG_TC2XX) && !defined(CFG_TC3XX))
extern uint8 Os_VectorToIsr[NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS];
#endif
#if defined(CFG_ARMV7_M)
extern uint32 Os_ArchNestedIsr;
#endif
ISRType isrCnt = 0;
#if OS_ISR_CNT!=0
extern const OsIsrConstType Os_IsrConstList[OS_ISR_CNT];
#endif
#if OS_ISR_MAX_CNT!=0
OsIsrVarType Os_IsrVarList[OS_ISR_MAX_CNT];
#endif
uint8 Os_IsrStack[OS_NUM_CORES][OS_INTERRUPT_STACK_SIZE] __balign(0x10);
// IMPROVEMENT: remove. Make soft links or whatever
#if defined(CFG_ARM_CM3)
#include "irq_types.h"
#endif
/* ----------------------------[private functions]---------------------------*/
#if defined(CFG_OS_ISR_HOOKS)
/**
* Call external hook function.
*
* @param isrP Pointer to Isr
*/
static inline void Os_PreIsrHookStartI( OsIsrVarType *isrP ) {
Os_PreIsrHook(isrP->id);
}
static inline void Os_PreIsrHookStartPreemptI( OsIsrVarType *isrP ) {
#if defined(CFG_T1_ENABLE)
/* T1 figures out this state, so it does not want it */
#else
Os_PreIsrHook(isrP->id);
#endif
}
/**
* Call external hook function.
*
* @param isrP Pointer to Isr
*/
static inline void Os_PostIsrHookPreemptI( OsIsrVarType *isrP ) {
#if defined(CFG_T1_ENABLE)
/* T1 figures out this state, so it does not want it */
#else
Os_PostIsrHook(isrP->id);
#endif
}
/** */
static inline void Os_PostIsrHookTerminateI( OsIsrVarType *isrP ) {
Os_PostIsrHook(isrP->id);
}
#endif
static inline ISRType Os_CheckISRinstalled( const OsIsrConstType * isrPtr ) {
ISRType id;
#if defined(CFG_TC2XX) || defined(CFG_TC3XX)
id = (ISRType)Irq_GetISRinstalledId((uint8) isrPtr->priority);
#else
id = (ISRType)Os_VectorToIsr[isrPtr->vector + IRQ_INTERRUPT_OFFSET ];
#endif
return id;
}
static inline OsIsrVarType * Os_GetIsrVarType(uint16 isrIndex, uint16 *isrVector ) {
OsIsrVarType *isrVPtr = NULL_PTR;
/*lint -e578 MISRA:CONFIGURATION:initialising index based on configuration:[MISRA 2012 Rule 5.8, required]*/
uint16 index;
#if defined(CFG_TC2XX) || defined(CFG_TC3XX)
index = isrIndex;
#else
index = Os_VectorToIsr[isrIndex];
*isrVector = isrIndex;
#endif
ASSERT(index != VECTOR_ILL);
ASSERT(index < OS_ISR_MAX_CNT);
isrVPtr = &Os_IsrVarList[index]; /*lint !e838, OK redefinition */
#if defined(CFG_TC2XX) || defined(CFG_TC3XX)
*isrVector = (uint16)isrVPtr->constPtr->vector;
#endif
return isrVPtr;
}
/* ----------------------------[public functions]----------------------------*/
void Os_IsrAddWithId( const OsIsrConstType * isrPtr, ISRType id ) {
Os_IsrVarList[id].constPtr = isrPtr;
Os_IsrVarList[id].id = id;
#if defined(CFG_OS_ISR_HOOKS)
Os_IsrVarList[id].preemtedId = INVALID_ISR;
#endif
#if (!defined(CFG_TC2XX) && !defined(CFG_TC3XX))
Os_VectorToIsr[isrPtr->vector + IRQ_INTERRUPT_OFFSET ] = (uint8)id;
#endif
#if defined(CFG_TMS570) || defined(CFG_ARMV7_M) || defined(CFG_TRAVEO)
/*lint -e732 MISRA:OTHER:loss of sign:[MISRA 2004 Info, advisory] */
Irq_EnableVector2( isrPtr->entry, isrPtr->vector, isrPtr->type, isrPtr->priority, Os_ApplGetCore(isrPtr->appOwner) );
#elif defined(CFG_TC2XX) || defined(CFG_TC3XX)
Irq_EnableVector2( isrPtr->entry, isrPtr->vector, (uint16)id, isrPtr->priority, (uint8)IfxCpu_getCoreId() );
#else
Irq_EnableVector( isrPtr->vector, isrPtr->priority, Os_ApplGetCore(isrPtr->appOwner ) );
#endif
}
void Os_IsrInit( void ) {
Irq_Init();
isrCnt = OS_ISR_CNT;
/* May be possible to do this in another way*/
#if (!defined(CFG_TC2XX) && !defined(CFG_TC3XX))
memset(Os_VectorToIsr,VECTOR_ILL,(uint32)NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS);
#endif
#if OS_ISR_CNT != 0
/* Attach the interrupts */
GetSpinlock(OS_SPINLOCK);
for (ISRType i = 0; i < isrCnt; i++) {
Os_IsrAddWithId(&Os_IsrConstList[i],i);
/* Initialize the Isr linked list for resource handling */
/*lint -e{9036} MISRA:EXTERNAL_FILE::[MISRA 2012 Rule 14.4, required] */
TAILQ_INIT(&Os_IsrVarList[i].resourceHead);
}
ReleaseSpinlock(OS_SPINLOCK);
#endif
}
/**
* Adds an ISR to a list of Isr's. The ISRType (id) is returned
* for the "created" ISR.
*
* @param isrPtr Pointer to const data holding ISR information.
* @return
*/
ISRType Os_IsrAdd( const OsIsrConstType * isrPtr ) {
ISRType id;
ISRType installedId;
ASSERT( isrPtr != NULL_PTR );
ASSERT( (isrPtr->vector + IRQ_INTERRUPT_OFFSET) < NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS );
/* Check if we already have installed it */
installedId = Os_CheckISRinstalled( isrPtr );
if( installedId != VECTOR_ILL ) {
/* The vector is already installed */
id = installedId;
} else {
/* It a new vector */
#if (OS_NUM_CORES > 1)
GetSpinlock(OS_RTE_SPINLOCK);
#endif
id = isrCnt;
isrCnt++;
#if (OS_NUM_CORES > 1)
ReleaseSpinlock(OS_RTE_SPINLOCK);
#endif
/* Since OS_ISR_MAX_CNT defines the allocation limit for Os_IsrVarList,
* we must not allocate more IDs than that */
ASSERT(id<(ISRType)OS_ISR_MAX_CNT);
Os_IsrAddWithId(isrPtr,id);
}
return id;
}
#if !defined(BUILD_OS_SAFETY_PLATFORM)
void Os_IsrRemove( sint16 vector, sint16 type, uint8 priority, ApplicationType app ) {
#if defined(CFG_TC2XX) || defined(CFG_TC3XX)
/* Not suppored yet */
#else
(void)app;
(void)type;
(void)priority;
Os_VectorToIsr[vector + IRQ_INTERRUPT_OFFSET ] = VECTOR_ILL;
#endif
}
#endif
/*
* Resources:
* Irq_VectorTable[]
* Irq_IsrTypeTable[]
* Irq_PriorityTable[]
*
* exception table
* interrupt table
*
* Usual HW resources.
* - prio in HW (ppc and arm (even cortex m4))
*
*
* TOOL GENERATES ALL
* Irq_VectorTable CONST
* Irq_IsrTypeTable CONST
* Irq_PriorityTable CONST Can probably be a table with ISR_MAX number
* of for a CPU with prio registers. For masking
* CPUs it's better to keep an array to that indexing
* can be used.
*
* The problem with this approach is that the tool needs to know everything.
*
* TOOL GENERATES PART
* Irq_VectorTable VAR Since we must add vectors later
* Irq_IsrTypeTable VAR Since we must add vectors later
* Irq_PriorityTable VAR
*
*/
/*-----------------------------------------------------------------*/
void Os_IsrGetStackInfo( OsIsrStackType *stack ) {
stack->top = Os_IsrStack[GetCoreID()];
stack->size = sizeof(Os_IsrStack[GetCoreID()]);
}
OsIsrVarType *Os_IsrGet( ISRType id ) {
OsIsrVarType *rv = NULL_PTR;
#if OS_ISR_MAX_CNT != 0
if( id < isrCnt ) {
rv = &Os_IsrVarList[id];
}
#else
(void)id;
#endif
return rv;
}
ApplicationType Os_IsrGetApplicationOwner( ISRType id ) {
/** @req SWS_Os_00274 */
ApplicationType rv = (uint32)INVALID_OSAPPLICATION;
#if (OS_ISR_MAX_CNT!=0)
if( id < isrCnt ) {
rv = Os_IsrGet(id)->constPtr->appOwner;
}
#else
(void)id;
#endif
return rv;
}
#if ((OS_SC3 == STD_ON) || (OS_SC4 == STD_ON))
/**
@brief Check stackmarks for interrupt stack are ok.
* @return FALSE if the end-mark is not ok.
*/
static boolean Os_IsIsrStackmarkOk( void )
{
boolean rv = FALSE;
const uint8 *top = Os_IsrStack[GetCoreID()];
const uint8 *bottom = top + sizeof(Os_IsrStack[GetCoreID()]); /*lint !e9016 MISRA:PERFORMANCE:Calculation size:[MISRA 2012 Rule 18.4, advisory] */
if( ( *top == STACK_PATTERN ) && ( *(bottom - 1UL) == STACK_PATTERN ) ) {
rv = TRUE;
}
return rv;
}
/**
* @brief Perform stack check on system ISR
*
* @param id The ID of the application
*/
void Os_IsrStackPerformCheck( void ) {
#if (OS_STACK_MONITORING == 1)
/*lint --e{9036} MISRA:OTHER:Os_IsIsrStackmarkOk() return boolean value:[MISRA 2012 Rule 14.4, required]*/
if( Os_IsIsrStackmarkOk() == FALSE ) {
/** @req SWS_Os_00396
* If a stack fault is detected by stack monitoring AND the configured scalability
* class is 3 or 4, the Operating System module shall call the ProtectionHook() with
* the status E_OS_STACKFAULT.
* */
Os_CallProtectionHook(E_OS_STACKFAULT);
}
#endif /* (OS_STACK_MONITORING == 1) */
}
#endif
void *Os_Isr( void *stack, uint16 isrTableIndex)
{
OsIsrVarType *isrPtr = NULL_PTR;
OsTaskVarType *taskPtr = NULL_PTR;
OsIsrVarType *oldIsrPtr = NULL_PTR;
uint16 vector = 0;
#if defined(CFG_TC2XX) || defined(CFG_TC3XX)
uint32 *CSAPtr = NULL_PTR;
#endif
/*lint -e838 MISRA:OTHER:default value:[MISRA 2004 Info, advisory] */
isrPtr = Os_GetIsrVarType(isrTableIndex, &vector);
ASSERT( isrPtr != NULL_PTR );
#if defined(CFG_TMS570)
ASSERT( isrPtr->constPtr->type == ISR_TYPE_2 );
#else
if( isrPtr->constPtr->type == ISR_TYPE_1) {
oldIsrPtr = OS_SYS_PTR->currIsrPtr;
OS_SYS_PTR->currIsrPtr = isrPtr;
OS_SYS_PTR->intNestCnt++;
Irq_Enable();
isrPtr->constPtr->entry();
Irq_Disable();
OS_SYS_PTR->intNestCnt--;
OS_SYS_PTR->currIsrPtr = oldIsrPtr;
/*lint -e713 MISRA:OTHER:casting unsigned short to short:[MISRA 2004 Info, advisory]*/
ACK_INTERRUPT(vector);
return stack; /*lint !e904 MISRA:OTHER:return since the rest of the function is applicable for ISR_TYPE_2:[MISRA 2012 Rule 15.5, advisory]*/
}else{
ASSERT( isrPtr->constPtr->type == ISR_TYPE_2 );
}
#endif
/* Check if we interrupted a task or ISR */
#if defined(CFG_ARMV7_M)
if( (OS_SYS_PTR->intNestCnt + Os_ArchNestedIsr) == 0 ) {
#else
if( OS_SYS_PTR->intNestCnt == 0 ) {
#endif
/* We interrupted a task */
Os_CallPostTaskHook();
/* Save info for preempted pcb */
taskPtr = Os_SysTaskGetCurr();
#ifndef CFG_ARMV7_M
taskPtr->stack.curr = stack;
#endif
taskPtr->state = ST_READY;
OS_DEBUG(D_TASK,"Preempted %s\n",taskPtr->constPtr->name);
#if ((OS_SC3 == STD_ON) || (OS_SC4 == STD_ON))
/* Save current application */
ApplicationType curAppl = OS_SYS_PTR->currApplId;
OS_SYS_PTR->currApplId = INVALID_OSAPPLICATION;
#endif
Os_StackPerformCheck(taskPtr);
#if ((OS_SC3 == STD_ON) || (OS_SC4 == STD_ON))
OS_SYS_PTR->currApplId = curAppl;
#endif
#if defined (CFG_ARMV7_M)
} else if (Os_ArchNestedIsr == 1) {
/* Do nothing.
* We have a run the ISR but it's not terminated yet. */
#endif
} else {
/* We interrupted an ISR, save it */
oldIsrPtr = OS_SYS_PTR->currIsrPtr;
#if defined(CFG_OS_ISR_HOOKS)
isrPtr->preemtedId = oldIsrPtr->id;
Os_PostIsrHookPreemptI(oldIsrPtr);
#endif
}
OS_SYS_PTR->intNestCnt++;
isrPtr->state = ST_ISR_RUNNING;
OS_SYS_PTR->currIsrPtr = isrPtr;
Irq_SOI();
#if defined(CFG_ARM_CR4) || defined(CFG_TMS570LC43X)
Irq_SOI3(isrPtr->constPtr->priority);
#endif
#if defined(CFG_OS_ISR_HOOKS)
Os_PreIsrHookStartI(isrPtr);
#endif
#if defined(CFG_TRAVEO)
isrPtr->constPtr->entry();
#else
#if (OS_SC3==STD_ON) || (OS_SC4==STD_ON)
LOG_S_U32("entry: ",vector);
{
OsAppVarType *aP = Os_ApplGet(isrPtr->constPtr->appOwner);
if( aP->trusted == 0) {
/* Os_ArchCallIsrEntry will lock and unlock interrupts (so don't do that here ) */
OsAppVarType *paP = NULL_PTR;
LOG_S_U32("app: ",isrPtr->constPtr->appOwner);
/* Get preemted application */
if( oldIsrPtr != NULL_PTR ) {
paP = Os_ApplGet(oldIsrPtr->constPtr->appOwner);
LOG_S_U32("papp: ",oldIsrPtr->constPtr->appOwner);
} else {
ASSERT(taskPtr != NULL_PTR );
paP = Os_ApplGet(taskPtr->constPtr->applOwnerId);
LOG_S_U32("papp: ",taskPtr->constPtr->applOwnerId);
}
aP->nestCnt++;
OS_SYS_PTR->currApplId = aP->appId;
Os_ArchCallIsrEntry(aP,isrPtr->constPtr->entry,paP);
Os_AppIsrStackPerformCheck( isrPtr->constPtr->appOwner );
aP->nestCnt--;
} else {
OS_SYS_PTR->currApplId = aP->appId;
Irq_Enable();
isrPtr->constPtr->entry();
Os_IsrStackPerformCheck();
Irq_Disable();
}
}
LOG_S_U32("exit: ",vector);
#else
Irq_Enable();
isrPtr->constPtr->entry();
Irq_Disable();
#endif
#endif
#if defined(CFG_OS_ISR_HOOKS)
Os_PostIsrHookTerminateI(isrPtr);
if( isrPtr->preemtedId != INVALID_ISR ) {
OS_SYS_PTR->currIsrPtr = &Os_IsrVarList[isrPtr->preemtedId];
Os_PreIsrHookStartPreemptI( OS_SYS_PTR->currIsrPtr );
isrPtr->preemtedId = INVALID_ISR;
}
#endif
/* Check so that ISR2 haven't disabled the interrupts */
/** @req SWS_Os_00368 */
if( Os_SysIntAnyDisabled() ) {
Os_SysIntClearAll();
Os_CallErrorHook(E_OS_DISABLEDINT);
}
isrPtr->state = ST_ISR_NOT_RUNNING;
OS_SYS_PTR->currIsrPtr = isrPtr;
/*lint -e713 MISRA:OTHER:casting unsigned short to short:[MISRA 2004 Info, advisory]*/
ACK_INTERRUPT(vector);
--OS_SYS_PTR->intNestCnt;
#if defined (CFG_ARMV7_M)
return NULL_PTR;
#else
// We have preempted a task
if( (OS_SYS_PTR->intNestCnt == 0) ) {
OsTaskVarType *new_pcb = Os_TaskGetTop();
Os_StackPerformCheck(new_pcb);
/*lint -e{9007} MISRA:FALSE_POSITIVE:No side effects of Os_SchedulerResourceIsFree:[MISRA 2012 Rule 13.5, required]*/
if( (new_pcb == OS_SYS_PTR->currTaskPtr) ||
(OS_SYS_PTR->currTaskPtr->constPtr->scheduling == NON) )
{
/* Just bring the preempted task back to running */
OS_SYS_PTR->currTaskPtr->state = ST_RUNNING;
OS_SYS_PTR->currApplId = new_pcb->constPtr->applOwnerId;
Os_CallPreTaskHook();
#if (OS_SC3==STD_ON) || (OS_SC4==STD_ON)
// Set MPU memory regions for the resuming application
Os_MMSetUserMode(new_pcb);
#endif
#ifdef CFG_T1_ENABLE
Os_StartTaskHook(OS_SYS_PTR->currTaskPtr->constPtr->pid);
#endif
} else {
OS_DEBUG(D_TASK,"Found candidate %s\n",new_pcb->constPtr->name);
#if defined(CFG_TC2XX) || defined(CFG_TC3XX)
/* Mark context with 0, so that we can free it later */
/*lint -e{9027} MISRA:FALSE_POSITIVE:ASM and bitwise operations:[MISRA 2012 Rule 10.1, required]*/
/*lint -e{9033} MISRA:FALSE_POSITIVE:ASM and bitwise operations:[MISRA 2012 Rule 10.8, required]*/
/*lint -e{931} MISRA:FALSE_POSITIVE:ASM and bitwise operations:[MISRA 2012 Rule 13.2, required]*/
/*lint -e{923} MISRA:FALSE_POSITIVE:ASM and bitwise operations:[MISRA 2012 Rule 11.6, required]*/
CSAPtr = (uint32 *)CSA_TO_ADDRESS(_mfcr(CPU_PCXI));
CSAPtr[0] = 0;
#endif
Os_TaskSwapContextTo(NULL_PTR,new_pcb);
}
} else {
/* We have a nested interrupt */
OS_SYS_PTR->currApplId = oldIsrPtr->constPtr->appOwner;
OS_SYS_PTR->currIsrPtr = oldIsrPtr;
#if (OS_SC3==STD_ON) || (OS_SC4==STD_ON)
// Set MPU memory regions for the resuming application
Os_MMSetUserModeIsr(oldIsrPtr);
#endif
}
return stack;
#endif /*CFG_ARMV7_M*/
}
void Os_Arc_GetIsrInfo( Arc_PcbType *pcbPtr, ISRType isrId ) {
const OsIsrVarType *isrPtr = Os_IsrGet(isrId);
if( isrPtr != NULL_PTR ) {
strncpy(pcbPtr->name,Os_IsrGet(isrId)->constPtr->name,OS_ARC_PCB_NAME_SIZE);
}
}
ISRType Os_Arc_GetIsrCount( void ) {
return isrCnt;
}
/**
* This service returns the identifier of the currently executing ISR
*
* If its caller is not a category 2 ISR (or Hook routines called
* inside a category 2 ISR), GetISRID() shall return INVALID_ISR.
*
* @return
*/
/** @req SWS_Os_00511 OS provides the service GetISRID() */
/** @req SWS_Os_00515 GetISRID() available in all Scalability Classes. */
ISRType GetISRID( void ) {
ISRType id = INVALID_ISR;
/** @req SWS_Os_00264 */
if(OS_SYS_PTR->intNestCnt == 0 ) {
id = INVALID_ISR;
#if defined(CFG_ARM_CR4) || defined(CFG_ARM_CR5)
/* The pre-/post on cortex-r is very short so we don't record any information */
#else
} else if( Os_SysIsrGetCurr()->constPtr->type == ISR_TYPE_1 ) {
id = INVALID_ISR;
#endif
} else {
id = (ISRType)Os_SysIsrGetCurr()->id;
}
/** @req SWS_Os_00263 */
return id;
}
|
2301_81045437/classic-platform
|
system/Os/rtos/src/os_isr.c
|
C
|
unknown
| 18,990
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/**
* @brief Message Box
*
* @addtogroup OS
* @details Implements APIs to post and fetch messages to/from a message box.
* The message box only supports one datatype, OsMBoxMsg (uint32_t)
* .
* Design:
* Posting a message is a matter of adding the message to the message
* box and signal the semaphore.
* Fetching will wait for the semaphore to be signaled, then get the message
* from the mailbox.
* Messages are added/remove in FIFO order and is implemented by a
* circular buffer.
* .
* The API is tuned to make it easy to port LWIP. The LWIP API is:
* - sys_mbox_t sys_mbox_new(int size)
* - sys_mbox_free(sys_mbox_t mbox):
* - sys_mbox_post(sys_mbox_t mbox, void *msg):
* - u32_t sys_arch_mbox_fetch(sys_mbox_t mbox, void **msg, u32_t timeout).
* - (u32_t sys_arch_mbox_tryfetch(sys_mbox_t mbox, void **msg) )
* .
*
* @{
*/
/* ----------------------------[includes]------------------------------------*/
#include "os_i.h"
#include "os_sem.h"
#include "os_mbox.h"
#if defined(CFG_LOG) && (LOG_OS_MBOX)
#define _LOG_NAME_ "os_mbox"
#endif
#include "log.h"
/* ----------------------------[private define]------------------------------*/
/* ----------------------------[private macro]-------------------------------*/
/* ----------------------------[private typedef]-----------------------------*/
/* ----------------------------[private function prototypes]-----------------*/
/* ----------------------------[private variables]---------------------------*/
/* ----------------------------[private functions]---------------------------*/
/* ----------------------------[public functions]----------------------------*/
void MBoxInit( OsMBoxType *mbox, OsMBoxMsg *msgBuff, uint32 msgCnt ) {
LOG_S("Init");
mbox->msgBuff = msgBuff;
mbox->maxCnt = msgCnt;
mbox->putPtr = msgBuff;
mbox->getPtr = msgBuff;
mbox->topPtr = msgBuff + msgCnt;
/* Set current count */
mbox->cnt = 0UL;
SemInit(&mbox->sem,SEM_LOCKED);
}
StatusType MBoxPost(OsMBoxType *mbox, OsMBoxMsg msg) {
StatusType rv = E_OK;
imask_t flags;
ASSERT(mbox != NULL);
LOG_S("Post");
Irq_Save(flags);
/* Check if it's full or not */
if( mbox->cnt >= mbox->maxCnt ) {
rv = E_OS_FULL;
} else {
mbox->cnt++;
*mbox->putPtr = msg;
mbox->putPtr++;
if( mbox->putPtr >= mbox->topPtr ) {
mbox->putPtr = mbox->msgBuff;
}
/* Wake waiting thread */
rv = SemSignal(&mbox->sem);
}
Irq_Restore(flags);
return rv;
}
StatusType MBoxFetchTmo(OsMBoxType *mbox, OsMBoxMsg *msg, uint32 tmo) {
StatusType rv;
imask_t flags;
LOG_S("FetchTmo");
Irq_Save(flags);
rv = SemWaitTmo(&mbox->sem,tmo);
if( rv == E_OK ) {
*msg = *mbox->getPtr;
mbox->getPtr++;
if( mbox->getPtr >= mbox->topPtr ) {
mbox->getPtr = mbox->msgBuff;
}
ASSERT(mbox->cnt > 0 );
--mbox->cnt;
}
Irq_Restore(flags);
return rv;
}
/** @} */
|
2301_81045437/classic-platform
|
system/Os/rtos/src/os_mbox.c
|
C
|
unknown
| 4,054
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#include "os_i.h"
void StartCore(CoreIDType CoreID, StatusType* Status) {
if (CoreID >= OS_NUM_CORES) {
*Status = E_OS_ID;
}
else if (Os_Sys[CoreID].status.os_started) {
*Status = E_OS_ACCESS;
}
else if (Os_Sys[CoreID].status.activated) {
*Status = E_OS_STATE;
} else {
boolean validId = Os_StartCore(CoreID);
if (!validId) {
*Status = E_OS_ID;
} else {
Os_Sys[CoreID].status.activated = true;
*Status = E_OK;
}
}
}
boolean Os_OnRunningCore(ObjectTypeType ObjectType, uint32_t objectId) {
ApplicationType app = CheckObjectOwnership(ObjectType,objectId);
if (Os_ApplGetCore(app) == GetCoreID()) {
return true;
}
else {
return false;
}
}
|
2301_81045437/classic-platform
|
system/Os/rtos/src/os_multicore.c
|
C
|
unknown
| 1,582
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef MULTICORE_H_
#define MULTICORE_H_
#if (OS_NUM_CORES > 1)
#include "application.h"
#include "sys.h"
typedef struct {
OsServiceIdType op;
uint32_t arg1;
uint32_t arg2;
uint32_t arg3;
boolean opFinished;
StatusType result;
} OsCoreMessageBoxType;
boolean Os_OnRunningCore(ObjectTypeType ObjectType, uint32_t objectId);
void Os_CoreNotificationInit();
StatusType Os_NotifyCore(CoreIDType coreId, OsServiceIdType op,
uint32_t arg1, uint32_t arg2, uint32_t arg3);
#else
/*lint -emacro(506, Os_OnRunningCore) MISRA:FALSE_POSITIVE:For always evaluating as true:[MISRA 2012 Rule 2.1, required]*/
/*lint -emacro(774, Os_OnRunningCore) MISRA:FALSE_POSITIVE:For always evaluating as true:[MISRA 2012 Rule 14.3, required]*/
#define Os_OnRunningCore(x,y) true
#endif
#endif /* MULTICORE_H_ */
|
2301_81045437/classic-platform
|
system/Os/rtos/src/os_multicore_i.h
|
C
|
unknown
| 1,628
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/** @reqSettings DEFAULT_SPECIFICATION_REVISION=4.3.0 */
#include "os_i.h"
/**
* Interpret the exception and call ProtectionHook/Shutdown hook
* with a E_OS_xx as argument
*
* @param exception The exception number
* @param pData
*/
void Os_Arc_Panic(uint32 exception, void *pData) {
(void)pData; /*lint !e920 MISRA:FALSE_POSITIVE:Allowed to cast pointer to void here:[MISRA 2012 Rule 1.3, required]*/
StatusType protArg;
protArg = Os_ArchGetProtectionType(exception);
Os_CallProtectionHook(protArg);
}
|
2301_81045437/classic-platform
|
system/Os/rtos/src/os_panic.c
|
C
|
unknown
| 1,314
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/** @reqSettings DEFAULT_SPECIFICATION_REVISION=4.3.0 */
#include "os_i.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
/*
* Implementation notes:
* Error checks for E_OS_ID and E_OS_VALUE are not used. For
* the safety platform it's enough that we check that values are
* within application range.
*
* E_OS_CALLEVEL is probably wrong in the Autosar specification,
* you should be able read/write from interrupt context.
*
* NOT Supported:
* [SWS_Os_00806]
*
*
*/
/**
* Function to check if a region should be checked at all.
*/
static boolean shouldCheckRegion( void ) {
boolean rv = FALSE;
ApplicationType currApp = GetApplicationID();
/* @CODECOV:OTHER_TEST_EXIST: Tested during SIL only */
__CODE_COVERAGE_IGNORE__
if( (OS_SYS_PTR->osFlags & SYSTEM_FLAGS_IN_OS) == 0u ) {
__CODE_COVERAGE_IGNORE__
if( currApp != INVALID_OSAPPLICATION ) {
const OsAppConstType *aConstP = Os_ApplGetConst(currApp);
if( aConstP->trusted == 0u ) {
rv = TRUE;
}
}
}
return rv;
}
/* Keep MISRA happy function */
static boolean checkRange( AreaIdType Area, uint32 Address, uint32 ReadValue, uint32 size ) {
boolean rv = FALSE;
if( shouldCheckRegion() == TRUE ) {
if( Os_MMValidPerAddressRange(Area, (uint32)Address, size) == TRUE ) {
if( Os_ValidAddressRange((uint32)ReadValue, size ) == TRUE ) {
rv = TRUE;
}
}
} else {
rv = TRUE;
}
return rv;
}
#endif
/**
* @brief Function to read peripheral 8-bit address
* @details
* @param Area
* @param Address The address to read
* @param ReadValue Content of the given memory location
* @retval E_OK If area is valid
*/
StatusType Os_ReadPeripheral8 ( AreaIdType Area, const uint8 * Address, uint8 * ReadValue) {
/*lint -e{920} MISRA:STANDARDIZED_INTERFACE::[MISRA 2012 Rule 2.7, advisory] */
(void)Area;
/*lint -e{923} MISRA:STANDARDIZED_INTERFACE:: cast from pointer to unsigned int [MISRA 2012 Rule 11.1, required], [MISRA 2012 Rule 11.4, advisory], [MISRA 2012 Rule 11.6, required] */
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
StatusType rv = E_OK;
OS_VALIDATE_STD( ( checkRange( Area, (uint32)Address,(uint32)ReadValue, sizeof(uint8) ) == TRUE) ,
E_OS_ILLEGAL_ADDRESS ,
OSServiceId_ReadPeripheral8 );
#endif
*ReadValue = *Address;
return E_OK;
}
/**
* @brief Function to read peripheral 16-bit address
* @details
* @param Area
* @param Address The address to read
* @param ReadValue Content of the given memory location
* @retval E_OK If area is valid
*/
StatusType Os_ReadPeripheral16( AreaIdType Area, const uint16 * Address, uint16 * ReadValue) {
/*lint -e{920} MISRA:STANDARDIZED_INTERFACE::[MISRA 2012 Rule 2.7, advisory] */
(void)Area;
/*lint -e{923} MISRA:STANDARDIZED_INTERFACE:: cast from pointer to unsigned int [MISRA 2012 Rule 11.1, required], [MISRA 2012 Rule 11.4, advisory], [MISRA 2012 Rule 11.6, required] */
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
StatusType rv = E_OK;
OS_VALIDATE_STD( ( checkRange( Area, (uint32)Address,(uint32)ReadValue, sizeof(uint16)) == TRUE) ,
E_OS_ILLEGAL_ADDRESS ,
OSServiceId_ReadPeripheral16 );
#endif
*ReadValue = *Address;
return E_OK;
}
/**
* @brief Function to read peripheral 32-bit address
* @details
* @param Area
* @param Address The address to read
* @param ReadValue Content of the given memory location
* @retval E_OK If area is valid
*/
StatusType Os_ReadPeripheral32( AreaIdType Area, const uint32 * Address, uint32 * ReadValue) {
/*lint -e{920} MISRA:STANDARDIZED_INTERFACE::[MISRA 2012 Rule 2.7, advisory] */
(void)Area;
/*lint -e{923} MISRA:STANDARDIZED_INTERFACE:: cast from pointer to unsigned int [MISRA 2012 Rule 11.1, required], [MISRA 2012 Rule 11.4, advisory], [MISRA 2012 Rule 11.6, required] */
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
StatusType rv = E_OK;
OS_VALIDATE_STD( ( checkRange( Area, (uint32)Address,(uint32)ReadValue, sizeof(uint32)) == TRUE) ,
E_OS_ILLEGAL_ADDRESS ,
OSServiceId_ReadPeripheral32);
#endif
*ReadValue = *Address;
return E_OK;
}
/**
* @brief Function to write peripheral 8-bit address
* @details
* @param Area
* @param Address The address to read
* @param ReadValue Content of the given memory location
* @retval E_OK If area is valid
*/
StatusType Os_WritePeripheral8 ( AreaIdType Area, uint8 *Address, uint8 WriteValue) {
/*lint -e{920} MISRA:STANDARDIZED_INTERFACE::[MISRA 2012 Rule 2.7, advisory] */
(void)Area;
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
StatusType rv = E_OK;
if( shouldCheckRegion() == TRUE ) {
/*lint -e{923} MISRA:STANDARDIZED_INTERFACE:: cast from pointer to unsigned int [MISRA 2012 Rule 11.4, advisory], [MISRA 2012 Rule 11.6, required] */
OS_VALIDATE_STD( (Os_MMValidPerAddressRange( Area,(uint32)Address,(uint32)sizeof(uint8)) == TRUE) ,
E_OS_ILLEGAL_ADDRESS , OSServiceId_WritePeripheral8);
}
#endif
*Address = WriteValue;
return E_OK;
}
/**
* @brief Function to write peripheral 16-bit address
* @details
* @param Area
* @param Address The address to read
* @param ReadValue Content of the given memory location
* @retval E_OK If area is valid
*/
StatusType Os_WritePeripheral16( AreaIdType Area, uint16 *Address, uint16 WriteValue) {
/*lint -e{920} MISRA:STANDARDIZED_INTERFACE::[MISRA 2012 Rule 2.7, advisory] */
(void)Area;
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
StatusType rv = E_OK;
if( shouldCheckRegion() == TRUE ) {
/*lint -e{923} MISRA:STANDARDIZED_INTERFACE:: cast from pointer to unsigned int [MISRA 2012 Rule 11.4, advisory], [MISRA 2012 Rule 11.6, required] */
OS_VALIDATE_STD( (Os_MMValidPerAddressRange( Area,(uint32)Address,(uint32)sizeof(uint16)) == TRUE) ,
E_OS_ILLEGAL_ADDRESS , OSServiceId_WritePeripheral16);
}
#endif
*Address = WriteValue;
return E_OK;
}
/**
* @brief Function to write peripheral 16-bit address
* @details
* @param Area
* @param Address The address to read
* @param ReadValue Content of the given memory location
* @retval E_OK If area is valid
*/
StatusType Os_WritePeripheral32( AreaIdType Area, uint32 *Address, uint32 WriteValue) {
/*lint -e{920} MISRA:STANDARDIZED_INTERFACE::[MISRA 2012 Rule 2.7, advisory] */
(void)Area;
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
StatusType rv = E_OK;
if( shouldCheckRegion() == TRUE ) {
/*lint -e{923} MISRA:STANDARDIZED_INTERFACE:: cast from pointer to unsigned int [MISRA 2012 Rule 11.4, advisory], [MISRA 2012 Rule 11.6, required] */
OS_VALIDATE_STD( (Os_MMValidPerAddressRange( Area,(uint32)Address,(uint32)sizeof(uint32)) == TRUE) ,
E_OS_ILLEGAL_ADDRESS , OSServiceId_WritePeripheral32);
}
#endif
*Address = WriteValue;
return E_OK;
}
/**
* @brief Function to modify peripheral 8-bit address
* @details
* @param Area
* @param Address The address to read
* @param ClearMask Address will be modified with bit-AND
* @param SetMask Address will be modified with bit-OR
* @retval E_OK If area is valid
*/
StatusType Os_ModifyPeripheral8( AreaIdType Area, uint8 *Address, uint8 ClearMask, uint8 SetMask) {
/*lint -e{920} MISRA:STANDARDIZED_INTERFACE::[MISRA 2012 Rule 2.7, advisory] */
(void)Area;
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
StatusType rv = E_OK;
if( shouldCheckRegion() == TRUE ) {
/*lint -e{923} MISRA:STANDARDIZED_INTERFACE:: cast from pointer to unsigned int [MISRA 2012 Rule 11.4, advisory], [MISRA 2012 Rule 11.6, required] */
OS_VALIDATE_STD( (Os_MMValidPerAddressRange( Area,(uint32)Address,(uint32)sizeof(uint8)) == TRUE) ,
E_OS_ILLEGAL_ADDRESS , OSServiceId_ModifyPeripheral8);
}
#endif
*Address = ((*Address & ClearMask) | SetMask);
return E_OK;
}
/**
* @brief Function to modify peripheral 16-bit address
* @details
* @param Area
* @param Address The address to read
* @param ClearMask Address will be modified with bit-AND
* @param SetMask Address will be modified with bit-OR
* @retval E_OK If area is valid
*/
StatusType Os_ModifyPeripheral16( AreaIdType Area, uint16 *Address, uint16 ClearMask, uint16 SetMask) {
/*lint -e{920} MISRA:STANDARDIZED_INTERFACE::[MISRA 2012 Rule 2.7, advisory] */
(void)Area;
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
StatusType rv = E_OK;
if( shouldCheckRegion() == TRUE ) {
/*lint -e{923} MISRA:STANDARDIZED_INTERFACE:: cast from pointer to unsigned int [MISRA 2012 Rule 11.4, advisory], [MISRA 2012 Rule 11.6, required] */
OS_VALIDATE_STD( (Os_MMValidPerAddressRange( Area,(uint32)Address,(uint32)sizeof(uint16)) == TRUE) ,
E_OS_ILLEGAL_ADDRESS , OSServiceId_ModifyPeripheral16);
}
#endif
*Address = ((*Address & ClearMask) | SetMask);
return E_OK;
}
/**
* @brief Function to modify peripheral 32-bit address
* @details
* @param Area
* @param Address The address to read
* @param ClearMask Address will be modified with bit-AND
* @param SetMask Address will be modified with bit-OR
* @retval E_OK If area is valid
*/
StatusType Os_ModifyPeripheral32( AreaIdType Area, uint32 *Address, uint32 ClearMask, uint32 SetMask) {
/*lint -e{920} MISRA:STANDARDIZED_INTERFACE::[MISRA 2012 Rule 2.7, advisory] */
(void)Area;
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
StatusType rv = E_OK;
if( shouldCheckRegion() == TRUE ) {
/*lint -e{923} MISRA:STANDARDIZED_INTERFACE:: cast from pointer to unsigned int [MISRA 2012 Rule 11.4, advisory], [MISRA 2012 Rule 11.6, required] */
OS_VALIDATE_STD( (Os_MMValidPerAddressRange( Area,(uint32)Address,(uint32)sizeof(uint32)) == TRUE) ,
E_OS_ILLEGAL_ADDRESS , OSServiceId_ModifyPeripheral32);
}
#endif
*Address = ((*Address & ClearMask) | SetMask);
return E_OK;
}
|
2301_81045437/classic-platform
|
system/Os/rtos/src/os_peripheral.c
|
C
|
unknown
| 11,543
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/** @reqSettings DEFAULT_SPECIFICATION_REVISION=4.3.0 */
#include "os_i.h"
#if !defined(MAX)
#define MAX(_x,_y) (((_x) > (_y)) ? (_x) : (_y))
#endif
/* INFO
* - If OsTaskSchedule = NON, Task it not preemptable, no internal resource may be assigned to a task
* (cause it already have one of prio 32)
* FULL, Task is preemptable
* - On Schedule() .... This service has no influence on tasks with no internal resource
* assigned (preemptable tasks).
*
* OSEK on internal resources:
* - Non preemptable tasks are a special group with an internal resource of the
* same priority as RES_SCHEDULER assigned
*
*
* Assign RES_SCHEDULER with prio 32.
* Assign internal resources to NON preemptable task.
*
* So that leaves us with:
* - NON
* - Cannot assign internal resource.
* It automatically gets internal resource with same prio as RES_SCHEDULER
*
* - FULL
* - Assigned. Used for grouping tasks.
* - No assigned.
*
* What does that mean?
* - It's probably OK to do a GetResource(RES_SCHEDULER) from a NON task (although pointless)
* - GetResource(<any>) from a NON task is wrong
*
* Generation/Implementation:
* - Resources to 32. Alloc with .resourceAlloc = ((1<<RES_1) |(1<<RES_2));
* - Keep allocated resources as stack to comply with LIFO order.
* - A linked resource is just another name for an existing resource. See OsResource in Autosar SWS OS.
* This means that no resource object should be generated, just the define in Os_Cfg.h
* - A task with Scheduling=NON have priority (although it's internal priority is 32)
*
*/
struct OsResource resScheduler;
/**
* This call serves to enter critical sections in the code that are
* assigned to the resource referenced by <ResID>. A critical
* section shall always be left using ReleaseResource.
*
* The OSEK priority ceiling protocol for resource management is described
* in chapter 8.5. Nested resource occupation is only allowed if the inner
* critical sections are completely executed within the surrounding critical
* section (strictly stacked, see chapter 8.2, Restrictions when using
* resources). Nested occupation of one and the same resource is also
* forbidden! It is recommended that corresponding calls to GetResource and
* ReleaseResource appear within the same function.
*
* It is not allowed to use services which are points of rescheduling for
* non preemptable tasks (TerminateTask,ChainTask, Schedule and WaitEvent,
* see chapter 4.6.2) in critical sections.
* Additionally, critical sections are to be left before completion of
* an interrupt service routine.
* Generally speaking, critical sections should be short.
* The service may be called from an from task level (see Figure 12-1).
* Resource access in ISR is not supported.
*
* @param ResID
* @return
*/
/* @req OSEK_SWS_RM_00010 */
StatusType GetResource( ResourceType ResID ) {
StatusType rv = E_OK;
OsResourceType *rPtr;
imask_t flags;
/* Validation of parameters, if failure, function will return */
/* This is not inline with Table 8, ISO26262-6:2011, Req 1a and 1h */
OS_VALIDATE_STD_1((Os_SysIntAnyDisabled() == FALSE) , E_OS_DISABLEDINT,
OSServiceId_GetResource,ResID); /* @req SWS_Os_00093 */
/* RES_SCHEDULER is assigned OS_RESOURCE_CNT, so OS_RESOURCE_CNT is a valid Id */
OS_VALIDATE_STD_1((ResID <= OS_RESOURCE_CNT), E_OS_ID,
OSServiceId_GetResource,ResID); /* @req OSEK_SWS_RM_00001 */ /*lint !e775 MISRA:CONFIGURATION:argument check:[MISRA 2004 Info, advisory] */
#if (OS_APPLICATION_CNT > 1)
if (ResID != RES_SCHEDULER) {
rv = Os_ApplHaveAccess( Os_ResourceGet(ResID)->accessingApplMask );
if( rv != E_OK ) {
/* OS_STD_ERR_1: Function will return after calling ErrorHook */
/* This is not inline with Table 8, ISO26262-6:2011, Req 1a and 1h */
OS_STD_ERR_1(OSServiceId_GetResource,ResID);
}
}
#endif
Irq_Save(flags);
if( OS_SYS_PTR->intNestCnt != 0 ) {
/* Interrupt requesting for resource is not supported */
rv = E_OS_ISR_RESOURCE;
Irq_Restore(flags);
/* OS_STD_ERR_1: Function will return after calling ErrorHook */
/* This is not inline with Table 8, ISO26262-6:2011, Req 1a and 1h */
OS_STD_ERR_1(OSServiceId_GetResource,ResID);
} else {
OsTaskVarType *taskPtr = Os_SysTaskGetCurr();
if( ResID == RES_SCHEDULER ) {
rPtr = OS_SYS_PTR->resScheduler;
} else {
/* Check we can access it:
* 1. we don't have access to the resource
* 2. resource already taken
* 3. We don't have priority less than ceiling priority
*/
rPtr = Os_ResourceGet(ResID);
if( ((taskPtr->constPtr->resourceAccess & (1UL<< ResID)) == 0) || /* 1 */
(rPtr->owner != NO_TASK_OWNER) || /* 2 */
(taskPtr->activePriority > rPtr->ceiling_priority) ) { /* 3 */
rv = E_OS_ACCESS; /* @req OSEK_SWS_RM_00003 */
Irq_Restore(flags);
/* OS_STD_ERR_1: Function will return after calling ErrorHook */
/* This is not inline with Table 8, ISO26262-6:2011, Req 1a and 1h */
OS_STD_ERR_1(OSServiceId_GetResource,ResID);
}
}
/* Add the resource to the list of resources held by this task */
Os_TaskResourceAdd(rPtr,taskPtr);
}
Irq_Restore(flags);
return rv;
}
/**
* ReleaseResource is the counterpart of GetResource and
* serves to leave critical sections in the code that are assigned to
* the resource referenced by <ResID>.
*
* For information on nesting conditions, see particularities of
* GetResource. The service may be called from an task level.
* resource access from ISR is not supported.
*
* @param ResID
* @return
*/
/* @req OSEK_SWS_RM_00011*/
StatusType ReleaseResource( ResourceType ResID) {
StatusType rv = E_OK;
OsTaskVarType *pcbPtr = Os_SysTaskGetCurr();
OsResourceType *rPtr;
imask_t flags;
/* Validation of parameters, if failure, function will return */
/* This is not inline with Table 8, ISO26262-6:2011, Req 1a and 1h */
OS_VALIDATE_STD_1((Os_SysIntAnyDisabled() == FALSE) , E_OS_DISABLEDINT,
OSServiceId_ReleaseResource,ResID); /* @req SWS_Os_00093 */
/* RES_SCHEDULER is assigned OS_RESOURCE_CNT, so OS_RESOURCE_CNT is a valid Id */
OS_VALIDATE_STD_1((ResID <= OS_RESOURCE_CNT), E_OS_ID,
OSServiceId_ReleaseResource,ResID); /* @req OSEK_SWS_RM_00005*/ /*lint !e775 MISRA:CONFIGURATION:argument check:[MISRA 2004 Info, advisory] */
Irq_Save(flags);
if( OS_SYS_PTR->intNestCnt != 0 ) {
/* Interrupt's release request for resource is not supported */
rv = E_OS_ISR_RESOURCE;
Irq_Restore(flags);
OS_STD_ERR_1(OSServiceId_ReleaseResource,ResID);
}
else
{
/* OS_STD_ERR_1: Function will return after calling ErrorHook */
/* This is not inline with Table 8, ISO26262-6:2011, Req 1a and 1h */
if( ResID == RES_SCHEDULER ) {
rPtr = OS_SYS_PTR->resScheduler;
} else {
/* Check we can access it */
if( (pcbPtr->constPtr->resourceAccess & (1UL<< ResID)) == 0 ) {
rv = E_OS_ID;
OS_STD_ERR_1(OSServiceId_ReleaseResource,ResID);
}
rPtr = Os_ResourceGet(ResID);
}
/* Check for invalid configuration */
if( rPtr->owner == NO_TASK_OWNER)
{
rv = E_OS_NOFUNC; /* @req OSEK_SWS_RM_00008 */
Irq_Restore(flags);
OS_STD_ERR_1(OSServiceId_ReleaseResource,ResID);
}
ASSERT(pcbPtr->activePriority >= rPtr->ceiling_priority);
Os_TaskResourceRemove(rPtr,pcbPtr);
/* do a rescheduling (in some cases) (see OSEK OS 4.6.1) */
if ( (pcbPtr->constPtr->scheduling == FULL) ) {
const OsTaskVarType* top_pcb = Os_TaskGetTop();
/* only dispatch if some other ready task has higher prio */
if (top_pcb->activePriority > Os_SysTaskGetCurr()->activePriority) {
Os_Dispatch(OP_RELEASE_RESOURCE);
}
}
}
Irq_Restore(flags);
return rv;
}
void Os_ResourceGetInternal( void ) {
OsTaskVarType *pcbPtr = Os_SysTaskGetCurr();
OsResourceType *rPtr = pcbPtr->constPtr->resourceIntPtr;
if( rPtr != NULL_PTR ) {
OS_DEBUG(D_RESOURCE,"Get IR proc:%s prio:%u old_task_prio:%u\n",
Os_SysTaskGetCurr()->constPtr->name,
(unsigned)rPtr->ceiling_priority,
(unsigned)rPtr->old_task_prio);
Os_TaskResourceAdd(rPtr,pcbPtr);
}
}
void Os_ResourceReleaseInternal( void ) {
OsTaskVarType *pcbPtr = Os_SysTaskGetCurr();
OsResourceType *rPtr = pcbPtr->constPtr->resourceIntPtr;
if( rPtr != NULL_PTR ) {
OS_DEBUG(D_RESOURCE,"Rel IR proc:%s prio:%u old_task_prio:%u\n",
Os_SysTaskGetCurr()->constPtr->name,
(unsigned)rPtr->ceiling_priority,
(unsigned)rPtr->old_task_prio);
Os_TaskResourceRemove(rPtr,pcbPtr);
}
}
/**
*
* @param pcb_p
* @return
*/
void Os_ResourceInit( void ) {
#if (OS_RESOURCE_CNT > 0)
const OsTaskVarType *pcb_p;
OsResourceType *rsrc_p;
OsPriorityType topPrio;
#endif
/* For now, assign the scheduler resource here */
OS_SYS_PTR->resScheduler->ceiling_priority = OS_RES_SCHEDULER_PRIO;
strcpy(OS_SYS_PTR->resScheduler->id,"RES_SCHEDULER");
OS_SYS_PTR->resScheduler->nr = RES_SCHEDULER;
OS_SYS_PTR->resScheduler->owner = NO_TASK_OWNER;
/* Calculate ceiling priority
* We make this as simple as possible. The ceiling priority
* is set to the same priority as the highest priority task that
* access it.
*
* Note that this applies both internal and standard resources.
* */
#if (OS_RESOURCE_CNT > 0)
for( uint32 i=0; i < OS_RESOURCE_CNT; i++) {
rsrc_p = Os_ResourceGet((ResourceType)i);
topPrio = 0;
for( TaskType pi = 0; pi < OS_TASK_CNT; pi++) {
pcb_p = Os_TaskGet(pi);
if((pcb_p->constPtr->resourceAccess & (1UL<<i)) != FALSE) {
topPrio = MAX(topPrio,pcb_p->constPtr->prio);
}
}
rsrc_p->ceiling_priority = topPrio;
}
#endif
}
|
2301_81045437/classic-platform
|
system/Os/rtos/src/os_resource.c
|
C
|
unknown
| 11,607
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/** @reqSettings DEFAULT_SPECIFICATION_REVISION=4.3.0 */
#ifndef RESOURCE_I_H_
#define RESOURCE_I_H_
/**
* STD container: OsResource
* OsResourceProperty: 1 INTERNAL, LINKED, STANDARD
* OsResourceAccessingApplication: 0..*
* OsResourceLinkedResourceRef: 0..1
*/
typedef enum {
/* External resource */
RESOURCE_TYPE_STANDARD,//!< RESOURCE_TYPE_STANDARD
/* ?? */
RESOURCE_TYPE_LINKED, //!< RESOURCE_TYPE_LINKED
/* Internal resource */
RESOURCE_TYPE_INTERNAL //!< RESOURCE_TYPE_INTERNAL
} OsResourcePropertyType;
typedef struct OsResource {
char_t id[16];
uint32 nr; /* The running number, starting at RES_SCHEDULER=0 */
uint32 ceiling_priority; /* The calculated ceiling prio */
uint32 old_task_prio; /* Stored prio of the owner oi the resource */
TaskType owner; /* Owner of the resource */
OsResourcePropertyType type;
#if (OS_USE_APPLICATIONS == STD_ON)
ApplicationType applOwnerId; /* Application that owns this task */
uint32 accessingApplMask; /* Applications that may access task
* when state is APPLICATION_ACCESSIBLE */
#endif
TAILQ_ENTRY(OsResource) listEntry; /* List of resources for each task. */
} OsResourceType;
#if OS_RESOURCE_CNT!=0
extern GEN_RESOURCE_HEAD;
#endif
static inline OsResourceType *Os_ResourceGet( ResourceType resource ) {
#if OS_RESOURCE_CNT!=0
return &resource_list[resource];
#else
(void)resource;
return NULL_PTR;
#endif
}
static inline ApplicationType Os_ResourceGetApplicationOwner( ResourceType id ) {
/** @req SWS_Os_00274 */
ApplicationType rv = INVALID_OSAPPLICATION;
#if (OS_RESOURCE_CNT!=0)
if( id < OS_RESOURCE_CNT ) {
rv = Os_ResourceGet(id)->applOwnerId;
}
#else
(void)id;
#endif
return rv;
}
extern struct OsResource resScheduler;
static inline _Bool Os_SchedulerResourceIsFree( void ) {
return (OS_SYS_PTR->resScheduler->owner == NO_TASK_OWNER );
}
void Os_ResourceGetInternal(void );
void Os_ResourceReleaseInternal( void );
void Os_ResourceInit( void );
#endif /* RESOURCE_I_H_ */
|
2301_81045437/classic-platform
|
system/Os/rtos/src/os_resource_i.h
|
C
|
unknown
| 2,956
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/** @reqSettings DEFAULT_SPECIFICATION_REVISION=4.3.0 */
/*
* How Autosar sees the scheduletable
*
* duration
* repeating
* accessionApplication
* counterRef
* autostart [0..1]
* |--- absValue (only if type==ABSOLUTE )
* |--- relOffset (only if type==RELATIVE )
* |--- type (ABSOLUTE, RELATIVE, SYNCHRON )
* |--- modeRef
* |
* expiryPoint [1..*]
* |--- offset
* |--- EventSetting [0..*]
* | |--- SetEvent
* | `--- SetEventTaskRef
* |
* |--- TaskActivation [0..*]
* | `- TaskRef
* |
* |--- AdjustableExpPoint [0..1] (only if syncStrategy!=NONE)
* | |--- maxAdvance
* | `--- macRetard
* |
* sync
* |--- explicitPrecision (only if syncStrategy==EXPLICIT )
* |--- syncStrategy (NONE,EXPLICIT,IMPLICIT )
*
*/
/*
* Generic requirements this module can handle
*/
/** @req SWS_Os_00007 OS shall permit multiple schdeule table */
/** @req SWS_Os_00410 At least one schedule table per counter */
/** @req SWS_Os_00411 One tick on counter corresponds to one tick on schedule table */
/** @req SWS_Os_00428 If schedule table processing has been cancelled before reaching the
* Final Expiry Point and is subsequently restarted then means that the
* re-start occurs from the start of the schedule table. */
/* ----------------------------[includes]------------------------------------*/
#include "os_i.h"
/* ----------------------------[private define]------------------------------*/
/* ----------------------------[private macro]-------------------------------*/
/* Initial check is to silence some compilers when OS_SCHTBL_CNT == 0 */
#define SCHED_CHECK_ID(x) ( (OS_SCHTBL_CNT != 0UL) && ((x) < OS_SCHTBL_CNT) )
/* ----------------------------[private typedef]-----------------------------*/
/* ----------------------------[private function prototypes]-----------------*/
#if (OS_SCHTBL_CNT != 0)
StatusType Os_StartScheduleTableRelStartup(ScheduleTableType sid, TickType offset);
StatusType Os_StartScheduleTableAbsStartup(ScheduleTableType sid, TickType start );
#endif
/* ----------------------------[private variables]---------------------------*/
/* ----------------------------[private functions]---------------------------*/
/**
* Calculates expire value and changes state depending it's state.
*
* Note!
* We can't cheat with the final + initial expire-point, instead we
* must setup trigger after the final delay and set the "previous"
* table to SCHEDULETABLE_STOPPED and the new to SCHEDULETABLE_RUNNING.
*
* @param stbl Ptr to a Schedule Table.
*/
static void Os_SchTblUpdateState( OsSchTblType *stbl ) {
TickType delta;
TickType initalOffset;
TickType finalOffset;
OsSchTblType *nextStblPtr;
_Bool handleLast = 0; /*lint !e970 MISRA:OTHER:type _Bool declared outside:[MISRA 2012 Directive 4.6, advisory] */
if( (stbl->expire_curr_index) == (SA_LIST_CNT(&stbl->expirePointList) - 1) ) {
/* We are at the last expiry point */
finalOffset = Os_SchTblGetFinalOffset(stbl);
if (finalOffset != 0) {
stbl->expire_val = Os_CounterAdd(
Os_CounterGetValue(stbl->counter),
Os_CounterGetMaxValue(stbl->counter),
finalOffset );
stbl->expire_curr_index++;
return;/*lint !e904 MISRA:OTHER:Return statement is necessary in case of reporting a DET error:[MISRA 2012 Rule 15.5, advisory]*/
} else {
/* Only single shot may have an offset of 0 */
ASSERT(stbl->repeating == SINGLE_SHOT);
handleLast = 1;
}
}
if( handleLast ||
( (stbl->expire_curr_index) == SA_LIST_CNT(&stbl->expirePointList) ) )
{
/* At final offset */
/** @req SWS_Os_00194 */
if( (stbl->repeating == REPEATING) || (stbl->next != NULL) ) {
if( stbl->next != NULL ) {
/** @req SWS_Os_00284 */
nextStblPtr = stbl->next;
/* NextScheduleTable() have been called */
ASSERT( nextStblPtr->state==SCHEDULETABLE_NEXT );
/* We don't care about REPEATING or SINGLE_SHOT here */
initalOffset = Os_SchTblGetInitialOffset(nextStblPtr);
stbl->state = SCHEDULETABLE_STOPPED;
nextStblPtr->state = SCHEDULETABLE_RUNNING;
nextStblPtr->expire_val = Os_CounterAdd(
Os_CounterGetValue(nextStblPtr->counter),
Os_CounterGetMaxValue(nextStblPtr->counter),
initalOffset );
} else {
/** @req SWS_Os_00414 */
/* REPEATING */
ASSERT( stbl->repeating == REPEATING );
initalOffset = Os_SchTblGetInitialOffset(stbl);
stbl->expire_val = Os_CounterAdd(
Os_CounterGetValue(stbl->counter),
Os_CounterGetMaxValue(stbl->counter),
initalOffset );
}
} else {
ASSERT( stbl->repeating == SINGLE_SHOT );
/** @req SWS_Os_00009 */
stbl->state = SCHEDULETABLE_STOPPED;
}
stbl->expire_curr_index = 0;
} else {
delta = SA_LIST_GET(&stbl->expirePointList,stbl->expire_curr_index+1)->offset -
SA_LIST_GET(&stbl->expirePointList,stbl->expire_curr_index)->offset ;
stbl->expire_val = Os_CounterAdd(
Os_CounterGetValue(stbl->counter),
Os_CounterGetMaxValue(stbl->counter),
delta );
stbl->expire_curr_index++;
}
return;
}
/* ----------------------------[public functions]----------------------------*/
/**
* Consistency checks for scheduletables. This should really be checked by
* the generator.
*
* See chapter 11.2.
*
* @return
*/
#if (OS_SCHTBL_CNT != 0)
/*lint -e818 MISRA:OTHER:sTblPtr is not pointing to constant:[MISRA 2012 Rule 8.13, advisory] */
static void ScheduleTableConsistenyCheck( OsSchTblType *sTblPtr ){
#if ( OS_SC2 == STD_ON ) || ( OS_SC4 == STD_ON )
/** @req SWS_Os_00440 */
if( sTblPtr->sync.syncStrategy == IMPLICIT ) {
ASSERT( sTblPtr->duration == (sTblPtr->counter->alarm_base.maxallowedvalue +1) );
}
/** OS431 */
if( sTblPtr->sync.syncStrategy == EXPLICIT ) {
ASSERT( sTblPtr->duration <= (sTblPtr->counter->alarm_base.maxallowedvalue +1) );
}
#endif
/** @req SWS_Os_00401 */
ASSERT(SA_LIST_CNT(&sTblPtr->expirePointList)>=1);
{
int iter;/*lint !e970 MISRA:OTHER:iterator variable :[MISRA 2012 Directive 4.6, advisory] */
TickType delta = 0;
TickType minCycle = Os_CounterGetMinCycle(sTblPtr->counter);
TickType maxValue = Os_CounterGetMaxValue(sTblPtr->counter);
/* - start at offset=0
* - X expiry points = SA_LIST_CNT
* - Final offset.
*/
/** @req SWS_Os_00443 */
/** @req SWS_Os_00408 */
for(iter=0; iter < SA_LIST_CNT(&sTblPtr->expirePointList) ; iter++) {
delta = SA_LIST_GET(&sTblPtr->expirePointList,iter)->offset - delta;
/* initial offset may be zero (OS443) */
if(iter!=0) {
ASSERT( delta >= minCycle );
}
ASSERT( delta <= maxValue );
}
/* Final */
/** @req SWS_Os_00444 */ /** !req SWS_Os_00427 */
delta = sTblPtr->duration - SA_LIST_GET(&sTblPtr->expirePointList,iter-1)->offset;
ASSERT( delta >= minCycle );
ASSERT( delta <= maxValue );
// if assert is defined not to access the argument(s) lint warnings about the arguments not used
//lint -save -e438 -e529
}
//lint -restore Restore the inhibit messages within block above
}
#endif
/** @req SWS_Os_00347 StartScheduleTableRel API */
/** @req SWS_Os_00521 StartScheduleTableRel available in all Scalability Classes. */
StatusType StartScheduleTableRel(ScheduleTableType sid, TickType offset) {
StatusType rv = E_OK;
OsSchTblType *sPtr;
TickType max_offset;
imask_t state;
/* Validation of parameters, if failure, function will return */
/* OS_STD_ERR_2: Function will return after calling ErrorHook */
/* This is not inline with Table 8, ISO26262-6:2011, Req 1a and 1h */
OS_VALIDATE_STD_2((Os_SysIntAnyDisabled() == FALSE) , E_OS_DISABLEDINT,
OSServiceId_StartScheduleTableRel,sid, offset); /* @req SWS_Os_00093 */
/** @req SWS_BSW_00029 */
#if (OS_STATUS_EXTENDED == STD_ON )
/** @req SWS_Os_00275 */
/*lint -e685 MISRA:CONFIGURATION:argument check:[MISRA 2012 Rule 14.3, required] */
/*lint -e568 MISRA:CONFIGURATION:argument check:[MISRA 2004 Info, advisory] */
OS_VALIDATE_STD_2(SCHED_CHECK_ID(sid) , E_OS_ID,
OSServiceId_StartScheduleTableRel,sid, offset);
#endif
sPtr = Os_SchTblGet(sid);
#if (OS_APPLICATION_CNT > 1)
rv = Os_ApplHaveAccess( sPtr->accessingApplMask );
if( rv != E_OK ) {
OS_STD_ERR_2(OSServiceId_StartScheduleTableRel,sid, offset);
}
#endif
#if ( OS_SC2 == STD_ON ) || ( OS_SC4 == STD_ON )
if( sPtr->sync != NULL ) {
/* EXPLICIT or IMPLICIT */
/** OS452 */ /** OS430 */
OS_VALIDATE_STD_2((sPtr->sync->syncStrategy != IMPLICIT) , E_OS_ID,
OSServiceId_StartScheduleTableRel,sid, offset);
}
#endif
max_offset = Os_CounterGetMaxValue(sPtr->counter);
/** @req SWS_BSW_00029 */
#if (OS_STATUS_EXTENDED == STD_ON )
/** @req SWS_Os_00276 */
/** @req SWS_Os_00332 */
/*lint -e{9007} MISRA:FALSE_POSITIVE:No side effects of Os_SchTblGetInitialOffset:[MISRA 2012 Rule 13.5, required]*/
if( (offset == 0) || ((offset + Os_SchTblGetInitialOffset(sPtr)) > max_offset ) ) {
rv = E_OS_VALUE;
OS_STD_ERR_2(OSServiceId_StartScheduleTableRel,sid, offset);
}
#endif
/** @req SWS_Os_00277 */
/*lint -e539 MISRA:CONFIGURATION:argument check:[MISRA 2004 Info, advisory] */
OS_VALIDATE_STD_2((sPtr->state == SCHEDULETABLE_STOPPED) , E_OS_STATE,
OSServiceId_StartScheduleTableRel,sid, offset);
Irq_Save(state);
/* calculate the expire value.. */
/** @req SWS_Os_00278 */
sPtr->expire_val = Os_CounterAdd(
Os_CounterGetValue(sPtr->counter),
max_offset,
offset + Os_SchTblGetInitialOffset(sPtr) );
sPtr->state = SCHEDULETABLE_RUNNING;
Irq_Restore(state);
return rv;
}
/** @req SWS_Os_00358 StartScheduleTableAbs API */
/** @req SWS_Os_00522 StartScheduleTableAbs available in all Scalability Classes. */
StatusType StartScheduleTableAbs(ScheduleTableType sid, TickType start ){
StatusType rv = E_OK;
OsSchTblType *sTblPtr;
imask_t state;
/* Validation of parameters, if failure, function will return */
/* This is not inline with Table 8, ISO26262-6:2011, Req 1a and 1h */
OS_VALIDATE_STD_2((Os_SysIntAnyDisabled() == FALSE) , E_OS_DISABLEDINT,
OSServiceId_StartScheduleTableAbs,sid, start); /* @req SWS_Os_00093 */
/** @req SWS_Os_00348 */
OS_VALIDATE_STD_2(SCHED_CHECK_ID(sid) , E_OS_ID,
OSServiceId_StartScheduleTableAbs,sid, start);
sTblPtr = Os_SchTblGet(sid);
#if (OS_APPLICATION_CNT > 1)
rv = Os_ApplHaveAccess( sTblPtr->accessingApplMask );
if( rv != E_OK ) {
/* OS_STD_ERR_2: Function will return after calling ErrorHook */
/* This is not inline with Table 8, ISO26262-6:2011, Req 1a and 1h */
OS_STD_ERR_2(OSServiceId_StartScheduleTableAbs,sid, start);
}
#endif
/** @req SWS_Os_00349 */
OS_VALIDATE_STD_2((start <= Os_CounterGetMaxValue(sTblPtr->counter)) , E_OS_VALUE,
OSServiceId_StartScheduleTableAbs,sid, start);
/** @req SWS_Os_00350 */
OS_VALIDATE_STD_2((sTblPtr->state == SCHEDULETABLE_STOPPED) , E_OS_STATE,
OSServiceId_StartScheduleTableAbs,sid, start);
Irq_Save(state);
/** !req SWS_Os_00351 (SCHEDULETABLE_RUNNING_AND_SYNCHRONOUS not supported) */
sTblPtr->expire_val = start + Os_SchTblGetInitialOffset(sTblPtr);
sTblPtr->state = SCHEDULETABLE_RUNNING;
Irq_Restore(state);
return rv;
}
/**
*
* @param sid
* @return
*/
/** OS201 OS provides the service StartScheduleTableSynchron() */
/** OS525 StartScheduleTableSynchron() available in Scalability Classes 2 and 4. */
#if ( OS_SC2 == STD_ON ) || ( OS_SC4 == STD_ON )
StatusType StartScheduleTableSynchron(ScheduleTableType sid ){
OsSchTblType *s_p;
StatusType rv = E_OK;
imask_t state;
/* Validation of parameters, if failure, function will return */
/* This is not inline with Table 8, ISO26262-6:2011, Req 1a and 1h */
OS_VALIDATE_STD_1((Os_SysIntAnyDisabled() == FALSE) , E_OS_DISABLEDINT,
OSServiceId_StartScheduleTableSynchron,sid); /* @req SWS_Os_00093 */
Irq_Save(state);
OS_VALIDATE_STD_1(SCHED_CHECK_ID(sid) , E_OS_ID,
OSServiceId_StartScheduleTableSynchron,sid);
/** OS387 */
OS_VALIDATE_STD_1(( s_p->sync.syncStrategy == EXPLICIT ) , E_OS_ID,
OSServiceId_StartScheduleTableSynchron,sid);
/** OS388 */
OS_VALIDATE_STD_1(( s_p->state == SCHEDULETABLE_STOPPED ) , E_OS_STATE,
OSServiceId_StartScheduleTableSynchron,sid);
/** OS389 */ /** OS435 */
s_p->state = SCHEDULETABLE_WAITING;
Irq_Restore(state);
return rv;
}
#endif
/** @req SWS_Os_00006 */
/** @req SWS_Os_00523 StopScheduleTable available in all Scalability Classes. */
/* IMPROVEMENT: Implement StopScheduleTable */
StatusType StopScheduleTable(ScheduleTableType sid) {
StatusType rv = E_OK;
OsSchTblType *sPtr;
/* Validation of parameters, if failure, function will return */
/* This is not inline with Table 8, ISO26262-6:2011, Req 1a and 1h */
OS_VALIDATE_STD_1( (Os_SysIntAnyDisabled() == FALSE) , E_OS_DISABLEDINT,
OSServiceId_StopScheduleTable,sid); /* @req SWS_Os_00093 */
/** @req SWS_Os_00279 */
OS_VALIDATE_STD_1( SCHED_CHECK_ID(sid) , E_OS_ID,
OSServiceId_StopScheduleTable,sid);
sPtr = Os_SchTblGet(sid);
/** @req SWS_Os_00280 */
OS_VALIDATE_STD_1( (sPtr->state != SCHEDULETABLE_STOPPED), E_OS_NOFUNC,
OSServiceId_StopScheduleTable,sid);
/** @req SWS_Os_00281 */
sPtr->state = SCHEDULETABLE_STOPPED;
return rv;
}
/** @req SWS_Os_00191 */
/** @req SWS_Os_00524 NextScheduleTable available in all Scalability Classes. */
StatusType NextScheduleTable( ScheduleTableType sid_curr, ScheduleTableType sid_next) {
StatusType rv = E_OK;
(void)sid_curr;
(void)sid_next;
OsSchTblType *sFromPtr;
OsSchTblType *sToPtr;
imask_t state;
/* Validation of parameters, if failure, function will return */
/* This is not inline with Table 8, ISO26262-6:2011, Req 1a and 1h */
OS_VALIDATE_STD_2( (Os_SysIntAnyDisabled() == FALSE) , E_OS_DISABLEDINT,
OSServiceId_NextScheduleTable,sid_curr, sid_next); /* @req SWS_Os_00093 */
/** @req SWS_Os_00282 */
OS_VALIDATE_STD_2(SCHED_CHECK_ID(sid_curr) , E_OS_ID,
OSServiceId_NextScheduleTable,sid_curr, sid_next);
OS_VALIDATE_STD_2(SCHED_CHECK_ID(sid_next) , E_OS_ID,
OSServiceId_NextScheduleTable,sid_curr, sid_next);
sFromPtr = Os_SchTblGet(sid_curr);
sToPtr = Os_SchTblGet(sid_next);
/** @req SWS_Os_00330 */
OS_VALIDATE_STD_2( (sFromPtr->counter == sToPtr->counter), E_OS_ID ,
OSServiceId_NextScheduleTable,sid_curr, sid_next);
/** @req SWS_Os_00283 */
if( (sFromPtr->state == SCHEDULETABLE_STOPPED) ||
(sFromPtr->state == SCHEDULETABLE_NEXT) )
{
rv = E_OS_NOFUNC;
/* OS_STD_ERR_2: Function will return after calling ErrorHook */
/* This is not inline with Table 8, ISO26262-6:2011, Req 1a and 1h */
OS_STD_ERR_2(OSServiceId_NextScheduleTable,sid_curr, sid_next);
}
/** @req SWS_Os_00309 */
OS_VALIDATE_STD_2( (sToPtr->state == SCHEDULETABLE_STOPPED ), E_OS_STATE,
OSServiceId_NextScheduleTable,sid_curr, sid_next);
Irq_Save(state);
/** @req SWS_Os_00453 */
if( sFromPtr->state == SCHEDULETABLE_STOPPED ) {
sFromPtr->next->state = SCHEDULETABLE_STOPPED;
} else {
/** @req SWS_Os_00324 */
if( sFromPtr->next != NULL ) {
// Stop the schedule-table that was to be next.
sFromPtr->next->state = SCHEDULETABLE_STOPPED;
}
sFromPtr->next = sToPtr;
sToPtr->state = SCHEDULETABLE_NEXT;
sToPtr->expire_curr_index = 0;
}
Irq_Restore(state);
return rv;
}
/**
*
* @param sid
* @param globalTime
* @return
*/
/** OS199 OS provides the service SyncScheduleTable() */
/** OS526 SyncScheduleTable() available in Scalability Classes 2 and 4. */
#if ( OS_SC2 == STD_ON ) || ( OS_SC4 == STD_ON )
StatusType SyncScheduleTable( ScheduleTableType ScheduleTableID, TickType Value ) {
StatusType rv = E_OK;
OsSchTblType *s_p;
imask_t state;
/* Validation of parameters, if failure, function will return */
/* This is not inline with Table 8, ISO26262-6:2011, Req 1a and 1h */
OS_VALIDATE_STD_2( (Os_SysIntAnyDisabled() == FALSE) , E_OS_DISABLEDINT,
OSServiceId_SyncScheduleTable,ScheduleTableID, Value); /* @req SWS_Os_00093 */
OS_VALIDATE_STD_2(SCHED_CHECK_ID(ScheduleTableID) , E_OS_ID,
OSServiceId_SyncScheduleTable,ScheduleTableID, Value);
s_p = Os_SchTblGet(ScheduleTableID);
/** OS454 */
OS_VALIDATE_STD_2( ( s_p->sync.syncStrategy == EXPLICIT ) , E_OS_ID,
OSServiceId_SyncScheduleTable,ScheduleTableID, Value);
/** OS455 */
OS_VALIDATE_STD_2( ( Value <= s_p->duration ) , E_OS_VALUE,
OSServiceId_SyncScheduleTable,ScheduleTableID, Value);
Irq_Save(state);
/** OS456 */
if( (s_p->state == SCHEDULETABLE_STOPPED) ||
(s_p->state == SCHEDULETABLE_NEXT) ) {
rv = E_OS_STATE;
/* OS_STD_ERR_2: Function will return after calling ErrorHook */
/* This is not inline with Table 8, ISO26262-6:2011, Req 1a and 1h */
OS_STD_ERR_2(OSServiceId_SyncScheduleTable,ScheduleTableID, Value);
}
switch(s_p->state) {
case SCHEDULETABLE_WAITING:
// First time we called since started. Set the sync counter to
// the value provided.
s_p->sync.syncCounter = Value;
s_p->state = SCHEDULETABLE_RUNNING_AND_SYNCHRONOUS;
break;
case SCHEDULETABLE_RUNNING:
case SCHEDULETABLE_RUNNING_AND_SYNCHRONOUS:
s_p->sync.deviation = s_p->sync.syncCounter - Value;
if( s_p->sync.deviation != 0 ) {
// We are not at sync any more...
/** OS419 */
s_p->state = SCHEDULETABLE_RUNNING;
}
break;
default:
ASSERT(0);
break;
}
Irq_Restore(state);
return rv;
}
#endif
/**
*
* @param sid
* @param status
* @return
*/
/** @req SWS_Os_00528 GetScheduleTableStatus() available in all Scalability Classes. */
/** @req SWS_Os_00227 */
StatusType GetScheduleTableStatus( ScheduleTableType sid, ScheduleTableStatusRefType status ) {
StatusType rv = E_OK;
/*lint -e954 MISRA:OTHER:need not be const pointer:[MISRA 2012 Rule 8.13, advisory] */
OsSchTblType *s_p;
(void)status; /*lint !e920 MISRA:FALSE_POSITIVE:Allowed to cast pointer to void here:[MISRA 2012 Rule 1.3, required]*/
imask_t state;
/* Validation of parameters, if failure, function will return */
/* This is not inline with Table 8, ISO26262-6:2011, Req 1a and 1h */
OS_VALIDATE_STD_2( (Os_SysIntAnyDisabled() == FALSE) , E_OS_DISABLEDINT ,
OSServiceId_GetScheduleTableStatus,sid, status); /* @req SWS_Os_00093 */
/** @req SWS_Os_00293 */
OS_VALIDATE_STD_2(SCHED_CHECK_ID(sid) , E_OS_ID,
OSServiceId_GetScheduleTableStatus,sid, status);
s_p = Os_SchTblGet(sid);
Irq_Save(state);
switch(s_p->state) {
/** @req SWS_Os_00289 */
case SCHEDULETABLE_STOPPED:
/** @req SWS_Os_00353 */
case SCHEDULETABLE_NEXT:
/** OS290 */
case SCHEDULETABLE_RUNNING_AND_SYNCHRONOUS:
/** OS354 */
case SCHEDULETABLE_WAITING:
/** OS291 */
case SCHEDULETABLE_RUNNING:
*status = s_p->state;
break;
default:
ASSERT(0);
}
Irq_Restore(state);
return rv;
}
/**
*
* @param sid
* @return
*/
/** OS422 OS provides the service SetScheduleTableAsync() */
/** OS527 SetScheduleTableAsync() available in Scalability Classes 2 and 4. */
#if ( OS_SC2 == STD_ON ) || ( OS_SC4 == STD_ON )
StatusType SetScheduleTableAsync( ScheduleTableType sid ) {
StatusType rv = E_OK;
OsSchTblType *s_p;
imask_t state;
/* Validation of parameters, if failure, function will return */
/* This is not inline with Table 8, ISO26262-6:2011, Req 1a and 1h */
OS_VALIDATE_STD_1( (Os_SysIntAnyDisabled() == FALSE) , E_OS_DISABLEDINT ,
OSServiceId_SetScheduleTableAsync,sid ); /* @req SWS_Os_00093 */
OS_VALIDATE_STD_1(SCHED_CHECK_ID(sid) , E_OS_ID,
OSServiceId_SetScheduleTableAsync,sid);
s_p = Os_SchTblGet(sid);
/** OS458 */
OS_VALIDATE_STD_1( ( s_p->sync.syncStrategy == EXPLICIT ) , E_OS_ID ,
OSServiceId_SetScheduleTableAsync,sid );
Irq_Save(state);
/** !req SWS_Os_00362 */ /** !req SWS_Os_00323 */ /** !req SWS_Os_00483 */
/** OS300 */
s_p->state = SCHEDULETABLE_RUNNING;
Irq_Restore(state);
return rv;
}
#endif
/**
* Go through the schedule tables connected to this counter
*
* @param c_p Pointer to counter object
*/
void Os_SchTblCheck(OsCounterType *c_p) {
/** @req SWS_Os_00002 */
/** @req SWS_Os_00007 */
OsSchTblType *sched_obj;
/* Iterate through the schedule tables */
/*lint -e9036 -e818 MISRA:PERFORMANCE:this is a continuous loop:[MISRA 2012 Rule 14.4, required] */
SLIST_FOREACH(sched_obj,&c_p->sched_head,sched_list) {
if( sched_obj->state == SCHEDULETABLE_STOPPED ) {
continue;
}
#if ( OS_SC2 == STD_ON ) || ( OS_SC4 == STD_ON )
if( sched_obj->sync.syncStrategy == IMPLICIT ) {
// ....
} else {
int adj;
// Handle EXPLICIT
if( sched_obj->sync.deviation > 0 ) {
// The sync counter was set back ==
// we have more time to complete the table
adj = MIN(sched_obj->sync.deviation, getAdjExpPoint(sched_obj)->maxAdvance );
sched_obj->sync.deviation -= adj;
} else if( sched_obj->sync.deviation < 0 ) {
// The sync counter was set forward ==
// we have less time to complete the table
adj = MIN((-sched_obj->sync.deviation), getAdjExpPoint(sched_obj)->maxRetard);
sched_obj->sync.deviation -= adj;
} else {
// all is well
sched_obj->state = SCHEDULETABLE_RUNNING_AND_SYNCHRONOUS;
}
}
#endif
/* Check if the expire point have been hit */
if( ((sched_obj->state == SCHEDULETABLE_RUNNING) ||
(sched_obj->state == SCHEDULETABLE_RUNNING_AND_SYNCHRONOUS) ) &&
(c_p->val == sched_obj->expire_val) )
{
if ( sched_obj->expire_curr_index < SA_LIST_CNT(&sched_obj->expirePointList) ) {
OsScheduleTableExpiryPointType * action;
uint32_t i;
action = SA_LIST_GET(&sched_obj->expirePointList,sched_obj->expire_curr_index);
/** @req SWS_Os_00407 */
/** @req SWS_Os_00412 */
/* According to OS412 activate tasks before events */
for(i=0; i< (uint32_t)action->taskListCnt;i++ ) {
(void)ActivateTask(action->taskList[i]);
}
for(i=0; i< (uint32_t)action->eventListCnt;i++ ) {
(void)SetEvent( action->eventList[i].task, action->eventList[i].event);
}
}
// Calc new expire val and state
Os_SchTblUpdateState(sched_obj);
}
}
}
/**
*
*/
void Os_SchTblInit( void ) {
#if (OS_SCHTBL_CNT != 0)
OsSchTblType *s_p;
/*lint -e{681, 685, 568} MISRA:CONFIGURATION:Allow MISRA violations depending on configuration:[MISRA 2004 Info,advisory]*/
for( ScheduleTableType i=0; i < OS_SCHTBL_CNT;i++ ) {
s_p = Os_SchTblGet(i);
ScheduleTableConsistenyCheck(s_p);
}
#endif
}
void Os_SchTblAutostart( void ) {
#if (OS_SCHTBL_CNT != 0)
/*lint -e{681, 685, 568} MISRA:CONFIGURATION:Allow MISRA violations depending on configuration:[MISRA 2004 Info,advisory]*/
for(ScheduleTableType j=0; j < OS_SCHTBL_CNT; j++ ) {
OsSchTblType *sPtr;
sPtr = Os_SchTblGet(j);
if( sPtr->autostartPtr != NULL ) {
const struct OsSchTblAutostart *autoPtr = sPtr->autostartPtr;
/* Check appmode */
if( OS_SYS_PTR->appMode & autoPtr->appMode ) {
/* Start the schedule table */
switch(autoPtr->type) {
case SCHTBL_AUTOSTART_ABSOLUTE:
(void)Os_StartScheduleTableAbsStartup(j,autoPtr->offset);
break;
case SCHTBL_AUTOSTART_RELATIVE:
(void)Os_StartScheduleTableRelStartup(j,autoPtr->offset);
break;
#if defined(OS_SC2) || defined(OS_SC4)
case SCHTBL_AUTOSTART_SYNCHRONE:
/* IMPROVEMENT: Add support */
break;
#endif
default:
ASSERT(0); // Illegal value
break;
}
}
}
}
#endif
}
#if (OS_SCHTBL_CNT != 0)
/*
* Os_StartScheduleTableRelStartup: Start the relative scheduletable during shartup phase.
* Difference between StartScheduleTableRel and Os_StartScheduleTableRelStartup is, no interrup check is not available (i.e. SWS_Os_00093)
*/
StatusType Os_StartScheduleTableRelStartup(ScheduleTableType sid, TickType offset) {
StatusType rv = E_OK;
OsSchTblType *sPtr;
TickType max_offset;
imask_t state;
/* OS_STD_ERR_2: Function will return after calling ErrorHook */
/* This is not inline with Table 8, ISO26262-6:2011, Req 1a and 1h */
/** @req SWS_BSW_00029 */
#if (OS_STATUS_EXTENDED == STD_ON )
/** @req SWS_Os_00275 */
OS_VALIDATE_STD_2(SCHED_CHECK_ID(sid) , E_OS_ID,
OSServiceId_StartScheduleTableRel,sid, offset);
#endif
sPtr = Os_SchTblGet(sid);
#if (OS_APPLICATION_CNT > 1)
rv = Os_ApplHaveAccess( sPtr->accessingApplMask );
if( rv != E_OK ) {
OS_STD_ERR_2(OSServiceId_StartScheduleTableRel,sid, offset);
}
#endif
#if ( OS_SC2 == STD_ON ) || ( OS_SC4 == STD_ON )
if( sPtr->sync != NULL ) {
/* EXPLICIT or IMPLICIT */
/** OS452 */ /** OS430 */
if( sPtr->sync->syncStrategy == IMPLICIT ) {
rv = E_OS_ID;
OS_STD_ERR_2(OSServiceId_StartScheduleTableRel,sid, offset);
}
}
#endif
max_offset = Os_CounterGetMaxValue(sPtr->counter);
/** @req SWS_BSW_00029 */
#if (OS_STATUS_EXTENDED == STD_ON )
/** @req SWS_Os_00276 */
/** @req SWS_Os_00332 */
/*lint -e{9007} MISRA:FALSE_POSITIVE:No side effects of Os_SchTblGetInitialOffset:[MISRA 2012 Rule 13.5, required]*/
if( (offset == 0) || ((offset + Os_SchTblGetInitialOffset(sPtr)) > max_offset ) ) {
rv = E_OS_VALUE;
OS_STD_ERR_2(OSServiceId_StartScheduleTableRel,sid, offset);
}
#endif
/** @req SWS_Os_00277 */
if( sPtr->state != SCHEDULETABLE_STOPPED ) {
rv = E_OS_STATE;
OS_STD_ERR_2(OSServiceId_StartScheduleTableRel,sid, offset);
}
Irq_Save(state);
/* calculate the expire value.. */
/** @req SWS_Os_00278 */
sPtr->expire_val = Os_CounterAdd(
Os_CounterGetValue(sPtr->counter),
max_offset,
offset + Os_SchTblGetInitialOffset(sPtr) );
sPtr->state = SCHEDULETABLE_RUNNING;
Irq_Restore(state);
return rv;
}
/*
* Os_StartScheduleTableAbsStartup: Start the absolute scheduletable during shartup phase.
* Difference between StartScheduleTableAbs and Os_StartScheduleTableAbsStartup is, no interrup check is not available (i.e. SWS_Os_00093)
*/
StatusType Os_StartScheduleTableAbsStartup(ScheduleTableType sid, TickType start ){
StatusType rv = E_OK;
OsSchTblType *sTblPtr;
imask_t state;
/** @req SWS_Os_00348 */
OS_VALIDATE_STD_2(SCHED_CHECK_ID(sid) , E_OS_ID,
OSServiceId_StartScheduleTableAbs,sid, start);
sTblPtr = Os_SchTblGet(sid);
/* OS_STD_ERR_2: Function will return after calling ErrorHook */
/* This is not inline with Table 8, ISO26262-6:2011, Req 1a and 1h */
#if (OS_APPLICATION_CNT > 1)
rv = Os_ApplHaveAccess( sTblPtr->accessingApplMask );
if( rv != E_OK ) {
OS_STD_ERR_2(OSServiceId_StartScheduleTableAbs,sid, start);
}
#endif
/** @req SWS_Os_00349 */
if( start > Os_CounterGetMaxValue(sTblPtr->counter) ) {
rv = E_OS_VALUE;
OS_STD_ERR_2(OSServiceId_StartScheduleTableAbs,sid, start);
}
/** @req SWS_Os_00350 */
if( sTblPtr->state != SCHEDULETABLE_STOPPED ) {
rv = E_OS_STATE;
OS_STD_ERR_2(OSServiceId_StartScheduleTableAbs,sid, start);
}
Irq_Save(state);
/** !req SWS_Os_00351 (SCHEDULETABLE_RUNNING_AND_SYNCHRONOUS not supported) */
sTblPtr->expire_val = start + Os_SchTblGetInitialOffset(sTblPtr);
sTblPtr->state = SCHEDULETABLE_RUNNING;
Irq_Restore(state);
return rv;
}
#endif
|
2301_81045437/classic-platform
|
system/Os/rtos/src/os_sched_table.c
|
C
|
unknown
| 31,726
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/** @reqSettings DEFAULT_SPECIFICATION_REVISION=4.3.0 */
#ifndef SCHED_TABLE_I_H_
#define SCHED_TABLE_I_H_
/* Should hold the internal API used by the schedule tables */
#define SCHEDULE_ACTION_ACTIVATETASK 0
#define SCHEDULE_ACTION_SETEVENT 1
struct OsCounter;
#define SINGLE_SHOT 0
#define REPEATING 1
#if ( OS_SC2 == STD_ON ) || ( OS_SC4 == STD_ON )
enum OsScheduleTableSyncStrategy {
NONE, /* Support for sync, this is same as no OS */
EXPLICIT, /* synchronize with "external" counter */
IMPLICIT, /* sync internal */
};
#endif
enum OsScheduleTableAutostartType {
SCHTBL_AUTOSTART_ABSOLUTE, /* Start with StartScheduleTableAbs() */
SCHTBL_AUTOSTART_RELATIVE, /* Start with StartScheduleTableRel() */
SCHTBL_AUTOSTART_SYNCHRONE /* StartScheduleTableSyncon() */
};
/* STD container: OsScheduleTableEventSetting
* OsScheduleTableSetEventRef: 1
* OsScheduleTableSetEventTaskRef: 1
*/
typedef struct OsScheduleTableEventSetting {
EventMaskType event;
TaskType task;
} OsScheduleTableEventSettingType;
/* OsScheduleTableTaskActivation */
/* STD container: OsScheduleTableExpiryPoint
* OsScheduleTblExpPointOffset: 1 Int
* OsScheduleTableEventSetting: 0..*
* OsScheduleTableTaskActivation: 0..*
* OsScheduleTblAdjustableExpPoint: 0..1
* */
/** @req SWS_Os_00402 */
/** @req SWS_Os_00403 */
typedef struct OsScheduleTableExpiryPoint {
/** @req SWS_Os_00404 */
TickType offset;
const TaskType * taskList; /* List of events to activate */
uint8_t taskListCnt;
uint8_t eventListCnt;
const OsScheduleTableEventSettingType *eventList; /* List of events to activate */
} OsScheduleTableExpiryPointType;
#if ( OS_SC2 == STD_ON ) || ( OS_SC4 == STD_ON )
typedef struct OsScheduleTableSync {
/* SPEC */
enum OsScheduleTableSyncStrategy syncStrategy;
int explicitPrecision; /* from spec. (only if syncStrategy==EXPLICIT ) */
/* OWN */
GlobalTimeTickType syncCounter; /* This counter is advanced by the driver counter but is
* synchronized by SyncScheduleTable() */
int deviation; /* This is the deviation from the sync counter to the drive counter.
* (set by SyncScheduleTable())
* Calculated as 'driver count' - 'global time count from SyncScheduleTable()' */
} OsScheduleTableSyncType;
/* SPEC */
typedef struct OsSchTblAdjExpPoint {
uint8_t maxAdvance;
uint8_t maxRetard;
} OsSchTblAdjExpPointType;
#endif
/* STD container: OsScheduleTableAutostart
* OsScheduleTableAbsValue 1 Int
* OsScheduleTableAutostartType 1 Enum
* OsScheduleTableRelOffset 1 Int
* OsScheduleTableAppModeRef 1..* Ref to OsAppMode
*/
struct OsSchTblAutostart {
enum OsScheduleTableAutostartType type;
/* offset applies to both rel and abs */
TickType offset;
AppModeType appMode; // IMPROVEMENT (?)
};
/* STD container: OsScheduleTable
* OsScheduleTableDuration: 1 Int
* OsScheduleTableRepeating: 1 Bool
* OsSchTblAccessingApplication 0..* Ref
* OsScheduleTableCounterRef: 1 Ref
* OsScheduleTableAutostart[C] 0..1
* OsScheduleTableExpiryPoint[C] 1..*
* OsScheduleTableSync 0..1
*/
typedef struct OsSchTbl {
char * name;
TickType duration; /* OsScheduleTableDuration */
/** @req SWS_Os_00413 */
_Bool repeating; /* If true, the schedule is periodic, OS009
* OsScheduleTableRepeating , 0 - SINGLE_SHOT */
#if (OS_USE_APPLICATIONS == STD_ON)
ApplicationType applOwnerId;
uint32 accessingApplMask;
#endif
/** @req SWS_Os_00409 */
struct OsCounter * counter; /* pointer to this tables counter, OsScheduleTableCounterRef */
const struct OsSchTblAutostart * autostartPtr; /* OsScheduleTableAutostart[C] */
/*lint -esym(123, sync) MISRA:OTHER:sync is typically also defined as a macro, but should give other compiler warnings if usage of them is mixed up:[MISRA 2004 Info, advisory] */
struct OsScheduleTableSync * sync; /* NULL if NONE, and non-NULL if EXPLICIT and IMPLICIT */
#if ( OS_SC2 == STD_ON ) || ( OS_SC4 == STD_ON )
struct OsSchTblAdjExpPoint adjExpPoint;
#endif
uint32 id;
/* The current index into the expire list
* The value is updated at each expire point. */
int expire_curr_index;
/* When this table expires the next time
* This value should be compared to the counter that drives
* the counter to check if it has expired.
* The value is updated at each expire point. */
TickType expire_val;
ScheduleTableStatusType state;
/* Pointer to next schedule table, if any
* (don't use normal lists here since we have no list head) */
struct OsSchTbl *next;
/* Head of static expire point list
* OsScheduleTableExpiryPoint[C] */
SA_LIST_HEAD(alist,OsScheduleTableExpiryPoint) expirePointList;
/* Entry in the list of schedule tables connected to a specific
* counter */
SLIST_ENTRY(OsSchTbl) sched_list;
} OsSchTblType;
void Os_SchTblInit( void );
void Os_SchTblCalcExpire( OsSchTblType *stbl );
void Os_SchTblCheck(OsCounterType *c_p);
void Os_SchTblAutostart( void );
#if (OS_SCHTBL_CNT!=0)
extern GEN_SCHTBL_HEAD;
#endif
static inline OsSchTblType *Os_SchTblGet( ScheduleTableType sched_id ) {
#if (OS_SCHTBL_CNT!=0)
return &sched_list[sched_id];
#else
(void)sched_id;
return NULL;
#endif
}
static inline TickType Os_SchTblGetInitialOffset( OsSchTblType *sPtr ) {
return SA_LIST_GET(&sPtr->expirePointList,0)->offset;
}
static inline TickType Os_SchTblGetFinalOffset( OsSchTblType *sPtr ) {
return (sPtr->duration -
SA_LIST_GET(&sPtr->expirePointList, SA_LIST_CNT(&sPtr->expirePointList)-1)->offset);
}
static inline ApplicationType Os_SchTblGetApplicationOwner( ScheduleTableType id ) {
/** @req SWS_Os_00274 */
ApplicationType rv = INVALID_OSAPPLICATION;
#if (OS_SCHTBL_CNT!=0)
if( id < OS_SCHTBL_CNT ) {
rv = Os_SchTblGet(id)->applOwnerId;
}
#else
(void)id;
#endif
return rv;
}
/* Accessor functions */
#if ( OS_SC2 == STD_ON ) || ( OS_SC4 == STD_ON )
static inline OsSchTblAdjExpPointType *getAdjExpPoint( OsSchTblType *stblPtr ) {
return &stblPtr->adjExpPoint;
}
#endif
#endif /*SCHED_TABLE_I_H_*/
|
2301_81045437/classic-platform
|
system/Os/rtos/src/os_sched_table_i.h
|
C
|
unknown
| 7,359
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/**
* @brief Semaphores
*
* @addtogroup OS
* @details Implements semaphores and binary semaphores.
*
* @{
*/
/* ----------------------------[includes]------------------------------------*/
#include "os_i.h"
#include "os_internal.h"
#include "logger.h"
#include "sys/queue.h"
#if defined(CFG_LOG) && (LOG_OS_SEM)
#define _LOG_NAME_ "os_sem"
#endif
#include "log.h"
/* ----------------------------[private define]------------------------------*/
/* ----------------------------[private macro]-------------------------------*/
/* ----------------------------[private typedef]-----------------------------*/
/* ----------------------------[private function prototypes]-----------------*/
/* ----------------------------[private variables]---------------------------*/
/* ----------------------------[private functions]---------------------------*/
/**
* @brief Add a task, tP, last in a list of tasks waiting on
* a semaphore
*
* @param[in] sP Pointer to semaphore
* @param[in] tP Pointer to task
*/
static void Os_SemQAddTail(OsSemType *sP, OsTaskVarType *tP) {
STAILQ_INSERT_TAIL(&sP->taskHead, tP, semEntry);
}
/**
* @brief return the first task waiting on a semaphore
*
* @param[in] sP Pointer to semaphore
* @return Pointer to the first task
*/
static OsTaskVarType * Os_SemQFirst(OsSemType *sP) {
return STAILQ_FIRST(&sP->taskHead);
}
/**
* @brief Remove the first task waiting on the semaphore
*
* @param[in] sP Pointer to semaphore
*/
static void Os_SemQRemoveHead(OsSemType *sP) {
STAILQ_REMOVE_HEAD(&sP->taskHead, semEntry);
}
/**
* @brief Remove a task in the list of tasks waiting for semaphore sP
*
* @param[in] sP Pointer to semaphore
* @param[in] tP Pointer to task
*/
static void Os_SemQRemove(OsSemType *sP, OsTaskVarType *tP) {
STAILQ_REMOVE(&sP->taskHead, tP, OsTaskVar, semEntry);
}
/**
* @brief Function to check if there is any waiting for the semaphore
*
* @param[in] sP Pointer to semaphore
* @return
*/
static boolean Os_SemQIsEmpty(OsSemType *sP) {
return STAILQ_EMPTY( &sP->taskHead );
}
/**
* @brief Perform sanity checking on a task
* were a semaphore service is called
*
* @param[in] tP Pointer to task
* @return
*/
static StatusType SemWaitChecks( OsTaskVarType *tP ) {
StatusType rv = E_OK;
ASSERT(OS_SYS_PTR->intNestCnt == 0);
if (tP->constPtr->proc_type != PROC_EXTENDED) {
rv = E_OS_ACCESS;
OS_STD_ERR_1(OSServiceId_SemWaitChecks,rv);
}
else if (Os_TaskOccupiesResources(tP)) {
rv = E_OS_RESOURCE;
OS_STD_ERR_1(OSServiceId_SemWaitChecks,rv);
}
return rv;
}
/* ----------------------------[public functions]----------------------------*/
/**
* @brief Function to initialize a semaphore
* @details
* @param[in] semPtr Pointer to semaphore to initialize
* @param[in] initialCount Initial count of the semaohore
* @return
*/
StatusType SemInit(OsSemType *semPtr, sint32 initialCount ) {
StatusType rv = E_OK;
if( semPtr != NULL_PTR ) {
/* Check for empty */
ASSERT( Os_SemQIsEmpty( semPtr ));
semPtr->count = initialCount;
STAILQ_INIT(&semPtr->taskHead);
} else {
/* NULL_PTR pointer check */
Os_CallErrorHook(E_OS_VALUE);
rv = E_OS_VALUE;
}
return rv;
}
StatusType SemWait(OsSemType *semPtr) {
return SemWaitTmo(semPtr, TMO_INFINITE );
}
StatusType SemWaitTmo(OsSemType *semPtr, TickType tmo) {
OsTaskVarType *pcbPtr = Os_SysTaskGetCurr();
uint32_t flags;
StatusType rv = E_OK;
Irq_Save(flags);
LOG_S_U32(__func__,(uint32)semPtr);
if( semPtr != NULL_PTR ) {
/* Someone is waiting at the semaphore, so it can't be empty OR
* Counter with values 0,1 must have an empty queue*/
ASSERT( ((semPtr->count < 0) && !Os_SemQIsEmpty(semPtr)) ||
((semPtr->count >= 0) && Os_SemQIsEmpty(semPtr)) );
if( (rv = SemWaitChecks(pcbPtr)) == E_OK ) {
semPtr->count--;
if( semPtr->count < 0 ) {
/* It's locked */
if (tmo == TMO_MIN ) {
/* Restore sem value and return timeout */
semPtr->count++;
Irq_Restore(flags);
return E_OS_TIMEOUT;
}
LOG_S_U32("WAIT",(uint32)semPtr);
/* Add us to the current task */
OS_SYS_PTR->currTaskPtr->semPtr = semPtr;
/* Add this task to the semaphore */
Os_SemQAddTail( semPtr, pcbPtr);
rv = Os_DispatchToSleepWithTmo(OP_WAIT_SEMAPHORE, tmo);
/* Return values here are:
* E_OK We dispatched
* E_OS_RESOURCE Dispatcher locked..
* E_OS_TIMEOUT Timeout
*/
if( rv == E_OS_TIMEOUT ) {
LOG_S_U32("REMOVE",(uint32)semPtr);
/* Remove us from the semaphore queue.
* We have already removed from the timer queue and put into ready state here */
Os_SemQRemove( semPtr, OS_SYS_PTR->currTaskPtr);
/* Restore sem value */
semPtr->count++;
}
} else {
/* It's unlocked */
LOG_S_U32("UNLOCKED",(uint32)semPtr);
}
}
} else {
/* NULL_PTR pointer check */
Os_CallErrorHook(E_OS_VALUE);
rv = E_OS_VALUE;
}
Irq_Restore(flags);
return rv;
}
StatusType SemSignal(OsSemType *semPtr) {
uint32_t flags;
OsTaskVarType *taskPtr;
StatusType rv = E_OK;
Irq_Save(flags);
LOG_S_U32(__func__,(uint32)semPtr);
ASSERT( ((semPtr->count < 0) && !Os_SemQIsEmpty(semPtr)) ||
((semPtr->count >= 0) && Os_SemQIsEmpty(semPtr)) );
if (semPtr != NULL_PTR) {
semPtr->count++;
if (semPtr->count <= 0) {
LOG_S_U32("RM_FIRST",(uint32)semPtr);
/* Remove the first task that waits at the semaphore */
taskPtr = Os_SemQFirst(semPtr);
ASSERT(taskPtr != NULL_PTR);
/* Release the first task in queue */
Os_SemQRemoveHead(semPtr);
if( taskPtr->state == ST_SUSPENDED) {
/* We tried to signal semaphore that have a suspended task */
Os_CallErrorHook(E_OS_STATE);
rv = E_OS_VALUE;
} else {
LOG_S_U32("WAKE",(uint32)semPtr);
/* Remove us from the timerQ */
if (taskPtr->tmoVal != TMO_INFINITE ) {
Os_TimerQRemove(taskPtr);
}
taskPtr->rv = E_OK;
Os_TaskMakeReady(taskPtr);
if( (OS_SYS_PTR->intNestCnt == 0) &&
(Os_SysTaskGetCurr()->constPtr->scheduling == FULL) &&
(taskPtr->activePriority > Os_SysTaskGetCurr()->activePriority) &&
(Os_SysIntAnyDisabled() == FALSE ) &&
(Os_SchedulerResourceIsFree())) {
Os_Dispatch(OP_SIGNAL_SEMAPHORE);
}
}
}
else {
/* We do nothing */
/* IMPROVEMENT: We could do a counter wrap check here */
}
}
else {
/* NULL_PTR pointer check */
Os_CallErrorHook(E_OS_VALUE);
rv = E_OS_VALUE;
}
Irq_Restore(flags);
return rv;
}
/**
* @brief Function to signal a binary semaphore.
*
* @param[in] semPtr Pointer to a semaphore.
* .
* @retval E_OS_VALUE Semaphore count was already 1.
* @return See SemSignal for more return values.
*/
StatusType BSemSignal( OsSemType *semPtr ) {
StatusType rv;
/* semPtr is also checked in SemSignal */
if (semPtr != NULL_PTR) {
/* Binary semaphores may not grow above 1 */
if( semPtr->count == BSEM_UNLOCKED ) {
Os_CallErrorHook(E_OS_VALUE);
rv = E_OS_VALUE;
} else {
rv = SemSignal(semPtr);
}
} else {
/* NULL_PTR pointer check */
Os_CallErrorHook(E_OS_VALUE);
rv = E_OS_VALUE;
}
return rv;
}
/** @} */
|
2301_81045437/classic-platform
|
system/Os/rtos/src/os_sem.c
|
C
|
unknown
| 9,433
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#include "os_i.h"
/**
* Will sleep for sleep ticks. This works only for extended
* tasks. If sleep is 0 it will just call the dispatcher to
* see if there is anything with higher or equal priority to run.
*
* @param sleep
* @return E_OS_ACCESS if called from a basic task
* E_OS_RESOURCE called while holding a resource
* E_OS_CALLEVEL if called from interrupt context
* E_OK if called from a FULL task
*/
StatusType Sleep( TickType sleep ) {
StatusType rv = E_OK;
OsTaskVarType *pcbPtr;
uint32_t flags;
/* Validation of parameters, if failure, function will return */
/* This is not inline with Table 8, ISO26262-6:2011, Req 1a and 1h */
OS_VALIDATE_STD_1( (Os_SysIntAnyDisabled() == FALSE) , E_OS_DISABLEDINT ,
OSServiceId_Sleep,sleep); /* @req SWS_Os_00093 */
pcbPtr = Os_SysTaskGetCurr();
OS_VALIDATE_STD_1( (pcbPtr->constPtr->proc_type == PROC_EXTENDED) , E_OS_ACCESS ,
OSServiceId_Sleep,sleep);
/* Check that we are not calling from interrupt context */
OS_VALIDATE_STD_1( ( OS_SYS_PTR->intNestCnt == 0 ) , E_OS_CALLEVEL ,
OSServiceId_Sleep,sleep);
if ( Os_TaskOccupiesResources(pcbPtr) ) {
rv = E_OS_RESOURCE;
/* OS_STD_ERR_1: Function will return after calling ErrorHook */
/* This is not inline with Table 8, ISO26262-6:2011, Req 1a and 1h */
OS_STD_ERR_1(OSServiceId_Sleep,sleep);
}
Irq_Save(flags);
if ( Os_SchedulerResourceIsFree() ) {
if( sleep != TMO_MIN ) {
rv = Os_DispatchToSleepWithTmo(OP_SLEEP,sleep);
ASSERT(rv == E_OS_TIMEOUT);
rv = E_OK;
} else {
/* Put us last in the ready list, by first removing us and
* then adding us again */
TAILQ_REMOVE(&OS_SYS_PTR->ready_head,pcbPtr,ready_list);
TAILQ_INSERT_TAIL(& OS_SYS_PTR->ready_head,pcbPtr,ready_list);
OsTaskVarType *topTask = Os_TaskGetTop();
if( topTask != pcbPtr ) {
Os_Dispatch(OP_SCHEDULE);
}
}
}
Irq_Restore(flags);
return rv;
}
|
2301_81045437/classic-platform
|
system/Os/rtos/src/os_sleep.c
|
C
|
unknown
| 2,985
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#include "os_i.h"
#define SPINLOCK_CHECK_ID(_spinlockId) (((_spinlockId) < OS_SPINLOCK_CNT) )
static StatusType GetSpinlockDeadlockCheck(SpinlockIdType spinlock_id)
{
StatusType rv = E_OK;
OsSpinlockType *sPtr;
OsTaskVarType *pcbPtr = Os_SysTaskGetCurr();
OS_VALIDATE( (Os_SysIntAnyDisabled() == FALSE) , E_OS_DISABLEDINT ); /* @req SWS_Os_00093 */
/** OS696 */
/* Check if the same task has already occupied the spinlock */
if (pcbPtr != NULL) { // When the OS itself is running pcbPtr is NULL
TAILQ_FOREACH(sPtr, &pcbPtr->spinlockHead, spinlockEntry ) {
if (sPtr->id == spinlock_id)
rv = E_OS_INTERFERENCE_DEADLOCK;
}
}
/** !req OS690, OS708 */
/* IMPROVEMENT: Check if other tasks or ISRs on the same core have already occupied the spinlock */
/** !req OS691, OS709 */
/* IMPROVEMENT: Check that occupying this spinlock is correct according to the nesting list */
return rv;
}
static StatusType ReleaseSpinlockAccessCheck(SpinlockIdType spinlock_id)
{
StatusType rv = E_OK;
OsSpinlockType *sPtr;
OsTaskVarType *pcbPtr = Os_SysTaskGetCurr();
OS_VALIDATE( (Os_SysIntAnyDisabled() == FALSE) , E_OS_DISABLEDINT ); /* @req SWS_Os_00093 */
/** !req OS699 */
/* Check if the task actually occupies the spinlock */
if (pcbPtr != NULL) { // When the OS itself is running pcbPtr is NULL
rv = E_OS_ACCESS;
TAILQ_FOREACH(sPtr, &pcbPtr->spinlockHead, spinlockEntry ) {
if (sPtr->id == spinlock_id)
rv = E_OK;
}
}
/** !req OS701 */
/* TOIMPROVEMENTDO: Check that no other spinlock has to be released before this one */
/** !req OS702 */
/* IMPROVEMENT: Check that LIFO order is correct in relation to RESOURCES */
return rv;
}
StatusType GetSpinlock(SpinlockIdType spinlock_id)
{
StatusType rv = E_OK;
OsSpinlockType *sPtr;
OsTaskVarType *pcbPtr = Os_SysTaskGetCurr();
OS_VALIDATE( (Os_SysIntAnyDisabled() == FALSE) , E_OS_DISABLEDINT ); /* @req SWS_Os_00093 */
/** OS689 */
OS_VALIDATE((SPINLOCK_CHECK_ID(spinlock_id)) , E_OS_ID );
sPtr = Os_SpinlockGet(spinlock_id);
#if (OS_APPLICATION_CNT > 1)
/** OS692 */
OS_VALIDATE( ( Os_ApplHaveAccess( sPtr->accessingApplMask ) == E_OK) , E_OS_ACCESS );
#endif
OS_VALIDATE( (GetSpinlockDeadlockCheck(spinlock_id)==E_OK), E_OS_INTERFERENCE_DEADLOCK);
/** OS687 */
Os_GetSpinlock(sPtr);
if (pcbPtr != NULL)
TAILQ_INSERT_TAIL(&pcbPtr->spinlockHead, sPtr, spinlockEntry);
/** OS688 */
return rv;
}
StatusType ReleaseSpinlock(SpinlockIdType spinlock_id)
{
StatusType rv = E_OK;
OsSpinlockType *sPtr;
OsTaskVarType *pcbPtr = Os_SysTaskGetCurr();
OS_VALIDATE( (Os_SysIntAnyDisabled() == FALSE) , E_OS_DISABLEDINT ); /* @req SWS_Os_00093 */
/** OS698 */
OS_VALIDATE((SPINLOCK_CHECK_ID(spinlock_id)) , E_OS_ID );
sPtr = Os_SpinlockGet(spinlock_id);
#if (OS_APPLICATION_CNT > 1)
/** OS700 */
OS_VALIDATE( ( Os_ApplHaveAccess( sPtr->accessingApplMask ) == E_OK) , E_OS_ACCESS );
#endif
OS_VALIDATE( (ReleaseSpinlockAccessCheck(spinlock_id) == E_OK), E_OS_ACCESS);
if (pcbPtr != NULL)
TAILQ_REMOVE(&pcbPtr->spinlockHead, sPtr, spinlockEntry);
Os_ReleaseSpinlock(sPtr);
/** OS697 */
return rv;
}
StatusType TryToGetSpinlock(SpinlockIdType spinlock_id, TryToGetSpinlockType* success)
{
StatusType rv = E_OK;
OsSpinlockType *sPtr;
OsTaskVarType *pcbPtr;
OS_VALIDATE( (Os_SysIntAnyDisabled() == FALSE) , E_OS_DISABLEDINT ); /* @req SWS_Os_00093 */
/** OS707 */
OS_VALIDATE((SPINLOCK_CHECK_ID(spinlock_id)) , E_OS_ID );
sPtr = Os_SpinlockGet(spinlock_id);
#if (OS_APPLICATION_CNT > 1)
/** OS710 */
OS_VALIDATE( ( Os_ApplHaveAccess( sPtr->accessingApplMask ) == E_OK) , E_OS_ACCESS );
#endif
OS_VALIDATE( (GetSpinlockDeadlockCheck(spinlock_id)==E_OK), E_OS_INTERFERENCE_DEADLOCK);
/** OS704 */ /** OS705 */
*success = Os_TryToGetSpinlock(sPtr);
if (*success == TRYTOGETSPINLOCK_SUCCESS) {
pcbPtr = Os_SysTaskGetCurr();
if (pcbPtr != NULL) {
TAILQ_INSERT_TAIL(&pcbPtr->spinlockHead, sPtr, spinlockEntry);
}
}
/** OS706 */
return rv;
}
|
2301_81045437/classic-platform
|
system/Os/rtos/src/os_spinlock.c
|
C
|
unknown
| 5,235
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SPINLOCK_I_H_
#define SPINLOCK_I_H_
typedef struct OsSpinlock {
SpinlockIdType id;
char name[32];
volatile unsigned int lock;
#if (OS_USE_APPLICATIONS == STD_ON)
uint32 accessingApplMask;
#endif
TAILQ_ENTRY(OsSpinlock) spinlockEntry;
} OsSpinlockType;
#if OS_SPINLOCK_CNT!=0
extern GEN_SPINLOCK_HEAD;
#endif
static inline OsSpinlockType *Os_SpinlockGet(SpinlockIdType id) {
#if OS_SPINLOCK_CNT!=0
return &spinlock_list[id];
#else
(void)id;
return NULL;
#endif
}
void Os_ArchGetSpinlock( volatile unsigned int *);
TryToGetSpinlockType Os_ArchTryToGetSpinlock( volatile unsigned int *);
void Os_ArchReleaseSpinlock( volatile unsigned int *);
static inline void Os_GetSpinlock(OsSpinlockType *sPtr) {
Os_ArchGetSpinlock(&sPtr->lock);
}
static inline TryToGetSpinlockType Os_TryToGetSpinlock(OsSpinlockType *sPtr) {
return (TryToGetSpinlockType)Os_ArchTryToGetSpinlock(&sPtr->lock);
}
static inline void Os_ReleaseSpinlock(OsSpinlockType *sPtr) {
Os_ArchReleaseSpinlock(&sPtr->lock);
}
#endif /*SPINLOCK_I_H_*/
|
2301_81045437/classic-platform
|
system/Os/rtos/src/os_spinlock_i.h
|
C
|
unknown
| 1,864
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SYS_H_
#define SYS_H_
#define SYSTEM_FLAGS_IN_OS 1u
/* STD container : OsOs. OSEK properties
* Class: ALL
*
* OsScalabilityClass: 0..1 SC1,SC2,SC3,SC4
* OsStackMonitoring: 1 Stack monitoring of tasks/category 2
* OsStatus 1 EXTENDED or STANDARD status
* OsUseGetServiceId 1 We can use the OSErrorGetServiceId() function
* OsUseParameterAccess 1 We save the parameters in OSError_XX_YY()
* OsUseResScheduler 1
* OsHooks[C] 1
*
* From OSEK/VDX oil:
*
* OS ExampleOS {
* STATUS = STANDARD;
* STARTUPHOOK = TRUE;
* ERRORHOOK = TRUE;
* SHUTDOWNHOOK = TRUE;
* PRETASKHOOK = FALSE;
* POSTTASKHOOK = FALSE;
* USEGETSERVICEID = FALSE;
* USEPARAMETERACCESS = FALSE;
* USERESSCHEDULER = TRUE;
* };
*
* OS_SC1 | OS_SC2 | OS_SC3 | OS_SC4
* OS_STACK_MONITORING
* OS_STATUS_EXTENDED / OS_STATUS_STANDARD
* OS_USE_GET_SERVICE_ID
* OS_USE_PARAMETER_ACCESS
* OS_RES_SCHEDULER
* */
struct os_conf_global_hook_s;
typedef enum {
OP_SET_EVENT = 1,
OP_WAIT_EVENT = 2,
OP_ACTIVATE_TASK = 4,
OP_TERMINATE_TASK = 8,
OP_SCHEDULE = 16,
OP_CHAIN_TASK = 32,
OP_RELEASE_RESOURCE = 64,
OP_SLEEP = 128,
OP_WAIT_SEMAPHORE = 256,
OP_SIGNAL_SEMAPHORE = 512,
} OpType ;
typedef struct Os_CoreStatus {
boolean activated;
boolean os_started;
boolean init_os_called;
} Os_CoreStatusType;
/*
* Global system structure
*/
typedef struct Os_Sys {
struct OsTaskVar *currTaskPtr; /* Current running task*/
struct OsTaskVar *oldTaskPtr;
struct OsIsrVar *currIsrPtr;
struct OsTaskVar *pcb_list; /* List of all tasks */
struct OsTaskVar *chainedPcbPtr;
uint32 intNestCnt; /* Interrupt nested count, 0 if no interrupt active */
TickType tick; /* The OS Tick counter */
uint8 op; /* The current operation */
void * intStack; /* Ptr to the interrupt stack */
struct OsHooks *hooks;
/* parameters for functions, used by OSErrorXXX() */
uint32 param1;
uint32 param2;
uint32 param3;
uint32 serviceId;
AppModeType appMode; /* According to OSEK 8.3 RES_SCHEDULER is accessible to all tasks */
#if (OS_USE_APPLICATIONS == STD_ON)
ApplicationStateType currApplState;
ApplicationType currApplId;
#endif
uint32 task_cnt;
uint32 isrCnt;
#if defined(CFG_KERNEL_EXTRA)
/* List of PCB's to be put in ready list when timeout */
TAILQ_HEAD(,OsTaskVar) timerHead; /* TASK */
OsSemType *semPtr;
#endif
TAILQ_HEAD(,OsTaskVar) ready_head; /* Ready queue */
struct OsResource *resScheduler; /* According to OSEK 8.3 RES_SCHEDULER is accessible to all tasks */
Os_CoreStatusType status;
boolean osFlags; /* Indication that the kernel is running */
} Os_SysType;
/*lint -esym(9003,Os_Sys) MISRA:OTHER:cannot be defined in block scope as it may be configured so several files use it:[MISRA 2012 Rule 8.9, advisory] */
extern Os_SysType Os_Sys[OS_NUM_CORES];
#if (OS_NUM_CORES > 1)
#define OS_SYS_PTR (&Os_Sys[GetCoreID()])
#else
#define OS_SYS_PTR (&Os_Sys[0])
#endif // (OS_NUM_CORES > 1)
static inline void Os_SysTaskSetCurr( struct OsTaskVar *pcb ) {
OS_SYS_PTR->currTaskPtr = pcb;
}
static inline struct OsTaskVar *Os_SysTaskGetCurr( void ) {
return OS_SYS_PTR->currTaskPtr;
}
static inline struct OsIsrVar *Os_SysIsrGetCurr( void ) {
return OS_SYS_PTR->currIsrPtr;
}
/**
* Check if any of the interrupt disable/suspends counters is != 0
*
* @return 1 if there are outstanding disable/suspends
*/
static inline _Bool Os_SysIntAnyDisabled( void ) {
return ((Os_IntDisableAllCnt | Os_IntSuspendAllCnt) != 0);
}
/**
* Clear all disable/system interrupts
*/
static inline void Os_SysIntClearAll( void ) {
Os_IntDisableAllCnt = 0;
Os_IntSuspendAllCnt = 0;
}
#endif /*SYS_H_*/
|
2301_81045437/classic-platform
|
system/Os/rtos/src/os_sys.h
|
C
|
unknown
| 4,829
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/** @reqSettings DEFAULT_SPECIFICATION_REVISION=4.3.0 */
/* ----------------------------[includes]------------------------------------*/
#include "os_i.h"
#include "debug.h"
/* ----------------------------[private define]------------------------------*/
/* ----------------------------[private macro]-------------------------------*/
/* ----------------------------[private typedef]-----------------------------*/
/* ----------------------------[private function prototypes]-----------------*/
void Os_StackSetup( OsTaskVarType *pcbPtr );
/* ----------------------------[private variables]---------------------------*/
#if OS_TASK_CNT!=0
OsTaskVarType Os_TaskVarList[OS_TASK_CNT];
#endif
/* ----------------------------[private functions]---------------------------*/
/**
* @brief Change state of a running task to not running.
* @param[in] pcb Pointer to task
*/
static inline void Os_TaskRunningToReady( OsTaskVarType *currPcbPtr ) {
ASSERT(currPcbPtr->state == ST_RUNNING );
currPcbPtr->state = ST_READY;
}
/**
* @brief Remove task from ready queue
* @param[in] pcb Pointer to task
*/
/*lint --e{818} MISRA:OTHER:need not be const pointer:[MISRA 2012 Rule 8.13, advisory] */
static void Os_ReadyQRemove(OsTaskVarType *tPtr) {
/*lint -e{9012, 9036} MISRA:EXTERNAL_FILE::[MISRA 2012 Rule 15.6, required], [MISRA 2012 Rule 14.4, required] */
TAILQ_REMOVE(&OS_SYS_PTR->ready_head,tPtr,ready_list);
OS_DEBUG(D_TASK,"Removed %s from ready list\n",pcb->constPtr->name);
}
/**
* @brief Add task to ready queue
* @param[in] pcb Pointer to task
*/
static void Os_ReadyQEnqueue(OsTaskVarType *pcb) {
/*lint -e{9036} MISRA:EXTERNAL_FILE::[MISRA 2012 Rule 14.4, required] */
TAILQ_INSERT_TAIL(& OS_SYS_PTR->ready_head,pcb,ready_list);
}
#if defined(CFG_KERNEL_EXTRA)
/**
* @brief Change state of a task to sleeping and remove from
* ready queue.
* @param pcb Pointer to task
*/
static inline void Os_TaskMakeSleeping( OsTaskVarType *pcb )
{
ASSERT( pcb->state & (ST_READY|ST_RUNNING) );
pcb->state = ST_SLEEPING;
Os_ReadyQRemove(pcb);
}
/**
* @brief Change state of a task to waiting on semaphore.
* Remove from ready queue.
* @param pcb Pointer to task
*/
static inline void Os_TaskMakeWaitingOnSem( OsTaskVarType *pcb )
{
ASSERT( pcb->state & (ST_READY|ST_RUNNING) );
pcb->state = ST_WAIT_SEM;
Os_ReadyQRemove(pcb);
}
#endif
/**
* @brief Change state of a task to waiting on suspended.
* Remove from ready queue.
*
* @param[in] pcb Pointer to task
*/
static inline void Os_TaskMakeSuspended( OsTaskVarType *pcb )
{
ASSERT( pcb->state & (ST_READY|ST_RUNNING) );
pcb->state = ST_SUSPENDED;
Os_ReadyQRemove(pcb);
}
/**
* @brief Set a clean context of a task.
* @details When a task a restarted (chained, terminate/activate) the context
* is setup as virgin.
*
* @param[in] pcb Pointer to task
*/
static inline void Os_Arc_SetCleanContext( OsTaskVarType *pcb ) {
if (pcb->constPtr->proc_type == PROC_EXTENDED) {
/** OSEK ActivateTask Cleanup events
* OSEK,ActivateTask, When an extended task is transferred from suspended
* state into ready state all its events are cleared.*/
pcb->ev_set = 0;
pcb->ev_wait = 0;
}
Os_StackSetup(pcb);
Os_ArchSetupContext(pcb);
}
/* ----------------------------[public functions]----------------------------*/
/**
* Make a task go the READY state
* Used by API: ActivateTask(), SetEvent()
*
* @param[in] currPcbPtr
*/
void Os_TaskMakeReady( OsTaskVarType *pcb ) {
if( ( pcb->state & ( ST_READY | ST_RUNNING ) ) == 0 ) {
pcb->state = ST_READY;
Os_ReadyQEnqueue(pcb);
OS_DEBUG(D_TASK,"Added %s to ready list\n",pcb->constPtr->name);
}
}
/**
* Make a task go the the WAITING state
* Used by API: WaitEvent
*
*
* @param[in] pcb Ptr to the task
*/
void Os_TaskMakeWaiting( OsTaskVarType *pcb )
{
ASSERT( pcb->state & (ST_READY|ST_RUNNING) );
pcb->state = ST_WAIT_EVENT;
Os_ReadyQRemove(pcb);
OS_DEBUG(D_TASK,"Removed %s from ready list\n",pcb->constPtr->name);
}
/**
* Fill the stack with a predefined pattern
*
* @param pcbPtr Pointer to the pcb to fill with pattern
*/
static void Os_StackFill(const OsTaskVarType *pcbPtr) {
const uint8 *p = pcbPtr->stack.curr;
/*lint -e{946} MISRA:FALSE_POSITIVE:Pointers belong to the same "array":[MISRA 2012 Rule 18.3, required]*/
ASSERT(pcbPtr->stack.curr > pcbPtr->stack.top);
/*lint -e{9033, 946, 947} MISRA:FALSE_POSITIVE:Pointers belong to the same "array":
*[MISRA 2012 Rule 18.2, required], [MISRA 2012 Rule 18.3, required]
*/
memset(pcbPtr->stack.top,STACK_PATTERN, (size_t)(p - (uint8 *)pcbPtr->stack.top) );
}
/* ----------------------------[public functions prototype]----------------------------*/
void Os_TaskPost( void );
//void Os_TaskSetupAndSwap( void );
/* ----------------------------[public functions definition]----------------------------*/
#if defined(CFG_PPC) || defined(CFG_ARMV7_AR) || defined (CFG_ARM_CR4) || defined(CFG_RH850) || defined(CFG_TMS570LC43X) || defined(CFG_TC2XX) || defined(CFG_TC3XX)
/**
* We come here after a task have returned.
*
*/
void Os_TaskPost( void ) {
/* We must manipulate OS structures so swap to privileged mode for SC3 and SC4 alone*/
#if ((OS_SC3 == STD_ON) || (OS_SC4 == STD_ON))
#if defined(CFG_PPC) || defined(CFG_TMS570)
OS_TRAP_Os_SetPrivilegedMode();
#elif defined(CFG_TC2XX)
uint32 pcxi = Os_GetCurrentPcxi();
Os_ArchToPrivilegedMode(pcxi);
#endif // arch
#endif // SC3 || SC4
OsTaskVarType *currPcbPtr= OS_SYS_PTR->currTaskPtr;
/** @req SWS_Os_00239 */
Irq_Disable();
if( Os_SysIntAnyDisabled() ) {
Os_SysIntClearAll();
}
/** @req SWS_Os_00070 */
if( Os_TaskOccupiesResources(currPcbPtr) ) {
Os_TaskResourceFreeAll(currPcbPtr);
}
/** @req SWS_Os_00069 */
Os_CallErrorHook(E_OS_MISSINGEND);
/** @req SWS_Os_00052 */
(void)TerminateTask();
}
#else // for Cortex M
/**
* Start an extended task.
* Tasks done:
* - Grab the internal resource for the process
* - Set it running state.
* - Start to execute the process
*
*/
void Os_TaskStartExtended( void ) {
OsTaskVarType *pcb;
pcb = Os_SysTaskGetCurr();
Os_ArchFirstCall();
/* We got back without any TerminateTask() or ChainTask()
*
* OSEK:
* Each task shall terminate itself at the end of its code.
* Ending the task without a call to TerminateTask or ChainTask
* is strictly forbidden and causes undefined behaviour.
*
* Autosar:
* OS052, OS069, OS070 and OS239
* */
/** @req SWS_Os_00239 */
Irq_Disable();
if( Os_SysIntAnyDisabled() ) {
Os_SysIntClearAll();
}
/** @req SWS_Os_00070 */
if( Os_TaskOccupiesResources(pcb) ) {
Os_TaskResourceFreeAll(pcb);
}
/** @req SWS_Os_00069 */
Os_CallErrorHook(E_OS_MISSINGEND);
/** @req SWS_Os_00052 */
(void)TerminateTask();
}
/**
* Start an basic task.
* Starting Basic & Extended task is same for Autosar (not like OSEK)
* Hence calling Os_TaskStartExtended() inside Os_TaskStartBasic to keep
* backward compatibility
*/
void Os_TaskStartBasic( void ) {
Os_TaskStartExtended();
}
#endif
/** @req SWS_Os_00067 */
void Os_StackSetup( OsTaskVarType *pcbPtr ) {
uint8 *bottom;
/* Find bottom of the stack so that we can place the
* context there.
*
* stack bottom = high address. stack top = low address
*/
/*lint -e{9016} MISRA:FALSE_POSITIVE:Allow calculation of address using pointers arithmetic:[MISRA 2012 Rule 18.4, advisory] */
bottom = (uint8 *)pcbPtr->stack.top + pcbPtr->stack.size;
/*lint -e{923} MISRA:FALSE_POSITIVE:Pointer is converted to integer to check the alignment:[MISRA 2012 Rule 11.6, required] */
ASSERT( ((uint32)bottom & 0x7UL) == 0 );
pcbPtr->stack.curr = bottom;
Os_StackSetStartmark(pcbPtr);
// Make some space for back-chain.
bottom -= ARCH_BACKCHAIN_SIZE;
// Set the current stack so that it points to the context
pcbPtr->stack.curr = bottom - Os_ArchGetScSize();
Os_StackSetEndmark(pcbPtr);
}
/**
* Setup the context for a pcb. The context differs for different arch's
* so we call the arch dependent functions also.
* The context at setup is always a small context.
*
* @param pcb Ptr to the pcb to setup context for.
*/
void Os_TaskContextInit( OsTaskVarType *pcb ) {
if( pcb->constPtr->autostart == TRUE) {
pcb->activations++;
Os_TaskMakeReady(pcb);
} else {
pcb->state = ST_SUSPENDED;
}
Os_StackSetup(pcb);
Os_StackFill(pcb);
Os_ArchSetupContext(pcb);
}
/**
* Find the top priority task. Even the running task is included.
* @return
*/
OsTaskVarType *Os_TaskGetTop( void ){
OsTaskVarType *i_pcb;
OsTaskVarType *top_prio_pcb = NULL_PTR;
OsPriorityType top_prio = 0;
boolean found = FALSE;
OS_DEBUG(D_TASK,"os_find_top_prio_proc\n");
/*lint -e{9036} MISRA:EXTERNAL_FILE::[MISRA 2012 Rule 14.4, required] */
TAILQ_FOREACH(i_pcb,& OS_SYS_PTR->ready_head,ready_list) {
// all ready task on the current core are candidates
if (Os_OnRunningCore(OBJECT_TASK,i_pcb->constPtr->pid)) {
ASSERT((i_pcb->state & (ST_READY | ST_RUNNING)) != 0u);
if( found == TRUE) {
if( i_pcb->activePriority > top_prio ) {
top_prio = i_pcb->activePriority;
top_prio_pcb = i_pcb;
}
} else {
found = TRUE;
top_prio = i_pcb->activePriority;
top_prio_pcb = i_pcb;
}
}
}
ASSERT(top_prio_pcb!=NULL_PTR);
OS_DEBUG(D_TASK,"Found %s\n",top_prio_pcb->constPtr->name);
return top_prio_pcb;
}
#if defined(CFG_ARMV7_AR) || defined(CFG_ARM_CR4) || defined(CFG_RH850) || defined(CFG_TMS570LC43X) || defined(CFG_TC2XX)
void Os_TaskSetupAndSwap( void ) {
OsTaskVarType *pcbPtr = Os_SysTaskGetCurr();
Os_ArchSetupContext(pcbPtr);
Os_ArchSwapContextTo(NULL_PTR, pcbPtr);
}
#endif
#ifdef CFG_T1_ENABLE
void Os_SwapPreHandler(OpType op,OsTaskVarType *old_pcb, OsTaskVarType *new_pcb){
switch (op) {
case OP_SET_EVENT:
break;
case OP_WAIT_EVENT:
Os_WaitEventHook(old_pcb->constPtr->pid);
break;
#if defined(CFG_KERNEL_EXTRA)
case OP_WAIT_SEMAPHORE:
Os_WaitEventHook(old_pcb->constPtr->pid);
break;
case OP_SLEEP:
Os_WaitEventHook(old_pcb->constPtr->pid);
break;
#endif
default:
/* @CODECOV:DEFAULT_CASE:Default statement is required for defensive programming. */
ASSERT(0);
break;
}
}
void Os_SwapPostHandler(OpType op,OsTaskVarType *old_pcb, OsTaskVarType *new_pcb){
switch (op) {
case OP_WAIT_EVENT:
Os_ResumeEventHook(old_pcb->constPtr->pid);
break;
#if defined(CFG_KERNEL_EXTRA)
case OP_WAIT_SEMAPHORE:
Os_ResumeEventHook(old_pcb->constPtr->pid);
break;
case OP_SLEEP:
Os_ResumeEventHook(old_pcb->constPtr->pid);
break;
#endif
default:
break;
}
}
#endif
// we come here from
// - WaitEvent()
// old_pcb -> WAITING
// new_pcb -> READY(RUNNING)
// - Schedule(),
// old_pcb -> READY
// new_pcb -> READY/RUNNING
/*
* two strategies
* 1. When running ->
* - remove from ready queue
* - set state == ST_RUNNING
*
* 2. When running ->
* * leave in ready queue
* * set state == ST_RUNNING
* - ready queue and ST_READY not the same
* + No need to remove the running process from ready queue
*/
#if defined(CFG_KERNEL_EXTRA)
/**
* Insert a task into the timer queue sorted with shortest timeout first.
*
* @param tPtr Task to insert.
*/
void Os_TimerQInsertSorted(OsTaskVarType *tPtr) {
OsTaskVarType *i_pcb;
uint8 insertLast = 1u;
ASSERT(tPtr!=NULL_PTR);
if ( TAILQ_EMPTY(& OS_SYS_PTR->timerHead) ) {
ASSERT( TAILQ_FIRST(& OS_SYS_PTR->timerHead) != tPtr );
TAILQ_INSERT_HEAD(& OS_SYS_PTR->timerHead,tPtr, timerEntry);
} else {
TAILQ_FOREACH(i_pcb,& OS_SYS_PTR->timerHead,timerEntry) {
ASSERT(i_pcb != tPtr );
if ( (tPtr->tmo) < (i_pcb->tmo) ) {
TAILQ_INSERT_BEFORE(i_pcb, tPtr, timerEntry);
insertLast = 0u;
break;
}
}
if( insertLast == 1u) {
ASSERT(i_pcb != tPtr );
TAILQ_INSERT_TAIL(& OS_SYS_PTR->timerHead,tPtr, timerEntry);
}
}
}
boolean Os_TimerQIsPresent(OsTaskVarType *tPtr) {
boolean rv = FALSE;
OsTaskVarType *i_pcb;
ASSERT(tPtr!=NULL_PTR);
TAILQ_FOREACH(i_pcb,& OS_SYS_PTR->timerHead,timerEntry) {
if( i_pcb == tPtr ) {
rv = TRUE;
break;
}
}
return rv;
}
/**
* returns true if list is empty
* @return
*/
boolean Os_TimerQIsEmpty( void ) {
return TAILQ_EMPTY(&OS_SYS_PTR->timerHead);
}
/**
* returns first task in timer queue (it does NOT remove it)
* @return
*/
OsTaskVarType * Os_TimerQFirst( void ) {
return TAILQ_FIRST(&OS_SYS_PTR->timerHead);
}
/**
* Remove task from timer queue.
* @param tPtr
*/
void Os_TimerQRemove(OsTaskVarType *tPtr) {
tPtr->tmo = TMO_INFINITE;
TAILQ_REMOVE(&OS_SYS_PTR->timerHead, tPtr, timerEntry);
}
StatusType Os_DispatchToSleepWithTmo( OpType op, TickType tmo) {
StatusType rv = E_OK;
OsTaskVarType *currPcbPtr = Os_SysTaskGetCurr();
ASSERT(tmo != 0);
/* Check if there is a dispatch lock */
if ( Os_SchedulerResourceIsFree() ) {
TickType now;
currPcbPtr->tmoVal = tmo;
if( tmo != TMO_INFINITE) {
now = GetOsTick();
currPcbPtr->tmo = now + tmo;
Os_TimerQInsertSorted(currPcbPtr );
}
currPcbPtr->rv = E_OK;
Os_Dispatch(op);
rv = currPcbPtr->rv;
/*
* rv = E_OK - Released from SignalSem/xx
* rv = E_OS_TIMEOUT - Released from OsTick
*
* Cases:
* rv tmo Action
* ------------------------------------
* E_OK 0 None
* E_OS_TIMEOUT 0 None
* E_OK X Add to queue
* E_OS_TIMEOUT X Add to queue
* E_OK INF None
* E_OS_TIMEOUT INF None
*/
} else {
/* Dispatched locked, can't go to sleep */
rv = E_OS_RESOURCE;
}
return rv;
}
#endif
/*
* Function: Os_TaskStartFromBeginning
* This function does the context setup and makes a fresh start of the task
*/
void Os_TaskStartFromBeginning( OsTaskVarType *pcbPtr )
{
#if defined(CFG_PPC)
Os_TaskMakeRunning(pcbPtr);
Os_SysTaskSetCurr(pcbPtr);
Os_CallPreTaskHook();
#ifdef CFG_T1_ENABLE
Os_StartTaskHook(pcbPtr->constPtr->pid);
#endif // CFG_T1_ENABLE
/* Adjust stack pointer beyond the context area */
Os_StackSetup(pcbPtr);
Os_ArchSetStackPointer(pcbPtr->stack.curr);
Os_ArchSetupContext(pcbPtr);
Os_ArchSwapContextTo(NULL_PTR, pcbPtr);
#elif defined(CFG_ARMV7_AR) || defined(CFG_ARM_CR4) || defined(CFG_RH850) || defined(CFG_TMS570LC43X) || defined(CFG_TC2XX)
Os_TaskMakeRunning(pcbPtr);
Os_SysTaskSetCurr(pcbPtr);
Os_CallPreTaskHook();
#ifdef CFG_T1_ENABLE
Os_StartTaskHook(pcbPtr->constPtr->pid);
#endif // CFG_T1_ENABLE
/* Adjust stack pointer beyond the context area */
Os_StackSetup(pcbPtr);
Os_ArchSetSpAndCall(pcbPtr->stack.curr,Os_TaskSetupAndSwap);
#else // ARCH other than PPC, ARMV7_AR, ARMCR4, RH850, TMS570, TC2XX
/* Setup the stack again, and just call the basic task */
Os_StackSetup(pcbPtr);
/* NOTE: release and get the internal resource ? */
Os_TaskMakeRunning(pcbPtr);
Os_SysTaskSetCurr(pcbPtr);
Os_CallPreTaskHook();
#ifdef CFG_T1_ENABLE
Os_StartTaskHook(pcbPtr->constPtr->pid);
#endif // CFG_T1_ENABLE
Os_ArchSetSpAndCall(pcbPtr->stack.curr,Os_TaskStartBasic);
ASSERT(0);
#endif
}
/**
* Tries to Dispatch.
*
* Used by:
* ActivateTask()
* WaitEvent()
* TerminateTask()
* ChainTask()
*
* @param force Force a re-scheduling
*
*/
void Os_Dispatch(OpType op) {
OsTaskVarType *pcbPtr;
OsTaskVarType *currPcbPtr = Os_SysTaskGetCurr();
ASSERT(OS_SYS_PTR->intNestCnt == 0);
ASSERT(Os_SchedulerResourceIsFree());
/* When calling post hook we must still be in ST_RUNNING */
ASSERT(currPcbPtr->state & ST_RUNNING); Os_CallPostTaskHook();
/* Go the correct state for running task */
switch (op) {
case OP_SET_EVENT:
case OP_SCHEDULE:
case OP_RELEASE_RESOURCE:
Os_TaskRunningToReady(currPcbPtr);
break;
case OP_WAIT_EVENT:
Os_TaskMakeWaiting(currPcbPtr);
break;
#if defined(CFG_KERNEL_EXTRA)
case OP_WAIT_SEMAPHORE:
Os_TaskMakeWaitingOnSem(currPcbPtr);
break;
case OP_SIGNAL_SEMAPHORE:
Os_TaskRunningToReady(currPcbPtr);
break;
case OP_SLEEP:
Os_TaskMakeSleeping(currPcbPtr);
break;
#endif
case OP_ACTIVATE_TASK:
Os_TaskMakeReady(currPcbPtr);
break;
case OP_CHAIN_TASK:
ASSERT(OS_SYS_PTR->chainedPcbPtr != NULL_PTR)
;
/* # from chain top
* ----------------------------------------------------------
* 1 1 1 1 1->RUNNING
* 2 1 1 2 1->READY, 2->RUNNING
* 3 1 2 2 1->SUSPENDED/READY*, 2->RUNNING
* 4 1 2 3 1->SUSPENDED/READY*, 2->READY , 3-RUNNING
*
* *) Depends on the number of activations.
*
* - Chained task is always READY when coming from ChainTask()
*/
if (currPcbPtr != OS_SYS_PTR->chainedPcbPtr) {
/* #3 and #4 */
ASSERT(currPcbPtr->activations > 0);
--currPcbPtr->activations;
if (currPcbPtr->activations == 0) {
Os_TaskMakeSuspended(currPcbPtr);
}
else {
Os_TaskRunningToReady(currPcbPtr);
currPcbPtr->reactivation = REACTIVATE_FROM_CHAINTASK;
}
/* Chained task is already in READY */
}
break;
case OP_TERMINATE_TASK:
#ifdef CFG_T1_ENABLE
Os_StopTaskHook(currPcbPtr->constPtr->pid);
#endif
/* OSEK TerminateTask
* In case of tasks with multiple activation requests,
* terminating the current instance of the task automatically puts the next
* instance of the same task into the ready state
*/
ASSERT(currPcbPtr->activations > 0)
;
--currPcbPtr->activations;
if (currPcbPtr->activations == 0) {
Os_TaskMakeSuspended(currPcbPtr);
}
break;
__CODE_COVERAGE_IGNORE__
default:
/* @CODECOV:DEFAULT_CASE: Default statement is required for defensive programming. */
ASSERT(0)
;
break;
}
pcbPtr = Os_TaskGetTop();
/* Swap if we found any process or are forced (multiple activations)*/
if (pcbPtr != currPcbPtr) {
/*
* Swap context
*/
ASSERT(pcbPtr!=NULL_PTR);
Os_ResourceReleaseInternal();
// Check for stack faults (under/overflow)
Os_StackPerformCheck(currPcbPtr);
OS_DEBUG(D_TASK,"Swapping to: %s\n",pcbPtr->constPtr->name);
#ifdef CFG_T1_ENABLE
Os_SwapPreHandler(op,currPcbPtr,pcbPtr);
#endif
#if defined(CFG_TC2XX) || defined(CFG_TC3XX)
if ( (op == OP_TERMINATE_TASK) || (op == OP_CHAIN_TASK) ) {
if (pcbPtr->reactivation == REACTIVATE_FROM_CHAINTASK) {
pcbPtr->reactivation = REACTIVATE_NORMAL;
Os_TaskStartFromBeginning(pcbPtr);
}
else {
Os_TaskSwapContextTo(NULL_PTR,pcbPtr);
}
}
else {
Os_TaskSwapContext(currPcbPtr,pcbPtr);
}
#else
if ((pcbPtr->reactivation == REACTIVATE_FROM_CHAINTASK)) {
pcbPtr->reactivation = REACTIVATE_NORMAL;
Os_TaskStartFromBeginning(pcbPtr);
}
else {
/* Adjust stack pointer beyond the context area */
Os_TaskSwapContext(currPcbPtr, pcbPtr);
}
#endif
#ifdef CFG_T1_ENABLE
Os_SwapPostHandler(op,currPcbPtr,pcbPtr);
#endif
}
else {
OS_DEBUG(D_TASK,"Continuing task %s\n",pcbPtr->constPtr->name);
Os_TaskStartFromBeginning(pcbPtr);
}
}
/*
* Functions: Os_TaskSwapContext
* Description: Function to change the context to new task and
* saving current task context to resume.
*/
void Os_TaskSwapContext(OsTaskVarType *old_pcb, OsTaskVarType *new_pcb ) {
Os_SysTaskSetCurr(new_pcb);
#if (OS_USE_APPLICATIONS == STD_ON)
OS_SYS_PTR->currApplId = new_pcb->constPtr->applOwnerId;
#endif
Os_ResourceGetInternal();
Os_TaskMakeRunning(new_pcb);
/* NOTE: The pretask hook is not called with the right stack
* (it's called on the old task stack, not the new ) */
Os_CallPreTaskHook();
#ifdef CFG_T1_ENABLE
Os_StartTaskHook(new_pcb->constPtr->pid);
#endif
Os_ArchSwapContext(old_pcb,new_pcb);
}
/*
* Functions: Os_TaskSwapContextTo
* Description: Used to change the context to new task
* when current running task need not be resumed. E.g. from Terminatetask, Chaintask, ISR.
*/
void Os_TaskSwapContextTo(OsTaskVarType *old_pcb, OsTaskVarType *new_pcb ) {
Os_SysTaskSetCurr(new_pcb);
#if (OS_USE_APPLICATIONS == STD_ON)
OS_SYS_PTR->currApplId = new_pcb->constPtr->applOwnerId;
#endif
Os_ResourceGetInternal();
Os_TaskMakeRunning(new_pcb);
Os_CallPreTaskHook();
#ifdef CFG_T1_ENABLE
Os_StartTaskHook(new_pcb->constPtr->pid);
#endif
Os_ArchSwapContextTo(old_pcb,new_pcb);
ASSERT(0);
}
#if !(defined(CFG_SAFETY_PLATFORM) || defined(BUILD_OS_SAFETY_PLATFORM))
void Os_Arc_GetStackInfo( TaskType task, StackInfoType *s) {
OsTaskVarType *pcb = Os_TaskGet(task);
if (s != NULL_PTR) {
s->curr = Os_ArchGetStackPtr();
s->top = pcb->stack.top;
s->at_swap = pcb->stack.curr;
s->size = pcb->stack.size;
s->usage = (void *)Os_StackGetUsage(pcb);
/*lint -e{923} MISRA:FALSE_POSITIVE:Pointer shall not be converted to integer vause because of undefined alignement issue, here the pointer is converted to integer to check the alignment:[MISRA 2012 Rule 11.6, required] */
/*lint -e{734} MISRA:FALSE_POSITIVE:No precision loss due to this typecasting:[MISRA 2004 Info, advisory] */
s->usageInPercent = ((s->size - (uint32)((size_t)s->usage - (size_t)s->top))*100)/s->size;
}
}
#endif
/**
* Returns the state of a task (running, ready, waiting, suspended)
* at the time of calling GetTaskState.
*
* @param TaskId Task reference
* @param State Reference to the state of the task
*/
StatusType GetTaskState(TaskType TaskId, TaskStateRefType State) {
state_t curr_state;
StatusType rv = E_OK;
const OsTaskVarType *pcb;
/* Validation of parameters, if failure, function will return */
/* This is not inline with Table 8, ISO26262-6:2011, Req 1a and 1h */
OS_VALIDATE_STD_2( (State != NULL_PTR), E_OS_PARAM_POINTER ,
OSServiceId_GetTaskState,TaskId, State); /* @req SWS_Os_00566 */
#if (OS_SC3==STD_ON) || (OS_SC4==STD_ON)
OS_VALIDATE_STD_2( (OS_VALIDATE_ADDRESS_RANGE(State,sizeof(TaskStateType)) == TRUE ) , E_OS_ILLEGAL_ADDRESS ,
OSServiceId_GetTaskState,TaskId, State);/*@req SWS_Os_00051 */
#endif
OS_VALIDATE_STD_2( TASK_CHECK_ID(TaskId) , E_OS_ID,
OSServiceId_GetTaskState,TaskId, State); /* @req OSEK_SWS_TM_00030 */
pcb = Os_TaskGet(TaskId);
#if (OS_APPLICATION_CNT > 1) && ( OS_NUM_CORES > 1)
if (Os_ApplGetCore(pcb->constPtr->applOwnerId) != GetCoreID()) {
StatusType status = Os_NotifyCore(Os_ApplGetCore(pcb->constPtr->applOwnerId),
OSServiceId_GetTaskState,
TaskId,
(uint32)State,
(uint32)0);
return status;
}
#endif
curr_state = os_pcb_get_state(pcb);
switch(curr_state) {
case ST_RUNNING:
*State = TASK_STATE_RUNNING;
break;
case ST_WAIT_EVENT:
*State = TASK_STATE_WAITING;
break;
#if defined(CFG_KERNEL_EXTRA)
case ST_WAIT_SEM:
*State = TASK_STATE_WAITING_SEM;
break;
#endif
case ST_SUSPENDED:
*State = TASK_STATE_SUSPENDED;
break;
case ST_READY:
*State = TASK_STATE_READY;
break;
__CODE_COVERAGE_IGNORE__
default:
/** @CODECOV:DEFAULT_CASE:Default statement is required for defensive programming. */
ASSERT(0);
break;
}
return rv;
}
/**
* GetTaskID returns the information about the TaskID of the task
* which is currently running.
*
* @param task_id Reference to the task which is currently running
* @return
*/
/* @req OSEK_SWS_TM_00015 */
StatusType GetTaskID(TaskRefType TaskID) {
StatusType rv = E_OK;
/* Validation of parameters, if failure, function will return */
/* This is not inline with Table 8, ISO26262-6:2011, Req 1a and 1h */
OS_VALIDATE_STD_1((TaskID != NULL_PTR), E_OS_PARAM_POINTER, OSServiceId_GetTaskID, TaskID); /* @req SWS_Os_00566 */
#if (OS_SC3==STD_ON) || (OS_SC4==STD_ON)
OS_VALIDATE_STD_1( (OS_VALIDATE_ADDRESS_RANGE(TaskID, sizeof(TaskType)) == TRUE) , E_OS_ILLEGAL_ADDRESS ,
OSServiceId_GetTaskID,TaskID);/*@req SWS_Os_00051 */
#endif
*TaskID = INVALID_TASK;
if ( OS_SYS_PTR->intNestCnt == 0) {
/* A task is running */
*TaskID = OS_SYS_PTR->currTaskPtr->constPtr->pid; /* @req OSEK_SWS_TM_00016 */
}
return rv;
}
/**
* The task <TaskID> is transferred from the suspended state into
* the ready state. The operating system ensures that the task
* code is being executed from the first statement.
*
* The service may be called from interrupt level and from task
* level (see Figure 12-1).
* Rescheduling after the call to ActivateTask depends on the
* place it is called from (ISR, non preemptable task, preemptable
* task).
*
* If E_OS_LIMIT is returned the activation is ignored.
* When an extended task is transferred from suspended state
* into ready state all its events are cleared.
*
* Note!
* ActivateTask will not immediately change the state of the task
* in case of multiple activation requests. If the task is not
* suspended, the activation will only be recorded and performed later.
*
* @param pid
* @return
*/
StatusType ActivateTask( TaskType TaskID ) {
imask_t flags;
const OsTaskVarType *currPcbPtr = Os_SysTaskGetCurr();
OsTaskVarType *destPcbPtr;
StatusType rv = E_OK;
OS_DEBUG(D_TASK,"# ActivateTask %s\n",currPcbPtr->constPtr->name);
OS_VALIDATE_STD_1( TASK_CHECK_ID(TaskID) , E_OS_ID,
OSServiceId_ActivateTask,TaskID); /* @req OSEK_SWS_TM_00001 */
destPcbPtr = Os_TaskGet(TaskID);
#if (OS_SC3==STD_ON) || (OS_SC4==STD_ON)
/* @req SWS_Os_00448
* The Operating System module shall prevent access of OS-Applications, trusted or non-trusted,
* to objects not belonging to this OS-Application,
* except access rights for such objects are explicitly granted by configuration.
* NOTE: As this requirement is generic to OS applications, requirement tagging done here alone. */
if( destPcbPtr->constPtr->applOwnerId != currPcbPtr->constPtr->applOwnerId ) {
ApplicationType appId;
/* @req SWS_Os_00509
* If a service call is made on an Operating System object that is owned by another OS-Application
* without state APPLICATION_ACCESSIBLE, then the Operating System module shall return E_OS_ACCESS.
* NOTE: As this requirement is generic to OS applications, requirement tagging done here alone. */
OS_VALIDATE_STD_1( (Os_ApplCheckState(destPcbPtr->constPtr->applOwnerId) != E_OS_ACCESS) , E_OS_ACCESS,
OSServiceId_ActivateTask,TaskID);
/* Do we have access to the task we are activating */
appId = Os_GetCurrTaskISROwnerId();
OS_VALIDATE_STD_1( (Os_ApplCheckAccess(appId , destPcbPtr->constPtr->accessingApplMask) != E_OS_ACCESS) , E_OS_ACCESS,
OSServiceId_ActivateTask,TaskID);
#if (OS_NUM_CORES > 1)
if (Os_ApplGetCore(destPcbPtr->constPtr->applOwnerId) != GetCoreID()) {
StatusType status = Os_NotifyCore(Os_ApplGetCore(destPcbPtr->constPtr->applOwnerId),
OSServiceId_ActivateTask,
TaskID,
(uint32)NULL,
(uint32)NULL);
return status;
}
#endif
}
#endif
/* @req SWS_Os_00093 ActivateTask */
OS_VALIDATE_STD_1( (Os_SysIntAnyDisabled() == FALSE) , E_OS_DISABLEDINT,
OSServiceId_ActivateTask,TaskID);
Irq_Save(flags);
#ifdef CFG_T1_ENABLE
Os_ActivateTaskHook(destPcbPtr->constPtr->pid);
#endif
destPcbPtr->activations++;
if( os_pcb_get_state(destPcbPtr) != ST_SUSPENDED ) {
/** Too many task activations */
if( destPcbPtr->activations > destPcbPtr->constPtr->activationLimit ) {
/* Standard */
rv=E_OS_LIMIT; /* OSEK Standard Status */ /* @req OSEK_SWS_TM_00002 */
Irq_Restore(flags);
--destPcbPtr->activations;
/* OS_STD_ERR_1: Function will return after calling ErrorHook */
/* This is not inline with Table 8, ISO26262-6:2011, Req 1a and 1h */
OS_STD_ERR_1(OSServiceId_ActivateTask,TaskID);
}
} else {
/* We have a suspended task, make it ready for use */
/* @req OSEK_SWS_TM_00003 */
ASSERT( destPcbPtr->activations == 1 );
Os_Arc_SetCleanContext(destPcbPtr);
Os_TaskMakeReady(destPcbPtr);
}
/* Preempt only if we are preemptable and target has higher prio than us */
/*lint -e{9007} MISRA:FALSE_POSITIVE:No side effects of Os_SchedulerResourceIsFree:[MISRA 2012 Rule 13.5, required]*/
if( (OS_SYS_PTR->intNestCnt == 0) &&
(currPcbPtr->constPtr->scheduling == FULL) &&
(destPcbPtr->activePriority > Os_SysTaskGetCurr()->activePriority)) {
Os_Dispatch(OP_ACTIVATE_TASK);
}
Irq_Restore(flags);
return rv;
}
/**
* This service causes the termination of the calling task. The
* calling task is transferred from the running state into the
* suspended state.
*
* An internal resource assigned to the calling task is automatically
* released. Other resources occupied by the task shall have been
* released before the call to TerminateTask. If a resource is still
* occupied in standard status the behaviour is undefined.
*
* If the call was successful, TerminateTask does not return to the
* call level and the status can not be evaluated.
*
* If the version with extended status is used, the service returns
* in case of error, and provides a status which can be evaluated
* in the application.
*
* If the service TerminateTask is called successfully, it enforces a
* rescheduling.
*
* [ Ending a task function without call to TerminateTask
* or ChainTask is strictly forbidden and may leave the system in an
* undefined state. ]
*
* [] is an OSEK requirement and is overridden by OS052
*
* @return
*/
StatusType TerminateTask( void ) {
StatusType rv = E_OK;
OsTaskVarType *currPcbPtr = Os_SysTaskGetCurr();
/* Validation of parameters, if failure, function will return */
/* This is not inline with Table 8, ISO26262-6:2011, Req 1a and 1h */
OS_VALIDATE_STD( (Os_SysIntAnyDisabled() == FALSE) , E_OS_DISABLEDINT , OSServiceId_TerminateTask); /* @req SWS_Os_00093 */
OS_DEBUG(D_TASK,"# TerminateTask %s\n",OS_SYS_PTR->currTaskPtr->constPtr->name);
OS_VALIDATE_STD( OS_SYS_PTR->intNestCnt == 0, E_OS_CALLEVEL, OSServiceId_TerminateTask); /* @req OSEK_SWS_TM_00005 */
OS_VALIDATE_STD( !Os_TaskOccupiesResources(currPcbPtr), E_OS_RESOURCE , OSServiceId_TerminateTask); /* @req OSEK_SWS_TM_00004 */
#if (OS_NUM_CORES > 1)
OS_VALIDATE_STD( !Os_TaskOccupiesSpinlocks(currPcbPtr), E_OS_SPINLOCK , OSServiceId_TerminateTask); /* SWS_Os_00612 */
#endif
Irq_Disable();
/* Force the dispatcher to find something, even if its us */
Os_Dispatch(OP_TERMINATE_TASK); /* @req OSEK_SWS_TM_00006 */
ASSERT(0);
return rv;
}
StatusType ChainTask( TaskType TaskId ) {
imask_t flags;
StatusType rv = E_OK;
OsTaskVarType *currPcbPtr = Os_SysTaskGetCurr();
OsTaskVarType *destPcbPtr;
/* Validation of parameters, if failure, function will return */
/* This is not inline with Table 8, ISO26262-6:2011, Req 1a and 1h */
OS_VALIDATE_STD_1((Os_SysIntAnyDisabled() == FALSE) , E_OS_DISABLEDINT,
OSServiceId_ChainTask,TaskId); /* @req SWS_Os_00093 */
OS_VALIDATE_STD_1(TASK_CHECK_ID(TaskId) , E_OS_ID,
OSServiceId_ChainTask,TaskId); /* @req SWS_Os_00093 */ /* @req OSEK_SWS_TM_00007*/
destPcbPtr = Os_TaskGet(TaskId);
OS_DEBUG(D_TASK,"# ChainTask %s\n",destPcbPtr->constPtr->name);
/* Validation of parameters, if failure, function will return */
/* This is not inline with Table 8, ISO26262-6:2011, Req 1a and 1h */
OS_VALIDATE_STD_1( OS_SYS_PTR->intNestCnt == 0, E_OS_CALLEVEL ,
OSServiceId_ChainTask,TaskId); /* @req OSEK_SWS_TM_00010 */
OS_VALIDATE_STD_1( !Os_TaskOccupiesResources(currPcbPtr), E_OS_RESOURCE ,
OSServiceId_ChainTask,TaskId); /* @req OSEK_SWS_TM_00009 */
#if (OS_NUM_CORES > 1)
OS_VALIDATE_STD_1( !Os_TaskOccupiesSpinlocks(currPcbPtr), E_OS_SPINLOCK ,
OSServiceId_ChainTask,TaskId); /* SWS_Os_00612 */
#endif
Irq_Save(flags);
if (currPcbPtr != destPcbPtr) {
/** Too many task activations */
if( (destPcbPtr->activations + 1) > destPcbPtr->constPtr->activationLimit ) {
rv = E_OS_LIMIT; /* OSEK Standard Status */ /* @req OSEK_SWS_TM_00008*/
Irq_Restore(flags);
/* OS_STD_ERR_1: Function will return after calling ErrorHook */
/* This is not inline with Table 8, ISO26262-6:2011, Req 1a and 1h */
OS_STD_ERR_1(OSServiceId_ChainTask,TaskId);
}
if( os_pcb_get_state(destPcbPtr) == ST_SUSPENDED ) {
ASSERT( destPcbPtr->activations == 0 );
Os_Arc_SetCleanContext(destPcbPtr);
Os_TaskMakeReady(destPcbPtr);
}
destPcbPtr->activations++;
}
OS_SYS_PTR->chainedPcbPtr = destPcbPtr;
#if (OS_APPLICATION_CNT > 1) && (OS_NUM_CORES > 1)
if (Os_ApplGetCore(destPcbPtr->constPtr->applOwnerId) != GetCoreID()) {
StatusType status = Os_NotifyCore(Os_ApplGetCore(destPcbPtr->constPtr->applOwnerId),
OSServiceId_ChainTask,
TaskId,
0,
0);
OS_SYS_PTR->chainedPcbPtr = destPcbPtr;
(void)status;
}
#endif
Os_Dispatch(OP_CHAIN_TASK); /* @req OSEK_SWS_TM_00011 */
ASSERT( 0 );
return rv;
}
/**
* If a higher-priority task is ready, the internal resource of the task
* is released, the current task is put into the ready state, its
* context is saved and the higher-priority task is executed.
* Otherwise the calling task is continued.
*
* NOTE: The OSEK spec says a lot of strange things under "particulareties"
* that I don't understand
*
* See OSEK/VDX 13.2.3.4
*
*/
StatusType Schedule( void ) {
StatusType rv = E_OK;
imask_t flags;
OsTaskVarType *currPcbPtr = Os_SysTaskGetCurr();
OS_DEBUG(D_TASK,"# Schedule %s\n",currPcbPtr->constPtr->name);
/* Validation of parameters, if failure, function will return */
/* This is not inline with Table 8, ISO26262-6:2011, Req 1a and 1h */
OS_VALIDATE_STD( (Os_SysIntAnyDisabled() == FALSE) , E_OS_DISABLEDINT , OSServiceId_Schedule); /* @req SWS_Os_00093 */
OS_VALIDATE_STD( OS_SYS_PTR->intNestCnt == 0, E_OS_CALLEVEL, OSServiceId_Schedule); /* @req SWS_Os_00088 */ /* @req OSEK_SWS_TM_00013 */
OS_VALIDATE_STD( !Os_TaskOccupiesResources(currPcbPtr), E_OS_RESOURCE , OSServiceId_Schedule); /* OSEK */ /* @req OSEK_SWS_TM_00012 */
#if (OS_NUM_CORES > 1)
OS_VALIDATE_STD( !Os_TaskOccupiesSpinlocks(currPcbPtr), E_OS_SPINLOCK , OSServiceId_Schedule); /* SWS_Os_00624 */
#endif
ASSERT( Os_SysTaskGetCurr()->state & ST_RUNNING);
/* We need to figure out if we have an internal resource,
* otherwise no re-scheduling.
* NON - Have internal resource prio OS_RES_SCHEDULER_PRIO (32+)
* FULL - Assigned internal resource OR
* No assigned internal resource.
* */
if( Os_SysTaskGetCurr()->constPtr->scheduling == NON ) {
Irq_Save(flags);
const OsTaskVarType* top_pcb = Os_TaskGetTop();
/* only dispatch if some other ready task has higher prio */
if (top_pcb->activePriority > Os_SysTaskGetCurr()->activePriority) {
Os_Dispatch(OP_SCHEDULE); /* @req OSEK_SWS_TM_00014 */
}
Irq_Restore(flags);
}
return rv;
}
#if !(defined(CFG_SAFETY_PLATFORM) || defined(BUILD_OS_SAFETY_PLATFORM))
void Os_Arc_GetTaskInfo( Arc_PcbType *pcbPtr, TaskType taskId, uint32 flags ) {
const OsTaskVarType *tP = Os_TaskGet(taskId);
ASSERT(pcbPtr!=NULL_PTR);
if( (flags & OS_ARC_F_TASK_BASIC) != 0u) {
strncpy(pcbPtr->name,tP->constPtr->name,OS_ARC_PCB_NAME_SIZE);
pcbPtr->tasktype = (tP->constPtr->proc_type == (proc_type_t)PROC_EXTENDED ) ? (uint32)ARC_TASKTYPE_EXENDED : (uint32)ARC_TASKTYPE_BASIC;
}
if( (flags & OS_ARC_F_TASK_STACK) != 0u ) {
Os_Arc_GetStackInfo(taskId, &pcbPtr->stack );
}
}
#endif
void Os_StackPerformCheck( OsTaskVarType *pcbPtr ) {
#if (OS_STACK_MONITORING == 1)
if((FALSE == Os_StackIsEndmarkOk(pcbPtr)) || (FALSE == Os_StackIsStartmarkOk(pcbPtr)) ) /*lint !e9007, OK side effect tested */
{
/** @req SWS_Os_00396
* If a stack fault is detected by stack monitoring AND the configured scalability
* class is 3 or 4, the Operating System module shall call the ProtectionHook() with
* the status E_OS_STACKFAULT.
* */
Os_CallProtectionHook(E_OS_STACKFAULT);
}
#endif
}
|
2301_81045437/classic-platform
|
system/Os/rtos/src/os_task.c
|
C
|
unknown
| 41,304
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/** @reqSettings DEFAULT_SPECIFICATION_REVISION=4.3.0 */
#ifndef TASK_I_H_
#define TASK_I_H_
/* ----------------------------[includes]------------------------------------*/
/* ----------------------------[define]--------------------------------------*/
#define PID_IDLE 0U
#define ST_READY (uint32)1U
#define ST_WAIT_EVENT ((uint32)1U<<(uint32)1U)
#define ST_SUSPENDED ((uint32)1U<<(uint32)2U)
#define ST_RUNNING ((uint32)1U<<(uint32)3U)
#define ST_NOT_STARTED ((uint32)1U<<(uint32)4U)
#define ST_SLEEPING ((uint32)1U<<(uint32)5U)
#define ST_WAIT_SEM ((uint32)1U<<(uint32)6U)
#define ST_WAIT_MUTEX ((uint32)1U<<(uint32)7U)
#define ST_ISR_RUNNING (uint32)1U
#define ST_ISR_NOT_RUNNING (uint32)2U
/* ----------------------------[macro]---------------------------------------*/
#define TASK_CHECK_ID(x) ((x) < OS_TASK_CNT)
/* ----------------------------[typedef]-------------------------------------*/
struct OsTaskConst;
typedef uint16 state_t;
/* from Os.h types */
typedef TaskType OsTaskidType;
typedef EventMaskType OsEventType;
/* Autosar want relative priorities */
typedef uint32 OsPriorityType;
/* OsTask/OsTaskSchedule */
enum OsTaskSchedule {
FULL,
NON
};
/*-----------------------------------------------------------------*/
typedef uint8 proc_type_t;
#define PROC_BASIC 0x1
#define PROC_EXTENDED 0x3
typedef struct {
void *curr; /* Current stack ptr( at swap time ) */
void *top; /* Top of the stack( low address ) */
uint32 size; /* The size of the stack */
} OsStackType;
#define SYS_FLAG_HOOK_STATE_EXPECTING_PRE 0
#define SYS_FLAG_HOOK_STATE_EXPECTING_POST 1
#define REACTIVATE_NORMAL (0)
#define REACTIVATE_FROM_CHAINTASK (1)
typedef struct OsTaskVar {
OsStackType stack;
state_t state;
OsEventType ev_wait; /* Events the task wait for
* ( what events WaitEvent() was called with) */
OsEventType ev_set; /* Events that are set by SetEvent() on the task */
OsEventType ev_react; /* The events the task may react on */
uint32 flags;
OsPriorityType activePriority; /* Priority of the task, this can be different depening on if the
* task hold resources. Related to priority inversion */
uint8 activations; /* The number of queued activation of a task */
uint8 reactivation; /* Retains the history for, after chaining a task the current task shall start from the beginning (when activation count > 1) */
uint32 resourceMaskTaken; /* What resource that are currently held by this task
* Typically (1<<RES_xxx) | (1<<RES_yyy) */
TAILQ_HEAD(head,OsResource) resourceHead;
#if (OS_NUM_CORES > 1)
TAILQ_HEAD(shead,OsSpinlock) spinlockHead; /* Occupied spinlocks list */
#endif
const struct OsTaskConst *constPtr;
uint32 regs[16]; /* NOTE: Arch specific regs .. make space for them later...*/
#if defined(CFG_KERNEL_EXTRA)
TAILQ_ENTRY(OsTaskVar) timerEntry;
/* Absolute timeout in ticks */
TickType tmo;
/* Set timeout value */
TickType tmoVal;
/* return value back to scheduler */
StatusType rv;
OsSemType *semPtr;
/* Semaphore list */
STAILQ_ENTRY(OsTaskVar) semEntry;
/* Mutex list */
STAILQ_ENTRY(OsTaskVar) mutexEntry;
#endif
TAILQ_ENTRY(OsTaskVar) ready_list;
} OsTaskVarType;
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
/* STD container : OsTask
* OsTaskActivation: 1
* OsTaskPriority: 1
* OsTaskSchedule: 1
* OsTaskAccessingApplication: 0..*
* OsTaskEventRef: 0..*
* OsTaskResourceRef: 0..*
* OsTaskAutoStart[C] 0..1
* OsTaskTimingProtection[C] 0..1
* */
typedef struct OsTaskConst {
OsTaskidType pid;
OsPriorityType prio;
void (*entry)( void );
proc_type_t proc_type;
uint8 autostart;
OsStackType stack;
#if (OS_USE_APPLICATIONS == STD_ON)
ApplicationType applOwnerId; /* Application that owns this task */
uint32 accessingApplMask; /* Applications that may access task
* when state is APPLICATION_ACCESSIBLE */
#endif
const char *name;
enum OsTaskSchedule scheduling;
uint32 resourceAccess;
EventMaskType eventMask;
struct OsResource *resourceIntPtr; /* pointer to internal resource, NULL if none */
uint8 activationLimit;
} OsTaskConstType;
/* ----------------------------[function prototypes]-------------------------*/
extern OsTaskVarType Os_TaskVarList[OS_TASK_CNT];
extern GEN_TASK_HEAD;
void Os_Dispatch( OpType op );
StatusType Os_DispatchToSleepWithTmo( OpType op, uint32 tmo);
void Os_TaskMakeReady( OsTaskVarType *pcb );
void Os_TaskMakeWaiting( OsTaskVarType *pcb );
void Os_TaskSwapContext ( OsTaskVarType *old_pcb, OsTaskVarType *new_pcb );
void Os_TaskSwapContextTo( OsTaskVarType *old_pcb, OsTaskVarType *new_pcb );
void Os_TaskStartFromBeginning( OsTaskVarType *pcbPtr );
void Os_TaskStartExtended( void );
void Os_TaskStartBasic( void );
void Os_TaskContextInit( OsTaskVarType *pcb );
TaskType Os_AddTask( OsTaskVarType *pcb );
OsTaskVarType * Os_TaskGetTop( void );
/**
* Set the task to running state and remove from ready list
*
* @params pcb Ptr to pcb
*/
static inline void Os_TaskMakeRunning( OsTaskVarType *pcb ) {
pcb->state = ST_RUNNING;
}
static inline OsTaskVarType * Os_TaskGet( TaskType pid ) {
return &Os_TaskVarList[pid];
}
static inline ApplicationType Os_TaskGetApplicationOwner( TaskType id ) {
ApplicationType rv;
if( id < OS_TASK_CNT ) {
rv = Os_TaskConstList[id].applOwnerId;
} else {
/** @req SWS_Os_00274 */
rv = INVALID_OSAPPLICATION;
}
return rv;
}
/**
* Add a resource to a list of resources held by pcbPtr
*
* @param rPtr Ptr to the resource to add to the task
* @param pcbPtr Ptr to the task
*/
static inline void Os_TaskResourceAdd( OsResourceType *rPtr, OsTaskVarType *pcbPtr) {
/* Save old task prio in resource and set new task prio */
rPtr->owner = pcbPtr->constPtr->pid;
rPtr->old_task_prio = pcbPtr->activePriority;
pcbPtr->activePriority = rPtr->ceiling_priority;
if( rPtr->type != RESOURCE_TYPE_INTERNAL ) {
TAILQ_INSERT_TAIL(&pcbPtr->resourceHead, rPtr, listEntry);
}
}
/**
* Remove a resource from the list of resources held by pcbPtr
* @param rPtr Ptr to the resource to remove from the task
* @param pcbPtr Ptr to the task
*/
static inline void Os_TaskResourceRemove( OsResourceType *rPtr , OsTaskVarType *pcbPtr) {
ASSERT( rPtr->owner == pcbPtr->constPtr->pid );
rPtr->owner = NO_TASK_OWNER;
pcbPtr->activePriority = rPtr->old_task_prio;
if( rPtr->type != RESOURCE_TYPE_INTERNAL ) {
/* The list can't be empty here */
ASSERT( !TAILQ_EMPTY(&pcbPtr->resourceHead) );
/* The list should be popped in LIFO order */
ASSERT( TAILQ_LAST(&pcbPtr->resourceHead, head) == rPtr );
/* Remove the entry */
TAILQ_REMOVE(&pcbPtr->resourceHead, rPtr, listEntry);
}
}
/**
* Free all resource held by a task.
*
* @param pcbPtr Ptr to the task
*/
static inline void Os_TaskResourceFreeAll( OsTaskVarType *pcbPtr ) {
OsResourceType *rPtr;
/* Pop the queue */
TAILQ_FOREACH(rPtr, &pcbPtr->resourceHead, listEntry ) {
Os_TaskResourceRemove(rPtr,pcbPtr);
}
}
#define os_pcb_get_state(pcb) ((pcb)->state)
#if !(defined(CFG_SAFETY_PLATFORM) || defined(BUILD_OS_SAFETY_PLATFORM))
static inline void *Os_StackGetUsage( OsTaskVarType *pcb ) {
uint8 *p = pcb->stack.curr;
uint8 *end = pcb->stack.top;
while( (*end == STACK_PATTERN) && (end<p)) {
end++;
}
return (void *)end;
}
#endif
static inline void Os_StackSetStartmark( OsTaskVarType *pcbPtr ) {
uint8 *start = (uint8 *)pcbPtr->stack.top + pcbPtr->stack.size;
/* For Tricore architecture NULL in the start of the stack is used for CSA linked list.
* Hence setting STACK_PATTERN in start-1.
*/
*(start-1) = STACK_PATTERN;
}
static inline void Os_StackSetEndmark( OsTaskVarType *pcbPtr ) {
uint8 *end = pcbPtr->stack.top;
*end = STACK_PATTERN;
}
static inline boolean Os_StackIsEndmarkOk( OsTaskVarType *pcbPtr ) {
boolean rv = FALSE;
uint8 *end = pcbPtr->stack.top;
rv = ( *end == STACK_PATTERN);
if( !rv ) {
// stack overflow occurred
OS_DEBUG(D_TASK,"Stack End Mark is bad for %s curr: %p curr: %p\n",
pcbPtr->constPtr->name,
pcbPtr->stack.curr,
pcbPtr->stack.top );
}
return rv;
}
static inline boolean Os_StackIsStartmarkOk( OsTaskVarType *pcbPtr ) {
boolean rv = FALSE;
uint8 *start = (uint8 *)pcbPtr->stack.top + pcbPtr->stack.size;
rv = ( *(start-1) == STACK_PATTERN);
if( !rv ) {
// stack underflow occurred
OS_DEBUG(D_TASK,"Stack Start Mark is bad for %s curr: %p curr: %p\n",
pcbPtr->constPtr->name,
pcbPtr->stack.curr,
pcbPtr->stack.top );
}
return rv;
}
void Os_StackPerformCheck( OsTaskVarType *pcbPtr );
static inline _Bool Os_TaskOccupiesResources( OsTaskVarType *pcb ) {
return !(TAILQ_EMPTY(&pcb->resourceHead));
}
#if (OS_NUM_CORES > 1)
static inline _Bool Os_TaskOccupiesSpinlocks( OsTaskVarType *pcb ) {
return !(TAILQ_EMPTY(&pcb->spinlockHead));
}
#endif //OS_NUM_CORES > 1
void Os_TimerQInsertSorted(OsTaskVarType *tPtr);
boolean Os_TimerQIsPresent(OsTaskVarType *tPtr);
/**
* returns true if list is empty
* @return
*/
boolean Os_TimerQIsEmpty( void );
/**
* returns first task in timer queue (it does NOT remove it)
* @return
*/
OsTaskVarType * Os_TimerQFirst( void );
/**
* Remove task from timer queue.
* @param tPtr
*/
void Os_TimerQRemove(OsTaskVarType *tPtr);
#endif /*TASK_I_H_*/
|
2301_81045437/classic-platform
|
system/Os/rtos/src/os_task_i.h
|
C
|
unknown
| 11,327
|
#SchM
# Add the regular SchM as a target if both SCHM is used as module
# and if SAFETY_PLATFORM has not been added to CFG +=
obj-$(USE_SCHM)-$(if $(CFG_SAFETY_PLATFORM),,y) += SchM.o
# Add safety platform SCHM solution if both SCHM and
# CFG_SAFETYPLATFORM have been defined
obj-$(USE_SCHM)-$(CFG_SAFETY_PLATFORM) += SchM_partition_QM.o
obj-$(USE_SCHM)-$(CFG_SAFETY_PLATFORM) += SchM_partition_A0.o
# The SchM/inc should always be included even if SchM module is not used
inc-y += $(ROOTDIR)/system/SchM/inc
vpath-$(USE_SCHM) += $(ROOTDIR)/system/SchM/src
# MemMap is located in src directory, used for safety platform
inc-$(USE_SCHM)-$(CFG_SAFETY_PLATFORM) += $(ROOTDIR)/system/SchM/src
|
2301_81045437/classic-platform
|
system/SchM/SchM.mod.mk
|
Makefile
|
unknown
| 715
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/** @reqSettings DEFAULT_SPECIFICATION_REVISION=4.3.0 */
/** @fileSafetyClassification ASIL **/ /* Same SchM.h always used */
/* @req ARC_SWS_SchM_00002 The Basic Software Scheduler shall provide APIs for other BSW modules to enter exclusive areas */
/* @req ARC_SWS_SchM_00009 The Basic Software Scheduler shall provide complementary APIs for other BSW modules to exit exclusive areas */
/* @req SWS_BSW_00020 */
/* @req ARC_SWS_SchM_00010 The SchM module shall be designed and implemented as a compile and hardware independent module. */
#ifndef SCHM_H_
#define SCHM_H_
/* @req SWS_BSW_00024 Include AUTOSAR Standard Types Header in implementation header */
#include "Std_Types.h"
#define SCHM_MODULE_ID 130u
#define SCHM_VENDOR_ID 60u
/* @req SWS_BSW_00059 Published information */
#define SCHM_SW_MAJOR_VERSION 1u
#define SCHM_SW_MINOR_VERSION 0u
#define SCHM_SW_PATCH_VERSION 0u
#define SCHM_AR_RELEASE_MAJOR_VERSION 4u
#define SCHM_AR_RELEASE_MINOR_VERSION 0u
void SchM_GetVersionInfo( Std_VersionInfoType *versionInfo ); /* @req ARC_SWS_SchM_00007 */
void SchM_Init( void );
void SchM_Deinit( void );
#define SchM_Enter( _module, _exc_area ) \
SchM_Enter_EcuM ## _module ## _exc_area
#define SchM_Exit( _module, _exc_area ) \
SchM_Enter_EcuM ## _module ## _exc_area
#define CONCAT_(_x,_y) _x##_y
typedef struct {
uint32 timer;
} SchM_InfoType;
#define SCHM_DECLARE(_mod) \
SchM_InfoType SchM_Info_ ## _mod
/* @req ARC_SWS_SchM_00008 */
#define SCHM_MAINFUNCTION(_mod,_func) \
if( (++SchM_Info_ ## _mod.timer % SCHM_MAINFUNCTION_CYCLE_ ## _mod )== 0 ) { \
_func; \
SchM_Info_ ## _mod.timer = 0; \
}
#endif /*SCHM_H_*/
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM.h
|
C
|
unknown
| 2,567
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef _SCHM_ADC_H_
#define _SCHM_ADC_H_
#endif /* SCHM_CAN_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_Adc.h
|
C
|
unknown
| 832
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_BSWM_H_
#define SCHM_BSWM_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_BswM_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_BswM_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_BswM_EA_0() SuspendOSInterrupts()
#define SchM_Exit_BswM_EA_0() ResumeOSInterrupts()
#endif
#define SCHM_MAINFUNCTION_BSWM() SCHM_MAINFUNCTION(BSWM,BswM_MainFunction())
#endif /* SCHM_BSWM_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_BswM.h
|
C
|
unknown
| 1,216
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_CAN_H_
#define SCHM_CAN_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_Can_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_Can_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_Can_EA_0() SuspendOSInterrupts()
#define SchM_Exit_Can_EA_0() ResumeOSInterrupts()
#endif
#define SCHM_MAINFUNCTION_CAN_WRITE() SCHM_MAINFUNCTION(CAN_WRITE,Can_MainFunction_Write())
#define SCHM_MAINFUNCTION_CAN_READ() SCHM_MAINFUNCTION(CAN_READ,Can_MainFunction_Read())
#define SCHM_MAINFUNCTION_CAN_BUSOFF() SCHM_MAINFUNCTION(CAN_BUSOFF,Can_MainFunction_BusOff())
#define SCHM_MAINFUNCTION_CAN_WAKEUP() SCHM_MAINFUNCTION(CAN_WAKEUP,Can_MainFunction_Wakeup())
#define SCHM_MAINFUNCTION_CAN_ERROR() SCHM_MAINFUNCTION(CAN_ERROR,Can_Arc_MainFunction_Error())
#define SCHM_MAINFUNCTION_CAN_MODE() SCHM_MAINFUNCTION(CAN_MODE,Can_MainFunction_Mode())
#endif /* SCHM_CAN_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_Can.h
|
C
|
unknown
| 1,705
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_CANIF_H_
#define SCHM_CANIF_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_CanIf_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_CanIf_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_CanIf_EA_0() SuspendOSInterrupts()
#define SchM_Exit_CanIf_EA_0() ResumeOSInterrupts()
#endif
#endif /* SCHM_CANIF_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_CanIf.h
|
C
|
unknown
| 1,149
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_CANNM_H_
#define SCHM_CANNM_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_CanNm_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_CanNm_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_CanNm_EA_0() SuspendOSInterrupts()
#define SchM_Exit_CanNm_EA_0() ResumeOSInterrupts()
#endif
#define SCHM_MAINFUNCTION_CANNM() SCHM_MAINFUNCTION(CANNM,CanNm_MainFunction())
/* Skip "instance", req INTEGR058 */
#if 0
#define SchM_Enter_CanNm(uint8 exclusiveArea )
#define SchM_Exit_CanNM(uint8 exclusiveArea )
#define SchM_ActMainFunction_CanNm(uint8 exclusiveArea )
#define SchM_CancelMainFunction_CanNm( uint8 exclusiveArea )
#endif
#endif /* SCHM_CANNM_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_CanNm.h
|
C
|
unknown
| 1,505
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_CANSM_H_
#define SCHM_CANSM_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_CanSm_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_CanSm_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_CanSm_EA_0() SuspendOSInterrupts()
#define SchM_Exit_CanSm_EA_0() ResumeOSInterrupts()
#endif
#define SCHM_MAINFUNCTION_CANSM() SCHM_MAINFUNCTION(CANSM,CanSM_MainFunction())
#endif /* SCHM_CANSM_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_CanSM.h
|
C
|
unknown
| 1,249
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_CANTP_H_
#define SCHM_CANTP_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_CanTp_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_CanTp_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_CanTp_EA_0() SuspendOSInterrupts()
#define SchM_Exit_CanTp_EA_0() ResumeOSInterrupts()
#endif
#define SCHM_MAINFUNCTION_CANTP() SCHM_MAINFUNCTION(CANTP,CanTp_MainFunction())
#endif /* SCHM_CANTP_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_CanTp.h
|
C
|
unknown
| 1,247
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_CANTRCV_H_
#define SCHM_CANTRCV_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_CanTrcv_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_CanTrcv_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_CanTrcv_EA_0() SuspendOSInterrupts()
#define SchM_Exit_CanTrcv_EA_0() ResumeOSInterrupts()
#endif
#define SCHM_MAINFUNCTION_CANTRCV() SCHM_MAINFUNCTION(CANTRCV,CanTrcv_MainFunction())
#endif /* SCHM_CANTRCV_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_CanTrcv.h
|
C
|
unknown
| 1,269
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_COM_H_
#define SCHM_COM_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_Com_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_Com_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_Com_EA_0() SuspendOSInterrupts()
#define SchM_Exit_Com_EA_0() ResumeOSInterrupts()
#endif
#define SCHM_MAINFUNCTION_COMRX() SCHM_MAINFUNCTION(COMRX,Com_MainFunctionRx())
#define SCHM_MAINFUNCTION_COMTX() SCHM_MAINFUNCTION(COMTX,Com_MainFunctionTx())
#endif /* SCHM_COM_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_Com.h
|
C
|
unknown
| 1,303
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_COMM_H_
#define SCHM_COMM_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_ComM_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_ComM_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_ComM_EA_0() SuspendOSInterrupts()
#define SchM_Exit_ComM_EA_0() ResumeOSInterrupts()
#endif
#define SCHM_MAINFUNCTION_COMM() SCHM_MAINFUNCTION(COMM,ComM_MainFunction_All_Channels())
#endif /* SCHM_COMM_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_ComM.h
|
C
|
unknown
| 1,240
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_DCM_H_
#define SCHM_DCM_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_Dcm_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_Dcm_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_Dcm_EA_0() SuspendOSInterrupts()
#define SchM_Exit_Dcm_EA_0() ResumeOSInterrupts()
#endif
#define SCHM_MAINFUNCTION_DCM() SCHM_MAINFUNCTION(DCM,Dcm_MainFunction())
#endif /* SCHM_DCM_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_Dcm.h
|
C
|
unknown
| 1,215
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_DEM_H_
#define SCHM_DEM_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_Dem_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_Dem_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_Dem_EA_0() SuspendOSInterrupts()
#define SchM_Exit_Dem_EA_0() ResumeOSInterrupts()
#endif
#define SCHM_MAINFUNCTION_DEM() SCHM_MAINFUNCTION(DEM,Dem_MainFunction())
#endif /* SCHM_DEM_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_Dem.h
|
C
|
unknown
| 1,215
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_DET_H_
#define SCHM_DET_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_Det_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_Det_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_Det_EA_0() SuspendOSInterrupts()
#define SchM_Exit_Det_EA_0() ResumeOSInterrupts()
#endif
#endif /* SCHM_DET_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_Det.h
|
C
|
unknown
| 1,128
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_DIO_H_
#define SCHM_DIO_H_
#include "Os.h"
#define SchM_Enter_Dio_EA_0() SuspendOSInterrupts()
#define SchM_Exit_Dio_EA_0() ResumeOSInterrupts()
#endif /* SCHM_DIO_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_Dio.h
|
C
|
unknown
| 954
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_DLT_H_
#define SCHM_DLT_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_Dlt_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_Dlt_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_Dlt_EA_0() SuspendOSInterrupts()
#define SchM_Exit_Dlt_EA_0() ResumeOSInterrupts()
#endif
#endif /* SCHM_DLT_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_Dlt.h
|
C
|
unknown
| 1,135
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_DOIP_H_
#define SCHM_DOIP_H_
#include "Os.h"
#define SchM_Enter_DoIP_EA_0() SuspendOSInterrupts()
#define SchM_Exit_DoIP_EA_0() ResumeOSInterrupts()
#endif /* SCHM_DoIP_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_DoIP.h
|
C
|
unknown
| 954
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_EA_H
#define SCHM_EA_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_Ea_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_Ea_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_Ea_EA_0() SuspendOSInterrupts()
#define SchM_Exit_Ea_EA_0() ResumeOSInterrupts()
#endif
#define SCHM_MAINFUNCTION_EA() SCHM_MAINFUNCTION(EA,Ea_MainFunction())
#endif /* SCHM_EA_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_Ea.h
|
C
|
unknown
| 1,205
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_ECUM_H_
#define SCHM_ECUM_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_EcuM_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_EcuM_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_EcuM_EA_0() SuspendOSInterrupts()
#define SchM_Exit_EcuM_EA_0() ResumeOSInterrupts()
#endif // (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#if defined(CFG_SAFETY_PLATFORM)
#define SCHM_MAINFUNCTION_ECUM_ASIL(_state,_rv) SP_SCHM_MAINFUNCTION(_rv,ECUM_A0,EcuM_MainFunction_Partition_A0(_state))
#define SCHM_MAINFUNCTION_ECUM_QM(_state,_rv) SP_SCHM_MAINFUNCTION(_rv,ECUM_QM,EcuM_MainFunction_Partition_QM(_state))
#else
#define SCHM_MAINFUNCTION_ECUM() SCHM_MAINFUNCTION(ECUM,EcuM_MainFunction())
#endif // CFG_SAFETY_PLATFORM
/* Skip "instance", req INTEGR058 */
#if 0
#define SchM_Enter_EcuM(uint8 exclusiveArea )
#define SchM_Exit_EcuM(uint8 exclusiveArea )
#define SchM_ActMainFunction_EcuM(uint8 exclusiveArea )
#define SchM_CancelMainFunction_EcuM( uint8 exclusiveArea )
#endif
#endif /* SCHM_ECUM_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_EcuM.h
|
C
|
unknown
| 1,855
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_EEP_H_
#define SCHM_EEP_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_Eep_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_Eep_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_Eep_EA_0() SuspendOSInterrupts()
#define SchM_Exit_Eep_EA_0() ResumeOSInterrupts()
#endif
#define SCHM_MAINFUNCTION_EEP() SCHM_MAINFUNCTION(EEP,Eep_MainFunction())
#endif /* SCHM_EEP_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_Eep.h
|
C
|
unknown
| 1,230
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_ETH_H_
#define SCHM_ETH_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_Eth_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_Eth_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_Eth_EA_0() SuspendOSInterrupts()
#define SchM_Exit_Eth_EA_0() ResumeOSInterrupts()
#endif
#endif /* SCHM_ETH_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_Eth.h
|
C
|
unknown
| 1,135
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_ETHIF_H_
#define SCHM_ETHIF_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_EthIf_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_EthIf_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_EthIf_EA_0() SuspendOSInterrupts()
#define SchM_Exit_EthIf_EA_0() ResumeOSInterrupts()
#endif
#endif /* SCHM_ETHIF_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_EthIf.h
|
C
|
unknown
| 1,149
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_FEE_H_
#define SCHM_FEE_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_Fee_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_Fee_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_Fee_EA_0() SuspendOSInterrupts()
#define SchM_Exit_Fee_EA_0() ResumeOSInterrupts()
#endif
#define SCHM_MAINFUNCTION_FEE() SCHM_MAINFUNCTION(FEE,Fee_MainFunction())
#endif /* SCHM_FEE_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_Fee.h
|
C
|
unknown
| 1,217
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef _SCHM_FIM_H_
#define _SCHM_FIM_H_
#define SCHM_MAINFUNCTION_FIM() SCHM_MAINFUNCTION(FIM,FiM_MainFunction())
#endif /* _SCHM_FIM_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_FiM.h
|
C
|
unknown
| 902
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_FLS_H_
#define SCHM_FLS_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_Fls_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_Fls_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_Fls_EA_0() SuspendOSInterrupts()
#define SchM_Exit_Fls_EA_0() ResumeOSInterrupts()
#endif
#define SCHM_MAINFUNCTION_FLS() SCHM_MAINFUNCTION(FLS,Fls_MainFunction())
#endif /* SCHM_FLS_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_Fls.h
|
C
|
unknown
| 1,227
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_FRIF_H_
#define SCHM_FRIF_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_FrIf_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_FrIf_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_FrIf_EA_0() SuspendOSInterrupts()
#define SchM_Exit_FrIf_EA_0() ResumeOSInterrupts()
#endif
/* #define SCHM_MAINFUNCTION_FRIF() SCHM_MAINFUNCTION(FrIf,FrIf_MainFunction()) */
#endif /* SCHM_FRIF_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_FrIf.h
|
C
|
unknown
| 1,229
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_FRNM_H_
#define SCHM_FRNM_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_FrNm_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_FrNm_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_FrNm_EA_0() SuspendOSInterrupts()
#define SchM_Exit_FrNm_EA_0() ResumeOSInterrupts()
#endif
#endif /* SCHM_FRNM_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_FrNm.h
|
C
|
unknown
| 1,137
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_FRSM_H_
#define SCHM_FRSM_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_FrSM_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_FrSM_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_FrSM_EA_0() SuspendOSInterrupts()
#define SchM_Exit_FrSM_EA_0() ResumeOSInterrupts()
#endif
#endif /* SCHM_FRSM_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_FrSM.h
|
C
|
unknown
| 1,135
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_FRTP_H_
#define SCHM_FRTP_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_FrTp_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_FrTp_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_FrTp_EA_0() SuspendOSInterrupts()
#define SchM_Exit_FrTp_EA_0() ResumeOSInterrupts()
#endif
#endif /* SCHM_FRTP_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_FrTp.h
|
C
|
unknown
| 1,137
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_GPT_H_
#define SCHM_GPT_H_
/* INTEGR094 sws_bsw_scheduler */
#include "Os.h"
#define SchM_Enter_Gpt_EA_0() SuspendOSInterrupts()
#define SchM_Exit_Gpt_EA_0() ResumeOSInterrupts()
#endif /* SCHM_GPT_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_Gpt.h
|
C
|
unknown
| 980
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_I2C_H_
#define SCHM_I2C_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_I2c_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_I2c_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_I2c_EA_0() SuspendOSInterrupts()
#define SchM_Exit_I2c_EA_0() ResumeOSInterrupts()
#endif
#define SCHM_MAINFUNCTION_I2C() SCHM_MAINFUNCTION(I2C,I2c_MainFunction())
#endif /* SCHM_I2C_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_I2c.h
|
C
|
unknown
| 1,238
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_PORT_H_
#define SCHM_PORT_H_
/* INTEGR094 sws_bsw_scheduler */
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_Icu_EXCLUSIVE_AREA_0 SYS_CALL_SuspendOSInterrupts
#define SchM_Exit_Icu_EXCLUSIVE_AREA_0 SYS_CALL_ResumeOSInterrupts
#else
#define SchM_Enter_Icu_EXCLUSIVE_AREA_0 SuspendAllInterrupts
#define SchM_Exit_Icu_EXCLUSIVE_AREA_0 ResumeAllInterrupts
#endif
#endif /* SCHM_PORT_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_Icu.h
|
C
|
unknown
| 1,216
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_IOHWAB_H_
#define SCHM_IOHWAB_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_IoHwAb_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_IoHwAb_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_IoHwAb_EA_0() SuspendOSInterrupts()
#define SchM_Exit_IoHwAb_EA_0() ResumeOSInterrupts()
#endif
#define SCHM_MAINFUNCTION_IOHWAB() SCHM_MAINFUNCTION(IOHWAB,IoHwAb_MainFunction())
#endif /* SCHM_IOHWAB_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_IoHwAb.h
|
C
|
unknown
| 1,259
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_IPDUM_H_
#define SCHM_IPDUM_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_IpduM_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_IpduM_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_IpduM_EA_0() SuspendOSInterrupts()
#define SchM_Exit_IpduM_EA_0() ResumeOSInterrupts()
#endif
#endif /* SCHM_IPDUM_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_IpduM.h
|
C
|
unknown
| 1,142
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_J1939TP_H_
#define SCHM_J1939TP_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_J1939Tp_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_J1939Tp_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_J1939Tp_EA_0() SuspendOSInterrupts()
#define SchM_Exit_J1939Tp_EA_0() ResumeOSInterrupts()
#endif
#define SCHM_MAINFUNCTION_J1939TP() SCHM_MAINFUNCTION(J1939TP,J1939Tp_MainFunction())
#endif /* SCHM_DEM_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_J1939Tp.h
|
C
|
unknown
| 1,251
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_LIN_H_
#define SCHM_LIN_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_Lin_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_Lin_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_Lin_EA_0() SuspendOSInterrupts()
#define SchM_Exit_Lin_EA_0() ResumeOSInterrupts()
#endif
#endif /* SCHM_LIN_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_Lin.h
|
C
|
unknown
| 1,130
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_LINCDD_H_
#define SCHM_LINCDD_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_LinCdd_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_LinCdd_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_LinCdd_EA_0() SuspendOSInterrupts()
#define SchM_Exit_LinCdd_EA_0() ResumeOSInterrupts()
#endif
#define SCHM_MAINFUNCTION_LINCDD() SCHM_MAINFUNCTION(LINCDD,LinSlv_MainFunction())
#endif /* SCHM_LINCDD_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_LinCdd.h
|
C
|
unknown
| 1,245
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_LINIF_H_
#define SCHM_LINIF_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_LinIf_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_LinIf_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_LinIf_EA_0() SuspendOSInterrupts()
#define SchM_Exit_LinIf_EA_0() ResumeOSInterrupts()
#endif
#define SCHM_MAINFUNCTION_LINIF() SCHM_MAINFUNCTION(LINIF,LinIf_MainFunction())
#endif /* SCHM_LINIF_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_LinIf.h
|
C
|
unknown
| 1,235
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_LINSM_H_
#define SCHM_LINSM_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_LinSM_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_LinSM_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_LinSM_EA_0() SuspendOSInterrupts()
#define SchM_Exit_LinSM_EA_0() ResumeOSInterrupts()
#endif
#define SCHM_MAINFUNCTION_LINSM() SCHM_MAINFUNCTION(LINSM,LinSM_MainFunction())
#endif /* SCHM_LINSM_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_LinSM.h
|
C
|
unknown
| 1,236
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_MCU_H_
#define SCHM_MCU_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_Mcu_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_Mcu_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_Mcu_EA_0() SuspendOSInterrupts()
#define SchM_Exit_Mcu_EA_0() ResumeOSInterrupts()
#endif
#endif /* SCHM_CAN_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_Mcu.h
|
C
|
unknown
| 1,149
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_NM_H_
#define SCHM_NM_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_Nm_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_Nm_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_Nm_EA_0() SuspendOSInterrupts()
#define SchM_Exit_Nm_EA_0() ResumeOSInterrupts()
#endif
#define SCHM_MAINFUNCTION_NM() SCHM_MAINFUNCTION(NM,Nm_MainFunction())
#endif /* SCHM_NM_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_Nm.h
|
C
|
unknown
| 1,219
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_NVM_H_
#define SCHM_NVM_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_NvM_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_NvM_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_NvM_EA_0() SuspendOSInterrupts()
#define SchM_Exit_NvM_EA_0() ResumeOSInterrupts()
#endif
#define SCHM_MAINFUNCTION_NVM() SCHM_MAINFUNCTION(NVM,NvM_MainFunction())
#endif /* SCHM_NVM_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_NvM.h
|
C
|
unknown
| 1,215
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_OCU_H_
#define SCHM_OCU_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_Ocu_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_Ocu_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_Ocu_EA_0() SuspendOSInterrupts()
#define SchM_Exit_Ocu_EA_0() ResumeOSInterrupts()
#endif
/*
#define SCHM_MAINFUNCTION_CAN_WRITE() SCHM_MAINFUNCTION(CAN_WRITE,Can_MainFunction_Write())
#define SCHM_MAINFUNCTION_CAN_READ() SCHM_MAINFUNCTION(CAN_READ,Can_MainFunction_Read())
#define SCHM_MAINFUNCTION_CAN_BUSOFF() SCHM_MAINFUNCTION(CAN_BUSOFF,Can_MainFunction_BusOff())
#define SCHM_MAINFUNCTION_CAN_WAKEUP() SCHM_MAINFUNCTION(CAN_WAKEUP,Can_MainFunction_Wakeup())
#define SCHM_MAINFUNCTION_CAN_ERROR() SCHM_MAINFUNCTION(CAN_ERROR,Can_Arc_MainFunction_Error())
*/
#endif /* SCHM_OCU_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_Ocu.h
|
C
|
unknown
| 1,636
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_OSEKNM_H_
#define SCHM_OSEKNM_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_OsekNm_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_OsekNm_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_OsekNm_EA_0() SuspendOSInterrupts()
#define SchM_Exit_OsekNm_EA_0() ResumeOSInterrupts()
#endif
#endif /* SCHM_OSEKNM_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_OsekNm.h
|
C
|
unknown
| 1,149
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_PDUR_H_
#define SCHM_PDUR_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_PduR_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_PduR_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_PduR_EA_0() SuspendOSInterrupts()
#define SchM_Exit_PduR_EA_0() ResumeOSInterrupts()
#endif
#endif /* SCHM_PDUR_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_PduR.h
|
C
|
unknown
| 1,145
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_PORT_H_
#define SCHM_PORT_H_
/* INTEGR094 sws_bsw_scheduler */
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_Port_EA_0() (void)SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_Port_EA_0() (void)SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_Port_EA_0() SuspendOSInterrupts()
#define SchM_Exit_Port_EA_0() ResumeOSInterrupts()
#endif
#endif /* SCHM_PORT_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_Port.h
|
C
|
unknown
| 1,182
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_PWM_H_
#define SCHM_PWM_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_Pwm_EA_0() (void)SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_Pwm_EA_0() (void)SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_Pwm_EA_0() SuspendOSInterrupts()
#define SchM_Exit_Pwm_EA_0() ResumeOSInterrupts()
#endif
#endif /* SCHM_PWM_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_Pwm.h
|
C
|
unknown
| 1,147
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_RTM_H_
#define SCHM_RTM_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_Rtm_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_Rtm_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_Rtm_EA_0() SuspendOSInterrupts()
#define SchM_Exit_Rtm_EA_0() ResumeOSInterrupts()
#endif
#define SCHM_MAINFUNCTION_RTM() SCHM_MAINFUNCTION(RTM,Rtm_MainFunction())
#endif /* SAFESCHM_WDGM_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_Rtm.h
|
C
|
unknown
| 1,234
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_SD_H_
#define SCHM_SD_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_SD_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_SD_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_SD_EA_0() SuspendOSInterrupts()
#define SchM_Exit_SD_EA_0() ResumeOSInterrupts()
#endif
#endif /* SCHM_SD_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_SD.h
|
C
|
unknown
| 1,121
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/** @reqSettings DEFAULT_SPECIFICATION_REVISION=4.3.0 */
/* @req ARC_SWS_SchM_00002 The Basic Software Scheduler shall provide APIs for other BSW modules to enter exclusive areas */
/* @req ARC_SWS_SchM_00009 The Basic Software Scheduler shall provide complementary APIs for other BSW modules to exit exclusive areas */
#ifndef SCHM_SP_H_
#define SCHM_SP_H_
#include "Std_Types.h"
#define SCHM_MODULE_ID 130u
#define SCHM_VENDOR_ID 60u
/* Implementation version */
#define SCHM_SW_MAJOR_VERSION 1u
#define SCHM_SW_MINOR_VERSION 0u
#define SCHM_SW_PATCH_VERSION 0u
/* Error IDs */
#define SCHM_E_SYNCH 1u
/* Service IDs */
#define SCHM_SID_A0 0x01
#define SCHM_SID_QM 0x02
void SchM_GetVersionInfo( Std_VersionInfoType *versionInfo ); /* @req ARC_SWS_SchM_00007 */
#ifndef SCHM_TASK_EXTENDED_CONDITION
#define SCHM_TASK_EXTENDED_CONDITION 1
#endif
typedef struct {
uint32 timer;
} SchM_InfoType;
#define SCHM_DECLARE(_mod) \
SchM_InfoType SchM_Info_ ## _mod \
/* @req ARC_SWS_SchM_00008 */
#define SCHM_MAINFUNCTION(_mod,_func) \
if( (++SchM_Info_ ## _mod.timer % SCHM_MAINFUNCTION_CYCLE_ ## _mod )== 0 ) { \
_func; \
SchM_Info_ ## _mod.timer = 0; \
}
#define SP_SCHM_MAINFUNCTION(_rv,_mod,_func) \
if( (++SchM_Info_ ## _mod.timer % SCHM_MAINFUNCTION_CYCLE_ ## _mod )== 0 ) { \
_rv = _func; \
SchM_Info_ ## _mod.timer = 0; \
}
#endif /* SCHM_SP_H_*/
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_SP.h
|
C
|
unknown
| 2,308
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_SAFEIOHWAB_H_
#define SCHM_SAFEIOHWAB_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_SafeIoHwAb_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_SafeIoHwAb_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_SafeIoHwAb_EA_0() SuspendOSInterrupts()
#define SchM_Exit_SafeIoHwAb_EA_0() ResumeOSInterrupts()
#endif
#define SCHM_MAINFUNCTION_SAFEIOHWAB() SCHM_MAINFUNCTION(SAFEIOHWAB,SafeIoHwAb_MainFunction())
#endif /* SCHM_IOHWAB_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_SafeIoHwAb.h
|
C
|
unknown
| 1,295
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_SOAD_H_
#define SCHM_SOAD_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_SoAd_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_SoAd_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_SoAd_EA_0() SuspendOSInterrupts()
#define SchM_Exit_SoAd_EA_0() ResumeOSInterrupts()
#endif
#endif /* SCHM_SOAD_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_SoAd.h
|
C
|
unknown
| 1,135
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_SPI_H_
#define SCHM_SPI_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_Spi_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_Spi_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_Spi_EA_0() SuspendOSInterrupts()
#define SchM_Exit_Spi_EA_0() ResumeOSInterrupts()
#endif
/* IMPROVEMENT */
#define SCHM_MAINFUNCTION_SPI() SCHM_MAINFUNCTION(SPI,Spi_MainFunction_Handling())
#endif /* SCHM_NVM_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_Spi.h
|
C
|
unknown
| 1,246
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_STBM_H_
#define SCHM_STBM_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_StbM_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_StbM_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_StbM_EA_0() SuspendOSInterrupts()
#define SchM_Exit_StbM_EA_0() ResumeOSInterrupts()
#endif
#define SCHM_MAINFUNCTION_STBM() SCHM_MAINFUNCTION(STBM,StbM_MainFunction())
#endif /* SCHM_STBM_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_StbM.h
|
C
|
unknown
| 1,216
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_TCPIP_H_
#define SCHM_TCPIP_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_TcpIp_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_TcpIp_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_TcpIp_EA_0() SuspendOSInterrupts()
#define SchM_Exit_TcpIp_EA_0() ResumeOSInterrupts()
#endif
#endif /* SCHM_TCPIP_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_TcpIp.h
|
C
|
unknown
| 1,142
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_UDPNM_H_
#define SCHM_UDPNM_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_UdpNm_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_UdpNm_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_UdpNm_EA_0() SuspendOSInterrupts()
#define SchM_Exit_UdpNm_EA_0() ResumeOSInterrupts()
#endif
//#define SCHM_MAINFUNCTION_UDPNM() SCHM_MAINFUNCTION(UDPNM,UdpNm_MainFunction())
#endif /* SCHM_UDPNM_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_UdpNm.h
|
C
|
unknown
| 1,239
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_WDG_H_
#define SCHM_WDG_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_Wdg_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_Wdg_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_Wdg_EA_0() SuspendOSInterrupts()
#define SchM_Exit_Wdg_EA_0() ResumeOSInterrupts()
#endif
#endif /* SCHM_WDG_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_Wdg.h
|
C
|
unknown
| 1,128
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_WDGM_H_
#define SCHM_WDGM_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_WdgM_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_WdgM_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_WdgM_EA_0() SuspendOSInterrupts()
#define SchM_Exit_WdgM_EA_0() ResumeOSInterrupts()
#endif
#define SCHM_MAINFUNCTION_WDGM() SCHM_MAINFUNCTION(WDGM,WdgM_MainFunction())
#endif /* SCHM_WDGM_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_WdgM.h
|
C
|
unknown
| 1,239
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef SCHM_XCP_H_
#define SCHM_XCP_H_
#include "Os.h"
#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)
#define SchM_Enter_Xcp_EA_0() SYS_CALL_SuspendOSInterrupts()
#define SchM_Exit_Xcp_EA_0() SYS_CALL_ResumeOSInterrupts()
#else
#define SchM_Enter_Xcp_EA_0() SuspendOSInterrupts()
#define SchM_Exit_Xcp_EA_0() ResumeOSInterrupts()
#endif
#define SCHM_MAINFUNCTION_XCP() SCHM_MAINFUNCTION(XCP,Xcp_MainFunction())
#endif /* SCHM_XCP_H_ */
|
2301_81045437/classic-platform
|
system/SchM/inc/SchM_Xcp.h
|
C
|
unknown
| 1,245
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/** @reqSettings DEFAULT_SPECIFICATION_REVISION=4.3.0 */
/** @fileSafetyClassification QM **/ /* File is not used for safety platform. */
/* ----------------------------[information]----------------------------------*/
/*
*
* Description:
* Implements the SchM module
*
* Support:
* General Have Support
* -------------------------------------------
* SCHM_DEV_ERROR_DETECT N
* SCHM_VERSION_INFO_API N
*
* General Have Support
* -------------------------------------------
* SCHM_POSITION_IN_TASK N
* SCHM_MAINFUNCTION_REF N
* SCHM_MAPPED_TO_TASK N
* .....
*
* Implementation Notes:
* There are a lot of examples in SchM about scheduling and it
* all seems very complicated. What is boils down to is that
* the BSW MainFunctions have different requirements. Most modules
* have only periodic needs for timeouts and other things. But there
* are also module that needs extra iterations at certain points in time, to
* be really efficient.
*
*
* BSW Module Code:
* SchM_Enter_NvM(EXCLUSIVE_AREA_0);
* ..Do stuff...
* SchM_Enter_NvM(EXCLUSIVE_AREA_0);
*
* but today we have Irq_Save(state), Irq_Restore(state).
* ArcCore Irq_Save/Irq_Restore is almost the same as SuspendAllInterrupts/ResumeAllInterrupts,
* since they can both be nested and saves state. But the OSEK (Susp../Resume..) can't do it locally, it
* assumes some kind of local FIFO, that is bad.
*
*
* BSW Modules with generated mainfunction period times. Checked Only 3.1.5
*
* Specification Studio Core=Generator
* --------------------------------------------------------------------------------------
* Adc N/A *1
* Can CanMainFunctionReadPerdiod No No
* CanMainFunctionWritePerdiod
* ..
* CanIf Have No mainf N/A
* CanNm CanNmMainFunctionPeriod Yes Accessible in struct.. not as define
* CanSm Have mainf. but no period Yes*2 Nothing is generated
* CanTp CanTpMainFunctionPeriod Yes CANTP_MAIN_FUNCTION_PERIOD_TIME_MS
* CanTrcv Have mainf. but no period N/A
* Com Have mainf. but no period No*3
* ComM ComMMainFunctionPeriod Yes Accessible in struct.. not as define
* Dcm Have MainF. DcmTaskTime Yes DCM_MAIN_FUNCTION_PERIOD_TIME_MS
* Dem Have MainF. DemTaskTime No
* EcuM Have MainF.EcuMMainFunctionPeriod Yes ECUM_MAIN_FUNCTION_PERIOD
* Ea Have MainF. ON_PRE_CONDITION (ie not cyclic)
* Eep Have MainF. VARIABLE_CYCLIC
* Fee Have MainF. ON_PRE_CONDITION
* Fls Have MainF. FIXED_CYCLIC
* IoHwAb Have no mainfunction
* ..
* Nm Have MainF. FIXED_CYCLIC , No
* NmCycletimeMainFunction
* NvM Have MainF. VARIABLE_CYCLIC No
* PduR Have no MainF.
* Spi Have MainF. FIXED_CYCLIC, no period
* WdgM Have MainF. WdgMTriggerCycle *4
*
* *1 No MainFunction
* *2 What is it used for?
* *3 Com have lots of timing... it's related to what? (reads timer?)
* *4 Probably not.
*
* ----->>>>
*
* Conclusion:
* * Support in generator is extremely limited.
* * Support in specification is limited
* * Support in studio is limited
*
* Write scheduling information directly in the SchM_<mod>.h files.
* OR
* Write scheduling information in SchM_cfg.h....better (keeps information in one place)
*
* #if defined(USE_SCHM)
* ASSERT( SCHM_TIMER(x) == <period> )
* #endif
*
* It seems it's mandatory to include SchM_<mod>.h for each BSW module.
* So,
* - <mod>.c ALWAYS include SchM_<mod.h>
* - SchM.c have condidional include on SchM_<mod>.h, e.g must define it's MainFunctions.
*
*
*
*/
/* @req SWS_BSW_00005 */
#include "SchM.h"
#include "SchM_cfg.h"
#if defined(USE_KERNEL)
#include "Os.h"
#endif
#if defined(USE_MCU)
#include "Mcu.h"
#endif
#if defined(USE_GPT)
#include "Gpt.h"
#endif
#if defined(USE_CAN)
#include "Can.h"
#include "SchM_Can.h"
#else
#define SCHM_MAINFUNCTION_CAN_WRITE()
#define SCHM_MAINFUNCTION_CAN_READ()
#define SCHM_MAINFUNCTION_CAN_BUSOFF()
#define SCHM_MAINFUNCTION_CAN_ERROR()
#define SCHM_MAINFUNCTION_CAN_WAKEUP()
#define SCHM_MAINFUNCTION_CAN_MODE()
#endif
#if defined(USE_CANIF)
#include "CanIf.h"
#include "SchM_CanIf.h"
#endif
#if defined(USE_XCP)
#include "Xcp.h"
#include "SchM_Xcp.h"
#else
#define SCHM_MAINFUNCTION_XCP()
#endif
#if defined(USE_PDUR)
#include "PduR.h"
#include "SchM_PduR.h"
#endif
#if defined(USE_COM)
#include "Com.h"
#include "SchM_Com.h"
#else
#define SCHM_MAINFUNCTION_COMRX()
#define SCHM_MAINFUNCTION_COMTX()
#endif
#if defined(USE_CANTP)
#include "CanTp.h"
#include "SchM_CanTp.h"
#else
#define SCHM_MAINFUNCTION_CANTP()
#endif
#if defined(USE_BSWM)
#include "BswM.h"
#include "SchM_BswM.h"
#else
#define SCHM_MAINFUNCTION_BSWM()
#endif
#if defined(USE_FRTP)
#include "FrTp.h"
#include "SchM_FrTp.h"
#else
#define SCHM_MAINFUNCTION_FRTP()
#endif
#if defined(USE_J1939TP)
#include "J1939Tp.h"
#include "SchM_J1939Tp.h"
#else
#define SCHM_MAINFUNCTION_J1939TP()
#endif
#if defined(USE_DCM)
#include "Dcm.h"
#include "SchM_Dcm.h"
#else
#define SCHM_MAINFUNCTION_DCM()
#endif
#if defined(USE_DEM)
#include "Dem.h"
#include "SchM_Dem.h"
#else
#define SCHM_MAINFUNCTION_DEM()
#endif
#if defined(USE_PWM)
#include "Pwm.h"
#include "SchM_Pwm.h"
#endif
#if defined(USE_IOHWAB)
#include "IoHwAb.h"
#include "SchM_IoHwAb.h"
#else
#define SCHM_MAINFUNCTION_IOHWAB()
#endif
#if defined(USE_FLS)
#include "Fls.h"
#include "SchM_Fls.h"
#else
#define SCHM_MAINFUNCTION_FLS()
#endif
#if defined(USE_ECUM_FIXED) || defined(USE_ECUM_FLEXIBLE)
#include "EcuM.h"
#include "SchM_EcuM.h"
#else
#define SCHM_MAINFUNCTION_ECUM()
#endif
#if defined(USE_EEP)
#include "Eep.h"
#include "SchM_Eep.h"
#else
#define SCHM_MAINFUNCTION_EEP()
#endif
#if defined(USE_FEE)
#include "Fee.h"
#include "SchM_Fee.h"
#else
#define SCHM_MAINFUNCTION_FEE()
#endif
#if defined(USE_EA)
#include "Ea.h"
#include "SchM_Ea.h"
#else
#define SCHM_MAINFUNCTION_EA()
#endif
#if defined(USE_NVM)
#include "NvM.h"
#include "SchM_NvM.h"
#else
#define SCHM_MAINFUNCTION_NVM()
#endif
#if defined(USE_COMM)
#include "ComM.h"
#include "SchM_ComM.h"
#else
#define SCHM_MAINFUNCTION_COMM()
#endif
#if defined(USE_NM)
#include "Nm.h"
#include "SchM_Nm.h"
#else
#define SCHM_MAINFUNCTION_NM()
#endif
#if defined(USE_CANNM)
#include "CanNm.h"
#include "SchM_CanNm.h"
#else
#define SCHM_MAINFUNCTION_CANNM()
#endif
#if defined(USE_CANSM)
#include "CanSM.h"
#include "SchM_CanSM.h"
#else
#define SCHM_MAINFUNCTION_CANSM()
#endif
#if defined(USE_UDPNM)
#include "UdpNm.h"
#endif
#if defined(USE_LINIF)
#include "LinIf.h"
#else
#define SCHM_MAINFUNCTION_LINIF()
#endif
#if defined(USE_LINSM)
#include "LinSM.h"
#else
#define SCHM_MAINFUNCTION_LINSM()
#endif
#if defined(USE_SPI)
#include "Spi.h"
#include "SchM_Spi.h"
#else
#define SCHM_MAINFUNCTION_SPI()
#endif
#if defined(USE_WDG)
#include "Wdg.h"
#endif
#if defined(USE_WDGM)
#include "WdgM.h"
#include "SchM_WdgM.h"
#else
#define SCHM_MAINFUNCTION_WDMG()
#endif
#if defined(USE_FIM)
#include "FiM.h"
#include "SchM_FiM.h"
#else
#define SCHM_MAINFUNCTION_FIM()
#endif
#if (CAN_USE_WRITE_POLLING == STD_ON)
SCHM_DECLARE(CAN_WRITE);
#endif
#if (CAN_USE_READ_POLLING == STD_ON)
SCHM_DECLARE(CAN_READ);
#endif
#if (CAN_USE_BUSOFF_POLLING == STD_ON)
SCHM_DECLARE(CAN_BUSOFF);
#endif
#if (CAN_USE_WAKEUP_POLLING == STD_ON)
SCHM_DECLARE(CAN_WAKEUP);
#endif
#if (ARC_CAN_ERROR_POLLING == STD_ON)
SCHM_DECLARE(CAN_ERROR);
#endif
SCHM_DECLARE(CAN_MODE);
SCHM_DECLARE(XCP);
SCHM_DECLARE(LINIF);
SCHM_DECLARE(COMRX);
SCHM_DECLARE(COMTX);
SCHM_DECLARE(CANTP);
SCHM_DECLARE(BSWM);
SCHM_DECLARE(CANNM);
SCHM_DECLARE(DCM);
SCHM_DECLARE(DEM);
SCHM_DECLARE(FIM);
SCHM_DECLARE(IOHWAB);
SCHM_DECLARE(COMM);
SCHM_DECLARE(NM);
SCHM_DECLARE(CANSM);
SCHM_DECLARE(LINSM);
SCHM_DECLARE(ECUM);
SCHM_DECLARE(NVM);
SCHM_DECLARE(FEE);
SCHM_DECLARE(EEP);
SCHM_DECLARE(EA);
SCHM_DECLARE(FLS);
SCHM_DECLARE(J1939TP);
/* @req SWS_BSW_00071 The state of a BSW Module shall be set accordingly at the end of Initialization function. */
void SchM_Init( void ) {
}
/* @req SWS_BSW_00072 The state of a BSW Module shall be set accordingly at the beginning of the De-Initialization function */
void SchM_Deinit( void ) {
}
/* @req SWS_BSW_00064 GetVersionInfo shall execute synchronously */
/* @req SWS_BSW_00052 GetVersion info shall only have one parameter */
/* @req SWS_BSW_00164 No restriction on calling context */
/* @req SWS_BSW_00236 Configuration parameters to get Version Info */
/* @req SWS_BSW_00051 */
#if ( SCHM_VERSION_INFO_API == STD_ON )
void SchM_GetVersionInfo( Std_VersionInfoType *versionInfo ) {
if(versionInfo != NULL_PTR) {
versionInfo->vendorID = SCHM_VENDOR_ID;
versionInfo->moduleID = SCHM_MODULE_ID;
versionInfo->sw_major_version = SCHM_SW_MAJOR_VERSION;
versionInfo->sw_minor_version = SCHM_SW_MINOR_VERSION;
versionInfo->sw_patch_version = SCHM_SW_PATCH_VERSION;
}
}
#endif
static void runMemory( void ) {
SCHM_MAINFUNCTION_NVM();
SCHM_MAINFUNCTION_EA();
SCHM_MAINFUNCTION_FEE();
SCHM_MAINFUNCTION_EEP();
SCHM_MAINFUNCTION_FLS();
SCHM_MAINFUNCTION_SPI();
}
/**
* Startup task.
*/
TASK(SchM_Startup){
/* At this point EcuM == ECUM_STATE_STARTUP_ONE */
/* Set events on TASK_ID_BswService_Mem */
SetRelAlarm(ALARM_ID_Alarm_BswService, 10, 2);
/*
* Call EcuM_StartupTwo that do:
* - Startup RTE,
* - Wait for Nvm to complete
* - Call EcuM_AL_DriverInitThree() to initiate Nvm dependent modules.
*/
EcuM_StartupTwo();
/* Start to schedule BSW parts */
CancelAlarm(ALARM_ID_Alarm_BswService);
SetRelAlarm(ALARM_ID_Alarm_BswService, 10, 5);
#if !defined(CFG_SCHM_DISABLE_ECUM_REQUEST_RUN)
EcuM_RequestRUN(ECUM_USER_User_1);
#endif
TerminateTask();
}
TASK(SchM_BswService) {
EcuM_StateType state;
EcuM_GetState(&state);
switch( state ) {
case ECUM_STATE_STARTUP_ONE:
/* Nothing to schedule */
break;
case ECUM_STATE_STARTUP_TWO:
runMemory();
break;
default:
runMemory();
SCHM_MAINFUNCTION_BSWM();
SCHM_MAINFUNCTION_ECUM();
SCHM_MAINFUNCTION_CAN_MODE();
#if (CAN_USE_WRITE_POLLING == STD_ON)
SCHM_MAINFUNCTION_CAN_WRITE();
#endif
#if (CAN_USE_READ_POLLING == STD_ON)
SCHM_MAINFUNCTION_CAN_READ();
#endif
#if (CAN_USE_BUSOFF_POLLING == STD_ON)
SCHM_MAINFUNCTION_CAN_BUSOFF();
#endif
#if (ARC_CAN_ERROR_POLLING == STD_ON)
extern void Can_Arc_MainFunction_Error(void);
SCHM_MAINFUNCTION_CAN_ERROR();
#endif
#if (CAN_USE_WAKEUP_POLLING == STD_ON)
SCHM_MAINFUNCTION_CAN_WAKEUP();
#endif
SCHM_MAINFUNCTION_COMRX();
SCHM_MAINFUNCTION_COMTX();
SCHM_MAINFUNCTION_XCP();
SCHM_MAINFUNCTION_CANTP();
SCHM_MAINFUNCTION_J1939TP();
SCHM_MAINFUNCTION_DCM();
SCHM_MAINFUNCTION_DEM();
SCHM_MAINFUNCTION_FIM();
SCHM_MAINFUNCTION_IOHWAB();
SCHM_MAINFUNCTION_COMM();
SCHM_MAINFUNCTION_NM();
SCHM_MAINFUNCTION_CANNM();
SCHM_MAINFUNCTION_CANSM();
SCHM_MAINFUNCTION_LINIF();
SCHM_MAINFUNCTION_LINSM();
break;
}
TerminateTask();
}
void SchM_MainFunction( void ) {
}
|
2301_81045437/classic-platform
|
system/SchM/src/SchM.c
|
C
|
unknown
| 12,788
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/** @reqSettings DEFAULT_SPECIFICATION_REVISION=4.3.0 */
/*lint -save -e451 MISRA:STANDARDIZED_INTERFACE:AUTOSAR need Inclusion:[MISRA 2012 Directive 4.10, required]*/
/*lint -save -e9021 MISRA:STANDARDIZED_INTERFACE:AUTOSAR need Inclusion:[MISRA 2012 Rule 20.5, advisory] */
#ifdef SCHM_START_SEC_VAR_CLEARED_ASIL_UNSPECIFIED
#include "MemMap.h"
#undef SCHM_MEMMAP_ERROR
#undef SCHM_START_SEC_VAR_CLEARED_ASIL_UNSPECIFIED
#endif
#ifdef SCHM_STOP_SEC_VAR_CLEARED_ASIL_UNSPECIFIED
#include "MemMap.h"
#undef SCHM_MEMMAP_ERROR
#undef SCHM_STOP_SEC_VAR_CLEARED_ASIL_UNSPECIFIED
#endif
#ifdef SCHM_START_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "MemMap.h"
#undef SCHM_MEMMAP_ERROR
#undef SCHM_START_SEC_VAR_CLEARED_QM_UNSPECIFIED
#endif
#ifdef SCHM_STOP_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "MemMap.h"
#undef SCHM_MEMMAP_ERROR
#undef SCHM_STOP_SEC_VAR_CLEARED_QM_UNSPECIFIED
#endif
/*lint -restore */
|
2301_81045437/classic-platform
|
system/SchM/src/SchM_MemMap.h
|
C
|
unknown
| 1,684
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/** @reqSettings DEFAULT_SPECIFICATION_REVISION=4.3.0 */
/** @fileSafetyClassification ASIL **/ /* SchM_Partition_A0 contains SchM task for SP A0 partition */
#include "SchM_SP.h"
#include "SchM_cfg.h"
#if defined(HOST_TEST)
#include "schm_devtest_stubs.h"
#endif
#if defined(USE_KERNEL)
#include "Os.h"
#endif
#if defined(USE_ECUM_FIXED)
#include "EcuM.h"
#include "SchM_EcuM.h"
/* @req SWS_BSW_00006 include the BSW Memory mapping header */
/*lint -e451 MISRA:STANDARDIZED_INTERFACE:AUTOSAR need Inclusion:[MISRA 2012 Directive 4.10, required] */
/*lint -e9019 MISRA:STANDARDIZED_INTERFACE:AUTOSAR need Inclusion:[MISRA 2012 Rule 20.1, advisory]*/
#define SCHM_START_SEC_VAR_CLEARED_ASIL_UNSPECIFIED
#include "SchM_MemMap.h"
SCHM_DECLARE(ECUM_A0);
#define SCHM_STOP_SEC_VAR_CLEARED_ASIL_UNSPECIFIED
#include "SchM_MemMap.h"
#else
#define SCHM_MAINFUNCTION_ECUM_A0()
#endif
#if defined(USE_RTM)
#include "Rtm.h"
#include "SchM_Rtm.h"
#define SCHM_START_SEC_VAR_CLEARED_ASIL_UNSPECIFIED
#include "SchM_MemMap.h"
SCHM_DECLARE(RTM);
#define SCHM_STOP_SEC_VAR_CLEARED_ASIL_UNSPECIFIED
#include "SchM_MemMap.h"
#else
#define SCHM_MAINFUNCTION_RTM()
#endif
#if defined(USE_WDGM)
#include "WdgM.h"
#include "SchM_WdgM.h"
#define SCHM_START_SEC_VAR_CLEARED_ASIL_UNSPECIFIED
#include "SchM_MemMap.h"
SCHM_DECLARE(WDGM);
#define SCHM_STOP_SEC_VAR_CLEARED_ASIL_UNSPECIFIED
#include "SchM_MemMap.h"
#else
#define SCHM_MAINFUNCTION_WDGM()
#endif
#if defined(USE_SAFEIOHWAB)
#include "SafeIoHwAb.h"
#include "SchM_SafeIoHwAb.h"
#define SCHM_START_SEC_VAR_CLEARED_ASIL_UNSPECIFIED
#include "SchM_MemMap.h"
SCHM_DECLARE(SAFEIOHWAB);
#define SCHM_STOP_SEC_VAR_CLEARED_ASIL_UNSPECIFIED
#include "SchM_MemMap.h"
#else
#define SCHM_MAINFUNCTION_SAFEIOHWAB()
#endif
#define SCHM_START_SEC_VAR_CLEARED_ASIL_UNSPECIFIED
#include "SchM_MemMap.h"
uint32 SchMCounter;
#define SCHM_STOP_SEC_VAR_CLEARED_ASIL_UNSPECIFIED
#include "SchM_MemMap.h"
/* GetVersionInfo for Safety platform SchM (common for all partitions) */
void SchM_GetVersionInfo( Std_VersionInfoType *versionInfo ) {
if(versionInfo != NULL_PTR) {
versionInfo->vendorID = SCHM_VENDOR_ID;
versionInfo->moduleID = SCHM_MODULE_ID;
versionInfo->sw_major_version = SCHM_SW_MAJOR_VERSION;
versionInfo->sw_minor_version = SCHM_SW_MINOR_VERSION;
versionInfo->sw_patch_version = SCHM_SW_PATCH_VERSION;
}
}
/* @req ARC_SWS_SchM_00003 */
/* @req ARC_SWS_SchM_00011 The service EcuM mainfunctions shall not be called from tasks which may invoke runnable entities. */
TASK(SchM_Partition_A0) {
EcuM_StateType state;
EventMaskType Event = (EventMaskType) 255u;
EcuM_SP_RetStatus retStatus = ECUM_SP_OK;
do {
/*lint -e534 MISRA:HARDWARE_ACCESS::[MISRA 2012 Rule 17.7, required] */
SYS_CALL_WaitEvent((EVENT_MASK_Alarm_BswServices_Partition_A0 | EVENT_MASK_DetReportError_QM | EVENT_MASK_SynchPartition_A0));
SYS_CALL_GetEvent(TASK_ID_SchM_Partition_A0, &Event); /*lint !e923 MISRA:FALSE_POSITIVE:SYS_CALL:[MISRA 2012 Rule 11.1, required]*/
SchMCounter++;
/* @req ARC_SWS_SchM_00005 */
if ((Event & EVENT_MASK_DetReportError_QM) != 0) {
SYS_CALL_ClearEvent(EVENT_MASK_DetReportError_QM);
SCHM_MAINFUNCTION_RTM();
} else { /* do nothing */ }
/* Synchronize with the QM partition */ /* @req ARC_SWS_SchM_00004 */
if ((Event & EVENT_MASK_SynchPartition_A0) != 0) {
/* If we enter here it mean QM partition is done */
SYS_CALL_ClearEvent(EVENT_MASK_SynchPartition_A0);
/*lint -restore */
/* Therefore, we can tell EcuM, SchM is ready for next state */
EcuM_SP_Sync_UpdateStatus(ECUM_SP_PARTITION_FUN_COMPLETED_QM);
} else {
/* do nothing */
}
/* Periodic task trigger from OS Alarm */
if ((Event & EVENT_MASK_Alarm_BswServices_Partition_A0 ) != 0) {
SYS_CALL_ClearEvent(EVENT_MASK_Alarm_BswServices_Partition_A0);
(void) EcuM_GetState(&state);
/* ARC_SWS_SchM_00006 The BSW scheduler shall schedule BSW modules by calling their MainFunctions */
switch (state) {
case ECUM_STATE_STARTUP_ONE:
case ECUM_STATE_STARTUP_TWO:
SCHM_MAINFUNCTION_ECUM_ASIL(state, retStatus);
break;
default:
SCHM_MAINFUNCTION_ECUM_ASIL(state, retStatus);
if (retStatus == ECUM_SP_PARTITION_ERR) {
#if defined(USE_RTM)
Rtm_EntryType err;
err.errorType = RTM_ERRORTYPE_BSW;
err.error.bsw.moduleId = SCHM_MODULE_ID;
err.error.bsw.errorId = SCHM_E_SYNCH;
Rtm_ReportFailure(&err);
#endif
}
else {
/* Do nothing (Can be used for >2 partitions) */
}
SCHM_MAINFUNCTION_SAFEIOHWAB();
SCHM_MAINFUNCTION_RTM();
SCHM_MAINFUNCTION_WDGM();
break;
}
}
else {
/* do nothing */
}
} while (SCHM_TASK_EXTENDED_CONDITION != 0); /*lint !e506 MISRA:STANDARDIZED_INTERFACE:Extended Task shall never terminate:[MISRA 2012 Rule 2.1, required] */
}
|
2301_81045437/classic-platform
|
system/SchM/src/SchM_partition_A0.c
|
C
|
unknown
| 6,358
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/** @reqSettings DEFAULT_SPECIFICATION_REVISION=4.3.0 */
/** @fileSafetyClassification QM **/ /* SchM_Partition_QM contains SchM task for SP QM partition. */
#include "SchM_SP.h"
#include "SchM_cfg.h"
#if defined(HOST_TEST)
#include "schm_devtest_stubs.h"
#endif
/*lint -save -e451 MISRA:STANDARDIZED_INTERFACE:AUTOSAR need Inclusion:[MISRA 2012 Directive 4.10, required]*/
/*lint -save -e553 MISRA:STANDARDIZED_INTERFACE:AUTOSAR need Inclusion: [MISRA 2012 Rule 20.9, required]*/
/*lint -save -e9019 MISRA:STANDARDIZED_INTERFACE:AUTOSAR need Inclusion:[MISRA 2012 Rule 20.1, advisory] */
#if defined(USE_KERNEL)
#include "Os.h"
#endif
#if defined(USE_MCU)
#include "Mcu.h"
#endif
#if defined(USE_GPT)
#include "Gpt.h"
#endif
#if defined(USE_CAN)
#include "Can.h"
#include "SchM_Can.h"
/*lint -restore */
#define SCHM_START_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
SCHM_DECLARE(CAN_MODE);
#define SCHM_STOP_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
#else
#define SCHM_MAINFUNCTION_CAN_WRITE()
#define SCHM_MAINFUNCTION_CAN_READ()
#define SCHM_MAINFUNCTION_CAN_BUSOFF()
#define SCHM_MAINFUNCTION_CAN_ERROR()
#define SCHM_MAINFUNCTION_CAN_WAKEUP()
#define SCHM_MAINFUNCTION_CAN_MODE()
#endif
#if defined(USE_CANIF)
#include "CanIf.h"
#include "SchM_CanIf.h"
#endif
#if defined(USE_XCP)
#include "Xcp.h"
#include "SchM_Xcp.h"
#define SCHM_START_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
SCHM_DECLARE(XCP);
#define SCHM_STOP_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
#else
#define SCHM_MAINFUNCTION_XCP()
#endif
#if defined(USE_PDUR)
#include "PduR.h"
#include "SchM_PduR.h"
#endif
#if defined(USE_COM)
#include "Com.h"
#include "SchM_Com.h"
#define SCHM_START_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
SCHM_DECLARE(COMRX);
#define SCHM_STOP_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
#define SCHM_START_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
SCHM_DECLARE(COMTX);
#define SCHM_STOP_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
#else
#define SCHM_MAINFUNCTION_COMRX()
#define SCHM_MAINFUNCTION_COMTX()
#endif
#if defined(USE_CANTP)
#include "CanTp.h"
#include "SchM_CanTp.h"
#define SCHM_START_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
SCHM_DECLARE(CANTP);
#define SCHM_STOP_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
#else
#define SCHM_MAINFUNCTION_CANTP()
#endif
#if defined(USE_BSWM)
#include "BswM.h"
#include "SchM_BswM.h"
#define SCHM_START_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
SCHM_DECLARE(BSWM);
#define SCHM_STOP_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
#else
#define SCHM_MAINFUNCTION_BSWM()
#endif
#if defined(USE_FRTP)
#include "FrTp.h"
#include "SchM_FrTp.h"
#else
#define SCHM_MAINFUNCTION_FRTP()
#endif
#if defined(USE_J1939TP)
#include "J1939Tp.h"
#include "SchM_J1939Tp.h"
#define SCHM_START_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
SCHM_DECLARE(J1939TP);
#define SCHM_STOP_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
#else
#define SCHM_MAINFUNCTION_J1939TP()
#endif
#if defined(USE_DCM)
#include "Dcm.h"
#include "SchM_Dcm.h"
#define SCHM_START_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
SCHM_DECLARE(DCM);
#define SCHM_STOP_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
#else
#define SCHM_MAINFUNCTION_DCM()
#endif
#if defined(USE_DEM)
#include "Dem.h"
#include "SchM_Dem.h"
#define SCHM_START_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
SCHM_DECLARE(DEM);
#define SCHM_STOP_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
#else
#define SCHM_MAINFUNCTION_DEM()
#endif
#if defined(USE_PWM)
#include "Pwm.h"
#include "SchM_Pwm.h"
#endif
#if defined(USE_IOHWAB)
#include "IoHwAb.h"
#include "SchM_IoHwAb.h"
#define SCHM_START_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
SCHM_DECLARE(IOHWAB);
#define SCHM_STOP_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
#else
#define SCHM_MAINFUNCTION_IOHWAB()
#endif
#if defined(USE_FLS)
#include "Fls.h"
#include "SchM_Fls.h"
#define SCHM_START_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
SCHM_DECLARE(FLS);
#define SCHM_STOP_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
#else
#define SCHM_MAINFUNCTION_FLS()
#endif
#if defined(USE_ECUM_FIXED)
#include "EcuM.h"
#include "SchM_EcuM.h"
#define SCHM_START_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
SCHM_DECLARE(ECUM_QM);
#define SCHM_STOP_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
#else
#define SCHM_MAINFUNCTION_ECUM_QM()
#endif
#if defined(USE_EEP)
#include "Eep.h"
#include "SchM_Eep.h"
#define SCHM_START_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
SCHM_DECLARE(EEP);
#define SCHM_STOP_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
#else
#define SCHM_MAINFUNCTION_EEP()
#endif
#if defined(USE_FEE)
#include "Fee.h"
#include "SchM_Fee.h"
#define SCHM_START_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
SCHM_DECLARE(FEE);
#define SCHM_STOP_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
#else
#define SCHM_MAINFUNCTION_FEE()
#endif
#if defined(USE_EA)
#include "Ea.h"
#include "SchM_Ea.h"
#define SCHM_START_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
SCHM_DECLARE(EA);
#define SCHM_STOP_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
#else
#define SCHM_MAINFUNCTION_EA()
#endif
#if defined(USE_NVM)
#include "NvM.h"
#include "SchM_NvM.h"
#define SCHM_START_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
SCHM_DECLARE(NVM);
#define SCHM_STOP_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
#else
#define SCHM_MAINFUNCTION_NVM()
#endif
#if defined(USE_COMM)
#include "ComM.h"
#include "SchM_ComM.h"
#define SCHM_START_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
SCHM_DECLARE(COMM);
#define SCHM_STOP_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
#else
#define SCHM_MAINFUNCTION_COMM()
#endif
#if defined(USE_NM)
#include "Nm.h"
#include "SchM_Nm.h"
#define SCHM_START_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
SCHM_DECLARE(NM);
#define SCHM_STOP_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
#else
#define SCHM_MAINFUNCTION_NM()
#endif
#if defined(USE_CANNM)
#include "CanNm.h"
#include "SchM_CanNm.h"
#define SCHM_START_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
SCHM_DECLARE(CANNM);
#define SCHM_STOP_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
#else
#define SCHM_MAINFUNCTION_CANNM()
#endif
#if defined(USE_CANSM)
#include "CanSM.h"
#include "SchM_CanSM.h"
#define SCHM_START_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
SCHM_DECLARE(CANSM);
#define SCHM_STOP_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
#else
#define SCHM_MAINFUNCTION_CANSM()
#endif
#if defined(USE_CANTRCV)
#include "CanTrcv.h"
#include "SchM_CanTrcv.h"
#define SCHM_START_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
SCHM_DECLARE(CANTRCV);
#define SCHM_STOP_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
#else
#define SCHM_MAINFUNCTION_CANTRCV()
#endif
#if defined(USE_UDPNM)
#include "UdpNm.h"
#endif
#if defined(USE_LINIF)
#include "LinIf.h"
#include "SchM_LinIf.h"
#define SCHM_START_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
SCHM_DECLARE(LINIF);
#define SCHM_STOP_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
#else
#define SCHM_MAINFUNCTION_LINIF()
#endif
#if defined(USE_LINSM)
#include "LinSM.h"
#include "SchM_LinSM.h"
#define SCHM_START_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
SCHM_DECLARE(LINSM);
#define SCHM_STOP_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
#else
#define SCHM_MAINFUNCTION_LINSM()
#endif
#if defined(USE_CDD_LINSLV)
#include "CDD_LinSlv.h"
#include "SchM_LinCdd.h"
#define SCHM_START_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
SCHM_DECLARE(LINCDD);
#define SCHM_STOP_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
#else
#define SCHM_MAINFUNCTION_LINCDD()
#endif
#if defined(USE_SPI) && !defined(CFG_SPI_ASIL)
#include "Spi.h"
#include "SchM_Spi.h"
#define SCHM_START_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
SCHM_DECLARE(SPI);
#define SCHM_STOP_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
#else
#define SCHM_MAINFUNCTION_SPI()
#endif
#if defined(USE_WDG)
#include "Wdg.h"
#endif
#if (CAN_USE_WRITE_POLLING == STD_ON)
#define SCHM_START_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
SCHM_DECLARE(CAN_WRITE);
#define SCHM_STOP_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
#endif
#if (CAN_USE_READ_POLLING == STD_ON)
#define SCHM_START_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
SCHM_DECLARE(CAN_READ);
#define SCHM_STOP_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
#endif
#if (CAN_USE_BUSOFF_POLLING == STD_ON)
#define SCHM_START_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
SCHM_DECLARE(CAN_BUSOFF);
#define SCHM_STOP_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
#endif
#if (CAN_USE_WAKEUP_POLLING == STD_ON)
#define SCHM_START_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
SCHM_DECLARE(CAN_WAKEUP);
#define SCHM_STOP_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
#endif
#if (ARC_CAN_ERROR_POLLING == STD_ON)
#define SCHM_START_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
SCHM_DECLARE(CAN_ERROR);
#define SCHM_STOP_SEC_VAR_CLEARED_QM_UNSPECIFIED
#include "SchM_MemMap.h"
#endif
#if defined(USE_FIM)
#include "FiM.h"
#include "SchM_FiM.h"
#else
#define SCHM_MAINFUNCTION_FIM()
#endif
/*lint -restore */
static void runMemory( void ) {
SCHM_MAINFUNCTION_NVM();
SCHM_MAINFUNCTION_EA();
SCHM_MAINFUNCTION_FEE();
SCHM_MAINFUNCTION_EEP();
SCHM_MAINFUNCTION_FLS();
SCHM_MAINFUNCTION_SPI();
}
/* @req ARC_SWS_SchM_00003 */
/* @req ARC_SWS_SchM_00011 The service EcuM mainfunctions shall not be called from tasks which may invoke runnable entities. */
TASK(SchM_Partition_QM) {
EcuM_StateType state;
EcuM_SP_RetStatus retStatus = ECUM_SP_OK;
do {
/*lint -save -e534 MISRA:HARDWARE_ACCESS::[MISRA 2012 Rule 17.7, required] */
SYS_CALL_WaitEvent(EVENT_MASK_Alarm_BswServices_Partition_QM);
SYS_CALL_ClearEvent(EVENT_MASK_Alarm_BswServices_Partition_QM);
EcuM_GetState(&state);
/*lint -restore */
/* @req ARC_SWS_SchM_00006 The BSW scheduler shall schedule BSW modules by calling their MainFunctions */
switch( state ) {
case ECUM_STATE_STARTUP_ONE:
case ECUM_STATE_STARTUP_TWO:
SCHM_MAINFUNCTION_ECUM_QM(state, retStatus);
/* Synchronize with the ASIL partition */
if (retStatus == ECUM_SP_RELEASE_SYNC) {
retStatus = ECUM_SP_OK;
/* Report to ASIL SchM, QM is ready */ /* ARC_SWS_SchM_00004 */
SYS_CALL_SetEvent(TASK_ID_SchM_Partition_A0, EVENT_MASK_SynchPartition_A0); /*lint !e534 MISRA:HARDWARE_ACCESS::[MISRA 2012 Rule 17.7, required] */
}
break;
default: /* Schedule BSW on QM partition */
runMemory(); /*lint !e522 MISRA:FALSE_POSITIVE:Schedule BSW on QM partition:[MISRA 2012 Rule 2.2, required]*/
SCHM_MAINFUNCTION_BSWM();
SCHM_MAINFUNCTION_ECUM_QM(state, retStatus);
SCHM_MAINFUNCTION_CANTRCV();
SCHM_MAINFUNCTION_CAN_MODE();
/*lint -save -e553 MISRA:CONFIGURATION:CAN polling:[MISRA 2012 Rule 20.9, required]*/
#if (CAN_USE_WRITE_POLLING == STD_ON)
SCHM_MAINFUNCTION_CAN_WRITE();
#endif
#if (CAN_USE_READ_POLLING == STD_ON)
SCHM_MAINFUNCTION_CAN_READ();
#endif
#if (CAN_USE_BUSOFF_POLLING == STD_ON)
SCHM_MAINFUNCTION_CAN_BUSOFF();
#endif
#if (ARC_CAN_ERROR_POLLING == STD_ON)
SCHM_MAINFUNCTION_CAN_ERROR();
#endif
#if (CAN_USE_WAKEUP_POLLING == STD_ON)
SCHM_MAINFUNCTION_CAN_WAKEUP();
#endif
/*lint -restore */
SCHM_MAINFUNCTION_COMRX();
SCHM_MAINFUNCTION_COMTX();
SCHM_MAINFUNCTION_XCP();
SCHM_MAINFUNCTION_CANTP();
SCHM_MAINFUNCTION_J1939TP();
SCHM_MAINFUNCTION_DCM();
SCHM_MAINFUNCTION_DEM();
SCHM_MAINFUNCTION_FIM();
SCHM_MAINFUNCTION_IOHWAB();
SCHM_MAINFUNCTION_COMM();
SCHM_MAINFUNCTION_NM();
SCHM_MAINFUNCTION_CANNM();
SCHM_MAINFUNCTION_CANSM();
SCHM_MAINFUNCTION_LINIF();
SCHM_MAINFUNCTION_LINSM();
SCHM_MAINFUNCTION_LINCDD();
/* Check if QM EcuM is ready with synching */
if (retStatus == ECUM_SP_RELEASE_SYNC) {
retStatus = ECUM_SP_OK;
/* Report to ASIL SchM, QM is ready */
SYS_CALL_SetEvent(TASK_ID_SchM_Partition_A0, EVENT_MASK_SynchPartition_A0); /*lint !e534 MISRA:HARDWARE_ACCESS::[MISRA 2012 Rule 17.7, required] */
}
break;
}
} while (SCHM_TASK_EXTENDED_CONDITION != 0); /*lint !e506 MISRA:PERFORMANCE:Required to loop task in order to synchronize partitions:[MISRA 2012 Rule 2.1, required]*/
}
|
2301_81045437/classic-platform
|
system/SchM/src/SchM_partition_QM.c
|
C
|
unknown
| 14,657
|
#StbM
obj-$(USE_STBM) += StbM.o
obj-$(USE_STBM) += StbM_Cfg.o
inc-$(USE_STBM) += $(ROOTDIR)/system/StbM/inc
inc-$(USE_STBM) += $(ROOTDIR)/include/rte
vpath-$(USE_STBM) += $(ROOTDIR)/system/StbM/src
|
2301_81045437/classic-platform
|
system/StbM/StbM.mod.mk
|
Makefile
|
unknown
| 208
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/** @reqSettings DEFAULT_SPECIFICATION_REVISION=4.2.2 */
#ifndef STBM_H_
#define STBM_H_
#include "Std_Types.h"
#include "StbM_Types.h"
#include "Rte_StbM_Type.h"
#if defined(USE_ETHTSYN)
#include "EthTSyn.h"
#endif
#define STBM_VENDOR_ID 60u
#define STBM_MODULE_ID 160u
#define STBM_AR_RELEASE_MAJOR_VERSION 4u
#define STBM_AR_RELEASE_MINOR_VERSION 2u
#define STBM_AR_RELEASE_REVISION_VERSION 2u
#define STBM_AR_MAJOR_VERSION STBM_AR_RELEASE_MAJOR_VERSION
#define STBM_AR_MINOR_VERSION STBM_AR_RELEASE_MINOR_VERSION
#define STBM_AR_PATCH_VERSION STBM_AR_RELEASE_REVISION_VERSION
#define STBM_SW_MAJOR_VERSION 1u
#define STBM_SW_MINOR_VERSION 0u
#define STBM_SW_PATCH_VERSION 0u
#include "StbM_Cfg.h"
/*
* Errors described by StbM 7.4.1 Error classification.
*****************************************************/
/** @req SWS_StbM_00041 */
#define STBM_E_PARAM 0x0Au
#define STBM_E_NOT_INITIALIZED 0x0Bu
#define STBM_E_PARAM_POINTER 0x10u
#define STBM_E_INIT_FAILED 0x11u
#define STBM_INVALID_OS_COUNTER 0xFFFFFFFFu
#define STBM_INVALID_ETH_TIMEDOMAIN 0xFFFFFFFFu
#define STBM_INVALID_TIMEBASE 0xFFFFu
#define STBM_INVALID_NVM_HANDLE 0xFFu
#define STBM_NANOSEC_MAX_VALUE 1000000000ULL
/*
* Service IDs for StbM function definitions.
*/
/* @req SWS_StbM_00041 */
#define STBM_SERVICE_ID_INIT 0x00u
#define STBM_SERVICE_ID_MAIN_FUNCTION 0x04u
#define STBM_SERVICE_ID_GET_VERSION_INFO 0x05u
#define STBM_SERVICE_ID_GET_CURRENT_TIME 0x07u
#define STBM_SERVICE_ID_GET_CURRENT_TIME_EXTENDED 0x08u
#define STBM_SERVICE_ID_GET_CURRENT_RAW 0x09u
#define STBM_SERVICE_ID_GET_CURRENT_DIFF 0x0Au
#define STBM_SERVICE_ID_SET_GLOBAL_TIME 0x0Bu
#define STBM_SERVICE_ID_SET_USER_DATA 0x0Cu
#define STBM_SERVICE_ID_SET_OFFSET 0x0Du
#define STBM_SERVICE_ID_GET_OFFSET 0x0Eu
#define STBM_SERVICE_ID_BUS_SET_GLOBAL_TIME 0x0Fu
/*lint -esym(9003, StbMConfigData) Could define variable at block scope. OK, false positive. */
extern const StbM_ConfigType StbMConfigData;
/* 8.1.3 Standard functions */
/* This service returns the version information of this module. */
/* @req SWS_StbM_00066 */
#if ( STBM_VERSION_INFO_API == STD_ON )
void StbM_GetVersionInfo(Std_VersionInfoType* versioninfo);
#endif /* STBM_VERSION_INFO_API */
/* Initializes the Synchronized Time-base Manager */
/* @req SWS_StbM_00052 */
void StbM_Init(const StbM_ConfigType* ConfigPtr);
/* @req SWS_StbM_00195 */
Std_ReturnType StbM_GetCurrentTime(StbM_SynchronizedTimeBaseType timeBaseId, StbM_TimeStampType* timeStampPtr, StbM_UserDataType* userDataPtr );
/* !req SWS_StbM_00200 */
#if (STBM_GET_CURRENT_TIME_EXT_AVIALBLE == STD_ON)
Std_ReturnType StbM_GetCurrentTimeExtended(StbM_SynchronizedTimeBaseType timeBaseId, StbM_TimeStampExtendedType* timeStampPtr, StbM_UserDataType* userDataPtr );
#endif
/* @req SWS_StbM_00205 */
Std_ReturnType StbM_GetCurrentTimeRaw(StbM_TimeStampRawType* timeStampRawPtr);
/* @req SWS_StbM_00209 */
Std_ReturnType StbM_GetCurrentTimeDiff(StbM_TimeStampRawType givenTimeStamp, StbM_TimeStampRawType* timeStampDiffPtr );
/* @req SWS_StbM_00213 */
Std_ReturnType StbM_SetGlobalTime(StbM_SynchronizedTimeBaseType timeBaseId, const StbM_TimeStampType* timeStampPtr, const StbM_UserDataType* userDataPtr );
/* @req SWS_StbM_00218 */
Std_ReturnType StbM_SetUserData(StbM_SynchronizedTimeBaseType timeBaseId, const StbM_UserDataType* userDataPtr );
/* @req SWS_StbM_00223 */
Std_ReturnType StbM_SetOffset(StbM_SynchronizedTimeBaseType timeBaseId, const StbM_TimeStampType* timeStampPtr );
/* @req SWS_StbM_00228 */
Std_ReturnType StbM_GetOffset(StbM_SynchronizedTimeBaseType timeBaseId, StbM_TimeStampType* timeStampPtr );
/* @req SWS_StbM_00233 */
Std_ReturnType StbM_BusSetGlobalTime(StbM_SynchronizedTimeBaseType timeBaseId, const StbM_TimeStampType* timeStampPtr, const StbM_UserDataType* userDataPtr, boolean syncToTimeBase );
/* @req SWS_StbM_00057 */
void StbM_MainFunction(void);
extern const StbM_ConfigType StbMConfigData;
#endif /* STBM_H_ */
|
2301_81045437/classic-platform
|
system/StbM/inc/StbM.h
|
C
|
unknown
| 5,157
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/** @reqSettings DEFAULT_SPECIFICATION_REVISION=4.2.2 */
#ifndef STBM_TYPES_H_
#define STBM_TYPES_H_
#if defined(USE_NVM)
#include "NvM.h"
#endif
/* @req SWS_StbM_00142 */ /* @req SWS_StbM_00150 */
typedef uint16 StbM_SynchronizedTimeBaseType;
/* @req SWS_StbM_00194 */
typedef uint32 StbM_TimeStampRawType;
typedef enum{
NO_STORAGE,
STORAGE_AT_SHUTDOWN
}StbM_StoreTimebaseNVType;
typedef struct {
StbM_SynchronizedTimeBaseType StbMOffsetTimeBaseID; /* Reference to the Synchronized Time-Base */
uint32 StbMLocalTimeRef; /* Reference to local time Hardware/OsCounterTicksPerBase OS counter */
uint32 StbMEthGlobalTimeDomainRef; /* Reference to local time shall be accessed on an Ethernet bus*/
boolean StbMIsHardwareTimersupported; /* used this for identify the hardware timer is enabled */
float64 StbMSyncLossThreshold; /* minimum delta between the time value in two sync messages for which the sync loss flag is set */
float64 StbMSyncLossTimeout; /* timeout for the situation that the time synchronization gets lost in the scope of the time domain*/
StbM_SynchronizedTimeBaseType StbMSyncTimeBaseId; /* Synchronized time-base via a unique identifier */
StbM_StoreTimebaseNVType StbMStoreTimebaseNonVolatile; /* specifying that the time base shall be stored in the NvRam*/
const boolean StbMIsSystemWideGlobalTimeMaster; /* global time master that acts as a system-wide source of time information with respect to global time.*/
#if defined(USE_NVM)
NvM_BlockIdType StbMNvmUseBlockID;
#endif
}StbMSyncTimeBaseType;
typedef struct {
const StbMSyncTimeBaseType *StbMSynchronizedTimeBaseRef; /* Reference to the required synchronized time-base */
uint32 StbMTriggeredCustomerPeriod; /* triggering period of the triggered customer in microseconds */
uint16 StbMOSScheduleTableRef; /* Reference Mandatory reference to synchronized OS ScheduleTable,*/
}StbMTriggeredCustomerType;
/** Top level config container for STBM implementation. */
typedef struct {
const StbMSyncTimeBaseType* StbMSyncTimeBase; /* Reference to Synchronized time base */
const StbMTriggeredCustomerType* StbMTriggeredCustomer; /* Reference to Synchronized Trigger Customers */
}StbM_ConfigType; /* @req SWS_StbM_00249*/
#endif /* STBM_TYPES_H_ */
|
2301_81045437/classic-platform
|
system/StbM/inc/StbM_Types.h
|
C
|
unknown
| 3,286
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/** @reqSettings DEFAULT_SPECIFICATION_REVISION=4.2.2 */
/* @req SWS_StbM_00051 */ /* For types included from required files*/
/* @req SWS_StbM_00124 */ /* data types uint8, uint16 and sint32 used in the interfaces refer AUTOSAR data types*/
/* @req SWS_StbM_00180 */ /* StbM shall maintain the Local Time Base autonomously either via StbMLocalTimeRef or via StbMEthGlobalTimeDomainRef */
/* @req SWS_StbM_00193 */ /* For StbMOffsetTimeBase shall only be valid for StbMSynchronizedTimeBaseIdentifier 16 till 31, Added This check in .chk*/
/* @req SWS_StbM_00245 */ /* STBM shall support VARIANT-PRE-COMPILE, created only cfg.h and cfg.c in xpt */
/* RTE related tagging */
/* @req SWS_StbM_00131 */ /* Local RTE can access the internal behaviour of StbM */
/* @req SWS_StbM_00240 */ /* CS service interface - StbM_GlobalTime_Master*/
/* @req SWS_StbM_00244 */ /* Provider port - GlobalTime_Master*/
/* @req SWS_StbM_00247 */ /* CS service interface - StbM_GlobalTime_Slave*/
/* @req SWS_StbM_00248 */ /* Provider port - GlobalTime_Slave*/
#include <string.h>
#include "StbM.h"
#include "SchM_StbM.h"
#if defined(USE_DEM)
#include "Dem.h"
#endif
#if defined(USE_KERNEL) /* @req SWS_StbM_00065 */
#include "Os.h"
#endif
#if defined(USE_ETHTSYN) /* @req SWS_StbM_00246 */
#include "EthTSyn.h"
#endif
#if defined(USE_NVM)
#include "NvM.h"
#endif
#include "StbM_Internal.h"
#include "StbM_Cfg.h"
#include "Os.h"
#if (STBM_DEV_ERROR_DETECT == STD_ON)
#include "Det.h"
#endif
/*lint -emacro(904,STBM_DET_REPORTERROR)*/ /*904 PC-Lint exception to MISRA 14.7 (validate DET macros)*/
#if (STBM_DEV_ERROR_DETECT == STD_ON)
#define STBM_DET_REPORTERROR(_cond ,_api, _error, ...) \
if (!_cond) { \
(void)Det_ReportError(STBM_MODULE_ID, 0, _api, _error); \
return __VA_ARGS__; \
}
#else
#define STBM_DET_REPORTERROR(_cond ,_api, _error, ...) \
if (!_cond) { \
return __VA_ARGS__; \
}
#endif
#define StbM_SET_BIT(byte,mask) ((byte) |= (mask))
#define StbM_CLR_BIT(byte,mask) ((byte) &= (~mask))
#define StbM_GET_BIT(byte,mask) (byte & (mask))
#define STBM_TIMEOUT_MASK 0x01u
#define STBM_TIMELEAP_MASK 0x02u
#define STBM_SYNC_TO_GATEWAY_MASK 0x04u
#define STBM_GLOBAL_TIME_BASE_MASK 0x08u
/* Configuration of StbM channel */
static const StbM_ConfigType* StbM_ConfigPtr = NULL;
static StbM_Internal_TimebaseType StbM_InternalTimeBases[STBM_SYNC_TIME_BASE_COUNT];
/* Internal run time data */
static StbM_Internal_RunTimeType StbM_Internal_RunTime = {
.StbMInitStatus = STBM_STATUS_UNINIT, /* @req SWS_StbM_00100 */
.timeBase = StbM_InternalTimeBases,
#if (STBM_TRIGGERED_CUSTOMER_COUNT > 0)
.StbmTriggeredPeriod = {0},
#endif
};
/* Internal function declarations */
static Std_ReturnType StbM_Internal_ValidateTimeBaseId(const StbM_SynchronizedTimeBaseType timeBaseId, uint8 *timeBaseIndex);
static Std_ReturnType StbM_Internal_UpdateOSCounterTimeStamp(uint8 timeBaseIndex );
static uint64 Convert_To_NanoSec(StbM_TimeStampType timeStampValue);
#if (STBM_TRIGGERED_CUSTOMER_COUNT > 0)
#if ( OS_SC2 == STD_ON ) || ( OS_SC4 == STD_ON )
static void stbmsyncScheduleTable(uint8 syncTriggerdCount);
#endif
#endif
/**
*
* @param version info
*/
/* This service returns the version information of this module. */
/* @req SWS_StbM_00066 */
#if ( STBM_VERSION_INFO_API == STD_ON )
void StbM_GetVersionInfo(Std_VersionInfoType* versioninfo){
/* @req SWS_StbM_00094*/
STBM_DET_REPORTERROR((NULL != versioninfo),STBM_SERVICE_ID_GET_VERSION_INFO,STBM_E_PARAM_POINTER);
STD_GET_VERSION_INFO(versioninfo, STBM);
return;
}
#endif /* STBM_VERSION_INFO_API */
/**
*
* @param ConfigPtr
*/
/* @req SWS_StbM_00052 */
void StbM_Init(const StbM_ConfigType* ConfigPtr){
uint8 timeBaseIndex;
/* @req SWS_StbM_00250 */ /* Configuration pointer ConfigPtr shall always have a NULL_PTR value */
(void)*ConfigPtr; /* It is not used */
StbM_ConfigPtr = &StbMConfigData;
StbM_Internal_RunTime.StbMInitStatus = STBM_STATUS_UNINIT ;
/* @req SWS_StbM_00170 */
for(timeBaseIndex=0; timeBaseIndex < STBM_SYNC_TIME_BASE_COUNT;timeBaseIndex++){
memset(&StbM_Internal_RunTime.timeBase[timeBaseIndex],0,sizeof(StbM_Internal_TimebaseType));
/* @req SWS_StbM_00171 */
if(StbM_ConfigPtr->StbMSyncTimeBase[timeBaseIndex].StbMStoreTimebaseNonVolatile == STORAGE_AT_SHUTDOWN){
#if defined(USE_NVM)
/* NVM handling should be done */
STBM_DET_REPORTERROR((StbM_ConfigPtr->StbMSyncTimeBase[timeBaseIndex].StbMNvmUseBlockID != STBM_INVALID_NVM_HANDLE),STBM_SERVICE_ID_INIT,STBM_E_INIT_FAILED); /* @req SWS_StbM_00099 */
(void)NvM_ReadBlock(StbM_ConfigPtr->StbMSyncTimeBase[timeBaseIndex].StbMNvmUseBlockID, &StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp);
#endif
}
if((StbM_ConfigPtr->StbMSyncTimeBase[timeBaseIndex].StbMIsHardwareTimersupported==TRUE)
|| (StbM_ConfigPtr->StbMSyncTimeBase[timeBaseIndex].StbMLocalTimeRef == STBM_INVALID_OS_COUNTER)){
StbM_Internal_RunTime.timeBase[timeBaseIndex].synchronisedRawtime = STBM_INVALID_OS_COUNTER;
StbM_Internal_RunTime.timeBase[timeBaseIndex].rawTimeDiff =STBM_INVALID_OS_COUNTER;
}
}
#if (STBM_TRIGGERED_CUSTOMER_COUNT > 0)
uint8 trigCustCount; /* added to avoid lint error when no trigger customers are configured*/
for(trigCustCount=0;trigCustCount<STBM_TRIGGERED_CUSTOMER_COUNT;trigCustCount++)
{
StbM_Internal_RunTime.StbmTriggeredPeriod[trigCustCount]=0;
}
#endif
StbM_Internal_RunTime.StbMInitStatus = STBM_STATUS_INIT; /* @req SWS_StbM_00121 */
}
/**
*
* @param timeBaseId
* @param timeStampPtr
* @param userDataPtr
* @return
*/
/* @req SWS_StbM_00195 */
Std_ReturnType StbM_GetCurrentTime( StbM_SynchronizedTimeBaseType timeBaseId, StbM_TimeStampType* timeStampPtr, StbM_UserDataType* userDataPtr ){
Std_ReturnType status;
uint8 timeBaseIndex;
uint8 absoluteTimebaseIndex;
#if (defined(USE_ETHTSYN) && (ETHTSYN_HARDWARE_TIMESTAMP_SUPPORT == STD_ON))
StbM_TimeStampType internalTimeStampValue;
EthTSyn_SyncStateType syncState;
#endif
status = E_NOT_OK;
/* @req SWS_StbM_00198 */ /* @req SWS_StbM_00199 */
STBM_DET_REPORTERROR((STBM_STATUS_INIT == StbM_Internal_RunTime.StbMInitStatus),STBM_SERVICE_ID_GET_CURRENT_TIME,STBM_E_NOT_INITIALIZED,status);
status = StbM_Internal_ValidateTimeBaseId(timeBaseId,&timeBaseIndex);
/* If time base Id not found */
STBM_DET_REPORTERROR((status != E_NOT_OK),STBM_SERVICE_ID_GET_CURRENT_TIME,STBM_E_PARAM,status); /* @req SWS_StbM_00196 */
STBM_DET_REPORTERROR((NULL != timeStampPtr),STBM_SERVICE_ID_GET_CURRENT_TIME,STBM_E_PARAM_POINTER,E_NOT_OK); /* @req SWS_StbM_00197 */
STBM_DET_REPORTERROR((NULL != userDataPtr),STBM_SERVICE_ID_GET_CURRENT_TIME,STBM_E_PARAM_POINTER,E_NOT_OK); /* @req SWS_StbM_00197 */
if(timeBaseId <= VALID_TIME_DOMAIN_MAX){ /* @req SWS_StbM_00173 */
/** Assumed if both local and eth time reference is selected Eth has more priority */
if(StbM_ConfigPtr->StbMSyncTimeBase[timeBaseIndex].StbMEthGlobalTimeDomainRef!=STBM_INVALID_ETH_TIMEDOMAIN){
#if (defined(USE_ETHTSYN) && (ETHTSYN_HARDWARE_TIMESTAMP_SUPPORT == STD_ON))
status = EthTSyn_GetCurrentTime( timeBaseId, &internalTimeStampValue, &syncState );
if(status == E_OK){
StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.nanoseconds = internalTimeStampValue.nanoseconds;
StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.seconds = internalTimeStampValue.seconds;
StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.secondsHi = internalTimeStampValue.secondsHi;
switch(syncState){ /* @req SWS_StbM_00176 */
case ETHTSYN_SYNC:
StbM_SET_BIT(StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.timeBaseStatus, STBM_GLOBAL_TIME_BASE_MASK);
break;
case ETHTSYN_UNSYNC:/* @req SWS_StbM_00189 */
if (STBM_GLOBAL_TIME_BASE_MASK == (StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.timeBaseStatus & STBM_GLOBAL_TIME_BASE_MASK)){
StbM_SET_BIT(StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.timeBaseStatus, STBM_TIMEOUT_MASK);
}
break;
case ETHTSYN_UNCERTAIN:
status = E_NOT_OK;
break;
case ETHTSYN_NEVERSYNC:
StbM_CLR_BIT(StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.timeBaseStatus, STBM_GLOBAL_TIME_BASE_MASK);
StbM_CLR_BIT(StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.timeBaseStatus, STBM_TIMEOUT_MASK);
break;
default:
status = E_NOT_OK;
break;
}
timeStampPtr->timeBaseStatus = StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.timeBaseStatus;
timeStampPtr->nanoseconds = StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.nanoseconds;
timeStampPtr->seconds = StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.seconds;
timeStampPtr->secondsHi = StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.secondsHi ;
}
#endif
}else if(StbM_ConfigPtr->StbMSyncTimeBase[timeBaseIndex].StbMLocalTimeRef != STBM_INVALID_OS_COUNTER){
/* @req SWS_StbM_00178 */
status = StbM_Internal_UpdateOSCounterTimeStamp(timeBaseIndex);
timeStampPtr->nanoseconds = StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.nanoseconds;
timeStampPtr->seconds = StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.seconds;
timeStampPtr->secondsHi = StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.secondsHi ;
timeStampPtr->timeBaseStatus = StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.timeBaseStatus;
}else{
/* Do nothing */
}
userDataPtr->userByte0 = StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentUserData.userByte0;
userDataPtr->userByte1 = StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentUserData.userByte1;
userDataPtr->userByte2 = StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentUserData.userByte2;
userDataPtr->userDataLength = StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentUserData.userDataLength;
}else if ((timeBaseId >= OFFSET_TIME_DOMAIN_MIN)&&(timeBaseId <= OFFSET_TIME_DOMAIN_MAX)){
if(StbM_ConfigPtr->StbMSyncTimeBase[timeBaseIndex].StbMOffsetTimeBaseID != STBM_INVALID_TIMEBASE){
/* @req SWS_StbM_00177*/
status = StbM_Internal_ValidateTimeBaseId(StbM_ConfigPtr->StbMSyncTimeBase[timeBaseIndex].StbMOffsetTimeBaseID,&absoluteTimebaseIndex);
if(status == E_OK){
timeStampPtr->nanoseconds = StbM_Internal_RunTime.timeBase[absoluteTimebaseIndex].StbMCurrentTimeStamp.nanoseconds+StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.nanoseconds;
timeStampPtr->seconds = StbM_Internal_RunTime.timeBase[absoluteTimebaseIndex].StbMCurrentTimeStamp.seconds + StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.seconds;
timeStampPtr->secondsHi = StbM_Internal_RunTime.timeBase[absoluteTimebaseIndex].StbMCurrentTimeStamp.secondsHi + StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.secondsHi;
if ((StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.nanoseconds != 0)
|| (StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.seconds != 0)
|| (StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.secondsHi !=0)) {
timeStampPtr->timeBaseStatus = StbM_Internal_RunTime.timeBase[absoluteTimebaseIndex].StbMCurrentTimeStamp.timeBaseStatus;
} else {
timeStampPtr->timeBaseStatus = 0;
}
}
}
}else{
status = E_NOT_OK;
}
return status;
}
/**
*
* @param timeBaseId
* @param timeStampPtr
* @param userDataPtr
* @return
*/
/* !req SWS_StbM_00200 */
#if (STBM_GET_CURRENT_TIME_EXT_AVIALBLE == STD_ON)
Std_ReturnType StbM_GetCurrentTimeExtended( StbM_SynchronizedTimeBaseType timeBaseId, StbM_TimeStampExtendedType* timeStampPtr, StbM_UserDataType* userDataPtr ){
Std_ReturnType status;
uint8 timeBaseIndex;
status = E_NOT_OK;
/* @req SWS_StbM_00198 */ /* @req SWS_StbM_00199 */
STBM_DET_REPORTERROR((STBM_STATUS_INIT == StbM_Internal_RunTime.StbMInitStatus),STBM_SERVICE_ID_GET_CURRENT_TIME_EXTENDED,STBM_E_NOT_INITIALIZED,status);
status = StbM_Internal_ValidateTimeBaseId(timeBaseId,&timeBaseIndex);
/* If time base Id not found */
STBM_DET_REPORTERROR((status != E_NOT_OK),STBM_SERVICE_ID_GET_CURRENT_TIME_EXTENDED,STBM_E_PARAM,E_NOT_OK); /* !req SWS_StbM_00201 */
STBM_DET_REPORTERROR((NULL != timeStampPtr),STBM_SERVICE_ID_GET_CURRENT_TIME_EXTENDED,STBM_E_PARAM_POINTER,E_NOT_OK); /* !req SWS_StbM_00202 */
STBM_DET_REPORTERROR((NULL != userDataPtr),STBM_SERVICE_ID_GET_CURRENT_TIME_EXTENDED,STBM_E_PARAM_POINTER,E_NOT_OK); /* !req SWS_StbM_00202 */
return status;
}
#endif
/**
*
* @param timeStampRawPtr
* @return
*/
/* @req SWS_StbM_00205 */
Std_ReturnType StbM_GetCurrentTimeRaw( StbM_TimeStampRawType* timeStampRawPtr ){
Std_ReturnType status;
StbM_TimeStampRawType timeStampRawdiff;
uint8 timeBaseIndex;
uint8 rawtimeindex;
status = E_OK;
rawtimeindex =0;
/* @req SWS_StbM_00198 */ /* @req SWS_StbM_00199 */
STBM_DET_REPORTERROR((STBM_STATUS_INIT == StbM_Internal_RunTime.StbMInitStatus),STBM_SERVICE_ID_GET_CURRENT_RAW,STBM_E_NOT_INITIALIZED,E_NOT_OK);
STBM_DET_REPORTERROR((NULL != timeStampRawPtr),STBM_SERVICE_ID_GET_CURRENT_RAW,STBM_E_PARAM_POINTER,E_NOT_OK); /* @req SWS_StbM_00206 */
//Consider first element as smallest
timeStampRawdiff = StbM_Internal_RunTime.timeBase[0].rawTimeDiff;
/* finding the smallest difference from all the time bases for the best raw time*/
for (timeBaseIndex = 0; timeBaseIndex < STBM_SYNC_TIME_BASE_COUNT; timeBaseIndex++){
if(StbM_Internal_RunTime.timeBase[timeBaseIndex].rawTimeDiff < timeStampRawdiff){
timeStampRawdiff = StbM_Internal_RunTime.timeBase[timeBaseIndex].rawTimeDiff;
rawtimeindex = timeBaseIndex;
}
}
/* @req SWS_StbM_00174 */
*timeStampRawPtr = StbM_Internal_RunTime.timeBase[rawtimeindex].synchronisedRawtime;
return status;
}
/**
*
* @param givenTimeStamp
* @param timeStampDiffPtr
* @return
*/
/* @req SWS_StbM_00209 */
Std_ReturnType StbM_GetCurrentTimeDiff( StbM_TimeStampRawType givenTimeStamp, StbM_TimeStampRawType* timeStampDiffPtr ){
Std_ReturnType status;
StbM_TimeStampRawType timeStampRawdiff;
uint8 timeBaseIndex;
uint8 rawtimeindex;
status = E_OK;
rawtimeindex=0;
/* @req SWS_StbM_00198 */ /* @req SWS_StbM_00199 */
STBM_DET_REPORTERROR((STBM_STATUS_INIT == StbM_Internal_RunTime.StbMInitStatus),STBM_SERVICE_ID_GET_CURRENT_DIFF,STBM_E_NOT_INITIALIZED,E_NOT_OK);
STBM_DET_REPORTERROR((NULL != timeStampDiffPtr),STBM_SERVICE_ID_GET_CURRENT_DIFF,STBM_E_PARAM_POINTER,E_NOT_OK); /* @req SWS_StbM_00210 */
/* Consider first element as smallest */
timeStampRawdiff = StbM_Internal_RunTime.timeBase[0].rawTimeDiff;
/* finding the smallest difference from all the time bases for the best raw time*/
for (timeBaseIndex = 0; timeBaseIndex < STBM_SYNC_TIME_BASE_COUNT; timeBaseIndex++) {
if (StbM_Internal_RunTime.timeBase[timeBaseIndex].rawTimeDiff < timeStampRawdiff){
timeStampRawdiff = StbM_Internal_RunTime.timeBase[timeBaseIndex].rawTimeDiff;
rawtimeindex = timeBaseIndex;
}
}
/* @req SWS_StbM_00175 */
if(StbM_Internal_RunTime.timeBase[rawtimeindex].synchronisedRawtime < givenTimeStamp){
/*lint -e{9048} to fix UINT32_MAX unsigned integer literal without a 'U' suffix */
*timeStampDiffPtr = (UINT32_MAX - givenTimeStamp) + StbM_Internal_RunTime.timeBase[rawtimeindex].synchronisedRawtime + 1U;
}else {
*timeStampDiffPtr = StbM_Internal_RunTime.timeBase[rawtimeindex].synchronisedRawtime - givenTimeStamp ;
}
return status;
}
/**
*
* @param timeBaseId
* @param timeStampPtr
* @param userDataPtr
* @return
*/
/* @req SWS_StbM_00213 */
Std_ReturnType StbM_SetGlobalTime( StbM_SynchronizedTimeBaseType timeBaseId, const StbM_TimeStampType* timeStampPtr, const StbM_UserDataType* userDataPtr ){
Std_ReturnType status;
uint8 timeBaseIndex;
status = E_NOT_OK;
/* @req SWS_StbM_00198 */ /* @req SWS_StbM_00199 */
STBM_DET_REPORTERROR((STBM_STATUS_INIT == StbM_Internal_RunTime.StbMInitStatus),STBM_SERVICE_ID_SET_GLOBAL_TIME,STBM_E_NOT_INITIALIZED,status);
status = StbM_Internal_ValidateTimeBaseId(timeBaseId,&timeBaseIndex);
/* If time base Id not found */
STBM_DET_REPORTERROR((status != E_NOT_OK),STBM_SERVICE_ID_SET_GLOBAL_TIME,STBM_E_PARAM,E_NOT_OK); /* @req SWS_StbM_00214 */
STBM_DET_REPORTERROR((NULL != timeStampPtr),STBM_SERVICE_ID_SET_GLOBAL_TIME,STBM_E_PARAM_POINTER,E_NOT_OK); /* @req SWS_StbM_00215 */
if(StbM_ConfigPtr->StbMSyncTimeBase[timeBaseIndex].StbMIsSystemWideGlobalTimeMaster == TRUE){
/* @req SWS_StbM_00181 */
StbM_SET_BIT(StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.timeBaseStatus, STBM_GLOBAL_TIME_BASE_MASK);
StbM_CLR_BIT(StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.timeBaseStatus, STBM_SYNC_TO_GATEWAY_MASK);
StbM_CLR_BIT(StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.timeBaseStatus, STBM_TIMELEAP_MASK);
StbM_CLR_BIT(StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.timeBaseStatus, STBM_TIMEOUT_MASK);
StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.nanoseconds = timeStampPtr->nanoseconds;
StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.seconds = timeStampPtr->seconds;
StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.secondsHi= timeStampPtr->secondsHi;
if(userDataPtr != NULL){
StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentUserData.userByte0= userDataPtr->userByte0;
StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentUserData.userByte1 = userDataPtr->userByte1;
StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentUserData.userByte2 = userDataPtr->userByte2;
StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentUserData.userDataLength = userDataPtr->userDataLength;
}
#if (defined(USE_ETHTSYN) && (ETHTSYN_HARDWARE_TIMESTAMP_SUPPORT == STD_ON))
/* This is as per sequence diagram in EthTSyn module 9.5 section */
status = EthTSyn_SetGlobalTime(timeBaseId,&StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp);
#endif
}
return status;
}
/**
*
* @param timeBaseId
* @param userDataPtr
* @return
*/
/* @req SWS_StbM_00218 */
Std_ReturnType StbM_SetUserData( StbM_SynchronizedTimeBaseType timeBaseId, const StbM_UserDataType* userDataPtr){
Std_ReturnType status;
uint8 timeBaseIndex;
/* @req SWS_StbM_00198 */ /* @req SWS_StbM_00199 */
STBM_DET_REPORTERROR((STBM_STATUS_INIT == StbM_Internal_RunTime.StbMInitStatus),STBM_SERVICE_ID_SET_USER_DATA,STBM_E_NOT_INITIALIZED,E_NOT_OK);
status = StbM_Internal_ValidateTimeBaseId(timeBaseId,&timeBaseIndex);
/* If time base Id not found */
STBM_DET_REPORTERROR((status != E_NOT_OK),STBM_SERVICE_ID_SET_USER_DATA,STBM_E_PARAM,E_NOT_OK); /* @req SWS_StbM_00219 */
STBM_DET_REPORTERROR((NULL != userDataPtr),STBM_SERVICE_ID_SET_USER_DATA,STBM_E_PARAM_POINTER,E_NOT_OK); /* @req SWS_StbM_00220 */
StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentUserData.userByte0= userDataPtr->userByte0;
StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentUserData.userByte1 = userDataPtr->userByte1;
StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentUserData.userByte2 = userDataPtr->userByte2;
StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentUserData.userDataLength = userDataPtr->userDataLength;
return status;
}
/**
*
* @param timeBaseId
* @param timeStampPtr
* @return
*/
/* @req SWS_StbM_00223 */
Std_ReturnType StbM_SetOffset( StbM_SynchronizedTimeBaseType timeBaseId, const StbM_TimeStampType* timeStampPtr ){
Std_ReturnType status;
uint8 offsettimeBaseIndex;
status = E_NOT_OK;
/* @req SWS_StbM_00198 */ /* @req SWS_StbM_00199 *//* @req SWS_StbM_00190 */
STBM_DET_REPORTERROR((STBM_STATUS_INIT == StbM_Internal_RunTime.StbMInitStatus),STBM_SERVICE_ID_SET_OFFSET,STBM_E_NOT_INITIALIZED,status);
status = StbM_Internal_ValidateTimeBaseId(timeBaseId,&offsettimeBaseIndex);
/* If time base Id not found */
STBM_DET_REPORTERROR((status != E_NOT_OK),STBM_SERVICE_ID_SET_OFFSET,STBM_E_PARAM,E_NOT_OK); /* @req SWS_StbM_00224 */
STBM_DET_REPORTERROR((NULL != timeStampPtr),STBM_SERVICE_ID_SET_OFFSET,STBM_E_PARAM_POINTER,E_NOT_OK); /* @req SWS_StbM_00225 */
/* @req SWS_StbM_00191 */
if ((timeBaseId >= OFFSET_TIME_DOMAIN_MIN)&&(timeBaseId <= OFFSET_TIME_DOMAIN_MAX)){
/* @req SWS_StbM_00177 */
StbM_Internal_RunTime.timeBase[offsettimeBaseIndex].StbMCurrentTimeStamp.nanoseconds =timeStampPtr->nanoseconds;
StbM_Internal_RunTime.timeBase[offsettimeBaseIndex].StbMCurrentTimeStamp.seconds =timeStampPtr->seconds;
StbM_Internal_RunTime.timeBase[offsettimeBaseIndex].StbMCurrentTimeStamp.secondsHi =timeStampPtr->secondsHi;
} else {
status = E_NOT_OK;
}
return status;
}
/**
*
* @param timeBaseId
* @param timeStampPtr
* @return
*/
/* @req SWS_StbM_00228 */
Std_ReturnType StbM_GetOffset( StbM_SynchronizedTimeBaseType timeBaseId, StbM_TimeStampType* timeStampPtr ){
Std_ReturnType status;
uint8 timeBaseIndex;
status = E_NOT_OK;
/* @req SWS_StbM_00198 */ /* @req SWS_StbM_00199 */
STBM_DET_REPORTERROR((STBM_STATUS_INIT == StbM_Internal_RunTime.StbMInitStatus),STBM_SERVICE_ID_GET_OFFSET,STBM_E_NOT_INITIALIZED,status);
status = StbM_Internal_ValidateTimeBaseId(timeBaseId,&timeBaseIndex);
/* If time base Id not found */
STBM_DET_REPORTERROR((status != E_NOT_OK),STBM_SERVICE_ID_GET_OFFSET,STBM_E_PARAM,E_NOT_OK); /* @req SWS_StbM_00229 */
STBM_DET_REPORTERROR((NULL != timeStampPtr),STBM_SERVICE_ID_GET_OFFSET,STBM_E_PARAM_POINTER,E_NOT_OK); /* @req SWS_StbM_00230 */
/* @req SWS_StbM_00191 *//* @req SWS_StbM_00192 */
if ((timeBaseId >= OFFSET_TIME_DOMAIN_MIN)&&(timeBaseId <= OFFSET_TIME_DOMAIN_MAX)){
timeStampPtr->nanoseconds = StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.nanoseconds;
timeStampPtr->seconds = StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.seconds ;
timeStampPtr->secondsHi = StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.secondsHi;
}else {
status = E_NOT_OK;
}
return status;
}
/**
*
* @param timeBaseId
* @param timeStampPtr
* @param userDataPtr
* @param syncToTimeBase
* @return
*/
/* @req SWS_StbM_00233 */
Std_ReturnType StbM_BusSetGlobalTime( StbM_SynchronizedTimeBaseType timeBaseId, const StbM_TimeStampType* timeStampPtr, const StbM_UserDataType* userDataPtr, boolean syncToTimeBase ){
/* @req SWS_StbM_00179*/ /** This is generic on updating time base status for each time domain */
Std_ReturnType status;
uint8 timeBaseIndex;
uint64 timeDiffToCmpThreshold;
uint64 stbmTimestampinNs;
uint64 recvdTimeStampinNs;
timeDiffToCmpThreshold =0;
status = E_NOT_OK;
/* @req SWS_StbM_00198 */ /* @req SWS_StbM_00199 */
STBM_DET_REPORTERROR((STBM_STATUS_INIT == StbM_Internal_RunTime.StbMInitStatus),STBM_SERVICE_ID_BUS_SET_GLOBAL_TIME,STBM_E_NOT_INITIALIZED,status);
status = StbM_Internal_ValidateTimeBaseId(timeBaseId,&timeBaseIndex);
/* If time base Id not found */
STBM_DET_REPORTERROR((status != E_NOT_OK),STBM_SERVICE_ID_BUS_SET_GLOBAL_TIME,STBM_E_PARAM,E_NOT_OK); /* @req SWS_StbM_00234 */
STBM_DET_REPORTERROR((NULL != timeStampPtr),STBM_SERVICE_ID_BUS_SET_GLOBAL_TIME,STBM_E_PARAM_POINTER,E_NOT_OK); /* @req SWS_StbM_00235 */
/** from SRS_StbM_20014 considered only for time slave time value will be modified */
if(StbM_ConfigPtr->StbMSyncTimeBase[timeBaseIndex].StbMIsSystemWideGlobalTimeMaster ==FALSE){
recvdTimeStampinNs = Convert_To_NanoSec(*timeStampPtr);
stbmTimestampinNs = Convert_To_NanoSec(StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp);
if((StbM_ConfigPtr->StbMSyncTimeBase[timeBaseIndex].StbMIsHardwareTimersupported==FALSE)&&(StbM_ConfigPtr->StbMSyncTimeBase[timeBaseIndex].StbMLocalTimeRef!=STBM_INVALID_OS_COUNTER)){
if(stbmTimestampinNs >recvdTimeStampinNs){
timeDiffToCmpThreshold =stbmTimestampinNs - recvdTimeStampinNs;
StbM_Internal_RunTime.timeBase[timeBaseIndex].synchronisedRawtime -=(uint32)timeDiffToCmpThreshold;
}else{
timeDiffToCmpThreshold = (recvdTimeStampinNs -stbmTimestampinNs);
StbM_Internal_RunTime.timeBase[timeBaseIndex].synchronisedRawtime +=(uint32)timeDiffToCmpThreshold;
}
StbM_Internal_RunTime.timeBase[timeBaseIndex].rawTimeDiff =(uint32)timeDiffToCmpThreshold;
}
/* @req SWS_StbM_00186 */ /* @req SWS_StbM_00182 */
if(StbM_ConfigPtr->StbMSyncTimeBase[timeBaseIndex].StbMSyncLossThreshold !=0){
if(timeDiffToCmpThreshold > StbM_ConfigPtr->StbMSyncTimeBase[timeBaseIndex].StbMSyncLossThreshold){
StbM_SET_BIT(StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.timeBaseStatus, STBM_TIMELEAP_MASK);
}else{
StbM_CLR_BIT(StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.timeBaseStatus, STBM_TIMELEAP_MASK);
}
}
/* @req SWS_StbM_00183 *//* @req SWS_StbM_00187 */
StbM_Internal_RunTime.timeBase[timeBaseIndex].syncLosstimer = StbM_ConfigPtr->StbMSyncTimeBase[timeBaseIndex].StbMSyncLossTimeout;
StbM_CLR_BIT(StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.timeBaseStatus, STBM_TIMEOUT_MASK);
if(userDataPtr != NULL){
StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentUserData.userByte0 = userDataPtr->userByte0;
StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentUserData.userByte1 = userDataPtr->userByte1;
StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentUserData.userByte2 = userDataPtr->userByte2;
StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentUserData.userDataLength = userDataPtr->userDataLength;
}
StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.nanoseconds = timeStampPtr->nanoseconds;
StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.seconds = timeStampPtr->seconds;
StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.secondsHi = timeStampPtr->secondsHi;
/* @req SWS_StbM_00185*/ /* @req SWS_StbM_00189 */
StbM_SET_BIT(StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.timeBaseStatus, STBM_GLOBAL_TIME_BASE_MASK);
/* @req SWS_StbM_00184 */ /* @req SWS_StbM_00188 */
if(syncToTimeBase == FALSE){
StbM_CLR_BIT(StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.timeBaseStatus, STBM_SYNC_TO_GATEWAY_MASK);
}else{
StbM_SET_BIT(StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.timeBaseStatus, STBM_SYNC_TO_GATEWAY_MASK);
}
}
return status;
}
/**
*
*/
/* @req SWS_StbM_00057 */
void StbM_MainFunction(void){
uint8 timebaseindex;
/* @req SWS_StbM_00198 */ /* @req SWS_StbM_00199 */
STBM_DET_REPORTERROR((STBM_STATUS_INIT == StbM_Internal_RunTime.StbMInitStatus),STBM_SERVICE_ID_MAIN_FUNCTION,STBM_E_NOT_INITIALIZED);
for(timebaseindex=0;timebaseindex<STBM_SYNC_TIME_BASE_COUNT;timebaseindex++){
if((StbM_ConfigPtr->StbMSyncTimeBase[timebaseindex].StbMIsHardwareTimersupported==FALSE)&&(StbM_ConfigPtr->StbMSyncTimeBase[timebaseindex].StbMLocalTimeRef!=STBM_INVALID_OS_COUNTER)){
(void)StbM_Internal_UpdateOSCounterTimeStamp(timebaseindex);
/* @req SWS_StbM_00187 */
/* Check if this time base is on a slave port */
if (FALSE == StbM_ConfigPtr->StbMSyncTimeBase[timebaseindex].StbMIsSystemWideGlobalTimeMaster) {
if(StbM_Internal_RunTime.timeBase[timebaseindex].syncLosstimer >= STBM_MAIN_FUNC_PERIOD){
StbM_Internal_RunTime.timeBase[timebaseindex].syncLosstimer -=STBM_MAIN_FUNC_PERIOD;
}else{
StbM_Internal_RunTime.timeBase[timebaseindex].syncLosstimer =0;
StbM_SET_BIT(StbM_Internal_RunTime.timeBase[timebaseindex].StbMCurrentTimeStamp.timeBaseStatus, STBM_TIMEOUT_MASK);
}
} /* Sync loss timer is not run for time base with hardware support */
}
}
#if (STBM_TRIGGERED_CUSTOMER_COUNT > 0)
#if ( OS_SC2 == STD_ON ) || ( OS_SC4 == STD_ON )
uint8 syncTriggerdCount;
/* @req SWS_StbM_00084 */
for(syncTriggerdCount = 0; syncTriggerdCount<STBM_TRIGGERED_CUSTOMER_COUNT;syncTriggerdCount++)
{
StbM_Internal_RunTime.StbmTriggeredPeriod[syncTriggerdCount]++;
if(StbM_ConfigPtr->StbMTriggeredCustomer[syncTriggerdCount].StbMTriggeredCustomerPeriod == StbM_Internal_RunTime.StbmTriggeredPeriod[syncTriggerdCount])
{
stbmsyncScheduleTable(syncTriggerdCount);
}
}
#endif
#endif
}
/**
* @brief - To validated the correct time base ID received.
* @param timeBaseId
* @param SynctimeBaseIndex
* @return
*/
static Std_ReturnType StbM_Internal_ValidateTimeBaseId(const StbM_SynchronizedTimeBaseType timeBaseId, uint8 *syncTimeBaseIndex){
uint8 loopIndex;
Std_ReturnType retValue;
retValue = E_NOT_OK;
for (loopIndex = 0; loopIndex < STBM_SYNC_TIME_BASE_COUNT; loopIndex++) {
if(StbM_ConfigPtr->StbMSyncTimeBase[loopIndex].StbMSyncTimeBaseId == timeBaseId)
{
*syncTimeBaseIndex = loopIndex;
retValue = E_OK;
break;
}
}
return retValue;
}
#if (STBM_TRIGGERED_CUSTOMER_COUNT > 0)
#if ( OS_SC2 == STD_ON ) || ( OS_SC4 == STD_ON )
/**
*
* @param syncTriggerdCount
*/
static void stbmsyncScheduleTable(uint8 syncTriggerdCount){
/* @req SWS_StbM_00020 */
TickType stbmNanoSecToTick;
Std_ReturnType retValue;
uint8 internalTimebaseIndex;
retValue = StbM_Internal_ValidateTimeBaseId(StbM_ConfigPtr->StbMTriggeredCustomer[syncTriggerdCount].StbMSynchronizedTimeBaseRef->StbMSyncTimeBaseId,&internalTimebaseIndex);
if(E_OK == retValue){
/* @req SWS_StbM_00077 */
if((STBM_GLOBAL_TIME_BASE_MASK == StbM_GET_BIT(StbM_Internal_RunTime.timeBase[internalTimebaseIndex].StbMCurrentTimeStamp.timeBaseStatus, STBM_GLOBAL_TIME_BASE_MASK))
&& (FALSE == StbM_GET_BIT(StbM_Internal_RunTime.timeBase[internalTimebaseIndex].StbMCurrentTimeStamp.timeBaseStatus, STBM_TIMEOUT_MASK))){
stbmNanoSecToTick = (TickType)(StbM_Internal_RunTime.timeBase[internalTimebaseIndex].synchronisedRawtime/OSTICKDURATION);
/* req SWS_StbM_00092 */ /* states check is done in API stbmsyncScheduleTable */
/* @req SWS_StbM_00107 */
(void)SyncScheduleTable(StbM_ConfigPtr->StbMTriggeredCustomer[syncTriggerdCount].StbMOSScheduleTableRef, stbmNanoSecToTick);
}
/* Reset the triggerring Counter */
StbM_Internal_RunTime.StbmTriggeredPeriod[syncTriggerdCount] = 0u;
}
}
#endif
#endif
/**
*
* @param timeStampNSValue - ns value of the time stamp
* @return
*/
static Std_ReturnType StbM_Internal_UpdateOSCounterTimeStamp(uint8 timeBaseIndex ){
Std_ReturnType status;
TickType osElapsedCounterValue;
uint32 osGetCounterTicksinNs;
uint64 secondsValue;
CounterType osCounterId;
osCounterId = (CounterType) StbM_ConfigPtr->StbMSyncTimeBase[timeBaseIndex].StbMLocalTimeRef;
status = GetElapsedValue(osCounterId,&StbM_Internal_RunTime.timeBase[timeBaseIndex].stbmInternalOsCounter,&osElapsedCounterValue);
if(status == E_OK){
osGetCounterTicksinNs = OS_TICKS2NS_OS_TICK(osElapsedCounterValue);
StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.nanoseconds += osGetCounterTicksinNs;
StbM_Internal_RunTime.timeBase[timeBaseIndex].synchronisedRawtime += osGetCounterTicksinNs;
if(StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.nanoseconds >(STBM_NANOSEC_MAX_VALUE-1) ){
secondsValue = ((((uint64)StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.secondsHi << 32u)) | StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.seconds);
secondsValue++;
StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.secondsHi = (uint16)(secondsValue>>32);
StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.seconds = (uint32)secondsValue;
StbM_Internal_RunTime.timeBase[timeBaseIndex].StbMCurrentTimeStamp.nanoseconds-= STBM_NANOSEC_MAX_VALUE;
}
}
return status;
}
/**
* @brief - To convert StbM_TimeStampType to 48 bit NanoSec value
* @param timeStampValue
* @return
*/
static uint64 Convert_To_NanoSec(StbM_TimeStampType timeStampValue)
{
uint64 convrtedNSValue;
uint64 secondsValue;
secondsValue = ((((uint64)timeStampValue.secondsHi << 32u)) | timeStampValue.seconds);
convrtedNSValue = (1000000000 * secondsValue) + timeStampValue.nanoseconds;
return (convrtedNSValue);
}
#ifdef HOST_TEST
StbM_Internal_RunTimeType* readinternal_StbMstatus(void );
StbM_Internal_RunTimeType* readinternal_StbMstatus(void)
{
return &StbM_Internal_RunTime;
}
#endif
|
2301_81045437/classic-platform
|
system/StbM/src/StbM.c
|
C
|
unknown
| 36,442
|
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef STBM_INTERNAL_TYPES_H_
#define STBM_INTERNAL_TYPES_H_
#include "Rte_StbM_Type.h"
#include "StbM_Types.h"
#define VALID_TIME_DOMAIN_MAX 15
#define VALID_TIME_DOMAIN_MIN 0
#define OFFSET_TIME_DOMAIN_MAX 31
#define OFFSET_TIME_DOMAIN_MIN 16
typedef enum {
STBM_STATUS_UNINIT,
STBM_STATUS_INIT
}StbM_Internal_InitStatusType;
typedef struct{
float64 syncLosstimer;
StbM_TimeStampRawType rawTimeDiff;
StbM_TimeStampRawType synchronisedRawtime;
TickType stbmInternalOsCounter;
StbM_UserDataType StbMCurrentUserData;
StbM_TimeStampExtendedType StbMCurrentTimeStampExtended;
StbM_TimeStampType StbMCurrentTimeStamp;
}StbM_Internal_TimebaseType;
typedef struct {
StbM_Internal_InitStatusType StbMInitStatus;
StbM_Internal_TimebaseType* timeBase;
#if (STBM_TRIGGERED_CUSTOMER_COUNT > 0)
uint8 StbmTriggeredPeriod[STBM_TRIGGERED_CUSTOMER_COUNT];
#endif
}StbM_Internal_RunTimeType;
#endif /* STBM_INTERNAL_TYPES_H_ */
|
2301_81045437/classic-platform
|
system/StbM/src/StbM_Internal.h
|
C
|
unknown
| 1,828
|
ARC_DIR?=core
ifeq (${MAKELEVEL},0)
# Build from within eclipse
ifeq ($(OS),Windows_NT)
PROJECT_DIR?=/$(subst :/,/,$(subst \,/,$(PWD)))
else
PROJECT_DIR?=$(PWD)
endif
ARC_PATH?=$(PROJECT_DIR)/../$(ARC_DIR)
BDIR=$(CURDIR)
export BDIR
else
# "Normal build
ARC_PATH?=../$(ARC_DIR)
PROJECT_DIR?=$(abspath $(CURDIR))
endif
export CROSS_COMPILE:=
export TEST_DIR:=$(abspath $(CURDIR))
export BOARDDIR:=linux
export BDIR=$(TEST_DIR)
export SELECT_CLIB=CLIB_NATIVE
export PROJECT_DIR
.PHONY: clean
clean all:
$(Q)$(MAKE) -r -C $(ARC_PATH) $(MAKECMDGOALS)
|
2301_81045437/classic-platform
|
testCommon/build_for_linux.mk
|
Makefile
|
unknown
| 621
|
# Usage:
# SHELL
# ...
# $ make -f build_single.mk BDIR=/c/projects/workspace/Ticket1129-nvm-arctest/NvMTests all
#
# ECLIPSE:
# C/C++ build->Build directory : ${project_loc}
# ARC_DIR=<your arc directory>
# BOARDDIR=linux
# Make target: -f build_single.mk BDIR=/c/projects/workspace/Ticket1129-nvm-arctest/NvmTests all
ARC_DIR?=core
ifeq (${MAKELEVEL},0)
# Build from within eclipse
ifeq ($(OS),Windows_NT)
PROJECT_DIR?=/$(subst :/,/,$(subst \,/,$(PWD)))
else
PROJECT_DIR?=$(PWD)
endif
ARC_PATH?=$(PROJECT_DIR)/../$(ARC_DIR)
BDIR=$(CURDIR)
export BDIR
else
# "Normal build
ARC_PATH?=../$(ARC_DIR)
PROJECT_DIR?=$(abspath $(CURDIR))
endif
export PROJECT_DIR
export Q
$(info ARC_DIR: $(ARC_DIR))
$(info ARC_PATH: $(ARC_PATH))
#$(info TEST_DIR: $(TEST_DIR))
$(info PROJECT_DIR: $(PROJECT_DIR))
$(info CURDIR: $(CURDIR))
$(info PWD: $(PWD))
ifeq ($(BOARDDIR), linux)
export SELECT_CLIB=CLIB_NATIVE
else
endif
.PHONY: clean
clean all:
$(Q)$(MAKE) -r -C $(ARC_PATH) $(MAKECMDGOALS)
|
2301_81045437/classic-platform
|
testCommon/build_single.mk
|
Makefile
|
unknown
| 1,127
|
# This file is included by the build_config.mk in the os tests
# It is currently only used for setting up the return value when
# lint produces warnings.
#
ALLOW_LINT_WARNINGS=y
CFG+=MINIMAL_OUTPUT
ifeq ($(board_name), mpc5604b_xpc560b)
ifeq ($(COMPILER), cw)
ALLOW_LINT_WARNINGS=n
endif
endif
ifeq ($(board_name), rh850f1l)
RH850_PARTNUM ?= RF7010243
endif
ifeq ($(BUILD_OS_SAFETY_PLATFORM),y)
def-y += OS_SYSTICK_APP=APPLICATION_ID_OsApplication_Sys
CFG+=TC2XX_OPTIMIZE_IRQ_VECTORTABLE_SIZE
CFG+=ARC_CLIB
# Currently only winidea support
SELECT_CONSOLE = TTY_WINIDEA
board_name_suffix=_sp
endif
|
2301_81045437/classic-platform
|
testCommon/common_build_config.mk
|
Makefile
|
unknown
| 649
|
###
# This file is supposed to be included from the test-specific makefiles.
# For this reason all paths in this file is relative to the current BDIR.
###
CFG_STANDARD_NEWLIB:=y
# === EmbUnit ===
VPATH += $(PROJECT_DIR)/embUnit/embUnit
inc-y += $(PROJECT_DIR)/embUnit/embUnit
LINT_EXCLUDE_PATHS += $(PROJECT_DIR)/embUnit/embUnit
VPATH += $(PROJECT_DIR)/embUnit/textui
inc-y += $(PROJECT_DIR)/embUnit/textui
LINT_EXCLUDE_PATHS += $(PROJECT_DIR)/embUnit/textui
inc-y += $(PROJECT_DIR)/embUnit
include $(PROJECT_DIR)/embUnit/embUnit/embUnit.mk
include $(PROJECT_DIR)/embUnit/textui/textui.mk
# === Common includes ===
inc-y += $(ROOTDIR)/testCommon/inc
# === Test specific configuration files ===
# The more precise configuration, the higher preceedance.
VPATH := ../config/$(board_name) ../config ../stubs ../utils $(VPATH)
inc-y := $(inc-pre-y) ../config/$(board_name) ../config ../stubs ../utils $(inc-y)
# === Test specific object files ===
# Our project files (adds all .c files in project root)
PROJECT_C_FILES=$(notdir $(wildcard ../*.c))
obj-y += $(PROJECT_C_FILES:%.c=%.o)
VPATH += ..
def-y += $(XML_HEADER_SWITCH)
def-y += $(XML_ESCAPE_SWITCH)
def-y += $(XML_OUTPUT_SWITCH)
ifeq (USE_LINSM, $(findstring USE_LINSM,$(def-y)))
inc-y += $(ROOTDIR)/communication/LinSM/inc
endif
ifeq (USE_LINIF, $(findstring USE_LINIF,$(def-y)))
inc-y += $(ROOTDIR)/communication/LinIf/inc
endif
ifeq (USE_CANSM, $(findstring USE_CANSM,$(def-y)))
inc-y += $(ROOTDIR)/communication/CanSM/inc
endif
ifeq (USE_CANIF, $(findstring USE_CANIF,$(def-y)))
inc-y += $(ROOTDIR)/communication/CanIf/inc
endif
ifeq (USE_LIN, $(findstring USE_LIN,$(def-y)))
inc-y += $(ROOTDIR)/mcal/Lin/inc
endif
ifeq (USE_SPI, $(findstring USE_SPI,$(def-y)))
inc-y += $(ROOTDIR)/mcal/Spi/inc
endif
ifeq (USE_FRSM, $(findstring USE_FRSM,$(def-y)))
inc-y += $(ROOTDIR)/communication/FrSM/inc
endif
ifeq (USE_ETHSM, $(findstring USE_ETHSM,$(def-y)))
inc-y += $(ROOTDIR)/communication/EthSM/inc
endif
ifeq (USE_ETH, $(findstring USE_ETH,$(def-y)))
inc-y += $(ROOTDIR)/mcal/Eth/inc
endif
ifeq (USE_NM, $(findstring USE_NM,$(def-y)))
inc-y += $(ROOTDIR)/communication/Nm/inc
endif
ifeq (USE_ECUM, $(findstring USE_ECUM,$(def-y)))
inc-y += $(ROOTDIR)/system/EcuM/inc
endif
ifeq (USE_DEM, $(findstring USE_DEM,$(def-y)))
inc-y += $(ROOTDIR)/diagnostic/Dem/inc
endif
ifeq (USE_COM, $(findstring USE_COM,$(def-y)))
inc-y += $(ROOTDIR)/communication/Com/inc
endif
ifeq (USE_COMM, $(findstring USE_COMM,$(def-y)))
inc-y += $(ROOTDIR)/communication/ComM/inc
endif
ifeq (USE_PDUR, $(findstring USE_PDUR,$(def-y)))
inc-y += $(ROOTDIR)/communication/PduR/inc
inc-y += $(ROOTDIR)/communication/Com/inc
endif
ifeq (USE_SD, $(findstring USE_SD,$(def-y)))
inc-y += $(ROOTDIR)/communication/SD/inc
endif
ifeq (USE_TCPIP, $(findstring USE_TCPIP,$(def-y)))
inc-y += $(ROOTDIR)/communication/TcpIp/inc
endif
ifeq (USE_SOAD, $(findstring USE_SOAD,$(def-y)))
inc-y += $(ROOTDIR)/communication/SoAd/inc
endif
ifeq (USE_DOIP, $(findstring USE_DOIP,$(def-y)))
inc-y += $(ROOTDIR)/communication/DoIP/inc
endif
ifeq (USE_DCM, $(findstring USE_DCM,$(def-y)))
inc-y += $(ROOTDIR)/diagnostic/Dcm/inc
endif
ifeq (USE_DET, $(findstring USE_DET,$(def-y)))
inc-y += $(ROOTDIR)/diagnostic/Det/inc
endif
ifeq (USE_NM, $(findstring USE_NM,$(def-y)))
inc-y += $(ROOTDIR)/communication/Nm/inc
endif
ifeq (USE_CANNM, $(findstring USE_CANNM,$(def-y)))
inc-y += $(ROOTDIR)/communication/CanNm/inc
endif
ifeq (USE_UDPNM, $(findstring USE_UDPNM,$(def-y)))
inc-y += $(ROOTDIR)/communication/UdpNm/inc
endif
ifeq (USE_CANTP, $(findstring USE_CANTP,$(def-y)))
inc-y += $(ROOTDIR)/communication/CanTp/inc
endif
ifeq (USE_MEMIF, $(findstring USE_MEMIF,$(def-y)))
inc-y += $(ROOTDIR)/memory/Memif/inc
endif
ifeq (USE_NVM, $(findstring USE_NVM,$(def-y)))
inc-y += $(ROOTDIR)/memory/NvM/inc
endif
ifeq (USE_Fee, $(findstring USE_FEE,$(def-y)))
inc-y += $(ROOTDIR)/memory/Fee/inc
endif
ifeq (USE_EA, $(findstring USE_EA,$(def-y)))
inc-y += $(ROOTDIR)/memory/Ea/inc
endif
ifeq (USE_BSWM, $(findstring USE_BSWM,$(def-y)))
inc-y += $(ROOTDIR)/system/BswM/inc
endif
|
2301_81045437/classic-platform
|
testCommon/tests_common.mk
|
Makefile
|
unknown
| 4,302
|
#!/bin/bash
if [ "$1" == "" ]; then
echo "error: T32 Installation path not supplied"
exit 1
fi
pwd_cmd=`cygpath -d \`pwd\``
#echo $pwd_cmd
echo "cd ${pwd_cmd}" > $1/t32.cmm
cat start.cmm >> $1/t32.cmm
##dos2unix $1/t32.cmm
cp -v config_sim.t32 $1
|
2301_81045437/classic-platform
|
tools/t32/copy_to_install.sh
|
Shell
|
unknown
| 270
|
#drivers
install-file-y += $(ROOTDIR)/t32/*.cmm,t32
install-file-y += $(ROOTDIR)/t32/*.dll,t32
install-file-y += $(ROOTDIR)/t32/*.men,t32
|
2301_81045437/classic-platform
|
tools/t32/makefile
|
Makefile
|
unknown
| 144
|
EXTRA_CFLAGS += $(USER_EXTRA_CFLAGS)
EXTRA_CFLAGS += -O1
#EXTRA_CFLAGS += -O3
#EXTRA_CFLAGS += -Wall
#EXTRA_CFLAGS += -Wextra
#EXTRA_CFLAGS += -Werror
#EXTRA_CFLAGS += -pedantic
#EXTRA_CFLAGS += -Wshadow -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes
EXTRA_CFLAGS += -Wno-unused-variable
#EXTRA_CFLAGS += -Wno-unused-value
EXTRA_CFLAGS += -Wno-unused-label
#EXTRA_CFLAGS += -Wno-unused-parameter
#EXTRA_CFLAGS += -Wno-unused-function
EXTRA_CFLAGS += -Wno-unused
#EXTRA_CFLAGS += -Wno-uninitialized
GCC_VER_49 := $(shell echo `$(CC) -dumpversion | cut -f1-2 -d.` \>= 4.9 | bc )
ifeq ($(GCC_VER_49),1)
EXTRA_CFLAGS += -Wno-date-time # Fix compile error && warning on gcc 4.9 and later
endif
EXTRA_CFLAGS += -I$(src)/include
EXTRA_LDFLAGS += --strip-debug
CONFIG_AUTOCFG_CP = n
########################## WIFI IC ############################
CONFIG_RTL8852A = n
CONFIG_RTL8852B = y
CONFIG_RTL8852C = n
######################### Interface ###########################
CONFIG_USB_HCI = n
CONFIG_PCI_HCI = y
CONFIG_SDIO_HCI = n
CONFIG_GSPI_HCI = n
########################## Features ###########################
CONFIG_MP_INCLUDED = y
CONFIG_CONCURRENT_MODE = n
CONFIG_POWER_SAVING = n
CONFIG_POWER_SAVE = y
CONFIG_IPS_MODE = default
CONFIG_LPS_MODE = default
CONFIG_BTC = y
CONFIG_WAPI_SUPPORT = n
CONFIG_EFUSE_CONFIG_FILE = y
CONFIG_EXT_CLK = n
CONFIG_TRAFFIC_PROTECT = n
CONFIG_LOAD_PHY_PARA_FROM_FILE = y
# Remember to set CONFIG_FILE_FWIMG when set CONFIG_FILE_FWIMG to y,
# or driver will fail on ifconfig up because can't find firmware file
CONFIG_FILE_FWIMG = n
CONFIG_TXPWR_BY_RATE = y
CONFIG_TXPWR_BY_RATE_EN = y
CONFIG_TXPWR_LIMIT = y
CONFIG_TXPWR_LIMIT_EN = n
CONFIG_RTW_CHPLAN = 0xFFFF
CONFIG_RTW_ADAPTIVITY_EN = disable
CONFIG_RTW_ADAPTIVITY_MODE = normal
CONFIG_80211D = n
CONFIG_SIGNAL_SCALE_MAPPING = n
CONFIG_80211W = y
CONFIG_REDUCE_TX_CPU_LOADING = n
CONFIG_BR_EXT = y
CONFIG_TDLS = n
CONFIG_WIFI_MONITOR = n
CONFIG_MCC_MODE = n
CONFIG_APPEND_VENDOR_IE_ENABLE = n
CONFIG_RTW_NAPI = y
CONFIG_RTW_GRO = y
CONFIG_RTW_NETIF_SG = y
CONFIG_RTW_IPCAM_APPLICATION = n
CONFIG_ICMP_VOQ = n
CONFIG_IP_R_MONITOR = n #arp VOQ and high rate
# user priority mapping rule : tos, dscp
CONFIG_RTW_UP_MAPPING_RULE = tos
CONFIG_PHL_ARCH = y
CONFIG_FSM = n
CONFIG_CMD_DISP = y
CONFIG_HWSIM = n
CONFIG_PHL_TEST_SUITE = n
CONFIG_WIFI_6 = y
RTW_PHL_RX = y
RTW_PHL_TX = y
RTW_PHL_BCN = y
DIRTY_FOR_WORK = y
CONFIG_DRV_FAKE_AP = n
CONFIG_DBG_AX_CAM = y
USE_TRUE_PHY = y
CONFIG_I386_BUILD_VERIFY = n
CONFIG_RTW_MBO = n
########################## Android ###########################
# CONFIG_RTW_ANDROID - 0: no Android, 4/5/6/7/8/9/10/11 : Android version
CONFIG_RTW_ANDROID = 0
ifeq ($(shell test $(CONFIG_RTW_ANDROID) -gt 0; echo $$?), 0)
EXTRA_CFLAGS += -DCONFIG_RTW_ANDROID=$(CONFIG_RTW_ANDROID)
endif
########################## Debug ###########################
CONFIG_RTW_DEBUG = y
# default log level is _DRV_INFO_ = 4,
# please refer to "How_to_set_driver_debug_log_level.doc" to set the available level.
CONFIG_RTW_LOG_LEVEL = 2
# enable /proc/net/rtlxxxx/ debug interfaces
CONFIG_PROC_DEBUG = y
######################## Wake On Lan ##########################
CONFIG_WOWLAN = n
# CONFIG_WAKE_TYPE definition:
# bit0: magic packet
# bit1: unicast packet (default pattern match)
# bit2: disconnect (beacon loss & deauth/dissociation)
# bit3: customized pattern match
# bit4: pairwise key rekey
CONFIG_WAKEUP_TYPE = 0x0f
CONFIG_WOW_LPS_MODE = default
#bit0: disBBRF off, #bit1: Wireless remote controller (WRC)
CONFIG_SUSPEND_TYPE = 0
CONFIG_WOW_STA_MIX = n
CONFIG_GPIO_WAKEUP = n
# Please contact with RTK support team first. After getting the agreement from RTK support team,
# you are just able to modify the CONFIG_WAKEUP_GPIO_IDX with customized requirement.
CONFIG_WAKEUP_GPIO_IDX = default
CONFIG_HIGH_ACTIVE_DEV2HST = n
######### only for USB #########
CONFIG_ONE_PIN_GPIO = n
CONFIG_HIGH_ACTIVE_HST2DEV = n
CONFIG_PNO_SUPPORT = n
CONFIG_PNO_SET_DEBUG = n
CONFIG_AP_WOWLAN = n
######### Notify SDIO Host Keep Power During Syspend ##########
CONFIG_RTW_SDIO_PM_KEEP_POWER = y
###################### MP HW TX MODE FOR VHT #######################
CONFIG_MP_VHT_HW_TX_MODE = n
###################### ROAMING #####################################
CONFIG_LAYER2_ROAMING = y
#bit0: ROAM_ON_EXPIRED, #bit1: ROAM_ON_RESUME, #bit2: ROAM_ACTIVE
CONFIG_ROAMING_FLAG = 0x3
###################### Platform Related #######################
CONFIG_PLATFORM_I386_PC = y
CONFIG_PLATFORM_RTL8198D = n
CONFIG_PLATFORM_ANDROID_X86 = n
CONFIG_PLATFORM_ANDROID_INTEL_X86 = n
CONFIG_PLATFORM_NV_TK1 = n
CONFIG_PLATFORM_NV_TK1_UBUNTU = n
CONFIG_PLATFORM_ARM_SUNxI = n
CONFIG_PLATFORM_RTK1319 = n
CONFIG_PLATFORM_RTK16XXB = n
CONFIG_PLATFORM_AML_S905 = n
CONFIG_PLATFORM_HUANGLONG = n
CONFIG_PLATFORM_ARM_RK3399 = n
########### CUSTOMER ################################
CONFIG_DRVEXT_MODULE = n
export TopDIR ?= $(shell pwd)
########### COMMON #################################
ifeq ($(CONFIG_GSPI_HCI), y)
HCI_NAME = gspi
endif
ifeq ($(CONFIG_SDIO_HCI), y)
HCI_NAME = sdio
endif
ifeq ($(CONFIG_USB_HCI), y)
HCI_NAME = usb
endif
ifeq ($(CONFIG_PCI_HCI), y)
HCI_NAME = pci
endif
ifeq ($(CONFIG_HWSIM), y)
HAL = hal_sim
else
HAL = phl
endif
ifeq ($(CONFIG_PLATFORM_RTL8198D), y)
DRV_PATH = $(src)
else ifeq ($(CONFIG_PLATFORM_ARM_RK3399), y)
DRV_PATH = $(src)
else
DRV_PATH = $(TopDIR)
endif
########### HAL_RTL8852A #################################
ifeq ($(CONFIG_RTL8852A), y)
IC_NAME := rtl8852a
ifeq ($(CONFIG_USB_HCI), y)
MODULE_NAME = 8852au
endif
ifeq ($(CONFIG_PCI_HCI), y)
MODULE_NAME = 8852ae
endif
ifeq ($(CONFIG_SDIO_HCI), y)
MODULE_NAME = 8852as
endif
endif
########### HAL_RTL8852B #################################
ifeq ($(CONFIG_RTL8852B), y)
IC_NAME := rtl8852b
ifeq ($(CONFIG_USB_HCI), y)
MODULE_NAME = 8852bu
endif
ifeq ($(CONFIG_PCI_HCI), y)
MODULE_NAME = 8852be
endif
ifeq ($(CONFIG_SDIO_HCI), y)
MODULE_NAME = 8852bs
endif
endif
########### HAL_RTL8852C #################################
ifeq ($(CONFIG_RTL8852C), y)
IC_NAME := rtl8852c
ifeq ($(CONFIG_USB_HCI), y)
MODULE_NAME = 8852cu
endif
ifeq ($(CONFIG_PCI_HCI), y)
MODULE_NAME = 8852ce
endif
ifeq ($(CONFIG_SDIO_HCI), y)
MODULE_NAME = 8852cs
endif
endif
########### AUTO_CFG #################################
ifeq ($(CONFIG_AUTOCFG_CP), y)
$(shell cp $(DRV_PATH)/autoconf_$(IC_NAME)_$(HCI_NAME)_linux.h $(DRV_PATH)/include/autoconf.h)
endif
########### END OF PATH #################################
ifeq ($(CONFIG_MP_INCLUDED), y)
#MODULE_NAME := $(MODULE_NAME)_mp
EXTRA_CFLAGS += -DCONFIG_MP_INCLUDED
CONFIG_PHL_TEST_SUITE = y
endif
ifeq ($(CONFIG_FSM), y)
EXTRA_CFLAGS += -DCONFIG_FSM
endif
ifeq ($(CONFIG_CMD_DISP), y)
EXTRA_CFLAGS += -DCONFIG_CMD_DISP
endif
ifeq ($(CONFIG_PHL_TEST_SUITE), y)
EXTRA_CFLAGS += -DCONFIG_PHL_TEST_SUITE
endif
ifeq ($(CONFIG_CONCURRENT_MODE), y)
EXTRA_CFLAGS += -DCONFIG_CONCURRENT_MODE
endif
ifeq ($(CONFIG_POWER_SAVING), y)
ifneq ($(CONFIG_IPS_MODE), default)
EXTRA_CFLAGS += -DRTW_IPS_MODE=$(CONFIG_IPS_MODE)
endif
ifneq ($(CONFIG_LPS_MODE), default)
EXTRA_CFLAGS += -DRTW_LPS_MODE=$(CONFIG_LPS_MODE)
endif
ifneq ($(CONFIG_WOW_LPS_MODE), default)
EXTRA_CFLAGS += -DRTW_WOW_LPS_MODE=$(CONFIG_WOW_LPS_MODE)
endif
EXTRA_CFLAGS += -DCONFIG_POWER_SAVING
endif
ifeq ($(CONFIG_POWER_SAVE), y)
EXTRA_CFLAGS += -DCONFIG_POWER_SAVE
endif
ifeq ($(CONFIG_BTC), y)
EXTRA_CFLAGS += -DCONFIG_BTC
endif
ifeq ($(CONFIG_WAPI_SUPPORT), y)
EXTRA_CFLAGS += -DCONFIG_WAPI_SUPPORT
endif
ifeq ($(CONFIG_WIFI_6), y)
EXTRA_CFLAGS += -DCONFIG_WIFI_6
endif
ifeq ($(CONFIG_EFUSE_CONFIG_FILE), y)
EXTRA_CFLAGS += -DCONFIG_EFUSE_CONFIG_FILE
#EFUSE_MAP_PATH
USER_EFUSE_MAP_PATH ?=
ifneq ($(USER_EFUSE_MAP_PATH),)
EXTRA_CFLAGS += -DEFUSE_MAP_PATH=\"$(USER_EFUSE_MAP_PATH)\"
else
EXTRA_CFLAGS += -DEFUSE_MAP_PATH=\"/system/etc/wifi/wifi_efuse_$(MODULE_NAME).map\"
endif
#WIFIMAC_PATH
USER_WIFIMAC_PATH ?=
ifneq ($(USER_WIFIMAC_PATH),)
EXTRA_CFLAGS += -DWIFIMAC_PATH=\"$(USER_WIFIMAC_PATH)\"
else
EXTRA_CFLAGS += -DWIFIMAC_PATH=\"/data/wifimac.txt\"
endif
endif
ifeq ($(CONFIG_EXT_CLK), y)
EXTRA_CFLAGS += -DCONFIG_EXT_CLK
endif
ifeq ($(CONFIG_TRAFFIC_PROTECT), y)
EXTRA_CFLAGS += -DCONFIG_TRAFFIC_PROTECT
endif
ifeq ($(CONFIG_LOAD_PHY_PARA_FROM_FILE), y)
EXTRA_CFLAGS += -DCONFIG_LOAD_PHY_PARA_FROM_FILE
#EXTRA_CFLAGS += -DREALTEK_CONFIG_PATH_WITH_IC_NAME_FOLDER
EXTRA_CFLAGS += -DREALTEK_CONFIG_PATH=\"/lib/firmware/\"
endif
ifeq ($(CONFIG_FILE_FWIMG), y)
EXTRA_CFLAGS += -DCONFIG_FILE_FWIMG
# default external firmware path is [CONFIG_FIRMWARE_PATH][ic_name]/[fw_name]
# ex. Take 8852AE as example:
# normal firmware is [CONFIG_FIRMWARE_PATH]rtl8852ae/rtl8852afw.bin
# WOW firmware is [CONFIG_FIRMWARE_PATH]rtl8852ae/rtl8852afw_wowlan.bin
EXTRA_CFLAGS += -DCONFIG_FIRMWARE_PATH=\"\"
# EXTRA_CFLAGS += -DCONFIG_FIRMWARE_PATH=\"/lib/firmware/\"
endif
ifeq ($(CONFIG_TXPWR_BY_RATE), n)
EXTRA_CFLAGS += -DCONFIG_TXPWR_BY_RATE=0
else ifeq ($(CONFIG_TXPWR_BY_RATE), y)
EXTRA_CFLAGS += -DCONFIG_TXPWR_BY_RATE=1
endif
ifeq ($(CONFIG_TXPWR_BY_RATE_EN), n)
EXTRA_CFLAGS += -DCONFIG_TXPWR_BY_RATE_EN=0
else ifeq ($(CONFIG_TXPWR_BY_RATE_EN), y)
EXTRA_CFLAGS += -DCONFIG_TXPWR_BY_RATE_EN=1
else ifeq ($(CONFIG_TXPWR_BY_RATE_EN), auto)
EXTRA_CFLAGS += -DCONFIG_TXPWR_BY_RATE_EN=2
endif
ifeq ($(CONFIG_TXPWR_LIMIT), n)
EXTRA_CFLAGS += -DCONFIG_TXPWR_LIMIT=0
else ifeq ($(CONFIG_TXPWR_LIMIT), y)
EXTRA_CFLAGS += -DCONFIG_TXPWR_LIMIT=1
endif
ifeq ($(CONFIG_TXPWR_LIMIT_EN), n)
EXTRA_CFLAGS += -DCONFIG_TXPWR_LIMIT_EN=0
else ifeq ($(CONFIG_TXPWR_LIMIT_EN), y)
EXTRA_CFLAGS += -DCONFIG_TXPWR_LIMIT_EN=1
else ifeq ($(CONFIG_TXPWR_LIMIT_EN), auto)
EXTRA_CFLAGS += -DCONFIG_TXPWR_LIMIT_EN=2
endif
ifneq ($(CONFIG_RTW_CHPLAN), 0xFFFF)
EXTRA_CFLAGS += -DCONFIG_RTW_CHPLAN=$(CONFIG_RTW_CHPLAN)
endif
ifeq ($(CONFIG_CALIBRATE_TX_POWER_BY_REGULATORY), y)
EXTRA_CFLAGS += -DCONFIG_CALIBRATE_TX_POWER_BY_REGULATORY
endif
ifeq ($(CONFIG_CALIBRATE_TX_POWER_TO_MAX), y)
EXTRA_CFLAGS += -DCONFIG_CALIBRATE_TX_POWER_TO_MAX
endif
ifeq ($(CONFIG_RTW_ADAPTIVITY_EN), disable)
EXTRA_CFLAGS += -DCONFIG_RTW_ADAPTIVITY_EN=0
else ifeq ($(CONFIG_RTW_ADAPTIVITY_EN), enable)
EXTRA_CFLAGS += -DCONFIG_RTW_ADAPTIVITY_EN=1
else ifeq ($(CONFIG_RTW_ADAPTIVITY_EN), auto)
EXTRA_CFLAGS += -DCONFIG_RTW_ADAPTIVITY_EN=2
endif
ifeq ($(CONFIG_RTW_ADAPTIVITY_MODE), normal)
EXTRA_CFLAGS += -DCONFIG_RTW_ADAPTIVITY_MODE=0
else ifeq ($(CONFIG_RTW_ADAPTIVITY_MODE), carrier_sense)
EXTRA_CFLAGS += -DCONFIG_RTW_ADAPTIVITY_MODE=1
endif
ifeq ($(CONFIG_80211D), y)
EXTRA_CFLAGS += -DCONFIG_80211D
endif
ifeq ($(CONFIG_SIGNAL_SCALE_MAPPING), y)
EXTRA_CFLAGS += -DCONFIG_SIGNAL_SCALE_MAPPING
endif
ifeq ($(CONFIG_80211W), y)
EXTRA_CFLAGS += -DCONFIG_IEEE80211W
endif
ifeq ($(CONFIG_WOWLAN), y)
EXTRA_CFLAGS += -DCONFIG_WOWLAN -DRTW_WAKEUP_EVENT=$(CONFIG_WAKEUP_TYPE)
EXTRA_CFLAGS += -DRTW_SUSPEND_TYPE=$(CONFIG_SUSPEND_TYPE)
ifeq ($(CONFIG_WOW_STA_MIX), y)
EXTRA_CFLAGS += -DRTW_WOW_STA_MIX
endif
ifeq ($(CONFIG_SDIO_HCI), y)
EXTRA_CFLAGS += -DCONFIG_RTW_SDIO_PM_KEEP_POWER
endif
endif
ifeq ($(CONFIG_AP_WOWLAN), y)
EXTRA_CFLAGS += -DCONFIG_AP_WOWLAN
ifeq ($(CONFIG_SDIO_HCI), y)
EXTRA_CFLAGS += -DCONFIG_RTW_SDIO_PM_KEEP_POWER
endif
endif
ifeq ($(CONFIG_LAYER2_ROAMING), y)
EXTRA_CFLAGS += -DCONFIG_LAYER2_ROAMING -DCONFIG_ROAMING_FLAG=$(CONFIG_ROAMING_FLAG)
endif
ifeq ($(CONFIG_PNO_SUPPORT), y)
EXTRA_CFLAGS += -DCONFIG_PNO_SUPPORT
ifeq ($(CONFIG_PNO_SET_DEBUG), y)
EXTRA_CFLAGS += -DCONFIG_PNO_SET_DEBUG
endif
endif
ifeq ($(CONFIG_GPIO_WAKEUP), y)
EXTRA_CFLAGS += -DCONFIG_GPIO_WAKEUP
ifeq ($(CONFIG_ONE_PIN_GPIO), y)
EXTRA_CFLAGS += -DCONFIG_RTW_ONE_PIN_GPIO
endif
ifeq ($(CONFIG_HIGH_ACTIVE_DEV2HST), y)
EXTRA_CFLAGS += -DHIGH_ACTIVE_DEV2HST=1
else
EXTRA_CFLAGS += -DHIGH_ACTIVE_DEV2HST=0
endif
endif
ifeq ($(CONFIG_HIGH_ACTIVE_HST2DEV), y)
EXTRA_CFLAGS += -DHIGH_ACTIVE_HST2DEV=1
else
EXTRA_CFLAGS += -DHIGH_ACTIVE_HST2DEV=0
endif
ifneq ($(CONFIG_WAKEUP_GPIO_IDX), default)
EXTRA_CFLAGS += -DWAKEUP_GPIO_IDX=$(CONFIG_WAKEUP_GPIO_IDX)
endif
ifeq ($(CONFIG_RTW_SDIO_PM_KEEP_POWER), y)
ifeq ($(CONFIG_SDIO_HCI), y)
EXTRA_CFLAGS += -DCONFIG_RTW_SDIO_PM_KEEP_POWER
endif
endif
ifeq ($(CONFIG_REDUCE_TX_CPU_LOADING), y)
EXTRA_CFLAGS += -DCONFIG_REDUCE_TX_CPU_LOADING
endif
ifeq ($(CONFIG_BR_EXT), y)
BR_NAME = br0
EXTRA_CFLAGS += -DCONFIG_BR_EXT
EXTRA_CFLAGS += '-DCONFIG_BR_EXT_BRNAME="'$(BR_NAME)'"'
endif
ifeq ($(CONFIG_TDLS), y)
EXTRA_CFLAGS += -DCONFIG_TDLS
endif
ifeq ($(CONFIG_WIFI_MONITOR), y)
EXTRA_CFLAGS += -DCONFIG_WIFI_MONITOR
endif
ifeq ($(CONFIG_MCC_MODE), y)
EXTRA_CFLAGS += -DCONFIG_MCC_MODE
endif
ifeq ($(CONFIG_RTW_NAPI), y)
EXTRA_CFLAGS += -DCONFIG_RTW_NAPI
endif
ifeq ($(CONFIG_RTW_GRO), y)
EXTRA_CFLAGS += -DCONFIG_RTW_GRO
endif
ifeq ($(CONFIG_RTW_IPCAM_APPLICATION), y)
EXTRA_CFLAGS += -DCONFIG_RTW_IPCAM_APPLICATION
ifeq ($(CONFIG_WIFI_MONITOR), n)
EXTRA_CFLAGS += -DCONFIG_WIFI_MONITOR
endif
endif
ifeq ($(CONFIG_RTW_NETIF_SG), y)
EXTRA_CFLAGS += -DCONFIG_RTW_NETIF_SG
endif
ifeq ($(CONFIG_ICMP_VOQ), y)
EXTRA_CFLAGS += -DCONFIG_ICMP_VOQ
endif
ifeq ($(CONFIG_IP_R_MONITOR), y)
EXTRA_CFLAGS += -DCONFIG_IP_R_MONITOR
endif
ifeq ($(CONFIG_MP_VHT_HW_TX_MODE), y)
EXTRA_CFLAGS += -DCONFIG_MP_VHT_HW_TX_MODE
ifeq ($(CONFIG_PLATFORM_I386_PC), y)
## For I386 X86 ToolChain use Hardware FLOATING
EXTRA_CFLAGS += -mhard-float
else
## For ARM ToolChain use Hardware FLOATING
EXTRA_CFLAGS += -mfloat-abi=hard
endif
endif
ifeq ($(CONFIG_APPEND_VENDOR_IE_ENABLE), y)
EXTRA_CFLAGS += -DCONFIG_APPEND_VENDOR_IE_ENABLE
endif
ifeq ($(CONFIG_RTW_DEBUG), y)
EXTRA_CFLAGS += -DCONFIG_RTW_DEBUG
EXTRA_CFLAGS += -DRTW_LOG_LEVEL=$(CONFIG_RTW_LOG_LEVEL)
endif
ifeq ($(CONFIG_PROC_DEBUG), y)
EXTRA_CFLAGS += -DCONFIG_PROC_DEBUG
endif
ifeq ($(CONFIG_RTW_UP_MAPPING_RULE), dscp)
EXTRA_CFLAGS += -DCONFIG_RTW_UP_MAPPING_RULE=1
else
EXTRA_CFLAGS += -DCONFIG_RTW_UP_MAPPING_RULE=0
endif
EXTRA_CFLAGS += -DPLATFORM_LINUX
ifeq ($(USE_TRUE_PHY), y)
EXTRA_CFLAGS += -DUSE_TRUE_PHY
endif
ifeq ($(CONFIG_HWSIM), y)
EXTRA_CFLAGS += -DCONFIG_HWSIM
# To use pure sw beacon
EXTRA_CFLAGS += -DCONFIG_SWTIMER_BASED_TXBCN
EXTRA_CFLAGS += -DCONFIG_SUPPORT_MULTI_BCN
endif
ifeq ($(CONFIG_DRV_FAKE_AP), y)
EXTRA_CFLAGS += -DCONFIG_DRV_FAKE_AP
OBJS += core/rtw_fake_ap.o
endif
ifeq ($(CONFIG_DBG_AX_CAM), y)
EXTRA_CFLAGS += -DCONFIG_DBG_AX_CAM
endif
ifeq ($(CONFIG_I386_BUILD_VERIFY), y)
EXTRA_CFLAGS += -DCONFIG_I386_BUILD_VERIFY
endif
ifeq ($(CONFIG_RTW_MBO), y)
EXTRA_CFLAGS += -DCONFIG_RTW_MBO -DCONFIG_RTW_WNM -DCONFIG_RTW_BTM_ROAM
#EXTRA_CFLAGS += -DCONFIG_RTW_80211K
EXTRA_CFLAGS += -DCONFIG_RTW_80211R
EXTRA_CFLAGS += -DRTW_FT_DBG=0 -DRTW_WNM_DBG=0 -DRTW_MBO_DBG=0
endif
########### PLATFORM OPS ##########################
# Import platform assigned KSRC and CROSS_COMPILE
include $(wildcard $(DRV_PATH)/platform/*.mk)
# Import platform specific compile options
EXTRA_CFLAGS += -I$(src)/platform
#_PLATFORM_FILES := platform/platform_ops.o
OBJS += $(_PLATFORM_FILES)
########### CUSTOMER ################################
USER_MODULE_NAME ?=
ifneq ($(USER_MODULE_NAME),)
MODULE_NAME := $(USER_MODULE_NAME)
endif
ifneq ($(KERNELRELEASE),)
########### COMMON #################################
include $(src)/common.mk
EXTRA_CFLAGS += -DPHL_PLATFORM_LINUX
EXTRA_CFLAGS += -DCONFIG_PHL_ARCH
ifeq ($(RTW_PHL_RX), y)
EXTRA_CFLAGS += -DRTW_PHL_RX
endif
ifeq ($(RTW_PHL_TX), y)
EXTRA_CFLAGS += -DRTW_PHL_TX
endif
ifeq ($(RTW_PHL_BCN), y)
EXTRA_CFLAGS += -DRTW_PHL_BCN
endif
ifeq ($(DIRTY_FOR_WORK), y)
EXTRA_CFLAGS += -DDIRTY_FOR_WORK
endif
include $(src)/phl/phl.mk
obj-$(CONFIG_RTL8852BE) := $(MODULE_NAME).o
obj-$(CPTCFG_RTL8852AE) := $(MODULE_NAME).o
$(MODULE_NAME)-y = $(OBJS)
else
export CONFIG_RTL8852BE = m
all: modules
modules:
#rm -f .symvers.$(MODULE_NAME)
$(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KSRC) M=$(shell pwd) modules
#cp Module.symvers .symvers.$(MODULE_NAME)
strip:
$(CROSS_COMPILE)strip $(MODULE_NAME).ko --strip-unneeded
install:
install -p -m 644 $(MODULE_NAME).ko $(MODDESTDIR)
/sbin/depmod -a ${KVER}
uninstall:
rm -f $(MODDESTDIR)/$(MODULE_NAME).ko
/sbin/depmod -a ${KVER}
backup_rtlwifi:
@echo "Making backup rtlwifi drivers"
ifneq (,$(wildcard $(STAGINGMODDIR)/rtl*))
@tar cPf $(wildcard $(STAGINGMODDIR))/backup_rtlwifi_driver.tar $(wildcard $(STAGINGMODDIR)/rtl*)
@rm -rf $(wildcard $(STAGINGMODDIR)/rtl*)
endif
ifneq (,$(wildcard $(MODDESTDIR)realtek))
@tar cPf $(MODDESTDIR)backup_rtlwifi_driver.tar $(MODDESTDIR)realtek
@rm -fr $(MODDESTDIR)realtek
endif
ifneq (,$(wildcard $(MODDESTDIR)rtl*))
@tar cPf $(MODDESTDIR)../backup_rtlwifi_driver.tar $(wildcard $(MODDESTDIR)rtl*)
@rm -fr $(wildcard $(MODDESTDIR)rtl*)
endif
@/sbin/depmod -a ${KVER}
@echo "Please reboot your system"
restore_rtlwifi:
@echo "Restoring backups"
ifneq (,$(wildcard $(STAGINGMODDIR)/backup_rtlwifi_driver.tar))
@tar xPf $(STAGINGMODDIR)/backup_rtlwifi_driver.tar
@rm $(STAGINGMODDIR)/backup_rtlwifi_driver.tar
endif
ifneq (,$(wildcard $(MODDESTDIR)backup_rtlwifi_driver.tar))
@tar xPf $(MODDESTDIR)backup_rtlwifi_driver.tar
@rm $(MODDESTDIR)backup_rtlwifi_driver.tar
endif
ifneq (,$(wildcard $(MODDESTDIR)../backup_rtlwifi_driver.tar))
@tar xPf $(MODDESTDIR)../backup_rtlwifi_driver.tar
@rm $(MODDESTDIR)../backup_rtlwifi_driver.tar
endif
@/sbin/depmod -a ${KVER}
@echo "Please reboot your system"
config_r:
@echo "make config"
/bin/bash script/Configure script/config.in
.PHONY: modules clean
clean:
#$(MAKE) -C $(KSRC) M=$(shell pwd) clean
cd $(HAL) ; rm -fr */*/*/*/*.mod.c */*/*/*/*.mod */*/*/*/*.o */*/*/*/.*.cmd */*/*/*/*.ko
cd $(HAL) ; rm -fr */*/*/*.mod.c */*/*/*.mod */*/*/*.o */*/*/.*.cmd */*/*/*.ko
cd $(HAL) ; rm -fr */*/*.mod.c */*/*.mod */*/*.o */*/.*.cmd */*/*.ko
cd $(HAL) ; rm -fr */*.mod.c */*.mod */*.o */.*.cmd */*.ko
cd $(HAL) ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko
cd core ; rm -fr */*.mod.c */*.mod */*.o */.*.cmd */*.ko
cd core ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko
cd os_dep/linux ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko
cd os_dep/linux/hwsim ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko
cd os_dep ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko
cd platform ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko
rm -fr Module.symvers ; rm -fr Module.markers ; rm -fr modules.order
rm -fr *.mod.c *.mod *.o .*.cmd *.ko *~
rm -fr .tmp_versions
endif
|
2301_81045437/rtl8852be
|
Makefile
|
Makefile
|
agpl-3.0
| 18,356
|
#!/bin/bash
rmmod 8192cu
rmmod 8192ce
rmmod 8192du
rmmod 8192de
|
2301_81045437/rtl8852be
|
clean
|
Shell
|
agpl-3.0
| 64
|
########### OS_DEP PATH #################################
_OS_INTFS_FILES := os_dep/osdep_service.o \
os_dep/osdep_service_linux.o \
os_dep/linux/rtw_cfg.o \
os_dep/linux/os_intfs.o \
os_dep/linux/ioctl_linux.o \
os_dep/linux/xmit_linux.o \
os_dep/linux/mlme_linux.o \
os_dep/linux/recv_linux.o \
os_dep/linux/ioctl_cfg80211.o \
os_dep/linux/rtw_cfgvendor.o \
os_dep/linux/wifi_regd.o \
os_dep/linux/rtw_android.o \
os_dep/linux/rtw_proc.o \
os_dep/linux/nlrtw.o \
os_dep/linux/rtw_rhashtable.o
ifeq ($(CONFIG_HWSIM), y)
_OS_INTFS_FILES += os_dep/linux/hwsim/medium/local.o
_OS_INTFS_FILES += os_dep/linux/hwsim/medium/sock_udp.o
_OS_INTFS_FILES += os_dep/linux/hwsim/medium/loopback.o
_OS_INTFS_FILES += os_dep/linux/hwsim/core.o
_OS_INTFS_FILES += os_dep/linux/hwsim/txrx.o
_OS_INTFS_FILES += os_dep/linux/hwsim/netdev.o
_OS_INTFS_FILES += os_dep/linux/hwsim/cfg80211.o
_OS_INTFS_FILES += os_dep/linux/hwsim/platform_dev.o
_OS_INTFS_FILES += os_dep/linux/$(HCI_NAME)_ops_linux.o
else
_OS_INTFS_FILES += os_dep/linux/$(HCI_NAME)_intf.o
_OS_INTFS_FILES += os_dep/linux/$(HCI_NAME)_ops_linux.o
endif
ifeq ($(CONFIG_MP_INCLUDED), y)
_OS_INTFS_FILES += os_dep/linux/ioctl_mp.o \
os_dep/linux/ioctl_efuse.o
endif
ifeq ($(CONFIG_SDIO_HCI), y)
_OS_INTFS_FILES += os_dep/linux/custom_gpio_linux.o
endif
ifeq ($(CONFIG_GSPI_HCI), y)
_OS_INTFS_FILES += os_dep/linux/custom_gpio_linux.o
endif
########### CORE PATH #################################
_CORE_FILES := core/rtw_cmd.o \
core/rtw_security.o \
core/rtw_debug.o \
core/rtw_io.o \
core/rtw_ioctl_query.o \
core/rtw_ioctl_set.o \
core/rtw_ieee80211.o \
core/rtw_mlme.o \
core/rtw_mlme_ext.o \
core/rtw_sec_cam.o \
core/rtw_mi.o \
core/rtw_wlan_util.o \
core/rtw_vht.o \
core/rtw_he.o \
core/rtw_pwrctrl.o \
core/rtw_rf.o \
core/rtw_chplan.o \
core/monitor/rtw_radiotap.o \
core/rtw_recv.o \
core/rtw_recv_shortcut.o \
core/rtw_sta_mgt.o \
core/rtw_ap.o \
core/rtw_csa.o \
core/wds/rtw_wds.o \
core/mesh/rtw_mesh.o \
core/mesh/rtw_mesh_pathtbl.o \
core/mesh/rtw_mesh_hwmp.o \
core/rtw_xmit.o \
core/rtw_xmit_shortcut.o \
core/rtw_p2p.o \
core/rtw_tdls.o \
core/rtw_br_ext.o \
core/rtw_sreset.o \
core/rtw_rm.o \
core/rtw_rm_fsm.o \
core/rtw_rm_util.o \
core/rtw_trx.o \
core/rtw_beamforming.o \
core/rtw_scan.o
#core/efuse/rtw_efuse.o
_CORE_FILES += core/rtw_phl.o \
core/rtw_phl_cmd.o
EXTRA_CFLAGS += -I$(src)/core/crypto
_CORE_FILES += core/crypto/aes-internal.o \
core/crypto/aes-internal-enc.o \
core/crypto/aes-gcm.o \
core/crypto/aes-ccm.o \
core/crypto/aes-omac1.o \
core/crypto/ccmp.o \
core/crypto/gcmp.o \
core/crypto/aes-siv.o \
core/crypto/aes-ctr.o \
core/crypto/sha256-internal.o \
core/crypto/sha256.o \
core/crypto/sha256-prf.o \
core/crypto/rtw_crypto_wrap.o \
core/rtw_swcrypto.o
ifeq ($(CONFIG_WOWLAN), y)
_CORE_FILES += core/rtw_wow.o
endif
ifeq ($(CONFIG_PCI_HCI), y)
_CORE_FILES += core/rtw_trx_pci.o
endif
ifeq ($(CONFIG_USB_HCI), y)
_CORE_FILES += core/rtw_trx_usb.o
endif
ifeq ($(CONFIG_SDIO_HCI), y)
_CORE_FILES += core/rtw_sdio.o
_CORE_FILES += core/rtw_trx_sdio.o
endif
ifeq ($(CONFIG_MP_INCLUDED), y)
_CORE_FILES += core/rtw_mp.o
endif
ifeq ($(CONFIG_WAPI_SUPPORT), y)
_CORE_FILES += core/rtw_wapi.o \
core/rtw_wapi_sms4.o
endif
ifeq ($(CONFIG_BTC), y)
_CORE_FILES += core/rtw_btc.o
endif
ifeq ($(CONFIG_RTW_MBO), y)
_CORE_FILES += core/rtw_mbo.o core/rtw_ft.o core/rtw_wnm.o
endif
OBJS += $(_OS_INTFS_FILES) $(_CORE_FILES)
|
2301_81045437/rtl8852be
|
common.mk
|
Makefile
|
agpl-3.0
| 3,585
|
/*
* Counter with CBC-MAC (CCM) with AES
*
* Copyright (c) 2010-2012, Jouni Malinen <j@w1.fi>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
*/
#include "rtw_crypto_wrap.h"
#include "aes.h"
#include "aes_wrap.h"
static void xor_aes_block(u8 *dst, const u8 *src)
{
u32 *d = (u32 *) dst;
u32 *s = (u32 *) src;
*d++ ^= *s++;
*d++ ^= *s++;
*d++ ^= *s++;
*d++ ^= *s++;
}
static void aes_ccm_auth_start(void *aes, size_t M, size_t L, const u8 *nonce,
const u8 *aad, size_t aad_len, size_t plain_len,
u8 *x)
{
u8 aad_buf[2 * AES_BLOCK_SIZE];
u8 b[AES_BLOCK_SIZE];
/* Authentication */
/* B_0: Flags | Nonce N | l(m) */
b[0] = aad_len ? 0x40 : 0 /* Adata */;
b[0] |= (((M - 2) / 2) /* M' */ << 3);
b[0] |= (L - 1) /* L' */;
os_memcpy(&b[1], nonce, 15 - L);
WPA_PUT_BE16(&b[AES_BLOCK_SIZE - L], plain_len);
wpa_hexdump_key(_MSG_EXCESSIVE_, "CCM B_0", b, AES_BLOCK_SIZE);
aes_encrypt(aes, b, x); /* X_1 = E(K, B_0) */
if (!aad_len)
return;
WPA_PUT_BE16(aad_buf, aad_len);
os_memcpy(aad_buf + 2, aad, aad_len);
os_memset(aad_buf + 2 + aad_len, 0, sizeof(aad_buf) - 2 - aad_len);
xor_aes_block(aad_buf, x);
aes_encrypt(aes, aad_buf, x); /* X_2 = E(K, X_1 XOR B_1) */
if (aad_len > AES_BLOCK_SIZE - 2) {
xor_aes_block(&aad_buf[AES_BLOCK_SIZE], x);
/* X_3 = E(K, X_2 XOR B_2) */
aes_encrypt(aes, &aad_buf[AES_BLOCK_SIZE], x);
}
}
static void aes_ccm_auth(void *aes, const u8 *data, size_t len, u8 *x)
{
size_t last = len % AES_BLOCK_SIZE;
size_t i;
for (i = 0; i < len / AES_BLOCK_SIZE; i++) {
/* X_i+1 = E(K, X_i XOR B_i) */
xor_aes_block(x, data);
data += AES_BLOCK_SIZE;
aes_encrypt(aes, x, x);
}
if (last) {
/* XOR zero-padded last block */
for (i = 0; i < last; i++)
x[i] ^= *data++;
aes_encrypt(aes, x, x);
}
}
static void aes_ccm_encr_start(size_t L, const u8 *nonce, u8 *a)
{
/* A_i = Flags | Nonce N | Counter i */
a[0] = L - 1; /* Flags = L' */
os_memcpy(&a[1], nonce, 15 - L);
}
static void aes_ccm_encr(void *aes, size_t L, const u8 *in, size_t len, u8 *out,
u8 *a)
{
size_t last = len % AES_BLOCK_SIZE;
size_t i;
/* crypt = msg XOR (S_1 | S_2 | ... | S_n) */
for (i = 1; i <= len / AES_BLOCK_SIZE; i++) {
WPA_PUT_BE16(&a[AES_BLOCK_SIZE - 2], i);
/* S_i = E(K, A_i) */
aes_encrypt(aes, a, out);
xor_aes_block(out, in);
out += AES_BLOCK_SIZE;
in += AES_BLOCK_SIZE;
}
if (last) {
WPA_PUT_BE16(&a[AES_BLOCK_SIZE - 2], i);
aes_encrypt(aes, a, out);
/* XOR zero-padded last block */
for (i = 0; i < last; i++)
*out++ ^= *in++;
}
}
static void aes_ccm_encr_auth(void *aes, size_t M, u8 *x, u8 *a, u8 *auth)
{
size_t i;
u8 tmp[AES_BLOCK_SIZE];
wpa_hexdump_key(_MSG_EXCESSIVE_, "CCM T", x, M);
/* U = T XOR S_0; S_0 = E(K, A_0) */
WPA_PUT_BE16(&a[AES_BLOCK_SIZE - 2], 0);
aes_encrypt(aes, a, tmp);
for (i = 0; i < M; i++)
auth[i] = x[i] ^ tmp[i];
wpa_hexdump_key(_MSG_EXCESSIVE_, "CCM U", auth, M);
}
static void aes_ccm_decr_auth(void *aes, size_t M, u8 *a, const u8 *auth, u8 *t)
{
size_t i;
u8 tmp[AES_BLOCK_SIZE];
wpa_hexdump_key(_MSG_EXCESSIVE_, "CCM U", auth, M);
/* U = T XOR S_0; S_0 = E(K, A_0) */
WPA_PUT_BE16(&a[AES_BLOCK_SIZE - 2], 0);
aes_encrypt(aes, a, tmp);
for (i = 0; i < M; i++)
t[i] = auth[i] ^ tmp[i];
wpa_hexdump_key(_MSG_EXCESSIVE_, "CCM T", t, M);
}
/* AES-CCM with fixed L=2 and aad_len <= 30 assumption */
int aes_ccm_ae(const u8 *key, size_t key_len, const u8 *nonce,
size_t M, const u8 *plain, size_t plain_len,
const u8 *aad, size_t aad_len, u8 *crypt, u8 *auth)
{
const size_t L = 2;
void *aes;
u8 x[AES_BLOCK_SIZE], a[AES_BLOCK_SIZE];
if (aad_len > 30 || M > AES_BLOCK_SIZE)
return -1;
aes = aes_encrypt_init(key, key_len);
if (aes == NULL)
return -1;
aes_ccm_auth_start(aes, M, L, nonce, aad, aad_len, plain_len, x);
aes_ccm_auth(aes, plain, plain_len, x);
/* Encryption */
aes_ccm_encr_start(L, nonce, a);
aes_ccm_encr(aes, L, plain, plain_len, crypt, a);
aes_ccm_encr_auth(aes, M, x, a, auth);
aes_encrypt_deinit(aes);
return 0;
}
/* AES-CCM with fixed L=2 and aad_len <= 30 assumption */
int aes_ccm_ad(const u8 *key, size_t key_len, const u8 *nonce,
size_t M, const u8 *crypt, size_t crypt_len,
const u8 *aad, size_t aad_len, const u8 *auth, u8 *plain)
{
const size_t L = 2;
void *aes;
u8 x[AES_BLOCK_SIZE], a[AES_BLOCK_SIZE];
u8 t[AES_BLOCK_SIZE];
if (aad_len > 30 || M > AES_BLOCK_SIZE)
return -1;
aes = aes_encrypt_init(key, key_len);
if (aes == NULL)
return -1;
/* Decryption */
aes_ccm_encr_start(L, nonce, a);
aes_ccm_decr_auth(aes, M, a, auth, t);
/* plaintext = msg XOR (S_1 | S_2 | ... | S_n) */
aes_ccm_encr(aes, L, crypt, crypt_len, plain, a);
aes_ccm_auth_start(aes, M, L, nonce, aad, aad_len, crypt_len, x);
aes_ccm_auth(aes, plain, crypt_len, x);
aes_encrypt_deinit(aes);
if (os_memcmp_const(x, t, M) != 0) {
wpa_printf(_MSG_EXCESSIVE_, "CCM: Auth mismatch");
return -1;
}
return 0;
}
|
2301_81045437/rtl8852be
|
core/crypto/aes-ccm.c
|
C
|
agpl-3.0
| 5,042
|
/*
* AES-128/192/256 CTR
*
* Copyright (c) 2003-2007, Jouni Malinen <j@w1.fi>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
*/
#include "rtw_crypto_wrap.h"
#include "aes.h"
#include "aes_wrap.h"
/**
* aes_ctr_encrypt - AES-128/192/256 CTR mode encryption
* @key: Key for encryption (key_len bytes)
* @key_len: Length of the key (16, 24, or 32 bytes)
* @nonce: Nonce for counter mode (16 bytes)
* @data: Data to encrypt in-place
* @data_len: Length of data in bytes
* Returns: 0 on success, -1 on failure
*/
int aes_ctr_encrypt(const u8 *key, size_t key_len, const u8 *nonce,
u8 *data, size_t data_len)
{
void *ctx;
size_t j, len, left = data_len;
int i;
u8 *pos = data;
u8 counter[AES_BLOCK_SIZE], buf[AES_BLOCK_SIZE];
ctx = aes_encrypt_init(key, key_len);
if (ctx == NULL)
return -1;
os_memcpy(counter, nonce, AES_BLOCK_SIZE);
while (left > 0) {
aes_encrypt(ctx, counter, buf);
len = (left < AES_BLOCK_SIZE) ? left : AES_BLOCK_SIZE;
for (j = 0; j < len; j++)
pos[j] ^= buf[j];
pos += len;
left -= len;
for (i = AES_BLOCK_SIZE - 1; i >= 0; i--) {
counter[i]++;
if (counter[i])
break;
}
}
aes_encrypt_deinit(ctx);
return 0;
}
/**
* aes_128_ctr_encrypt - AES-128 CTR mode encryption
* @key: Key for encryption (key_len bytes)
* @nonce: Nonce for counter mode (16 bytes)
* @data: Data to encrypt in-place
* @data_len: Length of data in bytes
* Returns: 0 on success, -1 on failure
*/
int aes_128_ctr_encrypt(const u8 *key, const u8 *nonce,
u8 *data, size_t data_len)
{
return aes_ctr_encrypt(key, 16, nonce, data, data_len);
}
|
2301_81045437/rtl8852be
|
core/crypto/aes-ctr.c
|
C
|
agpl-3.0
| 1,664
|