diff --git a/boards/Kconfig b/boards/Kconfig index 341bb060a2..1f0ef89538 100644 --- a/boards/Kconfig +++ b/boards/Kconfig @@ -1918,6 +1918,14 @@ config ARCH_BOARD_SABRE_6QUAD This options selects support for NuttX on the NXP/Freescale Sabre board featuring the iMX 6Quad CPU. +config ARCH_BOARD_QEMU_ARMV7A + bool "Qemu ARMv7a CPUs board" + depends on ARCH_CHIP_QEMU_ARM + select ARCH_HAVE_IRQBUTTONS + ---help--- + This options selects support for NuttX on the QEMU ARMv7a + virt + board featuring the qemu ARMv7a CPUs. + config ARCH_BOARD_QEMU_ARMV8A bool "Qemu ARMv8a CPUs board" depends on ARCH_CHIP_QEMU @@ -3081,6 +3089,7 @@ config ARCH_BOARD default "rv-virt" if ARCH_BOARD_QEMU_RV_VIRT default "star64" if ARCH_BOARD_JH7110_STAR64 default "sabre-6quad" if ARCH_BOARD_SABRE_6QUAD + default "qemu-armv7a" if ARCH_BOARD_QEMU_ARMV7A default "qemu-armv8a" if ARCH_BOARD_QEMU_ARMV8A default "pinephone" if ARCH_BOARD_PINEPHONE default "fvp-armv8r" if ARCH_BOARD_FVP_ARMV8R @@ -3275,6 +3284,9 @@ endif if ARCH_BOARD_SABRE_6QUAD source "boards/arm/imx6/sabre-6quad/Kconfig" endif +if ARCH_BOARD_QEMU_ARMV7A +source "boards/arm/qemu/qemu-armv7a/Kconfig" +endif if ARCH_BOARD_QEMU_ARMV8A source "boards/arm64/qemu/qemu-armv8a/Kconfig" endif diff --git a/boards/arm/qemu/qemu-armv7a/Kconfig b/boards/arm/qemu/qemu-armv7a/Kconfig new file mode 100644 index 0000000000..0cd8af20eb --- /dev/null +++ b/boards/arm/qemu/qemu-armv7a/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_ARMV7A +endif diff --git a/boards/arm/qemu/qemu-armv7a/README.txt b/boards/arm/qemu/qemu-armv7a/README.txt new file mode 100644 index 0000000000..ba719a5653 --- /dev/null +++ b/boards/arm/qemu/qemu-armv7a/README.txt @@ -0,0 +1,62 @@ +README.txt +========== + +This board configuration will use QEMU to emulate generic ARM v7-A series +hardware platform and provides support for these devices: + + - GICv2 interrupt controllers + - ARM Generic Timer + - PL011 UART controller + +Contents +======== + - Getting Started + - Status + - Platform Features + - Debugging with QEMU + - FPU Support and Performance + - SMP Support + - References + +Getting Started +=============== + +1. Configuring and running + 1.1 Single Core + Configuring NuttX and compile: + $ ./tools/configure.sh -l qemu-armv7a:nsh + $ make + Running with qemu + $ qemu-system-arm -cpu cortex-a7 -nographic \ + -machine virt,virtualization=off,gic-version=2 \ + -net none -chardev stdio,id=con,mux=on -serial chardev:con \ + -mon chardev=con,mode=readline -kernel ./nuttx + +Debugging with QEMU +=================== + +The nuttx ELF image can be debugged with QEMU. + +1. To debug the nuttx (ELF) with symbols, make sure the following change have + applied to defconfig. + ++CONFIG_DEBUG_SYMBOLS=y + +2. Run QEMU(at shell terminal 1) + + Single Core + $ qemu-system-arm -cpu cortex-a7 -nographic \ + -machine virt,virtualization=off,gic-version=2 \ + -net none -chardev stdio,id=con,mux=on -serial chardev:con \ + -mon chardev=con,mode=readline -kernel ./nuttx -S -s + +3. Run gdb with TUI, connect to QEMU, load nuttx and continue (at shell terminal 2) + + $ arm-none-eabi-gdb -tui --eval-command='target remote localhost:1234' nuttx + (gdb) c + Continuing. + ^C + Program received signal SIGINT, Interrupt. + nx_start () at armv7-a/arm_head.S:209 + (gdb) + diff --git a/boards/arm/qemu/qemu-armv7a/configs/nsh/defconfig b/boards/arm/qemu/qemu-armv7a/configs/nsh/defconfig new file mode 100644 index 0000000000..3800d3a3b2 --- /dev/null +++ b/boards/arm/qemu/qemu-armv7a/configs/nsh/defconfig @@ -0,0 +1,74 @@ +# +# 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_ALARM_ARCH=y +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="qemu-armv7a" +CONFIG_ARCH_BOARD_QEMU_ARMV7A=y +CONFIG_ARCH_CHIP="qemu" +CONFIG_ARCH_CHIP_QEMU_ARM=y +CONFIG_ARCH_CHIP_QEMU_CORTEXA7=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_LOWVECTORS=y +CONFIG_BUILTIN=y +CONFIG_DEBUG_ASSERTIONS=y +CONFIG_DEBUG_ERROR=y +CONFIG_DEBUG_FEATURES=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_INFO=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_DEBUG_WARN=y +CONFIG_DEFAULT_TASK_STACKSIZE=4096 +CONFIG_DEV_ZERO=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_EXPERIMENTAL=y +CONFIG_FLASH_SIZE=134217728 +CONFIG_FLASH_START=0 +CONFIG_FLASH_VSTART=0 +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_NSH_ROMFSETC=y +CONFIG_ONESHOT=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAMLOG=y +CONFIG_RAM_SIZE=134217728 +CONFIG_RAM_START=0x40000000 +CONFIG_RAM_VSTART=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_DAY=25 +CONFIG_START_MONTH=4 +CONFIG_START_YEAR=2023 +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-armv7a/include/board.h b/boards/arm/qemu/qemu-armv7a/include/board.h new file mode 100644 index 0000000000..b5053e2ba7 --- /dev/null +++ b/boards/arm/qemu/qemu-armv7a/include/board.h @@ -0,0 +1,59 @@ +/**************************************************************************** + * boards/arm/qemu/qemu-armv7a/include/board.h + * + * 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_ARMV7A_INCLUDE_BOARD_H +#define __BOARDS_ARM_QEMU_QEMU_ARMV7A_INCLUDE_BOARD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_QEMU_QEMU_ARMV7A_INCLUDE_BOARD_H */ diff --git a/boards/arm/qemu/qemu-armv7a/scripts/Make.defs b/boards/arm/qemu/qemu-armv7a/scripts/Make.defs new file mode 100644 index 0000000000..0c59a422d2 --- /dev/null +++ b/boards/arm/qemu/qemu-armv7a/scripts/Make.defs @@ -0,0 +1,48 @@ +############################################################################ +# boards/arm/qemu/qemu-armv7a/scripts/Make.defs +# +# 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/armv7-a/Toolchain.defs + +LDSCRIPT = dramboot.ld + +ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) + +CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe +CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) +CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe +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 + +# ELF module definitions + +CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs +CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs + +LDELFFLAGS = -r -e main +LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld) diff --git a/boards/arm/qemu/qemu-armv7a/scripts/dramboot.ld b/boards/arm/qemu/qemu-armv7a/scripts/dramboot.ld new file mode 100644 index 0000000000..30a16e65bf --- /dev/null +++ b/boards/arm/qemu/qemu-armv7a/scripts/dramboot.ld @@ -0,0 +1,105 @@ +/**************************************************************************** + * boards/arm/qemu/qemu-armv7a/scripts/dramboot_armv7a.ld + * + * 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. + * + ****************************************************************************/ +OUTPUT_ARCH(arm) +ENTRY(__start) +PHDRS +{ + text PT_LOAD ; +} +SECTIONS +{ + . = 0x40000000; + .text : { + _stext = .; /* Text section */ + *(.vectors) + *(.text) + *(.text.cold) + *(.text.unlikely) + *(.fixup) + *(.gnu.warning) + } :text + . = ALIGN(4096); + .init_section : { + _sinit = ABSOLUTE(.); + KEEP(*(.init_array .init_array.*)) + _einit = ABSOLUTE(.); + } :text + . = ALIGN(4096); + _etext = .; /* End_1 of .text */ + _sztext = _etext - _stext; + .rodata : { + _srodata = .; /* Read-only data */ + *(.rodata) + *(.rodata.*) + *(.data.rel.ro) + *(.data.rel.ro.*) + } :text + . = ALIGN(4096); + _erodata = .; /* End of read-only data */ + _szrodata = _erodata - _srodata; + _eronly = .; /* End of read-only data */ + .data : { /* Data */ + _sdata = .; + *(.data.page_aligned) + *(.data) + . = ALIGN(8); + __start_impls = .; + *(.impls) + KEEP(*(.impls)) + . = ALIGN(4); + __stop_impls = .; + *(.data.rel) + *(.data.rel.*) + CONSTRUCTORS + } :text + _edata = .; /* End+1 of .data */ + .bss : { /* BSS */ + _sbss = .; + *(.bss) + . = ALIGN(1 << 3); + } :text + . = ALIGN(4096); + _ebss = .; + _szbss = _ebss - _sbss; + .initstack : { /* INIT STACK */ + _s_initstack = .; + *(.initstack) + . = ALIGN(16); + } :text + . = ALIGN(4096); + _e_initstack = . ; + _szdata = _e_initstack - _sdata; + /* Sections to be discarded */ + /DISCARD/ : { + *(.exit.text) + *(.exit.data) + *(.exitcall.exit) + *(.eh_frame) + } + /* 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-armv7a/src/Makefile b/boards/arm/qemu/qemu-armv7a/src/Makefile new file mode 100644 index 0000000000..4de74ccb43 --- /dev/null +++ b/boards/arm/qemu/qemu-armv7a/src/Makefile @@ -0,0 +1,29 @@ +############################################################################ +# boards/arm/qemu/qemu-armv7a/src/Makefile +# +# 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 + +include $(TOPDIR)/boards/Board.mk diff --git a/boards/arm/qemu/qemu-armv7a/src/qemu-armv7a.h b/boards/arm/qemu/qemu-armv7a/src/qemu-armv7a.h new file mode 100644 index 0000000000..23235f2cbd --- /dev/null +++ b/boards/arm/qemu/qemu-armv7a/src/qemu-armv7a.h @@ -0,0 +1,59 @@ +/**************************************************************************** + * boards/arm/qemu/qemu-armv7a/src/qemu-armv7a.h + * + * 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_ARMV7A_SRC_QEMU_ARMV7A_H +#define __BOARDS_ARM_QEMU_QEMU_ARMV7A_SRC_QEMU_ARMV7A_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +/**************************************************************************** + * 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_ARMV7A_SRC_QEMU_ARMV7A_H */ diff --git a/boards/arm/qemu/qemu-armv7a/src/qemu_appinit.c b/boards/arm/qemu/qemu-armv7a/src/qemu_appinit.c new file mode 100644 index 0000000000..491cf2dd60 --- /dev/null +++ b/boards/arm/qemu/qemu-armv7a/src/qemu_appinit.c @@ -0,0 +1,76 @@ +/**************************************************************************** + * boards/arm/qemu/qemu-armv7a/src/qemu_appinit.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 + +#include + +#include + +#include "qemu-armv7a.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-armv7a/src/qemu_boardinit.c b/boards/arm/qemu/qemu-armv7a/src/qemu_boardinit.c new file mode 100644 index 0000000000..2907d68d93 --- /dev/null +++ b/boards/arm/qemu/qemu-armv7a/src/qemu_boardinit.c @@ -0,0 +1,113 @@ +/**************************************************************************** + * boards/arm/qemu/qemu-armv7a/src/qemu_boardinit.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 +#include +#include +#include "qemu-armv7a.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 */ diff --git a/boards/arm/qemu/qemu-armv7a/src/qemu_bringup.c b/boards/arm/qemu/qemu-armv7a/src/qemu_bringup.c new file mode 100644 index 0000000000..e281f161f5 --- /dev/null +++ b/boards/arm/qemu/qemu-armv7a/src/qemu_bringup.c @@ -0,0 +1,99 @@ +/**************************************************************************** + * boards/arm/qemu/qemu-armv7a/src/qemu_bringup.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 + +#include +#include + +#include +#include + +#include "qemu-armv7a.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define QEMU_VIRTIO_MMIO_BASE 0x0a000000 +#define QEMU_VIRTIO_MMIO_REGSIZE 0x200 +#define QEMU_VIRTIO_MMIO_IRQ 48 +#define QEMU_VIRTIO_MMIO_NUM 4 + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: qemu_virtio_register_mmio_devices + ****************************************************************************/ + +#ifdef CONFIG_DRIVERS_VIRTIO_MMIO +static void qemu_virtio_register_mmio_devices(void) +{ + uintptr_t virtio = (uintptr_t)QEMU_VIRTIO_MMIO_BASE; + size_t size = QEMU_VIRTIO_MMIO_REGSIZE; + int irq = QEMU_VIRTIO_MMIO_IRQ; + int i; + + for (i = 0; i < QEMU_VIRTIO_MMIO_NUM; i++) + { + virtio_register_mmio_device((void *)(virtio + size * i), irq + i); + } +} +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: imx_bringup + * + * Description: + * Bring up board features + * + ****************************************************************************/ + +int qemu_bringup(void) +{ + int ret; + +#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 + +#ifdef CONFIG_DRIVERS_VIRTIO_MMIO + qemu_virtio_register_mmio_devices(); +#endif + + UNUSED(ret); + return OK; +}