diff --git a/arch/arm/arm/src/include/los_hwi_pri.h b/arch/arm/arm/src/include/los_hwi_pri.h index ad8e589c9c1210c8c1d0f699e7449b84e1f20ab7..174b01890c5c689bcafbf573d4b7dfbf6dc78545 100644 --- a/arch/arm/arm/src/include/los_hwi_pri.h +++ b/arch/arm/arm/src/include/los_hwi_pri.h @@ -59,7 +59,7 @@ extern VOID OsIncHwiFormCnt(UINT32 index); extern UINT32 OsGetHwiFormCnt(UINT32 index); extern CHAR *OsGetHwiFormName(UINT32 index); extern VOID OsInterrupt(UINT32 intNum); -extern VOID SyscallHandleInit(VOID); +extern VOID OsSyscallHandleInit(VOID); #ifdef __cplusplus #if __cplusplus diff --git a/arch/arm/arm/src/los_arch_mmu.c b/arch/arm/arm/src/los_arch_mmu.c index edb22e4745344d8af9779f176539f97a34055eae..435dcfaf2d7faed05b9d0a64c5be9a951d5167a6 100644 --- a/arch/arm/arm/src/los_arch_mmu.c +++ b/arch/arm/arm/src/los_arch_mmu.c @@ -963,8 +963,6 @@ VOID OsInitMappingStartUp(VOID) OsSetKSectionAttr(KERNEL_VMM_BASE, FALSE); OsSetKSectionAttr(UNCACHED_VMM_BASE, TRUE); OsKSectionNewAttrEnable(); - - OsArchMmuInitPerCPU(); } #endif diff --git a/arch/arm/arm/src/los_exc.c b/arch/arm/arm/src/los_exc.c index 873b8e1ab88a56ab82dd110f898a828afac2476d..47430b824adc969c35eb2a1660f2d20caabf461b 100644 --- a/arch/arm/arm/src/los_exc.c +++ b/arch/arm/arm/src/los_exc.c @@ -37,9 +37,6 @@ #ifdef LOSCFG_SAVE_EXCINFO #include "los_excinfo_pri.h" #endif -#ifdef LOSCFG_EXC_INTERACTION -#include "los_exc_interaction_pri.h" -#endif #include "los_sys_stack_pri.h" #include "los_stackinfo_pri.h" #ifdef LOSCFG_COREDUMP @@ -196,8 +193,8 @@ UINT32 OsArmSharedPageFault(UINT32 excType, ExcContext *frame, UINT32 far, UINT3 if (irqEnable) { ArchIrqEnable(); } else { - PrintExcInfo("[ERR][%s] may be held scheduler lock when entering [%s]\n", - OsCurrTaskGet()->taskName, __FUNCTION__); + PrintExcInfo("[ERR][%s] may be held scheduler lock when entering [%s] on cpu [%u]\n", + OsCurrTaskGet()->taskName, __FUNCTION__, ArchCurrCpuid()); } #else ArchIrqEnable(); @@ -1149,9 +1146,6 @@ LITE_OS_SEC_TEXT_INIT VOID OsExcHandleEntry(UINT32 excType, ExcContext *excBufAd } #endif } -#ifdef LOSCFG_EXC_INTERACTION - OsExcInteractionTaskKeep(); -#endif #ifdef LOSCFG_SHELL_CMD_DEBUG SystemRebootFunc rebootHook = OsGetRebootHook(); diff --git a/compat/posix/src/time.c b/compat/posix/src/time.c index c44d6e46c8339698a813b12c0485c9c0791bef09..b94c6a2aa8cc2ef7ae2bf90c6b1b885a889bf85f 100644 --- a/compat/posix/src/time.c +++ b/compat/posix/src/time.c @@ -1080,7 +1080,7 @@ int getitimer(int which, struct itimerval *value) } #ifdef LOSCFG_KERNEL_VDSO -VOID OsGetVdsoTime(VdsoDataPage *vdsoDataPage) +VOID OsVdsoTimeGet(VdsoDataPage *vdsoDataPage) { UINT32 intSave; struct timespec64 tmp = {0}; diff --git a/drivers/char/mem/src/mem.c b/drivers/char/mem/src/mem.c index 07786cc8f23ea0452895e701a6c76ae39570384d..c16ca27c26d4ba0b3a49018e577b7c1d9dd20999 100644 --- a/drivers/char/mem/src/mem.c +++ b/drivers/char/mem/src/mem.c @@ -32,7 +32,6 @@ #include "fcntl.h" #include "linux/kernel.h" - static int MemOpen(struct file *filep) { return 0; @@ -99,4 +98,3 @@ int DevMemRegister(void) { return register_driver("/dev/mem", &g_memDevOps, 0666, 0); /* 0666: file mode */ } - diff --git a/fs/proc/os_adapt/proc_init.c b/fs/proc/os_adapt/proc_init.c index 738a170c013622399b723ccd883bb84acafc7586..5af830bc2898b2d823a3a1eac198a3472d6b422a 100644 --- a/fs/proc/os_adapt/proc_init.c +++ b/fs/proc/os_adapt/proc_init.c @@ -29,11 +29,12 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "internal.h" -#include -#include #include "proc_fs.h" +#include "internal.h" +#include "stdio.h" +#include "sys/mount.h" #include "sys/stat.h" +#include "los_init.h" #ifdef LOSCFG_FS_PROC @@ -52,7 +53,7 @@ void ProcFsInit(void) PRINT_ERR("mount procfs err %d\n", ret); return; } - PRINTK("Mount procfs finished.\n"); + ProcMountsInit(); #if defined(LOSCFG_SHELL_CMD_DEBUG) && defined(LOSCFG_KERNEL_VM) ProcVmmInit(); @@ -61,4 +62,7 @@ void ProcFsInit(void) ProcUptimeInit(); ProcKernelTraceInit(); } + +LOS_MODULE_INIT(ProcFsInit, LOS_INIT_LEVEL_KMOD_EXTENDED); + #endif diff --git a/fs/vfs/operation/fs_init.c b/fs/vfs/operation/fs_init.c index a06952d28ca4d62fa9b99ba3d66384205d94a7a2..a8cf60b7c4633b1bd440474594e11698aeeef1a2 100644 --- a/fs/vfs/operation/fs_init.c +++ b/fs/vfs/operation/fs_init.c @@ -34,6 +34,7 @@ #include "fs/fs.h" #include "fs/fs_operation.h" #include "linux/spinlock.h" +#include "los_init.h" #include "los_printf.h" #include "fs/mount.h" #include "fs/path_cache.h" @@ -89,3 +90,5 @@ void los_vfs_init(void) #endif g_vfs_init = true; } + +LOS_MODULE_INIT(los_vfs_init, LOS_INIT_LEVEL_KMOD_BASIC); diff --git a/kernel/base/core/los_process.c b/kernel/base/core/los_process.c index a1342e8e0b1018494a6ad37148e2ebf44290d18e..7d273d136c3b902d1402d63a8e6793931c13c1dd 100644 --- a/kernel/base/core/los_process.c +++ b/kernel/base/core/los_process.c @@ -740,11 +740,6 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsSystemProcessCreate(VOID) LOS_ListInit(&g_processGroup->groupList); OsCurrProcessSet(kerInitProcess); - ret = OsCreateResourceFreeTask(); - if (ret != LOS_OK) { - return ret; - } - LosProcessCB *idleProcess = OS_PCB_FROM_PID(g_kernelIdleProcess); ret = OsInitPCB(idleProcess, OS_KERNEL_MODE, OS_TASK_PRIORITY_LOWEST, "KIdle"); if (ret != LOS_OK) { diff --git a/kernel/base/core/los_swtmr.c b/kernel/base/core/los_swtmr.c index 2f734f40489f1fbf7b4beaca2ffff673686089fb..c2b0ba440a05b7ea16069e8557b9d7349d5fbf43 100644 --- a/kernel/base/core/los_swtmr.c +++ b/kernel/base/core/los_swtmr.c @@ -30,11 +30,12 @@ */ #include "los_swtmr_pri.h" -#include "los_sortlink_pri.h" -#include "los_queue_pri.h" -#include "los_task_pri.h" +#include "los_init.h" #include "los_process_pri.h" +#include "los_queue_pri.h" #include "los_sched_pri.h" +#include "los_sortlink_pri.h" +#include "los_task_pri.h" #if (LOSCFG_BASE_CORE_SWTMR == YES) @@ -116,7 +117,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsSwtmrInit(VOID) size = sizeof(SWTMR_CTRL_S) * LOSCFG_BASE_CORE_SWTMR_LIMIT; swtmr = (SWTMR_CTRL_S *)LOS_MemAlloc(m_aucSysMem0, size); /* system resident resource */ if (swtmr == NULL) { - return LOS_ERRNO_SWTMR_NO_MEMORY; + ret = LOS_ERRNO_SWTMR_NO_MEMORY; + goto ERROR; } (VOID)memset_s(swtmr, size, 0, size); @@ -131,36 +133,45 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsSwtmrInit(VOID) g_swtmrHandlerPool = (UINT8 *)LOS_MemAlloc(m_aucSysMem1, swtmrHandlePoolSize); /* system resident resource */ if (g_swtmrHandlerPool == NULL) { - return LOS_ERRNO_SWTMR_NO_MEMORY; + ret = LOS_ERRNO_SWTMR_NO_MEMORY; + goto ERROR; } ret = LOS_MemboxInit(g_swtmrHandlerPool, swtmrHandlePoolSize, sizeof(SwtmrHandlerItem)); if (ret != LOS_OK) { - return LOS_ERRNO_SWTMR_HANDLER_POOL_NO_MEM; + ret = LOS_ERRNO_SWTMR_HANDLER_POOL_NO_MEM; + goto ERROR; } ret = OsSchedSwtmrScanRegister((SchedScan)OsSwtmrScan); if (ret != LOS_OK) { - return ret; + goto ERROR; } } ret = LOS_QueueCreate(NULL, OS_SWTMR_HANDLE_QUEUE_SIZE, &g_percpu[cpuid].swtmrHandlerQueue, 0, sizeof(CHAR *)); if (ret != LOS_OK) { - return LOS_ERRNO_SWTMR_QUEUE_CREATE_FAILED; + ret = LOS_ERRNO_SWTMR_QUEUE_CREATE_FAILED; + goto ERROR; } ret = OsSwtmrTaskCreate(); if (ret != LOS_OK) { - return LOS_ERRNO_SWTMR_TASK_CREATE_FAILED; + ret = LOS_ERRNO_SWTMR_TASK_CREATE_FAILED; + goto ERROR; } ret = OsSortLinkInit(&g_percpu[cpuid].swtmrSortLink); if (ret != LOS_OK) { - return LOS_ERRNO_SWTMR_SORTLINK_CREATE_FAILED; + ret = LOS_ERRNO_SWTMR_SORTLINK_CREATE_FAILED; + goto ERROR; } return LOS_OK; + +ERROR: + PRINT_ERR("OsSwtmrInit error! ret = %u\n", ret); + return ret; } /* @@ -522,5 +533,4 @@ LITE_OS_SEC_TEXT UINT32 LOS_SwtmrDelete(UINT16 swtmrID) return ret; } -#endif /* (LOSCFG_BASE_CORE_SWTMR == YES) */ - +#endif /* LOSCFG_BASE_CORE_SWTMR */ diff --git a/kernel/base/core/los_task.c b/kernel/base/core/los_task.c index 3ec37d24cba37e9a0bd9e809b23ade512c4f72dd..00bd9e275e3ede9657fdb48642a8b9a4f01c0dba 100644 --- a/kernel/base/core/los_task.c +++ b/kernel/base/core/los_task.c @@ -31,17 +31,21 @@ #include "los_task_pri.h" #include "los_base_pri.h" -#include "los_sem_pri.h" #include "los_event_pri.h" -#include "los_mux_pri.h" -#include "los_hw_pri.h" #include "los_exc.h" +#include "los_hw_pri.h" +#include "los_init.h" #include "los_memstat_pri.h" #include "los_mp.h" +#include "los_mux_pri.h" +#include "los_sched_pri.h" +#include "los_sem_pri.h" #include "los_spinlock.h" +#include "los_strncpy_from_user.h" #include "los_percpu_pri.h" -#include "los_sched_pri.h" #include "los_process_pri.h" +#include "los_vm_map.h" +#include "los_vm_syscall.h" #ifdef LOSCFG_KERNEL_CPUP #include "los_cpup_pri.h" @@ -49,19 +53,12 @@ #if (LOSCFG_BASE_CORE_SWTMR == YES) #include "los_swtmr_pri.h" #endif -#ifdef LOSCFG_EXC_INTERACTION -#include "los_exc_interaction_pri.h" -#endif #if (LOSCFG_KERNEL_LITEIPC == YES) #include "hm_liteipc.h" #endif -#include "los_strncpy_from_user.h" -#include "los_vm_syscall.h" #ifdef LOSCFG_ENABLE_OOM_LOOP_TASK #include "los_oom.h" #endif -#include "los_vm_map.h" - #if (LOSCFG_BASE_CORE_TSK_LIMIT <= 0) #error "task maxnum cannot be zero" @@ -187,6 +184,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsTaskInit(VOID) { UINT32 index; UINT32 size; + UINT32 ret; g_taskMaxNum = LOSCFG_BASE_CORE_TSK_LIMIT; size = (g_taskMaxNum + 1) * sizeof(LosTaskCB); @@ -196,7 +194,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsTaskInit(VOID) */ g_taskCBArray = (LosTaskCB *)LOS_MemAlloc(m_aucSysMem0, size); if (g_taskCBArray == NULL) { - return LOS_ERRNO_TSK_NO_MEMORY; + ret = LOS_ERRNO_TSK_NO_MEMORY; + goto EXIT; } (VOID)memset_s(g_taskCBArray, size, 0, size); @@ -212,7 +211,13 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsTaskInit(VOID) LOS_TraceReg(LOS_TRACE_TASK, OsTaskTrace, LOS_TRACE_TASK_NAME, LOS_TRACE_ENABLE); #endif - return OsSchedInit(); + ret = OsSchedInit(); + +EXIT: + if (ret != LOS_OK) { + PRINT_ERR("OsTaskInit error\n"); + } + return ret; } UINT32 OsGetIdleTaskId(VOID) @@ -353,12 +358,6 @@ LITE_OS_SEC_TEXT_INIT STATIC UINT32 OsTaskCreateParamCheck(const UINT32 *taskID, return LOS_ERRNO_TSK_PRIOR_ERROR; } -#ifdef LOSCFG_EXC_INTERACTION - if (!OsExcInteractionTaskCheck(initParam)) { - *pool = m_aucSysMem0; - poolSize = OS_EXC_INTERACTMEM_SIZE; - } -#endif if (initParam->uwStackSize > poolSize) { return LOS_ERRNO_TSK_STKSZ_TOO_LARGE; } @@ -442,11 +441,6 @@ STATIC VOID OsTaskKernelResourcesToFree(UINT32 syncSignal, UINTPTR topOfStack) OsTaskSyncDestroy(syncSignal); -#ifdef LOSCFG_EXC_INTERACTION - if (topOfStack < (UINTPTR)m_aucSysMem1) { - poolTmp = (VOID *)m_aucSysMem0; - } -#endif (VOID)LOS_MemFree(poolTmp, (VOID *)topOfStack); } @@ -1667,7 +1661,7 @@ STATIC VOID OsResourceRecoveryTask(VOID) } } -LITE_OS_SEC_TEXT UINT32 OsCreateResourceFreeTask(VOID) +LITE_OS_SEC_TEXT UINT32 OsResourceFreeTaskCreate(VOID) { UINT32 ret; UINT32 taskID; @@ -1690,3 +1684,5 @@ LITE_OS_SEC_TEXT UINT32 OsCreateResourceFreeTask(VOID) return ret; } +LOS_MODULE_INIT(OsResourceFreeTaskCreate, LOS_INIT_LEVEL_KMOD_TASK); + diff --git a/kernel/base/core/los_tick.c b/kernel/base/core/los_tick.c index c765cff7cd1d54c18efdc9ab051736dc24b3b3dc..e799e4db4e6ae5069c9fdd87d6b888685eba454d 100644 --- a/kernel/base/core/los_tick.c +++ b/kernel/base/core/los_tick.c @@ -54,7 +54,7 @@ LITE_OS_SEC_TEXT VOID OsTickHandler(VOID) #endif #ifdef LOSCFG_KERNEL_VDSO - OsUpdateVdsoTimeval(); + OsVdsoTimevalUpdate(); #endif #if (LOSCFG_BASE_CORE_TICK_HW_TIME == YES) diff --git a/kernel/base/include/los_memory_pri.h b/kernel/base/include/los_memory_pri.h index 12c6e0229f8463fc8d36077db1a8edab0b6c4840..b9fc707fa190bfa0a586e87fe13d7c682c4df564 100644 --- a/kernel/base/include/los_memory_pri.h +++ b/kernel/base/include/los_memory_pri.h @@ -41,18 +41,13 @@ extern "C" { #endif /* __cplusplus */ #endif /* __cplusplus */ -extern UINT32 OsMemSystemInit(UINTPTR memStart); -extern STATUS_T OsKHeapInit(size_t size); - -#ifdef LOSCFG_EXC_INTERACTION -extern UINT32 OsMemExcInteractionInit(UINTPTR memStart); -#endif -extern VOID OsDumpMemByte(size_t length, UINTPTR addr); - #ifdef LOSCFG_MEM_LEAKCHECK extern VOID OsMemUsedNodeShow(VOID *pool); #endif +extern UINT32 OsMemSystemInit(UINTPTR memStart); +extern STATUS_T OsKHeapInit(size_t size); +extern VOID OsDumpMemByte(size_t length, UINTPTR addr); extern VOID OsMemResetEndNode(VOID *pool, UINTPTR preAddr); extern UINT32 OsMemLargeNodeFree(const VOID *ptr); extern BOOL OsMemIsHeapNode(const VOID *ptr); diff --git a/kernel/base/include/los_task_pri.h b/kernel/base/include/los_task_pri.h index e5b81cb0f37f7541e09f706f7c8ac8125ad54524..d95474f2038cc1dbeb2668dde46743bd04ec4705 100644 --- a/kernel/base/include/los_task_pri.h +++ b/kernel/base/include/los_task_pri.h @@ -488,7 +488,7 @@ extern VOID OsExecDestroyTaskGroup(VOID); extern VOID OsProcessSuspendAllTask(VOID); extern UINT32 OsUserTaskOperatePermissionsCheck(LosTaskCB *taskCB); extern VOID OsWriteResourceEvent(UINT32 events); -extern UINT32 OsCreateResourceFreeTask(VOID); +extern UINT32 OsResourceFreeTaskCreate(VOID); #define OS_TASK_WAIT_ANYPROCESS (1 << 0U) #define OS_TASK_WAIT_PROCESS (1 << 1U) diff --git a/kernel/base/include/los_vm_syscall.h b/kernel/base/include/los_vm_syscall.h index 56e1411fbe4670a75026e4450e30c37b35c1bdb4..dbcb3d129892a037e36583992d99ff957251ba93 100644 --- a/kernel/base/include/los_vm_syscall.h +++ b/kernel/base/include/los_vm_syscall.h @@ -59,11 +59,11 @@ STATIC INLINE BOOL LOS_IsAnonymousMapping(unsigned long flags) VADDR_T LOS_MMap(VADDR_T vaddr, size_t len, unsigned prot, unsigned long flags, int fd, unsigned long pgoff); STATUS_T LOS_UnMMap(VADDR_T addr, size_t size); VOID *LOS_DoBrk(VOID *addr); -int LOS_DoMprotect(VADDR_T vaddr, size_t len, unsigned long prot); +INT32 LOS_DoMprotect(VADDR_T vaddr, size_t len, unsigned long prot); VADDR_T LOS_DoMremap(VADDR_T oldAddress, size_t oldSize, size_t newSize, int flags, VADDR_T newAddr); VOID LOS_DumpMemRegion(VADDR_T vaddr); -INT32 ShmInit(VOID); -INT32 ShmDeinit(VOID); +UINT32 ShmInit(VOID); +UINT32 ShmDeinit(VOID); INT32 ShmGet(key_t key, size_t size, INT32 shmflg); VOID *ShmAt(INT32 shmid, const VOID *shmaddr, INT32 shmflg); INT32 ShmCtl(INT32 shmid, INT32 cmd, struct shmid_ds *buf); diff --git a/kernel/base/ipc/los_futex.c b/kernel/base/ipc/los_futex.c index d98d493076f10c4c85fcb7374478ae3349703bc2..9e720e2fd9e75b72602b1dec5f4d300e7472a796 100644 --- a/kernel/base/ipc/los_futex.c +++ b/kernel/base/ipc/los_futex.c @@ -30,12 +30,13 @@ */ #include "los_futex_pri.h" -#include "los_process_pri.h" +#include "los_exc.h" #include "los_hash.h" -#include "los_sys_pri.h" +#include "los_init.h" +#include "los_process_pri.h" #include "los_sched_pri.h" +#include "los_sys_pri.h" #include "los_mp.h" -#include "los_exc.h" #include "los_mux_pri.h" #include "user_copy.h" @@ -100,6 +101,8 @@ UINT32 OsFutexInit(VOID) return LOS_OK; } +LOS_MODULE_INIT(OsFutexInit, LOS_INIT_LEVEL_KMOD_EXTENDED); + #ifdef LOS_FUTEX_DEBUG STATIC VOID OsFutexShowTaskNodeAttr(const LOS_DL_LIST *futexList) { diff --git a/kernel/base/misc/mempt_shellcmd.c b/kernel/base/misc/mempt_shellcmd.c index 333d5b284097830e18982a170cba991418ceb1fe..7177ace6824ada216d73033f1107a5be8f3f14ce 100644 --- a/kernel/base/misc/mempt_shellcmd.c +++ b/kernel/base/misc/mempt_shellcmd.c @@ -105,14 +105,7 @@ LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdMemCheck(INT32 argc, const CHAR *argv[]) WriteExcInfoToBuf("system memcheck over, all passed!\n"); #endif } -#ifdef LOSCFG_EXC_INTERACTION - if (LOS_MemIntegrityCheck(m_aucSysMem0) == LOS_OK) { - PRINTK("exc interaction memcheck over, all passed!\n"); -#ifdef LOSCFG_SAVE_EXCINFO - WriteExcInfoToBuf("exc interaction memcheck over, all passed!\n"); -#endif - } -#endif + return 0; } @@ -138,11 +131,6 @@ LITE_OS_SEC_TEXT_MINOR STATIC VOID OsShellCmdSectionInfo(INT32 argc, const CHAR LITE_OS_SEC_TEXT_MINOR STATIC UINT32 OsShellCmdFreeInfo(INT32 argc, const CHAR *argv[]) { -#ifdef LOSCFG_EXC_INTERACTION - UINT32 memUsed0 = LOS_MemTotalUsedGet(m_aucSysMem0); - UINT32 totalMem0 = LOS_MemPoolSizeGet(m_aucSysMem0); - UINT32 freeMem0 = totalMem0 - memUsed0; -#endif UINT32 memUsed = LOS_MemTotalUsedGet(m_aucSysMem1); UINT32 totalMem = LOS_MemPoolSizeGet(m_aucSysMem1); UINT32 freeMem = totalMem - memUsed; @@ -165,31 +153,17 @@ LITE_OS_SEC_TEXT_MINOR STATIC UINT32 OsShellCmdFreeInfo(INT32 argc, const CHAR * if ((argc == 0) || ((argc == 1) && (strcmp(argv[0], "-k") == 0)) || ((argc == 1) && (strcmp(argv[0], "-m") == 0))) { -#ifdef LOSCFG_EXC_INTERACTION - PRINTK("\r\n***** Mem:system mem Mem1:exception interaction mem *****\n"); -#endif PRINTK("\r\n total used free heap\n"); } if ((argc == 1) && (strcmp(argv[0], "-k") == 0)) { PRINTK("Mem: %-9u %-10u %-10u %-10u\n", MEM_SIZE_TO_KB(totalMem), MEM_SIZE_TO_KB(memUsed), MEM_SIZE_TO_KB(freeMem), MEM_SIZE_TO_KB(memUsedHeap)); -#ifdef LOSCFG_EXC_INTERACTION - PRINTK("Mem1: %-9u %-10u %-10u\n", MEM_SIZE_TO_KB(totalMem), MEM_SIZE_TO_KB(memUsed), - MEM_SIZE_TO_KB(freeMem)); -#endif } else if ((argc == 1) && (strcmp(argv[0], "-m") == 0)) { PRINTK("Mem: %-9u %-10u %-10u %-10u\n", MEM_SIZE_TO_MB(totalMem), MEM_SIZE_TO_MB(memUsed), MEM_SIZE_TO_MB(freeMem), MEM_SIZE_TO_MB(memUsedHeap)); -#ifdef LOSCFG_EXC_INTERACTION - PRINTK("Mem1: %-9u %-10u %-10u\n", MEM_SIZE_TO_MB(totalMem), MEM_SIZE_TO_MB(memUsed), - MEM_SIZE_TO_MB(freeMem)); -#endif } else if (argc == 0) { PRINTK("Mem: %-9u %-10u %-10u %-10u\n", totalMem, memUsed, freeMem, memUsedHeap); -#ifdef LOSCFG_EXC_INTERACTION - PRINTK("Mem1: %-9u %-10u %-10u\n", totalMem0, memUsed0, freeMem0); -#endif } else { PRINTK("\nUsage: free or free [-k/-m]\n"); return OS_ERROR; @@ -255,10 +229,6 @@ LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdMemUsed(INT32 argc, const CHAR *argv[]) OsMemUsedNodeShow(m_aucSysMem1); -#ifdef LOSCFG_EXC_INTERACTION - PRINTK("\n exc interaction memory\n"); - OsMemUsedNodeShow(m_aucSysMem0); -#endif return 0; } #endif diff --git a/kernel/base/mp/los_mp.c b/kernel/base/mp/los_mp.c index fc26d2c35927513f43cb86422af0257a12c71600..c98cc01e313bbd29ab35304f8284af0b6bb08ba4 100644 --- a/kernel/base/mp/los_mp.c +++ b/kernel/base/mp/los_mp.c @@ -30,11 +30,11 @@ */ #include "los_mp.h" -#include "los_task_pri.h" +#include "los_init.h" #include "los_percpu_pri.h" #include "los_sched_pri.h" #include "los_swtmr.h" - +#include "los_task_pri.h" #if (LOSCFG_KERNEL_SMP == YES) @@ -105,5 +105,7 @@ UINT32 OsMpInit(VOID) return LOS_OK; } +LOS_MODULE_INIT(OsMpInit, LOS_INIT_LEVEL_KMOD_TASK); + #endif diff --git a/kernel/base/vm/los_vm_boot.c b/kernel/base/vm/los_vm_boot.c index b178c80a850210ccde5adbffa344f8f4c73b5f1b..81287a263c6247b4a0201c1d10316a6cde6f55bf 100644 --- a/kernel/base/vm/los_vm_boot.c +++ b/kernel/base/vm/los_vm_boot.c @@ -57,44 +57,27 @@ VOID *OsVmBootMemAlloc(size_t len) return (VOID *)ptr; } -#ifdef LOSCFG_KERNEL_VM UINT32 OsSysMemInit(VOID) { STATUS_T ret; +#ifdef LOSCFG_KERNEL_VM OsKSpaceInit(); +#endif ret = OsKHeapInit(OS_KHEAP_BLOCK_SIZE); if (ret != LOS_OK) { - VM_ERR("OsKHeapInit fail"); + VM_ERR("OsKHeapInit fail\n"); return LOS_NOK; } +#ifdef LOSCFG_KERNEL_VM OsVmPageStartup(); g_kHeapInited = TRUE; OsInitMappingStartUp(); - -#ifdef LOSCFG_KERNEL_SHM - ret = ShmInit(); - if (ret < 0) { - VM_ERR("ShmInit fail"); - return LOS_NOK; - } -#endif - return LOS_OK; -} #else -UINT32 OsSysMemInit(VOID) -{ - STATUS_T ret; - - ret = OsKHeapInit(OS_KHEAP_BLOCK_SIZE); - if (ret != LOS_OK) { - VM_ERR("OsKHeapInit fail"); - return LOS_NOK; - } g_kHeapInited = TRUE; - return LOS_OK; -} #endif + return LOS_OK; +} diff --git a/kernel/base/vm/oom.c b/kernel/base/vm/oom.c index 1c89662b145012499c9aef12b37eb8766b229a73..f0c3c471e53af358dbca4c09193954727d0dabde 100644 --- a/kernel/base/vm/oom.c +++ b/kernel/base/vm/oom.c @@ -31,6 +31,7 @@ #include "sys_config.h" #include "los_oom.h" +#include "los_init.h" #include "los_vm_dump.h" #include "los_vm_lock.h" #include "los_vm_phys.h" @@ -245,5 +246,8 @@ LITE_OS_SEC_TEXT_MINOR UINT32 OomTaskInit(VOID) return LOS_OK; #endif } + +LOS_MODULE_INIT(OomTaskInit, LOS_INIT_LEVEL_KMOD_TASK); + #endif diff --git a/kernel/base/vm/shm.c b/kernel/base/vm/shm.c index aadca5f1c248b1d93015c626dd17fff3ea732ab6..577eb1606f93aa8c965077e7a17ec5fd3d349ca3 100644 --- a/kernel/base/vm/shm.c +++ b/kernel/base/vm/shm.c @@ -36,6 +36,7 @@ #include "sys/shm.h" #include "sys/stat.h" #include "los_config.h" +#include "los_init.h" #include "los_vm_map.h" #include "los_vm_filemap.h" #include "los_vm_phys.h" @@ -111,20 +112,20 @@ STATIC struct shminfo g_shmInfo = { STATIC struct shmIDSource *g_shmSegs = NULL; STATIC UINT32 g_shmUsedPageCount; -INT32 ShmInit(VOID) +UINT32 ShmInit(VOID) { UINT32 ret; UINT32 i; ret = LOS_MuxInit(&g_sysvShmMux, NULL); if (ret != LOS_OK) { - return -1; + goto ERROR; } g_shmSegs = LOS_MemAlloc((VOID *)OS_SYS_MEM_ADDR, sizeof(struct shmIDSource) * g_shmInfo.shmmni); if (g_shmSegs == NULL) { (VOID)LOS_MuxDestroy(&g_sysvShmMux); - return -1; + goto ERROR; } (VOID)memset_s(g_shmSegs, (sizeof(struct shmIDSource) * g_shmInfo.shmmni), 0, (sizeof(struct shmIDSource) * g_shmInfo.shmmni)); @@ -136,10 +137,16 @@ INT32 ShmInit(VOID) } g_shmUsedPageCount = 0; - return 0; + return LOS_OK; + +ERROR: + VM_ERR("ShmInit fail\n"); + return LOS_NOK; } -INT32 ShmDeinit(VOID) +LOS_MODULE_INIT(ShmInit, LOS_INIT_LEVEL_VM_COMPLETE); + +UINT32 ShmDeinit(VOID) { UINT32 ret; diff --git a/kernel/common/console.c b/kernel/common/console.c index 742afd60cbbd2d4f8a9cc58b505806630f59f59c..584acc3e80bc48bde0ac789b6a2cc8092abee873 100644 --- a/kernel/common/console.c +++ b/kernel/common/console.c @@ -1374,7 +1374,6 @@ INT32 system_console_init(const CHAR *deviceName) LOS_SpinUnlockRestore(&g_consoleSpin, intSave); #ifdef LOSCFG_SHELL - ret = OsShellInit(consoleID); if (ret != LOS_OK) { PRINT_ERR("%s, %d\n", __FUNCTION__, __LINE__); diff --git a/kernel/common/los_config.c b/kernel/common/los_config.c index bca1ceb151de6eb26d07e8aabe70bc9c4fd6e4eb..b894e7967b30c8c326d96e4e1d0f57846f0c2598 100644 --- a/kernel/common/los_config.c +++ b/kernel/common/los_config.c @@ -30,93 +30,27 @@ */ #include "los_config.h" -#include "string.h" #include "stdio.h" -#include "los_oom.h" -#ifdef LOSCFG_COMPAT_LINUXKPI -#include "linux/workqueue.h" -#include "linux/module.h" -#endif -#include "los_sys.h" -#include "los_tick.h" -#include "los_task_pri.h" -#include "los_printf.h" -#include "los_swtmr.h" -#include "los_swtmr_pri.h" +#include "string.h" +#include "gic_common.h" +#include "los_atomic.h" +#include "los_exc_pri.h" +#include "los_hwi_pri.h" +#include "los_hw_tick_pri.h" +#include "los_init_pri.h" #include "los_memory_pri.h" -#include "los_sem_pri.h" +#include "los_mp.h" #include "los_mux_pri.h" -#include "los_rwlock_pri.h" +#include "los_printf.h" +#include "los_process_pri.h" #include "los_queue_pri.h" -#include "los_memstat_pri.h" -#include "los_hwi_pri.h" +#include "los_sem_pri.h" #include "los_spinlock.h" -#include "los_mp.h" -#include "los_atomic.h" -#include "los_exc_pri.h" -#include "gic_common.h" +#include "los_swtmr_pri.h" +#include "los_task_pri.h" +#include "los_tick.h" #include "los_vm_boot.h" -#ifdef LOSCFG_FS_VFS -#include "fs/fs.h" -#include "fs/fs_operation.h" -#endif - -#if (LOSCFG_KERNEL_TRACE == YES) -#include "los_trace.h" -#endif - -#ifdef LOSCFG_KERNEL_CPUP -#include "los_cpup_pri.h" -#endif - -#ifdef LOSCFG_COMPAT_POSIX -#include "pprivate.h" -#endif - -#ifdef LOSCFG_DRIVERS_HDF_PLATFORM_UART -#include "console.h" -#endif -#ifdef LOSCFG_ARCH_CORTEX_M7 -#include "los_exc_pri.h" -#endif -#include "los_hw_tick_pri.h" -#include "los_hwi_pri.h" - -#if defined(LOSCFG_HW_RANDOM_ENABLE) || defined (LOSCFG_DRIVERS_RANDOM) -#include "randomdev.h" -#include "yarrow.h" -#endif -#ifdef LOSCFG_SHELL_DMESG -#include "dmesg_pri.h" -#endif -#ifdef LOSCFG_SHELL_LK -#include "shell_pri.h" -#endif - -#ifdef LOSCFG_KERNEL_PIPE -#include "pipe_common.h" -#endif - -#include "los_process_pri.h" -#include "los_futex_pri.h" - -#ifdef LOSCFG_KERNEL_VDSO -#include "los_vdso.h" -#endif - -#if (LOSCFG_KERNEL_LITEIPC == YES) -#include "hm_liteipc.h" -#endif - -#ifdef LOSCFG_DRIVERS_HIEVENT -#include "hievent_driver.h" -#endif - -#if (LOSCFG_BASE_CORE_HILOG == YES) -#include "los_hilog.h" -#endif - STATIC SystemRebootFunc g_rebootHook = NULL; VOID OsSetRebootHook(SystemRebootFunc func) @@ -131,236 +65,214 @@ SystemRebootFunc OsGetRebootHook(VOID) extern UINT32 OsSystemInit(VOID); extern VOID SystemInit(VOID); +#if (LOSCFG_KERNEL_SMP == 1) +extern VOID release_secondary_cores(VOID); +#endif -LITE_OS_SEC_TEXT_INIT VOID osRegister(VOID) +LITE_OS_SEC_TEXT_INIT STATIC UINT32 EarliestInit(VOID) { + /* Must be placed at the beginning of the boot process */ + OsSetMainTask(); + OsCurrTaskSet(OsGetMainTask()); + g_sysClock = OS_SYS_CLOCK; g_tickPerSecond = LOSCFG_BASE_CORE_TICK_PER_SECOND; - return; + return LOS_OK; +} + +LITE_OS_SEC_TEXT_INIT STATIC UINT32 ArchEarlyInit(VOID) +{ + UINT32 ret = LOS_OK; + + /* set system counter freq */ +#ifndef LOSCFG_TEE_ENABLE + HalClockFreqWrite(OS_SYS_CLOCK); +#endif + +#if (LOSCFG_PLATFORM_HWI == 1) + OsHwiInit(); +#endif + + OsExcInit(); + + ret = OsTickInit(g_sysClock, LOSCFG_BASE_CORE_TICK_PER_SECOND); + if (ret != LOS_OK) { + PRINT_ERR("OsTickInit error!\n"); + return ret; + } + + return LOS_OK; +} + +LITE_OS_SEC_TEXT_INIT STATIC UINT32 PlatformEarlyInit(VOID) +{ +#if defined(LOSCFG_PLATFORM_UART_WITHOUT_VFS) && defined(LOSCFG_DRIVERS) + uart_init(); +#endif /* LOSCFG_PLATFORM_UART_WITHOUT_VFS */ + + return LOS_OK; } LITE_OS_SEC_TEXT_INIT STATIC UINT32 OsIpcInit(VOID) { UINT32 ret; -#if (LOSCFG_BASE_IPC_SEM == YES) + +#if (LOSCFG_BASE_IPC_SEM == 1) ret = OsSemInit(); if (ret != LOS_OK) { + PRINT_ERR("OsSemInit error\n"); return ret; } #endif -#if (LOSCFG_BASE_IPC_QUEUE == YES) +#if (LOSCFG_BASE_IPC_QUEUE == 1) ret = OsQueueInit(); if (ret != LOS_OK) { + PRINT_ERR("OsQueueInit error\n"); return ret; } #endif return LOS_OK; } -#ifdef LOSCFG_KERNEL_PIPE -LITE_OS_SEC_TEXT_INIT STATIC VOID OsDriverPipeInit(VOID) +LITE_OS_SEC_TEXT_INIT STATIC UINT32 ArchInit(VOID) { - (VOID)pipe_init(); -} +#ifdef LOSCFG_KERNEL_MMU + OsArchMmuInitPerCPU(); #endif + return LOS_OK; +} -#ifdef LOSCFG_DRIVERS_HIEVENT -LITE_OS_SEC_TEXT_INIT STATIC VOID OsDriverHiEventInit(VOID) +LITE_OS_SEC_TEXT_INIT STATIC UINT32 PlatformInit(VOID) { - (VOID)HieventInit(); + return LOS_OK; } -#endif -#ifdef LOSCFG_COMPAT_BSD -extern void configure (void); -LITE_OS_SEC_TEXT_INIT STATIC INT32 OsBsdInit(VOID) +LITE_OS_SEC_TEXT_INIT STATIC UINT32 KModInit(VOID) { - /* - * WORKAROUND: Inside configure(), nexus_init() function calls - * HiSi-specific, library procedure - machine_resource_init(). - * The latter one is defined in libhi35xx_bsp.a which is only - * available for Hi3516 and Hi3518. - * Temporarily ifdef configure until this routine is implemented - * by other platforms. - */ -#if defined(LOSCFG_PLATFORM_HI3516DV300) || defined(LOSCFG_PLATFORM_HI3518EV300) - configure(); +#if (LOSCFG_BASE_CORE_SWTMR == 1) + OsSwtmrInit(); #endif - mi_startup(SI_SUB_ARCH_INIT); return LOS_OK; } -#endif + +LITE_OS_SEC_TEXT_INIT VOID OsSystemInfo(VOID) +{ +#ifdef LOSCFG_DEBUG_VERSION + const CHAR *buildType = "debug"; +#else + const CHAR *buildType = "release"; +#endif /* LOSCFG_DEBUG_VERSION */ + + PRINT_RELEASE("\n******************Welcome******************\n\n" + "Processor : %s" +#if (LOSCFG_KERNEL_SMP == 1) + " * %d\n" + "Run Mode : SMP\n" +#else + "\n" + "Run Mode : UP\n" +#endif + "GIC Rev : %s\n" + "build time : %s %s\n" + "Kernel : %s %d.%d.%d.%d/%s\n" + "\n*******************************************\n", + LOS_CpuInfo(), +#if (LOSCFG_KERNEL_SMP == 1) + LOSCFG_KERNEL_SMP_CORE_NUM, +#endif + HalIrqVersion(), __DATE__, __TIME__,\ + KERNEL_NAME, KERNEL_MAJOR, KERNEL_MINOR, KERNEL_PATCH, KERNEL_ITRE, buildType); +} LITE_OS_SEC_TEXT_INIT INT32 OsMain(VOID) { UINT32 ret; +#ifdef LOS_INIT_STATISTICS + UINT64 startNsec, endNsec, durationUsec; +#endif - osRegister(); - -#ifdef LOSCFG_SHELL_DMESG - ret = OsDmesgInit(); + ret = EarliestInit(); if (ret != LOS_OK) { return ret; } -#endif + OsInitCall(LOS_INIT_LEVEL_EARLIEST); -#ifdef LOSCFG_SHELL_LK - OsLkLoggerInit(NULL); -#endif - -#if (LOSCFG_KERNEL_TRACE == YES) - LOS_TraceInit(); -#endif - -#ifdef LOSCFG_EXC_INTERACTION -#ifdef LOSCFG_ARCH_CORTEX_M7 - /* 4096: 4K space for Stack */ - ret = OsMemExcInteractionInit((UINT32)&__bss_end + 4096); -#else - ret = OsMemExcInteractionInit((UINTPTR)&__bss_end); -#endif + ret = ArchEarlyInit(); if (ret != LOS_OK) { return ret; } -#endif + OsInitCall(LOS_INIT_LEVEL_ARCH_EARLY); -#if (LOSCFG_PLATFORM_HWI == YES) - OsHwiInit(); -#endif - - OsExcInit(); - - ret = OsTickInit(g_sysClock, LOSCFG_BASE_CORE_TICK_PER_SECOND); + ret = PlatformEarlyInit(); if (ret != LOS_OK) { return ret; } + OsInitCall(LOS_INIT_LEVEL_PLATFORM_EARLY); -#ifdef LOSCFG_PLATFORM_UART_WITHOUT_VFS -#ifdef LOSCFG_DRIVERS - uart_init(); + /* system and chip info */ + OsSystemInfo(); + + PRINT_RELEASE("\nmain core booting up...\n"); + +#ifdef LOS_INIT_STATISTICS + startNsec = LOS_CurrNanosec(); #endif -#ifdef LOSCFG_SHELL -#endif //LOSCFG_SHELL -#endif //LOSCFG_PLATFORM_UART_WITHOUT_VFS + ret = OsTaskInit(); if (ret != LOS_OK) { - PRINT_ERR("OsTaskInit error\n"); return ret; } -#if ((LOSCFG_BASE_IPC_QUEUE == YES) || (LOSCFG_BASE_IPC_MUX == YES) || \ - (LOSCFG_BASE_IPC_SEM == YES) || (LOSCFG_BASE_IPC_RWLOCK == YES)) - ret = OsIpcInit(); - if (ret != LOS_OK) { - return ret; - } -#endif + OsInitCall(LOS_INIT_LEVEL_KMOD_PREVM); ret = OsSysMemInit(); if (ret != LOS_OK) { - PRINT_ERR("OsSysMemInit error\n"); return ret; } - -#ifdef LOSCFG_KERNEL_SYSCALL - SyscallHandleInit(); +#if (LOSCFG_KERNEL_SMP == 1) + release_secondary_cores(); #endif + OsInitCall(LOS_INIT_LEVEL_VM_COMPLETE); - /* - * CPUP should be inited before first task creation which depends on the semaphore - * when LOSCFG_KERNEL_SMP_TASK_SYNC is enabled. So don't change this init sequence - * if not neccessary. The sequence should be like this: - * 1. OsIpcInit - * 2. OsCpupInit - * 3. other inits have task creation - */ -#ifdef LOSCFG_KERNEL_CPUP - ret = OsCpupInit(); + ret = OsIpcInit(); if (ret != LOS_OK) { - PRINT_ERR("OsCpupInit error\n"); return ret; } -#endif ret = OsSystemProcessCreate(); if (ret != LOS_OK) { return ret; } -#if (LOSCFG_BASE_CORE_SWTMR == YES) - ret = OsSwtmrInit(); + ret = ArchInit(); if (ret != LOS_OK) { return ret; } -#endif - -#ifdef LOSCFG_KERNEL_CPUP - OsCpupGuardCreator(); -#endif - -#if (LOSCFG_KERNEL_SMP == YES) - (VOID)OsMpInit(); -#endif + OsInitCall(LOS_INIT_LEVEL_ARCH); -#if defined(LOSCFG_HW_RANDOM_ENABLE) || defined (LOSCFG_DRIVERS_RANDOM) - random_alg_context.ra_init_alg(NULL); - run_harvester_iterate(NULL); -#endif - -#ifdef LOSCFG_COMPAT_BSD - ret = OsBsdInit(); + ret = PlatformInit(); if (ret != LOS_OK) { - PRINT_ERR("init bsd failed!\n"); return ret; } -#endif - -#ifdef LOSCFG_KERNEL_PIPE - OsDriverPipeInit(); -#endif + OsInitCall(LOS_INIT_LEVEL_PLATFORM); - ret = OsSystemInit(); + ret = KModInit(); if (ret != LOS_OK) { return ret; } -#if (LOSCFG_BASE_CORE_HILOG == YES) - ret = HiLogDriverInit(); - if (ret != LOS_OK) { - return ret; - } -#endif -#if LOSCFG_DRIVERS_HIEVENT - OsDriverHiEventInit(); -#endif + OsInitCall(LOS_INIT_LEVEL_KMOD_BASIC); -#if (LOSCFG_KERNEL_LITEIPC == YES) - ret = LiteIpcInit(); - if (ret != LOS_OK) { - return ret; - } -#endif + OsInitCall(LOS_INIT_LEVEL_KMOD_EXTENDED); -#ifdef LOSCFG_KERNEL_VDSO - ret = OsInitVdso(); - if (ret != LOS_OK) { - return ret; - } -#endif + OsInitCall(LOS_INIT_LEVEL_KMOD_TASK); -#ifdef LOSCFG_KERNEL_VM - ret = OsFutexInit(); - if (ret != LOS_OK) { - PRINT_ERR("Create futex failed : %d!\n", ret); - return ret; - } - - ret = OomTaskInit(); - if (ret != LOS_OK) { - return ret; - } +#ifdef LOS_INIT_STATISTICS + endNsec = LOS_CurrNanosec(); + durationUsec = (endNsec - startNsec) / OS_SYS_NS_PER_US; + PRINTK("The main core takes %lluus to start.\n", durationUsec); #endif return LOS_OK; @@ -382,7 +294,7 @@ STATIC UINT32 OsSystemInitTaskCreate(VOID) sysTask.pcName = "SystemInit"; sysTask.usTaskPrio = LOSCFG_BASE_CORE_TSK_DEFAULT_PRIO; sysTask.uwResved = LOS_TASK_STATUS_DETACHED; -#if (LOSCFG_KERNEL_SMP == YES) +#if (LOSCFG_KERNEL_SMP == 1) sysTask.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid()); #endif return LOS_TaskCreate(&taskID, &sysTask); @@ -392,12 +304,7 @@ STATIC UINT32 OsSystemInitTaskCreate(VOID) UINT32 OsSystemInit(VOID) { UINT32 ret; -#ifdef LOSCFG_FS_VFS - los_vfs_init(); -#endif -#ifdef LOSCFG_COMPAT_LINUXKPI - g_pstSystemWq = create_workqueue("system_wq"); -#endif + ret = OsSystemInitTaskCreate(); if (ret != LOS_OK) { return ret; @@ -406,3 +313,4 @@ UINT32 OsSystemInit(VOID) return 0; } +LOS_MODULE_INIT(OsSystemInit, LOS_INIT_LEVEL_KMOD_TASK); diff --git a/kernel/common/los_config.h b/kernel/common/los_config.h index 7b9cb0ad3d0007babc8176b2940b84d50ed1eb5b..ad44d41b4188b04b33902591da9421c47274c731 100644 --- a/kernel/common/los_config.h +++ b/kernel/common/los_config.h @@ -253,9 +253,11 @@ extern UINT32 __heap_end; * @ingroup los_config * Maximum number of semaphores. */ +#ifndef OS_SEM_COUNT_MAX #define OS_SEM_COUNT_MAX 0xFFFE +#endif -/****************************** mutex module configuration ******************************/ +/****************************** Mutex module configuration ******************************/ /** * @ingroup los_config * Configuration item for mutex module tailoring @@ -397,7 +399,7 @@ extern UINT32 __heap_end; #define OS_AUTOINIT_DYNLOADER YES #endif -/****************************** exception information configuration ******************************/ +/****************************** Exception information configuration ******************************/ #ifdef LOSCFG_SAVE_EXCINFO /** * @ingroup los_config @@ -411,7 +413,7 @@ extern UINT32 __heap_end; * @attention * * */ diff --git a/kernel/common/los_exc_interaction.c b/kernel/common/los_exc_interaction.c deleted file mode 100644 index 66e904aedacbaeb06b26c88db6656beb4d6c2436..0000000000000000000000000000000000000000 --- a/kernel/common/los_exc_interaction.c +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. - * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "los_exc_interaction_pri.h" -#ifdef LOSCFG_EXC_INTERACTION -#include "los_task_pri.h" -#ifdef LOSCFG_SHELL -#include "shell.h" -#include "shell_pri.h" -#endif -#include "console.h" -#include "hisoc/uart.h" -#include "hal_hwi.h" - -/* Inter-module variable and function */ -extern CONSOLE_CB *g_console[]; - -#define IS_UARTSHELL_ID(taskID) (((taskID) == shellCB->shellTaskHandle) || \ - ((taskID) == shellCB->shellEntryHandle)) - -STATIC BOOL IsIdleTask(UINT32 taskID) -{ - UINT32 i; - - for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) { - if (taskID == g_percpu[i].idleTaskID) { - return TRUE; - } - } - - return FALSE; -} - -STATIC BOOL IsSwtTask(UINT32 taskID) -{ - UINT32 i; - - for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) { - if (taskID == g_percpu[i].swtmrTaskID) { - return TRUE; - } - } - - return FALSE; -} - -UINT32 OsExcInteractionTaskCheck(const TSK_INIT_PARAM_S *initParam) -{ - if (initParam->pfnTaskEntry == (TSK_ENTRY_FUNC)OsIdleTask) { - return LOS_OK; - } - if ((initParam->pfnTaskEntry == (TSK_ENTRY_FUNC)ShellTask) || - (initParam->pfnTaskEntry == (TSK_ENTRY_FUNC)ShellEntry)) { - return LOS_OK; - } - return LOS_NOK; -} - -VOID OsExcInteractionTaskKeep(VOID) -{ - LosTaskCB *taskCB = NULL; - UINT32 taskID; - UINT32 curIrqNum; - ShellCB *shellCB = NULL; - CONSOLE_CB *consoleCB = NULL; - - consoleCB = g_console[CONSOLE_SERIAL - 1]; - if (consoleCB == NULL) { - PRINTK("Serial Shell Uninitialized\n"); - return; - } - shellCB = (ShellCB *)(consoleCB->shellHandle); - - g_intCount[ArchCurrCpuid()] = 0; - for (taskID = 0; taskID < g_taskMaxNum; taskID++) { - if (taskID == OsCurrTaskGet()->taskID) { - continue; - } else if ((IsIdleTask(taskID) == TRUE) || IS_UARTSHELL_ID(taskID)) { - continue; - } - - taskCB = OS_TCB_FROM_TID(taskID); - if (OsTaskIsUnused(taskCB)) { - continue; - } - if (IsSwtTask(taskID) == TRUE) { - taskCB->taskStatus &= (~OS_TASK_FLAG_SYSTEM_TASK); - } - - (VOID)LOS_TaskDelete(taskID); - } - HalIrqInit(); - HalIrqUnmask(NUM_HAL_INTERRUPT_UART); - curIrqNum = HalCurIrqGet(); - HalIrqClear(curIrqNum); - (VOID)LOS_TaskDelete(OsCurrTaskGet()->taskID); - /* unreachable */ -} - -#endif diff --git a/kernel/common/los_hilog.c b/kernel/common/los_hilog.c index 8731ad8348390d4f3e1caad807eac7cae59490e4..7ff2f215fd73c8c1c13706a3f5a57c7b0885434b 100644 --- a/kernel/common/los_hilog.c +++ b/kernel/common/los_hilog.c @@ -30,6 +30,7 @@ */ #include "los_hilog.h" +#include "los_init.h" #include "los_mp.h" #include "los_mux.h" #include "los_process_pri.h" @@ -328,9 +329,10 @@ static void HiLogDeviceInit(void) g_hiLogDev.count = 0; } -int HiLogDriverInit(VOID) +int OsHiLogDriverInit(VOID) { HiLogDeviceInit(); return register_driver(HILOG_DRIVER, &g_hilogFops, DRIVER_MODE, NULL); } +LOS_MODULE_INIT(OsHiLogDriverInit, LOS_INIT_LEVEL_KMOD_EXTENDED); diff --git a/kernel/common/los_hilog.h b/kernel/common/los_hilog.h index 9cf10e66e9d5b9d29dd2ebf181c709a4d1a7cc8b..e719e5e7b320b90ee0fe3dd392966aa1f0a31e9a 100644 --- a/kernel/common/los_hilog.h +++ b/kernel/common/los_hilog.h @@ -42,7 +42,7 @@ extern "C" { #define __user #endif -extern int HiLogDriverInit(void); +extern int OsHiLogDriverInit(void); #ifdef __cplusplus #if __cplusplus diff --git a/kernel/common/los_init.c b/kernel/common/los_init.c new file mode 100644 index 0000000000000000000000000000000000000000..6ba26aa9d93efdd2157048eeb85b247343cf56f3 --- /dev/null +++ b/kernel/common/los_init.c @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used + * to endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "los_init_pri.h" +#include "los_atomic.h" +#include "los_config.h" +#include "los_hw.h" +#include "los_printf.h" +#include "los_spinlock.h" +#include "los_typedef.h" + +#ifdef LOS_INIT_DEBUG +#include "los_sys_pri.h" +#include "los_tick.h" +#endif + +/** + * Register kernel init level labels. + */ +OS_INIT_LEVEL_REG(kernel, 10, g_kernInitLevelList); + +STATIC volatile UINT32 g_initCurrentLevel = OS_INVALID_VALUE; +STATIC volatile struct ModuleInitInfo *g_initCurrentModule = 0; +STATIC Atomic g_initCount = 0; +STATIC SPIN_LOCK_INIT(g_initLock); + +/** + * It is recommended that each startup framework encapsulate a layer of its own calling interface. + */ +STATIC VOID InitLevelCall(const CHAR *name, const UINT32 level, struct ModuleInitInfo *initLevelList[]) +{ + struct ModuleInitInfo *module = NULL; +#ifdef LOS_INIT_DEBUG + UINT64 startNsec, endNsec; + UINT64 totalTime = 0; + UINT64 singleTime = 0; + UINT32 ret; +#endif + + if (ArchCurrCpuid() == 0) { +#ifdef LOS_INIT_DEBUG + PRINTK("-------- %s Module Init... level = %u --------\n", name, level); +#endif + g_initCurrentLevel = level; + g_initCurrentModule = initLevelList[level]; + } else { + while (g_initCurrentLevel != level) { + } + } + + do { + LOS_SpinLock(&g_initLock); + if (g_initCurrentModule >= initLevelList[level + 1]) { + LOS_SpinUnlock(&g_initLock); + break; + } + module = (struct ModuleInitInfo *)g_initCurrentModule; + g_initCurrentModule++; + LOS_SpinUnlock(&g_initLock); + if (module->hook != NULL) { +#ifdef LOS_INIT_DEBUG + ret = LOS_OK; + startNsec = LOS_CurrNanosec(); + ret = (UINT32)module->hook(); + endNsec = LOS_CurrNanosec(); + singleTime = endNsec - startNsec; + totalTime += singleTime; + PRINTK("Starting %s module consumes %llu ns. Run on cpu %u\n", module->name, singleTime, ArchCurrCpuid()); +#else + module->hook(); +#endif + } +#ifdef LOS_INIT_DEBUG + if (ret != LOS_OK) { + PRINT_ERR("%s initialization failed at module %s, function addr at 0x%x, ret code is %u\n", + name, module->name, module->hook, ret); + } +#endif + } while (1); + + if (level >= LOS_INIT_LEVEL_VM_COMPLETE) { + LOS_AtomicInc(&g_initCount); + while ((LOS_AtomicRead(&g_initCount) % LOSCFG_KERNEL_CORE_NUM) != 0) { + } + } + +#ifdef LOS_INIT_DEBUG + PRINTK("%s initialization at level %u consumes %lluns on cpu %u.\n", name, level, totalTime, ArchCurrCpuid()); +#endif +} + +VOID OsInitCall(const UINT32 level) +{ + if (level >= LOS_INIT_LEVEL_FINISH) { + return; + } + + InitLevelCall("Kernel", level, g_kernInitLevelList); +} diff --git a/kernel/common/los_init.h b/kernel/common/los_init.h new file mode 100644 index 0000000000000000000000000000000000000000..632207cdf65a68f4d76416291535a38f5b41b4f6 --- /dev/null +++ b/kernel/common/los_init.h @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used + * to endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _LOS_INIT_H +#define _LOS_INIT_H + +#include "los_init_info.h" + +/** + * Kernel Module Init Level + */ +#define LOS_INIT_LEVEL_EARLIEST 0 +#define LOS_INIT_LEVEL_ARCH_EARLY 1 +#define LOS_INIT_LEVEL_PLATFORM_EARLY 2 +#define LOS_INIT_LEVEL_KMOD_PREVM 3 +#define LOS_INIT_LEVEL_VM_COMPLETE 4 +#define LOS_INIT_LEVEL_ARCH 5 +#define LOS_INIT_LEVEL_PLATFORM 6 +#define LOS_INIT_LEVEL_KMOD_BASIC 7 +#define LOS_INIT_LEVEL_KMOD_EXTENDED 8 +#define LOS_INIT_LEVEL_KMOD_TASK 9 +#define LOS_INIT_LEVEL_FINISH 10 + +/** + * @ingroup los_init + * @brief Register a startup module to the startup process. + * + * @par Description: + * This API is used to register a startup module to the startup process. + * + * @attention + * + * + * @param _hook [IN] Type #UINT32 (*)(VOID) Register function. + * @param _level [IN] Type #UINT32 Init level in the kernel. + * + * @retval None + * @par Dependency: + * + * @see + */ +#define LOS_MODULE_INIT(_hook, _level) OS_INIT_HOOK_REG(kernel, _hook, _level) + +#endif /* _LOS_INIT_H */ diff --git a/kernel/common/los_init_info.h b/kernel/common/los_init_info.h new file mode 100644 index 0000000000000000000000000000000000000000..3711a013f8520ece1a7652ad4c16b558b9156c08 --- /dev/null +++ b/kernel/common/los_init_info.h @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used + * to endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _LOS_INIT_INFO_H +#define _LOS_INIT_INFO_H + +#include "stdalign.h" +#include "los_toolchain.h" +#include "los_typedef.h" + +/** + * @ingroup los_init_info + * Macro LOS_INIT_DEBUG needs to be defined here, used to debug the init framework. + * #define LOS_INIT_DEBUG + */ + +/** + * @ingroup los_init_info + * Macro LOS_INIT_STATISTICS needs to be defined here, used to count the kernel startup time. + * @attention + * + * #define LOS_INIT_STATISTICS + */ + +#if defined(LOS_INIT_STATISTICS) && defined(LOS_INIT_DEBUG) +#error "LOS_INIT_STATISTICS needs LOS_INIT_DEBUG to be undefined" +#endif + +#define INIT_SECTION(_type, _level, _hook) __attribute__((section(".rodata.init."#_type"."#_level"."#_hook))) +#define INIT_ALIGN __attribute__((aligned(alignof(struct ModuleInitInfo)))) + +typedef UINT32 (*OsInitHook)(VOID); + +struct ModuleInitInfo { + OsInitHook hook; +#ifdef LOS_INIT_DEBUG + const CHAR *name; +#endif +}; + +#ifdef LOS_INIT_DEBUG +#define SET_MODULE_NAME(_hook) .name = #_hook, +#else +#define SET_MODULE_NAME(_hook) +#endif + +/** +* @ingroup los_init_info +* @brief Add a registration module to the specified level in a startup framework. +* +* @par Description: +* This API is used to add a registration module to the specified level in a startup framework. +* @attention + * +* +* @param _type [IN] Type name of startup framework. +* @param _hook [IN] Register function. +* @param _level [IN] At which _level do you want to register. +* +* @retval None +* @par Dependency: +* +* @see +*/ +#define OS_INIT_HOOK_REG(_type, _hook, _level) \ + STATIC const struct ModuleInitInfo ModuleInitInfo_##_hook \ + USED INIT_SECTION(_type, _level, _hook) INIT_ALIGN = { \ + .hook = (UINT32 (*)(VOID))&_hook, \ + SET_MODULE_NAME(_hook) \ + }; + +#define EXTERN_LABEL(_type, _level) extern struct ModuleInitInfo __##_type##_init_level_##_level; +#define GET_LABEL(_type, _level) &__##_type##_init_level_##_level, + +#define INIT_LABEL_REG_0(_op, _type) \ + _op(_type, 0) +#define INIT_LABEL_REG_1(_op, _type) \ + INIT_LABEL_REG_0(_op, _type) \ + _op(_type, 1) +#define INIT_LABEL_REG_2(_op, _type) \ + INIT_LABEL_REG_1(_op, _type) \ + _op(_type, 2) +#define INIT_LABEL_REG_3(_op, _type) \ + INIT_LABEL_REG_2(_op, _type) \ + _op(_type, 3) +#define INIT_LABEL_REG_4(_op, _type) \ + INIT_LABEL_REG_3(_op, _type) \ + _op(_type, 4) +#define INIT_LABEL_REG_5(_op, _type) \ + INIT_LABEL_REG_4(_op, _type) \ + _op(_type, 5) +#define INIT_LABEL_REG_6(_op, _type) \ + INIT_LABEL_REG_5(_op, _type) \ + _op(_type, 6) +#define INIT_LABEL_REG_7(_op, _type) \ + INIT_LABEL_REG_6(_op, _type) \ + _op(_type, 7) +#define INIT_LABEL_REG_8(_op, _type) \ + INIT_LABEL_REG_7(_op, _type) \ + _op(_type, 8) +#define INIT_LABEL_REG_9(_op, _type) \ + INIT_LABEL_REG_8(_op, _type) \ + _op(_type, 9) +#define INIT_LABEL_REG_10(_op, _type) \ + INIT_LABEL_REG_9(_op, _type) \ + _op(_type, 10) + +/** +* @ingroup los_init_info +* @brief Define a set of levels and initialize the labels of each level. +* +* @par Description: +* This API is used to define a set of levels and initialize the labels of each level. +* @attention + * +* +* @param _type [IN] Type name of startup framework. +* @param _num [IN] The maximum effective level of the startup framework, the level range is [0, _num]. +* @param _list [IN] Static global array, used to manage labels at all levels. +* +* @retval None +* @par Dependency: +* +* @see +*/ +#define OS_INIT_LEVEL_REG(_type, _num, _list) \ + INIT_LABEL_REG_##_num(EXTERN_LABEL, _type) \ + STATIC struct ModuleInitInfo* _list [] = { \ + INIT_LABEL_REG_##_num(GET_LABEL, _type) \ + } + +#endif /* _LOS_INIT_INFO_H */ diff --git a/kernel/common/los_exc_interaction_pri.h b/kernel/common/los_init_pri.h similarity index 79% rename from kernel/common/los_exc_interaction_pri.h rename to kernel/common/los_init_pri.h index dcced5754e500a9444228a80a6b9159abec494eb..9258c6312ee8a3ba15a93ba694356849167dbbce 100644 --- a/kernel/common/los_exc_interaction_pri.h +++ b/kernel/common/los_init_pri.h @@ -29,25 +29,12 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _LOS_EXC_INTER_PRI_H -#define _LOS_EXC_INTER_PRI_H +#ifndef _LOS_INIT_PRI_H +#define _LOS_INIT_PRI_H -#include "los_config.h" -#include "los_task.h" +#include "los_init.h" +#include "los_typedef.h" -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ +VOID OsInitCall(const UINT32 level); -extern UINT32 OsExcInteractionTaskCheck(const TSK_INIT_PARAM_S *initParam); -extern VOID OsExcInteractionTaskKeep(VOID); - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif /* _LOS_EXC_INTER_PRI_H */ +#endif /* _LOS_INIT_PRI_H */ \ No newline at end of file diff --git a/kernel/extended/cpup/los_cpup.c b/kernel/extended/cpup/los_cpup.c index 0c6446cf5baa5ab314312e03d9c7346e14255c4d..3f68e82b60e31ccf3ffc78853394ea939e3d0040 100644 --- a/kernel/extended/cpup/los_cpup.c +++ b/kernel/extended/cpup/los_cpup.c @@ -30,8 +30,9 @@ */ #include "los_cpup_pri.h" -#include "los_process_pri.h" #include "los_base.h" +#include "los_init.h" +#include "los_process_pri.h" #include "los_swtmr.h" @@ -134,14 +135,18 @@ LITE_OS_SEC_TEXT_INIT VOID OsCpupGuard(VOID) SCHEDULER_UNLOCK(intSave); } -LITE_OS_SEC_TEXT_INIT VOID OsCpupGuardCreator(VOID) +LITE_OS_SEC_TEXT_INIT UINT32 OsCpupGuardCreator(VOID) { (VOID)LOS_SwtmrCreate(LOSCFG_BASE_CORE_TICK_PER_SECOND, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)OsCpupGuard, &cpupSwtmrID, 0); (VOID)LOS_SwtmrStart(cpupSwtmrID); + + return LOS_OK; } +LOS_MODULE_INIT(OsCpupGuardCreator, LOS_INIT_LEVEL_KMOD_TASK); + /* * Description: initialization of CPUP * Return : LOS_OK or Error Information @@ -158,6 +163,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsCpupInit(VOID) size = cpupMaxNum * sizeof(OsIrqCpupCB); g_irqCpup = (OsIrqCpupCB *)LOS_MemAlloc(m_aucSysMem0, size); if (g_irqCpup == NULL) { + PRINT_ERR("OsCpupInit error\n"); return LOS_ERRNO_CPUP_NO_MEMORY; } @@ -171,6 +177,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsCpupInit(VOID) return LOS_OK; } +LOS_MODULE_INIT(OsCpupInit, LOS_INIT_LEVEL_KMOD_EXTENDED); + STATIC VOID OsResetCpup(OsCpupBase *cpup, UINT64 cycle) { UINT16 loop; diff --git a/kernel/extended/dynload/src/los_load_elf.c b/kernel/extended/dynload/src/los_load_elf.c index be5c65adb11624a16a6920cf617f70d7a9c9c001..1d0fa835cfbab868f4c4177d78dafe73efa13d87 100644 --- a/kernel/extended/dynload/src/los_load_elf.c +++ b/kernel/extended/dynload/src/los_load_elf.c @@ -863,7 +863,7 @@ STATIC INT32 OsMakeArgsStack(ELFLoadInfo *loadInfo, UINTPTR interpMapBase) AUX_VEC_ENTRY(auxVector, vecIndex, AUX_EXECFN, (UINTPTR)loadInfo->execName); #ifdef LOSCFG_KERNEL_VDSO - vdsoLoadAddr = OsLoadVdso(OsCurrProcessGet()); + vdsoLoadAddr = OsVdsoLoad(OsCurrProcessGet()); if (vdsoLoadAddr != 0) { AUX_VEC_ENTRY(auxVector, vecIndex, AUX_SYSINFO_EHDR, vdsoLoadAddr); } diff --git a/kernel/extended/include/los_cpup_pri.h b/kernel/extended/include/los_cpup_pri.h index b19426a2a25bd386afb6a1f4f4bcd23ebe6ed96c..fd0662e16515d39866a635655e6aca5e44acc9f6 100644 --- a/kernel/extended/include/los_cpup_pri.h +++ b/kernel/extended/include/los_cpup_pri.h @@ -63,7 +63,7 @@ typedef struct { } OsIrqCpupCB; extern UINT32 OsCpupInit(VOID); -extern VOID OsCpupGuardCreator(VOID); +extern UINT32 OsCpupGuardCreator(VOID); extern VOID OsCpupCycleEndStart(UINT32 runTaskID, UINT32 newTaskID); extern UINT32 OsGetAllTaskCpuUsageUnsafe(UINT16 mode, CPUP_INFO_S *cpupInfo, UINT32 len); extern UINT32 OsGetAllProcessCpuUsageUnsafe(UINT16 mode, CPUP_INFO_S *cpupInfo, UINT32 len); diff --git a/kernel/extended/liteipc/hm_liteipc.c b/kernel/extended/liteipc/hm_liteipc.c index 51dc48dffcae7bee9cb06123dcd386cbbce78757..1a8dc3b312f75f489b26582bba6adb8c3b69b857 100644 --- a/kernel/extended/liteipc/hm_liteipc.c +++ b/kernel/extended/liteipc/hm_liteipc.c @@ -31,8 +31,9 @@ #include "hm_liteipc.h" #include "linux/kernel.h" -#include +#include "fs/fs.h" #include "fs_file.h" +#include "los_init.h" #include "los_mp.h" #include "los_mux.h" #include "los_process_pri.h" @@ -43,10 +44,10 @@ #include "los_trace.h" #include "los_trace_frame.h" #endif +#include "los_vm_lock.h" #include "los_vm_map.h" #include "los_vm_page.h" #include "los_vm_phys.h" -#include "los_vm_lock.h" #define USE_TASKID_AS_HANDLE YES #define USE_MMAP YES @@ -139,7 +140,7 @@ LITE_OS_SEC_TEXT STATIC VOID IpcTrace(IpcMsg *msg, UINT32 operation, UINT32 ipcS } #endif -LITE_OS_SEC_TEXT_INIT UINT32 LiteIpcInit(VOID) +LITE_OS_SEC_TEXT_INIT UINT32 OsLiteIpcInit(VOID) { UINT32 ret, i; #if (USE_TASKID_AS_HANDLE == YES) @@ -168,6 +169,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 LiteIpcInit(VOID) return ret; } +LOS_MODULE_INIT(OsLiteIpcInit, LOS_INIT_LEVEL_KMOD_EXTENDED); + LITE_OS_SEC_TEXT STATIC int LiteIpcOpen(struct file *filep) { return 0; diff --git a/kernel/extended/liteipc/hm_liteipc.h b/kernel/extended/liteipc/hm_liteipc.h index dc9806af4d343cae94411cb659f1267f119a7683..3dfa09316166210022fa318b0e0628a3ada5de92 100644 --- a/kernel/extended/liteipc/hm_liteipc.h +++ b/kernel/extended/liteipc/hm_liteipc.h @@ -175,7 +175,7 @@ typedef struct { #define IPC_THREAD_STATUS_STOP 0x0008U /* init liteipc driver */ -extern UINT32 LiteIpcInit(VOID); +extern UINT32 OsLiteIpcInit(VOID); /* init process liteipc memory pool */ extern UINT32 LiteIpcPoolInit(ProcIpcInfo *ipcInfo); diff --git a/kernel/extended/trace/los_trace.c b/kernel/extended/trace/los_trace.c index 184884e44bc1ee1fa6d9ac35de9dfa1641cbffbd..7a9284a2cce9dc01bfd15f18199dc0adfbf2ac07 100644 --- a/kernel/extended/trace/los_trace.c +++ b/kernel/extended/trace/los_trace.c @@ -30,23 +30,23 @@ */ #include "los_trace_pri.h" +#include "ctype.h" #include "securec.h" -#include "los_typedef.h" +#include "los_init.h" #include "los_task_pri.h" -#include "ctype.h" +#include "los_typedef.h" #ifdef LOSCFG_SHELL #include "shcmd.h" #include "shell.h" -#include "unistd.h" #include "stdlib.h" +#include "unistd.h" #endif - #ifndef LOSCFG_KERNEL_TRACE -VOID LOS_TraceInit(VOID) +UINT32 OsTraceInit(VOID) { - return; + return LOS_OK; } UINT32 LOS_TraceReg(TraceType traceType, WriteHook inHook, const CHAR *typeStr, TraceSwitch onOff) @@ -112,7 +112,7 @@ STATIC UINT8 traceBufArray[LOS_TRACE_BUFFER_SIZE]; STATIC TraceBufferCtl traceBufCtl; STATIC TraceHook traceFunc[LOS_TRACE_TYPE_MAX + 1]; -VOID LOS_TraceInit(VOID) +UINT32 OsTraceInit(VOID) { UINT32 intSave; @@ -129,6 +129,8 @@ VOID LOS_TraceInit(VOID) traceBufCtl.onOff = LOS_TRACE_ENABLE; TRACE_UNLOCK(intSave); + + return LOS_OK; } UINT32 LOS_TraceReg(TraceType traceType, WriteHook inHook, const CHAR *typeStr, TraceSwitch onOff) @@ -509,3 +511,4 @@ SHELLCMD_ENTRY(trace_shellcmd, CMD_TYPE_EX, "trace", 1, (CmdCallBackFunc)OsShell #endif +LOS_MODULE_INIT(OsTraceInit, LOS_INIT_LEVEL_EARLIEST); diff --git a/kernel/extended/vdso/include/los_vdso.h b/kernel/extended/vdso/include/los_vdso.h index a16cc5d9d50fb8262db9150997d0246f1c1da88b..aedc45920ddb4cc666a1c64894804b686dd3af3d 100644 --- a/kernel/extended/vdso/include/los_vdso.h +++ b/kernel/extended/vdso/include/los_vdso.h @@ -43,9 +43,9 @@ extern "C" { #endif /* __cplusplus */ #endif /* __cplusplus */ -extern UINT32 OsInitVdso(VOID); -extern vaddr_t OsLoadVdso(const LosProcessCB *); -extern VOID OsUpdateVdsoTimeval(VOID); +extern UINT32 OsVdsoInit(VOID); +extern vaddr_t OsVdsoLoad(const LosProcessCB *); +extern VOID OsVdsoTimevalUpdate(VOID); #ifdef __cplusplus #if __cplusplus diff --git a/kernel/extended/vdso/include/los_vdso_pri.h b/kernel/extended/vdso/include/los_vdso_pri.h index fece0026146de7644a48fa51b5e6df857ae7b92b..3e56a487e2c8150485c56d663cfaf2a4cf0bb852 100644 --- a/kernel/extended/vdso/include/los_vdso_pri.h +++ b/kernel/extended/vdso/include/los_vdso_pri.h @@ -43,7 +43,7 @@ extern "C" { #define LITE_VDSO_DATAPAGE __attribute__((section(".data.vdso.datapage"))) -extern VOID OsGetVdsoTime(VdsoDataPage *); +extern VOID OsVdsoTimeGet(VdsoDataPage *); extern CHAR __vdso_data_start; extern CHAR __vdso_text_start; diff --git a/kernel/extended/vdso/src/los_vdso.c b/kernel/extended/vdso/src/los_vdso.c index 8275b43f92e355cdf3d0ececb61b177d87a9cdac..80b2cc5600c03f6ac077625a637f950d146d7c4c 100644 --- a/kernel/extended/vdso/src/los_vdso.c +++ b/kernel/extended/vdso/src/los_vdso.c @@ -31,6 +31,7 @@ #include "los_vdso_pri.h" #include "los_vdso_datapage.h" +#include "los_init.h" #include "los_vm_map.h" #include "los_vm_lock.h" #include "los_vm_phys.h" @@ -40,7 +41,7 @@ LITE_VDSO_DATAPAGE VdsoDataPage g_vdsoDataPage __attribute__((__used__)); STATIC size_t g_vdsoSize; -UINT32 OsInitVdso(VOID) +UINT32 OsVdsoInit(VOID) { g_vdsoSize = &__vdso_text_end - &__vdso_data_start; @@ -51,7 +52,9 @@ UINT32 OsInitVdso(VOID) return LOS_OK; } -STATIC INT32 OsMapVdso(LosVmSpace *space, size_t len, PADDR_T paddr, VADDR_T vaddr, UINT32 flag) +LOS_MODULE_INIT(OsVdsoInit, LOS_INIT_LEVEL_KMOD_EXTENDED); + +STATIC INT32 OsVdsoMap(LosVmSpace *space, size_t len, PADDR_T paddr, VADDR_T vaddr, UINT32 flag) { STATUS_T ret; @@ -68,7 +71,7 @@ STATIC INT32 OsMapVdso(LosVmSpace *space, size_t len, PADDR_T paddr, VADDR_T vad return LOS_OK; } -vaddr_t OsLoadVdso(const LosProcessCB *processCB) +vaddr_t OsVdsoLoad(const LosProcessCB *processCB) { INT32 ret = -1; LosVmMapRegion *vdsoRegion = NULL; @@ -87,7 +90,7 @@ vaddr_t OsLoadVdso(const LosProcessCB *processCB) } vdsoRegion->regionFlags |= VM_MAP_REGION_FLAG_VDSO; - ret = OsMapVdso(processCB->vmSpace, g_vdsoSize, LOS_PaddrQuery((VOID *)(&__vdso_data_start)), + ret = OsVdsoMap(processCB->vmSpace, g_vdsoSize, LOS_PaddrQuery((VOID *)(&__vdso_data_start)), vdsoRegion->range.base, flag); if (ret != LOS_OK) { ret = LOS_RegionFree(processCB->vmSpace, vdsoRegion); @@ -105,23 +108,23 @@ LOCK_RELEASE: return 0; } -STATIC VOID OsLockVdso(VdsoDataPage *vdsoDataPage) +STATIC VOID LockVdsoDataPage(VdsoDataPage *vdsoDataPage) { vdsoDataPage->lockCount = 1; DMB; } -STATIC VOID OsUnlockVdso(VdsoDataPage *vdsoDataPage) +STATIC VOID UnlockVdsoDataPage(VdsoDataPage *vdsoDataPage) { DMB; vdsoDataPage->lockCount = 0; } -VOID OsUpdateVdsoTimeval(VOID) +VOID OsVdsoTimevalUpdate(VOID) { VdsoDataPage *kVdsoDataPage = (VdsoDataPage *)(&__vdso_data_start); - OsLockVdso(kVdsoDataPage); - OsGetVdsoTime(kVdsoDataPage); - OsUnlockVdso(kVdsoDataPage); + LockVdsoDataPage(kVdsoDataPage); + OsVdsoTimeGet(kVdsoDataPage); + UnlockVdsoDataPage(kVdsoDataPage); } diff --git a/kernel/include/los_trace.h b/kernel/include/los_trace.h index 6a97f1a6f0ab82997dda30b13687ea6483fd0c88..b68f627bc2df22175a72c0aa7695cea54a5e55f8 100644 --- a/kernel/include/los_trace.h +++ b/kernel/include/los_trace.h @@ -153,12 +153,12 @@ VOID LOS_Trace(TraceType traceType, ...); * * @param None. * - * @retval None. + * @retval #LOS_OK : The trace function is initialized successfully. * @par Dependency: *
  • los_trace.h: the header file that contains the API declaration.
