x86 multiboot.h
Change-Id: I245564a98fb9e2572b88f8feb7411ad6800a543c
This commit is contained in:
@@ -26,7 +26,7 @@ void print_memmap(kinfo_t *cbi)
|
||||
int m;
|
||||
assert(cbi->mmap_size < MAXMEMMAP);
|
||||
for(m = 0; m < cbi->mmap_size; m++) {
|
||||
phys_bytes addr = cbi->memmap[m].addr, endit = cbi->memmap[m].addr + cbi->memmap[m].len;
|
||||
phys_bytes addr = cbi->memmap[m].mm_base_addr, endit = cbi->memmap[m].mm_base_addr + cbi->memmap[m].mm_length;
|
||||
printf("%08lx-%08lx ",addr, endit);
|
||||
}
|
||||
printf("\nsize %08lx\n", cbi->mmap_size);
|
||||
@@ -46,8 +46,8 @@ void cut_memmap(kinfo_t *cbi, phys_bytes start, phys_bytes end)
|
||||
|
||||
for(m = 0; m < cbi->mmap_size; m++) {
|
||||
phys_bytes substart = start, subend = end;
|
||||
phys_bytes memaddr = cbi->memmap[m].addr,
|
||||
memend = cbi->memmap[m].addr + cbi->memmap[m].len;
|
||||
phys_bytes memaddr = cbi->memmap[m].mm_base_addr,
|
||||
memend = cbi->memmap[m].mm_base_addr + cbi->memmap[m].mm_length;
|
||||
|
||||
/* adjust cut range to be a subset of the free memory */
|
||||
if(substart < memaddr) substart = memaddr;
|
||||
@@ -57,7 +57,7 @@ void cut_memmap(kinfo_t *cbi, phys_bytes start, phys_bytes end)
|
||||
/* if there is any overlap, forget this one and add
|
||||
* 1-2 subranges back
|
||||
*/
|
||||
cbi->memmap[m].addr = cbi->memmap[m].len = 0;
|
||||
cbi->memmap[m].mm_base_addr = cbi->memmap[m].mm_length = 0;
|
||||
if(substart > memaddr)
|
||||
add_memmap(cbi, memaddr, substart-memaddr);
|
||||
if(subend < memend)
|
||||
@@ -91,11 +91,11 @@ void add_memmap(kinfo_t *cbi, u64_t addr, u64_t len)
|
||||
|
||||
for(m = 0; m < MAXMEMMAP; m++) {
|
||||
phys_bytes highmark;
|
||||
if(cbi->memmap[m].len) {
|
||||
if(cbi->memmap[m].mm_length) {
|
||||
continue;
|
||||
}
|
||||
cbi->memmap[m].addr = addr;
|
||||
cbi->memmap[m].len = len;
|
||||
cbi->memmap[m].mm_base_addr = addr;
|
||||
cbi->memmap[m].mm_length = len;
|
||||
cbi->memmap[m].type = MULTIBOOT_MEMORY_AVAILABLE;
|
||||
if(m >= cbi->mmap_size) {
|
||||
cbi->mmap_size = m+1;
|
||||
@@ -136,16 +136,16 @@ phys_bytes pg_alloc_page(kinfo_t *cbi)
|
||||
|
||||
for(m = 0; m < cbi->mmap_size; m++) {
|
||||
mmap = &cbi->memmap[m];
|
||||
if(!mmap->len) {
|
||||
if(!mmap->mm_length) {
|
||||
continue;
|
||||
}
|
||||
assert(mmap->len > 0);
|
||||
assert(!(mmap->len % ARM_PAGE_SIZE));
|
||||
assert(!(mmap->addr % ARM_PAGE_SIZE));
|
||||
assert(mmap->mm_length > 0);
|
||||
assert(!(mmap->mm_length % ARM_PAGE_SIZE));
|
||||
assert(!(mmap->mm_base_addr % ARM_PAGE_SIZE));
|
||||
|
||||
u32_t addr = mmap->addr;
|
||||
mmap->addr += ARM_PAGE_SIZE;
|
||||
mmap->len -= ARM_PAGE_SIZE;
|
||||
u32_t addr = mmap->mm_base_addr;
|
||||
mmap->mm_base_addr += ARM_PAGE_SIZE;
|
||||
mmap->mm_length -= ARM_PAGE_SIZE;
|
||||
|
||||
cbi->kernel_allocated_bytes_dynamic += ARM_PAGE_SIZE;
|
||||
|
||||
|
||||
@@ -187,7 +187,7 @@ void setup_mbi(multiboot_info_t *mbi, char *bootargs)
|
||||
memset(mbi, 0, sizeof(*mbi));
|
||||
mbi->flags = MULTIBOOT_INFO_MODS | MULTIBOOT_INFO_MEM_MAP |
|
||||
MULTIBOOT_INFO_CMDLINE;
|
||||
mbi->mods_count = MB_MODS_NR;
|
||||
mbi->mi_mods_count = MB_MODS_NR;
|
||||
mbi->mods_addr = (u32_t)&mb_modlist;
|
||||
|
||||
int i;
|
||||
@@ -205,8 +205,8 @@ void setup_mbi(multiboot_info_t *mbi, char *bootargs)
|
||||
mbi->mmap_length = sizeof(mb_memmap);
|
||||
|
||||
mb_memmap.size = sizeof(multiboot_memory_map_t);
|
||||
mb_memmap.addr = MB_MMAP_START;
|
||||
mb_memmap.len = MB_MMAP_SIZE;
|
||||
mb_memmap.mm_base_addr = MB_MMAP_START;
|
||||
mb_memmap.mm_length = MB_MMAP_SIZE;
|
||||
mb_memmap.type = MULTIBOOT_MEMORY_AVAILABLE;
|
||||
}
|
||||
|
||||
@@ -286,10 +286,10 @@ void get_parameters(kinfo_t *cbi, char *bootargs)
|
||||
assert(!(cbi->bootstrap_start % ARM_PAGE_SIZE));
|
||||
cbi->bootstrap_len = rounddown(cbi->bootstrap_len, ARM_PAGE_SIZE);
|
||||
assert(mbi->flags & MULTIBOOT_INFO_MODS);
|
||||
assert(mbi->mods_count < MULTIBOOT_MAX_MODS);
|
||||
assert(mbi->mods_count > 0);
|
||||
assert(mbi->mi_mods_count < MULTIBOOT_MAX_MODS);
|
||||
assert(mbi->mi_mods_count > 0);
|
||||
memcpy(&cbi->module_list, (void *) mbi->mods_addr,
|
||||
mbi->mods_count * sizeof(multiboot_module_t));
|
||||
mbi->mi_mods_count * sizeof(multiboot_module_t));
|
||||
|
||||
memset(cbi->memmap, 0, sizeof(cbi->memmap));
|
||||
/* mem_map has a variable layout */
|
||||
@@ -300,7 +300,7 @@ void get_parameters(kinfo_t *cbi, char *bootargs)
|
||||
mmap = (multiboot_memory_map_t *)
|
||||
((unsigned long) mmap + mmap->size + sizeof(mmap->size))) {
|
||||
if(mmap->type != MULTIBOOT_MEMORY_AVAILABLE) continue;
|
||||
add_memmap(cbi, mmap->addr, mmap->len);
|
||||
add_memmap(cbi, mmap->mm_base_addr, mmap->mm_length);
|
||||
}
|
||||
} else {
|
||||
assert(mbi->flags & MULTIBOOT_INFO_MEMORY);
|
||||
@@ -312,11 +312,11 @@ void get_parameters(kinfo_t *cbi, char *bootargs)
|
||||
* with each other. Pretend the kernel is an extra module for a
|
||||
* second.
|
||||
*/
|
||||
k = mbi->mods_count;
|
||||
k = mbi->mi_mods_count;
|
||||
assert(k < MULTIBOOT_MAX_MODS);
|
||||
cbi->module_list[k].mod_start = kernbase;
|
||||
cbi->module_list[k].mod_end = kernbase + kernsize;
|
||||
cbi->mods_with_kernel = mbi->mods_count+1;
|
||||
cbi->mods_with_kernel = mbi->mi_mods_count+1;
|
||||
cbi->kern_mod = k;
|
||||
|
||||
for(m = 0; m < cbi->mods_with_kernel; m++) {
|
||||
|
||||
@@ -64,7 +64,7 @@ multiboot_module_t *bootmod(int pnr)
|
||||
p = i - NR_TASKS;
|
||||
if(image[i].proc_nr == pnr) {
|
||||
assert(p < MULTIBOOT_MAX_MODS);
|
||||
assert(p < kinfo.mbi.mods_count);
|
||||
assert(p < kinfo.mbi.mi_mods_count);
|
||||
return &kinfo.module_list[p];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ MINIX:
|
||||
|
||||
.balign 8
|
||||
|
||||
#define MULTIBOOT_FLAGS (MULTIBOOT_MEMORY_INFO | MULTIBOOT_PAGE_ALIGN)
|
||||
#define MULTIBOOT_FLAGS (MULTIBOOT_HEADER_WANT_MEMORY | MULTIBOOT_HEADER_MODS_ALIGNED)
|
||||
|
||||
multiboot_magic:
|
||||
.long MULTIBOOT_HEADER_MAGIC
|
||||
|
||||
@@ -23,7 +23,7 @@ void print_memmap(kinfo_t *cbi)
|
||||
int m;
|
||||
assert(cbi->mmap_size < MAXMEMMAP);
|
||||
for(m = 0; m < cbi->mmap_size; m++) {
|
||||
phys_bytes addr = cbi->memmap[m].addr, endit = cbi->memmap[m].addr + cbi->memmap[m].len;
|
||||
phys_bytes addr = cbi->memmap[m].mm_base_addr, endit = cbi->memmap[m].mm_base_addr + cbi->memmap[m].mm_length;
|
||||
printf("%08lx-%08lx ",addr, endit);
|
||||
}
|
||||
printf("\nsize %08lx\n", cbi->mmap_size);
|
||||
@@ -43,8 +43,8 @@ void cut_memmap(kinfo_t *cbi, phys_bytes start, phys_bytes end)
|
||||
|
||||
for(m = 0; m < cbi->mmap_size; m++) {
|
||||
phys_bytes substart = start, subend = end;
|
||||
phys_bytes memaddr = cbi->memmap[m].addr,
|
||||
memend = cbi->memmap[m].addr + cbi->memmap[m].len;
|
||||
phys_bytes memaddr = cbi->memmap[m].mm_base_addr,
|
||||
memend = cbi->memmap[m].mm_base_addr + cbi->memmap[m].mm_length;
|
||||
|
||||
/* adjust cut range to be a subset of the free memory */
|
||||
if(substart < memaddr) substart = memaddr;
|
||||
@@ -54,7 +54,7 @@ void cut_memmap(kinfo_t *cbi, phys_bytes start, phys_bytes end)
|
||||
/* if there is any overlap, forget this one and add
|
||||
* 1-2 subranges back
|
||||
*/
|
||||
cbi->memmap[m].addr = cbi->memmap[m].len = 0;
|
||||
cbi->memmap[m].mm_base_addr = cbi->memmap[m].mm_length = 0;
|
||||
if(substart > memaddr)
|
||||
add_memmap(cbi, memaddr, substart-memaddr);
|
||||
if(subend < memend)
|
||||
@@ -74,8 +74,8 @@ phys_bytes alloc_lowest(kinfo_t *cbi, phys_bytes len)
|
||||
assert(kernel_may_alloc);
|
||||
|
||||
for(m = 0; m < cbi->mmap_size; m++) {
|
||||
if(cbi->memmap[m].len < len) continue;
|
||||
if(cbi->memmap[m].addr < lowest) lowest = cbi->memmap[m].addr;
|
||||
if(cbi->memmap[m].mm_length < len) continue;
|
||||
if(cbi->memmap[m].mm_base_addr < lowest) lowest = cbi->memmap[m].mm_base_addr;
|
||||
}
|
||||
assert(lowest != EMPTY);
|
||||
cut_memmap(cbi, lowest, len);
|
||||
@@ -103,10 +103,10 @@ void add_memmap(kinfo_t *cbi, u64_t addr, u64_t len)
|
||||
|
||||
for(m = 0; m < MAXMEMMAP; m++) {
|
||||
phys_bytes highmark;
|
||||
if(cbi->memmap[m].len) continue;
|
||||
cbi->memmap[m].addr = addr;
|
||||
cbi->memmap[m].len = len;
|
||||
cbi->memmap[m].type = MULTIBOOT_MEMORY_AVAILABLE;
|
||||
if(cbi->memmap[m].mm_length) continue;
|
||||
cbi->memmap[m].mm_base_addr = addr;
|
||||
cbi->memmap[m].mm_length = len;
|
||||
cbi->memmap[m].mm_type = MULTIBOOT_MEMORY_AVAILABLE;
|
||||
if(m >= cbi->mmap_size)
|
||||
cbi->mmap_size = m+1;
|
||||
highmark = addr + len;
|
||||
@@ -144,16 +144,16 @@ phys_bytes pg_alloc_page(kinfo_t *cbi)
|
||||
|
||||
for(m = cbi->mmap_size-1; m >= 0; m--) {
|
||||
mmap = &cbi->memmap[m];
|
||||
if(!mmap->len) continue;
|
||||
assert(mmap->len > 0);
|
||||
assert(!(mmap->len % I386_PAGE_SIZE));
|
||||
assert(!(mmap->addr % I386_PAGE_SIZE));
|
||||
if(!mmap->mm_length) continue;
|
||||
assert(mmap->mm_length > 0);
|
||||
assert(!(mmap->mm_length % I386_PAGE_SIZE));
|
||||
assert(!(mmap->mm_base_addr % I386_PAGE_SIZE));
|
||||
|
||||
mmap->len -= I386_PAGE_SIZE;
|
||||
mmap->mm_length -= I386_PAGE_SIZE;
|
||||
|
||||
cbi->kernel_allocated_bytes_dynamic += I386_PAGE_SIZE;
|
||||
|
||||
return mmap->addr + mmap->len;
|
||||
return mmap->mm_base_addr + mmap->mm_length;
|
||||
}
|
||||
|
||||
panic("can't find free memory");
|
||||
|
||||
@@ -129,12 +129,12 @@ void get_parameters(u32_t ebx, kinfo_t *cbi)
|
||||
cbi->serial_debug_baud = 115200;
|
||||
|
||||
/* parse boot command line */
|
||||
if (mbi->flags&MULTIBOOT_INFO_CMDLINE) {
|
||||
if (mbi->mi_flags & MULTIBOOT_INFO_HAS_CMDLINE) {
|
||||
static char var[BUF];
|
||||
static char value[BUF];
|
||||
|
||||
/* Override values with cmdline argument */
|
||||
memcpy(cmdline, (void *) mbi->cmdline, BUF);
|
||||
memcpy(cmdline, (void *) mbi->mi_cmdline, BUF);
|
||||
p = cmdline;
|
||||
while (*p) {
|
||||
var_i = 0;
|
||||
@@ -172,38 +172,38 @@ void get_parameters(u32_t ebx, kinfo_t *cbi)
|
||||
|
||||
assert(!(cbi->bootstrap_start % I386_PAGE_SIZE));
|
||||
cbi->bootstrap_len = rounddown(cbi->bootstrap_len, I386_PAGE_SIZE);
|
||||
assert(mbi->flags & MULTIBOOT_INFO_MODS);
|
||||
assert(mbi->mods_count < MULTIBOOT_MAX_MODS);
|
||||
assert(mbi->mods_count > 0);
|
||||
memcpy(&cbi->module_list, (void *) mbi->mods_addr,
|
||||
mbi->mods_count * sizeof(multiboot_module_t));
|
||||
assert(mbi->mi_flags & MULTIBOOT_INFO_HAS_MODS);
|
||||
assert(mbi->mi_mods_count < MULTIBOOT_MAX_MODS);
|
||||
assert(mbi->mi_mods_count > 0);
|
||||
memcpy(&cbi->module_list, (void *) mbi->mi_mods_addr,
|
||||
mbi->mi_mods_count * sizeof(multiboot_module_t));
|
||||
|
||||
memset(cbi->memmap, 0, sizeof(cbi->memmap));
|
||||
/* mem_map has a variable layout */
|
||||
if(mbi->flags & MULTIBOOT_INFO_MEM_MAP) {
|
||||
if(mbi->mi_flags & MULTIBOOT_INFO_HAS_MMAP) {
|
||||
cbi->mmap_size = 0;
|
||||
for (mmap = (multiboot_memory_map_t *) mbi->mmap_addr;
|
||||
(unsigned long) mmap < mbi->mmap_addr + mbi->mmap_length;
|
||||
mmap = (multiboot_memory_map_t *)
|
||||
((unsigned long) mmap + mmap->size + sizeof(mmap->size))) {
|
||||
if(mmap->type != MULTIBOOT_MEMORY_AVAILABLE) continue;
|
||||
add_memmap(cbi, mmap->addr, mmap->len);
|
||||
((unsigned long) mmap + mmap->mm_size + sizeof(mmap->mm_size))) {
|
||||
if(mmap->mm_type != MULTIBOOT_MEMORY_AVAILABLE) continue;
|
||||
add_memmap(cbi, mmap->mm_base_addr, mmap->mm_length);
|
||||
}
|
||||
} else {
|
||||
assert(mbi->flags & MULTIBOOT_INFO_MEMORY);
|
||||
add_memmap(cbi, 0, mbi->mem_lower_unused*1024);
|
||||
add_memmap(cbi, 0x100000, mbi->mem_upper_unused*1024);
|
||||
assert(mbi->mi_flags & MULTIBOOT_INFO_HAS_MEMORY);
|
||||
add_memmap(cbi, 0, mbi->mi_mem_lower*1024);
|
||||
add_memmap(cbi, 0x100000, mbi->mi_mem_upper*1024);
|
||||
}
|
||||
|
||||
/* Sanity check: the kernel nor any of the modules may overlap
|
||||
* with each other. Pretend the kernel is an extra module for a
|
||||
* second.
|
||||
*/
|
||||
k = mbi->mods_count;
|
||||
k = mbi->mi_mods_count;
|
||||
assert(k < MULTIBOOT_MAX_MODS);
|
||||
cbi->module_list[k].mod_start = kernbase;
|
||||
cbi->module_list[k].mod_end = kernbase + kernsize;
|
||||
cbi->mods_with_kernel = mbi->mods_count+1;
|
||||
cbi->mods_with_kernel = mbi->mi_mods_count+1;
|
||||
cbi->kern_mod = k;
|
||||
|
||||
for(m = 0; m < cbi->mods_with_kernel; m++) {
|
||||
@@ -229,7 +229,7 @@ kinfo_t *pre_init(u32_t magic, u32_t ebx)
|
||||
*/
|
||||
get_parameters(ebx, &kinfo);
|
||||
|
||||
assert(magic == MULTIBOOT_BOOTLOADER_MAGIC);
|
||||
assert(magic == MULTIBOOT_INFO_MAGIC);
|
||||
|
||||
/* Make and load a pagetable that will map the kernel
|
||||
* to where it should be; but first a 1:1 mapping so
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <minix/cpufeature.h>
|
||||
#include <sys/types.h>
|
||||
#include <machine/multiboot.h>
|
||||
#include "kernel/kernel.h"
|
||||
|
||||
@@ -286,7 +287,7 @@ multiboot_module_t *bootmod(int pnr)
|
||||
p = i - NR_TASKS;
|
||||
if(image[i].proc_nr == pnr) {
|
||||
assert(p < MULTIBOOT_MAX_MODS);
|
||||
assert(p < kinfo.mbi.mods_count);
|
||||
assert(p < kinfo.mbi.mi_mods_count);
|
||||
return &kinfo.module_list[p];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,9 +152,9 @@ void kmain(kinfo_t *local_cbi)
|
||||
|
||||
proc_init();
|
||||
|
||||
if(NR_BOOT_MODULES != kinfo.mbi.mods_count)
|
||||
if(NR_BOOT_MODULES != kinfo.mbi.mi_mods_count)
|
||||
panic("expecting %d boot processes/modules, found %d",
|
||||
NR_BOOT_MODULES, kinfo.mbi.mods_count);
|
||||
NR_BOOT_MODULES, kinfo.mbi.mi_mods_count);
|
||||
|
||||
/* Set up proc table entries for processes in boot image. */
|
||||
for (i=0; i < NR_BOOT_PROCS; ++i) {
|
||||
|
||||
Reference in New Issue
Block a user