提交 8cde7685 编写于 作者: A arvinzzz

refactor: Refactored the kernel boot process and added a init framework

close: #I3I768

Change-Id: I4f801df4abe1a9afdf43391c28276e96a5e81513
上级 8a48f492
......@@ -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
......
......@@ -963,8 +963,6 @@ VOID OsInitMappingStartUp(VOID)
OsSetKSectionAttr(KERNEL_VMM_BASE, FALSE);
OsSetKSectionAttr(UNCACHED_VMM_BASE, TRUE);
OsKSectionNewAttrEnable();
OsArchMmuInitPerCPU();
}
#endif
......
......@@ -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();
......
......@@ -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};
......
......@@ -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 */
}
......@@ -29,11 +29,12 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "internal.h"
#include <stdio.h>
#include <sys/mount.h>
#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
......@@ -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);
......@@ -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) {
......
......@@ -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 */
......@@ -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);
......@@ -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)
......
......@@ -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);
......
......@@ -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)
......
......@@ -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);
......
......@@ -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)
{
......
......@@ -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
......
......@@ -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
......@@ -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;
}
......@@ -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
......@@ -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;
......
......@@ -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__);
......
......@@ -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);
......@@ -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
* <ul>
* <li> if uses, the address must be valid in flash, and it should not overlap with other addresses
* used to store valid information. </li>
* used to store valid information. </li>
* </ul>
*
*/
......
......@@ -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);
......@@ -42,7 +42,7 @@ extern "C" {
#define __user
#endif
extern int HiLogDriverInit(void);
extern int OsHiLogDriverInit(void);
#ifdef __cplusplus
#if __cplusplus
......
/*
* 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);
}
......@@ -29,100 +29,50 @@
* 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"
#ifndef _LOS_INIT_H
#define _LOS_INIT_H
/* Inter-module variable and function */
extern CONSOLE_CB *g_console[];
#include "los_init_info.h"
#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 */
}
/**
* 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
* <ul>
* <li>Register a new module in the boot process of the kernel as part of the kernel capability component.</li>
* <li>In the startup framework, within the same _level, the startup sequence is sorted by
* the registered function name </li>
* <li>If the registration is not accompanied by the startup process after calling this interface,
* try to add -u_hook to liteos_tables_ldflags.mk </li>
* </ul>
*
* @param _hook [IN] Type #UINT32 (*)(VOID) Register function.
* @param _level [IN] Type #UINT32 Init level in the kernel.
*
* @retval None
* @par Dependency:
* <ul><li>los_init.h: the header file that contains the API declaration.</li></ul>
* @see
*/
#define LOS_MODULE_INIT(_hook, _level) OS_INIT_HOOK_REG(kernel, _hook, _level)
#endif
#endif /* _LOS_INIT_H */
/*
* 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
* <ul>
* <li> if uses, the macro LOS_INIT_DEBUG must be undefined. </li>
* </ul>
* #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
* <ul>
* <li>It is not recommended to call directly, it is recommended that each startup framework
* encapsulate a layer of interface in los_init.h.</li>
* </ul>
*
* @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:
* <ul><li>los_task_info.h: the header file that contains the API declaration.</li></ul>
* @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
* <ul>
* <li>This interface is used to add a new startup framework.</li>
* <li>To use this interface, you need to add a corresponding section description in
* the liteos.ld and liteos_llvm.ld files to match </li>
* </ul>
*
* @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:
* <ul><li>los_task_info.h: the header file that contains the API declaration.</li></ul>
* @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 */
......@@ -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
......@@ -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;
......
......@@ -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);
}
......
......@@ -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);
......
......@@ -31,8 +31,9 @@
#include "hm_liteipc.h"
#include "linux/kernel.h"
#include <fs/fs.h>
#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;
......
......@@ -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);
......
......@@ -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);
......@@ -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
......
......@@ -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;
......
......@@ -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);
}
......@@ -153,12 +153,12 @@ VOID LOS_Trace(TraceType traceType, ...);
*
* @param None.
*
* @retval None.
* @retval #LOS_OK : The trace function is initialized successfully.
* @par Dependency:
* <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
* @see LOS_TraceInit
* @see OsTraceInit
*/
VOID LOS_TraceInit(VOID);
UINT32 OsTraceInit(VOID);
/**
* @ingroup los_trace
......
......@@ -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();
......
......@@ -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[];
......
......@@ -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
......@@ -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
......@@ -35,6 +35,7 @@
#include "stdio.h"
#include "time.h"
#include "los_event.h"
#include "los_tick.h"
#include "securec.h"
......
......@@ -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)
{
......
......@@ -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))
......
......@@ -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))
......
......@@ -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)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册