- * @see LOS_TraceInit + * @see OsTraceInit */ -VOID LOS_TraceInit(VOID); +UINT32 OsTraceInit(VOID); /** * @ingroup los_trace diff --git a/platform/main.c b/platform/main.c index 05270cbbb0162c77b092e33710e2ce65ebeaeba2..a021b1d9f1eb7e4dfa5cb209002070665d445046 100644 --- a/platform/main.c +++ b/platform/main.c @@ -30,69 +30,58 @@ */ #include "los_config.h" -#include "los_printf.h" +#include "gic_common.h" +#include "los_arch_mmu.h" #include "los_atomic.h" +#include "los_init_pri.h" +#include "los_printf.h" #include "los_process_pri.h" -#include "los_task_pri.h" -#include "los_swtmr_pri.h" #include "los_sched_pri.h" -#include "los_arch_mmu.h" -#include "gic_common.h" +#include "los_swtmr_pri.h" +#include "los_task_pri.h" -#if (LOSCFG_KERNEL_SMP == YES) +#if (LOSCFG_KERNEL_SMP == 1) STATIC Atomic g_ncpu = 1; #endif -LITE_OS_SEC_TEXT_INIT VOID OsSystemInfo(VOID) -{ -#ifdef LOSCFG_DEBUG_VERSION - const CHAR *buildType = "debug"; -#else - const CHAR *buildType = "release"; -#endif /* LOSCFG_DEBUG_VERSION */ - - PRINT_RELEASE("\n******************Welcome******************\n\n" - "Processor : %s" -#if (LOSCFG_KERNEL_SMP == YES) - " * %d\n" - "Run Mode : SMP\n" -#else - "\n" - "Run Mode : UP\n" -#endif - "GIC Rev : %s\n" - "build time : %s %s\n" - "Kernel : %s %d.%d.%d.%d/%s\n" - "\n*******************************************\n", - LOS_CpuInfo(), -#if (LOSCFG_KERNEL_SMP == YES) - LOSCFG_KERNEL_SMP_CORE_NUM, -#endif - HalIrqVersion(), __DATE__, __TIME__,\ - KERNEL_NAME, KERNEL_MAJOR, KERNEL_MINOR, KERNEL_PATCH, KERNEL_ITRE, buildType); -} - LITE_OS_SEC_TEXT_INIT VOID secondary_cpu_start(VOID) { -#if (LOSCFG_KERNEL_SMP == YES) +#if (LOSCFG_KERNEL_SMP == 1) UINT32 cpuid = ArchCurrCpuid(); -#ifdef LOSCFG_KERNEL_MMU - OsArchMmuInitPerCPU(); -#endif - OsCurrTaskSet(OsGetMainTask()); - /* increase cpu counter */ + /* increase cpu counter and sync multi-core */ LOS_AtomicInc(&g_ncpu); + while (LOS_AtomicRead(&g_ncpu) < LOSCFG_KERNEL_CORE_NUM) { + asm volatile("wfe"); + } + asm volatile("sev"); + OsInitCall(LOS_INIT_LEVEL_VM_COMPLETE); + +#ifdef LOSCFG_KERNEL_MMU + OsArchMmuInitPerCPU(); +#endif /* store each core's hwid */ CPU_MAP_SET(cpuid, OsHwIDGet()); HalIrqInitPercpu(); + OsInitCall(LOS_INIT_LEVEL_ARCH); + + OsInitCall(LOS_INIT_LEVEL_PLATFORM); OsCurrProcessSet(OS_PCB_FROM_PID(OsGetKernelInitProcessID())); + OsInitCall(LOS_INIT_LEVEL_KMOD_BASIC); + +#if (LOSCFG_BASE_CORE_SWTMR == 1) OsSwtmrInit(); +#endif + + OsInitCall(LOS_INIT_LEVEL_KMOD_EXTENDED); + OsIdleTaskCreate(); + OsInitCall(LOS_INIT_LEVEL_KMOD_TASK); + OsSchedStart(); while (1) { __asm volatile("wfi"); @@ -100,7 +89,7 @@ LITE_OS_SEC_TEXT_INIT VOID secondary_cpu_start(VOID) #endif } -#if (LOSCFG_KERNEL_SMP == YES) +#if (LOSCFG_KERNEL_SMP == 1) #ifdef LOSCFG_TEE_ENABLE #define TSP_CPU_ON 0xb2000011UL STATIC INT32 raw_smc_send(UINT32 cmd) @@ -124,6 +113,8 @@ STATIC VOID trigger_secondary_cpu(VOID) LITE_OS_SEC_TEXT_INIT VOID release_secondary_cores(VOID) { + PRINT_RELEASE("releasing %u secondary cores\n", LOSCFG_KERNEL_SMP_CORE_NUM - 1); + trigger_secondary_cpu(); /* wait until all APs are ready */ while (LOS_AtomicRead(&g_ncpu) < LOSCFG_KERNEL_CORE_NUM) { @@ -136,6 +127,8 @@ LITE_OS_SEC_TEXT_INIT VOID release_secondary_cores(VOID) { UINT32 regval; + PRINT_RELEASE("releasing %u secondary cores\n", LOSCFG_KERNEL_SMP_CORE_NUM - 1); + /* clear the second cpu reset status */ READ_UINT32(regval, PERI_CRG30_BASE); CLEAR_RESET_REG_STATUS(regval); @@ -151,31 +144,13 @@ LITE_OS_SEC_TEXT_INIT VOID release_secondary_cores(VOID) LITE_OS_SEC_TEXT_INIT INT32 main(VOID) { - UINT32 uwRet = LOS_OK; - - OsSetMainTask(); - OsCurrTaskSet(OsGetMainTask()); - - /* set system counter freq */ -#ifndef LOSCFG_TEE_ENABLE - HalClockFreqWrite(OS_SYS_CLOCK); -#endif - - /* system and chip info */ - OsSystemInfo(); - - PRINT_RELEASE("\nmain core booting up...\n"); + UINT32 uwRet; uwRet = OsMain(); if (uwRet != LOS_OK) { return LOS_NOK; } -#if (LOSCFG_KERNEL_SMP == YES) - PRINT_RELEASE("releasing %u secondary cores\n", LOSCFG_KERNEL_SMP_CORE_NUM - 1); - release_secondary_cores(); -#endif - CPU_MAP_SET(0, OsHwIDGet()); OsSchedStart(); diff --git a/shell/full/include/shell_pri.h b/shell/full/include/shell_pri.h index 022ae1455c12a68276ab05e062cf6663dd9f1ef6..603e79d99293ce64780ebed5b18c0f0df2cfdebf 100644 --- a/shell/full/include/shell_pri.h +++ b/shell/full/include/shell_pri.h @@ -42,7 +42,7 @@ extern "C" { #endif /* __cplusplus */ #ifdef LOSCFG_SHELL_LK -extern VOID OsLkLoggerInit(const CHAR *str); +extern UINT32 OsLkLoggerInit(VOID); #endif extern CmdItem g_shellcmd[]; diff --git a/shell/full/src/base/shell_lk.c b/shell/full/src/base/shell_lk.c index 9e2474b847a51dc3e6e8daf109f8abb50ec4634b..a9606bd865931badf4bf7f300a946cb173f4df33 100644 --- a/shell/full/src/base/shell_lk.c +++ b/shell/full/src/base/shell_lk.c @@ -30,15 +30,16 @@ */ #include "shell_lk.h" +#include "securec.h" +#include "stdio.h" +#include "stdlib.h" +#include "unistd.h" #include "shcmd.h" #ifdef LOSCFG_SHELL_DMESG #include "dmesg_pri.h" #endif +#include "los_init.h" #include "los_printf_pri.h" -#include "unistd.h" -#include "stdlib.h" -#include "stdio.h" -#include "securec.h" #ifdef LOSCFG_SHELL_LK @@ -208,19 +209,21 @@ VOID LOS_LkRegHook(LK_FUNC hook) g_osLkHook = hook; } -VOID OsLkLoggerInit(const CHAR *str) +UINT32 OsLkLoggerInit(VOID) { - (VOID)str; (VOID)memset_s(&g_logger, sizeof(Logger), 0, sizeof(Logger)); OsLkTraceLvSet(TRACE_DEFAULT); LOS_LkRegHook(OsLkDefaultFunc); #ifdef LOSCFG_SHELL_DMESG (VOID)LOS_DmesgLvSet(TRACE_DEFAULT); #endif + return LOS_OK; } #ifdef LOSCFG_SHELL_CMD_DEBUG SHELLCMD_ENTRY(log_shellcmd, CMD_TYPE_EX, "log", 1, (CmdCallBackFunc)CmdLog); #endif +LOS_MODULE_INIT(OsLkLoggerInit, LOS_INIT_LEVEL_EARLIEST); + #endif diff --git a/shell/full/src/cmds/dmesg.c b/shell/full/src/cmds/dmesg.c index 8342c676e734e58279c0d9d977db537d4d5870f4..8c100c7c89b16d3b7d95e13856ba134c5aeb2e0d 100644 --- a/shell/full/src/cmds/dmesg.c +++ b/shell/full/src/cmds/dmesg.c @@ -56,8 +56,9 @@ Case B: #include "show.h" #include "shcmd.h" #include "securec.h" -#include "unistd.h" #include "stdlib.h" +#include "unistd.h" +#include "los_init.h" #include "los_task.h" @@ -766,5 +767,6 @@ ERR_OUT: } SHELLCMD_ENTRY(dmesg_shellcmd, CMD_TYPE_STD, "dmesg", XARGS, (CmdCallBackFunc)OsShellCmdDmesg); +LOS_MODULE_INIT(OsDmesgInit, LOS_INIT_LEVEL_EARLIEST); #endif diff --git a/shell/full/src/cmds/watch_shell.c b/shell/full/src/cmds/watch_shell.c index 33f885923b441f2163a24b34bc65c8ffd230f315..88e67f571a7c3e7cf009c66b2f3f142e76b855da 100644 --- a/shell/full/src/cmds/watch_shell.c +++ b/shell/full/src/cmds/watch_shell.c @@ -35,6 +35,7 @@ #include "stdio.h" #include "time.h" #include "los_event.h" +#include "los_tick.h" #include "securec.h" diff --git a/syscall/los_syscall.c b/syscall/los_syscall.c index 3b6e5098b63129df7888fb4729b0d96dceef2c42..a0ebbef4a056687e9d1d0af2eddb5863834a5e17 100644 --- a/syscall/los_syscall.c +++ b/syscall/los_syscall.c @@ -34,6 +34,7 @@ #include "fs/fs.h" #include "fs/file.h" #endif +#include "los_init.h" #include "los_signal.h" #include "los_syscall.h" #include "los_task_pri.h" @@ -81,7 +82,7 @@ typedef UINT32 (*SyscallFun7)(UINT32, UINT32, UINT32, UINT32, UINT32, UINT32, UI static UINTPTR g_syscallHandle[SYS_CALL_NUM] = {0}; static UINT8 g_syscallNArgs[(SYS_CALL_NUM + 1) / NARG_PER_BYTE] = {0}; -void SyscallHandleInit(void) +void OsSyscallHandleInit(void) { #define SYSCALL_HAND_DEF(id, fun, rType, nArg) \ if ((id) < SYS_CALL_NUM) { \ @@ -93,6 +94,8 @@ void SyscallHandleInit(void) #undef SYSCALL_HAND_DEF } +LOS_MODULE_INIT(OsSyscallHandleInit, LOS_INIT_LEVEL_KMOD_EXTENDED); + /* The SYSCALL ID is in R7 on entry. Parameters follow in R0..R6 */ VOID OsArmA32SyscallHandle(TaskContext *regs) { diff --git a/tools/build/liteos.ld b/tools/build/liteos.ld index f656f96d1256ba927c6a06144f86cb3c750b60bc..2b2ac8f6ca208de5084b014f0caeb1e050084669 100644 --- a/tools/build/liteos.ld +++ b/tools/build/liteos.ld @@ -9,6 +9,7 @@ SECTIONS KEEP (*(.set_sysinit_set)) __stop_set_sysinit_set = ABSOLUTE(.); } > ram + .got ALIGN(0x4) : { *(.got.plt) *(.got) } > ram .gcc_except_table ALIGN (0x8) : { . = .; } > ram .gcc_except_table : { KEEP(*(.gcc_except_table*)) } @@ -53,6 +54,27 @@ SECTIONS .rodata ALIGN(0x1000) : { __rodata_start = .; + __kernel_init_level_0 = ABSOLUTE(.); + KEEP(*( SORT (.rodata.init.kernel.0.*))); + __kernel_init_level_1 = ABSOLUTE(.); + KEEP(*( SORT (.rodata.init.kernel.1.*))); + __kernel_init_level_2 = ABSOLUTE(.); + KEEP(*( SORT (.rodata.init.kernel.2.*))); + __kernel_init_level_3 = ABSOLUTE(.); + KEEP(*( SORT (.rodata.init.kernel.3.*))); + __kernel_init_level_4 = ABSOLUTE(.); + KEEP(*( SORT (.rodata.init.kernel.4.*))); + __kernel_init_level_5 = ABSOLUTE(.); + KEEP(*( SORT (.rodata.init.kernel.5.*))); + __kernel_init_level_6 = ABSOLUTE(.); + KEEP(*( SORT (.rodata.init.kernel.6.*))); + __kernel_init_level_7 = ABSOLUTE(.); + KEEP(*( SORT (.rodata.init.kernel.7.*))); + __kernel_init_level_8 = ABSOLUTE(.); + KEEP(*( SORT (.rodata.init.kernel.8.*))); + __kernel_init_level_9 = ABSOLUTE(.); + KEEP(*( SORT (.rodata.init.kernel.9.*))); + __kernel_init_level_10 = ABSOLUTE(.); *(.rodata .rodata.* .gnu.linkonce.r.*) __exc_table_start = .; KEEP(*(__exc_table)) diff --git a/tools/build/liteos_llvm.ld b/tools/build/liteos_llvm.ld index b3de3f9d7258c04d590325ece2b37240ca782d04..281e328f8c66bcd6b3c541e11dc8aa65318502a0 100644 --- a/tools/build/liteos_llvm.ld +++ b/tools/build/liteos_llvm.ld @@ -69,6 +69,27 @@ SECTIONS .rodata : ALIGN(0x1000) { __rodata_start = .; + __kernel_init_level_0 = ABSOLUTE(.); + KEEP(*( SORT (.rodata.init.kernel.0.*))); + __kernel_init_level_1 = ABSOLUTE(.); + KEEP(*( SORT (.rodata.init.kernel.1.*))); + __kernel_init_level_2 = ABSOLUTE(.); + KEEP(*( SORT (.rodata.init.kernel.2.*))); + __kernel_init_level_3 = ABSOLUTE(.); + KEEP(*( SORT (.rodata.init.kernel.3.*))); + __kernel_init_level_4 = ABSOLUTE(.); + KEEP(*( SORT (.rodata.init.kernel.4.*))); + __kernel_init_level_5 = ABSOLUTE(.); + KEEP(*( SORT (.rodata.init.kernel.5.*))); + __kernel_init_level_6 = ABSOLUTE(.); + KEEP(*( SORT (.rodata.init.kernel.6.*))); + __kernel_init_level_7 = ABSOLUTE(.); + KEEP(*( SORT (.rodata.init.kernel.7.*))); + __kernel_init_level_8 = ABSOLUTE(.); + KEEP(*( SORT (.rodata.init.kernel.8.*))); + __kernel_init_level_9 = ABSOLUTE(.); + KEEP(*( SORT (.rodata.init.kernel.9.*))); + __kernel_init_level_10 = ABSOLUTE(.); *(.rodata .rodata.* .gnu.linkonce.r.*) __exc_table_start = .; KEEP(*(__exc_table)) diff --git a/tools/build/mk/liteos_tables_ldflags.mk b/tools/build/mk/liteos_tables_ldflags.mk index 07d50a02379a328d1910351c995eb3cd8a340321..c2a9dd98432e5c465a33e2b869ceafbbc5601463 100644 --- a/tools/build/mk/liteos_tables_ldflags.mk +++ b/tools/build/mk/liteos_tables_ldflags.mk @@ -39,7 +39,6 @@ #dynload_shellcmd.c -uldinit_shellcmd -ucall_shellcmd -ufindsym_shellcmd -ulddrop_shellcmd -umclose_shellcmd -umopen_shellcmd LITEOS_TABLES_KERNEL_LDFLAGS := \ -utask_shellcmd \ - -ug_usrVdsoDataPage\ -uvm_shellcmd \ -ucpup_shellcmd \ -uhelp_shellcmd \ @@ -116,11 +115,17 @@ LITEOS_TABLES_EXTEND_LDFLAGS := \ -uuart_config_shellcmd\ -uusb_debug_shellcmd +LITEOS_TABLES_KERNEL_INIT_LDFLAGS := \ + -uOsTraceInit \ + -ulos_vfs_init \ + -uProcFsInit \ + -uOsDriverRandomInit \ + -uHieventInit + LITEOS_TABLES_DRIVER_LDFLAGS := \ -ui2c_init \ -ugpio_init \ -uregulator_init \ - -uMtdInitList \ -uhispi_init \ -uhifmc100_init \ -uhisfc350_init \ @@ -163,5 +168,6 @@ LITEOS_TABLES_LDFLAGS := \ $(LITEOS_TABLES_TOOLS_LDFLAGS) \ $(LITEOS_TABLES_EXTEND_LDFLAGS) \ $(LITEOS_TABLES_FSMAP_LDFLAGS) \ - $(LITEOS_TABLES_DRIVER_LDFLAGS) + $(LITEOS_TABLES_DRIVER_LDFLAGS) \ + $(LITEOS_TABLES_KERNEL_INIT_LDFLAGS)