/[grub]/grub2/boot/powerpc/ieee1275/cmain.c
ViewVC logotype

Diff of /grub2/boot/powerpc/ieee1275/cmain.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by hollisb, Sun May 1 03:45:35 2005 UTC revision 1.8 by hollisb, Tue May 17 02:25:19 2005 UTC
# Line 71  grub_ieee1275_find_options (void) Line 71  grub_ieee1275_find_options (void)
71  }  }
72    
73  void cmain (uint32_t r3, uint32_t r4, uint32_t r5);  void cmain (uint32_t r3, uint32_t r4, uint32_t r5);
 /* Setup the argument vector and pass control over to the main  
    function.  */  
74  void  void
75  cmain (uint32_t r3, uint32_t r4 __attribute__((unused)), uint32_t r5)  cmain (uint32_t r3, uint32_t r4 __attribute__((unused)), uint32_t r5)
76  {  {
   char **argv, args[256];  
   grub_ieee1275_phandle_t chosen;  
   int argc = 0, actual;  
   
77    if (r5 == 0xdeadbeef)    if (r5 == 0xdeadbeef)
78      {      {
79        /* Entered from Old World stage1.  */        /* Entered from Old World stage1.  */
# Line 106  cmain (uint32_t r3, uint32_t r4 __attrib Line 100  cmain (uint32_t r3, uint32_t r4 __attrib
100    
101    grub_ieee1275_find_options ();    grub_ieee1275_find_options ();
102    
   /* If any argument was passed to the kernel (us), they are  
      put in the bootargs property of /chosen.  The string can  
      be null (just the nul-character), so check that the size  
      is actually greater than one.  */  
   
   grub_ieee1275_finddevice ("/chosen", &chosen);  
   if (grub_ieee1275_get_property (chosen, "bootargs", args,  
                                   sizeof args, &actual) == 0  
       && actual > 1)  
     {  
       /* A command line was passed.  */  
       char *str = args;  
       int nr = 1;  
   
       /* First time around we count the number of arguments.  */  
       argc = 2;  
       while (*str && *str == ' ')  
         str++;  
   
       while (*str)  
         if (*(str++) == ' ')  
           {  
             while (*str && *str == ' ')  
               str++;  
             if (*str)  
               argc++;  
           }  
       argv = alloca (sizeof (char *) * (argc + 2));  
   
       /* The bootargs property does not contain the program  
          name, just the arguments.  */  
       argv[0] = "grub";  
   
       /* Second time around we fill in the argv.  */  
       str = args;  
   
       while (*str && *str == ' ')  
         str++;  
       argv[nr++] = str;  
   
       while (*str)  
         {  
           if (*str == ' ')  
             {  
               *(str++) = '\0';  
               while (*str && *str == ' ')  
                 str++;  
               if (*str)  
                 argv[nr++] = str;  
             }  
           else  
             str++;  
         }  
       argv[nr] = 0;  
     }  
   else  
     {  
       argv = alloca (sizeof (char *) * 2);  
       argv[0] = "grub";  
       argv[1] = 0;  
       argc = 1;  
     }  
103    /* Now invoke the main function.  */    /* Now invoke the main function.  */
   /* XXX: grub_main does not parse arguments yet.  */  
104    grub_main ();    grub_main ();
105    
106    /* Never reached.  */    /* Never reached.  */

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26