forked from Mirrors/opensbi
lib: utils/irqchip: Use heap in PLIC, APLIC and IMSIC drivers
Let's use heap allocation in PLIC, APLIC, and IMSIC irqchip drivers instead of using a fixed size global array. Signed-off-by: Anup Patel <apatel@ventanamicro.com> Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
This commit is contained in:
@@ -11,16 +11,12 @@
|
||||
#include <libfdt.h>
|
||||
#include <sbi/riscv_asm.h>
|
||||
#include <sbi/sbi_error.h>
|
||||
#include <sbi/sbi_heap.h>
|
||||
#include <sbi/sbi_hartmask.h>
|
||||
#include <sbi_utils/fdt/fdt_helper.h>
|
||||
#include <sbi_utils/irqchip/fdt_irqchip.h>
|
||||
#include <sbi_utils/irqchip/imsic.h>
|
||||
|
||||
#define IMSIC_MAX_NR 16
|
||||
|
||||
static unsigned long imsic_count = 0;
|
||||
static struct imsic_data imsic[IMSIC_MAX_NR];
|
||||
|
||||
static int irqchip_imsic_update_hartid_table(void *fdt, int nodeoff,
|
||||
struct imsic_data *id)
|
||||
{
|
||||
@@ -71,27 +67,27 @@ static int irqchip_imsic_cold_init(void *fdt, int nodeoff,
|
||||
int rc;
|
||||
struct imsic_data *id;
|
||||
|
||||
if (IMSIC_MAX_NR <= imsic_count)
|
||||
return SBI_ENOSPC;
|
||||
id = &imsic[imsic_count];
|
||||
id = sbi_zalloc(sizeof(*id));
|
||||
if (!id)
|
||||
return SBI_ENOMEM;
|
||||
|
||||
rc = fdt_parse_imsic_node(fdt, nodeoff, id);
|
||||
if (rc)
|
||||
return rc;
|
||||
if (!id->targets_mmode)
|
||||
return 0;
|
||||
if (rc || !id->targets_mmode)
|
||||
goto fail_free_data;
|
||||
|
||||
rc = irqchip_imsic_update_hartid_table(fdt, nodeoff, id);
|
||||
if (rc)
|
||||
return rc;
|
||||
goto fail_free_data;
|
||||
|
||||
rc = imsic_cold_irqchip_init(id);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
imsic_count++;
|
||||
goto fail_free_data;
|
||||
|
||||
return 0;
|
||||
|
||||
fail_free_data:
|
||||
sbi_free(id);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static const struct fdt_match irqchip_imsic_match[] = {
|
||||
|
Reference in New Issue
Block a user