Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arm/qemu: add cortex-r5 support #15593

Merged
merged 3 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions arch/arm/include/armv7-r/cp15.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@

#define CP15_CNTPCT(lo,hi) _CP15_64(0, lo, hi, c14) /* Physical Count register */

#define CP15_CNTP_CVAL(lo,hi) _CP15_64(2, lo, hi, c14) /* Physical Timer CompareValue register */

#define CP15_DCIALLU(r) _CP15(0, r, c15, c5, 0) /* Invalidate data cache */

#define CP15_SET(reg, value) \
Expand Down
4 changes: 4 additions & 0 deletions arch/arm/src/armv7-r/mpcore.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,18 @@
/* Peripheral Base Offsets **************************************************/

#define MPCORE_SCU_OFFSET 0x0000 /* 0x0000-0x00fc SCU registers */
#ifndef MPCORE_ICC_OFFSET
#define MPCORE_ICC_OFFSET 0x2000 /* 0x0000-0x00FC Interrupt controller interface */
#endif
#define MPCORE_GTM_OFFSET 0x0200 /* 0x0200-0x02ff Global timer */

/* 0x0300-0x05ff Reserved */
#define MPCORE_PTM_OFFSET 0x0600 /* 0x0600-0x06ff Private timers and watchdogs */

/* 0x0700-0x07ff Reserved */
#ifndef MPCORE_ICD_OFFSET
#define MPCORE_ICD_OFFSET 0x1000 /* 0x1000-0x1fff Interrupt Distributor */
#endif

/* Peripheral Base Addresses ************************************************/

Expand Down
4 changes: 4 additions & 0 deletions arch/arm/src/armv7-r/sctlr.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
* Pre-processor Definitions
****************************************************************************/

/* Vector Base Address Register (VBAR) */

#define VBAR_MASK (0xffffffe0)

/* CP15 c0 Registers ********************************************************/

/* Main ID Register (MIDR): CRn=c0, opc1=0, CRm=c0, opc2=0
Expand Down
6 changes: 5 additions & 1 deletion arch/arm/src/qemu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
#
# ##############################################################################

set(SRCS qemu_boot.c qemu_serial.c qemu_irq.c qemu_timer.c qemu_memorymap.c)
set(SRCS qemu_boot.c qemu_serial.c qemu_irq.c qemu_timer.c)

if(CONFIG_ARCH_ARMV7A)
list(APPEND SRCS qemu_memorymap.c)
endif()

if(CONFIG_SMP)
list(APPEND SRCS qemu_cpuboot.c)
Expand Down
8 changes: 8 additions & 0 deletions arch/arm/src/qemu/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ config ARCH_CHIP_QEMU_CORTEXA7
select ARMV7A_HAVE_GTM
select ARMV7A_HAVE_PTM

config ARCH_CHIP_QEMU_CORTEXR5
bool "Qemu virtual Processor (cortex-r5)"
select ARCH_CORTEXR5
select ARCH_HAVE_FPU
select ARCH_HAVE_LOWVECTORS
select ARMV7R_HAVE_GICv2
select ARMV7R_HAVE_PTM

endchoice # Qemu Chip Selection

endmenu # "Qemu Virt Chip Selection"
Expand Down
13 changes: 11 additions & 2 deletions arch/arm/src/qemu/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,20 @@
#
############################################################################

ifeq ($(CONFIG_ARCH_ARMV7A),y)
include armv7-a/Make.defs
endif

ifeq ($(CONFIG_ARCH_ARMV7R),y)
include armv7-r/Make.defs
endif

# qemu-specific C source files
CHIP_CSRCS = qemu_boot.c qemu_serial.c qemu_irq.c qemu_timer.c qemu_memorymap.c
CHIP_CSRCS += qemu_pgalloc.c
CHIP_CSRCS = qemu_boot.c qemu_serial.c qemu_irq.c qemu_timer.c

ifeq ($(CONFIG_ARCH_ARMV7A),y)
CHIP_CSRCS += qemu_pgalloc.c qemu_memorymap.c
endif

ifeq ($(CONFIG_SMP),y)
CHIP_CSRCS += qemu_cpuboot.c
Expand Down
17 changes: 16 additions & 1 deletion arch/arm/src/qemu/qemu_boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
#include <nuttx/config.h>

#include "arm_internal.h"
#include "arm_cpu_psci.h"

#ifdef CONFIG_ARM_PSCI
# include "arm_cpu_psci.h"
#endif

#include "qemu_irq.h"
#include "qemu_memorymap.h"
Expand All @@ -43,6 +46,10 @@
# include <nuttx/sched_note.h>
#endif

#ifdef CONFIG_ARCH_ARMV7R
# include <nuttx/init.h>
#endif

#include <nuttx/syslog/syslog_rpmsg.h>

/****************************************************************************
Expand Down Expand Up @@ -73,9 +80,11 @@ void arm_boot(void)
up_perf_init(0);
#endif

#ifdef CONFIG_ARCH_ARMV7A
/* Set the page table for section */

