aboutsummaryrefslogtreecommitdiff
path: root/riscv
diff options
context:
space:
mode:
authorJerry Zhao <jerryz123@berkeley.edu>2023-06-06 11:21:21 -0700
committerJerry Zhao <jerryz123@berkeley.edu>2023-06-20 12:23:47 -0700
commit701029d28b0e73f98a36869ef9317c49f0dc2949 (patch)
treee84191569aa072bdacb41e25cb509e7eef932fc4 /riscv
parent37e50ad49914725f6ba0364255e2ae809c60f0f2 (diff)
downloadriscv-isa-sim-701029d28b0e73f98a36869ef9317c49f0dc2949.zip
riscv-isa-sim-701029d28b0e73f98a36869ef9317c49f0dc2949.tar.gz
riscv-isa-sim-701029d28b0e73f98a36869ef9317c49f0dc2949.tar.bz2
ns16550_t: ns16550 should parse interrupt id from the fdt
Diffstat (limited to 'riscv')
-rw-r--r--riscv/dts.cc10
-rw-r--r--riscv/dts.h2
-rw-r--r--riscv/ns16550.cc7
3 files changed, 15 insertions, 4 deletions
diff --git a/riscv/dts.cc b/riscv/dts.cc
index 8c1ceb4..cc65e3c 100644
--- a/riscv/dts.cc
+++ b/riscv/dts.cc
@@ -293,6 +293,7 @@ int fdt_parse_plic(const void *fdt, reg_t *plic_addr, uint32_t *ndev,
int fdt_parse_ns16550(const void *fdt, reg_t *ns16550_addr,
uint32_t *reg_shift, uint32_t *reg_io_width,
+ uint32_t* reg_int_id,
const char *compatible)
{
int nodeoffset, len, rc;
@@ -324,6 +325,15 @@ int fdt_parse_ns16550(const void *fdt, reg_t *ns16550_addr,
}
}
+ reg_p = (fdt32_t *)fdt_getprop(fdt, nodeoffset, "interrupts", &len);
+ if (reg_int_id) {
+ if (reg_p) {
+ *reg_int_id = fdt32_to_cpu(*reg_p);
+ } else {
+ *reg_int_id = NS16550_INTERRUPT_ID;
+ }
+ }
+
return 0;
}
diff --git a/riscv/dts.h b/riscv/dts.h
index 10d3cc1..7ec1ceb 100644
--- a/riscv/dts.h
+++ b/riscv/dts.h
@@ -27,7 +27,7 @@ int fdt_parse_clint(const void *fdt, reg_t *clint_addr,
int fdt_parse_plic(const void *fdt, reg_t *plic_addr, uint32_t *ndev,
const char *compatible);
int fdt_parse_ns16550(const void *fdt, reg_t *ns16550_addr,
- uint32_t *reg_shift, uint32_t *reg_io_width,
+ uint32_t *reg_shift, uint32_t *reg_io_width, uint32_t* reg_int_id,
const char *compatible);
int fdt_parse_pmp_num(const void *fdt, int cpu_offset, reg_t *pmp_num);
int fdt_parse_pmp_alignment(const void *fdt, int cpu_offset, reg_t *pmp_align);
diff --git a/riscv/ns16550.cc b/riscv/ns16550.cc
index a4bd204..dabe3a9 100644
--- a/riscv/ns16550.cc
+++ b/riscv/ns16550.cc
@@ -343,11 +343,12 @@ std::string ns16550_generate_dts(const sim_t* sim)
ns16550_t* ns16550_parse_from_fdt(const void* fdt, const sim_t* sim, reg_t* base)
{
- uint32_t ns16550_shift, ns16550_io_width;
+ uint32_t ns16550_shift, ns16550_io_width, ns16550_int_id;
if (fdt_parse_ns16550(fdt, base,
- &ns16550_shift, &ns16550_io_width, "ns16550a") == 0) {
+ &ns16550_shift, &ns16550_io_width, &ns16550_int_id,
+ "ns16550a") == 0) {
abstract_interrupt_controller_t* intctrl = sim->get_intctrl();
- return new ns16550_t(intctrl, NS16550_INTERRUPT_ID, ns16550_shift, ns16550_io_width);
+ return new ns16550_t(intctrl, ns16550_int_id, ns16550_shift, ns16550_io_width);
} else {
return nullptr;
}