├── Huawei_LiteOS ├── kernel │ ├── base │ │ ├── core │ │ │ ├── los_priqueue.c │ │ │ ├── los_priqueue.inc │ │ │ ├── los_swtmr.c │ │ │ ├── los_swtmr.inc │ │ │ ├── los_sys.c │ │ │ ├── los_sys.inc │ │ │ ├── los_task.c │ │ │ ├── los_task.inc │ │ │ ├── los_tick.c │ │ │ ├── los_tick.inc │ │ │ ├── los_timeslice.c │ │ │ └── los_timeslice.inc │ │ ├── include │ │ │ ├── los_base.ph │ │ │ ├── los_event.ph │ │ │ ├── los_list.ph │ │ │ ├── los_membox.ph │ │ │ ├── los_memory.ph │ │ │ ├── los_memstat.ph │ │ │ ├── los_multipledlinkhead.ph │ │ │ ├── los_mux.ph │ │ │ ├── los_printf.ph │ │ │ ├── los_priqueue.ph │ │ │ ├── los_queue.ph │ │ │ ├── los_sem.ph │ │ │ ├── los_swtmr.ph │ │ │ ├── los_sys.ph │ │ │ ├── los_task.ph │ │ │ ├── los_tick.ph │ │ │ ├── los_timeslice.ph │ │ │ └── los_typedef.ph │ │ ├── ipc │ │ │ ├── los_event.c │ │ │ ├── los_event.inc │ │ │ ├── los_mux.c │ │ │ ├── los_mux.inc │ │ │ ├── los_queue.c │ │ │ ├── los_queue.inc │ │ │ ├── los_sem.c │ │ │ └── los_sem.inc │ │ ├── mem │ │ │ ├── los_membox.c │ │ │ ├── los_membox.inc │ │ │ ├── los_memory.c │ │ │ ├── los_memory.inc │ │ │ ├── los_memstat.c │ │ │ ├── los_memstat.inc │ │ │ ├── los_multipledlinkhead.c │ │ │ └── los_multipledlinkhead.inc │ │ └── misc │ │ │ └── los_misc.c │ └── include │ │ ├── los_base.h │ │ ├── los_errno.h │ │ ├── los_event.h │ │ ├── los_list.h │ │ ├── los_membox.h │ │ ├── los_memory.h │ │ ├── los_multipledlinkhead.h │ │ ├── los_mux.h │ │ ├── los_printf.h │ │ ├── los_priqueue.h │ │ ├── los_queue.h │ │ ├── los_sem.h │ │ ├── los_swtmr.h │ │ ├── los_sys.h │ │ ├── los_tables.h │ │ ├── los_task.h │ │ ├── los_tick.h │ │ └── los_typedef.h └── platform │ ├── bsp │ └── sample │ │ └── config │ │ ├── los_builddef.h │ │ ├── los_config.c │ │ └── los_config.h │ └── cpu │ └── arm │ └── cortex-m4 │ ├── los_dispatch.s │ ├── los_hw.c │ ├── los_hw.h │ ├── los_hw_tick.c │ ├── los_hwi.c │ ├── los_hwi.h │ └── los_vendor.s ├── LICENSE ├── Projects └── EWARM │ └── cortex-m4 │ └── stm32f411 │ ├── Application │ └── README.md │ ├── Huawei_LiteOS.dep │ ├── Huawei_LiteOS.ewd │ ├── Huawei_LiteOS.ewp │ ├── Huawei_LiteOS.ewt │ ├── Huawei_LiteOS.eww │ ├── Huawei_LiteOS_cortexMF411.icf │ └── settings │ ├── Huawei_LiteOS.Debug.cspy.bat │ ├── Huawei_LiteOS.crun │ ├── Huawei_LiteOS.dbgdt │ ├── Huawei_LiteOS.dni │ ├── Huawei_LiteOS.wsdt │ ├── Huawei_LiteOS.wspos │ └── Huawei_LiteOS_Debug.jlink ├── README.md └── doc └── HuaweiLiteOSKernelDevGuide.chm /Huawei_LiteOS/kernel/base/core/los_priqueue.c: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #include "los_priqueue.inc" 36 | 37 | #include "los_base.ph" 38 | #include "los_task.ph" 39 | 40 | #include "los_memory.h" 41 | 42 | LITE_OS_SEC_BSS LOS_DL_LIST *g_pstLosPriorityQueueList; 43 | 44 | VOID osPriqueueInit(VOID) 45 | { 46 | UINT32 uwPri = 0; 47 | UINT32 uwSize = 0; 48 | 49 | uwSize = LOS_PRIORITY_QUEUE_PRIORITYNUM * sizeof(LOS_DL_LIST); 50 | g_pstLosPriorityQueueList = (LOS_DL_LIST *)LOS_MemAlloc(m_aucSysMem0, uwSize); 51 | if (NULL == g_pstLosPriorityQueueList) 52 | { 53 | return; 54 | } 55 | 56 | for (uwPri = 0; uwPri < LOS_PRIORITY_QUEUE_PRIORITYNUM; ++uwPri) 57 | { 58 | LOS_ListInit(&g_pstLosPriorityQueueList[uwPri]); 59 | } 60 | } 61 | 62 | VOID LOS_PriqueueEnqueue(LOS_DL_LIST *ptrPQItem, UINT32 uwPri) 63 | { 64 | LOS_ListTailInsert(&g_pstLosPriorityQueueList[uwPri], ptrPQItem); 65 | } 66 | 67 | VOID LOS_PriqueueDequeue(LOS_DL_LIST *ptrPQItem) 68 | { 69 | LOS_ListDelete(ptrPQItem); 70 | } 71 | 72 | LOS_DL_LIST *LOS_PriqueueTop(VOID) 73 | { 74 | UINT32 uwPri = 0; 75 | 76 | for (uwPri = 0; uwPri < LOS_PRIORITY_QUEUE_PRIORITYNUM; ++uwPri) 77 | { 78 | if (!LOS_ListEmpty(&g_pstLosPriorityQueueList[uwPri])) 79 | { 80 | return LOS_DL_LIST_FIRST(&g_pstLosPriorityQueueList[uwPri]); 81 | } 82 | } 83 | 84 | return (LOS_DL_LIST *)NULL; 85 | } 86 | 87 | UINT32 LOS_PriqueueSize(UINT32 uwPri) 88 | { 89 | UINT32 uwItemCnt = 0; 90 | LOS_DL_LIST *pstCurPQNode = (LOS_DL_LIST *)NULL; 91 | 92 | LOS_DL_LIST_FOR_EACH(pstCurPQNode, &g_pstLosPriorityQueueList[uwPri]) 93 | { 94 | ++uwItemCnt; 95 | } 96 | 97 | return uwItemCnt; 98 | } 99 | 100 | UINT32 LOS_PriqueueTotalSize(VOID) 101 | { 102 | UINT32 uwPri = 0; 103 | UINT32 uwTotalSize = 0; 104 | 105 | for (uwPri = 0; uwPri < LOS_PRIORITY_QUEUE_PRIORITYNUM; ++uwPri) 106 | { 107 | uwTotalSize += LOS_PriqueueSize(uwPri); 108 | } 109 | 110 | return uwTotalSize; 111 | } 112 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/base/core/los_priqueue.inc: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #ifndef _LOS_PRIQUEUE_INC 36 | #define _LOS_PRIQUEUE_INC 37 | 38 | #include "los_priqueue.ph" 39 | 40 | #endif /* _LOS_PRIQUEUE_INC */ 41 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/base/core/los_swtmr.inc: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #ifndef _LOS_SWTMR_INC 36 | #define _LOS_SWTMR_INC 37 | 38 | #include "los_swtmr.ph" 39 | 40 | #ifdef __cplusplus 41 | #if __cplusplus 42 | extern "C" { 43 | #endif /* __cplusplus */ 44 | #endif /* __cplusplus */ 45 | 46 | 47 | extern SWTMR_CTRL_S *m_pstSwtmrFreeList; 48 | 49 | 50 | 51 | 52 | #ifdef __cplusplus 53 | #if __cplusplus 54 | } 55 | #endif /* __cplusplus */ 56 | #endif /* __cplusplus */ 57 | 58 | #endif /* _LOS_SWTMR_INC */ 59 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/base/core/los_sys.inc: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #ifndef _LOS_SYS_INC 36 | #define _LOS_SYS_INC 37 | 38 | #include "los_sys.ph" 39 | 40 | #ifdef __cplusplus 41 | #if __cplusplus 42 | extern "C" { 43 | #endif /* __cplusplus */ 44 | #endif /* __cplusplus */ 45 | 46 | 47 | /** 48 | * @ingroup los_sys 49 | *Number of operable bits of a 32-bit operand 50 | */ 51 | #define OS_SYS_MV_32_BIT 32 52 | 53 | /** 54 | * @ingroup los_sys 55 | *Number of milliseconds in one second. 56 | */ 57 | #define OS_SYS_MS_PER_SECOND 1000 58 | 59 | /** 60 | * @ingroup los_sys 61 | *Number of microseconds in one second. 62 | */ 63 | #define OS_SYS_US_PER_SECOND 1000000 64 | 65 | /** 66 | * @ingroup los_sys 67 | *The maximum length of name. 68 | */ 69 | #define OS_SYS_APPVER_NAME_MAX 64 70 | 71 | /** 72 | * @ingroup los_sys 73 | *The magic word. 74 | */ 75 | #define OS_SYS_MAGIC_WORD 0xAAAAAAAA 76 | 77 | /** 78 | * @ingroup los_sys 79 | *The initialization value of stack space. 80 | */ 81 | #define OS_SYS_EMPTY_STACK 0xCACACACA 82 | 83 | 84 | #ifdef __cplusplus 85 | #if __cplusplus 86 | } 87 | #endif /* __cplusplus */ 88 | #endif /* __cplusplus */ 89 | 90 | #endif /* _LOS_SYS_INC */ 91 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/base/core/los_task.inc: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #ifndef _LOS_TASK_INC 36 | #define _LOS_TASK_INC 37 | 38 | #include "los_task.ph" 39 | 40 | #ifdef __cplusplus 41 | #if __cplusplus 42 | extern "C" { 43 | #endif /* __cplusplus */ 44 | #endif /* __cplusplus */ 45 | 46 | 47 | #define EVALUATE_L(UWNUM, VALUE) \ 48 | UWNUM = (((UWNUM) & 0xf8000000) | (VALUE)) 49 | 50 | #define EVALUATE_H(UWNUM, VALUE) \ 51 | UWNUM = (((UWNUM) & 0x07ffffff)| ((VALUE) << 27)) 52 | 53 | #define UWROLLNUMSUB(UWNUM1,UWNUM2) \ 54 | UWNUM1 = ((UWNUM1 & 0xf8000000) | (UWROLLNUM(UWNUM1) - UWROLLNUM(UWNUM2))) 55 | 56 | #define UWROLLNUMADD(UWNUM1,UWNUM2) \ 57 | UWNUM1 = ((UWNUM1 & 0xf8000000) | (UWROLLNUM(UWNUM1) + UWROLLNUM(UWNUM2))) 58 | 59 | #define UWROLLNUM(UWNUM) ((UWNUM) & 0x07ffffff) 60 | 61 | #define UWSORTINDEX(UWNUM) (UWNUM >> 27) 62 | 63 | #define UWROLLNUMDEC(UWNUM) \ 64 | UWNUM = (UWNUM - 1) 65 | 66 | #define OS_TSK_SORTLINK_LEN 32 67 | #define OS_TSK_SORTLINK_LOGLEN 5 68 | #define OS_TSK_SORTLINK_MASK (OS_TSK_SORTLINK_LEN - 1) 69 | 70 | #define OS_CHECK_TASK_BLOCK ((OS_TASK_STATUS_DELAY | OS_TASK_STATUS_PEND | OS_TASK_STATUS_SUSPEND | OS_TASK_STATUS_EVENT | OS_TASK_STATUS_PEND_QUEUE)) 71 | 72 | #define OS_TASK_ID_CHECK(uwTaskID) LOS_ASSERT_COND(OS_TSK_GET_INDEX(uwTaskID) < g_uwTskMaxNum) 73 | #define OS_CHECK_TSK_PID_NOIDLE(uwTaskID) (OS_TSK_GET_INDEX(uwTaskID) >= g_uwTskMaxNum) 74 | 75 | typedef struct tagTskSortLinkAttr 76 | { 77 | LOS_DL_LIST *pstSortLink; 78 | UINT16 usCursor; 79 | UINT16 usUnUsed; 80 | } TSK_SORTLINK_ATTRIBUTE_S; 81 | 82 | /** 83 | * @ingroup los_task 84 | * Task stack information structure. 85 | * 86 | */ 87 | typedef struct tagStackInfo 88 | { 89 | UINT32 uwTop; /**, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #include "los_tick.inc" 36 | 37 | #include "los_base.ph" 38 | #include "los_swtmr.ph" 39 | #include "los_task.ph" 40 | #include "los_timeslice.ph" 41 | 42 | #ifdef __cplusplus 43 | #if __cplusplus 44 | extern "C" { 45 | #endif /* __cplusplus */ 46 | #endif /* __cplusplus */ 47 | 48 | 49 | LITE_OS_SEC_BSS UINT64 g_ullTickCount; 50 | LITE_OS_SEC_BSS UINT32 g_uwTicksPerSec; 51 | LITE_OS_SEC_BSS UINT32 g_uwCyclePerSec; 52 | 53 | /***************************************************************************** 54 | Description : Tick interruption handler 55 | Input : None 56 | Output : None 57 | Return : None 58 | *****************************************************************************/ 59 | extern void hal_clock_irqclear(void); 60 | LITE_OS_SEC_TEXT VOID osTickHandler(VOID) 61 | { 62 | #if (LOSCFG_BASE_CORE_TICK_HW_TIME == YES) 63 | hal_clock_irqclear();//diff from every platform 64 | #endif 65 | 66 | g_ullTickCount ++; 67 | 68 | #if(LOSCFG_BASE_CORE_TIMESLICE == YES) 69 | osTimesliceCheck(); 70 | #endif 71 | 72 | osTaskScan(); //task timeout scan 73 | 74 | #if (LOSCFG_BASE_CORE_SWTMR == YES) 75 | if (osSwtmrScan() != LOS_OK){ 76 | PRINT_ERR("%s, %d\n", __FUNCTION__, __LINE__); 77 | } 78 | #endif 79 | } 80 | 81 | 82 | #ifdef __cplusplus 83 | #if __cplusplus 84 | } 85 | #endif /* __cplusplus */ 86 | #endif /* __cplusplus */ 87 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/base/core/los_tick.inc: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #ifndef _LOS_TICK_INC 36 | #define _LOS_TICK_INC 37 | 38 | #include "los_tick.ph" 39 | 40 | #endif /* _LOS_TICK_INC */ 41 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/base/core/los_timeslice.c: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #include "los_sys.ph" 36 | #include "los_task.ph" 37 | #include "los_tick.ph" 38 | #include "los_typedef.ph" 39 | 40 | #ifdef __cplusplus 41 | #if __cplusplus 42 | extern "C" { 43 | #endif /* __cplusplus */ 44 | #endif /* __cplusplus */ 45 | 46 | #if(LOSCFG_BASE_CORE_TIMESLICE == YES) 47 | LITE_OS_SEC_BSS OS_TASK_ROBIN_S g_stTaskTimeSlice; 48 | 49 | /***************************************************************************** 50 | Function : osTimesliceInit 51 | Description : Initialztion Timeslice 52 | Input : None 53 | Output : None 54 | Return : None 55 | *****************************************************************************/ 56 | LITE_OS_SEC_TEXT_INIT VOID osTimesliceInit(VOID) 57 | { 58 | g_stTaskTimeSlice.pstTask = (LOS_TASK_CB *)NULL; 59 | g_stTaskTimeSlice.usTout = LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT; 60 | } 61 | 62 | /***************************************************************************** 63 | Function : osTimesliceCheck 64 | Description : check Timeslice 65 | Input : None 66 | Output : None 67 | Return : None 68 | *****************************************************************************/ 69 | LITE_OS_SEC_TEXT VOID osTimesliceCheck(VOID) 70 | { 71 | if (g_stTaskTimeSlice.pstTask != g_stLosTask.pstRunTask) 72 | { 73 | g_stTaskTimeSlice.pstTask = g_stLosTask.pstRunTask; 74 | g_stTaskTimeSlice.usTime = (UINT16)g_ullTickCount + g_stTaskTimeSlice.usTout - 1; 75 | } 76 | 77 | if (g_stTaskTimeSlice.usTime == (UINT16)g_ullTickCount) 78 | { 79 | g_stTaskTimeSlice.pstTask = (LOS_TASK_CB *)NULL; 80 | if (LOS_TaskYield() != LOS_OK) 81 | { 82 | PRINT_INFO("%s, %d\n", __FUNCTION__, __LINE__); 83 | } 84 | } /*lint !e548*/ 85 | } 86 | 87 | #endif 88 | 89 | #ifdef __cplusplus 90 | #if __cplusplus 91 | } 92 | #endif /* __cplusplus */ 93 | #endif /* __cplusplus */ 94 | 95 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/base/core/los_timeslice.inc: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | /**@defgroup los_timeslice Timeslice 36 | * @ingroup kernel 37 | */ 38 | 39 | #ifndef _LOS_TIMESLICE_INC 40 | #define _LOS_TIMESLICE_INC 41 | 42 | #include "los_timeslice.ph" 43 | 44 | #endif /* _LOS_TIMESLICE_INC */ 45 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/base/include/los_base.ph: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #ifndef _LOS_BASE_PH 36 | #define _LOS_BASE_PH 37 | 38 | #include "los_base.h" 39 | 40 | #ifdef __cplusplus 41 | #if __cplusplus 42 | extern "C" { 43 | #endif /* __cplusplus */ 44 | #endif /* __cplusplus */ 45 | 46 | 47 | /** 48 | * @ingroup los_base 49 | * Define the CPU Tick structure. 50 | */ 51 | typedef struct tagCpuTick 52 | { 53 | UINT32 uwCntHi; /**< Upper 32 bits of the tick value*/ 54 | UINT32 uwCntLo; /**< Lower 32 bits of the tick value*/ 55 | } CPU_TICK; 56 | 57 | #define OS_GOTO_ERREND() \ 58 | do \ 59 | { \ 60 | goto LOS_ERREND; \ 61 | } while (0) 62 | 63 | 64 | #ifdef __cplusplus 65 | #if __cplusplus 66 | } 67 | #endif /* __cplusplus */ 68 | #endif /* __cplusplus */ 69 | 70 | #endif /* _LOS_BASE_PH */ 71 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/base/include/los_event.ph: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #ifndef _LOS_EVENT_PH 36 | #define _LOS_EVENT_PH 37 | 38 | #include "los_event.h" 39 | 40 | #ifdef __cplusplus 41 | #if __cplusplus 42 | extern "C" { 43 | #endif /* __cplusplus */ 44 | #endif /* __cplusplus */ 45 | 46 | 47 | extern UINT32 osEventReadOnce(PEVENT_CB_S pstEventCB, UINT32 uwEventMask, UINT32 uwMode, UINT32 uwTimeOut); 48 | extern UINT32 osEventWriteOnce(PEVENT_CB_S pstEventCB, UINT32 uwEvents); 49 | 50 | 51 | #ifdef __cplusplus 52 | #if __cplusplus 53 | } 54 | #endif /* __cplusplus */ 55 | #endif /* __cplusplus */ 56 | 57 | #endif /* _LOS_EVENT_PH */ 58 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/base/include/los_list.ph: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #ifndef _LOS_LIST_PH 36 | #define _LOS_LIST_PH 37 | 38 | #include "los_list.h" 39 | 40 | #endif /* _LOS_LIST_PH */ 41 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/base/include/los_membox.ph: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #ifndef _LOS_MEMBOX_PH 36 | #define _LOS_MEMBOX_PH 37 | 38 | #include "los_membox.h" 39 | 40 | #ifdef __cplusplus 41 | #if __cplusplus 42 | extern "C" { 43 | #endif /* __cplusplus */ 44 | #endif /* __cplusplus */ 45 | 46 | 47 | #ifdef __cplusplus 48 | #if __cplusplus 49 | } 50 | #endif /* __cplusplus */ 51 | #endif /* __cplusplus */ 52 | 53 | #endif /* _LOS_MEMBOX_PH */ 54 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/base/include/los_memory.ph: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #ifndef _LOS_MEMORY_PH 36 | #define _LOS_MEMORY_PH 37 | 38 | #include "los_memory.h" 39 | 40 | #ifdef __cplusplus 41 | #if __cplusplus 42 | extern "C" { 43 | #endif /* __cplusplus */ 44 | #endif /* __cplusplus */ 45 | 46 | 47 | /* 48 | * memcheck error code: the stack have not inited 49 | * Value: 0x02000100 50 | * Solution: do memcheck must after stack mem init 51 | */ 52 | #define OS_ERRNO_MEMCHECK_NOT_INIT LOS_ERRNO_OS_ERROR(LOS_MOD_MEM, 0x0) 53 | 54 | /* 55 | * memcheck error code: the pPtr is NULL 56 | * Value: 0x02000101 57 | * Solution: don't give a NULL parameter 58 | */ 59 | #define OS_ERRNO_MEMCHECK_PARA_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_MEM, 0x1) 60 | 61 | /* 62 | * memcheck error code: the pPtr addr not in the suit range 63 | * Value: 0x02000102 64 | * Solution: check pPtr and comfirm it included by stack 65 | */ 66 | #define OS_ERRNO_MEMCHECK_OUTSIDE LOS_ERRNO_OS_ERROR(LOS_MOD_MEM, 0x2) 67 | 68 | /* 69 | * memcheck error code: can't find the ctrl node 70 | * Value: 0x02000103 71 | * Solution: confirm the pPtr if this node has been freed or has not been alloced 72 | */ 73 | #define OS_ERRNO_MEMCHECK_NO_HEAD LOS_ERRNO_OS_ERROR(LOS_MOD_MEM, 0x3) 74 | 75 | /* 76 | * memcheck error code: the para level is wrong 77 | * Value: 0x02000104 78 | * Solution: checkout the memcheck level by the func "OS_GetMemCheck_Level" 79 | */ 80 | #define OS_ERRNO_MEMCHECK_WRONG_LEVEL LOS_ERRNO_OS_ERROR(LOS_MOD_MEM, 0x4) 81 | 82 | /* 83 | * memcheck error code: memcheck func not open 84 | * Value: 0x02000105 85 | * Solution: enable memcheck by the func "OS_SetMemCheck_Level" 86 | */ 87 | #define OS_ERRNO_MEMCHECK_DISABLED LOS_ERRNO_OS_ERROR(LOS_MOD_MEM, 0x5) 88 | 89 | 90 | #ifdef __cplusplus 91 | #if __cplusplus 92 | } 93 | #endif /* __cplusplus */ 94 | #endif /* __cplusplus */ 95 | 96 | #endif /* _LOS_MEMORY_PH */ 97 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/base/include/los_memstat.ph: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #ifndef _LOS_MEMSTAT_PH 36 | #define _LOS_MEMSTAT_PH 37 | 38 | #include "los_typedef.h" 39 | 40 | #ifdef __cplusplus 41 | #if __cplusplus 42 | extern "C" { 43 | #endif /* __cplusplus */ 44 | #endif /* __cplusplus */ 45 | 46 | 47 | extern VOID osTaskMemUsedInc(UINT32 uwUsedSize); 48 | extern VOID osTaskMemUsedDec(UINT32 uwUsedSize); 49 | extern UINT32 osTaskMemUsage(UINT32 uwTaskId); 50 | 51 | 52 | #ifdef __cplusplus 53 | #if __cplusplus 54 | } 55 | #endif /* __cplusplus */ 56 | #endif /* __cplusplus */ 57 | 58 | #endif /* _LOS_MEMSTAT_PH */ 59 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/base/include/los_multipledlinkhead.ph: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #ifndef _LOS_MULTIPLE_DLINK_HEAD_PH 36 | #define _LOS_MULTIPLE_DLINK_HEAD_PH 37 | 38 | #include "los_multipledlinkhead.h" 39 | 40 | #endif /* _LOS_MULTIPLE_DLINK_HEAD_PH */ 41 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/base/include/los_mux.ph: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #ifndef _LOS_MUX_PH 36 | #define _LOS_MUX_PH 37 | 38 | #include "los_task.ph" 39 | 40 | #include "los_mux.h" 41 | 42 | #ifdef __cplusplus 43 | #if __cplusplus 44 | extern "C"{ 45 | #endif /* __cplusplus */ 46 | #endif /* __cplusplus */ 47 | 48 | 49 | /** 50 | * @ingroup los_mux 51 | * Mutex object. 52 | */ 53 | typedef struct 54 | { 55 | UINT8 ucMuxStat; /**< State OS_MUX_UNUSED,OS_MUX_USED */ 56 | UINT16 usMuxCount; /**< Times of locking a mutex */ 57 | UINT32 ucMuxID; /**< Handle ID*/ 58 | LOS_DL_LIST stMuxList; /**< Mutex linked list*/ 59 | LOS_TASK_CB *pstOwner; /**< The current thread that is locking a mutex*/ 60 | UINT16 usPriority; /**< Priority of the thread that is locking a mutex */ 61 | } MUX_CB_S; 62 | 63 | /** 64 | * @ingroup los_mux 65 | * Mutex state: not in use. 66 | */ 67 | #define OS_MUX_UNUSED 0 68 | 69 | /** 70 | * @ingroup los_mux 71 | * Mutex state: in use. 72 | */ 73 | #define OS_MUX_USED 1 74 | 75 | extern MUX_CB_S *g_pstAllMux; 76 | 77 | /** 78 | * @ingroup los_mux 79 | * Obtain the pointer to a mutex object of the mutex that has a specified handle. 80 | */ 81 | #define GET_MUX(muxid) (((MUX_CB_S *)g_pstAllMux) + (muxid)) 82 | 83 | 84 | #ifdef __cplusplus 85 | #if __cplusplus 86 | } 87 | #endif /* __cplusplus */ 88 | #endif /* __cplusplus */ 89 | 90 | #endif /* _LOS_MUX_PH */ 91 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/base/include/los_printf.ph: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #ifndef _LOS_PRINTF_PH 36 | #define _LOS_PRINTF_PH 37 | 38 | #include "los_printf.h" 39 | 40 | #ifdef __cplusplus 41 | #if __cplusplus 42 | extern "C" { 43 | #endif /* __cplusplus */ 44 | #endif /* __cplusplus */ 45 | 46 | 47 | void _dprintf(const char *fmt, va_list ap); 48 | int __dprintf(const char *fmt, va_list ap, void (*uart_fputc)(unsigned n, void *cookie), char *cookie); 49 | 50 | 51 | #ifdef __cplusplus 52 | #if __cplusplus 53 | } 54 | #endif /* __cplusplus */ 55 | #endif /* __cplusplus */ 56 | 57 | #endif /* _LOS_PRINTF_PH */ 58 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/base/include/los_priqueue.ph: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #ifndef _LOS_PRIQUEUE_PH 36 | #define _LOS_PRIQUEUE_PH 37 | 38 | #include "los_priqueue.h" 39 | 40 | #ifdef __cplusplus 41 | #if __cplusplus 42 | extern "C" { 43 | #endif /* __cplusplus */ 44 | #endif /* __cplusplus */ 45 | 46 | 47 | /** 48 | *@ingroup los_priqueue 49 | *@brief Initialize the priority queue. 50 | * 51 | *@par Description: 52 | *This API is used to initialize the priority queue. 53 | *@attention 54 | *
    55 | *
  • None.
  • 56 | *
