Re: [PATCHv2] dprintf implementation

2005-05-08 Thread Hollis Blanchard
On Apr 14, 2005, at 9:08 AM, Vincent Pelletier wrote:
Here is a clean diff with that new grub_strword version.
Thanks Vincent! I've just checked this in (with a slight tweak: needed 
to add ## to the macro to allow passing no arguments).

Now what do we think of this patch? It adds output like this:
grub set debug=loader
grub linux (hda,0)/zImage.chrp
../loader/powerpc/ieee1275/linux.c,207 : Loading segment 0 at 0x400060, 
size 0xe1000
grub boot
../loader/powerpc/ieee1275/linux.c,59 : entry point: 0x400060
../loader/powerpc/ieee1275/linux.c,60 : initrd at: 0xc000, size 0x0
../loader/powerpc/ieee1275/linux.c,62 : /chosen/bootargs:
../loader/powerpc/ieee1275/linux.c,63 : jumping to Linux...

Are we happy with that formatting?
-Hollis
Index: loader/powerpc/ieee1275/linux.c
===
RCS file: /cvsroot/grub/grub2/loader/powerpc/ieee1275/linux.c,v
retrieving revision 1.6
diff -u -p -w -r1.6 linux.c
--- loader/powerpc/ieee1275/linux.c 14 Feb 2005 18:41:33 -  1.6
+++ loader/powerpc/ieee1275/linux.c 9 May 2005 02:03:46 -
@@ -56,6 +56,12 @@ grub_linux_boot (void)
   grub_ieee1275_set_property (chosen, bootargs, linux_args,
  grub_strlen (linux_args) + 1, actual);
   
+  grub_dprintf (loader, entry point: 0x%x\n, linux_addr);
+  grub_dprintf (loader, initrd at: 0x%x, size 0x%x\n, initrd_addr,
+   initrd_size);
+  grub_dprintf (loader, /chosen/bootargs: %s\n, linux_args);
+  grub_dprintf (loader, jumping to Linux...\n);
+
   /* Boot the kernel.  */
   linuxmain = (kernel_entry_t) linux_addr;
   linuxmain ((void *) initrd_addr, initrd_size, grub_ieee1275_entry_fn, 0, 0);
