<div>there is an bug(at least in my eyes).</div>
<div>/main/grub/grub.c </div>
<div>line 937:</div>
<div>plen=strrchr(CMDLINE_TMP,'/') -(CMDLINE_TMP+7) +1;</div>
<div>function strrchr returns the pointer which is (char*), right?<br><br></div>
<div class="gmail_quote">2010/3/26 repository service <span dir="ltr"><<a href="mailto:svn@coreboot.org">svn@coreboot.org</a>></span><br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">Author: stepan<br>Date: Fri Mar 26 12:57:34 2010<br>New Revision: 114<br>URL: <a href="http://tracker.coreboot.org/trac/filo/changeset/114" target="_blank">http://tracker.coreboot.org/trac/filo/changeset/114</a><br>
<br>Log:<br>grub interface update<br>- add support for "default" (aka grubonce) support through cmos<br>- add dumpmem command<br>- add isolinux parser<br><br>Signed-off-by: Stefan Reinauer <<a href="mailto:stepan@coresystems.de">stepan@coresystems.de</a>><br>
<br>Modified:<br>  trunk/filo/Config.in<br>  trunk/filo/include/grub/shared.h<br>  trunk/filo/main/grub/builtins.c<br>  trunk/filo/main/grub/grub.c<br><br>Modified: trunk/filo/Config.in<br>==============================================================================<br>
--- trunk/filo/Config.in        Fri Mar 26 12:55:18 2010        (r113)<br>+++ trunk/filo/Config.in        Fri Mar 26 12:57:34 2010        (r114)<br>@@ -79,6 +79,14 @@<br>       help<br>         Time in second before booting AUTOBOOT_FILE<br>
<br>+config ISOLINUX_PARSER<br>+       bool "Support for parsing isolinux.cfg config files"<br>+       default n<br>+       depends on USE_GRUB<br>+       help<br>+         If you enable this function, FILO will be able to parse isolinux.cfg<br>
+         config files in addition to filo.lst/menu.lst files.<br>+<br> endmenu<br><br> menu "Drivers"<br><br>Modified: trunk/filo/include/grub/shared.h<br>==============================================================================<br>
--- trunk/filo/include/grub/shared.h    Fri Mar 26 12:55:18 2010        (r113)<br>+++ trunk/filo/include/grub/shared.h    Fri Mar 26 12:57:34 2010        (r114)<br>@@ -132,7 +132,6 @@<br>  MAX_ERR_NUM<br> } grub_error_t;<br>
<br>-extern int saved_entryno;<br> extern char config_file[];<br><br> /* GUI interface variables. */<br><br>Modified: trunk/filo/main/grub/builtins.c<br>==============================================================================<br>
--- trunk/filo/main/grub/builtins.c     Fri Mar 26 12:55:18 2010        (r113)<br>+++ trunk/filo/main/grub/builtins.c     Fri Mar 26 12:57:34 2010        (r114)<br>@@ -2,7 +2,7 @@<br> * This file is part of FILO.<br> *<br>
 *  Copyright (C) 1999,2000,2001,2002,2004  Free Software Foundation, Inc.<br>- *  Copyright (C) 2005-2008 coresystems GmbH<br>+ *  Copyright (C) 2005-2010 coresystems GmbH<br> *<br> * This program is free software; you can redistribute it and/or modify<br>
 * it under the terms of the GNU General Public License as published by<br>@@ -20,6 +20,8 @@<br><br> #include <libpayload-config.h><br> #include <libpayload.h><br>+#include <getopt.h><br>+<br> #include <config.h><br>
 #include <fs.h><br> #include <lib.h><br>@@ -45,7 +47,6 @@<br> // other..<br> unsigned long install_partition = 0x20000;<br> unsigned long boot_drive = 0;<br>-int saved_entryno = 0;<br> char config_file[128] = "\0";<br>
<br> kernel_t kernel_type;<br>@@ -336,6 +337,15 @@<br> /* default */<br> static int default_func(char *arg, int flags)<br> {<br>+       unsigned char buf[1];<br>+       if (get_option(buf, "boot_default"))<br>+               buf[0] = 0xff;<br>
+<br>+       if ((unsigned char)buf[0] != 0xff) {<br>+               printf("Default override by CMOS.\n");<br>+               return 0;<br>+       }<br>+<br>       if (!safe_parse_maxint(&arg, &default_entry))<br>
               return 1;<br><br>@@ -354,7 +364,47 @@<br> };<br><br> #if CONFIG_DEVELOPER_TOOLS<br>-/* default */<br>+/* dumpmem */<br>+static int dumpmem_func(char *arg, int flags)<br>+{<br>+       int ret = string_to_args("dumpmem", arg);<br>