57 | *@param none. 58 | * 59 | *@retval none. 60 | *@par Dependency: 61 | *
  • los_priqueue.h: the header file that contains the API declaration.
62 | *@see none. 63 | *@since Huawei LiteOS V100R001C00 64 | */ 65 | extern VOID osPriqueueInit(VOID); 66 | 67 | 68 | #ifdef __cplusplus 69 | #if __cplusplus 70 | } 71 | #endif /* __cplusplus */ 72 | #endif /* __cplusplus */ 73 | 74 | #endif /* _LOS_PRIQUEUE_PH */ 75 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/base/include/los_sem.ph: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #ifndef _LOS_SEM_PH 36 | #define _LOS_SEM_PH 37 | 38 | #include "los_sem.h" 39 | 40 | #ifdef __cplusplus 41 | #if __cplusplus 42 | extern "C" { 43 | #endif /* __cplusplus */ 44 | #endif /* __cplusplus */ 45 | 46 | 47 | /** 48 | * @ingroup los_sem 49 | * Semaphore control structure. 50 | */ 51 | typedef struct 52 | { 53 | UINT8 usSemStat; /**< Semaphore state*/ 54 | UINT16 uwSemCount; /**< Number of available semaphores*/ 55 | UINT32 usSemID; /**< Semaphore control structure ID*/ 56 | LOS_DL_LIST stSemList; /**< Queue of tasks that are waiting on a semaphore*/ 57 | } SEM_CB_S; 58 | 59 | /** 60 | * @ingroup los_sem 61 | *The semaphore is not in use. 62 | * 63 | */ 64 | #define OS_SEM_UNUSED 0 65 | /** 66 | * @ingroup los_sem 67 | *The semaphore is used. 68 | * 69 | */ 70 | #define OS_SEM_USED 1 71 | /** 72 | * @ingroup los_sem 73 | * Obtain the head node in a semaphore doubly linked list. 74 | * 75 | */ 76 | #define GET_SEM_LIST(ptr) LOS_DL_LIST_ENTRY(ptr, SEM_CB_S, stSemList) 77 | extern SEM_CB_S *g_pstAllSem; 78 | /** 79 | * @ingroup los_sem 80 | * Obtain a semaphore ID. 81 | * 82 | */ 83 | #define GET_SEM(semid) (((SEM_CB_S *)g_pstAllSem) + (semid)) 84 | /** 85 | * @ingroup los_sem 86 | * Maximum value of task information. 87 | * 88 | */ 89 | #define OS_MAX_PENDTASK_INFO 4 90 | 91 | 92 | #ifdef __cplusplus 93 | #if __cplusplus 94 | } 95 | #endif /* __cplusplus */ 96 | #endif /* __cplusplus */ 97 | 98 | #endif /* _LOS_SEM_PH */ 99 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/base/include/los_swtmr.ph: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #ifndef _LOS_SWTMR_PH 36 | #define _LOS_SWTMR_PH 37 | 38 | #include "los_swtmr.h" 39 | 40 | #ifdef __cplusplus 41 | #if __cplusplus 42 | extern "C" { 43 | #endif /* __cplusplus */ 44 | #endif /* __cplusplus */ 45 | 46 | 47 | /** 48 | * @ingroup los_swtmr 49 | * Software timer state 50 | */ 51 | enum enSwTmrState 52 | { 53 | OS_SWTMR_STATUS_UNUSED, /**< The software timer is not used.*/ 54 | OS_SWTMR_STATUS_CREATED, /**< The software timer is created.*/ 55 | OS_SWTMR_STATUS_TICKING, /**< The software timer is timing.*/ 56 | }; 57 | 58 | /** 59 | * @ingroup los_swtmr 60 | * Structure of the callback function that handles software timer timeout 61 | */ 62 | typedef struct tagSwTmrHandlerItem 63 | { 64 | SWTMR_PROC_FUNC pfnHandler; /**< Callback function that handles software timer timeout */ 65 | UINT32 uwArg; /**< Parameter passed in when the callback function that handles software timer timeout is called */ 66 | } SWTMR_HANDLER_ITEM_S; 67 | 68 | /** 69 | * @ingroup los_swtmr 70 | * Type of the pointer to the structure of the callback function that handles software timer timeout 71 | */ 72 | typedef SWTMR_HANDLER_ITEM_S *SWTMR_HANDLER_ITEM_P; 73 | 74 | extern SWTMR_CTRL_S *m_pstSwtmrCBArray; 75 | 76 | #define OS_SWT_FROM_SID(SwTmrID) ((SWTMR_CTRL_S *)m_pstSwtmrCBArray + (SwTmrID % LOSCFG_BASE_CORE_SWTMR_LIMIT)) 77 | 78 | /** 79 | *@ingroup los_swtmr 80 | *@brief Scan a software timer. 81 | * 82 | *@par Description: 83 | *
    84 | *
  • This API is used to scan a software timer when a Tick interrupt occurs and determine whether the software timer expires.
  • 85 | *
86 | *@attention 87 | *
    88 | *
  • None.
  • 89 | *
90 | * 91 | *@param None. 92 | * 93 | *@retval None. 94 | *@par Dependency: 95 | *
  • los_swtmr.h: the header file that contains the API declaration.
96 | *@see LOS_SwtmrStop 97 | *@since Huawei LiteOS V100R001C00 98 | */ 99 | extern UINT32 osSwtmrScan(VOID); 100 | 101 | 102 | #ifdef __cplusplus 103 | #if __cplusplus 104 | } 105 | #endif /* __cplusplus */ 106 | #endif /* __cplusplus */ 107 | 108 | #endif /* _LOS_SWTMR_PH */ 109 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/base/include/los_sys.ph: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #ifndef _LOS_SYS_PH 36 | #define _LOS_SYS_PH 37 | 38 | #include "los_base.ph" 39 | 40 | #include "los_sys.h" 41 | 42 | #ifdef __cplusplus 43 | #if __cplusplus 44 | extern "C" { 45 | #endif /* __cplusplus */ 46 | #endif /* __cplusplus */ 47 | 48 | 49 | /** 50 | * @ingroup los_sys 51 | *Number of milliseconds in one second. 52 | */ 53 | #define OS_SYS_MS_PER_SECOND 1000 54 | 55 | /** 56 | * @ingroup los_sys 57 | *Number of microseconds in one second. 58 | */ 59 | #define OS_SYS_US_PER_SECOND 1000000 60 | 61 | /** 62 | *@ingroup los_sys 63 | *@brief Convert cycles to milliseconds. 64 | * 65 | *@par Description: 66 | *This API is used to convert cycles to milliseconds. 67 | *@attention 68 | *
    69 | *
  • None.
  • 70 | *
