repo_name
stringlengths 6
97
| path
stringlengths 3
341
| text
stringlengths 8
1.02M
|
---|---|---|
edward-jones/riscv-fw-infrastructure | WD-Firmware/psp/api_inc/psp_timers.h | /*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2020-2021 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file psp_timers.h
* @author <NAME>
* @date 28.01.2020
* @brief The file defines core's Machine timer-counter api services.
*
*/
#ifndef __PSP_TIMERS_H__
#define __PSP_TIMERS_H__
/**
* include files
*/
/**
* definitions
*/
/**
* types
*/
/**
* local prototypes
*/
/**
* external prototypes
*/
/**
* global variables
*/
/**
* macros
*/
/**
* APIs
*/
/**
* @brief Setup and activate core Machine Timer
*
*
* @param - udPeriodCycles - defines the timer's period in cycles
*
*/
void pspMachineTimerCounterSetupAndRun(u64_t udPeriodCycles);
/**
* @brief Get Machine Timer counter value
*
*
* @return u64_t - Timer counter value
*
*/
u64_t pspMachineTimerCounterGet(void);
/**
* @brief Get Machine Time compare counter value
*
*
* @return u64_t – Time compare counter value
*
*/
u64_t pspMachineTimerCompareCounterGet(void);
#endif /* __PSP_TIMERS_H__*/
|
edward-jones/riscv-fw-infrastructure | WD-Firmware/psp/api_inc/psp_memory_utils.h | <filename>WD-Firmware/psp/api_inc/psp_memory_utils.h<gh_stars>10-100
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2020 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file psp_memory_utils.h
* @author <NAME>
* @date 24.06.2020
* @brief Memory utilities for PSP usage
*
*/
#ifndef __PSP_MEMORY_UTILS_H__
#define __PSP_MEMORY_UTILS_H__
/**
* include files
*/
/**
* definitions
*/
/**
* types
*/
/**
* local prototypes
*/
/**
* external prototypes
*/
/**
* macros
*/
/**
* global variables
*/
/**
* APIs
*/
/**
* @brief - PSP implementation of memset function - bytes setting
*
* @parameter - address of the memory to be set
* @parameter - pattern to set
* @parameter - number of bytes to set
*
* @return - address of the memory that has been set
*/
void* pspMemsetBytes(void* pMemory, s08_t siVal, u32_t uiSizeInBytes);
#endif /* __PSP_MEMORY_UTILS_H__ */
|
edward-jones/riscv-fw-infrastructure | WD-Firmware/psp/psp_corr_err_cnt_eh2.c | <filename>WD-Firmware/psp/psp_corr_err_cnt_eh2.c
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2020-2021 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file psp_corr_err_cnt_eh2.c
* @author <NAME>
* @date 05.07.2020
* @brief The file contains interface for correctable-error counters in eh2
*/
/**
* include files
*/
#include "psp_api.h"
#include "psp_internal_mutex_eh2.h"
/**
* types
*/
/**
* definitions
*/
#define D_PSP_CORR_ERR_MAX_THRESHOLD 26
/**
* local prototypes
*/
/**
* external prototypes
*/
/**
* macros
*/
/**
* global variables
*/
/**
* APIs
*/
/**
* @brief Set Thershold for a counter of specific correctable-error
*
* @param - eCorrectableerrorCounter - one of E_ICACHE_CORR_ERR_COUNTER or E_ICCM_CORR_ERR_COUNTER or E_DCCM_CORR_ERR_COUNTER
* @param - uiThreshold - When set, an interrupt is raised when 2**uiThreshold errors occur
*
* ***Note*** 26 is the largest acceptable value. If a larger value is set, it is treated as 26.
*
* ***Note*** Pay attention to register your ISR for E_MACHINE_CORRECTABLE_ERROR_CAUSE interrupt
*
*/
D_PSP_TEXT_SECTION void pspMachineCorErrCntSetThreshold(ePspCorrectableErrorCounters_t eCounter, u32_t uiThreshold)
{
u32_t uiCsrValueToSet = 0 ;
/* Maximum number to set as threshold is 26 */
M_PSP_ASSERT(D_PSP_CORR_ERR_MAX_THRESHOLD >= uiThreshold);
/* As these CSRs are common to all harts, make sure that they will not be accessed simultaneously by more than single hart */
pspInternalMutexLock(E_MUTEX_INTERNAL_FOR_CORR_ERR_COUNTERS);
uiCsrValueToSet = (uiThreshold << D_PSP_CORR_ERR_THRESH_SHIFT);
/* Set the threshold in the relevant CSR */
switch (eCounter)
{
case E_ICACHE_CORR_ERR_COUNTER:
M_PSP_WRITE_CSR(D_PSP_MICECT_NUM, uiCsrValueToSet);
break;
case E_ICCM_CORR_ERR_COUNTER:
M_PSP_SET_CSR(D_PSP_MICCMECT_NUM, uiCsrValueToSet);
break;
case E_DCCM_CORR_ERR_COUNTER:
M_PSP_SET_CSR(D_PSP_MDCCMECT_NUM, uiCsrValueToSet);
break;
default:
break;
}
/* Remove the multi-harts access protection */
pspInternalMutexUnlock(E_MUTEX_INTERNAL_FOR_CORR_ERR_COUNTERS);
}
|
edward-jones/riscv-fw-infrastructure | WD-Firmware/cti/loc_inc/cti_utilities.h | <reponame>edward-jones/riscv-fw-infrastructure
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2020 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file cti_utilities.h
* @author <NAME>
* @date 01.07.2020
* @brief The file defines cti (comrv testing infrastructure) utils api
*/
#ifndef __CTI_UTILITIES_H
#define __CTI_UTILITIES_H
/**
* INCLUDES
*/
/**
* DEFINITIONS
*/
/**
* MACROS
*/
/**
* TYPEDEFS
*/
/**
* EXPORTED GLOBALS
*/
/**
* ENUM
*/
/**
* FUNCTIONS PROTOTYPES
*/
E_CTI_RESULT ctiSetErrorBit(S_FW_CB_PTR pCtiFrameWorkCB, E_TEST_ERROR eValue);
E_TEST_ERROR ctiGetErrorBits(S_FW_CB_PTR pCtiFrameWorkCB);
void ctiResetOvlGlobal();
#endif /* __CTI_UTILITIES_H */
|
edward-jones/riscv-fw-infrastructure | WD-Firmware/rtos/rtosal/api_inc/rtosal_macros.h | <filename>WD-Firmware/rtos/rtosal/api_inc/rtosal_macros.h
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2019 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file rtosal_macros.h
* @author <NAME>
* @date 07.02.2019
* @brief The file defines the RTOS AL macros
*/
#ifndef __RTOSAL_MACRO_H__
#define __RTOSAL_MACRO_H__
/**
* include files
*/
/**
* macros
*/
/* error checking macro */
#if (D_RTOSAL_ERROR_CHECK==1)
#define M_RTOSAL_VALIDATE_FUNC_PARAM(param, conditionMet, returnCode) \
if (conditionMet) \
{ \
fptrParamErrorNotification((const void*)(param), returnCode); \
return (returnCode); \
}
#else
#define M_RTOSAL_VALIDATE_FUNC_PARAM(param, conditionMet, returnCode)
#endif /* #if (D_RTOSAL_ERROR_CHECK==1) */
//TODO: update RTOSAL_SECTION to D_RTOSAL_SECTION
#define RTOSAL_SECTION __attribute__((section("RTOSAL_SEC")))
#endif /* __RTOSAL_MACRO_H__ */
|
edward-jones/riscv-fw-infrastructure | WD-Firmware/demo/demo_getchar.c | <filename>WD-Firmware/demo/demo_getchar.c
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2021 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file demo_getchar.c
* @author <NAME>
* @date 23.02.2021
* @brief This demo show getchar usage
*/
/**
* include files
*/
#include "common_types.h"
#include "demo_platform_al.h"
#include "demo_utils.h"
/**
* definitions
*/
#define D_MAX_STR_SIZE 64
/**
* macros
*/
/**
* types
*/
/**
* local prototypes
*/
/**
* external prototypes
*/
/**
* global variables
*/
/**
* functions
*/
void demoStart(void)
{
M_DEMO_START_PRINT();
#ifdef D_NONE_AUTOMATION
u08_t ucIdx=0;
u08_t ucStringArr[D_MAX_STR_SIZE] = {0};
printfNexys("please write any string following [enter]. limited characters=64. \n\r");
do
{
ucStringArr[ucIdx] = uartGetchar();
ucIdx++;
if (ucIdx == D_MAX_STR_SIZE)
{
printfNexys("Too many characters pressed -> terminating ");
return;
}
}while(ucStringArr[ucIdx-1] != 0x0D && ucStringArr[ucIdx-1] != 0x0a); //user press 'enter' or new LF
printfNexys("Echoing your input: %s",ucStringArr);
#endif
M_DEMO_END_PRINT();
}
|
edward-jones/riscv-fw-infrastructure | WD-Firmware/psp/psp_memory_utils.c | /*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2020 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file psp_utils.c
* @author <NAME>
* @date 24.06.2020
* @brief Utilities for PSP usage
*
*/
/**
* include files
*/
#include "psp_api.h"
/**
* types
*/
/**
* definitions
*/
/**
* local prototypes
*/
/**
* external prototypes
*/
/**
* macros
*/
/**
* global variables
*/
/**
* APIs
*/
/**
* @brief - PSP implementation of memset function - bytes setting
*
* @parameter - address of the memory to be set
* @parameter - pattern to set
* @parameter - number of bytes to set
*
* @return - address of the memory that has been set
*/
D_PSP_TEXT_SECTION void* pspMemsetBytes(void* pMemory, s08_t siVal, u32_t uiSizeInBytes)
{
u32_t uiIndex;
M_PSP_ASSERT(NULL != pMemory);
/* Loop on the memory and set it according the inputs */
for (uiIndex = 0 ; uiIndex < uiSizeInBytes ; uiIndex++)
{
*(u08_t*)(pMemory + uiIndex) = siVal;
}
return pMemory;
}
|
edward-jones/riscv-fw-infrastructure | WD-Firmware/cti/cti_groups_tests.c | <gh_stars>10-100
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2020-2021 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file cti_groups_tests.c
* @author <NAME>
* @date 01.07.2020
* @brief The file implements cti framework
*/
/************************************************************
* the overlay area is 4KB
* the overlay table occupied 2KB
* thus we have 2KB for our groups
***********************************************************/
/**
* include files
*/
#include "common_types.h"
#include "comrv_api.h"
#include "cti.h"
#include "psp_api.h"
#ifdef D_COMRV_RTOS_SUPPORT
#include "rtosal_event_api.h"
#endif /* D_COMRV_RTOS_SUPPORT */
/**
* macros
*/
#define M_CTI_DUMMY_FUNCTION(x) \
void _OVERLAY_ ctiTestFuncOverlay ## x ## Vect() \
{ \
M_CTI_10_NOPS \
M_CTI_10_NOPS \
M_CTI_10_NOPS \
}; \
/**
* definitions
*/
#define D_CTI_OVERLAY_TABLE_ENTRIES (3)
#define D_CTI_NUM_OF_LOOPS 13
#define D_CTI_SUM_OF_ARGS 6
#define D_CTI_DATA_OVL_ARR_SIZE 10
/* generate ovl dummy function to fill the ovelay area */
#define M_CTI_FUNCTIONS_GENERATOR \
M_CTI_DUMMY_FUNCTION(120) \
M_CTI_DUMMY_FUNCTION(121) \
M_CTI_DUMMY_FUNCTION(122) \
M_CTI_DUMMY_FUNCTION(123) \
M_CTI_DUMMY_FUNCTION(124) \
M_CTI_DUMMY_FUNCTION(125) \
M_CTI_DUMMY_FUNCTION(126) \
M_CTI_DUMMY_FUNCTION(127) \
M_CTI_DUMMY_FUNCTION(128) \
M_CTI_DUMMY_FUNCTION(129) \
M_CTI_DUMMY_FUNCTION(130) \
M_CTI_DUMMY_FUNCTION(131) \
M_CTI_DUMMY_FUNCTION(132) \
M_CTI_DUMMY_FUNCTION(133) \
M_CTI_DUMMY_FUNCTION(134) \
M_CTI_DUMMY_FUNCTION(135) \
M_CTI_DUMMY_FUNCTION(136) \
M_CTI_DUMMY_FUNCTION(137) \
M_CTI_DUMMY_FUNCTION(138) \
M_CTI_DUMMY_FUNCTION(139) \
M_CTI_DUMMY_FUNCTION(140) \
M_CTI_DUMMY_FUNCTION(141) \
M_CTI_DUMMY_FUNCTION(142) \
M_CTI_DUMMY_FUNCTION(143) \
M_CTI_DUMMY_FUNCTION(144) \
M_CTI_DUMMY_FUNCTION(145) \
M_CTI_DUMMY_FUNCTION(146) \
M_CTI_DUMMY_FUNCTION(147) \
M_CTI_DUMMY_FUNCTION(148) \
M_CTI_DUMMY_FUNCTION(149) \
M_CTI_DUMMY_FUNCTION(150) \
M_CTI_DUMMY_FUNCTION(151) \
M_CTI_DUMMY_FUNCTION(152) \
M_CTI_DUMMY_FUNCTION(153) \
M_CTI_DUMMY_FUNCTION(154) \
M_CTI_DUMMY_FUNCTION(155) \
M_CTI_DUMMY_FUNCTION(156) \
M_CTI_DUMMY_FUNCTION(157) \
M_CTI_DUMMY_FUNCTION(158) \
M_CTI_DUMMY_FUNCTION(159)
/**
* types
*/
/**
* local prototypes
*/
void ctiTaskBTest(void);
E_TEST_ERROR ctiOvlTestSanity(S_FW_CB_PTR pCtiFrameWorkCB);
E_TEST_ERROR ctiOvlTestCrcCheck(S_FW_CB_PTR pCtiFrameWorkCB);
E_TEST_ERROR ctiOvlTestMultigroup(S_FW_CB_PTR pCtiFrameWorkCB);
E_TEST_ERROR ctiOvlTestThreadSafe(S_FW_CB_PTR pCtiFrameWorkCB);
E_TEST_ERROR ctiOvlTestLockUnlock(S_FW_CB_PTR pCtiFrameWorkCB);
E_TEST_ERROR ctiOvlTestGroupingOvlt(S_FW_CB_PTR pCtiFrameWorkCB);
E_TEST_ERROR ctiOvlTestCriticalSection(S_FW_CB_PTR pCtiFrameWorkCB);
E_TEST_ERROR ctiOvlTestGroupWithSameSize(S_FW_CB_PTR pCtiFrameWorkCB);
E_TEST_ERROR ctiOvlTestResetEvictionCounters(S_FW_CB_PTR pCtiFrameWorkCB);
E_TEST_ERROR ctiOvlTestGroupWithDifferentSize(S_FW_CB_PTR pCtiFrameWorkCB);
E_TEST_ERROR ctiOvlTestDefragOverlayedFunctions(S_FW_CB_PTR pCtiFrameWorkCB);
/**
* external prototypes
*/
extern void demoComrvSetErrorHandler(void* fptrAddress);
/**
* global variables
*/
u32_t g_uiVar;
u32_t g_uiTempArr[256] = {0};
stCtiFuncsHitCounter g_stCtiOvlFuncsHitCounter;
void* G_pProgramCounterAddress;
#ifdef D_COMRV_RTOS_SUPPORT
extern rtosalEventGroup_t stRtosalEventGroupCb;
#ifdef D_COMRV_OVL_DATA_SUPPORT
_DATA_OVERLAY_ const u32_t uiSomeOverlayData[D_CTI_DATA_OVL_ARR_SIZE] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
#endif /* D_COMRV_OVL_DATA_SUPPORT */
#endif /* D_COMRV_RTOS_SUPPORT */
const ctiTestFunctionPtr g_pLookupTableCtiTestOvl[E_CB_TEST_OVL_MAX] =
{
ctiOvlTestSanity, /* E_CB_TEST_OVL_GROUP_SANITY */
ctiOvlTestGroupWithSameSize, /* E_CB_TEST_OVL_GROUP_WITH_SAME_SIZE */
ctiOvlTestGroupWithDifferentSize, /* E_CB_TEST_OVL_GROUP_WITH_DIFFERENT_SIZE */
ctiOvlTestMultigroup, /* E_CB_TEST_OVL_GROUP_MULTIGROUP */
ctiOvlTestLockUnlock, /* E_CB_TEST_OVL_GROUP_LOCK_UNLOCK */
ctiOvlTestDefragOverlayedFunctions, /* E_CB_TEST_OVL_GROUP_DEFRAG_OVERLAY_MEMORY */
ctiOvlTestGroupingOvlt, /* E_CB_TEST_OVL_GROUP_OVLA */
ctiOvlTestCrcCheck, /* E_CB_TEST_OVL_OVL_CRC_CHECK */
ctiOvlTestCriticalSection, /* E_CB_TEST_OVL_CRITICAL_SECTION */
ctiOvlTestThreadSafe, /* E_CB_TEST_OVL_THREAD_SAFE */
ctiOvlTestResetEvictionCounters, /* E_CB_TEST_OVL_RESET_EVICTION_COUNTERS */
};
/*
* the following groups contains the following functions:
*
*group 101:
* ctiTestFuncOverlay101Vect,
* ctiTestFuncOverlay105Vect
*
*group 102
* ctiTestFuncOverlay105Vect,
* ctiTestFuncOverlay102Vect,
* ctiTestFuncOverlay104Vect,
* ctiTestFuncOverlay107Vect
*
*group 103:
* ctiTestFuncOverlay103Vect
*
*group 104:
* ctiTestFuncOverlay106Vect
*
*group 105:
* ctiTestFuncOverlay108Vect
*
*group 106:
* ctiTestFuncOverlay109Vect not used in code
*
*group 107:
* ctiTestFuncOverlay110Vect
*
*group 108:
* ctiTestFuncOverlay111Vect
*
*group 109:
* ctiTestFuncOverlay112Vect
*/
/* define dummy functions to fill the overlay */
M_CTI_FUNCTIONS_GENERATOR
/**
* @brief error function pointer used by some tests
*
* @param errornum - error number
*
* @return errornum - error number
*/
u32_t ctiOvlUserSystemErrorVect(const comrvErrorArgs_t* pErrorArgs)
{
g_stCtiOvlFuncsHitCounter.uiErrorNum = pErrorArgs->uiErrorNum;
return pErrorArgs->uiErrorNum;
}
/**
* @brief sanity test: verify ovl groups are loaded when needed
*
* @param structure that holds 3 parameters
*
* @return error bit map
*/
E_TEST_ERROR ctiOvlTestSanity(S_FW_CB_PTR pCtiFrameWorkCB)
{
/* call FUNCTION in GROUP 101 - GROUP size 0x200 */
ctiTestFuncOverlay101Vect();
/* we expect 1 hits in file_syetem_read for the overlay function in GROUP 101 */
if (g_stCtiOvlFuncsHitCounter.uiComrvLoad != 1)
{
ctiSetErrorBit(pCtiFrameWorkCB, E_TEST_ERROR_OVL_FAILED);
}
else
{
/* call FUNCTION in GROUP 103 - GROUP size is 0x200 */
ctiTestFuncOverlay103Vect();
/* we expect 1 hits in file_syetem_read; none for the lookup table, one for the overlay function in GROUP 103 */
if (g_stCtiOvlFuncsHitCounter.uiComrvLoad != 2)
{
ctiSetErrorBit(pCtiFrameWorkCB, E_TEST_ERROR_OVL_SANITY_FAILED);
}
else
{
/* call FUNCTION in GROUP 102 - GROUP size 0x200 */
ctiTestFuncOverlay102Vect();
/* call function from GROUP 102 that calls another function from GROUP 102 - GROUP size 0x200 */
ctiTestFuncOverlay104Vect();
/* we expect 0 hits in file_syetem_read because the function supposed to be resident */
if (g_stCtiOvlFuncsHitCounter.uiComrvLoad != 3)
{
ctiSetErrorBit(pCtiFrameWorkCB, E_TEST_ERROR_OVL_SANITY_FAILED);
}
}
}
return ctiGetErrorBits(pCtiFrameWorkCB);
}
/**
* @brief Groups with the same size: verify ovl groups are loaded when
* needed while the groups with the same size
*
* @param structure that holds 3 parameters
*
* @return error bit map
*/
E_TEST_ERROR ctiOvlTestGroupWithSameSize(S_FW_CB_PTR pCtiFrameWorkCB)
{
/* call FUNCTION in GROUP 101 - GROUP size 0x200 */
ctiTestFuncOverlay101Vect();
/* we expect 1 hit in file_syetem_read; the overlay function in GROUP 101 */
if (g_stCtiOvlFuncsHitCounter.uiComrvLoad != 1)
{
ctiSetErrorBit(pCtiFrameWorkCB, E_TEST_ERROR_OVL_FAILED);
}
else
{
/* call FUNCTION in GROUP 101 and 102 - GROUP size 0x200 */
ctiTestFuncOverlay105Vect();
/* we expect 0 hits in file_syetem_read because the function was loaded in GROUP 101 */
if (g_stCtiOvlFuncsHitCounter.uiComrvLoad != 1)
{
ctiSetErrorBit(pCtiFrameWorkCB, E_TEST_ERROR_OVL_UNIFORM_GROUPS_FAILED);
}
else
{
/* call FUNCTION in GROUP 103 - GROUP size is 0x200 */
ctiTestFuncOverlay103Vect();
/* we expect 1 hits in file_syetem_read; for the overlay function in GROUP 103 */
if (g_stCtiOvlFuncsHitCounter.uiComrvLoad != 2)
{
ctiSetErrorBit(pCtiFrameWorkCB, E_TEST_ERROR_OVL_UNIFORM_GROUPS_FAILED);
}
}
}
return ctiGetErrorBits(pCtiFrameWorkCB);
}
/**
* @brief Groups with the same size: verify ovl groups are loaded when
* needed while the groups with the same size
*
* @param structure that holds 3 parameters
*
* @return error bit map
*/
E_TEST_ERROR ctiOvlTestGroupWithDifferentSize(S_FW_CB_PTR pCtiFrameWorkCB)
{
/* call FUNCTION in GROUP 101 - GROUP size 0x200 */
ctiTestFuncOverlay101Vect();
/* we expect 1 hits in file_syetem_read; one for the lookup table and one for the overlay
function in GROUP 101 */
if (g_stCtiOvlFuncsHitCounter.uiComrvLoad != 1)
{
ctiSetErrorBit(pCtiFrameWorkCB, E_TEST_ERROR_OVL_FAILED);
}
else
{
/* call FUNCTION in GROUP 104 (GROUP size 0xA00), the GROUP is bigger than GROUP 101 */
ctiTestFuncOverlay106Vect();
/* we expect 1 hits in file_syetem_read; for the overlay function in GROUP 104 */
if (g_stCtiOvlFuncsHitCounter.uiComrvLoad != 2)
{
ctiSetErrorBit(pCtiFrameWorkCB, E_TEST_ERROR_OVL_NON_UNIFORM_GROUPS_FAILED);
}
}
return ctiGetErrorBits(pCtiFrameWorkCB);
}
/**
* @brief multiple Groups: verify ovl groups are loaded when
* needed while the groups with the same size
*
* @param structure that holds 3 parameters
*
* @return error bit map
*/
E_TEST_ERROR ctiOvlTestMultigroup(S_FW_CB_PTR pCtiFrameWorkCB)
{
#ifdef D_COMRV_ENABLE_MULTI_GROUP_SUPPORT
void* pOverlayFunctionPC;
/* call FUNCTION in GROUP 101 - GROUP size 0x200 */
ctiTestFuncOverlay101Vect();
/* call MG function group 101 */
ctiTestFuncOverlay105Vect();
/* we expect 1 hit in file_syetem_read; for the overlay function in GROUP 101 */
if (g_stCtiOvlFuncsHitCounter.uiComrvLoad != 1)
{
ctiSetErrorBit(pCtiFrameWorkCB, E_TEST_ERROR_OVL_FAILED);
return ctiGetErrorBits(pCtiFrameWorkCB);
}
/* save the first multigroup function instance address */
pOverlayFunctionPC = G_pProgramCounterAddress;
/* fill the cache area with by calling overlay functions - will evict the first GROUP */
#undef M_CTI_DUMMY_FUNCTION
#define M_CTI_DUMMY_FUNCTION(x) ctiTestFuncOverlay ## x ## Vect();
M_CTI_FUNCTIONS_GENERATOR
/* call FUNCTION in GROUP 102 - GROUP size 0x200 */
ctiTestFuncOverlay102Vect();
if (g_stCtiOvlFuncsHitCounter.uiComrvLoad != 43)
{
ctiSetErrorBit(pCtiFrameWorkCB, E_TEST_ERROR_OVL_MULTI_GROUPS_FAILED);
return ctiGetErrorBits(pCtiFrameWorkCB);
}
/* call MG function group 105 */
ctiTestFuncOverlay105Vect();
/* we expect no hit in file_syetem_read because the function is already resident */
if (g_stCtiOvlFuncsHitCounter.uiComrvLoad != 43)
{
ctiSetErrorBit(pCtiFrameWorkCB, E_TEST_ERROR_OVL_MULTI_GROUPS_FAILED);
return ctiGetErrorBits(pCtiFrameWorkCB);
}
/* compare the addresses of the MG function */
if (pOverlayFunctionPC == G_pProgramCounterAddress)
{
ctiSetErrorBit(pCtiFrameWorkCB, E_TEST_ERROR_OVL_MULTI_GROUPS_FAILED);
}
#endif /* D_COMRV_ENABLE_MULTI_GROUP_SUPPORT */
return ctiGetErrorBits(pCtiFrameWorkCB);
}
/**
* @brief Lock / Unlock Groups: verify ovl groups are loaded when
* needed while the groups with the same size
*
* @param structure that holds 3 parameters
*
* @return error bit map
*/
E_TEST_ERROR ctiOvlTestLockUnlock(S_FW_CB_PTR pCtiFrameWorkCB)
{
u08_t ucCounter = 10;
#undef M_CTI_DUMMY_FUNCTION
#define M_CTI_DUMMY_FUNCTION(x) ctiTestFuncOverlay ## x ## Vect();
M_CTI_FUNCTIONS_GENERATOR
/* call FUNCTION in GROUP 101 - GROUP size is 0x200 */
ctiTestFuncOverlay101Vect();
/* call FUNCTION in GROUP 102 - GROUP size is 0x200 */
ctiTestFuncOverlay102Vect();
/* call FUNCTION in GROUP 103 - GROUP size is 0x200 */
ctiTestFuncOverlay103Vect();
/* call FUNCTION in GROUP 102 - GROUP size is 0x200 */
ctiTestFuncOverlay104Vect();
/* call FUNCTION in GROUP 101 - GROUP size is 0x200 */
ctiTestFuncOverlay105Vect();
/* call FUNCTION in GROUP 102 - GROUP size is 0x200 */
ctiTestFuncOverlay107Vect();
while (ucCounter--)
{
/* run at GROUP 107 - GROUP at size 0xc00 */
ctiTestFuncOverlay111Vect();
}
comrvLockUnlockOverlayGroupByFunction((void*)ctiTestFuncOverlay111Vect, D_COMRV_GROUP_STATE_LOCK);
/* run at GROUP 109 - GROUP at size 0x800 */
ctiTestFuncOverlay112Vect();
/* call FUNCTION in GROUP 101 - GROUP size 0x200 */
ctiTestFuncOverlay101Vect();
if (g_stCtiOvlFuncsHitCounter.uiComrvLoad != 45)
{
ctiSetErrorBit(pCtiFrameWorkCB, E_TEST_ERROR_OVL_FAILED);
}
else
{
/* lock GROUP 101 */
comrvLockUnlockOverlayGroupByFunction((void*)ctiTestFuncOverlay101Vect, D_COMRV_GROUP_STATE_LOCK);
/* fill the resident area with dummy functions and try to evict the first GROUP */
#undef M_CTI_DUMMY_FUNCTION
#define M_CTI_DUMMY_FUNCTION(x) ctiTestFuncOverlay ## x ## Vect();
M_CTI_FUNCTIONS_GENERATOR
/* call FUNCTION in GROUP 101 */
ctiTestFuncOverlay101Vect();
/* we expect 0 hits in file_syetem_read; the GROUP supposed to be locked */
if (g_stCtiOvlFuncsHitCounter.uiComrvLoad != 85)
{
ctiSetErrorBit(pCtiFrameWorkCB, E_TEST_ERROR_OVL_LOCK_UNLOCK_FAILED);
}
else
{
/* unlock GROUP 101 */
comrvLockUnlockOverlayGroupByFunction((void*)ctiTestFuncOverlay101Vect, D_COMRV_GROUP_STATE_UNLOCK);
/* fill the resident area with dummy functions and try to evict the first GROUP */
M_CTI_FUNCTIONS_GENERATOR
/* call FUNCTION in GROUP 101 */
ctiTestFuncOverlay101Vect();
/* we expect 1 hits in file_syetem_read; the GROUP supposed to be evicted */
if (g_stCtiOvlFuncsHitCounter.uiComrvLoad != 126)
{
ctiSetErrorBit(pCtiFrameWorkCB, E_TEST_ERROR_OVL_LOCK_UNLOCK_FAILED);
}
}
}
return ctiGetErrorBits(pCtiFrameWorkCB);
}
/**
* @brief Defrag Overlay Area: verify ovl core using defrag
*
* @param structure that holds 3 parameters
*
* @return error bit map
*/
E_TEST_ERROR ctiOvlTestDefragOverlayedFunctions(S_FW_CB_PTR pCtiFrameWorkCB)
{
/* fill cache */
ctiTestFuncOverlay120Vect();
ctiTestFuncOverlay121Vect();
ctiTestFuncOverlay122Vect();
ctiTestFuncOverlay123Vect();
ctiTestFuncOverlay124Vect();
ctiTestFuncOverlay125Vect();
ctiTestFuncOverlay126Vect();
ctiTestFuncOverlay127Vect();
ctiTestFuncOverlay128Vect();
ctiTestFuncOverlay129Vect();
ctiTestFuncOverlay130Vect();
ctiTestFuncOverlay131Vect();
ctiTestFuncOverlay132Vect();
ctiTestFuncOverlay133Vect();
ctiTestFuncOverlay134Vect();
ctiTestFuncOverlay135Vect();
ctiTestFuncOverlay136Vect();
ctiTestFuncOverlay137Vect();
ctiTestFuncOverlay138Vect();
ctiTestFuncOverlay139Vect();
ctiTestFuncOverlay140Vect();
ctiTestFuncOverlay141Vect();
ctiTestFuncOverlay142Vect();
ctiTestFuncOverlay143Vect();
ctiTestFuncOverlay144Vect();
ctiTestFuncOverlay145Vect();
ctiTestFuncOverlay146Vect();
ctiTestFuncOverlay147Vect();
ctiTestFuncOverlay148Vect();
ctiTestFuncOverlay149Vect();
ctiTestFuncOverlay150Vect();
ctiTestFuncOverlay151Vect();
/* make funcs 125, 135 and 147 to be the next eviction
candidates by not calling them */
ctiTestFuncOverlay120Vect();
ctiTestFuncOverlay121Vect();
ctiTestFuncOverlay122Vect();
ctiTestFuncOverlay123Vect();
ctiTestFuncOverlay124Vect();
ctiTestFuncOverlay126Vect();
ctiTestFuncOverlay127Vect();
ctiTestFuncOverlay128Vect();
ctiTestFuncOverlay129Vect();
ctiTestFuncOverlay130Vect();
ctiTestFuncOverlay131Vect();
ctiTestFuncOverlay132Vect();
ctiTestFuncOverlay133Vect();
ctiTestFuncOverlay134Vect();
ctiTestFuncOverlay136Vect();
ctiTestFuncOverlay137Vect();
ctiTestFuncOverlay138Vect();
ctiTestFuncOverlay139Vect();
ctiTestFuncOverlay140Vect();
ctiTestFuncOverlay141Vect();
ctiTestFuncOverlay142Vect();
ctiTestFuncOverlay143Vect();
ctiTestFuncOverlay144Vect();
ctiTestFuncOverlay145Vect();
ctiTestFuncOverlay146Vect();
ctiTestFuncOverlay148Vect();
ctiTestFuncOverlay149Vect();
ctiTestFuncOverlay150Vect();
ctiTestFuncOverlay151Vect();
/* evict lock functions 126, 136 and 148 */
comrvLockUnlockOverlayGroupByFunction(ctiTestFuncOverlay126Vect, D_COMRV_GROUP_STATE_LOCK);
comrvLockUnlockOverlayGroupByFunction(ctiTestFuncOverlay136Vect, D_COMRV_GROUP_STATE_LOCK);
comrvLockUnlockOverlayGroupByFunction(ctiTestFuncOverlay148Vect, D_COMRV_GROUP_STATE_LOCK);
/* clear load counter */
g_stCtiOvlFuncsHitCounter.uiComrvLoad = 0;
/* reset counter */
g_stCtiOvlFuncsHitCounter.uiDefragCounter = 0;
/* lets call a 0x600 bytes overlay - we expect that
funcs 125, 138 and 147 be evicted */
ctiTestFuncOverlay110Vect();
/* we expect more than 1 hit in defrag and 1 read in read */
if (g_stCtiOvlFuncsHitCounter.uiDefragCounter < 1 ||
g_stCtiOvlFuncsHitCounter.uiComrvLoad != 1)
{
ctiSetErrorBit(pCtiFrameWorkCB, E_TEST_ERROR_OVL_DEFRAG_FAILED);
return ctiGetErrorBits(pCtiFrameWorkCB);
}
/* make sure other functions were not evicted */
ctiTestFuncOverlay120Vect();
ctiTestFuncOverlay121Vect();
ctiTestFuncOverlay122Vect();
ctiTestFuncOverlay123Vect();
ctiTestFuncOverlay124Vect();
ctiTestFuncOverlay126Vect();
ctiTestFuncOverlay127Vect();
ctiTestFuncOverlay128Vect();
ctiTestFuncOverlay129Vect();
ctiTestFuncOverlay130Vect();
ctiTestFuncOverlay131Vect();
ctiTestFuncOverlay132Vect();
ctiTestFuncOverlay133Vect();
ctiTestFuncOverlay134Vect();
ctiTestFuncOverlay136Vect();
ctiTestFuncOverlay137Vect();
ctiTestFuncOverlay138Vect();
ctiTestFuncOverlay139Vect();
ctiTestFuncOverlay140Vect();
ctiTestFuncOverlay141Vect();
ctiTestFuncOverlay142Vect();
ctiTestFuncOverlay143Vect();
ctiTestFuncOverlay144Vect();
ctiTestFuncOverlay145Vect();
ctiTestFuncOverlay146Vect();
ctiTestFuncOverlay148Vect();
ctiTestFuncOverlay149Vect();
ctiTestFuncOverlay150Vect();
ctiTestFuncOverlay151Vect();
if (g_stCtiOvlFuncsHitCounter.uiComrvLoad == 1)
{
/* make sure 125, 135 and 147 are evicted */
ctiTestFuncOverlay125Vect();
ctiTestFuncOverlay135Vect();
ctiTestFuncOverlay147Vect();
if (g_stCtiOvlFuncsHitCounter.uiComrvLoad == 4)
{
/* make sure locked functions were not evicted */
ctiTestFuncOverlay126Vect();
ctiTestFuncOverlay136Vect();
ctiTestFuncOverlay148Vect();
if (g_stCtiOvlFuncsHitCounter.uiComrvLoad != 4)
{
ctiSetErrorBit(pCtiFrameWorkCB, E_TEST_ERROR_OVL_DEFRAG_FAILED);
}
else
{
/* make sure locked overlays become lru */
ctiTestFuncOverlay120Vect();
ctiTestFuncOverlay121Vect();
ctiTestFuncOverlay122Vect();
ctiTestFuncOverlay123Vect();
ctiTestFuncOverlay124Vect();
ctiTestFuncOverlay125Vect();
ctiTestFuncOverlay127Vect();
ctiTestFuncOverlay128Vect();
ctiTestFuncOverlay129Vect();
ctiTestFuncOverlay130Vect();
ctiTestFuncOverlay131Vect();
ctiTestFuncOverlay132Vect();
ctiTestFuncOverlay133Vect();
ctiTestFuncOverlay134Vect();
ctiTestFuncOverlay135Vect();
ctiTestFuncOverlay137Vect();
ctiTestFuncOverlay138Vect();
ctiTestFuncOverlay139Vect();
ctiTestFuncOverlay140Vect();
ctiTestFuncOverlay141Vect();
ctiTestFuncOverlay142Vect();
ctiTestFuncOverlay143Vect();
ctiTestFuncOverlay144Vect();
ctiTestFuncOverlay145Vect();
ctiTestFuncOverlay146Vect();
ctiTestFuncOverlay147Vect();
ctiTestFuncOverlay149Vect();
ctiTestFuncOverlay150Vect();
ctiTestFuncOverlay151Vect();
/* calling the following functions will cause the
eviction lru items to be spread such that the actual
lru won't be used (locked) */
ctiTestFuncOverlay121Vect();
ctiTestFuncOverlay122Vect();
ctiTestFuncOverlay123Vect();
ctiTestFuncOverlay124Vect();
/* reset counter */
g_stCtiOvlFuncsHitCounter.uiDefragCounter = 0;
/* no we want to load an overlay size of 0x600 and see that
defrag works while keeping the locked lru as the real lru */
ctiTestFuncOverlay110Vect();
/* we expect more than 1 hit in defrag */
if (g_stCtiOvlFuncsHitCounter.uiDefragCounter < 1)
{
ctiSetErrorBit(pCtiFrameWorkCB, E_TEST_ERROR_OVL_DEFRAG_FAILED);
}
}
}
else
{
ctiSetErrorBit(pCtiFrameWorkCB, E_TEST_ERROR_OVL_DEFRAG_FAILED);
}
}
else
{
ctiSetErrorBit(pCtiFrameWorkCB, E_TEST_ERROR_OVL_DEFRAG_FAILED);
}
return ctiGetErrorBits(pCtiFrameWorkCB);
}
/**
* @brief grouping tool
*
* @param structure that holds 3 parameters
*
* @return error bit map
*/
E_TEST_ERROR ctiOvlTestGroupingOvlt(S_FW_CB_PTR pCtiFrameWorkCB)
{
u32_t uiLoopCount = 25;
while( uiLoopCount--)
{
ctiTestFuncOverlay120Vect();
ctiTestFuncOverlay121Vect();
}
uiLoopCount = 75;
while (uiLoopCount--)
{
ctiTestFuncOverlay123Vect();
ctiTestFuncOverlay124Vect();
}
uiLoopCount = 125;
while (uiLoopCount-- )
{
ctiTestFuncOverlay125Vect();
ctiTestFuncOverlay126Vect();
}
return ctiGetErrorBits(pCtiFrameWorkCB);
}
/**
* @brief critical section (FW POV): verify critical section (comrv
* disable/enable); this is used to verify
* that overlay functions are not been called
*
* @param structure that holds 3 parameters
*
* @return error bit map
*/
E_TEST_ERROR ctiOvlTestCriticalSection(S_FW_CB_PTR pCtiFrameWorkCB)
{
/* Assign a system error function to capture when we fail on critical section */
demoComrvSetErrorHandler(ctiOvlUserSystemErrorVect);
/* call FUNCTION in GROUP 101 - GROUP size 0x200
call the first ovl function to verify sanity */
ctiTestFuncOverlay101Vect();
/* comrv is working fine so we can test the disable/enable */
if (g_stCtiOvlFuncsHitCounter.uiErrorNum == 0)
{
/* disable comrv */
comrvDisable();
/* call FUNCTION in GROUP 102 - GROUP size 0x200
supposed to trigger an error.
the error function will disable the critical section bit to avoid
infinity loop */
ctiTestFuncOverlay102Vect();
if (g_stCtiOvlFuncsHitCounter.uiErrorNum == 0)
{
ctiSetErrorBit(pCtiFrameWorkCB, E_TEST_ERROR_OVL_CRITICAL_SECTION_FAILED);
}
/* enable comrv */
comrvEnable();
}
/* clear the function pointer for the remaining tests */
demoComrvSetErrorHandler(NULL);
return ctiGetErrorBits(pCtiFrameWorkCB);
}
/**
* @brief Calculate and compare loaded overlay CRC
*
* @param None
*
* @return E_TEST_ERROR
*/
E_TEST_ERROR ctiOvlTestCrcCheck(S_FW_CB_PTR pCtiFrameWorkCB)
{
/* Assign a system error function to capture when we fail on on CRC */
demoComrvSetErrorHandler(ctiOvlUserSystemErrorVect);
/* call FUNCTION in GROUP 101 - GROUP size is 0x200 */
ctiTestFuncOverlay101Vect();
/* call FUNCTION in GROUP 102 - GROUP size is 0x200 */
ctiTestFuncOverlay102Vect();
/* call FUNCTION in GROUP 103 - GROUP size is 0x200 */
ctiTestFuncOverlay103Vect();
/* clear the function pointer for the remaining tests */
demoComrvSetErrorHandler(NULL);
/* check we didn't get a CRC error */
if (g_stCtiOvlFuncsHitCounter.uiErrorNum != 0)
{
ctiSetErrorBit(pCtiFrameWorkCB, E_TEST_ERROR_OVL_CRC_FAILED);
}
return ctiGetErrorBits(pCtiFrameWorkCB);
}
/**
* @brief Test the ovl thread safe core
*
* @param None
*
* @return E_TEST_ERROR
*/
E_TEST_ERROR ctiOvlTestThreadSafe(S_FW_CB_PTR pCtiFrameWorkCB)
{
#ifdef D_COMRV_RTOS_SUPPORT
#ifdef D_COMRV_OVL_DATA_SUPPORT
u32_t *pDataOverlay, uiIndex;
#endif /* D_COMRV_OVL_DATA_SUPPORT */
/* register software interrupt handler */
pspMachineInterruptsRegisterIsr(ctiSwiIsr, E_MACHINE_SOFTWARE_CAUSE);
/* enable sw int */
pspMachineInterruptsEnableIntNumber(D_PSP_INTERRUPTS_MACHINE_SW);
/* update sync point */
pCtiFrameWorkCB->uiTestSyncPoint = D_CTI_TASK_SYNC_BEFORE_ENTER_CRITICAL_SEC;
/* call FUNCTION in GROUP 101 - GROUP size 0x200
to initiate the first thread safe test (read_backing_store) */
ctiTestFuncOverlay101Vect();
/* update sync point */
pCtiFrameWorkCB->uiTestSyncPoint = D_CTI_TASK_SYNC_AFTER_ENTER_CRITICAL_SEC;
/* call FUNCTION in GROUP 103 - GROUP size is 0x200
to initiate the second thread safe test */
ctiTestFuncOverlay103Vect();
/* update sync point */
pCtiFrameWorkCB->uiTestSyncPoint = D_CTI_TASK_SYNC_BEFORE_EXIT_CRITICAL_SEC;
/* call FUNCTION in GROUP 104 - GROUP size is 0x200
to initiate the second thread safe test */
ctiTestFuncOverlay104Vect();
/* update sync point */
pCtiFrameWorkCB->uiTestSyncPoint = D_CTI_TASK_SYNC_AFTER_EXIT_CRITICAL_SEC;
/* call FUNCTION in GROUP 106 - GROUP size is 0x200
to initiate the second thread safe test */
ctiTestFuncOverlay106Vect();
/* update sync point */
pCtiFrameWorkCB->uiTestSyncPoint = D_CTI_TASK_SYNC_AFTER_SEARCH_LOAD;
/* call FUNCTION in GROUP 113 - GROUP size is 0x200
to initiate the second thread safe test */
ctiTestFuncOverlay113Vect(1, 2, 3);
/* we expect 1 load - the high priority task completed running and cleared
the load counter */
if (g_stCtiOvlFuncsHitCounter.uiComrvLoad != 1)
{
ctiSetErrorBit(pCtiFrameWorkCB, E_TEST_ERROR_OVL_THREAD_SAFE_READ_BACK_STORE);
}
#ifdef D_COMRV_OVL_DATA_SUPPORT
/* update sync point */
pCtiFrameWorkCB->uiTestSyncPoint = D_CTI_TASK_SYNC_DATA_OVERLAY;
/* load data overlay */
pDataOverlay = (u32_t*)comrvDataOverlayAllocation(uiSomeOverlayData);
/* we expect no load - cleared by the high priority task */
if (g_stCtiOvlFuncsHitCounter.uiComrvLoad != 0)
{
ctiSetErrorBit(pCtiFrameWorkCB, E_TEST_ERROR_OVL_DATA_OVERLAY_FAILED);
}
/* verify the read data content - even if the higher priority task filled cache */
for (uiIndex = 0 ; uiIndex < D_CTI_DATA_OVL_ARR_SIZE ; uiIndex++)
{
if (pDataOverlay[uiIndex] != uiIndex)
{
ctiSetErrorBit(pCtiFrameWorkCB, E_TEST_ERROR_OVL_DATA_OVERLAY_FAILED);
break;
}
}
/* second reference to the data overlay */
pDataOverlay = (u32_t*)comrvDataOverlayAllocation(uiSomeOverlayData);
/* we still expect no additional load as overlay data already loaded */
if (g_stCtiOvlFuncsHitCounter.uiComrvLoad != 0)
{
ctiSetErrorBit(pCtiFrameWorkCB, E_TEST_ERROR_OVL_DATA_OVERLAY_FAILED);
}
#endif /* D_COMRV_OVL_DATA_SUPPORT */
/* update sync point */
pCtiFrameWorkCB->uiTestSyncPoint = D_CTI_TASK_SYNC_SAME_OVERLAY;
/* the 2 tasks call the same function */
ctiTestFuncOverlay120Vect();
/* we expect 1 load - the high priority task waited for the low priority task to complete the load */
if (g_stCtiOvlFuncsHitCounter.uiComrvLoad != 1)
{
ctiSetErrorBit(pCtiFrameWorkCB, E_TEST_ERROR_OVL_SAME_OVERLAY_FAILED);
}
#endif /* D_COMRV_RTOS_SUPPORT */
return ctiGetErrorBits(pCtiFrameWorkCB);
}
#ifdef D_COMRV_RTOS_SUPPORT
/**
* @brief task b test function; test 2 tasks calling
* overlay functions (high priority task)
*
* @param None
*
* @return None
*/
void ctiTaskBTest(void)
{
S_FW_CB_PTR pCtiFrameWorkCB = g_pCtiFrameWorkCB;
rtosalEventBits_t stRtosalEventBits;
/* sync point 1 */
rtosalEventGroupGet(&stRtosalEventGroupCb, D_CTI_TASK_SYNC_BEFORE_ENTER_CRITICAL_SEC,
&stRtosalEventBits, D_RTOSAL_OR_CLEAR, D_RTOSAL_WAIT_FOREVER);
/* call function from GROUP 108 (GROUP size 0x400) */
ctiTestFuncOverlay108Vect();
/* we expect 1 load */
if (g_stCtiOvlFuncsHitCounter.uiComrvLoad == 1)
{
/* sync point 2 */
rtosalEventGroupGet(&stRtosalEventGroupCb, D_CTI_TASK_SYNC_AFTER_ENTER_CRITICAL_SEC,
&stRtosalEventBits, D_RTOSAL_OR_CLEAR, D_RTOSAL_WAIT_FOREVER);
/* call overlay func */
ctiTestFuncOverlay110Vect();
/* we expect total 4 loads */
if (g_stCtiOvlFuncsHitCounter.uiComrvLoad == 4)
{
/* sync point 3 */
rtosalEventGroupGet(&stRtosalEventGroupCb, D_CTI_TASK_SYNC_BEFORE_EXIT_CRITICAL_SEC,
&stRtosalEventBits, D_RTOSAL_OR_CLEAR, D_RTOSAL_WAIT_FOREVER);
/* call overlay func */
ctiTestFuncOverlay111Vect();
/* we expect total of 6 loads */
if (g_stCtiOvlFuncsHitCounter.uiComrvLoad == 6)
{
/* sync point 4 */
rtosalEventGroupGet(&stRtosalEventGroupCb, D_CTI_TASK_SYNC_AFTER_EXIT_CRITICAL_SEC,
&stRtosalEventBits, D_RTOSAL_OR_CLEAR, D_RTOSAL_WAIT_FOREVER);
/* call overlay func */
ctiTestFuncOverlay112Vect();
/* we expect total of 8 loads */
if (g_stCtiOvlFuncsHitCounter.uiComrvLoad == 8)
{
/* sync point 5 */
rtosalEventGroupGet(&stRtosalEventGroupCb, D_CTI_TASK_SYNC_AFTER_SEARCH_LOAD,
&stRtosalEventBits, D_RTOSAL_OR_CLEAR, D_RTOSAL_WAIT_FOREVER);
/* fill the resident area with dummy functions and try to evict the first GROUP */
#undef M_CTI_DUMMY_FUNCTION
#define M_CTI_DUMMY_FUNCTION(x) ctiTestFuncOverlay ## x ## Vect();
M_CTI_FUNCTIONS_GENERATOR
/* clear load counter */
g_stCtiOvlFuncsHitCounter.uiComrvLoad = 0;
#ifdef D_COMRV_OVL_DATA_SUPPORT
/* sync point 6 */
rtosalEventGroupGet(&stRtosalEventGroupCb, D_CTI_TASK_SYNC_DATA_OVERLAY,
&stRtosalEventBits, D_RTOSAL_OR_CLEAR, D_RTOSAL_WAIT_FOREVER);
/* fill the resident area - data overlay won't be evicted */
M_CTI_FUNCTIONS_GENERATOR
#endif /* D_COMRV_OVL_DATA_SUPPORT */
/* clear load counter */
g_stCtiOvlFuncsHitCounter.uiComrvLoad = 0;
/* sync point 7 */
rtosalEventGroupGet(&stRtosalEventGroupCb, D_CTI_TASK_SYNC_SAME_OVERLAY,
&stRtosalEventBits, D_RTOSAL_OR_CLEAR, D_RTOSAL_WAIT_FOREVER);
/* the 2 tasks call the same function */
ctiTestFuncOverlay120Vect();
}
else
{
ctiSetErrorBit(pCtiFrameWorkCB, E_TEST_ERROR_OVL_THREAD_SAFE_READ_BACK_STORE);
}
}
else
{
ctiSetErrorBit(pCtiFrameWorkCB, E_TEST_ERROR_OVL_THREAD_SAFE_READ_BACK_STORE);
}
}
else
{
ctiSetErrorBit(pCtiFrameWorkCB, E_TEST_ERROR_OVL_THREAD_SAFE_READ_BACK_STORE);
}
}
}
/**
* @brief this function is called when a swi is raised
* (currently only applies to whisper)
*
* @param None
*
* @return None
*/
void ctiSwiIsr(void)
{
u32_t uiSyncPintVal = ctiGetCurrentSyncPoint();
rtosalEventBits_t stRtosalEventBits;
/* clear swi indication so we are not interrupted again */
M_CTI_CLEAR_SW_INT();
/* clear sync point so that comrv engine won't hit it again */
ctiSetCurrentSyncPoint(D_CTI_TASK_SYNC_NONE); \
/* send an event - next sync point */
rtosalEventGroupSet(&stRtosalEventGroupCb, uiSyncPintVal,
D_RTOSAL_OR, &stRtosalEventBits);
}
#endif /* D_COMRV_RTOS_SUPPORT */
/**
* @brief tests the 'reset eviction counters' api
*
* @param None
*
* @return None
*/
E_TEST_ERROR ctiOvlTestResetEvictionCounters(S_FW_CB_PTR pCtiFrameWorkCB)
{
lru_t tIntex;
comrvStatus_t stComrvStatus;
comrvGetStatus(&stComrvStatus);
/* fill the cache */
ctiTestFuncOverlay120Vect(); /* will be lru 0 */
ctiTestFuncOverlay121Vect(); /* will be lru 1 */
ctiTestFuncOverlay122Vect(); /* will be lru 2 */
ctiTestFuncOverlay123Vect(); /* will be lru 3 */
ctiTestFuncOverlay124Vect(); /* and so on ... */
ctiTestFuncOverlay125Vect();
ctiTestFuncOverlay126Vect();
ctiTestFuncOverlay127Vect();
ctiTestFuncOverlay128Vect();
ctiTestFuncOverlay129Vect();
ctiTestFuncOverlay130Vect();
ctiTestFuncOverlay131Vect();
ctiTestFuncOverlay132Vect();
ctiTestFuncOverlay133Vect();
ctiTestFuncOverlay134Vect();
ctiTestFuncOverlay135Vect();
ctiTestFuncOverlay136Vect();
ctiTestFuncOverlay137Vect();
ctiTestFuncOverlay138Vect();
ctiTestFuncOverlay139Vect();
ctiTestFuncOverlay140Vect();
ctiTestFuncOverlay141Vect();
ctiTestFuncOverlay142Vect();
ctiTestFuncOverlay143Vect();
ctiTestFuncOverlay144Vect();
ctiTestFuncOverlay145Vect();
ctiTestFuncOverlay146Vect();
ctiTestFuncOverlay147Vect();
ctiTestFuncOverlay148Vect();
ctiTestFuncOverlay149Vect();
ctiTestFuncOverlay150Vect();
ctiTestFuncOverlay151Vect(); /* will be the mru */
/* the expected lru is ctiTestFuncOverlay120Vect and mru is ctiTestFuncOverlay130Vect */
comrvGetStatus(&stComrvStatus);
/* verify lru/mru are correct */
if (stComrvStatus.pComrvCB->ucLruIndex != 0 &&
stComrvStatus.pComrvCB->ucMruIndex != 31)
{
ctiSetErrorBit(pCtiFrameWorkCB, E_TEST_ERROR_OVL_RESET_EVICT_CNTR_FAILED);
}
/* verify lru list */
for (tIntex = stComrvStatus.pComrvCB->ucLruIndex ; tIntex < stComrvStatus.pComrvCB->ucMruIndex ; )
{
if (stComrvStatus.pComrvCB->stOverlayCache[tIntex].unLru.stFields.typNextLruIndex != tIntex+1)
{
ctiSetErrorBit(pCtiFrameWorkCB, E_TEST_ERROR_OVL_RESET_EVICT_CNTR_FAILED);
}
tIntex = stComrvStatus.pComrvCB->stOverlayCache[tIntex].unLru.stFields.typNextLruIndex;
}
ctiTestFuncOverlay151Vect(); /* will be lru 0 */
ctiTestFuncOverlay150Vect(); /* will be lru 1 */
ctiTestFuncOverlay149Vect(); /* will be lru 2 */
ctiTestFuncOverlay148Vect(); /* will be lru 3 */
ctiTestFuncOverlay147Vect(); /* and so on ... */
ctiTestFuncOverlay146Vect();
ctiTestFuncOverlay145Vect();
ctiTestFuncOverlay144Vect();
ctiTestFuncOverlay143Vect();
ctiTestFuncOverlay142Vect();
ctiTestFuncOverlay141Vect();
ctiTestFuncOverlay140Vect();
ctiTestFuncOverlay139Vect();
ctiTestFuncOverlay138Vect();
ctiTestFuncOverlay137Vect();
ctiTestFuncOverlay136Vect();
ctiTestFuncOverlay135Vect();
ctiTestFuncOverlay134Vect();
ctiTestFuncOverlay133Vect();
ctiTestFuncOverlay132Vect();
ctiTestFuncOverlay131Vect();
ctiTestFuncOverlay130Vect();
ctiTestFuncOverlay129Vect();
ctiTestFuncOverlay128Vect();
ctiTestFuncOverlay127Vect();
ctiTestFuncOverlay126Vect();
ctiTestFuncOverlay125Vect();
ctiTestFuncOverlay124Vect();
ctiTestFuncOverlay123Vect();
ctiTestFuncOverlay122Vect();
ctiTestFuncOverlay121Vect();
ctiTestFuncOverlay120Vect(); /* will be mru */
/* verify lru/mru are correct */
if (stComrvStatus.pComrvCB->ucLruIndex != 31 && /* entry 29 is now lru */
stComrvStatus.pComrvCB->ucMruIndex != 0) /* entry 0 is now mru */
{
ctiSetErrorBit(pCtiFrameWorkCB, E_TEST_ERROR_OVL_RESET_EVICT_CNTR_FAILED);
}
/* verify lru list */
for (tIntex = stComrvStatus.pComrvCB->ucLruIndex ; tIntex > stComrvStatus.pComrvCB->ucMruIndex ; )
{
if (stComrvStatus.pComrvCB->stOverlayCache[tIntex].unLru.stFields.typNextLruIndex != tIntex-1)
{
ctiSetErrorBit(pCtiFrameWorkCB, E_TEST_ERROR_OVL_RESET_EVICT_CNTR_FAILED);
}
tIntex = stComrvStatus.pComrvCB->stOverlayCache[tIntex].unLru.stFields.typNextLruIndex;
}
/* reset eviction counters */
comrvReset(E_RESET_TYPE_LRU_HISTORY);
/* verify lru/mru are correct */
if (stComrvStatus.pComrvCB->ucLruIndex != 0 && /* entry 0 is now lru */
stComrvStatus.pComrvCB->ucMruIndex != 31) /* entry 29 is now mru */
{
ctiSetErrorBit(pCtiFrameWorkCB, E_TEST_ERROR_OVL_RESET_EVICT_CNTR_FAILED);
}
/* clear load counter - verify we don't load any of the functions */
g_stCtiOvlFuncsHitCounter.uiComrvLoad = 0;
/* call the overlay functions */
ctiTestFuncOverlay151Vect();
ctiTestFuncOverlay150Vect();
ctiTestFuncOverlay149Vect();
ctiTestFuncOverlay148Vect();
ctiTestFuncOverlay147Vect();
ctiTestFuncOverlay146Vect();
ctiTestFuncOverlay145Vect();
ctiTestFuncOverlay144Vect();
ctiTestFuncOverlay143Vect();
ctiTestFuncOverlay142Vect();
ctiTestFuncOverlay141Vect();
ctiTestFuncOverlay140Vect();
ctiTestFuncOverlay139Vect();
ctiTestFuncOverlay138Vect();
ctiTestFuncOverlay137Vect();
ctiTestFuncOverlay136Vect();
ctiTestFuncOverlay135Vect();
ctiTestFuncOverlay134Vect();
ctiTestFuncOverlay133Vect();
ctiTestFuncOverlay132Vect();
ctiTestFuncOverlay131Vect();
ctiTestFuncOverlay130Vect();
ctiTestFuncOverlay129Vect();
ctiTestFuncOverlay128Vect();
ctiTestFuncOverlay127Vect();
ctiTestFuncOverlay126Vect();
ctiTestFuncOverlay125Vect();
ctiTestFuncOverlay124Vect();
ctiTestFuncOverlay123Vect();
ctiTestFuncOverlay122Vect();
ctiTestFuncOverlay121Vect();
ctiTestFuncOverlay120Vect();
/* we expect 0 hits (0 loads) - all functions should be loaded */
if (g_stCtiOvlFuncsHitCounter.uiComrvLoad != 0)
{
ctiSetErrorBit(pCtiFrameWorkCB, E_TEST_ERROR_OVL_RESET_EVICT_CNTR_FAILED);
}
return ctiGetErrorBits(pCtiFrameWorkCB);
}
/**
* @brief run at GROUP 101 - GROUP size 0x200
*
* @param pCtiFrameWorkCB
*
* @return None
*/
void _OVERLAY_ ctiTestFuncOverlay101Vect(void)
{
u32_t* pVar = &g_uiVar;
u32_t uiLoopCount = D_CTI_NUM_OF_LOOPS;
*pVar = 0;
while( uiLoopCount--)
{
*pVar +=1;
}
}
/**
* @brief run at GROUP 102 and call function at GROUP 103 - GROUP size 0x200
*
* @param pCtiFrameWorkCB
*
* @return None
*/
void _OVERLAY_ ctiTestFuncOverlay102Vect(void)
{
u32_t* pVar = &g_uiVar;
u32_t uiLoopCount = 100;
*pVar = 0;
while( uiLoopCount--)
{
*pVar +=1;
}
/* call FUNCTION in GROUP 103 - GROUP size is 0x200 */
ctiTestFuncOverlay103Vect();
}
/**
* @brief run at GROUP 103 - GROUP size 0x200
*
* @param pCtiFrameWorkCB
*
* @return None
*/
void _OVERLAY_ ctiTestFuncOverlay103Vect(void)
{
u32_t* pVar = &g_uiVar;
u32_t uiLoopCount = 50;
*pVar = 0;
while( uiLoopCount--)
{
*pVar +=1;
}
}
/**
* @brief run at GROUP 102 and call function at GROUP 102 - GROUP size 0x200
*
* @param pCtiFrameWorkCB
*
* @return None
*/
void _OVERLAY_ ctiTestFuncOverlay104Vect(void)
{
u32_t* pVar = &g_uiVar;
u32_t uiLoopCount = 10;
*pVar = 0;
while( uiLoopCount--)
{
*pVar +=1;
}
/* call FUNCTION in GROUP 102 - GROUP size is 0x200 */
ctiTestFuncOverlay107Vect();
}
/**
* @brief run at GROUP 100 and at GROUP 101 && 102 in case of multigroup
* GROUP size 0x200
*
* @param pCtiFrameWorkCB
*
* @return None
*/
void _OVERLAY_ ctiTestFuncOverlay105Vect(void)
{
u32_t* pVar = &g_uiVar;
u32_t uiLoopCount = 25;
*pVar = 0;
while( uiLoopCount--)
{
*pVar +=1;
}
asm volatile ("auipc %0, 0" : "=r" (G_pProgramCounterAddress) : );
}
/**
* @brief run at GROUP 103 - GROUP size 0xA00
*
* @param pCtiFrameWorkCB
*
* @return None
*/
void _OVERLAY_ ctiTestFuncOverlay106Vect(void)
{
u32_t* pVar = &g_uiVar;
u32_t uiLoopCount = 256;
u32_t* pArr = g_uiTempArr;
*pVar = 0;
M_CTI_512B_NOPS;
while( uiLoopCount--)
{
*pVar +=1;
pArr[uiLoopCount] = (*pVar)++ ;
if (pArr[uiLoopCount] % 7 == 0)
{
pArr[uiLoopCount]++;
}
}
M_CTI_512B_NOPS;
M_CTI_512B_NOPS;
M_CTI_512B_NOPS;
M_CTI_100_NOPS;
}
/**
* @brief run at GROUP 102 - GROUP at size 0x200
*
* @param None
*
* @return None
*/
void _OVERLAY_ ctiTestFuncOverlay107Vect(void)
{
u32_t* pVar = &g_uiVar;
u32_t uiLoopCount = 75;
*pVar = 0;
while( uiLoopCount--)
{
*pVar +=1;
}
}
#ifdef D_COMRV_RTOS_SUPPORT
/**
* @brief run at GROUP 105 - GROUP at size 0x400
*
* @param pCtiFrameWorkCB
*
* @return None
*/
void _OVERLAY_ ctiTestFuncOverlay108Vect(void)
{
u32_t* pVar = &g_uiVar;
u32_t uiLoopCount = D_CTI_NUM_OF_LOOPS;
*pVar = 0;
M_CTI_512B_NOPS;
M_CTI_100_NOPS;
while( uiLoopCount--)
{
*pVar +=1;
}
}
#endif /* D_COMRV_RTOS_SUPPORT */
/**
* @brief run at GROUP 106 - GROUP at size 0x400
*
* @param pCtiFrameWorkCB
*
* @return None
*/
void _OVERLAY_ ctiTestFuncOverlay109Vect(void)
{
u32_t* pVar = &g_uiVar;
u32_t uiLoopCount = D_CTI_NUM_OF_LOOPS;
*pVar = 0;
M_CTI_512B_NOPS;
M_CTI_100_NOPS;
while( uiLoopCount--)
{
*pVar +=1;
}
}
/**
* @brief run at GROUP 107 - GROUP at size 0x600
*
* @param pCtiFrameWorkCB
*
* @return None
*/
void _OVERLAY_ ctiTestFuncOverlay110Vect(void)
{
u32_t* pVar = &g_uiVar;
u32_t uiLoopCount = D_CTI_NUM_OF_LOOPS;
*pVar = 0;
while( uiLoopCount--)
{
*pVar +=1;
}
M_CTI_512B_NOPS;
M_CTI_512B_NOPS;
M_CTI_100_NOPS;
}
/**
* @brief run at GROUP 107 - GROUP at size 0xc00
*
* @param pCtiFrameWorkCB
*
* @return None
*/
void _OVERLAY_ ctiTestFuncOverlay111Vect(void)
{
u32_t* pVar = &g_uiVar;
u32_t uiLoopCount = D_CTI_NUM_OF_LOOPS;
*pVar = 0;
while( uiLoopCount--)
{
*pVar +=1;
}
M_CTI_512B_NOPS;
M_CTI_512B_NOPS;
M_CTI_512B_NOPS;
M_CTI_512B_NOPS;
M_CTI_512B_NOPS;
M_CTI_100_NOPS;
}
/**
* @brief run at GROUP 109 - GROUP at size 0x800
*
* @param pCtiFrameWorkCB
*
* @return None
*/
void _OVERLAY_ ctiTestFuncOverlay112Vect(void)
{
u32_t* pVar = &g_uiVar;
u32_t uiLoopCount = D_CTI_NUM_OF_LOOPS;
*pVar = 0;
while( uiLoopCount--)
{
*pVar +=1;
}
M_CTI_512B_NOPS;
M_CTI_512B_NOPS;
M_CTI_512B_NOPS;
M_CTI_100_NOPS;
}
#ifdef D_COMRV_RTOS_SUPPORT
/**
* @brief run at GROUP 110 - GROUP at size 0x800
*
* @param uiVar1, uiVar2, uiVar3 - integers
*
* @return None
*/
void _OVERLAY_ ctiTestFuncOverlay113Vect(u32_t uiVar1, u32_t uiVar2, u32_t uiVar3)
{
/* verify we got all correct args */
if (uiVar1 + uiVar2 + uiVar3 != D_CTI_SUM_OF_ARGS)
{
M_PSP_EBREAK();
}
M_CTI_100_NOPS;
}
#endif /* D_COMRV_RTOS_SUPPORT */
|
edward-jones/riscv-fw-infrastructure | WD-Firmware/rtos/rtosal/rtosal_interrupt.c | <gh_stars>10-100
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2019 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file rtosal_interrupt.c
* @author <NAME>
* @date 21.01.2019
* @brief The file implements the RTOS AL interrupt API
*
*/
/**
* include files
*/
#include "rtosal_interrupt_api.h"
#include "rtosal_util.h"
/**
* definitions
*/
/**
* macros
*/
/**
* types
*/
/**
* local prototypes
*/
/**
* external prototypes
*/
/**
* global variables
*/
/**
* The function installs an interrupt service routine per risc-v cause
*
* @param fptrRtosalInterruptHandler – function pointer to the interrupt
* service routine
* @param uiInterruptId – interrupt ID number
* @param uiInterruptPriority – interrupt priority
* @param stCauseIndex – value of the mcuase register this
* interrupt is assigned to
* @return u32_t - D_RTOSAL_SUCCESS
* - D_RTOSAL_CALLER_ERROR
*/
u32_t rtosalInstallIsr(rtosalInterruptHandler_t fptrRtosalInterruptHandler,
u32_t uiInterruptId , u32_t uiInterruptPriority,
rtosalInterruptCause_t stCauseIndex)
{
return D_RTOSAL_SUCCESS;
}
|
edward-jones/riscv-fw-infrastructure | WD-Firmware/psp/api_inc/psp_nmi_eh2.h | /*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2020 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file psp_nmi_eh2.h
* @author <NAME>
* @date 19.05.2020
* @brief The file defines the psp NMI interfaces for features of SweRV EH2
*
*/
#ifndef __PSP_NMI_EH2_H__
#define __PSP_NMI_EH2_H__
/**
* include files
*/
/**
* types
*/
/**
* definitions
*/
/**
* local prototypes
*/
/**
* external prototypes
*/
/**
* macros
*/
/**
* global variables
*/
/**
* APIs
*/
/**
* @brief - delegate pin-asserted NMI to a given Hart (HW thread)
* That means - upon occurence of the pin-asserted NMI, it will be handelled by the given Hart
*
* @parameter - Hart number to delegate the NMI to
*/
void pspMachineNmiSetDelegation(u32_t uiHartNumber);
/**
* @brief - clear delegation of pin-asserted NMI for a given Hart (HW thread)
* That means - upon occurence of the pin-asserted NMI, the given Hart will not handle the NMI
*
* @parameter - Hart number to clear NMI delegation from
*/
void pspMachineNmiClearDelegation(u32_t uiHartNumber);
/**
* @brief - check whether pin-asserted NMI handling is delegated to the given hart (HW thread) or not
*
* @parameter - Hart number
* @return - 0/1 to indicate whether the NMI handling is delegated to the given hart-number or not
*/
u32_t pspMachineNmiIsDelegatedToHart(u32_t uiHartNumber);
#endif /* __PSP_NMI_EH2_H__ */
|
edward-jones/riscv-fw-infrastructure | WD-Firmware/rtos/rtosal/rtosal_semaphore.c | /*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2019 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file rtosal_semaphore.c
* @author <NAME>
* @date 21.01.2019
* @brief The file implements the RTOS AL queue API
*
*/
/**
* include files
*/
#include "rtosal_semaphore_api.h"
#include "rtosal_macros.h"
#include "rtosal_util.h"
#include "rtosal_interrupt_api.h"
#include "rtosal_task_api.h"
#include "psp_api.h"
#ifdef D_USE_FREERTOS
#include "semphr.h"
#else
#error "Add appropriate RTOS definitions"
#endif /* #ifdef D_USE_FREERTOS */
/**
* definitions
*/
/**
* macros
*/
/**
* types
*/
/**
* local prototypes
*/
/**
* external prototypes
*/
/**
* global variables
*/
/**
* Create a semaphore
*
* @param pRtosalSemaphoreCb - Pointer to semaphore control block to be created
* @param pRtosalSemaphoreName - String of the Semaphore name (for debuging)
* @param iSemaphoreInitialCount - Semaphore initial count value
* @param uiSemaphoreMaxCount - Maximum semaphore count value that can be reached
*
* @return u32_t - D_RTOSAL_SUCCESS
* - D_RTOSAL_SEMAPHORE_ERROR - The ptr, cMsgQueueCB, in the pRtosalSemaphoreCb is invalid
* - D_RTOSAL_CALLER_ERROR - The caller can not call this function
*/
RTOSAL_SECTION u32_t rtosalSemaphoreCreate(rtosalSemaphore_t* pRtosalSemaphoreCb, s08_t *pRtosalSemaphoreName,
s32_t iSemaphoreInitialCount, u32_t uiSemaphoreMaxCount)
{
u32_t uiRes;
void* pSemCb;
M_RTOSAL_VALIDATE_FUNC_PARAM(pRtosalSemaphoreCb, pRtosalSemaphoreCb == NULL, D_RTOSAL_SEMAPHORE_ERROR);
#ifdef D_USE_FREERTOS
/* create the semaphore */
pSemCb = xSemaphoreCreateCountingStatic(uiSemaphoreMaxCount,
iSemaphoreInitialCount,
(StaticSemaphore_t*)pRtosalSemaphoreCb->cSemaphoreCB);
/* semaphore created successfully */
if (pSemCb == (void*)pRtosalSemaphoreCb->cSemaphoreCB)
{
/* assign a name to the created semaphore */
vQueueAddToRegistry((void*)pRtosalSemaphoreCb->cSemaphoreCB, (const char*)pRtosalSemaphoreName);
uiRes = D_RTOSAL_SUCCESS;
}
else
{
uiRes = D_RTOSAL_SEMAPHORE_ERROR;
}
#elif D_USE_THREADX
#error "Add THREADX appropriate definitions"
#else
#error "Add appropriate RTOS definitions"
#endif /* #ifdef D_USE_FREERTOS */
return uiRes;
}
/**
* Delete a semaphore
*
* @param pRtosalSemaphoreCb - pointer to semaphore control block to be destroyed
*
* @return u32_t - D_RTOSAL_SUCCESS
* - D_RTOSAL_SEMAPHORE_ERROR - The ptr, cMsgQueueCB, in the pRtosalSemaphoreCb is invalid
* - D_RTOSAL_CALLER_ERROR - The caller can not call this function
*/
RTOSAL_SECTION u32_t rtosalSemaphoreDestroy(rtosalSemaphore_t* pRtosalSemaphoreCb)
{
u32_t uiRes;
M_RTOSAL_VALIDATE_FUNC_PARAM(pRtosalSemaphoreCb, pRtosalSemaphoreCb == NULL, D_RTOSAL_SEMAPHORE_ERROR);
#ifdef D_USE_FREERTOS
vSemaphoreDelete(pRtosalSemaphoreCb->cSemaphoreCB);
uiRes = D_RTOSAL_SUCCESS;
#elif D_USE_THREADX
#error "Add THREADX appropriate definitions"
#else
#error "Add appropriate RTOS definitions"
#endif /* #ifdef D_USE_FREERTOS */
return uiRes;
}
/**
* Wait for a semaphore to become available
*
* @param pRtosalSemaphoreCb - Pointer to semaphore control block to wait for
* @param uiWaitTimeoutTicks - Define how many ticks to wait in case the
* semaphore isn�t available: D_RTOSAL_NO_WAIT,
* D_RTOSAL_WAIT_FOREVER or timer ticks value
*
* @return u32_t - D_RTOSAL_SUCCESS
* - D_RTOSAL_DELETED - The semaphore was already deleted when this api was called
* - D_RTOSAL_NO_INSTANCE - Counting is zero, can not get lock on the giving window time
* - D_RTOSAL_WAIT_ABORTED - aborted by different consumer (like other thread)
* - D_RTOSAL_SEMAPHORE_ERROR - The ptr, cMsgQueueCB, in the pRtosalSemaphoreCb is invalid
* - D_RTOSAL_WAIT_ERROR - Invalide uiWaitTimeoutTicks: if caller is not a thread it
* must use "NO WAIT"
*/
RTOSAL_SECTION u32_t rtosalSemaphoreWait(rtosalSemaphore_t* pRtosalSemaphoreCb, u32_t uiWaitTimeoutTicks)
{
u32_t uiRes;
#ifdef D_USE_FREERTOS
/* specify if a context switch is needed as a uiResult calling FreeRTOS ...ISR function */
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
#elif D_USE_THREADX
#error "Add THREADX appropriate definitions"
#else
#error "Add appropriate RTOS definitions"
#endif /* #ifdef D_USE_FREERTOS */
M_RTOSAL_VALIDATE_FUNC_PARAM(pRtosalSemaphoreCb, pRtosalSemaphoreCb == NULL, D_RTOSAL_SEMAPHORE_ERROR);
#ifdef D_USE_FREERTOS
/* rtosalSemaphoreWait invoked from an ISR context */
if (rtosalIsInterruptContext() == D_RTOSAL_INT_CONTEXT)
{
uiRes = xSemaphoreTakeFromISR(pRtosalSemaphoreCb->cSemaphoreCB, &xHigherPriorityTaskWoken);
}
else
{
uiRes = xSemaphoreTake((void*)pRtosalSemaphoreCb->cSemaphoreCB, uiWaitTimeoutTicks);
}
/* successfully obtained the semaphore */
if (uiRes == pdPASS)
{
uiRes = D_RTOSAL_SUCCESS;
}
else
{
uiRes = D_RTOSAL_NO_INSTANCE;
}
/* due to the wait we got an indicating that a context
switch should be requested before the interrupt exits */
if (uiRes == D_RTOSAL_SUCCESS && xHigherPriorityTaskWoken == pdTRUE)
{
rtosalContextSwitchIndicationSet();
}
#elif D_USE_THREADX
#error "Add THREADX appropriate definitions"
#else
#error "Add appropriate RTOS definitions"
#endif /* #ifdef D_USE_FREERTOS */
return uiRes;
}
/**
* Release a semaphore
*
* @param pRtosalSemaphoreCb - pointer to semaphore control block to be released
*
* @return u32_t - D_RTOSAL_SUCCESS
* - D_RTOSAL_SEMAPHORE_ERROR - The ptr, cMsgQueueCB, in the pRtosalSemaphoreCb is invalid
*/
RTOSAL_SECTION u32_t rtosalSemaphoreRelease(rtosalSemaphore_t* pRtosalSemaphoreCb)
{
u32_t uiRes;
#ifdef D_USE_FREERTOS
/* specify if a context switch is needed as a uiResult calling FreeRTOS ...ISR function */
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
#elif D_USE_THREADX
#error "Add THREADX appropriate definitions"
#else
#error "Add appropriate RTOS definitions"
#endif /* #ifdef D_USE_FREERTOS */
M_RTOSAL_VALIDATE_FUNC_PARAM(pRtosalSemaphoreCb, pRtosalSemaphoreCb == NULL, D_RTOSAL_SEMAPHORE_ERROR);
#ifdef D_USE_FREERTOS
/* rtosalSemaphoreRelease invoked from an ISR context */
if (rtosalIsInterruptContext() == D_RTOSAL_INT_CONTEXT)
{
uiRes = xSemaphoreGiveFromISR(pRtosalSemaphoreCb->cSemaphoreCB, &xHigherPriorityTaskWoken);
}
else
{
uiRes = xSemaphoreGive(pRtosalSemaphoreCb->cSemaphoreCB);
}
/* give eas successful */
if (uiRes == pdPASS)
{
uiRes = D_RTOSAL_SUCCESS;
}
else
{
uiRes = D_RTOSAL_NO_INSTANCE;
}
/* due to the wait we got an indicating that a context
switch should be requested before the interrupt exits */
if (uiRes == D_RTOSAL_SUCCESS && xHigherPriorityTaskWoken == pdTRUE)
{
rtosalContextSwitchIndicationSet();
}
#elif D_USE_THREADX
#error "Add THREADX appropriate definitions"
#else
#error "Add appropriate RTOS definitions"
#endif /* #ifdef D_USE_FREERTOS */
return uiRes;
}
|
edward-jones/riscv-fw-infrastructure | WD-Firmware/demo/demo_cache_control.c | <gh_stars>1-10
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2020-2021 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file demo_cache_control.c
* @author <NAME>
* @date 26.03.2020
* @brief The file implements the cache control demo
*/
/**
* include files
*/
#include "common_types.h"
#include "demo_platform_al.h"
#include "demo_utils.h"
#include "bsp_mem_map.h"
#include "psp_api.h"
/**
* definitions
*/
#define D_MAIN_MEM_INDEX (0)
#define D_DEMO_MAX_LOOP_COUNT (65536)
#define D_DEMO_EXPECTED_TIMER_VAL_WHEN_CACHE_ON (200000)
#define D_DEMO_EXPECTED_TIMER_VAL_WHEN_CACHE_OFF (3000000)
#define D_DEMO_OLOF_SWERV (0xC1)
#define D_REF_PERCENTAGE_WEIGHT_KEY (2) /*value equal to hundreds of %. 2=200%, 4=400% etc...*/
/**
* macros
*/
#define M_DEMO_CACHE_CONTROL_BUSYLOOP_CODE_TO_MEASURE() for (uiIndex = 0 ; uiIndex < D_DEMO_MAX_LOOP_COUNT ; uiIndex++) \
{ \
asm volatile ("nop"); \
}
/**
* types
*/
/**
* local prototypes
*/
/**
* external prototypes
*/
/**
* global variables
*/
/**
* functions
*/
void demoStart(void)
{
u32_t uiIndex;
volatile u64_t ulCounterCacheOFF;
volatile u64_t ulCounterCacheON;
volatile u64_t ulCounterCache_t1;
volatile u64_t ulCounterCache_t2;
M_DEMO_START_PRINT();
/* Register interrupt vector */
pspMachineInterruptsSetVecTableAddress(&M_PSP_VECT_TABLE);
/* Run this demo only if target is Swerv. Cannot run on Whisper */
if (D_PSP_TRUE == demoIsSwervBoard())
{
#ifdef D_SWERV_EH2
/* Initialize PSP mutexs */
pspMutexInitPspMutexs();
#endif
/* clear all mrac bits - disable cache and sideeffect bits */
for (uiIndex = 0 ; uiIndex < D_CACHE_CONTROL_MAX_NUMBER_OF_REGIONS ; uiIndex++)
{
pspMachineCacheControlDisableIcache(uiIndex);
pspMachineCacheControlDisableSideEfect(uiIndex);
}
/* Disable Machine-Timer interrupt so we won't get interrupted
timer interrupt not needed in this demo */
pspMachineInterruptsDisableIntNumber(D_PSP_INTERRUPTS_MACHINE_TIMER);
/* Activates Core's timer */
pspMachineTimerCounterSetupAndRun(0xFFFFFFFF);
/* sample the timer value */
ulCounterCache_t1 = pspMachineTimerCounterGet();
/* we disable (again) the cache just to have the same amount
of measured instructions */
pspMachineCacheControlDisableIcache(D_MAIN_MEM_INDEX);
/* execute some code */
M_DEMO_CACHE_CONTROL_BUSYLOOP_CODE_TO_MEASURE();
/* sample the timer value */
ulCounterCache_t2 = pspMachineTimerCounterGet();
/* sum the result for the "busy loop example " */
ulCounterCacheOFF = ulCounterCache_t2 - ulCounterCache_t1;
/* enable cache for the main memory so we can measure how much
time execution takes */
pspMachineCacheControlEnableIcache(D_MAIN_MEM_INDEX);
/* execute some code */
M_DEMO_CACHE_CONTROL_BUSYLOOP_CODE_TO_MEASURE();
/* sample the timer value */
ulCounterCache_t2 = pspMachineTimerCounterGet();
/* sum the result for the "busy loop example " */
ulCounterCacheON = ulCounterCache_t2 - ulCounterCacheOFF; /*OFF was the reference t1 */
/* we assumed that when cache is ON the result for "busy loops"
will be at least D_REF_PERCENTAGE_WEIGHT_KEY better */
if(ulCounterCacheOFF/ulCounterCacheON >= D_REF_PERCENTAGE_WEIGHT_KEY)
{
M_DEMO_ERR_PRINT();
asm volatile ("ebreak");
}
}
else
/* whisper */
{
printfNexys("This demo can't run under whisper");
}
M_DEMO_END_PRINT();
}
|
edward-jones/riscv-fw-infrastructure | WD-Firmware/rtos/rtosal/api_inc/rtosal_event_api.h | /*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2019 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file rtosal_event_api.h
* @author <NAME>
* @date 07.02.2019
* @brief The file defines the RTOS AL event interfaces
*/
#ifndef __RTOSAL_EVENT_API_H__
#define __RTOSAL_EVENT_API_H__
/**
* include files
*/
#include "rtosal_config.h"
#include "rtosal_defines.h"
#include "rtosal_types.h"
/**
* definitions
*/
/**
* macros
*/
/* define control block size */
#ifdef D_USE_FREERTOS
#define M_EVENT_GROUP_CB_SIZE_IN_BYTES sizeof(StaticEventGroup_t)
#elif D_USE_THREADX
#define M_EVENT_GROUP_CB_SIZE_IN_BYTES sizeof(TBD) // size of the CB struct
#else
#error "Add appropriate RTOS definitions"
#endif /* #ifdef D_USE_FREERTOS */
/**
* types
*/
/* event group */
typedef struct rtosalEventGroup
{
#ifdef D_USE_FREERTOS
void* eventGroupHandle;
#else
#error "Add appropriate RTOS definitions"
#endif /* #ifdef D_USE_FREERTOS */
s08_t cEventGroupCB[M_EVENT_GROUP_CB_SIZE_IN_BYTES];
} rtosalEventGroup_t;
/* event group bits */
typedef u32_t rtosalEventBits_t;
/**
* local prototypes
*/
/**
* external prototypes
*/
/**
* global variables
*/
/**
* APIs
*/
/**
* Create an event group
*/
u32_t rtosalEventGroupCreate(rtosalEventGroup_t* pRtosalEventGroupCb, s08_t* pRtosalEventGroupName);
/**
* Destroy a specific event group
*/
u32_t rtosalEventGroupDestroy(rtosalEventGroup_t* pRtosalEventGroupCb);
/**
* Set the event bits of a specific event group
*/
u32_t rtosalEventGroupSet(rtosalEventGroup_t* pRtosalEventGroupCb,
rtosalEventBits_t stSetRtosalEventBits,
u32_t uiSetOption, rtosalEventBits_t* pRtosalEventBits);
/**
* Retrieve the event bits of a specific event group
*/
u32_t rtosalEventGroupGet(rtosalEventGroup_t* pRtosalEventGroupCb, u32_t uiRetrieveEvents,
rtosalEventBits_t* pRtosalEventBits, u32_t uiRetrieveOption,
u32_t uiWaitTimeoutTicks);
#endif /* __RTOSAL_EVENT_API_H__ */
|
edward-jones/riscv-fw-infrastructure | WD-Firmware/rtos/rtosal/api_inc/rtosal_semaphore_api.h | <gh_stars>10-100
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2019 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file rtosal_semaphore_api.h
* @author <NAME>
* @date 07.02.2019
* @brief The file defines the RTOS AL semaphore interfaces
*/
#ifndef __RTOSAL_SEMAPHORE_API_H__
#define __RTOSAL_SEMAPHORE_API_H__
/**
* include files
*/
#include "rtosal_config.h"
#include "rtosal_defines.h"
#include "rtosal_types.h"
/**
* definitions
*/
/**
* macros
*/
#ifdef D_USE_FREERTOS
#define M_SEMAPHORE_CB_SIZE_IN_BYTES sizeof(StaticSemaphore_t)
#elif D_USE_THREADX
#define M_SEMAPHORE_CB_SIZE_IN_BYTES sizeof(TBD) // size of the CB struct
#else
#error "Add appropriate RTOS definitions"
#endif /* #ifdef D_USE_FREERTOS */
/**
* types
*/
/* semaphore */
typedef struct rtosalSemaphore
{
s08_t cSemaphoreCB[M_SEMAPHORE_CB_SIZE_IN_BYTES];
} rtosalSemaphore_t;
/**
* local prototypes
*/
/**
* external prototypes
*/
/**
* global variables
*/
/**
* APIs
*/
/**
* Create a semaphore
*/
u32_t rtosalSemaphoreCreate(rtosalSemaphore_t* pRtosalSemaphoreCb, s08_t *pRtosalSemaphoreName,
s32_t iSemaphoreInitialCount, u32_t uiSemaphoreMaxCount);
/**
* Delete a semaphore
*/
u32_t rtosalSemaphoreDestroy(rtosalSemaphore_t* pRtosalSemaphoreCb);
/**
* Wait for a semaphore to become available
*/
u32_t rtosalSemaphoreWait(rtosalSemaphore_t* pRtosalSemaphoreCb, u32_t uiWaitTimeoutTicks);
/**
* Release a semaphore
*/
u32_t rtosalSemaphoreRelease(rtosalSemaphore_t* pRtosalSemaphoreCb);
#endif /* __RTOSAL_SEMAPHORE_API_H__ */
|
edward-jones/riscv-fw-infrastructure | WD-Firmware/psp/api_inc/psp_performance_monitor_el2.h | <filename>WD-Firmware/psp/api_inc/psp_performance_monitor_el2.h
/*
* Copyright (c) 2010-2016 Western Digital, Inc.
*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2020 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file psp_performance_monitor_el2.h
* @author <NAME>
* @date 20.08.2020
* @brief performance monitor api provider for SweRV EL2
*
*/
#ifndef _PSP_PERFORMANCE_MONITOR_EL2_H_
#define _PSP_PERFORMANCE_MONITOR_EL2_H_
/**
* include files
*/
/**
* definitions
*/
/*
* Performance monitoring events
*/
#define D_BITMANIP_COMMITED 54
#define D_BUS_LOADS_COMMITED 55
#define D_BUS_STORES_COMMITED 56
#define D_CYCLES_IN_SLEEP_C3_STATE 512
#define D_DMA_READS_ALL 513
#define D_DMA_WRITES_ALL 514
#define D_DMA_READS_TO_DCCM 515
#define D_DMA_WRITESS_TO_DCCM 516
/**
* macros
*/
/**
* types
*/
/**
* local prototypes
*/
/**
* external prototypes
*/
/**
* global variables
*/
/**
* APIs
*/
/**
* @brief The function disable a specific performance monitor counter
*
* @param uiPerfMonCounter- Performance-Monitor counter to disable/enable
* supported counters to enable/disbale are:
* D_PSP_CYCLE_COUNTER
* D_PSP_INSTRET_COUNTER
* D_PSP_COUNTER0
* D_PSP_COUNTER1
* D_PSP_COUNTER2
* D_PSP_COUNTER3
*/
void pspMachinePerfMonitorDisableCounter(u32_t uiPerfMonCounter);
/**
* @brief The function enable a specific performance monitor counter
*
* @param uiPerfMonCounter- Performance-Monitor counter to disable/enable
* supported counters to enable/disbale are:
* D_PSP_CYCLE_COUNTER
* D_PSP_INSTRET_COUNTER
* D_PSP_COUNTER0
* D_PSP_COUNTER1
* D_PSP_COUNTER2
* D_PSP_COUNTER3
*/
void pspMachinePerfMonitorEnableCounter(u32_t uiPerfMonCounter);
#endif /* _PSP_PERFORMANCE_MONITOR_EL2_H_ */
|
edward-jones/riscv-fw-infrastructure | WD-Firmware/psp/api_inc/psp_mutex_eh2.h | <filename>WD-Firmware/psp/api_inc/psp_mutex_eh2.h
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2020 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file psp_mutex_eh2.h
* @author <NAME>
* @date 24.06.2020
* @brief The file defines the psp mutex and relevant APIs
* Relevant for SweRV-EH2 (multi-harts and atomic commands supported)
*
*/
#ifndef __PSP_MUTEX_EH2_H__
#define __PSP_MUTEX_EH2_H__
/**
* include files
*/
/**
* definitions
*/
#define D_PSP_MUTEX_OCCUIPED 1 /* 'occupied' means- the mutex is used by the application (can 'lock' and 'free' it) */
#define D_PSP_MUTEX_UNOCCUIPED 0 /* 'unoccupied' means- the mutex is not used by the application (cannot 'lock' or 'free' it) */
#define D_PSP_MUTEX_LOCKED 1
#define D_PSP_MUTEX_UNLOCKED 0
/**
* types
*/
typedef struct pspMutexControlBlock
{
u32_t uiMutexState; /* D_PSP_MUTEX_LOCKED / D_PSP_MUTEX_UNLOCKED */
u32_t uiMutexOccupied :1; /* D_PSP_MUTEX_OCCUIPED / D_PSP_MUTEX_UNOCCUIPED */
u32_t uiMutexCreator :1; /* Created by: 0 - Hart0 / 1 - Hart1 . Only the creator is allowed to destroy */
} pspMutexCb_t;
/**
* local prototypes
*/
/**
* external prototypes
*/
/**
* macros
*/
/**
* global variables
*/
/**
* APIs
*/
/**
* @brief - Initialize (zero) mutexs that PSP is using internally for multi-harts safe activities
*
*/
void pspMutexInitPspMutexs(void);
/**
* @brief - Initialize (zero) heap of mutexs.
*
* @parameter - Address of the mutexs heap
* @parameter - Number of mutexs in the heap
*
*/
void pspMutexHeapInit(pspMutexCb_t* pMutexHeapAddress, u32_t uiNumOfMutexs);
/**
* @brief - Create a mutex in the mutexs-heap.
* - Mark it as 'occupied'
* - Mark the hart that created it
*
* @return - Address of the created mutex. In case of failure return NULL.
*/
pspMutexCb_t* pspMutexCreate(void);
/**
* @brief - Destroy (remove the 'occupied' mark) a mutex in the mutexs-heap
*
* @parameter - Address of the mutex to be destroyed
*
* @return - Address of the destroyed mutex. In case of failure return NULL.
*/
pspMutexCb_t* pspMutexDestroy(pspMutexCb_t* pMutex);
/**
* @brief - Lock a mutex using atomic commands.
*
* @parameter - pointer to the mutex to lock
*
*/
void pspMutexAtomicLock(pspMutexCb_t* pMutex);
/**
* @brief - Free a mutex using atomic commands.
*
* @parameter - pointer to the mutex to free
*
*/
void pspMutexAtomicUnlock(pspMutexCb_t* pMutex);
#endif /* __PSP_MUTEX_EH2_H__ */
|
edward-jones/riscv-fw-infrastructure | WD-Firmware/common/api_inc/common_defines.h | /*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2019 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file common_defines.h
* @author <NAME>
* @date 21.01.2019
* @brief The file defines the fw defines
*/
#ifndef __FW_DEFINES_H__
#define __FW_DEFINES_H__
/**
* include files
*/
/**
* definitions
*/
/**
* macros
*/
/**
* types
*/
/**
* local prototypes
*/
/**
* external prototypes
*/
/**
* global variables
*/
/**
* APIs
*/
#endif /* __FW_DEFINES_H__ */
|
edward-jones/riscv-fw-infrastructure | WD-Firmware/demo/demo_cti_rtosal.c | <reponame>edward-jones/riscv-fw-infrastructure<gh_stars>10-100
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2019-2021 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* include files
*/
#include "common_types.h"
#include "demo_platform_al.h"
#include "demo_utils.h"
#include "cti_api.h"
#include "comrv_api.h"
#include "rtosal_task_api.h"
#include "rtosal_time_api.h"
#include "rtosal_mutex_api.h"
#include "rtosal_event_api.h"
#include "psp_api.h"
/**
* definitions
*/
/* we need to flush the i$ when loading code to memory area (comrv cache) */
/* TOOD: try to use only FENCEI */
#define M_DEMO_COMRV_RTOS_FENCE() M_PSP_INST_FENCE(); \
M_PSP_INST_FENCEI();
/* The rate the data is sent to the queue, specified in milliseconds, and
converted to ticks (using the definition of D_TICK_TIME_MS) */
#define D_MAIN_QUEUE_SEND_PERIOD_TICKS (200/D_TICK_TIME_MS)
/* Stack size of the tasks in this application */
#define D_TASK_A_STACK_SIZE 450
#define D_TASK_B_STACK_SIZE 450
#define D_DEMO_TASK_RUNNING 0
#define D_DEMO_TASK_COMPLETED 1
#define D_DEMO_EVENT 0xFFFF
/**
* macros
*/
/**
* types
*/
typedef u32_t (*DemoExternalErrorHook_t)(const comrvErrorArgs_t* pErrorArgs);
/**
* local prototypes
*/
void demoCreateTasks(void *pParam);
void demoTestTaskA(void* pValueToSend);
void demoTestTaskB(void* pValueToSend);
/**
* external prototypes
*/
extern void* _OVERLAY_STORAGE_START_ADDRESS_;
extern u32_t xcrc32(const u08_t *pBuf, s32_t siLen, u32_t uiInit);
/**
* global variables
*/
/* globals related to the tasks in this demo */
static rtosalTask_t stTestTaskA;
static rtosalTask_t stTestTaskB;
static rtosalStackType_t uTestTaskAStackBuffer[D_TASK_A_STACK_SIZE];
static rtosalStackType_t uTestTaskBStackBuffer[D_TASK_B_STACK_SIZE];
rtosalMutex_t stComrvMutex;
static u32_t uiPrevIntState;
rtosalEventGroup_t stRtosalEventGroupCb;
u32_t G_uiTaskBStatus;
DemoExternalErrorHook_t fptrDemoExternalErrorHook = NULL;
/**
* functions
*/
void demoStart(void)
{
u32_t uiIsSwerv;
comrvInitArgs_t stComrvInitArgs;
stComrvInitArgs.ucCanLoadComrvTables = 1;
M_DEMO_START_PRINT();
uiIsSwerv = demoIsSwervBoard();
/* verify we only run whisper */
if (uiIsSwerv == D_PSP_FALSE)
{
/* Disable the timer interrupts until setup is done. */
pspMachineInterruptsDisableIntNumber(D_PSP_INTERRUPTS_MACHINE_TIMER);
/* Init ComRV engine */
comrvInit(&stComrvInitArgs);
rtosalStart(demoCreateTasks);
}
printfNexys("This demo can only execute under whisper");
M_DEMO_END_PRINT();
}
/**
* demoCreateTasks
*
* Initialize the application:
* - Register unhandled exceptions, Ecall exception and Timer ISR
* - Create the Rx tasks
* - Create the comrv mutex
*
* This function is called from RTOS abstraction layer. After its
* completion, the scheduler is kicked on and the tasks are start to be active
*
*/
void demoCreateTasks(void *pParam)
{
u32_t res;
/* Disable the machine external & timer interrupts until setup is done. */
pspMachineInterruptsDisableIntNumber(D_PSP_INTERRUPTS_MACHINE_EXT);
pspMachineInterruptsDisableIntNumber(D_PSP_INTERRUPTS_MACHINE_TIMER);
/* Enable the Machine-External bit in MIE */
pspMachineInterruptsEnableIntNumber(D_PSP_INTERRUPTS_MACHINE_EXT);
/* Create the rx task */
res = rtosalTaskCreate(&stTestTaskA, (s08_t*)"TASK-A-RV", E_RTOSAL_PRIO_30,
demoTestTaskA, (u32_t)NULL, D_TASK_A_STACK_SIZE,
uTestTaskAStackBuffer, 0, D_RTOSAL_AUTO_START, 0);
if (res != D_RTOSAL_SUCCESS)
{
demoOutputMsg("Test-A Task creation failed\n", 24);
M_DEMO_ERR_PRINT();
M_DEMO_ENDLESS_LOOP();
}
/* Create the test task */
res = rtosalTaskCreate(&stTestTaskB, (s08_t*)"TASK-B-RV", E_RTOSAL_PRIO_29,
demoTestTaskB, (u32_t)NULL, D_TASK_B_STACK_SIZE,
uTestTaskBStackBuffer, 0, D_RTOSAL_AUTO_START, 0);
if (res != D_RTOSAL_SUCCESS)
{
demoOutputMsg("Test-B Task creation failed\n", 24);
M_DEMO_ERR_PRINT();
M_DEMO_ENDLESS_LOOP();
}
/* create the comrv mutex */
res = rtosalMutexCreate(&stComrvMutex, (s08_t*)"comrv", D_RTOSAL_INHERIT);
if (res != D_RTOSAL_SUCCESS)
{
demoOutputMsg("comrv mutex creation failed\n", 28);
M_DEMO_ERR_PRINT();
M_DEMO_ENDLESS_LOOP();
}
res = rtosalEventGroupCreate(&stRtosalEventGroupCb, NULL);
if (res != D_RTOSAL_SUCCESS)
{
demoOutputMsg("event creation failed\n", 22);
M_DEMO_ERR_PRINT();
M_DEMO_ENDLESS_LOOP();
}
/* set timer tick period */
rtosalTimerSetPeriod(D_TICK_TIME_MS * (D_CLOCK_RATE / D_PSP_MSEC));
}
/**
* Test task A function (low priority)
*
* pvParameters - not in use
*/
void demoTestTaskA(void* pValueToSend)
{
rtosalEventBits_t stRtosalEventBits;
/* call the test environment */
ctiMain();
/* if both tasks tests completed */
if (G_uiTaskBStatus == D_DEMO_TASK_COMPLETED)
{
M_DEMO_END_PRINT();
}
/* no need to continue from here - wait for a non existing event */
rtosalEventGroupGet(&stRtosalEventGroupCb, D_DEMO_EVENT,
&stRtosalEventBits, D_RTOSAL_OR_CLEAR, D_RTOSAL_WAIT_FOREVER);
}
/**
* Test task B function (higher priority than task A)
*
* pvParameters - not in use
*/
void demoTestTaskB(void* pValueToSend)
{
rtosalEventBits_t stRtosalEventBits;
/* mark the task has started running */
G_uiTaskBStatus = D_DEMO_TASK_RUNNING;
/* run the test */
ctiTaskBTest();
/* mark task has completed */
G_uiTaskBStatus = D_DEMO_TASK_COMPLETED;
/* no need to continue from here - wait for a non existing event */
rtosalEventGroupGet(&stRtosalEventGroupCb, D_DEMO_EVENT,
&stRtosalEventBits, D_RTOSAL_OR_CLEAR, D_RTOSAL_WAIT_FOREVER);
}
/**
* memory copy hook
*
* @param none
*
* @return none
*/
void comrvMemcpyHook(void* pDest, void* pSrc, u32_t uiSizeInBytes)
{
u32_t loopCount = uiSizeInBytes/(sizeof(u32_t)), i;
/* copy dwords */
for (i = 0; i < loopCount ; i++)
{
*((u32_t*)pDest + i) = *((u32_t*)pSrc + i);
}
loopCount = uiSizeInBytes - (loopCount*(sizeof(u32_t)));
/* copy bytes */
for (i = (i-1)*(sizeof(u32_t)) ; i < loopCount ; i++)
{
*((u08_t*)pDest + i) = *((u08_t*)pSrc + i);
}
}
/**
* load overlay group hook
*
* @param pLoadArgs - refer to comrvLoadArgs_t for exact args
*
* @return loaded address or NULL if unable to load
*/
void* comrvLoadOvlayGroupHook(comrvLoadArgs_t* pLoadArgs)
{
g_stCtiOvlFuncsHitCounter.uiComrvLoad++;
comrvMemcpyHook(pLoadArgs->pDest, (u08_t*)&_OVERLAY_STORAGE_START_ADDRESS_ + pLoadArgs->uiGroupOffset, pLoadArgs->uiSizeInBytes);
/* it is upto the end user of comrv to synchronize the instruction and data stream after
overlay data has been written to destination memory */
M_DEMO_COMRV_RTOS_FENCE();
return pLoadArgs->pDest;
}
/**
* set a function pointer to be called by comrvErrorHook
*
* @param pErrorArgs - pointer to error arguments
*
* @return none
*/
void demoComrvSetErrorHandler(void* fptrAddress)
{
fptrDemoExternalErrorHook = fptrAddress;
}
/**
* error hook
*
* @param pErrorArgs - pointer to error arguments
*
* @return none
*/
void comrvErrorHook(const comrvErrorArgs_t* pErrorArgs)
{
comrvStatus_t stComrvStatus;
comrvGetStatus(&stComrvStatus);
/* if external error handler was set e.g. cti */
if (fptrDemoExternalErrorHook == NULL)
{
/* we can't continue so loop forever */
M_DEMO_ERR_PRINT();
M_DEMO_ENDLESS_LOOP();
}
else
{
fptrDemoExternalErrorHook(pErrorArgs);
}
}
/**
* Invalidate data cache hook
*
* @param pAddress - memory address to invalidate
* uiNumSizeInBytes - number of bytes to invalidate
*
* @return none
*/
void comrvInvalidateDataCacheHook(const void* pAddress, u32_t uiNumSizeInBytes)
{
(void)pAddress;
(void)uiNumSizeInBytes;
}
/**
* enter critical section
*
* @param None
*
* @return 0 - success, non-zero - failure
*/
u32_t comrvEnterCriticalSectionHook(void)
{
if (rtosalGetSchedulerState() != D_RTOSAL_SCHEDULER_NOT_STARTED)
{
if (rtosalMutexWait(&stComrvMutex, D_RTOSAL_WAIT_FOREVER) != D_RTOSAL_SUCCESS)
{
return 1;
}
}
else
{
pspMachineInterruptsDisable(&uiPrevIntState);
}
return 0;
}
/**
* exit critical section
*
* @param None
*
* @return 0 - success, non-zero - failure
*/
u32_t comrvExitCriticalSectionHook(void)
{
if (rtosalGetSchedulerState() != D_RTOSAL_SCHEDULER_NOT_STARTED)
{
if (rtosalMutexRelease(&stComrvMutex) != D_RTOSAL_SUCCESS)
{
return 1;
}
}
else
{
pspMachineInterruptsRestore(uiPrevIntState);
}
return 0;
}
/**
* crc calculation hook
*
* @param pAddress - memory address to calculate
* memSizeInBytes - number of bytes to calculate
* uiExpectedResult - expected crc result
*
* @return calculated CRC
*/
#ifdef D_COMRV_ENABLE_CRC_SUPPORT
u32_t comrvCrcCalcHook(const void* pAddress, u16_t usMemSizeInBytes, u32_t uiExpectedResult)
{
volatile u32_t uiCrc;
uiCrc = xcrc32(pAddress, usMemSizeInBytes, 0xffffffff);
return !(uiExpectedResult == uiCrc);
}
#endif /* D_COMRV_ENABLE_CRC_SUPPORT */
|
edward-jones/riscv-fw-infrastructure | WD-Firmware/board/nexys_a7_el2/bsp/bsp_external_interrupts.h | /*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2019 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file bsp_external_interrupts.h
* @author <NAME>
* @date 29.03.2020
* @brief External_interrupts creation in Nexys_A7 SweRVolf FPGA
*/
#ifndef __BSP_EXTERNAL_INTERRUPTS_H__
#define __BSP_EXTERNAL_INTERRUPTS_H__
/**
* include files
*/
/**
* definitions
*/
/* Specified RAM address for generation of external interrupts (SwerVolf special implementation) */
#if (0 != D_EXT_INTS_GENERATION_REG_ADDRESS)
#define D_BSP_EXT_INTS_GENERATION_REGISTER D_EXT_INTS_GENERATION_REG_ADDRESS
#else
#error "External interrupts generation address is not defined"
#endif
/* In SwreVolf we have the capability to create 2 different external interrupts */
#define D_BSP_IRQ_3 3
#define D_BSP_IRQ_4 4
#define D_BSP_FIRST_IRQ_NUM D_BSP_IRQ_3
#define D_BSP_LAST_IRQ_NUM D_BSP_IRQ_4
/*
Register 0x8000100B (offset B in sys_con memory, at SweRVolf FPGA) is used for generating external interrupts by demo FW
-------------------------------------------
| Bits | Name | Description |
| ---- | ------------------ | ------------------
| 7 | irq4_triger | --> 1 = Trigger IRQ line 4
| 6 | irq4_type | --> Interrupt type: 0 = Level. IRQ4 is asserted until sw_irq4 is cleared, 1 = Edge. Writing to sw_irq4 only asserts IRQ4 for one clock cycle
| 5 | irq4_polarity | --> IRQ4 polarity: 0 = Active high, 1 = active low
| 4 | rout_timer_to_irq4 | --> When set to '1', Timer interrupt is routed to irq4
| 3 | irq3_triger | --> 1 = Trigger IRQ line 3
| 2 | irq3_type | --> Interrupt type: 0 = Level. IRQ3 is asserted until sw_irq3 is cleared, 1 = Edge. Writing to sw_irq3 only asserts IRQ3 for one clock cycle
| 1 | irq3_polarity | --> IRQ3 polarity: 0 = Active high, 1 = active low
| 0 | rout_timer_to_irq3 | --> When set to '1', Timer interrupt is routed to irq3
-------------------------------------------*/
#define D_BSP_ROUT_TIMER_TO_IRQ3 0
#define D_BSP_IRQ3_POLARITY_BIT 1
#define D_BSP_IRQ3_TYPE_BIT 2
#define D_BSP_IRQ3_ACTIVATE_BIT 3
#define D_BSP_ROUT_TIMER_TO_IRQ4 4
#define D_BSP_IRQ4_POLARITY_BIT 5
#define D_BSP_IRQ4_TYPE_BIT 6
#define D_BSP_IRQ4_ACTIVATE_BIT 7
/**
* types
*/
/**
* local prototypes
*/
/**
* external prototypes
*/
/**
* macros
*/
/**
* global variables
*/
/**
* APIs
*/
/**
* Initialize the register that used for triggering IRQs generation
*
* @param uiExtInterruptPolarity - indicates the polarity mode. Based on that, the triggering register should be initialized.
*/
void bspInitializeGenerationRegister(u32_t uiExtInterruptPolarity);
/**
* For IRQ3 or IRQ4 on the SweRVolf FPGA board, set polarity, type(i.e.edge/level) and triggering the interrupt
*
* @param - uiExtInterruptNumber - D_BSP_IRQ_3 or D_BSP_IRQ_4
* @param - uiExtInterruptPolarity - Active High / Low
* @param - uiExtInterruptType - Edge (pulse of 1 clock cycle) / Level (change level)
*/
void bspGenerateExtInterrupt(u32_t uiExtInterruptNumber, u32_t uiExtInterruptPolarity, u32_t uiExtInterruptType);
/**
* Clear generation of external interrupt(s)
*
* @param - uiExtInterruptNumber - D_BSP_IRQ_3 or D_BSP_IRQ_4
*
*/
void bspClearExtInterrupt(u32_t uiExtInterruptNumber);
#endif /* __BSP_EXTERNAL_INTERRUPTS_H__ */
|
edward-jones/riscv-fw-infrastructure | WD-Firmware/psp/psp_internal_timers_eh1.c | <filename>WD-Firmware/psp/psp_internal_timers_eh1.c
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2020-2021 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file psp_internal_timers_eh1.c
* @author <NAME>
* @date 8.12.2019
* @brief This file implements EH1 timers service functions
*
*/
/**
* include files
*/
#include "psp_api.h"
/**
* definitions
*/
/**
* macros
*/
/**
* types
*/
/**
* local prototypes
*/
/**
* external prototypes
*/
/**
* global variables
*/
/**
* Internal functions
*/
/**
* @brief Setup and activate Internal core's Timer
*
* @param - uiTimer - indicates which timer to setup and run
*
* @param - udPeriodCycles - defines the timer's period in cycles
*
*/
D_PSP_TEXT_SECTION void pspMachineInternalTimerCounterSetupAndRun(u32_t uiTimer, u64_t udPeriodCycles)
{
u32_t uiNow, uiThen;
M_PSP_ASSERT((D_PSP_INTERNAL_TIMER0 == uiTimer) || (D_PSP_INTERNAL_TIMER1 == uiTimer));
switch (uiTimer)
{
case D_PSP_INTERNAL_TIMER0:
/* Read Timer0 counter */
uiNow = M_PSP_READ_CSR(D_PSP_MITCNT0_NUM);
uiThen = uiNow + (u32_t)udPeriodCycles;
/* Set Timer0 bound */
M_PSP_WRITE_CSR(D_PSP_MITBND0_NUM, uiThen);
/* Enable Timer0 counting */
M_PSP_SET_CSR(D_PSP_MITCTL0_NUM, D_PSP_MITCTL_EN_MASK);
break;
case D_PSP_INTERNAL_TIMER1:
/* Read Timer1 counter */
uiNow = M_PSP_READ_CSR(D_PSP_MITCNT1_NUM);
uiThen = uiNow + (u32_t)udPeriodCycles;
/* Set Timer1 bound */
M_PSP_WRITE_CSR(D_PSP_MITBND1_NUM, uiThen);
/* Enable Timer1 counting */
M_PSP_SET_CSR(D_PSP_MITCTL1_NUM, D_PSP_MITCTL_EN_MASK);
break;
default:
break;
}
}
/**
* @brief Get Core Internal Timer counter value
*
* @param - uitimer - indicates from which timer to get the counter value
*
* @return u64_t - Timer counter value
*
*/
D_PSP_TEXT_SECTION u64_t pspMachineInternalTimerCounterGet(u32_t uiTimer)
{
u64_t udCounter = 0;
M_PSP_ASSERT((D_PSP_INTERNAL_TIMER0 == uiTimer) || (D_PSP_INTERNAL_TIMER1 == uiTimer));
switch (uiTimer)
{
case D_PSP_INTERNAL_TIMER0:
udCounter = (u64_t)M_PSP_READ_CSR(D_PSP_MITCNT0_NUM);
break;
case D_PSP_INTERNAL_TIMER1:
udCounter = (u64_t)M_PSP_READ_CSR(D_PSP_MITCNT1_NUM);
break;
default:
break;
}
return (udCounter);
}
/**
* @brief Get Core Internal Timer compare counter value
*
* @param - uitimer - indicates from which timer to get the compare-counter value
*
* @return u64_t – Time compare counter value
*
*/
D_PSP_TEXT_SECTION u64_t pspMachineInternalTimerCompareCounterGet(u32_t uiTimer)
{
u64_t udCounterCompare = 0;
M_PSP_ASSERT((D_PSP_INTERNAL_TIMER0 == uiTimer) || (D_PSP_INTERNAL_TIMER1 == uiTimer));
switch (uiTimer)
{
case D_PSP_INTERNAL_TIMER0:
udCounterCompare = (u64_t)M_PSP_READ_CSR(D_PSP_MITBND0_NUM);
break;
case D_PSP_INTERNAL_TIMER1:
udCounterCompare = (u64_t)M_PSP_READ_CSR(D_PSP_MITBND1_NUM);
break;
default:
break;
}
return (udCounterCompare);
}
/**
* @brief Enable Core Internal timer counting when core in sleep mode
*
* @param - uiTimer - indicates which timer to setup
*
*/
D_PSP_TEXT_SECTION void pspMachineInternalTimerEnableCountInSleepMode(u32_t uiTimer)
{
M_PSP_ASSERT((D_PSP_INTERNAL_TIMER0 == uiTimer) || (D_PSP_INTERNAL_TIMER1 == uiTimer));
switch (uiTimer)
{
case D_PSP_INTERNAL_TIMER0:
M_PSP_SET_CSR(D_PSP_MITCTL0_NUM,D_PSP_MITCTL_HALT_EN_MASK);
break;
case D_PSP_INTERNAL_TIMER1:
M_PSP_SET_CSR(D_PSP_MITCTL1_NUM,D_PSP_MITCTL_HALT_EN_MASK);
break;
default:
break;
}
}
/**
* @brief Disable Core Internal timer counting when core in sleep mode
*
* @param - uiTimer - indicates which timer to setup
*
*/
D_PSP_TEXT_SECTION void pspMachineInternalTimerDisableCountInSleepMode(u32_t uiTimer)
{
M_PSP_ASSERT((D_PSP_INTERNAL_TIMER0 == uiTimer) || (D_PSP_INTERNAL_TIMER1 == uiTimer));
switch (uiTimer)
{
case D_PSP_INTERNAL_TIMER0:
M_PSP_CLEAR_CSR(D_PSP_MITCTL0_NUM,D_PSP_MITCTL_HALT_EN_MASK);
break;
case D_PSP_INTERNAL_TIMER1:
M_PSP_CLEAR_CSR(D_PSP_MITCTL1_NUM,D_PSP_MITCTL_HALT_EN_MASK);
break;
default:
break;
}
}
/**
* @brief Enable Core Internal timer counting when core in in stall
*
* @param - uiTimer - indicates which timer to setup
*
*/
D_PSP_TEXT_SECTION void pspMachineInternalTimerEnableCountInStallMode(u32_t uiTimer)
{
M_PSP_ASSERT((D_PSP_INTERNAL_TIMER0 == uiTimer) || (D_PSP_INTERNAL_TIMER1 == uiTimer));
switch (uiTimer)
{
case D_PSP_INTERNAL_TIMER0:
M_PSP_SET_CSR(D_PSP_MITCTL0_NUM,D_PSP_MITCTL_PAUSE_EN_MASK);
break;
case D_PSP_INTERNAL_TIMER1:
M_PSP_SET_CSR(D_PSP_MITCTL1_NUM,D_PSP_MITCTL_PAUSE_EN_MASK);
break;
default:
break;
}
}
/**
* @brief Disable Core Internal timer counting when core in in stall
*
* @param - uiTimer - indicates which timer to setup
*
*/
D_PSP_TEXT_SECTION void pspMachineInternalTimerDisableCountInStallMode(u32_t uiTimer)
{
M_PSP_ASSERT((D_PSP_INTERNAL_TIMER0 == uiTimer) || (D_PSP_INTERNAL_TIMER1 == uiTimer));
switch (uiTimer)
{
case D_PSP_INTERNAL_TIMER0:
M_PSP_CLEAR_CSR(D_PSP_MITCTL0_NUM,D_PSP_MITCTL_PAUSE_EN_MASK);
break;
case D_PSP_INTERNAL_TIMER1:
M_PSP_CLEAR_CSR(D_PSP_MITCTL1_NUM,D_PSP_MITCTL_PAUSE_EN_MASK);
break;
default:
break;
}
}
|
edward-jones/riscv-fw-infrastructure | WD-Firmware/psp/api_inc/psp_csrs_eh2.h | /*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2019 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file psp_csrs_eh2.h
* @author <NAME>
* @date 01.12.2019
* @brief Definitions of Swerv's (EH2 version) CSRs
*
*/
#ifndef __PSP_CSRS_EH2_H__
#define __PSP_CSRS_EH2_H__
/**
* include files
*/
/**
* definitions
*/
/**********************************/
/* Non standard CSRs in SweRV EH2 */
/**********************************/
#define D_PSP_MHARTSTART_NUM 0x7FC /* Hart Start Control register */
#define D_PSP_MNMIPDEL_NUM 0x7FE /* NMI Pin Delegation register */
#define D_PSP_MNMIPDEL_MASK 0x00000003 /* Only bits 0 and 1 are relevant */
#define D_PSP_MHARTNUM_NUM 0xFC4 /* Total Number of Harts register */
#define D_PSP_MHARTNUM_TOTAL_MASK 0x00000003 /* Total number of Harts in this core - bits 0..1 */
/*************************************/
/* PIC memory mapped registers */
/*************************************/
/* meidel CSR */
#define D_PSP_PIC_MEIDEL_OFFSET 0x6000
#define D_PSP_PIC_MEIDEL_ADDR PSP_PIC_BASE_ADDRESS + D_PSP_PIC_MEIDEL_OFFSET /* External interrupts delegation register */
#define D_PSP_MEIDEL_DELEGATION_MASK 0x00000001 /* bit 0 */
/* meitp CSR */
#define D_PSP_PIC_MEITP_OFFSET 0x1800
#define D_PSP_MEITP_ADDR PSP_PIC_BASE_ADDRESS + D_PSP_PIC_MEITP_OFFSET /* External interrupts per-hart pending */
/*****************************************/
/* EH2 specific fields in standard CSRs */
/*****************************************/
/* mhartid CSR */
//#define D_PSP_MHARTID_NUM 0xF14
#define D_PSP_MHARTID_CORE_ID_MASK 0xFFFFFFF0 /* Core ID field - bits 4..31 */
#define D_PSP_MHARTID_CORE_ID_SHIFT 4 /* Core ID field shift - 4 */
#define D_PSP_MHARTID_HART_ID_MASK 0x0000000F /* Hart ID field - bits 0..3 */
#define D_PSP_MHARTID_HART_ID_SHIFT 0 /* Hart ID field shift - 0 */
/**
* macros
*/
/**
* types
*/
/**
* local prototypes
*/
/**
* external prototypes
*/
/**
* global variables
*/
/**
* APIs
*/
#endif /* __PSP_CSRS_EH2_H__ */
|
edward-jones/riscv-fw-infrastructure | WD-Firmware/demo/demo_software_interrupts.c | /*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2019 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* include files
*/
#include "psp_api.h"
#include "demo_platform_al.h"
#include "demo_utils.h"
/**
* definitions
*/
#define D_DEMO_NUM_OF_SW_INTERRUPTS 15
/**
* external prototypes
*/
u32_t* pSwIntCtrl = (u32_t*)D_SW_INT_ADDRESS;
/**
* global variables
*/
u32_t g_uiSwIsrCount1 = 0;
u32_t g_uiSwIsrCount2 = 0;
u32_t g_uiSyncPoint = 0;
/**
* macros
*/
/* Macros to trigger and clear software interrupt (relevant to Whisper only) */
#define M_DEMO_TRIGGER_SW_INTERRUPT() *pSwIntCtrl = 1;
#define M_DEMO_CLEAR_SW_INTERRUPT() *pSwIntCtrl = 0;
#define M_DEMO_SET_SYNC_POINT() g_uiSyncPoint = 1;
#define M_DEMO_CLEAR_SYNC_POINT() g_uiSyncPoint = 0;
#define M_DEMO_IS_SYNC_POINT_SET() (g_uiSyncPoint != 0)
/**
* types
*/
/**
* local prototypes
*/
/**
* functions
*/
void demoSoftwareIsr1()
{
g_uiSwIsrCount1++;
M_DEMO_SET_SYNC_POINT();
M_DEMO_CLEAR_SW_INTERRUPT();
}
void demoSoftwareIsr2()
{
g_uiSwIsrCount2++;
M_DEMO_SET_SYNC_POINT();
M_DEMO_CLEAR_SW_INTERRUPT();
}
/**
* demoSoftwareInterrupts - demo for software interrupt setup and ISRs
* - part1: enable software interrupts and verify they occur
* - part2: disable software interrupts and verify they do not occur
*/
void demoSoftwareInterrupts(void)
{
u32_t uiInterruptsStatus;
u32_t uiNumberOfSwInterrupts;
/* Disable interrupts */
pspMachineInterruptsDisable(&uiInterruptsStatus);
/* Register software ISR number 1 */
pspMachineInterruptsRegisterIsr(demoSoftwareIsr1, E_MACHINE_SOFTWARE_CAUSE);
/* Enable software interrupts */
pspMachineInterruptsEnableIntNumber(D_PSP_INTERRUPTS_MACHINE_SW);
/* Enable interrupts*/
pspMachineInterruptsEnable();
/* Create a series of software interrupts */
for(uiNumberOfSwInterrupts = 0; uiNumberOfSwInterrupts < D_DEMO_NUM_OF_SW_INTERRUPTS; uiNumberOfSwInterrupts++)
{
M_DEMO_TRIGGER_SW_INTERRUPT();
while(M_DEMO_IS_SYNC_POINT_SET())
{
M_DEMO_CLEAR_SYNC_POINT();
};
}
/* Check that expected number of software ISRs have been called */
if (D_DEMO_NUM_OF_SW_INTERRUPTS != g_uiSwIsrCount1)
{
M_DEMO_ENDLESS_LOOP();
}
/* Disable software interrupts */
pspMachineInterruptsDisableIntNumber(D_PSP_INTERRUPTS_MACHINE_SW);
/* Register software ISR number 2 */
pspMachineInterruptsRegisterIsr(demoSoftwareIsr2, E_MACHINE_SOFTWARE_CAUSE);
/* Create a series of software interrupts */
for(uiNumberOfSwInterrupts = 0; uiNumberOfSwInterrupts < D_DEMO_NUM_OF_SW_INTERRUPTS; uiNumberOfSwInterrupts++)
{
M_DEMO_TRIGGER_SW_INTERRUPT();
while(M_DEMO_IS_SYNC_POINT_SET())
{
M_DEMO_CLEAR_SYNC_POINT();
};
}
/* Check that no software ISRs have been called */
if (g_uiSwIsrCount2 > 0)
{
M_DEMO_ENDLESS_LOOP();
}
}
/**
* demoStart - startup point of the demo application. called from main function.
*
*/
void demoStart(void)
{
M_DEMO_START_PRINT();
/* Register interrupt vector */
pspMachineInterruptsSetVecTableAddress(&M_PSP_VECT_TABLE);
/* Run this demo only if target is Whisper. Cannot run on SweRV */
if (D_PSP_FALSE == demoIsSwervBoard())
{
/* Software interrupts demo function */
demoSoftwareInterrupts();
}
else
{
/* SweRV */
printfNexys("This demo is currently not supported in SweRV FPGA Board");
}
M_DEMO_END_PRINT();
}
|
edward-jones/riscv-fw-infrastructure | WD-Firmware/psp/api_inc/psp_nmi_eh1.h | /*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2020 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file psp_nmi_eh1.h
* @author <NAME>
* @date 13.04.2020
* @brief The file contains NMI handlers registration service (relevant to SweRV EH1)
*/
#ifndef __PSP_NMI_EH1_H__
#define __PSP_NMI_EH1_H__
/**
* include files
*/
/**
* types
*/
/* NMI handler definition */
typedef void (*pspNmiHandler_t)(void);
/**
* definitions
*/
#define D_PSP_NMI_EXT_PIN_ASSERTION 0
#define D_PSP_NMI_D_BUS_STORE_ERROR 0xF0000000
#define D_PSP_NMI_D_BUS_LOAD_ERROR 0xF0000001
/**
* local prototypes
*/
/**
* external prototypes
*/
/**
* macros
*/
/**
* global variables
*/
/**
* APIs
*/
/**
* @brief - set address of NMI initial handler in nmi_vec
*
* @parameter - uiNmiVecAddress - address of NMI_VEC register
* @parameter - fptrNmiSelector - address of NMI initial handler
*/
void pspMachineNmiSetVec(u32_t uiNmiVecAddress, pspNmiHandler_t fptrNmiSelector);
/**
* @brief - The function installs an Non-Maskable Interrupt (NMI) service routine
*
* input parameter - fptrNmiHandler - function pointer to the NMI service routine
* input parameter - uiNmiCause - NMI source
* Note that the value of this input parameter could be only one of these:
* - D_PSP_NMI_EXT_PIN_ASSERTION
* - D_PSP_NMI_D_BUS_STORE_ERROR
* - D_PSP_NMI_D_BUS_LOAD_ERROR
*
* @return u32_t - previously registered ISR. If NULL then registeration had an error
*/
pspNmiHandler_t pspMachineNmiRegisterHandler(pspNmiHandler_t fptrNmiHandler, u32_t uiNmiCause);
/**
* @brief - This function is called upon NMI and selects the appropriate handler
*
*/
D_PSP_NO_RETURN void pspMachineNmiHandlerSelector(void);
#endif /* __PSP_NMI_EH1_H__ */
|
edward-jones/riscv-fw-infrastructure | WD-Firmware/psp/api_inc/psp_attributes.h | /*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2019-2021 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file psp_attributes.h
* @author <NAME>
* @date 26.08.2019
* @brief The file defines attribute directives that relevant to our PSP
*
*/
#ifndef __PSP_ATTRIBUTES_H__
#define __PSP_ATTRIBUTES_H__
#if defined (__GNUC__) || defined (__clang__)
/**
* include files
*/
/**
* definitions
*/
#define D_PSP_INTERRUPT __attribute__((interrupt))
#define D_PSP_NO_INLINE __attribute__((noinline))
#define D_PSP_ALWAYS_INLINE D_PSP_INLINE __attribute__((always_inline))
#define D_PSP_ALIGNED(x) __attribute__ ((aligned(x)))
#define D_PSP_WEAK __attribute__(( weak ))
#define D_PSP_TEXT_SECTION __attribute__((section(".psp_code_section")))
#define D_PSP_DATA_SECTION __attribute__((section(".psp_data_section")))
#define D_PSP_NO_RETURN __attribute__((noreturn))
#define D_PSP_USED __attribute__((used))
#define D_PSP_CREATE_ATTR(name, val) __attribute__((section(#name),aligned(val)))
#define D_PSP_GENERAL_DATA_SECTION(name, align_avl) D_PSP_CREATE_ATTR( (#name), align_avl )
/**
* macros
*/
/**
* types
*/
#else
#error "Currently, GCC and LLVM are the only supported compilers."
#endif /* defined (__GNUC__) || defined (__clang__) */
#endif /* __PSP_ATTRIBUTES_H__ */
|
edward-jones/riscv-fw-infrastructure | WD-Firmware/demo/demo_comrv_dataoverlay.c | <reponame>edward-jones/riscv-fw-infrastructure
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2021 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* include files
*/
#include "common_types.h"
#include "psp_macros.h"
#include "comrv_api.h"
#include "demo_platform_al.h"
#include "psp_csrs.h"
#include "demo_utils.h"
/**
* definitions
*/
#define D_DEMO_ARR_SIZE 10
/**
* macros
*/
#define M_DEMO_5_NOPS() \
asm volatile ("nop"); \
asm volatile ("nop"); \
asm volatile ("nop"); \
asm volatile ("nop"); \
asm volatile ("nop");
#define OVL_OverlayFunc0 _OVERLAY_
#define OVL_OverlayFunc1 _OVERLAY_
#define OVL_OverlayFunc2 _OVERLAY_
/**
* types
*/
/**
* local prototypes
*/
void OVL_OverlayFunc0 OverlayFunc0(void);
void OVL_OverlayFunc1 OverlayFunc1(void);
void OVL_OverlayFunc1 OverlayFunc2(void);
/**
* external prototypes
*/
/**
* global variables
*/
_DATA_OVERLAY_ const u32_t uiSomeOverlayData[D_DEMO_ARR_SIZE] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
/**
* functions
*/
/* overlay function 2 */
void OVL_OverlayFunc2 OverlayFunc2(void)
{
M_DEMO_5_NOPS();
}
/* overlay function 1 */
void OVL_OverlayFunc1 OverlayFunc1(void)
{
M_DEMO_5_NOPS();
}
/* overlay function 0 */
void OVL_OverlayFunc0 OverlayFunc0(void)
{
M_DEMO_5_NOPS();
}
void AdditionalDataOverlayExamples(void)
{
u32_t uiIndex;
const u32_t *pToSameOvlData, *pToOvlData;
/* allocate the same data overlay (to simulate a call from a different code location) */
pToSameOvlData = comrvDataOverlayAllocation(uiSomeOverlayData);
/* release the RO data overlay uiSomeOverlayData - since there are 2 pointers
referencing the same data overlay, it will still be available after releasing
it once */
comrvDataOverlayRelease(uiSomeOverlayData);
/* call overlay functions - data overlay shouldn't be evicted */
OverlayFunc0();
OverlayFunc1();
/* verify that the data didn't change and still loaded */
for (uiIndex = 0 ; uiIndex < D_DEMO_ARR_SIZE ; uiIndex++)
{
if (pToSameOvlData[uiIndex] != uiIndex)
{
M_DEMO_ENDLESS_LOOP();
}
}
/* re allocate the RO data overlay to make it MRU */
pToOvlData = comrvDataOverlayAllocation(uiSomeOverlayData);
/* release of RO data overlay */
comrvDataOverlayRelease(uiSomeOverlayData);
/* second release of RO data overlay */
comrvDataOverlayRelease(uiSomeOverlayData);
/* call overlay functions - since the data overlay isn't being referrenced anymore
the following 2 calls shall take the entire cache (overriding the occupied data overlay memory)*/
OverlayFunc0();
OverlayFunc1();
/* verify that the data overlay isn't available */
for (uiIndex = 0 ; uiIndex < D_DEMO_ARR_SIZE ; uiIndex++)
{
if (pToSameOvlData[uiIndex] == uiIndex)
{
M_DEMO_ENDLESS_LOOP();
}
}
}
void demoStart(void)
{
u32_t uiIndex;
const u32_t *pToOvlData;
comrvInitArgs_t stComrvInitArgs;
M_DEMO_START_PRINT();
/* Register interrupt vector */
pspMachineInterruptsSetVecTableAddress(&M_PSP_VECT_TABLE);
/* mark that comrv init shall load comrv tables */
stComrvInitArgs.ucCanLoadComrvTables = 1;
/* init comrv */
comrvInit(&stComrvInitArgs);
/* call overlay function */
OverlayFunc0();
OverlayFunc1();
/* load the RO data overlay */
pToOvlData = comrvDataOverlayAllocation(uiSomeOverlayData);
/* verify the read data content */
for (uiIndex = 0 ; uiIndex < D_DEMO_ARR_SIZE ; uiIndex++)
{
if (pToOvlData[uiIndex] != uiIndex)
{
M_DEMO_ENDLESS_LOOP();
}
}
/* call OverlayFunc2 - same group as uiSomeOverlayData */
OverlayFunc2();
/* more examples */
AdditionalDataOverlayExamples();
M_DEMO_END_PRINT();
}
|
edward-jones/riscv-fw-infrastructure | WD-Firmware/rtos/rtosal/api_inc/rtosal_types.h | <filename>WD-Firmware/rtos/rtosal/api_inc/rtosal_types.h
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2019 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file rtosal_types.h
* @author <NAME>
* @date 21.01.2019
* @brief The defines RTOS AL specific types
*
*/
#ifndef __RTOSAL_TYPES_H__
#define __RTOSAL_TYPES_H__
/**
* include files
*/
#include "common_types.h"
#ifdef D_USE_FREERTOS
#include "FreeRTOS.h"
#else
#error "Add appropriate RTOS definitions"
#endif /* #ifdef D_USE_FREERTOS */
/**
* types
*/
#ifdef D_USE_FREERTOS
typedef u32_t rtosalStackType_t;
#elif D_USE_THREADX
#error *** TODO: need to define the TBD ***
typedef TBD rtosalStackType_t;
#else
#error "Add appropriate RTOS definitions"
#endif /* #ifdef D_USE_FREERTOS */
#ifdef D_USE_FREERTOS
typedef StaticTask_t rtosalStaticTask_t;
#elif D_USE_THREADX
#error *** TODO: need to define the TBD ***
typedef TBD rtosalStaticTask_t;
#else
#error "Add appropriate RTOS definitions"
#endif /* #ifdef D_USE_FREERTOS */
#ifdef D_USE_FREERTOS
typedef StackType_t rtosalStack_t;
#elif D_USE_THREADX
#error *** TODO: need to define the TBD ***
typedef TBD rtosalStack_t;
#else
#error "Add appropriate RTOS definitions"
#endif /* __RTOSAL_TYPES_H__ */
#endif /* __RTOSAL_TYPES_H__ */
|
edward-jones/riscv-fw-infrastructure | WD-Firmware/psp/psp_timers.c | /*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2020-2021 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file psp_timers.c
* @author <NAME>
* @date 13.11.2019
* @brief This file implements core's Machine timer-counter api services.
*/
/**
* include files
*/
#include "psp_api.h"
/**
* definitions
*/
#if defined(D_MTIME_ADDRESS) && defined(D_MTIMECMP_ADDRESS)
#define D_PSP_MTIME_ADDRESS D_MTIME_ADDRESS
#define D_PSP_MTIMECMP_ADDRESS D_MTIMECMP_ADDRESS
#else
#error "D_MTIME_ADDRESS or D_MTIMECMP_ADDRESS are not defined"
#endif
/**
* macros
*/
/**
* types
*/
/**
* local prototypes
*/
/**
* external prototypes
*/
/**
* global variables
*/
/**
* APIs
*/
/**
* @brief Setup and activate core Machine Timer
*
*
* @param - udPeriodCycles - defines the timer's period in cycles
*
*/
D_PSP_TEXT_SECTION void pspMachineTimerCounterSetupAndRun(u64_t udPeriodCycles)
{
M_PSP_ASSERT((D_PSP_MTIME_ADDRESS != 0) && (D_PSP_MTIMECMP_ADDRESS != 0));
/* Set the mtime and mtimecmp (memory-mapped registers) per privileged spec */
volatile u64_t *pMtime = (u64_t*)D_PSP_MTIME_ADDRESS;
volatile u64_t *pMtimecmp = (u64_t*)D_PSP_MTIMECMP_ADDRESS;
u64_t udNow = *pMtime;
u64_t udThen = udNow + udPeriodCycles;
*pMtimecmp = udThen;
}
/**
* @brief Get Machine Timer counter value
*
*
* @return u64_t - Timer counter value
*
*/
D_PSP_TEXT_SECTION u64_t pspMachineTimerCounterGet(void)
{
volatile u64_t *pMtime = (u64_t*)D_PSP_MTIME_ADDRESS;
return *pMtime;
}
/**
* @brief Get Machine Time compare counter value
*
*
* @return u64_t – Time compare counter value
*
*/
D_PSP_TEXT_SECTION u64_t pspMachineTimerCompareCounterGet(void)
{
volatile u64_t *pMtimecmp = (u64_t*)D_PSP_MTIMECMP_ADDRESS;
return *pMtimecmp;
}
|
edward-jones/riscv-fw-infrastructure | WD-Firmware/psp/psp_internal_timers_el2.c | <gh_stars>0
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2020-2021 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file psp_internal_timers_el2.c
* @author <NAME>
* @date 19.08.2020
* @brief This file implements EL2 timers service functions
*
*/
/**
* include files
*/
#include "psp_api.h"
/**
* definitions
*/
/**
* macros
*/
/**
* types
*/
/**
* local prototypes
*/
/**
* external prototypes
*/
/**
* global variables
*/
/**
* Internal functions
*/
/**
* @brief Cascade Timer0 and Timer1 to act as a single timer
* In this mode, Timer1 counts up when Timer0 reachs its bound value. Timer1 interrupt raises when Timer1 reachs its bound.
* **Note** In 'cascade' mode HALT-EN, and PAUSE-EN indications must be the set identically for both timers
* so part this function also set disable all of them here.
*
* @param - udPeriodCycles - defines the timer's period in cycles
*
*/
D_PSP_TEXT_SECTION void pspMachineInternalTimerSetup64bitTimer(u64_t udPeriodCycles)
{
u32_t uiNow, uiThen;
/* Read Timer0 counter */
uiNow = M_PSP_READ_CSR(D_PSP_MITCNT0_NUM);
/* Add the lower 32bit of the input 'udPeriodCycles' parameter */
uiThen = uiNow + (u32_t)udPeriodCycles;
/* Set Timer0 bound */
M_PSP_WRITE_CSR(D_PSP_MITBND0_NUM, uiThen);
/* Read Timer1 counter */
uiNow = M_PSP_READ_CSR(D_PSP_MITCNT1_NUM);
/* Add the upper 32bit of the input 'udPeriodCycles' parameter */
uiThen = uiNow + (u32_t)(udPeriodCycles >> D_PSP_SHIFT_32);
/* Set Timer0 bound */
M_PSP_WRITE_CSR(D_PSP_MITBND1_NUM, uiThen);
/* In cascade mode, the HALT-EN, and PAUSE-EN bits must be the set identically for both timers - so disable all of them them now */
M_PSP_CLEAR_CSR(D_PSP_MITCTL0_NUM,D_PSP_MITCTL_PAUSE_EN_MASK);
M_PSP_CLEAR_CSR(D_PSP_MITCTL1_NUM,D_PSP_MITCTL_PAUSE_EN_MASK);
M_PSP_CLEAR_CSR(D_PSP_MITCTL0_NUM,D_PSP_MITCTL_HALT_EN_MASK);
M_PSP_CLEAR_CSR(D_PSP_MITCTL1_NUM,D_PSP_MITCTL_HALT_EN_MASK);
/* Enable Timer0 and Timer1 counting */
M_PSP_SET_CSR(D_PSP_MITCTL0_NUM, D_PSP_MITCTL_EN_MASK);
M_PSP_SET_CSR(D_PSP_MITCTL1_NUM, D_PSP_MITCTL_EN_MASK);
}
/**
* @brief Setup and activate Internal core's Timer
*
* @param - uiTimer - indicates which timer to setup and run
*
* @param - udPeriodCycles - defines the timer's period in cycles
*
*/
D_PSP_TEXT_SECTION void pspMachineInternalTimerCounterSetupAndRun(u32_t uiTimer, u64_t udPeriodCycles)
{
u32_t uiNow, uiThen;
M_PSP_ASSERT((D_PSP_INTERNAL_TIMER0 == uiTimer) ||(D_PSP_INTERNAL_TIMER1 == uiTimer) || (D_PSP_INTERNAL_64BIT_TIMER == uiTimer));
switch (uiTimer)
{
case D_PSP_INTERNAL_TIMER0:
/* Read Timer0 counter */
uiNow = M_PSP_READ_CSR(D_PSP_MITCNT0_NUM);
uiThen = uiNow + (u32_t)udPeriodCycles;
/* Set Timer0 bound */
M_PSP_WRITE_CSR(D_PSP_MITBND0_NUM, uiThen);
/* Enable Timer0 counting */
M_PSP_SET_CSR(D_PSP_MITCTL0_NUM, D_PSP_MITCTL_EN_MASK);
break;
case D_PSP_INTERNAL_TIMER1:
/* Read Timer1 counter */
uiNow = M_PSP_READ_CSR(D_PSP_MITCNT1_NUM);
uiThen = uiNow + (u32_t)udPeriodCycles;
/* Set Timer1 bound */
M_PSP_WRITE_CSR(D_PSP_MITBND1_NUM, uiThen);
/* Enable Timer1 counting */
M_PSP_SET_CSR(D_PSP_MITCTL1_NUM, D_PSP_MITCTL_EN_MASK);
break;
case D_PSP_INTERNAL_64BIT_TIMER:
pspMachineInternalTimerSetup64bitTimer(udPeriodCycles);
break;
default:
break;
}
}
/**
* @brief Get Core Internal Timer counter value
*
* @param - uitimer - indicates from which timer to get the counter value
*
* @return u64_t - Timer counter value
*
*/
D_PSP_TEXT_SECTION u64_t pspMachineInternalTimerCounterGet(u32_t uiTimer)
{
u64_t udCounter = 0;
u64_t udCounterTemp = 0;
M_PSP_ASSERT((D_PSP_INTERNAL_TIMER0 == uiTimer) || (D_PSP_INTERNAL_TIMER1 == uiTimer) || (D_PSP_INTERNAL_64BIT_TIMER == uiTimer));
switch (uiTimer)
{
case D_PSP_INTERNAL_TIMER0:
udCounter = (u64_t)M_PSP_READ_CSR(D_PSP_MITCNT0_NUM);
break;
case D_PSP_INTERNAL_TIMER1:
udCounter = (u64_t)M_PSP_READ_CSR(D_PSP_MITCNT1_NUM);
break;
case D_PSP_INTERNAL_64BIT_TIMER:
udCounterTemp = M_PSP_READ_CSR(D_PSP_MITCNT1_NUM);
udCounter = udCounterTemp << D_PSP_SHIFT_32;
udCounter |= M_PSP_READ_CSR(D_PSP_MITCNT0_NUM);
break;
default:
break;
}
return (udCounter);
}
/**
* @brief Get Core Internal Timer compare counter value
*
* @param - uitimer - indicates from which timer to get the compare-counter value
*
* @return u64_t – Time compare counter value
*
*/
D_PSP_TEXT_SECTION u64_t pspMachineInternalTimerCompareCounterGet(u32_t uiTimer)
{
u64_t udCounterCompare = 0;
u64_t udCounterCompareTemp = 0;
M_PSP_ASSERT((D_PSP_INTERNAL_TIMER0 == uiTimer) || (D_PSP_INTERNAL_TIMER1 == uiTimer) || (D_PSP_INTERNAL_64BIT_TIMER == uiTimer));
switch (uiTimer)
{
case D_PSP_INTERNAL_TIMER0:
udCounterCompare = (u64_t)M_PSP_READ_CSR(D_PSP_MITBND0_NUM);
break;
case D_PSP_INTERNAL_TIMER1:
udCounterCompare = (u64_t)M_PSP_READ_CSR(D_PSP_MITBND1_NUM);
break;
case D_PSP_INTERNAL_64BIT_TIMER:
udCounterCompareTemp = M_PSP_READ_CSR(D_PSP_MITBND1_NUM);
udCounterCompare = udCounterCompareTemp << D_PSP_SHIFT_32;
udCounterCompare |= M_PSP_READ_CSR(D_PSP_MITBND0_NUM);
break;
default:
break;
}
return (udCounterCompare);
}
/**
* @brief Enable Core Internal timer counting when core in sleep mode
*
* @param - uiTimer - indicates which timer to setup
*
*/
D_PSP_TEXT_SECTION void pspMachineInternalTimerEnableCountInSleepMode(u32_t uiTimer)
{
M_PSP_ASSERT((D_PSP_INTERNAL_TIMER0 == uiTimer) || (D_PSP_INTERNAL_TIMER1 == uiTimer) || (D_PSP_INTERNAL_64BIT_TIMER == uiTimer));
switch (uiTimer)
{
case D_PSP_INTERNAL_TIMER0:
M_PSP_SET_CSR(D_PSP_MITCTL0_NUM,D_PSP_MITCTL_HALT_EN_MASK);
break;
case D_PSP_INTERNAL_TIMER1:
M_PSP_SET_CSR(D_PSP_MITCTL1_NUM,D_PSP_MITCTL_HALT_EN_MASK);
break;
case D_PSP_INTERNAL_64BIT_TIMER:
M_PSP_SET_CSR(D_PSP_MITCTL0_NUM,D_PSP_MITCTL_HALT_EN_MASK);
M_PSP_SET_CSR(D_PSP_MITCTL1_NUM,D_PSP_MITCTL_HALT_EN_MASK);
break;
default:
break;
}
}
/**
* @brief Disable Core Internal timer counting when core in sleep mode
*
* @param - uiTimer - indicates which timer to setup
*
*/
D_PSP_TEXT_SECTION void pspMachineInternalTimerDisableCountInSleepMode(u32_t uiTimer)
{
M_PSP_ASSERT((D_PSP_INTERNAL_TIMER0 == uiTimer) || (D_PSP_INTERNAL_TIMER1 == uiTimer) || (D_PSP_INTERNAL_64BIT_TIMER == uiTimer));
switch (uiTimer)
{
case D_PSP_INTERNAL_TIMER0:
M_PSP_CLEAR_CSR(D_PSP_MITCTL0_NUM,D_PSP_MITCTL_HALT_EN_MASK);
break;
case D_PSP_INTERNAL_TIMER1:
M_PSP_CLEAR_CSR(D_PSP_MITCTL1_NUM,D_PSP_MITCTL_HALT_EN_MASK);
break;
case D_PSP_INTERNAL_64BIT_TIMER:
M_PSP_CLEAR_CSR(D_PSP_MITCTL0_NUM,D_PSP_MITCTL_HALT_EN_MASK);
M_PSP_CLEAR_CSR(D_PSP_MITCTL1_NUM,D_PSP_MITCTL_HALT_EN_MASK);
break;
default:
break;
}
}
/**
* @brief Enable Core Internal timer counting when core in in stall
*
* @param - uiTimer - indicates which timer to setup
*
*/
D_PSP_TEXT_SECTION void pspMachineInternalTimerEnableCountInStallMode(u32_t uiTimer)
{
M_PSP_ASSERT((D_PSP_INTERNAL_TIMER0 == uiTimer) || (D_PSP_INTERNAL_TIMER1 == uiTimer) || (D_PSP_INTERNAL_64BIT_TIMER == uiTimer));
switch (uiTimer)
{
case D_PSP_INTERNAL_TIMER0:
M_PSP_SET_CSR(D_PSP_MITCTL0_NUM,D_PSP_MITCTL_PAUSE_EN_MASK);
break;
case D_PSP_INTERNAL_TIMER1:
M_PSP_SET_CSR(D_PSP_MITCTL1_NUM,D_PSP_MITCTL_PAUSE_EN_MASK);
break;
case D_PSP_INTERNAL_64BIT_TIMER:
M_PSP_SET_CSR(D_PSP_MITCTL0_NUM,D_PSP_MITCTL_PAUSE_EN_MASK);
M_PSP_SET_CSR(D_PSP_MITCTL1_NUM,D_PSP_MITCTL_PAUSE_EN_MASK);
break;
default:
break;
}
}
/**
* @brief Disable Core Internal timer counting when core in in stall
*
* @param - uiTimer - indicates which timer to setup
*
*/
D_PSP_TEXT_SECTION void pspMachineInternalTimerDisableCountInStallMode(u32_t uiTimer)
{
M_PSP_ASSERT((D_PSP_INTERNAL_TIMER0 == uiTimer) || (D_PSP_INTERNAL_TIMER1 == uiTimer) || (D_PSP_INTERNAL_64BIT_TIMER == uiTimer));
switch (uiTimer)
{
case D_PSP_INTERNAL_TIMER0:
M_PSP_CLEAR_CSR(D_PSP_MITCTL0_NUM,D_PSP_MITCTL_PAUSE_EN_MASK);
break;
case D_PSP_INTERNAL_TIMER1:
M_PSP_CLEAR_CSR(D_PSP_MITCTL1_NUM,D_PSP_MITCTL_PAUSE_EN_MASK);
break;
case D_PSP_INTERNAL_64BIT_TIMER:
M_PSP_CLEAR_CSR(D_PSP_MITCTL0_NUM,D_PSP_MITCTL_PAUSE_EN_MASK);
M_PSP_CLEAR_CSR(D_PSP_MITCTL1_NUM,D_PSP_MITCTL_PAUSE_EN_MASK);
break;
default:
break;
}
}
|
edward-jones/riscv-fw-infrastructure | WD-Firmware/cti/cti_utilities.c | <filename>WD-Firmware/cti/cti_utilities.c<gh_stars>10-100
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2020 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file cti_utilities.c
* @author <NAME>
* @date 01.07.2020
* @brief The file implements cti framework
*/
/**
* include files
*/
#include "common_types.h"
#include "cti.h"
#include "psp_api.h"
/**
* definitions
*/
/**
* macros
*/
#define M_CTI_INT_DISABLE(pPrevIntState) pspMachineInterruptsDisable(pPrevIntState)
#define M_CTI_INT_ENABLE(uiPrevIntState) pspMachineInterruptsRestore(uiPrevIntState)
/**
* types
*/
/**
* local prototypes
*/
/**
* external prototypes
*/
extern stCtiFuncsHitCounter g_stCtiOvlFuncsHitCounter;
/**
* global variables
*/
/**
* @brief secure setter for E_TEST_ERROR
*
* @param pCtiFrameWorkCB - Value that we want to assign
* @param eValue - Pointer to E_TEST_ERROR
*
* @return E_CTI_RESULT
*/
E_CTI_RESULT ctiSetErrorBit(S_FW_CB_PTR pCtiFrameWorkCB, E_TEST_ERROR eValue)
{
u32_t uiPrevIntState;
E_CTI_RESULT eRes;
if (pCtiFrameWorkCB == NULL)
{
eRes = E_CTI_ERROR;
}
else
{
eRes = E_CTI_OK;
}
M_CTI_INT_DISABLE(&uiPrevIntState);
pCtiFrameWorkCB->eTestErrorBitmap |= eValue;
M_CTI_INT_ENABLE(uiPrevIntState);
return E_CTI_OK;
}
/**
* @brief
*
* @param pCtiFrameWorkCB
*
* @return E_CTI_RESULT
*/
E_TEST_ERROR ctiGetErrorBits(S_FW_CB_PTR pCtiFrameWorkCB)
{
return pCtiFrameWorkCB->eTestErrorBitmap;
}
/**
* @brief reset the test ovl global struct and call reset
*
* @param None
*
* @return None
*/
void ctiResetOvlGlobal(void)
{
g_stCtiOvlFuncsHitCounter.uiComrvLoad = 0;
g_stCtiOvlFuncsHitCounter.uiDefragCounter = 0;
g_stCtiOvlFuncsHitCounter.uiErrorNum = 0;
}
|
edward-jones/riscv-fw-infrastructure | WD-Firmware/psp/api_inc/psp_timers_el2.h | /*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2020-2021 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file psp_timers_el2.h
* @author <NAME>
* @date 19.08.2020
* @brief The file defines timer api services for EL2 core.
*
*/
#ifndef __PSP_TIMERS_EL2_H__
#define __PSP_TIMERS_EL2_H__
/**
* include files
*/
/**
* definitions
*/
/* Machine timer and internal timers 1 & 2 are defined in psp_timers_eh1.h */
/*
#define D_PSP_INTERNAL_TIMER0 1
#define D_PSP_INTERNAL_TIMER1 2
*/
/* In SweRV EL2 there is also a 64bit timer */
#define D_PSP_INTERNAL_64BIT_TIMER 3
/**
* types
*/
/**
* local prototypes
*/
/**
* external prototypes
*/
/**
* global variables
*/
/**
* macros
*/
/**
* APIs
*/
/**
* @brief Cascade Timer0 and Timer1 to act as a single timer
* In this mode, Timer1 counts up when Timer0 reachs its bound value. Timer1 interrupt raises when Timer1 reachs its bound.
* **Note** In 'cascade' mode HALT-EN, and PAUSE-EN indications must be the set identically for both timers
* so part this function also set disable all of them here.
*
* @param - udPeriodCycles - defines the timer's period in cycles
*
*/
void pspMachineInternalTimerSetup64bitTimer(u64_t udPeriodCycles);
#endif /* __PSP_TIMERS_EL2_H__ */
|
edward-jones/riscv-fw-infrastructure | WD-Firmware/board/nexys_a7_eh2/bsp/bsp_version.h | <filename>WD-Firmware/board/nexys_a7_eh2/bsp/bsp_version.h<gh_stars>1-10
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2019 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author <NAME>
* @date 24.02.2020
* @brief Supplies SweRVolf version information
*/
#ifndef __BSP_VERSION_H__
#define __BSP_VERSION_H__
/* version sturct */
typedef struct swervolfVersion
{
u08_t ucRev;
u08_t ucMinor;
u08_t ucMajor;
u08_t ucMisc;
u32_t uiSha;
} swervolfVersion_t;
/**
*
* The function return version num
*
* @param inputs: ucRev, minor, major, sha, dirty
*
*/
void versionGetSwervolfVer(swervolfVersion_t *pSwervolfVersion);
#endif //__BSP_VERSION_H__
|
edward-jones/riscv-fw-infrastructure | WD-Firmware/cti/loc_inc/cti_tests.h | /*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2020 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file cti_tests.h
* @author <NAME>
* @date 01.07.2020
* @brief The file defines cti (comrv testing infrastructure) test overlay functions
*/
#ifndef __CTI_TESTS_H
#define __CTI_TESTS_H
/*
* INCLUDES
*/
#include "comrv_defines.h"
/*
* MACROS
*/
/*
* DEFINITIONS
*/
/*
* TYPEDEFS
*/
/*
* EXPORTED GLOBALS
*/
/*
* FUNCTIONS PROTOTYPES
*/
typedef int (*comrvti_test_ovl)(S_FW_CB_PARAM_PTR);
extern const ctiTestFunctionPtr g_pLookupTableCtiTestOvl[E_CB_TEST_OVL_MAX];
void ctiSwiIsr();
/*
* OVL functions prototypes
*/
void _OVERLAY_ ctiTestFuncOverlay101Vect(void);
void _OVERLAY_ ctiTestFuncOverlay102Vect(void);
void _OVERLAY_ ctiTestFuncOverlay103Vect(void);
void _OVERLAY_ ctiTestFuncOverlay104Vect(void);
void _OVERLAY_ ctiTestFuncOverlay105Vect(void);
void _OVERLAY_ ctiTestFuncOverlay106Vect(void);
void _OVERLAY_ ctiTestFuncOverlay107Vect(void);
void _OVERLAY_ ctiTestFuncOverlay109Vect(void);
void _OVERLAY_ ctiTestFuncOverlay110Vect(void);
void _OVERLAY_ ctiTestFuncOverlay111Vect(void);
void _OVERLAY_ ctiTestFuncOverlay112Vect(void);
#ifdef D_COMRV_RTOS_SUPPORT
void _OVERLAY_ ctiTestFuncOverlay108Vect(void);
void _OVERLAY_ ctiTestFuncOverlay113Vect(u32_t var1, u32_t var2, u32_t var3);
#endif /* D_COMRV_RTOS_SUPPORT */
/*
* OVL DUMMY functions prototypes and define
*/
void _OVERLAY_ ctiTestFuncOverlay120Vect(void);
void _OVERLAY_ ctiTestFuncOverlay121Vect(void);
void _OVERLAY_ ctiTestFuncOverlay122Vect(void);
void _OVERLAY_ ctiTestFuncOverlay123Vect(void);
void _OVERLAY_ ctiTestFuncOverlay124Vect(void);
void _OVERLAY_ ctiTestFuncOverlay125Vect(void);
void _OVERLAY_ ctiTestFuncOverlay126Vect(void);
void _OVERLAY_ ctiTestFuncOverlay127Vect(void);
void _OVERLAY_ ctiTestFuncOverlay128Vect(void);
void _OVERLAY_ ctiTestFuncOverlay129Vect(void);
void _OVERLAY_ ctiTestFuncOverlay130Vect(void);
void _OVERLAY_ ctiTestFuncOverlay131Vect(void);
void _OVERLAY_ ctiTestFuncOverlay132Vect(void);
void _OVERLAY_ ctiTestFuncOverlay133Vect(void);
void _OVERLAY_ ctiTestFuncOverlay134Vect(void);
void _OVERLAY_ ctiTestFuncOverlay135Vect(void);
void _OVERLAY_ ctiTestFuncOverlay136Vect(void);
void _OVERLAY_ ctiTestFuncOverlay137Vect(void);
void _OVERLAY_ ctiTestFuncOverlay138Vect(void);
void _OVERLAY_ ctiTestFuncOverlay139Vect(void);
void _OVERLAY_ ctiTestFuncOverlay140Vect(void);
void _OVERLAY_ ctiTestFuncOverlay141Vect(void);
void _OVERLAY_ ctiTestFuncOverlay142Vect(void);
void _OVERLAY_ ctiTestFuncOverlay143Vect(void);
void _OVERLAY_ ctiTestFuncOverlay144Vect(void);
void _OVERLAY_ ctiTestFuncOverlay145Vect(void);
void _OVERLAY_ ctiTestFuncOverlay146Vect(void);
void _OVERLAY_ ctiTestFuncOverlay147Vect(void);
void _OVERLAY_ ctiTestFuncOverlay148Vect(void);
void _OVERLAY_ ctiTestFuncOverlay149Vect(void);
void _OVERLAY_ ctiTestFuncOverlay150Vect(void);
void _OVERLAY_ ctiTestFuncOverlay151Vect(void);
void _OVERLAY_ ctiTestFuncOverlay152Vect(void);
void _OVERLAY_ ctiTestFuncOverlay153Vect(void);
void _OVERLAY_ ctiTestFuncOverlay154Vect(void);
void _OVERLAY_ ctiTestFuncOverlay155Vect(void);
void _OVERLAY_ ctiTestFuncOverlay156Vect(void);
void _OVERLAY_ ctiTestFuncOverlay157Vect(void);
void _OVERLAY_ ctiTestFuncOverlay158Vect(void);
void _OVERLAY_ ctiTestFuncOverlay159Vect(void);
#endif /* __CTI_TESTS_H */
|
edward-jones/riscv-fw-infrastructure | WD-Firmware/psp/api_inc/psp_nmi_el2.h | <reponame>edward-jones/riscv-fw-infrastructure<gh_stars>10-100
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2020 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file psp_nmi_el2.h
* @author <NAME>
* @date 18.08.2020
* @brief The file defines the psp NMI interfaces for features of SweRV EL2
*
*/
#ifndef __PSP_NMI_EL2_H__
#define __PSP_NMI_EL2_H__
/**
* include files
*/
/**
* types
*/
/**
* definitions
*/
#define D_PSP_NMI_FAST_INT_DOUBLE_BIT_ECC_ERROR 0xF0001000
#define D_PSP_NMI_FAST_INT_DCCM_ACCESS_ERROR 0xF0001001
#define D_PSP_NMI_FAST_INT_NON_DCCM_REGION_ERROR 0xF0001002
/**
* local prototypes
*/
/**
* external prototypes
*/
/**
* macros
*/
/**
* global variables
*/
/**
* APIs
*/
#endif /* __PSP_NMI_EL2_H__ */
|
edward-jones/riscv-fw-infrastructure | WD-Firmware/psp/api_inc/psp_performance_monitor_eh1.h | /*
* Copyright (c) 2010-2016 Western Digital, Inc.
*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2020 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file psp_performance_monitor.h
* @author <NAME>
* @date 15.03.2020
* @brief performance monitor api provider
*
*/
#ifndef _PSP_PERFORMANCE_MONITOR_H_
#define _PSP_PERFORMANCE_MONITOR_H_
/**
* include files
*/
/**
* definitions
*/
#define D_PSP_CYCLE_COUNTER M_PSP_BIT_MASK(0)
#define D_PSP_TIME_COUNTER M_PSP_BIT_MASK(1)
#define D_PSP_INSTRET_COUNTER M_PSP_BIT_MASK(2)
#define D_PSP_COUNTER0 M_PSP_BIT_MASK(3)
#define D_PSP_COUNTER1 M_PSP_BIT_MASK(4)
#define D_PSP_COUNTER2 M_PSP_BIT_MASK(5)
#define D_PSP_COUNTER3 M_PSP_BIT_MASK(6)
/*
* Performance monitoring events
*/
/* Event 0 is Reserved */
#define D_CYCLES_CLOCKS_ACTIVE 1
#define D_I_CACHE_HITS 2
#define D_I_CACHE_MISSES 3
#define D_INSTR_COMMITTED_ALL 4
#define D_INSTR_COMMITTED_16BIT 5
#define D_INSTR_COMMITTED_32BIT 6
#define D_INSTR_ALLIGNED_ALL 7
#define D_INSTR_DECODED_ALL 8
#define D_MULS_COMMITTED 9
#define D_DIVS_COMMITTED 10
#define D_LOADS_COMMITED 11
#define D_STORES_COMMITTED 12
#define D_MISALIGNED_LOADS 13
#define D_MISALIGNED_STORES 14
#define D_ALUS_COMMITTED 15
#define D_CSR_READ 16
#define D_CSR_READ_WRITE 17
#define D_WRITE_RD_0 18
#define D_EBREAK 19
#define D_ECALL 20
#define D_FENCE 21
#define D_FENCE_I 22
#define D_MRET 23
#define D_BRANCHES_COMMITTED 24
#define D_BRANCHES_MISPREDICTED 25
#define D_BRANCHES_TAKEN 26
#define D_UNPREDICTABLE_BRANCHES 27
#define D_CYCLES_FETCH_STALLED 28
#define D_CYCLES_ALIGNER_STALLED 29
#define D_CYCLE_DECODE_STALLED 30
#define D_CYCLE_POSTSYNC_STALLED 31
#define D_CYCLE_PRESYNC_STALLED 32
#define D_CYCLE_FROZEN 33
#define D_CYCLES_SB_WB_STALLED 34
#define D_CYCLES_DMA_DCCM_TRANSACTION_STALLED 35
#define D_CYCLES_DMA_ICCM_TRANSACTION_STALLED 36
#define D_EXCEPTIONS_TAKEN 37
#define D_TIMER_INTERRUPTS_TAKEN 38
#define D_EXTERNAL_INTERRUPTS_TAKEN 39
#define D_TLU_FLUSHES 40
#define D_BRANCH_FLUSHES 41
#define D_I_BUS_TRANSACTIONS_INSTR 42
#define D_D_BUD_TRANSACTIONS_LD_ST 43
#define D_D_BUS_TRANSACTIONS_MISALIGNED 44
#define D_I_BUS_ERRORS 45
#define D_D_BUS_ERRORS 46
#define D_CYCLES_STALLED_DUE_TO_I_BUS_BUSY 47
#define D_CYCLES_STALLED_DUE_TO_D_BUS_BUSY 48
#define D_CYCLES_INTERRUPTS_DISABLED 49
#define D_CYCLES_INTERRUPTS_STALLED_WHILE_DISABLED 50
/**
* macros
*/
/**
* types
*/
/*
* Performance monitoring events
*/
/**
* local prototypes
*/
/**
* external prototypes
*/
/**
* global variables
*/
/**
* APIs
*/
/**
* @brief The function disables all the performance monitors
* ** Note ** Only Performance-Monitor counters 3..6 are disabled by this setting.
* The instruction-retired, cycles and time counters stay enabled.
*
*/
void pspMachinePerfMonitorDisableAll(void);
/**
* @brief The function enables all the performance monitors
*
*/
void pspMachinePerfMonitorEnableAll(void);
/**
* @brief The function pair a counter to an event
*
* @param uiCounter – counter to be set
* – supported counters are:
* D_PSP_COUNTER0
* D_PSP_COUNTER1
* D_PSP_COUNTER2
* D_PSP_COUNTER3
* @param eEvent – event to be paired to the selected counter
*
* @return No return value
*/
void pspMachinePerfCounterSet(u32_t uiCounter, u32_t uiEvent);
/**
* @brief The function gets the counter value (64 bit)
*
* @param eCounter – counter index
* – supported counters are:
* D_PSP_CYCLE_COUNTER
* D_PSP_TIME_COUNTER
* D_PSP_INSTRET_COUNTER
* D_PSP_COUNTER0
* D_PSP_COUNTER1
* D_PSP_COUNTER2
* D_PSP_COUNTER3
*
* @return u32_t – Counter value
*/
u64_t pspMachinePerfCounterGet(u32_t uiCounter);
#endif /* _PSP_PERFORMANCE_MONITOR_H_ */
|
edward-jones/riscv-fw-infrastructure | WD-Firmware/rtos/rtosal/rtosal_time.c | /*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2020-2021 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file rtosal_time.c
* @author <NAME>
* @date 21.01.2019
* @brief The file implements the RTOS AL timeer API
*
*/
/**
* include files
*/
#include "rtosal_time_api.h"
#include "rtosal_macros.h"
#include "rtosal_util.h"
#include "rtosal_interrupt_api.h"
#include "psp_api.h"
#include "rtosal_task_api.h"
#ifdef D_USE_FREERTOS
#include "timers.h"
#else
#error "Add appropriate RTOS definitions"
#endif /* #ifdef D_USE_FREERTOS */
/**
* definitions
*/
/**
* macros
*/
/**
* types
*/
/**
* local prototypes
*/
/**
* external prototypes
*/
/**
* global variables
*/
u32_t g_uTimerPeriod = 0;
/**
* @brief Timer creation function
*
* @param pRtosalTimerCb - Pointer to the timer control block to be created
* @param pTimerName - String of the timer name (for debuging)
* @param fptrTimerCallcabk - Function handler for timer expiration processing
* @param pTimeParam - A parameter to pass to the timer expiration function
* handler
* @param uiAutoActivate - Auto start timer after creation, Usage:
* D_RTOSAL_AUTO_START timer shall be activated when created
* D_RTOSAL_NO_ACTIVATE dont start timer on creation
* created; otherwise D_RTOSAL_NO_ACTIVATE
* @param uiTicks - Timer expiration period
* @param uiRescheduleTicks - Timer period after first expiration; used for
* periodic timer, meaning after expiration of uiTicks,
* how many ticks to wait before activating again
*
* @return u32_t - D_RTOSAL_SUCCESS
* - D_RTOSAL_TIMER_ERROR - The ptr, cTaskCB, in the pRtosalTimerCb is invalid
* or fptrTimerCallcabk is inavlid
* - D_RTOSAL_TICK_ERROR - Invalid uiTicks
* - D_RTOSAL_ACTIVATE_ERROR - Invalid uiAutoActivate
* - D_RTOSAL_CALLER_ERROR - The caller can not call this function
*/
RTOSAL_SECTION u32_t rtosTimerCreate(rtosalTimer_t* pRtosalTimerCb, s08_t *pRtosTimerName,
rtosalTimerHandler_t fptrRtosTimerCallcabk,
u32_t uiTimeCallbackParam, u32_t uiAutoActivate,
u32_t uiTicks, u32_t uiRescheduleTicks)
{
u32_t uiRes;
#ifdef D_USE_FREERTOS
UBaseType_t uiAutoReload;
#else
#error "Add appropriate RTOS definitions"
#endif /* #ifdef D_USE_FREERTOS */
M_RTOSAL_VALIDATE_FUNC_PARAM(pRtosalTimerCb, pRtosalTimerCb == NULL, D_RTOSAL_TIMER_ERROR);
#ifdef D_USE_FREERTOS
/* for one time timer */
uiAutoReload = (uiRescheduleTicks != 0) ? (pdTRUE) : (pdFALSE);
pRtosalTimerCb->timerHandle = xTimerCreateStatic((const char *)pRtosTimerName, uiTicks, uiAutoReload,
(void*)uiTimeCallbackParam, (TimerCallbackFunction_t)fptrRtosTimerCallcabk,
(StaticTimer_t*)pRtosalTimerCb->cTimerCB);
/* failed to create the timer */
if (pRtosalTimerCb->timerHandle == NULL)
{
uiRes = D_RTOSAL_TIMER_ERROR;
}
/* do we need to activate it now */
else if (uiAutoActivate == D_RTOSAL_AUTO_START)
{
uiRes = xTimerStart(pRtosalTimerCb->timerHandle, 0);
if (uiRes == pdPASS)
{
uiRes = D_RTOSAL_SUCCESS;
}
/* failed to activate the timer */
else
{
uiRes = D_RTOSAL_ACTIVATE_ERROR;
}
}
else
{
uiRes = D_RTOSAL_SUCCESS;
}
#elif D_USE_THREADX
#error "Add THREADX appropriate definitions"
#else
#error "Add appropriate RTOS definitions"
#endif /* #ifdef D_USE_FREERTOS */
return uiRes;
}
/**
* @brief Destroy a timer
*
* @param pRtosalTimerCb - Pointer to the timer control block to be destroyed
*
* @return u32_t - D_RTOSAL_SUCCESS
* - D_RTOSAL_TIMER_ERROR - The ptr, cTaskCB, in the pRtosalTimerCb is invalid
* - D_RTOSAL_CALLER_ERROR - The caller can not call this function
*/
RTOSAL_SECTION u32_t rtosTimerDestroy(rtosalTimer_t* pRtosalTimerCb)
{
u32_t uiRes;
M_RTOSAL_VALIDATE_FUNC_PARAM(pRtosalTimerCb, pRtosalTimerCb == NULL, D_RTOSAL_TIMER_ERROR);
#ifdef D_USE_FREERTOS
uiRes = xTimerDelete(pRtosalTimerCb->timerHandle, 0);
if (uiRes == pdPASS)
{
uiRes = D_RTOSAL_SUCCESS;
}
else
{
uiRes = D_RTOSAL_TIMER_ERROR;
}
#elif D_USE_THREADX
#error "Add THREADX appropriate definitions"
#else
#error "Add appropriate RTOS definitions"
#endif /* #ifdef D_USE_FREERTOS */
return uiRes;
}
/**
* @brief Start a timer
*
* @param pRtosalTimerCb - Pointer to the timer control block to be started
*
* @return u32_t - D_RTOSAL_SUCCESS
* - D_RTOSAL_TIMER_ERROR - The ptr, cTaskCB, in the pRtosalTimerCb is invalid
* - D_RTOSAL_ACTIVATE_ERROR - Timer is already running or already expried
* - D_RTOSAL_FAIL - Timers was not activated, request to active was rejected
*/
RTOSAL_SECTION u32_t rtosTimerStart(rtosalTimer_t* pRtosalTimerCb)
{
u32_t uiRes;
#ifdef D_USE_FREERTOS
/* specify if a context switch is needed as a uiResult calling FreeRTOS ...ISR function */
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
#else
#error "Add appropriate RTOS definitions"
#endif /* #ifdef D_USE_FREERTOS */
M_RTOSAL_VALIDATE_FUNC_PARAM(pRtosalTimerCb, pRtosalTimerCb == NULL, D_RTOSAL_TIMER_ERROR);
#ifdef D_USE_FREERTOS
/* rtosTimerStart invoked from an ISR context */
if (rtosalIsInterruptContext() == D_RTOSAL_INT_CONTEXT)
{
uiRes = xTimerStartFromISR(pRtosalTimerCb->timerHandle, &xHigherPriorityTaskWoken);
}
else
{
uiRes = xTimerStart(pRtosalTimerCb->timerHandle, 0);
}
/* align the return code */
if (uiRes == pdPASS)
{
uiRes = D_RTOSAL_SUCCESS;
}
else
{
/* The message could not be sent */
uiRes = D_RTOSAL_ACTIVATE_ERROR;
}
/* due to the start we got an indicating that a context switch
should be requested before the interrupt exits */
if (uiRes == D_RTOSAL_SUCCESS && xHigherPriorityTaskWoken == pdTRUE)
{
rtosalContextSwitchIndicationSet();
}
#elif D_USE_THREADX
#error "Add THREADX appropriate definitions"
#else
#error "Add appropriate RTOS definitions"
#endif /* #ifdef D_USE_FREERTOS */
return uiRes;
}
/**
* @brief Stop a timer
*
* @param pRtosalTimerCb - Pointer to the timer control block to be started
*
* @return u32_t - D_RTOSAL_SUCCESS
* - D_RTOSAL_TIMER_ERROR - The ptr, cTaskCB, in the pRtosalTimerCb is invalid
* - D_RTOSAL_FAIL - Timers was not Stopped, request to stop was rejected
*/
RTOSAL_SECTION u32_t rtosTimerStop(rtosalTimer_t* pRtosalTimerCb)
{
u32_t uiRes;
#ifdef D_USE_FREERTOS
/* specify if a context switch is needed as a uiResult calling FreeRTOS ...ISR function */
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
#else
#error "Add appropriate RTOS definitions"
#endif /* #ifdef D_USE_FREERTOS */
M_RTOSAL_VALIDATE_FUNC_PARAM(pRtosalTimerCb, pRtosalTimerCb == NULL, D_RTOSAL_TIMER_ERROR);
#ifdef D_USE_FREERTOS
/* rtosTimerStop invoked from an ISR context */
if (rtosalIsInterruptContext() == D_RTOSAL_INT_CONTEXT)
{
uiRes = xTimerStopFromISR(pRtosalTimerCb->timerHandle, &xHigherPriorityTaskWoken);
}
else
{
uiRes = xTimerStop(pRtosalTimerCb->timerHandle, 0);
}
/* align the return code */
if (uiRes == pdPASS)
{
uiRes = D_RTOSAL_SUCCESS;
}
else
{
/* The message could not be sent */
uiRes = D_RTOSAL_FAIL;
}
/* due to the stop we got an indicating that a context switch
should be requested before the interrupt exits */
if (uiRes == D_RTOSAL_SUCCESS && xHigherPriorityTaskWoken == pdTRUE)
{
rtosalContextSwitchIndicationSet();
}
#elif D_USE_THREADX
#error "Add THREADX appropriate definitions"
#else
#error "Add appropriate RTOS definitions"
#endif /* #ifdef D_USE_FREERTOS */
return uiRes;
}
/**
* @brief Modify the timer expiration value
*
* @param pRtosalTimerCb - Pointer to the timer control block to be modified
* @param uiTicks - Timer expiration period
* @param uiRescheduleTicks - Timer period after first expiration; used for
* periodic timer, meaning after expiration of uiTicks,
* how many ticks to wait before activating again
*
* @return u32_t - D_RTOSAL_SUCCESS
* - D_RTOSAL_TIMER_ERROR - The ptr, cTaskCB, in the pRtosalTimerCb is invalid
* - D_RTOSAL_TICK_ERROR - Invalid uiTicks
* - D_RTOSAL_CALLER_ERROR - The caller can not call this function
* - D_RTOSAL_ACTIVATE_ERROR - Timer is already running or already expried
*/
RTOSAL_SECTION u32_t rtosTimerModifyPeriod(rtosalTimer_t* pRtosalTimerCb, u32_t uiTicks, u32_t uiRescheduleTicks)
{
u32_t uiRes;
#ifdef D_USE_FREERTOS
/* specify if a context switch is needed as a uiResult calling FreeRTOS ...ISR function */
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
#elif D_USE_THREADX
UINT uiActive;
#else
#error "Add appropriate RTOS definitions"
#endif /* #ifdef D_USE_FREERTOS */
M_RTOSAL_VALIDATE_FUNC_PARAM(pRtosalTimerCb, pRtosalTimerCb == NULL, D_RTOSAL_TIMER_ERROR);
#ifdef D_USE_FREERTOS
/* rtosTimerModifyPeriod invoked from an ISR context */
if (rtosalIsInterruptContext() == D_RTOSAL_INT_CONTEXT)
{
uiRes = xTimerChangePeriodFromISR(pRtosalTimerCb->timerHandle, uiTicks, &xHigherPriorityTaskWoken);
}
else
{
uiRes = xTimerChangePeriod(pRtosalTimerCb->timerHandle, uiTicks, 0);
}
/* align the return code */
if (uiRes == pdPASS)
{
uiRes = D_RTOSAL_SUCCESS;
}
else
{
/* The message could not be sent */
uiRes = D_RTOSAL_FAIL;
}
/* due to the period change we got an indicating that a context switch
should be requested before the interrupt exits */
if (uiRes == D_RTOSAL_SUCCESS && xHigherPriorityTaskWoken == pdTRUE)
{
rtosalContextSwitchIndicationSet();
}
#elif D_USE_THREADX
/* get timer info */
// TODO:
//uiRes = add a call to ThreadX timer get period API
if (uiRes == D_RTOSAL_SUCCESS)
{
/* check if the timer is active - we need to stop it */
if (uiActive == TX_TRUE)
{
//uiRes = add a call to ThreadX timer stop API
}
/* deactivate was successful */
if (uiRes == D_RTOSAL_SUCCESS)
{
/* now we are sure the timer is inactive, we can change it */
//uiRes = add a call to ThreadX timer change period API
/* check if the timer was active - we need to restart it */
if (uiRes == D_RTOSAL_SUCCESS && uiActive == TX_TRUE)
{
//uiRes = add a call to ThreadX timer start API
}
}
}
#elif D_USE_THREADX
#error "Add THREADX appropriate definitions"
#else
#error "Add appropriate RTOS definitions"
#endif /* #ifdef D_USE_FREERTOS */
return uiRes;
}
/**
* @brief rtosalTimerSetPeriod - Store the input parameter in a global variable for usage along the program run
* (used for setup the timer-counter as the period time to count-up)
*
* @param timerPeriod
*
*/
void rtosalTimerSetPeriod(u32_t timerPeriod)
{
g_uTimerPeriod = timerPeriod;
}
/**
* @brief rtosalTimerSetup - Setup & activates core's timer
*
* @param void
*
*/
void rtosalTimerSetup(void)
{
/* In case g_uTimerPeriod = 0 then there is no point to activate the timer */
M_PSP_ASSERT(0 == g_uTimerPeriod);
/* Enable timer interrupt */
pspMachineInterruptsEnableIntNumber(D_PSP_INTERRUPTS_MACHINE_TIMER);
/* Activates Core's timer with the calculated period */
pspMachineTimerCounterSetupAndRun(g_uTimerPeriod);
}
/**
* @brief rtosalTimerIntHandler - Timer interrupt handler
*
* @param void
*
*/
void rtosalTimerIntHandler(void)
{
/* Disable Machine-Timer interrupt */
pspMachineInterruptsDisableIntNumber(D_PSP_INTERRUPTS_MACHINE_TIMER);
/* Increment the RTOS tick. */
rtosalTick();
/* Setup the Timer for next round */
rtosalTimerSetup();
}
|
edward-jones/riscv-fw-infrastructure | WD-Firmware/psp/api_inc/psp_int_vect_eh2.h | /*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2020 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file psp_int_vect_eh2.h
* @author <NAME>
* @date 12.07.2020
* @brief Define the interrupts vector tables of hart0 and hart1 in SweRV EH2
*/
#ifndef __PSP_INT_VECT_EH2_H__
#define __PSP_INT_VECT_EH2_H__
/**
* include files
*/
/**
* macros
*/
/**
* types
*/
/**
* definitions
*/
#ifdef M_PSP_VECT_TABLE
#undef M_PSP_VECT_TABLE
/* Interrupt vector table */
/* In SweRV EH2 with single HW thread - only psp_vect_table_hart0 is used */
#define M_PSP_VECT_TABLE psp_vect_table_hart0
#endif
/* In SweRV EH2 with 2 HW thread - both psp_vect_table_hart0 psp_vect_table_hart1 are used */
#define M_PSP_VECT_TABLE_HART0 psp_vect_table_hart0
#define M_PSP_VECT_TABLE_HART1 psp_vect_table_hart1
/**
* local prototypes
*/
/**
* external prototypes
*/
void psp_vect_table_hart0(void);
void psp_vect_table_hart1(void);
/**
* global variables
*/
/**
* APIs
*/
#endif /* __PSP_INT_VECT_EH2_H__ */
|
edward-jones/riscv-fw-infrastructure | WD-Firmware/psp/api_inc/psp_csrs_el2.h | /*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2020 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file psp_csrs_el2.h
* @author <NAME>
* @date 09.8.2020
* @brief Definitions of Swerv's (EL2 version) CSRs
*
*/
#ifndef __PSP_CSRS_EL2_H__
#define __PSP_CSRS_EL2_H__
/**
* include files
*/
/**
* definitions
*/
/**********************************/
/* Non standard CSRs in SweRV EL2 */
/**********************************/
/* mscause CSR */
#define D_PSP_MSCAUSE_NUM 0x7FF /* Machine Secondary cause CSR */
/* Instruction access fault */
#define D_PSP_I_SIDE_BUS_ERROR 0
#define D_PSP_I_SIDE_DOUBLE_BIT_ECC_ERROR 1
#define D_PSP_I_SIDE_UNMAPPED_ADDRESS_ERROR 2
#define D_PSP_I_SIDE_ACCESS_OUT_OF_MPU_RANGE 3
/* Illegal instruction */
#define D_PSP_INSTRUCTION_DATA 0
/* Breakpoint */
#define D_PSP_EBREAK_NOT_TODEBUG_MODE 0
#define D_PSP_TRIGGER_HIT_NOT_TO_DEBUG_MODE 1
/* Load address misaligned */
#define D_PSP_D_SIDE_LOAD_ACROSS_REGION_BOUNDARY 0
#define D_PSP_D_SIDE_SIZE_MISALIGNED_LOAD_TO_NON_IDEMPOTENT_ADDRESS 1
/* Load access fault */
#define D_PSP_D_SIDE_CORE_LOCAL_LOAD_UNMAPPED_ADDRESS_ERROR 0
#define D_PSP_D_SIDE_DCCM_LOAD_DOUBLE_BIT_ECC_ERROR 1
#define D_PSP_D_SIDE_LOAD_STACK_CHECK_ERROR 2
#define D_PSP_D_SIDE_LOAD_SIDE_LOAD_ACCESS_OUT_OF_MPU_RANGE 3
#define D_PSP_D_SIDE_64_LOAD_ACCESS_ERROR 4
#define D_PSP_D_SIDE_LOAD_REGION_PREDICTION_ERROR 5
#define D_PSP_D_SIDE_PIC_LOAD_ACCESS_ERROR 6
/* Store/AMO address misaligned */
#define D_PSP_D_SIDE_STORE_ACROSS_REGION_BOUNDARY 0
#define D_PSP_D_SIDE_SIZE_MISALIGNED_STORE_TO_NON_IDEMPOTENT_ADDRESS 1
/* Store/AMO access fault */
#define D_PSP_D_SIDE_CORE_LOCAL_STORE_UNMAPPED_ADDRESS_ERROR 0
#define D_PSP_D_SIDE_DCCM_STORE_DOUBLE_BIT_ECC_ERROR 1
#define D_PSP_D_SIDE_STORE_STACK_CHECK_ERROR 2
#define D_PSP_D_SIDE_STORE_SIDE_LOAD_ACCESS_OUT_OF_MPU_RANGE 3
#define D_PSP_D_SIDE_64_STORE_ACCESS_ERROR 4
#define D_PSP_D_STORE_REGION_PREDICTION_ERROR 5
#define D_PSP_D_SIDE_PIC_STORE_ACCESS_ERROR 6
/* Environment call from M-mode */
#define D_PSP_ECALL 0
/**************/
/* Force-Debug CSRs */
/**************/
#define D_PSP_MFDHT_NUM 0x7CE /* Forced Debug Halt Threshold register */
#define D_PSP_MFDHT_ENABLE_MASK 0x00000001 /* bit 0 */
#define D_PSP_MFDHT_THRESHOLD_MASK 0x0000003E /* Power-of-two exponent of timeout threshold - bits 1..5 */
#define D_PSP_MFDHT_THRESHOLD_SHIFT 1
#define D_PSP_MFDHS_NUM 0x7CF /* Forced Debug Halt Status register */
#define D_PSP_MFDS_LSU_STATUS_MASK 0x00000001 /* LSU bus transaction termination status - bit 0 */
#define D_PSP_MFDS_IFU_STATUS_MASK 0x00000002 /* IFU bus transaction termination status - bit 1 */
/**************************************/
/* Performance monitoring control CSR */
/**************************************/
#define D_PSP_MCOUNTINHIBIT_NUM 0x320
/**
* macros
*/
/**
* types
*/
/**
* local prototypes
*/
/**
* external prototypes
*/
/**
* global variables
*/
/**
* APIs
*/
#endif /* __PSP_CSRS_EL2_H__ */
|
edward-jones/riscv-fw-infrastructure | WD-Firmware/rtos/rtosal/api_inc/rtosal_task_api.h | /*
* SPDX-License-Identifier: Apache-2.0
* Copyright 2019 Western Digital Corporation or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:*www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file rtosal_task_api.h
* @author <NAME>
* @date 07.02.2019
* @brief The file defines the RTOS AL task interfaces
*/
#ifndef __RTOSAL_TASK_API_H__
#define __RTOSAL_TASK_API_H__
/**
* include files
*/
#include "rtosal_config.h"
#include "rtosal_defines.h"
#include "rtosal_types.h"
#include "rtosal_macros.h"
/**
* definitions
*/
/**
* macros
*/
#ifdef D_USE_FREERTOS
#define M_TASK_CB_SIZE_IN_BYTES sizeof(StaticTask_t)
#elif D_USE_THREADX
#define M_TASK_CB_SIZE_IN_BYTES sizeof(TBD) // size of the CB struct
#else
#error "Add appropriate RTOS definitions"
#endif /* #ifdef D_USE_FREERTOS */
#ifdef D_USE_FREERTOS
#define D_MAX_PRIORITY (configMAX_PRIORITIES-1)
#elif D_USE_THREADX
#define D_MAX_PRIORITY (TBD) // size of the CB struct
#else
#error "Add appropriate RTOS definitions"
#endif /* #ifdef D_USE_FREERTOS */
/**
* types
*/
#ifdef D_USE_FREERTOS
typedef void* entryPointParam_t;
#elif D_USE_THREADX
#error *** TODO: need to define the TBD ***
typedef TBD entryPointParam_t;
#else
#error "Add appropriate RTOS definitions"
#endif /* #ifdef D_USE_FREERTOS */
typedef enum rtosalPriority
{
#ifdef D_USE_FREERTOS
E_RTOSAL_PRIO_0 = 31, /* highest priority */
E_RTOSAL_PRIO_1 = 30,
E_RTOSAL_PRIO_2 = 29,
E_RTOSAL_PRIO_3 = 28,
E_RTOSAL_PRIO_4 = 27,
E_RTOSAL_PRIO_5 = 26,
E_RTOSAL_PRIO_6 = 25,
E_RTOSAL_PRIO_7 = 24,
E_RTOSAL_PRIO_8 = 23,
E_RTOSAL_PRIO_9 = 22,
E_RTOSAL_PRIO_10 = 21,
E_RTOSAL_PRIO_11 = 20,
E_RTOSAL_PRIO_12 = 19,
E_RTOSAL_PRIO_13 = 18,
E_RTOSAL_PRIO_14 = 17,
E_RTOSAL_PRIO_15 = 16,
E_RTOSAL_PRIO_16 = 15,
E_RTOSAL_PRIO_17 = 14,
E_RTOSAL_PRIO_18 = 13,
E_RTOSAL_PRIO_19 = 12,
E_RTOSAL_PRIO_20 = 11,
E_RTOSAL_PRIO_21 = 10,
E_RTOSAL_PRIO_22 = 9,
E_RTOSAL_PRIO_23 = 8,
E_RTOSAL_PRIO_24 = 7,
E_RTOSAL_PRIO_25 = 6,
E_RTOSAL_PRIO_26 = 5,
E_RTOSAL_PRIO_27 = 4,
E_RTOSAL_PRIO_28 = 3,
E_RTOSAL_PRIO_29 = 2,
E_RTOSAL_PRIO_30 = 1,
E_RTOSAL_PRIO_31 = 0,
#elif D_USE_THREADX
E_RTOSAL_PRIO_0 = 0, /* highest priority */
E_RTOSAL_PRIO_1 = 1,
E_RTOSAL_PRIO_2 = 2,
E_RTOSAL_PRIO_3 = 3,
E_RTOSAL_PRIO_4 = 4,
E_RTOSAL_PRIO_5 = 5,
E_RTOSAL_PRIO_6 = 6,
E_RTOSAL_PRIO_7 = 7,
E_RTOSAL_PRIO_8 = 8,
E_RTOSAL_PRIO_9 = 9,
E_RTOSAL_PRIO_10 = 10,
E_RTOSAL_PRIO_11 = 11,
E_RTOSAL_PRIO_12 = 12,
E_RTOSAL_PRIO_13 = 13,
E_RTOSAL_PRIO_14 = 14,
E_RTOSAL_PRIO_15 = 15,
E_RTOSAL_PRIO_16 = 16,
E_RTOSAL_PRIO_17 = 17,
E_RTOSAL_PRIO_18 = 18,
E_RTOSAL_PRIO_19 = 19,
E_RTOSAL_PRIO_20 = 20,
E_RTOSAL_PRIO_21 = 21,
E_RTOSAL_PRIO_22 = 22,
E_RTOSAL_PRIO_23 = 23,
E_RTOSAL_PRIO_24 = 24,
E_RTOSAL_PRIO_25 = 25,
E_RTOSAL_PRIO_26 = 26,
E_RTOSAL_PRIO_27 = 27,
E_RTOSAL_PRIO_28 = 28,
E_RTOSAL_PRIO_29 = 29,
E_RTOSAL_PRIO_30 = 30,
E_RTOSAL_PRIO_31 = 31,
#else
#error "Add appropriate RTOS definitions"
#endif /* #ifdef D_USE_FREERTOS */
E_RTOSAL_PRIO_MAX = E_RTOSAL_PRIO_31
} rtosalPriority_t;
typedef struct rtosalTask
{
#ifdef D_USE_FREERTOS
void* taskHandle;
#else
#error "Add appropriate RTOS definitions"
#endif /* #ifdef D_USE_FREERTOS */
s08_t cTaskCB[M_TASK_CB_SIZE_IN_BYTES];
} rtosalTask_t;
/* task handler definition */
typedef void (*rtosalTaskHandler_t)(entryPointParam_t);
/* application specific initialization function */
typedef void (*rtosalApplicationInit_t)(void *pParam);
/* application specific timer-tick handler function */
typedef void (*rtosalTimerTickHandler_t)(void);
/**
* local prototypes
*/
/**
* external prototypes
*/
/**
* global variables
*/
/**
* APIs
*/
/**
* Task creation function
*/
u32_t rtosalTaskCreate(rtosalTask_t* pRtosalTaskCb, const s08_t* pTaskName, rtosalPriority_t uiPriority,
rtosalTaskHandler_t fptrRtosTaskEntryPoint, u32_t uiTaskEntryPointParameter,
u32_t uiStackSize, void * pStackBuffer, u32_t uiTimeSliceTicks,
u32_t uiAutoStart, u32_t uiPreemptThuiReshold);
/**
* Delete a task
*/
u32_t rtosalTaskDestroy(rtosalTask_t* pRtosalTaskCb);
/**
* Change the priority of a specific task
*/
u32_t rtosalTaskPriorityChange(rtosalTask_t* pRtosalTaskCb, u32_t uiNewPriority,
u32_t *pOldPriority);
/**
* Voluntarily yield CPU time to another task
*/
void rtosalTaskYield(void);
/**
* Resume a suspended task
*/
u32_t rtosalTaskResume(rtosalTask_t* pRtosalTaskCb);
/**
* Suspend the execution of a specific task for a specific time
*/
u32_t rtosalTaskSleep(u32_t uiTimerTicks);
/**
* Suspend the execution of a specific task
*/
u32_t rtosalTaskSuspend(rtosalTask_t* pRtosalTaskCb);
/**
* Abort a task which is in currently blocked
*/
u32_t rtosalTaskWaitAbort(rtosalTask_t* pRtosalTaskCb);
/**
* Initialization of the RTOS and starting the scheduler operation
*/
void rtosalStart(rtosalApplicationInit_t fptrInit);
/**
* Ending of scheduler operation
*/
void rtosalEndScheduler(void);
/**
* Registration for TimerTick handler function
*/
void rtosalRegisterTimerTickHandler(rtosalTimerTickHandler_t fptrHandler);
/**
* @brief set indication that context-switch is required
*
* @param None
*
*/
void rtosalContextSwitchIndicationSet(void);
/**
* @brief clear the context-switch indication
*
* @param None
*
*/
void rtosalContextSwitchIndicationClear(void);
/**
* retrieve scheduler state
*/
u32_t rtosalGetSchedulerState(void);
#endif /* __RTOSAL_TASK_API_H__ */
|
chzchzchz/chaos | attractor.h | <gh_stars>1-10
#ifndef ATTRACTOR_H
#define ATTRACTOR_H
#include <vector>
#include "xfm.h"
#include "hitmap.h"
#define MAP_DEGREE 3
#define SEARCH_DIM_X 100
#define SEARCH_DIM_Y 100
#define SEARCH_VMIN -2.0
#define SEARCH_VMAX 2.0
#define MIN_FILL 0.15
#define SEARCH_ITERS 10000
class Attractor
{
public:
Attractor();
const xfm& get_xfm(void) const { return search_xfm; }
void apply(HitMap& hm, unsigned iters) const;
private:
bool try_vec_bounds(unsigned iters);
bool try_vecs(unsigned iters);
bool try_vecs_usage(unsigned iters) const;
unsigned find_vecs(void);
struct xfm search_xfm;
std::vector<double> a, b;
};
#endif
|
chzchzchz/chaos | hitmap.h | <filename>hitmap.h
#ifndef HITMAP_H
#define HITMAP_H
#include "xfm.h"
class HitMap
{
public:
HitMap(const struct xfm& xfm_, unsigned x, unsigned y);
HitMap(unsigned x, unsigned y);
~HitMap();
void inc(double x, double y);
unsigned get_dim_x(void) const { return dimx; }
unsigned get_dim_y(void) const { return dimy; }
const unsigned char *get_row(unsigned y) const { return img[y]; }
unsigned get_fill_count(void) const;
private:
void init_img(void);
unsigned char **img;
unsigned int dimx;
unsigned int dimy;
struct xfm hm_xfm;
};
#endif
|
chzchzchz/chaos | xfm.h | <gh_stars>1-10
#ifndef XFM_H
#define XFM_H
// describes how to scale/translate x,y coords
struct xfm {
xfm()
: scaleX(1.0)
, scaleY(1.0)
, xlateX(0.0)
, xlateY(0.0)
{}
double scaleX;
double scaleY;
double xlateX;
double xlateY;
};
#endif
|
robcog-iai/UMenu | Source/UMenu/Public/CreateServerUI.h | <reponame>robcog-iai/UMenu<filename>Source/UMenu/Public/CreateServerUI.h
// Copyright 2018, Institute for Artificial Intelligence - University of Bremen
#pragma once
#include "SlateBasics.h"
#include "MainMenuHUD.h"
#include "MenuGI.h"
// Lays out and controls the Main Menu UI for our tutorial.
class UMENU_API SCreateServerUI : public SCompoundWidget
{
public:
SLATE_BEGIN_ARGS(SCreateServerUI)
{}
SLATE_ARGUMENT(TWeakObjectPtr<class AMainMenuHUD>, MainMenuHUD)
SLATE_END_ARGS()
// Constructs and lays out the Main Menu UI Widget.
// args Arguments structure that contains widget-specific setup information.
void Construct(const FArguments& args);
// Stores a weak reference to the HUD controlling this class.
TWeakObjectPtr<class AMainMenuHUD> MainMenuHUD;
// Style for the menu
const struct FGlobalStyle* MenuStyle;
// Called when the back button was clicked
FReply BackClicked();
// Box will later display the list of maps
TSharedPtr<SVerticalBox> Box;
// Pulls the map names out of the projects map folder
TArray<FString> GetAllMapNames();
// List of map names
TArray<FString> Maps;
// Adds the maps to the Box so they are shown in the UI
void AddMapsToList();
// Opens the map that was clicked
FReply OpenMapClicked(FString MapName);
// Called when the checkboxs status was changed
void VRCheckBoxChanged(ECheckBoxState InCheckedState);
// Called to get the current status of the checkbox
ECheckBoxState IsVRBoxActive() const;
}; |
robcog-iai/UMenu | Source/UMenu/Public/MainMenuHUD.h | <gh_stars>1-10
// Copyright 2018, Institute for Artificial Intelligence - University of Bremen
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/HUD.h"
#include "MainMenuHUD.generated.h"
/**
*
*/
UCLASS()
class UMENU_API AMainMenuHUD : public AHUD
{
GENERATED_BODY()
// Initializes the Slate UI and adds it as widget content to the game viewport.
virtual void PostInitializeComponents() override;
// Reference to the Main Menu Slate UI.
TSharedPtr<class SMainMenuUI> MainMenuUI;
// Reference to the Main Menu Slate UI.
TSharedPtr<class SServerListUI> ServerListUI;
// Reference to the Main Menu Slate UI.
TSharedPtr<class SCreateServerUI> CreateServerUI;
// Reference to the Main Menu Slate UI.
TSharedPtr<class SSettingsUI> SettingsUI;
// Reference to the Main Menu Slate UI.
TSharedPtr<class SIngameUI> IngameListUI;
public:
// Load server list ui
void LoadServerList();
// Load map list ui
void LoadMapList();
// Load settings ui
void LoadSettings();
// Go back to the main menu ui
void LoadMainMenuFromServerList();
// Go back to the main menu ui
void LoadMainMenuFromCreateServer();
// Go back to the main menu ui
void LoadMainMenuFromSettings();
/**
Tells the UI how many sessions have been found
@param i - number of found sessions
*/
UFUNCTION(BlueprintCallable)
void GiveSessionsNumber(int i);
// Makes the UI visible
UFUNCTION(BlueprintCallable)
void MakeVisible();
// Makes the UI hidden
UFUNCTION(BlueprintCallable)
void MakeHidden();
};
|
robcog-iai/UMenu | Source/UMenu/Public/SettingsUI.h | <reponame>robcog-iai/UMenu
// Copyright 2018, Institute for Artificial Intelligence - University of Bremen
#pragma once
#include "SlateBasics.h"
#include "MainMenuHUD.h"
#include "MenuGI.h"
// Lays out and controls the Main Menu UI for our tutorial.
class UMENU_API SSettingsUI : public SCompoundWidget
{
public:
SLATE_BEGIN_ARGS(SSettingsUI)
{}
SLATE_ARGUMENT(TWeakObjectPtr<class AMainMenuHUD>, MainMenuHUD)
SLATE_END_ARGS()
// Constructs and lays out the Main Menu UI Widget.
// args Arguments structure that contains widget-specific setup information.
void Construct(const FArguments& args);
// Go back to the main menu ui
FReply BackClicked();
// Stores a weak reference to the HUD controlling this class.
TWeakObjectPtr<class AMainMenuHUD> MainMenuHUD;
// Style for the menu
const struct FGlobalStyle* MenuStyle;
// Is called when the text was changed
void OnTextChanged(const FText & Text);
// Is called when the button is clicked
FReply ButtonClicked();
// Is called when check box status changed
void CheckBoxChanged(ECheckBoxState InCheckedState);
// Is called to see if checkbox is currently checked
ECheckBoxState IsBoxActive() const;
}; |
robcog-iai/UMenu | Source/UMenu/Public/MenuGI.h | <filename>Source/UMenu/Public/MenuGI.h
// Copyright 2017, Institute for Artificial Intelligence - University of Bremen
#pragma once
#include "CoreMinimal.h"
#include "Engine/GameInstance.h"
#include "UMenu.h"
#include "MenuGI.generated.h"
/**
*
*/
UCLASS()
class UMENU_API UMenuGI : public UGameInstance
{
GENERATED_BODY()
public:
// Finds a session
UFUNCTION(BlueprintImplementableEvent)
void FindSessionEvent();
// Joins a session
UFUNCTION(BlueprintImplementableEvent)
void JoinSessionEvent();
// Opens a map
UFUNCTION(BlueprintImplementableEvent)
void OpenMap();
// Map name
UPROPERTY(BlueprintReadWrite)
FString Map;
// VR mode on/off
UPROPERTY(BlueprintReadWrite)
bool bVRMode;
// Multiplayer on/off
UPROPERTY(BlueprintReadWrite)
bool bMultiplayer;
// List of found sessions
UPROPERTY(BlueprintReadWrite)
TArray<FString> FoundSession;
};
|
robcog-iai/UMenu | Source/UMenu/Public/MenuStyles.h | // Copyright 2018, Institute for Artificial Intelligence - University of Bremen
#pragma once
#include "CoreMinimal.h"
#include "SlateBasics.h"
/**
*
*/
class UMENU_API FMenuStyles
{
public:
// Initializes the value of MenuStyleInstance and registers it with the Slate Style Registry.
static void Initialize();
// Unregisters the Slate Style Set and then resets the MenuStyleInstance pointer.
static void Shutdown();
// Retrieves a reference to the Slate Style pointed to by MenuStyleInstance.
static const class ISlateStyle& Get();
// Retrieves the name of the Style Set.
static FName GetStyleSetName();
private:
// Creates the Style Set.
static TSharedRef<class FSlateStyleSet> Create();
// Singleton instance used for our Style Set.
static TSharedPtr<class FSlateStyleSet> MenuStyleInstance;
}; |
robcog-iai/UMenu | Source/UMenu/Public/ServerListUI.h | <gh_stars>1-10
// Copyright 2018, Institute for Artificial Intelligence - University of Bremen
#pragma once
#include "SlateBasics.h"
#include "MainMenuHUD.h"
// Lays out and controls the Main Menu UI for our tutorial.
class UMENU_API SServerListUI : public SCompoundWidget
{
public:
SLATE_BEGIN_ARGS(SServerListUI)
{}
SLATE_ARGUMENT(TWeakObjectPtr<class AMainMenuHUD>, MainMenuHUD)
SLATE_END_ARGS()
// Constructs and lays out the Main Menu UI Widget.
// args Arguments structure that contains widget-specific setup information.
void Construct(const FArguments& args);
// Stores a weak reference to the HUD controlling this class.
TWeakObjectPtr<class AMainMenuHUD> MainMenuHUD;
// Style for the menu
const struct FGlobalStyle* MenuStyle;
// Called if "JoinGame" has been clicked
FReply JoinGameClicked();
// Called if "FindSession" has been clicked
FReply FindSessionClicked();
/**
Updates the displayed number of found sessions
@param i - number of sessions
*/
void UpdateSessionsString(int i);
// Default string that shows number of sessions
FString SessionsString = "Sessions: 0";
// TAttribute with session text
TAttribute<FText> Sessions;
// Getter for sessions text that is used to update UI if it changes
FText GetSessions() const;
// Go back to main menu ui
FReply BackClicked();
// Box for server list
TSharedPtr<SVerticalBox> Box;
// List of server names
TArray<FString> Servers;
}; |
robcog-iai/UMenu | Source/UMenu/Public/GlobalMenuStyle.h | // Copyright 2018, Institute for Artificial Intelligence - University of Bremen
#pragma once
#include "SlateWidgetStyleContainerBase.h"
#include "SlateWidgetStyle.h"
#include "SlateBasics.h"
#include "GlobalMenuStyle.generated.h"
// Provides a group of global style settings for our game menus!
USTRUCT()
struct UMENU_API FGlobalStyle : public FSlateWidgetStyle
{
GENERATED_USTRUCT_BODY()
// Stores a list of Brushes we are using (we aren't using any) into OutBrushes.
virtual void GetResources(TArray<const FSlateBrush*>& OutBrushes) const override;
// Stores the TypeName for our widget style.
static const FName TypeName;
// Retrieves the type name for our global style, which will be used by our Style Set to load the right file.
virtual const FName GetTypeName() const override;
// Allows us to set default values for our various styles.
static const FGlobalStyle& GetDefault();
// Style that define the appearance of all menu buttons.
UPROPERTY(EditAnywhere, Category = Appearance)
FButtonStyle MenuButtonStyle;
// Style that defines the text on all of our menu buttons.
UPROPERTY(EditAnywhere, Category = Appearance)
FTextBlockStyle MenuButtonTextStyle;
// Style that defines the text for our menu title.
UPROPERTY(EditAnywhere, Category = Appearance)
FTextBlockStyle MenuTitleStyle;
// Style for the editable text box
UPROPERTY(EditAnywhere, Category = Appearance)
FEditableTextBoxStyle TextBox;
};
// Provides a widget style container to allow us to edit properties in-editor
UCLASS(hidecategories = Object, MinimalAPI)
class UGlobalMenuStyle : public USlateWidgetStyleContainerBase
{
GENERATED_UCLASS_BODY()
public:
// This is our actual Style object.
UPROPERTY(EditAnywhere, Category = Appearance, meta = (ShowOnlyInnerProperties))
FGlobalStyle MenuStyle;
// Retrievs the style that this container manages.
virtual const struct FSlateWidgetStyle* const GetStyle() const override
{
return static_cast<const struct FSlateWidgetStyle*>(&MenuStyle);
}
}; |
AppleEducate/arkit-by-example | arkit-by-example/ViewController.h | //
// ViewController.h
// arkit-by-example
//
// Created by md on 6/8/17.
// Copyright © 2017 ruanestudios. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <SceneKit/SceneKit.h>
#import <ARKit/ARKit.h>
#import "Plane.h"
#import "Cube.h"
#import "Config.h"
#import "MessageView.h"
@interface ViewController : UIViewController<UIPopoverPresentationControllerDelegate>
- (void)setupScene;
- (void)setupLights;
- (void)setupPhysics;
- (void)setupRecognizers;
- (void)updateConfig;
- (void)hidePlanes;
- (void)refresh;
- (void)disableTracking:(BOOL)disabled;
- (void)insertCube:(ARHitTestResult *)hitResult;
- (void)explode:(ARHitTestResult *)hitResult;
- (void)insertCubeFrom: (UITapGestureRecognizer *)recognizer;
- (void)explodeFrom: (UITapGestureRecognizer *)recognizer;
- (void)geometryConfigFrom: (UITapGestureRecognizer *)recognizer;
- (IBAction)settingsUnwind:(UIStoryboardSegue *)segue;
- (IBAction)detectPlanesChanged:(id)sender;
@property (nonatomic, retain) NSMutableDictionary<NSUUID *, Plane *> *planes;
@property (nonatomic, retain) NSMutableArray<Cube *> *cubes;
@property (nonatomic, retain) Config *config;
@property (nonatomic, retain) ARWorldTrackingSessionConfiguration *arConfig;
@property (weak, nonatomic) IBOutlet MessageView *messageViewer;
@property (nonatomic) ARTrackingState currentTrackingState;
@end
|
MLinesCode/The-Complete-FAANG-Preparation | 3]. Competitive Programming/09]. HackerRank/1]. Practice/01]. C/1]. Introduction/_03)_Functions_in_C.c | <reponame>MLinesCode/The-Complete-FAANG-Preparation<gh_stars>1000+
#include <stdio.h>
/*
Add `int max_of_four(int a, int b, int c, int d)` here.
*/
int main()
{
int a, b, c, d,y;
scanf("%d\n",&a);
scanf("%d\n",&b);
scanf("%d\n",&c);
scanf("%d",&d);
if (a>b && a>c && a>d){
if (b<c && b<d){
y = b;
}
else if (c<b && c<d){
y = c;
}
else if (d<b && d<c){
y = d;
}
printf("%d\n", a);
}
else if (b>a && b>c && b>d) {
if (a<c && a<d){
y = a;
}
else if(c<a && c<d){
y = c;
}
else if(d<a && d<c){
y = d;
}
printf("%d\n", b);
}
else if (c>a && c>b && c>d)
{
if (a<b && a<d){
y = a;
}
else if(b<a && b<d){
y = b;
}
else if(d<a && d<b){
y = d;
}
printf("%d\n", c);
}
else if (d>a && d>b && d>c) {
if (a<b && a<c){
y = a;
}
else if(b<a && b<c){
y = b;
}
else if(c<a && c<b){
y = c;
}
printf("%d\n", d);
}
return 0;
}
|
MLinesCode/The-Complete-FAANG-Preparation | 3]. Competitive Programming/09]. HackerRank/1]. Practice/01]. C/1]. Introduction/_04)_Playing_With_Characters.c | #include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main()
{
char ch;
char stri[100],sent[10000];
scanf("%c\n",&ch);
gets(stri);
gets(sent);
printf("%c\n",ch);
puts(stri);
puts(sent);
return 0;
}
|
MLinesCode/The-Complete-FAANG-Preparation | 1]. DSA/1]. Data Structures/07]. Doubly Linked List/C/_001)_Palindrome_Checking.c | <filename>1]. DSA/1]. Data Structures/07]. Doubly Linked List/C/_001)_Palindrome_Checking.c
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
struct node{
char letter;
struct node *next;
struct node *prev;
}*head,*newhead,*temp,*newtemp,*new;
int main(){
int i,length,flag=1;
char input[20];
printf("\nEnter String: ");
scanf("%s",input);
length = strlen(input);
for(i=0;i<length;i++){ //storing one letter per node
new = (struct node *)malloc(sizeof(struct node));
new->letter = input[i];
new->next = NULL;
new->prev = NULL;
if(head==NULL){
head = new;
temp = new;
}
else{
new->prev = temp;
temp->next = new;
temp = new;
temp->next = NULL;
}
}
newhead = head;
newtemp = temp;
for(i=0;i<length;i++){
if(newhead->letter!=newtemp->letter){
flag=0;
break;
}
else{
flag=1;
}
newhead = newhead->next;
newtemp = newtemp->prev;
}
if(flag==0){
printf("Not palindrome");
}
else{
printf("Palindrome");
}
return 0;
}
|
MLinesCode/The-Complete-FAANG-Preparation | 3]. Competitive Programming/09]. HackerRank/1]. Practice/01]. C/2]. Conditionals and Loops/_03)_Sum_of_Digits_of_a_Five_Digit_Numbe.c | <gh_stars>1000+
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
int n,rem=0,sum=0;
scanf("%d", &n);
while(n!=0){
rem=n%10;
sum=sum+rem;
n=n/10;
}
printf("%d",sum);
return 0;
}
|
ElToberino/WiFiManager_for_Multidisplay | strings_en.h | <gh_stars>1-10
/**
* strings_en.h
* engligh strings for
* WifiManager_for_Multidisplay, forked by ElToberino of
* WiFiManager, a library for the ESP8266/Arduino platform
* for configuration of WiFi credentials using a Captive Portal
*
* all changes of this fork are marked with ///CHANGE MULTIDISPLAY
*
* @author <NAME>
* @author tablatronix
* @version 0.0.0
* @license MIT
*
*/
#ifndef _WM_STRINGS_H_
#define _WM_STRINGS_H_
#ifndef WIFI_MANAGER_OVERRIDE_STRINGS
// !!! THIS DOES NOT WORK, you cannot define in a sketch, if anyone one knows how to order includes to be able to do this help!
const char HTTP_HEAD_START[] PROGMEM = "<!DOCTYPE html><html lang='en'><head><meta name='format-detection' content='telephone=no'><meta charset='UTF-8'><meta name='viewport' content='width=device-width,initial-scale=1,user-scalable=no'/><title>{v}</title>";
///CHANGE MULTIDISPLAY -> Javascript file is loaded from SPIFFS
//const char HTTP_SCRIPT[] PROGMEM = "<script>function c(l){ document.getElementById('s').value=l.innerText||l.textContent; p = l.nextElementSibling.classList.contains('l'); document.getElementById('p').disabled = !p; if(p)document.getElementById('p').focus();}</script>";
const char HTTP_LINK_REL[] PROGMEM = "<link rel='stylesheet' href='/css'/><script type='text/javascript' src='/js'></script>"; ///CHANGE MULTIDISPLAY -> new html element calls function to load css and js from SPIFFS
const char HTTP_HEAD_END[] PROGMEM = "</head><body class='{c}'><div class='wrap'>";
const char HTTP_ROOT_MAIN[] PROGMEM = "<h1>Tobers Multidisplay</h1><h2><b>AP: </b>{v}</h2>"; ///CHANGE MULTIDISPLAY -> new content
const char * const HTTP_PORTAL_MENU[] PROGMEM = {
"<form action='/wifi' method='get'><button>Configure WiFi</button></form><br/>\n", // MENU_WIFI
"<form action='/0wifi' method='get'><button>Configure WiFi (No Scan)</button></form><br/>\n", // MENU_WIFINOSCAN
"<form action='/info' method='get'><button>Info</button></form><br/>\n", // MENU_INFO
"<form action='/param' method='get'><button>Setup</button></form><br/>\n",//MENU_PARAM
"<form action='/close' method='get'><button>Close</button></form><br/>\n", // MENU_CLOSE
"<form action='/restart' method='get'><button>Restart</button></form><br/>\n",// MENU_RESTART
"<form action='/exit' method='get'><button>Skip & Exit</button></form><br/>\n", // MENU_EXIT ///CHANGE MULTIDISPLAY
"<form action='/erase' method='get'><button class='D'>Erase</button></form><br/>\n", // MENU_ERASE
"<hr><br/>" // MENU_SEP
};
// const char HTTP_PORTAL_OPTIONS[] PROGMEM = strcat(HTTP_PORTAL_MENU[0] , HTTP_PORTAL_MENU[3] , HTTP_PORTAL_MENU[7]);
const char HTTP_PORTAL_OPTIONS[] PROGMEM = "";
const char HTTP_ITEM_QI[] PROGMEM = "<div role='img' aria-label='{r}%' title='{r}%' class='q q-{q} {i} {h}'></div>"; // rssi icons
const char HTTP_ITEM_QP[] PROGMEM = "<div class='q {h}'>{r}%</div>"; // rssi percentage
const char HTTP_ITEM[] PROGMEM = "<div><a href='#p' onclick='c(this)'>{v}</a>{qi}{qp}</div>"; // {q} = HTTP_ITEM_QI, {r} = HTTP_ITEM_QP
// const char HTTP_ITEM[] PROGMEM = "<div><a href='#p' onclick='c(this)'>{v}</a> {R} {r}% {q} {e}</div>"; // test all tokens
const char HTTP_FORM_START[] PROGMEM = "<form method='POST' action='{v}'>";
const char HTTP_FORM_WIFI[] PROGMEM = "<label for='s'>SSID</label><input id='s' name='s' maxlength='32' autocorrect='off' autocapitalize='none' placeholder='{v}'><br/><label for='p'>Password</label><input id='p' name='p' maxlength='64' type='password' placeholder='{p}'>";
const char HTTP_FORM_WIFI_END[] PROGMEM = "";
const char HTTP_FORM_STATIC_HEAD[] PROGMEM = "<hr><br/>";
const char HTTP_FORM_STATIC_END[] PROGMEM = "<hr>";
const char HTTP_FORM_END[] PROGMEM = "<button type='submit'>Save</button></form>";
const char HTTP_RADIO_ADV[] PROGMEM = "<hr><span class='labelAdv'>Advanced Settings<br><br></span><label for='dhcp' class='staticRadioLabel'>DHCP</label><input type='radio' id='dhcp' class='staticRadioInput' onclick='staticCheck();' checked='checked' autocomplete='off' name='toggle'><label for='static' class='staticRadioLabel'>Static IP</label><input type='radio' id='static' class='staticRadioInput' onclick='staticCheck();' autocomplete='off' name='toggle'>"; ///CHANGE MULTIDISPLAY
const char HTTP_FORM_LABEL[] PROGMEM = "<label for='{i}' id='{lb}' class='staticlabel'>{t}</label>"; ///CHANGE MULTIDISPLAY -> added id and class for label
const char HTTP_FORM_PARAM_HEAD[] PROGMEM = "<hr><br/>";
const char HTTP_FORM_PARAM[] PROGMEM = "<input id='{i}' name='{n}' class='none' maxlength='{l}' value='{v}' {c}>"; ///CHANGE MULTIDISPLAY -> added class for label
const char HTTP_SCAN_LINK[] PROGMEM = "<br/><form action='/wifi?refresh=1' method='POST'><button name='refresh' value='1'>Refresh</button></form>";
const char HTTP_SAVING_CRED[] PROGMEM = "<h3>...saving WiFi credentials...</h3>"; ///CHANGE MULTIDISPLAY -> new html element
const char HTTP_SAVED[] PROGMEM = "<div class='closing'>Trying to connect ESP to network.<br />If it fails reconnect to AP to try again</div>"; ///CHANGE MULTIDISPLAY -> added class for label
const char HTTP_PARAMSAVED[] PROGMEM = "<div class='closing'>Saved<br/></div>"; ///CHANGE MULTIDISPLAY -> added class for label
const char HTTP_END[] PROGMEM = "</div></body></html>";
const char HTTP_ERASEBTN[] PROGMEM = "<br/><form action='/erase' method='get'><button class='D'>Erase WiFi Config</button></form>";
const char HTTP_STATUS_ON[] PROGMEM = "<div class='msg P'><strong>Connected</strong> to {v}<br/><em><small>with IP {i}</small></em></div>";
const char HTTP_STATUS_OFF[] PROGMEM = "<div class='msg {c}'><strong>Not Connected</strong> to {v}{r}</div>";
const char HTTP_STATUS_OFFPW[] PROGMEM = "<br/>Authentication Failure"; // STATION_WRONG_PASSWORD, no eps32
const char HTTP_STATUS_OFFNOAP[] PROGMEM = "<br/>AP not found"; // WL_NO_SSID_AVAIL
const char HTTP_STATUS_OFFFAIL[] PROGMEM = "<br/>Could not Connect"; // WL_CONNECT_FAILED
const char HTTP_STATUS_NONE[] PROGMEM = "<div class='msg'>No AP set</div>";
const char HTTP_BR[] PROGMEM = "<br/>";
/// CHANGE MULTIDISPLAY: ADDITIONAL VARIABLES
const char HTTP_MULTIDISPLAY[] PROGMEM = "<h1>Tobers Multidisplay</h1>";
const char HTTP_BACKLINK[] PROGMEM = "<div class='backlink'><a href='/'>Back</a></div>";
const char HTTP_WIFI_SELECT[] PROGMEM = "<h3>Select your WiFi</h3>";
const char HTTP_INFOLINK[] PROGMEM = "<div class='info'><a href=\"info\">Show device info</a></div>";
const char HTTP_DEVICE_INFO[] PROGMEM = "<p class='deviceinfo'>Device Info: ";
const char HTTP_CLOSING[] PROGMEM = "<h3>...closing config portal...</h3>";
const char HTTP_CLOSING_FWD_1[] PROGMEM = "<div class='closing'>Setting up Multidisplay in AP-Mode<br>with IP <a href=\"http://";
const char HTTP_CLOSING_FWD_2[] PROGMEM = "\" style=\"text-decoration:none;\">";
const char HTTP_CLOSING_FWD_3[] PROGMEM = "</a><br>Please wait for a moment<br>then reconnect to AP<br><progress value='0' max='10' id='ctdBar'></progress></div>";
const char HTTP_STYLE_LIGHT[] PROGMEM = "<style>" /// CHANGE MULTDISPLAY: -> new html element: less CSS for exit and saving site
"body {text-align:center; margin:0; padding:0; background-color:#f6b54d; font-size:1em; font-family:sans-serif; color:white;} "
"h1 {text-align:center; font-size:180%; margin:0; padding:0; margin-bottom:0.5em; color:#af601a;} "
"h3 {text-align:center; font-weight:normal; margin:0; padding:0; margin-top:0.8em; margin-bottom:1em; color:white; font-size:115%;} "
".wrap {margin:1em; background-color:#f39c12; text-align:left; display:inline-block; padding:1em; border-radius:1em;} "
"a {color:white;} a:hover {color:#af601a;} a:active {color:#af601a;} "
".closing {margin-top:2em; margin-bottom:2em; text-align:center; line-height:1.5;} "
"</style>"
"<script>"
"var timeleft = 10;"
"var waitTimer = setInterval(function(){"
"if(timeleft <= 0){"
"clearInterval(waitTimer);"
"}"
"document.getElementById('ctdBar').value = 10 - timeleft;"
"timeleft -= 1;"
"}, 600);"
"</script>"
;
//const char HTTP_STYLE[] PROGMEM = "<style></style>"; /// CHANGE MULTIDISPLAY -> large(!) embedded CSS abandoned for CSS loading from SPIFFS
const char HTTP_HELP[] PROGMEM =
"<br/><h3>Available Pages</h3><hr>"
"<table class='table'>"
"<thead><tr><th>Page</th><th>Function</th></tr></thead><tbody>"
"<tr><td><a href='/'>/</a></td>"
"<td>Menu page.</td></tr>"
"<tr><td><a href='/wifi'>/wifi</a></td>"
"<td>Show WiFi scan results and enter WiFi configuration.(/0wifi noscan)</td></tr>"
"<tr><td><a href='/wifisave'>/wifisave</a></td>"
"<td>Save WiFi configuration information and configure device. Needs variables supplied.</td></tr>"
"<tr><td><a href='/param'>/param</a></td>"
"<td>Parameter page</td></tr>"
"<tr><td><a href='/info'>/info</a></td>"
"<td>Information page</td></tr>"
"<tr><td><a href='/close'>/close</a></td>"
"<td>Close the captiveportal popup,configportal will remain active</td></tr>"
"<tr><td><a href='/exit'>/exit</a></td>"
"<td>Exit Config Portal, configportal will close</td></tr>"
"<tr><td><a href='/restart'>/restart</a></td>"
"<td>Reboot the device</td></tr>"
"<tr><td><a href='/erase'>/erase</a></td>"
"<td>Erase WiFi configuration and reboot Device. Device will not reconnect to a network until new WiFi configuration data is entered.</td></tr>"
"</table>"
"<p/>More information about WiFiManager at <a href='https://github.com/tzapu/WiFiManager'>https://github.com/tzapu/WiFiManager</a>.";
#ifdef JSTEST
const char HTTP_JS[] PROGMEM =
"<script>function postAjax(url, data, success) {"
" var params = typeof data == 'string' ? data : Object.keys(data).map("
" function(k){ return encodeURIComponent(k) + '=' + encodeURIComponent(data[k]) }"
" ).join('&');"
" var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject(\"Microsoft.XMLHTTP\");"
" xhr.open('POST', url);"
" xhr.onreadystatechange = function() {"
" if (xhr.readyState>3 && xhr.status==200) { success(xhr.responseText); }"
" };"
" xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');"
" xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');"
" xhr.send(params);"
" return xhr;}"
"postAjax('/status', 'p1=1&p2=Hello+World', function(data){ console.log(data); });"
"postAjax('/status', { p1: 1, p2: 'Hello World' }, function(data){ console.log(data); });"
"</script>";
#endif
// Info html
#ifdef ESP32
const char HTTP_INFO_esphead[] PROGMEM = "<span style='color:#af601a;'>Esp32</span></p><hr><dl>"; ///CHANGE MULTIDISPLAY -> added <span>
const char HTTP_INFO_chiprev[] PROGMEM = "<dt>Chip Rev</dt><dd>{1}</dd>";
const char HTTP_INFO_lastreset[] PROGMEM = "<dt>Last reset reason</dt><dd>CPU0: {1}<br/>CPU1: {2}</dd>";
const char HTTP_INFO_aphost[] PROGMEM = "<dt>Acccess Point Hostname</dt><dd>{1}</dd>";
#else
const char HTTP_INFO_esphead[] PROGMEM = "<span style='color:#af601a;'>Esp8266</span></p><hr><dl>"; ///CHANGE MULTIDISPLAY -> added <span>
const char HTTP_INFO_flashsize[] PROGMEM = "<dt>Real Flash Size</dt><dd>{1} bytes</dd>";
const char HTTP_INFO_fchipid[] PROGMEM = "<dt>Flash Chip ID</dt><dd>{1}</dd>";
const char HTTP_INFO_corever[] PROGMEM = "<dt>Core Version</dt><dd>{1}</dd>";
const char HTTP_INFO_bootver[] PROGMEM = "<dt>Boot Version</dt><dd>{1}</dd>";
const char HTTP_INFO_memsketch[] PROGMEM = "<dt>Memory - Sketch Size</dt><dd>Used / Total bytes<br/>{1} / {2}";
const char HTTP_INFO_memsmeter[] PROGMEM = "<br/><progress value='{1}' max='{2}'></progress></dd>";
const char HTTP_INFO_lastreset[] PROGMEM = "<dt>Last reset reason</dt><dd>{1}</dd>";
#endif
const char HTTP_INFO_freeheap[] PROGMEM = "<dt>Memory - Free Heap</dt><dd>{1} bytes available</dd></dl>"; ///CHANGE MULTIDISPLAY -> added </dl>
const char HTTP_INFO_wifihead[] PROGMEM = "<br/><h3 style='margin-bottom:0em;'>WiFi</h3><hr><dl>"; ///CHANGE MULTIDISPLAY -> added style & added <dl>
const char HTTP_INFO_uptime[] PROGMEM = "<dt>Uptime</dt><dd>{1} Mins {2} Secs</dd>";
const char HTTP_INFO_chipid[] PROGMEM = "<dt>Chip ID</dt><dd>{1}</dd>";
const char HTTP_INFO_idesize[] PROGMEM = "<dt>Flash Size</dt><dd>{1} bytes</dd>";
const char HTTP_INFO_sdkver[] PROGMEM = "<dt>SDK Version</dt><dd>{1}</dd>";
const char HTTP_INFO_cpufreq[] PROGMEM = "<dt>CPU Frequency</dt><dd>{1}MHz</dd>";
const char HTTP_INFO_apip[] PROGMEM = "<dt>Access Point IP</dt><dd>{1}</dd>";
const char HTTP_INFO_apmac[] PROGMEM = "<dt>Access Point MAC</dt><dd>{1}</dd>";
const char HTTP_INFO_apssid[] PROGMEM = "<dt>SSID</dt><dd>{1}</dd>";
const char HTTP_INFO_apbssid[] PROGMEM = "<dt>BSSID</dt><dd>{1}</dd>";
const char HTTP_INFO_staip[] PROGMEM = "<dt>Station IP</dt><dd>{1}</dd>";
const char HTTP_INFO_stagw[] PROGMEM = "<dt>Station Gateway</dt><dd>{1}</dd>";
const char HTTP_INFO_stasub[] PROGMEM = "<dt>Station Subnet</dt><dd>{1}</dd>";
const char HTTP_INFO_dnss[] PROGMEM = "<dt>DNS Server</dt><dd>{1}</dd>";
const char HTTP_INFO_host[] PROGMEM = "<dt>Hostname</dt><dd>{1}</dd>";
const char HTTP_INFO_stamac[] PROGMEM = "<dt>Station MAC</dt><dd>{1}</dd>";
const char HTTP_INFO_conx[] PROGMEM = "<dt>Connected</dt><dd>{1}</dd>";
const char HTTP_INFO_autoconx[] PROGMEM = "<dt>Autoconnect</dt><dd>{1}</dd>";
const char HTTP_INFO_temp[] PROGMEM = "<dt>Temperature</dt><dd>{1} C° / {2} F°</dd>";
// Strings
const char S_y[] PROGMEM = "Yes";
const char S_n[] PROGMEM = "No";
const char S_enable[] PROGMEM = "Enabled";
const char S_disable[] PROGMEM = "Disabled";
const char S_GET[] PROGMEM = "GET";
const char S_POST[] PROGMEM = "POST";
const char S_NA[] PROGMEM = "Unknown";
const char S_passph[] PROGMEM = ""; ///CHANGE MULTIDISPLAY -> no placeholders for password field
const char S_titlewifisaved[] PROGMEM = "Credentials Saved";
const char S_titlewifisettings[] PROGMEM = "Settings Saved";
const char S_titlewifi[] PROGMEM = "Config ESP";
const char S_titleinfo[] PROGMEM = "Info";
const char S_titleparam[] PROGMEM = "Setup";
const char S_titleparamsaved[] PROGMEM = "Setup Saved";
const char S_titleexit[] PROGMEM = "Exit";
const char S_titlereset[] PROGMEM = "Reset";
const char S_titleerase[] PROGMEM = "Erase";
const char S_titleclose[] PROGMEM = "Close";
const char S_options[] PROGMEM = "options";
const char S_nonetworks[] PROGMEM = "No networks found. Refresh to scan again.";
const char S_staticip[] PROGMEM = "Static IP";
const char S_staticgw[] PROGMEM = "Static Gateway";
const char S_staticdns[] PROGMEM = "Static DNS";
const char S_subnet[] PROGMEM = "Subnet";
const char S_exiting[] PROGMEM = "Exiting";
const char S_resetting[] PROGMEM = "Module will reset in a few seconds.";
const char S_closing[] PROGMEM = "You can close the page, portal will continue to run";
const char S_error[] PROGMEM = "An Error Occured";
const char S_notfound[] PROGMEM = "File Not Found\n\n";
const char S_uri[] PROGMEM = "URI: ";
const char S_method[] PROGMEM = "\nMethod: ";
const char S_args[] PROGMEM = "\nArguments: ";
const char S_parampre[] PROGMEM = "param_";
// debug strings
const char D_HR[] PROGMEM = "--------------------";
// END WIFI_MANAGER_OVERRIDE_STRINGS
#endif
// -----------------------------------------------------------------------------------------------
// DO NOT EDIT BELOW THIS LINE
const uint8_t _nummenutokens = 9;
const char * const _menutokens[9] PROGMEM = {
"wifi",
"wifinoscan",
"info",
"param",
"close",
"restart",
"exit",
"erase",
"sep"
};
const char R_root[] PROGMEM = "/";
const char R_wifi[] PROGMEM = "/wifi";
const char R_wifinoscan[] PROGMEM = "/0wifi";
const char R_wifisave[] PROGMEM = "/wifisave";
const char R_info[] PROGMEM = "/info";
const char R_param[] PROGMEM = "/param";
const char R_paramsave[] PROGMEM = "/paramsave";
const char R_restart[] PROGMEM = "/restart";
const char R_exit[] PROGMEM = "/exit";
const char R_close[] PROGMEM = "/close";
const char R_erase[] PROGMEM = "/erase";
const char R_status[] PROGMEM = "/status";
//Strings
const char S_ip[] PROGMEM = "ip";
const char S_gw[] PROGMEM = "gw";
const char S_sn[] PROGMEM = "sn";
const char S_dns[] PROGMEM = "dns";
// softap ssid default prefix
#ifdef ESP8266
const char S_ssidpre[] PROGMEM = "ESP";
#elif defined(ESP32)
const char S_ssidpre[] PROGMEM = "ESP32";
#else
const char S_ssidpre[] PROGMEM = "WM";
#endif
//Tokens
//@todo consolidate and reduce
const char T_ss[] PROGMEM = "{"; // token start sentinel
const char T_es[] PROGMEM = "}"; // token end sentinel
const char T_1[] PROGMEM = "{1}"; // @token 1
const char T_2[] PROGMEM = "{2}"; // @token 2
const char T_v[] PROGMEM = "{v}"; // @token v
const char T_I[] PROGMEM = "{I}"; // @token I
const char T_i[] PROGMEM = "{i}"; // @token i
const char T_n[] PROGMEM = "{n}"; // @token n
const char T_p[] PROGMEM = "{p}"; // @token p
const char T_t[] PROGMEM = "{t}"; // @token t
const char T_l[] PROGMEM = "{l}"; // @token l
const char T_c[] PROGMEM = "{c}"; // @token c
const char T_e[] PROGMEM = "{e}"; // @token e
const char T_q[] PROGMEM = "{q}"; // @token q
const char T_r[] PROGMEM = "{r}"; // @token r
const char T_R[] PROGMEM = "{R}"; // @token R
const char T_h[] PROGMEM = "{h}"; // @token h
const char Label_ID[] PROGMEM = "{lb}"; // @token lb ///CHANGE MULTIDISPLAY -> new token for label id
// http
const char HTTP_HEAD_CL[] PROGMEM = "Content-Length";
const char HTTP_HEAD_CT[] PROGMEM = "text/html";
const char HTTP_HEAD_CT2[] PROGMEM = "text/plain";
const char HTTP_HEAD_CORS[] PROGMEM = "Access-Control-Allow-Origin";
const char HTTP_HEAD_CORS_ALLOW_ALL[] PROGMEM = "*";
const char * const WIFI_STA_STATUS[] PROGMEM
{
"WL_IDLE_STATUS", // 0 STATION_IDLE
"WL_NO_SSID_AVAIL", // 1 STATION_NO_AP_FOUND
"WL_SCAN_COMPLETED", // 2
"WL_CONNECTED", // 3 STATION_GOT_IP
"WL_CONNECT_FAILED", // 4 STATION_CONNECT_FAIL, STATION_WRONG_PASSWORD(NI)
"WL_CONNECTION_LOST", // 5
"WL_DISCONNECTED", // 6
"WL_STATION_WRONG_PASSWORD" // 7 KLUDGE
};
#ifdef ESP32
const char * const AUTH_MODE_NAMES[] PROGMEM
{
"OPEN",
"WEP",
"WPA_PSK",
"WPA2_PSK",
"WPA_WPA2_PSK",
"WPA2_ENTERPRISE",
"MAX"
};
#elif defined(ESP8266)
const char * const AUTH_MODE_NAMES[] PROGMEM
{
"",
"",
"WPA_PSK", // 2 ENC_TYPE_TKIP
"",
"WPA2_PSK", // 4 ENC_TYPE_CCMP
"WEP", // 5 ENC_TYPE_WEP
"",
"OPEN", //7 ENC_TYPE_NONE
"WPA_WPA2_PSK", // 8 ENC_TYPE_AUTO
};
#endif
const char* const WIFI_MODES[] PROGMEM = { "NULL", "STA", "AP", "STA+AP" };
#ifdef ESP32
// as 2.5.2
// typedef struct {
// char cc[3]; /**< country code string */
// uint8_t schan; /**< start channel */
// uint8_t nchan; /**< total channel number */
// int8_t max_tx_power; /**< This field is used for getting WiFi maximum transmitting power, call esp_wifi_set_max_tx_power to set the maximum transmitting power. */
// wifi_country_policy_t policy; /**< country policy */
// } wifi_country_t;
const wifi_country_t WM_COUNTRY_US{"US",1,11,CONFIG_ESP32_PHY_MAX_TX_POWER,WIFI_COUNTRY_POLICY_AUTO};
const wifi_country_t WM_COUNTRY_CN{"CN",1,13,CONFIG_ESP32_PHY_MAX_TX_POWER,WIFI_COUNTRY_POLICY_AUTO};
const wifi_country_t WM_COUNTRY_JP{"JP",1,14,CONFIG_ESP32_PHY_MAX_TX_POWER,WIFI_COUNTRY_POLICY_AUTO};
#elif defined(ESP8266)
// typedef struct {
// char cc[3]; /**< country code string */
// uint8_t schan; /**< start channel */
// uint8_t nchan; /**< total channel number */
// uint8_t policy; /**< country policy */
// } wifi_country_t;
const wifi_country_t WM_COUNTRY_US{"US",1,11,WIFI_COUNTRY_POLICY_AUTO};
const wifi_country_t WM_COUNTRY_CN{"CN",1,13,WIFI_COUNTRY_POLICY_AUTO};
const wifi_country_t WM_COUNTRY_JP{"JP",1,14,WIFI_COUNTRY_POLICY_AUTO};
#endif
#endif |
CircuitMess/JayD-Library | src/AudioLib/Effects/LowPass.h | #ifndef JAYD_LIBRARY_LOWPASS_H
#define JAYD_LIBRARY_LOWPASS_H
#include <Arduino.h>
#include "../Effect.h"
class LowPass : public Effect{
public:
LowPass();
void applyEffect(int16_t *inBuffer, int16_t *outBuffer, size_t numSamples) override;
void setIntensity(uint8_t intensity) override;
private:
int16_t signalProcessing(int16_t sample);
float filter;
float filter2;
float fAmp;
float fAmpI;
};
#endif //JAYD_LIBRARY_LOWPASS_H
|
CircuitMess/JayD-Library | src/AudioLib/Effect.h | <reponame>CircuitMess/JayD-Library<filename>src/AudioLib/Effect.h
#ifndef JAYD_EFFECT_H
#define JAYD_EFFECT_H
class Effect
{
public:
virtual ~Effect() = default;
virtual void applyEffect(int16_t *inBuffer, int16_t *outBuffer, size_t numSamples) = 0;
virtual void setIntensity(uint8_t intensity) = 0;
};
#endif |
CircuitMess/JayD-Library | src/AudioLib/SpeedModifier.h | <filename>src/AudioLib/SpeedModifier.h<gh_stars>1-10
#ifndef JAYD_LIBRARY_SPEEDMODIFIER_H
#define JAYD_LIBRARY_SPEEDMODIFIER_H
#include "Generator.h"
#include "Source.h"
#include <Buffer/DataBuffer.h>
class SpeedModifier : public Generator {
public:
SpeedModifier(Source* source);
~SpeedModifier();
size_t generate(int16_t* outBuffer) override;
int available() override;
/**
* Set speed multiplier as modifier. Will get mapped from 0-255 to 0.5 - 2.0
* @param modifier
*/
void setModifier(uint8_t modifier);
/**
* Set speed multiplier.
* @param speed
*/
void setSpeed(float speed);
void setSource(Source* source);
private:
Source *source = nullptr;
DataBuffer* dataBuffer = nullptr;
float speed = 1;
float remainder = 0;
void fillBuffer();
};
#endif //JAYD_LIBRARY_SPEEDMODIFIER_H
|
CircuitMess/JayD-Library | src/AudioLib/Converter.h | <filename>src/AudioLib/Converter.h
#ifndef JAYD_CONVERTER_H
#define JAYD_CONVERTER_H
#include "Generator.h"
#include "Source.h"
class Converter : public Generator {
public:
Converter(Source* source);
~Converter();
size_t generate(int16_t* outBuffer) override;
private:
Source* source;
};
#endif |
CircuitMess/JayD-Library | src/AudioLib/SourceAAC.h | #ifndef JAYD_SOURCEAAC_H
#define JAYD_SOURCEAAC_H
#include <Arduino.h>
#include "../AudioSetup.hpp"
#include <FS.h>
#include "Source.h"
#include "../Services/SDScheduler.h"
#include "Decoder/libhelix-aac/aacdec.h"
#include <Buffer/RingBuffer.h>
#include <aacenc_lib.h>
#include <aacdecoder_lib.h>
#include <Buffer/DataBuffer.h>
class SourceAAC : public Source
{
public:
SourceAAC();
SourceAAC(fs::File file);
~SourceAAC();
size_t generate(int16_t* outBuffer) override;
int available() override;
uint16_t getDuration() override;
uint16_t getElapsed() override;
void seek(uint16_t time, fs::SeekMode mode) override;
void open(fs::File file);
void close() override;
void setVolume(uint8_t volume);
void setRepeat(bool repeat);
void setSongDoneCallback(void (*callback)());
private:
fs::File file;
uint32_t bitrate = 0;
size_t dataSize = 0;
size_t movedBytes = 0;
float volume = 1.0f;
RingBuffer readBuffer;
bool readJobPending = false;
DataBuffer fillBuffer;
DataBuffer dataBuffer;
void refill();
HAACDecoder hAACDecoder = nullptr;
struct ADTSHeader {
unsigned char syncword_0_to_8: 8;
unsigned char protection_absent: 1;
unsigned char layer: 2;
unsigned char ID: 1;
unsigned char syncword_9_to_12: 4;
unsigned char channel_configuration_0_bit: 1;
unsigned char private_bit: 1;
unsigned char sampling_frequency_index: 4;
unsigned char profile: 2;
unsigned char frame_length_0_to_1: 2;
unsigned char copyrignt_identification_start: 1;
unsigned char copyright_identification_bit: 1;
unsigned char home: 1;
unsigned char original_or_copy: 1;
unsigned char channel_configuration_1_to_2: 2;
unsigned char frame_length_2_to_9: 8;
unsigned char adts_buffer_fullness_0_to_4: 5;
unsigned char frame_length_10_to_12: 3;
unsigned char number_of_raw_data_blocks_in_frame: 2;
unsigned char adts_buffer_fullness_5_to_10: 6;
};
SDResult* readResult = nullptr;
void addReadJob(bool full = false);
void processReadJob();
void resetDecoding();
bool repeat = false;
void (*songDoneCallback)() = nullptr;
};
#endif |
CircuitMess/JayD-Library | src/AudioLib/OutputAAC.h | #ifndef JAYD_OUTPUTFS_H
#define JAYD_OUTPUTFS_H
#include "Output.h"
#include "../AudioSetup.hpp"
#include <FS.h>
#include <aacenc_lib.h>
#include <Buffer/DataBuffer.h>
#include "../Services/SDScheduler.h"
#define OUTFS_DECODE_BUFSIZE 1024 * NUM_CHANNELS // The output buffer size should be 6144 bits per channel excluding the LFE channel.
#define OUTFS_BUFSIZE 4 * 1024 * NUM_CHANNELS
#define OUTFS_WRITESIZE 1 * 1024 * NUM_CHANNELS // should be smaller than BUFSIZE
#define OUTFS_BUFCOUNT 16
class OutputAAC : public Output
{
public:
OutputAAC();
OutputAAC(const fs::File& file);
~OutputAAC();
void init() override;
void deinit() override;
const fs::File& getFile() const;
void setFile(const fs::File& file);
protected:
void output(size_t numBytes) override;
private:
fs::File file;
AACENC_BufDesc inBufDesc;
AACENC_BufDesc outBufDesc;
HANDLE_AACENCODER encoder;
AACENC_InArgs inArgs;
void setupBuffers();
bool writePending[OUTFS_BUFCOUNT] = { false };
SDResult* writeResult[OUTFS_BUFCOUNT] = { nullptr };
void addWriteJob();
void processWriteJob();
uint8_t* decodeBuffer = nullptr;
DataBuffer* outBuffers[OUTFS_BUFCOUNT] = { nullptr };
std::vector<uint8_t> freeBuffers;
};
#endif |
CircuitMess/JayD-Library | src/AudioLib/Systems/MixSystem.h | #ifndef JAYD_LIBRARY_MIXSYSTEM_H
#define JAYD_LIBRARY_MIXSYSTEM_H
#include <Util/Task.h>
#include "../OutputI2S.h"
#include "../OutputAAC.h"
#include "../OutputSplitter.h"
#include "../SpeedModifier.h"
#include "../EffectProcessor.h"
#include "../Mixer.h"
#include "../SourceWAV.h"
#include "../EffectType.hpp"
#include "../SourceAAC.h"
#include <Sync/Queue.h>
#include "../InfoGenerator.h"
#include "../OutputWAV.h"
struct MixRequest {
enum { ADD_SPEED, REMOVE_SPEED, SET_SPEED, SET_EFFECT, SET_EFFECT_INTENSITY, SET_INFO, SET_SEEK, RECORD } type;
uint8_t channel;
uint8_t slot;
size_t value;
};
class MixSystem {
public:
MixSystem();
MixSystem(const fs::File& f1, const fs::File& f2);
virtual ~MixSystem();
constexpr static const char* const recordPath = "/.Jay-D_Recording.wav";
bool open(uint8_t channel, const fs::File& file);
Task audioTask;
static void audioThread(Task* task);
void start();
void stop();
bool isRunning();
uint16_t getDuration(uint8_t channel);
uint16_t getElapsed(uint8_t channel);
void setVolume(uint8_t channel, uint8_t volume);
void setMix(uint8_t ratio);
void addSpeed(uint8_t channel);
void removeSpeed(uint8_t channel);
void setSpeed(uint8_t channel, uint8_t speed);
void setEffect(uint8_t channel, uint8_t slot, EffectType type);
void setEffectIntensity(uint8_t channel, uint8_t slot, uint8_t intensity);
void setOutInfo(InfoGenerator* outInfoGen);
void setChannelInfo(uint8_t channel, InfoGenerator* channelInfoGen);
void pauseChannel(uint8_t channel);
void resumeChannel(uint8_t channel);
bool isChannelPaused(uint8_t channel);
void seekChannel(uint8_t channel, uint16_t time);
void startRecording();
void stopRecording();
bool isRecording();
void setChannelDoneCallback(uint8_t channel, void(*callback)());
private:
bool running = false;
Queue queue;
fs::File file[2];
fs::File fileOut;
SourceAAC* source[2] = { nullptr };
EffectProcessor* effector[2];
Mixer* mixer;
OutputI2S* i2s;
OutputWAV* fsOut;
OutputSplitter* out;
SpeedModifier* speed[2] = { nullptr };
void _addSpeed(uint8_t channel);
void _removeSpeed(uint8_t channel);
void _setSpeed(uint8_t channel, uint8_t speed);
void _setEffect(uint8_t channel, uint8_t slot, EffectType type);
void _setEffectIntensity(uint8_t channel, uint8_t slot, uint8_t intensity);
void _setInfoGenerator(uint8_t channel, InfoGenerator* generator);
void _seekChannel(uint8_t channel, uint16_t time);
void _startRecording();
void _stopRecording();
static Effect* (* getEffect[EffectType::COUNT])();
uint16_t seek[2];
int seekPending[2] = { 0 };
};
#endif //JAYD_LIBRARY_MIXSYSTEM_H
|
CircuitMess/JayD-Library | src/AudioLib/InfoGenerator.h | <gh_stars>1-10
#ifndef JAYD_LIBRARY_INFOGENERATOR_H
#define JAYD_LIBRARY_INFOGENERATOR_H
#include "Generator.h"
class InfoGenerator : public Generator {
public:
size_t generate(int16_t *outBuffer) override;
int available() override;
void setSource(Generator* gen);
protected:
virtual void captureInfo(int16_t *outBuffer, size_t readBytes) = 0;
private:
Generator* generator;
};
#endif //JAYD_LIBRARY_INFOGENERATOR_H
|
CircuitMess/JayD-Library | src/Matrix/MatrixPartition.h | <filename>src/Matrix/MatrixPartition.h
#ifndef JAYD_LIBRARY_MATRIXPARTITION_H
#define JAYD_LIBRARY_MATRIXPARTITION_H
#include <Arduino.h>
#include <Devices/LEDmatrix/LEDmatrix.h>
class MatrixPartition : public LoopListener {
public:
MatrixPartition(LEDmatrixImpl* matrix, uint8_t width, uint8_t height);
virtual void vu(uint16_t amp);
void drawPixel(int x, int y, uint8_t brightness);
void clear(bool on = false);
void startAnimation(Animation* _animation, bool loop);
void stopAnimation();
float getAnimationCompletionRate();
void loop(uint _time) override;
void drawBitmap(int x, int y, uint width, uint height, uint8_t* data);
virtual void push() = 0;
protected:
LEDmatrixImpl* matrix;
uint8_t width;
uint8_t height;
uint8_t* buffer;
AnimationFrame* animationFrame = nullptr;
Animation* animation = nullptr;
bool animationLoop = 0;
uint currentFrameTime = 0;
uint animationStartMicros = 0;
};
#endif //JAYD_LIBRARY_MATRIXPARTITION_H
|
CircuitMess/JayD-Library | src/AudioLib/Effects/BitCrusher.h | #ifndef JAYD_LIBRARY_BITCRUSHER_H
#define JAYD_LIBRARY_BITCRUSHER_H
#include <Arduino.h>
#include "../Effect.h"
class BitCrusher : public Effect {
public:
BitCrusher();
void applyEffect(int16_t *inBuffer, int16_t *outBuffer, size_t numSamples) override;
void setIntensity(uint8_t intensity) override;
private:
int16_t signalProcessing(int16_t sample);
uint16_t scaleFactor = 1;
};
#endif //JAYD_LIBRARY_BITCRUSHER_H
|
CircuitMess/JayD-Library | src/Matrix/MatrixBig.h | <gh_stars>1-10
#ifndef JAYD_LIBRARY_MATRIXBIG_H
#define JAYD_LIBRARY_MATRIXBIG_H
#include "MatrixPartition.h"
class MatrixBig : public MatrixPartition {
public:
MatrixBig(LEDmatrixImpl* matrix);
void push() override;
};
#endif //JAYD_LIBRARY_MATRIXBIG_H
|
CircuitMess/JayD-Library | src/AudioLib/Effects/Reverb.h | <reponame>CircuitMess/JayD-Library<gh_stars>1-10
#ifndef JAYD_LIBRARY_REVERB_H
#define JAYD_LIBRARY_REVERB_H
#include <Arduino.h>
#include "../Effect.h"
class Reverb : public Effect{
public:
Reverb();
~Reverb() override;
void applyEffect(int16_t *inBuffer, int16_t *outBuffer, size_t numSamples) override;
void setIntensity(uint8_t intensity);
private:
static const uint32_t length = 25000;
int16_t signalProcessing(int16_t sample);
int16_t* echo = nullptr;
uint16_t echoCount = 0;
float echoAmount = 0;
float horizontalScale = 1.0f/16.0f;
float verticalScale = 18.0f/16.0f;
};
#endif //JAYD_LIBRARY_REVERB_H
|
CircuitMess/JayD-Library | src/PerfMon.h | <reponame>CircuitMess/JayD-Library
#ifndef JAYD_LIBRARY_PERFMON_H
#define JAYD_LIBRARY_PERFMON_H
#include <Arduino.h>
#include <vector>
#include <Sync/Mutex.h>
struct PerfMonReport {
String name;
uint32_t duration;
};
class PerfMon {
public:
void init();
void start(String name);
void end();
void report();
private:
String current;
uint32_t initTime = 0;
uint32_t startTime = 0;
Mutex mutex;
std::vector<PerfMonReport> reports;
};
extern PerfMon Profiler;
#endif //JAYD_LIBRARY_PERFMON_H
|
CircuitMess/JayD-Library | src/AudioLib/Mixer.h | <filename>src/AudioLib/Mixer.h
#ifndef JAYD_MIXER_H
#define JAYD_MIXER_H
#include <Arduino.h>
#include <vector>
#include "Generator.h"
#include "Source.h"
class Mixer : public Generator
{
public:
Mixer();
~Mixer();
size_t generate(int16_t* outBuffer) override;
int available() override;
Generator* getSource(size_t index);
void setSource(size_t index, Generator* source);
void addSource(Generator* source);
uint8_t getMixRatio();
void setMixRatio(uint8_t ratio);
void pauseChannel(uint8_t channel);
void resumeChannel(uint8_t channel);
bool isChannelPaused(uint8_t channel);
private:
std::vector<Generator*> sourceList;
std::vector<int16_t*> bufferList;
uint8_t mixRatio = 122; //half-half by default, 0 = only first track, 255 = only second track
std::vector<bool> pauseList;
};
#endif |
CircuitMess/JayD-Library | src/AudioLib/Output.h | #ifndef JAYD_OUTPUT_H
#define JAYD_OUTPUT_H
#include <Arduino.h>
#include <Loop/LoopListener.h>
class OutputSplitter;
class Generator;
class Output : public LoopListener
{
friend OutputSplitter;
public:
Output(bool timed = false);
~Output();
void setSource(Generator* gen);
void loop(uint _time) override;
void stop();
void start();
void setGain(float gain);
float getGain();
bool isRunning();
protected:
virtual void output(size_t numSamples) = 0;
int16_t *inBuffer = nullptr;
Generator* generator;
virtual void init() = 0;
virtual void deinit() = 0;
private:
float gain = 1.0; //0 - 1.0
uint32_t lastSample = 0;
size_t receivedSamples = 0;
bool timed = false;
bool running = false;
};
#endif |
CircuitMess/JayD-Library | src/Matrix/MatrixManager.h | #ifndef JAYD_LIBRARY_MATRIXMANAGER_H
#define JAYD_LIBRARY_MATRIXMANAGER_H
#include <Arduino.h>
#include "MatrixBig.h"
#include "MatrixL.h"
#include "MatrixR.h"
#include "MatrixMid.h"
class MatrixManager : public LoopListener {
public:
MatrixManager(LEDmatrixImpl* ledmatrix);
MatrixBig matrixBig;
MatrixL matrixL;
MatrixR matrixR;
MatrixMid matrixMid;
void loop(uint time);
void push();
void stopAnimation();
void clear(bool on = false);
void startRandom();
void stopRandom();
private:
LEDmatrixImpl* ledmatrix;
static const uint8_t idleAnims = 20;
bool playingRandom = false;
std::vector<uint> usedIdleAnimations;
std::vector<uint> unusedIdleAnimations;
void playRandom();
static const char* PartitionNames[4];
MatrixPartition* partitions[4];
};
#endif //JAYD_LIBRARY_MATRIXMANAGER_H
|
CircuitMess/JayD-Library | src/Matrix/MatrixMid.h | #ifndef JAYD_LIBRARY_MATRIXMID_H
#define JAYD_LIBRARY_MATRIXMID_H
#include "MatrixPartition.h"
class MatrixMid : public MatrixPartition {
public:
MatrixMid(LEDmatrixImpl* matrix);
void push() override;
void vu(uint16_t value) override;
};
#endif //JAYD_LIBRARY_MATRIXMID_H
|
CircuitMess/JayD-Library | src/Matrix/Visualizer.h | <gh_stars>1-10
#ifndef JAYD_LIBRARY_VISUALIZER_H
#define JAYD_LIBRARY_VISUALIZER_H
#include "MatrixPartition.h"
#include "../AudioLib/InfoGenerator.h"
class Visualizer {
public:
Visualizer(MatrixPartition *matrix);
virtual InfoGenerator *getInfoGenerator() = 0;
protected:
MatrixPartition *matrix;
};
#endif //JAYD_LIBRARY_VISUALIZER_H
|
CircuitMess/JayD-Library | src/AudioLib/VuInfoGenerator.h | #ifndef JAYD_LIBRARY_VUINFOGENERATOR_H
#define JAYD_LIBRARY_VUINFOGENERATOR_H
#include "InfoGenerator.h"
class VuInfoGenerator : public InfoGenerator{
public:
uint16_t getVu();
protected:
void captureInfo(int16_t *outBuffer, size_t readSamples) override;
private:
uint16_t vu = 0;
};
#endif //JAYD_LIBRARY_VUINFOGENERATOR_H
|
CircuitMess/JayD-Library | src/Matrix/RoundVuVisualiser.h | #ifndef JAYD_LIBRARY_ROUNDVUVISUALISER_H
#define JAYD_LIBRARY_ROUNDVUVISUALISER_H
#include "Visualizer.h"
#include "../AudioLib/VuInfoGenerator.h"
class RoundVuVisualiser: public Visualizer, public LoopListener{
public:
RoundVuVisualiser(MatrixPartition *matrix);
InfoGenerator *getInfoGenerator() override;
void loop(uint _millis) override;
private:
VuInfoGenerator info;
void drawSquare(uint8_t width, uint8_t value);
};
#endif //JAYD_LIBRARY_ROUNDVUVISUALISER_H
|
CircuitMess/JayD-Library | src/AudioLib/Source.h | <reponame>CircuitMess/JayD-Library<filename>src/AudioLib/Source.h<gh_stars>1-10
#ifndef JAYD_SOURCE_H
#define JAYD_SOURCE_H
#include "Generator.h"
#include <FS.h>
class Source : public Generator
{
public:
virtual int getBytesPerSample();
virtual int getSampleRate();
virtual int getChannels();
virtual uint16_t getDuration() = 0;
virtual uint16_t getElapsed() = 0;
virtual void seek(uint16_t time, fs::SeekMode mode) = 0;
virtual void close() = 0;
protected:
uint8_t channels = 0;
uint32_t sampleRate = 0;
uint8_t bytesPerSample = 0;
};
#endif |
CircuitMess/JayD-Library | src/AudioLib/OutputI2S.h | #ifndef JAYD_OUTPUTI2S_H
#define JAYD_OUTPUTI2S_H
#include "Output.h"
#include <driver/i2s.h>
class OutputI2S : public Output
{
public:
OutputI2S(i2s_config_t config, i2s_pin_config_t pins, i2s_port_t port = I2S_NUM_0);
~OutputI2S();
void init() override;
void deinit() override;
protected:
void output(size_t numBytes) override;
private:
i2s_config_t config;
i2s_pin_config_t pins;
i2s_port_t port;
};
#endif |
CircuitMess/JayD-Library | src/AudioLib/OutputSplitter.h | #ifndef JAYD_LIBRARY_OUTPUTSPLITTER_H
#define JAYD_LIBRARY_OUTPUTSPLITTER_H
#include <vector>
#include "Output.h"
class OutputSplitter : public Output {
public:
OutputSplitter();
virtual ~OutputSplitter();
void addOutput(Output* output);
void setOutput(size_t i, Output* output);
Output* getOutput(size_t i);
void removeOutput(size_t i);
protected:
void output(size_t numSamples) override;
void init() override;
void deinit() override;
private:
std::vector<Output*> outputs;
void checkTimed();
};
#endif //JAYD_LIBRARY_OUTPUTSPLITTER_H
|
CircuitMess/JayD-Library | src/AudioLib/Effects/HighPass.h | <filename>src/AudioLib/Effects/HighPass.h
#ifndef JAYD_LIBRARY_HIGHPASS_H
#define JAYD_LIBRARY_HIGHPASS_H
#include <Arduino.h>
#include "../Effect.h"
class HighPass: public Effect {
public:
HighPass();
void applyEffect(int16_t *inBuffer, int16_t *outBuffer, size_t numSamples) override;
void setIntensity(uint8_t intensity) override;
private:
int16_t signalProcessing(int16_t sample);
float filter;
float filter2;
float fAmp;
float fAmpI;
};
#endif //JAYD_LIBRARY_HIGHPASS_H
|
CircuitMess/JayD-Library | src/AudioLib/Decoder/ID3Parser.h | #ifndef JAYD_ID3PARSER_H
#define JAYD_ID3PARSER_H
#include <Arduino.h>
#include <FS.h>
struct ID3Metadata {
ID3Metadata(){}
size_t headerSize = 0;
char* title = nullptr;
char* album = nullptr;
char* artist = nullptr;
};
class ID3Parser {
public:
ID3Parser(fs::File& file);
ID3Metadata parse();
private:
fs::File file;
bool unsync;
bool extendedHeader;
bool experimental;
uint8_t* data;
size_t dataPtr = 0;
size_t size; // without header
template<typename T>
static void swendian(T* data){
size_t swapped = 0;
for(int i = 0; i < sizeof(T); i++){
swapped = (swapped << 8) | ((uint8_t*) data)[i];
}
memcpy(data, &swapped, sizeof(T));
}
template<typename T>
static void sync(T* data){
uint32_t mask = 0x7F;
uint32_t value = *data & mask;
mask = mask << 8;
for(int i = 1; i < sizeof(T); i++){
value |= (value & mask) >> i;
}
*data = value;
}
};
#endif //JAYD_ID3PARSER_H
|
CircuitMess/JayD-Library | src/AudioLib/SourceMP3.h | #ifndef JAYD_SOURCEMP3_H
#define JAYD_SOURCEMP3_H
#include <Arduino.h>
#include "../AudioSetup.hpp"
#include <FS.h>
#include "Source.h"
#include "../Services/SDScheduler.h"
#include "Decoder/libhelix-mp3/mp3dec.h"
#include "Decoder/ID3Parser.h"
#include "SourceMP3.h"
#include <Buffer/RingBuffer.h>
#include <Buffer/DataBuffer.h>
class SourceMP3 : public Source
{
public:
SourceMP3();
SourceMP3(fs::File file);
~SourceMP3();
size_t generate(int16_t* outBuffer) override;
int available() override;
uint16_t getDuration() override;
uint16_t getElapsed() override;
void seek(uint16_t time, fs::SeekMode mode) override;
void open(fs::File file);
void close() override;
void setVolume(uint8_t volume);
const ID3Metadata& getMetadata() const;
private:
fs::File file;
uint32_t bitrate = 0;
size_t dataSize = 0;
size_t readData = 0;
float volume = 1.0f;
RingBuffer readBuffer;
bool readJobPending = false;
DataBuffer fillBuffer;
DataBuffer dataBuffer;
HMP3Decoder decoder = nullptr;
ID3Metadata metadata;
SDResult* readResult = nullptr;
void addReadJob(bool full = false);
void processReadJob();
};
#endif |
CircuitMess/JayD-Library | src/AudioLib/SourceWAV.h | <filename>src/AudioLib/SourceWAV.h
#ifndef JAYD_SOURCEWAV_H
#define JAYD_SOURCEWAV_H
#include <Arduino.h>
#include "../AudioSetup.hpp"
#include <FS.h>
#include "Source.h"
#include "../Services/SDScheduler.h"
#include <Buffer/RingBuffer.h>
class SourceWAV : public Source
{
public:
SourceWAV();
SourceWAV(fs::File file);
~SourceWAV();
size_t generate(int16_t* outBuffer) override;
int available() override;
uint16_t getDuration() override;
uint16_t getElapsed() override;
void seek(uint16_t time, fs::SeekMode mode) override;
void open(fs::File file);
void close() override;
void setVolume(uint8_t volume);
private:
fs::File file;
size_t dataSize;
size_t readData = 0;
bool readHeader();
float volume = 1.0f;
RingBuffer readBuffer;
bool readJobPending = false;
static const size_t readChunkSize = BUFFER_SIZE * 4;
SDResult* readResult = nullptr;
void addReadJob(bool full = false);
void processReadJob();
};
#endif |
CircuitMess/JayD-Library | src/Matrix/VuVisualizer.h | <reponame>CircuitMess/JayD-Library
#ifndef JAYD_LIBRARY_VUVISUALIZER_H
#define JAYD_LIBRARY_VUVISUALIZER_H
#include "Visualizer.h"
#include "../AudioLib/VuInfoGenerator.h"
class VuVisualizer : public Visualizer, public LoopListener {
public:
VuVisualizer(MatrixPartition *matrix);
InfoGenerator *getInfoGenerator() override;
void loop(uint _millis) override;
private:
VuInfoGenerator info;
};
#endif //JAYD_LIBRARY_VUVISUALIZER_H
|
CircuitMess/JayD-Library | src/Input/InputJayD.h | <filename>src/Input/InputJayD.h
#ifndef JAYD_INPUTJAYD_H
#define JAYD_INPUTJAYD_H
#include <Loop/LoopListener.h>
#include <Util/Vector.h>
#include <sys/param.h>
#include <vector>
#include <Util/Vector.h>
#define BYTE_IDENTIFY 0x0
#define JDNV_ADDR 0x43
#define BYTE_NUMEVENTS 0x12
#define BYTE_GETEVENTS 0x13
#define BYTE_GETPOTVALUE 0x14
#define NUM_BTN 9
#define NUM_ENC 7
#define NUM_POT 3
#define JDNV_PIN_RESET 13
enum DeviceType {
BTN, ENC, POT
};
struct InputEvent {
DeviceType deviceType;
uint8_t deviceID;
int8_t value;
};
class InputJayD;
class JayDInputListener {
friend InputJayD;
private:
virtual void buttonPress(uint8_t id);
virtual void buttonRelease(uint8_t id);
virtual void buttonHold(uint8_t id);
virtual void encoderMove(uint8_t id, int8_t value);
virtual void potMove(uint8_t id, uint8_t value);
};
class InputJayD : public LoopListener {
public:
InputJayD();
virtual void setBtnPressCallback(uint8_t id, void(*callback)());
virtual void setBtnReleaseCallback(uint8_t id, void (*callback)());
virtual void removeBtnPressCallback(uint8_t id);
virtual void removeBtnReleaseCallback(uint8_t id);
virtual void setBtnHeldCallback(uint8_t id, uint32_t holdTime, void (*callback)());
virtual void removeBtnHeldCallback(uint8_t id);
virtual void setEncoderMovedCallback(uint8_t id, void (*callback)(int8_t value));
virtual void removeEncoderMovedCallback(uint8_t id);
virtual void setPotMovedCallback(uint8_t id, void (*callback)(uint8_t value));
virtual void removePotMovedCallback(uint8_t id);
uint8_t getPotValue(uint8_t potID);
static InputJayD *getInstance();
void reset();
bool begin();
bool identify();
void addListener(JayDInputListener* listener);
void removeListener(JayDInputListener* listener);
void loop(uint _time) override;
void setHoldTime(uint32_t holdTime);
private:
std::vector<void (*)()> btnPressCallbacks;
std::vector<void (*)()> btnReleaseCallbacks;
std::vector<void (*)()> btnHoldCallbacks;
std::vector<void (*)(int8_t)> encMovedCallbacks;
std::vector<void (*)(uint8_t)> potMovedCallbacks;
std::vector <uint32_t> btnHoldValue;
std::vector <uint32_t> btnHoldStart;
std::vector<bool> wasPressed;
Vector<JayDInputListener*> listeners;
static InputJayD *instance;
uint8_t getNumEvents();
void fetchEvents(int numEvents);
void handleButtonEvent(uint8_t id, uint8_t value);
void handleEncoderEvent(uint8_t id, int8_t value);
void handlePotentiometerEvent(uint8_t id, uint8_t value);
void buttonHoldCheck();
uint32_t currentTime = 0;
uint32_t encoderTime = 0;
int8_t tempEncValue[7] = {0};
uint32_t holdTime = 0;
bool inited = false;
};
#endif //JAYD_LIBRARY_INPUTJAYD_H
|
CircuitMess/JayD-Library | src/AudioLib/Generator.h | #ifndef JAYD_GENERATOR_H
#define JAYD_GENERATOR_H
#include <Arduino.h>
class Generator
{
public:
virtual ~Generator() = default;
/**
* @brief Generates samples and copies them to the supplied buffer
*
* @param outBuffer Specified buffer for the generated samples.
* @return size_t Number of samples generated.
*/
virtual size_t generate(int16_t *outBuffer) = 0;
virtual int available() = 0;
};
#endif |
CircuitMess/JayD-Library | src/Matrix/MatrixL.h | <reponame>CircuitMess/JayD-Library
#ifndef JAYD_LIBRARY_MATRIXL_H
#define JAYD_LIBRARY_MATRIXL_H
#include "MatrixPartition.h"
class MatrixL : public MatrixPartition {
public:
MatrixL(LEDmatrixImpl* matrix);
void push() override;
};
#endif //JAYD_LIBRARY_MATRIXL_H
|
CircuitMess/JayD-Library | src/AudioLib/OutputWAV.h | #ifndef JAYD_OUTPUTWAV_H
#define JAYD_OUTPUTWAV_H
#include "Output.h"
#include "../AudioSetup.hpp"
#include <FS.h>
#include <aacenc_lib.h>
#include <Buffer/DataBuffer.h>
#include "../Services/SDScheduler.h"
#define OUTWAV_BUFSIZE 2 * 1024 * NUM_CHANNELS
#define OUTWAV_WRITESIZE 1 * 1024 * NUM_CHANNELS // should be smaller than BUFSIZE
#define OUTWAV_BUFCOUNT 16
class OutputWAV : public Output
{
public:
OutputWAV();
OutputWAV(const fs::File& file);
~OutputWAV();
void init() override;
void deinit() override;
const fs::File& getFile() const;
void setFile(const fs::File& file);
protected:
void output(size_t numBytes) override;
private:
const char* path;
fs::File file;
size_t dataLength;
void writeHeaderWAV(size_t size);
bool writePending[OUTWAV_BUFCOUNT] = { false };
SDResult* writeResult[OUTWAV_BUFCOUNT] = { nullptr };
void addWriteJob();
void processWriteJob();
DataBuffer* outBuffers[OUTWAV_BUFCOUNT] = { nullptr };
std::vector<uint8_t> freeBuffers;
};
#endif |
CircuitMess/JayD-Library | src/AudioLib/EffectProcessor.h | #ifndef JAYD_EFFECTPROCESSOR_H
#define JAYD_EFFECTPROCESSOR_H
#include <Arduino.h>
#include "Generator.h"
#include "Effect.h"
#include <vector>
class EffectProcessor : public Generator
{
public:
EffectProcessor(Generator* generator);
~EffectProcessor();
size_t generate(int16_t* outBuffer) override;
int available() override;
void addEffect(Effect* effect);
void removeEffect(int index);
Effect* getEffect(int index);
void setEffect(int index, Effect* effect);
void setSource(Generator* inputGenerator);
private:
std::vector<Effect*> effectList;
int16_t *effectBuffer = nullptr;
Generator* inputGenerator;
};
#endif |
CircuitMess/JayD-Library | src/Matrix/MatrixR.h | #ifndef JAYD_LIBRARY_MATRIXR_H
#define JAYD_LIBRARY_MATRIXR_H
#include "MatrixPartition.h"
class MatrixR : public MatrixPartition {
public:
MatrixR(LEDmatrixImpl* matrix);
void push() override;
};
#endif //JAYD_LIBRARY_MATRIXR_H
|
CircuitMess/JayD-Library | src/Settings.h | <reponame>CircuitMess/JayD-Library<gh_stars>1-10
#ifndef JAYD_LIBRARY_SETTINGS_H
#define JAYD_LIBRARY_SETTINGS_H
#include <Arduino.h>
struct SettingsData {
uint8_t brightnessLevel = 150; //medium brightness
uint8_t volumeLevel = 100; //medium volume
bool inputTested = false;
bool hwTested = false;
};
class SettingsImpl {
public:
bool begin();
void store();
SettingsData& get();
/**
* Resets the data (to zeroes). Doesn't store.
*/
void reset();
uint getVersion(){
return 1;
}
private:
SettingsData data;
};
extern SettingsImpl Settings;
#endif //JAYD_LIBRARY_SETTINGS_H
|
CircuitMess/JayD-Library | src/JayD.h | #ifndef JAYD_H
#define JAYD_H
#define PIN_BL 25
#define SD_CS 22
#define ENC_MID 0
#define ENC_L1 1
#define ENC_L2 6
#define ENC_L3 5
#define ENC_R1 4
#define ENC_R2 3
#define ENC_R3 2
#define POT_L 1
#define POT_MID 0
#define POT_R 2
#define BTN_L 0
#define BTN_R 1
#define BTN_MID 2
#define BTN_L1 3
#define BTN_L2 8
#define BTN_L3 7
#define BTN_R1 6
#define BTN_R2 5
#define BTN_R3 4
#define I2S_WS 4
#define I2S_DO 14
#define I2S_BCK 21
#define I2S_DI -1
#define I2C_SDA 26
#define I2C_SCL 27
#define SPI_SCK 18
#define SPI_MISO 19
#define SPI_MOSI 23
#define SPI_SS -1
#include <Arduino.h>
#include <CircuitOS.h>
#include <Loop/LoopManager.h>
#include <Display/Display.h>
#include <Devices/LEDmatrix/LEDmatrix.h>
#include <Devices/LEDmatrix/Animation.h>
#include "Matrix/MatrixManager.h"
#include <driver/i2s.h>
#include <SPIFFS.h>
#include <WiFi.h>
#include <SPI.h>
#include <SD.h>
#include "Settings.h"
#include "Services/SDScheduler.h"
#include "Input/InputJayD.h"
#include "AudioLib/Systems/MixSystem.h"
#include "AudioLib/Systems/PlaybackSystem.h"
extern const i2s_pin_config_t i2s_pin_config;
extern LEDmatrixImpl LEDmatrix;
extern MatrixManager matrixManager;
class JayDImpl {
public:
JayDImpl();
void begin();
Display& getDisplay();
private:
Display display;
};
extern JayDImpl JayD;
#endif |
CircuitMess/JayD-Library | src/AudioLib/Systems/PlaybackSystem.h | #ifndef JAYD_LIBRARY_PLAYBACKSYSTEM_H
#define JAYD_LIBRARY_PLAYBACKSYSTEM_H
#include <Util/Task.h>
#include "../OutputI2S.h"
#include "../SpeedModifier.h"
#include "../EffectProcessor.h"
#include "../Mixer.h"
#include "../SourceWAV.h"
#include "../EffectType.hpp"
#include "../SourceAAC.h"
#include <Sync/Queue.h>
struct PlaybackRequest {
enum { SEEK } type;
size_t value;
};
class PlaybackSystem {
public:
PlaybackSystem();
PlaybackSystem(const fs::File& f);
virtual ~PlaybackSystem();
bool open(const fs::File& file);
Task audioTask;
static void audioThread(Task* task);
void start();
void stop();
bool isRunning();
uint16_t getDuration();
uint16_t getElapsed();
void setVolume(uint8_t volume);
void seek(uint16_t time);
void setRepeat(bool repeat = true);
void updateGain();
private:
bool running = false;
bool repeat = false;
Queue queue;
fs::File file;
SourceAAC* source = nullptr;
OutputI2S* out;
void _seek(uint16_t time);
};
#endif //JAYD_LIBRARY_PLAYBACKSYSTEM_H
|
CircuitMess/JayD-Library | src/Services/SDScheduler.h | <filename>src/Services/SDScheduler.h
#ifndef JAYD_LIBRARY_SDSCHEDULER_H
#define JAYD_LIBRARY_SDSCHEDULER_H
#include <FS.h>
#include <vector>
#include <Loop/LoopListener.h>
#include <Sync/Queue.h>
struct SDResult {
uint8_t error;
size_t size;
uint8_t* buffer;
};
struct SDJob {
enum { SD_WRITE, SD_READ, SD_SEEK } type;
fs::File file;
size_t size;
uint8_t* buffer;
SDResult** result;
};
class SDScheduler : public LoopListener {
public:
SDScheduler();
void addJob(SDJob *job);
void loop(uint micros) override;
private:
Queue jobs;
void doJob(SDJob* job);
};
extern SDScheduler Sched;
#endif //JAYD_LIBRARY_SDSCHEDULER_H
|
fengjixuchui/C3 | Src/Common/FSecure/Slack/SlackApi.h | <gh_stars>0
#pragma once
#include "Common/json/json.hpp"
#include "Common/CppRestSdk/include/cpprest/http_client.h"
using json = nlohmann::json; //for easy parsing of json API: https://github.com/nlohmann/json
namespace FSecure
{
class Slack
{
public:
/// Constructor for the Slack Api class.
/// @param token - the token generated by Slack when an "app" was installed to a workspace
/// @param proxyString - the proxy to use
Slack(std::string const& token, std::string const& channelName);
/// Default constructor.
Slack() = default;
/// Write a message to the channel this Slack object is set to.
/// @param text - the text of the message
/// @return - a timestamp of the message that was written to the channel.
std::string WriteMessage(std::string const& text);
/// Set the channel that this object uses for communications
/// @param channel - the channelId (not name), for example CGPMGFGSH.
void SetChannel(std::string const& channelId);
/// set the token for this object.
/// @param token - the textual api token.
void SetToken(std::string const& token);
/// Creates a channel on slack, if the channel exists already, will call ListChannels internally to get the channelId.
/// @param channelName - the actual name of the channel, such as "general".
/// @return - the channelId of the new or already existing channel.
std::string CreateChannel(std::string const& channelName);
/// Read the replies to a message
/// @param timestamp - the timestamp of the original message, from which we can gather the replies.
/// @return - an array of pairs containing the reply timestamp and reply text
std::vector<std::pair<std::string, std::string>> ReadReplies(std::string const& timestamp);
/// List all the channels in the workspace the object's token is tied to.
/// @return - a map of {channelName -> channelId}
std::map<std::string, std::string> ListChannels();
/// Get all of the messages by a direction. This is a C3 specific method, used by a server relay to get client messages and vice versa.
/// @param direction - the direction to search for (eg. "S2C").
/// @return - a vector of timestamps, where timestamp allows replies to be read later
std::vector<std::string> GetMessagesByDirection(std::string const& direction);
/// Edit a previously sent message.
/// @param message - the message to update to, this will overwrite the previous message.
/// @param timestamp - the timestamp of the message to update.
void UpdateMessage(std::string const& message, std::string const& timestamp);
/// Create a thread on a message by writing a reply to it.
/// @param text - the text to send as a reply.
/// @param timestamp - the timestamp of the message that the reply is for.
void WriteReply(std::string const& text, std::string const& timestamp);
/// Use Slack's file API to upload data as files. This is useful when a payload is large (for example during implant staging).
/// This function is called internally whenever a WriteReply is called with a payload of more than 120k characters.
/// @param data - the data to be sent.
/// @param ts - the timestamp, needed as this method is only used during WriteReply.
void UploadFile(std::string const& data, std::string const& ts);
/// Delete a message from the channel
/// @param timestamp - the timestamp of the message to delete.
void DeleteMessage(std::string const& timestamp);
private:
/// The channel through which messages are sent and received, will be sent when the object is created.
std::string m_Channel;
/// The Slack API token that allows the object access to the workspace. Needs to be manually created as described in documentation.
std::string m_Token;
/// Hold proxy settings
web::http::client::http_client_config m_HttpConfig;
/// Send http request, uses preset token for authentication
std::string SendHttpRequest(std::string const& host, std::string const& contentType, std::string const& data);
/// Send http request with json data, uses preset token for authentication
json SendJsonRequest(std::string const& url, json const& data);
/// Use Slack's File API to retrieve files.
/// @param url - the url where the file can be retrieved.
/// @return - the data within the file.
std::string GetFile(std::string const& url);
};
}
|
SamChenzx/SETravel | Example/SETravel/SEViewController.h | <reponame>SamChenzx/SETravel
//
// SEViewController.h
// SETravel
//
// Created by chenzhixiang on 08/07/2021.
// Copyright (c) 2021 chenzhixiang. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface SEViewController : UIViewController
@end
|
SamChenzx/SETravel | SETravel/Classes/KSCoverageInfoView.h | //
// KSCoverageInfoView.h
// gifDebugHelperModule
//
// Created by <NAME> on 2021/10/15.
//
#if KSIsDebugging && KSCOVERAGE
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSInteger, KSCoverageCaseType) {
KSCoverageCaseTypeQAManual,
KSCoverageCaseTypeRDManual,
KSCoverageCaseTypeUIAutomation,
};
typedef NSString *KSCoverageInfoKey NS_EXTENSIBLE_STRING_ENUM;
FOUNDATION_EXTERN KSCoverageInfoKey const KSCoverageUserInfo;
FOUNDATION_EXTERN KSCoverageInfoKey const KSCoverageCaseInfo;
FOUNDATION_EXTERN KSCoverageInfoKey const KSCoverageTypeInfo;
@interface KSCoverageInfoView : UIView
@property (nonatomic, copy) void(^didCancelBlock)(void);
@property (nonatomic, copy) void(^didConfirmBlock)(NSDictionary * caseInfoDic, BOOL shouldReset);
@end
NS_ASSUME_NONNULL_END
#endif
|
SamChenzx/SETravel | Example/Pods/Headers/Public/SETravel/gifTestResourceCDNFetcher.h | <gh_stars>0
//
// gifTestResourceCDNFetcher.h
// gifTestTools
//
// Created by <NAME> on 2021/8/26.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
typedef void(^fetchCompletionBlock)(NSString * _Nullable path, NSError * _Nullable error);
@interface gifTestResourceCDNFetcher : NSObject
+ (void)fetchResourceWithURLStrings:(NSArray<NSString *> *)URLStrings completionBlock:(fetchCompletionBlock)completionBlock;
+ (NSString *)syncFetchResourceWithURLStrings:(NSArray<NSString *> *)URLStrings;
@end
NS_ASSUME_NONNULL_END
|
SamChenzx/SETravel | SETravel/Classes/KSCoverageManager.h | //
// KSCoverageManager.h
// gifDebugHelperModule
//
// Created by <NAME> on 2021/10/20.
//
#if KSIsDebugging && KSCOVERAGE
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface KSCoverageManager : NSObject
+ (instancetype)sharedManager;
- (void)uploadFilesWithInfo:(NSDictionary *)infoDic shouldReset:(BOOL)shouldReset;
@end
NS_ASSUME_NONNULL_END
#endif
|
SamChenzx/SETravel | Example/SETravel/SEAppDelegate.h | //
// SEAppDelegate.h
// SETravel
//
// Created by chenzhixiang on 08/07/2021.
// Copyright (c) 2021 chenzhixiang. All rights reserved.
//
@import UIKit;
@interface SEAppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
|
afking/xl320 | motors.h | /* Dynamixel Communication 2.0 */
/* Implements the dynamixel communication protocol for XL-320. */
#ifndef MOTORS_H
#define MOTORS_H
#include "mbed.h"
class DM2 {
public:
// Create Dynamixel Communication protocol 2.0
DM2(PinName tx, PinName rx, int baud=1000000);
int Level;
int Test(int ID=1);
int Ping(int ID=1);
int SetID(int ID, int newID);
int SetBaud(int ID, int rate);
int SetReturnLevel(int ID, int lvl);
int SetLED(int ID, int colour);
int Rainbow(int ID);
int SetP(int ID, int value);
int SetI(int ID, int value);
int SetD(int ID, int value);
int SetGoalPosition(int ID, int angle);
int SetGoalVelocity(int ID, int velocity);
int SetGoalTorque(int ID, int torque);
int SetPunch(int ID, int punch);
int GetValue(int ID, int address, int *val);
private :
// REPLY BUFFER
static unsigned char recycle[255];
int statusError(unsigned char* buf, int n);
int length(unsigned char* buf);
void flush();
void packetPrint(int bytes, unsigned char* buf);
void write(unsigned char* buf, int n);
int read(int ID, unsigned char* buf, int nMax=255);
int send(int ID, int bytes, unsigned char* data, unsigned char ins=0x03, unsigned char* reply=recycle);
//int ping(int ID);
int dataPack(int start, unsigned char* data, int address, int value);
int dataPush(int ID, int address, int value);
int dataPull(int ID, int address, int* val);
Serial _out;
Serial _in;
int _baud;
int _bitPeriod;
};
// EEPROM
#define XL_MODEL_NUMBER_L 0
#define XL_MODEL_NUMBER_H 1
#define XL_VERSION 2
#define XL_ID 3
#define XL_BAUD_RATE 4
#define XL_RETURN_DELAY_TIME 5
#define XL_CW_ANGLE_LIMIT_L 6
#define XL_CW_ANGLE_LIMIT_H 7
#define XL_CCW_ANGLE_LIMIT_L 8
#define XL_CCW_ANGLE_LIMIT_H 9
#define XL_CONTROL_MODE 11
#define XL_LIMIT_TEMPERATURE 12
#define XL_DOWN_LIMIT_VOLTAGE 13
#define XL_UP_LIMIT_VOLTAGE 14
#define XL_MAX_TORQUE_L 15
#define XL_MAX_TORQUE_H 16
#define XL_RETURN_LEVEL 17
#define XL_ALARM_SHUTDOWN 18
// RAM
#define XL_TORQUE_ENABLE 24
#define XL_LED 25
#define XL_D_GAIN 27
#define XL_I_GAIN 28
#define XL_P_GAIN 29
#define XL_GOAL_POSITION_L 30
#define XL_GOAL_SPEED_L 32
#define XL_GOAL_TORQUE 35
#define XL_PRESENT_POSITION 37
#define XL_PRESENT_SPEED 39
#define XL_PRESENT_LOAD 41
#define XL_PRESENT_VOLTAGE 45
#define XL_PRESENT_TEMPERATURE 46
#define XL_REGISTERED_INSTRUCTION 47
#define XL_MOVING 49
#define XL_HARDWARE_ERROR 50
#define XL_PUNCH 51
// INS
const unsigned char INS_Ping = 0x01; // Corresponding device ID command to check if packet reaches
const unsigned char INS_Read = 0x02; // Read command
const unsigned char INS_Write = 0x03; // Write command
const unsigned char INS_RegWrite = 0x04; // When receiving a write command packet data is not immediately written instead it goes into standby momentarily until action command arrives
const unsigned char INS_Action = 0x05; // Go command for Reg Write
const unsigned char INS_Factory = 0x06; // Reset All data to factory default settings
const unsigned char INS_Reboot = 0x08; // Reboot device
const unsigned char INS_StatusReturn = 0x55; // Instruction Packet response
const unsigned char INS_SyncRead = 0x82; // Read data from the same location and same size for multiple devices simultaneously
const unsigned char INS_SyncWrite = 0x83; // Write data from the same location and same size for multiple devices simultaneously
const unsigned char INS_BulkRead = 0x92; // Read data from the different locations and different sizes for multiple devices simultaneously
const unsigned char INS_BulkWrite = 0x93; // Write data from the different locations and different sizes for multiple devices simultaneously
// ID
const unsigned char ID_Broadcast = 0xFE; // 254(0xFE) is used as the Broadcast ID
// Util
#define DM_MAKEWORD(a, b) ((unsigned short)(((unsigned char)(((unsigned long)(a)) & 0xff)) | ((unsigned short)((unsigned char)(((unsigned long)(b)) & 0xff))) << 8))
#define DM_LOBYTE(w) ((unsigned char)(((unsigned long)(w)) & 0xff))
#define DM_HIBYTE(w) ((unsigned char)((((unsigned long)(w)) >> 8) & 0xff))
unsigned short update_crc(unsigned short crc_accum, unsigned char *data_blk_ptr, unsigned short data_blk_size);
#endif |
alonf/UniversalACRemote | PubSub.h | <reponame>alonf/UniversalACRemote
// PubSub.h
#ifndef _PUBSUB_h
#define _PUBSUB_h
#include <functional>
#include <vector>
template<typename TOwner, typename ...Args>
class PubSub
{
friend TOwner;
using CommandNotificationPtr_t = std::function<void(Args...)>;
private:
std::vector<CommandNotificationPtr_t> _subscribers;
void NotifyAll(Args... args) const;
public:
void Register(CommandNotificationPtr_t subscriber);
};
template <typename TOwner, typename ... Args>
void PubSub<TOwner, Args...>::Register(CommandNotificationPtr_t subscriber)
{
_subscribers.push_back(subscriber);
}
template <typename TOwner, typename ... Args>
void PubSub<TOwner, Args...>::NotifyAll(Args... args) const
{
for (auto subscriber : _subscribers)
{
subscriber(std::forward<Args>(args)...);
}
}
#endif
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.