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 dump_multiboot_info(void)1856c6c0feSFrançois Revoldump_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); 23*0f350f05SAugustin Cavalier dprintf(" flags: 0x%x\n", gMultiBootInfo->flags); 242ef563d8SFrançois Revol 2556c6c0feSFrançois Revol if (gMultiBootInfo->flags & MULTIBOOT_INFO_BOOTDEV) 26*0f350f05SAugustin Cavalier dprintf(" boot_device: 0x%x\n", gMultiBootInfo->boot_device); 272ef563d8SFrançois Revol 282ef563d8SFrançois Revol if (gMultiBootInfo->flags & MULTIBOOT_INFO_CMDLINE 292ef563d8SFrançois Revol && gMultiBootInfo->cmdline) 3056c6c0feSFrançois Revol dprintf(" cmdline: '%s'\n", (char *)gMultiBootInfo->cmdline); 312ef563d8SFrançois Revol 3256c6c0feSFrançois Revol if (gMultiBootInfo->boot_loader_name) 332ef563d8SFrançois Revol dprintf(" boot_loader_name: '%s'\n", 342ef563d8SFrançois Revol (char *)gMultiBootInfo->boot_loader_name); 3556c6c0feSFrançois Revol } 3656c6c0feSFrançois Revol 3756c6c0feSFrançois Revol 3856c6c0feSFrançois Revol status_t parse_multiboot_commandline(stage2_args * args)3956c6c0feSFrançois Revolparse_multiboot_commandline(stage2_args *args) 4056c6c0feSFrançois Revol { 4156c6c0feSFrançois Revol static const char *sArgs[] = { NULL, NULL }; 422ef563d8SFrançois Revol 432ef563d8SFrançois Revol if (!gMultiBootInfo || !(gMultiBootInfo->flags & MULTIBOOT_INFO_CMDLINE) 442ef563d8SFranç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; 482ef563d8SFranç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; 562ef563d8SFrançois Revol 5756c6c0feSFrançois Revol sArgs[0] = cmdline; 5856c6c0feSFrançois Revol args->arguments = sArgs; 5970b50f38SFrançois Revol args->arguments_count = 1; 602ef563d8SFrançois Revol 6156c6c0feSFrançois Revol return B_OK; 6256c6c0feSFrançois Revol } 63