71 | * 72 | *@param udwCycle [IN] Number of cycles. 73 | * 74 | *@retval Number of milliseconds obtained through the conversion. Cycles are successfully converted to milliseconds. 75 | *@par Dependency: 76 | *
  • los_sys.h: the header file that contains the API declaration.
77 | *@see None. 78 | *@since Huawei LiteOS V100R001C00 79 | */ 80 | INLINE UINT64 osCycle2MS(UINT64 udwCycle) 81 | { 82 | return (UINT64)((udwCycle / (OS_SYS_CLOCK / OS_SYS_MS_PER_SECOND))); 83 | } 84 | 85 | /** 86 | *@ingroup los_sys 87 | *@brief Convert cycles to microseconds. 88 | * 89 | *@par Description: 90 | *This API is used to convert cycles to microseconds. 91 | *@attention 92 | *
    93 | *
  • None.
  • 94 | *
95 | * 96 | *@param udwCycle [IN] Number of cycles. 97 | * 98 | *@retval Number of microseconds obtained through the conversion. Cycles are successfully converted to microseconds. 99 | *@par Dependency: 100 | *
  • los_sys.h: the header file that contains the API declaration.
101 | *@see None. 102 | *@since Huawei LiteOS V100R001C00 103 | */ 104 | INLINE UINT64 osCycle2US(UINT64 udwCycle) 105 | { 106 | UINT64 udwTmp = OS_SYS_CLOCK / OS_SYS_US_PER_SECOND; 107 | return (UINT64)(udwCycle / udwTmp); 108 | } 109 | 110 | /** 111 | *@ingroup los_sys 112 | *@brief Convert cycles to milliseconds. 113 | * 114 | *@par Description: 115 | *This API is used to convert cycles to milliseconds. 116 | *@attention 117 | *
    118 | *
  • None.
  • 119 | *
120 | * 121 | *@param pstCpuTick [IN] Number of CPU cycles. 122 | *@param puwMsHi [OUT] Upper 32 bits of the number of milliseconds. 123 | *@param puwMsLo [OUT] Lower 32 bits of the number of milliseconds. 124 | * 125 | *@retval #LOS_ERRNO_SYS_PTR_NULL 0x02000011: Invalid parameter. 126 | *@retval #LOS_OK 0: Cycles are successfully converted to microseconds. 127 | *@par Dependency: 128 | *
  • los_sys.h: the header file that contains the API declaration.
129 | *@see None. 130 | *@since Huawei LiteOS V100R001C00 131 | */ 132 | extern UINT32 osCpuTick2MS(CPU_TICK *pstCpuTick, UINT32 *puwMsHi, UINT32 *puwMsLo); 133 | 134 | /** 135 | *@ingroup los_sys 136 | *@brief Convert cycles to microseconds. 137 | * 138 | *@par Description: 139 | *This API is used to convert cycles to microseconds. 140 | *@attention 141 | *
    142 | *
  • None.
  • 143 | *
144 | * 145 | *@param pstCpuTick [IN] Number of CPU cycles. 146 | *@param puwUsHi [OUT] Upper 32 bits of the number of microseconds. 147 | *@param puwUsLo [OUT] Lower 32 bits of the number of microseconds. 148 | * 149 | *@retval #LOS_ERRNO_SYS_PTR_NULL 0x02000011: Invalid parameter. 150 | *@retval #LOS_OK 0: Cycles are successfully converted to microseconds. 151 | *@par Dependency: 152 | *
  • los_sys.h: the header file that contains the API declaration.
153 | *@see None. 154 | *@since Huawei LiteOS V100R001C00 155 | */ 156 | extern UINT32 osCpuTick2US(CPU_TICK *pstCpuTick, UINT32 *puwUsHi, UINT32 *puwUsLo); 157 | 158 | 159 | #ifdef __cplusplus 160 | #if __cplusplus 161 | } 162 | #endif /* __cplusplus */ 163 | #endif /* __cplusplus */ 164 | 165 | #endif /* _LOS_SYS_PH */ 166 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/base/include/los_tick.ph: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #ifndef _LOS_TICK_PH 36 | #define _LOS_TICK_PH 37 | 38 | #include "los_tick.h" 39 | 40 | #ifdef __cplusplus 41 | #if __cplusplus 42 | extern "C" { 43 | #endif /* __cplusplus */ 44 | #endif /* __cplusplus */ 45 | 46 | 47 | /** 48 | * @ingroup los_tick 49 | * Count of Ticks 50 | */ 51 | extern UINT64 g_ullTickCount; 52 | 53 | /** 54 | * @ingroup los_tick 55 | * @brief Handle the system tick timeout. 56 | * 57 | * @par Description: 58 | * This API is called when the system tick timeout and triggers the interrupt. 59 | * 60 | * @attention 61 | *
    62 | *
  • None.
  • 63 | *
64 | * 65 | * @param none. 66 | * 67 | * @retval None. 68 | * @par Dependency: 69 | *
  • los_tick.h: the header file that contains the API declaration.
70 | * @see None. 71 | * @since Huawei LiteOS V100R001C00 72 | */ 73 | extern VOID osTickHandler(VOID); 74 | 75 | 76 | #ifdef __cplusplus 77 | #if __cplusplus 78 | } 79 | #endif /* __cplusplus */ 80 | #endif /* __cplusplus */ 81 | 82 | #endif /* _LOS_TICK_PH */ 83 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/base/include/los_timeslice.ph: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | /**@defgroup los_timeslice Timeslice 36 | * @ingroup kernel 37 | */ 38 | 39 | #ifndef _LOS_TIMESLICE_PH 40 | #define _LOS_TIMESLICE_PH 41 | 42 | #ifdef __cplusplus 43 | #if __cplusplus 44 | extern "C" { 45 | #endif /* __cplusplus */ 46 | #endif /* __cplusplus */ 47 | 48 | 49 | /** 50 | *@ingroup los_timeslice 51 | *@brief Initialize time slices. 52 | * 53 | *@par Description: 54 | *
    55 | *
  • This API is used to initialize time slices that defines the cycle of time slices according to LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT.
  • 56 | *
57 | *@attention 58 | *
    59 | *
  • None.
  • 60 | *
61 | * 62 | *@param None. 63 | * 64 | *@retval None. 65 | *@par Dependency: 66 | *
  • los_timeslice.h: the header file that contains the API declaration.
