Issue created by Sebastian Huber: 
https://gitlab.rtems.org/rtems/rtos/rtems/-/work_items/5790



## Summary

The drivers in `bsps/riscv/riscv/irq/irq.c` and
`bsps/riscv/riscv/clock/clockdrv.c` read the hardware facts from the device
tree. These are the CLINT base, the PLIC base, the PLIC contexts, the
interrupt count, the timebase frequency and the hart count. A BSP which
finds them through AMBA Plug & Play or at fixed addresses cannot use the
drivers. Merge request !1471 therefore copies both drivers into
`bsps/riscv/noel/`. The copies diverge already. The NOEL copy assigns no
priority to the last PLIC source, so this source never fires.

## Proposal

Move the drivers to `bsps/riscv/shared/`. Each BSP provides
`<bsp/irqimpl.h>`. It defines the hardware facts as static inline
functions:

```c
static inline volatile RISCV_CLINT_regs *riscv_clint_get( void );
static inline volatile RISCV_PLIC_regs  *riscv_plic_get( void );
static inline uint32_t riscv_plic_get_context( uint32_t hart_index );
static inline uint32_t riscv_plic_get_interrupt_count( void );
static inline uint32_t riscv_get_timebase_frequency( void );
static inline uint32_t riscv_get_hart_count( void );
```

The BSP chooses how each function gets its value:

| BSP | Value |
| --- | --- |
| riscv | variable, set from the device tree |
| noel | variable, set from AMBA Plug & Play |
| BSP with fixed addresses | constant from a BSP option |

The sparc BSPs use the same header and the same pattern, see
`LEON3_IrqCtrl_Regs` in the leon3 `<bsp/irqimpl.h>`. The refactoring does
not change the behaviour of the existing BSPs. The author of !1471 agreed
to the proposal on 2026-10-01.

This description was created with Claude Code assistance.

-- 
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/work_items/5790
You're receiving this email because of your account on gitlab.rtems.org. 
Unsubscribe from this thread: 
https://gitlab.rtems.org/-/namespace/49/sent_notifications/5-df2j3zqr3cgnjkxbarxu6vv1p-1d/unsubscribe
 | Manage all notifications: https://gitlab.rtems.org/-/profile/notifications | 
Help: https://gitlab.rtems.org/help


_______________________________________________
bugs mailing list
[email protected]
http://lists.rtems.org/mailman/listinfo/bugs

Reply via email to