update openharmony 1.0.1

This commit is contained in:
mamingshuai
2021-03-11 20:30:40 +08:00
parent c343c46b91
commit 778c8b9930
234 changed files with 9721 additions and 3414 deletions

66
kernel/BUILD.gn Normal file
View File

@@ -0,0 +1,66 @@
# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021, 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.
static_library("kernel") {
sources = [
"src/los_event.c",
"src/los_init.c",
"src/los_mux.c",
"src/los_queue.c",
"src/los_sem.c",
"src/los_swtmr.c",
"src/los_task.c",
"src/los_tick.c",
"src/mm/los_membox.c",
"src/mm/los_memory.c",
]
include_dirs = [
"include",
"arch/include",
"../components/cpup",
"../components/exchook",
"../utils",
"//third_party/bounds_checking_function/include",
]
if ("$board_cpu" == "cortex-m3") {
deps = [ "arch/arm/cortex-m3/gcc/:arch" ]
} else if ("$board_cpu" == "cortex-m4") {
deps = [ "arch/arm/cortex-m4/gcc/:arch" ]
} else if ("$board_cpu" == "cortex-m7") {
deps = [ "arch/arm/cortex-m7/gcc/:arch" ]
} else if ("$board_cpu" == "cortex-m33") {
deps = [ "arch/arm/cortex-m33/gcc/:arch" ]
} else if ("$board_cpu" == "") {
if ("$board_arch" == "rv32imac" || "$board_arch" == "rv32imafdc") {
deps = [ "arch/risc-v/riscv32/gcc:arch" ]
}
}
}

View File

@@ -0,0 +1,25 @@
Copyright (c) 2009 - 2013 ARM LIMITED
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 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.
- Neither the name of ARM 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 COPYRIGHT HOLDERS AND 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.

View File

@@ -0,0 +1,11 @@
[
{
"Name" : "CMSIS",
"License" : "BSD 3-Clause License",
"License File" : "LICENSE",
"Version Number" : "3.2",
"Owner" : "denny.shenwei@huawei.com",
"Upstream URL" : "http://www.arm.com/zh/products/processors/cortex-m/cortex-microcontroller-software-interface-standard.php",
"Description" : "The Cortex Microcontroller Software Interface Standard (CMSIS) is a vendor-independent hardware abstraction layer for microcontrollers that are based on Arm® Cortex® processors"
}
]

View File

@@ -0,0 +1,37 @@
* -------------------------------------------------------------------
* Copyright (C) 2011-2013 ARM Limited. All rights reserved.
*
* Date: 18 March 2013
* Revision: V3.20
*
* Project: Cortex Microcontroller Software Interface Standard (CMSIS)
* Title: Release Note for CMSIS
*
* -------------------------------------------------------------------
NOTE - Open the index.html file to access CMSIS documentation
The Cortex Microcontroller Software Interface Standard (CMSIS) provides a single standard across all
Cortex-Mx processor series vendors. It enables code re-use and code sharing across software projects
and reduces time-to-market for new embedded applications.
CMSIS is released under the terms of the end user license agreement ("CMSIS END USER LICENCE AGREEMENT.pdf").
Any user of the software package is bound to the terms and conditions of the end user license agreement.
You will find the following sub-directories:
Documentation - Contains CMSIS documentation.
DSP_Lib - MDK project files, Examples and source files etc.. to build the
CMSIS DSP Software Library for Cortex-M0, Cortex-M3, Cortex-M4 processors.
Include - CMSIS Core Support and CMSIS DSP Include Files.
Lib - CMSIS DSP Libraries.
RTOS - CMSIS RTOS API template header file.
SVD - CMSIS SVD Schema files and Conversion Utility.

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -56,7 +56,6 @@ extern "C" {
* @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)
{
@@ -92,7 +91,6 @@ STATIC INLINE INT32 HalAtomicXchg32bits(volatile INT32 *v, INT32 val)
* @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)
{
@@ -129,7 +127,6 @@ STATIC INLINE INT32 HalAtomicDecRet(volatile INT32 *v)
* @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)
{

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -309,45 +309,18 @@ extern UINT32 _BootVectors[];
*/
#define OS_EXC_SYS_TICK 15
/* *
* @ingroup los_hwi
* hardware interrupt form mapping handling function array.
*/
extern HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT];
#if (OS_HWI_WITH_ARG == 1)
/* *
* @ingroup los_hwi
* hardware interrupt Slave form mapping handling function array.
*/
extern HWI_SLAVE_FUNC g_hwiSlaveForm[OS_VECTOR_CNT];
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
#define OsSetVectonr(num, vector, arg) \
do { \
g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt; \
g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector; \
g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT].pParm = (VOID *)arg; \
} while(0)
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
#else
/* *
* @ingroup los_hwi
* hardware interrupt Slave form mapping handling function array.
*/
extern HWI_PROC_FUNC g_hwiSlaveForm[OS_VECTOR_CNT];
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
#define OsSetVector(num, vector) \
do { \
g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt; \
g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT] = vector; \
} while(0)
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
#endif
/* *

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -149,17 +149,6 @@ LITE_OS_SEC_TEXT_INIT VOID *HalTskStackInit(UINT32 taskID, UINT32 stackSize, VOI
return (VOID *)context;
}
void HalBackTrace()
{
}
#if (LOSCFG_MEM_LEAKCHECK == 1)
VOID HalRecordLR(UINTPTR *LR, UINT32 LRSize, UINT32 jumpCount,
UINTPTR stackStart, UINTPTR stackEnd)
{
}
#endif
LITE_OS_SEC_TEXT_INIT UINT32 HalStartSchedule(OS_TICK_HANDLER handler)
{
UINT32 ret;

View File

@@ -1,6 +1,6 @@
;
; Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
; Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
; Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
; Copyright (c) 2020-2021 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:

View File

@@ -1,6 +1,6 @@
;
; Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
; Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
; Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
; Copyright (c) 2020-2021 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:

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -51,12 +51,56 @@ UINT32 g_intCount = 0;
#pragma data_alignment=0x100
LITE_OS_SEC_VEC
#endif
HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* hardware interrupt form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
#if (OS_HWI_WITH_ARG == 1)
HWI_SLAVE_FUNC g_hwiSlaveForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
typedef struct {
HWI_PROC_FUNC pfnHandler;
VOID *pParm;
} HWI_HANDLER_FUNC;
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
}
}
#else
HWI_PROC_FUNC g_hwiSlaveForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
}
}
#endif
__weak VOID SysTick_Handler(VOID)
@@ -132,12 +176,12 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
HalPreInterruptHandler(hwiIndex);
#if (OS_HWI_WITH_ARG == 1)
if (g_hwiSlaveForm[hwiIndex].pfnHandler != 0) {
g_hwiSlaveForm[hwiIndex].pfnHandler((VOID *)g_hwiSlaveForm[hwiIndex].pParm);
if (g_hwiHandlerForm[hwiIndex].pfnHandler != 0) {
g_hwiHandlerForm[hwiIndex].pfnHandler((VOID *)g_hwiHandlerForm[hwiIndex].pParm);
}
#else
if (g_hwiSlaveForm[hwiIndex] != 0) {
g_hwiSlaveForm[hwiIndex]();
if (g_hwiHandlerForm[hwiIndex] != 0) {
g_hwiHandlerForm[hwiIndex]();
}
#endif

View File

@@ -1,26 +1,38 @@
;/*----------------------------------------------------------------------------
;* Huawei - LiteOS
;
; Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
; Copyright (c) 2020-2021 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.
;
;*----------------------------------------------------------------------------
;* Name: LOS_VENDOR.S
;* Purpose: Thread scheduler
;* Rev.: V1.0.0
;*----------------------------------------------------------------------------
;*
;* Copyright (c) 2014, Huawei Technologies Co., Ltd.
;* All rights reserved.
;* Permission to use, copy, modify, and distribute this software for any
;* purpose with or without fee is hereby granted, provided that the above
;* copyright notice and this permission notice appear in all copies.
;*THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
;*WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
;*MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
;*ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
;*WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
;*ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
;*OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
;*---------------------------------------------------------------------------*/
PRESERVE8

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -67,6 +67,7 @@ WEAK UINT32 HalTickStart(OS_TICK_HANDLER *handler)
#endif
#endif
g_sysClock = OS_SYS_CLOCK;
g_cyclesPerTick = OS_SYS_CLOCK / LOSCFG_BASE_CORE_TICK_PER_SECOND;
g_ullTickCount = 0;

View File

@@ -0,0 +1,46 @@
# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021, 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.
static_library("arch") {
sources = [
"los_context.c",
"los_dispatch.S",
"los_exc.S",
"los_interrupt.c",
"los_timer.c",
]
include_dirs = [
"../../../../../kernel/arch/include",
"../../../../../kernel/include",
"../../../../../utils",
"./",
"//third_party/bounds_checking_function/include",
]
}

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -56,7 +56,6 @@ extern "C" {
* @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)
{
@@ -92,7 +91,6 @@ STATIC INLINE INT32 HalAtomicXchg32bits(volatile INT32 *v, INT32 val)
* @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)
{
@@ -129,7 +127,6 @@ STATIC INLINE INT32 HalAtomicDecRet(volatile INT32 *v)
* @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)
{

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -309,45 +309,18 @@ extern UINT32 _BootVectors[];
*/
#define OS_EXC_SYS_TICK 15
/* *
* @ingroup los_hwi
* hardware interrupt form mapping handling function array.
*/
extern HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT];
#if (OS_HWI_WITH_ARG == 1)
/* *
* @ingroup los_hwi
* hardware interrupt Slave form mapping handling function array.
*/
extern HWI_SLAVE_FUNC g_hwiSlaveForm[OS_VECTOR_CNT];
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
#define OsSetVectonr(num, vector, arg) \
do { \
g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt; \
g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector; \
g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT].pParm = (VOID *)arg; \
} while(0)
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
#else
/* *
* @ingroup los_hwi
* hardware interrupt Slave form mapping handling function array.
*/
extern HWI_PROC_FUNC g_hwiSlaveForm[OS_VECTOR_CNT];
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
#define OsSetVector(num, vector) \
do { \
g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt; \
g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT] = vector; \
} while(0)
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
#endif
/* *

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -46,12 +46,56 @@ UINT32 g_intCount = 0;
/*lint -restore*/
HWI_PROC_FUNC __attribute__((aligned(0x100))) g_hwiForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* hardware interrupt form mapping handling function array.
*/
STATIC HWI_PROC_FUNC __attribute__((aligned(0x100))) g_hwiForm[OS_VECTOR_CNT] = {0};
#if (OS_HWI_WITH_ARG == 1)
HWI_SLAVE_FUNC g_hwiSlaveForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
typedef struct {
HWI_PROC_FUNC pfnHandler;
VOID *pParm;
} HWI_HANDLER_FUNC;
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
}
}
#else
HWI_PROC_FUNC g_hwiSlaveForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
}
}
#endif
/* ****************************************************************************
@@ -122,12 +166,12 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
HalPreInterruptHandler(hwiIndex);
#if (OS_HWI_WITH_ARG == 1)
if (g_hwiSlaveForm[hwiIndex].pfnHandler != 0) {
g_hwiSlaveForm[hwiIndex].pfnHandler((VOID *)g_hwiSlaveForm[hwiIndex].pParm);
if (g_hwiHandlerForm[hwiIndex].pfnHandler != 0) {
g_hwiHandlerForm[hwiIndex].pfnHandler((VOID *)g_hwiHandlerForm[hwiIndex].pParm);
}
#else
if (g_hwiSlaveForm[hwiIndex] != 0) {
g_hwiSlaveForm[hwiIndex]();
if (g_hwiHandlerForm[hwiIndex] != 0) {
g_hwiHandlerForm[hwiIndex]();
}
#endif

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -66,6 +66,7 @@ WEAK UINT32 HalTickStart(OS_TICK_HANDLER *handler)
#endif
#endif
g_sysClock = OS_SYS_CLOCK;
g_cyclesPerTick = OS_SYS_CLOCK / LOSCFG_BASE_CORE_TICK_PER_SECOND;
g_ullTickCount = 0;

View File

@@ -0,0 +1,47 @@
# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021, 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.
static_library("arch") {
sources = [
"los_context.c",
"los_dispatch.S",
"los_exc.S",
"los_interrupt.c",
"los_mpu.c",
"los_timer.c",
]
include_dirs = [
"../../../../../kernel/arch/include",
"../../../../../kernel/include",
"../../../../../utils",
"./",
"//third_party/bounds_checking_function/include",
]
}

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -56,7 +56,6 @@ extern "C" {
* @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)
{
@@ -92,7 +91,6 @@ STATIC INLINE INT32 HalAtomicXchg32bits(volatile INT32 *v, INT32 val)
* @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)
{
@@ -129,7 +127,6 @@ STATIC INLINE INT32 HalAtomicDecRet(volatile INT32 *v)
* @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)
{

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -41,7 +41,7 @@ extern "C" {
#endif /* __cpluscplus */
#endif /* __cpluscplus */
typedef struct tagTskContext {
typedef struct TagTskContext {
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined(__FPU_USED) && (__FPU_USED == 1U)))
UINT32 S16;
@@ -128,4 +128,3 @@ extern VOID HalStartToRun(VOID);
#endif /* __cpluscplus */
#endif /* _LOS_ARCH_CONTEXT_H */

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -309,45 +309,18 @@ extern UINT32 _BootVectors[];
*/
#define OS_EXC_SYS_TICK 15
/* *
* @ingroup los_hwi
* hardware interrupt form mapping handling function array.
*/
extern HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT];
#if (OS_HWI_WITH_ARG == 1)
/* *
* @ingroup los_hwi
* hardware interrupt Slave form mapping handling function array.
*/
extern HWI_SLAVE_FUNC g_hwiSlaveForm[OS_VECTOR_CNT];
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
#define OsSetVectonr(num, vector, arg) \
do { \
g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt; \
g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector; \
g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT].pParm = (VOID *)arg; \
} while(0)
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
#else
/* *
* @ingroup los_hwi
* hardware interrupt Slave form mapping handling function array.
*/
extern HWI_PROC_FUNC g_hwiSlaveForm[OS_VECTOR_CNT];
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
#define OsSetVector(num, vector) \
do { \
g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt; \
g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT] = vector; \
} while(0)
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
#endif
/* *
@@ -461,6 +434,8 @@ extern VOID HalPendSV(VOID);
#define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC
#define OS_NVIC_INT_CTRL_SIZE 4
#define OS_NVIC_SHCSR_SIZE 4
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_SIZE
@@ -474,15 +449,14 @@ extern VOID HalPendSV(VOID);
#define OS_EXC_EVENT 0x00000001
/**
*@ingroup los_exc
* @ingroup los_exc
* the struct of register files
*
* description: the register files that saved when exception triggered
*
* notes:the following register with prefix 'uw' correspond to the registers in the cpu data sheet.
*/
typedef struct tagExcContext {
//handler save
typedef struct TagExcContext {
#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined (__FPU_USED ) && (__FPU_USED == 1U)) )
UINT32 S16;
@@ -511,7 +485,7 @@ typedef struct tagExcContext {
UINT32 uwR10;
UINT32 uwR11;
UINT32 uwPriMask;
//auto save
/* auto save */
UINT32 uwSP;
UINT32 uwR0;
UINT32 uwR1;
@@ -557,7 +531,7 @@ VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT
* @attention:
* <ul><li>None.</li></ul>
*
*@param uwArraySize [IN] Memory size of exception.
* @param uwArraySize [IN] Memory size of exception.
*
* @retval: None
* @par Dependency:
@@ -576,202 +550,164 @@ VOID HalHwiInit();
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:总线状态寄存器入栈时发生错误
* @ingroup los_exc
* Cortex-M4 exception types: An error occurred while the bus status register was being pushed.
*/
#define OS_EXC_BF_STKERR 1
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:总线状态寄存器出栈时发生错误
* @ingroup los_exc
* Cortex-M4 exception types: An error occurred while the bus status register was out of the stack.
*/
#define OS_EXC_BF_UNSTKERR 2
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:总线状态寄存器不精确的数据访问违例
* @ingroup los_exc
* Cortex-M4 exception types: Bus status register imprecise data access violation.
*/
#define OS_EXC_BF_IMPRECISERR 3
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:总线状态寄存器精确的数据访问违例
* @ingroup los_exc
* Cortex-M4 exception types: Bus status register exact data access violation.
*/
#define OS_EXC_BF_PRECISERR 4
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:总线状态寄存器取指时的访问违例
* @ingroup los_exc
* Cortex-M4 exception types: Bus status register access violation while pointing.
*/
#define OS_EXC_BF_IBUSERR 5
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:存储器管理状态寄存器入栈时发生错误
* @ingroup los_exc
* Cortex-M4 exception types: An error occurred while the memory management status register was being pushed.
*/
#define OS_EXC_MF_MSTKERR 6
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:存储器管理状态寄存器出栈时发生错误
* @ingroup los_exc
* Cortex-M4 exception types: An error occurred while the memory management status register was out of the stack.
*/
#define OS_EXC_MF_MUNSTKERR 7
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:存储器管理状态寄存器数据访问违例
* @ingroup los_exc
* Cortex-M4 exception types: Memory management status register data access violation.
*/
#define OS_EXC_MF_DACCVIOL 8
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:存储器管理状态寄存器取指访问违例
* @ingroup los_exc
* Cortex-M4 exception types: Memory management status register access violation.
*/
#define OS_EXC_MF_IACCVIOL 9
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:用法错误,表示除法运算时除数为零
* @ingroup los_exc
* Cortex-M4 exception types: ncorrect usage indicating that the divisor is zero during the division operation.
*/
#define OS_EXC_UF_DIVBYZERO 10
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:用法错误,未对齐访问导致的错误
* @ingroup los_exc
* Cortex-M4 exception types: Usage error, error caused by unaligned access.
*/
#define OS_EXC_UF_UNALIGNED 11
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:用法错误,试图执行协处理器相关指令
* @ingroup los_exc
* Cortex-M4 exception types: Incorrect usage attempting to execute coprocessor related instruction.
*/
#define OS_EXC_UF_NOCP 12
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:用法错误在异常返回时试图非法地加载EXC_RETURN到PC
* @ingroup los_exc
* Cortex-M4 exception types: Usage error attempting to load EXC_RETURN to PC illegally on exception return.
*/
#define OS_EXC_UF_INVPC 13
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:用法错误试图切入ARM状态
* @ingroup los_exc
* Cortex-M4 exception types: Incorrect usage, attempting to cut to ARM state.
*/
#define OS_EXC_UF_INVSTATE 14
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:用法错误,执行的指令其编码是未定义的——解码不能
* @ingroup los_exc
* Cortex-M4 exception types: Incorrect usage. Executed instruction whose code is undefined.
*/
#define OS_EXC_UF_UNDEFINSTR 15
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:NMI中断
* @ingroup los_exc
* Cortex-M4 exception types: NMI
*/
#define OS_EXC_CAUSE_NMI 16
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:硬fault
* @ingroup los_exc
* Cortex-M4 exception types: hard fault
*/
#define OS_EXC_CAUSE_HARDFAULT 17
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:任务处理函数退出
* @ingroup los_exc
* Cortex-M4 exception types: The task handler exits.
*/
#define OS_EXC_CAUSE_TASK_EXIT 18
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:致命错误
* @ingroup los_exc
* Cortex-M4 exception types: A fatal error.
*/
#define OS_EXC_CAUSE_FATAL_ERR 19
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:调试事件导致的硬fault
* @ingroup los_exc
* Cortex-M4 exception types: Hard Fault caused by a debug event.
*/
#define OS_EXC_CAUSE_DEBUGEVT 20
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:取向量时发生的硬fault
* @ingroup los_exc
* Cortex-M4 exception types: A hard fault that occurs when a quantity is oriented.
*/
#define OS_EXC_CAUSE_VECTBL 21
/**
*@ingroup los_exc
* 异常信息结构体
* @ingroup los_exc
* Exception information structure
*
* 描述:M4平台下的异常触发时保存的异常信息
* Description: Exception information saved when an exception is triggered on the Cortex-M4 platform.
*
*/
typedef struct tagExcInfo {
/**< 异常发生阶段: 0表示异常发生在初始化中1表示异常发生在任务中2表示异常发生在中断中 */
typedef struct TagExcInfo {
/**< Exception occurrence phase: 0 means that an exception occurs in initialization, 1 means that an exception occurs in a task, and 2 means that an exception occurs in an interrupt */
UINT16 phase;
/**< 异常类型,出异常时对照上面列出的1-19号 */
/**< Exception type. When exceptions occur, check the numbers 1 - 19 listed above */
UINT16 type;
/**< 若为精确地址访问错误表示异常发生时的错误访问地址 */
/**< If the exact address access error indicates the wrong access address when the exception occurred */
UINT32 faultAddr;
/**< 在中断中发生异常表示中断号。在任务中发生异常表示任务id如果发生在初始化中则为0xffffffff */
/**< An exception occurs in an interrupt, indicating the interrupt number. An exception occurs in the task, indicating the task ID, or 0xFFFFFFFF if it occurs during initialization */
UINT32 thrdPid;
/**< 异常嵌套个数,目前仅支持第一次进入异常时执行注册的钩子函数 */
/**< Number of nested exceptions. Currently only registered hook functions are supported when an exception is entered for the first time */
UINT16 nestCnt;
/**< 保留 */
/**< reserve */
UINT16 reserved;
/**< 自动压栈浮点寄存器的异常发生时刻的硬件上下文 */
EXC_CONTEXT_S * context;
/**< Hardware context at the time an exception to the automatic stack floating-point register occurs */
EXC_CONTEXT_S *context;
} ExcInfo;
extern UINT32 g_curNestCount;
extern UINT32 g_intCount;
static VOID OsExcSave2DDR(VOID);
VOID OsExcInfoDisplay(ExcInfo *exc);
extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo;
typedef struct tagExcInfoCallBackArray {
ExcInfoType uwType;
UINT32 uwValid;
EXC_INFO_SAVE_CALLBACK pFnExcInfoCb;
VOID* pArg;
} ExcInfoArray;
#define MAX_SCENE_INFO_SIZE (8 + sizeof(ExcInfo) - 4 + sizeof(EXC_CONTEXT_S))
#define MAX_TSK_INFO_SIZE (8 + sizeof(TSK_INFO_S) * (LOSCFG_BASE_CORE_TSK_LIMIT + 1))
#define MAX_INT_INFO_SIZE (8 + 0x164)
#if (LOSCFG_BASE_IPC_QUEUE == 1)
#define MAX_QUEUE_INFO_SIZE (8 + sizeof(QUEUE_INFO_S) * LOSCFG_BASE_IPC_QUEUE_LIMIT)
#else
#define MAX_QUEUE_INFO_SIZE (0)
#endif
#if (LOSCFG_BASE_CORE_EXC_TSK_SWITCH == 1)
#define MAX_SWITCH_INFO_SIZE (8 + (sizeof(UINT32) + sizeof(CHAR) * LOS_TASK_NAMELEN) * OS_TASK_SWITCH_INFO_COUNT)
#else
#define MAX_SWITCH_INFO_SIZE (0)
#endif
#if (LOSCFG_BASE_MEM_NODE_INTEGRITY_CHECK == 1)
#define MAX_MEM_INFO_SIZE (8 + sizeof(MEM_INFO_S) * OS_SYS_MEM_NUM)
#else
#define MAX_MEM_INFO_SIZE (0)
#endif
#define MAX_EXC_MEM_SIZE ( 4 + MAX_SCENE_INFO_SIZE + MAX_TSK_INFO_SIZE + MAX_QUEUE_INFO_SIZE + MAX_INT_INFO_SIZE + MAX_SWITCH_INFO_SIZE + MAX_MEM_INFO_SIZE + 4)
#ifdef __cplusplus
#if __cplusplus
}
@@ -779,4 +715,3 @@ typedef struct tagExcInfoCallBackArray {
#endif /* __cpluscplus */
#endif /* _LOS_EXC_H */

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -28,11 +28,12 @@
* 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 "los_context.h"
#include "securec.h"
#include "los_interrupt.h"
#include "los_arch_context.h"
#include "los_task.h"
#include "los_interrupt.h"
#include "los_arch_interrupt.h"
#include "los_arch_timer.h"
@@ -64,7 +65,8 @@ LITE_OS_SEC_TEXT_INIT VOID HalArchInit()
LITE_OS_SEC_TEXT_MINOR VOID HalSysExit(VOID)
{
LOS_IntLock();
for(;;);
while (1) {
}
}
/* ****************************************************************************
@@ -149,11 +151,6 @@ LITE_OS_SEC_TEXT_INIT VOID *HalTskStackInit(UINT32 taskID, UINT32 stackSize, VOI
return (VOID *)context;
}
void HalBackTrace()
{
}
LITE_OS_SEC_TEXT_INIT UINT32 HalStartSchedule(OS_TICK_HANDLER handler)
{
UINT32 ret;
@@ -170,5 +167,3 @@ LITE_OS_SEC_TEXT_INIT UINT32 HalStartSchedule(OS_TICK_HANDLER handler)
}
#endif /* __cplusplus */
#endif /* __cplusplus */

View File

@@ -1,7 +1,40 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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.
*/
.syntax unified
.arch armv7e-m
.fpu fpv5-d16
.thumb
.equ OS_FPU_CPACR, 0xE000ED88
.equ OS_FPU_CPACR_ENABLE, 0x00F00000
.equ OS_NVIC_INT_CTRL, 0xE000ED04
.equ OS_NVIC_SYSPRI2, 0xE000ED20
.equ OS_NVIC_PENDSV_PRI, 0xF0F00000
@@ -42,15 +75,31 @@ HalStartToRun:
strh r7, [r0 , #4]
ldr r12, [r0]
ldr.w r1, =OS_FPU_CPACR
ldr r1, [r1]
and r1, r1, #OS_FPU_CPACR_ENABLE
cmp r1, #OS_FPU_CPACR_ENABLE
bne __DisabledFPU
add r12, r12, #100
ldmfd r12!, {R0-R7}
add r12, r12, #72
msr psp, r12
vpush {s0}
vpop {s0}
mov lr, r5
cpsie i
bx r6
__DisabledFPU:
add r12, r12, #36
ldmfd r12!, {r0-r7}
msr psp, r12
mov lr, r5
cpsie I
bx r6
.fnend
@@ -111,11 +160,17 @@ HalPendSV:
cpsid I
HalTaskSwitch:
mrs r0, psp
stmfd r0!, {r4-r12}
ldr.w r3, =OS_FPU_CPACR
ldr r3, [r3]
and r3, r3, #OS_FPU_CPACR_ENABLE
cmp r3, #OS_FPU_CPACR_ENABLE
bne __DisabledFPU1
vstmdb r0!, {d8-d15}
__DisabledFPU1:
ldr r5, =g_losTask
ldr r6, [r5]
str r0, [r6]
@@ -137,13 +192,16 @@ HalTaskSwitch:
orr r7, r7, r8
strh r7, [r0 , #4]
ldr r1, [r0]
ldr r1, [r0]
and r3, r3, #OS_FPU_CPACR_ENABLE
cmp r3, #OS_FPU_CPACR_ENABLE
bne __DisabledFPU2
vldmia r1!, {d8-d15}
__DisabledFPU2:
ldmfd r1!, {r4-r12}
msr psp, r1
msr PRIMASK, r12
bx lr
.fnend

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -224,7 +224,7 @@ HalExcUsageFault:
LDR R0, =OS_NVIC_FSR
LDR R0, [R0]
MOV R1, #0x030F
MOVW R1, #0x030F
LSL R1, R1, #16
AND R0, R0, R1
MOV R12, #0
@@ -281,7 +281,7 @@ _ExcInMSP:
PUSH {R3}
MRS R12, PRIMASK // store message-->exc: disable int?
PUSH {R4-R12} // store message-->exc: {R4-R12}
#VPUSH {D8-D15} // FPU
#VPUSH {D8-D15} // FPU
B _handleEntry
.fnend
@@ -291,10 +291,10 @@ _NoFloatInMsp:
.fnstart
.cantunwind
ADD R3, R13, #32
PUSH {R3} // save IRQ SP // store message-->exc: MSP(R13)
PUSH {R3} // store message-->exc: MSP(R13)
MRS R12, PRIMASK // store message-->exc: disable int?
PUSH {R4-R12} // store message-->exc: {R4-R12}
MRS R12, PRIMASK // store message-->exc: disable int?
PUSH {R4-R12} // store message-->exc: {R4-R12}
ORR R0, R0, #FLAG_NO_FLOAT
B _handleEntry
.fnend
@@ -320,7 +320,7 @@ _hwiActiveCheckNext:
LDR R2, =g_taskScheduled
LDR R2, [R2]
TST R2, #1 // OS_FLG_BGD_ACTIVE
TST R2, #1 // OS_FLG_BGD_ACTIVE
BEQ _ExcInMSP // if exc occured in Init then branch
@@ -333,7 +333,7 @@ _hwiActiveCheckNext:
MRS R3, PSP
ADD R12, R3, #104
PUSH {R12} // save task SP
PUSH {R12} // save task SP
MRS R12, PRIMASK
PUSH {R4-R12}
@@ -341,8 +341,8 @@ _hwiActiveCheckNext:
// copy auto saved task register
LDMFD R3!, {R4-R11} // R4-R11 store PSP reg(auto push when exc in task)
#VLDMIA R3!, {D8-D15} // FPU
#VSTMDB R2!, {D8-D15} // FPU
#VLDMIA R3!, {D8-D15} // FPU
#VSTMDB R2!, {D8-D15} // FPU
STMFD R2!, {R4-R11}
B _handleEntry
.fnend
@@ -352,12 +352,12 @@ _hwiActiveCheckNext:
_NoFloatInPsp:
.fnstart
.cantunwind
MOV R2, R13 //no auto push floating registers
MOV R2, R13 //no auto push floating registers
SUB R13, #32 // add 8 Bytes reg(for STMFD)
MRS R3, PSP
ADD R12, R3, #32
PUSH {R12} // save task SP
PUSH {R12} // save task SP
MRS R12, PRIMASK
PUSH {R4-R12}

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -29,12 +29,11 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_interrupt.h"
#include <stdarg.h>
#include "los_context.h"
#include "los_arch_interrupt.h"
#include <stdarg.h>
#include "los_debug.h"
#include "los_task.h"
#include "los_tick.h"
#ifdef __cplusplus
#if __cplusplus
@@ -43,8 +42,8 @@ extern "C" {
#endif /* __cplusplus */
/*lint -save -e40 -e522 -e533*/
UINT32 g_intCount = 0;
/*lint -restore*/
#ifdef __ICCARM__
#pragma location = ".data.vector"
@@ -52,14 +51,63 @@ UINT32 g_intCount = 0;
#elif defined(__CC_ARM) || defined(__GNUC__)
LITE_OS_SEC_VEC
#endif
HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* hardware interrupt form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
#if (OS_HWI_WITH_ARG == 1)
HWI_SLAVE_FUNC g_hwiSlaveForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
typedef struct {
HWI_PROC_FUNC pfnHandler;
VOID *pParm;
} HWI_HANDLER_FUNC;
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
}
}
#else
HWI_PROC_FUNC g_hwiSlaveForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
}
}
#endif
WEAK VOID SysTick_Handler(VOID)
{
return;
}
/* ****************************************************************************
Function : HalIntNumGet
Description : Get a interrupt number
@@ -91,6 +139,16 @@ LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
while (1) {}
}
WEAK VOID HalPreInterruptHandler(UINT32 arg)
{
return;
}
WEAK VOID HalAftInterruptHandler(UINT32 arg)
{
return;
}
/* ****************************************************************************
Function : HalInterrupt
Description : Hardware interrupt entry function
@@ -115,15 +173,20 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
hwiIndex = HalIntNumGet();
HalPreInterruptHandler(hwiIndex);
#if (OS_HWI_WITH_ARG == 1)
if (g_hwiSlaveForm[hwiIndex].pfnHandler != 0) {
g_hwiSlaveForm[hwiIndex].pfnHandler((VOID *)g_hwiSlaveForm[hwiIndex].pParm);
if (g_hwiHandlerForm[hwiIndex].pfnHandler != 0) {
g_hwiHandlerForm[hwiIndex].pfnHandler((VOID *)g_hwiHandlerForm[hwiIndex].pParm);
}
#else
if (g_hwiSlaveForm[hwiIndex] != 0) {
g_hwiSlaveForm[hwiIndex]();
if (g_hwiHandlerForm[hwiIndex] != 0) {
g_hwiHandlerForm[hwiIndex]();
}
#endif
HalAftInterruptHandler(hwiIndex);
intSave = LOS_IntLock();
g_intCount--;
LOS_IntRestore(intSave);
@@ -141,10 +204,10 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 HalHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PRIOR_T hwiPrio,
HWI_MODE_T mode,
HWI_PROC_FUNC handler,
HWI_ARG_T arg)
HWI_PRIOR_T hwiPrio,
HWI_MODE_T mode,
HWI_PROC_FUNC handler,
HWI_ARG_T arg)
{
UINTPTR intSave;
@@ -204,8 +267,6 @@ LITE_OS_SEC_TEXT_INIT UINT32 HalHwiDelete(HWI_HANDLE_T hwiNum)
return LOS_OK;
}
#define OS_NVIC_INT_CTRL_SIZE 4
#define OS_NVIC_SHCSR_SIZE 4
#define FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17)
@@ -213,9 +274,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 HalHwiDelete(HWI_HANDLE_T hwiNum)
#define DIV0FAULT (1 << 4)
#define HARDFAULT_IRQN (-13)
static ExcInfoArray g_excArray[OS_EXC_TYPE_MAX];
static ExcInfo g_excInfo = {0};
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,
@@ -224,15 +283,20 @@ 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
};
#if (LOSCFG_KERNEL_PRINTF != 0)
UINT32 HalExcNvicDump(UINT32 index, UINT32 *excContent)
{
UINT32 *base = NULL;
UINT32 len = 0, i, j;
UINT32 len, 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};
UINT32 rgNvicLens[OS_NR_NVIC_EXC_DUMP_Types] = {OS_NVIC_INT_ENABLE_SIZE, OS_NVIC_INT_PEND_SIZE,
OS_NVIC_INT_ACT_SIZE, OS_NVIC_INT_PRI_SIZE, OS_NVIC_EXCPRI_SIZE, OS_NVIC_SHCSR_SIZE, OS_NVIC_INT_CTRL_SIZE};
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
};
UINT32 rgNvicLens[OS_NR_NVIC_EXC_DUMP_Types] = {
OS_NVIC_INT_ENABLE_SIZE, OS_NVIC_INT_PEND_SIZE, OS_NVIC_INT_ACT_SIZE,
OS_NVIC_INT_PRI_SIZE, OS_NVIC_EXCPRI_SIZE, OS_NVIC_SHCSR_SIZE, OS_NVIC_INT_CTRL_SIZE
};
char strRgEnable[] = "enable";
char strRgPending[] = "pending";
char strRgActive[] = "active";
@@ -240,7 +304,10 @@ UINT32 HalExcNvicDump(UINT32 index, UINT32 *excContent)
char strRgException[] = "exception";
char strRgShcsr[] = "shcsr";
char strRgIntCtrl[] = "control";
char *strRgs[] = {strRgEnable, strRgPending, strRgActive, strRgPriority, strRgException, strRgShcsr, strRgIntCtrl};
char *strRgs[] = {
strRgEnable, strRgPending, strRgActive, strRgPriority,
strRgException, strRgShcsr, strRgIntCtrl
};
(VOID)index;
(VOID)excContent;
@@ -249,7 +316,7 @@ UINT32 HalExcNvicDump(UINT32 index, UINT32 *excContent)
base = (UINT32 *)rgNvicBases[i];
len = rgNvicLens[i];
PRINTK("interrupt %s register, base address: 0x%x, size: 0x%x\n", strRgs[i], base, len);
len = (len >> 2);
len = (len >> 2); /* 2: Gets the next register offset */
for (j = 0; j < len; j++) {
PRINTK("0x%x ", *(base + j));
}
@@ -257,6 +324,7 @@ UINT32 HalExcNvicDump(UINT32 index, UINT32 *excContent)
}
return 0;
}
#endif
UINT32 HalExcContextDump(UINT32 index, UINT32 *excContent)
{
@@ -288,20 +356,9 @@ UINT32 HalExcContextDump(UINT32 index, UINT32 *excContent)
return 0;
}
VOID HalDumpMsg(VOID)
{
UINT32 index = 0;
for (index = 0; index < (OS_EXC_TYPE_MAX - 1); index++) {
if (g_excArray[index].uwValid == FALSE) {
continue;
}
g_excArray[index].pFnExcInfoCb(index, g_excArray[index].pArg);
}
}
LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr)
{
UINT16 tmpFlag = (excType >> 16) & OS_NULL_SHORT;
UINT16 tmpFlag = (excType >> 16) & OS_NULL_SHORT; /* 16: Get Exception Type */
g_intCount++;
g_excInfo.nestCnt++;
@@ -329,22 +386,9 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
} else {
g_excInfo.context = excBufAddr;
}
HalDumpMsg();
HalSysExit();
}
VOID HalExcRegister(ExcInfoType type, EXC_INFO_SAVE_CALLBACK func, VOID *arg)
{
ExcInfoArray *excInfo = NULL;
if ((type >= OS_EXC_TYPE_MAX) || (func == NULL)) {
PRINT_ERR("HalExcRegister ERROR!\n");
return;
}
excInfo = &(g_excArray[type]);
excInfo->uwType = type;
excInfo->pFnExcInfoCb = func;
excInfo->pArg = arg;
excInfo->uwValid = TRUE;
OsDoExcHook(EXC_INTERRUPT);
HalSysExit();
}
/* ****************************************************************************
@@ -360,7 +404,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit()
UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */
g_hwiForm[1] = Reset_Handler; /* [1] reset */
for (index = 2; index < OS_VECTOR_CNT; index++) {
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
@@ -371,6 +415,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit()
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;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = SysTick_Handler;
/* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
@@ -384,9 +429,6 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit()
/* Enable DIV 0 and unaligned exception */
*(volatile UINT32 *)OS_NVIC_CCR |= DIV0FAULT;
HalExcRegister(OS_EXC_TYPE_CONTEXT, (EXC_INFO_SAVE_CALLBACK)HalExcContextDump, NULL);
HalExcRegister(OS_EXC_TYPE_NVIC, (EXC_INFO_SAVE_CALLBACK)HalExcNvicDump, NULL);
return;
}

