Clean up bootinfo
This commit is contained in:
@ -6,7 +6,11 @@
|
||||
|
||||
BootInfo BOOT_INFO;
|
||||
|
||||
static volatile struct limine_paging_mode_request PAGING_REQ = {
|
||||
#define DEFINE_REQ(partname, partid) \
|
||||
static volatile struct limine_##partname##_request partname##_req = \
|
||||
{ .id = LIMINE_##partid##_REQUEST, .revision = 0 }
|
||||
|
||||
static volatile struct limine_paging_mode_request paging_req = {
|
||||
.id = LIMINE_PAGING_MODE_REQUEST,
|
||||
.revision = 0,
|
||||
#if defined(__x86_64__)
|
||||
@ -16,58 +20,38 @@ static volatile struct limine_paging_mode_request PAGING_REQ = {
|
||||
#endif
|
||||
};
|
||||
|
||||
static volatile struct limine_kernel_address_request KERN_ADDR_REQ = {
|
||||
.id = LIMINE_KERNEL_ADDRESS_REQUEST, .revision = 0,
|
||||
};
|
||||
|
||||
static volatile struct limine_hhdm_request HHDM_REQ = {
|
||||
.id = LIMINE_HHDM_REQUEST, .revision = 0,
|
||||
};
|
||||
|
||||
static volatile struct limine_memmap_request MEMMAP_REQ = {
|
||||
.id = LIMINE_MEMMAP_REQUEST, .revision = 0,
|
||||
};
|
||||
|
||||
static volatile struct limine_smp_request SMP_REQ = {
|
||||
.id = LIMINE_SMP_REQUEST, .revision = 0,
|
||||
};
|
||||
|
||||
static volatile struct limine_rsdp_request RSDP_REQ = {
|
||||
.id = LIMINE_RSDP_REQUEST, .revision = 0,
|
||||
};
|
||||
|
||||
static volatile struct limine_framebuffer_request FB_REQ = {
|
||||
.id = LIMINE_FRAMEBUFFER_REQUEST, .revision = 0,
|
||||
};
|
||||
|
||||
static volatile struct limine_module_request MODULE_REQ = {
|
||||
.id = LIMINE_MODULE_REQUEST, .revision = 0,
|
||||
};
|
||||
DEFINE_REQ(kernel_address, KERNEL_ADDRESS);
|
||||
DEFINE_REQ(hhdm, HHDM);
|
||||
DEFINE_REQ(memmap, MEMMAP);
|
||||
DEFINE_REQ(smp, SMP);
|
||||
DEFINE_REQ(rsdp, RSDP);
|
||||
DEFINE_REQ(framebuffer, FRAMEBUFFER);
|
||||
DEFINE_REQ(module, MODULE);
|
||||
|
||||
void bootinfo_init(void) {
|
||||
if (FB_REQ.response == NULL || FB_REQ.response->framebuffer_count < 1) {
|
||||
if (framebuffer_req.response == NULL || framebuffer_req.response->framebuffer_count < 1) {
|
||||
hal_hang();
|
||||
}
|
||||
BOOT_INFO.fb = FB_REQ.response->framebuffers[0];
|
||||
BOOT_INFO.fb = framebuffer_req.response->framebuffers[0];
|
||||
|
||||
struct limine_module_response *modulesres= MODULE_REQ.response;
|
||||
struct limine_module_response *modulesres= module_req.response;
|
||||
BOOT_INFO.modules = modulesres;
|
||||
|
||||
struct limine_paging_mode_response *pagingres = PAGING_REQ.response;
|
||||
struct limine_paging_mode_response *pagingres = paging_req.response;
|
||||
#if defined(__x86_64__)
|
||||
if (pagingres->mode != LIMINE_PAGING_MODE_X86_64_4LVL) {
|
||||
#endif
|
||||
hal_hang();
|
||||
}
|
||||
|
||||
struct limine_hhdm_response *hhdmres = HHDM_REQ.response;
|
||||
struct limine_hhdm_response *hhdmres = hhdm_req.response;
|
||||
BOOT_INFO.hhdm_off = hhdmres->offset;
|
||||
|
||||
struct limine_kernel_address_response *kernaddrres = KERN_ADDR_REQ.response;
|
||||
struct limine_kernel_address_response *kernaddrres = kernel_address_req.response;
|
||||
BOOT_INFO.kern_virtbase = kernaddrres->virtual_base;
|
||||
BOOT_INFO.kern_physbase = kernaddrres->physical_base;
|
||||
|
||||
struct limine_memmap_response *memmapres = MEMMAP_REQ.response;
|
||||
struct limine_memmap_response *memmapres = memmap_req.response;
|
||||
BOOT_INFO.memmap_entries = memmapres->entries;
|
||||
BOOT_INFO.memmap_entrycount = memmapres->entry_count;
|
||||
|
||||
@ -79,7 +63,7 @@ void bootinfo_init(void) {
|
||||
}
|
||||
}
|
||||
|
||||
struct limine_smp_response *smpres = SMP_REQ.response;
|
||||
struct limine_smp_response *smpres = smp_req.response;
|
||||
BOOT_INFO.smp = smpres;
|
||||
|
||||
BOOT_INFO.smp_bspindex = (uint64_t)(-1);
|
||||
@ -93,6 +77,6 @@ void bootinfo_init(void) {
|
||||
hal_hang();
|
||||
}
|
||||
|
||||
struct limine_rsdp_response *rsdpres = RSDP_REQ.response;
|
||||
struct limine_rsdp_response *rsdpres = rsdp_req.response;
|
||||
BOOT_INFO.rsdp = (size_t)rsdpres->address - BOOT_INFO.hhdm_off;
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ typedef struct {
|
||||
uint64_t smp_bspindex;
|
||||
LIMINE_PTR(struct limine_framebuffer *) fb;
|
||||
LIMINE_PTR(struct limine_module_response *) modules;
|
||||
LIMINE_PTR(struct limine_executable_file_response *) exec;
|
||||
} BootInfo;
|
||||
|
||||
extern BootInfo BOOT_INFO;
|
||||
|
Reference in New Issue
Block a user