[boot] Boot modes in kernel startup...

This commit is contained in:
Kevin Lange 2011-02-19 19:27:46 -06:00
parent e46f6ce634
commit e64ce6ba38
2 changed files with 41 additions and 4 deletions

31
kernel/include/boot.h Normal file
View File

@ -0,0 +1,31 @@
#ifndef BOOT_H
#define BOOT_H
/*
* Boot Information Types
* Used in the kernel boot process to determine
* how we booted and where we can get BIOS
* information from that bootloader.
*
*/
#include <system.h>
/*
* Multiboot
* A format managed by GNU and used in GRUB.
* Also supported natively by QEMU and a few
* other emulators.
*/
#include <multiboot.h>
/*
* Boot Types
*/
enum BOOTMODE {
unknown,
mrboots,
multiboot
};
#endif /* BOOT_H */

View File

@ -30,7 +30,7 @@
*/
#include <system.h>
#include <multiboot.h>
#include <boot.h>
#include <ext2.h>
/*
@ -56,10 +56,10 @@
*/
int main(struct multiboot *mboot_ptr, uint32_t mboot_mag)
{
int using_multiboot = 0;
enum BOOTMODE boot_mode = unknown; /* Boot Mode */
char * ramdisk = NULL;
if (mboot_mag == MULTIBOOT_EAX_MAGIC) {
using_multiboot = 1;
boot_mode = multiboot;
/* Realing memory to the end of the multiboot modules */
kmalloc_startat(0x200000);
if (mboot_ptr->flags & (1 << 3)) {
@ -70,6 +70,12 @@ int main(struct multiboot *mboot_ptr, uint32_t mboot_mag)
memcpy(ramdisk, (char *)module_start, module_end - module_start);
}
}
} else {
/*
* This isn't a multiboot attempt. We were probably loaded by
* Mr. Boots, our dedicated boot loader. Verify this...
*/
boot_mode = mrboots;
}
/* Initialize core modules */
@ -92,7 +98,7 @@ int main(struct multiboot *mboot_ptr, uint32_t mboot_mag)
settextcolor(12, 0);
kprintf("[%s %s]\n", KERNEL_UNAME, KERNEL_VERSION_STRING);
if (using_multiboot) {
if (boot_mode == multiboot) {
/* Print multiboot information */
dump_multiboot(mboot_ptr);