Description: refactor
Reviewed-by: likailong
This commit is contained in:
0
kernel/arch/arm/cortex-m3/keil/cmsis/ARMCM3.h
Executable file → Normal file
0
kernel/arch/arm/cortex-m3/keil/cmsis/ARMCM3.h
Executable file → Normal file
0
kernel/arch/arm/cortex-m3/keil/cmsis/core_cm3.h
Executable file → Normal file
0
kernel/arch/arm/cortex-m3/keil/cmsis/core_cm3.h
Executable file → Normal file
0
kernel/arch/arm/cortex-m3/keil/cmsis/core_cmFunc.h
Executable file → Normal file
0
kernel/arch/arm/cortex-m3/keil/cmsis/core_cmFunc.h
Executable file → Normal file
0
kernel/arch/arm/cortex-m3/keil/cmsis/core_cmInstr.h
Executable file → Normal file
0
kernel/arch/arm/cortex-m3/keil/cmsis/core_cmInstr.h
Executable file → Normal file
161
kernel/arch/arm/cortex-m3/keil/los_arch_atomic.h
Normal file
161
kernel/arch/arm/cortex-m3/keil/los_arch_atomic.h
Normal file
@@ -0,0 +1,161 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef LOS_ATOMIC_H
|
||||
#define LOS_ATOMIC_H
|
||||
|
||||
#include "los_compiler.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/**
|
||||
* @ingroup los_atomic
|
||||
* @brief Atomic exchange for 32-bit variable.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to implement the atomic exchange for 32-bit variable and return the previous value of the atomic variable.
|
||||
* @attention
|
||||
* <ul>The pointer v must not be NULL.</ul>
|
||||
*
|
||||
* @param v [IN] The variable pointer.
|
||||
* @param val [IN] The exchange value.
|
||||
*
|
||||
* @retval #INT32 The previous value of the atomic variable
|
||||
* @par Dependency:
|
||||
* <ul><li>los_atomic.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see
|
||||
* @since Huawei LiteOS V100R001C00
|
||||
*/
|
||||
STATIC INLINE INT32 HalAtomicXchg32bits(volatile INT32 *v, INT32 val)
|
||||
{
|
||||
INT32 prevVal = 0;
|
||||
UINT32 status = 0;
|
||||
|
||||
do {
|
||||
__asm__ __volatile__("ldrex %0, [%3]\n"
|
||||
"strex %1, %4, [%3]"
|
||||
: "=&r"(prevVal), "=&r"(status), "+m"(*v)
|
||||
: "r"(v), "r"(val)
|
||||
: "cc");
|
||||
} while (__builtin_expect(status != 0, 0));
|
||||
|
||||
return prevVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup los_atomic
|
||||
* @brief Atomic auto-decrement.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to implementating the atomic auto-decrement and return the result of auto-decrement.
|
||||
* @attention
|
||||
* <ul>
|
||||
* <li>The pointer v must not be NULL.</li>
|
||||
* <li>The value which v point to must not be INT_MIN to avoid overflow after reducing 1.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param v [IN] The addSelf variable pointer.
|
||||
*
|
||||
* @retval #INT32 The return value of variable auto-decrement.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_atomic.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see
|
||||
* @since Huawei LiteOS V100R001C00
|
||||
*/
|
||||
STATIC INLINE INT32 HalAtomicDecRet(volatile INT32 *v)
|
||||
{
|
||||
INT32 val = 0;
|
||||
UINT32 status = 0;
|
||||
|
||||
do {
|
||||
__asm__ __volatile__("ldrex %0, [%3]\n"
|
||||
"sub %0, %0, #1\n"
|
||||
"strex %1, %0, [%3]"
|
||||
: "=&r"(val), "=&r"(status), "+m"(*v)
|
||||
: "r"(v)
|
||||
: "cc");
|
||||
} while (__builtin_expect(status != 0, 0));
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup los_atomic
|
||||
* @brief Atomic exchange for 32-bit variable with compare.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to implement the atomic exchange for 32-bit variable, if the value of variable is equal to oldVal.
|
||||
* @attention
|
||||
* <ul>The pointer v must not be NULL.</ul>
|
||||
*
|
||||
* @param v [IN] The variable pointer.
|
||||
* @param val [IN] The new value.
|
||||
* @param oldVal [IN] The old value.
|
||||
*
|
||||
* @retval TRUE The previous value of the atomic variable is not equal to oldVal.
|
||||
* @retval FALSE The previous value of the atomic variable is equal to oldVal.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_atomic.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see
|
||||
* @since Huawei LiteOS V100R001C00
|
||||
*/
|
||||
STATIC INLINE BOOL HalAtomicCmpXchg32bits(volatile INT32 *v, INT32 val, INT32 oldVal)
|
||||
{
|
||||
INT32 prevVal = 0;
|
||||
UINT32 status = 0;
|
||||
|
||||
do {
|
||||
__asm__ __volatile__("1: ldrex %0, %2\n"
|
||||
" mov %1, #0\n"
|
||||
" cmp %0, %3\n"
|
||||
" bne 2f\n"
|
||||
" strex %1, %4, %2\n"
|
||||
"2:"
|
||||
: "=&r"(prevVal), "=&r"(status), "+Q"(*v)
|
||||
: "r"(oldVal), "r"(val)
|
||||
: "cc");
|
||||
} while (__builtin_expect(status != 0, 0));
|
||||
|
||||
return prevVal != oldVal;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* LOS_ATOMIC_H */
|
||||
|
||||
325
kernel/arch/arm/cortex-m3/keil/los_context.h → kernel/arch/arm/cortex-m3/keil/los_arch_context.h
Executable file → Normal file
325
kernel/arch/arm/cortex-m3/keil/los_context.h → kernel/arch/arm/cortex-m3/keil/los_arch_context.h
Executable file → Normal file
@@ -1,194 +1,131 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup los_hw hardware
|
||||
* @ingroup kernel
|
||||
*/
|
||||
|
||||
#ifndef _LOS_HW_H
|
||||
#define _LOS_HW_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* *
|
||||
* @ingroup los_hw
|
||||
* The initialization value of stack space.
|
||||
*/
|
||||
#define EMPTY_STACK 0xCACA
|
||||
|
||||
/* *
|
||||
* @ingroup los_hw
|
||||
* Trigger a task.
|
||||
*/
|
||||
#define OsTaskTrap() __asm(" TRAP #31")
|
||||
|
||||
/* *
|
||||
* @ingroup los_hw
|
||||
* Check task schedule.
|
||||
*/
|
||||
#define LOS_CHECK_SCHEDULE ((!g_losTaskLock))
|
||||
|
||||
/* *
|
||||
* @ingroup los_hw
|
||||
* Define the type of a task context control block.
|
||||
*/
|
||||
typedef struct tagTskContext {
|
||||
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||
(defined(__FPU_USED) && (__FPU_USED == 1U)))
|
||||
UINT32 S16;
|
||||
UINT32 S17;
|
||||
UINT32 S18;
|
||||
UINT32 S19;
|
||||
UINT32 S20;
|
||||
UINT32 S21;
|
||||
UINT32 S22;
|
||||
UINT32 S23;
|
||||
UINT32 S24;
|
||||
UINT32 S25;
|
||||
UINT32 S26;
|
||||
UINT32 S27;
|
||||
UINT32 S28;
|
||||
UINT32 S29;
|
||||
UINT32 S30;
|
||||
UINT32 S31;
|
||||
#endif
|
||||
UINT32 uwR4;
|
||||
UINT32 uwR5;
|
||||
UINT32 uwR6;
|
||||
UINT32 uwR7;
|
||||
UINT32 uwR8;
|
||||
UINT32 uwR9;
|
||||
UINT32 uwR10;
|
||||
UINT32 uwR11;
|
||||
UINT32 uwPriMask;
|
||||
UINT32 uwR0;
|
||||
UINT32 uwR1;
|
||||
UINT32 uwR2;
|
||||
UINT32 uwR3;
|
||||
UINT32 uwR12;
|
||||
UINT32 uwLR;
|
||||
UINT32 uwPC;
|
||||
UINT32 uwxPSR;
|
||||
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||
(defined(__FPU_USED) && (__FPU_USED == 1U)))
|
||||
UINT32 S0;
|
||||
UINT32 S1;
|
||||
UINT32 S2;
|
||||
UINT32 S3;
|
||||
UINT32 S4;
|
||||
UINT32 S5;
|
||||
UINT32 S6;
|
||||
UINT32 S7;
|
||||
UINT32 S8;
|
||||
UINT32 S9;
|
||||
UINT32 S10;
|
||||
UINT32 S11;
|
||||
UINT32 S12;
|
||||
UINT32 S13;
|
||||
UINT32 S14;
|
||||
UINT32 S15;
|
||||
UINT32 FPSCR;
|
||||
UINT32 NO_NAME;
|
||||
#endif
|
||||
} TaskContext;
|
||||
|
||||
/* *
|
||||
* @ingroup los_hw
|
||||
* @brief: Task stack initialization.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to initialize the task stack.
|
||||
*
|
||||
* @attention:
|
||||
* <ul><li>None.</li></ul>
|
||||
*
|
||||
* @param taskID [IN] Type#UINT32: TaskID.
|
||||
* @param stackSize [IN] Type#UINT32: Total size of the stack.
|
||||
* @param topStack [IN] Type#VOID *: Top of task's stack.
|
||||
*
|
||||
* @retval: context Type#TaskContext *.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_hw.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
*/
|
||||
extern VOID *OsTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack);
|
||||
|
||||
/**
|
||||
* @ingroup los_hw
|
||||
* @brief: Function to task exit.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to exit task.
|
||||
*
|
||||
* @attention:
|
||||
* <ul><li>None.</li></ul>
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @retval: None.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_hw.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
*/
|
||||
LITE_OS_SEC_TEXT_MINOR VOID OsTaskExit(VOID);
|
||||
|
||||
/* *
|
||||
* @ingroup los_hw
|
||||
* @brief: The M3 wait interrupt instruction.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to make CPU enter to power-save mode.
|
||||
*
|
||||
* @attention:
|
||||
* <ul><li>None.</li></ul>
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @retval: None.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_hw.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
*/
|
||||
extern VOID OsEnterSleep(VOID);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _LOS_HW_H */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _LOS_ARCH_CONTEXT_H
|
||||
#define _LOS_ARCH_CONTEXT_H
|
||||
|
||||
#include "los_config.h"
|
||||
#include "los_compiler.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
typedef struct tagTskContext {
|
||||
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||
(defined(__FPU_USED) && (__FPU_USED == 1U)))
|
||||
UINT32 S16;
|
||||
UINT32 S17;
|
||||
UINT32 S18;
|
||||
UINT32 S19;
|
||||
UINT32 S20;
|
||||
UINT32 S21;
|
||||
UINT32 S22;
|
||||
UINT32 S23;
|
||||
UINT32 S24;
|
||||
UINT32 S25;
|
||||
UINT32 S26;
|
||||
UINT32 S27;
|
||||
UINT32 S28;
|
||||
UINT32 S29;
|
||||
UINT32 S30;
|
||||
UINT32 S31;
|
||||
#endif
|
||||
UINT32 uwR4;
|
||||
UINT32 uwR5;
|
||||
UINT32 uwR6;
|
||||
UINT32 uwR7;
|
||||
UINT32 uwR8;
|
||||
UINT32 uwR9;
|
||||
UINT32 uwR10;
|
||||
UINT32 uwR11;
|
||||
UINT32 uwPriMask;
|
||||
UINT32 uwR0;
|
||||
UINT32 uwR1;
|
||||
UINT32 uwR2;
|
||||
UINT32 uwR3;
|
||||
UINT32 uwR12;
|
||||
UINT32 uwLR;
|
||||
UINT32 uwPC;
|
||||
UINT32 uwxPSR;
|
||||
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||
(defined(__FPU_USED) && (__FPU_USED == 1U)))
|
||||
UINT32 S0;
|
||||
UINT32 S1;
|
||||
UINT32 S2;
|
||||
UINT32 S3;
|
||||
UINT32 S4;
|
||||
UINT32 S5;
|
||||
UINT32 S6;
|
||||
UINT32 S7;
|
||||
UINT32 S8;
|
||||
UINT32 S9;
|
||||
UINT32 S10;
|
||||
UINT32 S11;
|
||||
UINT32 S12;
|
||||
UINT32 S13;
|
||||
UINT32 S14;
|
||||
UINT32 S15;
|
||||
UINT32 FPSCR;
|
||||
UINT32 NO_NAME;
|
||||
#endif
|
||||
} TaskContext;
|
||||
|
||||
/**
|
||||
* @ingroup los_config
|
||||
* @brief: Task start running function.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to start a task.
|
||||
*
|
||||
* @attention:
|
||||
* <ul><li>None.</li></ul>
|
||||
*
|
||||
* @param: None.
|
||||
*
|
||||
* @retval None.
|
||||
*
|
||||
* @par Dependency:
|
||||
* <ul><li>los_config.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
*/
|
||||
extern VOID HalStartToRun(VOID);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
#endif /* _LOS_ARCH_CONTEXT_H */
|
||||
|
||||
1867
kernel/arch/arm/cortex-m3/keil/los_interrupt.h → kernel/arch/arm/cortex-m3/keil/los_arch_interrupt.h
Executable file → Normal file
1867
kernel/arch/arm/cortex-m3/keil/los_interrupt.h → kernel/arch/arm/cortex-m3/keil/los_arch_interrupt.h
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
54
kernel/arch/arm/cortex-m3/keil/los_arch_timer.h
Normal file
54
kernel/arch/arm/cortex-m3/keil/los_arch_timer.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _LOS_ARCH_TIMER_H
|
||||
#define _LOS_ARCH_TIMER_H
|
||||
|
||||
#include "los_config.h"
|
||||
#include "los_compiler.h"
|
||||
#include "los_context.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
UINT32 HalTickStart(OS_TICK_HANDLER handler);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
#endif /* _LOS_ARCH_TIMER_H */
|
||||
|
||||
48
kernel/arch/arm/cortex-m4/iar/los_hw.c → kernel/arch/arm/cortex-m3/keil/los_context.c
Executable file → Normal file
48
kernel/arch/arm/cortex-m4/iar/los_hw.c → kernel/arch/arm/cortex-m3/keil/los_context.c
Executable file → Normal file
@@ -28,9 +28,14 @@
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "los_config.h"
|
||||
#include "los_task.h"
|
||||
#include "securec.h"
|
||||
#include "los_interrupt.h"
|
||||
#include "los_arch_context.h"
|
||||
#include "los_arch_interrupt.h"
|
||||
#include "los_arch_timer.h"
|
||||
#include "ARMCM3.h"
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
@@ -38,20 +43,32 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : OsTaskExit
|
||||
Description : Task exit function
|
||||
Function : HalArchInit
|
||||
Description : arch init function
|
||||
Input : None
|
||||
Output : None
|
||||
Return : None
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR VOID OsTaskExit(VOID)
|
||||
LITE_OS_SEC_TEXT_INIT VOID HalArchInit()
|
||||
{
|
||||
HalHwiInit();
|
||||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : HalSysExit
|
||||
Description : exit function
|
||||
Input : None
|
||||
Output : None
|
||||
Return : None
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR VOID HalSysExit(VOID)
|
||||
{
|
||||
LOS_IntLock();
|
||||
for(;;);
|
||||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : OsTskStackInit
|
||||
Function : HalTskStackInit
|
||||
Description : Task stack initialization function
|
||||
Input : taskID --- TaskID
|
||||
stackSize --- Total size of the stack
|
||||
@@ -59,7 +76,7 @@ LITE_OS_SEC_TEXT_MINOR VOID OsTaskExit(VOID)
|
||||
Output : None
|
||||
Return : Context pointer
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_INIT VOID *OsTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
|
||||
LITE_OS_SEC_TEXT_INIT VOID *HalTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
|
||||
{
|
||||
TaskContext *context = NULL;
|
||||
errno_t result;
|
||||
@@ -125,18 +142,27 @@ LITE_OS_SEC_TEXT_INIT VOID *OsTskStackInit(UINT32 taskID, UINT32 stackSize, VOID
|
||||
context->uwR2 = 0x02020202L;
|
||||
context->uwR3 = 0x03030303L;
|
||||
context->uwR12 = 0x12121212L;
|
||||
context->uwLR = (UINT32)(UINTPTR)OsTaskExit;
|
||||
context->uwLR = (UINT32)(UINTPTR)HalSysExit;
|
||||
context->uwPC = (UINT32)(UINTPTR)OsTaskEntry;
|
||||
context->uwxPSR = 0x01000000L;
|
||||
|
||||
return (VOID *)context;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT VOID OsEnterSleep(VOID)
|
||||
void HalBackTrace()
|
||||
{
|
||||
__DSB();
|
||||
__WFI();
|
||||
__ISB();
|
||||
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 HalStartSchedule(OS_TICK_HANDLER handler)
|
||||
{
|
||||
UINT32 ret;
|
||||
ret = HalTickStart(handler);
|
||||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
}
|
||||
HalStartToRun();
|
||||
return LOS_OK; /* never return */
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
34
kernel/arch/arm/cortex-m3/keil/los_dispatch.S
Executable file → Normal file
34
kernel/arch/arm/cortex-m3/keil/los_dispatch.S
Executable file → Normal file
@@ -31,15 +31,14 @@
|
||||
|
||||
PRESERVE8
|
||||
|
||||
EXPORT LOS_IntLock
|
||||
EXPORT LOS_IntUnLock
|
||||
EXPORT LOS_IntRestore
|
||||
EXPORT LOS_StartToRun
|
||||
EXPORT osTaskSchedule
|
||||
EXPORT osPendSV
|
||||
EXPORT HalIntLock
|
||||
EXPORT HalIntUnLock
|
||||
EXPORT HalIntRestore
|
||||
EXPORT HalStartToRun
|
||||
EXPORT HalTaskSchedule
|
||||
EXPORT HalPendSV
|
||||
|
||||
IMPORT g_losTask
|
||||
IMPORT g_taskSwitchHook
|
||||
IMPORT g_taskScheduled
|
||||
|
||||
OS_NVIC_INT_CTRL EQU 0xE000ED04
|
||||
@@ -52,7 +51,7 @@ OS_TASK_STATUS_RUNNING EQU 0x0010
|
||||
THUMB
|
||||
REQUIRE8
|
||||
|
||||
LOS_StartToRun
|
||||
HalStartToRun
|
||||
LDR R4, =OS_NVIC_SYSPRI2
|
||||
LDR R5, =OS_NVIC_PENDSV_PRI
|
||||
STR R5, [R4]
|
||||
@@ -94,38 +93,31 @@ LOS_StartToRun
|
||||
BX R6
|
||||
|
||||
|
||||
LOS_IntLock
|
||||
HalIntLock
|
||||
MRS R0, PRIMASK
|
||||
CPSID I
|
||||
BX LR
|
||||
|
||||
LOS_IntUnLock
|
||||
HalIntUnLock
|
||||
MRS R0, PRIMASK
|
||||
CPSIE I
|
||||
BX LR
|
||||
|
||||
LOS_IntRestore
|
||||
HalIntRestore
|
||||
MSR PRIMASK, R0
|
||||
BX LR
|
||||
|
||||
osTaskSchedule
|
||||
HalTaskSchedule
|
||||
LDR R0, =OS_NVIC_INT_CTRL
|
||||
LDR R1, =OS_NVIC_PENDSVSET
|
||||
STR R1, [R0]
|
||||
BX LR
|
||||
|
||||
osPendSV
|
||||
HalPendSV
|
||||
MRS R12, PRIMASK
|
||||
CPSID I
|
||||
|
||||
LDR R2, =g_taskSwitchHook
|
||||
LDR R2, [R2]
|
||||
CBZ R2, TaskSwitch
|
||||
PUSH {R12, LR}
|
||||
BLX R2
|
||||
POP {R12, LR}
|
||||
|
||||
TaskSwitch
|
||||
HalTaskSwitch
|
||||
MRS R0, PSP
|
||||
|
||||
STMFD R0!, {R4-R12}
|
||||
|
||||
30
kernel/arch/arm/cortex-m3/keil/los_hw_exc.S → kernel/arch/arm/cortex-m3/keil/los_exc.S
Executable file → Normal file
30
kernel/arch/arm/cortex-m3/keil/los_hw_exc.S → kernel/arch/arm/cortex-m3/keil/los_exc.S
Executable file → Normal file
@@ -33,16 +33,14 @@
|
||||
AREA |.text|, CODE, READONLY
|
||||
THUMB
|
||||
|
||||
EXPORT OsExcNMI
|
||||
EXPORT OsExcHardFault
|
||||
EXPORT OsExcMemFault
|
||||
EXPORT OsExcBusFault
|
||||
EXPORT OsExcUsageFault
|
||||
EXPORT OsExcSvcCall
|
||||
EXPORT HalExcNMI
|
||||
EXPORT HalExcHardFault
|
||||
EXPORT HalExcMemFault
|
||||
EXPORT HalExcBusFault
|
||||
EXPORT HalExcUsageFault
|
||||
EXPORT HalExcSvcCall
|
||||
|
||||
IMPORT OsExcHandleEntry
|
||||
;IMPORT g_vuwLosFlag
|
||||
;IMPORT g_curNestCount
|
||||
IMPORT HalExcHandleEntry
|
||||
IMPORT g_uwExcTbl
|
||||
IMPORT g_taskScheduled
|
||||
|
||||
@@ -66,12 +64,12 @@ OS_NVIC_ACT_BASE EQU 0xE000E300
|
||||
OS_NVIC_SHCSRS EQU 0xE000ED24
|
||||
OS_NVIC_SHCSR_MASK EQU 0xC00
|
||||
|
||||
OsExcNMI
|
||||
HalExcNMI
|
||||
MOV R0, #OS_EXC_CAUSE_NMI
|
||||
MOV R1, #0
|
||||
B osExcDispatch
|
||||
|
||||
OsExcHardFault
|
||||
HalExcHardFault
|
||||
MOV R0, #OS_EXC_CAUSE_HARDFAULT
|
||||
LDR R2, =OS_NVIC_HFSR
|
||||
LDR R2, [R2]
|
||||
@@ -122,7 +120,7 @@ osHFExcCommonBMU
|
||||
ORR R0, R0 ,R12
|
||||
B osExcDispatch
|
||||
|
||||
OsExcSvcCall
|
||||
HalExcSvcCall
|
||||
TST LR, #0x4
|
||||
ITE EQ
|
||||
MRSEQ R0, MSP
|
||||
@@ -132,7 +130,7 @@ OsExcSvcCall
|
||||
MOV R1, #0
|
||||
B osExcDispatch
|
||||
|
||||
OsExcBusFault
|
||||
HalExcBusFault
|
||||
LDR R0, =OS_NVIC_FSR
|
||||
LDR R0, [R0]
|
||||
|
||||
@@ -149,7 +147,7 @@ _ExcBusNoADDR
|
||||
MOV R12,#0
|
||||
B osExcCommonBMU
|
||||
|
||||
OsExcMemFault
|
||||
HalExcMemFault
|
||||
LDR R0, =OS_NVIC_FSR
|
||||
LDR R0, [R0]
|
||||
|
||||
@@ -166,7 +164,7 @@ _ExcMemNoADDR
|
||||
MOV R12,#0
|
||||
B osExcCommonBMU
|
||||
|
||||
OsExcUsageFault
|
||||
HalExcUsageFault
|
||||
LDR R0, =OS_NVIC_FSR
|
||||
LDR R0, [R0]
|
||||
|
||||
@@ -281,7 +279,7 @@ _handleEntry
|
||||
MOV R3, R13 ; R13:the 4th param
|
||||
CPSID I
|
||||
CPSID F
|
||||
B OsExcHandleEntry
|
||||
B HalExcHandleEntry
|
||||
|
||||
NOP
|
||||
END
|
||||
172
kernel/arch/arm/cortex-m3/keil/los_interrupt.c
Executable file → Normal file
172
kernel/arch/arm/cortex-m3/keil/los_interrupt.c
Executable file → Normal file
@@ -29,12 +29,11 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "los_interrupt.h"
|
||||
#include "los_context.h"
|
||||
#include "los_arch_interrupt.h"
|
||||
#include <stdarg.h>
|
||||
#include "los_debug.h"
|
||||
#include "los_task.h"
|
||||
#if (LOSCFG_KERNEL_TICKLESS == YES)
|
||||
#include "los_tick.h"
|
||||
#endif
|
||||
#include "ARMCM3.h"
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
@@ -43,99 +42,79 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*lint -save -e40 -e522 -e533*/
|
||||
__weak VOID SysTickHandler(VOID)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UINT32 g_vuwIntCount = 0;
|
||||
UINT32 g_intCount = 0;
|
||||
/*lint -restore*/
|
||||
#ifdef __ICCARM__
|
||||
#pragma location = ".data.vector"
|
||||
#elif defined(__CC_ARM) || defined(__GNUC__)
|
||||
#pragma data_alignment=0x100
|
||||
LITE_OS_SEC_VEC
|
||||
#endif
|
||||
HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {
|
||||
(HWI_PROC_FUNC)0, // [0] Top of Stack
|
||||
(HWI_PROC_FUNC)Reset_Handler, // [1] reset
|
||||
(HWI_PROC_FUNC)OsHwiDefaultHandler, // [2] NMI Handler
|
||||
(HWI_PROC_FUNC)OsHwiDefaultHandler, // [3] Hard Fault Handler
|
||||
(HWI_PROC_FUNC)OsHwiDefaultHandler, // [4] MPU Fault Handler
|
||||
(HWI_PROC_FUNC)OsHwiDefaultHandler, // [5] Bus Fault Handler
|
||||
(HWI_PROC_FUNC)OsHwiDefaultHandler, // [6] Usage Fault Handler
|
||||
(HWI_PROC_FUNC)0, // [7] Reserved
|
||||
(HWI_PROC_FUNC)0, // [8] Reserved
|
||||
(HWI_PROC_FUNC)0, // [9] Reserved
|
||||
(HWI_PROC_FUNC)0, // [10] Reserved
|
||||
(HWI_PROC_FUNC)OsHwiDefaultHandler, // [11] SVCall Handler
|
||||
(HWI_PROC_FUNC)OsHwiDefaultHandler, // [12] Debug Monitor Handler
|
||||
(HWI_PROC_FUNC)0, // [13] Reserved
|
||||
(HWI_PROC_FUNC)osPendSV, // [14] PendSV Handler
|
||||
(HWI_PROC_FUNC)SysTickHandler, // [15] SysTick Handler
|
||||
};
|
||||
HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
|
||||
|
||||
|
||||
#if (OS_HWI_WITH_ARG == YES)
|
||||
#if (OS_HWI_WITH_ARG == 1)
|
||||
HWI_SLAVE_FUNC g_hwiSlaveForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
|
||||
#else
|
||||
HWI_PROC_FUNC g_hwiSlaveForm[OS_VECTOR_CNT] = {0};
|
||||
#endif
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : OsIntNumGet
|
||||
Function : HalIntNumGet
|
||||
Description : Get a interrupt number
|
||||
Input : None
|
||||
Output : None
|
||||
Return : Interrupt Indexes number
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR UINT32 OsIntNumGet(VOID)
|
||||
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
|
||||
{
|
||||
return __get_IPSR();
|
||||
}
|
||||
|
||||
inline UINT32 HalIsIntAcvive(VOID)
|
||||
{
|
||||
return (g_intCount > 0);
|
||||
}
|
||||
/* ****************************************************************************
|
||||
Function : OsHwiDefaultHandler
|
||||
Function : HalHwiDefaultHandler
|
||||
Description : default handler of the hardware interrupt
|
||||
Input : None
|
||||
Output : None
|
||||
Return : None
|
||||
**************************************************************************** */
|
||||
/*lint -e529*/
|
||||
LITE_OS_SEC_TEXT_MINOR VOID OsHwiDefaultHandler(VOID)
|
||||
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||
{
|
||||
UINT32 irqNum = OsIntNumGet();
|
||||
UINT32 irqNum = HalIntNumGet();
|
||||
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
|
||||
while (1) {}
|
||||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : OsInterrupt
|
||||
Function : HalInterrupt
|
||||
Description : Hardware interrupt entry function
|
||||
Input : None
|
||||
Output : None
|
||||
Return : None
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT VOID OsInterrupt(VOID)
|
||||
LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
||||
{
|
||||
UINT32 hwiIndex;
|
||||
UINT32 intSave;
|
||||
|
||||
#if (LOSCFG_KERNEL_RUNSTOP == YES)
|
||||
#if (LOSCFG_KERNEL_RUNSTOP == 1)
|
||||
SCB->SCR &= (UINT32) ~((UINT32)SCB_SCR_SLEEPDEEP_Msk);
|
||||
#endif
|
||||
|
||||
intSave = LOS_IntLock();
|
||||
|
||||
g_vuwIntCount++;
|
||||
g_intCount++;
|
||||
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
hwiIndex = OsIntNumGet();
|
||||
#if (LOSCFG_KERNEL_TICKLESS == YES)
|
||||
osUpdateKernelTickCount(hwiIndex);
|
||||
#endif
|
||||
hwiIndex = HalIntNumGet();
|
||||
|
||||
#if (OS_HWI_WITH_ARG == YES)
|
||||
#if (OS_HWI_WITH_ARG == 1)
|
||||
if (g_hwiSlaveForm[hwiIndex].pfnHandler != 0) {
|
||||
g_hwiSlaveForm[hwiIndex].pfnHandler((VOID *)g_hwiSlaveForm[hwiIndex].pParm);
|
||||
}
|
||||
@@ -145,12 +124,12 @@ LITE_OS_SEC_TEXT VOID OsInterrupt(VOID)
|
||||
}
|
||||
#endif
|
||||
intSave = LOS_IntLock();
|
||||
g_vuwIntCount--;
|
||||
g_intCount--;
|
||||
LOS_IntRestore(intSave);
|
||||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : LOS_HwiCreate
|
||||
Function : HalHwiCreate
|
||||
Description : create hardware interrupt
|
||||
Input : hwiNum --- hwi num to create
|
||||
hwiPrio --- priority of the hwi
|
||||
@@ -160,7 +139,7 @@ LITE_OS_SEC_TEXT VOID OsInterrupt(VOID)
|
||||
Output : None
|
||||
Return : LOS_OK on success or error code on failure
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 LOS_HwiCreate(HWI_HANDLE_T hwiNum,
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 HalHwiCreate(HWI_HANDLE_T hwiNum,
|
||||
HWI_PRIOR_T hwiPrio,
|
||||
HWI_MODE_T mode,
|
||||
HWI_PROC_FUNC handler,
|
||||
@@ -176,7 +155,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_HwiCreate(HWI_HANDLE_T hwiNum,
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)OsHwiDefaultHandler) {
|
||||
if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
|
||||
return OS_ERRNO_HWI_ALREADY_CREATED;
|
||||
}
|
||||
|
||||
@@ -185,7 +164,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_HwiCreate(HWI_HANDLE_T hwiNum,
|
||||
}
|
||||
|
||||
intSave = LOS_IntLock();
|
||||
#if (OS_HWI_WITH_ARG == YES)
|
||||
#if (OS_HWI_WITH_ARG == 1)
|
||||
OsSetVector(hwiNum, handler, arg);
|
||||
#else
|
||||
OsSetVector(hwiNum, handler);
|
||||
@@ -199,13 +178,13 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_HwiCreate(HWI_HANDLE_T hwiNum,
|
||||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : LOS_HwiDelete
|
||||
Function : HalHwiDelete
|
||||
Description : Delete hardware interrupt
|
||||
Input : hwiNum --- hwi num to delete
|
||||
Output : None
|
||||
Return : LOS_OK on success or error code on failure
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 LOS_HwiDelete(HWI_HANDLE_T hwiNum)
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 HalHwiDelete(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
UINT32 intSave;
|
||||
|
||||
@@ -217,7 +196,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_HwiDelete(HWI_HANDLE_T hwiNum)
|
||||
|
||||
intSave = LOS_IntLock();
|
||||
|
||||
g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsHwiDefaultHandler;
|
||||
g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
@@ -235,9 +214,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_HwiDelete(HWI_HANDLE_T hwiNum)
|
||||
|
||||
static ExcInfoArray g_excArray[OS_EXC_TYPE_MAX];
|
||||
|
||||
UINT32 g_curNestCount = 0;
|
||||
static ExcInfo g_excInfo;
|
||||
static EVENT_CB_S g_excEvent;
|
||||
static ExcInfo g_excInfo = {0};
|
||||
|
||||
UINT8 g_uwExcTbl[FAULT_STATUS_REG_BIT] = {
|
||||
0, 0, 0, 0, 0, 0, OS_EXC_UF_DIVBYZERO, OS_EXC_UF_UNALIGNED,
|
||||
@@ -246,19 +223,10 @@ UINT8 g_uwExcTbl[FAULT_STATUS_REG_BIT] = {
|
||||
0, 0, 0, OS_EXC_MF_MSTKERR, OS_EXC_MF_MUNSTKERR, 0, OS_EXC_MF_DACCVIOL, OS_EXC_MF_IACCVIOL
|
||||
};
|
||||
|
||||
__attribute__((noinline)) VOID LOS_Panic(const CHAR *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap,fmt);
|
||||
PRINT_ERR(fmt, ap);
|
||||
va_end(ap);
|
||||
asm volatile ("swi 0");
|
||||
}
|
||||
|
||||
UINT32 OsExcNvicDump(UINT32 index, UINT32 *excContent)
|
||||
UINT32 HalExcNvicDump(UINT32 index, UINT32 *excContent)
|
||||
{
|
||||
UINT32 *base = NULL;
|
||||
UINT32 len = 0,i,j;
|
||||
UINT32 len = 0, i, j;
|
||||
#define OS_NR_NVIC_EXC_DUMP_Types 7
|
||||
UINT32 rgNvicBases[OS_NR_NVIC_EXC_DUMP_Types] = {OS_NVIC_SETENA_BASE, OS_NVIC_SETPEND_BASE,
|
||||
OS_NVIC_INT_ACT_BASE, OS_NVIC_PRI_BASE, OS_NVIC_EXCPRI_BASE, OS_NVIC_SHCSR, OS_NVIC_INT_CTRL};
|
||||
@@ -286,9 +254,10 @@ UINT32 OsExcNvicDump(UINT32 index, UINT32 *excContent)
|
||||
}
|
||||
PRINTK("\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
UINT32 OsExcContextDump(UINT32 index, UINT32 *excContent)
|
||||
UINT32 HalExcContextDump(UINT32 index, UINT32 *excContent)
|
||||
{
|
||||
(VOID)index;
|
||||
(VOID)excContent;
|
||||
@@ -315,9 +284,10 @@ UINT32 OsExcContextDump(UINT32 index, UINT32 *excContent)
|
||||
PRINTK("LR = 0x%x\n", g_excInfo.context->uwLR);
|
||||
PRINTK("PC = 0x%x\n", g_excInfo.context->uwPC);
|
||||
PRINTK("xPSR = 0x%x\n", g_excInfo.context->uwxPSR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
VOID OsDumpMsg(VOID)
|
||||
VOID HalDumpMsg(VOID)
|
||||
{
|
||||
UINT32 index = 0;
|
||||
for (index = 0; index < (OS_EXC_TYPE_MAX - 1); index++) {
|
||||
@@ -328,21 +298,11 @@ VOID OsDumpMsg(VOID)
|
||||
}
|
||||
}
|
||||
|
||||
VOID OsExcNotify(VOID)
|
||||
{
|
||||
UINT32 ret = LOS_EventWrite(&g_excEvent, OS_EXC_EVENT);
|
||||
if (ret != LOS_OK) {
|
||||
PRINT_ERR("event notify failed\n");
|
||||
}
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT VOID OsExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid,
|
||||
EXC_CONTEXT_S *excBufAddr)
|
||||
LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr)
|
||||
{
|
||||
UINT16 tmpFlag = (excType >> 16) & OS_NULL_SHORT;
|
||||
g_curNestCount++;
|
||||
g_vuwIntCount++;
|
||||
g_excInfo.nestCnt = g_curNestCount;
|
||||
g_intCount++;
|
||||
g_excInfo.nestCnt++;
|
||||
|
||||
g_excInfo.type = excType & OS_NULL_SHORT;
|
||||
|
||||
@@ -351,7 +311,6 @@ LITE_OS_SEC_TEXT_INIT VOID OsExcHandleEntry(UINT32 excType, UINT32 faultAddr, UI
|
||||
} else {
|
||||
g_excInfo.faultAddr = OS_EXC_IMPRECISE_ACCESS_ADDR;
|
||||
}
|
||||
|
||||
if (g_losTask.runTask != NULL) {
|
||||
if (tmpFlag & OS_EXC_FLAG_IN_HWI) {
|
||||
g_excInfo.phase = OS_EXC_IN_HWI;
|
||||
@@ -364,25 +323,20 @@ LITE_OS_SEC_TEXT_INIT VOID OsExcHandleEntry(UINT32 excType, UINT32 faultAddr, UI
|
||||
g_excInfo.phase = OS_EXC_IN_INIT;
|
||||
g_excInfo.thrdPid = OS_NULL_INT;
|
||||
}
|
||||
|
||||
if (excType & OS_EXC_FLAG_NO_FLOAT) {
|
||||
g_excInfo.context = (EXC_CONTEXT_S *)((CHAR *)excBufAddr - LOS_OFF_SET_OF(EXC_CONTEXT_S, uwR4));
|
||||
} else {
|
||||
g_excInfo.context = excBufAddr;
|
||||
}
|
||||
|
||||
OsDumpMsg();
|
||||
|
||||
OsExcNotify();
|
||||
|
||||
LOS_Reboot();
|
||||
HalDumpMsg();
|
||||
HalSysExit();
|
||||
}
|
||||
|
||||
VOID OsExcRegister(ExcInfoType type, EXC_INFO_SAVE_CALLBACK func, VOID *arg)
|
||||
VOID HalExcRegister(ExcInfoType type, EXC_INFO_SAVE_CALLBACK func, VOID *arg)
|
||||
{
|
||||
ExcInfoArray *excInfo = NULL;
|
||||
if ((type >= OS_EXC_TYPE_MAX) || (func == NULL)) {
|
||||
PRINT_ERR("OsExcRegister ERROR!\n");
|
||||
PRINT_ERR("HalExcRegister ERROR!\n");
|
||||
return;
|
||||
}
|
||||
excInfo = &(g_excArray[type]);
|
||||
@@ -392,33 +346,29 @@ VOID OsExcRegister(ExcInfoType type, EXC_INFO_SAVE_CALLBACK func, VOID *arg)
|
||||
excInfo->uwValid = TRUE;
|
||||
}
|
||||
|
||||
void OsBackTrace()
|
||||
{
|
||||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : OsHwiInit
|
||||
Function : HalHwiInit
|
||||
Description : initialization of the hardware interrupt
|
||||
Input : None
|
||||
Output : None
|
||||
Return : None
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_INIT VOID OsHwiInit()
|
||||
LITE_OS_SEC_TEXT_INIT VOID HalHwiInit()
|
||||
{
|
||||
UINT32 index;
|
||||
UINT32 ret;
|
||||
|
||||
for (index = OS_SYS_VECTOR_CNT; index < OS_VECTOR_CNT; index++) {
|
||||
g_hwiForm[index] = (HWI_PROC_FUNC)OsHwiDefaultHandler;
|
||||
g_hwiForm[0] = 0; /* [0] Top of Stack */
|
||||
g_hwiForm[1] = Reset_Handler; /* [1] reset */
|
||||
for (index = 2; index < OS_VECTOR_CNT; index++) {
|
||||
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||
}
|
||||
|
||||
/* Exception handler register */
|
||||
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = OsExcHardFault;
|
||||
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = OsExcNMI;
|
||||
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = OsExcMemFault;
|
||||
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = OsExcBusFault;
|
||||
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = OsExcUsageFault;
|
||||
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = OsExcSvcCall;
|
||||
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI;
|
||||
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault;
|
||||
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault;
|
||||
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault;
|
||||
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault;
|
||||
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalExcSvcCall;
|
||||
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV;
|
||||
|
||||
/* Interrupt vector table location */
|
||||
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
|
||||
@@ -431,15 +381,9 @@ LITE_OS_SEC_TEXT_INIT VOID OsHwiInit()
|
||||
/* Enable DIV 0 and unaligned exception */
|
||||
*(volatile UINT32 *)OS_NVIC_CCR |= DIV0FAULT;
|
||||
|
||||
/* Init Exception Event */
|
||||
ret = LOS_EventInit(&g_excEvent);
|
||||
if (ret != LOS_OK) {
|
||||
PRINT_ERR("[EXC]init excepiton event failed!\n");
|
||||
return;
|
||||
}
|
||||
HalExcRegister(OS_EXC_TYPE_CONTEXT, (EXC_INFO_SAVE_CALLBACK)HalExcContextDump, NULL);
|
||||
HalExcRegister(OS_EXC_TYPE_NVIC, (EXC_INFO_SAVE_CALLBACK)HalExcNvicDump, NULL);
|
||||
|
||||
OsExcRegister(OS_EXC_TYPE_CONTEXT, (EXC_INFO_SAVE_CALLBACK)OsExcContextDump, NULL);
|
||||
OsExcRegister(OS_EXC_TYPE_NVIC, (EXC_INFO_SAVE_CALLBACK)OsExcNvicDump, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
6
kernel/arch/arm/cortex-m3/keil/los_vendor.s → kernel/arch/arm/cortex-m3/keil/los_startup.s
Executable file → Normal file
6
kernel/arch/arm/cortex-m3/keil/los_vendor.s → kernel/arch/arm/cortex-m3/keil/los_startup.s
Executable file → Normal file
@@ -29,7 +29,7 @@
|
||||
THUMB
|
||||
|
||||
IMPORT ||Image$$ARM_LIB_STACKHEAP$$ZI$$Limit||
|
||||
IMPORT OsHwiDefaultHandler
|
||||
IMPORT HalHwiDefaultHandler
|
||||
|
||||
EXPORT _BootVectors
|
||||
EXPORT Reset_Handler
|
||||
@@ -37,8 +37,8 @@
|
||||
_BootVectors
|
||||
DCD ||Image$$ARM_LIB_STACKHEAP$$ZI$$Limit||
|
||||
DCD Reset_Handler
|
||||
DCD OsHwiDefaultHandler
|
||||
DCD OsHwiDefaultHandler
|
||||
DCD HalHwiDefaultHandler
|
||||
DCD HalHwiDefaultHandler
|
||||
|
||||
|
||||
Reset_Handler
|
||||
94
kernel/arch/arm/cortex-m3/keil/los_hw_tick.c → kernel/arch/arm/cortex-m3/keil/los_timer.c
Executable file → Normal file
94
kernel/arch/arm/cortex-m3/keil/los_hw_tick.c → kernel/arch/arm/cortex-m3/keil/los_timer.c
Executable file → Normal file
@@ -28,29 +28,28 @@
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "los_config.h"
|
||||
#include "los_tick.h"
|
||||
#include "los_interrupt.h"
|
||||
#include "los_arch_interrupt.h"
|
||||
#include "ARMCM3.h"
|
||||
#include "los_timer.h"
|
||||
#include "los_context.h"
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
#define TICK_CHECK 0x4000000
|
||||
#define CYCLE_CHECK 0xFFFFFFFFU
|
||||
#define SHIFT_32_BIT 32
|
||||
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : OsTickStart
|
||||
Function : HalTickStart
|
||||
Description : Configure Tick Interrupt Start
|
||||
Input : none
|
||||
output : none
|
||||
return : LOS_OK - Success , or LOS_ERRNO_TICK_CFG_INVALID - failed
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 OsTickStart(VOID)
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 HalTickStart(OS_TICK_HANDLER *handler)
|
||||
{
|
||||
UINT32 ret;
|
||||
|
||||
@@ -60,10 +59,10 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsTickStart(VOID)
|
||||
return LOS_ERRNO_TICK_CFG_INVALID;
|
||||
}
|
||||
|
||||
#if (OS_HWI_WITH_ARG == YES)
|
||||
OsSetVector(SysTick_IRQn, (HWI_PROC_FUNC)OsTickHandler, NULL);
|
||||
#if (OS_HWI_WITH_ARG == 1)
|
||||
OsSetVector(SysTick_IRQn, (HWI_PROC_FUNC)handler, NULL);
|
||||
#else
|
||||
OsSetVector(SysTick_IRQn, OsTickHandler);
|
||||
OsSetVector(SysTick_IRQn, (HWI_PROC_FUNC)handler);
|
||||
#endif
|
||||
|
||||
g_cyclesPerTick = OS_SYS_CLOCK / LOSCFG_BASE_CORE_TICK_PER_SECOND;
|
||||
@@ -77,32 +76,14 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsTickStart(VOID)
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
#if (LOSCFG_KERNEL_TICKLESS == YES)
|
||||
/* ****************************************************************************
|
||||
Function : LOS_SysTickReload
|
||||
Description : reconfig systick, and clear SysTick_IRQn
|
||||
Input : cyclesPerTick --- cycles Per Tick
|
||||
output : none
|
||||
return : none
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR VOID LOS_SysTickReload(UINT32 cyclesPerTick)
|
||||
{
|
||||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
||||
SysTick->LOAD = (UINT32)(cyclesPerTick - 1UL); /* set reload register */
|
||||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : LOS_SysTickCurrCycleGet
|
||||
Function : HalSysTickCurrCycleGet
|
||||
Description : Get System cycle count
|
||||
Input : none
|
||||
output : none
|
||||
return : hwCycle --- the system cycle count
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR UINT32 LOS_SysTickCurrCycleGet(VOID)
|
||||
LITE_OS_SEC_TEXT_MINOR UINT32 HalSysTickCurrCycleGet(VOID)
|
||||
{
|
||||
UINT32 hwCycle;
|
||||
UINTPTR intSave;
|
||||
@@ -122,14 +103,14 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_SysTickCurrCycleGet(VOID)
|
||||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : LOS_GetCpuCycle
|
||||
Function : HalGetCpuCycle
|
||||
Description : Get System cycle count
|
||||
Input : none
|
||||
output : cntHi --- CpuTick High 4 byte
|
||||
cntLo --- CpuTick Low 4 byte
|
||||
return : none
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR VOID LOS_GetCpuCycle(UINT32 *cntHi, UINT32 *cntLo)
|
||||
LITE_OS_SEC_TEXT_MINOR VOID HalGetCpuCycle(UINT32 *cntHi, UINT32 *cntLo)
|
||||
{
|
||||
UINT64 swTick;
|
||||
UINT64 cycle;
|
||||
@@ -158,14 +139,14 @@ LITE_OS_SEC_TEXT_MINOR VOID LOS_GetCpuCycle(UINT32 *cntHi, UINT32 *cntLo)
|
||||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : LOS_GetSystickCycle
|
||||
Function : HalGetSystickCycle
|
||||
Description : Get Sys tick cycle count
|
||||
Input : none
|
||||
output : cntHi --- SysTick count High 4 byte
|
||||
cntLo --- SysTick count Low 4 byte
|
||||
return : none
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR VOID LOS_GetSystickCycle(UINT32 *cntHi, UINT32 *cntLo)
|
||||
LITE_OS_SEC_TEXT_MINOR VOID HalGetSystickCycle(UINT32 *cntHi, UINT32 *cntLo)
|
||||
{
|
||||
UINT64 swTick;
|
||||
UINT64 cycle;
|
||||
@@ -201,62 +182,49 @@ LITE_OS_SEC_TEXT_MINOR VOID LOS_GetSystickCycle(UINT32 *cntHi, UINT32 *cntLo)
|
||||
return;
|
||||
}
|
||||
|
||||
#define MAX_HOUR 24
|
||||
#define MAX_MINUTES 60
|
||||
#define MAX_SECONDS 60
|
||||
#define MILSEC 1000
|
||||
#define RTC_WAKEUPCLOCK_RTCCLK 32768
|
||||
#define RTC_WAKEUPCLOCK_RTCCLK_DIV 16
|
||||
#define RTC_CALIBRATE_SLEEP_TIME 8
|
||||
#define MACHINE_CYCLE_DEALAY_TIMES 4000
|
||||
|
||||
static BOOL g_sysSleepFlag = FALSE;
|
||||
|
||||
VOID LOS_TickLock(VOID)
|
||||
VOID HalTickLock(VOID)
|
||||
{
|
||||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||
}
|
||||
|
||||
VOID LOS_TickUnlock(VOID)
|
||||
VOID HalTickUnlock(VOID)
|
||||
{
|
||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||
}
|
||||
|
||||
BOOL LOS_GetSysSleepFlag(VOID)
|
||||
BOOL HalGetSysSleepFlag(VOID)
|
||||
{
|
||||
return g_sysSleepFlag;
|
||||
}
|
||||
|
||||
VOID LOS_ClearSysSleepFlag(VOID)
|
||||
VOID HalClearSysSleepFlag(VOID)
|
||||
{
|
||||
g_sysSleepFlag = FALSE;
|
||||
}
|
||||
|
||||
VOID LOS_EnterSleep(LOS_SysSleepEnum sleep)
|
||||
VOID HalEnterSleep(LOS_SysSleepEnum sleep)
|
||||
{
|
||||
__DSB();
|
||||
__WFI();
|
||||
__ISB();
|
||||
}
|
||||
|
||||
VOID LOS_SystemWakeup(UINT32 hwiIndex)
|
||||
{
|
||||
}
|
||||
//extern unsigned int SystemCoreClock;
|
||||
void LOS_HalDelay(UINT32 ticks)
|
||||
void HalDelay(UINT32 ticks)
|
||||
{
|
||||
UINT32 delayTimes;
|
||||
#if 0
|
||||
/* there are 4 machine cycle in loop */
|
||||
if ((ticks * (SystemCoreClock / MACHINE_CYCLE_DEALAY_TIMES)) >= 0xffffffff) {
|
||||
delayTimes = 0xffffffff;
|
||||
} else {
|
||||
delayTimes = ticks * (SystemCoreClock / MACHINE_CYCLE_DEALAY_TIMES);
|
||||
}
|
||||
|
||||
while (delayTimes) {
|
||||
delayTimes = delayTimes - 1;
|
||||
}
|
||||
UINT32 delayTimes;
|
||||
/* there are 4 machine cycle in loop */
|
||||
if ((ticks * (SystemCoreClock / MACHINE_CYCLE_DEALAY_TIMES)) >= 0xffffffff) {
|
||||
delayTimes = 0xffffffff;
|
||||
} else {
|
||||
delayTimes = ticks * (SystemCoreClock / MACHINE_CYCLE_DEALAY_TIMES);
|
||||
}
|
||||
while (delayTimes) {
|
||||
delayTimes = delayTimes - 1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
161
kernel/arch/arm/cortex-m4/iar/los_arch_atomic.h
Normal file
161
kernel/arch/arm/cortex-m4/iar/los_arch_atomic.h
Normal file
@@ -0,0 +1,161 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef LOS_ATOMIC_H
|
||||
#define LOS_ATOMIC_H
|
||||
|
||||
#include "los_compiler.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/**
|
||||
* @ingroup los_atomic
|
||||
* @brief Atomic exchange for 32-bit variable.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to implement the atomic exchange for 32-bit variable and return the previous value of the atomic variable.
|
||||
* @attention
|
||||
* <ul>The pointer v must not be NULL.</ul>
|
||||
*
|
||||
* @param v [IN] The variable pointer.
|
||||
* @param val [IN] The exchange value.
|
||||
*
|
||||
* @retval #INT32 The previous value of the atomic variable
|
||||
* @par Dependency:
|
||||
* <ul><li>los_atomic.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see
|
||||
* @since Huawei LiteOS V100R001C00
|
||||
*/
|
||||
STATIC INLINE INT32 HalAtomicXchg32bits(volatile INT32 *v, INT32 val)
|
||||
{
|
||||
INT32 prevVal = 0;
|
||||
UINT32 status = 0;
|
||||
|
||||
do {
|
||||
__asm__ __volatile__("ldrex %0, [%3]\n"
|
||||
"strex %1, %4, [%3]"
|
||||
: "=&r"(prevVal), "=&r"(status), "+m"(*v)
|
||||
: "r"(v), "r"(val)
|
||||
: "cc");
|
||||
} while (__builtin_expect(status != 0, 0));
|
||||
|
||||
return prevVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup los_atomic
|
||||
* @brief Atomic auto-decrement.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to implementating the atomic auto-decrement and return the result of auto-decrement.
|
||||
* @attention
|
||||
* <ul>
|
||||
* <li>The pointer v must not be NULL.</li>
|
||||
* <li>The value which v point to must not be INT_MIN to avoid overflow after reducing 1.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param v [IN] The addSelf variable pointer.
|
||||
*
|
||||
* @retval #INT32 The return value of variable auto-decrement.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_atomic.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see
|
||||
* @since Huawei LiteOS V100R001C00
|
||||
*/
|
||||
STATIC INLINE INT32 HalAtomicDecRet(volatile INT32 *v)
|
||||
{
|
||||
INT32 val = 0;
|
||||
UINT32 status = 0;
|
||||
|
||||
do {
|
||||
__asm__ __volatile__("ldrex %0, [%3]\n"
|
||||
"sub %0, %0, #1\n"
|
||||
"strex %1, %0, [%3]"
|
||||
: "=&r"(val), "=&r"(status), "+m"(*v)
|
||||
: "r"(v)
|
||||
: "cc");
|
||||
} while (__builtin_expect(status != 0, 0));
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup los_atomic
|
||||
* @brief Atomic exchange for 32-bit variable with compare.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to implement the atomic exchange for 32-bit variable, if the value of variable is equal to oldVal.
|
||||
* @attention
|
||||
* <ul>The pointer v must not be NULL.</ul>
|
||||
*
|
||||
* @param v [IN] The variable pointer.
|
||||
* @param val [IN] The new value.
|
||||
* @param oldVal [IN] The old value.
|
||||
*
|
||||
* @retval TRUE The previous value of the atomic variable is not equal to oldVal.
|
||||
* @retval FALSE The previous value of the atomic variable is equal to oldVal.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_atomic.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see
|
||||
* @since Huawei LiteOS V100R001C00
|
||||
*/
|
||||
STATIC INLINE BOOL HalAtomicCmpXchg32bits(volatile INT32 *v, INT32 val, INT32 oldVal)
|
||||
{
|
||||
INT32 prevVal = 0;
|
||||
UINT32 status = 0;
|
||||
|
||||
do {
|
||||
__asm__ __volatile__("1: ldrex %0, %2\n"
|
||||
" mov %1, #0\n"
|
||||
" cmp %0, %3\n"
|
||||
" bne 2f\n"
|
||||
" strex %1, %4, %2\n"
|
||||
"2:"
|
||||
: "=&r"(prevVal), "=&r"(status), "+Q"(*v)
|
||||
: "r"(oldVal), "r"(val)
|
||||
: "cc");
|
||||
} while (__builtin_expect(status != 0, 0));
|
||||
|
||||
return prevVal != oldVal;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* LOS_ATOMIC_H */
|
||||
|
||||
325
kernel/arch/arm/cortex-m4/iar/los_context.h → kernel/arch/arm/cortex-m4/iar/los_arch_context.h
Executable file → Normal file
325
kernel/arch/arm/cortex-m4/iar/los_context.h → kernel/arch/arm/cortex-m4/iar/los_arch_context.h
Executable file → Normal file
@@ -1,194 +1,131 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup los_hw hardware
|
||||
* @ingroup kernel
|
||||
*/
|
||||
|
||||
#ifndef _LOS_HW_H
|
||||
#define _LOS_HW_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* *
|
||||
* @ingroup los_hw
|
||||
* The initialization value of stack space.
|
||||
*/
|
||||
#define EMPTY_STACK 0xCACA
|
||||
|
||||
/* *
|
||||
* @ingroup los_hw
|
||||
* Trigger a task.
|
||||
*/
|
||||
#define OsTaskTrap() __asm(" TRAP #31")
|
||||
|
||||
/* *
|
||||
* @ingroup los_hw
|
||||
* Check task schedule.
|
||||
*/
|
||||
#define LOS_CHECK_SCHEDULE ((!g_losTaskLock))
|
||||
|
||||
/* *
|
||||
* @ingroup los_hw
|
||||
* Define the type of a task context control block.
|
||||
*/
|
||||
typedef struct tagTskContext {
|
||||
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||
(defined(__FPU_USED) && (__FPU_USED == 1U)))
|
||||
UINT32 S16;
|
||||
UINT32 S17;
|
||||
UINT32 S18;
|
||||
UINT32 S19;
|
||||
UINT32 S20;
|
||||
UINT32 S21;
|
||||
UINT32 S22;
|
||||
UINT32 S23;
|
||||
UINT32 S24;
|
||||
UINT32 S25;
|
||||
UINT32 S26;
|
||||
UINT32 S27;
|
||||
UINT32 S28;
|
||||
UINT32 S29;
|
||||
UINT32 S30;
|
||||
UINT32 S31;
|
||||
#endif
|
||||
UINT32 uwR4;
|
||||
UINT32 uwR5;
|
||||
UINT32 uwR6;
|
||||
UINT32 uwR7;
|
||||
UINT32 uwR8;
|
||||
UINT32 uwR9;
|
||||
UINT32 uwR10;
|
||||
UINT32 uwR11;
|
||||
UINT32 uwPriMask;
|
||||
UINT32 uwR0;
|
||||
UINT32 uwR1;
|
||||
UINT32 uwR2;
|
||||
UINT32 uwR3;
|
||||
UINT32 uwR12;
|
||||
UINT32 uwLR;
|
||||
UINT32 uwPC;
|
||||
UINT32 uwxPSR;
|
||||
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||
(defined(__FPU_USED) && (__FPU_USED == 1U)))
|
||||
UINT32 S0;
|
||||
UINT32 S1;
|
||||
UINT32 S2;
|
||||
UINT32 S3;
|
||||
UINT32 S4;
|
||||
UINT32 S5;
|
||||
UINT32 S6;
|
||||
UINT32 S7;
|
||||
UINT32 S8;
|
||||
UINT32 S9;
|
||||
UINT32 S10;
|
||||
UINT32 S11;
|
||||
UINT32 S12;
|
||||
UINT32 S13;
|
||||
UINT32 S14;
|
||||
UINT32 S15;
|
||||
UINT32 FPSCR;
|
||||
UINT32 NO_NAME;
|
||||
#endif
|
||||
} TaskContext;
|
||||
|
||||
/* *
|
||||
* @ingroup los_hw
|
||||
* @brief: Task stack initialization.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to initialize the task stack.
|
||||
*
|
||||
* @attention:
|
||||
* <ul><li>None.</li></ul>
|
||||
*
|
||||
* @param taskID [IN] Type#UINT32: TaskID.
|
||||
* @param stackSize [IN] Type#UINT32: Total size of the stack.
|
||||
* @param topStack [IN] Type#VOID *: Top of task's stack.
|
||||
*
|
||||
* @retval: context Type#TaskContext *.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_hw.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
*/
|
||||
extern VOID *OsTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack);
|
||||
|
||||
/**
|
||||
* @ingroup los_hw
|
||||
* @brief: Function to task exit.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to exit task.
|
||||
*
|
||||
* @attention:
|
||||
* <ul><li>None.</li></ul>
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @retval: None.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_hw.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
*/
|
||||
LITE_OS_SEC_TEXT_MINOR VOID OsTaskExit(VOID);
|
||||
|
||||
/* *
|
||||
* @ingroup los_hw
|
||||
* @brief: The M3 wait interrupt instruction.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to make CPU enter to power-save mode.
|
||||
*
|
||||
* @attention:
|
||||
* <ul><li>None.</li></ul>
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @retval: None.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_hw.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
*/
|
||||
extern VOID OsEnterSleep(VOID);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _LOS_HW_H */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _LOS_ARCH_CONTEXT_H
|
||||
#define _LOS_ARCH_CONTEXT_H
|
||||
|
||||
#include "los_config.h"
|
||||
#include "los_compiler.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
typedef struct tagTskContext {
|
||||
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||
(defined(__FPU_USED) && (__FPU_USED == 1U)))
|
||||
UINT32 S16;
|
||||
UINT32 S17;
|
||||
UINT32 S18;
|
||||
UINT32 S19;
|
||||
UINT32 S20;
|
||||
UINT32 S21;
|
||||
UINT32 S22;
|
||||
UINT32 S23;
|
||||
UINT32 S24;
|
||||
UINT32 S25;
|
||||
UINT32 S26;
|
||||
UINT32 S27;
|
||||
UINT32 S28;
|
||||
UINT32 S29;
|
||||
UINT32 S30;
|
||||
UINT32 S31;
|
||||
#endif
|
||||
UINT32 uwR4;
|
||||
UINT32 uwR5;
|
||||
UINT32 uwR6;
|
||||
UINT32 uwR7;
|
||||
UINT32 uwR8;
|
||||
UINT32 uwR9;
|
||||
UINT32 uwR10;
|
||||
UINT32 uwR11;
|
||||
UINT32 uwPriMask;
|
||||
UINT32 uwR0;
|
||||
UINT32 uwR1;
|
||||
UINT32 uwR2;
|
||||
UINT32 uwR3;
|
||||
UINT32 uwR12;
|
||||
UINT32 uwLR;
|
||||
UINT32 uwPC;
|
||||
UINT32 uwxPSR;
|
||||
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||
(defined(__FPU_USED) && (__FPU_USED == 1U)))
|
||||
UINT32 S0;
|
||||
UINT32 S1;
|
||||
UINT32 S2;
|
||||
UINT32 S3;
|
||||
UINT32 S4;
|
||||
UINT32 S5;
|
||||
UINT32 S6;
|
||||
UINT32 S7;
|
||||
UINT32 S8;
|
||||
UINT32 S9;
|
||||
UINT32 S10;
|
||||
UINT32 S11;
|
||||
UINT32 S12;
|
||||
UINT32 S13;
|
||||
UINT32 S14;
|
||||
UINT32 S15;
|
||||
UINT32 FPSCR;
|
||||
UINT32 NO_NAME;
|
||||
#endif
|
||||
} TaskContext;
|
||||
|
||||
/**
|
||||
* @ingroup los_config
|
||||
* @brief: Task start running function.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to start a task.
|
||||
*
|
||||
* @attention:
|
||||
* <ul><li>None.</li></ul>
|
||||
*
|
||||
* @param: None.
|
||||
*
|
||||
* @retval None.
|
||||
*
|
||||
* @par Dependency:
|
||||
* <ul><li>los_config.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
*/
|
||||
extern VOID HalStartToRun(VOID);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
#endif /* _LOS_ARCH_CONTEXT_H */
|
||||
|
||||
1867
kernel/arch/arm/cortex-m4/iar/los_interrupt.h → kernel/arch/arm/cortex-m4/iar/los_arch_interrupt.h
Executable file → Normal file
1867
kernel/arch/arm/cortex-m4/iar/los_interrupt.h → kernel/arch/arm/cortex-m4/iar/los_arch_interrupt.h
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
54
kernel/arch/arm/cortex-m4/iar/los_arch_timer.h
Normal file
54
kernel/arch/arm/cortex-m4/iar/los_arch_timer.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _LOS_ARCH_TIMER_H
|
||||
#define _LOS_ARCH_TIMER_H
|
||||
|
||||
#include "los_config.h"
|
||||
#include "los_compiler.h"
|
||||
#include "los_context.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
UINT32 HalTickStart(OS_TICK_HANDLER handler);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
#endif /* _LOS_ARCH_TIMER_H */
|
||||
|
||||
47
kernel/arch/arm/cortex-m3/keil/los_hw.c → kernel/arch/arm/cortex-m4/iar/los_context.c
Executable file → Normal file
47
kernel/arch/arm/cortex-m3/keil/los_hw.c → kernel/arch/arm/cortex-m4/iar/los_context.c
Executable file → Normal file
@@ -28,10 +28,14 @@
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "los_config.h"
|
||||
#include "los_task.h"
|
||||
#include "securec.h"
|
||||
#include "ARMCM3.h"
|
||||
#include "los_interrupt.h"
|
||||
#include "los_arch_context.h"
|
||||
#include "los_arch_interrupt.h"
|
||||
#include "los_arch_timer.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
@@ -39,20 +43,32 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : OsTaskExit
|
||||
Function : HalArchInit
|
||||
Description : arch init function
|
||||
Input : None
|
||||
Output : None
|
||||
Return : None
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_INIT VOID HalArchInit()
|
||||
{
|
||||
HalHwiInit();
|
||||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : HalSysExit
|
||||
Description : Task exit function
|
||||
Input : None
|
||||
Output : None
|
||||
Return : None
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR VOID OsTaskExit(VOID)
|
||||
LITE_OS_SEC_TEXT_MINOR VOID HalSysExit(VOID)
|
||||
{
|
||||
LOS_IntLock();
|
||||
for(;;);
|
||||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : OsTskStackInit
|
||||
Function : HalTskStackInit
|
||||
Description : Task stack initialization function
|
||||
Input : taskID --- TaskID
|
||||
stackSize --- Total size of the stack
|
||||
@@ -60,7 +76,7 @@ LITE_OS_SEC_TEXT_MINOR VOID OsTaskExit(VOID)
|
||||
Output : None
|
||||
Return : Context pointer
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_INIT VOID *OsTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
|
||||
LITE_OS_SEC_TEXT_INIT VOID *HalTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
|
||||
{
|
||||
TaskContext *context = NULL;
|
||||
errno_t result;
|
||||
@@ -126,18 +142,27 @@ LITE_OS_SEC_TEXT_INIT VOID *OsTskStackInit(UINT32 taskID, UINT32 stackSize, VOID
|
||||
context->uwR2 = 0x02020202L;
|
||||
context->uwR3 = 0x03030303L;
|
||||
context->uwR12 = 0x12121212L;
|
||||
context->uwLR = (UINT32)(UINTPTR)OsTaskExit;
|
||||
context->uwLR = (UINT32)(UINTPTR)HalSysExit;
|
||||
context->uwPC = (UINT32)(UINTPTR)OsTaskEntry;
|
||||
context->uwxPSR = 0x01000000L;
|
||||
|
||||
return (VOID *)context;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT VOID OsEnterSleep(VOID)
|
||||
void HalBackTrace()
|
||||
{
|
||||
__DSB();
|
||||
__WFI();
|
||||
__ISB();
|
||||
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 HalStartSchedule(OS_TICK_HANDLER handler)
|
||||
{
|
||||
UINT32 ret;
|
||||
ret = HalTickStart(handler);
|
||||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
}
|
||||
HalStartToRun();
|
||||
return LOS_OK; /* never return */
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
34
kernel/arch/arm/cortex-m4/iar/los_dispatch.S
Executable file → Normal file
34
kernel/arch/arm/cortex-m4/iar/los_dispatch.S
Executable file → Normal file
@@ -31,15 +31,14 @@
|
||||
|
||||
PRESERVE8
|
||||
|
||||
EXPORT LOS_IntLock
|
||||
EXPORT LOS_IntUnLock
|
||||
EXPORT LOS_IntRestore
|
||||
EXPORT LOS_StartToRun
|
||||
EXPORT osTaskSchedule
|
||||
EXPORT osPendSV
|
||||
EXPORT HalIntLock
|
||||
EXPORT HalIntUnLock
|
||||
EXPORT HalIntRestore
|
||||
EXPORT HalStartToRun
|
||||
EXPORT HalTaskSchedule
|
||||
EXPORT HalPendSV
|
||||
|
||||
IMPORT g_losTask
|
||||
IMPORT g_taskSwitchHook
|
||||
IMPORT g_taskScheduled
|
||||
|
||||
OS_NVIC_INT_CTRL EQU 0xE000ED04
|
||||
@@ -52,7 +51,7 @@ OS_TASK_STATUS_RUNNING EQU 0x0010
|
||||
THUMB
|
||||
REQUIRE8
|
||||
|
||||
LOS_StartToRun
|
||||
HalStartToRun
|
||||
LDR R4, =OS_NVIC_SYSPRI2
|
||||
LDR R5, =OS_NVIC_PENDSV_PRI
|
||||
STR R5, [R4]
|
||||
@@ -93,38 +92,31 @@ LOS_StartToRun
|
||||
BX R6
|
||||
|
||||
|
||||
LOS_IntLock
|
||||
HalIntLock
|
||||
MRS R0, PRIMASK
|
||||
CPSID I
|
||||
BX LR
|
||||
|
||||
LOS_IntUnLock
|
||||
HalIntUnLock
|
||||
MRS R0, PRIMASK
|
||||
CPSIE I
|
||||
BX LR
|
||||
|
||||
LOS_IntRestore
|
||||
HalIntRestore
|
||||
MSR PRIMASK, R0
|
||||
BX LR
|
||||
|
||||
osTaskSchedule
|
||||
HalTaskSchedule
|
||||
LDR R0, =OS_NVIC_INT_CTRL
|
||||
LDR R1, =OS_NVIC_PENDSVSET
|
||||
STR R1, [R0]
|
||||
BX LR
|
||||
|
||||
osPendSV
|
||||
HalPendSV
|
||||
MRS R12, PRIMASK
|
||||
CPSID I
|
||||
|
||||
LDR R2, =g_taskSwitchHook
|
||||
LDR R2, [R2]
|
||||
CBZ R2, TaskSwitch
|
||||
PUSH {R12, LR}
|
||||
BLX R2
|
||||
POP {R12, LR}
|
||||
|
||||
TaskSwitch
|
||||
HalTaskSwitch
|
||||
MRS R0, PSP
|
||||
|
||||
STMFD R0!, {R4-R12}
|
||||
|
||||
30
kernel/arch/arm/cortex-m4/iar/los_hw_exc.S → kernel/arch/arm/cortex-m4/iar/los_exc.S
Executable file → Normal file
30
kernel/arch/arm/cortex-m4/iar/los_hw_exc.S → kernel/arch/arm/cortex-m4/iar/los_exc.S
Executable file → Normal file
@@ -33,16 +33,14 @@
|
||||
SECTION .text:CODE(2)
|
||||
THUMB
|
||||
|
||||
EXPORT OsExcNMI
|
||||
EXPORT OsExcHardFault
|
||||
EXPORT OsExcMemFault
|
||||
EXPORT OsExcBusFault
|
||||
EXPORT OsExcUsageFault
|
||||
EXPORT OsExcSvcCall
|
||||
EXPORT HalExcNMI
|
||||
EXPORT HalExcHardFault
|
||||
EXPORT HalExcMemFault
|
||||
EXPORT HalExcBusFault
|
||||
EXPORT HalExcUsageFault
|
||||
EXPORT HalExcSvcCall
|
||||
|
||||
IMPORT OsExcHandleEntry
|
||||
IMPORT g_vuwLosFlag
|
||||
IMPORT g_uwCurNestCount
|
||||
IMPORT HalExcHandleEntry
|
||||
IMPORT g_uwExcTbl
|
||||
IMPORT g_taskScheduled
|
||||
|
||||
@@ -66,12 +64,12 @@ OS_NVIC_ACT_BASE EQU 0xE000E300
|
||||
OS_NVIC_SHCSRS EQU 0xE000ED24
|
||||
OS_NVIC_SHCSR_MASK EQU 0xC00
|
||||
|
||||
OsExcNMI
|
||||
HalExcNMI
|
||||
MOV R0, #OS_EXC_CAUSE_NMI
|
||||
MOV R1, #0
|
||||
B osExcDispatch
|
||||
|
||||
OsExcHardFault
|
||||
HalExcHardFault
|
||||
MOV R0, #OS_EXC_CAUSE_HARDFAULT
|
||||
LDR R2, =OS_NVIC_HFSR
|
||||
LDR R2, [R2]
|
||||
@@ -122,7 +120,7 @@ osHFExcCommonBMU
|
||||
ORR R0, R0 ,R12
|
||||
B osExcDispatch
|
||||
|
||||
OsExcSvcCall
|
||||
HalExcSvcCall
|
||||
TST LR, #0x4
|
||||
ITE EQ
|
||||
MRSEQ R0, MSP
|
||||
@@ -132,7 +130,7 @@ OsExcSvcCall
|
||||
MOV R1, #0
|
||||
B osExcDispatch
|
||||
|
||||
OsExcBusFault
|
||||
HalExcBusFault
|
||||
LDR R0, =OS_NVIC_FSR
|
||||
LDR R0, [R0]
|
||||
|
||||
@@ -149,7 +147,7 @@ _ExcBusNoADDR
|
||||
MOV R12,#0
|
||||
B osExcCommonBMU
|
||||
|
||||
OsExcMemFault
|
||||
HalExcMemFault
|
||||
LDR R0, =OS_NVIC_FSR
|
||||
LDR R0, [R0]
|
||||
|
||||
@@ -166,7 +164,7 @@ _ExcMemNoADDR
|
||||
MOV R12,#0
|
||||
B osExcCommonBMU
|
||||
|
||||
OsExcUsageFault
|
||||
HalExcUsageFault
|
||||
LDR R0, =OS_NVIC_FSR
|
||||
LDR R0, [R0]
|
||||
|
||||
@@ -281,7 +279,7 @@ _handleEntry
|
||||
MOV R3, R13 ; R13:the 4th param
|
||||
CPSID I
|
||||
CPSID F
|
||||
B OsExcHandleEntry
|
||||
B HalExcHandleEntry
|
||||
|
||||
NOP
|
||||
END
|
||||
175
kernel/arch/arm/cortex-m4/iar/los_interrupt.c
Executable file → Normal file
175
kernel/arch/arm/cortex-m4/iar/los_interrupt.c
Executable file → Normal file
@@ -29,12 +29,11 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "los_interrupt.h"
|
||||
#include "los_context.h"
|
||||
#include "los_arch_interrupt.h"
|
||||
#include <stdarg.h>
|
||||
#include "los_debug.h"
|
||||
#include "los_task.h"
|
||||
#if (LOSCFG_KERNEL_TICKLESS == YES)
|
||||
#include "los_tick.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
@@ -43,99 +42,79 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*lint -save -e40 -e522 -e533*/
|
||||
__weak VOID SysTickHandler(VOID)
|
||||
{
|
||||
return;
|
||||
}
|
||||
UINT32 g_vuwIntCount = 0;
|
||||
|
||||
UINT32 g_intCount = 0;
|
||||
/*lint -restore*/
|
||||
#ifdef __ICCARM__
|
||||
#pragma location = ".data.vector"
|
||||
#pragma data_alignment=0x100
|
||||
#elif defined(__CC_ARM) || defined(__GNUC__)
|
||||
LITE_OS_SEC_VEC
|
||||
#endif
|
||||
HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {
|
||||
(HWI_PROC_FUNC)0, // [0] Top of Stack
|
||||
(HWI_PROC_FUNC)Reset_Handler, // [1] reset
|
||||
(HWI_PROC_FUNC)OsHwiDefaultHandler, // [2] NMI Handler
|
||||
(HWI_PROC_FUNC)OsHwiDefaultHandler, // [3] Hard Fault Handler
|
||||
(HWI_PROC_FUNC)OsHwiDefaultHandler, // [4] MPU Fault Handler
|
||||
(HWI_PROC_FUNC)OsHwiDefaultHandler, // [5] Bus Fault Handler
|
||||
(HWI_PROC_FUNC)OsHwiDefaultHandler, // [6] Usage Fault Handler
|
||||
(HWI_PROC_FUNC)0, // [7] Reserved
|
||||
(HWI_PROC_FUNC)0, // [8] Reserved
|
||||
(HWI_PROC_FUNC)0, // [9] Reserved
|
||||
(HWI_PROC_FUNC)0, // [10] Reserved
|
||||
(HWI_PROC_FUNC)OsHwiDefaultHandler, // [11] SVCall Handler
|
||||
(HWI_PROC_FUNC)OsHwiDefaultHandler, // [12] Debug Monitor Handler
|
||||
(HWI_PROC_FUNC)0, // [13] Reserved
|
||||
(HWI_PROC_FUNC)osPendSV, // [14] PendSV Handler
|
||||
(HWI_PROC_FUNC)SysTickHandler, // [15] SysTick Handler
|
||||
};
|
||||
HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
|
||||
|
||||
|
||||
|
||||
#if (OS_HWI_WITH_ARG == YES)
|
||||
#if (OS_HWI_WITH_ARG == 1)
|
||||
HWI_SLAVE_FUNC g_hwiSlaveForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
|
||||
#else
|
||||
HWI_PROC_FUNC g_hwiSlaveForm[OS_VECTOR_CNT] = {0};
|
||||
#endif
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : OsIntNumGet
|
||||
Function : HalIntNumGet
|
||||
Description : Get a interrupt number
|
||||
Input : None
|
||||
Output : None
|
||||
Return : Interrupt Indexes number
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR UINT32 OsIntNumGet(VOID)
|
||||
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
|
||||
{
|
||||
return __get_IPSR();
|
||||
}
|
||||
|
||||
inline UINT32 HalIsIntAcvive(VOID)
|
||||
{
|
||||
return (g_intCount > 0);
|
||||
}
|
||||
/* ****************************************************************************
|
||||
Function : OsHwiDefaultHandler
|
||||
Function : HalHwiDefaultHandler
|
||||
Description : default handler of the hardware interrupt
|
||||
Input : None
|
||||
Output : None
|
||||
Return : None
|
||||
**************************************************************************** */
|
||||
/*lint -e529*/
|
||||
LITE_OS_SEC_TEXT_MINOR VOID OsHwiDefaultHandler(VOID)
|
||||
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||
{
|
||||
UINT32 irqNum = OsIntNumGet();
|
||||
UINT32 irqNum = HalIntNumGet();
|
||||
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
|
||||
while (1) {}
|
||||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : OsInterrupt
|
||||
Function : HalInterrupt
|
||||
Description : Hardware interrupt entry function
|
||||
Input : None
|
||||
Output : None
|
||||
Return : None
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT VOID OsInterrupt(VOID)
|
||||
LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
||||
{
|
||||
UINT32 hwiIndex;
|
||||
UINT32 intSave;
|
||||
|
||||
#if (LOSCFG_KERNEL_RUNSTOP == YES)
|
||||
#if (LOSCFG_KERNEL_RUNSTOP == 1)
|
||||
SCB->SCR &= (UINT32) ~((UINT32)SCB_SCR_SLEEPDEEP_Msk);
|
||||
#endif
|
||||
|
||||
intSave = LOS_IntLock();
|
||||
|
||||
g_vuwIntCount++;
|
||||
g_intCount++;
|
||||
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
hwiIndex = OsIntNumGet();
|
||||
#if (LOSCFG_KERNEL_TICKLESS == YES)
|
||||
osUpdateKernelTickCount(hwiIndex);
|
||||
#endif
|
||||
hwiIndex = HalIntNumGet();
|
||||
|
||||
#if (OS_HWI_WITH_ARG == YES)
|
||||
#if (OS_HWI_WITH_ARG == 1)
|
||||
if (g_hwiSlaveForm[hwiIndex].pfnHandler != 0) {
|
||||
g_hwiSlaveForm[hwiIndex].pfnHandler((VOID *)g_hwiSlaveForm[hwiIndex].pParm);
|
||||
}
|
||||
@@ -145,12 +124,12 @@ LITE_OS_SEC_TEXT VOID OsInterrupt(VOID)
|
||||
}
|
||||
#endif
|
||||
intSave = LOS_IntLock();
|
||||
g_vuwIntCount--;
|
||||
g_intCount--;
|
||||
LOS_IntRestore(intSave);
|
||||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : LOS_HwiCreate
|
||||
Function : HalHwiCreate
|
||||
Description : create hardware interrupt
|
||||
Input : hwiNum --- hwi num to create
|
||||
hwiPrio --- priority of the hwi
|
||||
@@ -160,7 +139,7 @@ LITE_OS_SEC_TEXT VOID OsInterrupt(VOID)
|
||||
Output : None
|
||||
Return : LOS_OK on success or error code on failure
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 LOS_HwiCreate(HWI_HANDLE_T hwiNum,
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 HalHwiCreate(HWI_HANDLE_T hwiNum,
|
||||
HWI_PRIOR_T hwiPrio,
|
||||
HWI_MODE_T mode,
|
||||
HWI_PROC_FUNC handler,
|
||||
@@ -176,7 +155,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_HwiCreate(HWI_HANDLE_T hwiNum,
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)OsHwiDefaultHandler) {
|
||||
if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
|
||||
return OS_ERRNO_HWI_ALREADY_CREATED;
|
||||
}
|
||||
|
||||
@@ -185,7 +164,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_HwiCreate(HWI_HANDLE_T hwiNum,
|
||||
}
|
||||
|
||||
intSave = LOS_IntLock();
|
||||
#if (OS_HWI_WITH_ARG == YES)
|
||||
#if (OS_HWI_WITH_ARG == 1)
|
||||
OsSetVector(hwiNum, handler, arg);
|
||||
#else
|
||||
OsSetVector(hwiNum, handler);
|
||||
@@ -199,13 +178,13 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_HwiCreate(HWI_HANDLE_T hwiNum,
|
||||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : LOS_HwiDelete
|
||||
Function : HalHwiDelete
|
||||
Description : Delete hardware interrupt
|
||||
Input : hwiNum --- hwi num to delete
|
||||
Output : None
|
||||
Return : LOS_OK on success or error code on failure
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 LOS_HwiDelete(HWI_HANDLE_T hwiNum)
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 HalHwiDelete(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
UINT32 intSave;
|
||||
|
||||
@@ -217,7 +196,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_HwiDelete(HWI_HANDLE_T hwiNum)
|
||||
|
||||
intSave = LOS_IntLock();
|
||||
|
||||
g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsHwiDefaultHandler;
|
||||
g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
@@ -235,9 +214,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_HwiDelete(HWI_HANDLE_T hwiNum)
|
||||
|
||||
static ExcInfoArray g_excArray[OS_EXC_TYPE_MAX];
|
||||
|
||||
UINT32 g_curNestCount = 0;
|
||||
static ExcInfo g_excInfo;
|
||||
static EVENT_CB_S g_excEvent;
|
||||
static ExcInfo g_excInfo = {0};
|
||||
|
||||
UINT8 g_uwExcTbl[FAULT_STATUS_REG_BIT] = {
|
||||
0, 0, 0, 0, 0, 0, OS_EXC_UF_DIVBYZERO, OS_EXC_UF_UNALIGNED,
|
||||
@@ -246,19 +223,10 @@ UINT8 g_uwExcTbl[FAULT_STATUS_REG_BIT] = {
|
||||
0, 0, 0, OS_EXC_MF_MSTKERR, OS_EXC_MF_MUNSTKERR, 0, OS_EXC_MF_DACCVIOL, OS_EXC_MF_IACCVIOL
|
||||
};
|
||||
|
||||
__attribute__((noinline)) VOID LOS_Panic(const CHAR *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap,fmt);
|
||||
PRINT_ERR(fmt, ap);
|
||||
va_end(ap);
|
||||
asm volatile ("swi 0");
|
||||
}
|
||||
|
||||
UINT32 OsExcNvicDump(UINT32 index, UINT32 *excContent)
|
||||
UINT32 HalExcNvicDump(UINT32 index, UINT32 *excContent)
|
||||
{
|
||||
UINT32 *base = NULL;
|
||||
UINT32 len = 0,i,j;
|
||||
UINT32 len = 0, i, j;
|
||||
#define OS_NR_NVIC_EXC_DUMP_Types 7
|
||||
UINT32 rgNvicBases[OS_NR_NVIC_EXC_DUMP_Types] = {OS_NVIC_SETENA_BASE, OS_NVIC_SETPEND_BASE,
|
||||
OS_NVIC_INT_ACT_BASE, OS_NVIC_PRI_BASE, OS_NVIC_EXCPRI_BASE, OS_NVIC_SHCSR, OS_NVIC_INT_CTRL};
|
||||
@@ -286,9 +254,10 @@ UINT32 OsExcNvicDump(UINT32 index, UINT32 *excContent)
|
||||
}
|
||||
PRINTK("\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
UINT32 OsExcContextDump(UINT32 index, UINT32 *excContent)
|
||||
UINT32 HalExcContextDump(UINT32 index, UINT32 *excContent)
|
||||
{
|
||||
(VOID)index;
|
||||
(VOID)excContent;
|
||||
@@ -315,9 +284,10 @@ UINT32 OsExcContextDump(UINT32 index, UINT32 *excContent)
|
||||
PRINTK("LR = 0x%x\n", g_excInfo.context->uwLR);
|
||||
PRINTK("PC = 0x%x\n", g_excInfo.context->uwPC);
|
||||
PRINTK("xPSR = 0x%x\n", g_excInfo.context->uwxPSR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
VOID OsDumpMsg(VOID)
|
||||
VOID HalDumpMsg(VOID)
|
||||
{
|
||||
UINT32 index = 0;
|
||||
for (index = 0; index < (OS_EXC_TYPE_MAX - 1); index++) {
|
||||
@@ -328,21 +298,11 @@ VOID OsDumpMsg(VOID)
|
||||
}
|
||||
}
|
||||
|
||||
VOID OsExcNotify(VOID)
|
||||
{
|
||||
UINT32 ret = LOS_EventWrite(&g_excEvent, OS_EXC_EVENT);
|
||||
if (ret != LOS_OK) {
|
||||
PRINT_ERR("event notify failed\n");
|
||||
}
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT VOID OsExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid,
|
||||
EXC_CONTEXT_S *excBufAddr)
|
||||
LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr)
|
||||
{
|
||||
UINT16 tmpFlag = (excType >> 16) & OS_NULL_SHORT;
|
||||
g_curNestCount++;
|
||||
g_vuwIntCount++;
|
||||
g_excInfo.nestCnt = g_curNestCount;
|
||||
g_intCount++;
|
||||
g_excInfo.nestCnt++;
|
||||
|
||||
g_excInfo.type = excType & OS_NULL_SHORT;
|
||||
|
||||
@@ -351,7 +311,6 @@ LITE_OS_SEC_TEXT_INIT VOID OsExcHandleEntry(UINT32 excType, UINT32 faultAddr, UI
|
||||
} else {
|
||||
g_excInfo.faultAddr = OS_EXC_IMPRECISE_ACCESS_ADDR;
|
||||
}
|
||||
|
||||
if (g_losTask.runTask != NULL) {
|
||||
if (tmpFlag & OS_EXC_FLAG_IN_HWI) {
|
||||
g_excInfo.phase = OS_EXC_IN_HWI;
|
||||
@@ -364,25 +323,20 @@ LITE_OS_SEC_TEXT_INIT VOID OsExcHandleEntry(UINT32 excType, UINT32 faultAddr, UI
|
||||
g_excInfo.phase = OS_EXC_IN_INIT;
|
||||
g_excInfo.thrdPid = OS_NULL_INT;
|
||||
}
|
||||
|
||||
if (excType & OS_EXC_FLAG_NO_FLOAT) {
|
||||
g_excInfo.context = (EXC_CONTEXT_S *)((CHAR *)excBufAddr - LOS_OFF_SET_OF(EXC_CONTEXT_S, uwR4));
|
||||
} else {
|
||||
g_excInfo.context = excBufAddr;
|
||||
}
|
||||
|
||||
OsDumpMsg();
|
||||
|
||||
OsExcNotify();
|
||||
|
||||
LOS_Reboot();
|
||||
HalDumpMsg();
|
||||
HalSysExit();
|
||||
}
|
||||
|
||||
VOID OsExcRegister(ExcInfoType type, EXC_INFO_SAVE_CALLBACK func, VOID *arg)
|
||||
VOID HalExcRegister(ExcInfoType type, EXC_INFO_SAVE_CALLBACK func, VOID *arg)
|
||||
{
|
||||
ExcInfoArray *excInfo = NULL;
|
||||
if ((type >= OS_EXC_TYPE_MAX) || (func == NULL)) {
|
||||
PRINT_ERR("OsExcRegister ERROR!\n");
|
||||
PRINT_ERR("HalExcRegister ERROR!\n");
|
||||
return;
|
||||
}
|
||||
excInfo = &(g_excArray[type]);
|
||||
@@ -392,33 +346,29 @@ VOID OsExcRegister(ExcInfoType type, EXC_INFO_SAVE_CALLBACK func, VOID *arg)
|
||||
excInfo->uwValid = TRUE;
|
||||
}
|
||||
|
||||
void OsBackTrace()
|
||||
{
|
||||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : OsHwiInit
|
||||
Function : HalHwiInit
|
||||
Description : initialization of the hardware interrupt
|
||||
Input : None
|
||||
Output : None
|
||||
Return : None
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_INIT VOID OsHwiInit()
|
||||
LITE_OS_SEC_TEXT_INIT VOID HalHwiInit()
|
||||
{
|
||||
UINT32 index;
|
||||
UINT32 ret;
|
||||
|
||||
for (index = OS_SYS_VECTOR_CNT; index < OS_VECTOR_CNT; index++) {
|
||||
g_hwiForm[index] = (HWI_PROC_FUNC)OsHwiDefaultHandler;
|
||||
g_hwiForm[0] = 0; /* [0] Top of Stack */
|
||||
g_hwiForm[1] = Reset_Handler; /* [1] reset */
|
||||
for (index = 2; index < OS_VECTOR_CNT; index++) {
|
||||
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||
}
|
||||
|
||||
/* Exception handler register */
|
||||
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = OsExcHardFault;
|
||||
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = OsExcNMI;
|
||||
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = OsExcMemFault;
|
||||
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = OsExcBusFault;
|
||||
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = OsExcUsageFault;
|
||||
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = OsExcSvcCall;
|
||||
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI;
|
||||
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault;
|
||||
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault;
|
||||
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault;
|
||||
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault;
|
||||
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalExcSvcCall;
|
||||
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV;
|
||||
|
||||
/* Interrupt vector table location */
|
||||
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
|
||||
@@ -431,15 +381,8 @@ LITE_OS_SEC_TEXT_INIT VOID OsHwiInit()
|
||||
/* Enable DIV 0 and unaligned exception */
|
||||
*(volatile UINT32 *)OS_NVIC_CCR |= DIV0FAULT;
|
||||
|
||||
/* Init Exception Event */
|
||||
ret = LOS_EventInit(&g_excEvent);
|
||||
if (ret != LOS_OK) {
|
||||
PRINT_ERR("[EXC]init excepiton event failed!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
OsExcRegister(OS_EXC_TYPE_CONTEXT, (EXC_INFO_SAVE_CALLBACK)OsExcContextDump, NULL);
|
||||
OsExcRegister(OS_EXC_TYPE_NVIC, (EXC_INFO_SAVE_CALLBACK)OsExcNvicDump, NULL);
|
||||
HalExcRegister(OS_EXC_TYPE_CONTEXT, (EXC_INFO_SAVE_CALLBACK)HalExcContextDump, NULL);
|
||||
HalExcRegister(OS_EXC_TYPE_NVIC, (EXC_INFO_SAVE_CALLBACK)HalExcNvicDump, NULL);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
94
kernel/arch/arm/cortex-m4/iar/los_hw_tick.c → kernel/arch/arm/cortex-m4/iar/los_timer.c
Executable file → Normal file
94
kernel/arch/arm/cortex-m4/iar/los_hw_tick.c → kernel/arch/arm/cortex-m4/iar/los_timer.c
Executable file → Normal file
@@ -28,28 +28,27 @@
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "los_config.h"
|
||||
#include "los_tick.h"
|
||||
#include "los_interrupt.h"
|
||||
#include "los_arch_interrupt.h"
|
||||
#include "los_timer.h"
|
||||
#include "los_context.h"
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
#define TICK_CHECK 0x4000000
|
||||
#define CYCLE_CHECK 0xFFFFFFFFU
|
||||
#define SHIFT_32_BIT 32
|
||||
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : OsTickStart
|
||||
Function : HalTickStart
|
||||
Description : Configure Tick Interrupt Start
|
||||
Input : none
|
||||
output : none
|
||||
return : LOS_OK - Success , or LOS_ERRNO_TICK_CFG_INVALID - failed
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 OsTickStart(VOID)
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 HalTickStart(OS_TICK_HANDLER *handler)
|
||||
{
|
||||
UINT32 ret;
|
||||
|
||||
@@ -59,10 +58,10 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsTickStart(VOID)
|
||||
return LOS_ERRNO_TICK_CFG_INVALID;
|
||||
}
|
||||
|
||||
#if (OS_HWI_WITH_ARG == YES)
|
||||
OsSetVector(SysTick_IRQn, (HWI_PROC_FUNC)OsTickHandler, NULL);
|
||||
#if (OS_HWI_WITH_ARG == 1)
|
||||
OsSetVector(SysTick_IRQn, (HWI_PROC_FUNC)handler, NULL);
|
||||
#else
|
||||
OsSetVector(SysTick_IRQn, OsTickHandler);
|
||||
OsSetVector(SysTick_IRQn, (HWI_PROC_FUNC)handler);
|
||||
#endif
|
||||
|
||||
g_cyclesPerTick = OS_SYS_CLOCK / LOSCFG_BASE_CORE_TICK_PER_SECOND;
|
||||
@@ -76,32 +75,14 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsTickStart(VOID)
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
#if (LOSCFG_KERNEL_TICKLESS == YES)
|
||||
/* ****************************************************************************
|
||||
Function : LOS_SysTickReload
|
||||
Description : reconfig systick, and clear SysTick_IRQn
|
||||
Input : cyclesPerTick --- cycles Per Tick
|
||||
output : none
|
||||
return : none
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR VOID LOS_SysTickReload(UINT32 cyclesPerTick)
|
||||
{
|
||||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
||||
SysTick->LOAD = (UINT32)(cyclesPerTick - 1UL); /* set reload register */
|
||||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : LOS_SysTickCurrCycleGet
|
||||
Function : HalSysTickCurrCycleGet
|
||||
Description : Get System cycle count
|
||||
Input : none
|
||||
output : none
|
||||
return : hwCycle --- the system cycle count
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR UINT32 LOS_SysTickCurrCycleGet(VOID)
|
||||
LITE_OS_SEC_TEXT_MINOR UINT32 HalSysTickCurrCycleGet(VOID)
|
||||
{
|
||||
UINT32 hwCycle;
|
||||
UINTPTR intSave;
|
||||
@@ -121,14 +102,14 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_SysTickCurrCycleGet(VOID)
|
||||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : LOS_GetCpuCycle
|
||||
Function : HalGetCpuCycle
|
||||
Description : Get System cycle count
|
||||
Input : none
|
||||
output : cntHi --- CpuTick High 4 byte
|
||||
cntLo --- CpuTick Low 4 byte
|
||||
return : none
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR VOID LOS_GetCpuCycle(UINT32 *cntHi, UINT32 *cntLo)
|
||||
LITE_OS_SEC_TEXT_MINOR VOID HalGetCpuCycle(UINT32 *cntHi, UINT32 *cntLo)
|
||||
{
|
||||
UINT64 swTick;
|
||||
UINT64 cycle;
|
||||
@@ -157,14 +138,14 @@ LITE_OS_SEC_TEXT_MINOR VOID LOS_GetCpuCycle(UINT32 *cntHi, UINT32 *cntLo)
|
||||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : LOS_GetSystickCycle
|
||||
Function : HalGetSystickCycle
|
||||
Description : Get Sys tick cycle count
|
||||
Input : none
|
||||
output : cntHi --- SysTick count High 4 byte
|
||||
cntLo --- SysTick count Low 4 byte
|
||||
return : none
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR VOID LOS_GetSystickCycle(UINT32 *cntHi, UINT32 *cntLo)
|
||||
LITE_OS_SEC_TEXT_MINOR VOID HalGetSystickCycle(UINT32 *cntHi, UINT32 *cntLo)
|
||||
{
|
||||
UINT64 swTick;
|
||||
UINT64 cycle;
|
||||
@@ -200,62 +181,49 @@ LITE_OS_SEC_TEXT_MINOR VOID LOS_GetSystickCycle(UINT32 *cntHi, UINT32 *cntLo)
|
||||
return;
|
||||
}
|
||||
|
||||
#define MAX_HOUR 24
|
||||
#define MAX_MINUTES 60
|
||||
#define MAX_SECONDS 60
|
||||
#define MILSEC 1000
|
||||
#define RTC_WAKEUPCLOCK_RTCCLK 32768
|
||||
#define RTC_WAKEUPCLOCK_RTCCLK_DIV 16
|
||||
#define RTC_CALIBRATE_SLEEP_TIME 8
|
||||
#define MACHINE_CYCLE_DEALAY_TIMES 4000
|
||||
|
||||
static BOOL g_sysSleepFlag = FALSE;
|
||||
|
||||
VOID LOS_TickLock(VOID)
|
||||
VOID HalTickLock(VOID)
|
||||
{
|
||||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||
}
|
||||
|
||||
VOID LOS_TickUnlock(VOID)
|
||||
VOID HalTickUnlock(VOID)
|
||||
{
|
||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||
}
|
||||
|
||||
BOOL LOS_GetSysSleepFlag(VOID)
|
||||
BOOL HalGetSysSleepFlag(VOID)
|
||||
{
|
||||
return g_sysSleepFlag;
|
||||
}
|
||||
|
||||
VOID LOS_ClearSysSleepFlag(VOID)
|
||||
VOID HalClearSysSleepFlag(VOID)
|
||||
{
|
||||
g_sysSleepFlag = FALSE;
|
||||
}
|
||||
|
||||
VOID LOS_EnterSleep(LOS_SysSleepEnum sleep)
|
||||
VOID HalEnterSleep(LOS_SysSleepEnum sleep)
|
||||
{
|
||||
__DSB();
|
||||
__WFI();
|
||||
__ISB();
|
||||
}
|
||||
|
||||
VOID LOS_SystemWakeup(UINT32 hwiIndex)
|
||||
{
|
||||
}
|
||||
//extern unsigned int SystemCoreClock;
|
||||
void LOS_HalDelay(UINT32 ticks)
|
||||
void HalDelay(UINT32 ticks)
|
||||
{
|
||||
UINT32 delayTimes;
|
||||
#if 0
|
||||
/* there are 4 machine cycle in loop */
|
||||
if ((ticks * (SystemCoreClock / MACHINE_CYCLE_DEALAY_TIMES)) >= 0xffffffff) {
|
||||
delayTimes = 0xffffffff;
|
||||
} else {
|
||||
delayTimes = ticks * (SystemCoreClock / MACHINE_CYCLE_DEALAY_TIMES);
|
||||
}
|
||||
|
||||
while (delayTimes) {
|
||||
delayTimes = delayTimes - 1;
|
||||
}
|
||||
UINT32 delayTimes;
|
||||
/* there are 4 machine cycle in loop */
|
||||
if ((ticks * (SystemCoreClock / MACHINE_CYCLE_DEALAY_TIMES)) >= 0xffffffff) {
|
||||
delayTimes = 0xffffffff;
|
||||
} else {
|
||||
delayTimes = ticks * (SystemCoreClock / MACHINE_CYCLE_DEALAY_TIMES);
|
||||
}
|
||||
while (delayTimes) {
|
||||
delayTimes = delayTimes - 1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
56
kernel/arch/include/los_arch.h
Normal file
56
kernel/arch/include/los_arch.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _LOS_ARCH_H
|
||||
#define _LOS_ARCH_H
|
||||
|
||||
#include "los_config.h"
|
||||
#include "los_compiler.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
|
||||
VOID HalArchInit();
|
||||
void HalBackTrace();
|
||||
#define LOS_BackTrace HalBackTrace
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
#endif /* _LOS_ARCH_H */
|
||||
|
||||
51
kernel/arch/include/los_atomic.h
Normal file
51
kernel/arch/include/los_atomic.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef LOS_ATOMIC_H
|
||||
#define LOS_ATOMIC_H
|
||||
|
||||
#include "los_compiler.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* LOS_ATOMIC_H */
|
||||
|
||||
127
kernel/arch/include/los_context.h
Normal file
127
kernel/arch/include/los_context.h
Normal file
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup los_hw hardware
|
||||
* @ingroup kernel
|
||||
*/
|
||||
|
||||
#ifndef _LOS_HW_H
|
||||
#define _LOS_HW_H
|
||||
|
||||
#include "los_compiler.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* *
|
||||
* @ingroup los_hw
|
||||
* @brief: Task stack initialization.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to initialize the task stack.
|
||||
*
|
||||
* @attention:
|
||||
* <ul><li>None.</li></ul>
|
||||
*
|
||||
* @param taskID [IN] Type#UINT32: TaskID.
|
||||
* @param stackSize [IN] Type#UINT32: Total size of the stack.
|
||||
* @param topStack [IN] Type#VOID *: Top of task's stack.
|
||||
*
|
||||
* @retval: context Type#TaskContext *.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_hw.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
*/
|
||||
extern VOID *HalTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack);
|
||||
/**
|
||||
* @ingroup los_hw
|
||||
* @brief: Function to sys exit.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to sys exit.
|
||||
*
|
||||
* @attention:
|
||||
* <ul><li>None.</li></ul>
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @retval: None.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_hw.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
*/
|
||||
LITE_OS_SEC_TEXT_MINOR VOID HalSysExit(VOID);
|
||||
|
||||
/* *
|
||||
* @ingroup los_context
|
||||
* @brief: Task scheduling Function.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to scheduling task.
|
||||
*
|
||||
* @attention:
|
||||
* <ul><li>None.</li></ul>
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @retval: None.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_context.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
*/
|
||||
extern VOID HalTaskSchedule(VOID);
|
||||
|
||||
typedef VOID (*OS_TICK_HANDLER)(VOID);
|
||||
UINT32 HalStartSchedule(OS_TICK_HANDLER handler);
|
||||
|
||||
UINTPTR HalIntLock(VOID);
|
||||
#define LOS_IntLock HalIntLock
|
||||
|
||||
VOID HalIntRestore(UINTPTR intSave);
|
||||
#define LOS_IntRestore HalIntRestore
|
||||
|
||||
UINTPTR HalIntUnLock(VOID);
|
||||
#define LOS_IntUnLock HalIntUnLock
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _LOS_HW_H */
|
||||
|
||||
156
kernel/arch/include/los_interrupt.h
Normal file
156
kernel/arch/include/los_interrupt.h
Normal file
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _LOS_INTERRUPT_H
|
||||
#define _LOS_INTERRUPT_H
|
||||
#include "los_config.h"
|
||||
#include "los_compiler.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* *
|
||||
* @ingroup los_config
|
||||
* Configuration item for interrupt with argument
|
||||
*/
|
||||
#ifndef OS_HWI_WITH_ARG
|
||||
#define OS_HWI_WITH_ARG 0
|
||||
#endif
|
||||
|
||||
typedef UINT32 HWI_HANDLE_T;
|
||||
|
||||
typedef UINT16 HWI_PRIOR_T;
|
||||
|
||||
typedef UINT16 HWI_MODE_T;
|
||||
|
||||
typedef UINT32 HWI_ARG_T;
|
||||
|
||||
typedef enum {
|
||||
OS_EXC_TYPE_CONTEXT = 0,
|
||||
OS_EXC_TYPE_TSK = 1,
|
||||
OS_EXC_TYPE_QUE = 2,
|
||||
OS_EXC_TYPE_NVIC = 3,
|
||||
OS_EXC_TYPE_TSK_SWITCH = 4,
|
||||
OS_EXC_TYPE_MEM = 5,
|
||||
OS_EXC_TYPE_MAX = 6
|
||||
} ExcInfoType;
|
||||
|
||||
typedef UINT32 (*EXC_INFO_SAVE_CALLBACK)(UINT32, VOID*);
|
||||
|
||||
#if (OS_HWI_WITH_ARG == 1)
|
||||
typedef VOID (*HWI_PROC_FUNC)(VOID *parm);
|
||||
typedef struct {
|
||||
HWI_PROC_FUNC pfnHandler;
|
||||
VOID *pParm;
|
||||
} HWI_SLAVE_FUNC;
|
||||
|
||||
#else
|
||||
|
||||
typedef VOID (*HWI_PROC_FUNC)(void);
|
||||
|
||||
#endif
|
||||
UINT32 HalIsIntAcvive(VOID);
|
||||
#define OS_INT_ACTIVE (HalIsIntAcvive())
|
||||
#define OS_INT_INACTIVE (!(OS_INT_ACTIVE))
|
||||
|
||||
VOID HalExcRegister(ExcInfoType type, EXC_INFO_SAVE_CALLBACK func, VOID *arg);
|
||||
/* *
|
||||
* @ingroup los_hwi
|
||||
* @brief Delete hardware interrupt.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to delete hardware interrupt.
|
||||
*
|
||||
* @attention
|
||||
* <ul>
|
||||
* <li>The hardware interrupt module is usable only when the configuration item for hardware interrupt tailoring is enabled.</li>
|
||||
* <li>Hardware interrupt number value range: [OS_USER_HWI_MIN,OS_USER_HWI_MAX]. The value range applicable for a Cortex-A7 platform is [32,95].</li>
|
||||
* <li>OS_HWI_MAX_NUM specifies the maximum number of interrupts that can be created.</li>
|
||||
* <li>Before executing an interrupt on a platform, refer to the chip manual of the platform.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param hwiNum [IN] Type#HWI_HANDLE_T: hardware interrupt number. The value range applicable for a Cortex-A7 platform is [32,95].
|
||||
*
|
||||
* @retval #OS_ERRNO_HWI_NUM_INVALID 0x02000900: Invalid interrupt number.
|
||||
* @retval #LOS_OK 0 : The interrupt is successfully delete.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
*/
|
||||
extern UINT32 HalHwiDelete(HWI_HANDLE_T hwiNum);
|
||||
|
||||
/* *
|
||||
* @ingroup los_hwi
|
||||
* @brief Create a hardware interrupt.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to configure a hardware interrupt and register a hardware interrupt handling function.
|
||||
*
|
||||
* @attention
|
||||
* <ul>
|
||||
* <li>The hardware interrupt module is usable only when the configuration item for hardware interrupt tailoring is enabled.</li>
|
||||
* <li>Hardware interrupt number value range: [OS_USER_HWI_MIN,OS_USER_HWI_MAX]. The value range applicable for a Cortex-A7 platform is [32,95].</li>
|
||||
* <li>OS_HWI_MAX_NUM specifies the maximum number of interrupts that can be created.</li>
|
||||
* <li>Before executing an interrupt on a platform, refer to the chip manual of the platform.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param hwiNum [IN] Type#HWI_HANDLE_T: hardware interrupt number. The value range applicable for a Cortex-A7 platform is [32,95].
|
||||
* @param hwiPrio [IN] Type#HWI_PRIOR_T: hardware interrupt priority. Ignore this parameter temporarily.
|
||||
* @param mode [IN] Type#HWI_MODE_T: hardware interrupt mode. Ignore this parameter temporarily.
|
||||
* @param handler [IN] Type#HWI_PROC_FUNC: interrupt handler used when a hardware interrupt is triggered.
|
||||
* @param arg [IN] Type#HWI_ARG_T: input parameter of the interrupt handler used when a hardware interrupt is triggered.
|
||||
*
|
||||
* @retval #OS_ERRNO_HWI_PROC_FUNC_NULL 0x02000901: Null hardware interrupt handling function.
|
||||
* @retval #OS_ERRNO_HWI_NUM_INVALID 0x02000900: Invalid interrupt number.
|
||||
* @retval #OS_ERRNO_HWI_NO_MEMORY 0x02000903: Insufficient memory for hardware interrupt creation.
|
||||
* @retval #OS_ERRNO_HWI_ALREADY_CREATED 0x02000904: The interrupt handler being created has already been created.
|
||||
* @retval #LOS_OK 0 : The interrupt is successfully created.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
*/
|
||||
extern UINT32 HalHwiCreate(HWI_HANDLE_T hwiNum,
|
||||
HWI_PRIOR_T hwiPrio,
|
||||
HWI_MODE_T mode,
|
||||
HWI_PROC_FUNC handler,
|
||||
HWI_ARG_T arg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _LOS_INTERRUPT_H */
|
||||
|
||||
193
kernel/arch/include/los_timer.h
Normal file
193
kernel/arch/include/los_timer.h
Normal file
@@ -0,0 +1,193 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#define TICK_CHECK 0x4000000
|
||||
#define CYCLE_CHECK 0xFFFFFFFFU
|
||||
#define SHIFT_32_BIT 32
|
||||
#define MAX_HOUR 24
|
||||
#define MAX_MINUTES 60
|
||||
#define MAX_SECONDS 60
|
||||
#define MILSEC 1000
|
||||
#define RTC_WAKEUPCLOCK_RTCCLK 32768
|
||||
#define RTC_WAKEUPCLOCK_RTCCLK_DIV 16
|
||||
#define RTC_CALIBRATE_SLEEP_TIME 8
|
||||
#define MACHINE_CYCLE_DEALAY_TIMES 4000
|
||||
|
||||
typedef enum {
|
||||
OS_SYS_NORMAL_SLEEP = 0,
|
||||
OS_SYS_DEEP_SLEEP,
|
||||
} LOS_SysSleepEnum;
|
||||
|
||||
VOID HalTickLock(VOID);
|
||||
|
||||
VOID HalTickUnlock(VOID);
|
||||
|
||||
BOOL HalGetSysSleepFlag(VOID);
|
||||
|
||||
VOID HalClearSysSleepFlag(VOID);
|
||||
|
||||
|
||||
VOID HalEnterSleep(LOS_SysSleepEnum sleep);
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup los_timer
|
||||
* @brief Configure Tick Interrupt Start.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to configure Tick Interrupt Start while macro LOSCFG_BASE_CORE_TICK_HW_TIME is No.
|
||||
*
|
||||
* @attention
|
||||
* <ul>
|
||||
* <li>None.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param: None.
|
||||
*
|
||||
* @retval #LOS_OK 0:configure Tick Interrupt success.
|
||||
* @retval #LOS_ERRNO_TICK_CFG_INVALID 0x02000400:configure Tick Interrupt failed.
|
||||
*
|
||||
* @par Dependency:
|
||||
* <ul><li>los_config.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see
|
||||
*/
|
||||
|
||||
#if (LOSCFG_KERNEL_TICKLESS == YES)
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* @brief reconfig systick, and clear SysTick_IRQn.
|
||||
*
|
||||
* @par Description:
|
||||
* <ul>
|
||||
* <li>This API is used to reconfig systick, and clear SysTick_IRQn.</li>
|
||||
* </ul>
|
||||
* @attention
|
||||
* <ul>
|
||||
* <li>None.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param cyclesPerTick [IN] Cycles Per Tick
|
||||
*
|
||||
* @retval None.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see LOS_IntRestore
|
||||
*/
|
||||
extern VOID HalSysTickReload(UINT32 cyclesPerTick);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* @brief Get System cycle count.
|
||||
*
|
||||
* @par Description:
|
||||
* <ul>
|
||||
* <li>This API is used to Get System cycle count.</li>
|
||||
* </ul>
|
||||
* @attention
|
||||
* <ul>
|
||||
* <li>None.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @retval: The value of the system cycle count.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see LOS_IntRestore
|
||||
*/
|
||||
extern UINT32 HalSysTickCurrCycleGet(VOID);
|
||||
|
||||
|
||||
/* *
|
||||
* @ingroup los_hwi
|
||||
* @brief Get value from xPSR register.
|
||||
*
|
||||
* @par Description:
|
||||
* <ul>
|
||||
* <li>This API is used to Get value from xPSR register.</li>
|
||||
* </ul>
|
||||
* @attention
|
||||
* <ul>
|
||||
* <li>None.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param cntHi [IN] CpuTick High 4 byte
|
||||
* @param cntLo [IN] CpuTick Low 4 byte
|
||||
*
|
||||
* @retval None.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see LOS_IntRestore
|
||||
*/
|
||||
extern VOID HalGetCpuCycle(UINT32 *cntHi, UINT32 *cntLo);
|
||||
|
||||
|
||||
|
||||
extern VOID HalGetSystickCycle(UINT32 *puwCntHi, UINT32 *puwCntLo);
|
||||
|
||||
/**
|
||||
* @ingroup los_tickless
|
||||
* @brief enable the tickless mode.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to enable the tickless mode. System can change from periodic clock mode to dynamic clock mode.
|
||||
*
|
||||
* @attention
|
||||
* <ul>
|
||||
* </ul>
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @retval None.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_tickless.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see LOS_TicklessDisable
|
||||
*/
|
||||
extern VOID HalTicklessEnable(VOID);
|
||||
/**
|
||||
* @ingroup los_tickless
|
||||
* @brief disable the tickless mode.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to diable the tickless mode. System will not change from periodic clock mode to dynamic clock mode.
|
||||
*
|
||||
* @attention
|
||||
* <ul>
|
||||
* </ul>
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @retval None.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_tickless.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see LOS_TicklessEnable
|
||||
*/
|
||||
extern VOID HalTicklessDisable(VOID);
|
||||
0
kernel/arch/risc-v/asm/soc_common.h
Executable file → Normal file
0
kernel/arch/risc-v/asm/soc_common.h
Executable file → Normal file
21
kernel/arch/risc-v/los_context.h → kernel/arch/risc-v/los_arch_context.h
Executable file → Normal file
21
kernel/arch/risc-v/los_context.h → kernel/arch/risc-v/los_arch_context.h
Executable file → Normal file
@@ -29,10 +29,11 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _LOS_HW_H
|
||||
#define _LOS_HW_H
|
||||
#ifndef _LOS_ARCH_CONTEXT_H
|
||||
#define _LOS_ARCH_CONTEXT_H
|
||||
|
||||
#include "los_compiler.h"
|
||||
#include "los_context.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
@@ -46,12 +47,6 @@ extern "C" {
|
||||
*/
|
||||
#define EMPTY_STACK 0xCACA
|
||||
|
||||
/**
|
||||
* @ingroup los_hw
|
||||
* Check task schedule.
|
||||
*/
|
||||
#define LOS_CHECK_SCHEDULE ((!g_losTaskLock) && (!OS_INT_ACTIVE))
|
||||
|
||||
#define TP_INIT_VALUE 0x02020202L
|
||||
#define SP_INIT_VALUE 0x03030303L
|
||||
#define S11_INIT_VALUE 0x04040404L
|
||||
@@ -127,8 +122,14 @@ STATIC INLINE UINTPTR GetSP(VOID)
|
||||
return spSave;
|
||||
}
|
||||
|
||||
extern VOID *OsTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack);
|
||||
extern VOID OsTaskScheduleCheck(VOID);
|
||||
STATIC INLINE UINTPTR GetFp(VOID)
|
||||
{
|
||||
UINTPTR fpSave = 0;
|
||||
__asm__ __volatile__("mv %0, s0" : "=r"(fpSave));
|
||||
return fpSave;
|
||||
}
|
||||
|
||||
extern VOID HalStartToRun(VOID);
|
||||
|
||||
/**
|
||||
* @ingroup los_hw
|
||||
288
kernel/arch/risc-v/los_arch_interrupt.h
Normal file
288
kernel/arch/risc-v/los_arch_interrupt.h
Normal file
@@ -0,0 +1,288 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef _LOS_HWI_H
|
||||
#define _LOS_HWI_H
|
||||
|
||||
#include "los_compiler.h"
|
||||
#include "los_config.h"
|
||||
#include "los_interrupt.h"
|
||||
#include "los_arch_context.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Define the type of a hardware interrupt vector table function.
|
||||
*/
|
||||
typedef struct tagHwiHandleForm {
|
||||
HWI_PROC_FUNC pfnHook;
|
||||
VOID *uwParam;
|
||||
UINTPTR uwreserved;
|
||||
} HWI_HANDLE_FORM_S;
|
||||
|
||||
typedef struct {
|
||||
UINT32 mcause;
|
||||
UINT32 mtval;
|
||||
UINT32 medeleg;
|
||||
UINT32 gp;
|
||||
TaskContext taskContext;
|
||||
} LosExcContext;
|
||||
|
||||
typedef struct {
|
||||
UINT16 nestCnt;
|
||||
UINT16 type;
|
||||
UINT32 thrID;
|
||||
LosExcContext *context;
|
||||
} LosExcInfo;
|
||||
|
||||
typedef UINT32 (*EXC_INFO_SAVE_CALLBACK)(UINT32, VOID*);
|
||||
|
||||
typedef struct {
|
||||
ExcInfoType uwType;
|
||||
UINT32 uwValid;
|
||||
EXC_INFO_SAVE_CALLBACK pFnExcInfoCb;
|
||||
VOID* pArg;
|
||||
} ExcInfoArray;
|
||||
|
||||
#define MAX_EXC_MEM_SIZE 0
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Highest priority of a hardware interrupt.
|
||||
*/
|
||||
#define OS_HWI_PRIO_HIGHEST 7
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Lowest priority of a hardware interrupt.
|
||||
*/
|
||||
#define OS_HWI_PRIO_LOWEST 1
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Count of HimiDeer system interrupt vector.
|
||||
*/
|
||||
#define OS_RISCV_SYS_VECTOR_CNT (RISCV_SYS_MAX_IRQ + 1)
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Count of HimiDeer local interrupt vector 0 - 5, enabled by CSR mie 26 -31 bit.
|
||||
*/
|
||||
#define OS_RISCV_MIE_IRQ_VECTOR_CNT 6
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Count of HimiDeer local interrupt vector 6 - 31, enabled by custom CSR locie0 0 - 25 bit.
|
||||
*/
|
||||
#define OS_RISCV_CUSTOM_IRQ_VECTOR_CNT RISCV_PLIC_VECTOR_CNT
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Count of HimiDeer local IRQ interrupt vector.
|
||||
*/
|
||||
#define OS_RISCV_LOCAL_IRQ_VECTOR_CNT (OS_RISCV_MIE_IRQ_VECTOR_CNT + OS_RISCV_SYS_VECTOR_CNT)
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Count of himideer interrupt vector.
|
||||
*/
|
||||
#define OS_RISCV_VECTOR_CNT (OS_RISCV_SYS_VECTOR_CNT + OS_RISCV_CUSTOM_IRQ_VECTOR_CNT)
|
||||
|
||||
/**
|
||||
* Maximum number of supported hardware devices that generate hardware interrupts.
|
||||
* The maximum number of hardware devices that generate hardware interrupts supported by hi3518ev200 is 32.
|
||||
*/
|
||||
#define OS_HWI_MAX_NUM OS_RISCV_VECTOR_CNT
|
||||
|
||||
/**
|
||||
* Maximum interrupt number.
|
||||
*/
|
||||
#define OS_HWI_MAX ((OS_HWI_MAX_NUM) - 1)
|
||||
|
||||
/**
|
||||
* Minimum interrupt number.
|
||||
*/
|
||||
#define OS_HWI_MIN 0
|
||||
|
||||
/**
|
||||
* Maximum usable interrupt number.
|
||||
*/
|
||||
#define OS_USER_HWI_MAX OS_HWI_MAX
|
||||
|
||||
/**
|
||||
* Minimum usable interrupt number.
|
||||
*/
|
||||
#define OS_USER_HWI_MIN OS_HWI_MIN
|
||||
|
||||
extern HWI_HANDLE_FORM_S g_hwiForm[OS_HWI_MAX_NUM];
|
||||
|
||||
extern VOID HalHwiInit(VOID);
|
||||
extern UINT32 HalGetHwiFormCnt(HWI_HANDLE_T hwiNum);
|
||||
extern HWI_HANDLE_FORM_S *HalGetHwiForm(VOID);
|
||||
extern VOID HalHwiInterruptDone(HWI_HANDLE_T hwiNum);
|
||||
extern VOID HalHwiDefaultHandler(VOID *arg);
|
||||
|
||||
extern UINT32 g_intCount;
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Hardware interrupt error code: Invalid interrupt number.
|
||||
*
|
||||
* Value: 0x02000900
|
||||
*
|
||||
* Solution: Ensure that the interrupt number is valid. The value range of the interrupt number applicable
|
||||
* for a risc-v platform is [0, OS_RISCV_VECTOR_CNT].
|
||||
*/
|
||||
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Hardware interrupt error code: Null hardware interrupt handling function.
|
||||
*
|
||||
* Value: 0x02000901
|
||||
*
|
||||
* Solution: Pass in a valid non-null hardware interrupt handling function.
|
||||
*/
|
||||
#define OS_ERRNO_HWI_PROC_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x01)
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Hardware interrupt error code: Insufficient interrupt resources for hardware interrupt creation.
|
||||
*
|
||||
* Value: 0x02000902
|
||||
*
|
||||
* Solution: Increase the configured maximum number of supported hardware interrupts.
|
||||
*/
|
||||
#define OS_ERRNO_HWI_CB_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x02)
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Hardware interrupt error code: Insufficient memory for hardware interrupt initialization.
|
||||
*
|
||||
* Value: 0x02000903
|
||||
*
|
||||
* Solution: Expand the configured memory.
|
||||
*/
|
||||
#define OS_ERRNO_HWI_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x03)
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Hardware interrupt error code: The interrupt has already been created.
|
||||
*
|
||||
* Value: 0x02000904
|
||||
*
|
||||
* Solution: Check whether the interrupt specified by the passed-in interrupt number has already been created.
|
||||
*/
|
||||
#define OS_ERRNO_HWI_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x04)
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Hardware interrupt error code: Invalid interrupt priority.
|
||||
*
|
||||
* Value: 0x02000905
|
||||
*
|
||||
* Solution: Ensure that the interrupt priority is valid.
|
||||
*/
|
||||
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Hardware interrupt error code: Incorrect interrupt creation mode.
|
||||
*
|
||||
* Value: 0x02000906
|
||||
*
|
||||
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or OS_HWI_MODE_FAST of which the
|
||||
* value can be 0 or 1.
|
||||
*/
|
||||
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Hardware interrupt error code: The interrupt has already been created as a fast interrupt.
|
||||
*
|
||||
* Value: 0x02000907
|
||||
*
|
||||
* Solution: Check whether the interrupt specified by the passed-in interrupt number has already been created.
|
||||
*/
|
||||
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Hardware interrupt error code: The API is called during an interrupt, which is forbidden.
|
||||
*
|
||||
* Value: 0x02000908
|
||||
*
|
||||
* * Solution: Do not call the API during an interrupt.
|
||||
*/
|
||||
#define OS_ERRNO_HWI_INTERR LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x08)
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Hardware interrupt error code:the hwi support SHARED error.
|
||||
*
|
||||
* Value: 0x02000909
|
||||
*
|
||||
* * Solution:check the input params hwiMode and irqParam of HalHwiCreate or HalHwiDelete whether adapt the current
|
||||
* hwi.
|
||||
*/
|
||||
#define OS_ERRNO_HWI_SHARED_ERROR LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x09)
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Hardware interrupt error code:Invalid interrupt Arg when interrupt mode is IRQF_SHARED.
|
||||
*
|
||||
* Value: 0x0200090a
|
||||
*
|
||||
* * Solution:check the interrupt Arg, Arg should not be NULL and pDevId should not be NULL.
|
||||
*/
|
||||
#define OS_ERRNO_HWI_ARG_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0a)
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Hardware interrupt error code:The interrupt corresponded to the hwi number or devid has not been created.
|
||||
*
|
||||
* Value: 0x0200090b
|
||||
*
|
||||
* * Solution:check the hwi number or devid, make sure the hwi number or devid need to delete.
|
||||
*/
|
||||
#define OS_ERRNO_HWI_HWINUM_UNCREATE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0b)
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _LOS_HWI_H */
|
||||
54
kernel/arch/risc-v/los_arch_timer.h
Normal file
54
kernel/arch/risc-v/los_arch_timer.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _LOS_ARCH_TIMER_H
|
||||
#define _LOS_ARCH_TIMER_H
|
||||
|
||||
#include "los_config.h"
|
||||
#include "los_compiler.h"
|
||||
#include "los_context.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
UINT32 HalTickStart(OS_TICK_HANDLER handler);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cpluscplus */
|
||||
#endif /* __cpluscplus */
|
||||
|
||||
#endif /* _LOS_ARCH_TIMER_H */
|
||||
|
||||
39
kernel/arch/risc-v/los_hw.c → kernel/arch/risc-v/los_context.c
Executable file → Normal file
39
kernel/arch/risc-v/los_hw.c → kernel/arch/risc-v/los_context.c
Executable file → Normal file
@@ -29,10 +29,12 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "los_context.h"
|
||||
#include "los_interrupt.h"
|
||||
#include "los_arch_context.h"
|
||||
#include "los_arch_interrupt.h"
|
||||
#include "los_arch_timer.h"
|
||||
#include "los_task.h"
|
||||
#include "los_memory.h"
|
||||
#include "los_timer.h"
|
||||
#include "soc.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -41,14 +43,19 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
LITE_OS_SEC_TEXT_MINOR VOID OsTaskExit(VOID)
|
||||
LITE_OS_SEC_TEXT_INIT VOID HalArchInit(VOID)
|
||||
{
|
||||
OsDisableIRQ();
|
||||
HalHwiInit();
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_MINOR VOID HalSysExit(VOID)
|
||||
{
|
||||
HalIntLock();
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT VOID *OsTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
|
||||
LITE_OS_SEC_TEXT_INIT VOID *HalTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
|
||||
{
|
||||
UINT32 index;
|
||||
TaskContext *context = NULL;
|
||||
@@ -92,13 +99,24 @@ LITE_OS_SEC_TEXT_INIT VOID *OsTskStackInit(UINT32 taskID, UINT32 stackSize, VOID
|
||||
context->t2 = T2_INIT_VALUE;
|
||||
context->t1 = T1_INIT_VALUE;
|
||||
context->t0 = T0_INIT_VALUE;
|
||||
context->ra = (UINT32)(UINTPTR)OsTaskExit;
|
||||
context->ra = (UINT32)(UINTPTR)HalSysExit;
|
||||
return (VOID *)context;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT VOID OsTaskScheduleCheck(VOID)
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 HalStartSchedule(OS_TICK_HANDLER handler)
|
||||
{
|
||||
#if (LOSCFG_BASE_CORE_TSK_MONITOR == YES)
|
||||
UINT32 ret;
|
||||
ret = HalTickStart(handler);
|
||||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
}
|
||||
HalStartToRun();
|
||||
return LOS_OK; /* never return */
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT VOID HalTaskScheduleCheck(VOID)
|
||||
{
|
||||
#if (LOSCFG_BASE_CORE_TSK_MONITOR == 1)
|
||||
OsTaskSwitchCheck();
|
||||
#endif
|
||||
return;
|
||||
@@ -119,6 +137,11 @@ LITE_OS_SEC_TEXT VOID dsb(VOID)
|
||||
__asm__ __volatile__("fence":::"memory");
|
||||
}
|
||||
|
||||
VOID HalEnterSleep(LOS_SysSleepEnum sleep)
|
||||
{
|
||||
wfi();
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
44
kernel/arch/risc-v/los_dispatch.S
Executable file → Normal file
44
kernel/arch/risc-v/los_dispatch.S
Executable file → Normal file
@@ -31,15 +31,16 @@
|
||||
|
||||
#include "soc.h"
|
||||
|
||||
.global LOS_IntLock
|
||||
.global LOS_IntUnLock
|
||||
.global LOS_IntRestore
|
||||
.global LOS_StartToRun
|
||||
.global osTaskSchedule
|
||||
.global OsDisableIRQ
|
||||
.global TaskSwitch
|
||||
.global HalEnableIRQ
|
||||
.global HalDisableIRQ
|
||||
.global HalIntLock
|
||||
.global HalIntUnLock
|
||||
.global HalIntRestore
|
||||
.global HalStartToRun
|
||||
.global HalTaskSchedule
|
||||
.global HalTaskSwitch
|
||||
.extern __irq_stack_top
|
||||
.extern OsTaskScheduleCheck
|
||||
.extern HalTaskScheduleCheck
|
||||
.extern printk
|
||||
.equ OS_TASK_STATUS_RUNNING, 0x0010
|
||||
.equ OS_TASK_STATUS_NOT_RUNNING, 0xFFEF
|
||||
@@ -132,7 +133,7 @@
|
||||
addi sp, sp, 32 * REGBYTES
|
||||
.endm
|
||||
|
||||
LOS_StartToRun:
|
||||
HalStartToRun:
|
||||
// disable interrupts
|
||||
csrci mstatus, RISCV_MSTATUS_MIE
|
||||
|
||||
@@ -143,18 +144,23 @@ LOS_StartToRun:
|
||||
|
||||
j SwitchNewTask
|
||||
|
||||
osTaskSchedule:
|
||||
HalTaskSchedule:
|
||||
la t0, g_intCount
|
||||
lw t1, 0(t0)
|
||||
bne t1, zero, 1f
|
||||
|
||||
li t0, RISCV_MSTATUS_MIE | RISCV_MSTATUS_MPIE
|
||||
csrrc a1, mstatus, t0
|
||||
|
||||
la t0, g_losTask
|
||||
lw t1, 0(t0)
|
||||
lw t2, 4(t0)
|
||||
bne t1, t2, 1f
|
||||
bne t1, t2, 2f
|
||||
|
||||
csrw mstatus, a1
|
||||
ret
|
||||
1:
|
||||
ret
|
||||
2:
|
||||
addi sp, sp, -(32 * REGBYTES)
|
||||
andi a1, a1, RISCV_MSTATUS_MIE
|
||||
ori a1, a1, 0x180
|
||||
@@ -164,7 +170,7 @@ osTaskSchedule:
|
||||
|
||||
j SaveContextAndSwitchTask
|
||||
|
||||
TaskSwitch:
|
||||
HalTaskSwitch:
|
||||
la t0, g_losTaskLock
|
||||
lw t1, 0(t0)
|
||||
bgtz t1, NotSwitch
|
||||
@@ -191,7 +197,7 @@ SaveContextAndSwitchTask:
|
||||
sh t2, TASK_CB_STATUS(t1)
|
||||
sw sp, TASK_CB_KERNEL_SP(t1)
|
||||
|
||||
call OsTaskScheduleCheck
|
||||
call HalTaskScheduleCheck
|
||||
|
||||
SwitchNewTask:
|
||||
// copy newTask into runTask
|
||||
@@ -227,27 +233,27 @@ NotSwitch:
|
||||
mret
|
||||
|
||||
.section .text
|
||||
OsDisableIRQ:
|
||||
HalDisableIRQ:
|
||||
li t0, (RISCV_MSTATUS_MPIE | RISCV_MSTATUS_MIE) // mpie | mie
|
||||
csrrc zero, mstatus, t0
|
||||
ret
|
||||
|
||||
OsEnableIRQ:
|
||||
HalEnableIRQ:
|
||||
csrsi mstatus, RISCV_MSTATUS_MIE
|
||||
ret
|
||||
|
||||
LOS_IntLock:
|
||||
HalIntLock:
|
||||
csrr a0, mstatus // return value
|
||||
li t0, RISCV_MSTATUS_MIE // mie
|
||||
csrrc zero, mstatus, t0
|
||||
ret
|
||||
|
||||
LOS_IntUnLock:
|
||||
HalIntUnLock:
|
||||
csrr a0, mstatus // return value
|
||||
li t0, RISCV_MSTATUS_MIE // mie
|
||||
csrrs zero, mstatus, t0
|
||||
ret
|
||||
|
||||
LOS_IntRestore:
|
||||
HalIntRestore:
|
||||
csrw mstatus, a0
|
||||
ret
|
||||
|
||||
24
kernel/arch/risc-v/los_trap.S → kernel/arch/risc-v/los_exc.S
Executable file → Normal file
24
kernel/arch/risc-v/los_trap.S → kernel/arch/risc-v/los_exc.S
Executable file → Normal file
@@ -29,8 +29,8 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _LOS_TRAP_S
|
||||
#define _LOS_TRAP_S
|
||||
#ifndef _LOS_EXC_S
|
||||
#define _LOS_EXC_S
|
||||
#include "soc.h"
|
||||
|
||||
.macro PUSH_ECALL_CALLER_REG
|
||||
@@ -114,11 +114,11 @@
|
||||
.endm
|
||||
|
||||
.section .interrupt.text
|
||||
.extern OsExcEntry
|
||||
.extern HalExcEntry
|
||||
.extern g_excInfo
|
||||
.global TrapEntry
|
||||
.global HalTrapEntry
|
||||
.align 4
|
||||
TrapEntry:
|
||||
HalTrapEntry:
|
||||
PUSH_OTHER_REG
|
||||
addi sp, sp, -4 * REGBYTES
|
||||
sw a0, 0 * REGBYTES(sp)
|
||||
@@ -142,7 +142,7 @@ TrapEntry:
|
||||
1:
|
||||
addi t1, t1, 0x1
|
||||
sh t1, 0(t0)
|
||||
call OsExcEntry
|
||||
call HalExcEntry
|
||||
la t0, g_excInfo
|
||||
sh zero, 0(t0)
|
||||
csrr sp, mscratch
|
||||
@@ -156,23 +156,23 @@ TrapEntry:
|
||||
|
||||
|
||||
.section .interrupt.text
|
||||
.extern TrapEntry
|
||||
.global TrapVector
|
||||
.extern HalTrapEntry
|
||||
.global HalTrapVector
|
||||
.equ TRAP_INTERRUPT_MODE_MASK, 0x80000000
|
||||
.equ TRAP_INTERRUPT_NUM_MASK, 0x7FFFFFFF
|
||||
.align 4
|
||||
TrapVector:
|
||||
HalTrapVector:
|
||||
PUSH_ECALL_CALLER_REG
|
||||
csrr a0, mcause
|
||||
li a1, TRAP_INTERRUPT_MODE_MASK
|
||||
li a2, TRAP_INTERRUPT_NUM_MASK
|
||||
and a1, a0, a1
|
||||
and a0, a2, a0
|
||||
beqz a1, TrapEntry
|
||||
beqz a1, HalTrapEntry
|
||||
PUSH_OTHER_CALLER_REG
|
||||
csrw mscratch, sp
|
||||
la sp, __start_and_irq_stack_top
|
||||
jal OsHwiInterruptDone
|
||||
j TaskSwitch
|
||||
jal HalHwiInterruptDone
|
||||
j HalTaskSwitch
|
||||
|
||||
#endif /* _LOS_TRAP_S */
|
||||
163
kernel/arch/risc-v/los_exc.c → kernel/arch/risc-v/los_interrupt.c
Executable file → Normal file
163
kernel/arch/risc-v/los_exc.c → kernel/arch/risc-v/los_interrupt.c
Executable file → Normal file
@@ -31,7 +31,9 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include "los_interrupt.h"
|
||||
#include "los_arch.h"
|
||||
#include "los_arch_interrupt.h"
|
||||
#include "los_arch_context.h"
|
||||
#include "los_task.h"
|
||||
#include "los_debug.h"
|
||||
#include "riscv_hal.h"
|
||||
@@ -69,7 +71,7 @@ const CHAR g_excInformation[RISCV_EXC_TYPE_NUM][50] = {
|
||||
#define FP_OFFSET 8
|
||||
#define OS_MAX_BACKTRACE 15
|
||||
#define FP_ALIGN(value) (((UINT32)(value) & (UINT32)(LOSCFG_STACK_POINT_ALIGN_SIZE - 1)) == 0)
|
||||
#define FP_CHECK(value) (OsBackTraceFpCheck(value) && ((UINT32)(value) != FP_INIT_VALUE) && FP_ALIGN(value))
|
||||
#define FP_CHECK(value) (HalBackTraceFpCheck(value) && ((UINT32)(value) != FP_INIT_VALUE) && FP_ALIGN(value))
|
||||
|
||||
LITE_OS_SEC_BSS UINT32 g_intCount = 0;
|
||||
LITE_OS_SEC_BSS UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM];
|
||||
@@ -77,16 +79,16 @@ LITE_OS_SEC_DATA_INIT HWI_HANDLE_FORM_S g_hwiForm[OS_HWI_MAX_NUM] = {
|
||||
{ .pfnHook = NULL, .uwParam = 0 }, // 0 User software interrupt handler
|
||||
{ .pfnHook = NULL, .uwParam = 0 }, // 1 Supervisor software interrupt handler
|
||||
{ .pfnHook = NULL, .uwParam = 0 }, // 2 Reserved
|
||||
{ .pfnHook = OsHwiDefaultHandler, .uwParam = 0 }, // 3 Machine software interrupt handler
|
||||
{ .pfnHook = HalHwiDefaultHandler, .uwParam = 0 }, // 3 Machine software interrupt handler
|
||||
{ .pfnHook = NULL, .uwParam = 0 }, // 4 User timer interrupt handler
|
||||
{ .pfnHook = NULL, .uwParam = 0 }, // 5 Supervisor timer interrupt handler
|
||||
{ .pfnHook = NULL, .uwParam = 0 }, // 6 Reserved
|
||||
{ .pfnHook = OsHwiDefaultHandler, .uwParam = 0 }, // 7 Machine timer interrupt handler
|
||||
{ .pfnHook = HalHwiDefaultHandler, .uwParam = 0 }, // 7 Machine timer interrupt handler
|
||||
{ .pfnHook = NULL, .uwParam = 0 }, // 8 User external interrupt handler
|
||||
{ .pfnHook = NULL, .uwParam = 0 }, // 9 Supervisor external interrupt handler
|
||||
{ .pfnHook = NULL, .uwParam = 0 }, // 10 Reserved
|
||||
{ .pfnHook = OsHwiDefaultHandler, .uwParam = 0 }, // 11 Machine external interrupt handler
|
||||
{ .pfnHook = OsHwiDefaultHandler, .uwParam = 0 }, // 12 NMI handler
|
||||
{ .pfnHook = HalHwiDefaultHandler, .uwParam = 0 }, // 11 Machine external interrupt handler
|
||||
{ .pfnHook = HalHwiDefaultHandler, .uwParam = 0 }, // 12 NMI handler
|
||||
{ .pfnHook = NULL, .uwParam = 0 }, // 13 Reserved
|
||||
{ .pfnHook = NULL, .uwParam = 0 }, // 14 Reserved
|
||||
{ .pfnHook = NULL, .uwParam = 0 }, // 15 Reserved
|
||||
@@ -102,7 +104,7 @@ LITE_OS_SEC_DATA_INIT HWI_HANDLE_FORM_S g_hwiForm[OS_HWI_MAX_NUM] = {
|
||||
{ .pfnHook = NULL, .uwParam = 0 }, // 25 Reserved
|
||||
};
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT VOID OsHwiDefaultHandler(UINTPTR arg)
|
||||
LITE_OS_SEC_TEXT_INIT VOID HalHwiDefaultHandler(VOID *arg)
|
||||
{
|
||||
(VOID)arg;
|
||||
PRINT_ERR("default handler\n");
|
||||
@@ -110,17 +112,17 @@ LITE_OS_SEC_TEXT_INIT VOID OsHwiDefaultHandler(UINTPTR arg)
|
||||
}
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT VOID OsHwiInit(VOID)
|
||||
LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
||||
{
|
||||
UINT32 index;
|
||||
for (index = OS_RISCV_SYS_VECTOR_CNT; index < OS_HWI_MAX_NUM; index++) {
|
||||
g_hwiForm[index].pfnHook = OsHwiDefaultHandler;
|
||||
g_hwiForm[index].pfnHook = HalHwiDefaultHandler;
|
||||
g_hwiForm[index].uwParam = 0;
|
||||
}
|
||||
}
|
||||
|
||||
typedef VOID (*HwiProcFunc)(UINTPTR);
|
||||
__attribute__((section(".interrupt.text"))) VOID OsHwiInterruptDone(HWI_HANDLE_T hwiNum)
|
||||
typedef VOID (*HwiProcFunc)(VOID *arg);
|
||||
__attribute__((section(".interrupt.text"))) VOID HalHwiInterruptDone(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
g_intCount++;
|
||||
|
||||
@@ -133,7 +135,7 @@ __attribute__((section(".interrupt.text"))) VOID OsHwiInterruptDone(HWI_HANDLE_T
|
||||
g_intCount--;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT UINT32 OsGetHwiFormCnt(HWI_HANDLE_T hwiNum)
|
||||
LITE_OS_SEC_TEXT UINT32 HalGetHwiFormCnt(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum < OS_HWI_MAX_NUM) {
|
||||
return g_hwiFormCnt[hwiNum];
|
||||
@@ -142,13 +144,19 @@ LITE_OS_SEC_TEXT UINT32 OsGetHwiFormCnt(HWI_HANDLE_T hwiNum)
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT HWI_HANDLE_FORM_S *OsGetHwiForm(VOID)
|
||||
LITE_OS_SEC_TEXT HWI_HANDLE_FORM_S *HalGetHwiForm(VOID)
|
||||
{
|
||||
return g_hwiForm;
|
||||
}
|
||||
|
||||
|
||||
inline UINT32 HalIsIntAcvive(VOID)
|
||||
{
|
||||
return (g_intCount > 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
Function : LOS_HwiCreate
|
||||
Function : HalHwiCreate
|
||||
Description : create hardware interrupt
|
||||
Input : hwiNum --- hwi num to create
|
||||
hwiPrio --- priority of the hwi
|
||||
@@ -158,11 +166,11 @@ LITE_OS_SEC_TEXT HWI_HANDLE_FORM_S *OsGetHwiForm(VOID)
|
||||
Output : None
|
||||
Return : LOS_OK on success or error code on failure
|
||||
*****************************************************************************/
|
||||
LITE_OS_SEC_TEXT UINT32 LOS_HwiCreate(HWI_HANDLE_T hwiNum,
|
||||
LITE_OS_SEC_TEXT UINT32 HalHwiCreate(HWI_HANDLE_T hwiNum,
|
||||
HWI_PRIOR_T hwiPrio,
|
||||
HWI_MODE_T hwiMode,
|
||||
HWI_PROC_FUNC hwiHandler,
|
||||
HWI_IRQ_PARAM_S irqParam)
|
||||
HWI_ARG_T irqParam)
|
||||
{
|
||||
UINT32 intSave;
|
||||
|
||||
@@ -174,7 +182,7 @@ LITE_OS_SEC_TEXT UINT32 LOS_HwiCreate(HWI_HANDLE_T hwiNum,
|
||||
}
|
||||
if (g_hwiForm[hwiNum].pfnHook == NULL) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
} else if (g_hwiForm[hwiNum].pfnHook != OsHwiDefaultHandler) {
|
||||
} else if (g_hwiForm[hwiNum].pfnHook != HalHwiDefaultHandler) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
if ((hwiPrio < OS_HWI_PRIO_LOWEST) || (hwiPrio > OS_HWI_PRIO_HIGHEST)) {
|
||||
@@ -183,10 +191,10 @@ LITE_OS_SEC_TEXT UINT32 LOS_HwiCreate(HWI_HANDLE_T hwiNum,
|
||||
|
||||
intSave = LOS_IntLock();
|
||||
g_hwiForm[hwiNum].pfnHook = hwiHandler;
|
||||
g_hwiForm[hwiNum].uwParam = irqParam;
|
||||
g_hwiForm[hwiNum].uwParam = (VOID *)irqParam;
|
||||
|
||||
if (hwiNum >= OS_RISCV_SYS_VECTOR_CNT) {
|
||||
OsSetLocalInterPri(hwiNum, hwiPrio);
|
||||
HalSetLocalInterPri(hwiNum, hwiPrio);
|
||||
}
|
||||
|
||||
LOS_IntRestore(intSave);
|
||||
@@ -195,12 +203,12 @@ LITE_OS_SEC_TEXT UINT32 LOS_HwiCreate(HWI_HANDLE_T hwiNum,
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
Function : LOS_HwiDelete
|
||||
Function : HalHwiDelete
|
||||
Description : Delete hardware interrupt
|
||||
Input : hwiNum --- hwi num to delete
|
||||
Return : LOS_OK on success or error code on failure
|
||||
*****************************************************************************/
|
||||
LITE_OS_SEC_TEXT UINT32 LOS_HwiDelete(HWI_HANDLE_T hwiNum, HWI_IRQ_PARAM_S irqParam)
|
||||
LITE_OS_SEC_TEXT UINT32 HalHwiDelete(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
UINT32 intSave;
|
||||
|
||||
@@ -209,13 +217,13 @@ LITE_OS_SEC_TEXT UINT32 LOS_HwiDelete(HWI_HANDLE_T hwiNum, HWI_IRQ_PARAM_S irqPa
|
||||
}
|
||||
|
||||
intSave = LOS_IntLock();
|
||||
g_hwiForm[hwiNum].pfnHook = OsHwiDefaultHandler;
|
||||
g_hwiForm[hwiNum].pfnHook = HalHwiDefaultHandler;
|
||||
g_hwiForm[hwiNum].uwParam = 0;
|
||||
LOS_IntRestore(intSave);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT VOID BackTraceSub(UINT32 fp)
|
||||
STATIC VOID BackTraceSub(UINT32 fp)
|
||||
{
|
||||
UINT32 backFp = fp;
|
||||
UINT32 tmpFp;
|
||||
@@ -231,21 +239,21 @@ LITE_OS_SEC_TEXT VOID BackTraceSub(UINT32 fp)
|
||||
count++;
|
||||
|
||||
if ((count == OS_MAX_BACKTRACE) || (backFp == tmpFp) || \
|
||||
(!OsBackTraceRaCheck(backRa))) {
|
||||
(!HalBackTraceRaCheck(backRa))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
PRINTK("*******backtrace end*******\n");
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT VOID BackTrace(UINT32 fp)
|
||||
STATIC VOID BackTrace(UINT32 fp)
|
||||
{
|
||||
PRINTK("*******backtrace begin*******\n");
|
||||
|
||||
BackTraceSub(fp);
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT static VOID OsExcBackTrace(UINT32 fp, UINT32 ra)
|
||||
STATIC VOID ExcBackTrace(UINT32 fp, UINT32 ra)
|
||||
{
|
||||
UINT32 backFp;
|
||||
if (FP_CHECK(fp)) {
|
||||
@@ -259,54 +267,7 @@ LITE_OS_SEC_TEXT static VOID OsExcBackTrace(UINT32 fp, UINT32 ra)
|
||||
}
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT VOID OsTaskBackTrace(UINT32 taskID)
|
||||
{
|
||||
LosTaskCB *taskCB = NULL;
|
||||
|
||||
if (taskID >= g_taskMaxNum) {
|
||||
PRINT_ERR("\r\nTask PID is invalid!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
taskCB = OS_TCB_FROM_TID(taskID);
|
||||
if ((taskCB->taskStatus & OS_TASK_STATUS_UNUSED) || (taskCB->taskEntry == NULL) ||
|
||||
(taskCB->taskName == NULL)) {
|
||||
PRINT_ERR("\r\nThe task is not created!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (taskCB->taskStatus & OS_TASK_STATUS_RUNNING) {
|
||||
OsBackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
PRINTK("taskName = %s\n", taskCB->taskName);
|
||||
PRINTK("taskID = 0x%x\n", taskCB->taskID);
|
||||
PRINTK("curr ra = 0x%08x\n", ((TaskContext *)(taskCB->stackPointer))->ra);
|
||||
OsExcBackTrace(((TaskContext *)(taskCB->stackPointer))->s0, ((TaskContext *)(taskCB->stackPointer))->ra);
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT VOID OsBackTrace(VOID)
|
||||
{
|
||||
UINT32 fp = GetFp();
|
||||
PRINTK("taskName = %s\n", g_losTask.runTask->taskName);
|
||||
PRINTK("taskID = %u\n", g_losTask.runTask->taskID);
|
||||
PRINTK("curr fp = 0x%08x \n", fp);
|
||||
BackTrace(fp);
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT VOID LOS_Panic(const CHAR *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
PRINTK(fmt, ap);
|
||||
va_end(ap);
|
||||
OsDisableIRQ();
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
STATIC VOID OsDisplayTaskInfo(VOID)
|
||||
STATIC VOID DisplayTaskInfo(VOID)
|
||||
{
|
||||
TSK_INFO_S taskInfo;
|
||||
UINT32 index;
|
||||
@@ -326,7 +287,7 @@ STATIC VOID OsDisplayTaskInfo(VOID)
|
||||
return;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT STATIC VOID OsExcInfoDisplayContext(const LosExcInfo *exc)
|
||||
STATIC VOID ExcInfoDisplayContext(const LosExcInfo *exc)
|
||||
{
|
||||
const TaskContext *taskContext = &(exc->context->taskContext);
|
||||
|
||||
@@ -366,10 +327,10 @@ LITE_OS_SEC_TEXT STATIC VOID OsExcInfoDisplayContext(const LosExcInfo *exc)
|
||||
PRINTK("t5 = 0x%x\n", taskContext->t5);
|
||||
PRINTK("t6 = 0x%x\n", taskContext->t6);
|
||||
|
||||
OsExcBackTrace(taskContext->s0, taskContext->ra);
|
||||
ExcBackTrace(taskContext->s0, taskContext->ra);
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT VOID OsExcInfoDisplay(const LosExcContext *excBufAddr)
|
||||
STATIC VOID ExcInfoDisplay(const LosExcContext *excBufAddr)
|
||||
{
|
||||
g_excInfo.type = excBufAddr->mcause;
|
||||
g_excInfo.context = (LosExcContext *)excBufAddr;
|
||||
@@ -385,31 +346,31 @@ LITE_OS_SEC_TEXT VOID OsExcInfoDisplay(const LosExcContext *excBufAddr)
|
||||
PRINTK("taskName = %s\n\r", g_losTask.runTask->taskName);
|
||||
PRINTK("taskID = %u\n\r", g_losTask.runTask->taskID);
|
||||
PRINTK("system mem addr:0x%x\n\r", (UINTPTR)OS_SYS_MEM_ADDR);
|
||||
OsExcInfoDisplayContext(&g_excInfo);
|
||||
ExcInfoDisplayContext(&g_excInfo);
|
||||
}
|
||||
|
||||
VOID OsExcEntry(const LosExcContext *excBufAddr)
|
||||
VOID HalExcEntry(const LosExcContext *excBufAddr)
|
||||
{
|
||||
if (g_excInfo.nestCnt > 2) {
|
||||
PRINTK("hard faule!\n\r");
|
||||
goto SYSTEM_DEATH;
|
||||
}
|
||||
|
||||
OsExcInfoDisplay(excBufAddr);
|
||||
ExcInfoDisplay(excBufAddr);
|
||||
|
||||
PRINTK("----------------All Task infomation ------------\n\r");
|
||||
OsDisplayTaskInfo();
|
||||
DisplayTaskInfo();
|
||||
|
||||
SYSTEM_DEATH:
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
VOID OsExcRegister(ExcInfoType type, EXC_INFO_SAVE_CALLBACK func, VOID *arg)
|
||||
VOID HalExcRegister(ExcInfoType type, EXC_INFO_SAVE_CALLBACK func, VOID *arg)
|
||||
{
|
||||
ExcInfoArray *excInfo = NULL;
|
||||
if ((type >= OS_EXC_TYPE_MAX) || (func == NULL)) {
|
||||
PRINT_ERR("OsExcRegister ERROR!\n");
|
||||
PRINT_ERR("HalExcRegister ERROR!\n");
|
||||
return;
|
||||
}
|
||||
excInfo = &(g_excArray[type]);
|
||||
@@ -419,6 +380,42 @@ VOID OsExcRegister(ExcInfoType type, EXC_INFO_SAVE_CALLBACK func, VOID *arg)
|
||||
excInfo->uwValid = TRUE;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT VOID HalTaskBackTrace(UINT32 taskID)
|
||||
{
|
||||
LosTaskCB *taskCB = NULL;
|
||||
|
||||
if (taskID >= g_taskMaxNum) {
|
||||
PRINT_ERR("\r\nTask PID is invalid!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
taskCB = OS_TCB_FROM_TID(taskID);
|
||||
if ((taskCB->taskStatus & OS_TASK_STATUS_UNUSED) || (taskCB->taskEntry == NULL) ||
|
||||
(taskCB->taskName == NULL)) {
|
||||
PRINT_ERR("\r\nThe task is not created!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (taskCB->taskStatus & OS_TASK_STATUS_RUNNING) {
|
||||
HalBackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
PRINTK("taskName = %s\n", taskCB->taskName);
|
||||
PRINTK("taskID = 0x%x\n", taskCB->taskID);
|
||||
PRINTK("curr ra = 0x%08x\n", ((TaskContext *)(taskCB->stackPointer))->ra);
|
||||
ExcBackTrace(((TaskContext *)(taskCB->stackPointer))->s0, ((TaskContext *)(taskCB->stackPointer))->ra);
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT VOID HalBackTrace(VOID)
|
||||
{
|
||||
UINT32 fp = GetFp();
|
||||
PRINTK("taskName = %s\n", g_losTask.runTask->taskName);
|
||||
PRINTK("taskID = %u\n", g_losTask.runTask->taskID);
|
||||
PRINTK("curr fp = 0x%08x \n", fp);
|
||||
BackTrace(fp);
|
||||
}
|
||||
|
||||
/* stack protector */
|
||||
UINT32 __stack_chk_guard = 0xd00a0dff;
|
||||
|
||||
@@ -1,539 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef _LOS_HWI_H
|
||||
#define _LOS_HWI_H
|
||||
|
||||
#include "los_compiler.h"
|
||||
#include "los_config.h"
|
||||
#include "los_context.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Define the type of a hardware interrupt number.
|
||||
*/
|
||||
typedef UINT32 HWI_HANDLE_T;
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Define the type of a hardware interrupt priority.
|
||||
*/
|
||||
typedef UINT16 HWI_PRIOR_T;
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Define the type of hardware interrupt mode configurations.
|
||||
*/
|
||||
typedef UINT16 HWI_MODE_T;
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Define the type of the parameter used for the hardware interrupt creation function.
|
||||
* The function of this parameter varies among platforms.
|
||||
*/
|
||||
typedef UINT32 HWI_ARG_T;
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Define the type of a hardware interrupt handling function.
|
||||
*/
|
||||
typedef VOID (*HWI_PROC_FUNC)(UINTPTR);
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Define the type of a hardware interrupt vector table function.
|
||||
*/
|
||||
typedef VOID (**HWI_VECTOR_FUNC)(VOID);
|
||||
|
||||
/*
|
||||
* These flags used only by the kernel as part of the
|
||||
* irq handling routines.
|
||||
*
|
||||
* IRQF_SHARED - allow sharing the irq among several devices
|
||||
*/
|
||||
#define IRQF_SHARED 0x8000
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Define the type of a hardware interrupt vector table function.
|
||||
*/
|
||||
typedef struct tagHwiHandleForm {
|
||||
HWI_PROC_FUNC pfnHook;
|
||||
HWI_ARG_T uwParam;
|
||||
UINTPTR uwreserved;
|
||||
} HWI_HANDLE_FORM_S;
|
||||
|
||||
typedef UINTPTR HWI_IRQ_PARAM_S;
|
||||
|
||||
typedef struct {
|
||||
UINT32 mcause;
|
||||
UINT32 mtval;
|
||||
UINT32 medeleg;
|
||||
UINT32 gp;
|
||||
TaskContext taskContext;
|
||||
} LosExcContext;
|
||||
|
||||
typedef struct {
|
||||
UINT16 nestCnt;
|
||||
UINT16 type;
|
||||
UINT32 thrID;
|
||||
LosExcContext *context;
|
||||
} LosExcInfo;
|
||||
|
||||
typedef enum {
|
||||
OS_EXC_TYPE_CONTEXT = 0,
|
||||
OS_EXC_TYPE_TSK = 1,
|
||||
OS_EXC_TYPE_QUE = 2,
|
||||
OS_EXC_TYPE_NVIC = 3,
|
||||
OS_EXC_TYPE_TSK_SWITCH = 4,
|
||||
OS_EXC_TYPE_MEM = 5,
|
||||
OS_EXC_TYPE_MAX = 6
|
||||
} ExcInfoType;
|
||||
|
||||
typedef UINT32 (*EXC_INFO_SAVE_CALLBACK)(UINT32, VOID*);
|
||||
|
||||
typedef struct {
|
||||
ExcInfoType uwType;
|
||||
UINT32 uwValid;
|
||||
EXC_INFO_SAVE_CALLBACK pFnExcInfoCb;
|
||||
VOID* pArg;
|
||||
} ExcInfoArray;
|
||||
|
||||
#define MAX_EXC_MEM_SIZE 0
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Highest priority of a hardware interrupt.
|
||||
*/
|
||||
#define OS_HWI_PRIO_HIGHEST 7
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Lowest priority of a hardware interrupt.
|
||||
*/
|
||||
#define OS_HWI_PRIO_LOWEST 1
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Count of HimiDeer system interrupt vector.
|
||||
*/
|
||||
#define OS_RISCV_SYS_VECTOR_CNT (RISCV_SYS_MAX_IRQ + 1)
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Count of HimiDeer local interrupt vector 0 - 5, enabled by CSR mie 26 -31 bit.
|
||||
*/
|
||||
#define OS_RISCV_MIE_IRQ_VECTOR_CNT 6
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Count of HimiDeer local interrupt vector 6 - 31, enabled by custom CSR locie0 0 - 25 bit.
|
||||
*/
|
||||
#define OS_RISCV_CUSTOM_IRQ_VECTOR_CNT RISCV_PLIC_VECTOR_CNT
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Count of HimiDeer local IRQ interrupt vector.
|
||||
*/
|
||||
#define OS_RISCV_LOCAL_IRQ_VECTOR_CNT (OS_RISCV_MIE_IRQ_VECTOR_CNT + OS_RISCV_SYS_VECTOR_CNT)
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Count of himideer interrupt vector.
|
||||
*/
|
||||
#define OS_RISCV_VECTOR_CNT (OS_RISCV_SYS_VECTOR_CNT + OS_RISCV_CUSTOM_IRQ_VECTOR_CNT)
|
||||
|
||||
/**
|
||||
* Maximum number of supported hardware devices that generate hardware interrupts.
|
||||
* The maximum number of hardware devices that generate hardware interrupts supported by hi3518ev200 is 32.
|
||||
*/
|
||||
#define OS_HWI_MAX_NUM OS_RISCV_VECTOR_CNT
|
||||
|
||||
/**
|
||||
* Maximum interrupt number.
|
||||
*/
|
||||
#define OS_HWI_MAX ((OS_HWI_MAX_NUM) - 1)
|
||||
|
||||
/**
|
||||
* Minimum interrupt number.
|
||||
*/
|
||||
#define OS_HWI_MIN 0
|
||||
|
||||
/**
|
||||
* Maximum usable interrupt number.
|
||||
*/
|
||||
#define OS_USER_HWI_MAX OS_HWI_MAX
|
||||
|
||||
/**
|
||||
* Minimum usable interrupt number.
|
||||
*/
|
||||
#define OS_USER_HWI_MIN OS_HWI_MIN
|
||||
|
||||
extern HWI_HANDLE_FORM_S g_hwiForm[OS_HWI_MAX_NUM];
|
||||
|
||||
extern VOID OsHwiInit(VOID);
|
||||
extern UINT32 OsGetHwiFormCnt(HWI_HANDLE_T hwiNum);
|
||||
extern HWI_HANDLE_FORM_S *OsGetHwiForm(VOID);
|
||||
extern VOID OsHwiInterruptDone(HWI_HANDLE_T hwiNum);
|
||||
extern VOID OsHwiDefaultHandler(UINTPTR arg);
|
||||
|
||||
extern VOID BackTraceSub(UINT32 fp);
|
||||
extern VOID OsDisableIRQ(VOID);
|
||||
extern VOID OsEnableIRQ(VOID);
|
||||
|
||||
extern VOID LOS_Panic(const CHAR *fmt, ...);
|
||||
extern VOID OsBackTrace(VOID);
|
||||
extern VOID OsTaskBackTrace(UINT32 taskID);
|
||||
extern VOID OsExcInit(VOID);
|
||||
extern VOID OsExcRegister(ExcInfoType type, EXC_INFO_SAVE_CALLBACK func, VOID *arg);
|
||||
|
||||
STATIC INLINE UINTPTR GetFp(VOID)
|
||||
{
|
||||
UINTPTR fpSave = 0;
|
||||
__asm__ __volatile__("mv %0, s0" : "=r"(fpSave));
|
||||
return fpSave;
|
||||
}
|
||||
|
||||
extern UINT32 g_intCount;
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* An interrupt is active.
|
||||
*/
|
||||
#define OS_INT_ACTIVE (g_intCount > 0)
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* An interrupt is inactive.
|
||||
*/
|
||||
#define OS_INT_INACTIVE (!(OS_INT_ACTIVE))
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Hardware interrupt error code: Invalid interrupt number.
|
||||
*
|
||||
* Value: 0x02000900
|
||||
*
|
||||
* Solution: Ensure that the interrupt number is valid. The value range of the interrupt number applicable
|
||||
* for a risc-v platform is [0, OS_RISCV_VECTOR_CNT].
|
||||
*/
|
||||
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Hardware interrupt error code: Null hardware interrupt handling function.
|
||||
*
|
||||
* Value: 0x02000901
|
||||
*
|
||||
* Solution: Pass in a valid non-null hardware interrupt handling function.
|
||||
*/
|
||||
#define OS_ERRNO_HWI_PROC_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x01)
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Hardware interrupt error code: Insufficient interrupt resources for hardware interrupt creation.
|
||||
*
|
||||
* Value: 0x02000902
|
||||
*
|
||||
* Solution: Increase the configured maximum number of supported hardware interrupts.
|
||||
*/
|
||||
#define OS_ERRNO_HWI_CB_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x02)
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Hardware interrupt error code: Insufficient memory for hardware interrupt initialization.
|
||||
*
|
||||
* Value: 0x02000903
|
||||
*
|
||||
* Solution: Expand the configured memory.
|
||||
*/
|
||||
#define OS_ERRNO_HWI_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x03)
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Hardware interrupt error code: The interrupt has already been created.
|
||||
*
|
||||
* Value: 0x02000904
|
||||
*
|
||||
* Solution: Check whether the interrupt specified by the passed-in interrupt number has already been created.
|
||||
*/
|
||||
#define OS_ERRNO_HWI_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x04)
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Hardware interrupt error code: Invalid interrupt priority.
|
||||
*
|
||||
* Value: 0x02000905
|
||||
*
|
||||
* Solution: Ensure that the interrupt priority is valid.
|
||||
*/
|
||||
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Hardware interrupt error code: Incorrect interrupt creation mode.
|
||||
*
|
||||
* Value: 0x02000906
|
||||
*
|
||||
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or OS_HWI_MODE_FAST of which the
|
||||
* value can be 0 or 1.
|
||||
*/
|
||||
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Hardware interrupt error code: The interrupt has already been created as a fast interrupt.
|
||||
*
|
||||
* Value: 0x02000907
|
||||
*
|
||||
* Solution: Check whether the interrupt specified by the passed-in interrupt number has already been created.
|
||||
*/
|
||||
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Hardware interrupt error code: The API is called during an interrupt, which is forbidden.
|
||||
*
|
||||
* Value: 0x02000908
|
||||
*
|
||||
* * Solution: Do not call the API during an interrupt.
|
||||
*/
|
||||
#define OS_ERRNO_HWI_INTERR LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x08)
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Hardware interrupt error code:the hwi support SHARED error.
|
||||
*
|
||||
* Value: 0x02000909
|
||||
*
|
||||
* * Solution:check the input params hwiMode and irqParam of LOS_HwiCreate or LOS_HwiDelete whether adapt the current
|
||||
* hwi.
|
||||
*/
|
||||
#define OS_ERRNO_HWI_SHARED_ERROR LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x09)
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Hardware interrupt error code:Invalid interrupt Arg when interrupt mode is IRQF_SHARED.
|
||||
*
|
||||
* Value: 0x0200090a
|
||||
*
|
||||
* * Solution:check the interrupt Arg, Arg should not be NULL and pDevId should not be NULL.
|
||||
*/
|
||||
#define OS_ERRNO_HWI_ARG_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0a)
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* Hardware interrupt error code:The interrupt corresponded to the hwi number or devid has not been created.
|
||||
*
|
||||
* Value: 0x0200090b
|
||||
*
|
||||
* * Solution:check the hwi number or devid, make sure the hwi number or devid need to delete.
|
||||
*/
|
||||
#define OS_ERRNO_HWI_HWINUM_UNCREATE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0b)
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* @brief Create a hardware interrupt.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to configure a hardware interrupt and register a hardware interrupt handling function.
|
||||
*
|
||||
* @attention
|
||||
* <ul>
|
||||
* <li>The hardware interrupt module is usable only when the configuration item for hardware interrupt tailoring
|
||||
* is enabled.</li>
|
||||
* <li>Hardware interrupt number value range: [OS_HWI_MIN,OS_HWI_MAX]. The value range applicable for a riscv
|
||||
* platform is [0, OS_HWI_MAX_NUM].</li>
|
||||
* <li>OS_HWI_MAX_NUM specifies the maximum number of interrupts that can be created.</li>
|
||||
* <li>Before executing an interrupt on a platform, refer to the chip manual of the platform.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param hwiNum [IN] Type#HWI_HANDLE_T: hardware interrupt number. The value range applicable for a riscv
|
||||
* platform is [0, OS_HWI_MAX_NUM].
|
||||
* @param hwiPrio [IN] Type#HWI_PRIOR_T: hardware interrupt priority. Ignore this parameter temporarily.
|
||||
* @param hwiMode [IN] Type#HWI_MODE_T: hardware interrupt mode. Ignore this parameter temporarily.
|
||||
* @param hwiHandler [IN] Type#HWI_PROC_FUNC: interrupt handler used when a hardware interrupt is triggered.
|
||||
* @param irqParam [IN] Type#HWI_IRQ_PARAM_S: input parameter of the interrupt handler used when a hardware
|
||||
* interrupt is triggered.
|
||||
*
|
||||
* @retval #OS_ERRNO_HWI_PROC_FUNC_NULL 0x02000901: Null hardware interrupt handling function.
|
||||
* @retval #OS_ERRNO_HWI_NUM_INVALID 0x02000900: Invalid interrupt number.
|
||||
* @retval #OS_ERRNO_HWI_NO_MEMORY 0x02000903: Insufficient memory for hardware interrupt creation.
|
||||
* @retval #OS_ERRNO_HWI_ALREADY_CREATED 0x02000904: The interrupt handler being created has already been
|
||||
* created.
|
||||
* @retval #LOS_OK 0 : The interrupt is successfully created.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
* @since Huawei LiteOS V200R003C00
|
||||
*/
|
||||
extern UINT32 LOS_HwiCreate(HWI_HANDLE_T hwiNum,
|
||||
HWI_PRIOR_T hwiPrio,
|
||||
HWI_MODE_T hwiMode,
|
||||
HWI_PROC_FUNC hwiHandler,
|
||||
HWI_IRQ_PARAM_S irqParam);
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* @brief Enable all interrupts.
|
||||
*
|
||||
* @par Description:
|
||||
* <ul>
|
||||
* <li>This API is used to enable all IRQ and FIQ interrupts in the CPSR.</li>
|
||||
* </ul>
|
||||
* @attention
|
||||
* <ul>
|
||||
* <li>None.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @retval CPSR value obtained after all interrupts are enabled.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see LOS_IntRestore
|
||||
* @since Huawei LiteOS V200R003C00
|
||||
*/
|
||||
extern UINT32 LOS_IntUnLock(VOID);
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* @brief Disable all interrupts.
|
||||
*
|
||||
* @par Description:
|
||||
* <ul>
|
||||
* <li>This API is used to disable all IRQ and FIQ interrupts in the CPSR.</li>
|
||||
* </ul>
|
||||
* @attention
|
||||
* <ul>
|
||||
* <li>None.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @retval CPSR value obtained before all interrupts are disabled.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see LOS_IntRestore
|
||||
* @since Huawei LiteOS V200R003C00
|
||||
*/
|
||||
extern UINT32 LOS_IntLock(VOID);
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* @brief Restore interrupts.
|
||||
*
|
||||
* @par Description:
|
||||
* <ul>
|
||||
* <li>This API is used to restore the CPSR value obtained before all interrupts are disabled.</li>
|
||||
* </ul>
|
||||
* @attention
|
||||
* <ul>
|
||||
* <li>This API can be called only after all interrupts are disabled, and the input parameter value should be the
|
||||
* value returned by calling the all interrupt disabling API.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param intSave [IN] CPSR value obtained before all interrupts are disabled.
|
||||
*
|
||||
* @retval None.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see LOS_IntLock
|
||||
* @since Huawei LiteOS V200R003C00
|
||||
*/
|
||||
extern VOID LOS_IntRestore(UINT32 intSave);
|
||||
|
||||
/* *
|
||||
* @ingroup los_hwi
|
||||
* @brief Get value from xPSR register.
|
||||
*
|
||||
* @par Description:
|
||||
* <ul>
|
||||
* <li>This API is used to Get value from xPSR register.</li>
|
||||
* </ul>
|
||||
* @attention
|
||||
* <ul>
|
||||
* <li>None.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param cntHi [IN] CpuTick High 4 byte
|
||||
* @param cntLo [IN] CpuTick Low 4 byte
|
||||
*
|
||||
* @retval None.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see LOS_IntRestore
|
||||
*/
|
||||
extern VOID LOS_GetCpuCycle(UINT32 *cntHi, UINT32 *cntLo);
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* @brief Delete hardware interrupt.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to delete hardware interrupt.
|
||||
*
|
||||
* @attention
|
||||
* <ul>
|
||||
* <li>The hardware interrupt module is usable only when the configuration item for hardware interrupt tailoring
|
||||
* is enabled.</li>
|
||||
* <li>Hardware interrupt number value range: [OS_HWI_MIN, OS_HWI_MAX]. The value range applicable for a riscv
|
||||
* platform is [0, OS_HWI_MAX_NUM].</li>
|
||||
* <li>OS_HWI_MAX_NUM specifies the maximum number of interrupts that can be created.</li>
|
||||
* <li>Before executing an interrupt on a platform, refer to the chip manual of the platform.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param hwiNum [IN] Type#HWI_HANDLE_T: hardware interrupt number. The value range applicable for a riscv
|
||||
* platform is [0, OS_HWI_MAX_NUM].
|
||||
* @param irqParam [IN] Type#HWI_IRQ_PARAM_S: id of hardware interrupt which will base on when delete the hardware
|
||||
* interrupt.
|
||||
*
|
||||
* @retval #OS_ERRNO_HWI_NUM_INVALID 0x02000900: Invalid interrupt number.
|
||||
* @retval #LOS_OK 0: The interrupt is successfully delete.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
* @since Huawei LiteOS V200R003C00
|
||||
*/
|
||||
extern UINT32 LOS_HwiDelete(HWI_HANDLE_T hwiNum, HWI_IRQ_PARAM_S irqParam);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _LOS_HWI_H */
|
||||
15
kernel/arch/risc-v/los_hw_tick.c → kernel/arch/risc-v/los_timer.c
Executable file → Normal file
15
kernel/arch/risc-v/los_hw_tick.c → kernel/arch/risc-v/los_timer.c
Executable file → Normal file
@@ -31,7 +31,7 @@
|
||||
|
||||
#include "los_tick.h"
|
||||
#include "los_config.h"
|
||||
#include "los_interrupt.h"
|
||||
#include "los_arch_interrupt.h"
|
||||
#include "riscv_hal.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -42,28 +42,27 @@ extern "C" {
|
||||
|
||||
#define NS_PER_SECOND 1000000000.0
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 OsTickStart(VOID)
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 HalTickStart(OS_TICK_HANDLER handler)
|
||||
{
|
||||
g_sysClock = OS_SYS_CLOCK;
|
||||
g_cyclesPerTick = g_sysClock / LOSCFG_BASE_CORE_TICK_PER_SECOND;
|
||||
g_intCount = 0;
|
||||
|
||||
SysClockInit(g_cyclesPerTick);
|
||||
HalClockInit(handler, g_cyclesPerTick);
|
||||
|
||||
return LOS_OK;
|
||||
return LOS_OK; /* never return */
|
||||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : LOS_GetCpuCycle
|
||||
Function : HalGetCpuCycle
|
||||
Description : Get System cycle count
|
||||
Input : none
|
||||
output : cntHi --- CpuTick High 4 byte
|
||||
cntLo --- CpuTick Low 4 byte
|
||||
return : none
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR VOID LOS_GetCpuCycle(UINT32 *cntHi, UINT32 *cntLo)
|
||||
LITE_OS_SEC_TEXT_MINOR VOID HalGetCpuCycle(UINT32 *cntHi, UINT32 *cntLo)
|
||||
{
|
||||
OsGetCpuCycle(cntHi, cntLo);
|
||||
HalGetSysCpuCycle(cntHi, cntLo);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user