67 | *@see None. 68 | *@since Huawei LiteOS V100R001C00 69 | */ 70 | extern VOID osTimesliceInit(VOID); 71 | 72 | /** 73 | *@ingroup los_timeslice 74 | *@brief Check time slices. 75 | * 76 | *@par Description: 77 | *
    78 | *
  • This API is used to check time slices. If the number of Ticks equals to the time for task switch, tasks are switched. Otherwise, the Tick counting continues.
  • 79 | *
80 | *@attention 81 | *
    82 | *
  • None.
  • 83 | *
84 | * 85 | *@param None. 86 | * 87 | *@retval None. 88 | *@par Dependency: 89 | *
  • los_timeslice.h: the header file that contains the API declaration.
90 | *@see None. 91 | *@since Huawei LiteOS V100R001C00 92 | */ 93 | extern VOID osTimesliceCheck(VOID); 94 | 95 | 96 | #ifdef __cplusplus 97 | #if __cplusplus 98 | } 99 | #endif /* __cplusplus */ 100 | #endif /* __cplusplus */ 101 | 102 | #endif /* _LOS_TIMESLICE_PH */ 103 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/base/include/los_typedef.ph: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #ifndef _LOS_TYPEDEF_PH 36 | #define _LOS_TYPEDEF_PH 37 | 38 | #include "los_typedef.h" 39 | 40 | #endif /* _LOS_TYPEDEF_PH */ 41 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/base/ipc/los_event.inc: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #ifndef _LOS_EVENT_INC 36 | #define _LOS_EVENT_INC 37 | 38 | #include "los_event.ph" 39 | 40 | #endif /* _LOS_EVENT_INC */ 41 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/base/ipc/los_mux.inc: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #ifndef _LOS_MUX_INC 36 | #define _LOS_MUX_INC 37 | 38 | #include "los_mux.ph" 39 | 40 | #ifdef __cplusplus 41 | #if __cplusplus 42 | extern "C"{ 43 | #endif /* __cplusplus */ 44 | #endif /* __cplusplus */ 45 | 46 | 47 | /** 48 | * @ingroup los_mux 49 | * Obtain the pointer to the linked list in the mutex pointed to by a specified pointer. 50 | */ 51 | #define GET_MUX_LIST(ptr) LOS_DL_LIST_ENTRY(ptr, MUX_CB_S, stMuxList) 52 | 53 | /** 54 | * @ingroup los_mux 55 | * Mutex global array address, which can be obtained by using a handle ID. 56 | */ 57 | extern MUX_CB_S *g_pstAllMux; 58 | 59 | 60 | #ifdef __cplusplus 61 | #if __cplusplus 62 | } 63 | #endif /* __cplusplus */ 64 | #endif /* __cplusplus */ 65 | 66 | #endif /* _LOS_MUX_INC */ 67 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/base/ipc/los_queue.inc: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #ifndef _LOS_QUEUE_INC 36 | #define _LOS_QUEUE_INC 37 | 38 | #include "los_queue.ph" 39 | 40 | #ifdef __cplusplus 41 | #if __cplusplus 42 | extern "C" { 43 | #endif /* __cplusplus */ 44 | #endif /* __cplusplus */ 45 | 46 | 47 | extern UINT32 osQueueCreate(UINT16 usLen, UINT32 *puwQueueID, UINT16 usMaxMsgSize, QUEUE_CB_S **ppstQueueCBOut); 48 | 49 | 50 | #ifdef __cplusplus 51 | #if __cplusplus 52 | } 53 | #endif /* __cplusplus */ 54 | #endif /* __cplusplus */ 55 | 56 | #endif /* _LOS_QUEUE_INC */ 57 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/base/ipc/los_sem.inc: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #ifndef _LOS_SEM_INC 36 | #define _LOS_SEM_INC 37 | 38 | #include "los_sem.ph" 39 | 40 | #ifdef __cplusplus 41 | #if __cplusplus 42 | extern "C" { 43 | #endif /* __cplusplus */ 44 | #endif /* __cplusplus */ 45 | 46 | 47 | extern SEM_CB_S *g_pstAllSem; 48 | 49 | 50 | #ifdef __cplusplus 51 | #if __cplusplus 52 | } 53 | #endif /* __cplusplus */ 54 | #endif /* __cplusplus */ 55 | 56 | #endif /* _LOS_SEM_INC */ 57 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/base/mem/los_membox.c: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #include "los_membox.inc" 36 | #include "los_base.ph" 37 | #include "los_hwi.h" 38 | #ifdef LOSCFG_LIB_LIBC 39 | #include "string.h" 40 | #endif 41 | 42 | #define OS_MEMBOX_NEXT(addr, uwBlkSize) (LOS_MEMBOX_NODE *)((UINT8 *)(addr) + (uwBlkSize)) 43 | 44 | #ifdef LOS_MEMBOX_CHECK 45 | #define OS_MEMBOX_MAGIC 0xa55a5aa5 46 | #define OS_MEMBOX_SET_MAGIC(addr) *((UINT32 *)(addr)) = OS_MEMBOX_MAGIC 47 | #define OS_MEMBOX_CHECK_MAGIC(addr) ((*((UINT32 *)(addr)) == OS_MEMBOX_MAGIC) ? LOS_OK : LOS_NOK) 48 | #else 49 | #define OS_MEMBOX_SET_MAGIC(addr) 50 | #define OS_MEMBOX_CHECK_MAGIC(addr) LOS_OK 51 | #endif 52 | 53 | #define OS_MEMBOX_USER_ADDR(addr) ((VOID *)((UINT8 *)(addr) + LOS_MEMBOX_MAGIC_SIZE)) 54 | #define OS_MEMBOX_NODE_ADDR(addr) ((LOS_MEMBOX_NODE *)((UINT8 *)(addr) - LOS_MEMBOX_MAGIC_SIZE)) 55 | 56 | 57 | INLINE UINT32 osCheckBoxMem(const LOS_MEMBOX_INFO *pstBoxInfo, const VOID *pNode) 58 | { 59 | UINT32 uwOffSet; 60 | 61 | if (pstBoxInfo->uwBlkSize == 0) 62 | { 63 | return LOS_NOK; 64 | } 65 | 66 | uwOffSet = ((UINT32)pNode - (UINT32)(pstBoxInfo + 1)); 67 | if ((uwOffSet % pstBoxInfo->uwBlkSize) != 0) 68 | { 69 | return LOS_NOK; 70 | } 71 | 72 | if ((uwOffSet / pstBoxInfo->uwBlkSize) >= pstBoxInfo->uwBlkNum) 73 | { 74 | return LOS_NOK; 75 | } 76 | 77 | return OS_MEMBOX_CHECK_MAGIC(pNode); 78 | } 79 | 80 | LITE_OS_SEC_TEXT_INIT UINT32 LOS_MemboxInit(VOID *pPool, UINT32 uwBoxSize, UINT32 uwBlkSize) 81 | { 82 | LOS_MEMBOX_INFO *pstBoxInfo = (LOS_MEMBOX_INFO *)pPool; 83 | LOS_MEMBOX_NODE *pstNode = (LOS_MEMBOX_NODE *)NULL; 84 | UINT32 i; 85 | UINTPTR uvIntSave; 86 | 87 | if (pPool == NULL) 88 | { 89 | return LOS_NOK; 90 | } 91 | 92 | if (uwBlkSize == 0) 93 | { 94 | return LOS_NOK; 95 | } 96 | 97 | if (uwBoxSize < sizeof(LOS_MEMBOX_INFO)) 98 | { 99 | return LOS_NOK; 100 | } 101 | 102 | uvIntSave = LOS_IntLock(); 103 | pstBoxInfo->uwBlkSize = LOS_MEMBOX_ALLIGNED(uwBlkSize + LOS_MEMBOX_MAGIC_SIZE); 104 | pstBoxInfo->uwBlkNum = ((uwBoxSize - sizeof(LOS_MEMBOX_INFO)) /pstBoxInfo->uwBlkSize); 105 | 106 | if (pstBoxInfo->uwBlkNum == 0) 107 | { 108 | LOS_IntRestore(uvIntSave); 109 | return LOS_NOK; 110 | } 111 | 112 | pstNode = (LOS_MEMBOX_NODE *)(pstBoxInfo + 1); 113 | 114 | pstBoxInfo->stFreeList.pstNext = pstNode; 115 | 116 | for (i = 0; i < pstBoxInfo->uwBlkNum - 1; ++i) 117 | { 118 | pstNode->pstNext = OS_MEMBOX_NEXT(pstNode, pstBoxInfo->uwBlkSize); 119 | pstNode = pstNode->pstNext; 120 | } 121 | 122 | pstNode->pstNext = (LOS_MEMBOX_NODE *)NULL; 123 | 124 | LOS_IntRestore(uvIntSave); 125 | 126 | return LOS_OK; 127 | } 128 | 129 | LITE_OS_SEC_TEXT VOID *LOS_MemboxAlloc(VOID *pPool) 130 | { 131 | LOS_MEMBOX_INFO *pstBoxInfo = (LOS_MEMBOX_INFO *)pPool; 132 | LOS_MEMBOX_NODE *pstNode = (LOS_MEMBOX_NODE *)NULL; 133 | LOS_MEMBOX_NODE *pstRet = (LOS_MEMBOX_NODE *)NULL; 134 | UINTPTR uvIntSave; 135 | 136 | if (pPool == NULL) 137 | { 138 | return NULL; 139 | } 140 | 141 | uvIntSave = LOS_IntLock(); 142 | pstNode = &(pstBoxInfo->stFreeList); 143 | if (pstNode->pstNext != NULL) 144 | { 145 | pstRet = pstNode->pstNext; 146 | pstNode->pstNext = pstRet->pstNext; 147 | OS_MEMBOX_SET_MAGIC(pstRet); 148 | } 149 | 150 | LOS_IntRestore(uvIntSave); 151 | 152 | return pstRet == NULL ? NULL : OS_MEMBOX_USER_ADDR(pstRet); 153 | } 154 | 155 | LITE_OS_SEC_TEXT UINT32 LOS_MemboxFree(VOID *pPool, VOID *pBox) 156 | { 157 | LOS_MEMBOX_INFO *pstBoxInfo = (LOS_MEMBOX_INFO *)pPool; 158 | UINT32 uwRet = LOS_NOK; 159 | UINTPTR uvIntSave; 160 | 161 | if (pPool == NULL || pBox == NULL) 162 | { 163 | return LOS_NOK; 164 | } 165 | 166 | uvIntSave = LOS_IntLock(); 167 | do 168 | { 169 | LOS_MEMBOX_NODE *pstNode = OS_MEMBOX_NODE_ADDR(pBox); 170 | 171 | if (osCheckBoxMem(pstBoxInfo, pstNode) != LOS_OK) 172 | { 173 | break; 174 | } 175 | 176 | pstNode->pstNext = pstBoxInfo->stFreeList.pstNext; 177 | pstBoxInfo->stFreeList.pstNext = pstNode; 178 | uwRet = LOS_OK; 179 | } while (0); 180 | 181 | LOS_IntRestore(uvIntSave); 182 | 183 | return uwRet; 184 | 185 | } 186 | 187 | LITE_OS_SEC_TEXT_MINOR VOID LOS_MemboxClr(VOID *pPool, VOID *pBox) 188 | { 189 | LOS_MEMBOX_INFO *pstBoxInfo = (LOS_MEMBOX_INFO *)pPool; 190 | 191 | if (pPool == NULL || pBox == NULL) 192 | { 193 | return; 194 | } 195 | 196 | (VOID)memset(pBox, 0, pstBoxInfo->uwBlkSize - LOS_MEMBOX_MAGIC_SIZE); 197 | } 198 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/base/mem/los_membox.inc: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #ifndef _LOS_MEMBOX_INC 36 | #define _LOS_MEMBOX_INC 37 | 38 | #include "los_membox.ph" 39 | 40 | #endif /* _LOS_MEMBOX_INC */ 41 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/base/mem/los_memory.inc: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #ifndef _LOS_MEMORY_INC 36 | #define _LOS_MEMORY_INC 37 | 38 | #include "los_memory.ph" 39 | #include "los_multipledlinkhead.ph" 40 | 41 | #ifdef __cplusplus 42 | #if __cplusplus 43 | extern "C" { 44 | #endif /* __cplusplus */ 45 | #endif /* __cplusplus */ 46 | 47 | 48 | #define OS_MEM_ENABLE_MEM_STATISTICS 49 | #ifdef OS_MEM_ENABLE_MEM_STATISTICS 50 | #include "los_memstat.ph" 51 | #define OS_MEM_ADD_USED(arg) osTaskMemUsedInc(arg) 52 | #define OS_MEM_REDUCE_USED(arg) osTaskMemUsedDec(arg) 53 | #else 54 | #define OS_MEM_ADD_USED(arg) 55 | #define OS_MEM_REDUCE_USED(arg) 56 | #endif 57 | 58 | #define OS_MEM_ALIGN(p, alignSize) (((unsigned int)(p) + alignSize -1) &(~ (alignSize -1))) 59 | #define OS_MEM_NODE_HEAD_SIZE sizeof(LOS_MEM_DYN_NODE) 60 | #define OS_MEM_MIN_POOL_SIZE (OS_DLNK_HEAD_SIZE + 2 * OS_MEM_NODE_HEAD_SIZE + sizeof(LOS_MEM_POOL_INFO)) 61 | #define OS_MEM_ALIGN_SIZE 4 62 | #define OS_MEM_NODE_USED_FLAG 0x80000000 63 | #define OS_MEM_NODE_ALIGNED_FLAG 0x40000000 64 | 65 | #define OS_MEM_NODE_GET_ALIGNED_FLAG(uwSizeAndFlag) ((uwSizeAndFlag) & OS_MEM_NODE_ALIGNED_FLAG) 66 | #define OS_MEM_NODE_SET_ALIGNED_FLAG(uwSizeAndFlag) (uwSizeAndFlag = ((uwSizeAndFlag) | OS_MEM_NODE_ALIGNED_FLAG)) 67 | #define OS_MEM_NODE_GET_ALIGNED_GAPSIZE(uwSizeAndFlag) ((uwSizeAndFlag) & (~OS_MEM_NODE_ALIGNED_FLAG)) 68 | #define OS_MEM_NODE_GET_USED_FLAG(uwSizeAndFlag) ((uwSizeAndFlag) & OS_MEM_NODE_USED_FLAG) 69 | #define OS_MEM_NODE_SET_USED_FLAG(uwSizeAndFlag) (uwSizeAndFlag = ((uwSizeAndFlag) | OS_MEM_NODE_USED_FLAG)) 70 | #define OS_MEM_NODE_GET_SIZE(uwSizeAndFlag) ((uwSizeAndFlag) & (~OS_MEM_NODE_USED_FLAG)) 71 | #define OS_MEM_IS_NODE_NEXT_EXIST(pstNode, pstPoolInfo) (((UINT32)(pstNode) + (pstNode)->uwSizeAndFlag) < ((UINT32)(pstPoolInfo) + (pstPoolInfo)->uwPoolSize)) 72 | #define OS_MEM_HEAD(pPool, uwSize) OS_DLnkHead(OS_MEM_HEAD_ADDR(pPool), uwSize) 73 | #define OS_MEM_HEAD_ADDR(pPool) ((VOID *)((UINT32)(pPool) + sizeof(LOS_MEM_POOL_INFO))) 74 | #define OS_MEM_NEXT_NODE(pstNode) ((LOS_MEM_DYN_NODE *)((UINT8 *)(pstNode) + OS_MEM_NODE_GET_SIZE((pstNode)->uwSizeAndFlag))) 75 | #define OS_MEM_FIRST_NODE(pPool) ((LOS_MEM_DYN_NODE *) ((UINT8 *)OS_MEM_HEAD_ADDR(pPool) + OS_DLNK_HEAD_SIZE)) 76 | #define OS_MEM_END_NODE(pPool, uwSize) ((LOS_MEM_DYN_NODE *)(((UINT8 *)(pPool) + (uwSize)) - OS_MEM_NODE_HEAD_SIZE)) 77 | #define OS_MEM_MIDDLE_ADDR_OPEN_END(startAddr, middleAddr, endAddr) (((UINT8 *)(startAddr) <= ((UINT8 *)(middleAddr))) && (((UINT8 *)(middleAddr)) < ((UINT8 *)(endAddr)))) 78 | #define OS_MEM_MIDDLE_ADDR(startAddr, middleAddr, endAddr) (((UINT8 *)(startAddr) <= ((UINT8 *)(middleAddr))) && (((UINT8 *)(middleAddr)) <= ((UINT8 *)(endAddr)))) 79 | #define OS_MEM_SET_MAGIC(value) (value) = (LOS_DL_LIST *)((UINT32)(&(value)) ^ 0xffffffff) 80 | #define OS_MEM_MAGIC_VALID(value) ((((UINT32)(value)) ^ ((UINT32)(&(value)))) == 0xffffffff) 81 | 82 | 83 | #ifdef __cplusplus 84 | #if __cplusplus 85 | } 86 | #endif /* __cplusplus */ 87 | #endif /* __cplusplus */ 88 | 89 | #endif /* _LOS_MEMORY_INC */ 90 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/base/mem/los_memstat.c: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #include "los_memstat.inc" 36 | 37 | #include "los_task.ph" 38 | 39 | #include "los_config.h" 40 | 41 | typedef struct { 42 | UINT32 uwMemUsed; 43 | } TSK_MEM_USED_INFO; 44 | 45 | LITE_OS_SEC_BSS_MINOR TSK_MEM_USED_INFO g_TskMemUsedInfo[LOSCFG_BASE_CORE_TSK_LIMIT + 1]; 46 | 47 | LITE_OS_SEC_TEXT_MINOR VOID osTaskMemUsedInc(UINT32 uwUsedSize) 48 | { 49 | UINT32 taskId; 50 | 51 | if (NULL == g_stLosTask.pstRunTask) 52 | { 53 | return; 54 | } 55 | 56 | if (OS_INT_ACTIVE) 57 | { 58 | return; 59 | } 60 | 61 | taskId = (UINT32) g_stLosTask.pstRunTask->uwTaskID; 62 | 63 | if (taskId > LOSCFG_BASE_CORE_TSK_LIMIT) 64 | { 65 | return; 66 | } 67 | 68 | g_TskMemUsedInfo[taskId].uwMemUsed += uwUsedSize; 69 | } 70 | 71 | LITE_OS_SEC_TEXT_MINOR VOID osTaskMemUsedDec(UINT32 uwUsedSize) 72 | { 73 | UINT32 taskId; 74 | 75 | taskId = (UINT32) g_stLosTask.pstRunTask->uwTaskID; 76 | 77 | if (taskId > LOSCFG_BASE_CORE_TSK_LIMIT) 78 | { 79 | return; 80 | } 81 | 82 | if (OS_INT_ACTIVE) 83 | { 84 | return; 85 | } 86 | 87 | g_TskMemUsedInfo[taskId].uwMemUsed -= uwUsedSize; 88 | } 89 | 90 | LITE_OS_SEC_TEXT_MINOR UINT32 osTaskMemUsage(UINT32 uwTaskId) 91 | { 92 | if ((UINT32)uwTaskId > LOSCFG_BASE_CORE_TSK_LIMIT) 93 | { 94 | return LOS_NOK; 95 | } 96 | 97 | return g_TskMemUsedInfo[(UINT32)uwTaskId].uwMemUsed; 98 | } 99 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/base/mem/los_memstat.inc: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #ifndef _LOS_MEMSTAT_INC 36 | #define _LOS_MEMSTAT_INC 37 | 38 | #include "los_memstat.ph" 39 | 40 | #endif /* _LOS_MEMSTAT_INC */ 41 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/base/mem/los_multipledlinkhead.c: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #include "los_multipledlinkhead.inc" 36 | 37 | #define IF_ELSE(mask, if_do, else_do) if(uwSize & (mask)){if_do}else{else_do} 38 | #define BIT_NUM(num) return num; 39 | #define BIT_NONE BIT_NUM(0xfffffff) 40 | 41 | INLINE UINT32 LOS_Log2(UINT32 uwSize) 42 | { 43 | IF_ELSE(0x80000000, \ 44 | BIT_NONE, \ 45 | IF_ELSE(0x7fff0000, \ 46 | IF_ELSE(0x7f000000,\ 47 | IF_ELSE(0x70000000,\ 48 | IF_ELSE(0x40000000,\ 49 | BIT_NUM(30),\ 50 | IF_ELSE(0x20000000, BIT_NUM(29), BIT_NUM(28))), \ 51 | IF_ELSE(0x0c000000, \ 52 | IF_ELSE(0x08000000, BIT_NUM(27), BIT_NUM(26)), \ 53 | IF_ELSE(0x02000000, BIT_NUM(25), BIT_NUM(24)))), \ 54 | IF_ELSE(0x00f00000, \ 55 | IF_ELSE(0x00c00000, \ 56 | IF_ELSE(0x00800000, BIT_NUM(23), BIT_NUM(22)), \ 57 | IF_ELSE(0x00200000, BIT_NUM(21), BIT_NUM(20))), \ 58 | IF_ELSE(0x000c0000,\ 59 | IF_ELSE(0x00080000, BIT_NUM(19), BIT_NUM(18)), \ 60 | IF_ELSE(0x00020000, BIT_NUM(17), BIT_NUM(16))))), \ 61 | IF_ELSE(0x0000ff00, \ 62 | IF_ELSE(0x0000f000, \ 63 | IF_ELSE(0x0000c000, \ 64 | IF_ELSE(0x00008000, BIT_NUM(15), BIT_NUM(14)), \ 65 | IF_ELSE(0x00002000, BIT_NUM(13), BIT_NUM(12))), \ 66 | IF_ELSE(0x00000c00, \ 67 | IF_ELSE(0x00000800, BIT_NUM(11), BIT_NUM(10)), \ 68 | IF_ELSE(0x00000200, BIT_NUM(9), BIT_NUM(8)))), \ 69 | IF_ELSE(0x000000f0, \ 70 | IF_ELSE(0x000000c0, \ 71 | IF_ELSE(0x00000080, BIT_NUM(7), BIT_NUM(6)), \ 72 | IF_ELSE(0x00000020, BIT_NUM(5), BIT_NUM(4))), \ 73 | IF_ELSE(0x0000000c, \ 74 | IF_ELSE(0x00000008, BIT_NUM(3), BIT_NUM(2)), \ 75 | IF_ELSE(0x00000002, BIT_NUM(1), BIT_NUM(0)))))))\ 76 | 77 | } 78 | 79 | LITE_OS_SEC_TEXT_INIT VOID LOS_DLnkInitMultiHead(VOID *pHeadAddr) 80 | { 81 | LOS_MULTIPLE_DLNK_HEAD *head = (LOS_MULTIPLE_DLNK_HEAD *)pHeadAddr; 82 | LOS_DL_LIST *pstListHead = head->stListHead; 83 | UINT32 i; 84 | 85 | for (i = 0; i < OS_MULTI_DLNK_NUM; ++i, ++pstListHead) 86 | { 87 | LOS_ListInit(pstListHead); 88 | } 89 | } 90 | 91 | LITE_OS_SEC_TEXT_MINOR LOS_DL_LIST *LOS_DLnkMultiHead(VOID *pHeadAddr, UINT32 uwSize) 92 | { 93 | LOS_MULTIPLE_DLNK_HEAD *head = (LOS_MULTIPLE_DLNK_HEAD *)pHeadAddr; 94 | UINT32 idx = LOS_Log2(uwSize); 95 | 96 | if(idx > OS_MAX_MULTI_DLNK_LOG2) 97 | { 98 | return (LOS_DL_LIST *)NULL; 99 | } 100 | 101 | if(idx <= OS_MIN_MULTI_DLNK_LOG2) 102 | { 103 | idx = OS_MIN_MULTI_DLNK_LOG2; 104 | } 105 | 106 | return head->stListHead + (idx - OS_MIN_MULTI_DLNK_LOG2); 107 | } 108 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/base/mem/los_multipledlinkhead.inc: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #ifndef _LOS_MULTIPLE_DLINK_HEAD_INC 36 | #define _LOS_MULTIPLE_DLINK_HEAD_INC 37 | 38 | #include "los_multipledlinkhead.ph" 39 | 40 | #endif /* _LOS_MULTIPLE_DLINK_HEAD_INC */ 41 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/base/misc/los_misc.c: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #include "los_base.ph" 36 | #include "los_sys.ph" 37 | #include "los_task.ph" 38 | 39 | #include "los_hwi.h" 40 | 41 | LITE_OS_SEC_TEXT UINT32 LOS_Align(UINT32 uwAddr, UINT32 uwBoundary) 42 | { 43 | if (uwAddr + uwBoundary - 1 > uwAddr) { 44 | return (uwAddr + uwBoundary - 1) & ~(uwBoundary - 1); 45 | } else { 46 | return uwAddr & ~(uwBoundary - 1); 47 | } 48 | } 49 | 50 | LITE_OS_SEC_TEXT_MINOR VOID LOS_Msleep(UINT32 uwMsecs) 51 | { 52 | UINT32 uwInterval = 0; 53 | 54 | if (OS_INT_ACTIVE) { 55 | return; 56 | } 57 | 58 | if (uwMsecs == 0) { 59 | uwInterval = 0; 60 | } else { 61 | uwInterval = LOS_MS2Tick(uwMsecs); 62 | if (uwInterval == 0) { 63 | uwInterval = 1; 64 | } 65 | } 66 | 67 | (VOID)LOS_TaskDelay(uwInterval); 68 | } 69 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/include/los_errno.h: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | /**@defgroup los_errno Error code 36 | * @ingroup kernel 37 | */ 38 | 39 | #ifndef _LOS_ERRNO_H 40 | #define _LOS_ERRNO_H 41 | 42 | #include "los_typedef.h" 43 | 44 | #ifdef __cplusplus 45 | #if __cplusplus 46 | extern "C" { 47 | #endif /* __cplusplus */ 48 | #endif /* __cplusplus */ 49 | 50 | enum LOS_MOUDLE_ID 51 | { 52 | LOS_MOD_SYS = 0x0, 53 | LOS_MOD_MEM = 0x1, 54 | LOS_MOD_TSK = 0x2, 55 | LOS_MOD_SWTMR = 0x3, 56 | LOS_MOD_TICK = 0x4, 57 | LOS_MOD_MSG = 0x5, 58 | LOS_MOD_QUE = 0x6, 59 | LOS_MOD_SEM = 0x7, 60 | LOS_MOD_MBOX = 0x8, 61 | LOS_MOD_HWI = 0x9, 62 | LOS_MOD_HWWDG = 0xa, 63 | LOS_MOD_CACHE = 0xb, 64 | LOS_MOD_HWTMR = 0xc, 65 | LOS_MOD_MMU = 0xd, 66 | 67 | LOS_MOD_LOG = 0xe, 68 | LOS_MOD_ERR = 0xf, 69 | 70 | LOS_MOD_EXC = 0x10, 71 | LOS_MOD_CSTK = 0x11, 72 | 73 | LOS_MOD_MPU = 0x12, 74 | LOS_MOD_NMHWI = 0x13, 75 | LOS_MOD_TRACE = 0x14, 76 | LOS_MOD_KNLSTAT = 0x15, 77 | LOS_MOD_EVTTIME = 0x16, 78 | LOS_MOD_THRDCPUP = 0x17, 79 | LOS_MOD_IPC = 0x18, 80 | LOS_MOD_STKMON = 0x19, 81 | LOS_MOD_TIMER = 0x1a, 82 | LOS_MOD_RESLEAKMON = 0x1b, 83 | LOS_MOD_EVENT = 0x1c, 84 | LOS_MOD_MUX = 0X1d, 85 | LOS_MOD_CPUP = 0x1e, 86 | LOS_MOD_SHELL = 0x31, 87 | LOS_MOD_BUTT 88 | }; 89 | 90 | /** 91 | * @ingroup los_errno 92 | * OS error code flag. 93 | */ 94 | #define LOS_ERRNO_OS_ID ((UINT32)0x00 << 16) 95 | 96 | /** 97 | * @ingroup los_errno 98 | * Define the error level as informative. 99 | */ 100 | #define LOS_ERRTYPE_NORMAL ((UINT32)0x00 << 24) 101 | 102 | /** 103 | * @ingroup los_errno 104 | * Define the error level as warning. 105 | */ 106 | #define LOS_ERRTYPE_WARN ((UINT32)0x01 << 24) 107 | 108 | /** 109 | * @ingroup los_errno 110 | * Define the error level as critical. 111 | */ 112 | #define LOS_ERRTYPE_ERROR ((UINT32)0x02 << 24) 113 | 114 | /** 115 | * @ingroup los_errno 116 | * Define the error level as fatal. 117 | */ 118 | #define LOS_ERRTYPE_FATAL ((UINT32)0x03 << 24) 119 | 120 | /** 121 | * @ingroup los_errno 122 | * Define fatal OS errors. 123 | */ 124 | #define LOS_ERRNO_OS_FATAL(MID, ERRNO) \ 125 | (LOS_ERRTYPE_FATAL | LOS_ERRNO_OS_ID | ((UINT32)(MID) << 8) | (ERRNO)) 126 | 127 | /** 128 | * @ingroup los_errno 129 | * Define critical OS errors. 130 | */ 131 | #define LOS_ERRNO_OS_ERROR(MID, ERRNO) \ 132 | (LOS_ERRTYPE_ERROR | LOS_ERRNO_OS_ID | ((UINT32)(MID) << 8) | (ERRNO)) 133 | 134 | /** 135 | * @ingroup los_errno 136 | * Define warning OS errors. 137 | */ 138 | #define LOS_ERRNO_OS_WARN(MID, ERRNO) \ 139 | (LOS_ERRTYPE_WARN | LOS_ERRNO_OS_ID | ((UINT32)(MID) << 8) | (ERRNO)) 140 | 141 | /** 142 | * @ingroup los_errno 143 | * Define informative OS errors. 144 | */ 145 | #define LOS_ERRNO_OS_NORMAL(MID, ERRNO) \ 146 | (LOS_ERRTYPE_NORMAL | LOS_ERRNO_OS_ID | ((UINT32)(MID) << 8) | (ERRNO)) 147 | 148 | 149 | #ifdef __cplusplus 150 | #if __cplusplus 151 | } 152 | #endif /* __cplusplus */ 153 | #endif /* __cplusplus */ 154 | 155 | #endif /* _LOS_ERRNO_H */ 156 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/include/los_membox.h: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | /** @defgroup los_membox Static memory 36 | * @ingroup mem 37 | */ 38 | 39 | #ifndef _LOS_MEMBOX_H 40 | #define _LOS_MEMBOX_H 41 | 42 | #include "los_config.h" 43 | 44 | #ifdef __cplusplus 45 | #if __cplusplus 46 | extern "C" { 47 | #endif /* __cplusplus */ 48 | #endif /* __cplusplus */ 49 | 50 | /** 51 | * @ingroup los_membox 52 | * Define whether to check the address validity 53 | */ 54 | #if (LOSCFG_BASE_MEM_NODE_INTEGRITY_CHECK == YES) 55 | #define LOS_MEMBOX_CHECK 56 | #endif 57 | 58 | /** 59 | * @ingroup los_membox 60 | * Structure of a free node in a memory pool 61 | */ 62 | typedef struct tagMEMBOX_NODE 63 | { 64 | struct tagMEMBOX_NODE *pstNext; /** 104 | *
  • This API is used to initialize a memory pool.
  • 105 | * 106 | *@attention 107 | *
      108 | *
    • None.
    • 109 | *
    110 | * 111 | *@param pPool [IN] Memory pool address. 112 | *@param uwBoxSize [IN] Memory pool size. 113 | *@param uwBlkSize [IN] Memory block size. 114 | * 115 | *@retval #LOS_NOK 1: The memory pool is successfully initialized. 116 | *@retval #LOS_OK 0: The memory pool fails to be initialized. 117 | *@par Dependency: 118 | *
      119 | *
    • los_membox.h: the header file that contains the API declaration.
    • 120 | *
    121 | *@see None. 122 | *@since Huawei LiteOS V100R001C00 123 | */ 124 | extern UINT32 LOS_MemboxInit(VOID *pPool, UINT32 uwBoxSize, UINT32 uwBlkSize); 125 | 126 | /** 127 | *@ingroup los_membox 128 | *@brief Request a memory block. 129 | * 130 | *@par Description: 131 | *
      132 | *
    • This API is used to request a memory block.
    • 133 | *
    134 | *@attention 135 | *
      136 | *
    • None.
    • 137 | *
    138 | * 139 | *@param pPool [IN] Memory pool address. 140 | * 141 | *@retval Memory block address. The request is accepted. 142 | *@retval NULL. The request fails. 143 | *@par Dependency: 144 | *
      145 | *
    • los_membox.h: the header file that contains the API declaration.
    • 146 | *
    147 | *@see LOS_MemboxFree 148 | *@since Huawei LiteOS V100R001C00 149 | */ 150 | extern VOID *LOS_MemboxAlloc(VOID *pPool); 151 | 152 | /** 153 | *@ingroup los_membox 154 | *@brief Free a memory block. 155 | * 156 | *@par Description: 157 | *
      158 | *
    • This API is used to free a memory block.
    • 159 | *
    160 | *@attention 161 | *
      162 | *
    • None.
    • 163 | *
    164 | * 165 | *@param pPool [IN] Memory pool address. 166 | *@param pBox [IN] Memory block address. 167 | * 168 | *@retval #LOS_NOK 1: This memory block fails to be freed. 169 | *@retval #LOS_OK 0: This memory block is successfully freed. 170 | *@par Dependency: 171 | *
      172 | *
    • los_membox.h: the header file that contains the API declaration.
    • 173 | *
    174 | *@see LOS_MemboxAlloc 175 | *@since Huawei LiteOS V100R001C00 176 | */ 177 | extern UINT32 LOS_MemboxFree(VOID *pPool, VOID *pBox); 178 | 179 | /** 180 | *@ingroup los_membox 181 | *@brief Clear a memory block. 182 | * 183 | *@par Description: 184 | *
      185 | *
    • This API is used to set the memory block value to be 0.
    • 186 | *
    187 | *@attention 188 | *
      189 | *
    • None.
    • 190 | *
    191 | * 192 | *@param pPool [IN] Memory pool address. 193 | *@param pBox [IN] Memory block address. 194 | * 195 | *@retval None. 196 | *@par Dependency: 197 | *
      198 | *
    • los_membox.h: the header file that contains the API declaration.
    • 199 | *
    200 | *@see None. 201 | *@since Huawei LiteOS V100R001C00 202 | */ 203 | extern VOID LOS_MemboxClr(VOID *pPool, VOID *pBox); 204 | 205 | 206 | #ifdef __cplusplus 207 | #if __cplusplus 208 | } 209 | #endif /* __cplusplus */ 210 | #endif /* __cplusplus */ 211 | 212 | #endif /* _LOS_MEMBOX_H */ 213 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/include/los_multipledlinkhead.h: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #ifndef _LOS_MULTIPLE_DLINK_HEAD_H 36 | #define _LOS_MULTIPLE_DLINK_HEAD_H 37 | 38 | #include "los_base.h" 39 | #include "los_list.h" 40 | 41 | #ifdef __cplusplus 42 | #if __cplusplus 43 | extern "C" { 44 | #endif /* __cplusplus */ 45 | #endif /* __cplusplus */ 46 | 47 | 48 | #define OS_MAX_MULTI_DLNK_LOG2 30 49 | #define OS_MIN_MULTI_DLNK_LOG2 4 50 | #define OS_MULTI_DLNK_NUM ((OS_MAX_MULTI_DLNK_LOG2 - OS_MIN_MULTI_DLNK_LOG2) + 1) 51 | #define OS_DLNK_HEAD_SIZE OS_MULTI_DLNK_HEAD_SIZE 52 | #define OS_DLnkInitHead LOS_DLnkInitMultiHead 53 | #define OS_DLnkHead LOS_DLnkMultiHead 54 | #define OS_DLnkNextHead LOS_DLnkNextMultiHead 55 | #define OS_DLnkFirstHead LOS_DLnkFirstMultiHead 56 | #define OS_MULTI_DLNK_HEAD_SIZE sizeof(LOS_MULTIPLE_DLNK_HEAD) 57 | 58 | typedef struct 59 | { 60 | LOS_DL_LIST stListHead[OS_MULTI_DLNK_NUM]; 61 | } LOS_MULTIPLE_DLNK_HEAD; 62 | 63 | INLINE LOS_DL_LIST *LOS_DLnkNextMultiHead(VOID *pHeadAddr, LOS_DL_LIST *pstListHead) 64 | { 65 | LOS_MULTIPLE_DLNK_HEAD *head = (LOS_MULTIPLE_DLNK_HEAD *)pHeadAddr; 66 | 67 | return (&(head->stListHead[OS_MULTI_DLNK_NUM - 1]) == pstListHead) ? NULL : (pstListHead + 1); 68 | } 69 | 70 | INLINE LOS_DL_LIST *LOS_DLnkFirstMultiHead(VOID *pHeadAddr) 71 | { 72 | return (LOS_DL_LIST *)pHeadAddr; 73 | } 74 | 75 | extern VOID LOS_DLnkInitMultiHead(VOID *pHeadAddr); 76 | extern LOS_DL_LIST *LOS_DLnkMultiHead(VOID *pHeadAddr, UINT32 uwSize); 77 | 78 | 79 | #ifdef __cplusplus 80 | #if __cplusplus 81 | } 82 | #endif /* __cplusplus */ 83 | #endif /* __cplusplus */ 84 | 85 | #endif /* _LOS_MULTIPLE_DLINK_HEAD_H */ 86 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/include/los_printf.h: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | /**@defgroup los_printf Printf 36 | * @ingroup kernel 37 | */ 38 | 39 | #ifndef _LOS_PRINTF_H 40 | #define _LOS_PRINTF_H 41 | #ifdef LOSCFG_LIB_LIBC 42 | #include "stdarg.h" 43 | #endif 44 | #ifdef LOSCFG_LIB_LIBCMINI 45 | #include "libcmini.h" 46 | #endif 47 | #include "los_typedef.h" 48 | 49 | #ifdef __cplusplus 50 | #if __cplusplus 51 | extern "C" { 52 | #endif /* __cplusplus */ 53 | #endif /* __cplusplus */ 54 | 55 | 56 | #define LOS_EMG_LEVEL 0 57 | 58 | #define LOS_COMMOM_LEVEL (LOS_EMG_LEVEL + 1) 59 | 60 | #define LOS_ERR_LEVEL (LOS_COMMOM_LEVEL + 1) 61 | 62 | #define LOS_WARN_LEVEL (LOS_ERR_LEVEL + 1) 63 | 64 | #define LOS_INFO_LEVEL (LOS_WARN_LEVEL + 1) 65 | 66 | #define LOS_DEBUG_LEVEL (LOS_INFO_LEVEL + 1) 67 | 68 | #define PRINT_LEVEL LOS_ERR_LEVEL 69 | 70 | //extern void dprintf(const char *fmt, ...); 71 | 72 | //#define diag_printf dprintf 73 | 74 | #if PRINT_LEVEL < LOS_DEBUG_LEVEL 75 | #define PRINT_DEBUG(fmt, args...) 76 | #else 77 | #define PRINT_DEBUG(fmt, args...) //do{(printf("[DEBUG] "), printf(fmt, ##args));}while(0) 78 | #endif 79 | 80 | #if PRINT_LEVEL < LOS_INFO_LEVEL 81 | #define PRINT_INFO(fmt, args...) 82 | #else 83 | #define PRINT_INFO(fmt, args...) //do{(printf("[INFO] "), printf(fmt, ##args));}while(0) 84 | #endif 85 | 86 | #if PRINT_LEVEL < LOS_WARN_LEVEL 87 | #define PRINT_WARN(fmt, args...) 88 | #else 89 | #define PRINT_WARN(fmt, args...) //do{(printf("[WARN] "), printf(fmt, ##args));}while(0) 90 | #endif 91 | 92 | #if PRINT_LEVEL < LOS_ERR_LEVEL 93 | #define PRINT_ERR(fmt, args...) 94 | #else 95 | #define PRINT_ERR(fmt, args...) //do{(printf("[ERR] "), printf(fmt, ##args));}while(0) 96 | #endif 97 | 98 | #if PRINT_LEVEL < LOS_COMMOM_LEVEL 99 | #define PRINTK(fmt, args...) 100 | #else 101 | #define PRINTK(fmt, args...) //printf(fmt, ##args) 102 | #endif 103 | 104 | #if PRINT_LEVEL < LOS_EMG_LEVEL 105 | #define PRINT_EMG(fmt, args...) 106 | #else 107 | #define PRINT_EMG(fmt, args...) //do{(printf("[EMG] "), printf(fmt, ##args));}while(0) 108 | #endif 109 | 110 | #define PRINT_RELEASE(fmt, args...) //printf(fmt, ##args) 111 | 112 | 113 | #ifdef __cplusplus 114 | #if __cplusplus 115 | } 116 | #endif /* __cplusplus */ 117 | #endif /* __cplusplus */ 118 | 119 | #endif /* _LOS_PRINTF_H */ 120 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/include/los_priqueue.h: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | /** @defgroup los_priqueue Priority queue 36 | * @ingroup kernel 37 | */ 38 | 39 | #ifndef _LOS_PRIQUEUE_H 40 | #define _LOS_PRIQUEUE_H 41 | 42 | #include "los_list.h" 43 | #include "los_typedef.h" 44 | 45 | #ifdef __cplusplus 46 | #if __cplusplus 47 | extern "C" { 48 | #endif /* __cplusplus */ 49 | #endif /* __cplusplus */ 50 | 51 | 52 | #define LOS_PRIORITY_QUEUE_PRIORITYNUM 32 53 | 54 | /** 55 | *@ingroup los_priqueue 56 | *@brief Insert a item to the priority queue. 57 | * 58 | *@par Description: 59 | *This API is used to insert a item to the priority queue according to the priority of this item. 60 | *@attention 61 | *
      62 | *
    • None.
    • 63 | *
    64 | *@param ptrPQItem [IN] The node of item to be inserted. 65 | *@param uwPri [IN] Priority of the item be inserted. 66 | * 67 | *@retval none. 68 | *@par Dependency: 69 | *
    • los_priqueue.h: the header file that contains the API declaration.
    70 | *@see LOS_PriqueueDequeue. 71 | *@since Huawei LiteOS V100R001C00 72 | */ 73 | extern VOID LOS_PriqueueEnqueue(LOS_DL_LIST *ptrPQItem, UINT32 uwPri); 74 | 75 | /** 76 | *@ingroup los_priqueue 77 | *@brief Delete a item from the priority queue. 78 | * 79 | *@par Description: 80 | *This API is used to delete a item from the priority queue. 81 | *@attention 82 | *
      83 | *
    • None.
    • 84 | *
    85 | *@param ptrPQItem [IN] The node of item to be deleted. 86 | * 87 | *@retval none. 88 | *@par Dependency: 89 | *
    • los_priqueue.h: the header file that contains the API declaration.
    90 | *@see LOS_PriqueueEnqueue. 91 | *@since Huawei LiteOS V100R001C00 92 | */ 93 | extern VOID LOS_PriqueueDequeue(LOS_DL_LIST *ptrPQItem); 94 | 95 | /** 96 | *@ingroup los_priqueue 97 | *@brief Obtain the item with highest priority. 98 | * 99 | *@par Description: 100 | *This API is used to obtain the item with highest priority in the priority queue. 101 | *@attention 102 | *
      103 | *
    • None.
    • 104 | *
    105 | *@param none. 106 | * 107 | *@retval NULL : The priority queue is empty. 108 | *@retval item node : The node of the item with highest priority. 109 | *@par Dependency: 110 | *
    • los_priqueue.h: the header file that contains the API declaration.
    111 | *@see none. 112 | *@since Huawei LiteOS V100R001C00 113 | */ 114 | extern LOS_DL_LIST *LOS_PriqueueTop(VOID); 115 | 116 | /** 117 | *@ingroup los_priqueue 118 | *@brief Obtain the number of items with the specified priority. 119 | * 120 | *@par Description: 121 | *This API is used to obtain the number of items with the specified priority. 122 | *@attention 123 | *
      124 | *
    • None.
    • 125 | *
    126 | *@param uwPri [IN] Obtain the number of items with the specified priority of uwPri. 127 | * 128 | *@retval The number of items :The number of items with the specified priority. 129 | *@par Dependency: 130 | *
    • los_priqueue.h: the header file that contains the API declaration.
    131 | *@see none. 132 | *@since Huawei LiteOS V100R001C00 133 | */ 134 | extern UINT32 LOS_PriqueueSize(UINT32 uwPri); 135 | 136 | /** 137 | *@ingroup los_priqueue 138 | *@brief Obtain the total number of items in the priority queue. 139 | * 140 | *@par Description: 141 | *This API is used to obtain the number of items in the priority queue. 142 | *@attention 143 | *
      144 | *
    • None.
    • 145 | *
    146 | * 147 | *@retval The number of items: The total number of items in the priority queue. 148 | *@par Dependency: 149 | *
    • los_priqueue.h: the header file that contains the API declaration.
    150 | *@see none. 151 | *@since Huawei LiteOS V100R001C00 152 | */ 153 | extern UINT32 LOS_PriqueueTotalSize(VOID); 154 | 155 | 156 | #ifdef __cplusplus 157 | #if __cplusplus 158 | } 159 | #endif /* __cplusplus */ 160 | #endif /* __cplusplus */ 161 | 162 | #endif /* _LOS_PRIQUEUE_H */ 163 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/include/los_tick.h: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | /**@defgroup los_tick Tick 36 | * @ingroup kernel 37 | */ 38 | 39 | #ifndef _LOS_TICK_H 40 | #define _LOS_TICK_H 41 | 42 | #include "los_errno.h" 43 | 44 | #ifdef __cplusplus 45 | #if __cplusplus 46 | extern "C" { 47 | #endif /* __cplusplus */ 48 | #endif /* __cplusplus */ 49 | 50 | 51 | /** 52 | * @ingroup los_tick 53 | * Tick error code: The Tick configuration is incorrect. 54 | * 55 | * Value: 0x02000400 56 | * 57 | * Solution: Change values of the OS_SYS_CLOCK and LOSCFG_BASE_CORE_TICK_PER_SECOND system time configuration modules in Los_config.h. 58 | */ 59 | #define LOS_ERRNO_TICK_CFG_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_TICK, 0x00) 60 | 61 | /** 62 | * @ingroup los_tick 63 | * Tick error code: This error code is not in use temporarily. 64 | * 65 | * Value: 0x02000401 66 | * 67 | * Solution: None. 68 | */ 69 | #define LOS_ERRNO_TICK_NO_HWTIMER LOS_ERRNO_OS_ERROR(LOS_MOD_TICK, 0x01) 70 | 71 | /** 72 | * @ingroup los_tick 73 | * Tick error code: The number of Ticks is too small. 74 | * 75 | * Value: 0x02000402 76 | * 77 | * Solution: Change values of the OS_SYS_CLOCK and LOSCFG_BASE_CORE_TICK_PER_SECOND system time configuration modules according to the SysTick_Config function. 78 | */ 79 | #define LOS_ERRNO_TICK_PER_SEC_TOO_SMALL LOS_ERRNO_OS_ERROR(LOS_MOD_TICK, 0x02) 80 | 81 | 82 | #ifdef __cplusplus 83 | #if __cplusplus 84 | } 85 | #endif /* __cplusplus */ 86 | #endif /* __cplusplus */ 87 | 88 | #endif /* _LOS_TICK_H */ 89 | -------------------------------------------------------------------------------- /Huawei_LiteOS/kernel/include/los_typedef.h: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | /**@defgroup los_typedef Type define 36 | * @ingroup kernel 37 | */ 38 | 39 | #ifndef _LOS_TYPEDEF_H 40 | #define _LOS_TYPEDEF_H 41 | 42 | #include "los_builddef.h" 43 | 44 | #ifdef __cplusplus 45 | #if __cplusplus 46 | extern "C" { 47 | #endif /* __cplusplus */ 48 | #endif /* __cplusplus */ 49 | 50 | 51 | #define INLINE static inline 52 | 53 | #ifndef LOS_TYPE_DEF 54 | #define LOS_TYPE_DEF 55 | 56 | /* type definitions */ 57 | typedef unsigned char UINT8; 58 | typedef unsigned short UINT16; 59 | typedef unsigned int UINT32; 60 | typedef signed char INT8; 61 | typedef signed short INT16; 62 | typedef signed int INT32; 63 | typedef float FLOAT; 64 | typedef double DOUBLE; 65 | typedef char CHAR; 66 | 67 | typedef unsigned int BOOL; 68 | typedef unsigned long long UINT64; 69 | typedef signed long long INT64; 70 | typedef unsigned int UINTPTR; 71 | typedef signed int INTPTR; 72 | 73 | #if 0 74 | typedef INT32 ssize_t; 75 | typedef UINT32 size_t; 76 | 77 | #ifndef uint8_t 78 | typedef unsigned char uint8_t; 79 | #endif 80 | #ifndef int8_t 81 | typedef signed char int8_t; 82 | #endif 83 | #ifndef uint16_t 84 | typedef unsigned short uint16_t; 85 | #endif 86 | #ifndef int16_t 87 | typedef signed short int16_t; 88 | #endif 89 | #ifndef uint32_t 90 | typedef unsigned int uint32_t; 91 | #endif 92 | #ifndef int32_t 93 | typedef signed int int32_t; 94 | #endif 95 | #ifndef int64_t 96 | typedef long long int64_t; 97 | #endif 98 | #ifndef uint64_t 99 | typedef unsigned long long uint64_t; 100 | #endif 101 | #endif 102 | 103 | #define VOID void 104 | #endif /*end of #ifndef LOS_TYPE_DEF*/ 105 | 106 | #ifndef FALSE 107 | #define FALSE ((BOOL)0) 108 | #endif 109 | 110 | #ifndef TRUE 111 | #define TRUE ((BOOL)1) 112 | #endif 113 | 114 | #ifndef __cplusplus 115 | 116 | #ifndef false 117 | #define false FALSE 118 | #endif 119 | 120 | #ifndef true 121 | #define true TRUE 122 | #endif 123 | 124 | #ifndef bool 125 | #define bool BOOL 126 | #endif 127 | 128 | #endif /* __cplusplus */ 129 | 130 | #ifndef NULL 131 | #define NULL ((VOID *)0) 132 | #endif 133 | 134 | #ifdef YES 135 | #undef YES 136 | #endif 137 | #define YES (1) 138 | 139 | #ifdef NO 140 | #undef NO 141 | #endif 142 | #define NO (0) 143 | 144 | #define OS_NULL_BYTE ((UINT8)0xFF) 145 | #define OS_NULL_SHORT ((UINT16)0xFFFF) 146 | #define OS_NULL_INT ((UINT32)0xFFFFFFFF) 147 | 148 | #ifndef LOS_OK 149 | #define LOS_OK (0) 150 | #endif 151 | 152 | #ifndef LOS_NOK 153 | #define LOS_NOK (1) 154 | #endif 155 | 156 | #define OS_FAIL (1) 157 | #define OS_ERROR (UINT32)(-1) 158 | #define OS_INVALID (UINT32)(-1) 159 | 160 | #define asm __asm 161 | #ifdef typeof 162 | #undef typeof 163 | #endif 164 | #define typeof __typeof__ 165 | 166 | 167 | #ifdef __cplusplus 168 | #if __cplusplus 169 | } 170 | #endif /* __cplusplus */ 171 | #endif /* __cplusplus */ 172 | 173 | #endif /* _LOS_TYPEDEF_H */ 174 | -------------------------------------------------------------------------------- /Huawei_LiteOS/platform/bsp/sample/config/los_builddef.h: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * HuaweiLite OS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to HuaweiLite OS of U.S. and the country in which you are located. 31 | * Import, export and usage of HuaweiLite OS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | /**@defgroup los_builddef 36 | * @ingroup kernel 37 | */ 38 | 39 | #ifndef _LOS_BUILDEF_H 40 | #define _LOS_BUILDEF_H 41 | 42 | #ifdef __cplusplus 43 | #if __cplusplus 44 | extern "C" { 45 | #endif /* __cpluscplus */ 46 | #endif /* __cpluscplus */ 47 | 48 | /** 49 | * @ingroup los_builddef 50 | * Define inline keyword 51 | */ 52 | #define INLINE static inline 53 | 54 | /** 55 | * @ingroup los_builddef 56 | * Little endian 57 | */ 58 | #define OS_LITTLE_ENDIAN 0x1234 59 | 60 | /** 61 | * @ingroup los_builddef 62 | * Big endian 63 | */ 64 | #define OS_BIG_ENDIAN 0x4321 65 | 66 | /** 67 | * @ingroup los_builddef 68 | * Byte order 69 | */ 70 | #ifndef OS_BYTE_ORDER 71 | #define OS_BYTE_ORDER OS_LITTLE_ENDIAN 72 | #endif 73 | 74 | /* Define OS code data sections */ 75 | /*The indicator function is inline*/ 76 | 77 | /** 78 | * @ingroup los_builddef 79 | * Allow inline sections 80 | */ 81 | #ifndef LITE_OS_SEC_ALW_INLINE 82 | #define LITE_OS_SEC_ALW_INLINE //__attribute__((always_inline)) 83 | #endif 84 | 85 | /** 86 | * @ingroup los_builddef 87 | * Vector table section 88 | */ 89 | #ifndef LITE_OS_SEC_VEC 90 | #define LITE_OS_SEC_VEC //__attribute__ ((section(".vector.bss"))) 91 | #endif 92 | 93 | /** 94 | * @ingroup los_builddef 95 | * .Text section (Code section) 96 | */ 97 | #ifndef LITE_OS_SEC_TEXT 98 | #define LITE_OS_SEC_TEXT //__attribute__((section(".sram.text"))) 99 | #endif 100 | 101 | /** 102 | * @ingroup los_builddef 103 | * .Text.ddr section 104 | */ 105 | #ifndef LITE_OS_SEC_TEXT_MINOR 106 | #define LITE_OS_SEC_TEXT_MINOR // __attribute__((section(".dyn.text"))) 107 | #endif 108 | 109 | /** 110 | * @ingroup los_builddef 111 | * .Text.init section 112 | */ 113 | #ifndef LITE_OS_SEC_TEXT_INIT 114 | #define LITE_OS_SEC_TEXT_INIT //__attribute__((section(".dyn.text"))) 115 | #endif 116 | 117 | /** 118 | * @ingroup los_builddef 119 | * .Data section 120 | */ 121 | #ifndef LITE_OS_SEC_DATA 122 | #define LITE_OS_SEC_DATA //__attribute__((section(".dyn.data"))) 123 | #endif 124 | 125 | /** 126 | * @ingroup los_builddef 127 | * .Data.init section 128 | */ 129 | #ifndef LITE_OS_SEC_DATA_INIT 130 | #define LITE_OS_SEC_DATA_INIT //__attribute__((section(".dyn.data"))) 131 | #endif 132 | 133 | /** 134 | * @ingroup los_builddef 135 | * Not initialized variable section 136 | */ 137 | #ifndef LITE_OS_SEC_BSS 138 | #define LITE_OS_SEC_BSS //__attribute__((section(".sym.bss"))) 139 | #endif 140 | 141 | /** 142 | * @ingroup los_builddef 143 | * .bss.ddr section 144 | */ 145 | #ifndef LITE_OS_SEC_BSS_MINOR 146 | #define LITE_OS_SEC_BSS_MINOR 147 | #endif 148 | 149 | /** 150 | * @ingroup los_builddef 151 | * .bss.init sections 152 | */ 153 | #ifndef LITE_OS_SEC_BSS_INIT 154 | #define LITE_OS_SEC_BSS_INIT 155 | #endif 156 | 157 | #ifndef LITE_OS_SEC_TEXT_DATA 158 | #define LITE_OS_SEC_TEXT_DATA //__attribute__((section(".dyn.data"))) 159 | #define LITE_OS_SEC_TEXT_BSS //__attribute__((section(".dyn.bss"))) 160 | #define LITE_OS_SEC_TEXT_RODATA //__attribute__((section(".dyn.rodata"))) 161 | #endif 162 | 163 | #ifndef LITE_OS_SEC_SYMDATA 164 | #define LITE_OS_SEC_SYMDATA //__attribute__((section(".sym.data"))) 165 | #endif 166 | 167 | #ifndef LITE_OS_SEC_SYMBSS 168 | #define LITE_OS_SEC_SYMBSS //__attribute__((section(".sym.bss"))) 169 | #endif 170 | 171 | 172 | #ifndef LITE_OS_SEC_KEEP_DATA_DDR 173 | #define LITE_OS_SEC_KEEP_DATA_DDR //__attribute__((section(".keep.data.ddr"))) 174 | #endif 175 | 176 | #ifndef LITE_OS_SEC_KEEP_TEXT_DDR 177 | #define LITE_OS_SEC_KEEP_TEXT_DDR //__attribute__((section(".keep.text.ddr"))) 178 | #endif 179 | 180 | #ifndef LITE_OS_SEC_KEEP_DATA_SRAM 181 | #define LITE_OS_SEC_KEEP_DATA_SRAM //__attribute__((section(".keep.data.sram"))) 182 | #endif 183 | 184 | #ifndef LITE_OS_SEC_KEEP_TEXT_SRAM 185 | #define LITE_OS_SEC_KEEP_TEXT_SRAM //__attribute__((section(".keep.text.sram"))) 186 | #endif 187 | 188 | #ifndef LITE_OS_SEC_BSS_MINOR 189 | #define LITE_OS_SEC_BSS_MINOR 190 | #endif 191 | 192 | #ifdef __cplusplus 193 | #if __cplusplus 194 | } 195 | #endif /* __cpluscplus */ 196 | #endif /* __cpluscplus */ 197 | 198 | 199 | #endif /* _LOS_BUILDEF_H */ 200 | -------------------------------------------------------------------------------- /Huawei_LiteOS/platform/bsp/sample/config/los_config.c: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #include "los_sys.h" 36 | #include "los_tick.h" 37 | #include "los_task.ph" 38 | #include "los_config.h" 39 | 40 | #ifdef __cplusplus 41 | #if __cplusplus 42 | extern "C" { 43 | #endif /* __cpluscplus */ 44 | #endif /* __cpluscplus */ 45 | 46 | #pragma data_alignment=8 47 | UINT8 *m_aucSysMem0; 48 | UINT32 g_sys_mem_addr_end = 0; 49 | extern UINT8 g_ucMemStart[]; 50 | extern UINT32 osTickInit(UINT32 uwSystemClock, UINT32 uwTickPerSecond); 51 | extern UINT32 g_uwTskMaxNum; 52 | 53 | void osEnableFPU(void) 54 | { 55 | *(volatile UINT32 *)0xE000ED88 |= ((3UL << 10*2)|(3UL << 11*2)); 56 | //SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); 57 | } 58 | /***************************************************************************** 59 | Function : osRegister 60 | Description : Configuring the maximum number of tasks 61 | Input : None 62 | Output : None 63 | Return : None 64 | *****************************************************************************/ 65 | LITE_OS_SEC_TEXT_INIT VOID osRegister(VOID) 66 | { 67 | g_uwTskMaxNum = LOSCFG_BASE_CORE_TSK_LIMIT + 1; /* Reserved 1 for IDLE */ 68 | g_sys_mem_addr_end = (UINT32)g_ucMemStart + OS_SYS_MEM_SIZE; 69 | return; 70 | } 71 | 72 | /***************************************************************************** 73 | Function : LOS_Start 74 | Description : Task start function 75 | Input : None 76 | Output : None 77 | Return : LOS_OK 78 | *****************************************************************************/ 79 | LITE_OS_SEC_TEXT_INIT UINT32 LOS_Start() 80 | { 81 | UINT32 uwRet; 82 | #if (LOSCFG_BASE_CORE_TICK_HW_TIME == NO) 83 | uwRet = osTickStart(); 84 | 85 | if (uwRet != LOS_OK) 86 | { 87 | PRINT_ERR("osTickStart error\n"); 88 | return uwRet; 89 | } 90 | #else 91 | os_timer_init(); 92 | #endif 93 | LOS_StartToRun(); 94 | 95 | return uwRet; 96 | } 97 | 98 | /***************************************************************************** 99 | Function : osMain 100 | Description : System kernel initialization function, configure all system modules 101 | Input : None 102 | Output : None 103 | Return : LOS_OK 104 | *****************************************************************************/ 105 | LITE_OS_SEC_TEXT_INIT int osMain(void) 106 | { 107 | UINT32 uwRet; 108 | 109 | osRegister(); 110 | 111 | uwRet = osMemSystemInit(); 112 | if (uwRet != LOS_OK) 113 | { 114 | PRINT_ERR("osMemSystemInit error %d\n", uwRet); 115 | return uwRet; 116 | } 117 | 118 | #if (LOSCFG_PLATFORM_HWI == YES) 119 | { 120 | osHwiInit(); 121 | } 122 | #endif 123 | 124 | uwRet =osTaskInit(); 125 | if (uwRet != LOS_OK) 126 | { 127 | PRINT_ERR("osTaskInit error\n"); 128 | return uwRet; 129 | } 130 | 131 | #if (LOSCFG_BASE_IPC_SEM == YES) 132 | { 133 | uwRet = osSemInit(); 134 | if (uwRet != LOS_OK) 135 | { 136 | return uwRet; 137 | } 138 | } 139 | #endif 140 | 141 | #if (LOSCFG_BASE_IPC_MUX == YES) 142 | { 143 | uwRet = osMuxInit(); 144 | if (uwRet != LOS_OK) 145 | { 146 | return uwRet; 147 | } 148 | } 149 | #endif 150 | 151 | #if (LOSCFG_BASE_IPC_QUEUE == YES) 152 | { 153 | uwRet = osQueueInit(); 154 | if (uwRet != LOS_OK) 155 | { 156 | PRINT_ERR("osQueueInit error\n"); 157 | return uwRet; 158 | } 159 | } 160 | #endif 161 | 162 | #if (LOSCFG_BASE_CORE_SWTMR == YES) 163 | { 164 | uwRet = osSwTmrInit(); 165 | if (uwRet != LOS_OK) 166 | { 167 | PRINT_ERR("osSwTmrInit error\n"); 168 | return uwRet; 169 | } 170 | } 171 | #endif 172 | 173 | #if(LOSCFG_BASE_CORE_TIMESLICE == YES) 174 | osTimesliceInit(); 175 | #endif 176 | 177 | uwRet = osIdleTaskCreate(); 178 | if (uwRet != LOS_OK) { 179 | return uwRet; 180 | } 181 | 182 | return LOS_OK; 183 | } 184 | 185 | 186 | /***************************************************************************** 187 | Function : main 188 | Description : Main function entry 189 | Input : None 190 | Output : None 191 | Return : None 192 | *****************************************************************************/ 193 | LITE_OS_SEC_TEXT_INIT 194 | int main(void) 195 | { 196 | UINT32 uwRet; 197 | uwRet = osMain(); 198 | if (uwRet != LOS_OK) { 199 | return LOS_NOK; 200 | } 201 | 202 | LOS_Start(); 203 | 204 | for (;;); 205 | /* Replace the dots (...) with your own code. */ 206 | } 207 | 208 | void osBackTrace(){} 209 | 210 | #ifdef __cplusplus 211 | #if __cplusplus 212 | } 213 | #endif /* __cpluscplus */ 214 | #endif /* __cpluscplus */ 215 | -------------------------------------------------------------------------------- /Huawei_LiteOS/platform/cpu/arm/cortex-m4/los_dispatch.s: -------------------------------------------------------------------------------- 1 | ;---------------------------------------------------------------------------- 2 | ; Copyright (c) <2013-2015>, 3 | ; All rights reserved. 4 | ; Redistribution and use in source and binary forms, with or without modification, 5 | ; are permitted provided that the following conditions are met: 6 | ; 1. Redistributions of source code must retain the above copyright notice, this list of 7 | ; conditions and the following disclaimer. 8 | ; 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | ; of conditions and the following disclaimer in the documentation and/or other materials 10 | ; provided with the distribution. 11 | ; 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | ; to endorse or promote products derived from this software without specific prior written 13 | ; permission. 14 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | ; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | ; THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | ; PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | ; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | ; EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | ; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | ; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | ; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | ; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | ; ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | ;---------------------------------------------------------------------------*/ 26 | ;---------------------------------------------------------------------------- 27 | ; Notice of Export Control Law 28 | ; =============================================== 29 | ; Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | ; include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | ; Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | ; applicable export control laws and regulations. 33 | ;---------------------------------------------------------------------------*/ 34 | 35 | PRESERVE8 36 | 37 | EXPORT LOS_IntLock 38 | EXPORT LOS_IntUnLock 39 | EXPORT LOS_IntRestore 40 | EXPORT LOS_StartToRun 41 | EXPORT osTaskSchedule 42 | EXPORT osPendSV 43 | 44 | IMPORT g_stLosTask 45 | IMPORT g_pfnTskSwitchHook 46 | IMPORT g_bTaskScheduled 47 | 48 | OS_NVIC_INT_CTRL EQU 0xE000ED04 49 | OS_NVIC_SYSPRI2 EQU 0xE000ED20 50 | OS_NVIC_PENDSV_PRI EQU 0xF0F00000 51 | OS_NVIC_PENDSVSET EQU 0x10000000 52 | OS_TASK_STATUS_RUNNING EQU 0x0010 53 | 54 | SECTION .text:CODE(2) 55 | THUMB 56 | REQUIRE8 57 | 58 | LOS_StartToRun 59 | LDR R4, =OS_NVIC_SYSPRI2 60 | LDR R5, =OS_NVIC_PENDSV_PRI 61 | STR R5, [R4] 62 | 63 | LDR R0, =g_bTaskScheduled 64 | MOV R1, #1 65 | STR R1, [R0] 66 | 67 | MOV R0, #2 68 | MSR CONTROL, R0 69 | 70 | 71 | LDR R0, =g_stLosTask 72 | LDR R2, [R0, #4] 73 | LDR R0, =g_stLosTask 74 | STR R2, [R0] 75 | 76 | LDR R3, =g_stLosTask 77 | LDR R0, [R3] 78 | LDRH R7, [R0 , #4] 79 | MOV R8, #OS_TASK_STATUS_RUNNING 80 | ORR R7, R7, R8 81 | STRH R7, [R0 , #4] 82 | 83 | LDR R12, [R0] 84 | ADD R12, R12, #100 85 | 86 | LDMFD R12!, {R0-R7} 87 | ADD R12, R12, #72 88 | MSR PSP, R12 89 | VPUSH S0; 90 | VPOP S0; 91 | 92 | MOV LR, R5 93 | ;MSR xPSR, R7 94 | 95 | CPSIE I 96 | BX R6 97 | 98 | 99 | LOS_IntLock 100 | MRS R0, PRIMASK 101 | CPSID I 102 | BX LR 103 | 104 | LOS_IntUnLock 105 | MRS R0, PRIMASK 106 | CPSIE I 107 | BX LR 108 | 109 | LOS_IntRestore 110 | MSR PRIMASK, R0 111 | BX LR 112 | 113 | osTaskSchedule 114 | LDR R0, =OS_NVIC_INT_CTRL 115 | LDR R1, =OS_NVIC_PENDSVSET 116 | STR R1, [R0] 117 | BX LR 118 | 119 | osPendSV 120 | MRS R12, PRIMASK 121 | CPSID I 122 | 123 | LDR R2, =g_pfnTskSwitchHook 124 | LDR R2, [R2] 125 | CBZ R2, TaskSwitch 126 | PUSH {R12, LR} 127 | BLX R2 128 | POP {R12, LR} 129 | 130 | TaskSwitch 131 | MRS R0, PSP 132 | 133 | STMFD R0!, {R4-R12} 134 | VSTMDB R0!, {D8-D15} 135 | 136 | LDR R5, =g_stLosTask 137 | LDR R6, [R5] 138 | STR R0, [R6] 139 | 140 | 141 | LDRH R7, [R6 , #4] 142 | MOV R8,#OS_TASK_STATUS_RUNNING 143 | BIC R7, R7, R8 144 | STRH R7, [R6 , #4] 145 | 146 | 147 | LDR R0, =g_stLosTask 148 | LDR R0, [R0, #4] 149 | STR R0, [R5] 150 | 151 | 152 | LDRH R7, [R0 , #4] 153 | MOV R8, #OS_TASK_STATUS_RUNNING 154 | ORR R7, R7, R8 155 | STRH R7, [R0 , #4] 156 | 157 | LDR R1, [R0] 158 | VLDMIA R1!, {D8-D15} 159 | LDMFD R1!, {R4-R12} 160 | MSR PSP, R1 161 | 162 | MSR PRIMASK, R12 163 | BX LR 164 | 165 | END 166 | -------------------------------------------------------------------------------- /Huawei_LiteOS/platform/cpu/arm/cortex-m4/los_hw.h: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | /**@defgroup los_hw hardware 36 | *@ingroup kernel 37 | */ 38 | 39 | #ifndef _LOS_HW_H 40 | #define _LOS_HW_H 41 | 42 | #include "los_base.h" 43 | 44 | #ifdef __cplusplus 45 | #if __cplusplus 46 | extern "C" { 47 | #endif /* __cplusplus */ 48 | #endif /* __cplusplus */ 49 | 50 | /** 51 | * @ingroup los_hw 52 | * The initialization value of stack space. 53 | */ 54 | #define EMPTY_STACK 0xCACA 55 | 56 | /** 57 | * @ingroup los_hw 58 | * Trigger a task. 59 | */ 60 | #define osTaskTrap() asm(" TRAP #31") 61 | 62 | /** 63 | * @ingroup los_hw 64 | * Check task schedule. 65 | */ 66 | #define LOS_CHECK_SCHEDULE ((!g_usLosTaskLock)) 67 | 68 | /** 69 | * @ingroup los_hw 70 | * Define the type of a task context control block. 71 | */ 72 | typedef struct tagTskContext 73 | { 74 | UINT32 S16; 75 | UINT32 S17; 76 | UINT32 S18; 77 | UINT32 S19; 78 | UINT32 S20; 79 | UINT32 S21; 80 | UINT32 S22; 81 | UINT32 S23; 82 | UINT32 S24; 83 | UINT32 S25; 84 | UINT32 S26; 85 | UINT32 S27; 86 | UINT32 S28; 87 | UINT32 S29; 88 | UINT32 S30; 89 | UINT32 S31; 90 | UINT32 uwR4; 91 | UINT32 uwR5; 92 | UINT32 uwR6; 93 | UINT32 uwR7; 94 | UINT32 uwR8; 95 | UINT32 uwR9; 96 | UINT32 uwR10; 97 | UINT32 uwR11; 98 | UINT32 uwPriMask; 99 | UINT32 uwR0; 100 | UINT32 uwR1; 101 | UINT32 uwR2; 102 | UINT32 uwR3; 103 | UINT32 uwR12; 104 | UINT32 uwLR; 105 | UINT32 uwPC; 106 | UINT32 uwxPSR; 107 | UINT32 S0; 108 | UINT32 S1; 109 | UINT32 S2; 110 | UINT32 S3; 111 | UINT32 S4; 112 | UINT32 S5; 113 | UINT32 S6; 114 | UINT32 S7; 115 | UINT32 S8; 116 | UINT32 S9; 117 | UINT32 S10; 118 | UINT32 S11; 119 | UINT32 S12; 120 | UINT32 S13; 121 | UINT32 S14; 122 | UINT32 S15; 123 | UINT32 FPSCR; 124 | UINT32 NO_NAME; 125 | } TSK_CONTEXT_S; 126 | 127 | 128 | 129 | /** 130 | * @ingroup los_hw 131 | * @brief: Task stack initialization. 132 | * 133 | * @par Description: 134 | * This API is used to initialize the task stack. 135 | * 136 | * @attention: 137 | *
    • None.
    138 | * 139 | * @param uwTaskID [IN] Type#UINT32: TaskID. 140 | * @param uwStackSize [IN] Type#UINT32: Total size of the stack. 141 | * @param pTopStack [IN] Type#VOID *: Top of task's stack. 142 | * 143 | * @retval: pstContext Type#TSK_CONTEXT_S *. 144 | * @par Dependency: 145 | *
    • los_hw.h: the header file that contains the API declaration.
    146 | * @see None. 147 | * @since Huawei LiteOS V100R001C00 148 | */ 149 | extern VOID * osTskStackInit(UINT32 uwTaskID, UINT32 uwStackSize, VOID *pTopStack); 150 | 151 | 152 | 153 | /** 154 | * @ingroup los_hw 155 | * @brief: Task scheduling Function. 156 | * 157 | * @par Description: 158 | * This API is used to scheduling task. 159 | * 160 | * @attention: 161 | *
    • None.
    162 | * 163 | * @param None. 164 | * 165 | * @retval: None. 166 | * @par Dependency: 167 | *
    • los_hw.h: the header file that contains the API declaration.
    168 | * @see None. 169 | * @since Huawei LiteOS V100R001C00 170 | */ 171 | extern VOID osSchedule(VOID); 172 | 173 | 174 | /** 175 | * @ingroup los_hw 176 | * @brief: Function to determine whether task scheduling is required. 177 | * 178 | * @par Description: 179 | * This API is used to Judge and entry task scheduling. 180 | * 181 | * @attention: 182 | *
    • None.
    183 | * 184 | * @param None. 185 | * 186 | * @retval: None. 187 | * @par Dependency: 188 | *
    • los_hw.h: the header file that contains the API declaration.
    189 | * @see None. 190 | * @since Huawei LiteOS V100R001C00 191 | */ 192 | extern VOID LOS_Schedule(VOID); 193 | 194 | #ifdef __cplusplus 195 | #if __cplusplus 196 | } 197 | #endif /* __cplusplus */ 198 | #endif /* __cplusplus */ 199 | 200 | 201 | #endif /* _LOS_HW_H */ 202 | 203 | -------------------------------------------------------------------------------- /Huawei_LiteOS/platform/cpu/arm/cortex-m4/los_hw_tick.c: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * Copyright (c) <2013-2015>, 3 | * All rights reserved. 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | * 1. Redistributions of source code must retain the above copyright notice, this list of 7 | * conditions and the following disclaimer. 8 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | * of conditions and the following disclaimer in the documentation and/or other materials 10 | * provided with the distribution. 11 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | * to endorse or promote products derived from this software without specific prior written 13 | * permission. 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | *---------------------------------------------------------------------------*/ 26 | /*---------------------------------------------------------------------------- 27 | * Notice of Export Control Law 28 | * =============================================== 29 | * Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | * applicable export control laws and regulations. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #include "los_tick.ph" 36 | 37 | #include "los_base.h" 38 | #include "los_task.ph" 39 | #include "los_swtmr.h" 40 | #include "los_hwi.h" 41 | 42 | #ifdef __cplusplus 43 | #if __cplusplus 44 | extern "C" { 45 | #endif /* __cpluscplus */ 46 | #endif /* __cpluscplus */ 47 | 48 | LITE_OS_SEC_BSS UINT32 g_uwCyclesPerTick; 49 | 50 | /*lint -save -e40 -e10 -e26 -e1013*/ 51 | /***************************************************************************** 52 | Function : osTickStart 53 | Description: Configure Tick Interrupt Start 54 | Input : none 55 | output : none 56 | return : LOS_OK - Success , or LOS_ERRNO_TICK_CFG_INVALID - failed 57 | *****************************************************************************/ 58 | LITE_OS_SEC_TEXT_INIT UINT32 osTickStart(VOID) 59 | { 60 | if ((0 == OS_SYS_CLOCK) 61 | || (0 == LOSCFG_BASE_CORE_TICK_PER_SECOND) 62 | || (LOSCFG_BASE_CORE_TICK_PER_SECOND > OS_SYS_CLOCK)) 63 | { 64 | return LOS_ERRNO_TICK_CFG_INVALID; 65 | } 66 | 67 | m_pstHwiForm[OS_EXC_SYS_TICK] = (HWI_PROC_FUNC)osInterrupt; 68 | m_pstHwiSlaveForm[OS_EXC_SYS_TICK] = osTickHandler; 69 | 70 | g_uwCyclesPerTick = OS_SYS_CLOCK / LOSCFG_BASE_CORE_TICK_PER_SECOND; 71 | g_ullTickCount = 0; 72 | 73 | *(volatile UINT32 *)OS_SYSTICK_RELOAD_REG = OS_SYS_CLOCK/LOSCFG_BASE_CORE_TICK_PER_SECOND - 1; 74 | *((volatile UINT8 *)OS_NVIC_EXCPRI_BASE + (((UINT32)(-1) & 0xF) - 4)) = ((7 << 4) & 0xff); 75 | *(volatile UINT32 *)OS_SYSTICK_CURRENT_REG = 0; 76 | *(volatile UINT32 *)OS_SYSTICK_CONTROL_REG = (1 << 2) | (1 << 1) | (1 << 0); 77 | 78 | return LOS_OK; 79 | } 80 | 81 | /***************************************************************************** 82 | Function : LOS_GetCpuCycle 83 | Description: Get System cycle count 84 | Input : none 85 | output : puwCntHi --- CpuTick High 4 byte 86 | puwCntLo --- CpuTick Low 4 byte 87 | return : none 88 | *****************************************************************************/ 89 | LITE_OS_SEC_TEXT_MINOR VOID LOS_GetCpuCycle(UINT32 *puwCntHi, UINT32 *puwCntLo) 90 | { 91 | UINT64 ullSwTick; 92 | UINT64 ullCycle; 93 | UINT32 uwIntSta; 94 | UINT32 uwHwCycle; 95 | UINTPTR uwIntSave; 96 | 97 | uwIntSave = LOS_IntLock(); 98 | 99 | ullSwTick = g_ullTickCount; 100 | 101 | uwHwCycle = *(volatile UINT32*)OS_SYSTICK_CURRENT_REG; 102 | uwIntSta = *(volatile UINT32*)OS_NVIC_INT_CTRL; 103 | 104 | /*tick has come, but may interrupt environment, not counting the Tick interrupt response, to do +1 */ 105 | if (((uwIntSta & 0x4000000) != 0)) 106 | { 107 | uwHwCycle = *(volatile UINT32*)OS_SYSTICK_CURRENT_REG; 108 | ullSwTick++; 109 | } 110 | 111 | ullCycle = (((ullSwTick) * g_uwCyclesPerTick) + (g_uwCyclesPerTick - uwHwCycle)); 112 | *puwCntHi = ullCycle >> 32; 113 | *puwCntLo = ullCycle & 0xFFFFFFFFU; 114 | 115 | LOS_IntRestore(uwIntSave); 116 | 117 | return; 118 | } 119 | #ifdef __cplusplus 120 | #if __cplusplus 121 | } 122 | #endif /* __cpluscplus */ 123 | #endif /* __cpluscplus */ -------------------------------------------------------------------------------- /Huawei_LiteOS/platform/cpu/arm/cortex-m4/los_vendor.s: -------------------------------------------------------------------------------- 1 | ;---------------------------------------------------------------------------- 2 | ; Copyright (c) <2013-2015>, 3 | ; All rights reserved. 4 | ; Redistribution and use in source and binary forms, with or without modification, 5 | ; are permitted provided that the following conditions are met: 6 | ; 1. Redistributions of source code must retain the above copyright notice, this list of 7 | ; conditions and the following disclaimer. 8 | ; 2. Redistributions in binary form must reproduce the above copyright notice, this list 9 | ; of conditions and the following disclaimer in the documentation and/or other materials 10 | ; provided with the distribution. 11 | ; 3. Neither the name of the copyright holder nor the names of its contributors may be used 12 | ; to endorse or promote products derived from this software without specific prior written 13 | ; permission. 14 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | ; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 | ; THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 | ; PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18 | ; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | ; EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | ; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 | ; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | ; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 | ; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 | ; ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | ;---------------------------------------------------------------------------*/ 26 | ;---------------------------------------------------------------------------- 27 | ; Notice of Export Control Law 28 | ; =============================================== 29 | ; Huawei LiteOS may be subject to applicable export control laws and regulations, which might 30 | ; include those applicable to Huawei LiteOS of U.S. and the country in which you are located. 31 | ; Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such 32 | ; applicable export control laws and regulations. 33 | ;---------------------------------------------------------------------------*/ 34 | 35 | MODULE ?cstartup 36 | 37 | ;; Forward declaration of sections. 38 | SECTION CSTACK:DATA:NOROOT(3) 39 | SECTION .intvec:CODE:NOROOT(2) 40 | 41 | EXTERN osEnableFPU 42 | EXTERN __iar_program_start 43 | EXPORT Reset_Handler 44 | PUBLIC __vector_table 45 | 46 | DATA 47 | __vector_table 48 | DCD sfe(CSTACK) 49 | DCD Reset_Handler ; Reset Handler 50 | 51 | Reset_Handler 52 | LDR R0, =osEnableFPU 53 | BLX R0 54 | LDR R0, =__iar_program_start 55 | BX R0 56 | END 57 | 58 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | * Copyright (c) <2013-2015>, 2 | * All rights reserved. 3 | * Redistribution and use in source and binary forms, with or without modification, 4 | * are permitted provided that the following conditions are met: 5 | * 1. Redistributions of source code must retain the above copyright notice, this list of 6 | * conditions and the following disclaimer. 7 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list 8 | * of conditions and the following disclaimer in the documentation and/or other materials 9 | * provided with the distribution. 10 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used 11 | * to endorse or promote products derived from this software without specific prior written 12 | * permission. 13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 14 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 15 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 20 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 21 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 22 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 23 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /Projects/EWARM/cortex-m4/stm32f411/Application/README.md: -------------------------------------------------------------------------------- 1 | Application Code -------------------------------------------------------------------------------- /Projects/EWARM/cortex-m4/stm32f411/Huawei_LiteOS.eww: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | $WS_DIR$\Huawei_LiteOS.ewp 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Projects/EWARM/cortex-m4/stm32f411/Huawei_LiteOS_cortexMF411.icf: -------------------------------------------------------------------------------- 1 | /*###ICF### Section handled by ICF editor, don't touch! ****/ 2 | /*-Editor annotation file-*/ 3 | /* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */ 4 | /*-Specials-*/ 5 | define symbol __ICFEDIT_intvec_start__ = 0x08000000; 6 | /*-Memory Regions-*/ 7 | define symbol __ICFEDIT_region_ROM_start__ = 0x08000000; 8 | define symbol __ICFEDIT_region_ROM_end__ = 0x0807FFFF; 9 | define symbol __ICFEDIT_region_RAM_start__ = 0x20000400; 10 | define symbol __ICFEDIT_region_RAM_end__ = 0x2001FFFF; 11 | /*-Sizes-*/ 12 | define symbol __ICFEDIT_size_cstack__ = 0x2000; 13 | define symbol __ICFEDIT_size_heap__ = 0x2000; 14 | /**** End of ICF editor section. ###ICF###*/ 15 | 16 | /*** VECTOR SIZE ***/ 17 | define symbol __ICFEDIT_region_VECTOR_start__ = 0x20000000; 18 | define symbol __ICFEDIT_region_VECTOR_end__ = 0x200003FF; 19 | /*** End of VECTOR SIZE ***/ 20 | 21 | define memory mem with size = 4G; 22 | define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__]; 23 | define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__]; 24 | 25 | /*** VECTOR region***/ 26 | define region VECTOR_region = mem:[from __ICFEDIT_region_VECTOR_start__ to __ICFEDIT_region_VECTOR_end__]; 27 | /*** End of VECTOR region***/ 28 | 29 | define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { }; 30 | define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { }; 31 | 32 | initialize by copy { readwrite }; 33 | do not initialize { section .noinit }; 34 | 35 | place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec }; 36 | 37 | /*** VECTOR ***/ 38 | place in VECTOR_region { section .vector }; 39 | /*** End of VECTOR ***/ 40 | 41 | place in ROM_region { readonly }; 42 | place in RAM_region { readwrite, 43 | block CSTACK, block HEAP }; -------------------------------------------------------------------------------- /Projects/EWARM/cortex-m4/stm32f411/settings/Huawei_LiteOS.Debug.cspy.bat: -------------------------------------------------------------------------------- 1 | @REM This batch file has been generated by the IAR Embedded Workbench 2 | @REM C-SPY Debugger, as an aid to preparing a command line for running 3 | @REM the cspybat command line utility using the appropriate settings. 4 | @REM 5 | @REM Note that this file is generated every time a new debug session 6 | @REM is initialized, so you may want to move or rename the file before 7 | @REM making changes. 8 | @REM 9 | @REM You can launch cspybat by typing the name of this batch file followed 10 | @REM by the name of the debug file (usually an ELF/DWARF or UBROF file). 11 | @REM 12 | @REM Read about available command line parameters in the C-SPY Debugging 13 | @REM Guide. Hints about additional command line parameters that may be 14 | @REM useful in specific cases: 15 | @REM --download_only Downloads a code image without starting a debug 16 | @REM session afterwards. 17 | @REM --silent Omits the sign-on message. 18 | @REM --timeout Limits the maximum allowed execution time. 19 | @REM 20 | 21 | 22 | "D:\EWARM_IAR\common\bin\cspybat" "D:\EWARM_IAR\arm\bin\armproc.dll" "D:\EWARM_IAR\arm\bin\armjlink.dll" %1 --plugin "D:\EWARM_IAR\arm\bin\armbat.dll" --device_macro "D:\EWARM_IAR\arm\config\debugger\ST\STM32F4xx.dmac" --flash_loader "D:\EWARM_IAR\arm\config\flashloader\ST\FlashSTM32F411xE.board" --backend -B "--endian=little" "--cpu=Cortex-M4F" "--fpu=VFPv4" "-p" "D:\EWARM_IAR\arm\CONFIG\debugger\ST\STM32F411CE.ddf" "--semihosting" "--device=STM32F411CE" "--drv_communication=USB0" "--jlink_speed=auto" "--jlink_initial_speed=1000" "--jlink_reset_strategy=0,0" "--jlink_interface=SWD" "--drv_catch_exceptions=0x000" "--drv_swo_clock_setup=72000000,0,2000000" 23 | 24 | 25 | -------------------------------------------------------------------------------- /Projects/EWARM/cortex-m4/stm32f411/settings/Huawei_LiteOS.crun: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1 5 | 6 | 7 | * 8 | * 9 | * 10 | 0 11 | 1 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Projects/EWARM/cortex-m4/stm32f411/settings/Huawei_LiteOS.dni: -------------------------------------------------------------------------------- 1 | [Stack] 2 | FillEnabled=0 3 | OverflowWarningsEnabled=1 4 | WarningThreshold=90 5 | SpWarningsEnabled=1 6 | WarnLogOnly=1 7 | UseTrigger=1 8 | TriggerName=main 9 | LimitSize=0 10 | ByteLimit=50 11 | [DebugChecksum] 12 | Checksum=-414167973 13 | [Exceptions] 14 | StopOnUncaught=_ 0 15 | StopOnThrow=_ 0 16 | [CodeCoverage] 17 | Enabled=_ 0 18 | [CallStack] 19 | ShowArgs=0 20 | [Disassembly] 21 | MixedMode=1 22 | [JLinkDriver] 23 | CStepIntDis=_ 0 24 | TraceBufferSize=0x00010000 25 | TraceStallIfFIFOFull=0x00000000 26 | TracePortSize=0x00000004 27 | [SWOTraceHWSettings] 28 | OverrideDefaultClocks=0 29 | CpuClock=72000000 30 | ClockAutoDetect=0 31 | ClockWanted=2000000 32 | JtagSpeed=2000000 33 | Prescaler=36 34 | TimeStampPrescIndex=0 35 | TimeStampPrescData=0 36 | PcSampCYCTAP=1 37 | PcSampPOSTCNT=15 38 | PcSampIndex=0 39 | DataLogMode=0 40 | ITMportsEnable=0 41 | ITMportsTermIO=0 42 | ITMportsLogFile=0 43 | ITMlogFile=$PROJ_DIR$\ITM.log 44 | [SWOTraceWindow] 45 | PcSampling=0 46 | InterruptLogs=0 47 | ForcedTimeStamps=0 48 | EventCPI=0 49 | EventEXC=0 50 | EventFOLD=0 51 | EventLSU=0 52 | EventSLEEP=0 53 | [PowerLog] 54 | LogEnabled=0 55 | GraphEnabled=0 56 | ShowTimeLog=1 57 | ShowTimeSum=0 58 | Title_0=I0 59 | Symbol_0=0 4 1 60 | LiveEnabled=0 61 | LiveFile=PowerLogLive.log 62 | [DataLog] 63 | LogEnabled=0 64 | SumEnabled=0 65 | GraphEnabled=0 66 | ShowTimeLog=1 67 | ShowTimeSum=1 68 | [EventLog] 69 | LogEnabled=0 70 | SumEnabled=0 71 | GraphEnabled=0 72 | ShowTimeLog=1 73 | ShowTimeSum=1 74 | SumSortOrder=0 75 | [InterruptLog] 76 | LogEnabled=0 77 | SumEnabled=0 78 | GraphEnabled=0 79 | ShowTimeLog=1 80 | ShowTimeSum=1 81 | SumSortOrder=0 82 | [Log file] 83 | LoggingEnabled=_ 0 84 | LogFile=_ "" 85 | Category=_ 0 86 | [TermIOLog] 87 | LoggingEnabled=_ 0 88 | LogFile=_ "" 89 | [CallStackLog] 90 | Enabled=0 91 | [PowerProbe] 92 | Frequency=10000 93 | Probe0=I0 94 | ProbeSetup0=2 1 1 2 0 0 95 | [DriverProfiling] 96 | Enabled=0 97 | Mode=1 98 | Graph=0 99 | Symbiont=0 100 | Exclusions= 101 | [Disassemble mode] 102 | mode=0 103 | [Breakpoints2] 104 | Count=0 105 | [Aliases] 106 | Count=0 107 | SuppressDialog=0 108 | -------------------------------------------------------------------------------- /Projects/EWARM/cortex-m4/stm32f411/settings/Huawei_LiteOS.wsdt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Huawei_LiteOS/Debug 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 287272727 16 | 17 | 18 | 19 | 20 | 21 | 22 | 20121532481 23 | 191622 24 | 25 | 26 | 27 | 28 | 29 | 30 | TabID-9963-2718 31 | Workspace 32 | Workspace 33 | 34 | 35 | Huawei_LiteOSHuawei_LiteOS/Huawei_LiteOSHuawei_LiteOS/Huawei_LiteOS/platformHuawei_LiteOS/Huawei_LiteOS/platform/cpuHuawei_LiteOS/Huawei_LiteOS/testHuawei_LiteOS/Output 36 | 37 | 38 | 39 | 0 40 | 41 | 42 | TabID-30-2904 43 | Build 44 | Build 45 | 46 | 47 | TabID-3022-11932Debug LogDebug-Log 48 | 49 | 0 50 | 51 | 52 | 53 | 54 | 55 | TextEditor$WS_DIR$\..\..\..\..\Huawei_LiteOS\kernel\include\los_base.h000002325622562TextEditor$WS_DIR$\..\..\..\..\Huawei_LiteOS\platform\cpu\arm\cortex-m4\los_hw.c000004100TextEditor$WS_DIR$\..\..\..\..\Huawei_LiteOS\platform\cpu\arm\cortex-m4\los_hw_tick.c000004100TextEditor$WS_DIR$\..\..\..\..\Huawei_LiteOS\platform\bsp\sample\config\los_config.c0000016557845784TextEditor$WS_DIR$\..\..\..\..\Huawei_LiteOS\kernel\base\core\los_task.c000008563025030250TextEditor$WS_DIR$\..\..\..\..\Huawei_LiteOS\platform\cpu\arm\cortex-m4\los_hwi.c00000145653565355TextEditor$WS_DIR$\..\..\..\..\Huawei_LiteOS\platform\bsp\sample\config\los_config.h0000027399129912TextEditor$WS_DIR$\..\..\..\..\Huawei_LiteOS\kernel\base\core\los_swtmr.c0000025292429240100000010000001 56 | 57 | 58 | 59 | 60 | 61 | 62 | iaridepm.enu1-2-2605361-2-2200200119048206612216071627066-2-23181682-2-216843201002381330579119048206612 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /Projects/EWARM/cortex-m4/stm32f411/settings/Huawei_LiteOS.wspos: -------------------------------------------------------------------------------- 1 | [MainWindow] 2 | WindowPlacement=_ 210 61 1470 950 3 3 | -------------------------------------------------------------------------------- /Projects/EWARM/cortex-m4/stm32f411/settings/Huawei_LiteOS_Debug.jlink: -------------------------------------------------------------------------------- 1 | [BREAKPOINTS] 2 | ForceImpTypeAny = 0 3 | ShowInfoWin = 1 4 | EnableFlashBP = 2 5 | BPDuringExecution = 0 6 | [CFI] 7 | CFISize = 0x00 8 | CFIAddr = 0x00 9 | [CPU] 10 | MonModeVTableAddr = 0xFFFFFFFF 11 | MonModeDebug = 0 12 | MaxNumAPs = 0 13 | LowPowerHandlingMode = 0 14 | OverrideMemMap = 0 15 | AllowSimulation = 1 16 | ScriptFile="" 17 | [FLASH] 18 | CacheExcludeSize = 0x00 19 | CacheExcludeAddr = 0x00 20 | MinNumBytesFlashDL = 0 21 | SkipProgOnCRCMatch = 1 22 | VerifyDownload = 1 23 | AllowCaching = 1 24 | EnableFlashDL = 2 25 | Override = 0 26 | Device="ARM7" 27 | [GENERAL] 28 | WorkRAMSize = 0x00 29 | WorkRAMAddr = 0x00 30 | RAMUsageLimit = 0x00 31 | [SWO] 32 | SWOLogFile="" 33 | [MEM] 34 | RdOverrideOrMask = 0x00 35 | RdOverrideAndMask = 0xFFFFFFFF 36 | RdOverrideAddr = 0xFFFFFFFF 37 | WrOverrideOrMask = 0x00 38 | WrOverrideAndMask = 0xFFFFFFFF 39 | WrOverrideAddr = 0xFFFFFFFF 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ##Huawei LiteOS Kernel项目地址迁移至:https://github.com/LITEOS/LiteOS_Kernel.git 2 | -------------------------------------------------------------------------------- /doc/HuaweiLiteOSKernelDevGuide.chm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Huawei/Huawei_LiteOS_Kernel/3131138fcda37c1397f029280a30f57a202eeeaf/doc/HuaweiLiteOSKernelDevGuide.chm --------------------------------------------------------------------------------