/* Kernel command line */
u32_t cmdline;
/* Boot-Module list */
- u32_t mods_count;
+ u32_t mi_mods_count;
u32_t mods_addr;
union
{
struct multiboot_mmap_entry
{
u32_t size;
- u64_t addr;
- u64_t len;
+ u64_t mm_base_addr;
+ u64_t mm_length;
#define MULTIBOOT_MEMORY_AVAILABLE 1
#define MULTIBOOT_MEMORY_RESERVED 2
u32_t type;
#ifndef _TYPE_H
#define _TYPE_H
+
+#include <sys/types.h>
+
#include <machine/multiboot.h>
#ifndef _MINIX_SYS_CONFIG_H
#include <minix/sys_config.h>
#endif
-#include <sys/types.h>
#include <sys/sigtypes.h>
#include <stdint.h>
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);
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;
/* 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)
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;
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;
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;
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;
}
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 */
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);
* 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++) {
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];
}
}
.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
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);
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;
/* 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)
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);
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;
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");
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;
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++) {
*/
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
#include <string.h>
#include <minix/cpufeature.h>
+#include <sys/types.h>
#include <machine/multiboot.h>
#include "kernel/kernel.h"
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];
}
}
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) {
/* Obtain and parse memory from kernel environment. */
/* XXX Any memory chunk in excess of NR_MEMS is silently ignored. */
for(i = 0; i < MIN(MAXMEMMAP, NR_MEMS); i++) {
- mem_chunks[i].base = kernel_boot_info.memmap[i].addr;
- mem_chunks[i].size = kernel_boot_info.memmap[i].len;
+ mem_chunks[i].base = kernel_boot_info.memmap[i].mm_base_addr;
+ mem_chunks[i].size = kernel_boot_info.memmap[i].mm_length;
}
/* Round physical memory to clicks. Round start up, round end down. */
+#ifndef _MACHINE_MULTIBOOT_H
+#define _MACHINE_MULTIBOOT_H 1
+
/* $NetBSD: multiboot.h,v 1.8 2009/02/22 18:05:42 ahoka Exp $ */
/*-
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef __MULTIBOOT_H__
-#define __MULTIBOOT_H__
-
-#if !defined(_KERNEL) && defined(_STANDALONE)
/* --------------------------------------------------------------------- */
#define MULTIBOOT_HEADER_HAS_VBE 0x00000004
#define MULTIBOOT_HEADER_HAS_ADDR 0x00010000
+#ifndef __ASSEMBLY__
+
#if !defined(_LOCORE)
struct multiboot_header {
uint32_t mh_magic;
extern struct multiboot_header *Multiboot_Header;
#endif /* !defined(_LOCORE) && defined(_KERNEL) */
+#endif /* __ASSEMBLY__ */
+
/* --------------------------------------------------------------------- */
/*
#define MULTIBOOT_INFO_HAS_APM_TABLE 0x00000400
#define MULTIBOOT_INFO_HAS_VBE 0x00000800
+#ifndef __ASSEMBLY__
+
#if !defined(_LOCORE)
struct multiboot_info {
uint32_t mi_flags;
uint32_t mmo_reserved;
};
-#endif /* !defined(_LOCORE) */
+#endif
-/* --------------------------------------------------------------------- */
+#endif /* __ASSEMBLY__ */
-/*
- * Prototypes for public functions defined in multiboot.c.
- */
-#if !defined(_LOCORE) && defined(_KERNEL)
-void multiboot_pre_reloc(struct multiboot_info *);
-void multiboot_post_reloc(void);
-void multiboot_print_info(void);
-bool multiboot_ksyms_addsyms_elf(void);
-#endif /* !defined(_LOCORE) */
+#ifdef __minix
-/* --------------------------------------------------------------------- */
-#else /* !defined(_KERNEL) && defined(_STANDALONE) */
-/* LSC FIXME: OLD MINIX DEFINITION: should be removed and replace with
- definition above... */
-#define MULTIBOOT_HEADER_MAGIC 0x1BADB002
+#ifndef __ASSEMBLY__
+typedef struct multiboot_info multiboot_info_t;
+typedef struct multiboot_module multiboot_module_t;
+typedef struct multiboot_mmap multiboot_memory_map_t;
+#endif
-#define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002
+#define MULTIBOOT_MEMORY_AVAILABLE 1
+#define MULTIBOOT_MAX_MODS 20
-/* Must pass memory information to OS. */
-#define MULTIBOOT_PAGE_ALIGN 0x00000001
+#define mod_start mmo_start
+#define mod_end mmo_end
-#define MULTIBOOT_MEMORY_INFO 0x00000002
+#define mmap_addr mi_mmap_addr
+#define mmap_length mi_mmap_length
#define MULTIBOOT_VIDEO_MODE 0x00000004
-
-#define MULTIBOOT_AOUT_KLUDGE 0x00010000
-
-/* consts used for Multiboot pre-init */
-
#define MULTIBOOT_VIDEO_MODE_EGA 1
-
#define MULTIBOOT_VIDEO_BUFFER 0xB8000
-/* Usable lower memory chunk has a upper bound */
-#define MULTIBOOT_LOWER_MEM_MAX 0x7f800
-
#define MULTIBOOT_CONSOLE_LINES 25
#define MULTIBOOT_CONSOLE_COLS 80
-#define MULTIBOOT_VIDEO_BUFFER_BYTES \
- (MULTIBOOT_CONSOLE_LINES*MULTIBOOT_CONSOLE_COLS*2)
-
-#define MULTIBOOT_STACK_SIZE 4096
-#define MULTIBOOT_PARAM_BUF_SIZE 1024
-
-#define MULTIBOOT_MAX_MODS 20
-
-/* Flags to be set in the ’flags’ member of the multiboot info structure. */
-
-#define MULTIBOOT_INFO_MEMORY 0x00000001
-#define MULTIBOOT_INFO_MEM_MAP 0x00000040
-
-/* Is there a boot device set? */
-#define MULTIBOOT_INFO_BOOTDEV 0x00000002
-
-/* Is the command-line defined? */
-#define MULTIBOOT_INFO_CMDLINE 0x00000004
-
-/* Are there modules to do something with? */
-#define MULTIBOOT_INFO_MODS 0x00000008
-
-#define MULTIBOOT_HIGH_MEM_BASE 0x100000
+#endif
-#ifndef __ASSEMBLY__
-
-#include <sys/types.h>
-/* The symbol table for a.out. */
-struct multiboot_aout_symbol_table
-{
- u32_t tabsize;
- u32_t strsize;
- u32_t addr;
- u32_t reserved;
-};
-/* The section header table for ELF. */
-struct multiboot_elf_section_header_table
-{
- u32_t num;
- u32_t size;
- u32_t addr;
- u32_t shndx;
-};
+/* --------------------------------------------------------------------- */
-typedef struct multiboot_elf_section_header_table multiboot_elf_section_header_table_t;
-typedef struct multiboot_aout_symbol_table multiboot_aout_symbol_table_t;
-
-struct multiboot_info
-{
- /* Multiboot info version number */
- u32_t flags;
- /* Available memory from BIOS */
- u32_t mem_lower_unused; /* minix uses memmap instead */
- u32_t mem_upper_unused;
- /* "root" partition */
- u32_t boot_device;
- /* Kernel command line */
- u32_t cmdline;
- /* Boot-Module list */
- u32_t mods_count;
- u32_t mods_addr;
- union
- {
- multiboot_aout_symbol_table_t aout_sym;
- multiboot_elf_section_header_table_t elf_sec;
- } u;
- /* Memory Mapping buffer */
- u32_t mmap_length;
- u32_t mmap_addr;
- /* Drive Info buffer */
- u32_t drives_length;
- u32_t drives_addr;
- /* ROM configuration table */
- u32_t config_table;
- /* Boot Loader Name */
- u32_t boot_loader_name;
- /* APM table */
- u32_t apm_table;
- /* Video */
- u32_t vbe_control_info;
- u32_t vbe_mode_info;
- u16_t vbe_mode;
- u16_t vbe_interface_seg;
- u16_t vbe_interface_off;
- u16_t vbe_interface_len;
-};
-typedef struct multiboot_info multiboot_info_t;
+/*
+ * Prototypes for public functions defined in multiboot.c.
+ */
+#if !defined(_LOCORE) && defined(_KERNEL)
+void multiboot_pre_reloc(struct multiboot_info *);
+void multiboot_post_reloc(void);
+void multiboot_print_info(void);
+bool multiboot_ksyms_addsyms_elf(void);
+#endif /* !defined(_LOCORE) */
-struct multiboot_mod_list
-{
- /* Memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */
- u32_t mod_start;
- u32_t mod_end;
- /* Module command line */
- u32_t cmdline;
- /* Pad struct to 16 bytes (must be zero) */
- u32_t pad;
-};
-typedef struct multiboot_mod_list multiboot_module_t;
+/* --------------------------------------------------------------------- */
-#define MULTIBOOT_MEMORY_AVAILABLE 1
-#define MULTIBOOT_MEMORY_RESERVED 2
-struct multiboot_mmap_entry
-{
- u32_t size;
- u64_t addr;
- u64_t len;
-#define MULTIBOOT_MEMORY_AVAILABLE 1
-#define MULTIBOOT_MEMORY_RESERVED 2
- u32_t type;
-} __attribute__((packed));
-typedef struct multiboot_mmap_entry multiboot_memory_map_t;
+#ifdef __minix
+#define MULTIBOOT_PARAM_BUF_SIZE 1024
+#endif
-#endif /* __ASSEMBLY__ */
-#endif /* !defined(_KERNEL) && defined(_STANDALONE) */
-#endif /* __MULTIBOOT_H__ */
+#endif