#ifndef BOOTINFO_BOOTINFO_H_
#define BOOTINFO_BOOTINFO_H_

#include <stdint.h>
#include <stddef.h>
#include <limine.h>

extern uint64_t kernel_text_start, kernel_text_end,
       kernel_rodata_start, kernel_rodata_end,
       kernel_data_start, kernel_data_end,
       kernel_start, kernel_end;

typedef struct {
  // Higher Half Direct Map: https://github.com/dreamportdev/Osdev-Notes/blob/master/01_Build_Process/02_Boot_Protocols.md#limine-protocol
  size_t hhdm_off;
  size_t kern_virtbase;
  size_t kern_physbase;
  size_t rsdp;
  size_t memmap_total;
  uint64_t memmap_entrycount;
  LIMINE_PTR(struct limine_memmap_entry **) memmap_entries;
  LIMINE_PTR(struct limine_smp_response *) smp;
  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;

#define IS_IN_HHDM(a) ((size_t)a >= BOOT_INFO.hhdm_off \
    && (size_t)a <= BOOT_INFO.hhdm_off + BOOT_INFO.memmap_total)

void bootinfo_init(void);

#endif // BOOTINFO_BOOTINFO_H_
