/*BEGIN_FILE_HDR **************************************************************************************************** * NOTICE * This software is the property of HiRain Technologies. Any information contained in this doc * should not be reproduced, or used, or disclosed without the written authorization from HiRain * Technologies. **************************************************************************************************** * File Name: Os_PeripheralArea.c **************************************************************************************************** * Project/Product: AUTOSAR OS PROJECT * Title: Os_PeripheralArea.c * Author: Hirain **************************************************************************************************** * Description: * * Peripheral Area Module of OS. **************************************************************************************************** * Limitations: * * None. **************************************************************************************************** * **************************************************************************************************** * Revision History: * Reference to Os_Cpu.c File. **************************************************************************************************** *END_FILE_HDR*/ /*PRQA S 0857 EOF*/ /* * Number of macro definitions exceeds 1024 */ #include "Os_Internal.h" /*************************************************************************************************** * OS API code ***************************************************************************************************/ /* BEGIN_FUNCTION_HDR **************************************************************************************************** * Function Name: Os_ReadPeripheral8 SWS_Os_91013 * * Description: This service returns the content of a given memory location (
). * * Inputs: hardware peripheral area reference *
memory address * * Outputs: content of the given memory location (
) * * Limitations: None **************************************************************************************************** END_FUNCTION_HDR*/ FUNC(StatusType, OS_CODE) Os_ReadPeripheral8 ( AreaIdType Area, P2CONST(Os_uint8, AUTOMATIC, OS_APPL_CONST) Address, P2VAR(Os_uint8, AUTOMATIC, OS_APPL_DATA) ReadValue ) { #if(OS_PERIPHERAL_AREA_NUMBER > 0) CoreIdType currentCoreID; #if(OS_APPLICATION_NUMBER > 0) ApplicationType tempAppId; #endif /* (OS_APPLICATION_NUMBER > 0) */ currentCoreID = OsCpu_GetCoreID(); if ((currentCoreID >= (CoreIdType)OS_USED_CORE_NUMBER) || (Os_CoreState[currentCoreID] != \ OS_CORE_START)) { /* can not record err in this state, as OS services can not be called. */ return E_OS_CORE; } if (OS_NO_API_USED != Os_IntAPIUsedFlag[currentCoreID]) { /* SWS_Os_00093 System error -- this API is called between interrupt processing function pairs */ OsHook_ReportError(currentCoreID, E_OS_DISABLEDINT, OSServiceId_ReadPeripheral8, \ OS_IE_NOMORE_INFO, (Os_uint32)Area, (Os_uint32)Os_IntAPIUsedFlag[currentCoreID], \ OS_IE_NO_ERRPAR); return E_OS_DISABLEDINT; } if ((OS_NULL == Address) || (OS_NULL == ReadValue)) { OsHook_ReportError(currentCoreID, E_OS_PARAM_POINTER, OSServiceId_ReadPeripheral8, \ OS_IE_NOMORE_INFO, (Os_uint32)Area, (Os_uint32)Address, (Os_uint32)ReadValue); return E_OS_PARAM_POINTER; } #if(OS_STATUS_LEVEL == OS_EXTENDED) if (Area >= (AreaIdType)OS_PERIPHERAL_AREA_NUMBER) { OsHook_ReportError(currentCoreID, E_OS_ID, OSServiceId_ReadPeripheral8, \ OS_IE_PERIPHERAL_AREA_ID, (Os_uint32)Area, (Os_uint32)Address, OS_IE_NO_ERRPAR); return E_OS_ID; } if ((Os_PeripheralAreaCfg[Area].startAddress > (Os_AddrType)Address) \ || (Os_PeripheralAreaCfg[Area].endAddress < (Os_AddrType)Address)) { OsHook_ReportError(currentCoreID, E_OS_VALUE, OSServiceId_ReadPeripheral8, \ OS_IE_PERIPHERAL_AREA_ADDRESS, (Os_uint32)Area, (Os_uint32)Address, OS_IE_NO_ERRPAR); return E_OS_VALUE; } if ((Os_uint16)(Os_CurrentContext[currentCoreID] & Os_ReadPeripheral8Mask) == (Os_uint16)0) { OsHook_ReportError(currentCoreID, E_OS_CALLEVEL, OSServiceId_ReadPeripheral8, \ OS_IE_NOMORE_INFO, (Os_uint32)Area, (Os_uint32)Os_CurrentContext[currentCoreID], \ OS_IE_NO_ERRPAR); return E_OS_CALLEVEL; } #endif /* (OS_STATUS_LEVEL == OS_EXTENDED) */ #if(OS_APPLICATION_NUMBER > 0) #if(OS_TRUSTED_FUNCTION_NUMBER > 0) if (Os_TrustFunApplicationId[currentCoreID] != OS_INVALID_OSAPPLICATION) { tempAppId = Os_TrustFunApplicationId[currentCoreID]; } else #endif /* (OS_TRUSTED_FUNCTION_NUMBER > 0) */ { tempAppId = Os_CurrentApplicationId[currentCoreID]; } if ((Os_ApplicationMaskType)0 == ((((Os_ApplicationMaskType)1) << tempAppId) \ & (Os_PeripheralAreaCfg[Area].appMask))) { OsHook_ReportError (currentCoreID, E_OS_ACCESS, OSServiceId_ReadPeripheral8, \ OS_IE_NO_ACCESS_RIGHT, (Os_uint32)Area, (Os_uint32)tempAppId, OS_IE_NO_ERRPAR); return E_OS_ACCESS; } if (OS_FALSE == OsApp_CheckingWriteable(currentCoreID, (Os_AddrType)ReadValue, \ sizeof(Os_uint8))) { OsHook_ReportError(currentCoreID, E_OS_ILLEGAL_ADDRESS, OSServiceId_ReadPeripheral8, \ OS_IE_NOMORE_INFO, (Os_uint32)ReadValue, OS_IE_NO_ERRPAR, OS_IE_NO_ERRPAR); return E_OS_ILLEGAL_ADDRESS; } #endif /* (OS_APPLICATION_NUMBER > 0) */ #endif /* #if(OS_PERIPHERAL_AREA_NUMBER > 0) */ *ReadValue = OsCpu_ReadIo8(Address); return E_OS_OK; } /* BEGIN_FUNCTION_HDR **************************************************************************************************** * Function Name: Os_ReadPeripheral16 SWS_Os_91015 * * Description: This service returns the content of a given memory location (
). * * Inputs: hardware peripheral area reference *
memory address * * Outputs: content of the given memory location (
) * * Limitations: None **************************************************************************************************** END_FUNCTION_HDR*/ FUNC(StatusType, OS_CODE) Os_ReadPeripheral16 ( AreaIdType Area, P2CONST(Os_uint16, AUTOMATIC, OS_APPL_CONST) Address, P2VAR(Os_uint16, AUTOMATIC, OS_APPL_DATA) ReadValue ) { #if(OS_PERIPHERAL_AREA_NUMBER > 0) CoreIdType currentCoreID; #if(OS_APPLICATION_NUMBER > 0) ApplicationType tempAppId; #endif /* (OS_APPLICATION_NUMBER > 0) */ currentCoreID = OsCpu_GetCoreID(); if ((currentCoreID >= (CoreIdType)OS_USED_CORE_NUMBER) || (Os_CoreState[currentCoreID] != \ OS_CORE_START)) { /* can not record err in this state, as OS services can not be called */ return E_OS_CORE; } if (OS_NO_API_USED != Os_IntAPIUsedFlag[currentCoreID]) { /* SWS_Os_00093 System error -- this API is called between interrupt processing function pairs */ OsHook_ReportError(currentCoreID, E_OS_DISABLEDINT, OSServiceId_ReadPeripheral16, \ OS_IE_NOMORE_INFO, (Os_uint32)Area, (Os_uint32)Os_IntAPIUsedFlag[currentCoreID], \ OS_IE_NO_ERRPAR); return E_OS_DISABLEDINT; } if ((OS_NULL == Address) || (OS_NULL == ReadValue)) { OsHook_ReportError(currentCoreID, E_OS_PARAM_POINTER, OSServiceId_ReadPeripheral16, \ OS_IE_NOMORE_INFO, (Os_uint32)Area, (Os_uint32)Address, (Os_uint32)ReadValue); return E_OS_PARAM_POINTER; } #if(OS_STATUS_LEVEL == OS_EXTENDED) if (Area >= (AreaIdType)OS_PERIPHERAL_AREA_NUMBER) { OsHook_ReportError(currentCoreID, E_OS_ID, OSServiceId_ReadPeripheral16, \ OS_IE_PERIPHERAL_AREA_ID, (Os_uint32)Area, (Os_uint32)Address, OS_IE_NO_ERRPAR); return E_OS_ID; } if ((Os_PeripheralAreaCfg[Area].startAddress > (Os_AddrType)Address) \ || (Os_PeripheralAreaCfg[Area].endAddress <= (Os_AddrType)Address)) { OsHook_ReportError(currentCoreID, E_OS_VALUE, OSServiceId_ReadPeripheral16, \ OS_IE_PERIPHERAL_AREA_ADDRESS, (Os_uint32)Area, (Os_uint32)Address, OS_IE_NO_ERRPAR); return E_OS_VALUE; } if ((Os_uint16)(Os_CurrentContext[currentCoreID] & Os_ReadPeripheral16Mask) == (Os_uint16)0) { OsHook_ReportError(currentCoreID, E_OS_CALLEVEL, OSServiceId_ReadPeripheral16, \ OS_IE_NOMORE_INFO, (Os_uint32)Area, (Os_uint32)Os_CurrentContext[currentCoreID], \ OS_IE_NO_ERRPAR); return E_OS_CALLEVEL; } #endif /* (OS_STATUS_LEVEL == OS_EXTENDED) */ #if(OS_APPLICATION_NUMBER > 0) #if(OS_TRUSTED_FUNCTION_NUMBER > 0) if (Os_TrustFunApplicationId[currentCoreID] != OS_INVALID_OSAPPLICATION) { tempAppId = Os_TrustFunApplicationId[currentCoreID]; } else #endif /* (OS_TRUSTED_FUNCTION_NUMBER > 0) */ { tempAppId = Os_CurrentApplicationId[currentCoreID]; } if ((Os_ApplicationMaskType)0 == ((((Os_ApplicationMaskType)1) << tempAppId) \ & (Os_PeripheralAreaCfg[Area].appMask))) { OsHook_ReportError (currentCoreID, E_OS_ACCESS, OSServiceId_ReadPeripheral16, \ OS_IE_NO_ACCESS_RIGHT, (Os_uint32)Area, (Os_uint32)tempAppId, OS_IE_NO_ERRPAR); return E_OS_ACCESS; } if (OS_FALSE == OsApp_CheckingWriteable(currentCoreID, (Os_AddrType)ReadValue, \ sizeof(Os_uint16))) { OsHook_ReportError(currentCoreID, E_OS_ILLEGAL_ADDRESS, OSServiceId_ReadPeripheral16, \ OS_IE_NOMORE_INFO, (Os_uint32)ReadValue, OS_IE_NO_ERRPAR, OS_IE_NO_ERRPAR); return E_OS_ILLEGAL_ADDRESS; } #endif /* (OS_APPLICATION_NUMBER > 0) */ #endif /* OS_PERIPHERAL_AREA_NUMBER > 0 */ *ReadValue = OsCpu_ReadIo16(Address); return E_OS_OK; } /* BEGIN_FUNCTION_HDR **************************************************************************************************** * Function Name: Os_ReadPeripheral32 SWS_Os_91014 * * Description: This service returns the content of a given memory location (
). * * Inputs: hardware peripheral area reference *
memory address * * Outputs: content of the given memory location (
) * * Limitations: None **************************************************************************************************** END_FUNCTION_HDR*/ FUNC(StatusType, OS_CODE) Os_ReadPeripheral32 ( AreaIdType Area, P2CONST(Os_uint32, AUTOMATIC, OS_APPL_CONST) Address, P2VAR(Os_uint32, AUTOMATIC, OS_APPL_DATA) ReadValue ) { #if(OS_PERIPHERAL_AREA_NUMBER > 0) CoreIdType currentCoreID; #if(OS_APPLICATION_NUMBER > 0) ApplicationType tempAppId; #endif /* (OS_APPLICATION_NUMBER > 0) */ currentCoreID = OsCpu_GetCoreID(); if ((currentCoreID >= (CoreIdType)OS_USED_CORE_NUMBER) || (Os_CoreState[currentCoreID] != \ OS_CORE_START)) { /* can not record err in this state, as OS services can not be called */ return E_OS_CORE; } if (OS_NO_API_USED != Os_IntAPIUsedFlag[currentCoreID]) { /* SWS_Os_00093 System error -- this API is called between interrupt processing function pairs */ OsHook_ReportError(currentCoreID, E_OS_DISABLEDINT, OSServiceId_ReadPeripheral32, \ OS_IE_NOMORE_INFO, (Os_uint32)Area, (Os_uint32)Os_IntAPIUsedFlag[currentCoreID], \ OS_IE_NO_ERRPAR); return E_OS_DISABLEDINT; } if ((OS_NULL == Address) || (OS_NULL == ReadValue)) { OsHook_ReportError(currentCoreID, E_OS_PARAM_POINTER, OSServiceId_ReadPeripheral32, \ OS_IE_NOMORE_INFO, (Os_uint32)Area, (Os_uint32)Address, (Os_uint32)ReadValue); return E_OS_PARAM_POINTER; } #if(OS_STATUS_LEVEL == OS_EXTENDED) if (Area >= (AreaIdType)OS_PERIPHERAL_AREA_NUMBER) { OsHook_ReportError(currentCoreID, E_OS_ID, OSServiceId_ReadPeripheral32, \ OS_IE_PERIPHERAL_AREA_ID, (Os_uint32)Area, (Os_uint32)Address, OS_IE_NO_ERRPAR); return E_OS_ID; } if ((Os_PeripheralAreaCfg[Area].startAddress > (Os_AddrType)Address) \ || (Os_PeripheralAreaCfg[Area].endAddress - (Os_AddrType)3 < (Os_AddrType)Address)) { OsHook_ReportError(currentCoreID, E_OS_VALUE, OSServiceId_ReadPeripheral32, \ OS_IE_PERIPHERAL_AREA_ADDRESS, (Os_uint32)Area, (Os_uint32)Address, OS_IE_NO_ERRPAR); return E_OS_VALUE; } if ((Os_uint16)(Os_CurrentContext[currentCoreID] & Os_ReadPeripheral32Mask) == (Os_uint16)0) { OsHook_ReportError(currentCoreID, E_OS_CALLEVEL, OSServiceId_ReadPeripheral32, \ OS_IE_NOMORE_INFO, (Os_uint32)Area, (Os_uint32)Os_CurrentContext[currentCoreID], \ OS_IE_NO_ERRPAR); return E_OS_CALLEVEL; } #endif /* (OS_STATUS_LEVEL == OS_EXTENDED) */ #if(OS_APPLICATION_NUMBER > 0) #if(OS_TRUSTED_FUNCTION_NUMBER > 0) if (Os_TrustFunApplicationId[currentCoreID] != OS_INVALID_OSAPPLICATION) { tempAppId = Os_TrustFunApplicationId[currentCoreID]; } else #endif /* (OS_TRUSTED_FUNCTION_NUMBER > 0) */ { tempAppId = Os_CurrentApplicationId[currentCoreID]; } if ((Os_ApplicationMaskType)0 == ((((Os_ApplicationMaskType)1) << tempAppId) \ & (Os_PeripheralAreaCfg[Area].appMask))) { OsHook_ReportError (currentCoreID, E_OS_ACCESS, OSServiceId_ReadPeripheral32, \ OS_IE_NO_ACCESS_RIGHT, (Os_uint32)Area, (Os_uint32)tempAppId, OS_IE_NO_ERRPAR); return E_OS_ACCESS; } if (OS_FALSE == OsApp_CheckingWriteable(currentCoreID, (Os_AddrType)ReadValue, \ sizeof(Os_uint32))) { OsHook_ReportError(currentCoreID, E_OS_ILLEGAL_ADDRESS, OSServiceId_ReadPeripheral32, \ OS_IE_NOMORE_INFO, (Os_uint32)ReadValue, OS_IE_NO_ERRPAR, OS_IE_NO_ERRPAR); return E_OS_ILLEGAL_ADDRESS; } #endif /* (OS_APPLICATION_NUMBER > 0) */ #endif /* OS_PERIPHERAL_AREA_NUMBER > 0 */ *ReadValue = OsCpu_ReadIo32(Address); return E_OS_OK; } /* BEGIN_FUNCTION_HDR **************************************************************************************************** * Function Name: Os_WritePeripheral8 SWS_Os_91010 * * Description: This service writes the to a given memory location (). * * Inputs: hardware peripheral area reference *
memory address * * Outputs: value to be written at the memory address * * Limitations: None **************************************************************************************************** END_FUNCTION_HDR*/ FUNC(StatusType, OS_CODE) Os_WritePeripheral8 ( AreaIdType Area, P2VAR(Os_uint8, AUTOMATIC, OS_APPL_DATA) Address, Os_uint8 WriteValue ) { #if(OS_PERIPHERAL_AREA_NUMBER > 0) CoreIdType currentCoreID; #if(OS_APPLICATION_NUMBER > 0) ApplicationType tempAppId; #endif /* (OS_APPLICATION_NUMBER > 0) */ currentCoreID = OsCpu_GetCoreID(); if ((currentCoreID >= (CoreIdType)OS_USED_CORE_NUMBER) || (Os_CoreState[currentCoreID] != \ OS_CORE_START)) { /* can not record err in this state, as OS services can not be called */ return E_OS_CORE; } if (OS_NO_API_USED != Os_IntAPIUsedFlag[currentCoreID]) { /* SWS_Os_00093 System error -- this API is called between interrupt processing function pairs */ OsHook_ReportError(currentCoreID, E_OS_DISABLEDINT, OSServiceId_WritePeripheral8, \ OS_IE_NOMORE_INFO, (Os_uint32)Area, (Os_uint32)Os_IntAPIUsedFlag[currentCoreID], \ OS_IE_NO_ERRPAR); return E_OS_DISABLEDINT; } if (OS_NULL == Address) { OsHook_ReportError(currentCoreID, E_OS_PARAM_POINTER, OSServiceId_WritePeripheral8, \ OS_IE_NOMORE_INFO, (Os_uint32)Area, (Os_uint32)Address, (Os_uint32)WriteValue); return E_OS_PARAM_POINTER; } #if(OS_STATUS_LEVEL == OS_EXTENDED) if (Area >= (AreaIdType)OS_PERIPHERAL_AREA_NUMBER) { OsHook_ReportError(currentCoreID, E_OS_ID, OSServiceId_WritePeripheral8, \ OS_IE_PERIPHERAL_AREA_ID, (Os_uint32)Area, (Os_uint32)Address, OS_IE_NO_ERRPAR); return E_OS_ID; } if ((Os_PeripheralAreaCfg[Area].startAddress > (Os_AddrType)Address) || \ (Os_PeripheralAreaCfg[Area].endAddress < (Os_AddrType)Address)) { OsHook_ReportError(currentCoreID, E_OS_VALUE, OSServiceId_WritePeripheral8, \ OS_IE_PERIPHERAL_AREA_ADDRESS, (Os_uint32)Area, (Os_uint32)Address, OS_IE_NO_ERRPAR); return E_OS_VALUE; } if ((Os_uint16)(Os_CurrentContext[currentCoreID] & Os_WritePeripheral8Mask) == (Os_uint16)0) { OsHook_ReportError(currentCoreID, E_OS_CALLEVEL, OSServiceId_WritePeripheral8, \ OS_IE_NOMORE_INFO, (Os_uint32)Area, (Os_uint32)Os_CurrentContext[currentCoreID], \ OS_IE_NO_ERRPAR); return E_OS_CALLEVEL; } #endif /* (OS_STATUS_LEVEL == OS_EXTENDED) */ #if(OS_APPLICATION_NUMBER > 0) #if(OS_TRUSTED_FUNCTION_NUMBER > 0) if (Os_TrustFunApplicationId[currentCoreID] != OS_INVALID_OSAPPLICATION) { tempAppId = Os_TrustFunApplicationId[currentCoreID]; } else #endif /* (OS_TRUSTED_FUNCTION_NUMBER > 0) */ { tempAppId = Os_CurrentApplicationId[currentCoreID]; } if ((Os_ApplicationMaskType)0 == ((((Os_ApplicationMaskType)1) << tempAppId) \ & (Os_PeripheralAreaCfg[Area].appMask))) { OsHook_ReportError (currentCoreID, E_OS_ACCESS, OSServiceId_WritePeripheral8, \ OS_IE_NO_ACCESS_RIGHT, (Os_uint32)Area, (Os_uint32)tempAppId, OS_IE_NO_ERRPAR); return E_OS_ACCESS; } #endif /* (OS_APPLICATION_NUMBER > 0) */ #endif /* OS_PERIPHERAL_AREA_NUMBER > 0 */ OsCpu_WriteIo8(Address, WriteValue); return E_OS_OK; } /* BEGIN_FUNCTION_HDR **************************************************************************************************** * Function Name: Os_WritePeripheral16 SWS_Os_91012 * * Description: This service writes the to a given memory location (). * * Inputs: hardware peripheral area reference *
memory address * * Outputs: value to be written at the memory address * * Limitations: None **************************************************************************************************** END_FUNCTION_HDR*/ FUNC(StatusType, OS_CODE) Os_WritePeripheral16 ( AreaIdType Area, P2VAR(Os_uint16, AUTOMATIC, OS_APPL_DATA) Address, Os_uint16 WriteValue ) { #if(OS_PERIPHERAL_AREA_NUMBER > 0) CoreIdType currentCoreID; #if(OS_APPLICATION_NUMBER > 0) ApplicationType tempAppId; #endif /* (OS_APPLICATION_NUMBER > 0) */ currentCoreID = OsCpu_GetCoreID(); if ((currentCoreID >= (CoreIdType)OS_USED_CORE_NUMBER) || (Os_CoreState[currentCoreID] != \ OS_CORE_START)) { /* can not record err in this state, as OS services can not be called */ return E_OS_CORE; } if (OS_NO_API_USED != Os_IntAPIUsedFlag[currentCoreID]) { /* SWS_Os_00093 System error -- this API is called between interrupt processing function pairs */ OsHook_ReportError(currentCoreID, E_OS_DISABLEDINT, OSServiceId_WritePeripheral16, \ OS_IE_NOMORE_INFO, (Os_uint32)Area, (Os_uint32)Os_IntAPIUsedFlag[currentCoreID], \ OS_IE_NO_ERRPAR); return E_OS_DISABLEDINT; } if (OS_NULL == Address) { OsHook_ReportError(currentCoreID, E_OS_PARAM_POINTER, OSServiceId_WritePeripheral16, \ OS_IE_NOMORE_INFO, (Os_uint32)Area, (Os_uint32)Address, (Os_uint32)WriteValue); return E_OS_PARAM_POINTER; } #if(OS_STATUS_LEVEL == OS_EXTENDED) if (Area >= (AreaIdType)OS_PERIPHERAL_AREA_NUMBER) { OsHook_ReportError(currentCoreID, E_OS_ID, OSServiceId_WritePeripheral16, \ OS_IE_PERIPHERAL_AREA_ID, (Os_uint32)Area, (Os_uint32)Address, OS_IE_NO_ERRPAR); return E_OS_ID; } if ((Os_PeripheralAreaCfg[Area].startAddress > (Os_AddrType)Address) || \ (Os_PeripheralAreaCfg[Area].endAddress <= (Os_AddrType)Address)) { OsHook_ReportError(currentCoreID, E_OS_VALUE, OSServiceId_WritePeripheral16, \ OS_IE_PERIPHERAL_AREA_ADDRESS, (Os_uint32)Area, (Os_uint32)Address, OS_IE_NO_ERRPAR); return E_OS_VALUE; } if ((Os_uint16)(Os_CurrentContext[currentCoreID] & Os_WritePeripheral16Mask) == (Os_uint16)0) { OsHook_ReportError(currentCoreID, E_OS_CALLEVEL, OSServiceId_WritePeripheral16, \ OS_IE_NOMORE_INFO, (Os_uint32)Area, (Os_uint32)Os_CurrentContext[currentCoreID], \ OS_IE_NO_ERRPAR); return E_OS_CALLEVEL; } #endif /* (OS_STATUS_LEVEL == OS_EXTENDED) */ #if(OS_APPLICATION_NUMBER > 0) #if(OS_TRUSTED_FUNCTION_NUMBER > 0) if (Os_TrustFunApplicationId[currentCoreID] != OS_INVALID_OSAPPLICATION) { tempAppId = Os_TrustFunApplicationId[currentCoreID]; } else #endif /* (OS_TRUSTED_FUNCTION_NUMBER > 0) */ { tempAppId = Os_CurrentApplicationId[currentCoreID]; } if ((Os_ApplicationMaskType)0 == ((((Os_ApplicationMaskType)1) << tempAppId) \ & (Os_PeripheralAreaCfg[Area].appMask))) { OsHook_ReportError (currentCoreID, E_OS_ACCESS, OSServiceId_WritePeripheral16, \ OS_IE_NO_ACCESS_RIGHT, (Os_uint32)Area, (Os_uint32)tempAppId, OS_IE_NO_ERRPAR); return E_OS_ACCESS; } #endif /* (OS_APPLICATION_NUMBER > 0) */ #endif /* OS_PERIPHERAL_AREA_NUMBER > 0 */ OsCpu_WriteIo16(Address, WriteValue); return E_OS_OK; } /* BEGIN_FUNCTION_HDR **************************************************************************************************** * Function Name: Os_WritePeripheral32 SWS_Os_91011 * * Description: This service writes the to a given memory location (). * * Inputs: hardware peripheral area reference *
memory address * * Outputs: value to be written at the memory address * * Limitations: None **************************************************************************************************** END_FUNCTION_HDR*/ FUNC(StatusType, OS_CODE) Os_WritePeripheral32 ( AreaIdType Area, P2VAR(Os_uint32, AUTOMATIC, OS_APPL_DATA) Address, Os_uint32 WriteValue ) { #if(OS_PERIPHERAL_AREA_NUMBER > 0) CoreIdType currentCoreID; #if(OS_APPLICATION_NUMBER > 0) ApplicationType tempAppId; #endif /* (OS_APPLICATION_NUMBER > 0) */ currentCoreID = OsCpu_GetCoreID(); if ((currentCoreID >= (CoreIdType)OS_USED_CORE_NUMBER) || (Os_CoreState[currentCoreID] != \ OS_CORE_START)) { /* can not record err in this state, as OS services can not be called */ return E_OS_CORE; } if (OS_NO_API_USED != Os_IntAPIUsedFlag[currentCoreID]) { /* SWS_Os_00093 System error -- this API is called between interrupt processing function pairs */ OsHook_ReportError(currentCoreID, E_OS_DISABLEDINT, OSServiceId_WritePeripheral32, \ OS_IE_NOMORE_INFO, (Os_uint32)Area, (Os_uint32)Os_IntAPIUsedFlag[currentCoreID], \ OS_IE_NO_ERRPAR); return E_OS_DISABLEDINT; } if (OS_NULL == Address) { OsHook_ReportError(currentCoreID, E_OS_PARAM_POINTER, OSServiceId_WritePeripheral32, \ OS_IE_NOMORE_INFO, (Os_uint32)Area, (Os_uint32)Address, (Os_uint32)WriteValue); return E_OS_PARAM_POINTER; } #if(OS_STATUS_LEVEL == OS_EXTENDED) if (Area >= (AreaIdType)OS_PERIPHERAL_AREA_NUMBER) { OsHook_ReportError(currentCoreID, E_OS_ID, OSServiceId_WritePeripheral32, \ OS_IE_PERIPHERAL_AREA_ID, (Os_uint32)Area, (Os_uint32)Address, OS_IE_NO_ERRPAR); return E_OS_ID; } if ((Os_PeripheralAreaCfg[Area].startAddress > (Os_AddrType)Address) || \ (Os_PeripheralAreaCfg[Area].endAddress - (Os_AddrType)3 < (Os_AddrType)Address)) { OsHook_ReportError(currentCoreID, E_OS_VALUE, OSServiceId_WritePeripheral32, \ OS_IE_PERIPHERAL_AREA_ADDRESS, (Os_uint32)Area, (Os_uint32)Address, OS_IE_NO_ERRPAR); return E_OS_VALUE; } if ((Os_uint16)(Os_CurrentContext[currentCoreID] & Os_WritePeripheral32Mask) == (Os_uint16)0) { OsHook_ReportError(currentCoreID, E_OS_CALLEVEL, OSServiceId_WritePeripheral32, \ OS_IE_NOMORE_INFO, (Os_uint32)Area, (Os_uint32)Os_CurrentContext[currentCoreID], \ OS_IE_NO_ERRPAR); return E_OS_CALLEVEL; } #endif /* (OS_STATUS_LEVEL == OS_EXTENDED) */ #if(OS_APPLICATION_NUMBER > 0) #if(OS_TRUSTED_FUNCTION_NUMBER > 0) if (Os_TrustFunApplicationId[currentCoreID] != OS_INVALID_OSAPPLICATION) { tempAppId = Os_TrustFunApplicationId[currentCoreID]; } else #endif /* (OS_TRUSTED_FUNCTION_NUMBER > 0) */ { tempAppId = Os_CurrentApplicationId[currentCoreID]; } if ((Os_ApplicationMaskType)0 == ((((Os_ApplicationMaskType)1) << tempAppId) \ & (Os_PeripheralAreaCfg[Area].appMask))) { OsHook_ReportError (currentCoreID, E_OS_ACCESS, OSServiceId_WritePeripheral32, \ OS_IE_NO_ACCESS_RIGHT, (Os_uint32)Area, (Os_uint32)tempAppId, OS_IE_NO_ERRPAR); return E_OS_ACCESS; } #endif /* (OS_APPLICATION_NUMBER > 0) */ #endif /* OS_PERIPHERAL_AREA_NUMBER > 0 */ OsCpu_WriteIo32(Address, WriteValue); return E_OS_OK; } /* BEGIN_FUNCTION_HDR **************************************************************************************************** * Function Name: Os_ModifyPeripheral8 SWS_Os_91016 * * Description: This service modifies a given memory location () * with the formula: * *
= ((*
& ) | ) * * Inputs: hardware peripheral area reference *
memory address * The bits caller wants to clear are 0b0, others are 0b1 * The bits caller wants to set are 0b1, others are 0b0 * * Outputs: None * * Limitations: None **************************************************************************************************** END_FUNCTION_HDR*/ FUNC(StatusType, OS_CODE) Os_ModifyPeripheral8 ( AreaIdType Area, P2VAR(Os_uint8, AUTOMATIC, OS_APPL_DATA) Address, Os_uint8 ClearMask, Os_uint8 SetMask ) { #if(OS_PERIPHERAL_AREA_NUMBER > 0) CoreIdType currentCoreID; #if(OS_APPLICATION_NUMBER > 0) ApplicationType tempAppId; #endif /* (OS_APPLICATION_NUMBER > 0) */ currentCoreID = OsCpu_GetCoreID(); if ((currentCoreID >= (CoreIdType)OS_USED_CORE_NUMBER) || (Os_CoreState[currentCoreID] != \ OS_CORE_START)) { /* can not record err in this state, as OS services can not be called */ return E_OS_CORE; } if (OS_NO_API_USED != Os_IntAPIUsedFlag[currentCoreID]) { /* SWS_Os_00093 System error -- this API is called between interrupt processing function pairs */ OsHook_ReportError(currentCoreID, E_OS_DISABLEDINT, OSServiceId_ModifyPeripheral8, \ OS_IE_NOMORE_INFO, (Os_uint32)Area, (Os_uint32)Os_IntAPIUsedFlag[currentCoreID], \ OS_IE_NO_ERRPAR); return E_OS_DISABLEDINT; } if (OS_NULL == Address) { OsHook_ReportError(currentCoreID, E_OS_PARAM_POINTER, OSServiceId_ModifyPeripheral8, \ OS_IE_NOMORE_INFO, (Os_uint32)Area, (Os_uint32)Address, OS_IE_NO_ERRPAR); return E_OS_PARAM_POINTER; } #if(OS_STATUS_LEVEL == OS_EXTENDED) if (Area >= (AreaIdType)OS_PERIPHERAL_AREA_NUMBER) { OsHook_ReportError(currentCoreID, E_OS_ID, OSServiceId_ModifyPeripheral8, \ OS_IE_PERIPHERAL_AREA_ID, (Os_uint32)Area, (Os_uint32)Address, OS_IE_NO_ERRPAR); return E_OS_ID; } if ((Os_PeripheralAreaCfg[Area].startAddress > (Os_AddrType)Address) || \ (Os_PeripheralAreaCfg[Area].endAddress < (Os_AddrType)Address)) { OsHook_ReportError(currentCoreID, E_OS_VALUE, OSServiceId_ModifyPeripheral8, \ OS_IE_PERIPHERAL_AREA_ADDRESS, (Os_uint32)Area, (Os_uint32)Address, OS_IE_NO_ERRPAR); return E_OS_VALUE; } if ((Os_uint16)(Os_CurrentContext[currentCoreID] & Os_ModifyPeripheral8Mask) == (Os_uint16)0) { OsHook_ReportError(currentCoreID, E_OS_CALLEVEL, OSServiceId_ModifyPeripheral8, \ OS_IE_NOMORE_INFO, (Os_uint32)Area, (Os_uint32)Os_CurrentContext[currentCoreID], \ OS_IE_NO_ERRPAR); return E_OS_CALLEVEL; } #endif /* (OS_STATUS_LEVEL == OS_EXTENDED) */ #if(OS_APPLICATION_NUMBER > 0) #if(OS_TRUSTED_FUNCTION_NUMBER > 0) if (Os_TrustFunApplicationId[currentCoreID] != OS_INVALID_OSAPPLICATION) { tempAppId = Os_TrustFunApplicationId[currentCoreID]; } else #endif /* (OS_TRUSTED_FUNCTION_NUMBER > 0) */ { tempAppId = Os_CurrentApplicationId[currentCoreID]; } if ((Os_ApplicationMaskType)0 == ((((Os_ApplicationMaskType)1) << tempAppId) \ & (Os_PeripheralAreaCfg[Area].appMask))) { OsHook_ReportError (currentCoreID, E_OS_ACCESS, OSServiceId_ModifyPeripheral8, \ OS_IE_NO_ACCESS_RIGHT, (Os_uint32)Area, (Os_uint32)tempAppId, OS_IE_NO_ERRPAR); return E_OS_ACCESS; } #endif /* (OS_APPLICATION_NUMBER > 0) */ #endif /* OS_PERIPHERAL_AREA_NUMBER > 0 */ OsCpu_RmwIo8(Address, ClearMask, SetMask); return E_OS_OK; } /* BEGIN_FUNCTION_HDR **************************************************************************************************** * Function Name: Os_ModifyPeripheral16 SWS_Os_91018 * * Description: This service modifies a given memory location () * with the formula: * *
= ((*
& ) | ) * * Inputs: hardware peripheral area reference *
memory address * The bits caller wants to clear are 0b0, others are 0b1 * The bits caller wants to set are 0b1, others are 0b0 * * Outputs: None * * Limitations: None **************************************************************************************************** END_FUNCTION_HDR*/ FUNC(StatusType, OS_CODE) Os_ModifyPeripheral16 ( AreaIdType Area, P2VAR(Os_uint16, AUTOMATIC, OS_APPL_DATA) Address, Os_uint16 ClearMask, Os_uint16 SetMask ) { #if(OS_PERIPHERAL_AREA_NUMBER > 0) CoreIdType currentCoreID; #if(OS_APPLICATION_NUMBER > 0) ApplicationType tempAppId; #endif /* (OS_APPLICATION_NUMBER > 0) */ currentCoreID = OsCpu_GetCoreID(); if ((currentCoreID >= (CoreIdType)OS_USED_CORE_NUMBER) || (Os_CoreState[currentCoreID] != \ OS_CORE_START)) { /* can not record err in this state, as OS services can not be called */ return E_OS_CORE; } if (OS_NO_API_USED != Os_IntAPIUsedFlag[currentCoreID]) { /* SWS_Os_00093 System error -- this API is called between interrupt processing function pairs */ OsHook_ReportError(currentCoreID, E_OS_DISABLEDINT, OSServiceId_ModifyPeripheral16, \ OS_IE_NOMORE_INFO, (Os_uint32)Area, (Os_uint32)Os_IntAPIUsedFlag[currentCoreID], \ OS_IE_NO_ERRPAR); return E_OS_DISABLEDINT; } if (OS_NULL == Address) { OsHook_ReportError(currentCoreID, E_OS_PARAM_POINTER, OSServiceId_ModifyPeripheral16, \ OS_IE_NOMORE_INFO, (Os_uint32)Area, (Os_uint32)Address, OS_IE_NO_ERRPAR); return E_OS_PARAM_POINTER; } #if(OS_STATUS_LEVEL == OS_EXTENDED) if (Area >= (AreaIdType)OS_PERIPHERAL_AREA_NUMBER) { OsHook_ReportError(currentCoreID, E_OS_ID, OSServiceId_ModifyPeripheral16, \ OS_IE_PERIPHERAL_AREA_ID, (Os_uint32)Area, (Os_uint32)Address, OS_IE_NO_ERRPAR); return E_OS_ID; } if ((Os_PeripheralAreaCfg[Area].startAddress > (Os_AddrType)Address) || \ (Os_PeripheralAreaCfg[Area].endAddress <= (Os_AddrType)Address)) { OsHook_ReportError(currentCoreID, E_OS_VALUE, OSServiceId_ModifyPeripheral16, \ OS_IE_PERIPHERAL_AREA_ADDRESS, (Os_uint32)Area, (Os_uint32)Address, OS_IE_NO_ERRPAR); return E_OS_VALUE; } if ((Os_uint16)(Os_CurrentContext[currentCoreID] & Os_ModifyPeripheral16Mask) == (Os_uint16)0) { OsHook_ReportError(currentCoreID, E_OS_CALLEVEL, OSServiceId_ModifyPeripheral16, \ OS_IE_NOMORE_INFO, (Os_uint32)Area, (Os_uint32)Os_CurrentContext[currentCoreID], \ OS_IE_NO_ERRPAR); return E_OS_CALLEVEL; } #endif /* (OS_STATUS_LEVEL == OS_EXTENDED) */ #if(OS_APPLICATION_NUMBER > 0) #if(OS_TRUSTED_FUNCTION_NUMBER > 0) if (Os_TrustFunApplicationId[currentCoreID] != OS_INVALID_OSAPPLICATION) { tempAppId = Os_TrustFunApplicationId[currentCoreID]; } else #endif /* (OS_TRUSTED_FUNCTION_NUMBER > 0) */ { tempAppId = Os_CurrentApplicationId[currentCoreID]; } if ((Os_ApplicationMaskType)0 == ((((Os_ApplicationMaskType)1) << tempAppId) \ & (Os_PeripheralAreaCfg[Area].appMask))) { OsHook_ReportError (currentCoreID, E_OS_ACCESS, OSServiceId_ModifyPeripheral16, \ OS_IE_NO_ACCESS_RIGHT, (Os_uint32)Area, (Os_uint32)tempAppId, OS_IE_NO_ERRPAR); return E_OS_ACCESS; } #endif /* (OS_APPLICATION_NUMBER > 0) */ #endif /* OS_PERIPHERAL_AREA_NUMBER > 0 */ OsCpu_RmwIo16(Address, ClearMask, SetMask); return E_OS_OK; } /* BEGIN_FUNCTION_HDR **************************************************************************************************** * Function Name: Os_ModifyPeripheral32 SWS_Os_91017 * * Description: This service modifies a given memory location () * with the formula: * *
= ((*
& ) | ) * * Inputs: hardware peripheral area reference *
memory address * The bits caller wants to clear are 0b0, others are 0b1 * The bits caller wants to set are 0b1, others are 0b0 * * Outputs: None * * Limitations: None **************************************************************************************************** END_FUNCTION_HDR*/ FUNC(StatusType, OS_CODE) Os_ModifyPeripheral32 ( AreaIdType Area, P2VAR(Os_uint32, AUTOMATIC, OS_APPL_DATA) Address, Os_uint32 ClearMask, Os_uint32 SetMask ) { #if(OS_PERIPHERAL_AREA_NUMBER > 0) CoreIdType currentCoreID; #if(OS_APPLICATION_NUMBER > 0) ApplicationType tempAppId; #endif /* (OS_APPLICATION_NUMBER > 0) */ currentCoreID = OsCpu_GetCoreID(); if ((currentCoreID >= (CoreIdType)OS_USED_CORE_NUMBER) || (Os_CoreState[currentCoreID] != \ OS_CORE_START)) { /* can not record err in this state, as OS services can not be called */ return E_OS_CORE; } if (OS_NO_API_USED != Os_IntAPIUsedFlag[currentCoreID]) { /* SWS_Os_00093 System error -- this API is called between interrupt processing function pairs */ OsHook_ReportError(currentCoreID, E_OS_DISABLEDINT, OSServiceId_ModifyPeripheral32, \ OS_IE_NOMORE_INFO, (Os_uint32)Area, (Os_uint32)Os_IntAPIUsedFlag[currentCoreID], \ OS_IE_NO_ERRPAR); return E_OS_DISABLEDINT; } if (OS_NULL == Address) { OsHook_ReportError(currentCoreID, E_OS_PARAM_POINTER, OSServiceId_ModifyPeripheral32, \ OS_IE_NOMORE_INFO, (Os_uint32)Area, (Os_uint32)Address, OS_IE_NO_ERRPAR); return E_OS_PARAM_POINTER; } #if(OS_STATUS_LEVEL == OS_EXTENDED) if (Area >= (AreaIdType)OS_PERIPHERAL_AREA_NUMBER) { OsHook_ReportError(currentCoreID, E_OS_ID, OSServiceId_ModifyPeripheral32, \ OS_IE_PERIPHERAL_AREA_ID, (Os_uint32)Area, (Os_uint32)Address, OS_IE_NO_ERRPAR); return E_OS_ID; } if ((Os_PeripheralAreaCfg[Area].startAddress > (Os_AddrType)Address) || \ (Os_PeripheralAreaCfg[Area].endAddress - (Os_AddrType)3 < (Os_AddrType)Address)) { OsHook_ReportError(currentCoreID, E_OS_VALUE, OSServiceId_ModifyPeripheral32, \ OS_IE_PERIPHERAL_AREA_ADDRESS, (Os_uint32)Area, (Os_uint32)Address, OS_IE_NO_ERRPAR); return E_OS_VALUE; } if ((Os_uint16)(Os_CurrentContext[currentCoreID] & Os_ModifyPeripheral32Mask) == (Os_uint16)0) { OsHook_ReportError(currentCoreID, E_OS_CALLEVEL, OSServiceId_ModifyPeripheral32, \ OS_IE_NOMORE_INFO, (Os_uint32)Area, (Os_uint32)Os_CurrentContext[currentCoreID], \ OS_IE_NO_ERRPAR); return E_OS_CALLEVEL; } #endif /* (OS_STATUS_LEVEL == OS_EXTENDED) */ #if(OS_APPLICATION_NUMBER > 0) #if(OS_TRUSTED_FUNCTION_NUMBER > 0) if (Os_TrustFunApplicationId[currentCoreID] != OS_INVALID_OSAPPLICATION) { tempAppId = Os_TrustFunApplicationId[currentCoreID]; } else #endif /* (OS_TRUSTED_FUNCTION_NUMBER > 0) */ { tempAppId = Os_CurrentApplicationId[currentCoreID]; } if ((Os_ApplicationMaskType)0 == ((((Os_ApplicationMaskType)1) << tempAppId) \ & (Os_PeripheralAreaCfg[Area].appMask))) { OsHook_ReportError (currentCoreID, E_OS_ACCESS, OSServiceId_ModifyPeripheral32, \ OS_IE_NO_ACCESS_RIGHT, (Os_uint32)Area, (Os_uint32)tempAppId, OS_IE_NO_ERRPAR); return E_OS_ACCESS; } #endif /* (OS_APPLICATION_NUMBER > 0) */ #endif /* OS_PERIPHERAL_AREA_NUMBER > 0 */ OsCpu_RmwIo32(Address, ClearMask, SetMask); return E_OS_OK; }