limine: Move SMP request to using SoA

This commit is contained in:
mintsuki 2022-03-18 07:26:56 +01:00
parent 76b9312d72
commit 03700dea96
3 changed files with 29 additions and 13 deletions

View File

@ -116,8 +116,7 @@ struct limine_5_level_paging_request {
struct limine_smp_info { struct limine_smp_info {
uint32_t processor_id; uint32_t processor_id;
uint32_t lapic_id; uint32_t lapic_id;
uint64_t reserved; uint64_t reserved[2];
LIMINE_PTR(void *) goto_address;
uint64_t extra_argument; uint64_t extra_argument;
}; };
@ -126,8 +125,11 @@ struct limine_smp_response {
uint32_t bsp_lapic_id; uint32_t bsp_lapic_id;
uint32_t unused; uint32_t unused;
uint64_t cpus_count; uint64_t cpu_count;
LIMINE_PTR(struct limine_smp_info *) cpus; LIMINE_PTR(uint32_t *) cpu_processor_id;
LIMINE_PTR(uint32_t *) cpu_lapic_id;
LIMINE_PTR(LIMINE_PTR(LIMINE_PTR(void *) *) *) cpu_goto_address;
LIMINE_PTR(LIMINE_PTR(LIMINE_PTR(void *) *) *) cpu_extra_argument;
}; };
struct limine_smp_request { struct limine_smp_request {

View File

@ -483,11 +483,10 @@ FEAT_START
break; // next feature break; // next feature
} }
struct limine_smp_info *smp_array;
struct smp_information *smp_info; struct smp_information *smp_info;
size_t cpu_count; size_t cpu_count;
uint32_t bsp_lapic_id; uint32_t bsp_lapic_id;
smp_info = init_smp(0, (void **)&smp_array, smp_info = init_smp(0, (void **)&smp_info,
&cpu_count, &bsp_lapic_id, &cpu_count, &bsp_lapic_id,
true, want_5lv, true, want_5lv,
pagemap, smp_request->flags & LIMINE_SMP_X2APIC, true, pagemap, smp_request->flags & LIMINE_SMP_X2APIC, true,
@ -507,8 +506,24 @@ FEAT_START
smp_response->flags |= (smp_request->flags & LIMINE_SMP_X2APIC) && x2apic_check(); smp_response->flags |= (smp_request->flags & LIMINE_SMP_X2APIC) && x2apic_check();
smp_response->bsp_lapic_id = bsp_lapic_id; smp_response->bsp_lapic_id = bsp_lapic_id;
smp_response->cpus_count = cpu_count; smp_response->cpu_count = cpu_count;
smp_response->cpus = reported_addr(smp_array);
uint32_t *cpu_processor_id = ext_mem_alloc(sizeof(uint32_t) * cpu_count);
uint32_t *cpu_lapic_id = ext_mem_alloc(sizeof(uint32_t) * cpu_count);
uint64_t *cpu_goto_address = ext_mem_alloc(sizeof(uint64_t) * cpu_count);
uint64_t *cpu_extra_argument = ext_mem_alloc(sizeof(uint64_t) * cpu_count);
for (size_t i = 0; i < cpu_count; i++) {
cpu_processor_id[i] = smp_info[i].acpi_processor_uid;
cpu_lapic_id[i] = smp_info[i].lapic_id;
cpu_goto_address[i] = reported_addr(&smp_info[i].goto_address);
cpu_extra_argument[i] = reported_addr(&smp_info[i].extra_argument);
}
smp_response->cpu_processor_id = reported_addr(cpu_processor_id);
smp_response->cpu_lapic_id = reported_addr(cpu_lapic_id);
smp_response->cpu_goto_address = reported_addr(cpu_goto_address);
smp_response->cpu_extra_argument = reported_addr(cpu_extra_argument);
smp_request->response = reported_addr(smp_response); smp_request->response = reported_addr(smp_response);
FEAT_END FEAT_END

View File

@ -224,11 +224,10 @@ FEAT_START
struct limine_smp_response *smp_response = _smp_request.response; struct limine_smp_response *smp_response = _smp_request.response;
e9_printf("Flags: %x", smp_response->flags); e9_printf("Flags: %x", smp_response->flags);
e9_printf("BSP LAPIC ID: %x", smp_response->bsp_lapic_id); e9_printf("BSP LAPIC ID: %x", smp_response->bsp_lapic_id);
e9_printf("CPUs count: %d", smp_response->cpus_count); e9_printf("CPU count: %d", smp_response->cpu_count);
for (size_t i = 0; i < smp_response->cpus_count; i++) { for (size_t i = 0; i < smp_response->cpu_count; i++) {
struct limine_smp_info *cpu = &smp_response->cpus[i]; e9_printf("Processor ID: %x", smp_response->cpu_processor_id[i]);
e9_printf("Processor ID: %x", cpu->processor_id); e9_printf("LAPIC ID: %x", smp_response->cpu_lapic_id[i]);
e9_printf("LAPIC ID: %x", cpu->lapic_id);
} }
FEAT_END FEAT_END