1 /* 2 * Copyright 2009, François Revol, revol@free.fr. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 #include "multiboot.h" 7 8 #include <KernelExport.h> 9 #include <string.h> 10 #include <boot/stage2_args.h> 11 12 extern struct multiboot_info *gMultiBootInfo; 13 14 // load_driver_settings.h 15 extern status_t add_safe_mode_settings(char *buffer); 16 17 void 18 dump_multiboot_info(void) 19 { 20 if (!gMultiBootInfo) 21 return; 22 dprintf("Found MultiBoot Info at %p\n", gMultiBootInfo); 23 dprintf(" flags: 0x%lx\n", gMultiBootInfo->flags); 24 25 if (gMultiBootInfo->flags & MULTIBOOT_INFO_BOOTDEV) 26 dprintf(" boot_device: 0x%lx\n", gMultiBootInfo->boot_device); 27 28 if (gMultiBootInfo->flags & MULTIBOOT_INFO_CMDLINE 29 && gMultiBootInfo->cmdline) 30 dprintf(" cmdline: '%s'\n", (char *)gMultiBootInfo->cmdline); 31 32 if (gMultiBootInfo->boot_loader_name) 33 dprintf(" boot_loader_name: '%s'\n", 34 (char *)gMultiBootInfo->boot_loader_name); 35 } 36 37 38 status_t 39 parse_multiboot_commandline(stage2_args *args) 40 { 41 static const char *sArgs[] = { NULL, NULL }; 42 43 if (!gMultiBootInfo || !(gMultiBootInfo->flags & MULTIBOOT_INFO_CMDLINE) 44 || !gMultiBootInfo->cmdline) 45 return B_ENTRY_NOT_FOUND; 46 47 const char *cmdline = (const char *)gMultiBootInfo->cmdline; 48 49 // skip kernel (bootloader) name 50 cmdline = strchr(cmdline, ' '); 51 if (!cmdline) 52 return B_ENTRY_NOT_FOUND; 53 cmdline++; 54 if (*cmdline == '\0') 55 return B_ENTRY_NOT_FOUND; 56 57 sArgs[0] = cmdline; 58 args->arguments = sArgs; 59 args->arguments_count = 1; 60 61 return B_OK; 62 } 63