156c6c0feSFrançois Revol /* 256c6c0feSFrançois Revol * Copyright 2009, François Revol, revol@free.fr. 356c6c0feSFrançois Revol * Distributed under the terms of the MIT License. 456c6c0feSFrançois Revol */ 556c6c0feSFrançois Revol 656c6c0feSFrançois Revol #include "multiboot.h" 756c6c0feSFrançois Revol 856c6c0feSFrançois Revol #include <KernelExport.h> 956c6c0feSFrançois Revol #include <string.h> 1056c6c0feSFrançois Revol #include <boot/stage2_args.h> 1156c6c0feSFrançois Revol 1256c6c0feSFrançois Revol extern struct multiboot_info *gMultiBootInfo; 1356c6c0feSFrançois Revol 1456c6c0feSFrançois Revol // load_driver_settings.h 1556c6c0feSFrançois Revol extern status_t add_safe_mode_settings(char *buffer); 1656c6c0feSFrançois Revol 1756c6c0feSFrançois Revol void 1856c6c0feSFrançois Revol dump_multiboot_info(void) 1956c6c0feSFrançois Revol { 2056c6c0feSFrançois Revol if (!gMultiBootInfo) 2156c6c0feSFrançois Revol return; 2256c6c0feSFrançois Revol dprintf("Found MultiBoot Info at %p\n", gMultiBootInfo); 2356c6c0feSFrançois Revol dprintf(" flags: 0x%lx\n", gMultiBootInfo->flags); 24*2ef563d8SFrançois Revol 2556c6c0feSFrançois Revol if (gMultiBootInfo->flags & MULTIBOOT_INFO_BOOTDEV) 2656c6c0feSFrançois Revol dprintf(" boot_device: 0x%lx\n", gMultiBootInfo->boot_device); 27*2ef563d8SFrançois Revol 28*2ef563d8SFrançois Revol if (gMultiBootInfo->flags & MULTIBOOT_INFO_CMDLINE 29*2ef563d8SFrançois Revol && gMultiBootInfo->cmdline) 3056c6c0feSFrançois Revol dprintf(" cmdline: '%s'\n", (char *)gMultiBootInfo->cmdline); 31*2ef563d8SFrançois Revol 3256c6c0feSFrançois Revol if (gMultiBootInfo->boot_loader_name) 33*2ef563d8SFrançois Revol dprintf(" boot_loader_name: '%s'\n", 34*2ef563d8SFrançois Revol (char *)gMultiBootInfo->boot_loader_name); 3556c6c0feSFrançois Revol } 3656c6c0feSFrançois Revol 3756c6c0feSFrançois Revol 3856c6c0feSFrançois Revol status_t 3956c6c0feSFrançois Revol parse_multiboot_commandline(stage2_args *args) 4056c6c0feSFrançois Revol { 4156c6c0feSFrançois Revol static const char *sArgs[] = { NULL, NULL }; 42*2ef563d8SFrançois Revol 43*2ef563d8SFrançois Revol if (!gMultiBootInfo || !(gMultiBootInfo->flags & MULTIBOOT_INFO_CMDLINE) 44*2ef563d8SFrançois Revol || !gMultiBootInfo->cmdline) 4556c6c0feSFrançois Revol return B_ENTRY_NOT_FOUND; 4656c6c0feSFrançois Revol 4756c6c0feSFrançois Revol const char *cmdline = (const char *)gMultiBootInfo->cmdline; 48*2ef563d8SFrançois Revol 4956c6c0feSFrançois Revol // skip kernel (bootloader) name 5056c6c0feSFrançois Revol cmdline = strchr(cmdline, ' '); 5156c6c0feSFrançois Revol if (!cmdline) 5256c6c0feSFrançois Revol return B_ENTRY_NOT_FOUND; 5356c6c0feSFrançois Revol cmdline++; 5456c6c0feSFrançois Revol if (*cmdline == '\0') 5556c6c0feSFrançois Revol return B_ENTRY_NOT_FOUND; 56*2ef563d8SFrançois Revol 5756c6c0feSFrançois Revol sArgs[0] = cmdline; 5856c6c0feSFrançois Revol args->arguments = sArgs; 59*2ef563d8SFrançois Revol 6056c6c0feSFrançois Revol return B_OK; 6156c6c0feSFrançois Revol } 62