Changeset 114
- Timestamp:
- Mar 26, 2010 12:57:34 PM (3 years ago)
- Location:
- trunk/filo
- Files:
-
- 4 edited
-
Config.in (modified) (1 diff)
-
include/grub/shared.h (modified) (1 diff)
-
main/grub/builtins.c (modified) (8 diffs)
-
main/grub/grub.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/filo/Config.in
r105 r114 79 79 help 80 80 Time in second before booting AUTOBOOT_FILE 81 82 config ISOLINUX_PARSER 83 bool "Support for parsing isolinux.cfg config files" 84 default n 85 depends on USE_GRUB 86 help 87 If you enable this function, FILO will be able to parse isolinux.cfg 88 config files in addition to filo.lst/menu.lst files. 81 89 82 90 endmenu -
trunk/filo/include/grub/shared.h
r83 r114 133 133 } grub_error_t; 134 134 135 extern int saved_entryno;136 135 extern char config_file[]; 137 136 -
trunk/filo/main/grub/builtins.c
r103 r114 3 3 * 4 4 * Copyright (C) 1999,2000,2001,2002,2004 Free Software Foundation, Inc. 5 * Copyright (C) 2005-20 08coresystems GmbH5 * Copyright (C) 2005-2010 coresystems GmbH 6 6 * 7 7 * This program is free software; you can redistribute it and/or modify … … 21 21 #include <libpayload-config.h> 22 22 #include <libpayload.h> 23 #include <getopt.h> 24 23 25 #include <config.h> 24 26 #include <fs.h> … … 46 48 unsigned long install_partition = 0x20000; 47 49 unsigned long boot_drive = 0; 48 int saved_entryno = 0;49 50 char config_file[128] = "\0"; 50 51 … … 337 338 static int default_func(char *arg, int flags) 338 339 { 340 unsigned char buf[1]; 341 if (get_option(buf, "boot_default")) 342 buf[0] = 0xff; 343 344 if ((unsigned char)buf[0] != 0xff) { 345 printf("Default override by CMOS.\n"); 346 return 0; 347 } 348 339 349 if (!safe_parse_maxint(&arg, &default_entry)) 340 350 return 1; … … 355 365 356 366 #if CONFIG_DEVELOPER_TOOLS 357 /* default */ 367 /* dumpmem */ 368 static int dumpmem_func(char *arg, int flags) 369 { 370 int ret = string_to_args("dumpmem", arg); 371 unsigned int mem_base, mem_len; 372 void *i; 373 374 if(ret || (string_argc != 3)) { 375 errnum = ERR_BAD_ARGUMENT; 376 return 1; 377 } 378 379 // FIXME 380 if (!safe_parse_maxint(&string_argv[1], &mem_base)) 381 return 1; 382 if (!safe_parse_maxint(&string_argv[2], &mem_len)) 383 return 1; 384 385 grub_printf("Dumping memory at 0x%08x (0x%x bytes)\n", 386 mem_base, mem_len); 387 388 for (i=phys_to_virt(mem_base); i<phys_to_virt(mem_base + mem_len); i++) { 389 if (((unsigned long)i & 0x0f) == 0) 390 grub_printf("\n%08x:", i); 391 unsigned char val = *((unsigned char *)i); 392 grub_printf(" %02x", val); 393 } 394 grub_printf("\n"); 395 396 return 0; 397 } 398 399 static struct builtin builtin_dumpmem = { 400 "dumpmem", 401 dumpmem_func, 402 BUILTIN_CMDLINE | BUILTIN_HELP_LIST, 403 "dumpmem", 404 "Dump memory" 405 }; 406 407 /* dumppm */ 358 408 static int dumppm_func(char *arg, int flags) 359 409 { … … 652 702 653 703 if (disk == -1) { 654 /* The user did specify a FILO name already */ 655 // grub_printf("No drive.\n"); 656 len = 0; // just copy the drive name 704 int cnt = 0; 705 len = 0; 706 while ((arg[cnt] != 0) && (arg[cnt+1] != 0)) { 707 if (arg[cnt] == ':' && arg[cnt+1] == '/') { 708 /* The user did specify a FILO name already */ 709 len = cnt; 710 break; 711 } 712 cnt++; 713 } 657 714 } else { 658 715 if (part == -1) { // No partition … … 896 953 for (i=0; i<lspci_indent; i++) 897 954 grub_printf("| "); 898 grub_printf("|- % x:%x.%x [%x:%x]\n", bus, slot, func,955 grub_printf("|- %02x:%02x.%x [%04x:%04x]\n", bus, slot, func, 899 956 val & 0xffff, val >> 16); 900 957 … … 1705 1762 &builtin_default, 1706 1763 #ifdef CONFIG_DEVELOPER_TOOLS 1764 &builtin_dumpmem, 1707 1765 &builtin_dumppm, 1708 1766 #endif -
trunk/filo/main/grub/grub.c
r83 r114 33 33 char DEFAULT_FILE_BUF[DEFAULT_FILE_BUFLEN]; /* THe buffer for the filename of "/boot/grub/default". */ 34 34 char CMDLINE_BUF[CMDLINE_BUFLEN]; /* The buffer for the command-line. */ 35 #ifdef CONFIG_ISOLINUX_PARSER 36 char CMDLINE_TMP[CMDLINE_BUFLEN]; /* The buffer for the command-line. */ 37 #endif 35 38 char HISTORY_BUF[HISTORY_BUFLEN]; /* The history buffer for the command-line. */ 36 39 char COMPLETION_BUF[COMPLETION_BUFLEN]; /* The buffer for the completion. */ … … 174 177 if (probe_menulst(bootdevice, "/boot/menu.lst")) 175 178 return; 179 #ifdef CONFIG_ISOLINUX_PARSER 180 if (probe_menulst(bootdevice, "/boot/isolinux/isolinux.cfg")) 181 return; 182 if (probe_menulst(bootdevice, "/isolinux/isolinux.cfg")) 183 return; 184 #endif 176 185 } 177 186 } while (bootdevice); … … 872 881 } 873 882 883 #ifdef CONFIG_ISOLINUX_PARSER 884 static int rewrite_isolinux_config(void) 885 { 886 /* TODO implement "default" */ 887 /* TODO implement "timeout" */ 888 if (!memcmp(CMDLINE_BUF, "LABEL ", 6) || 889 !memcmp(CMDLINE_BUF, "label ", 6)) { 890 strcpy(CMDLINE_TMP, "title "); 891 strlcat(CMDLINE_TMP, CMDLINE_BUF + 6, NEW_HEAPSIZE - 6); 892 memcpy(CMDLINE_BUF, CMDLINE_TMP, NEW_HEAPSIZE); 893 } else 894 if (!memcmp(CMDLINE_BUF, "KERNEL ", 7) || 895 !memcmp(CMDLINE_BUF, "kernel ", 7)) { 896 char *spos; 897 int pstart = 7, plen = 0; 898 strcpy(CMDLINE_TMP, "kernel "); 899 900 /* Find path of kernel */ 901 if (strstr(CMDLINE_BUF, " /")) { 902 // Our kernel has an absolute path, so 903 // we only grab the device portion of the 904 // config file 905 906 // (hd0,0)/configfile.cfg or hda1:/configfile.cfg 907 spos = strchr(config_file, '/'); 908 if (!spos) { 909 // (hd0,0)configfile.cfg 910 spos = strchr(config_file, ')'); 911 if (spos) spos++; 912 } 913 if (!spos) { 914 // hda1:configfile.cfg 915 spos = strchr(config_file, ':'); 916 if (spos) spos++; 917 } 918 } else { 919 spos = strrchr(config_file, '/'); 920 if (spos) spos++; 921 } 922 923 if (spos) { 924 char sback = spos[0]; 925 spos[0]=0; 926 strlcat(CMDLINE_TMP, config_file, NEW_HEAPSIZE); 927 plen = strlen(CMDLINE_TMP) - pstart; // path name len 928 spos[0]=sback; 929 } 930 931 /* copy kernel name */ 932 strlcat(CMDLINE_TMP, CMDLINE_BUF + 7, NEW_HEAPSIZE); 933 934 /* recalculate the new kernel path length, 935 * we're going to need this for initrd 936 */ 937 plen = strrchr(CMDLINE_TMP, '/') - (CMDLINE_TMP + 7) + 1; 938 939 /* read APPEND line */ 940 get_line_from_config(CMDLINE_BUF, NEW_HEAPSIZE, 1); 941 if (!memcmp(CMDLINE_BUF, "APPEND ", 7) || 942 !memcmp(CMDLINE_BUF, "append ", 7)) { 943 /* append APPEND line */ 944 strlcat(CMDLINE_TMP, " ", NEW_HEAPSIZE); 945 strlcat(CMDLINE_TMP, CMDLINE_BUF + 7, NEW_HEAPSIZE); 946 spos = strstr(CMDLINE_TMP, "initrd=") + 7; 947 if (spos && plen) { 948 strncpy(spos, CMDLINE_TMP + pstart, plen); 949 spos[plen] = 0; 950 spos = strstr(CMDLINE_BUF, "initrd=") + 7; 951 strlcat(CMDLINE_TMP, spos, NEW_HEAPSIZE); 952 } 953 } 954 955 /* copy temp string to real string */ 956 memcpy(CMDLINE_BUF, CMDLINE_TMP, NEW_HEAPSIZE); 957 } else { 958 // printf("skip: %s\n", CMDLINE_BUF); 959 return 1; 960 } 961 return 0; 962 } 963 #endif 964 874 965 int is_opened = 0, is_preset = 0; 875 966 … … 913 1004 /* Never return. */ 914 1005 for (;;) { 1006 char buf[10]; /* This is good enough. */ 915 1007 char *default_file = (char *) DEFAULT_FILE_BUF; 916 1008 int i; … … 921 1013 922 1014 /* Get a saved default entry if possible. */ 923 saved_entryno = 0;924 1015 *default_file = 0; 925 1016 926 strncat(default_file, config_file, DEFAULT_FILE_BUFLEN); 927 for (i = strlen(default_file); i >= 0; i--) 928 if (default_file[i] == '/') { 929 i++; 930 break; 931 } 932 default_file[i] = 0; 933 strncat(default_file + i, "default", DEFAULT_FILE_BUFLEN - i); 934 if (file_open(default_file)) { 935 char buf[10]; /* This is good enough. */ 936 char *p = buf; 937 int len; 938 939 len = file_read(buf, sizeof(buf)); 940 if (len > 0) { 941 buf[sizeof(buf) - 1] = 0; 942 safe_parse_maxint(&p, &saved_entryno); 943 } 944 945 file_close(); 1017 /* Look into CMOS first */ 1018 if (!get_option(buf, "boot_default")) { 1019 default_entry = ((unsigned char)buf[0] != 0xff) ? 1020 (unsigned char)buf[0] : 0; 1021 } else { 1022 strncat(default_file, config_file, DEFAULT_FILE_BUFLEN); 1023 for (i = strlen(default_file); i >= 0; i--) 1024 if (default_file[i] == '/') { 1025 i++; 1026 break; 1027 } 1028 default_file[i] = 0; 1029 strncat(default_file + i, "default", DEFAULT_FILE_BUFLEN - i); 1030 if (file_open(default_file)) { 1031 char *p = buf; 1032 int len; 1033 1034 len = file_read(buf, sizeof(buf)); 1035 if (len > 0) { 1036 buf[sizeof(buf) - 1] = 0; 1037 safe_parse_maxint(&p, &default_entry); 1038 } 1039 1040 file_close(); 1041 } 946 1042 } 947 1043 … … 949 1045 950 1046 do { 1047 #ifdef CONFIG_ISOLINUX_PARSER 1048 int isolinux_cfg = 0; 1049 #endif 951 1050 /* STATE 0: Before any title command. 952 1051 STATE 1: In a title command. … … 961 1060 is_opened = file_open(config_file); 962 1061 errnum = ERR_NONE; 1062 #ifdef CONFIG_ISOLINUX_PARSER 1063 if (strstr(config_file, "isolinux.cfg")) { 1064 printf("detected isolinux.cfg\n"); 1065 isolinux_cfg = 1; 1066 } 1067 #endif 963 1068 } 964 1069 … … 976 1081 while (get_line_from_config(cmdline, NEW_HEAPSIZE, !is_preset)) { 977 1082 struct builtin *builtin; 1083 #ifdef CONFIG_ISOLINUX_PARSER 1084 if (isolinux_cfg) { 1085 if (rewrite_isolinux_config()) 1086 continue; 1087 } 1088 #endif 978 1089 979 1090 /* Get the pointer to the builtin structure. */
Note: See TracChangeset
for help on using the changeset viewer.
