mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 10:58:49 +08:00
qemu/arm64: implement up_textheap_align and support sotest
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This commit is contained in:
parent
da95b35175
commit
8ad88a3fc5
6 changed files with 211 additions and 0 deletions
|
@ -55,6 +55,8 @@ config ARCH_CHIP_QEMU
|
|||
select ARCH_NEED_ADDRENV_MAPPING
|
||||
select ARCH_HAVE_POWEROFF
|
||||
select ARCH_HAVE_RESET
|
||||
select ARCH_HAVE_TEXT_HEAP
|
||||
select LIBC_ARCH_ELF_64BIT if LIBC_ARCH_ELF
|
||||
---help---
|
||||
QEMU virt platform (ARMv8a)
|
||||
|
||||
|
|
|
@ -26,3 +26,7 @@ CHIP_CSRCS = qemu_boot.c qemu_serial.c
|
|||
ifeq ($(CONFIG_ARCH_EARLY_PRINT),y)
|
||||
CHIP_ASRCS = qemu_lowputc.S
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ARCH_USE_TEXT_HEAP),y)
|
||||
CHIP_CSRCS += qemu_textheap.c
|
||||
endif
|
||||
|
|
113
arch/arm64/src/qemu/qemu_textheap.c
Normal file
113
arch/arm64/src/qemu/qemu_textheap.c
Normal file
|
@ -0,0 +1,113 @@
|
|||
/****************************************************************************
|
||||
* arch/arm64/src/qemu/qemu_textheap.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/queue.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
|
||||
#include "arm64_mmu.h"
|
||||
#include "arm64_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
extern uint8_t _sload[];
|
||||
extern uint8_t _szload[];
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static struct mm_heap_s *g_textheap;
|
||||
|
||||
/* Mark load segment cacheable, write-read and executable */
|
||||
|
||||
static struct arm_mmu_region g_mmu_load =
|
||||
MMU_REGION_FLAT_ENTRY("nx_load",
|
||||
(uint64_t)_sload,
|
||||
(uint64_t)_szload,
|
||||
MT_NORMAL | MT_RW | MT_EXECUTE | MT_SECURE);
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_textheap_memalign
|
||||
*
|
||||
* Description:
|
||||
* Allocate memory for text sections with the specified alignment.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void *up_textheap_memalign(size_t align, size_t size)
|
||||
{
|
||||
if (g_textheap == NULL)
|
||||
{
|
||||
if (arm64_mmu_set_memregion(&g_mmu_load) != 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
g_textheap = mm_initialize("textheap", (void *)&_sload,
|
||||
(size_t)_szload);
|
||||
}
|
||||
|
||||
return mm_memalign(g_textheap, align, size);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_textheap_free
|
||||
*
|
||||
* Description:
|
||||
* Free memory allocated for text sections.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void up_textheap_free(void *p)
|
||||
{
|
||||
if (g_textheap != NULL)
|
||||
{
|
||||
mm_free(g_textheap, p);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_textheap_heapmember
|
||||
*
|
||||
* Description:
|
||||
* Test if memory is from text heap.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
bool up_textheap_heapmember(void *p)
|
||||
{
|
||||
if (g_textheap != NULL)
|
||||
{
|
||||
return mm_heapmember(g_textheap, p);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
82
boards/arm64/qemu/qemu-armv8a/configs/sotest/defconfig
Normal file
82
boards/arm64/qemu/qemu-armv8a/configs/sotest/defconfig
Normal file
|
@ -0,0 +1,82 @@
|
|||
#
|
||||
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||
#
|
||||
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||
# modifications.
|
||||
#
|
||||
CONFIG_ARCH="arm64"
|
||||
CONFIG_ARCH_ARM64=y
|
||||
CONFIG_ARCH_BOARD="qemu-armv8a"
|
||||
CONFIG_ARCH_BOARD_QEMU_ARMV8A=y
|
||||
CONFIG_ARCH_CHIP="qemu"
|
||||
CONFIG_ARCH_CHIP_QEMU=y
|
||||
CONFIG_ARCH_CHIP_QEMU_A53=y
|
||||
CONFIG_ARCH_EARLY_PRINT=y
|
||||
CONFIG_ARCH_INTERRUPTSTACK=4096
|
||||
CONFIG_ARM64_SEMIHOSTING_HOSTFS=y
|
||||
CONFIG_ARM64_SEMIHOSTING_HOSTFS_CACHE_COHERENCE=y
|
||||
CONFIG_ARM64_STRING_FUNCTION=y
|
||||
CONFIG_BOARDCTL_ROMDISK=y
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DEBUG_ASSERTIONS=y
|
||||
CONFIG_DEBUG_BINFMT=y
|
||||
CONFIG_DEBUG_BINFMT_ERROR=y
|
||||
CONFIG_DEBUG_BINFMT_INFO=y
|
||||
CONFIG_DEBUG_BINFMT_WARN=y
|
||||
CONFIG_DEBUG_FEATURES=y
|
||||
CONFIG_DEBUG_FULLOPT=y
|
||||
CONFIG_DEBUG_SCHED=y
|
||||
CONFIG_DEBUG_SCHED_ERROR=y
|
||||
CONFIG_DEBUG_SCHED_INFO=y
|
||||
CONFIG_DEBUG_SCHED_WARN=y
|
||||
CONFIG_DEBUG_SYMBOLS=y
|
||||
CONFIG_DEFAULT_TASK_STACKSIZE=8192
|
||||
CONFIG_DEVICE_TREE=y
|
||||
CONFIG_DEV_ZERO=y
|
||||
CONFIG_EXAMPLES_HELLO=y
|
||||
CONFIG_EXAMPLES_SOTEST=y
|
||||
CONFIG_EXAMPLES_SOTEST_DEVMINOR=10
|
||||
CONFIG_EXPERIMENTAL=y
|
||||
CONFIG_FS_HOSTFS=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_FS_PROCFS_REGISTER=y
|
||||
CONFIG_FS_ROMFS=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_IDLETHREAD_STACKSIZE=8192
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LIBC_DLFCN=y
|
||||
CONFIG_LIBC_FDT=y
|
||||
CONFIG_MODLIB_DUMPBUFFER=y
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_PTHREAD_STACK_MIN=8192
|
||||
CONFIG_RAMLOG=y
|
||||
CONFIG_RAM_SIZE=134217728
|
||||
CONFIG_RAM_START=0x40000000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_READLINE_CMD_HISTORY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_HPWORK=y
|
||||
CONFIG_SCHED_HPWORKPRIORITY=192
|
||||
CONFIG_SPINLOCK=y
|
||||
CONFIG_STACK_COLORATION=y
|
||||
CONFIG_START_MONTH=3
|
||||
CONFIG_START_YEAR=2022
|
||||
CONFIG_SYMTAB_ORDEREDBYNAME=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_SYSTEM_SYSTEM=y
|
||||
CONFIG_SYSTEM_TIME64=y
|
||||
CONFIG_TESTING_GETPRIME=y
|
||||
CONFIG_TESTING_OSTEST=y
|
||||
CONFIG_UART1_BASE=0x9000000
|
||||
CONFIG_UART1_IRQ=33
|
||||
CONFIG_UART1_PL011=y
|
||||
CONFIG_UART1_SERIAL_CONSOLE=y
|
||||
CONFIG_UART_PL011=y
|
||||
CONFIG_USEC_PER_TICK=1000
|
|
@ -41,6 +41,11 @@ LDNXFLATFLAGS = -e main -s 2048
|
|||
|
||||
# ELF module definitions
|
||||
|
||||
CMODULEFLAGS = $(CFLAGS)
|
||||
|
||||
LDMODULEFLAGS = -r -e module_initialize
|
||||
LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
|
||||
CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs
|
||||
CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs
|
||||
|
||||
|
|
|
@ -62,6 +62,11 @@ SECTIONS
|
|||
_etext = .; /* End_1 of .text */
|
||||
_sztext = _etext - _stext;
|
||||
|
||||
_sload = .;
|
||||
. += 1048576;
|
||||
_eload = .;
|
||||
_szload = _eload - _sload;
|
||||
|
||||
. = ALIGN(4096);
|
||||
.rodata : {
|
||||
_srodata = .; /* Read-only data */
|
||||
|
|
Loading…
Reference in a new issue