1 #include "config.h" 2 #include "kernel/kernel.h" 3 #include "arch/common/elf_boot.h" 4 #include "libopenbios/sys_info.h" 5 #include "context.h" 6 #include "boot.h" 7 8 #define printf printk 9 #ifdef CONFIG_DEBUG_BOOT 10 #define debug printk 11 #else 12 #define debug(x...) 13 #endif 14 15 uint64_t qemu_mem_size; 16 unsigned long va_shift; 17 18 void collect_multiboot_info(struct sys_info *); 19 collect_sys_info(struct sys_info * info)20void collect_sys_info(struct sys_info *info) 21 { 22 int i; 23 unsigned long long total = 0; 24 struct memrange *mmap; 25 26 /* Pick up parameters given by bootloader to us */ 27 //info->boot_type = boot_ctx->eax; 28 //info->boot_data = boot_ctx->ebx; 29 info->boot_arg = boot_ctx->param[0]; 30 //debug("boot eax = %#lx\n", info->boot_type); 31 //debug("boot ebx = %#lx\n", info->boot_data); 32 info->boot_type = ELF_BHDR_MAGIC; 33 info->boot_data = virt_to_phys(&elf_image_notes); 34 debug("boot arg = %#lx\n", info->boot_arg); 35 36 collect_elfboot_info(info); 37 #ifdef CONFIG_LINUXBIOS 38 collect_linuxbios_info(info); 39 #endif 40 #ifdef CONFIG_IMAGE_ELF_MULTIBOOT 41 collect_multiboot_info(info); 42 #endif 43 44 if (!info->memrange) { 45 info->n_memranges = 1; 46 info->memrange = malloc(1 * sizeof(struct memrange)); 47 info->memrange[0].base = 0; 48 info->memrange[0].size = qemu_mem_size; 49 } 50 51 debug("\n"); 52 mmap=info->memrange; 53 for (i = 0; i < info->n_memranges; i++) { 54 debug("%08lx-", (long)mmap[i].base); 55 debug("%08lx\n", (long)mmap[i].base + (long)mmap[i].size); 56 total += mmap[i].size; 57 } 58 debug("RAM %ld MB\n", (long)total >> 20); 59 } 60