@@ -188,13 +194,18 @@ grub_rescue_cmd_linux (int argc, char *a
 
   if (phdr-p_type == PT_LOAD)
{
+ void *segment_addr = ((char *) entry) + offset;
+
  if (grub_file_seek (file, phdr-p_offset) == -1)
{
  grub_error (GRUB_ERR_BAD_OS, Invalid offset in program header);
  goto fail;
}
  
- if (grub_file_read (file, (void *) (((char *) entry) + offset) , 
phdr-p_filesz) 
+ grub_dprintf (loader, Loading segment %d at %p, size 0x%x\n, i,
+   segment_addr, phdr-p_filesz);
+
+ if (grub_file_read (file, segment_addr , phdr-p_filesz) 
  != (grub_ssize_t) phdr-p_filesz)
goto fail;
  
@@ -275,6 +286,8 @@ grub_rescue_cmd_initrd (int argc, char *
   goto fail;
 }
   
+  grub_dprintf (loader, Loading initrd at 0x%x, size 0x%x\n, addr, size);
+
   if (grub_file_read (file, (void *) addr, size) != size)
 {
   grub_ieee1275_release (addr, size);
___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


PPC executable name

2005-05-08 Thread Hollis Blanchard
I'd like to rename the PPC executable from grubof to grub. If 
nothing else, it will avoid the question is it grubof.cfg or 
grub.cfg?. Thoughts?

-Hollis

___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


[patch] small PPC cleanups

2005-05-08 Thread Hollis Blanchard
This patch corrects a couple of small issues I've come across in the PPC
code:
- struct module_info is unused
- we're declaring space for a stack but not using it
- GRUB_IEEE1275_MODULE_BASE is a 7-char address; add the missing 0

I've tested the stack change on briQ and G3. If there are no comments I
will commit this patch in a couple days.

-Hollis

2005-05-08  Hollis Blanchard  [EMAIL PROTECTED]

* boot/powerpc/ieee1275/cmain.c (module_info): Remove struct.
* boot/powerpc/ieee1275/crt0.S (_start): Use init_stack.
* include/grub/powerpc/ieee1275/kernel.h (GRUB_IEEE1275_MODULE_BASE):
Correct cosmetic typo.

Index: boot/powerpc/ieee1275/cmain.c
===
RCS file: /cvsroot/grub/grub2/boot/powerpc/ieee1275/cmain.c,v
retrieving revision 1.7
diff -u -p -r1.7 cmain.c
--- boot/powerpc/ieee1275/cmain.c   1 May 2005 03:45:35 -   1.7
+++ boot/powerpc/ieee1275/cmain.c   9 May 2005 02:29:56 -
@@ -24,12 +24,6 @@
 #include grub/machine/ieee1275.h
 #include grub/kernel.h
 
-struct module_info
-{
-  uint32_t start;
-  uint32_t end;
-};
-
 /* OpenFirmware entry point passed to us from the real bootloader.  */
 intptr_t (*grub_ieee1275_entry_fn) (void *);
 
Index: boot/powerpc/ieee1275/crt0.S
===
RCS file: /cvsroot/grub/grub2/boot/powerpc/ieee1275/crt0.S,v
retrieving revision 1.5
diff -u -p -r1.5 crt0.S
--- boot/powerpc/ieee1275/crt0.S4 Jan 2005 14:01:45 -   1.5
+++ boot/powerpc/ieee1275/crt0.S9 May 2005 02:29:56 -
@@ -25,6 +25,8 @@
.align  2
.globl  _start
 _start:
+   lis 2, [EMAIL PROTECTED]
+   ori 1, 2, [EMAIL PROTECTED]
li  2, 0
li  13, 0
 
Index: include/grub/powerpc/ieee1275/kernel.h
===
RCS file: /cvsroot/grub/grub2/include/grub/powerpc/ieee1275/kernel.h,v
retrieving revision 1.1
diff -u -p -r1.1 kernel.h
--- include/grub/powerpc/ieee1275/kernel.h  4 Jan 2005 14:01:45 -   
1.1
+++ include/grub/powerpc/ieee1275/kernel.h  9 May 2005 02:29:59 -
@@ -21,6 +21,6 @@
 #define GRUB_KERNEL_MACHINE_HEADER 1
 
 /* Where grub-mkimage places the core modules in memory.  */
-#define GRUB_IEEE1275_MODULE_BASE 0x030
+#define GRUB_IEEE1275_MODULE_BASE 0x0030
 
 #endif /* ! GRUB_KERNEL_MACHINE_HEADER */


___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


[ppc] [patch] set environment from commandline

2005-05-08 Thread Hollis Blanchard
We're doing a lot of useless work in cmain().

Also, this patch allows you to boot from the OF commandline, overriding
the defaults. Example:
boot enet:,grubof prefix=foo; debug=bar

Comments?

-Hollis

Index: boot/powerpc/ieee1275/cmain.c
===
RCS file: /cvsroot/grub/grub2/boot/powerpc/ieee1275/cmain.c,v
retrieving revision 1.7
diff -u -p -r1.7 cmain.c
--- boot/powerpc/ieee1275/cmain.c   1 May 2005 03:45:35 -   1.7
+++ boot/powerpc/ieee1275/cmain.c   9 May 2005 05:01:07 -
@@ -71,15 +71,9 @@ grub_ieee1275_find_options (void)
 }
 
 void cmain (uint32_t r3, uint32_t r4, uint32_t r5);
-/* Setup the argument vector and pass control over to the main
-   function.  */
 void
 cmain (uint32_t r3, uint32_t r4 __attribute__((unused)), uint32_t r5)
 {
-  char **argv, args[256];
-  grub_ieee1275_phandle_t chosen;
-  int argc = 0, actual;
-
   if (r5 == 0xdeadbeef)
 {
   /* Entered from Old World stage1.  */
@@ -106,70 +100,7 @@ cmain (uint32_t r3, uint32_t r4 __attrib
 
   grub_ieee1275_find_options ();
 
-  /* 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;
-}
   /* Now invoke the main function.  */
-  /* XXX: grub_main does not parse arguments yet.  */
   grub_main ();
 
   /* Never reached.  */
Index: kern/powerpc/ieee1275/init.c
===
RCS file: /cvsroot/grub/grub2/kern/powerpc/ieee1275/init.c,v
retrieving revision 1.17
diff -u -p -r1.17 init.c
--- kern/powerpc/ieee1275/init.c1 May 2005 03:45:36 -   1.17
+++ kern/powerpc/ieee1275/init.c9 May 2005 05:01:13 -
@@ -113,6 +113,9 @@ grub_set_prefix (void)
 void
 grub_machine_init (void)
 {
+  char args[256];
+  grub_ieee1275_phandle_t chosen;
+  int actual;
   extern char _start;
 
   grub_console_init ();
@@ -132,6 +135,41 @@ grub_machine_init (void)
   grub_set_prefix ();
 
   grub_ofdisk_init ();
+
+  /* Process commandline. */
+  grub_ieee1275_finddevice (/chosen, chosen);
+  if (grub_ieee1275_get_property (chosen, bootargs, args,
+ sizeof args, actual) == 0
+   actual  1)
+{
+  int i = 0;
+
+  while (i  actual)
+   {
+ char *command = args[i];
+ char *end;
+ char *val;
+
+ end = grub_strchr (command, ';');
+ if (end == 0)
+   i = actual; /* No more commands after this one.  */
+ else
+   {
+ *end = '\0';
+ i += end - command + 1;
+ while (grub_isspace(args[i]))
+   i++;
+   }
+
+ /* Process command.  */
+ val = grub_strchr (command, '=');
+ if (val)
+   {
+ *val = '\0';
+ grub_env_set (command, val + 1);
+   }
+   }
+}
 }
 
 void


___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel