【发布时间】:2020-09-26 16:26:17
【问题描述】:
我已经为 Cortex-A53 启动了一个简单的裸机应用程序。现在我想实现中断,但我遇到了一个问题。想读取寄存器ICC_SRE_ELx 以确定SRE 标志,以了解是否必须使用内存映射GIC 接口。如果启用了 SRE,还想写入这些寄存器以启用 IRQ 和 FIQ。
收到以下错误消息:
$ make
aarch64-suse-linux-gcc -c -Wall -I ./include -ffreestanding -mcpu=cortex-a53 misc.S -o misc.o
misc.S: Assembler messages:
misc.S:38: Error: unknown or missing system register name at operand 2 -- `mrs x0,ICC_SRE_EL2'
misc.S:42: Error: unknown or missing system register name at operand 2 -- `mrs w0,ICC_SRE_EL2'
misc.S:44: Error: unknown or missing system register name at operand 1 -- `msr ICC_SRE_EL2,w0'
misc.S:48: Error: unknown or missing system register name at operand 2 -- `mrs x0,ICC_SRE_EL2'
misc.S:50: Error: unknown or missing system register name at operand 2 -- `mrs x0,ICC_SRE_EL2'
写了这么简单的代码:
#include <asm.h>
#define ICC_SRE_EL2_FIQ 0x2
#define ICC_SRE_EL2_IRQ 0x4
.text
FUNCTION(_cpu_get_el)
mrs x0, CurrentEL
and x0, x0, #0xC
asr x0, x0, #2
ret
FUNCTION(_cpu_get_id)
mrs x0, MPIDR_EL1
and x0, x0, #0x3
ret
FUNCTION(_cpu_get_icc_sre_el2)
mrs x0, ICC_SRE_EL2
ret
FUNCTION(_cpu_set_icc_sre_el2_irq)
mrs x0, ICC_SRE_EL2
orr x0, x0, #ICC_SRE_EL2_IRQ
msr ICC_SRE_EL2, x0
ret
FUNCTION(_cpu_set_icc_sre_el2_fiq)
mrs x0, ICC_SRE_EL2
orr x0, x0, #ICC_SRE_EL2_FIQ
mrs x0, ICC_SRE_EL2
ret
.end
我使用以下 GCC 标志:
-Wall -I ./include -ffreestanding -mcpu=cortex-a53
根据official TRM,这些寄存器应该在Cortex-A53上实现。
我是这个架构的新手。任何帮助将不胜感激!
编辑:
我尝试了以下 GAS 版本:
我用过的操作系统(openSUSE Leap 15.1)的包:
$ aarch64-suse-linux-as --version
GNU assembler (GNU Binutils; devel:gcc / openSUSE_Leap_15.1) 2.34.0.20200325-lp151.386
Copyright (C) 2020 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `aarch64-suse-linux'.
official tool-chains from the ARM homepage:
$ ../gcc/bin/aarch64-none-elf-as --version
GNU assembler (GNU Toolchain for the A-profile Architecture 9.2-2019.12 (arm-9.10)) 2.33.1.20191209
Copyright (C) 2019 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `aarch64-none-elf'.
【问题讨论】:
-
据我所知,
-ffreestanding和-mcpu只影响 C 编译器。这里不涉及 C 编译器;您只是使用gcc驱动程序作为调用汇编程序的一种方式。 -
好的。我试图通过选项
-Wa,-mcpu=cortex-a53。不幸的是同样的错误。
标签: gcc cpu-registers arm64 gnu-assembler interrupt-handling