+       unsigned int mem_base, mem_len;<br>+       void *i;<br>+<br>+       if(ret || (string_argc != 3)) {<br>+               errnum = ERR_BAD_ARGUMENT;<br>+               return 1;<br>+       }<br>+<br>+       // FIXME<br>
+       if (!safe_parse_maxint(&string_argv[1], &mem_base))<br>+               return 1;<br>+       if (!safe_parse_maxint(&string_argv[2], &mem_len))<br>+               return 1;<br>+<br>+       grub_printf("Dumping memory at 0x%08x (0x%x bytes)\n",<br>
+                       mem_base, mem_len);<br>+<br>+       for (i=phys_to_virt(mem_base); i<phys_to_virt(mem_base + mem_len); i++) {<br>+               if (((unsigned long)i & 0x0f) == 0)<br>+                       grub_printf("\n%08x:", i);<br>
+               unsigned char val = *((unsigned char *)i);<br>+               grub_printf(" %02x", val);<br>+       }<br>+       grub_printf("\n");<br>+<br>+       return 0;<br>+}<br>+<br>+static struct builtin builtin_dumpmem = {<br>
+       "dumpmem",<br>+       dumpmem_func,<br>+       BUILTIN_CMDLINE | BUILTIN_HELP_LIST,<br>+       "dumpmem",<br>+       "Dump memory"<br>+};<br>+<br>+/* dumppm */<br> static int dumppm_func(char *arg, int flags)<br>
 {<br>       u16 pmbase;<br>@@ -651,9 +701,16 @@<br>       }<br><br>       if (disk == -1) {<br>-               /* The user did specify a FILO name already */<br>-               // grub_printf("No drive.\n");<br>
-               len = 0;        // just copy the drive name<br>+               int cnt = 0;<br>+               len = 0;<br>+               while ((arg[cnt] != 0) && (arg[cnt+1] != 0)) {<br>+                       if (arg[cnt] == ':' && arg[cnt+1] == '/') {<br>
+                               /* The user did specify a FILO name already */<br>+                               len = cnt;<br>+                               break;<br>+                       }<br>+                       cnt++;<br>
+               }<br>       } else {<br>               if (part == -1) {       // No partition<br>                       sprintf(devicename, "%s%c:", drivername, disk + 'a');<br>@@ -895,7 +952,7 @@<br><br>
                       for (i=0; i<lspci_indent; i++)<br>                               grub_printf("|  ");<br>-                       grub_printf("|- %x:%x.%x [%x:%x]\n", bus, slot, func,<br>+                       grub_printf("|- %02x:%02x.%x [%04x:%04x]\n", bus, slot, func,<br>
                                       val & 0xffff, val >> 16);<br><br>                       /* If this is a bridge, then follow it. */<br>@@ -1704,6 +1761,7 @@<br>       &builtin_configfile,<br>       &builtin_default,<br>
 #ifdef CONFIG_DEVELOPER_TOOLS<br>+       &builtin_dumpmem,<br>       &builtin_dumppm,<br> #endif<br> #ifdef CONFIG_EXPERIMENTAL<br><br>Modified: trunk/filo/main/grub/grub.c<br>==============================================================================<br>
--- trunk/filo/main/grub/grub.c Fri Mar 26 12:55:18 2010        (r113)<br>+++ trunk/filo/main/grub/grub.c Fri Mar 26 12:57:34 2010        (r114)<br>@@ -32,6 +32,9 @@<br> char PASSWORD_BUF[PASSWORD_BUFLEN]; /* The buffer for the password.  */<br>
 char DEFAULT_FILE_BUF[DEFAULT_FILE_BUFLEN]; /* THe buffer for the filename of "/boot/grub/default".  */<br> char CMDLINE_BUF[CMDLINE_BUFLEN]; /* The buffer for the command-line.  */<br>+#ifdef CONFIG_ISOLINUX_PARSER<br>
+char CMDLINE_TMP[CMDLINE_BUFLEN]; /* The buffer for the command-line.  */<br>+#endif<br> char HISTORY_BUF[HISTORY_BUFLEN]; /* The history buffer for the command-line. */<br> char COMPLETION_BUF[COMPLETION_BUFLEN]; /* The buffer for the completion.  */<br>
 char UNIQUE_BUF[UNIQUE_BUFLEN]; /* The buffer for the unique string.  */<br>@@ -173,6 +176,12 @@<br>                               return;<br>                       if (probe_menulst(bootdevice, "/boot/menu.lst"))<br>
                               return;<br>+#ifdef CONFIG_ISOLINUX_PARSER<br>+                       if (probe_menulst(bootdevice, "/boot/isolinux/isolinux.cfg"))<br>+                               return;<br>+                       if (probe_menulst(bootdevice, "/isolinux/isolinux.cfg"))<br>
+                               return;<br>+#endif<br>               }<br>       } while (bootdevice);<br><br>@@ -871,6 +880,88 @@<br>       return pos;<br> }<br><br>+#ifdef CONFIG_ISOLINUX_PARSER<br>+static int rewrite_isolinux_config(void)<br>
+{<br>+       /* TODO implement "default" */<br>+       /* TODO implement "timeout" */<br>+       if (!memcmp(CMDLINE_BUF, "LABEL ", 6) ||<br>+           !memcmp(CMDLINE_BUF, "label ", 6)) {<br>
+               strcpy(CMDLINE_TMP, "title ");<br>+               strlcat(CMDLINE_TMP, CMDLINE_BUF + 6, NEW_HEAPSIZE - 6);<br>+               memcpy(CMDLINE_BUF, CMDLINE_TMP, NEW_HEAPSIZE);<br>+       } else<br>
+       if (!memcmp(CMDLINE_BUF, "KERNEL ", 7) ||<br>+           !memcmp(CMDLINE_BUF, "kernel ", 7)) {<br>+               char *spos;<br>+               int pstart = 7, plen = 0;<br>+               strcpy(CMDLINE_TMP, "kernel ");<br>
+<br>+               /* Find path of kernel */<br>+               if (strstr(CMDLINE_BUF, " /")) {<br>+                       // Our kernel has an absolute path, so<br>+                       // we only grab the device portion of the<br>
+                       // config file<br>+<br>+                       // (hd0,0)/configfile.cfg or hda1:/configfile.cfg<br>+                       spos = strchr(config_file, '/');<br>+                       if (!spos) {<br>
+                               // (hd0,0)configfile.cfg<br>+                               spos = strchr(config_file, ')');<br>+                               if (spos) spos++;<br>+                       }<br>+                       if (!spos) {<br>
+                               // hda1:configfile.cfg<br>+                               spos = strchr(config_file, ':');<br>+                               if (spos) spos++;<br>+                       }<br>+               } else {<br>
+                       spos = strrchr(config_file, '/');<br>+                       if (spos) spos++;<br>+               }<br>+<br>+               if (spos) {<br>+                       char sback = spos[0];<br>+                       spos[0]=0;<br>
+                       strlcat(CMDLINE_TMP, config_file, NEW_HEAPSIZE);<br>+                       plen = strlen(CMDLINE_TMP) - pstart; // path name len<br>+                       spos[0]=sback;<br>+               }<br>+<br>
+               /* copy kernel name */<br>+               strlcat(CMDLINE_TMP, CMDLINE_BUF + 7, NEW_HEAPSIZE);<br>+<br>+               /* recalculate the new kernel path length,<br>+                * we're going to need this for initrd<br>
+                */<br>+               plen = strrchr(CMDLINE_TMP, '/') - (CMDLINE_TMP + 7) + 1;<br>+<br>+               /* read APPEND line */<br>+               get_line_from_config(CMDLINE_BUF, NEW_HEAPSIZE, 1);<br>
+               if (!memcmp(CMDLINE_BUF, "APPEND ", 7) ||<br>+                   !memcmp(CMDLINE_BUF, "append ", 7)) {<br>+                       /* append APPEND line */<br>+                       strlcat(CMDLINE_TMP, " ", NEW_HEAPSIZE);<br>
+                       strlcat(CMDLINE_TMP, CMDLINE_BUF + 7, NEW_HEAPSIZE);<br>+                       spos = strstr(CMDLINE_TMP, "initrd=") + 7;<br>+                       if (spos && plen) {<br>+                               strncpy(spos, CMDLINE_TMP + pstart, plen);<br>
+                               spos[plen] = 0;<br>+                               spos = strstr(CMDLINE_BUF, "initrd=") + 7;<br>+                               strlcat(CMDLINE_TMP, spos, NEW_HEAPSIZE);<br>+                       }<br>
+               }<br>+<br>+               /* copy temp string to real string */<br>+               memcpy(CMDLINE_BUF, CMDLINE_TMP, NEW_HEAPSIZE);<br>+       } else {<br>+               // printf("skip: %s\n", CMDLINE_BUF);<br>
+               return 1;<br>+       }<br>+       return 0;<br>+}<br>+#endif<br>+<br> int is_opened = 0, is_preset = 0;<br><br> /* This is the starting function in C.  */<br>@@ -912,6 +1003,7 @@<br><br>       /* Never return.  */<br>
       for (;;) {<br>+               char buf[10];   /* This is good enough.  */<br>               char *default_file = (char *) DEFAULT_FILE_BUF;<br>               int i;<br><br>@@ -920,34 +1012,41 @@<br>               /* Here load the configuration file.  */<br>
<br>               /* Get a saved default entry if possible.  */<br>-               saved_entryno = 0;<br>               *default_file = 0;<br><br>-               strncat(default_file, config_file, DEFAULT_FILE_BUFLEN);<br>
-               for (i = strlen(default_file); i >= 0; i--)<br>-                       if (default_file[i] == '/') {<br>-                               i++;<br>-                               break;<br>-                       }<br>
-               default_file[i] = 0;<br>-               strncat(default_file + i, "default", DEFAULT_FILE_BUFLEN - i);<br>-               if (file_open(default_file)) {<br>-                       char buf[10];   /* This is good enough.  */<br>
-                       char *p = buf;<br>-                       int len;<br>-<br>-                       len = file_read(buf, sizeof(buf));<br>-                       if (len > 0) {<br>-                               buf[sizeof(buf) - 1] = 0;<br>
-                               safe_parse_maxint(&p, &saved_entryno);<br>-                       }<br>+               /* Look into CMOS first */<br>+               if (!get_option(buf, "boot_default")) {<br>
+                       default_entry = ((unsigned char)buf[0] != 0xff) ?<br>+                               (unsigned char)buf[0] : 0;<br>+               } else {<br>+                       strncat(default_file, config_file, DEFAULT_FILE_BUFLEN);<br>
+                       for (i = strlen(default_file); i >= 0; i--)<br>+                               if (default_file[i] == '/') {<br>+                                       i++;<br>+                                       break;<br>
+                               }<br>+                       default_file[i] = 0;<br>+                       strncat(default_file + i, "default", DEFAULT_FILE_BUFLEN - i);<br>+                       if (file_open(default_file)) {<br>
+                               char *p = buf;<br>+                               int len;<br>+<br>+                               len = file_read(buf, sizeof(buf));<br>+                               if (len > 0) {<br>
+                                       buf[sizeof(buf) - 1] = 0;<br>+                                       safe_parse_maxint(&p, &default_entry);<br>+                               }<br><br>-                       file_close();<br>
+                               file_close();<br>+                       }<br>               }<br><br>               errnum = ERR_NONE;<br><br>               do {<br>+#ifdef CONFIG_ISOLINUX_PARSER<br>+                       int isolinux_cfg = 0;<br>
+#endif<br>                       /* STATE 0:  Before any title command.<br>                          STATE 1:  In a title command.<br>                          STATE >1: In a entry after a title command.  */<br>@@ -960,6 +1059,12 @@<br>
                       if (!is_opened) {<br>                               is_opened = file_open(config_file);<br>                               errnum = ERR_NONE;<br>+#ifdef CONFIG_ISOLINUX_PARSER<br>+                               if (strstr(config_file, "isolinux.cfg")) {<br>
+                                       printf("detected isolinux.cfg\n");<br>+                                       isolinux_cfg = 1;<br>+                               }<br>+#endif<br>                       }<br>
<br>                       if (!is_opened) {<br>@@ -975,6 +1080,12 @@<br>                       cmdline = (char *) CMDLINE_BUF;<br>                       while (get_line_from_config(cmdline, NEW_HEAPSIZE, !is_preset)) {<br>
                               struct builtin *builtin;<br>+#ifdef CONFIG_ISOLINUX_PARSER<br>+                               if (isolinux_cfg) {<br>+                                       if (rewrite_isolinux_config())<br>
+                                               continue;<br>+                               }<br>+#endif<br><br>                               /* Get the pointer to the builtin structure.  */<br>                               builtin = find_command(cmdline);<br>
<font color="#888888"><br>--<br>coreboot mailing list: <a href="mailto:coreboot@coreboot.org">coreboot@coreboot.org</a><br><a href="http://www.coreboot.org/mailman/listinfo/coreboot" target="_blank">http://www.coreboot.org/mailman/listinfo/coreboot</a><br>
</font></blockquote></div><br>