#include <stdbool.h>
#include <serial.h>
#include <printf.h>
#include <paging.h>
#include <video.h>
#include <acpi.h>

void panic() { // will fill with debugging info latter
  printf("Kernel panic!\n");
  for(;;);
}


void main() {
  if(!(init_serial(COM1))) {
    printf("\nKernal started on CPU 1!\n"); // will detect cpu later
  }

  rsdp_t *rsdp;
  struct memory_table *table = (struct memory_table *)&_meminfo_loc;
  struct vbe_infoblock *vbe_info = (struct vbe_infoblock *)0x500;
  debug_print_memory();

  rsdp = find_RSDP();
  if(!(rsdp)) {
    printf("Couldn't find the RSDP... uhh, not sure what to do now.\n");
    panic();
  }
  dump_video();
  
  if(rsdp->v1.version) { 
    map_page(0x200000, (rsdp->v2.xsdt_addr / 0x1000) * 0x1000, PAGE_SIZE_4K);
  }
  else {
    map_page(0x200000, (rsdp->v1.rsdt_addr / 0x1000) * 0x1000, PAGE_SIZE_4K);
    struct acpi_header *acpi = (struct acpi_header *)((uint64_t)0x200000 + (rsdp->v1.rsdt_addr % 0x1000));
  }

  printf("kernel is done, you can ignore this panic\n");
  panic();

}
