Import backup from 2004-07-10

This commit is contained in:
Josh Holtrop 2004-07-10 22:00:00 -04:00
parent 0729754659
commit 872d562d6a
6 changed files with 74 additions and 16 deletions

View File

@ -13,8 +13,9 @@ all:
clean:
make -C kernel clean
make -C include clean
# make -C rmmod clean
- rm *~
- rm *~ hos.flp
grub:

BIN
hos.flp

Binary file not shown.

View File

@ -4,7 +4,13 @@
#include "multiboot.h"
#define LINK_ADDRESS 0xC0000000
#define VIRT_OFFSET 0xC0000000
#define MAX_MODULES 16
#define MAX_MMAP 16
typedef unsigned int u32_t;
typedef unsigned short u16_t;
typedef unsigned char u8_t;
/* returns true to callee if we should jump to a real mode module */
int k_mbsave(mb_info_t *mbinfo, unsigned int mb_magic);

View File

@ -66,26 +66,26 @@ typedef struct
typedef struct
{
unsigned int flags;
unsigned int mem_lower;
unsigned int mem_lower; // present if flags[0] is set
unsigned int mem_upper;
unsigned int boot_device;
unsigned int cmdline;
unsigned int mods_count;
unsigned int boot_device; // 1
unsigned int cmdline; // 2
unsigned int mods_count; // 3
unsigned int mods_addr;
union
{
mb_aout_symbol_table_t aout_sym;
mb_elf_section_header_table_t elf_sec;
mb_aout_symbol_table_t aout_sym; // 4
mb_elf_section_header_table_t elf_sec; // 5
};
unsigned int mmap_length;
unsigned int mmap_length; // 6
unsigned int mmap_addr;
unsigned int drives_length;
unsigned int drives_length; // 7
unsigned int drives_addr;
unsigned int config_table;
unsigned int bootloader_name;
unsigned int apm_table;
unsigned int config_table; // 8
unsigned int bootloader_name; // 9
unsigned int apm_table; // 10
unsigned int vbe_control_info;
unsigned int vbe_control_info; // 11
unsigned int vbe_mode_info;
unsigned short vbe_mode;
unsigned short vbe_interface_seg;

View File

@ -1,7 +1,7 @@
;boot.asm
;Author: Josh Holtrop
;Date: 07/08/04
;Modified: 07/08/04
;Modified: 07/10/04
%define MULTIBOOT_MAGIC 0x1BADB002

View File

@ -3,10 +3,61 @@
#include "multiboot.h"
#include "module.h"
mb_info_t mb_info_block;
mb_mmap_t mb_mmap[MAX_MMAP];
mb_module_t mb_modules[MAX_MODULES];
mb_apm_t mb_apm_table;
char mb_cmdline[256];
/* This function runs in segmented memory - 0xC000_0000 is mapped to 0x0 but 0x0
itself is an invalid linear address. Therefore, the multiboot information addresses
must be manually adjusted by VIRT_OFFSET to become valid linear addresses. */
int k_mbsave(mb_info_t *mbinfo, unsigned int mb_magic)
{
if (mb_magic != MULTIBOOT_BOOTLOADER_MAGIC)
{
char *msg = "Bad multiboot magic identifier!";
char *dest = (char *) 0xC00B8000;
while (*msg)
{
*dest++ = *msg++;
*dest++ = 0x04; //red error message
}
for (;;) ;
}
mb_info_block = *mbinfo;
if (mb_info_block.flags & MB_BOOTLOADER_COMMAND_LINE)
{
mb_info_block.cmdline += VIRT_OFFSET;
memcpy(mb_cmdline, mb_info_block.cmdline, 256);
mb_cmdline[255] = 0;
}
if (mb_info_block.flags & MB_BOOTLOADER_MODS)
{
mb_info_block.mods_addr += VIRT_OFFSET;
int i;
for (i = 0; i < mb_info_block.mods_count && i < MAX_MODULES; i++)
{
mb_modules[i] = ((mb_module_t *)mb_info_block.mods_addr)[i];
}
}
if (mb_info_block.flags & MB_BOOTLOADER_MMAP)
{
mb_info_block.mmap_addr += VIRT_OFFSET - 4; //-4 to get to size field, not base_addr_low field
mb_mmap_t *mmap = (mb_mmap_t *)mb_info_block.mmap_addr;
int i, sz = 0;
for (i = 0; sz < mb_info_block.mmap_length && i < MAX_MMAP; i++)
{
sz += mmap->size;
mb_mmap[i] = *mmap;
mmap = (mb_mmap_t *)(((u32_t) mmap) + mmap->size);
}
}
if (mb_info_block.flags & MB_BOOTLOADER_APM)
{
mb_info_block.apm_table += VIRT_OFFSET;
mb_apm_table = *(mb_apm_t *)mb_info_block.apm_table;
}
return 0;
}