IssueNo:#I3E0F2
Description:Delete VM to support only kernel mode. Sig:liteos_a Feature or Bugfix:Feature Binary Source:No Change-Id: Ie1029c8fbc0c1b85c138663933118d2d148b7769
This commit is contained in:
parent
23c2c270b8
commit
c959d43684
1
Kconfig
1
Kconfig
|
@ -137,6 +137,7 @@ config PLATFORM_ADAPT
|
|||
config ENABLE_OOM_LOOP_TASK
|
||||
bool "Enable Oom loop task"
|
||||
default n
|
||||
depends on KERNEL_VM
|
||||
help
|
||||
Answer Y to enable oom loop kthread to check system out of memory.
|
||||
|
||||
|
|
|
@ -51,6 +51,8 @@ extern "C" {
|
|||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
|
||||
__attribute__((aligned(MMU_DESCRIPTOR_L1_SMALL_ENTRY_NUMBERS))) \
|
||||
__attribute__((section(".bss.prebss.translation_table"))) UINT8 \
|
||||
g_firstPageTable[MMU_DESCRIPTOR_L1_SMALL_ENTRY_NUMBERS];
|
||||
|
@ -70,6 +72,11 @@ STATIC INLINE PTE_T *OsGetPte2BasePtr(PTE_T pte1)
|
|||
return LOS_PaddrToKVaddr(pa);
|
||||
}
|
||||
|
||||
VADDR_T *OsGFirstTableGet(VOID)
|
||||
{
|
||||
return (VADDR_T *)g_firstPageTable;
|
||||
}
|
||||
|
||||
STATIC INLINE UINT32 OsUnmapL1Invalid(vaddr_t *vaddr, UINT32 *count)
|
||||
{
|
||||
UINT32 unmapCount;
|
||||
|
@ -146,7 +153,6 @@ STATIC VOID OsCvtPte2AttsToFlags(PTE_T l1Entry, PTE_T l2Entry, UINT32 *flags)
|
|||
|
||||
STATIC VOID OsPutL2Table(const LosArchMmu *archMmu, UINT32 l1Index, paddr_t l2Paddr)
|
||||
{
|
||||
LosVmPage *vmPage = NULL;
|
||||
UINT32 index;
|
||||
PTE_T ttEntry;
|
||||
/* check if any l1 entry points to this l2 table */
|
||||
|
@ -156,8 +162,9 @@ STATIC VOID OsPutL2Table(const LosArchMmu *archMmu, UINT32 l1Index, paddr_t l2Pa
|
|||
return;
|
||||
}
|
||||
}
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
/* we can free this l2 table */
|
||||
vmPage = LOS_VmPageGet(l2Paddr);
|
||||
LosVmPage *vmPage = LOS_VmPageGet(l2Paddr);
|
||||
if (vmPage == NULL) {
|
||||
LOS_Panic("bad page table paddr %#x\n", l2Paddr);
|
||||
return;
|
||||
|
@ -165,6 +172,9 @@ STATIC VOID OsPutL2Table(const LosArchMmu *archMmu, UINT32 l1Index, paddr_t l2Pa
|
|||
|
||||
LOS_ListDelete(&vmPage->node);
|
||||
LOS_PhysPageFree(vmPage);
|
||||
#else
|
||||
(VOID)LOS_MemFree(OS_SYS_MEM_ADDR, LOS_PaddrToKVaddr(l2Paddr));
|
||||
#endif
|
||||
}
|
||||
|
||||
STATIC VOID OsTryUnmapL1PTE(const LosArchMmu *archMmu, vaddr_t vaddr, UINT32 scanIndex, UINT32 scanCount)
|
||||
|
@ -370,13 +380,14 @@ STATIC UINT32 OsUnmapSection(LosArchMmu *archMmu, vaddr_t *vaddr, UINT32 *count)
|
|||
return MMU_DESCRIPTOR_L2_NUMBERS_PER_L1;
|
||||
}
|
||||
|
||||
|
||||
BOOL OsArchMmuInit(LosArchMmu *archMmu, VADDR_T *virtTtb)
|
||||
{
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
if (OsAllocAsid(&archMmu->asid) != LOS_OK) {
|
||||
VM_ERR("alloc arch mmu asid failed");
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
status_t retval = LOS_MuxInit(&archMmu->mtx, NULL);
|
||||
if (retval != LOS_OK) {
|
||||
|
@ -480,7 +491,6 @@ STATIC STATUS_T OsGetL2Table(LosArchMmu *archMmu, UINT32 l1Index, paddr_t *ppa)
|
|||
UINT32 index;
|
||||
PTE_T ttEntry;
|
||||
VADDR_T *kvaddr = NULL;
|
||||
LosVmPage *vmPage = NULL;
|
||||
UINT32 l2Offset = (MMU_DESCRIPTOR_L2_SMALL_SIZE / MMU_DESCRIPTOR_L1_SMALL_L2_TABLES_PER_PAGE) *
|
||||
(l1Index & (MMU_DESCRIPTOR_L1_SMALL_L2_TABLES_PER_PAGE - 1));
|
||||
/* lookup an existing l2 page table */
|
||||
|
@ -493,14 +503,22 @@ STATIC STATUS_T OsGetL2Table(LosArchMmu *archMmu, UINT32 l1Index, paddr_t *ppa)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
/* not found: allocate one (paddr) */
|
||||
vmPage = LOS_PhysPageAlloc();
|
||||
LosVmPage *vmPage = LOS_PhysPageAlloc();
|
||||
if (vmPage == NULL) {
|
||||
VM_ERR("have no memory to save l2 page");
|
||||
return LOS_ERRNO_VM_NO_MEMORY;
|
||||
}
|
||||
LOS_ListAdd(&archMmu->ptList, &vmPage->node);
|
||||
kvaddr = OsVmPageToVaddr(vmPage);
|
||||
#else
|
||||
kvaddr = LOS_MemAlloc(OS_SYS_MEM_ADDR, MMU_DESCRIPTOR_L2_SMALL_SIZE);
|
||||
if (kvaddr == NULL) {
|
||||
VM_ERR("have no memory to save l2 page");
|
||||
return LOS_ERRNO_VM_NO_MEMORY;
|
||||
}
|
||||
#endif
|
||||
(VOID)memset_s(kvaddr, MMU_DESCRIPTOR_L2_SMALL_SIZE, 0, MMU_DESCRIPTOR_L2_SMALL_SIZE);
|
||||
|
||||
/* get physical address */
|
||||
|
@ -751,21 +769,26 @@ VOID LOS_ArchMmuContextSwitch(LosArchMmu *archMmu)
|
|||
ttbcr |= MMU_DESCRIPTOR_TTBCR_PD0;
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
/* from armv7a arm B3.10.4, we should do synchronization changes of ASID and TTBR. */
|
||||
OsArmWriteContextidr(LOS_GetKVmSpace()->archMmu.asid);
|
||||
ISB;
|
||||
#endif
|
||||
OsArmWriteTtbr0(ttbr);
|
||||
ISB;
|
||||
OsArmWriteTtbcr(ttbcr);
|
||||
ISB;
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
if (archMmu) {
|
||||
OsArmWriteContextidr(archMmu->asid);
|
||||
ISB;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
STATUS_T LOS_ArchMmuDestroy(LosArchMmu *archMmu)
|
||||
{
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
LosVmPage *page = NULL;
|
||||
/* free all of the pages allocated in archMmu->ptList */
|
||||
while ((page = LOS_ListRemoveHeadType(&archMmu->ptList, LosVmPage, node)) != NULL) {
|
||||
|
@ -774,6 +797,7 @@ STATUS_T LOS_ArchMmuDestroy(LosArchMmu *archMmu)
|
|||
|
||||
OsArmWriteTlbiasid(archMmu->asid);
|
||||
OsFreeAsid(archMmu->asid);
|
||||
#endif
|
||||
(VOID)LOS_MuxDestroy(&archMmu->mtx);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
@ -806,11 +830,6 @@ STATIC VOID OsSwitchTmpTTB(VOID)
|
|||
ISB;
|
||||
}
|
||||
|
||||
VADDR_T *OsGFirstTableGet()
|
||||
{
|
||||
return (VADDR_T *)g_firstPageTable;
|
||||
}
|
||||
|
||||
STATIC VOID OsSetKSectionAttr(VOID)
|
||||
{
|
||||
/* every section should be page aligned */
|
||||
|
@ -930,6 +949,7 @@ VOID OsInitMappingStartUp(VOID)
|
|||
|
||||
OsArchMmuInitPerCPU();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
|
|
@ -45,6 +45,8 @@ extern "C" {
|
|||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
|
||||
STATIC SPIN_LOCK_INIT(g_cpuAsidLock);
|
||||
STATIC UINTPTR g_asidPool[BITMAP_NUM_WORDS(1UL << MMU_ARM_ASID_BITS)];
|
||||
|
||||
|
@ -72,6 +74,7 @@ VOID OsFreeAsid(UINT32 asid)
|
|||
LOS_BitmapClrNBits(g_asidPool, asid, 1);
|
||||
LOS_SpinUnlockRestore(&g_cpuAsidLock, flags);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
|
|
@ -187,6 +187,7 @@ STATIC INT32 OsDecodeDataFSR(UINT32 regDFSR)
|
|||
return ret;
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
UINT32 OsArmSharedPageFault(UINT32 excType, ExcContext *frame, UINT32 far, UINT32 fsr)
|
||||
{
|
||||
PRINT_INFO("page fault entry!!!\n");
|
||||
|
@ -226,6 +227,7 @@ UINT32 OsArmSharedPageFault(UINT32 excType, ExcContext *frame, UINT32 far, UINT3
|
|||
return LOS_ERRNO_VM_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
STATIC VOID OsExcType(UINT32 excType, ExcContext *excBufAddr, UINT32 far, UINT32 fsr)
|
||||
{
|
||||
|
@ -258,6 +260,7 @@ STATIC const CHAR *g_excTypeString[] = {
|
|||
"irq"
|
||||
};
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
STATIC VADDR_T OsGetTextRegionBase(LosVmMapRegion *region, LosProcessCB *runProcess)
|
||||
{
|
||||
struct file *curFilep = NULL;
|
||||
|
@ -292,36 +295,45 @@ DONE:
|
|||
#endif
|
||||
return curRegion->range.base;
|
||||
}
|
||||
#endif
|
||||
|
||||
STATIC VOID OsExcSysInfo(UINT32 excType, const ExcContext *excBufAddr)
|
||||
{
|
||||
LosTaskCB *runTask = OsCurrTaskGet();
|
||||
LosProcessCB *runProcess = OsCurrProcessGet();
|
||||
LosVmMapRegion *region = NULL;
|
||||
|
||||
PrintExcInfo("excType: %s\n"
|
||||
"processName = %s\n"
|
||||
"processID = %u\n"
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
"process aspace = 0x%08x -> 0x%08x\n"
|
||||
#endif
|
||||
"taskName = %s\n"
|
||||
"taskID = %u\n",
|
||||
g_excTypeString[excType],
|
||||
runProcess->processName,
|
||||
runProcess->processID,
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
runProcess->vmSpace->base,
|
||||
runProcess->vmSpace->base + runProcess->vmSpace->size,
|
||||
#endif
|
||||
runTask->taskName,
|
||||
runTask->taskID);
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
if (OsProcessIsUserMode(runProcess)) {
|
||||
PrintExcInfo("task user stack = 0x%08x -> 0x%08x\n",
|
||||
runTask->userMapBase, runTask->userMapBase + runTask->userMapSize);
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
PrintExcInfo("task kernel stack = 0x%08x -> 0x%08x\n",
|
||||
runTask->topOfStack, runTask->topOfStack + runTask->stackSize);
|
||||
}
|
||||
|
||||
PrintExcInfo("pc = 0x%x ", excBufAddr->PC);
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
LosVmMapRegion *region = NULL;
|
||||
if (g_excFromUserMode[ArchCurrCpuid()] == TRUE) {
|
||||
if (LOS_IsUserAddress((vaddr_t)excBufAddr->PC)) {
|
||||
region = LOS_RegionFind(runProcess->vmSpace, (VADDR_T)excBufAddr->PC);
|
||||
|
@ -338,7 +350,9 @@ STATIC VOID OsExcSysInfo(UINT32 excType, const ExcContext *excBufAddr)
|
|||
(VADDR_T)excBufAddr->ULR - OsGetTextRegionBase(region, runProcess));
|
||||
}
|
||||
PrintExcInfo("\nusp = 0x%x", excBufAddr->USP);
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
PrintExcInfo("\nklr = 0x%x\n"
|
||||
"ksp = 0x%x\n",
|
||||
excBufAddr->LR,
|
||||
|
@ -390,6 +404,7 @@ EXC_PROC_FUNC OsExcRegHookGet(VOID)
|
|||
return g_excHook;
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
STATIC VOID OsDumpExcVaddrRegion(LosVmSpace *space, LosVmMapRegion *region)
|
||||
{
|
||||
INT32 i, numPages, pageCount;
|
||||
|
@ -475,6 +490,7 @@ STATIC VOID OsDumpProcessUsedMemNode(UINT16 vmmFalgs)
|
|||
OsDumpProcessUsedMemRegion(runProcess, runspace, vmmFalgs);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
VOID OsDumpContextMem(const ExcContext *excBufAddr)
|
||||
{
|
||||
|
@ -561,18 +577,17 @@ STATIC VOID OsUserExcHandle(ExcContext *excBufAddr)
|
|||
/* this function is used to validate fp or validate the checking range start and end. */
|
||||
STATIC INLINE BOOL IsValidFP(UINTPTR regFP, UINTPTR start, UINTPTR end, vaddr_t *vaddr)
|
||||
{
|
||||
LosProcessCB *runProcess = NULL;
|
||||
LosVmSpace *runspace = NULL;
|
||||
VADDR_T kvaddr = regFP;
|
||||
PADDR_T paddr;
|
||||
|
||||
if (!((regFP > start) && (regFP < end) && IS_ALIGNED(regFP, sizeof(CHAR *)))) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
PADDR_T paddr;
|
||||
if (g_excFromUserMode[ArchCurrCpuid()] == TRUE) {
|
||||
runProcess = OsCurrProcessGet();
|
||||
runspace = runProcess->vmSpace;
|
||||
LosProcessCB *runProcess = OsCurrProcessGet();
|
||||
LosVmSpace *runspace = runProcess->vmSpace;
|
||||
if (runspace == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -583,6 +598,7 @@ STATIC INLINE BOOL IsValidFP(UINTPTR regFP, UINTPTR start, UINTPTR end, vaddr_t
|
|||
|
||||
kvaddr = (PADDR_T)(UINTPTR)LOS_PaddrToKVaddr(paddr);
|
||||
}
|
||||
#endif
|
||||
if (vaddr != NULL) {
|
||||
*vaddr = kvaddr;
|
||||
}
|
||||
|
@ -651,7 +667,6 @@ VOID BackTraceSub(UINTPTR regFP)
|
|||
UINTPTR stackStart, stackEnd;
|
||||
UINTPTR backFP = regFP;
|
||||
UINT32 count = 0;
|
||||
LosVmMapRegion *region = NULL;
|
||||
VADDR_T kvaddr;
|
||||
|
||||
if (FindSuitableStack(regFP, &stackStart, &stackEnd, &kvaddr) == FALSE) {
|
||||
|
@ -679,6 +694,8 @@ VOID BackTraceSub(UINTPTR regFP)
|
|||
return;
|
||||
}
|
||||
backFP = *(UINTPTR *)(UINTPTR)kvaddr;
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
LosVmMapRegion *region = NULL;
|
||||
if (LOS_IsUserAddress((VADDR_T)backLR) == TRUE) {
|
||||
region = LOS_RegionFind(OsCurrProcessGet()->vmSpace, (VADDR_T)backLR);
|
||||
}
|
||||
|
@ -686,7 +703,9 @@ VOID BackTraceSub(UINTPTR regFP)
|
|||
PrintExcInfo("traceback %u -- lr = 0x%x fp = 0x%x lr in %s --> 0x%x\n", count, backLR, backFP,
|
||||
OsGetRegionNameOrFilePath(region), backLR - region->range.base);
|
||||
region = NULL;
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
PrintExcInfo("traceback %u -- lr = 0x%x fp = 0x%x\n", count, backLR, backFP);
|
||||
}
|
||||
count++;
|
||||
|
@ -721,8 +740,9 @@ VOID OsExcHook(UINT32 excType, ExcContext *excBufAddr, UINT32 far, UINT32 fsr)
|
|||
#ifndef LOSCFG_DEBUG_VERSION
|
||||
if (g_excFromUserMode[ArchCurrCpuid()] != TRUE) {
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
OsDumpProcessUsedMemNode(OS_EXC_VMM_NO_REGION);
|
||||
|
||||
#endif
|
||||
OsExcStackInfo();
|
||||
#ifndef LOSCFG_DEBUG_VERSION
|
||||
}
|
||||
|
@ -1021,22 +1041,20 @@ LITE_OS_SEC_TEXT VOID STATIC OsExcPriorDisposal(ExcContext *excBufAddr)
|
|||
|
||||
LITE_OS_SEC_TEXT_INIT STATIC VOID OsPrintExcHead(UINT32 far)
|
||||
{
|
||||
#ifdef LOSCFG_DEBUG_VERSION
|
||||
LosVmSpace *space = NULL;
|
||||
VADDR_T vaddr;
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
/* You are not allowed to add any other print information before this exception information */
|
||||
if (g_excFromUserMode[ArchCurrCpuid()] == TRUE) {
|
||||
#ifdef LOSCFG_DEBUG_VERSION
|
||||
vaddr = ROUNDDOWN(far, PAGE_SIZE);
|
||||
space = LOS_SpaceGet(vaddr);
|
||||
VADDR_T vaddr = ROUNDDOWN(far, PAGE_SIZE);
|
||||
LosVmSpace *space = LOS_SpaceGet(vaddr);
|
||||
if (space != NULL) {
|
||||
LOS_DumpMemRegion(vaddr);
|
||||
}
|
||||
#endif
|
||||
PrintExcInfo("##################excFrom: User!####################\n");
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
PrintExcInfo("##################excFrom: kernel!###################\n");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -251,9 +251,11 @@ _osExceptPrefetchAbortHdl:
|
|||
|
||||
MOV R0, #OS_EXCEPT_PREFETCH_ABORT @ Set exception ID to OS_EXCEPT_PREFETCH_ABORT.
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
AND R4, R1, #CPSR_MASK_MODE @ Interrupted mode
|
||||
CMP R4, #CPSR_USER_MODE @ User mode
|
||||
BEQ _osExcPageFault @ Branch if user mode
|
||||
#endif
|
||||
|
||||
_osKernelExceptPrefetchAbortHdl:
|
||||
MOV LR, R5
|
||||
|
@ -273,8 +275,11 @@ _osExceptDataAbortHdl:
|
|||
MRS R1, SPSR
|
||||
|
||||
MOV R0, #OS_EXCEPT_DATA_ABORT @ Set exception ID to OS_EXCEPT_DATA_ABORT.
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
B _osExcPageFault
|
||||
#else
|
||||
B _osExceptDispatch
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ Description: Address abort exception handler
|
||||
|
@ -295,6 +300,7 @@ _osExceptFiqHdl:
|
|||
|
||||
B _osExceptDispatch @ Branch to global exception handler.
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
_osExcPageFault:
|
||||
SUB R3, SP, #(8 * 4) @ Save the start address of working registers.
|
||||
MSR CPSR_c, #(CPSR_INT_DISABLE | CPSR_SVC_MODE) @ Switch to SVC mode, and disable all interrupts
|
||||
|
@ -336,6 +342,7 @@ _osExcPageFault:
|
|||
|
||||
MOV R0, R5 @ exc type
|
||||
B _osExceptionSwi
|
||||
#endif
|
||||
|
||||
@ Description: Exception handler
|
||||
@ Parameter : R0 Exception Type
|
||||
|
|
|
@ -184,6 +184,7 @@ reloc_img_to_bottom_loop:
|
|||
sub r11, r11, r12 /* r11: eventual address offset */
|
||||
|
||||
reloc_img_to_bottom_done:
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
ldr r4, =g_firstPageTable /* r4: physical address of translation table and clear it */
|
||||
add r4, r4, r11
|
||||
mov r0, r4
|
||||
|
@ -212,11 +213,11 @@ reloc_img_to_bottom_done:
|
|||
str r12, [r4, r7, lsr #(20 - 2)] /* jumpTable[paIndex] = pt entry */
|
||||
rsb r7, r11, r6, lsl #20 /* r7: va */
|
||||
str r12, [r4, r7, lsr #(20 - 2)] /* jumpTable[vaIndex] = pt entry */
|
||||
|
||||
#endif
|
||||
bl _bootaddr_setup
|
||||
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
bl mmu_setup /* set up the mmu */
|
||||
|
||||
#endif
|
||||
/* clear out the interrupt and exception stack and set magic num to check the overflow */
|
||||
ldr r0, =__undef_stack
|
||||
ldr r1, =__exc_stack_top
|
||||
|
@ -294,7 +295,7 @@ clear_bss:
|
|||
|
||||
_start_hang:
|
||||
b _start_hang
|
||||
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
mmu_setup:
|
||||
mov r12, #0
|
||||
mcr p15, 0, r12, c8, c7, 0 /* Set c8 to control the TLB and set the mapping to invalid */
|
||||
|
@ -330,7 +331,7 @@ mmu_setup:
|
|||
isb
|
||||
sub lr, r11 /* adjust lr with delta of physical address and virtual address */
|
||||
bx lr
|
||||
|
||||
#endif
|
||||
.code 32
|
||||
|
||||
.global reset_platform
|
||||
|
@ -346,6 +347,7 @@ reset_platform:
|
|||
mov pc, r0 // Jump to reset vector
|
||||
#endif
|
||||
cpu_start:
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
ldr r4, =g_firstPageTable /* r4 = physical address of translation table and clear it */
|
||||
add r4, r4, r11
|
||||
orr r8, r4, #MMU_TTBRx_FLAGS
|
||||
|
@ -356,6 +358,7 @@ cpu_start:
|
|||
add r4, r4, r11 /* r4 = tt_trampoline paddr */
|
||||
|
||||
bl mmu_setup
|
||||
#endif
|
||||
bl secondary_cpu_start
|
||||
b .
|
||||
|
||||
|
@ -394,6 +397,7 @@ sp_set:
|
|||
* r10: flags
|
||||
* r9 and r12 will be used as variable
|
||||
*/
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
page_table_build:
|
||||
mov r9, r6
|
||||
bfc r9, #20, #12 /* r9: pa % MB */
|
||||
|
@ -412,7 +416,7 @@ page_table_build_loop:
|
|||
subs r8, #1 /* sizes-- */
|
||||
bne page_table_build_loop
|
||||
bx lr
|
||||
|
||||
#endif
|
||||
/*
|
||||
* init stack to initial value
|
||||
* r0 is stack mem start, r1 is stack mem end
|
||||
|
@ -465,6 +469,7 @@ _bootaddr_setup:
|
|||
|
||||
bx lr
|
||||
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
memset_optimized:
|
||||
mov r3, r0
|
||||
vdup.8 q0, r1
|
||||
|
@ -476,7 +481,7 @@ memset_optimized_loop:
|
|||
vstmia r3!, {d0 - d7}
|
||||
bge memset_optimized_loop
|
||||
bx lr
|
||||
|
||||
#endif
|
||||
init_done:
|
||||
.long 0xDEADB00B
|
||||
|
||||
|
|
|
@ -161,6 +161,7 @@ reloc_img_to_bottom_loop:
|
|||
sub r11, r11, r12 /* r11: eventual address offset */
|
||||
|
||||
reloc_img_to_bottom_done:
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
ldr r4, =g_firstPageTable /* r4: physical address of translation table and clear it */
|
||||
add r4, r4, r11
|
||||
mov r0, r4
|
||||
|
@ -191,7 +192,7 @@ reloc_img_to_bottom_done:
|
|||
str r12, [r4, r7, lsr #(20 - 2)] /* jumpTable[vaIndex] = pt entry */
|
||||
|
||||
bl mmu_setup /* set up the mmu */
|
||||
|
||||
#endif
|
||||
/* get cpuid and keep it in r11 */
|
||||
mrc p15, 0, r11, c0, c0, 5
|
||||
and r11, r11, #MPIDR_CPUID_MASK
|
||||
|
@ -286,6 +287,7 @@ clear_bss:
|
|||
_start_hang:
|
||||
b _start_hang
|
||||
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
mmu_setup:
|
||||
mov r12, #0
|
||||
mcr p15, 0, r12, c8, c7, 0 /* Set c8 to control the TLB and set the mapping to invalid */
|
||||
|
@ -322,7 +324,7 @@ mmu_setup:
|
|||
|
||||
sub lr, r11 /* adjust lr with delta of physical address and virtual address */
|
||||
bx lr
|
||||
|
||||
#endif
|
||||
.code 32
|
||||
|
||||
.global reset_platform
|
||||
|
@ -361,6 +363,7 @@ sp_set:
|
|||
* r10: flags
|
||||
* r9 and r12 will be used as variable
|
||||
*/
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
page_table_build:
|
||||
mov r9, r6
|
||||
bfc r9, #20, #12 /* r9: pa % MB */
|
||||
|
@ -379,7 +382,7 @@ page_table_build_loop:
|
|||
subs r8, #1 /* sizes-- */
|
||||
bne page_table_build_loop
|
||||
bx lr
|
||||
|
||||
#endif
|
||||
/*
|
||||
* init stack to initial value
|
||||
* r0 is stack mem start, r1 is stack mem end
|
||||
|
@ -432,6 +435,7 @@ _bootaddr_setup:
|
|||
|
||||
bx lr
|
||||
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
memset_optimized:
|
||||
mov r3, r0
|
||||
vdup.8 q0, r1
|
||||
|
@ -443,7 +447,7 @@ memset_optimized_loop:
|
|||
vstmia r3!, {d0 - d7}
|
||||
bge memset_optimized_loop
|
||||
bx lr
|
||||
|
||||
#endif
|
||||
init_done:
|
||||
.long 0xDEADB00B
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ static ssize_t MemWrite(FAR struct file *filep, FAR const char *buffer, size_t b
|
|||
|
||||
static ssize_t MemMap(FAR struct file *filep, FAR LosVmMapRegion *region)
|
||||
{
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
size_t size = region->range.size;
|
||||
PADDR_T paddr = region->pgOff << PAGE_SHIFT;
|
||||
VADDR_T vaddr = region->range.base;
|
||||
|
@ -78,7 +79,10 @@ static ssize_t MemMap(FAR struct file *filep, FAR LosVmMapRegion *region)
|
|||
if (LOS_ArchMmuMap(&space->archMmu, vaddr, paddr, size >> PAGE_SHIFT, region->regionFlags) <= 0) {
|
||||
return -EAGAIN;
|
||||
}
|
||||
|
||||
#else
|
||||
UNUSED(filep);
|
||||
UNUSED(region);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ void ProcFsInit(void)
|
|||
}
|
||||
PRINTK("Mount procfs finished.\n");
|
||||
ProcMountsInit();
|
||||
#ifdef LOSCFG_SHELL_CMD_DEBUG
|
||||
#if defined(LOSCFG_SHELL_CMD_DEBUG) && defined(LOSCFG_KERNEL_VM)
|
||||
ProcVmmInit();
|
||||
#endif
|
||||
ProcProcessInit();
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
#include "los_vm_lock.h"
|
||||
#include "los_process_pri.h"
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
|
||||
STATIC VOID OsVmDumpSeqSpaces(struct SeqBuf *seqBuf)
|
||||
{
|
||||
LosVmSpace *space = NULL;
|
||||
|
@ -112,3 +114,4 @@ void ProcVmmInit(void)
|
|||
pde->procFileOps = &VMM_PROC_FOPS;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
#include "los_atomic.h"
|
||||
#include "los_vm_filemap.h"
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
|
||||
static struct file_map g_file_mapping = {0};
|
||||
|
||||
uint init_file_mapping()
|
||||
|
@ -277,3 +279,4 @@ int update_file_path(char *old_path, char *new_path)
|
|||
(void)sem_post(&f_list->fl_sem);
|
||||
return LOS_OK;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -79,12 +79,13 @@ void los_vfs_init(void)
|
|||
PRINT_ERR("los_vfs_init VnodeDevInit failed error %d\n", retval);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
retval = init_file_mapping();
|
||||
if (retval != LOS_OK) {
|
||||
PRINT_ERR("Page cache file map init failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
g_vfs_init = true;
|
||||
}
|
||||
|
|
|
@ -63,7 +63,11 @@ static char *pread_buf_and_check(int fd, const struct iovec *iov, int iovcnt, ss
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
buf = (char *)LOS_VMalloc(buflen * sizeof(char));
|
||||
#else
|
||||
buf = (char *)malloc(buflen * sizeof(char));
|
||||
#endif
|
||||
if (buf == NULL) {
|
||||
set_errno(ENOMEM);
|
||||
*totalbytesread = VFS_ERROR;
|
||||
|
@ -73,7 +77,11 @@ static char *pread_buf_and_check(int fd, const struct iovec *iov, int iovcnt, ss
|
|||
*totalbytesread = (offset == NULL) ? read(fd, buf, buflen)
|
||||
: pread(fd, buf, buflen, *offset);
|
||||
if ((*totalbytesread == VFS_ERROR) || (*totalbytesread == 0)) {
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
LOS_VFree(buf);
|
||||
#else
|
||||
free(buf);
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -119,7 +127,11 @@ ssize_t vfs_readv(int fd, const struct iovec *iov, int iovcnt, off_t *offset)
|
|||
}
|
||||
|
||||
out:
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
LOS_VFree(buf);
|
||||
#else
|
||||
free(buf);
|
||||
#endif
|
||||
if ((i == 0) && (ret == iov[i].iov_len)) {
|
||||
/* failed in the first iovec copy, and 0 bytes copied */
|
||||
set_errno(EFAULT);
|
||||
|
|
|
@ -103,21 +103,33 @@ ssize_t vfs_writev(int fd, const struct iovec *iov, int iovcnt, off_t *offset)
|
|||
}
|
||||
|
||||
totallen = buflen * sizeof(char);
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
buf = (char *)LOS_VMalloc(totallen);
|
||||
#else
|
||||
buf = (char *)malloc(totallen);
|
||||
#endif
|
||||
if (buf == NULL) {
|
||||
return VFS_ERROR;
|
||||
}
|
||||
|
||||
ret = iov_trans_to_buf(buf, totallen, iov, iovcnt);
|
||||
if (ret <= 0) {
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
LOS_VFree(buf);
|
||||
#else
|
||||
free(buf);
|
||||
#endif
|
||||
return VFS_ERROR;
|
||||
}
|
||||
|
||||
bytestowrite = (ssize_t)ret;
|
||||
totalbyteswritten = (offset == NULL) ? write(fd, buf, bytestowrite)
|
||||
: pwrite(fd, buf, bytestowrite, *offset);
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
LOS_VFree(buf);
|
||||
#else
|
||||
free(buf);
|
||||
#endif
|
||||
return totalbyteswritten;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,9 +33,23 @@ config KERNEL_SCHED_STATISTICS
|
|||
help
|
||||
This option will enable schedulder statistics.
|
||||
|
||||
config KERNEL_MMU
|
||||
bool "Enable MMU"
|
||||
default y
|
||||
help
|
||||
This option will enable mmu.
|
||||
|
||||
config KERNEL_VM
|
||||
bool "Enable VM"
|
||||
default y
|
||||
depends on KERNEL_MMU
|
||||
help
|
||||
This option will enable vmm, pmm, page fault, etc.
|
||||
|
||||
config KERNEL_SYSCALL
|
||||
bool "Enable Syscall"
|
||||
default y
|
||||
depends on KERNEL_VM
|
||||
help
|
||||
This option will enable syscall.
|
||||
|
||||
|
@ -71,7 +85,7 @@ config CPUP_INCLUDE_IRQ
|
|||
config KERNEL_DYNLOAD
|
||||
bool "Enable Dynamic Load Feature"
|
||||
default y
|
||||
depends on KERNEL_EXTKERNEL && KERNEL_SYSCALL
|
||||
depends on KERNEL_EXTKERNEL && KERNEL_VM && KERNEL_SYSCALL
|
||||
help
|
||||
If you wish to build LiteOS with support for dynamic load.
|
||||
|
||||
|
@ -85,7 +99,7 @@ config ASLR
|
|||
config KERNEL_VDSO
|
||||
bool "Enable VDSO Feature"
|
||||
default n
|
||||
depends on KERNEL_EXTKERNEL && KERNEL_SYSCALL
|
||||
depends on KERNEL_EXTKERNEL && KERNEL_VM && KERNEL_SYSCALL
|
||||
help
|
||||
If you wish to speed up some system calls.
|
||||
|
||||
|
@ -99,14 +113,14 @@ config KERNEL_TRACE
|
|||
config KERNEL_SHM
|
||||
bool "Enable Shared Memory"
|
||||
default y
|
||||
depends on KERNEL_EXTKERNEL
|
||||
depends on KERNEL_EXTKERNEL && KERNEL_VM && KERNEL_SYSCALL
|
||||
help
|
||||
Answer Y to enable LiteOS support shared memory.
|
||||
|
||||
config KERNEL_LITEIPC
|
||||
bool "Enable liteipc"
|
||||
default y
|
||||
depends on KERNEL_EXTKERNEL
|
||||
depends on KERNEL_EXTKERNEL && KERNEL_VM
|
||||
help
|
||||
Answer Y to enable LiteOS support liteipc.
|
||||
|
||||
|
|
|
@ -40,10 +40,6 @@ LOCAL_SRCS := $(wildcard ipc/*.c) $(wildcard core/*.c) $(wildcard mem/membox/*.
|
|||
$(wildcard sched/sched_sq/*.c) \
|
||||
$(wildcard vm/*.c)
|
||||
|
||||
ifeq ($(LOSCFG_MEM_RECORDINFO), y)
|
||||
LOCAL_SRCS += $(wildcard mem/common/memrecord/*.c)
|
||||
endif
|
||||
|
||||
LOCAL_INCLUDE := \
|
||||
-I $(LITEOSTOPDIR)/kernel/base/include \
|
||||
-I $(LITEOSTOPDIR)/kernel/extended/include \
|
||||
|
|
|
@ -463,7 +463,6 @@ STATIC UINT32 OsProcessInit(VOID)
|
|||
LITE_OS_SEC_TEXT VOID OsProcessCBRecyleToFree(VOID)
|
||||
{
|
||||
UINT32 intSave;
|
||||
LosVmSpace *space = NULL;
|
||||
LosProcessCB *processCB = NULL;
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
|
@ -478,10 +477,13 @@ LITE_OS_SEC_TEXT VOID OsProcessCBRecyleToFree(VOID)
|
|||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
processCB->processStatus &= ~OS_PROCESS_FLAG_EXIT;
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
LosVmSpace *space = NULL;
|
||||
if (OsProcessIsUserMode(processCB)) {
|
||||
space = processCB->vmSpace;
|
||||
}
|
||||
processCB->vmSpace = NULL;
|
||||
#endif
|
||||
/* OS_PROCESS_FLAG_GROUP_LEADER: The lead process group cannot be recycled without destroying the PCB.
|
||||
* !OS_PROCESS_FLAG_UNUSED: Parent process does not reclaim child process resources.
|
||||
*/
|
||||
|
@ -494,34 +496,15 @@ LITE_OS_SEC_TEXT VOID OsProcessCBRecyleToFree(VOID)
|
|||
OsInsertPCBToFreeList(processCB);
|
||||
}
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
(VOID)LOS_VmSpaceFree(space);
|
||||
|
||||
#endif
|
||||
SCHEDULER_LOCK(intSave);
|
||||
}
|
||||
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
}
|
||||
|
||||
STATIC LosProcessCB *OsGetFreePCB(VOID)
|
||||
{
|
||||
LosProcessCB *processCB = NULL;
|
||||
UINT32 intSave;
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
if (LOS_ListEmpty(&g_freeProcess)) {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
PRINT_ERR("No idle PCB in the system!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
processCB = OS_PCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&g_freeProcess));
|
||||
LOS_ListDelete(&processCB->pendList);
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
|
||||
return processCB;
|
||||
}
|
||||
|
||||
STATIC VOID OsDeInitPCB(LosProcessCB *processCB)
|
||||
{
|
||||
UINT32 intSave;
|
||||
|
@ -600,6 +583,7 @@ STATIC UINT32 OsInitPCB(LosProcessCB *processCB, UINT32 mode, UINT16 priority, c
|
|||
LOS_ListInit(&processCB->exitChildList);
|
||||
LOS_ListInit(&(processCB->waitList));
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
if (OsProcessIsUserMode(processCB)) {
|
||||
processCB->vmSpace = OsCreateUserVmSapce();
|
||||
if (processCB->vmSpace == NULL) {
|
||||
|
@ -609,6 +593,7 @@ STATIC UINT32 OsInitPCB(LosProcessCB *processCB, UINT32 mode, UINT16 priority, c
|
|||
} else {
|
||||
processCB->vmSpace = LOS_GetKVmSpace();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_SECURITY_VID
|
||||
status_t status = VidMapListInit(processCB);
|
||||
|
@ -1276,6 +1261,26 @@ LITE_OS_SEC_TEXT INT32 LOS_GetCurrProcessGroupID(VOID)
|
|||
return LOS_GetProcessGroupID(OsCurrProcessGet()->processID);
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
STATIC LosProcessCB *OsGetFreePCB(VOID)
|
||||
{
|
||||
LosProcessCB *processCB = NULL;
|
||||
UINT32 intSave;
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
if (LOS_ListEmpty(&g_freeProcess)) {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
PRINT_ERR("No idle PCB in the system!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
processCB = OS_PCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&g_freeProcess));
|
||||
LOS_ListDelete(&processCB->pendList);
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
|
||||
return processCB;
|
||||
}
|
||||
|
||||
STATIC VOID *OsUserInitStackAlloc(LosProcessCB *processCB, UINT32 *size)
|
||||
{
|
||||
LosVmMapRegion *region = NULL;
|
||||
|
@ -1793,6 +1798,18 @@ LITE_OS_SEC_TEXT INT32 LOS_Fork(UINT32 flags, const CHAR *name, const TSK_ENTRY_
|
|||
flags |= CLONE_FILES;
|
||||
return OsCopyProcess(cloneFlag & flags, name, (UINTPTR)entry, stackSize);
|
||||
}
|
||||
#else
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 OsUserInitProcess(VOID)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
LITE_OS_SEC_TEXT VOID LOS_Exit(INT32 status)
|
||||
{
|
||||
OsTaskExitGroup((UINT32)status);
|
||||
OsProcessExit(OsCurrTaskGet(), (UINT32)status);
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT UINT32 LOS_GetCurrProcessID(VOID)
|
||||
{
|
||||
|
@ -1812,12 +1829,6 @@ LITE_OS_SEC_TEXT VOID OsProcessExit(LosTaskCB *runTask, INT32 status)
|
|||
SCHEDULER_UNLOCK(intSave);
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT VOID LOS_Exit(INT32 status)
|
||||
{
|
||||
OsTaskExitGroup((UINT32)status);
|
||||
OsProcessExit(OsCurrTaskGet(), (UINT32)status);
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT UINT32 LOS_GetSystemProcessMaximum(VOID)
|
||||
{
|
||||
return g_processMaxNum;
|
||||
|
@ -1847,6 +1858,7 @@ LITE_OS_SEC_TEXT UINTPTR OsGetSigHandler(VOID)
|
|||
{
|
||||
return OsCurrProcessGet()->sigHandler;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
|
|
|
@ -475,22 +475,22 @@ LITE_OS_SEC_TEXT VOID OsTaskCBRecyleToFree()
|
|||
|
||||
LITE_OS_SEC_TEXT VOID OsTaskResourcesToFree(LosTaskCB *taskCB)
|
||||
{
|
||||
LosProcessCB *processCB = OS_PCB_FROM_PID(taskCB->processID);
|
||||
UINT32 syncSignal = LOSCFG_BASE_IPC_SEM_LIMIT;
|
||||
UINT32 mapSize, intSave;
|
||||
UINTPTR mapBase, topOfStack;
|
||||
UINT32 ret;
|
||||
UINT32 intSave;
|
||||
UINTPTR topOfStack;
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
LosProcessCB *processCB = OS_PCB_FROM_PID(taskCB->processID);
|
||||
if (OsProcessIsUserMode(processCB) && (taskCB->userMapBase != 0)) {
|
||||
SCHEDULER_LOCK(intSave);
|
||||
mapBase = (UINTPTR)taskCB->userMapBase;
|
||||
mapSize = taskCB->userMapSize;
|
||||
UINT32 mapBase = (UINTPTR)taskCB->userMapBase;
|
||||
UINT32 mapSize = taskCB->userMapSize;
|
||||
taskCB->userMapBase = 0;
|
||||
taskCB->userArea = 0;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
|
||||
LOS_ASSERT(!(processCB->vmSpace == NULL));
|
||||
ret = OsUnMMap(processCB->vmSpace, (UINTPTR)mapBase, mapSize);
|
||||
UINT32 ret = OsUnMMap(processCB->vmSpace, (UINTPTR)mapBase, mapSize);
|
||||
if ((ret != LOS_OK) && (mapBase != 0) && !(processCB->processStatus & OS_PROCESS_STATUS_INIT)) {
|
||||
PRINT_ERR("process(%u) ummap user task(%u) stack failed! mapbase: 0x%x size :0x%x, error: %d\n",
|
||||
processCB->processID, taskCB->taskID, mapBase, mapSize, ret);
|
||||
|
@ -500,6 +500,7 @@ LITE_OS_SEC_TEXT VOID OsTaskResourcesToFree(LosTaskCB *taskCB)
|
|||
LiteIpcRemoveServiceHandle(taskCB);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
if (taskCB->taskStatus & OS_TASK_STATUS_UNUSED) {
|
||||
topOfStack = taskCB->topOfStack;
|
||||
|
@ -880,7 +881,9 @@ STATIC INLINE VOID OsTaskReleaseHoldLock(LosProcessCB *processCB, LosTaskCB *tas
|
|||
|
||||
if (processCB->processMode == OS_USER_MODE) {
|
||||
OsTaskJoinPostUnsafe(taskCB);
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
OsFutexNodeDeleteFromFutexHash(&taskCB->futex, TRUE, NULL, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
OsTaskSyncWake(taskCB);
|
||||
|
|
|
@ -104,7 +104,9 @@ typedef struct ProcessCB {
|
|||
#if (LOSCFG_KERNEL_LITEIPC == YES)
|
||||
ProcIpcInfo ipcInfo; /**< Memory pool for lite ipc */
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
LosVmSpace *vmSpace; /**< VMM space for processes */
|
||||
#endif
|
||||
#ifdef LOSCFG_FS_VFS
|
||||
struct files_struct *files; /**< Files held by the process */
|
||||
#endif
|
||||
|
|
|
@ -40,11 +40,15 @@ extern "C" {
|
|||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
#ifdef LOSCFG_TEE_ENABLE
|
||||
#define KERNEL_VADDR_BASE 0x41000000
|
||||
#else
|
||||
#define KERNEL_VADDR_BASE 0x40000000
|
||||
#endif
|
||||
#else
|
||||
#define KERNEL_VADDR_BASE DDR_MEM_ADDR
|
||||
#endif
|
||||
#define KERNEL_VADDR_SIZE DDR_MEM_SIZE
|
||||
|
||||
#define SYS_MEM_BASE DDR_MEM_ADDR
|
||||
|
@ -68,12 +72,21 @@ extern "C" {
|
|||
#define VMALLOC_START (UNCACHED_VMM_BASE + UNCACHED_VMM_SIZE)
|
||||
#define VMALLOC_SIZE 0x08000000
|
||||
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
#define PERIPH_DEVICE_BASE (VMALLOC_START + VMALLOC_SIZE)
|
||||
#define PERIPH_DEVICE_SIZE U32_C(PERIPH_PMM_SIZE)
|
||||
#define PERIPH_CACHED_BASE (PERIPH_DEVICE_BASE + PERIPH_DEVICE_SIZE)
|
||||
#define PERIPH_CACHED_SIZE U32_C(PERIPH_PMM_SIZE)
|
||||
#define PERIPH_UNCACHED_BASE (PERIPH_CACHED_BASE + PERIPH_CACHED_SIZE)
|
||||
#define PERIPH_UNCACHED_SIZE U32_C(PERIPH_PMM_SIZE)
|
||||
#else
|
||||
#define PERIPH_DEVICE_BASE PERIPH_PMM_BASE
|
||||
#define PERIPH_DEVICE_SIZE U32_C(PERIPH_PMM_SIZE)
|
||||
#define PERIPH_CACHED_BASE PERIPH_PMM_BASE
|
||||
#define PERIPH_CACHED_SIZE U32_C(PERIPH_PMM_SIZE)
|
||||
#define PERIPH_UNCACHED_BASE PERIPH_PMM_BASE
|
||||
#define PERIPH_UNCACHED_SIZE U32_C(PERIPH_PMM_SIZE)
|
||||
#endif
|
||||
|
||||
#define IO_DEVICE_ADDR(paddr) (paddr - PERIPH_PMM_BASE + PERIPH_DEVICE_BASE)
|
||||
#define IO_CACHED_ADDR(paddr) (paddr - PERIPH_PMM_BASE + PERIPH_CACHED_BASE)
|
||||
|
|
|
@ -45,6 +45,8 @@ extern "C" {
|
|||
#endif
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
|
||||
#define OS_FUTEX_FROM_FUTEXLIST(ptr) LOS_DL_LIST_ENTRY(ptr, FutexNode, futexList)
|
||||
#define OS_FUTEX_FROM_QUEUELIST(ptr) LOS_DL_LIST_ENTRY(ptr, FutexNode, queueList)
|
||||
#define OS_FUTEX_KEY_BASE USER_ASPACE_BASE
|
||||
|
@ -1003,6 +1005,7 @@ EXIT:
|
|||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
|
|
@ -50,7 +50,11 @@ extern "C" {
|
|||
|
||||
/* Used to cut non-essential functions. */
|
||||
#define OS_MEM_FREE_BY_TASKID 0
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
#define OS_MEM_EXPAND_ENABLE 1
|
||||
#else
|
||||
#define OS_MEM_EXPAND_ENABLE 0
|
||||
#endif
|
||||
|
||||
/* the dump size of current broken node when memcheck error */
|
||||
#define OS_MEM_NODE_DUMP_SIZE 64
|
||||
|
@ -331,6 +335,17 @@ STATIC INLINE struct OsMemNodeHead *PreSentinelNodeGet(const VOID *pool, const s
|
|||
return NULL;
|
||||
}
|
||||
|
||||
UINT32 OsMemLargeNodeFree(const VOID *ptr)
|
||||
{
|
||||
LosVmPage *page = OsVmVaddrToPage((VOID *)ptr);
|
||||
if ((page == NULL) || (page->nPages == 0)) {
|
||||
return LOS_NOK;
|
||||
}
|
||||
LOS_PhysPagesFreeContiguous((VOID *)ptr, page->nPages);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC INLINE BOOL TryShrinkPool(const VOID *pool, const struct OsMemNodeHead *node)
|
||||
{
|
||||
struct OsMemNodeHead *mySentinel = NULL;
|
||||
|
@ -1976,17 +1991,6 @@ BOOL OsMemIsHeapNode(const VOID *ptr)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
UINT32 OsMemLargeNodeFree(const VOID *ptr)
|
||||
{
|
||||
LosVmPage *page = OsVmVaddrToPage((VOID *)ptr);
|
||||
if ((page == NULL) || (page->nPages == 0)) {
|
||||
return LOS_NOK;
|
||||
}
|
||||
LOS_PhysPagesFreeContiguous((VOID *)ptr, page->nPages);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
|
|
|
@ -31,9 +31,6 @@
|
|||
|
||||
#include "stdlib.h"
|
||||
#include "los_memory_pri.h"
|
||||
#ifdef LOSCFG_MEM_RECORDINFO
|
||||
#include "los_memrecord_pri.h"
|
||||
#endif
|
||||
#ifdef LOSCFG_SHELL_EXCINFO
|
||||
#include "los_excinfo_pri.h"
|
||||
#endif
|
||||
|
@ -154,14 +151,21 @@ LITE_OS_SEC_TEXT_MINOR STATIC UINT32 OsShellCmdFreeInfo(INT32 argc, const CHAR *
|
|||
UINT32 memUsed = LOS_MemTotalUsedGet(m_aucSysMem1);
|
||||
UINT32 totalMem = LOS_MemPoolSizeGet(m_aucSysMem1);
|
||||
UINT32 freeMem = totalMem - memUsed;
|
||||
UINT32 usedCount, totalCount;
|
||||
UINT32 memUsedHeap = memUsed;
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
UINT32 usedCount, totalCount;
|
||||
OsVmPhysUsedInfoGet(&usedCount, &totalCount);
|
||||
totalMem = SYS_MEM_SIZE_DEFAULT;
|
||||
memUsed = SYS_MEM_SIZE_DEFAULT - (totalCount << PAGE_SHIFT);
|
||||
memUsed += (usedCount << PAGE_SHIFT) - freeMem;
|
||||
freeMem = totalMem - memUsed;
|
||||
#else
|
||||
totalMem = SYS_MEM_SIZE_DEFAULT;
|
||||
memUsed = g_vmBootMemBase - KERNEL_ASPACE_BASE;
|
||||
memUsed -= freeMem;
|
||||
freeMem -= totalMem - memUsed;
|
||||
#endif
|
||||
|
||||
if ((argc == 0) ||
|
||||
((argc == 1) && (strcmp(argv[0], "-k") == 0)) ||
|
||||
|
|
|
@ -217,6 +217,7 @@ STATIC VOID OsShellCmdAllProcessInfoShow(const LosProcessCB *pcbArray, const INT
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
STATIC VOID OsProcessMemUsageGet(UINT32 *memArray)
|
||||
{
|
||||
UINT32 pid;
|
||||
|
@ -242,6 +243,7 @@ STATIC VOID OsProcessMemUsageGet(UINT32 *memArray)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
STATIC UINT32 OsProcessInfoGet(LosProcessCB **pcbArray, INT32 **group, UINT32 **memArray, UINT16 flag)
|
||||
{
|
||||
|
@ -288,11 +290,13 @@ STATIC UINT32 OsProcessInfoGet(LosProcessCB **pcbArray, INT32 **group, UINT32 **
|
|||
(VOID)OsGetAllProcessAndTaskCpuUsageUnsafe(CPUP_LAST_ONE_SECONDS, processCpup1s, OS_PROCESS_AND_TASK_CPUP_LEN);
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
if (flag & OS_PROCESS_MEM_INFO) {
|
||||
*memArray = (UINT32 *)((UINTPTR)*pcbArray + OS_PROCESS_ALL_INFO_LEN);
|
||||
OsProcessMemUsageGet(*memArray);
|
||||
len += OS_PROCESS_MEM_ALL_INFO_LEN;
|
||||
}
|
||||
#endif
|
||||
|
||||
return len;
|
||||
}
|
||||
|
@ -567,7 +571,9 @@ LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdTskInfoGet(UINT32 taskID, VOID *seqBuf,
|
|||
LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdDumpTask(INT32 argc, const CHAR **argv)
|
||||
{
|
||||
UINT32 flag = 0;
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
flag |= OS_PROCESS_MEM_INFO;
|
||||
#endif
|
||||
|
||||
if (argc >= 2) { /* 2: The task shell name restricts the parameters */
|
||||
goto TASK_HELP;
|
||||
|
|
|
@ -50,6 +50,8 @@ extern "C" {
|
|||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
|
||||
#define ARGC_2 2
|
||||
#define ARGC_1 1
|
||||
#define ARGC_0 0
|
||||
|
@ -260,6 +262,7 @@ SHELLCMD_ENTRY(v2p_shellcmd, CMD_TYPE_SHOW, VMM_PMM_CMD, 1, (CmdCallBackFunc)OsS
|
|||
#ifdef LOSCFG_SHELL
|
||||
SHELLCMD_ENTRY(pmm_shellcmd, CMD_TYPE_SHOW, "pmm", 0, (CmdCallBackFunc)OsShellCmdDumpPmm);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
|
|
@ -942,9 +942,11 @@ STATIC INLINE VOID OsSchedSwitchProcess(LosProcessCB *runProcess, LosProcessCB *
|
|||
LOS_ASSERT(!(newProcess->processStatus & OS_PROCESS_STATUS_PENDING));
|
||||
newProcess->processStatus |= OS_PROCESS_STATUS_RUNNING;
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
if (OsProcessIsUserMode(newProcess)) {
|
||||
LOS_ArchMmuContextSwitch(&newProcess->vmSpace->archMmu);
|
||||
}
|
||||
#endif
|
||||
|
||||
OsCurrProcessSet(newProcess);
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@ VOID *OsVmBootMemAlloc(size_t len)
|
|||
return (VOID *)ptr;
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
UINT32 OsSysMemInit(VOID)
|
||||
{
|
||||
STATUS_T ret;
|
||||
|
@ -87,6 +88,20 @@ UINT32 OsSysMemInit(VOID)
|
|||
#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
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
|
|
@ -51,6 +51,8 @@ extern "C" {
|
|||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
|
||||
#define FLAG_SIZE 4
|
||||
#define FLAG_START 2
|
||||
|
||||
|
@ -549,6 +551,7 @@ VOID OsVmPhysUsedInfoGet(UINT32 *usedCount, UINT32 *totalCount)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
|
|
@ -51,6 +51,8 @@ extern "C" {
|
|||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
|
||||
extern char __exc_table_start[];
|
||||
extern char __exc_table_end[];
|
||||
|
||||
|
@ -453,6 +455,7 @@ DONE:
|
|||
(VOID)LOS_MuxRelease(&space->regionMux);
|
||||
return status;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
|
|
@ -48,6 +48,8 @@ extern "C" {
|
|||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
|
||||
STATIC VOID OsPageCacheAdd(LosFilePage *page, struct page_mapping *mapping, VM_OFFSET_T pgoff)
|
||||
{
|
||||
LosFilePage *fpage = NULL;
|
||||
|
@ -759,6 +761,14 @@ VOID OsVmmFileRegionFree(struct file *filep, LosProcessCB *processCB)
|
|||
}
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
INT32 OsVfsFileMmap(struct file *filep, LosVmMapRegion *region)
|
||||
{
|
||||
UNUSED(filep);
|
||||
UNUSED(region);
|
||||
return ENOERR;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "los_vm_common.h"
|
||||
#include "los_vm_map.h"
|
||||
#include "los_vm_lock.h"
|
||||
#include "los_memory.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
@ -82,6 +83,7 @@ VOID *ioremap_cached(PADDR_T paddr, unsigned long size)
|
|||
return (VOID *)(UINTPTR)paddr;
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
int remap_pfn_range(VADDR_T vaddr, unsigned long pfn, unsigned long size, unsigned long prot)
|
||||
{
|
||||
STATUS_T status = LOS_OK;
|
||||
|
@ -147,6 +149,7 @@ OUT:
|
|||
(VOID)LOS_MuxRelease(&space->regionMux);
|
||||
return status;
|
||||
}
|
||||
#endif
|
||||
|
||||
VOID *LOS_DmaMemAlloc(DMA_ADDR_T *dmaAddr, size_t size, size_t align, enum DmaMemType type)
|
||||
{
|
||||
|
@ -161,7 +164,11 @@ VOID *LOS_DmaMemAlloc(DMA_ADDR_T *dmaAddr, size_t size, size_t align, enum DmaMe
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
kVaddr = LOS_KernelMallocAlign(size, align);
|
||||
#else
|
||||
kVaddr = LOS_MemAllocAlign(OS_SYS_MEM_ADDR, size, align);
|
||||
#endif
|
||||
if (kVaddr == NULL) {
|
||||
VM_ERR("failed, size = %u, align = %u", size, align);
|
||||
return NULL;
|
||||
|
@ -189,9 +196,17 @@ VOID LOS_DmaMemFree(VOID *vaddr)
|
|||
|
||||
if ((addr >= UNCACHED_VMM_BASE) && (addr < UNCACHED_VMM_BASE + UNCACHED_VMM_SIZE)) {
|
||||
addr = UNCACHED_TO_VMM_ADDR(addr);
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
LOS_KernelFree((VOID *)addr);
|
||||
#else
|
||||
LOS_MemFree(OS_SYS_MEM_ADDR, (VOID *)addr);
|
||||
#endif
|
||||
} else if ((addr >= KERNEL_VMM_BASE) && (addr < KERNEL_VMM_BASE + KERNEL_VMM_SIZE)) {
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
LOS_KernelFree((VOID *)addr);
|
||||
#else
|
||||
LOS_MemFree(OS_SYS_MEM_ADDR, (VOID *)addr);
|
||||
#endif
|
||||
} else {
|
||||
VM_ERR("addr %#x not in dma area!!!", vaddr);
|
||||
}
|
||||
|
@ -200,17 +215,9 @@ VOID LOS_DmaMemFree(VOID *vaddr)
|
|||
|
||||
DMA_ADDR_T LOS_DmaVaddrToPaddr(VOID *vaddr)
|
||||
{
|
||||
status_t ret;
|
||||
paddr_t pa;
|
||||
LosVmSpace *space = LOS_GetKVmSpace();
|
||||
|
||||
ret = LOS_ArchMmuQuery(&space->archMmu, (VADDR_T)(UINTPTR)vaddr, &pa, NULL);
|
||||
if (ret != LOS_OK) {
|
||||
return (DMA_ADDR_T)NULL;
|
||||
}
|
||||
|
||||
return (DMA_ADDR_T)pa;
|
||||
return (DMA_ADDR_T)LOS_PaddrQuery(vaddr);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
|
|
|
@ -51,6 +51,8 @@ extern "C" {
|
|||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
|
||||
#define VM_MAP_WASTE_MEM_LEVEL (PAGE_SIZE >> 2)
|
||||
LosMux g_vmSpaceListMux;
|
||||
LOS_DL_LIST_HEAD(g_vmSpaceList);
|
||||
|
@ -178,6 +180,13 @@ BOOL OsVMallocSpaceInit(LosVmSpace *vmSpace, VADDR_T *virtTtb)
|
|||
return OsVmSpaceInitCommon(vmSpace, virtTtb);
|
||||
}
|
||||
|
||||
VOID OsKSpaceInit(VOID)
|
||||
{
|
||||
OsVmMapInit();
|
||||
OsKernVmSpaceInit(&g_kVmSpace, OsGFirstTableGet());
|
||||
OsVMallocSpaceInit(&g_vMallocSpace, OsGFirstTableGet());
|
||||
}
|
||||
|
||||
BOOL OsUserVmSpaceInit(LosVmSpace *vmSpace, VADDR_T *virtTtb)
|
||||
{
|
||||
vmSpace->base = USER_ASPACE_BASE;
|
||||
|
@ -222,13 +231,6 @@ LosVmSpace *OsCreateUserVmSapce(VOID)
|
|||
return space;
|
||||
}
|
||||
|
||||
VOID OsKSpaceInit(VOID)
|
||||
{
|
||||
OsVmMapInit();
|
||||
OsKernVmSpaceInit(&g_kVmSpace, OsGFirstTableGet());
|
||||
OsVMallocSpaceInit(&g_vMallocSpace, OsGFirstTableGet());
|
||||
}
|
||||
|
||||
STATIC BOOL OsVmSpaceParamCheck(LosVmSpace *vmSpace)
|
||||
{
|
||||
if (vmSpace == NULL) {
|
||||
|
@ -1151,6 +1153,11 @@ DONE:
|
|||
(VOID)LOS_MuxRelease(&space->regionMux);
|
||||
}
|
||||
|
||||
LosMux *OsGVmSpaceMuxGet(VOID)
|
||||
{
|
||||
return &g_vmSpaceListMux;
|
||||
}
|
||||
|
||||
STATIC INLINE BOOL OsMemLargeAlloc(UINT32 size)
|
||||
{
|
||||
if (g_kHeapInited == FALSE) {
|
||||
|
@ -1163,14 +1170,27 @@ STATIC INLINE BOOL OsMemLargeAlloc(UINT32 size)
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
#else
|
||||
PADDR_T LOS_PaddrQuery(VOID *vaddr)
|
||||
{
|
||||
if (!LOS_IsKernelAddress((VADDR_T)vaddr)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (PADDR_T)VMM_TO_DMA_ADDR((VADDR_T)vaddr);
|
||||
}
|
||||
#endif
|
||||
|
||||
VOID *LOS_KernelMalloc(UINT32 size)
|
||||
{
|
||||
VOID *ptr = NULL;
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
if (OsMemLargeAlloc(size)) {
|
||||
ptr = LOS_PhysPagesAllocContiguous(ROUNDUP(size, PAGE_SIZE) >> PAGE_SHIFT);
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
ptr = LOS_MemAlloc(OS_SYS_MEM_ADDR, size);
|
||||
}
|
||||
|
||||
|
@ -1181,9 +1201,12 @@ VOID *LOS_KernelMallocAlign(UINT32 size, UINT32 boundary)
|
|||
{
|
||||
VOID *ptr = NULL;
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
if (OsMemLargeAlloc(size) && IS_ALIGNED(PAGE_SIZE, boundary)) {
|
||||
ptr = LOS_PhysPagesAllocContiguous(ROUNDUP(size, PAGE_SIZE) >> PAGE_SHIFT);
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
ptr = LOS_MemAllocAlign(OS_SYS_MEM_ADDR, size, boundary);
|
||||
}
|
||||
|
||||
|
@ -1193,9 +1216,10 @@ VOID *LOS_KernelMallocAlign(UINT32 size, UINT32 boundary)
|
|||
VOID *LOS_KernelRealloc(VOID *ptr, UINT32 size)
|
||||
{
|
||||
VOID *tmpPtr = NULL;
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
LosVmPage *page = NULL;
|
||||
errno_t ret;
|
||||
|
||||
if (ptr == NULL) {
|
||||
tmpPtr = LOS_KernelMalloc(size);
|
||||
} else {
|
||||
|
@ -1221,30 +1245,30 @@ VOID *LOS_KernelRealloc(VOID *ptr, UINT32 size)
|
|||
tmpPtr = LOS_MemRealloc(OS_SYS_MEM_ADDR, ptr, size);
|
||||
}
|
||||
}
|
||||
#else
|
||||
tmpPtr = LOS_MemRealloc(OS_SYS_MEM_ADDR, ptr, size);
|
||||
#endif
|
||||
|
||||
return tmpPtr;
|
||||
}
|
||||
|
||||
VOID LOS_KernelFree(VOID *ptr)
|
||||
{
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
UINT32 ret;
|
||||
|
||||
if (OsMemIsHeapNode(ptr) == FALSE) {
|
||||
ret = OsMemLargeNodeFree(ptr);
|
||||
if (ret != LOS_OK) {
|
||||
VM_ERR("KernelFree %p failed", ptr);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
(VOID)LOS_MemFree(OS_SYS_MEM_ADDR, ptr);
|
||||
}
|
||||
}
|
||||
|
||||
LosMux *OsGVmSpaceMuxGet(VOID)
|
||||
{
|
||||
return &g_vmSpaceListMux;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
|
|
|
@ -41,6 +41,8 @@ extern "C" {
|
|||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
|
||||
LosVmPage *g_vmPageArray = NULL;
|
||||
size_t g_vmPageArraySize;
|
||||
|
||||
|
@ -128,6 +130,7 @@ LosVmPage *LOS_VmPageGet(PADDR_T paddr)
|
|||
|
||||
return page;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
|
|
@ -42,6 +42,8 @@ extern "C" {
|
|||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
|
||||
#define ONE_PAGE 1
|
||||
|
||||
/* Physical memory area array */
|
||||
|
@ -626,6 +628,16 @@ size_t LOS_PhysPagesFree(LOS_DL_LIST *list)
|
|||
|
||||
return count;
|
||||
}
|
||||
#else
|
||||
VADDR_T *LOS_PaddrToKVaddr(PADDR_T paddr)
|
||||
{
|
||||
if ((paddr < DDR_MEM_ADDR) || (paddr >= (DDR_MEM_ADDR + DDR_MEM_SIZE))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (VADDR_T *)DMA_TO_VMM_ADDR(paddr);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
#include "fs/file.h"
|
||||
#include "los_vm_filemap.h"
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
|
||||
/* unmap a lru page by map record info caller need lru lock */
|
||||
VOID OsUnmapPageLocked(LosFilePage *page, LosMapInfo *info)
|
||||
{
|
||||
|
@ -342,5 +344,6 @@ int OsTryShrinkMemory(size_t nPage)
|
|||
return 0;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -50,6 +50,8 @@ extern "C" {
|
|||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
|
||||
STATUS_T OsCheckMMapParams(VADDR_T *vaddr, unsigned long flags, size_t len, unsigned long pgoff)
|
||||
{
|
||||
if ((len == 0) || (len > USER_ASPACE_SIZE)) {
|
||||
|
@ -494,6 +496,7 @@ VOID LOS_DumpMemRegion(VADDR_T vaddr)
|
|||
OsDumpPte(vaddr);
|
||||
OsDumpAspace(space);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
|
|
@ -50,6 +50,8 @@ extern "C" {
|
|||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
|
||||
LITE_OS_SEC_BSS OomCB *g_oomCB = NULL;
|
||||
static SPIN_LOCK_INIT(g_oomSpinLock);
|
||||
|
||||
|
@ -248,6 +250,7 @@ LITE_OS_SEC_TEXT_MINOR UINT32 OomTaskInit(VOID)
|
|||
return LOS_OK;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
|
|
@ -80,9 +80,6 @@
|
|||
#ifdef LOSCFG_ARCH_CORTEX_M7
|
||||
#include "los_exc_pri.h"
|
||||
#endif
|
||||
#ifdef LOSCFG_MEM_RECORDINFO
|
||||
#include "los_memrecord_pri.h"
|
||||
#endif
|
||||
#include "los_hw_tick_pri.h"
|
||||
#include "los_hwi_pri.h"
|
||||
|
||||
|
@ -363,6 +360,7 @@ LITE_OS_SEC_TEXT_INIT INT32 OsMain(VOID)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
ret = OsFutexInit();
|
||||
if (ret != LOS_OK) {
|
||||
PRINT_ERR("Create futex failed : %d!\n", ret);
|
||||
|
@ -373,6 +371,7 @@ LITE_OS_SEC_TEXT_INIT INT32 OsMain(VOID)
|
|||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
@ -402,22 +401,6 @@ UINT32 OsSystemInitStep2(VOID)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_MEM_RECORDINFO
|
||||
STATIC UINT32 OsMemShowTaskCreate(VOID)
|
||||
{
|
||||
UINT32 taskID;
|
||||
TSK_INIT_PARAM_S appTask;
|
||||
|
||||
(VOID)memset_s(&appTask, sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
|
||||
appTask.pfnTaskEntry = (TSK_ENTRY_FUNC)OsMemRecordShowTask;
|
||||
appTask.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||
appTask.pcName = "memshow_Task";
|
||||
appTask.usTaskPrio = LOSCFG_BASE_CORE_TSK_DEFAULT_PRIO;
|
||||
appTask.uwResved = LOS_TASK_STATUS_DETACHED;
|
||||
return LOS_TaskCreate(&taskID, &appTask);
|
||||
}
|
||||
#endif
|
||||
|
||||
UINT32 OsSystemInit(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
|
@ -431,14 +414,6 @@ UINT32 OsSystemInit(VOID)
|
|||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
}
|
||||
#ifdef LOSCFG_MEM_RECORDINFO
|
||||
ret = OsMemShowTaskCreate();
|
||||
if (ret != LOS_OK) {
|
||||
PRINTK("create memshow_Task error %u\n", ret);
|
||||
return ret;
|
||||
}
|
||||
PRINTK("create memshow_Task ok\n");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -30,10 +30,10 @@
|
|||
*/
|
||||
|
||||
#include "los_user_init.h"
|
||||
|
||||
#ifdef LOSCFG_KERNEL_DYNLOAD
|
||||
#include "los_syscall.h"
|
||||
|
||||
#ifdef LOSCFG_KERNEL_SYSCALL
|
||||
|
||||
#define SYS_CALL_VALUE 0x900001
|
||||
|
||||
#ifdef LOSCFG_QUICK_START
|
||||
|
@ -59,7 +59,6 @@ LITE_USER_SEC_TEXT STATIC UINT32 sys_call3(UINT32 nbr, UINT32 parm1, UINT32 parm
|
|||
|
||||
return reg0;
|
||||
}
|
||||
#endif
|
||||
|
||||
LITE_USER_SEC_ENTRY VOID OsUserInit(VOID *args)
|
||||
{
|
||||
|
@ -69,3 +68,4 @@ LITE_USER_SEC_ENTRY VOID OsUserInit(VOID *args)
|
|||
while (1) {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -77,7 +77,9 @@ LITE_OS_SEC_TEXT_INIT VOID secondary_cpu_start(VOID)
|
|||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
UINT32 cpuid = ArchCurrCpuid();
|
||||
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
OsArchMmuInitPerCPU();
|
||||
#endif
|
||||
|
||||
OsCurrTaskSet(OsGetMainTask());
|
||||
|
||||
|
|
Loading…
Reference in New Issue