Skip to content

Commit 132e854

Browse files
committed
Allocate ACLINT register by 'SMP' configuration
Add an macro 'NUM_SMP' to device.h to indicate the number of SMPs, and allocate the size of the array of the registers in ACLINT device with the corresponding configuration.
1 parent ad6d0e8 commit 132e854

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ E :=
7878
S := $E $E
7979

8080
SMP ?= 1
81+
CFLAGS += -DNUM_HARTS=$(SMP)
8182
.PHONY: riscv-harts.dtsi
8283
riscv-harts.dtsi:
8384
$(Q)python3 scripts/gen-hart-dts.py $@ $(SMP) $(CLOCK_FREQ)

device.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,12 @@ void virtio_blk_write(hart_t *vm,
172172
uint32_t *virtio_blk_init(virtio_blk_state_t *vblk, char *disk_file);
173173
#endif /* SEMU_HAS(VIRTIOBLK) */
174174

175+
/* ACLINT */
176+
177+
#ifndef NUM_HARTS
178+
#define NUM_HARTS 1
179+
#endif
180+
175181
/* ACLINT MTIMER */
176182
typedef struct {
177183
/* A MTIMER device has two separate base addresses: one for the MTIME
@@ -190,7 +196,7 @@ typedef struct {
190196
* For more details, please refer to the register map at:
191197
* https://github.com/riscv/riscv-aclint/blob/main/riscv-aclint.adoc#21-register-map
192198
*/
193-
uint64_t mtimecmp[4095];
199+
uint64_t mtimecmp[NUM_HARTS];
194200
semu_timer_t mtime;
195201
} mtimer_state_t;
196202

@@ -218,7 +224,7 @@ typedef struct {
218224
* For more details, please refer to the register map at:
219225
* https://github.com/riscv/riscv-aclint/blob/main/riscv-aclint.adoc#31-register-map
220226
*/
221-
uint32_t msip[4096];
227+
uint32_t msip[NUM_HARTS];
222228
} mswi_state_t;
223229

224230
void aclint_mswi_update_interrupts(hart_t *hart, mswi_state_t *mswi);
@@ -245,7 +251,7 @@ typedef struct {
245251
* For more details, please refer to the register map at:
246252
* https://github.com/riscv/riscv-aclint/blob/main/riscv-aclint.adoc#41-register-map
247253
*/
248-
uint32_t ssip[4096];
254+
uint32_t ssip[NUM_HARTS];
249255
} sswi_state_t;
250256

251257
void aclint_sswi_update_interrupts(hart_t *hart, sswi_state_t *sswi);

0 commit comments

Comments
 (0)