|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v1 3/4] xen/riscv: implement basic aplic_preinit()
Based on the code from [1] provided by Romain Caritey from Microchip
with some minor changes():
- Xen code style fixes
- Drop static variable inside aplic_preinit() and check
aplic_info.node directly.
- Drop direct initialization of aplic_info.hw_version in aplic_preinit()
as this field is explicitly initialized during declaration/definition
of aplic_info.
- Rename gic* to intc* to not confuse with Arm's GIC.
- Keep only minimal of things needed at the moment:
- Declare DT device.
- Initialize APLIC node.
- Set hw_version for aplic_info.
Since Microchip originally developed aplic.c, an internal discussion with
them led to the decision to use the MIT license instead of the default
GPL-2.0-only.
[1]
https://gitlab.com/xen-project/people/olkur/xen/-/commit/7cfb4bd4748ca268142497ac5c327d2766fb342d
Signed-off-by: Romain Caritey <Romain.Caritey@xxxxxxxxxxxxx>
Signed-off-by: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
---
xen/arch/riscv/Makefile | 1 +
xen/arch/riscv/aplic.c | 50 +++++++++++++++++++++++++++++++
xen/arch/riscv/include/asm/intc.h | 20 +++++++++++++
3 files changed, 71 insertions(+)
create mode 100644 xen/arch/riscv/aplic.c
create mode 100644 xen/arch/riscv/include/asm/intc.h
diff --git a/xen/arch/riscv/Makefile b/xen/arch/riscv/Makefile
index 82016a957a..dd5fd25c7d 100644
--- a/xen/arch/riscv/Makefile
+++ b/xen/arch/riscv/Makefile
@@ -1,3 +1,4 @@
+obj-y += aplic.o
obj-y += cpufeature.o
obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
obj-y += entry.o
diff --git a/xen/arch/riscv/aplic.c b/xen/arch/riscv/aplic.c
new file mode 100644
index 0000000000..42fac32958
--- /dev/null
+++ b/xen/arch/riscv/aplic.c
@@ -0,0 +1,50 @@
+/* SPDX-License-Identifier: MIT */
+
+/*
+ * xen/arch/riscv/aplic.c
+ *
+ * RISC-V Advanced Platform-Level Interrupt Controller support
+ *
+ * Copyright (c) 2023-2024 Microchip.
+ * Copyright (c) 2024 Vates
+ */
+
+#include <xen/errno.h>
+#include <xen/init.h>
+#include <xen/types.h>
+
+#include <asm/device.h>
+#include <asm/intc.h>
+
+static struct intc_info aplic_info = {
+ .hw_version = INTC_APLIC,
+ .node = NULL
+};
+
+static int __init aplic_preinit(struct dt_device_node *node, const void *dat)
+{
+ if ( aplic_info.node )
+ {
+ printk("XEN doesn't support more than one S mode APLIC\n");
+ return -ENODEV;
+ }
+
+ /* don't process if APLIC node is not for S mode */
+ if ( dt_get_property(node, "riscv,children", NULL) )
+ return -ENODEV;
+
+ aplic_info.node = node;
+
+ return 0;
+}
+
+static const struct dt_device_match aplic_dt_match[] __initconst =
+{
+ DT_MATCH_COMPATIBLE("riscv,aplic"),
+ { /* sentinel */ },
+};
+
+DT_DEVICE_START(aplic, "APLIC", DEVICE_INTERRUPT_CONTROLLER)
+ .dt_match = aplic_dt_match,
+ .init = aplic_preinit,
+DT_DEVICE_END
diff --git a/xen/arch/riscv/include/asm/intc.h
b/xen/arch/riscv/include/asm/intc.h
new file mode 100644
index 0000000000..ff9bb33896
--- /dev/null
+++ b/xen/arch/riscv/include/asm/intc.h
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: MIT */
+
+/*
+ * (c) 2023-2024 Microchip Technology Inc.
+ * (c) 2024 Vates
+ */
+
+#ifndef ASM__RISCV__INTERRUPT_CONTOLLER_H
+#define ASM__RISCV__INTERRUPT_CONTOLLER_H
+
+enum intc_version {
+ INTC_APLIC,
+};
+
+struct intc_info {
+ enum intc_version hw_version;
+ const struct dt_device_node *node;
+};
+
+#endif /* ASM__RISCV__INTERRUPT_CONTOLLER_H */
--
2.48.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |