Skip to content

Commit

Permalink
fix(aia): add compatibility check for AIA and PLIC
Browse files Browse the repository at this point in the history
- Add a check in riscv.mk to ensure PLIC is not enabled when AIA is enabled
- Fix some coding style issues
  • Loading branch information
HuangBorong committed Feb 21, 2025
1 parent 99e2277 commit 11231c0
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 8 deletions.
4 changes: 4 additions & 0 deletions core/arch/riscv/riscv.mk
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ ifeq ($(CFG_RISCV_WITH_M_MODE_SM),y)
$(call force,CFG_RISCV_SBI,y)
endif

ifeq ($(CFG_RISCV_PLIC)-$(call cfg-one-enabled,CFG_RISCV_APLIC CFG_RISCV_APLIC_MSI CFG_RISCV_IMSIC),y-y)
$(error PLIC is incompatible with AIA)
endif

# Disable unsupported and other arch-specific flags
$(call force,CFG_CORE_FFA,n)
$(call force,CFG_SECURE_PARTITION,n)
Expand Down
2 changes: 1 addition & 1 deletion core/drivers/aplic_direct.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ void aplic_dump_state(void)
{
}

void* get_aplic_data(void)
struct aplic_data *get_aplic_data(void)
{
return NULL;
}
4 changes: 2 additions & 2 deletions core/drivers/aplic_msi.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void aplic_dump_state(void)
{
}

struct aplic_data* get_aplic_data(void)
struct aplic_data *get_aplic_data(void)
{
return &aplic_data;
}
}
10 changes: 7 additions & 3 deletions core/drivers/imsic.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,8 @@ TEE_Result fdt_parse_imsic_node(const void *fdt, int nodeoff,
if (val && len > 0)
imsic->hart_index_bits = fdt32_to_cpu(*val);
else
imsic->hart_index_bits = 32 -
__builtin_clz(CFG_TEE_CORE_NB_CORE - 1);
imsic->hart_index_bits =
32 - __builtin_clz(CFG_TEE_CORE_NB_CORE - 1);

val = fdt_getprop(fdt, nodeoff, "riscv,group-index-bits", &len);
if (val && len > 0)
Expand Down Expand Up @@ -352,7 +352,7 @@ void imsic_it_handle(void)
if (id == IMSIC_IPI_ID)
DMSG("Interprocessor interrupt");

if (id > 1 && id <= imsic->num_ids)
if (id > IMSIC_IPI_ID && id <= imsic->num_ids)
interrupt_call_handlers(&imsic->chip, id);
else
DMSG("ignoring interrupt %" PRIu32, id);
Expand Down Expand Up @@ -388,3 +388,7 @@ void imsic_init(paddr_t imsic_base_pa)

interrupt_main_init(&imsic->chip);
}

void imsic_dump_state(void)
{
}
2 changes: 1 addition & 1 deletion core/include/drivers/aplic_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,6 @@ TEE_Result aplic_init_from_device_tree(struct aplic_data *aplic);
TEE_Result aplic_set_source_mode(struct aplic_data *aplic, uint32_t source,
uint32_t type);

struct aplic_data* get_aplic_data(void);
struct aplic_data *get_aplic_data(void);

#endif /* __DRIVERS_APLIC_PRIV_H */
2 changes: 1 addition & 1 deletion core/include/drivers/imsic.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct imsic_data {
uint32_t hart_index_bits;
uint32_t group_index_bits;
uint32_t group_index_shift;
struct aplic_data* aplic;
struct aplic_data *aplic;
struct itr_chip chip;
};

Expand Down

0 comments on commit 11231c0

Please sign in to comment.