Skip to content

Commit

Permalink
lib: utils: Add M-mode {R/W} flags to the MMIO regions
Browse files Browse the repository at this point in the history
Add the M-mode readable/writable flags to mmio regions
of various drivers.

Signed-off-by: Himanshu Chauhan <hchauhan@ventanamicro.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Tested-by: Anup Patel <anup@brainfault.org>
  • Loading branch information
hschauhan authored and avpatel committed Jan 9, 2023
1 parent 3e2f573 commit 59a08cd
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
5 changes: 4 additions & 1 deletion lib/utils/ipi/aclint_mswi.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ int aclint_mswi_cold_init(struct aclint_mswi_data *mswi)
region_size = ((mswi->size - pos) < ACLINT_MSWI_ALIGN) ?
(mswi->size - pos) : ACLINT_MSWI_ALIGN;
sbi_domain_memregion_init(mswi->addr + pos, region_size,
SBI_DOMAIN_MEMREGION_MMIO, &reg);
(SBI_DOMAIN_MEMREGION_MMIO |
SBI_DOMAIN_MEMREGION_M_READABLE |
SBI_DOMAIN_MEMREGION_M_WRITABLE),
&reg);
rc = sbi_domain_root_add_memregion(&reg);
if (rc)
return rc;
Expand Down
5 changes: 4 additions & 1 deletion lib/utils/irqchip/aplic.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,10 @@ int aplic_cold_irqchip_init(struct aplic_data *aplic)
(last_deleg_irq == aplic->num_source) &&
(first_deleg_irq == 1))) {
sbi_domain_memregion_init(aplic->addr, aplic->size,
SBI_DOMAIN_MEMREGION_MMIO, &reg);
(SBI_DOMAIN_MEMREGION_MMIO |
SBI_DOMAIN_MEMREGION_M_READABLE |
SBI_DOMAIN_MEMREGION_M_WRITABLE),
&reg);
rc = sbi_domain_root_add_memregion(&reg);
if (rc)
return rc;
Expand Down
5 changes: 4 additions & 1 deletion lib/utils/irqchip/imsic.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,10 @@ int imsic_cold_irqchip_init(struct imsic_data *imsic)
for (i = 0; i < IMSIC_MAX_REGS && imsic->regs[i].size; i++) {
sbi_domain_memregion_init(imsic->regs[i].addr,
imsic->regs[i].size,
SBI_DOMAIN_MEMREGION_MMIO, &reg);
(SBI_DOMAIN_MEMREGION_MMIO |
SBI_DOMAIN_MEMREGION_M_READABLE |
SBI_DOMAIN_MEMREGION_M_WRITABLE),
&reg);
rc = sbi_domain_root_add_memregion(&reg);
if (rc)
return rc;
Expand Down
16 changes: 12 additions & 4 deletions lib/utils/timer/aclint_mtimer.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,26 +188,34 @@ int aclint_mtimer_cold_init(struct aclint_mtimer_data *mt,
rc = sbi_domain_root_add_memrange(mt->mtimecmp_addr,
mt->mtime_size + mt->mtimecmp_size,
MTIMER_REGION_ALIGN,
SBI_DOMAIN_MEMREGION_MMIO);
(SBI_DOMAIN_MEMREGION_MMIO |
SBI_DOMAIN_MEMREGION_M_READABLE |
SBI_DOMAIN_MEMREGION_M_WRITABLE));
if (rc)
return rc;
} else if (mt->mtimecmp_addr == (mt->mtime_addr + mt->mtime_size)) {
rc = sbi_domain_root_add_memrange(mt->mtime_addr,
mt->mtime_size + mt->mtimecmp_size,
MTIMER_REGION_ALIGN,
SBI_DOMAIN_MEMREGION_MMIO);
(SBI_DOMAIN_MEMREGION_MMIO |
SBI_DOMAIN_MEMREGION_M_READABLE |
SBI_DOMAIN_MEMREGION_M_WRITABLE));
if (rc)
return rc;
} else {
rc = sbi_domain_root_add_memrange(mt->mtime_addr,
mt->mtime_size, MTIMER_REGION_ALIGN,
SBI_DOMAIN_MEMREGION_MMIO);
(SBI_DOMAIN_MEMREGION_MMIO |
SBI_DOMAIN_MEMREGION_M_READABLE |
SBI_DOMAIN_MEMREGION_M_WRITABLE));
if (rc)
return rc;

rc = sbi_domain_root_add_memrange(mt->mtimecmp_addr,
mt->mtimecmp_size, MTIMER_REGION_ALIGN,
SBI_DOMAIN_MEMREGION_MMIO);
(SBI_DOMAIN_MEMREGION_MMIO |
SBI_DOMAIN_MEMREGION_M_READABLE |
SBI_DOMAIN_MEMREGION_M_WRITABLE));
if (rc)
return rc;
}
Expand Down

0 comments on commit 59a08cd

Please sign in to comment.