multiboot.c 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* vim: tabstop=4 shiftwidth=4 noexpandtab
  2. * This file is part of ToaruOS and is released under the terms
  3. * of the NCSA / University of Illinois License - see LICENSE.md
  4. * Copyright (C) 2011-2018 K. Lange
  5. *
  6. * Multiboot (GRUB) handler
  7. */
  8. #include <kernel/system.h>
  9. #include <kernel/logging.h>
  10. #include <kernel/multiboot.h>
  11. char * ramdisk = NULL;
  12. struct multiboot * mboot_ptr = NULL;
  13. struct multiboot *
  14. copy_multiboot(
  15. struct multiboot *mboot_ptr
  16. ) {
  17. struct multiboot *new_header = (struct multiboot *)kmalloc(sizeof(struct multiboot));
  18. memcpy(new_header, mboot_ptr, sizeof(struct multiboot));
  19. return new_header;
  20. }
  21. void
  22. dump_multiboot(
  23. struct multiboot *mboot_ptr
  24. ) {
  25. debug_print(INFO, "MULTIBOOT header at 0x%x:", (uintptr_t)mboot_ptr);
  26. debug_print(INFO, "Flags : 0x%x", mboot_ptr->flags);
  27. debug_print(INFO, "Mem Lo: 0x%x", mboot_ptr->mem_lower);
  28. debug_print(INFO, "Mem Hi: 0x%x", mboot_ptr->mem_upper);
  29. debug_print(INFO, "Boot d: 0x%x", mboot_ptr->boot_device);
  30. debug_print(INFO, "cmdlin: 0x%x", mboot_ptr->cmdline);
  31. debug_print(INFO, "Mods : 0x%x", mboot_ptr->mods_count);
  32. debug_print(INFO, "Addr : 0x%x", mboot_ptr->mods_addr);
  33. debug_print(INFO, "ELF n : 0x%x", mboot_ptr->num);
  34. debug_print(INFO, "ELF s : 0x%x", mboot_ptr->size);
  35. debug_print(INFO, "ELF a : 0x%x", mboot_ptr->addr);
  36. debug_print(INFO, "ELF h : 0x%x", mboot_ptr->shndx);
  37. debug_print(INFO, "MMap : 0x%x", mboot_ptr->mmap_length);
  38. debug_print(INFO, "Addr : 0x%x", mboot_ptr->mmap_addr);
  39. debug_print(INFO, "Drives: 0x%x", mboot_ptr->drives_length);
  40. debug_print(INFO, "Addr : 0x%x", mboot_ptr->drives_addr);
  41. debug_print(INFO, "Config: 0x%x", mboot_ptr->config_table);
  42. debug_print(INFO, "Loader: 0x%x", mboot_ptr->boot_loader_name);
  43. debug_print(INFO, "APM : 0x%x", mboot_ptr->apm_table);
  44. debug_print(INFO, "VBE Co: 0x%x", mboot_ptr->vbe_control_info);
  45. debug_print(INFO, "VBE Mo: 0x%x", mboot_ptr->vbe_mode_info);
  46. debug_print(INFO, "VBE In: 0x%x", mboot_ptr->vbe_mode);
  47. debug_print(INFO, "VBE se: 0x%x", mboot_ptr->vbe_interface_seg);
  48. debug_print(INFO, "VBE of: 0x%x", mboot_ptr->vbe_interface_off);
  49. debug_print(INFO, "VBE le: 0x%x", mboot_ptr->vbe_interface_len);
  50. if (mboot_ptr->flags & (1 << 2)) {
  51. debug_print(INFO, "Started with: %s", (char *)mboot_ptr->cmdline);
  52. }
  53. if (mboot_ptr->flags & (1 << 9)) {
  54. debug_print(INFO, "Booted from: %s", (char *)mboot_ptr->boot_loader_name);
  55. }
  56. if (mboot_ptr->flags & (1 << 0)) {
  57. debug_print(INFO, "%dkB lower memory", mboot_ptr->mem_lower);
  58. int mem_mb = mboot_ptr->mem_upper / 1024;
  59. debug_print(INFO, "%dkB higher memory (%dMB)", mboot_ptr->mem_upper, mem_mb);
  60. }
  61. if (mboot_ptr->flags & (1 << 3)) {
  62. debug_print(INFO, "Found %d module(s).", mboot_ptr->mods_count);
  63. if (mboot_ptr->mods_count > 0) {
  64. uint32_t i;
  65. for (i = 0; i < mboot_ptr->mods_count; ++i ) {
  66. uint32_t module_start = *((uint32_t*)mboot_ptr->mods_addr + 8 * i);
  67. uint32_t module_end = *(uint32_t*)(mboot_ptr->mods_addr + 8 * i + 4);
  68. debug_print(INFO, "Module %d is at 0x%x:0x%x", i+1, module_start, module_end);
  69. }
  70. }
  71. }
  72. }