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

arch/arm64: Add support for Generic Interrupt Controller Version 2 #7630

Merged
merged 1 commit into from
Nov 21, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions arch/arm64/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ config ARM_HAVE_NEON
---help---
Decide whether support NEON instruction

config ARM_GIC_VERSION
int "GIC version"
default 3
range 2 4
---help---
Version of Generic Interrupt Controller (GIC) supported by the
architecture

if ARCH_CHIP_QEMU
source "arch/arm64/src/qemu/Kconfig"
endif
Expand Down
13 changes: 13 additions & 0 deletions arch/arm64/include/qemu/chip.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,22 @@

#if defined(CONFIG_ARCH_CHIP_QEMU)

#if CONFIG_ARM_GIC_VERSION == 2

#define CONFIG_GICD_BASE 0x8000000
#define CONFIG_GICR_BASE 0x8010000

#elif CONFIG_ARM_GIC_VERSION == 3 || CONFIG_ARM_GIC_VERSION == 4

#define CONFIG_GICD_BASE 0x8000000
#define CONFIG_GICR_BASE 0x80a0000

#else

#error CONFIG_ARM_GIC_VERSION should be 2, 3 or 4

#endif /* CONFIG_ARM_GIC_VERSION */

#define CONFIG_RAMBANK1_ADDR 0x40000000
#define CONFIG_RAMBANK1_SIZE MB(128)

Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/src/common/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ CMN_CSRCS += arm64_sigdeliver.c

# Common C source files ( hardware BSP )
CMN_CSRCS += arm64_mmu.c arm64_arch_timer.c arm64_cache.c
CMN_CSRCS += arm64_doirq.c arm64_gicv3.c arm64_fatal.c
CMN_CSRCS += arm64_doirq.c arm64_gicv2.c arm64_gicv3.c arm64_fatal.c
CMN_CSRCS += arm64_syscall.c arm64_cpu_psci.c

# Use common heap allocation for now (may need to be customized later)
Expand Down
1 change: 1 addition & 0 deletions arch/arm64/src/common/arm64_gic.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
* [3:0] - IMPLEMENTATION DEFINED.
*/
#define GICD_PIDR2_ARCH_MASK 0xf0
#define GICD_PIDR2_ARCH_GICV2 0x20
#define GICD_PIDR2_ARCH_GICV3 0x30
#define GICD_PIDR2_ARCH_GICV4 0x40

Expand Down
1,389 changes: 1,389 additions & 0 deletions arch/arm64/src/common/arm64_gicv2.c

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions arch/arm64/src/common/arm64_gicv3.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
#include "arm64_gic.h"
#include "arm64_fatal.h"

#if CONFIG_ARM_GIC_VERSION == 3 || CONFIG_ARM_GIC_VERSION == 4

/***************************************************************************
* Pre-processor Definitions
***************************************************************************/
Expand Down Expand Up @@ -615,3 +617,5 @@ void arm64_gic_secondary_init(void)
}

#endif

#endif /* CONFIG_ARM_GIC_VERSION == 3 || CONFIG_ARM_GIC_VERSION == 4 */
21 changes: 18 additions & 3 deletions boards/arm64/qemu/qemu-armv8a/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ README.txt
This board configuration will use QEMU to emulate generic ARM64 v8-A series
hardware platform and provides support for these devices:

- GICv3 interrupt controller
- GICv2 and GICv3 interrupt controllers
- ARM Generic Timer
- PL011 UART controller

Expand Down Expand Up @@ -41,7 +41,7 @@ Getting Started
$ qemu-system-aarch64 --help

3. Configuring and running
3.1 Single Core
3.1 Single Core (GICv3)
Configuring NuttX and compile:
$ ./tools/configure.sh -l qemu-armv8a:nsh
$ make
Expand All @@ -51,7 +51,7 @@ Getting Started
-net none -chardev stdio,id=con,mux=on -serial chardev:con \
-mon chardev=con,mode=readline -kernel ./nuttx

3.2 SMP
3.2 SMP (GICv3)
Configuring NuttX and compile:
$ ./tools/configure.sh -l qemu-armv8a:nsh_smp
$ make
Expand All @@ -61,6 +61,16 @@ Getting Started
-net none -chardev stdio,id=con,mux=on -serial chardev:con \
-mon chardev=con,mode=readline -kernel ./nuttx

3.3 Single Core (GICv2)
Configuring NuttX and compile:
$ ./tools/configure.sh -l qemu-armv8a:nsh_gicv2
$ make
Running with qemu
$ qemu-system-aarch64 -cpu cortex-a53 -nographic \
-machine virt,virtualization=on,gic-version=2 \
-net none -chardev stdio,id=con,mux=on -serial chardev:con \
-mon chardev=con,mode=readline -kernel ./nuttx

Note:
1. Make sure the aarch64-none-elf toolchain install PATH has been added to environment variable
2. To quit QEMU, type Ctrl + X
Expand All @@ -70,6 +80,11 @@ Getting Started
Status
======

2022-11-18:
1. Added support for GICv2.

2. Added board configuration for nsh_gicv2.

2022-10-13:
1. Renamed the board configuration name from qemu-a53 to qemu-v8a.

Expand Down
66 changes: 66 additions & 0 deletions boards/arm64/qemu/qemu-armv8a/configs/nsh_gicv2/defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#
# 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_INTERRUPTSTACK=4096
CONFIG_ARM_GIC_VERSION=2
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=8192
CONFIG_DEV_ZERO=y
CONFIG_EXAMPLES_HELLO=y
CONFIG_EXPERIMENTAL=y
CONFIG_FS_PROCFS=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_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_READLINE=y
CONFIG_NSH_ROMFSETC=y
CONFIG_PREALLOC_TIMERS=4
CONFIG_PTHREAD_STACK_MIN=8192
CONFIG_QEMU_UART_PL011=y
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_TESTING_GETPRIME=y
CONFIG_TESTING_OSTEST=y
CONFIG_UART1_SERIAL_CONSOLE=y
CONFIG_USEC_PER_TICK=1000