qemu_setupmappings();
#endif

arm_fpuconfig();

Expand All @@ -98,6 +107,12 @@ void arm_boot(void)
#ifdef CONFIG_SYSLOG_RPMSG
syslog_rpmsg_init_early(g_syslog_rpmsg_buf, sizeof(g_syslog_rpmsg_buf));
#endif

#ifdef CONFIG_ARCH_ARMV7R
/* dont return per armv7-r/arm_head.S design */

nx_start();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we unify armv7-a and armv7-r start code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is per this commet. If it is still needed, maybe in the future we can check if armv7-a side can take the same approach for unifying?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My suggestion is: either let armv7-r call nx_start in assembly code, or remove nx_start in assemly code in armv7-a arm_head.S.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see #15624

#endif
}

#if defined(CONFIG_ARM_PSCI) && defined(CONFIG_SMP)
Expand Down
9 changes: 9 additions & 0 deletions boards/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2222,6 +2222,14 @@ config ARCH_BOARD_QEMU_ARMV8A
This options selects support for NuttX on the QEMU ARMv8a + virt
board featuring the qemu ARMv8a CPUs.

config ARCH_BOARD_QEMU_ARMV7R
bool "Qemu ARMv7r CPUs board"
depends on ARCH_CHIP_QEMU_ARM
select ARCH_HAVE_IRQBUTTONS
---help---
This selects support for NuttX on the QEMU ARMv7r + virt
board featuring the qemu ARMv7r CPUs.

config ARCH_BOARD_PINEPHONE
bool "PINE64 PinePhone"
depends on ARCH_CHIP_A64
Expand Down Expand Up @@ -3515,6 +3523,7 @@ config ARCH_BOARD
default "sabre-6quad" if ARCH_BOARD_SABRE_6QUAD
default "tc397" if ARCH_BOARD_TC397
default "qemu-armv7a" if ARCH_BOARD_QEMU_ARMV7A
default "qemu-armv7r" if ARCH_BOARD_QEMU_ARMV7R
default "qemu-armv8a" if ARCH_BOARD_QEMU_ARMV8A
default "pinephone" if ARCH_BOARD_PINEPHONE
default "pinephonepro" if ARCH_BOARD_PINEPHONE_PRO
Expand Down
25 changes: 25 additions & 0 deletions boards/arm/qemu/qemu-armv7r/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# ##############################################################################
# boards/arm/qemu/qemu-armv7r/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/dramboot.ld")

add_subdirectory(src)
7 changes: 7 additions & 0 deletions boards/arm/qemu/qemu-armv7r/Kconfig
Original file line number Diff line number Diff line change
@@ -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_ARMV7R
endif
60 changes: 60 additions & 0 deletions boards/arm/qemu/qemu-armv7r/configs/nsh/defconfig
Original file line number Diff line number Diff line change
@@ -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_ALARM_ARCH=y
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="qemu-armv7r"
CONFIG_ARCH_BOARD_QEMU_ARMV7R=y
CONFIG_ARCH_CHIP="qemu"
CONFIG_ARCH_CHIP_QEMU_ARM=y
CONFIG_ARCH_CHIP_QEMU_CORTEXR5=y
CONFIG_ARCH_INTERRUPTSTACK=2048
CONFIG_ARCH_LOWVECTORS=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_ONESHOT=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_STACK_COLORATION=y
CONFIG_START_DAY=25
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
61 changes: 61 additions & 0 deletions boards/arm/qemu/qemu-armv7r/include/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/****************************************************************************
* boards/arm/qemu/qemu-armv7r/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_ARMV7R_INCLUDE_BOARD_H
#define __BOARDS_ARM_QEMU_QEMU_ARMV7R_INCLUDE_BOARD_H

/****************************************************************************
* Included Files
****************************************************************************/

#include <nuttx/config.h>

/****************************************************************************
* 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_ARMV7R_INCLUDE_BOARD_H */
42 changes: 42 additions & 0 deletions boards/arm/qemu/qemu-armv7r/scripts/Make.defs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
############################################################################
# boards/arm/qemu/qemu-armv7r/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/armv7-r/Toolchain.defs

LDSCRIPT = dramboot.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
Loading
Loading