Skip to content

Commit 271dd7f

Browse files
josecmdanielRep
authored andcommitted
ref(core): refactor ipi_cpumsg_handler_size calculation
The way this size was being calculated using the linker generated a linking error when targetting risc-v. Signed-off-by: Jose Martins <[email protected]>
1 parent 7c8d141 commit 271dd7f

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/core/cpu.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ OBJPOOL_ALLOC(msg_pool, struct cpu_msg_node, CPU_MSG_POOL_SIZE);
2525
struct cpu_synctoken cpu_glb_sync = { .ready = false };
2626

2727
extern cpu_msg_handler_t ipi_cpumsg_handlers[];
28-
extern uint8_t _ipi_cpumsg_handlers_size;
2928
extern size_t _ipi_cpumsg_handlers_id_start[];
30-
size_t ipi_cpumsg_handler_num;
29+
extern size_t _ipi_cpumsg_handlers_id_end[];
30+
static size_t ipi_cpumsg_handler_num;
3131

3232
struct cpuif cpu_interfaces[PLAT_CPU_NUM];
3333

@@ -44,7 +44,8 @@ void cpu_init(cpuid_t cpu_id, paddr_t load_addr)
4444
if (cpu_is_master()) {
4545
cpu_sync_init(&cpu_glb_sync, platform.cpu_num);
4646

47-
ipi_cpumsg_handler_num = ((size_t)&_ipi_cpumsg_handlers_size) / sizeof(cpu_msg_handler_t);
47+
ipi_cpumsg_handler_num =
48+
(size_t)(_ipi_cpumsg_handlers_id_end - _ipi_cpumsg_handlers_id_start);
4849
for (size_t i = 0; i < ipi_cpumsg_handler_num; i++) {
4950
((size_t*)_ipi_cpumsg_handlers_id_start)[i] = i;
5051
}

src/linker.ld

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,9 @@ SECTIONS
4646
.ipi_cpumsg_handlers_id : {
4747
_ipi_cpumsg_handlers_id_start = .;
4848
*(.ipi_cpumsg_handlers_id)
49+
_ipi_cpumsg_handlers_id_end = .;
4950
}
5051

51-
_ipi_cpumsg_handlers_size = SIZEOF(.ipi_cpumsg_handlers);
52-
5352
. = ALIGN(PAGE_SIZE);
5453
_image_load_end = .;
5554

0 commit comments

Comments
 (0)