void grub_machine_init (void) { #ifdef GRUB_MACHINE_QEMU grub_qemu_init_cirrus (); #endif /* Initialize the console as early as possible. */ grub_vga_text_init (); auto int NESTED_FUNC_ATTR heap_init (grub_uint64_t, grub_uint64_t, grub_memory_type_t); int NESTED_FUNC_ATTR heap_init (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type) { #if GRUB_CPU_SIZEOF_VOID_P == 4 /* Restrict ourselves to 32-bit memory space. */ if (addr > GRUB_ULONG_MAX) return 0; if (addr + size > GRUB_ULONG_MAX) size = GRUB_ULONG_MAX - addr; #endif if (type != GRUB_MEMORY_AVAILABLE) return 0; /* Avoid the lower memory. */ if (addr < GRUB_MEMORY_MACHINE_LOWER_SIZE) { if (addr + size <= GRUB_MEMORY_MACHINE_LOWER_SIZE) return 0; else { size -= GRUB_MEMORY_MACHINE_LOWER_SIZE - addr; addr = GRUB_MEMORY_MACHINE_LOWER_SIZE; } } grub_mm_init_region ((void *) (grub_addr_t) addr, (grub_size_t) size); return 0; } #if defined (GRUB_MACHINE_MULTIBOOT) || defined (GRUB_MACHINE_QEMU) grub_machine_mmap_init (); #endif grub_machine_mmap_iterate (heap_init); grub_tsc_init (); }
void grub_machine_init (void) { grub_modbase = ALIGN_UP((grub_addr_t) _end + GRUB_KERNEL_MACHINE_MOD_GAP, GRUB_KERNEL_MACHINE_MOD_ALIGN); grub_ieee1275_init (); grub_console_init_early (); grub_claim_heap (); grub_console_init_lately (); grub_ofdisk_init (); grub_parse_cmdline (); #ifdef __i386__ grub_tsc_init (); #else grub_install_get_time_ms (grub_rtc_get_time_ms); #endif }
void grub_machine_init (void) { int i; int grub_lower_mem; /* Initialize the console as early as possible. */ grub_console_init (); grub_lower_mem = grub_get_conv_memsize () << 10; /* Sanity check. */ if (grub_lower_mem < GRUB_MEMORY_MACHINE_RESERVED_END) grub_fatal ("too small memory"); /* FIXME: This prevents loader/i386/linux.c from using low memory. When our heap implements support for requesting a chunk in low memory, this should no longer be a problem. */ #if 0 /* Add the lower memory into free memory. */ if (grub_lower_mem >= GRUB_MEMORY_MACHINE_RESERVED_END) add_mem_region (GRUB_MEMORY_MACHINE_RESERVED_END, grub_lower_mem - GRUB_MEMORY_MACHINE_RESERVED_END); #endif auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_memory_type_t); int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type) { /* Avoid the lower memory. */ if (addr < 0x100000) { if (size <= 0x100000 - addr) return 0; size -= 0x100000 - addr; addr = 0x100000; } /* Ignore >4GB. */ if (addr <= 0xFFFFFFFF && type == GRUB_MEMORY_AVAILABLE) { grub_size_t len; len = (grub_size_t) ((addr + size > 0xFFFFFFFF) ? 0xFFFFFFFF - addr : size); add_mem_region (addr, len); } return 0; } grub_machine_mmap_iterate (hook); compact_mem_regions (); for (i = 0; i < num_regions; i++) grub_mm_init_region ((void *) mem_regions[i].addr, mem_regions[i].size); grub_tsc_init (); }