diff options
| author | Anup Patel <[email protected]> | 2018-12-26 18:27:35 +0530 |
|---|---|---|
| committer | Anup Patel <[email protected]> | 2018-12-27 09:35:09 +0530 |
| commit | e34aa8a6719dd6c225e576e0617d05735776af6f (patch) | |
| tree | 59b041b592b1f139cb7850a522813f392a28c70b /platform | |
| parent | 7b59571758a5dec75c89928a60d982b29629cee6 (diff) | |
lib: Simplify sbi_platform irqchip_init() hooks
Instead of having separate irqchip_init() hooks for cold and
warm boot, this patch updates struct sbi_platform to have just
one irqchip_init() hook. The type of boot (cold or warm) is now
a boolean flag parameter for the updated irqchip_init() hook.
Signed-off-by: Anup Patel <[email protected]>
Diffstat (limited to 'platform')
| -rw-r--r-- | platform/kendryte/k210/platform.c | 25 | ||||
| -rw-r--r-- | platform/qemu/sifive_u/platform.c | 26 | ||||
| -rw-r--r-- | platform/qemu/virt/platform.c | 26 | ||||
| -rw-r--r-- | platform/sifive/hifive_u540/platform.c | 26 |
4 files changed, 56 insertions, 47 deletions
diff --git a/platform/kendryte/k210/platform.c b/platform/kendryte/k210/platform.c index ccb0ad66..43c32440 100644 --- a/platform/kendryte/k210/platform.c +++ b/platform/kendryte/k210/platform.c @@ -35,17 +35,21 @@ static char k210_console_getc(void) return uarths_getc(); } -static int k210_cold_irqchip_init(void) +static int k210_irqchip_init(u32 hartid, bool cold_boot) { - return plic_cold_irqchip_init(PLIC_BASE_ADDR, PLIC_NUM_SOURCES, - K210_HART_COUNT); -} + int rc; -static int k210_warm_irqchip_init(u32 core_id) -{ - return plic_warm_irqchip_init(core_id, - (2 * core_id), - (2 * core_id + 1)); + if (cold_boot) { + rc = plic_cold_irqchip_init(PLIC_BASE_ADDR, + PLIC_NUM_SOURCES, + K210_HART_COUNT); + if (rc) + return rc; + } + + return plic_warm_irqchip_init(hartid, + (2 * hartid), + (2 * hartid + 1)); } static int k210_cold_ipi_init(void) @@ -87,8 +91,7 @@ struct sbi_platform platform = { .console_putc = k210_console_putc, .console_getc = k210_console_getc, - .cold_irqchip_init = k210_cold_irqchip_init, - .warm_irqchip_init = k210_warm_irqchip_init, + .irqchip_init = k210_irqchip_init, .cold_ipi_init = k210_cold_ipi_init, .warm_ipi_init = clint_warm_ipi_init, diff --git a/platform/qemu/sifive_u/platform.c b/platform/qemu/sifive_u/platform.c index bbbe055a..db6dccd5 100644 --- a/platform/qemu/sifive_u/platform.c +++ b/platform/qemu/sifive_u/platform.c @@ -74,18 +74,21 @@ static int sifive_u_console_init(void) SIFIVE_U_PERIPH_CLK, 115200); } -static int sifive_u_cold_irqchip_init(void) +static int sifive_u_irqchip_init(u32 hartid, bool cold_boot) { - return plic_cold_irqchip_init(SIFIVE_U_PLIC_ADDR, - SIFIVE_U_PLIC_NUM_SOURCES, - SIFIVE_U_HART_COUNT); -} + int rc; -static int sifive_u_warm_irqchip_init(u32 target_hart) -{ - return plic_warm_irqchip_init(target_hart, - (2 * target_hart), - (2 * target_hart + 1)); + if (cold_boot) { + rc = plic_cold_irqchip_init(SIFIVE_U_PLIC_ADDR, + SIFIVE_U_PLIC_NUM_SOURCES, + SIFIVE_U_HART_COUNT); + if (rc) + return rc; + } + + return plic_warm_irqchip_init(hartid, + (2 * hartid), + (2 * hartid + 1)); } static int sifive_u_cold_ipi_init(void) @@ -118,8 +121,7 @@ struct sbi_platform platform = { .console_putc = sifive_uart_putc, .console_getc = sifive_uart_getc, .console_init = sifive_u_console_init, - .cold_irqchip_init = sifive_u_cold_irqchip_init, - .warm_irqchip_init = sifive_u_warm_irqchip_init, + .irqchip_init = sifive_u_irqchip_init, .ipi_inject = clint_ipi_inject, .ipi_sync = clint_ipi_sync, .ipi_clear = clint_ipi_clear, diff --git a/platform/qemu/virt/platform.c b/platform/qemu/virt/platform.c index 9e0d21a2..986dfc57 100644 --- a/platform/qemu/virt/platform.c +++ b/platform/qemu/virt/platform.c @@ -75,18 +75,21 @@ static int virt_console_init(void) VIRT_UART_BAUDRATE, 0, 1); } -static int virt_cold_irqchip_init(void) +static int virt_irqchip_init(u32 hartid, bool cold_boot) { - return plic_cold_irqchip_init(VIRT_PLIC_ADDR, - VIRT_PLIC_NUM_SOURCES, - VIRT_HART_COUNT); -} + int rc; -static int virt_warm_irqchip_init(u32 target_hart) -{ - return plic_warm_irqchip_init(target_hart, - (2 * target_hart), - (2 * target_hart + 1)); + if (cold_boot) { + rc = plic_cold_irqchip_init(VIRT_PLIC_ADDR, + VIRT_PLIC_NUM_SOURCES, + VIRT_HART_COUNT); + if (rc) + return rc; + } + + return plic_warm_irqchip_init(hartid, + (2 * hartid), + (2 * hartid + 1)); } static int virt_cold_ipi_init(void) @@ -119,8 +122,7 @@ struct sbi_platform platform = { .console_putc = uart8250_putc, .console_getc = uart8250_getc, .console_init = virt_console_init, - .cold_irqchip_init = virt_cold_irqchip_init, - .warm_irqchip_init = virt_warm_irqchip_init, + .irqchip_init = virt_irqchip_init, .ipi_inject = clint_ipi_inject, .ipi_sync = clint_ipi_sync, .ipi_clear = clint_ipi_clear, diff --git a/platform/sifive/hifive_u540/platform.c b/platform/sifive/hifive_u540/platform.c index 2db5dae8..6d6ac182 100644 --- a/platform/sifive/hifive_u540/platform.c +++ b/platform/sifive/hifive_u540/platform.c @@ -94,18 +94,21 @@ static int sifive_u_console_init(void) peri_in_freq, SIFIVE_UART_BAUDRATE); } -static int sifive_u_cold_irqchip_init(void) +static int sifive_u_irqchip_init(u32 hartid, bool cold_boot) { - return plic_cold_irqchip_init(SIFIVE_U_PLIC_ADDR, - SIFIVE_U_PLIC_NUM_SOURCES, - SIFIVE_U_HART_COUNT); -} + int rc; -static int sifive_u_warm_irqchip_init(u32 target_hart) -{ - return plic_warm_irqchip_init(target_hart, - (target_hart) ? (2 * target_hart - 1) : 0, - (target_hart) ? (2 * target_hart) : -1); + if (cold_boot) { + rc = plic_cold_irqchip_init(SIFIVE_U_PLIC_ADDR, + SIFIVE_U_PLIC_NUM_SOURCES, + SIFIVE_U_HART_COUNT); + if (rc) + return rc; + } + + return plic_warm_irqchip_init(hartid, + (hartid) ? (2 * hartid - 1) : 0, + (hartid) ? (2 * hartid) : -1); } static int sifive_u_cold_ipi_init(void) @@ -138,8 +141,7 @@ struct sbi_platform platform = { .console_putc = sifive_uart_putc, .console_getc = sifive_uart_getc, .console_init = sifive_u_console_init, - .cold_irqchip_init = sifive_u_cold_irqchip_init, - .warm_irqchip_init = sifive_u_warm_irqchip_init, + .irqchip_init = sifive_u_irqchip_init, .ipi_inject = clint_ipi_inject, .ipi_sync = clint_ipi_sync, .ipi_clear = clint_ipi_clear, |
