[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190610221621.10938-12-hch@lst.de>
Date: Tue, 11 Jun 2019 00:16:15 +0200
From: Christoph Hellwig <hch@....de>
To: Palmer Dabbelt <palmer@...ive.com>
Cc: Damien Le Moal <damien.lemoal@....com>,
linux-riscv@...ts.infradead.org, uclinux-dev@...inux.org,
linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: [PATCH 11/17] riscv: read hart ID from mhartid on boot
From: Damien Le Moal <damien.lemoal@....com>
When in M-Mode, we can use the mhartid CSR to get the ID of the running
HART. Doing so, direct M-Mode boot without firmware is possible.
Signed-off-by: Damien Le Moal <damien.lemoal@....com>
---
arch/riscv/kernel/head.S | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S
index cb5691d82b0b..e05379fd8b64 100644
--- a/arch/riscv/kernel/head.S
+++ b/arch/riscv/kernel/head.S
@@ -25,6 +25,14 @@ ENTRY(_start)
/* Reset all registers except ra, a0,a1 */
call reset_regs
+#ifdef CONFIG_M_MODE
+ /*
+ * The hartid in a0 is expected later on, and we have no firmware
+ * to hand it to us.
+ */
+ csrr a0, mhartid
+#endif
+
/* Load the global pointer */
.option push
.option norelax
--
2.20.1
Powered by blists - more mailing lists