This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 6e8eadd6b5553bedaacfd8cc6724b46aa1231851 Author: Yanfeng Liu <[email protected]> AuthorDate: Thu Feb 13 14:32:23 2025 +0800 boards/arm: add QEMU_ARMV8R_AARCH32 This adds board QEMU_ARMV8R_AARCH32 for trying Cortex-R52 on QEMU virt board with a sample config qemu-armv8r-aarch32:nsh. Signed-off-by: Yanfeng Liu <[email protected]> --- boards/Kconfig | 11 ++ boards/arm/qemu/qemu-armv8r-aarch32/CMakeLists.txt | 31 +++++ boards/arm/qemu/qemu-armv8r-aarch32/Kconfig | 7 + .../qemu/qemu-armv8r-aarch32/configs/nsh/defconfig | 60 ++++++++ .../arm/qemu/qemu-armv8r-aarch32/include/board.h | 56 ++++++++ .../qemu-armv8r-aarch32/include/board_memorymap.h | 101 ++++++++++++++ .../arm/qemu/qemu-armv8r-aarch32/scripts/Make.defs | 42 ++++++ .../arm/qemu/qemu-armv8r-aarch32/scripts/memory.ld | 58 ++++++++ .../arm/qemu/qemu-armv8r-aarch32/scripts/nuttx.ld | 152 +++++++++++++++++++++ .../qemu/qemu-armv8r-aarch32/src/CMakeLists.txt | 33 +++++ boards/arm/qemu/qemu-armv8r-aarch32/src/Makefile | 35 +++++ .../arm/qemu/qemu-armv8r-aarch32/src/qemu-armv8r.h | 61 +++++++++ .../qemu/qemu-armv8r-aarch32/src/qemu_appinit.c | 75 ++++++++++ .../qemu/qemu-armv8r-aarch32/src/qemu_boardinit.c | 129 +++++++++++++++++ .../qemu/qemu-armv8r-aarch32/src/qemu_bringup.c | 135 ++++++++++++++++++ 15 files changed, 986 insertions(+) diff --git a/boards/Kconfig b/boards/Kconfig index e07dd3bc90e..8d73e57c76c 100644 --- a/boards/Kconfig +++ b/boards/Kconfig @@ -2908,6 +2908,14 @@ config ARCH_BOARD_QEMU_ARMV7R This selects support for NuttX on the QEMU ARMv7r + virt board featuring the qemu ARMv7r CPUs. +config ARCH_BOARD_QEMU_ARMV8R_AARCH32 + bool "Qemu ARMv8r CPUs board" + depends on ARCH_CHIP_QEMU_ARM + select ARCH_HAVE_IRQBUTTONS + ---help--- + This selects support for NuttX on the QEMU ARMv8r + virt + board featuring the qemu ARMv8r aarch32 CPUs. + config ARCH_BOARD_PINEPHONE bool "PINE64 PinePhone" depends on ARCH_CHIP_A64 @@ -4749,6 +4757,9 @@ endif if ARCH_BOARD_QEMU_ARMV8A source "boards/arm64/qemu/qemu-armv8a/Kconfig" endif +if ARCH_BOARD_QEMU_ARMV8R_AARCH32 +source "boards/arm/qemu/qemu-armv8r-aarch32/Kconfig" +endif if ARCH_BOARD_PINEPHONE source "boards/arm64/a64/pinephone/Kconfig" endif diff --git a/boards/arm/qemu/qemu-armv8r-aarch32/CMakeLists.txt b/boards/arm/qemu/qemu-armv8r-aarch32/CMakeLists.txt new file mode 100644 index 00000000000..4a69c38d095 --- /dev/null +++ b/boards/arm/qemu/qemu-armv8r-aarch32/CMakeLists.txt @@ -0,0 +1,31 @@ +# ############################################################################## +# boards/arm/qemu/qemu-armv8r-aarch32/CMakeLists.txt +# +# SPDX-License-Identifier: Apache-2.0 +# +# 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. +# +# ############################################################################## + +set_property(GLOBAL PROPERTY LD_SCRIPT "${NUTTX_BOARD_DIR}/scripts/nuttx.ld") + +add_subdirectory(src) + +if(CONFIG_BUILD_PROTECTED) + add_subdirectory(kernel) + set_property(GLOBAL PROPERTY LD_SCRIPT_USER + ${CMAKE_CURRENT_LIST_DIR}/scripts/nuttx_user.ld) +endif() diff --git a/boards/arm/qemu/qemu-armv8r-aarch32/Kconfig b/boards/arm/qemu/qemu-armv8r-aarch32/Kconfig new file mode 100644 index 00000000000..e98201daf00 --- /dev/null +++ b/boards/arm/qemu/qemu-armv8r-aarch32/Kconfig @@ -0,0 +1,7 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +if ARCH_BOARD_QEMU_ARMV8R +endif diff --git a/boards/arm/qemu/qemu-armv8r-aarch32/configs/nsh/defconfig b/boards/arm/qemu/qemu-armv8r-aarch32/configs/nsh/defconfig new file mode 100644 index 00000000000..a8d2b087fb7 --- /dev/null +++ b/boards/arm/qemu/qemu-armv8r-aarch32/configs/nsh/defconfig @@ -0,0 +1,60 @@ +# +# 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="arm" +CONFIG_ARCH_BOARD="qemu-armv8r-aarch32" +CONFIG_ARCH_BOARD_QEMU_ARMV8R_AARCH32=y +CONFIG_ARCH_CHIP="qemu" +CONFIG_ARCH_CHIP_QEMU_ARM=y +CONFIG_ARCH_CHIP_QEMU_CORTEXR52=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_LOWVECTORS=y +CONFIG_ARM_SEMIHOSTING_POWEROFF=y +CONFIG_ARM_THUMB=y +CONFIG_BOARDCTL_POWEROFF=y +CONFIG_BUILTIN=y +CONFIG_DEBUG_ASSERTIONS=y +CONFIG_DEBUG_FEATURES=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DEFAULT_TASK_STACKSIZE=4096 +CONFIG_EXAMPLES_HELLO=y +CONFIG_FLASH_SIZE=1048576 +CONFIG_FS_PROCFS=y +CONFIG_FS_ROMFS=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_IDLETHREAD_STACKSIZE=4096 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=16777216 +CONFIG_RAM_START=0x40000000 +CONFIG_RAW_BINARY=y +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_HAVE_PARENT=y +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_HPWORKPRIORITY=192 +CONFIG_START_DAY=15 +CONFIG_START_MONTH=2 +CONFIG_START_YEAR=2025 +CONFIG_SYMTAB_ORDEREDBYNAME=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_SYSTEM=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 diff --git a/boards/arm/qemu/qemu-armv8r-aarch32/include/board.h b/boards/arm/qemu/qemu-armv8r-aarch32/include/board.h new file mode 100644 index 00000000000..c874699afef --- /dev/null +++ b/boards/arm/qemu/qemu-armv8r-aarch32/include/board.h @@ -0,0 +1,56 @@ +/**************************************************************************** + * boards/arm/qemu/qemu-armv8r-aarch32/include/board.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * 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. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_QEMU_QEMU_ARMV8R_AARCH32_INCLUDE_BOARD_H +#define __BOARDS_ARM_QEMU_QEMU_ARMV8R_AARCH32_INCLUDE_BOARD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +#if defined(__cplusplus) +extern "C" +{ +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#if defined(__cplusplus) +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_QEMU_QEMU_ARMV8R_AARCH32_INCLUDE_BOARD_H */ diff --git a/boards/arm/qemu/qemu-armv8r-aarch32/include/board_memorymap.h b/boards/arm/qemu/qemu-armv8r-aarch32/include/board_memorymap.h new file mode 100644 index 00000000000..dad51396c70 --- /dev/null +++ b/boards/arm/qemu/qemu-armv8r-aarch32/include/board_memorymap.h @@ -0,0 +1,101 @@ +/**************************************************************************** + * boards/arm/qemu/qemu-armv8r-aarch32/include/board_memorymap.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * 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. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_QEMU_QEMU_ARMV8R_AARCH32_INCLUDE_BOARD_MEMORYMAP_H +#define __BOARDS_ARM_QEMU_AEMU_ARMV8R_AARCH32_INCLUDE_BOARD_MEMORYMAP_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <stdint.h> + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* DDR start address */ + +#define QEMU_DDR_BASE (0x40000000) +#define QEMU_DDR_SIZE (0x40000000) + +/* Kernel code memory (RX) */ + +#define KFLASH_START (uintptr_t)__kflash_start +#define KFLASH_SIZE (uintptr_t)__kflash_size +#define KSRAM_START (uintptr_t)__ksram_start +#define KSRAM_SIZE (uintptr_t)__ksram_size +#define KSRAM_END (uintptr_t)__ksram_end + +/* Kernel RAM (RW) */ + +#define PGPOOL_START (uintptr_t)__pgheap_start +#define PGPOOL_SIZE (uintptr_t)__pgheap_size + +/* Page pool (RWX) */ + +#define PGPOOL_START (uintptr_t)__pgheap_start +#define PGPOOL_SIZE (uintptr_t)__pgheap_size +#define PGPOOL_END (PGPOOL_START + PGPOOL_SIZE) + +/* User flash */ + +#define UFLASH_START (uintptr_t)__uflash_start +#define UFLASH_SIZE (uintptr_t)__uflash_size + +/* User RAM */ + +#define USRAM_START (uintptr_t)__usram_start +#define USRAM_SIZE (uintptr_t)__usram_size +#define USRAM_END (USRAM_START + USRAM_SIZE) + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/* Kernel code memory (RX) */ + +extern uint8_t __kflash_start[]; +extern uint8_t __kflash_size[]; + +/* Kernel RAM (RW) */ + +extern uint8_t __ksram_start[]; +extern uint8_t __ksram_size[]; +extern uint8_t __ksram_end[]; + +/* Page pool (RWX) */ + +extern uint8_t __pgheap_start[]; +extern uint8_t __pgheap_size[]; + +/* User code memory (RX) */ + +extern uint8_t __uflash_start[]; +extern uint8_t __uflash_size[]; + +/* User RAM (RW) */ + +extern uint8_t __usram_start[]; +extern uint8_t __usram_size[]; + +#endif /* __BOARDS_ARM_QEMU_QEMU_ARMV8R_AARCH32_INCLUDE_BOARD_MEMORYMAP_H */ diff --git a/boards/arm/qemu/qemu-armv8r-aarch32/scripts/Make.defs b/boards/arm/qemu/qemu-armv8r-aarch32/scripts/Make.defs new file mode 100644 index 00000000000..2b36cb39ba0 --- /dev/null +++ b/boards/arm/qemu/qemu-armv8r-aarch32/scripts/Make.defs @@ -0,0 +1,42 @@ +############################################################################ +# boards/arm/qemu/qemu-armv8r-aarch32/scripts/Make.defs +# +# SPDX-License-Identifier: Apache-2.0 +# +# 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. +# +############################################################################ + +include $(TOPDIR)/.config +include $(TOPDIR)/tools/Config.mk +include $(TOPDIR)/arch/arm/src/armv8-r/Toolchain.defs + +LDSCRIPT = nuttx.ld + +ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) + +CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) +CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) +CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) +CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) +CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) +AFLAGS := $(CFLAGS) -D__ASSEMBLY__ + +# NXFLAT module definitions + +NXFLATLDFLAGS1 = -r -d -warn-common +NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)$(DELIM)binfmt$(DELIM)libnxflat$(DELIM)gnu-nxflat-pcrel.ld -no-check-sections +LDNXFLATFLAGS = -e main -s 2048 diff --git a/boards/arm/qemu/qemu-armv8r-aarch32/scripts/memory.ld b/boards/arm/qemu/qemu-armv8r-aarch32/scripts/memory.ld new file mode 100644 index 00000000000..91bbaa70c09 --- /dev/null +++ b/boards/arm/qemu/qemu-armv8r-aarch32/scripts/memory.ld @@ -0,0 +1,58 @@ +/**************************************************************************** + * boards/arm/qemu/qemu-armv8r-aarch32/scripts/memory.ld + * + * SPDX-License-Identifier: Apache-2.0 + * + * 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. + * + ****************************************************************************/ + +#include <nuttx/config.h> + +#ifdef CONFIG_BUILD_PROTECTED +/* Split FLASH and SRAM between kernel and user spaces */ + +# define KFLASH_SIZE (CONFIG_NUTTX_USERSPACE) +# define KSRAM_SIZE (CONFIG_RAM_SIZE / 2) +#else +/* Give FLASH and RAM to kernel */ + +# define KFLASH_SIZE (CONFIG_FLASH_SIZE) +# define KSRAM_SIZE (CONFIG_RAM_SIZE) +#endif + +#define KFLASH_START (CONFIG_FLASH_START) +#define KSRAM_START (CONFIG_RAM_START) + +#define UFLASH_START (KFLASH_START + KFLASH_SIZE) +#define USRAM_START (KSRAM_START + KSRAM_SIZE) + +#define UFLASH_SIZE (CONFIG_FLASH_SIZE - KFLASH_SIZE) +#define USRAM_SIZE (CONFIG_RAM_SIZE - KSRAM_SIZE) + +#if defined(CONFIG_BUILD_PROTECTED) && (KFLASH_SIZE != UFLASH_SIZE) +/* For simpler MPU settings, use 1:1 split for now */ + +# error "CONFIG_NUTTX_USERSPACE != CONFIG_FLASH_SIZE / 2" +#endif + +MEMORY +{ + kflash (rx) : ORIGIN = KFLASH_START, LENGTH = KFLASH_SIZE + uflash (rx) : ORIGIN = UFLASH_START, LENGTH = UFLASH_SIZE + ksram (rwx) : ORIGIN = KSRAM_START, LENGTH = KSRAM_SIZE + usram (rwx) : ORIGIN = USRAM_START, LENGTH = USRAM_SIZE +} diff --git a/boards/arm/qemu/qemu-armv8r-aarch32/scripts/nuttx.ld b/boards/arm/qemu/qemu-armv8r-aarch32/scripts/nuttx.ld new file mode 100644 index 00000000000..575c60fb53e --- /dev/null +++ b/boards/arm/qemu/qemu-armv8r-aarch32/scripts/nuttx.ld @@ -0,0 +1,152 @@ +/**************************************************************************** + * boards/arm/qemu/qemu-armv8r-aarch32/scripts/nuttx.ld + * + * SPDX-License-Identifier: Apache-2.0 + * + * 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. + * + ****************************************************************************/ + +#include "memory.ld" + +/* Provide these to avoid using config files for them */ + +__uflash_start = ORIGIN(uflash); +__uflash_size = LENGTH(uflash); +__usram_start = ORIGIN(usram); +__usram_size = LENGTH(usram); + +/* Provide the kernel boundaries as well */ + +__kflash_start = ORIGIN(kflash); +__kflash_size = LENGTH(kflash); +__ksram_start = ORIGIN(ksram); +__ksram_size = LENGTH(ksram); +__ksram_end = ORIGIN(ksram) + LENGTH(ksram); + + +OUTPUT_ARCH(arm) + +ENTRY(__start) + +SECTIONS +{ + + /* where the global variable out-of-bounds detection information located */ + +#ifdef CONFIG_MM_KASAN_GLOBAL + .kasan.unused : { + *(.data..LASANLOC*) + } + .kasan.global : { + KEEP (*(.data..LASAN0)) + KEEP (*(.data.rel.local..LASAN0)) + } + .kasan.shadows : { + *(.kasan.shadows) + } +#endif + + .text : { + _stext = .; /* Text section */ + __text_start = .; + KEEP(*(.hyp_vectors)) + . = ALIGN(32); + KEEP(*(.sys_vectors)) + *(.vectors) + *(.text*) + *(.fixup) + *(.gnu.warning) + } > kflash + + . = ALIGN(4096); + + .init_section : { + _sinit = ABSOLUTE(.); + KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) + KEEP(*(.init_array EXCLUDE_FILE(*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o) .ctors)) + _einit = ABSOLUTE(.); + . = ALIGN(4096); + _etext = .; /* End_1 of .text */ + _sztext = _etext - _stext; + } > kflash + + .ARM.extab : + { + *(.ARM.extab*) + } > kflash + + /* .ARM.exidx is sorted, so has to go in its own output section. */ + + PROVIDE_HIDDEN (__exidx_start = .); + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > kflash + PROVIDE_HIDDEN (__exidx_end = .); + + .rodata : { + _srodata = .; /* Read-only data */ + *(.rodata*) + *(.data.rel.ro*) + KEEP(*(SORT(.scattered_array*))); + . = ALIGN(4096); + _erodata = .; + } > kflash + + _eronly = LOADADDR(.data); + .data : { /* Data */ + _sdata = .; + *(.data*) + . = ALIGN(8); + __start_impls = .; + *(.impls) + KEEP(*(.impls)) + . = ALIGN(4); + __stop_impls = .; + _edata = .; + } > ksram AT > kflash + + .noinit : { + _snoinit = ABSOLUTE(.); + *(.noinit*) + _enoinit = ABSOLUTE(.); + } > ksram + + .bss : { /* BSS */ + _sbss = .; + *(.bss*) + . = ALIGN(4096); + _ebss = .; + } > ksram + + /* Sections to be discarded */ + /DISCARD/ : { + *(.exit.text) + *(.exit.data) + *(.exitcall.exit) + } + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } +} + diff --git a/boards/arm/qemu/qemu-armv8r-aarch32/src/CMakeLists.txt b/boards/arm/qemu/qemu-armv8r-aarch32/src/CMakeLists.txt new file mode 100644 index 00000000000..c4dfb584044 --- /dev/null +++ b/boards/arm/qemu/qemu-armv8r-aarch32/src/CMakeLists.txt @@ -0,0 +1,33 @@ +# ############################################################################## +# boards/arm/qemu/qemu-armv8r-aarch32/src/CMakeLists.txt +# +# SPDX-License-Identifier: Apache-2.0 +# +# 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. +# +# ############################################################################## +set(SRCS qemu_boardinit.c qemu_bringup.c) + +if(CONFIG_BOARDCTL) + list(APPEND SRCS qemu_appinit.c) +endif() + +if(CONFIG_LIBC_FDT) + target_include_directories(board + PRIVATE ${NUTTX_DIR}/libs/libc/fdt/dtc/libfdt) +endif() + +target_sources(board PRIVATE ${SRCS}) diff --git a/boards/arm/qemu/qemu-armv8r-aarch32/src/Makefile b/boards/arm/qemu/qemu-armv8r-aarch32/src/Makefile new file mode 100644 index 00000000000..377cf5b5532 --- /dev/null +++ b/boards/arm/qemu/qemu-armv8r-aarch32/src/Makefile @@ -0,0 +1,35 @@ +############################################################################ +# boards/arm/qemu/qemu-armv8r-aarch32/src/Makefile +# +# SPDX-License-Identifier: Apache-2.0 +# +# 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. +# +############################################################################ + +include $(TOPDIR)/Make.defs + +CSRCS = qemu_boardinit.c qemu_bringup.c + +ifeq ($(CONFIG_BOARDCTL),y) +CSRCS += qemu_appinit.c +endif + +ifeq ($(CONFIG_LIBC_FDT),y) +CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)fdt$(DELIM)dtc$(DELIM)libfdt +endif + +include $(TOPDIR)/boards/Board.mk diff --git a/boards/arm/qemu/qemu-armv8r-aarch32/src/qemu-armv8r.h b/boards/arm/qemu/qemu-armv8r-aarch32/src/qemu-armv8r.h new file mode 100644 index 00000000000..b1d0d12a0df --- /dev/null +++ b/boards/arm/qemu/qemu-armv8r-aarch32/src/qemu-armv8r.h @@ -0,0 +1,61 @@ +/**************************************************************************** + * boards/arm/qemu/qemu-armv8r-aarch32/src/qemu-armv8r.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * 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. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_QEMU_QEMU_ARMV8R_AARCH32_SRC_QEMU_ARMV8R_H +#define __BOARDS_ARM_QEMU_QEMU_ARMV8R_AARCH32_SRC_QEMU_ARMV8R_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <stdint.h> + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Public Functions Definitions + ****************************************************************************/ + +/**************************************************************************** + * Name: qemu_bringup + * + * Description: + * Bring up board features + * + ****************************************************************************/ + +#if defined(CONFIG_BOARDCTL) || defined(CONFIG_BOARD_LATE_INITIALIZE) +int qemu_bringup(void); +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_QEMU_QEMU_ARMV8R_AARCH32_SRC_QEMU_ARMV8R_H */ diff --git a/boards/arm/qemu/qemu-armv8r-aarch32/src/qemu_appinit.c b/boards/arm/qemu/qemu-armv8r-aarch32/src/qemu_appinit.c new file mode 100644 index 00000000000..e1c8cc63538 --- /dev/null +++ b/boards/arm/qemu/qemu-armv8r-aarch32/src/qemu_appinit.c @@ -0,0 +1,75 @@ +/**************************************************************************** + * boards/arm/qemu/qemu-armv8r-aarch32/src/qemu_appinit.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * 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/config.h> +#include <sys/types.h> +#include <nuttx/board.h> +#include "qemu-armv8r.h" + +#ifdef CONFIG_BOARDCTL + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_app_initialize + * + * Description: + * Perform application specific initialization. This function is never + * called directly from application code, but only indirectly via the + * (non-standard) boardctl() interface using the command BOARDIOC_INIT. + * + * Input Parameters: + * arg - The boardctl() argument is passed to the board_app_initialize() + * implementation without modification. The argument has no + * meaning to NuttX; the meaning of the argument is a contract + * between the board-specific initialization logic and the + * matching application logic. The value could be such things as a + * mode enumeration value, a set of DIP switch switch settings, a + * pointer to configuration data read from a file or serial FLASH, + * or whatever you would like to do with it. Every implementation + * should accept zero/NULL as a default configuration. + * + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is returned on + * any failure to indicate the nature of the failure. + * + ****************************************************************************/ + +int board_app_initialize(uintptr_t arg) +{ + UNUSED(arg); +#ifndef CONFIG_BOARD_LATE_INITIALIZE + /* Perform board initialization */ + + return qemu_bringup(); +#else + return OK; +#endif +} + +#endif /* CONFIG_BOARDCTL */ diff --git a/boards/arm/qemu/qemu-armv8r-aarch32/src/qemu_boardinit.c b/boards/arm/qemu/qemu-armv8r-aarch32/src/qemu_boardinit.c new file mode 100644 index 00000000000..ce380dd4b34 --- /dev/null +++ b/boards/arm/qemu/qemu-armv8r-aarch32/src/qemu_boardinit.c @@ -0,0 +1,129 @@ +/**************************************************************************** + * boards/arm/qemu/qemu-armv8r-aarch32/src/qemu_boardinit.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * 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/config.h> +#include <stdint.h> +#include <nuttx/board.h> +#include "qemu-armv8r.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: qemu_memory_initialize + * + * Description: + * All qemu architectures must provide the following entry point. This + * entry point is called early in the initialization before memory has + * been configured. This board-specific function is responsible for + * configuring any on-board memories. + * + * Logic in qemu_memory_initialize must be careful to avoid using any + * global variables because those will be uninitialized at the time this + * function is called. + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ****************************************************************************/ + +void qemu_memory_initialize(void) +{ + /* SDRAM was initialized by a bootloader in the supported configurations. */ +} + +/**************************************************************************** + * Name: qemu_board_initialize + * + * Description: + * All qemu architectures must provide the following entry point. This + * entry point is called in the initialization phase -- after + * qemu_memory_initialize and after all memory has been configured and + * mapped but before any devices have been initialized. + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ****************************************************************************/ + +void qemu_board_initialize(void) +{ +#ifdef CONFIG_ARCH_LEDS + /* Configure on-board LEDs if LED support has been selected. */ + +#endif +} + +/**************************************************************************** + * Name: board_late_initialize + * + * Description: + * If CONFIG_BOARD_LATE_INITIALIZE is selected, then an additional + * initialization call will be performed in the boot-up sequence to a + * function called board_late_initialize(). board_late_initialize() will be + * called immediately after up_intitialize() is called and just before the + * initial application is started. This additional initialization phase + * may be used, for example, to initialize board-specific device drivers. + * + ****************************************************************************/ + +#ifdef CONFIG_BOARD_LATE_INITIALIZE +void board_late_initialize(void) +{ + /* Perform board initialization */ + + qemu_bringup(); +} +#endif /* CONFIG_BOARD_LATE_INITIALIZE */ + +#ifdef CONFIG_BOARDCTL_POWEROFF +int board_power_off(int status) +{ + UNUSED(status); + +#ifdef CONFIG_ARM_SEMIHOSTING_POWEROFF + up_systempoweroff(); +#endif + + return 0; +} +#endif \ No newline at end of file diff --git a/boards/arm/qemu/qemu-armv8r-aarch32/src/qemu_bringup.c b/boards/arm/qemu/qemu-armv8r-aarch32/src/qemu_bringup.c new file mode 100644 index 00000000000..889873b5aec --- /dev/null +++ b/boards/arm/qemu/qemu-armv8r-aarch32/src/qemu_bringup.c @@ -0,0 +1,135 @@ +/**************************************************************************** + * boards/arm/qemu/qemu-armv8r-aarch32/src/qemu_bringup.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * 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/config.h> + +#include <sys/types.h> +#include <syslog.h> + +#include <nuttx/fs/fs.h> +#include <nuttx/fdt.h> + +#ifdef CONFIG_LIBC_FDT +# include <libfdt.h> +#endif + +#include "chip.h" +#include "qemu-armv8r.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifndef QEMU_SPI_IRQ_BASE +#define QEMU_SPI_IRQ_BASE 32 +#endif + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +#if defined(CONFIG_LIBC_FDT) && defined(CONFIG_DEVICE_TREE) + +/**************************************************************************** + * Name: register_devices_from_fdt + ****************************************************************************/ + +static void register_devices_from_fdt(void) +{ + const void *fdt = fdt_get(); + int ret; + + if (fdt == NULL) + { + return; + } + +#ifdef CONFIG_DRIVERS_VIRTIO_MMIO + ret = fdt_virtio_mmio_devices_register(fdt, QEMU_SPI_IRQ_BASE); + if (ret < 0) + { + syslog(LOG_ERR, "fdt_virtio_mmio_devices_register failed, ret=%d\n", + ret); + } +#endif + +#ifdef CONFIG_PCI + ret = fdt_pci_ecam_register(fdt); + if (ret < 0) + { + syslog(LOG_ERR, "fdt_pci_ecam_register failed, ret=%d\n", ret); + } +#endif + + UNUSED(ret); +} + +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: qemu_bringup + * + * Description: + * Bring up board features + * + ****************************************************************************/ + +int qemu_bringup(void) +{ + int ret; + +#ifdef CONFIG_FS_TMPFS + /* Mount the tmpfs file system */ + + ret = nx_mount(NULL, CONFIG_LIBC_TMPDIR, "tmpfs", 0, NULL); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to mount tmpfs at %s: %d\n", + CONFIG_LIBC_TMPDIR, ret); + } +#endif + +#ifdef CONFIG_FS_PROCFS + /* Mount the procfs file system */ + + ret = nx_mount(NULL, "/proc", "procfs", 0, NULL); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret); + } +#endif + +#if defined(CONFIG_LIBC_FDT) && defined(CONFIG_DEVICE_TREE) + register_devices_from_fdt(); +#endif + + UNUSED(ret); + return OK; +}
