1/* 2 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16#include "asm/platform.h" 17#include "asm/io.h" 18#include "soc/sys_ctrl.h" 19#include "los_typedef.h" 20#include "los_hwi.h" 21#include "los_task_pri.h" 22#include "los_spinlock.h" 23#ifdef LOSCFG_DRIVERS_RANDOM 24#include "soc/random.h" 25#endif 26#include "los_vm_map.h" 27#include "los_vm_zone.h" 28#include "los_vm_boot.h" 29#include "los_mmu_descriptor_v6.h" 30 31UINT32 OsRandomStackGuard(VOID) 32{ 33#ifdef LOSCFG_DRIVERS_RANDOM 34 UINT32 stackGuard = 0; 35 36 HiRandomHwInit(); 37 (VOID)HiRandomHwGetInteger(&stackGuard); 38 HiRandomHwDeinit(); 39 return stackGuard; 40#else 41 return 0; 42#endif 43} 44 45void OsReboot(void) 46{ 47 writel(0xffffffff, (SYS_CTRL_REG_BASE + REG_SC_SYSRES)); 48} 49 50void InitRebootHook(void) 51{ 52 OsSetRebootHook(OsReboot); 53} 54 55#ifdef LOSCFG_KERNEL_MMU 56LosArchMmuInitMapping g_archMmuInitMapping[] = { 57 { 58 .phys = SYS_MEM_BASE, 59 .virt = KERNEL_VMM_BASE, 60 .size = KERNEL_VMM_SIZE, 61 .flags = MMU_DESCRIPTOR_KERNEL_L1_PTE_FLAGS, 62 .name = "KernelCached", 63 }, 64 { 65 .phys = SYS_MEM_BASE, 66 .virt = UNCACHED_VMM_BASE, 67 .size = UNCACHED_VMM_SIZE, 68 .flags = MMU_INITIAL_MAP_NORMAL_NOCACHE, 69 .name = "KernelUncached", 70 }, 71 { 72 .phys = PERIPH_PMM_BASE, 73 .virt = PERIPH_DEVICE_BASE, 74 .size = PERIPH_DEVICE_SIZE, 75 .flags = MMU_INITIAL_MAP_DEVICE, 76 .name = "PeriphDevice", 77 }, 78 { 79 .phys = PERIPH_PMM_BASE, 80 .virt = PERIPH_CACHED_BASE, 81 .size = PERIPH_CACHED_SIZE, 82 .flags = MMU_DESCRIPTOR_KERNEL_L1_PTE_FLAGS, 83 .name = "PeriphCached", 84 }, 85 { 86 .phys = PERIPH_PMM_BASE, 87 .virt = PERIPH_UNCACHED_BASE, 88 .size = PERIPH_UNCACHED_SIZE, 89 .flags = MMU_INITIAL_MAP_STRONGLY_ORDERED, 90 .name = "PeriphStronglyOrdered", 91 }, 92 {0} 93}; 94#endif 95