View File

@@ -0,0 +1,207 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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.
*/
#include "los_mpu.h"
#include "los_config.h"
#include "los_context.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cpluscplus */
#endif /* __cpluscplus */
#define SIZE_4G_BYTE 0x100000000
#define MPU_MAX_REGION_NUM 16
typedef enum {
MPU_AP_FORBID_USER_FORBID = 0x0, /* Privileged:No access Unprivileged:No access */
MPU_AP_RW_USER_FORBID = 0x1, /* Privileged:Read/Write Unprivileged:No access */
MPU_AP_RW_USER_RO = 0x2, /* Privileged:Read/Write Unprivileged:Read-only */
MPU_AP_RW_USER_RW = 0x3, /* Privileged:Read/Write Unprivileged:Read/Write */
MPU_AP_NA_USER_NA = 0x4, /* Privileged:UNPREDICTABLE Unprivileged:UNPREDICTABLE */
MPU_AP_RO_USER_FORBID = 0x5, /* Privileged:Read-only Unprivileged:No access */
MPU_AP_RO_USER_RO = 0x6, /* Privileged:Read-only Unprivileged:Read-only */
} MpuApConfig;
VOID HalMpuEnable(UINT32 defaultRegionEnable)
{
UINTPTR intSave = HalIntLock();
MPU->CTRL = (MPU_CTRL_ENABLE_Msk | ((defaultRegionEnable << MPU_CTRL_PRIVDEFENA_Pos) & MPU_CTRL_PRIVDEFENA_Msk));
SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk;
__DSB();
__ISB();
HalIntRestore(intSave);
}
VOID HalMpuDisable(VOID)
{
UINTPTR intSave = HalIntLock();
MPU->CTRL = 0;
__DSB();
__ISB();
HalIntRestore(intSave);
}
STATIC VOID HalMpuRASRAddMemAttr(MPU_CFG_PARA *para, UINT32 *RASR)
{
BOOL cachable = 0;
BOOL buffable = 0;
switch (para->memType) {
case MPU_MEM_ON_CHIP_ROM:
case MPU_MEM_ON_CHIP_RAM:
cachable = 1;
buffable = 0;
break;
case MPU_MEM_XIP_PSRAM:
cachable = 1;
buffable = 1;
break;
case MPU_MEM_XIP_NOR_FLASH:
cachable = 0;
buffable = 1;
break;
default:
break;
}
(*RASR) |= ((cachable << MPU_RASR_C_Pos) | (buffable << MPU_RASR_B_Pos));
}
STATIC UINT32 HalMpuEncodeSize(UINT64 size)
{
UINT32 encodeSize = 0;
if (size > SIZE_4G_BYTE) {
return 0;
}
if ((size & 0x1F) != 0) { /* size sould aligned to 32 byte at least. */
return 0;
}
size = (size >> 2);
while (size != 0) {
if (((size & 1) != 0) && ((size & 0xFFFFFFFE) != 0)) { /* size != 2^x (5 <= x <= 32) 128B - 4GB */
return 0;
}
size = (size >> 1);
encodeSize++;
}
return encodeSize;
}
STATIC UINT32 HalMpuEncodeAP(MpuAccessPermission permission)
{
UINT32 ap;
switch (permission) {
case MPU_RW_BY_PRIVILEGED_ONLY:
ap = MPU_AP_RW_USER_FORBID;
break;
case MPU_RW_ANY:
ap = MPU_AP_RW_USER_RW;
break;
case MPU_RO_BY_PRIVILEGED_ONLY:
ap = MPU_AP_RO_USER_FORBID;
break;
case MPU_RO_ANY:
ap = MPU_AP_RO_USER_RO;
break;
default:
ap = MPU_AP_RW_USER_RW;
break;
}
return ap;
}
STATIC UINT32 HalMpuGetRASR(UINT32 encodeSize, MPU_CFG_PARA *para)
{
UINT32 RASR;
UINT32 ap;
ap = HalMpuEncodeAP(para->permission);
RASR = MPU_RASR_ENABLE_Msk;
RASR |= ((encodeSize << MPU_RASR_SIZE_Pos) & MPU_RASR_SIZE_Msk);
RASR |= ((ap << MPU_RASR_AP_Pos) & MPU_RASR_AP_Msk) | ((para->executable << MPU_RASR_XN_Pos) & MPU_RASR_XN_Msk) |
((para->shareability << MPU_RASR_S_Pos) & MPU_RASR_S_Msk);
HalMpuRASRAddMemAttr(para, &RASR);
return RASR;
}
UINT32 HalMpuSetRegion(UINT32 regionId, MPU_CFG_PARA *para)
{
UINT32 RASR;
UINT32 RBAR;
UINT32 RNR;
UINT32 encodeSize;
UINTPTR intSave;
UINT64 size;
if ((regionId >= MPU_MAX_REGION_NUM)||(para == NULL)) {
return LOS_NOK;
}
RNR = regionId;
encodeSize = HalMpuEncodeSize(para->size);
if (encodeSize == 0) {
return LOS_NOK;
}
size = para->size - 1; /* size aligned after encode check */
if ((para->baseAddr & size) != 0) { /* base addr should aligned to region size */
return LOS_NOK;
}
RBAR = para->baseAddr & MPU_RBAR_ADDR_Msk;
RASR = HalMpuGetRASR(encodeSize, para);
intSave = HalIntLock();
MPU->RNR = RNR;
MPU->RBAR = RBAR;
MPU->RASR = RASR;
__DSB();
__ISB();
HalIntRestore(intSave);
return LOS_OK;
}
UINT32 HalMpuDisableRegion(UINT32 regionId)
{
volatile UINT32 type;
UINTPTR intSave;
if (regionId >= MPU_MAX_REGION_NUM) {
return LOS_NOK;
}
intSave = HalIntLock();
type = MPU->TYPE;
if ((MPU_TYPE_DREGION_Msk & type) != 0) {
MPU->RNR = regionId;
MPU->RASR = 0;
__DSB();
__ISB();
}
HalIntRestore(intSave);
return LOS_OK;
}
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cpluscplus */
#endif /* __cpluscplus */

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -28,19 +28,19 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_timer.h"
#include "los_config.h"
#include "los_tick.h"
#include "los_arch_interrupt.h"
#include "los_timer.h"
#include "los_context.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cpluscplus */
#endif /* __cpluscplus */
/* ****************************************************************************
Function : HalTickStart
Description : Configure Tick Interrupt Start
@@ -48,7 +48,7 @@ Input : none
output : none
return : LOS_OK - Success , or LOS_ERRNO_TICK_CFG_INVALID - failed
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 HalTickStart(OS_TICK_HANDLER *handler)
WEAK UINT32 HalTickStart(OS_TICK_HANDLER *handler)
{
UINT32 ret;
@@ -65,6 +65,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 HalTickStart(OS_TICK_HANDLER *handler)
OsSetVector(SysTick_IRQn, (HWI_PROC_FUNC)handler);
#endif
#endif
g_sysClock = OS_SYS_CLOCK;
g_cyclesPerTick = OS_SYS_CLOCK / LOSCFG_BASE_CORE_TICK_PER_SECOND;
g_ullTickCount = 0;
@@ -76,6 +78,15 @@ LITE_OS_SEC_TEXT_INIT UINT32 HalTickStart(OS_TICK_HANDLER *handler)
return LOS_OK;
}
VOID HalSysTickReload(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;
}
/* ****************************************************************************
Function : HalSysTickCurrCycleGet
Description : Get System cycle count
@@ -186,46 +197,59 @@ static BOOL g_sysSleepFlag = FALSE;
VOID HalTickLock(VOID)
{
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
}
VOID HalTickUnlock(VOID)
{
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
}
BOOL HalGetSysSleepFlag(VOID)
{
return g_sysSleepFlag;
return g_sysSleepFlag;
}
VOID HalClearSysSleepFlag(VOID)
{
g_sysSleepFlag = FALSE;
g_sysSleepFlag = FALSE;
}
VOID HalEnterSleep(LOS_SysSleepEnum sleep)
{
__DSB();
__WFI();
__ISB();
__DSB();
__WFI();
__ISB();
}
//extern unsigned int SystemCoreClock;
void HalDelay(UINT32 ticks)
WEAK VOID HalDelay(UINT32 ticks)
{
#if 0
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
return;
}
WEAK UINT64 HalGetExpandTick(VOID)
{
return LOS_OK;
}
WEAK INT32 HalGetRtcTime(UINT64 *usec)
{
return LOS_OK;
}
WEAK INT32 HalGetRtcTimeZone(INT32 *timeZone)
{
return LOS_OK;
}
WEAK INT32 HalSetRtcTime(UINT64 utcTime, UINT64 *usec)
{
return LOS_OK;
}
WEAK INT32 HalSetRtcTimeZone(INT32 timeZone)
{
return LOS_OK;
}
#ifdef __cplusplus

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -56,7 +56,6 @@ extern "C" {
* @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)
{
@@ -92,7 +91,6 @@ STATIC INLINE INT32 HalAtomicXchg32bits(volatile INT32 *v, INT32 val)
* @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)
{
@@ -129,7 +127,6 @@ STATIC INLINE INT32 HalAtomicDecRet(volatile INT32 *v)
* @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)
{

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -41,7 +41,7 @@ extern "C" {
#endif /* __cpluscplus */
#endif /* __cpluscplus */
typedef struct tagTskContext {
typedef struct TagTskContext {
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined(__FPU_USED) && (__FPU_USED == 1U)))
UINT32 S16;

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -309,45 +309,18 @@ extern UINT32 _BootVectors[];
*/
#define OS_EXC_SYS_TICK 15
/* *
* @ingroup los_hwi
* hardware interrupt form mapping handling function array.
*/
extern HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT];
#if (OS_HWI_WITH_ARG == 1)
/* *
* @ingroup los_hwi
* hardware interrupt Slave form mapping handling function array.
*/
extern HWI_SLAVE_FUNC g_hwiSlaveForm[OS_VECTOR_CNT];
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
#define OsSetVectonr(num, vector, arg) \
do { \
g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt; \
g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector; \
g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT].pParm = (VOID *)arg; \
} while(0)
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
#else
/* *
* @ingroup los_hwi
* hardware interrupt Slave form mapping handling function array.
*/
extern HWI_PROC_FUNC g_hwiSlaveForm[OS_VECTOR_CNT];
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
#define OsSetVector(num, vector) \
do { \
g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt; \
g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT] = vector; \
} while(0)
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
#endif
/* *
@@ -476,15 +449,14 @@ extern VOID HalPendSV(VOID);
#define OS_EXC_EVENT 0x00000001
/**
*@ingroup los_exc
* @ingroup los_exc
* the struct of register files
*
* description: the register files that saved when exception triggered
*
* notes:the following register with prefix 'uw' correspond to the registers in the cpu data sheet.
*/
typedef struct tagExcContext {
//handler save
typedef struct TagExcContext {
#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined (__FPU_USED ) && (__FPU_USED == 1U)) )
UINT32 S16;
@@ -513,7 +485,7 @@ typedef struct tagExcContext {
UINT32 uwR10;
UINT32 uwR11;
UINT32 uwPriMask;
//auto save
/* auto save */
UINT32 uwSP;
UINT32 uwR0;
UINT32 uwR1;
@@ -559,7 +531,7 @@ VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT
* @attention:
* <ul><li>None.</li></ul>
*
*@param uwArraySize [IN] Memory size of exception.
* @param uwArraySize [IN] Memory size of exception.
*
* @retval: None
* @par Dependency:
@@ -578,155 +550,155 @@ VOID HalHwiInit();
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:总线状态寄存器入栈时发生错误
* @ingroup los_exc
* Cortex-M4 exception types: An error occurred while the bus status register was being pushed.
*/
#define OS_EXC_BF_STKERR 1
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:总线状态寄存器出栈时发生错误
* @ingroup los_exc
* Cortex-M4 exception types: An error occurred while the bus status register was out of the stack.
*/
#define OS_EXC_BF_UNSTKERR 2
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:总线状态寄存器不精确的数据访问违例
* @ingroup los_exc
* Cortex-M4 exception types: Bus status register imprecise data access violation.
*/
#define OS_EXC_BF_IMPRECISERR 3
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:总线状态寄存器精确的数据访问违例
* @ingroup los_exc
* Cortex-M4 exception types: Bus status register exact data access violation.
*/
#define OS_EXC_BF_PRECISERR 4
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:总线状态寄存器取指时的访问违例
* @ingroup los_exc
* Cortex-M4 exception types: Bus status register access violation while pointing.
*/
#define OS_EXC_BF_IBUSERR 5
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:存储器管理状态寄存器入栈时发生错误
* @ingroup los_exc
* Cortex-M4 exception types: An error occurred while the memory management status register was being pushed.
*/
#define OS_EXC_MF_MSTKERR 6
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:存储器管理状态寄存器出栈时发生错误
* @ingroup los_exc
* Cortex-M4 exception types: An error occurred while the memory management status register was out of the stack.
*/
#define OS_EXC_MF_MUNSTKERR 7
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:存储器管理状态寄存器数据访问违例
* @ingroup los_exc
* Cortex-M4 exception types: Memory management status register data access violation.
*/
#define OS_EXC_MF_DACCVIOL 8
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:存储器管理状态寄存器取指访问违例
* @ingroup los_exc
* Cortex-M4 exception types: Memory management status register access violation.
*/
#define OS_EXC_MF_IACCVIOL 9
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:用法错误,表示除法运算时除数为零
* @ingroup los_exc
* Cortex-M4 exception types: ncorrect usage indicating that the divisor is zero during the division operation.
*/
#define OS_EXC_UF_DIVBYZERO 10
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:用法错误,未对齐访问导致的错误
* @ingroup los_exc
* Cortex-M4 exception types: Usage error, error caused by unaligned access.
*/
#define OS_EXC_UF_UNALIGNED 11
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:用法错误,试图执行协处理器相关指令
* @ingroup los_exc
* Cortex-M4 exception types: Incorrect usage attempting to execute coprocessor related instruction.
*/
#define OS_EXC_UF_NOCP 12
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:用法错误在异常返回时试图非法地加载EXC_RETURN到PC
* @ingroup los_exc
* Cortex-M4 exception types: Usage error attempting to load EXC_RETURN to PC illegally on exception return.
*/
#define OS_EXC_UF_INVPC 13
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:用法错误试图切入ARM状态
* @ingroup los_exc
* Cortex-M4 exception types: Incorrect usage, attempting to cut to ARM state.
*/
#define OS_EXC_UF_INVSTATE 14
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:用法错误,执行的指令其编码是未定义的——解码不能
* @ingroup los_exc
* Cortex-M4 exception types: Incorrect usage. Executed instruction whose code is undefined.
*/
#define OS_EXC_UF_UNDEFINSTR 15
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:NMI中断
* @ingroup los_exc
* Cortex-M4 exception types: NMI
*/
#define OS_EXC_CAUSE_NMI 16
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:硬fault
* @ingroup los_exc
* Cortex-M4 exception types: hard fault
*/
#define OS_EXC_CAUSE_HARDFAULT 17
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:任务处理函数退出
* @ingroup los_exc
* Cortex-M4 exception types: The task handler exits.
*/
#define OS_EXC_CAUSE_TASK_EXIT 18
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:致命错误
* @ingroup los_exc
* Cortex-M4 exception types: A fatal error.
*/
#define OS_EXC_CAUSE_FATAL_ERR 19
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:调试事件导致的硬fault
* @ingroup los_exc
* Cortex-M4 exception types: Hard Fault caused by a debug event.
*/
#define OS_EXC_CAUSE_DEBUGEVT 20
/**
*@ingroup los_exc
*Cortex-M3异常具体类型:取向量时发生的硬fault
* @ingroup los_exc
* Cortex-M4 exception types: A hard fault that occurs when a quantity is oriented.
*/
#define OS_EXC_CAUSE_VECTBL 21
/**
*@ingroup los_exc
* 异常信息结构体
* @ingroup los_exc
* Exception information structure
*
* 描述:M4平台下的异常触发时保存的异常信息
* Description: Exception information saved when an exception is triggered on the Cortex-M4 platform.
*
*/
typedef struct tagExcInfo {
/**< 异常发生阶段: 0表示异常发生在初始化中1表示异常发生在任务中2表示异常发生在中断中 */
typedef struct TagExcInfo {
/**< Exception occurrence phase: 0 means that an exception occurs in initialization, 1 means that an exception occurs in a task, and 2 means that an exception occurs in an interrupt */
UINT16 phase;
/**< 异常类型,出异常时对照上面列出的1-19号 */
/**< Exception type. When exceptions occur, check the numbers 1 - 19 listed above */
UINT16 type;
/**< 若为精确地址访问错误表示异常发生时的错误访问地址 */
/**< If the exact address access error indicates the wrong access address when the exception occurred */
UINT32 faultAddr;
/**< 在中断中发生异常表示中断号。在任务中发生异常表示任务id如果发生在初始化中则为0xffffffff */
/**< An exception occurs in an interrupt, indicating the interrupt number. An exception occurs in the task, indicating the task ID, or 0xFFFFFFFF if it occurs during initialization */
UINT32 thrdPid;
/**< 异常嵌套个数,目前仅支持第一次进入异常时执行注册的钩子函数 */
/**< Number of nested exceptions. Currently only registered hook functions are supported when an exception is entered for the first time */
UINT16 nestCnt;
/**< 保留 */
/**< reserve */
UINT16 reserved;
/**< 自动压栈浮点寄存器的异常发生时刻的硬件上下文 */
EXC_CONTEXT_S * context;
/**< Hardware context at the time an exception to the automatic stack floating-point register occurs */
EXC_CONTEXT_S *context;
} ExcInfo;
extern UINT32 g_curNestCount;

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -28,11 +28,12 @@
* 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 "los_context.h"
#include "securec.h"
#include "los_interrupt.h"
#include "los_arch_context.h"
#include "los_task.h"
#include "los_interrupt.h"
#include "los_arch_interrupt.h"
#include "los_arch_timer.h"
@@ -64,7 +65,8 @@ LITE_OS_SEC_TEXT_INIT VOID HalArchInit()
LITE_OS_SEC_TEXT_MINOR VOID HalSysExit(VOID)
{
LOS_IntLock();
for(;;);
while (1) {
}
}
/* ****************************************************************************
@@ -149,78 +151,6 @@ LITE_OS_SEC_TEXT_INIT VOID *HalTskStackInit(UINT32 taskID, UINT32 stackSize, VOI
return (VOID *)context;
}
void HalBackTrace()
{
}
#if (LOSCFG_MEM_LEAKCHECK == 1)
#define CODE_SECTION_NAME ".text"
#pragma section=CODE_SECTION_NAME
#define CODE_START_ADDR ((UINTPTR)__section_begin(CODE_SECTION_NAME))
#define CODE_END_ADDR ((UINTPTR)__section_end(CODE_SECTION_NAME))
/* check the disassembly instruction is 'BL' or 'BLX' */
STATIC INLINE BOOL HalInsIsBlOrBlx(UINTPTR addr)
{
#define BL_INS_MASK 0xF800
#define BL_INS_HIGH 0xF800
#define BL_INS_LOW 0xF000
#define BLX_INX_MASK 0xFF00
#define BLX_INX 0x4700
UINT16 ins1 = *((UINT16 *)addr);
UINT16 ins2 = *((UINT16 *)(addr + 2)); /* 2: Thumb instruction is two bytes. */
if (((ins2 & BL_INS_MASK) == BL_INS_HIGH) && ((ins1 & BL_INS_MASK) == BL_INS_LOW)) {
return TRUE;
} else if ((ins2 & BLX_INX_MASK) == BLX_INX) {
return TRUE;
} else {
return FALSE;
}
}
VOID HalRecordLR(UINTPTR *LR, UINT32 LRSize, UINT32 jumpCount,
UINTPTR stackStart, UINTPTR stackEnd)
{
if (LR == NULL) {
return;
}
UINT32 count = 0;
UINT32 index = 0;
UINTPTR sp = stackStart;
UINTPTR pc;
/* copy called function address */
for (; sp < stackEnd; sp += sizeof(UINTPTR)) {
/* the *sp value may be LR, so need decrease a word to PC */
pc = *((UINTPTR *)sp) - sizeof(UINTPTR);
/* the Cortex-M using thumb instruction, so the pc must be an odd number */
if ((pc & 0x1) == 0) {
continue;
}
/* fix the PC address in thumb mode */
pc = *((UINTPTR *)sp) - 1;
if ((pc >= CODE_START_ADDR) && (pc <= CODE_END_ADDR) &&(count < LRSize) &&
HalInsIsBlOrBlx(pc - sizeof(UINTPTR))) {
if (index++ < jumpCount) {
continue;
}
LR[count++] = pc;
if (count == LRSize) {
break;
}
}
}
/* if linkReg is not enough,clean up the last of the effective LR as the end. */
if (count < LRSize) {
LR[count] = 0;
}
}
#endif
LITE_OS_SEC_TEXT_INIT UINT32 HalStartSchedule(OS_TICK_HANDLER handler)
{
UINT32 ret;
@@ -237,5 +167,3 @@ LITE_OS_SEC_TEXT_INIT UINT32 HalStartSchedule(OS_TICK_HANDLER handler)
}
#endif /* __cplusplus */
#endif /* __cplusplus */

View File

@@ -1,6 +1,6 @@
;
; Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
; Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
; Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
; Copyright (c) 2020-2021 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:

View File

@@ -1,6 +1,6 @@
;
; Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
; Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
; Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
; Copyright (c) 2020-2021 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:

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -29,9 +29,9 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_interrupt.h"
#include <stdarg.h>
#include "los_context.h"
#include "los_arch_interrupt.h"
#include <stdarg.h>
#include "los_debug.h"
#include "los_task.h"
@@ -51,15 +51,59 @@ UINT32 g_intCount = 0;
#elif defined(__CC_ARM) || defined(__GNUC__)
LITE_OS_SEC_VEC
#endif
HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* hardware interrupt form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
#if (OS_HWI_WITH_ARG == 1)
HWI_SLAVE_FUNC g_hwiSlaveForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
typedef struct {
HWI_PROC_FUNC pfnHandler;
VOID *pParm;
} HWI_HANDLER_FUNC;
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
}
}
#else
HWI_PROC_FUNC g_hwiSlaveForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
}
}
#endif
__weak VOID SysTick_Handler(VOID)
WEAK VOID SysTick_Handler(VOID)
{
return;
}
@@ -132,12 +176,12 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
HalPreInterruptHandler(hwiIndex);
#if (OS_HWI_WITH_ARG == 1)
if (g_hwiSlaveForm[hwiIndex].pfnHandler != 0) {
g_hwiSlaveForm[hwiIndex].pfnHandler((VOID *)g_hwiSlaveForm[hwiIndex].pParm);
if (g_hwiHandlerForm[hwiIndex].pfnHandler != 0) {
g_hwiHandlerForm[hwiIndex].pfnHandler((VOID *)g_hwiHandlerForm[hwiIndex].pParm);
}
#else
if (g_hwiSlaveForm[hwiIndex] != 0) {
g_hwiSlaveForm[hwiIndex]();
if (g_hwiHandlerForm[hwiIndex] != 0) {
g_hwiHandlerForm[hwiIndex]();
}
#endif
@@ -160,10 +204,10 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 HalHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PRIOR_T hwiPrio,
HWI_MODE_T mode,
HWI_PROC_FUNC handler,
HWI_ARG_T arg)
HWI_PRIOR_T hwiPrio,
HWI_MODE_T mode,
HWI_PROC_FUNC handler,
HWI_ARG_T arg)
{
UINTPTR intSave;
@@ -243,12 +287,16 @@ UINT8 g_uwExcTbl[FAULT_STATUS_REG_BIT] = {
UINT32 HalExcNvicDump(UINT32 index, UINT32 *excContent)
{
UINT32 *base = NULL;
UINT32 len = 0, i, j;
UINT32 len, 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};
UINT32 rgNvicLens[OS_NR_NVIC_EXC_DUMP_Types] = {OS_NVIC_INT_ENABLE_SIZE, OS_NVIC_INT_PEND_SIZE,
OS_NVIC_INT_ACT_SIZE, OS_NVIC_INT_PRI_SIZE, OS_NVIC_EXCPRI_SIZE, OS_NVIC_SHCSR_SIZE, OS_NVIC_INT_CTRL_SIZE};
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
};
UINT32 rgNvicLens[OS_NR_NVIC_EXC_DUMP_Types] = {
OS_NVIC_INT_ENABLE_SIZE, OS_NVIC_INT_PEND_SIZE, OS_NVIC_INT_ACT_SIZE,
OS_NVIC_INT_PRI_SIZE, OS_NVIC_EXCPRI_SIZE, OS_NVIC_SHCSR_SIZE, OS_NVIC_INT_CTRL_SIZE
};
char strRgEnable[] = "enable";
char strRgPending[] = "pending";
char strRgActive[] = "active";
@@ -256,7 +304,10 @@ UINT32 HalExcNvicDump(UINT32 index, UINT32 *excContent)
char strRgException[] = "exception";
char strRgShcsr[] = "shcsr";
char strRgIntCtrl[] = "control";
char *strRgs[] = {strRgEnable, strRgPending, strRgActive, strRgPriority, strRgException, strRgShcsr, strRgIntCtrl};
char *strRgs[] = {
strRgEnable, strRgPending, strRgActive, strRgPriority,
strRgException, strRgShcsr, strRgIntCtrl
};
(VOID)index;
(VOID)excContent;
@@ -265,7 +316,7 @@ UINT32 HalExcNvicDump(UINT32 index, UINT32 *excContent)
base = (UINT32 *)rgNvicBases[i];
len = rgNvicLens[i];
PRINTK("interrupt %s register, base address: 0x%x, size: 0x%x\n", strRgs[i], base, len);
len = (len >> 2);
len = (len >> 2); /* 2: Gets the next register offset */
for (j = 0; j < len; j++) {
PRINTK("0x%x ", *(base + j));
}
@@ -307,7 +358,7 @@ UINT32 HalExcContextDump(UINT32 index, UINT32 *excContent)
LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr)
{
UINT16 tmpFlag = (excType >> 16) & OS_NULL_SHORT;
UINT16 tmpFlag = (excType >> 16) & OS_NULL_SHORT; /* 16: Get Exception Type */
g_intCount++;
g_excInfo.nestCnt++;
@@ -353,7 +404,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit()
UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */
g_hwiForm[1] = Reset_Handler; /* [1] reset */
for (index = 2; index < OS_VECTOR_CNT; index++) {
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */

4
kernel/arch/arm/cortex-m4/iar/los_mpu.c Normal file → Executable file
View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -28,19 +28,19 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_timer.h"
#include "los_config.h"
#include "los_tick.h"
#include "los_arch_interrupt.h"
#include "los_timer.h"
#include "los_context.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cpluscplus */
#endif /* __cpluscplus */
/* ****************************************************************************
Function : HalTickStart
Description : Configure Tick Interrupt Start
@@ -65,6 +65,8 @@ WEAK UINT32 HalTickStart(OS_TICK_HANDLER *handler)
OsSetVector(SysTick_IRQn, (HWI_PROC_FUNC)handler);
#endif
#endif
g_sysClock = OS_SYS_CLOCK;
g_cyclesPerTick = OS_SYS_CLOCK / LOSCFG_BASE_CORE_TICK_PER_SECOND;
g_ullTickCount = 0;
@@ -195,34 +197,34 @@ static BOOL g_sysSleepFlag = FALSE;
VOID HalTickLock(VOID)
{
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
}
VOID HalTickUnlock(VOID)
{
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
}
BOOL HalGetSysSleepFlag(VOID)
{
return g_sysSleepFlag;
return g_sysSleepFlag;
}
VOID HalClearSysSleepFlag(VOID)
{
g_sysSleepFlag = FALSE;
g_sysSleepFlag = FALSE;
}
VOID HalEnterSleep(LOS_SysSleepEnum sleep)
{
__DSB();
__WFI();
__ISB();
__DSB();
__WFI();
__ISB();
}
WEAK VOID HalDelay(UINT32 ticks)
{
return;
}
WEAK UINT64 HalGetExpandTick(VOID)

View File

@@ -0,0 +1,46 @@
# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021, 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.
static_library("arch") {
sources = [
"los_context.c",
"los_dispatch.S",
"los_exc.S",
"los_interrupt.c",
"los_timer.c",
]
include_dirs = [
"../../../../../kernel/arch/include",
"../../../../../kernel/include",
"../../../../../utils",
"./",
"//third_party/bounds_checking_function/include",
]
}

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -56,7 +56,6 @@ extern "C" {
* @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)
{
@@ -92,7 +91,6 @@ STATIC INLINE INT32 HalAtomicXchg32bits(volatile INT32 *v, INT32 val)
* @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)
{
@@ -129,7 +127,6 @@ STATIC INLINE INT32 HalAtomicDecRet(volatile INT32 *v)
* @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)
{

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -309,45 +309,18 @@ extern UINT32 _BootVectors[];
*/
#define OS_EXC_SYS_TICK 15
/* *
* @ingroup los_hwi
* hardware interrupt form mapping handling function array.
*/
extern HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT];
#if (OS_HWI_WITH_ARG == 1)
/* *
* @ingroup los_hwi
* hardware interrupt Slave form mapping handling function array.
*/
extern HWI_SLAVE_FUNC g_hwiSlaveForm[OS_VECTOR_CNT];
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
#define OsSetVectonr(num, vector, arg) \
do { \
g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt; \
g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector; \
g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT].pParm = (VOID *)arg; \
} while(0)
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
#else
/* *
* @ingroup los_hwi
* hardware interrupt Slave form mapping handling function array.
*/
extern HWI_PROC_FUNC g_hwiSlaveForm[OS_VECTOR_CNT];
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
#define OsSetVector(num, vector) \
do { \
g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt; \
g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT] = vector; \
} while(0)
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
#endif
/* *

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -149,11 +149,6 @@ LITE_OS_SEC_TEXT_INIT VOID *HalTskStackInit(UINT32 taskID, UINT32 stackSize, VOI
return (VOID *)context;
}
void HalBackTrace()
{
}
LITE_OS_SEC_TEXT_INIT UINT32 HalStartSchedule(OS_TICK_HANDLER handler)
{
UINT32 ret;

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -46,12 +46,56 @@ UINT32 g_intCount = 0;
/*lint -restore*/
HWI_PROC_FUNC __attribute__((aligned(0x100))) g_hwiForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* hardware interrupt form mapping handling function array.
*/
STATIC HWI_PROC_FUNC __attribute__((aligned(0x100))) g_hwiForm[OS_VECTOR_CNT] = {0};
#if (OS_HWI_WITH_ARG == 1)
HWI_SLAVE_FUNC g_hwiSlaveForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
typedef struct {
HWI_PROC_FUNC pfnHandler;
VOID *pParm;
} HWI_HANDLER_FUNC;
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
}
}
#else
HWI_PROC_FUNC g_hwiSlaveForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
}
}
#endif
/* ****************************************************************************
@@ -122,12 +166,12 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
HalPreInterruptHandler(hwiIndex);
#if (OS_HWI_WITH_ARG == 1)
if (g_hwiSlaveForm[hwiIndex].pfnHandler != 0) {
g_hwiSlaveForm[hwiIndex].pfnHandler((VOID *)g_hwiSlaveForm[hwiIndex].pParm);
if (g_hwiHandlerForm[hwiIndex].pfnHandler != 0) {
g_hwiHandlerForm[hwiIndex].pfnHandler((VOID *)g_hwiHandlerForm[hwiIndex].pParm);
}
#else
if (g_hwiSlaveForm[hwiIndex] != 0) {
g_hwiSlaveForm[hwiIndex]();
if (g_hwiHandlerForm[hwiIndex] != 0) {
g_hwiHandlerForm[hwiIndex]();
}
#endif

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -66,6 +66,7 @@ WEAK UINT32 HalTickStart(OS_TICK_HANDLER *handler)
#endif
#endif
g_sysClock = OS_SYS_CLOCK;
g_cyclesPerTick = OS_SYS_CLOCK / LOSCFG_BASE_CORE_TICK_PER_SECOND;
g_ullTickCount = 0;

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -56,7 +56,6 @@ extern "C" {
* @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)
{
@@ -92,7 +91,6 @@ STATIC INLINE INT32 HalAtomicXchg32bits(volatile INT32 *v, INT32 val)
* @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)
{
@@ -129,7 +127,6 @@ STATIC INLINE INT32 HalAtomicDecRet(volatile INT32 *v)
* @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)
{

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:

35
kernel/arch/arm/cortex-m7/iar/los_arch_interrupt.h Normal file → Executable file
View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -309,45 +309,18 @@ extern UINT32 _BootVectors[];
*/
#define OS_EXC_SYS_TICK 15
/* *
* @ingroup los_hwi
* hardware interrupt form mapping handling function array.
*/
extern HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT];
#if (OS_HWI_WITH_ARG == 1)
/* *
* @ingroup los_hwi
* hardware interrupt Slave form mapping handling function array.
*/
extern HWI_SLAVE_FUNC g_hwiSlaveForm[OS_VECTOR_CNT];
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
#define OsSetVectonr(num, vector, arg) \
do { \
g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt; \
g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector; \
g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT].pParm = (VOID *)arg; \
} while(0)
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
#else
/* *
* @ingroup los_hwi
* hardware interrupt Slave form mapping handling function array.
*/
extern HWI_PROC_FUNC g_hwiSlaveForm[OS_VECTOR_CNT];
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
#define OsSetVector(num, vector) \
do { \
g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt; \
g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT] = vector; \
} while(0)
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
#endif
/* *

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -149,80 +149,6 @@ LITE_OS_SEC_TEXT_INIT VOID *HalTskStackInit(UINT32 taskID, UINT32 stackSize, VOI
return (VOID *)context;
}
void HalBackTrace()
{
}
#ifdef __ICCARM__
#if (LOSCFG_MEM_LEAKCHECK == 1)
#define CODE_SECTION_NAME ".text"
#pragma section=CODE_SECTION_NAME
#define CODE_START_ADDR ((UINTPTR)__section_begin(CODE_SECTION_NAME))
#define CODE_END_ADDR ((UINTPTR)__section_end(CODE_SECTION_NAME))
/* check the disassembly instruction is 'BL' or 'BLX' */
STATIC INLINE BOOL HalInsIsBlOrBlx(UINTPTR addr)
{
#define BL_INS_MASK 0xF800
#define BL_INS_HIGH 0xF800
#define BL_INS_LOW 0xF000
#define BLX_INX_MASK 0xFF00
#define BLX_INX 0x4700
UINT16 ins1 = *((UINT16 *)addr);
UINT16 ins2 = *((UINT16 *)(addr + 2)); /* 2: Thumb instruction is two bytes. */
if (((ins2 & BL_INS_MASK) == BL_INS_HIGH) && ((ins1 & BL_INS_MASK) == BL_INS_LOW)) {
return TRUE;
} else if ((ins2 & BLX_INX_MASK) == BLX_INX) {
return TRUE;
} else {
return FALSE;
}
}
VOID HalRecordLR(UINTPTR *LR, UINT32 LRSize, UINT32 jumpCount,
UINTPTR stackStart, UINTPTR stackEnd)
{
if (LR == NULL) {
return;
}
UINT32 count = 0;
UINT32 index = 0;
UINTPTR sp = stackStart;
UINTPTR pc;
/* copy called function address */
for (; sp < stackEnd; sp += sizeof(UINTPTR)) {
/* the *sp value may be LR, so need decrease a word to PC */
pc = *((UINTPTR *)sp) - sizeof(UINTPTR);
/* the Cortex-M using thumb instruction, so the pc must be an odd number */
if ((pc & 0x1) == 0) {
continue;
}
/* fix the PC address in thumb mode */
pc = *((UINTPTR *)sp) - 1;
if ((pc >= CODE_START_ADDR) && (pc <= CODE_END_ADDR) &&(count < LRSize) &&
HalInsIsBlOrBlx(pc - sizeof(UINTPTR))) {
if (index++ < jumpCount) {
continue;
}
LR[count++] = pc;
if (count == LRSize) {
break;
}
}
}
/* if linkReg is not enough,clean up the last of the effective LR as the end. */
if (count < LRSize) {
LR[count] = 0;
}
}
#endif
#endif
LITE_OS_SEC_TEXT_INIT UINT32 HalStartSchedule(OS_TICK_HANDLER handler)
{
UINT32 ret;

4
kernel/arch/arm/cortex-m7/iar/los_dispatch.S Normal file → Executable file
View File

@@ -1,6 +1,6 @@
;
; Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
; Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
; Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
; Copyright (c) 2020-2021 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:

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:

62
kernel/arch/arm/cortex-m7/iar/los_interrupt.c Normal file → Executable file
View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -47,12 +47,56 @@ UINT32 g_intCount = 0;
/*lint -restore*/
#pragma location = ".data.vector"
#pragma data_alignment=0x100
HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* hardware interrupt form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
#if (OS_HWI_WITH_ARG == 1)
HWI_SLAVE_FUNC g_hwiSlaveForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
typedef struct {
HWI_PROC_FUNC pfnHandler;
VOID *pParm;
} HWI_HANDLER_FUNC;
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
}
}
#else
HWI_PROC_FUNC g_hwiSlaveForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
}
}
#endif
WEAK VOID SysTick_Handler(VOID)
@@ -128,12 +172,12 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
HalPreInterruptHandler(hwiIndex);
#if (OS_HWI_WITH_ARG == 1)
if (g_hwiSlaveForm[hwiIndex].pfnHandler != 0) {
g_hwiSlaveForm[hwiIndex].pfnHandler((VOID *)g_hwiSlaveForm[hwiIndex].pParm);
if (g_hwiHandlerForm[hwiIndex].pfnHandler != 0) {
g_hwiHandlerForm[hwiIndex].pfnHandler((VOID *)g_hwiHandlerForm[hwiIndex].pParm);
}
#else
if (g_hwiSlaveForm[hwiIndex] != 0) {
g_hwiSlaveForm[hwiIndex]();
if (g_hwiHandlerForm[hwiIndex] != 0) {
g_hwiHandlerForm[hwiIndex]();
}
#endif

5
kernel/arch/arm/cortex-m7/iar/los_mpu.c Normal file → Executable file
View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -29,7 +29,6 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_mpu.h"
#include "los_config.h"
#include "los_context.h"
#ifdef __cplusplus

5
kernel/arch/arm/cortex-m7/iar/los_timer.c Normal file → Executable file
View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -66,6 +66,7 @@ WEAK UINT32 HalTickStart(OS_TICK_HANDLER *handler)
#endif
#endif
g_sysClock = OS_SYS_CLOCK;
g_cyclesPerTick = OS_SYS_CLOCK / LOSCFG_BASE_CORE_TICK_PER_SECOND;
g_ullTickCount = 0;

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -41,15 +41,7 @@ extern "C" {
#endif /* __cpluscplus */
#endif /* __cpluscplus */
VOID HalArchInit();
void HalBackTrace();
#define LOS_BackTrace HalBackTrace
#if (LOSCFG_MEM_LEAKCHECK == 1)
VOID HalRecordLR(UINTPTR *LR, UINT32 LRSize, UINT32 jumpCount,
UINTPTR stackStart, UINTPTR stackEnd);
#endif
VOID HalArchInit(VOID);
#ifdef __cplusplus
#if __cplusplus

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -58,16 +58,10 @@ typedef UINT32 HWI_ARG_T;
#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))
@@ -128,10 +122,10 @@ extern UINT32 HalHwiDelete(HWI_HANDLE_T hwiNum);
* @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);
HWI_PRIOR_T hwiPrio,
HWI_MODE_T mode,
HWI_PROC_FUNC handler,
HWI_ARG_T arg);
#ifdef __cplusplus
#if __cplusplus

4
kernel/arch/include/los_mpu.h Normal file → Executable file
View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -53,8 +53,8 @@ extern "C" {
#define MACHINE_CYCLE_DEALAY_TIMES (LOSCFG_BASE_CORE_TICK_PER_SECOND << 2)
typedef enum {
OS_SYS_NORMAL_SLEEP = 0,
OS_SYS_DEEP_SLEEP,
OS_SYS_NORMAL_SLEEP = 0,
OS_SYS_DEEP_SLEEP,
} LOS_SysSleepEnum;
VOID HalTickLock(VOID);

View File

@@ -0,0 +1,47 @@
# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021, 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.
static_library("arch") {
sources = [
"los_context.c",
"los_dispatch.S",
"los_exc.S",
"los_interrupt.c",
"los_timer.c",
]
include_dirs = [
"../../../../../kernel/arch/include",
"../../../../../kernel/include",
"../../../../../utils",
"./",
"./asm",
"//third_party/bounds_checking_function/include",
]
}

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -148,7 +148,6 @@ extern VOID HalStartToRun(VOID);
* @par Dependency:
* los_hw.h: the header file that contains the API declaration.
* @see None.
* @since Huawei LiteOS V200R002C00
*/
extern VOID wfi(VOID);
@@ -168,7 +167,6 @@ extern VOID wfi(VOID);
* @par Dependency:
* <ul><li>los_hw.h: the header file that contains the API declaration.</li></ul>
* @see None.
* @since Huawei LiteOS V200R002C00
*/
extern VOID mb(VOID);
@@ -188,7 +186,6 @@ extern VOID mb(VOID);
* @par Dependency:
* <ul><li>los_hw.h: the header file that contains the API declaration.</li></ul>
* @see None.
* @since Huawei LiteOS V200R002C00
*/
extern VOID dsb(VOID);

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -67,12 +67,6 @@ const CHAR g_excInformation[RISCV_EXC_TYPE_NUM][50] = {
{ "Store/AMO page fault!" },
};
#define RA_OFFSET 4
#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) (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];
LITE_OS_SEC_DATA_INIT HWI_HANDLE_FORM_S g_hwiForm[OS_HWI_MAX_NUM] = {
@@ -223,50 +217,6 @@ LITE_OS_SEC_TEXT UINT32 HalHwiDelete(HWI_HANDLE_T hwiNum)
return LOS_OK;
}
STATIC VOID BackTraceSub(UINT32 fp)
{
UINT32 backFp = fp;
UINT32 tmpFp;
UINT32 backRa;
UINT32 count = 0;
while (FP_CHECK(backFp)) {
tmpFp = backFp;
backRa = *((UINT32 *)(UINTPTR)(tmpFp - RA_OFFSET));
backFp = *((UINT32 *)(UINTPTR)(tmpFp - FP_OFFSET));
PRINTK("traceback %u -- ra = 0x%x fp = 0x%x\n", count, backRa, backFp);
count++;
if ((count == OS_MAX_BACKTRACE) || (backFp == tmpFp) || \
(!HalBackTraceRaCheck(backRa))) {
break;
}
}
PRINTK("*******backtrace end*******\n");
}
STATIC VOID BackTrace(UINT32 fp)
{
PRINTK("*******backtrace begin*******\n");
BackTraceSub(fp);
}
STATIC VOID ExcBackTrace(UINT32 fp, UINT32 ra)
{
UINT32 backFp;
if (FP_CHECK(fp)) {
backFp = *((UINT32 *)(UINTPTR)(fp - RA_OFFSET));
if ((backFp != ra) && FP_CHECK(backFp)) {
fp = backFp;
}
BackTrace(fp);
} else {
PRINTK("fp error, back trace failed!\n");
}
}
STATIC VOID DisplayTaskInfo(VOID)
{
TSK_INFO_S taskInfo;
@@ -287,6 +237,23 @@ STATIC VOID DisplayTaskInfo(VOID)
return;
}
STATIC VOID ExcBackTrace(VOID)
{
UINTPTR LR[LOSCFG_BACKTRACE_DEPTH] = {0};
UINT32 index;
OsBackTraceHookCall(LR, LOSCFG_BACKTRACE_DEPTH, 1); /* 1: Ignore the one layer call relationship within the function. */
PRINTK("----- traceback start -----\r\n");
for (index = 0; index < LOSCFG_BACKTRACE_DEPTH; index++) {
if (LR[index] == 0) {
break;
}
PRINTK("traceback %d -- lr = 0x%x\r\n", index, LR[index]);
}
PRINTK("----- traceback end -----\r\n");
}
STATIC VOID ExcInfoDisplayContext(const LosExcInfo *exc)
{
const TaskContext *taskContext = &(exc->context->taskContext);
@@ -327,7 +294,7 @@ STATIC VOID ExcInfoDisplayContext(const LosExcInfo *exc)
PRINTK("t5 = 0x%x\n", taskContext->t5);
PRINTK("t6 = 0x%x\n", taskContext->t6);
ExcBackTrace(taskContext->s0, taskContext->ra);
ExcBackTrace();
}
STATIC VOID ExcInfoDisplay(const LosExcContext *excBufAddr)
@@ -358,7 +325,6 @@ VOID HalExcEntry(const LosExcContext *excBufAddr)
UINT32 ret;
g_excInfo.type = excBufAddr->mcause & 0x1FF;
g_excInfo.context = (LosExcContext *)excBufAddr;
if (g_excInfo.nestCnt > 2) { /* 2: Number of layers of exception nesting */
PRINTK("hard faule!\n\r");
goto SYSTEM_DEATH;
@@ -384,60 +350,6 @@ SYSTEM_DEATH:
}
}
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);
}
#if (LOSCFG_MEM_LEAKCHECK == 1)
VOID HalRecordLR(UINTPTR *LR, UINT32 LRSize, UINT32 jumpCount,
UINTPTR stackStart, UINTPTR stackEnd)
{
}
#endif
/* stack protector */
UINT32 __stack_chk_guard = 0xd00a0dff;
VOID __stack_chk_fail(VOID)
{
OsDoExcHook(EXC_STACKOVERFLOW);
/* __builtin_return_address is a builtin function, building in gcc */
LOS_Panic("stack-protector: Kernel stack is corrupted in: %p\n",
__builtin_return_address(0));
}
#ifdef __cplusplus
#if __cplusplus
}

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -433,11 +433,35 @@ extern UINT8 *m_aucSysMem0;
/**
* @ingroup los_config
* Configuration memory leak detection
* @attention
* Need to enable backtrace module synchronously by configuration LOSCFG_BACKTRACE_TYPE,
* and call LOS_BackTraceInit to complete initialization before the memory pool is initialized.
*/
#ifndef LOSCFG_MEM_LEAKCHECK
#define LOSCFG_MEM_LEAKCHECK 0
#endif
/**
* @ingroup los_config
* The default is 4, which means that the function call stack is recorded from the kernel interface,
* such as LOS_MemAlloc/LOS_MemAllocAlign/LOS_MemRealloc/LOS_MemFree. If you want to further ignore
* the number of function call layers, you can increase this value appropriately.
* @attention
* The default is in the IAR tool. Under different compilation environments, this value needs to be adjusted.
*/
#ifndef LOSCFG_MEM_OMIT_LR_CNT
#define LOSCFG_MEM_OMIT_LR_CNT 4
#endif
/**
* @ingroup los_config
* The record number of layers of the function call relationship starting from the number of
* ignored layers(LOSCFG_MEM_OMIT_LR_CNT).
*/
#ifndef LOSCFG_MEM_RECORD_LR_CNT
#define LOSCFG_MEM_RECORD_LR_CNT 3
#endif
/**
* @ingroup los_config
* Configuration memory leak recorded num
@@ -546,6 +570,29 @@ extern UINT8 *m_aucSysMem0;
#define LOSCFG_KERNEL_PRINTF 1
#endif
/* =============================================================================
backtrace configuration
============================================================================= */
/**
* @ingroup los_config
* Configuration backtrace type
* 0: Close stack analysis module.
* 1: Call stack analysis for cortex-m series.
* 2: Call stack analysis for risc-v.
* others: Not currently supported.
*/
#ifndef LOSCFG_BACKTRACE_TYPE
#define LOSCFG_BACKTRACE_TYPE 0
#endif
/**
* @ingroup los_config
* Configuration backtrace depth.
*/
#ifndef LOSCFG_BACKTRACE_DEPTH
#define LOSCFG_BACKTRACE_DEPTH 15
#endif
#ifdef __cplusplus
#if __cplusplus
}

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -236,7 +236,7 @@ extern VOID LOS_ShowBox(VOID *pool);
* be abnormal.</li>
* </ul>
*
* @param boxMem [IN] Type #VOID* Pointer to the calculate membox.
* @param boxMem [IN] Type #VOID* Pointer to the calculate membox.
* @param maxBlk [OUT] Type #UINT32* Record membox max block.
* @param blkCnt [OUT] Type #UINT32* Record membox block count alreay allocated.
* @param blkSize [OUT] Type #UINT32* Record membox block size.

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -58,23 +58,6 @@ UINT32 OsMemExcInfoGet(UINT32 memNumMax, MemInfoCB *memExcInfo);
#define OS_SYS_MEM_ADDR LOSCFG_SYS_HEAP_ADDR
#if (LOSCFG_MEM_LEAKCHECK == 1)
/**
* @ingroup los_memory
* The default is 5, which means that the function call stack is recorded from the kernel interface,</li>
* such as LOS_MemAlloc/LOS_MemAllocAlign/LOS_MemRealloc/LOS_MemFree. If you want to further ignore</li>
* the number of function call layers, you can increase this value appropriately.
*
*/
#define LOS_OMIT_LR_CNT 5
/**
* @ingroup los_memory
* The record number of layers of the function call relationship starting from the number of</li>
* ignored layers(LOS_OMIT_LR_CNT).
*/
#define LOS_RECORD_LR_CNT 3
/**
* @ingroup los_memory
* @brief Print function call stack information of all used nodes.

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:

4
kernel/include/los_swtmr.h Executable file → Normal file
View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:

8
kernel/include/los_task.h Executable file → Normal file
View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -1651,8 +1651,8 @@ typedef struct {
typedef struct {
LOS_DL_LIST *sortLink;
UINT16 cursor;
UINT16 reserved;
UINT16 cursor;
UINT16 reserved;
} TaskSortLinkAttr;
/**

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -192,6 +192,14 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_KernelInit(VOID)
}
#endif
#ifdef LOSCFG_TEST
//ret = los_TestInit();
//if (ret != LOS_OK) {
// PRINT_ERR("los_TestInit error\n");
// return ret;
//}
#endif
#if (LOSCFG_PLATFORM_EXC == 1)
OsExcMsgDumpInit();
#endif

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -30,7 +30,6 @@
*/
#include "los_config.h"
#include "los_interrupt.h"
#include "los_arch.h"
#include "los_mux.h"
#include "los_memory.h"
#include "los_debug.h"
@@ -170,9 +169,6 @@ STATIC_INLINE UINT32 OsMuxValidCheck(LosMuxCB *muxPended)
if (g_losTaskLock) {
PRINT_ERR("!!!LOS_ERRNO_MUX_PEND_IN_LOCK!!!\n");
#if (LOSCFG_PLATFORM_EXC == 1)
LOS_BackTrace();
#endif
return LOS_ERRNO_MUX_PEND_IN_LOCK;
}

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -29,7 +29,6 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_config.h"
#include "los_arch.h"
#include "los_sem.h"
#include "los_memory.h"
#include "los_interrupt.h"
@@ -195,17 +194,11 @@ STATIC_INLINE UINT32 OsSemValidCheck(LosSemCB *semPended)
if (OS_INT_ACTIVE) {
PRINT_ERR("!!!LOS_ERRNO_SEM_PEND_INTERR!!!\n");
#if (LOSCFG_PLATFORM_EXC == 1)
LOS_BackTrace();
#endif
return LOS_ERRNO_SEM_PEND_INTERR;
}
if (g_losTaskLock) {
PRINT_ERR("!!!LOS_ERRNO_SEM_PEND_IN_LOCK!!!\n");
#if (LOSCFG_PLATFORM_EXC == 1)
LOS_BackTrace();
#endif
return LOS_ERRNO_SEM_PEND_IN_LOCK;
}

4
kernel/src/los_swtmr.c Executable file → Normal file
View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -39,6 +39,7 @@
#include "los_cpup.h"
#endif
#include "los_debug.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
@@ -240,7 +241,7 @@ LITE_OS_SEC_TEXT WEAK VOID OsIdleTask(VOID)
{
while (1) {
OsRecyleFinishedTask();
#if (LOSCFG_KERNEL_RUNSTOP == YES)
#if (LOSCFG_KERNEL_RUNSTOP == 1)
HalEnterSleep(OS_SYS_NORMAL_SLEEP);
#endif
}
@@ -1656,8 +1657,6 @@ VOID LOS_Schedule(VOID)
LOS_IntRestore(intSave);
}
#if (LOSCFG_BASE_CORE_TIMESLICE == 1)
LITE_OS_SEC_BSS OsTaskRobin g_taskTimeSlice;

6
kernel/src/los_tick.c Executable file → Normal file
View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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:
@@ -30,9 +30,9 @@
*/
#include "los_tick.h"
#include "los_config.h"
#include "los_task.h"
#include "los_swtmr.h"
#include "los_config.h"
#ifdef __cplusplus
#if __cplusplus

Some files were not shown because too many files have changed in this diff Show More