- }
- if (cfg_get_flag(label, "restricted"))
- restricted = 1;
- if (label) {
- if (params->args && password && restricted)
- check_password ("To specify image arguments you must enter the p");
- else if (password && !restricted)
- check_password ("P");
- }
- params->args = make_params(label, params->args);
- }
- }
-
- if (!strcmp (imagename, "help")) {
- prom_printf(
- "\nPress the tab key for a list of defined images.\n"
- "The label marked with a \"*\" is is the default image, "
- "press <return> to boot it.\n\n"
- "To boot any other label simply type its name and press <return>.\n\n"
- "To boot a kernel image which is not defined in the yaboot configuration \n"
- "file, enter the kernel image name as [device:][partno],/path, where \n"
- "\"device:\" is the OpenFirmware device path to the disk the image \n"
- "resides on, and \"partno\" is the partition number the image resides on.\n\n"
- "If you omit \"device:\" and \"partno\" yaboot will use the values of \n"
- "\"device=\" and \"partition=\" in yaboot.conf, right now those are set to: \n"
- "device=%s\n"
- "partition=%d\n\n", defdevice, defpart);
- return 0;
- }
-
- if (!strcmp (imagename, "halt")) {
- if (password)
- check_password ("P");
- prom_pause();
- return 0;
- }
- if (!strcmp (imagename, "bye")) {
- if (password) {
- check_password ("P");
- return 1;
- }
- return 1;
- }
-
- if (imagename[0] == '$') {
- /* forth command string */
- if (password)
- check_password ("P");
- prom_interpret(imagename+1);
- return 0;
- }
-
- strncpy(imagepath, imagename, 1024);
-
- if (!label && password)
- check_password ("To boot a custom image you must enter the p");
-
- if (!parse_device_path(imagepath, defdevice, defpart,
- "/vmlinux", ¶ms->kernel)) {
- prom_printf("%s: Unable to parse\n", imagepath);
- return 0;
- }
- DEBUG_F("after parse_device_path: dev=%s part=%d file=%s\n", params->kernel.dev,
- params->kernel.part, params->kernel.file);
-
- if (useconf) {
- p = cfg_get_strg(label, "initrd");
- if (p && *p) {
- DEBUG_F("Parsing initrd path <%s>\n", p);
- strncpy(initrdpath, p, 1024);
- if (!parse_device_path(initrdpath, defdevice, defpart,
- "/root.bin", ¶ms->rd)) {
- prom_printf("%s: Unable to parse\n", imagepath);
- return 0;
- }
- }
- p = cfg_get_strg(label, "sysmap");
- if (p && *p) {
- DEBUG_F("Parsing sysmap path <%s>\n", p);
- strncpy(sysmappath, p, 1024);
- if (!parse_device_path(sysmappath, defdevice, defpart,
- "/boot/System.map", ¶ms->sysmap)) {
- prom_printf("%s: Unable to parse\n", imagepath);
- return 0;
- }
- }
- }
- return 0;
+ }
+ p = cfg_get_strg(0, "pause-message");
+ if (p)
+ pause_message = p;
+ if (cfg_get_flag(0, "restricted"))
+ restricted = 1;
+ p = cfg_get_strg(imagename, "image");
+ if (p && *p) {
+ label = imagename;
+ imagename = p;
+ defdevice = cfg_get_strg(label, "device");
+ if(!defdevice) defdevice=boot.dev;
+ p = cfg_get_strg(label, "partition");
+ if (p) {
+ n = simple_strtol(p, &endp, 10);
+ if (endp != p && *endp == 0)
+ defpart = n;
+ }
+ if (cfg_get_flag(label, "restricted"))
+ restricted = 1;
+ if (label) {
+ if (params->args && password && restricted)
+ check_password ("To specify arguments for this image "
+ "you must enter the password.");
+ else if (password && !restricted)
+ check_password ("This image is restricted.");
+ }
+ params->args = make_params(label, params->args);
+ }
+ }
+
+ if (!strcmp (imagename, "help")) {
+ /* FIXME: defdevice shouldn't need to be reset all over the place */
+ if(!defdevice) defdevice = boot.dev;
+ prom_printf(
+ "\nPress the tab key for a list of defined images.\n"
+ "The label marked with a \"*\" is is the default image, "
+ "press <return> to boot it.\n\n"
+ "To boot any other label simply type its name and press <return>.\n\n"
+ "To boot a kernel image which is not defined in the yaboot configuration \n"
+ "file, enter the kernel image name as [[device:][partno],]/path, where \n"
+ "\"device:\" is the OpenFirmware device path to the disk the image \n"
+ "resides on, and \"partno\" is the partition number the image resides on.\n"
+ "Note that the comma (,) is only required if you specify an OpenFirmware\n"
+ "device, if you only specify a filename you should not start it with a \",\"\n\n"
+ "To boot a alternative initrd file rather than specified in the yaboot\n"
+ "configuration file, use the \"initrd\" command on Yaboot's prompt: \n"
+ "\"initrd=[name.img]\". This will load the \"name.img\" file after the default\n"
+ "kernel image. You can, also, specify a different initrd file to any other\n"
+ "label of the yaboot configuration file. Just type \"label initrd=[name.img]\"\n"
+ "and the specified initrd file will be loaded.\n\n"
+ "To load an alternative config file rather than /etc/yaboot.conf, enter\n"
+ "its device, partno and path, on Open Firmware Prompt:\n"
+ "boot conf=device:partno,/path/to/configfile\n."
+ "To reload the config file or load a new one, use the \"conf\" command\n"
+ "on Yaboot's prompt:\n"
+ "conf [device=device] [partition=partno] [file=/path/to/configfile]\n\n"
+ "If you omit \"device\" and \"partno\", Yaboot will use their current\n"
+ "values. You can check them by entering \"conf\" on Yaboot's prompt.\n");
+
+ return 0;
+ }
+
+ if (!strcmp (imagename, "halt")) {
+ if (password)
+ check_password ("Restricted command.");
+ prom_pause();
+ return 0;
+ }
+ if (!strcmp (imagename, "bye")) {
+ if (password) {
+ check_password ("Restricted command.");
+ return 1;
+ }
+ return 1;
+ }
+
+ if (!strncmp (imagename, "conf", 4)) {
+
+ // imagename = "conf file=blah dev=bleh part=blih"
+ DEBUG_F("Loading user-specified config file: %s\n",imagename);
+ if (password) {
+ check_password ("Restricted command.");
+ return 1;
+ }
+
+ // args= "file=blah dev=bleh part=blih"
+ char *args = params->args;
+
+ if (strlen(args)){
+
+ // set a pointer to the first space in args
+ char *space = strchr(args,' ');
+
+ int loop = 3;
+ while (loop > 0){
+ char temp[1024] = "0";
+
+ // copy next argument to temp
+ strncpy(temp, args, space-args);
+
+ // parse temp and set boot arguments
+ if (!strncmp (temp, "file=", 5)){
+ DEBUG_F("conf file: %s\n", temp+5);
+ strcpy(boot.file, temp+5);
+ } else if (!strncmp (temp, "device=", 7)){
+ DEBUG_F("conf device: %s\n", temp+7);
+ strcpy(boot.dev, temp+7);
+ } else if (!strncmp (temp, "partition=", 10)){
+ DEBUG_F("conf partition: %s\n", temp+10);
+ boot.part=simple_strtol(temp+10,NULL,10);
+ } else
+ space = NULL;
+
+ // set the pointer to the next space in args;
+ // set the loop control variable
+ if (strlen(space)>1){
+ // Go to the next argument
+ args = space+1;
+
+ loop--;
+ if (strchr(args,' ') == NULL)
+ space = &args[strlen(args)];
+ else
+ space = strchr(args,' ');
+ } else {
+ loop = -1;
+ space = NULL;
+ }
+ }
+
+ prom_printf("Loading config file...\n");
+ useconf = load_config_file(&boot);
+ if (useconf > 0){
+ if ((q = cfg_get_strg(0, "timeout")) != 0 && *q != 0)
+ timeout = simple_strtol(q, NULL, 0);
+ } else {
+ prom_printf("Restoring default values.\n");
+ strcpy(boot.file,"");
+ strcpy(boot.dev, defdevice_bak);
+ boot.part = defpart;
+ }
+
+ } else {
+ prom_printf("Current configuration:\n");
+ prom_printf("device: %s\n", boot.dev);
+ if (boot.part < 0)
+ prom_printf("partition: auto\n");
+ else
+ prom_printf("partition: %d\n", boot.part);
+ if (strlen(boot.file))
+ prom_printf("file: %s\n", boot.file);
+ else
+ prom_printf("file: /etc/%s\n",CONFIG_FILE_NAME);
+ }
+
+ imagename = "\0";
+ params->args = "\0";
+
+ return 0;
+ }
+
+ if (imagename[0] == '$') {
+ /* forth command string */
+ if (password)
+ check_password ("OpenFirmware commands are restricted.");
+ prom_interpret(imagename+1);
+ return 0;
+ }
+
+ strncpy(imagepath, imagename, 1024);
+
+ if (!label && password)
+ check_password ("To boot a custom image you must enter the password.");
+
+ params->kernel = boot; /* Copy all the original paramters */
+ if (!parse_device_path(imagepath, defdevice, defpart,
+ "/vmlinux", ¶ms->kernel)) {
+ prom_printf("%s: Unable to parse\n", imagepath);
+ return 0;
+ }
+ DEBUG_F("after parse_device_path: dev=%s part=%d file=%s\n", params->kernel.dev, params->kernel.part, params->kernel.file);
+ if (useconf) {
+ p = cfg_get_strg(label, "initrd");
+ if (p && *p) {
+
+ /* check if user seted to use a initrd file from boot console */
+ if (!definitrd && p != manualinitrd) {
+ if (manualinitrd[0] != "/" && (prom_get_devtype(defdevice_bak) != FILE_DEVICE_NET)) {
+ strcpy(initrdpath, "/");
+ strcat(initrdpath, manualinitrd);
+ } else
+ strncpy(initrdpath, manualinitrd, 1024);
+ } else
+ strncpy(initrdpath, p, 1024);
+
+ DEBUG_F("Parsing initrd path <%s>\n", initrdpath);
+ params->rd = boot; /* Copy all the original paramters */
+ if (!parse_device_path(initrdpath, defdevice, defpart,
+ "/root.bin", ¶ms->rd)) {
+ prom_printf("%s: Unable to parse\n", imagepath);
+ return 0;
+ }
+ }
+ p = cfg_get_strg(label, "sysmap");
+ if (p && *p) {
+ DEBUG_F("Parsing sysmap path <%s>\n", p);
+ strncpy(sysmappath, p, 1024);
+ params->sysmap = boot; /* Copy all the original paramters */
+ if (!parse_device_path(sysmappath, defdevice, defpart,
+ "/boot/System.map", ¶ms->sysmap)) {
+ prom_printf("%s: Unable to parse\n", imagepath);
+ return 0;
+ }
+ }
+ }
+ return 0;