All of lore.kernel.org
 help / color / mirror / Atom feed
* normal mode chainloader
@ 2004-06-21 18:00 Tomas Ebenlendr
  2004-06-22  9:00 ` Marco Gerards
  0 siblings, 1 reply; 37+ messages in thread
From: Tomas Ebenlendr @ 2004-06-21 18:00 UTC (permalink / raw)
  To: grub-devel


Here is patch that implements command chainloader in normal mode. It may be
done wrong way, but it is something to talk about. I successfully tested it
on bochs. (In fact it is so simple, that it must work.). I added an artifical
symbol to boot.mod to get dependency of normal mode loader commands on the
boot command.

P.S. Being offline is good. Result is one e-mail instead of 5 mails or more
as I did before.

P.P.S. I saw somewhere (in archive) that I should probably subscribe
	something for FSF. I don't understand this legal stuff, I
	subscribe anything good for this piece of sw if needed.
	(But I have no electronic signature yet :-(, I didn't need any.)

Notes on architecture dependent files:
	I dislike how architecture dependent files (headers, conf/*.rmk)
	are copied or cut&pasted between architectures. In fact my opinion
	is that	body of function may be architecture dependent, then it
	should be in architecture dir. But the interface (the prototype of
	the function) is architecture independent and so it shouldn't be
	in architecture dir (now I'm talking about loader.h).

	I didn't touched this because I want to know your opinion.
	(Try diff -rup include/grub/{i386/pc;powerpc/ieee1275} )

	Files are same probably because powerpc is not too far from
	ibm-pc. But I think they shouldn't be copied. They should be
	somehow shared. (Ok, it is not easy to find `name' for common
	code (directory), but I think that same files should be linked
	and nearly same files should include common part.)

	Folowing patch modifies only i386/pc architecture, but I think
	that exactly same changes should be done in powerpc files.

Changelog:
2004-06-21  Tomas Ebenlendr  <ebik@ucw.cz>

	Added normal mode command `chainloader' as module chain.mod,
	which depends on normal.mod and _chain.mod. There is also added
	dependency to boot.mod because of semantic dependency of these
	commands.

	* commands/boot.c: Add symbol grub_boot_dependency, used for
	semantic dependency of commands.
	* conf/i386-pc.rmk: Add i386/pc/chainloader_normal.c as
	chain.mod.
	* include/grub/boot_cmd.h: New file. The semantic dependency
	of loader commands and boot command.
	* include/grub/i386/pc/chainloader.h: New file. Exports
	body of chainloader command.
	* include/grub/i386/pc/loader.h: added FIXME, deleted prototype
	of rescue command chainloader.
	* loader/i386/pc/chainloader.c (grub_rescue_cmd_chainloader):
	all but arguments parsing moved to ...
	(grub_chainloader_cmd): ... this.
	* loader/i386/pc/chainloader_normal.c: New file. Defines the
	command chainloader.


diff -rupN -x CVS grub2_x/commands/boot.c grub2_work/commands/boot.c
--- grub2_x/commands/boot.c	2004-06-05 00:20:17.000000000 +0200
+++ grub2_work/commands/boot.c	2004-06-21 01:42:05.000000000 +0200
@@ -24,6 +24,8 @@
 #include <grub/misc.h>
 #include <grub/loader.h>
 
+int grub_boot_dependency;
+
 static grub_err_t
 grub_cmd_boot (struct grub_arg_list *state __attribute__ ((unused)),
 	       int argc, char **args __attribute__ ((unused)))
@@ -54,6 +56,8 @@ grub_boot_fini (void)
 GRUB_MOD_INIT
 {
   (void)mod;			/* To stop warning. */
+  grub_boot_dependency = 1; /* To let be loader commands dependent on this command
+			       (don't let gcc optimize off this symbol) */
   grub_register_command ("boot", grub_cmd_boot, GRUB_COMMAND_FLAG_BOTH,
 			 "boot", "Boot an operating system", 0);
 }
diff -rupN -x CVS grub2_x/conf/i386-pc.mk grub2_work/conf/i386-pc.mk
--- grub2_x/conf/i386-pc.mk	2004-06-05 00:20:17.000000000 +0200
+++ grub2_work/conf/i386-pc.mk	2004-06-21 01:16:47.000000000 +0200
@@ -717,7 +717,7 @@ genmoddep-util_genmoddep.d: util/genmodd
 
 # Modules.
 pkgdata_MODULES = _chain.mod _linux.mod fat.mod ufs.mod ext2.mod minix.mod normal.mod hello.mod \
-	 vga.mod font.mod _multiboot.mod ls.mod boot.mod cmp.mod cat.mod terminal.mod
+	 vga.mod font.mod _multiboot.mod ls.mod boot.mod cmp.mod cat.mod terminal.mod chain.mod
 
 # For _chain.mod.
 _chain_mod_SOURCES = loader/i386/pc/chainloader.c
@@ -758,6 +758,45 @@ _chain_mod-loader_i386_pc_chainloader.d:
 
 _chain_mod_CFLAGS = $(COMMON_CFLAGS)
 
+# For chain.mod.
+chain_mod_SOURCES = loader/i386/pc/chainloader_normal.c
+CLEANFILES += chain.mod mod-chain.o mod-chain.c pre-chain.o chain_mod-loader_i386_pc_chainloader_normal.o def-chain.lst und-chain.lst
+MOSTLYCLEANFILES += chain_mod-loader_i386_pc_chainloader_normal.d
+DEFSYMFILES += def-chain.lst
+UNDSYMFILES += und-chain.lst
+
+chain.mod: pre-chain.o mod-chain.o
+	-rm -f $@
+	$(LD) -r -o $@ $^
+	$(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
+
+pre-chain.o: chain_mod-loader_i386_pc_chainloader_normal.o
+	-rm -f $@
+	$(LD) -r -o $@ $^
+
+mod-chain.o: mod-chain.c
+	$(CC) $(CPPFLAGS) $(CFLAGS) $(chain_mod_CFLAGS) -c -o $@ $<
+
+mod-chain.c: moddep.lst genmodsrc.sh
+	sh $(srcdir)/genmodsrc.sh 'chain' $< > $@ || (rm -f $@; exit 1)
+
+def-chain.lst: pre-chain.o
+	$(NM) -g --defined-only -P -p $< | sed 's/^\([^ ]*\).*/\1 chain/' > $@
+
+und-chain.lst: pre-chain.o
+	echo 'chain' > $@
+	$(NM) -u -P -p $< | cut -f1 -d' ' >> $@
+
+chain_mod-loader_i386_pc_chainloader_normal.o: loader/i386/pc/chainloader_normal.c
+	$(CC) -Iloader/i386/pc -I$(srcdir)/loader/i386/pc $(CPPFLAGS) $(CFLAGS) $(chain_mod_CFLAGS) -c -o $@ $<
+
+chain_mod-loader_i386_pc_chainloader_normal.d: loader/i386/pc/chainloader_normal.c
+	set -e; 	  $(CC) -Iloader/i386/pc -I$(srcdir)/loader/i386/pc $(CPPFLAGS) $(CFLAGS) $(chain_mod_CFLAGS) -M $< 	  | sed 's,chainloader_normal\.o[ :]*,chain_mod-loader_i386_pc_chainloader_normal.o $@ : ,g' > $@; 	  [ -s $@ ] || rm -f $@
+
+-include chain_mod-loader_i386_pc_chainloader_normal.d
+
+chain_mod_CFLAGS = $(COMMON_CFLAGS)
+
 # For fat.mod.
 fat_mod_SOURCES = fs/fat.c
 CLEANFILES += fat.mod mod-fat.o mod-fat.c pre-fat.o fat_mod-fs_fat.o def-fat.lst und-fat.lst
diff -rupN -x CVS grub2_x/conf/i386-pc.rmk grub2_work/conf/i386-pc.rmk
--- grub2_x/conf/i386-pc.rmk	2004-06-05 00:20:17.000000000 +0200
+++ grub2_work/conf/i386-pc.rmk	2004-06-21 01:16:12.000000000 +0200
@@ -74,12 +74,16 @@ genmoddep_SOURCES = util/genmoddep.c
 
 # Modules.
 pkgdata_MODULES = _chain.mod _linux.mod fat.mod ufs.mod ext2.mod minix.mod normal.mod hello.mod \
-	 vga.mod font.mod _multiboot.mod ls.mod boot.mod cmp.mod cat.mod terminal.mod
+	 vga.mod font.mod _multiboot.mod ls.mod boot.mod cmp.mod cat.mod terminal.mod chain.mod
 
 # For _chain.mod.
 _chain_mod_SOURCES = loader/i386/pc/chainloader.c
 _chain_mod_CFLAGS = $(COMMON_CFLAGS)
 
+# For chain.mod.
+chain_mod_SOURCES = loader/i386/pc/chainloader_normal.c
+chain_mod_CFLAGS = $(COMMON_CFLAGS)
+
 # For fat.mod.
 fat_mod_SOURCES = fs/fat.c
 fat_mod_CFLAGS = $(COMMON_CFLAGS)
diff -rupN -x CVS grub2_x/include/grub/boot_cmd.h grub2_work/include/grub/boot_cmd.h
--- grub2_x/include/grub/boot_cmd.h	1970-01-01 01:00:00.000000000 +0100
+++ grub2_work/include/grub/boot_cmd.h	2004-06-21 01:33:53.000000000 +0200
@@ -0,0 +1,26 @@
+/* This file is intended as command dependency */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2002  Free Software Foundation, Inc.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef GRUB_BOOT_CMD_HEADER
+#define GRUB_BOOT_CMD_HEADER	1
+
+extern int EXPORT_VAR(grub_boot_dependency);
+
+#endif /* ! GRUB_BOOT_CMD_HEADER */
diff -rupN -x CVS grub2_x/include/grub/i386/pc/chainloader.h grub2_work/include/grub/i386/pc/chainloader.h
--- grub2_x/include/grub/i386/pc/chainloader.h	1970-01-01 01:00:00.000000000 +0100
+++ grub2_work/include/grub/i386/pc/chainloader.h	2004-06-21 01:19:52.000000000 +0200
@@ -0,0 +1,34 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2004  Free Software Foundation, Inc.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef GRUB_CHAINLOADER_MACHINE_HEADER
+#define GRUB_CHAINLOADER_MACHINE_HEADER	1
+
+#include <grub/dl.h>
+
+/* common function for normal and rescue mode commands*/
+typedef enum
+  {
+    GRUB_CHAINLOADER_FORCE = 0x1
+  }
+grub_chainloader_flags_t;
+
+void EXPORT_FUNC(grub_chainloader_cmd) (const char * file,grub_chainloader_flags_t flags);
+
+#endif /* ! GRUB_CHAINLOADER_MACHINE_HEADER */
diff -rupN -x CVS grub2_x/include/grub/i386/pc/loader.h grub2_work/include/grub/i386/pc/loader.h
--- grub2_x/include/grub/i386/pc/loader.h	2004-06-05 00:20:17.000000000 +0200
+++ grub2_work/include/grub/i386/pc/loader.h	2004-06-21 01:50:48.000000000 +0200
@@ -41,7 +41,8 @@ void EXPORT_FUNC(grub_multiboot_real_boo
 
 /* It is necessary to export these functions, because normal mode commands
    reuse rescue mode commands.  */
-void grub_rescue_cmd_chainloader (int argc, char *argv[]);
+/* FIXME these commands should be divided to argument parsing and real work, and moved to
+ * respective headers*/
 void grub_rescue_cmd_linux (int argc, char *argv[]);
 void grub_rescue_cmd_initrd (int argc, char *argv[]);
 void grub_rescue_cmd_multiboot (int argc, char *argv[]);
diff -rupN -x CVS grub2_x/loader/i386/pc/chainloader.c grub2_work/loader/i386/pc/chainloader.c
--- grub2_x/loader/i386/pc/chainloader.c	2004-06-05 00:20:18.000000000 +0200
+++ grub2_work/loader/i386/pc/chainloader.c	2004-06-21 00:41:54.000000000 +0200
@@ -20,6 +20,7 @@
 
 #include <grub/loader.h>
 #include <grub/machine/loader.h>
+#include <grub/machine/chainloader.h>
 #include <grub/file.h>
 #include <grub/err.h>
 #include <grub/device.h>
@@ -82,28 +83,15 @@ grub_chainloader_unload (void)
 }
 
 void
-grub_rescue_cmd_chainloader (int argc, char *argv[])
+grub_chainloader_cmd(const char * filename, grub_chainloader_flags_t flags)
 {
   grub_file_t file = 0;
   grub_uint16_t signature;
-  int force = 0;
 
   grub_dl_ref (my_mod);
   
-  if (argc > 0 && grub_strcmp (argv[0], "--force") == 0)
-    {
-      force = 1;
-      argc--;
-      argv++;
-    }
 
-  if (argc == 0)
-    {
-      grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
-      goto fail;
-    }
-
-  file = grub_file_open (argv[0]);
+  file = grub_file_open (filename);
   if (! file)
     goto fail;
 
@@ -119,7 +107,7 @@ grub_rescue_cmd_chainloader (int argc, c
 
   /* Check the signature.  */
   signature = *((grub_uint16_t *) (0x7C00 + GRUB_DISK_SECTOR_SIZE - 2));
-  if (signature != grub_le_to_cpu16 (0xaa55) && ! force)
+  if (signature != grub_le_to_cpu16 (0xaa55) && ! (flags & GRUB_CHAINLOADER_FORCE) )
     {
       grub_error (GRUB_ERR_BAD_OS, "invalid signature");
       goto fail;
@@ -137,6 +125,25 @@ grub_rescue_cmd_chainloader (int argc, c
   grub_dl_unref (my_mod);
 }
 
+static void
+grub_rescue_cmd_chainloader (int argc, char *argv[])
+{
+  grub_chainloader_flags_t flags = 0;
+
+  if (argc > 0 && grub_strcmp (argv[0], "--force") == 0)
+    {
+      flags |= GRUB_CHAINLOADER_FORCE;
+      argc--;
+      argv++;
+    }
+
+  if (argc == 0)
+      grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
+  else
+    grub_chainloader_cmd(argv[0],flags);
+}
+
+
 static const char loader_name[] = "chainloader";
 
 GRUB_MOD_INIT
diff -rupN -x CVS grub2_x/loader/i386/pc/chainloader_normal.c grub2_work/loader/i386/pc/chainloader_normal.c
--- grub2_x/loader/i386/pc/chainloader_normal.c	1970-01-01 01:00:00.000000000 +0100
+++ grub2_work/loader/i386/pc/chainloader_normal.c	2004-06-21 01:42:45.000000000 +0200
@@ -0,0 +1,57 @@
+/* chainloader_normal.c - boot another boot loader */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2004  Free Software Foundation, Inc.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <grub/machine/chainloader.h>
+#include <grub/err.h>
+#include <grub/normal.h>
+#include <grub/dl.h>
+#include <grub/boot_cmd.h>
+
+static const struct grub_arg_option options[] =
+  {
+    {"force", 'f', 0, "Skip bootsector magic number test.", 0, 0},
+    {0, 0, 0, 0, 0, 0}
+  };
+
+static grub_err_t
+chainloader_command (struct grub_arg_list *state,
+		     int argc, char **args)
+{
+  grub_chainloader_flags_t flags = state[0].set ? GRUB_CHAINLOADER_FORCE : 0 ;
+  if (argc == 0)
+    grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
+  else
+    grub_chainloader_cmd(args[0],flags);
+  return grub_errno;
+}
+
+GRUB_MOD_INIT
+{
+  (void)mod; /*To stop warning */
+  grub_boot_dependency = 1; /* To be dependent on boot command
+			       (don't let gcc optimize off this symbol) */
+  grub_register_command ("chainloader", chainloader_command, GRUB_COMMAND_FLAG_BOTH,
+			 "chainloader [options] FILE", "Prepare to boot another boot loader", options);
+}
+
+GRUB_MOD_FINI
+{
+  grub_unregister_command ("chainloader");
+}
-- 
                                 Tomas 'ebi' Ebenlendr
                                 http://get.to/ebik
                                 PF 2004.47027429923




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: normal mode chainloader
  2004-06-21 18:00 normal mode chainloader Tomas Ebenlendr
@ 2004-06-22  9:00 ` Marco Gerards
  2004-06-22 11:33   ` Tomas Ebenlendr
  2004-06-22 11:41   ` Tomas Ebenlendr
  0 siblings, 2 replies; 37+ messages in thread
From: Marco Gerards @ 2004-06-22  9:00 UTC (permalink / raw)
  To: grub-devel

ebik@artax.karlin.mff.cuni.cz (Tomas Ebenlendr) writes:

> Here is patch that implements command chainloader in normal mode. It may be
> done wrong way, but it is something to talk about. I successfully tested it
> on bochs. (In fact it is so simple, that it must work.). I added an artifical
> symbol to boot.mod to get dependency of normal mode loader commands on the
> boot command.

That is really nice!

Why is the dependency of the on boot.mod required?

> P.P.S. I saw somewhere (in archive) that I should probably subscribe
> 	something for FSF. I don't understand this legal stuff, I
> 	subscribe anything good for this piece of sw if needed.
> 	(But I have no electronic signature yet :-(, I didn't need any.)

That is right.  We need copyright assignments for GRUB.  It is
required so the FSF can defend copyright violations and prevent other
legal problems (remember SCO? ;)).

> Notes on architecture dependent files:
> 	I dislike how architecture dependent files (headers, conf/*.rmk)
> 	are copied or cut&pasted between architectures. In fact my opinion
> 	is that	body of function may be architecture dependent, then it
> 	should be in architecture dir. But the interface (the prototype of
> 	the function) is architecture independent and so it shouldn't be
> 	in architecture dir (now I'm talking about loader.h).

Well, that is correct.  It needs to be cleaned up a bit.  I will do
that when I will continue the work on the PPC port.

> 	Files are same probably because powerpc is not too far from
> 	ibm-pc. But I think they shouldn't be copied. They should be
> 	somehow shared. (Ok, it is not easy to find `name' for common
> 	code (directory), but I think that same files should be linked
> 	and nearly same files should include common part.)

Most files will be changed.  The port is not complete yet.  I think we
can better discuss that later.

> 	Folowing patch modifies only i386/pc architecture, but I think
> 	that exactly same changes should be done in powerpc files.

I can do that.


From this point the comments on your patch will follow.  The patch
looked quite good.  Most comments were GCS related, I hope you
understand that a consistent coding style is important to me.

Can you please read the GCS?  I don' like commenting much on a patch
that looks quite good. ;)

> 	* commands/boot.c: Add symbol grub_boot_dependency, used for
> 	semantic dependency of commands.

Please include the function (or whatever you modify).  In this case:

 	* commands/boot.c (GRUB_MOD_INIT): Add symbol
        grub_boot_dependency, used for semantic dependency of
        commands.

> 	* include/grub/i386/pc/loader.h: added FIXME, deleted prototype
> 	of rescue command chainloader.

Please use correct punctuation.  Start your sentences with a
capital.  A better way of describing this would be:

 	* include/grub/i386/pc/loader.h (prototype_name): Deleted
 	prototype of rescue command chainloader.

> 	* loader/i386/pc/chainloader_normal.c: New file. Defines the
> 	command chainloader.

For comments and entries in the changelog start sentences with a
capital, end with a dot and add two spaces after the dot.  For
example:

/* This is a comment.  Blah blah blah.  Foo.  */

This is in the GCS.  The main reason we want this is because emacs
expects this when using auto-fill-mode.

> +/* common function for normal and rescue mode commands*/

See what I said about comments.

> +    grub_chainloader_cmd(args[0],flags);

Please use:
grub_chainloader_cmd (args[0], flags);

> +  grub_boot_dependency = 1; /* To be dependent on boot command
> +			       (don't let gcc optimize off this symbol) */

I think it is cleaner to move this comment to the line above this one.

> +  grub_register_command ("chainloader", chainloader_command, GRUB_COMMAND_FLAG_BOTH,
> +			 "chainloader [options] FILE", "Prepare to boot another boot loader", options);
> +}

Please don't use such long lines.  Many people use 80 character wide
terminals.

Thanks,
Marco




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: normal mode chainloader
  2004-06-22  9:00 ` Marco Gerards
@ 2004-06-22 11:33   ` Tomas Ebenlendr
  2004-06-22 19:52     ` Marco Gerards
  2004-06-22 11:41   ` Tomas Ebenlendr
  1 sibling, 1 reply; 37+ messages in thread
From: Tomas Ebenlendr @ 2004-06-22 11:33 UTC (permalink / raw)
  To: The development of GRUB 2

> Why is the dependency of the on boot.mod required?

Because users will be confused if they can do some loader cmd and can't
boot cmd. No other reason.

> > P.P.S. I saw somewhere (in archive) that I should probably subscribe
> > 	something for FSF. ...
> 
> That is right.  We need copyright assignments for GRUB.  It is
> required so the FSF can defend copyright violations and prevent other
> legal problems (remember SCO? ;)).
> 
O.k. how?

> Can you please read the GCS?  I don' like commenting much on a patch
> that looks quite good. ;)

I have read it, but I'm used on another coding style, which we used for
our school project. (There are some things in GCS which we disagree.)
I will write better code after about 500 lines with GCS.


> grub_chainloader_cmd (args[0], flags);

Oh, sorry. That is the higlighting of operators. It seems readable

> 
> Please don't use such long lines.  Many people use 80 character wide
> terminals.
> 

I know, I'm used on automatic wrapping, but it works not in c source.
(I must create syntax higlighing which will show 78. char as error.)

-- 
                                 Tomas 'ebi' Ebenlendr
                                 http://get.to/ebik
                                 PF 2004.47417431947




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: normal mode chainloader
  2004-06-22  9:00 ` Marco Gerards
  2004-06-22 11:33   ` Tomas Ebenlendr
@ 2004-06-22 11:41   ` Tomas Ebenlendr
  2004-06-22 20:25     ` Marco Gerards
  1 sibling, 1 reply; 37+ messages in thread
From: Tomas Ebenlendr @ 2004-06-22 11:41 UTC (permalink / raw)
  To: The development of GRUB 2


Hm, I forgot to append the new version. (It fixes only the GCS-compliancy,
as you commented the patch).


Changelog:
2004-06-21  Tomas Ebenlendr  <ebik@ucw.cz>

	Added normal mode command `chainloader' as module chain.mod,
	which depends on normal.mod and _chain.mod. There is also added
	dependency to boot.mod because of semantic dependency of these
	commands.

	* commands/boot.c (GRUB_MOD_INIT): Add symbol
	grub_boot_dependency, used forsemantic dependency of
	commands.
	* conf/i386-pc.rmk: Add i386/pc/chainloader_normal.c as
	chain.mod.
	* include/grub/boot_cmd.h: New file. The semantic dependency
	of loader commands and boot command.
	* include/grub/i386/pc/chainloader.h: New file. Exports
	body of chainloader command.
	* include/grub/i386/pc/loader.h (grub_rescue_cmd_chainloader):
	Delete prototype of rescue command chainloader.
	* loader/i386/pc/chainloader.c (grub_rescue_cmd_chainloader):
	all but arguments parsing moved to ...
	(grub_chainloader_cmd): ... this.
	* loader/i386/pc/chainloader_normal.c: New file. Defines the
	command chainloader.


diff -rupN -x CVS grub2_x/commands/boot.c grub2_work/commands/boot.c
--- grub2_x/commands/boot.c	2004-06-05 00:20:17.000000000 +0200
+++ grub2_work/commands/boot.c	2004-06-21 01:42:05.000000000 +0200
@@ -24,6 +24,8 @@
 #include <grub/misc.h>
 #include <grub/loader.h>
 
+int grub_boot_dependency;
+
 static grub_err_t
 grub_cmd_boot (struct grub_arg_list *state __attribute__ ((unused)),
 	       int argc, char **args __attribute__ ((unused)))
@@ -54,6 +56,8 @@ grub_boot_fini (void)
 GRUB_MOD_INIT
 {
   (void)mod;			/* To stop warning. */
+  grub_boot_dependency = 1; /* To let be loader commands dependent on this command
+			       (don't let gcc optimize off this symbol) */
   grub_register_command ("boot", grub_cmd_boot, GRUB_COMMAND_FLAG_BOTH,
 			 "boot", "Boot an operating system", 0);
 }
diff -rupN -x CVS grub2_x/conf/i386-pc.mk grub2_work/conf/i386-pc.mk
--- grub2_x/conf/i386-pc.mk	2004-06-05 00:20:17.000000000 +0200
+++ grub2_work/conf/i386-pc.mk	2004-06-21 01:16:47.000000000 +0200
@@ -717,7 +717,7 @@ genmoddep-util_genmoddep.d: util/genmodd
 
 # Modules.
 pkgdata_MODULES = _chain.mod _linux.mod fat.mod ufs.mod ext2.mod minix.mod normal.mod hello.mod \
-	 vga.mod font.mod _multiboot.mod ls.mod boot.mod cmp.mod cat.mod terminal.mod
+	 vga.mod font.mod _multiboot.mod ls.mod boot.mod cmp.mod cat.mod terminal.mod chain.mod
 
 # For _chain.mod.
 _chain_mod_SOURCES = loader/i386/pc/chainloader.c
@@ -758,6 +758,45 @@ _chain_mod-loader_i386_pc_chainloader.d:
 
 _chain_mod_CFLAGS = $(COMMON_CFLAGS)
 
+# For chain.mod.
+chain_mod_SOURCES = loader/i386/pc/chainloader_normal.c
+CLEANFILES += chain.mod mod-chain.o mod-chain.c pre-chain.o chain_mod-loader_i386_pc_chainloader_normal.o def-chain.lst und-chain.lst
+MOSTLYCLEANFILES += chain_mod-loader_i386_pc_chainloader_normal.d
+DEFSYMFILES += def-chain.lst
+UNDSYMFILES += und-chain.lst
+
+chain.mod: pre-chain.o mod-chain.o
+	-rm -f $@
+	$(LD) -r -o $@ $^
+	$(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
+
+pre-chain.o: chain_mod-loader_i386_pc_chainloader_normal.o
+	-rm -f $@
+	$(LD) -r -o $@ $^
+
+mod-chain.o: mod-chain.c
+	$(CC) $(CPPFLAGS) $(CFLAGS) $(chain_mod_CFLAGS) -c -o $@ $<
+
+mod-chain.c: moddep.lst genmodsrc.sh
+	sh $(srcdir)/genmodsrc.sh 'chain' $< > $@ || (rm -f $@; exit 1)
+
+def-chain.lst: pre-chain.o
+	$(NM) -g --defined-only -P -p $< | sed 's/^\([^ ]*\).*/\1 chain/' > $@
+
+und-chain.lst: pre-chain.o
+	echo 'chain' > $@
+	$(NM) -u -P -p $< | cut -f1 -d' ' >> $@
+
+chain_mod-loader_i386_pc_chainloader_normal.o: loader/i386/pc/chainloader_normal.c
+	$(CC) -Iloader/i386/pc -I$(srcdir)/loader/i386/pc $(CPPFLAGS) $(CFLAGS) $(chain_mod_CFLAGS) -c -o $@ $<
+
+chain_mod-loader_i386_pc_chainloader_normal.d: loader/i386/pc/chainloader_normal.c
+	set -e; 	  $(CC) -Iloader/i386/pc -I$(srcdir)/loader/i386/pc $(CPPFLAGS) $(CFLAGS) $(chain_mod_CFLAGS) -M $< 	  | sed 's,chainloader_normal\.o[ :]*,chain_mod-loader_i386_pc_chainloader_normal.o $@ : ,g' > $@; 	  [ -s $@ ] || rm -f $@
+
+-include chain_mod-loader_i386_pc_chainloader_normal.d
+
+chain_mod_CFLAGS = $(COMMON_CFLAGS)
+
 # For fat.mod.
 fat_mod_SOURCES = fs/fat.c
 CLEANFILES += fat.mod mod-fat.o mod-fat.c pre-fat.o fat_mod-fs_fat.o def-fat.lst und-fat.lst
diff -rupN -x CVS grub2_x/conf/i386-pc.rmk grub2_work/conf/i386-pc.rmk
--- grub2_x/conf/i386-pc.rmk	2004-06-05 00:20:17.000000000 +0200
+++ grub2_work/conf/i386-pc.rmk	2004-06-21 01:16:12.000000000 +0200
@@ -74,12 +74,16 @@ genmoddep_SOURCES = util/genmoddep.c
 
 # Modules.
 pkgdata_MODULES = _chain.mod _linux.mod fat.mod ufs.mod ext2.mod minix.mod normal.mod hello.mod \
-	 vga.mod font.mod _multiboot.mod ls.mod boot.mod cmp.mod cat.mod terminal.mod
+	 vga.mod font.mod _multiboot.mod ls.mod boot.mod cmp.mod cat.mod terminal.mod chain.mod
 
 # For _chain.mod.
 _chain_mod_SOURCES = loader/i386/pc/chainloader.c
 _chain_mod_CFLAGS = $(COMMON_CFLAGS)
 
+# For chain.mod.
+chain_mod_SOURCES = loader/i386/pc/chainloader_normal.c
+chain_mod_CFLAGS = $(COMMON_CFLAGS)
+
 # For fat.mod.
 fat_mod_SOURCES = fs/fat.c
 fat_mod_CFLAGS = $(COMMON_CFLAGS)
diff -rupN -x CVS grub2_x/include/grub/boot_cmd.h grub2_work/include/grub/boot_cmd.h
--- grub2_x/include/grub/boot_cmd.h	1970-01-01 01:00:00.000000000 +0100
+++ grub2_work/include/grub/boot_cmd.h	2004-06-21 01:33:53.000000000 +0200
@@ -0,0 +1,26 @@
+/* This file is intended as command dependency */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2002  Free Software Foundation, Inc.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef GRUB_BOOT_CMD_HEADER
+#define GRUB_BOOT_CMD_HEADER	1
+
+extern int EXPORT_VAR(grub_boot_dependency);
+
+#endif /* ! GRUB_BOOT_CMD_HEADER */
diff -rupN -x CVS grub2_x/include/grub/i386/pc/chainloader.h grub2_work/include/grub/i386/pc/chainloader.h
--- grub2_x/include/grub/i386/pc/chainloader.h	1970-01-01 01:00:00.000000000 +0100
+++ grub2_work/include/grub/i386/pc/chainloader.h	2004-06-21 01:19:52.000000000 +0200
@@ -0,0 +1,34 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2004  Free Software Foundation, Inc.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef GRUB_CHAINLOADER_MACHINE_HEADER
+#define GRUB_CHAINLOADER_MACHINE_HEADER	1
+
+#include <grub/dl.h>
+
+/* Common function for normal and rescue mode commands. */
+typedef enum
+  {
+    GRUB_CHAINLOADER_FORCE = 0x1
+  }
+grub_chainloader_flags_t;
+
+void EXPORT_FUNC(grub_chainloader_cmd) (const char * file,grub_chainloader_flags_t flags);
+
+#endif /* ! GRUB_CHAINLOADER_MACHINE_HEADER */
diff -rupN -x CVS grub2_x/include/grub/i386/pc/loader.h grub2_work/include/grub/i386/pc/loader.h
--- grub2_x/include/grub/i386/pc/loader.h	2004-06-05 00:20:17.000000000 +0200
+++ grub2_work/include/grub/i386/pc/loader.h	2004-06-21 01:50:48.000000000 +0200
@@ -41,7 +41,8 @@ void EXPORT_FUNC(grub_multiboot_real_boo
 
 /* It is necessary to export these functions, because normal mode commands
    reuse rescue mode commands.  */
-void grub_rescue_cmd_chainloader (int argc, char *argv[]);
+/* FIXME these commands should be divided to argument parsing and real work, and moved to
+ * respective headers*/
 void grub_rescue_cmd_linux (int argc, char *argv[]);
 void grub_rescue_cmd_initrd (int argc, char *argv[]);
 void grub_rescue_cmd_multiboot (int argc, char *argv[]);
diff -rupN -x CVS grub2_x/loader/i386/pc/chainloader.c grub2_work/loader/i386/pc/chainloader.c
--- grub2_x/loader/i386/pc/chainloader.c	2004-06-05 00:20:18.000000000 +0200
+++ grub2_work/loader/i386/pc/chainloader.c	2004-06-21 00:41:54.000000000 +0200
@@ -20,6 +20,7 @@
 
 #include <grub/loader.h>
 #include <grub/machine/loader.h>
+#include <grub/machine/chainloader.h>
 #include <grub/file.h>
 #include <grub/err.h>
 #include <grub/device.h>
@@ -82,28 +83,15 @@ grub_chainloader_unload (void)
 }
 
 void
-grub_rescue_cmd_chainloader (int argc, char *argv[])
+grub_chainloader_cmd(const char * filename, grub_chainloader_flags_t flags)
 {
   grub_file_t file = 0;
   grub_uint16_t signature;
-  int force = 0;
 
   grub_dl_ref (my_mod);
   
-  if (argc > 0 && grub_strcmp (argv[0], "--force") == 0)
-    {
-      force = 1;
-      argc--;
-      argv++;
-    }
 
-  if (argc == 0)
-    {
-      grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
-      goto fail;
-    }
-
-  file = grub_file_open (argv[0]);
+  file = grub_file_open (filename);
   if (! file)
     goto fail;
 
@@ -119,7 +107,7 @@ grub_rescue_cmd_chainloader (int argc, c
 
   /* Check the signature.  */
   signature = *((grub_uint16_t *) (0x7C00 + GRUB_DISK_SECTOR_SIZE - 2));
-  if (signature != grub_le_to_cpu16 (0xaa55) && ! force)
+  if (signature != grub_le_to_cpu16 (0xaa55) && ! (flags & GRUB_CHAINLOADER_FORCE) )
     {
       grub_error (GRUB_ERR_BAD_OS, "invalid signature");
       goto fail;
@@ -137,6 +125,25 @@ grub_rescue_cmd_chainloader (int argc, c
   grub_dl_unref (my_mod);
 }
 
+static void
+grub_rescue_cmd_chainloader (int argc, char *argv[])
+{
+  grub_chainloader_flags_t flags = 0;
+
+  if (argc > 0 && grub_strcmp (argv[0], "--force") == 0)
+    {
+      flags |= GRUB_CHAINLOADER_FORCE;
+      argc--;
+      argv++;
+    }
+
+  if (argc == 0)
+      grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
+  else
+    grub_chainloader_cmd (argv[0], flags);
+}
+
+
 static const char loader_name[] = "chainloader";
 
 GRUB_MOD_INIT
diff -rupN -x CVS grub2_x/loader/i386/pc/chainloader_normal.c grub2_work/loader/i386/pc/chainloader_normal.c
--- grub2_x/loader/i386/pc/chainloader_normal.c	1970-01-01 01:00:00.000000000 +0100
+++ grub2_work/loader/i386/pc/chainloader_normal.c	2004-06-21 01:42:45.000000000 +0200
@@ -0,0 +1,59 @@
+/* chainloader_normal.c - boot another boot loader */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2004  Free Software Foundation, Inc.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <grub/machine/chainloader.h>
+#include <grub/err.h>
+#include <grub/normal.h>
+#include <grub/dl.h>
+#include <grub/boot_cmd.h>
+
+static const struct grub_arg_option options[] =
+  {
+    {"force", 'f', 0, "Skip bootsector magic number test.", 0, 0},
+    {0, 0, 0, 0, 0, 0}
+  };
+
+static grub_err_t
+chainloader_command (struct grub_arg_list *state,
+		     int argc, char **args)
+{
+  grub_chainloader_flags_t flags = state[0].set ? GRUB_CHAINLOADER_FORCE : 0 ;
+  if (argc == 0)
+    grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
+  else
+    grub_chainloader_cmd(args[0],flags);
+  return grub_errno;
+}
+
+GRUB_MOD_INIT
+{
+  (void)mod; /*To stop warning */
+  grub_boot_dependency = 1; /* To be dependent on boot command
+			       (don't let gcc optimize off this symbol) */
+  grub_register_command ("chainloader", chainloader_command,
+			  GRUB_COMMAND_FLAG_BOTH,
+			  "chainloader [options] FILE",
+			  "Prepare to boot another boot loader", options);
+}
+
+GRUB_MOD_FINI
+{
+  grub_unregister_command ("chainloader");
+}
-- 
                                 Tomas 'ebi' Ebenlendr
                                 http://get.to/ebik
                                 PF 2004.4742311779




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: normal mode chainloader
  2004-06-22 11:33   ` Tomas Ebenlendr
@ 2004-06-22 19:52     ` Marco Gerards
  2004-06-23  7:10       ` Tomas Ebenlendr
  0 siblings, 1 reply; 37+ messages in thread
From: Marco Gerards @ 2004-06-22 19:52 UTC (permalink / raw)
  To: The development of GRUB 2

ebik@artax.karlin.mff.cuni.cz (Tomas Ebenlendr) writes:

>> Why is the dependency of the on boot.mod required?
>
> Because users will be confused if they can do some loader cmd and can't
> boot cmd. No other reason.

This will be fixed by the autoloading that was proposed on the list.
If someone uses the boot command, the boot.mod will be autoloaded.  So
I think it is not a requirement.

>> > P.P.S. I saw somewhere (in archive) that I should probably subscribe
>> > 	something for FSF. ...
>> 
>> That is right.  We need copyright assignments for GRUB.  It is
>> required so the FSF can defend copyright violations and prevent other
>> legal problems (remember SCO? ;)).
>> 
> O.k. how?

I think Okuji should take care of that...

>> Can you please read the GCS?  I don' like commenting much on a patch
>> that looks quite good. ;)
>
> I have read it, but I'm used on another coding style, which we used for
> our school project. (There are some things in GCS which we disagree.)
> I will write better code after about 500 lines with GCS.

Ok, I have the same problems sometimes.  Hopefully you won't mind if I
continue sending comments in the meanwhile.

Thanks,
Marco




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: normal mode chainloader
  2004-06-22 11:41   ` Tomas Ebenlendr
@ 2004-06-22 20:25     ` Marco Gerards
  2004-06-23  7:29       ` Tomas Ebenlendr
                         ` (2 more replies)
  0 siblings, 3 replies; 37+ messages in thread
From: Marco Gerards @ 2004-06-22 20:25 UTC (permalink / raw)
  To: The development of GRUB 2

ebik@artax.karlin.mff.cuni.cz (Tomas Ebenlendr) writes:

> Hm, I forgot to append the new version. (It fixes only the GCS-compliancy,
> as you commented the patch).

Ok, here are the comments I still have, to be complete.  These
comments are only related to the GCS.

In my other email I told you what I thought of the boot.mod
dependency.  If that is worked out all you need is Okuji's blessing,
after that I will commit the patch (that reminds me about some other
patches I will commit real soon... :-/).

No need to go through this patch again.  Please do what you can do
while fixing this patch to the outcome of the discussing about the
boot.mod dependency, I will do the rest before committing.

> 	* commands/boot.c (GRUB_MOD_INIT): Add symbol
> 	grub_boot_dependency, used forsemantic dependency of
> 	commands.
> 	* conf/i386-pc.rmk: Add i386/pc/chainloader_normal.c as
> 	chain.mod.

Please include (chain_mod_SOURCES) here, like you did with
(GRUB_MODE_INIT).  Same for adding chain.mod to pkgdata_MODULES.  You
should notice you renamed _chain.mod to chain.mod.

> 	* include/grub/i386/pc/loader.h (grub_rescue_cmd_chainloader):
> 	Delete prototype of rescue command chainloader.

Ok, although I prefer `Deleted prototype' (or short `Deleted').

> +  grub_boot_dependency = 1; /* To let be loader commands dependent on this command
> +			       (don't let gcc optimize off this symbol) */

Please fix the comment.  I would use:


/* To let be loader commands dependent on this command (don't let gcc
   optimize off this symbol).  */
grub_boot_dependency = 1;

(Notice the `.' and the two spaces)

> diff -rupN -x CVS grub2_x/include/grub/boot_cmd.h grub2_work/include/grub/boot_cmd.h
> --- grub2_x/include/grub/boot_cmd.h	1970-01-01 01:00:00.000000000 +0100
> +++ grub2_work/include/grub/boot_cmd.h	2004-06-21 01:33:53.000000000 +0200
> @@ -0,0 +1,26 @@
> +/* This file is intended as command dependency */
> +/*
> + *  GRUB  --  GRand Unified Bootloader
> + *  Copyright (C) 2002  Free Software Foundation, Inc.

copyright crap: You have to update the copyright years.  In this case
add 2004.  AFAIK you should not use short notations or ranges, just
list the years like:

 *  Copyright (C) 2002, 2004  Free Software Foundation, Inc.

> +typedef enum
> +  {
> +    GRUB_CHAINLOADER_FORCE = 0x1
> +  }
> +grub_chainloader_flags_t;

I think this should be:

 } grub_chainloader_flags_t;

> +void EXPORT_FUNC(grub_chainloader_cmd) (const char * file,grub_chainloader_flags_t flags);

A long line...

> +/* FIXME these commands should be divided to argument parsing and real work, and moved to
> + * respective headers*/

Please fix this comment.

> -  if (signature != grub_le_to_cpu16 (0xaa55) && ! force)
> +  if (signature != grub_le_to_cpu16 (0xaa55) && ! (flags & GRUB_CHAINLOADER_FORCE) )

A long lines.  And the last parenthesis should not be separated with a
space.  This would be better:

if (signature != grub_le_to_cpu16 (0xaa55) 
    && ! (flags & GRUB_CHAINLOADER_FORCE))

> +  grub_boot_dependency = 1; /* To be dependent on boot command
> +			       (don't let gcc optimize off this symbol) */

The formatting of the comments is not correct.

Thanks,
Marco




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: normal mode chainloader
  2004-06-22 19:52     ` Marco Gerards
@ 2004-06-23  7:10       ` Tomas Ebenlendr
  2004-06-23 10:34         ` Yoshinori K. Okuji
  0 siblings, 1 reply; 37+ messages in thread
From: Tomas Ebenlendr @ 2004-06-23  7:10 UTC (permalink / raw)
  To: The development of GRUB 2

> >> Why is the dependency of the on boot.mod required?
> >
> > Because users will be confused if they can do some loader cmd and can't
> > boot cmd. No other reason.
> 
> This will be fixed by the autoloading that was proposed on the list.
> If someone uses the boot command, the boot.mod will be autoloaded.  So
> I think it is not a requirement.

That is not true in all cases. E.g. when there is corrupted or missing
boot.mod, or when autoloading is off. 

-- 
                                 Tomas 'ebi' Ebenlendr
                                 http://get.to/ebik
                                 PF 2004.47644321747




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: normal mode chainloader
  2004-06-22 20:25     ` Marco Gerards
@ 2004-06-23  7:29       ` Tomas Ebenlendr
  2004-06-23 10:55         ` Marco Gerards
  2004-06-23  8:11       ` Copyright crap Was: " Tomas Ebenlendr
  2004-06-23 11:58       ` Tomas Ebenlendr
  2 siblings, 1 reply; 37+ messages in thread
From: Tomas Ebenlendr @ 2004-06-23  7:29 UTC (permalink / raw)
  To: The development of GRUB 2

> 
> Please include (chain_mod_SOURCES) here, like you did with
> (GRUB_MODE_INIT).  Same for adding chain.mod to pkgdata_MODULES.  You
> should notice you renamed _chain.mod to chain.mod.

No, I didn't. I created new module chain.mod that depends on _chain.mod.
I will prefer naming chain_n.mod and chain_r.mod, but naming was not
decided so I use old one.

> copyright crap: You have to update the copyright years.  In this case
> add 2004.  AFAIK you should not use short notations or ranges, just
> list the years like:
> 
>  *  Copyright (C) 2002, 2004  Free Software Foundation, Inc.

Here should be probably only 2004, I copied another file, and deleted
all but copiright. I forgot to change the year. I will try to update
the modified files.

-- 
                                 Tomas 'ebi' Ebenlendr
                                 http://get.to/ebik
                                 PF 2004.47645776412




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Copyright crap Was: Re: normal mode chainloader
  2004-06-22 20:25     ` Marco Gerards
  2004-06-23  7:29       ` Tomas Ebenlendr
@ 2004-06-23  8:11       ` Tomas Ebenlendr
  2004-06-23  8:59         ` Jeroen Dekkers
  2004-06-23 11:58       ` Tomas Ebenlendr
  2 siblings, 1 reply; 37+ messages in thread
From: Tomas Ebenlendr @ 2004-06-23  8:11 UTC (permalink / raw)
  To: The development of GRUB 2


I think there should be copyright in:
conf/i386-pc.rmk,
autogen.sh. Here is the patch. Please fix years if they are wrong.

Changelog:
2004-06-23  Tomas Ebenlendr  <ebik@ucw.cz>

	* autogen.sh: Add copyright.
	* conf/i386-pc.rmk: Likewise.
	* conf/powerpc-ieee1275.rmk: Likewise.

diff -rupN -x CVS grub2_x/autogen.sh grub2_work/autogen.sh
--- grub2_x/autogen.sh	2004-06-05 00:20:17.000000000 +0200
+++ grub2_work/autogen.sh	2004-06-23 09:59:03.000000000 +0200
@@ -1,4 +1,15 @@
 #! /bin/sh
+#
+# Copyright (C) 2002  Free Software Foundation, Inc.
+#
+# This gensymlist.sh is free software; the author
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
 
 set -e
 
diff -rupN -x CVS grub2_x/conf/i386-pc.mk grub2_work/conf/i386-pc.mk
--- grub2_x/conf/i386-pc.mk	2004-06-23 09:58:16.000000000 +0200
+++ grub2_work/conf/i386-pc.mk	2004-06-23 09:59:43.000000000 +0200
@@ -1,4 +1,15 @@
 # -*- makefile -*-
+#
+# Copyright (C) 2002,2003,2004  Free Software Foundation, Inc.
+#
+# This gensymlist.sh is free software; the author
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
 
 COMMON_ASFLAGS = -nostdinc -fno-builtin
 COMMON_CFLAGS = -fno-builtin -mrtd -mregparm=3
diff -rupN -x CVS grub2_x/conf/i386-pc.rmk grub2_work/conf/i386-pc.rmk
--- grub2_x/conf/i386-pc.rmk	2004-06-23 09:58:16.000000000 +0200
+++ grub2_work/conf/i386-pc.rmk	2004-06-23 10:00:47.000000000 +0200
@@ -1,4 +1,15 @@
 # -*- makefile -*-
+#
+# Copyright (C) 2002,2003,2004  Free Software Foundation, Inc.
+#
+# This gensymlist.sh is free software; the author
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
 
 COMMON_ASFLAGS = -nostdinc -fno-builtin
 COMMON_CFLAGS = -fno-builtin -mrtd -mregparm=3
diff -rupN -x CVS grub2_x/conf/powerpc-ieee1275.mk grub2_work/conf/powerpc-ieee1275.mk
--- grub2_x/conf/powerpc-ieee1275.mk	2004-06-05 00:20:17.000000000 +0200
+++ grub2_work/conf/powerpc-ieee1275.mk	2004-06-23 10:00:36.000000000 +0200
@@ -1,5 +1,15 @@
-
 # -*- makefile -*-
+#
+# Copyright (C) 2002,2003,2004  Free Software Foundation, Inc.
+#
+# This gensymlist.sh is free software; the author
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
 
 COMMON_ASFLAGS = -nostdinc -fno-builtin -D__ASSEMBLY__
 COMMON_CFLAGS = -fno-builtin -D__ASSEMBLY__
diff -rupN -x CVS grub2_x/conf/powerpc-ieee1275.rmk grub2_work/conf/powerpc-ieee1275.rmk
--- grub2_x/conf/powerpc-ieee1275.rmk	2004-06-05 00:20:17.000000000 +0200
+++ grub2_work/conf/powerpc-ieee1275.rmk	2004-06-23 10:00:07.000000000 +0200
@@ -1,5 +1,15 @@
-
 # -*- makefile -*-
+#
+# Copyright (C) 2002,2003,2004  Free Software Foundation, Inc.
+#
+# This gensymlist.sh is free software; the author
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
 
 COMMON_ASFLAGS = -nostdinc -fno-builtin -D__ASSEMBLY__
 COMMON_CFLAGS = -fno-builtin -D__ASSEMBLY__
-- 
                                 Tomas 'ebi' Ebenlendr
                                 http://get.to/ebik
                                 PF 2004.4765193344




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Copyright crap Was: Re: normal mode chainloader
  2004-06-23  8:11       ` Copyright crap Was: " Tomas Ebenlendr
@ 2004-06-23  8:59         ` Jeroen Dekkers
  2004-06-23 10:43           ` Tomas Ebenlendr
  0 siblings, 1 reply; 37+ messages in thread
From: Jeroen Dekkers @ 2004-06-23  8:59 UTC (permalink / raw)
  To: The development of GRUB 2

At Wed, 23 Jun 2004 10:11:43 +0200,
Tomas Ebenlendr wrote:
> diff -rupN -x CVS grub2_x/conf/i386-pc.rmk grub2_work/conf/i386-pc.rmk
> --- grub2_x/conf/i386-pc.rmk	2004-06-23 09:58:16.000000000 +0200
> +++ grub2_work/conf/i386-pc.rmk	2004-06-23 10:00:47.000000000 +0200
> @@ -1,4 +1,15 @@
>  # -*- makefile -*-
> +#
> +# Copyright (C) 2002,2003,2004  Free Software Foundation, Inc.
> +#
> +# This gensymlist.sh is free software; the author
     	  ^^^^^^^^^^^^^
> +# gives unlimited permission to copy and/or distribute it,
> +# with or without modifications, as long as this notice is preserved.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
> +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
> +# PARTICULAR PURPOSE.

You should probably change "this gensymlist.sh" to "this file".

I also think it's okay to put the build script just under the GPL. I
don't see a reason for not doing it.

Jeroen Dekkers



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: normal mode chainloader
  2004-06-23  7:10       ` Tomas Ebenlendr
@ 2004-06-23 10:34         ` Yoshinori K. Okuji
  2004-06-23 10:40           ` Tomas Ebenlendr
  0 siblings, 1 reply; 37+ messages in thread
From: Yoshinori K. Okuji @ 2004-06-23 10:34 UTC (permalink / raw)
  To: The development of GRUB 2

On Wednesday 23 June 2004 09:10, Tomas Ebenlendr wrote:
> > This will be fixed by the autoloading that was proposed on the
> > list. If someone uses the boot command, the boot.mod will be
> > autoloaded.  So I think it is not a requirement.
>
> That is not true in all cases. E.g. when there is corrupted or
> missing boot.mod, or when autoloading is off.

If you cannot load boot.mod for a reason, what you get is the same as 
when a loader module cannot be loaded: The difference is only that you 
cannot execute boot or, say, linux. For ordinary users, these look 
identical. The only solution for these cases is to go back to the 
rescue mode and boot something from it. Then, there is no way to 
provide a good interface anyway.

If autoloading is off (although I'm not sure if it is better to allow 
the user to turn it off), the user should know what he/she does. He/She 
should load all required modules explicitly. This means that this 
person knows how GRUB works. For this person, it is no problem to load 
boot.mod manually.

Okuji



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: normal mode chainloader
  2004-06-23 10:34         ` Yoshinori K. Okuji
@ 2004-06-23 10:40           ` Tomas Ebenlendr
  0 siblings, 0 replies; 37+ messages in thread
From: Tomas Ebenlendr @ 2004-06-23 10:40 UTC (permalink / raw)
  To: The development of GRUB 2

> 
> If you cannot load boot.mod for a reason, what you get is the same as 
> when a loader module cannot be loaded: The difference is only that you 
> cannot execute boot or, say, linux. For ordinary users, these look 
> identical. The only solution for these cases is to go back to the 
> rescue mode and boot something from it. Then, there is no way to 
> provide a good interface anyway.
> 
> If autoloading is off (although I'm not sure if it is better to allow 
> the user to turn it off), the user should know what he/she does. He/She 
> should load all required modules explicitly. This means that this 
> person knows how GRUB works. For this person, it is no problem to load 
> boot.mod manually.
> 
> Okuji
> 

Okay, I have no other arguments for it, so
I will post next patch without the dependency symbol. 

-- 
                                 Tomas 'ebi' Ebenlendr
                                 http://get.to/ebik
                                 PF 2004.47684872116




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Copyright crap Was: Re: normal mode chainloader
  2004-06-23  8:59         ` Jeroen Dekkers
@ 2004-06-23 10:43           ` Tomas Ebenlendr
  0 siblings, 0 replies; 37+ messages in thread
From: Tomas Ebenlendr @ 2004-06-23 10:43 UTC (permalink / raw)
  To: The development of GRUB 2

> 
> You should probably change "this gensymlist.sh" to "this file".
> 

Yes I should read what I copy.

This should be correct (If the years match).:

Changelog:
2004-06-23  Tomas Ebenlendr  <ebik@ucw.cz>

	* autogen.sh: Add copyright.
	* conf/i386-pc.rmk: Likewise.
	* conf/powerpc-ieee1275.rmk: Likewise.

diff -rupN -x CVS grub2_x/autogen.sh grub2_work/autogen.sh
--- grub2_x/autogen.sh	2004-06-05 00:20:17.000000000 +0200
+++ grub2_work/autogen.sh	2004-06-23 09:59:03.000000000 +0200
@@ -1,4 +1,15 @@
 #! /bin/sh
+#
+# Copyright (C) 2002  Free Software Foundation, Inc.
+#
+# This autogen.sh is free software; the author
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
 
 set -e
 
diff -rupN -x CVS grub2_x/conf/i386-pc.mk grub2_work/conf/i386-pc.mk
--- grub2_x/conf/i386-pc.mk	2004-06-23 09:58:16.000000000 +0200
+++ grub2_work/conf/i386-pc.mk	2004-06-23 09:59:43.000000000 +0200
@@ -1,4 +1,15 @@
 # -*- makefile -*-
+#
+# Copyright (C) 2002,2003,2004  Free Software Foundation, Inc.
+#
+# This makefile is free software; the author
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
 
 COMMON_ASFLAGS = -nostdinc -fno-builtin
 COMMON_CFLAGS = -fno-builtin -mrtd -mregparm=3
diff -rupN -x CVS grub2_x/conf/i386-pc.rmk grub2_work/conf/i386-pc.rmk
--- grub2_x/conf/i386-pc.rmk	2004-06-23 09:58:16.000000000 +0200
+++ grub2_work/conf/i386-pc.rmk	2004-06-23 10:00:47.000000000 +0200
@@ -1,4 +1,15 @@
 # -*- makefile -*-
+#
+# Copyright (C) 2002,2003,2004  Free Software Foundation, Inc.
+#
+# This makefile is free software; the author
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
 
 COMMON_ASFLAGS = -nostdinc -fno-builtin
 COMMON_CFLAGS = -fno-builtin -mrtd -mregparm=3
diff -rupN -x CVS grub2_x/conf/powerpc-ieee1275.mk grub2_work/conf/powerpc-ieee1275.mk
--- grub2_x/conf/powerpc-ieee1275.mk	2004-06-05 00:20:17.000000000 +0200
+++ grub2_work/conf/powerpc-ieee1275.mk	2004-06-23 10:00:36.000000000 +0200
@@ -1,5 +1,15 @@
-
 # -*- makefile -*-
+#
+# Copyright (C) 2002,2003,2004  Free Software Foundation, Inc.
+#
+# This makefile is free software; the author
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
 
 COMMON_ASFLAGS = -nostdinc -fno-builtin -D__ASSEMBLY__
 COMMON_CFLAGS = -fno-builtin -D__ASSEMBLY__
diff -rupN -x CVS grub2_x/conf/powerpc-ieee1275.rmk grub2_work/conf/powerpc-ieee1275.rmk
--- grub2_x/conf/powerpc-ieee1275.rmk	2004-06-05 00:20:17.000000000 +0200
+++ grub2_work/conf/powerpc-ieee1275.rmk	2004-06-23 10:00:07.000000000 +0200
@@ -1,5 +1,15 @@
-
 # -*- makefile -*-
+#
+# Copyright (C) 2002,2003,2004  Free Software Foundation, Inc.
+#
+# This makefile is free software; the author
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
 
 COMMON_ASFLAGS = -nostdinc -fno-builtin -D__ASSEMBLY__
 COMMON_CFLAGS = -fno-builtin -D__ASSEMBLY__
-- 
                                 Tomas 'ebi' Ebenlendr
                                 http://get.to/ebik
                                 PF 2004.47685289542




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: normal mode chainloader
  2004-06-23  7:29       ` Tomas Ebenlendr
@ 2004-06-23 10:55         ` Marco Gerards
  2004-06-23 17:20           ` Jeroen Dekkers
  0 siblings, 1 reply; 37+ messages in thread
From: Marco Gerards @ 2004-06-23 10:55 UTC (permalink / raw)
  To: The development of GRUB 2

ebik@artax.karlin.mff.cuni.cz (Tomas Ebenlendr) writes:

>> 
>> copyright crap: You have to update the copyright years.  In this case
>> add 2004.  AFAIK you should not use short notations or ranges, just
>> list the years like:
>> 
>>  *  Copyright (C) 2002, 2004  Free Software Foundation, Inc.
>
> Here should be probably only 2004, I copied another file, and deleted
> all but copiright. I forgot to change the year. I will try to update
> the modified files.

If it is based on another file you should use preserve those copyright
notices/years as well (AFAIK).

--
Marco




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: normal mode chainloader
  2004-06-22 20:25     ` Marco Gerards
  2004-06-23  7:29       ` Tomas Ebenlendr
  2004-06-23  8:11       ` Copyright crap Was: " Tomas Ebenlendr
@ 2004-06-23 11:58       ` Tomas Ebenlendr
  2004-06-23 16:49         ` Marco Gerards
  2004-09-12 12:46         ` Marco Gerards
  2 siblings, 2 replies; 37+ messages in thread
From: Tomas Ebenlendr @ 2004-06-23 11:58 UTC (permalink / raw)
  To: The development of GRUB 2


Okay, here is the patch without dependency symbol. (I hope it is GCS
compliant now.)

Changelog:
2004-06-21  Tomas Ebenlendr  <ebik@ucw.cz>

	Added normal mode command `chainloader' as module chain.mod,
	which depends on normal.mod and _chain.mod.

	* conf/i386-pc.rmk (pkgdata_MODULES): Add chain.mod
	(chain_mod_SOURCES, chain_mod_CFLAGS): New module.
	chain.mod is build from chainloader_normal.c
	* include/grub/i386/pc/chainloader.h: New file. Exports
	body of chainloader command.
	* include/grub/i386/pc/loader.h (grub_rescue_cmd_chainloader):
	Deleted prototype.
	* loader/i386/pc/chainloader.c (grub_rescue_cmd_chainloader):
	all but arguments parsing moved to ...
	(grub_chainloader_cmd): ... this.
	* loader/i386/pc/chainloader_normal.c: New file. Defines the
	command chainloader.


diff -rupN -x CVS grub2_x/conf/i386-pc.mk grub2_work/conf/i386-pc.mk
--- grub2_x/conf/i386-pc.mk	2004-06-05 00:20:17.000000000 +0200
+++ grub2_work/conf/i386-pc.mk	2004-06-23 09:36:55.000000000 +0200
@@ -717,7 +717,7 @@ genmoddep-util_genmoddep.d: util/genmodd
 
 # Modules.
 pkgdata_MODULES = _chain.mod _linux.mod fat.mod ufs.mod ext2.mod minix.mod normal.mod hello.mod \
-	 vga.mod font.mod _multiboot.mod ls.mod boot.mod cmp.mod cat.mod terminal.mod
+	 vga.mod font.mod _multiboot.mod ls.mod boot.mod cmp.mod cat.mod terminal.mod chain.mod
 
 # For _chain.mod.
 _chain_mod_SOURCES = loader/i386/pc/chainloader.c
@@ -758,6 +758,45 @@ _chain_mod-loader_i386_pc_chainloader.d:
 
 _chain_mod_CFLAGS = $(COMMON_CFLAGS)
 
+# For chain.mod.
+chain_mod_SOURCES = loader/i386/pc/chainloader_normal.c
+CLEANFILES += chain.mod mod-chain.o mod-chain.c pre-chain.o chain_mod-loader_i386_pc_chainloader_normal.o def-chain.lst und-chain.lst
+MOSTLYCLEANFILES += chain_mod-loader_i386_pc_chainloader_normal.d
+DEFSYMFILES += def-chain.lst
+UNDSYMFILES += und-chain.lst
+
+chain.mod: pre-chain.o mod-chain.o
+	-rm -f $@
+	$(LD) -r -o $@ $^
+	$(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
+
+pre-chain.o: chain_mod-loader_i386_pc_chainloader_normal.o
+	-rm -f $@
+	$(LD) -r -o $@ $^
+
+mod-chain.o: mod-chain.c
+	$(CC) $(CPPFLAGS) $(CFLAGS) $(chain_mod_CFLAGS) -c -o $@ $<
+
+mod-chain.c: moddep.lst genmodsrc.sh
+	sh $(srcdir)/genmodsrc.sh 'chain' $< > $@ || (rm -f $@; exit 1)
+
+def-chain.lst: pre-chain.o
+	$(NM) -g --defined-only -P -p $< | sed 's/^\([^ ]*\).*/\1 chain/' > $@
+
+und-chain.lst: pre-chain.o
+	echo 'chain' > $@
+	$(NM) -u -P -p $< | cut -f1 -d' ' >> $@
+
+chain_mod-loader_i386_pc_chainloader_normal.o: loader/i386/pc/chainloader_normal.c
+	$(CC) -Iloader/i386/pc -I$(srcdir)/loader/i386/pc $(CPPFLAGS) $(CFLAGS) $(chain_mod_CFLAGS) -c -o $@ $<
+
+chain_mod-loader_i386_pc_chainloader_normal.d: loader/i386/pc/chainloader_normal.c
+	set -e; 	  $(CC) -Iloader/i386/pc -I$(srcdir)/loader/i386/pc $(CPPFLAGS) $(CFLAGS) $(chain_mod_CFLAGS) -M $< 	  | sed 's,chainloader_normal\.o[ :]*,chain_mod-loader_i386_pc_chainloader_normal.o $@ : ,g' > $@; 	  [ -s $@ ] || rm -f $@
+
+-include chain_mod-loader_i386_pc_chainloader_normal.d
+
+chain_mod_CFLAGS = $(COMMON_CFLAGS)
+
 # For fat.mod.
 fat_mod_SOURCES = fs/fat.c
 CLEANFILES += fat.mod mod-fat.o mod-fat.c pre-fat.o fat_mod-fs_fat.o def-fat.lst und-fat.lst
diff -rupN -x CVS grub2_x/conf/i386-pc.rmk grub2_work/conf/i386-pc.rmk
--- grub2_x/conf/i386-pc.rmk	2004-06-05 00:20:17.000000000 +0200
+++ grub2_work/conf/i386-pc.rmk	2004-06-23 09:36:55.000000000 +0200
@@ -74,12 +74,16 @@ genmoddep_SOURCES = util/genmoddep.c
 
 # Modules.
 pkgdata_MODULES = _chain.mod _linux.mod fat.mod ufs.mod ext2.mod minix.mod normal.mod hello.mod \
-	 vga.mod font.mod _multiboot.mod ls.mod boot.mod cmp.mod cat.mod terminal.mod
+	 vga.mod font.mod _multiboot.mod ls.mod boot.mod cmp.mod cat.mod terminal.mod chain.mod
 
 # For _chain.mod.
 _chain_mod_SOURCES = loader/i386/pc/chainloader.c
 _chain_mod_CFLAGS = $(COMMON_CFLAGS)
 
+# For chain.mod.
+chain_mod_SOURCES = loader/i386/pc/chainloader_normal.c
+chain_mod_CFLAGS = $(COMMON_CFLAGS)
+
 # For fat.mod.
 fat_mod_SOURCES = fs/fat.c
 fat_mod_CFLAGS = $(COMMON_CFLAGS)
diff -rupN -x CVS grub2_x/include/grub/i386/pc/chainloader.h grub2_work/include/grub/i386/pc/chainloader.h
--- grub2_x/include/grub/i386/pc/chainloader.h	1970-01-01 01:00:00.000000000 +0100
+++ grub2_work/include/grub/i386/pc/chainloader.h	2004-06-23 09:36:55.000000000 +0200
@@ -0,0 +1,34 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2004  Free Software Foundation, Inc.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef GRUB_CHAINLOADER_MACHINE_HEADER
+#define GRUB_CHAINLOADER_MACHINE_HEADER	1
+
+#include <grub/dl.h>
+
+/* Common function for normal and rescue mode commands. */
+typedef enum
+  {
+    GRUB_CHAINLOADER_FORCE = 0x1
+  } grub_chainloader_flags_t;
+
+void EXPORT_FUNC(grub_chainloader_cmd) (const char * file,
+					grub_chainloader_flags_t flags);
+
+#endif /* GRUB_CHAINLOADER_MACHINE_HEADER */
diff -rupN -x CVS grub2_x/include/grub/i386/pc/loader.h grub2_work/include/grub/i386/pc/loader.h
--- grub2_x/include/grub/i386/pc/loader.h	2004-06-05 00:20:17.000000000 +0200
+++ grub2_work/include/grub/i386/pc/loader.h	2004-06-23 09:48:43.000000000 +0200
@@ -1,6 +1,6 @@
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2002,2003  Free Software Foundation, Inc.
+ *  Copyright (C) 2002,2003,2004  Free Software Foundation, Inc.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -41,7 +41,8 @@ void EXPORT_FUNC(grub_multiboot_real_boo
 
 /* It is necessary to export these functions, because normal mode commands
    reuse rescue mode commands.  */
-void grub_rescue_cmd_chainloader (int argc, char *argv[]);
+/* FIXME: These commands should be divided to argument parsing and real work,
+   and moved to respective headers.  */
 void grub_rescue_cmd_linux (int argc, char *argv[]);
 void grub_rescue_cmd_initrd (int argc, char *argv[]);
 void grub_rescue_cmd_multiboot (int argc, char *argv[]);
diff -rupN -x CVS grub2_x/loader/i386/pc/chainloader.c grub2_work/loader/i386/pc/chainloader.c
--- grub2_x/loader/i386/pc/chainloader.c	2004-06-05 00:20:18.000000000 +0200
+++ grub2_work/loader/i386/pc/chainloader.c	2004-06-23 09:49:04.000000000 +0200
@@ -1,7 +1,7 @@
 /* chainloader.c - boot another boot loader */
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2002  Free Software Foundation, Inc.
+ *  Copyright (C) 2002,2004  Free Software Foundation, Inc.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -20,6 +20,7 @@
 
 #include <grub/loader.h>
 #include <grub/machine/loader.h>
+#include <grub/machine/chainloader.h>
 #include <grub/file.h>
 #include <grub/err.h>
 #include <grub/device.h>
@@ -82,28 +83,15 @@ grub_chainloader_unload (void)
 }
 
 void
-grub_rescue_cmd_chainloader (int argc, char *argv[])
+grub_chainloader_cmd(const char * filename, grub_chainloader_flags_t flags)
 {
   grub_file_t file = 0;
   grub_uint16_t signature;
-  int force = 0;
 
   grub_dl_ref (my_mod);
   
-  if (argc > 0 && grub_strcmp (argv[0], "--force") == 0)
-    {
-      force = 1;
-      argc--;
-      argv++;
-    }
 
-  if (argc == 0)
-    {
-      grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
-      goto fail;
-    }
-
-  file = grub_file_open (argv[0]);
+  file = grub_file_open (filename);
   if (! file)
     goto fail;
 
@@ -119,7 +107,8 @@ grub_rescue_cmd_chainloader (int argc, c
 
   /* Check the signature.  */
   signature = *((grub_uint16_t *) (0x7C00 + GRUB_DISK_SECTOR_SIZE - 2));
-  if (signature != grub_le_to_cpu16 (0xaa55) && ! force)
+  if (signature != grub_le_to_cpu16 (0xaa55)
+      && ! (flags & GRUB_CHAINLOADER_FORCE))
     {
       grub_error (GRUB_ERR_BAD_OS, "invalid signature");
       goto fail;
@@ -137,6 +126,25 @@ grub_rescue_cmd_chainloader (int argc, c
   grub_dl_unref (my_mod);
 }
 
+static void
+grub_rescue_cmd_chainloader (int argc, char *argv[])
+{
+  grub_chainloader_flags_t flags = 0;
+
+  if (argc > 0 && grub_strcmp (argv[0], "--force") == 0)
+    {
+      flags |= GRUB_CHAINLOADER_FORCE;
+      argc--;
+      argv++;
+    }
+
+  if (argc == 0)
+      grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
+  else
+    grub_chainloader_cmd (argv[0], flags);
+}
+
+
 static const char loader_name[] = "chainloader";
 
 GRUB_MOD_INIT
diff -rupN -x CVS grub2_x/loader/i386/pc/chainloader_normal.c grub2_work/loader/i386/pc/chainloader_normal.c
--- grub2_x/loader/i386/pc/chainloader_normal.c	1970-01-01 01:00:00.000000000 +0100
+++ grub2_work/loader/i386/pc/chainloader_normal.c	2004-06-23 09:41:58.000000000 +0200
@@ -0,0 +1,56 @@
+/* chainloader_normal.c - boot another boot loader */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2004  Free Software Foundation, Inc.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <grub/machine/chainloader.h>
+#include <grub/err.h>
+#include <grub/normal.h>
+#include <grub/dl.h>
+
+static const struct grub_arg_option options[] =
+  {
+    {"force", 'f', 0, "Skip bootsector magic number test.", 0, 0},
+    {0, 0, 0, 0, 0, 0}
+  };
+
+static grub_err_t
+chainloader_command (struct grub_arg_list *state,
+		     int argc, char **args)
+{
+  grub_chainloader_flags_t flags = state[0].set ? GRUB_CHAINLOADER_FORCE : 0 ;
+  if (argc == 0)
+    grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
+  else
+    grub_chainloader_cmd(args[0],flags);
+  return grub_errno;
+}
+
+GRUB_MOD_INIT
+{
+  (void)mod; /*To stop warning */
+  grub_register_command ("chainloader", chainloader_command,
+			  GRUB_COMMAND_FLAG_BOTH,
+			  "chainloader [options] FILE",
+			  "Prepare to boot another boot loader", options);
+}
+
+GRUB_MOD_FINI
+{
+  grub_unregister_command ("chainloader");
+}
-- 
                                 Tomas 'ebi' Ebenlendr
                                 http://get.to/ebik
                                 PF 2004.4769815384




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: normal mode chainloader
  2004-06-23 11:58       ` Tomas Ebenlendr
@ 2004-06-23 16:49         ` Marco Gerards
  2004-06-24  8:44           ` Tomas Ebenlendr
  2004-09-12 12:46         ` Marco Gerards
  1 sibling, 1 reply; 37+ messages in thread
From: Marco Gerards @ 2004-06-23 16:49 UTC (permalink / raw)
  To: The development of GRUB 2

ebik@artax.karlin.mff.cuni.cz (Tomas Ebenlendr) writes:

> Okay, here is the patch without dependency symbol. (I hope it is GCS
> compliant now.)

Great.

I have still some questions about the patch.  How do both loaders
(that is both in normal mode and rescue mode) find the generic
chainloader?  If I understand it correctly, the chain.mod depends on
_chain.mod, but how does this work?

Does it load _normal.mod and use those symbols?  Or does it really
share the code? (so there is not dependency on the rescue mode
chainloader at all, even when it is not part of core.mod).

Perhaps it would be better to just use one sourcecode file,
chainloader.c, like this:

#ifdef GRUB_NORMAL_MODE
  the normalmode code
#else
  rescue mode code
#endif

And just put -DGRUB_NORMAL_MODE in the CFLAGS when compiling the
normal mode module.  That will make it possible to use one sourcefile
for both modes.

Perhaps I just misunderstood your patch, if that is the case, please
tell me.  Next time I try to read your entire patch a bit earlier.
Same for the other patches, I try to apply them (after cleaning them
up a bit) this weekend.  Now I am still busy with school, it is taking
longer than I have expected.  I hope you understand.

Thanks,
Marco




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: normal mode chainloader
  2004-06-23 10:55         ` Marco Gerards
@ 2004-06-23 17:20           ` Jeroen Dekkers
  0 siblings, 0 replies; 37+ messages in thread
From: Jeroen Dekkers @ 2004-06-23 17:20 UTC (permalink / raw)
  To: The development of GRUB 2

At Wed, 23 Jun 2004 12:55:36 +0200,
Marco Gerards wrote:
> 
> ebik@artax.karlin.mff.cuni.cz (Tomas Ebenlendr) writes:
> 
> >> 
> >> copyright crap: You have to update the copyright years.  In this case
> >> add 2004.  AFAIK you should not use short notations or ranges, just
> >> list the years like:
> >> 
> >>  *  Copyright (C) 2002, 2004  Free Software Foundation, Inc.
> >
> > Here should be probably only 2004, I copied another file, and deleted
> > all but copiright. I forgot to change the year. I will try to update
> > the modified files.
> 
> If it is based on another file you should use preserve those copyright
> notices/years as well (AFAIK).

He wrote that he only copied the copyright header from the other
file...

Jeroen Dekkers



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: normal mode chainloader
  2004-06-23 16:49         ` Marco Gerards
@ 2004-06-24  8:44           ` Tomas Ebenlendr
  2004-06-24 15:26             ` Marco Gerards
  0 siblings, 1 reply; 37+ messages in thread
From: Tomas Ebenlendr @ 2004-06-24  8:44 UTC (permalink / raw)
  To: The development of GRUB 2

> I have still some questions about the patch.  How do both loaders
> (that is both in normal mode and rescue mode) find the generic
> chainloader?  If I understand it correctly, the chain.mod depends on
> _chain.mod, but how does this work?


The chain.mod (normal mode chainloader) contains only the code for
parsing arguments (static chainloader_command()).
This function calls symbol (grub_chainloader_cmd() that is in _chain.mod
(rescue mode chainloader), which does all the work.
In _chain.mod the function that impements rescue command chainloader
(grub_rescue_cmd_chainloader()) was splitted to function that does
argument paring, and the already mentioned function
(grub_chainloader_cmd()) that does the work.

_chain.mod is chainloader.c
chain.mod is chainloader_normal.c (and it containts omly argument
parsing)
-- 
                                 Tomas 'ebi' Ebenlendr
                                 http://get.to/ebik
                                 PF 2004.47933932908




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: normal mode chainloader
  2004-06-24  8:44           ` Tomas Ebenlendr
@ 2004-06-24 15:26             ` Marco Gerards
  2004-06-24 16:51               ` Tomas Ebenlendr
  0 siblings, 1 reply; 37+ messages in thread
From: Marco Gerards @ 2004-06-24 15:26 UTC (permalink / raw)
  To: The development of GRUB 2

ebik@artax.karlin.mff.cuni.cz (Tomas Ebenlendr) writes:

>> I have still some questions about the patch.  How do both loaders
>> (that is both in normal mode and rescue mode) find the generic
>> chainloader?  If I understand it correctly, the chain.mod depends on
>> _chain.mod, but how does this work?
>
>
> The chain.mod (normal mode chainloader) contains only the code for
> parsing arguments (static chainloader_command()).
> This function calls symbol (grub_chainloader_cmd() that is in _chain.mod
> (rescue mode chainloader), which does all the work.
> In _chain.mod the function that impements rescue command chainloader
> (grub_rescue_cmd_chainloader()) was splitted to function that does
> argument paring, and the already mentioned function
> (grub_chainloader_cmd()) that does the work.

But how is _chain loaded?  If it is not in core you can not call those
functions, right?

What do you think about what I proposed (with #ifdef)?  I don't think
such hard dependency would be right, if that would be the case.

Thanks,
Marco




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: normal mode chainloader
  2004-06-24 15:26             ` Marco Gerards
@ 2004-06-24 16:51               ` Tomas Ebenlendr
  2004-07-01 10:54                 ` Marco Gerards
  0 siblings, 1 reply; 37+ messages in thread
From: Tomas Ebenlendr @ 2004-06-24 16:51 UTC (permalink / raw)
  To: The development of GRUB 2

> 
> But how is _chain loaded?  If it is not in core you can not call those
> functions, right?
> 

Having a file depmod.lst which says chain depends on _chain, grub
automatically loads _chain. That works in cvs version. This file is
generated when compiling grub.

-- 
                                 Tomas 'ebi' Ebenlendr
                                 http://get.to/ebik
                                 PF 2004.48028296398




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: normal mode chainloader
  2004-06-24 16:51               ` Tomas Ebenlendr
@ 2004-07-01 10:54                 ` Marco Gerards
  2004-07-01 11:17                   ` Yoshinori K. Okuji
  0 siblings, 1 reply; 37+ messages in thread
From: Marco Gerards @ 2004-07-01 10:54 UTC (permalink / raw)
  To: The development of GRUB 2

ebik@artax.karlin.mff.cuni.cz (Tomas Ebenlendr) writes:

>> 
>> But how is _chain loaded?  If it is not in core you can not call those
>> functions, right?
>> 
>
> Having a file depmod.lst which says chain depends on _chain, grub
> automatically loads _chain. That works in cvs version. This file is
> generated when compiling grub.

Okuji, what do you think?  I don't know anything about module loading.

I will commit the patch, if you want me to.

Thanks,
Marco




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: normal mode chainloader
  2004-07-01 10:54                 ` Marco Gerards
@ 2004-07-01 11:17                   ` Yoshinori K. Okuji
  2004-07-01 11:53                     ` Tomas Ebenlendr
  0 siblings, 1 reply; 37+ messages in thread
From: Yoshinori K. Okuji @ 2004-07-01 11:17 UTC (permalink / raw)
  To: The development of GRUB 2

On Thursday 01 July 2004 12:54, Marco Gerards wrote:
> ebik@artax.karlin.mff.cuni.cz (Tomas Ebenlendr) writes:
> >> But how is _chain loaded?  If it is not in core you can not call
> >> those functions, right?
> >
> > Having a file depmod.lst which says chain depends on _chain, grub
> > automatically loads _chain. That works in cvs version. This file is
> > generated when compiling grub.
>
> Okuji, what do you think?  I don't know anything about module
> loading.

Using depmod.lst is the right way to resolve dependencies among modules. 
But, before applying his patch, I'd like to wait until his copyright 
assignment is finished.

Okuji



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: normal mode chainloader
  2004-07-01 11:17                   ` Yoshinori K. Okuji
@ 2004-07-01 11:53                     ` Tomas Ebenlendr
  2004-07-01 13:30                       ` Marco Gerards
  0 siblings, 1 reply; 37+ messages in thread
From: Tomas Ebenlendr @ 2004-07-01 11:53 UTC (permalink / raw)
  To: The development of GRUB 2

> 
> Using depmod.lst is the right way to resolve dependencies among modules. 
> But, before applying his patch, I'd like to wait until his copyright 
> assignment is finished.
> 
> Okuji
> 

ad copyright:
I will send the copyright snail-mail at this friday. Then I'm leaving to
Norway for one month.

ad modules:
In fact the dependencies are written somewhere in elf format and
depmod.lst is only for user to see what depends on what.

autoloading:
I wrote simple cmd-autoloading patch, but it triggers some mm-bug which I hunt
now. Moreover my network card in my laptop (where I hack for grub) is broken,
so I will post the patch when I return.

ad normal mode chainloader:
Consider moving loader/i386/pc/chainloader_normal.c to
commands/chainloader.c. I don't know which placement is better. (This
file will not contain any architecture dependent code as long as
arguments passed to command chainloader will be same for all
architectures.)
-- 
                                 Tomas 'ebi' Ebenlendr
                                 http://get.to/ebik
                                 PF 2004.49882529473




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: normal mode chainloader
  2004-07-01 11:53                     ` Tomas Ebenlendr
@ 2004-07-01 13:30                       ` Marco Gerards
  2004-07-01 16:03                         ` history, autoloading was: " Tomas Ebenlendr
  2004-09-10 22:05                         ` Marco Gerards
  0 siblings, 2 replies; 37+ messages in thread
From: Marco Gerards @ 2004-07-01 13:30 UTC (permalink / raw)
  To: The development of GRUB 2

ebik@artax.karlin.mff.cuni.cz (Tomas Ebenlendr) writes:

> ad copyright:
> I will send the copyright snail-mail at this friday. Then I'm leaving to
> Norway for one month.

I think Okuji will get a message from the FSF about this.  I think it
is safe to assume the FSF will receive the mail and to apply the
patch. :)

Or Okuji, do you really want to wait for the FSF to confirm this
assignment?

> ad modules:
> In fact the dependencies are written somewhere in elf format and
> depmod.lst is only for user to see what depends on what.

So that doesn't mean _chain gets autoloaded?

> autoloading:
> I wrote simple cmd-autoloading patch, but it triggers some mm-bug which I hunt
> now. Moreover my network card in my laptop (where I hack for grub) is broken,
> so I will post the patch when I return.

Which bugs are those?  I had some mm problems with the PPC port as
well.

If it is incorrect usage of malloc and free, you could use valgrind.

> ad normal mode chainloader:
> Consider moving loader/i386/pc/chainloader_normal.c to
> commands/chainloader.c. I don't know which placement is better. (This
> file will not contain any architecture dependent code as long as
> arguments passed to command chainloader will be same for all
> architectures.)

No, the chainloader is for the PC only.  And it depends on something
that is arch specific.

Thanks,
Marco




^ permalink raw reply	[flat|nested] 37+ messages in thread

* history, autoloading was: Re: normal mode chainloader
  2004-07-01 13:30                       ` Marco Gerards
@ 2004-07-01 16:03                         ` Tomas Ebenlendr
  2004-09-10 22:05                         ` Marco Gerards
  1 sibling, 0 replies; 37+ messages in thread
From: Tomas Ebenlendr @ 2004-07-01 16:03 UTC (permalink / raw)
  To: The development of GRUB 2

> 
> > ad modules:
> > In fact the dependencies are written somewhere in elf format and
> > depmod.lst is only for user to see what depends on what.
> 
> So that doesn't mean _chain gets autoloaded?
> 

It gets auoloaded. I only noted that you can delete depmod.lst, because
the information is stored somewhere in modules. I don't understand elf,
but it seems be the same way as in unix.

> > autoloading:
> > I wrote simple cmd-autoloading patch, but it triggers some mm-bug which I hunt
> > now. Moreover my network card in my laptop (where I hack for grub) is broken,
> > so I will post the patch when I return.
> 
> Which bugs are those?  I had some mm problems with the PPC port as
> well.
> 
> If it is incorrect usage of malloc and free, you could use valgrind.
> 

I don't know where the bug was, but it isn't trigerred anymore with
following history optimisation.

I also add patch that autoloads modules if they contain requested
commands. (It contains example autoload.lst).
I thinked of automatic generating of autoload.lst, but it is not so
easy. I'm not decided if I want to grep for register_command or do it in
some other way.

-------- HISTORY OPTIMISATION PATCH --------
Changelog:
	History is now replaced 'lazy'. It was replaced at each char
	before, which was not good, because history replacement is free
	on old content and strdup of new.

diff -rupN -x CVS grub2_x/normal/cmdline.c grub2_work_x/normal/cmdline.c
--- grub2_x/normal/cmdline.c	2004-06-28 19:09:55.000000000 +0200
+++ grub2_work_x/normal/cmdline.c	2004-07-01 16:32:06.000000000 +0200
@@ -640,6 +640,7 @@ grub_cmdline_get (const char *prompt, ch
 
 		lpos = 0;
 
+		grub_history_replace (histpos, buf);
 		if (histpos > 0)
 		  histpos--;
 
@@ -655,6 +656,7 @@ grub_cmdline_get (const char *prompt, ch
 
 		lpos = 0;
 
+		grub_history_replace (histpos, buf);
 		if (histpos < hist_used - 1)
 		  histpos++;
 
@@ -724,8 +726,9 @@ grub_cmdline_get (const char *prompt, ch
 	  break;
 	}
 
-      grub_history_replace (histpos, buf);
+      //grub_history_replace (histpos, buf);
     }
+  grub_history_replace (histpos, buf);
 
   grub_putchar ('\n');
   grub_refresh ();
------- END OF PATCH ------

-------- COMMAND AUTOLOAD PATCH ---------
Changelog:
	Added command autoloading support to variable `autocmd'.
	Whenever this variable is set to some file, this file is
	parsed to build list of commands and their modules. When unkonwn
	command is used and is contained in this list, it's module is
	loaded and command is run then.

	* autocmd.lst: New file. It should be in grub's root directory.
	This file is only an example.
	* include/grub/normal.h (grub_command_done): New prototype.
	Destrutor for normal/command.c.
	* normal/command.c (grub_autocmd_list_t): New data type.
	(grub_command_find): Added the autoloading code.
	(grub_autocmd_read): New function. Parses autocmd.lst.
	(grub_autocmd_set): New function. Write hook for variable
	`autocmd'.
	(grub_command_init): Added initialisation of variable `autocmd'.
	(grub_command_done): New function. Destructor for autoloading.
	Frees the list of commands and modules and unsets the write hook
	for `autocmd'.
	

diff -rupN -x CVS grub2_x/autocmd.lst grub2_debug/autocmd.lst
--- grub2_x/autocmd.lst	1970-01-01 01:00:00.000000000 +0100
+++ grub2_debug/autocmd.lst	2004-06-29 01:52:26.000000000 +0200
@@ -0,0 +1,2 @@
+boot boot
+chainloader chain
diff -rupN -x CVS grub2_x/include/grub/normal.h grub2_debug/include/grub/normal.h
--- grub2_x/include/grub/normal.h	2004-06-05 00:20:17.000000000 +0200
+++ grub2_debug/include/grub/normal.h	2004-06-29 03:07:59.000000000 +0200
@@ -1,7 +1,7 @@
 /* normal.h - prototypes for the normal mode */
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2002,2003  Free Software Foundation, Inc.
+ *  Copyright (C) 2002,2003,2004  Free Software Foundation, Inc.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -136,6 +136,7 @@ grub_err_t grub_set_history (int newsize
 int grub_iterate_commands (int (*iterate) (grub_command_t));
 int grub_command_execute (char *cmdline);
 void grub_command_init (void);
+void grub_command_done (void);
 void grub_normal_init_page (void);
 int grub_arg_parse (grub_command_t parser, int argc, char **argv,
 		    struct grub_arg_list *usr, char ***args, int *argnum);
diff -rupN -x CVS grub2_x/normal/command.c grub2_debug/normal/command.c
--- grub2_x/normal/command.c	2004-06-05 00:20:18.000000000 +0200
+++ grub2_debug/normal/command.c	2004-07-01 16:44:07.000000000 +0200
@@ -1,6 +1,6 @@
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2003  Free Software Foundation, Inc.
+ *  Copyright (C) 2003,2004  Free Software Foundation, Inc.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -24,9 +24,21 @@
 #include <grub/term.h>
 #include <grub/env.h>
 #include <grub/dl.h>
+#include <grub/file.h>
 
 static grub_command_t grub_command_list;
 
+typedef struct
+{
+  char * cmdname;
+  char * modulename;
+} grub_autocmd_list_t;
+
+static grub_autocmd_list_t * grub_autocmd_list = 0;
+/* Value less than zero disables warnings at start.  */
+static int grub_autocmd_count = -1;
+static char * grub_autocmd_buffer = 0;
+
 void
 grub_register_command (const char *name,
 		       grub_err_t (*func) (struct grub_arg_list *state,
@@ -82,6 +94,8 @@ grub_command_find (char *cmdline)
 {
   char *first_space;
   grub_command_t cmd;
+  grub_dl_t mod;
+  int i;
 
   first_space = grub_strchr (cmdline, ' ');
   if (first_space)
@@ -91,8 +105,40 @@ grub_command_find (char *cmdline)
     if (grub_strcmp (cmdline, cmd->name) == 0)
       break;
 
+  /* Automatic module loading.  */
   if (! cmd)
-    grub_error (GRUB_ERR_UNKNOWN_COMMAND, "unknown command `%s'", cmdline);
+    {
+      for (i = 0; i < grub_autocmd_count; i++)
+	{
+	  if (grub_strcmp (cmdline, grub_autocmd_list[i].cmdname) == 0)
+	    {
+	      mod = grub_dl_load (grub_autocmd_list[i].modulename);
+
+	      if (mod)
+		{
+		  grub_dl_ref (mod);
+		  for (cmd = grub_command_list; cmd; cmd = cmd->next)
+		    if (grub_strcmp (cmdline, cmd->name) == 0)
+		      break;
+
+		  /* Unload module if command was not there.  */
+		  if (!cmd)
+		    {
+		      if (! grub_dl_unref (mod))
+			grub_dl_unload (mod);
+
+		      grub_error(GRUB_ERR_UNKNOWN_COMMAND,
+				 "command `%s' not found in module `%s'",
+				 cmdline, grub_autocmd_list[i].modulename);
+		    }
+		}
+
+	      break;
+	    }
+	}
+      if (i >= grub_autocmd_count)
+	grub_error (GRUB_ERR_UNKNOWN_COMMAND, "unknown command `%s'", cmdline);
+    }
   
   if (first_space)
     *first_space = ' ';
@@ -171,6 +217,185 @@ grub_command_execute (char *cmdline)
   return ret;
 }
 
+
+/* Reads autocmd.lst and sets up list of commands provided by modules.  */
+static grub_err_t
+grub_autocmd_read (const char * name, int silent)
+{
+  grub_file_t file = 0;
+  grub_ssize_t size;
+  int state, i;
+  char *cmdname = 0, *modulename = 0, *pos, *end;
+
+  if ((name != 0) && (name[0] != 0))
+    {
+      file = grub_file_open (name);
+      if (! file)
+	{
+	  if (! silent)
+	    grub_error (grub_errno, "couldn't open file %s", name);
+
+	  /* Not goto failed. Preserve old setting here.  */
+	  return grub_errno;
+	}
+    }
+
+  grub_free (grub_autocmd_buffer);
+  grub_autocmd_buffer = 0;
+  grub_free (grub_autocmd_list);
+  grub_autocmd_list = 0;
+  grub_autocmd_count = 0;
+
+  /* Disable autoloading.  */
+  if ((name == 0) || (name[0] == 0))
+    return 0;
+
+  size = grub_file_size (file);
+  grub_autocmd_buffer = grub_malloc(size + 1);
+  if (! grub_autocmd_buffer)
+    goto failed;
+  if (grub_file_read (file, grub_autocmd_buffer, size) != (int) size)
+    goto failed;
+
+  /* Don't allow unfinished line.  */
+  grub_autocmd_buffer[size] = '\n';
+  end = grub_autocmd_buffer + size + 1;
+
+  /* Count number of entries.  */
+  /* Following state machine accepts lines with at least 2 words,
+   * the second word must not contain `/'.  */
+  state = 0;
+  /* State machine for text parsing:
+   * state == 0   begining of line,
+   * state == 1   first word,
+   * state == 2   spaces after first word,
+   * state == 3   rest of the line.
+   * state == 5   error. \0 or / in module name.  */
+  for (pos = grub_autocmd_buffer; pos < end; pos++)
+    switch (*pos)
+      {
+	case '\0':
+	  /* Bad character in text file.  */
+	  state = 5;
+	  break;
+
+	case '\n':
+
+	  /* At least two words.  */
+	  if (state == 3)
+	    grub_autocmd_count++;
+
+	  state = 0;
+	  break;
+
+	case ' ':
+	  if (state == 1)
+	    state = 2;
+	  break;
+
+	case '/':
+	  /* Bad module name.  */
+	  if (state == 3)
+	    state = 5;
+
+	default:
+	  /* Move to state 1 or 3.  */
+	  state |= 1;
+      }
+
+  grub_autocmd_list = grub_malloc(grub_autocmd_count
+				  * sizeof(grub_autocmd_list_t));
+  if (! grub_autocmd_list) goto failed;
+  
+  /* Fill in the list.  */
+  /* The same state machine. It sets pointers to names of commands and
+   * modules. A name is a word separated by ` '.  */
+  i=0; state = 0;
+  for (pos = grub_autocmd_buffer; pos < end; pos++)
+    switch (*pos)
+      {
+	case '\n':
+
+	  /* At least two words.  */
+	  if (state == 3)
+	    {
+	      grub_autocmd_list[i].cmdname = cmdname;
+	      grub_autocmd_list[i].modulename = modulename;
+	      i++;
+	      *pos = 0;
+	    }
+
+	  state = 0;
+	  break;
+
+	case ' ':
+	  /* Terminate the word.  */
+	  *pos = 0;
+	  if (state == 1)
+	    state = 2;
+	  break;
+
+	case '/':
+	case '\0':
+	  /* Bad module name.  */
+	  if (state == 3)
+	    state = 5;
+
+	default:
+	  switch (state)
+	    {
+	      case 0:
+		cmdname = pos;
+		state = 1;
+		break;
+	      case 2:
+		modulename = pos;
+		state = 3;
+		break;
+	    }
+      }
+
+  grub_file_close(file);
+  return 0;
+
+failed:
+  grub_file_close(file);
+  grub_free (grub_autocmd_buffer);
+  grub_autocmd_buffer = 0;
+  grub_free (grub_autocmd_list);
+  grub_autocmd_list = 0;
+  grub_autocmd_count = 0;
+
+  if (! silent) grub_error(grub_errno, "not enough memory");
+  return grub_errno;
+}
+
+/* `autocmd' variable write hook */
+static grub_err_t
+grub_autocmd_set (struct grub_env_var * env)
+{
+  char * p;
+  char * prefix = grub_env_get("prefix");
+
+  p = grub_strchr (env->value, '/');
+  if (! p)
+    {
+      p = grub_malloc (grub_strlen (prefix) + 1
+		       + grub_strlen (env->value) + 1);
+      if (p)
+	{
+	  grub_sprintf (p, "%s/%s", prefix, env->value);
+	  grub_autocmd_read (p, grub_autocmd_count < 0);
+	  grub_free (p);
+	}
+      return grub_errno;
+    }
+  else
+    return grub_autocmd_read(env->value, grub_autocmd_count < 0);
+}
+
+/* Basic normal mode commands.  */
+
 static grub_err_t
 rescue_command (struct grub_arg_list *state __attribute__ ((unused)),
 		int argc __attribute__ ((unused)),
@@ -303,6 +528,8 @@ lsmod_command (struct grub_arg_list *sta
 void
 grub_command_init (void)
 {
+  char * fname;
+
   /* This is a special command, because this never be called actually.  */
   grub_register_command ("title", 0, GRUB_COMMAND_FLAG_TITLE, 0, 0, 0);
 
@@ -323,4 +550,24 @@ grub_command_init (void)
 
   grub_register_command ("lsmod", lsmod_command, GRUB_COMMAND_FLAG_BOTH,
 			 "lsmod", "Show loaded modules.", 0);
+
+  grub_register_variable_hook("autocmd", 0, grub_autocmd_set);
+
+  fname = grub_env_get("autocmd");
+  /* Provide default value for `autocmd'.  */
+  if ((fname == 0) || (fname[0] == 0))
+    {
+      grub_env_set ("autocmd", "autocmd.lst");
+      if (grub_autocmd_count <= 0)
+	grub_env_set ("autocmd", "");
+    }
+  else
+    grub_env_set("autocmd",fname);
+}
+
+void
+grub_command_done (void)
+{
+  grub_register_variable_hook("autocmd", 0, 0);
+  grub_autocmd_read(0, 0);
 }
diff -rupN -x CVS grub2_x/normal/main.c grub2_debug/normal/main.c
--- grub2_x/normal/main.c	2004-06-05 00:20:18.000000000 +0200
+++ grub2_debug/normal/main.c	2004-07-01 16:45:38.000000000 +0200
@@ -1,7 +1,7 @@
 /* main.c - the normal mode main routine */
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2000,2001,2002,2003  Free Software Foundation, Inc.
+ *  Copyright (C) 2000,2001,2002,2003,2004  Free Software Foundation, Inc.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -368,12 +368,14 @@ GRUB_MOD_INIT
   grub_rescue_register_command ("normal", grub_rescue_cmd_normal,
 				"enter normal mode");
 
-  /* This registers some built-in commands.  */
+  /* This registers some built-in commands and sets up autoloading
+   * of commands.  */
   grub_command_init ();
 }
 
 GRUB_MOD_FINI
 {
+  grub_command_done ();
   grub_set_history (0);
   grub_rescue_unregister_command ("normal");
 }
------- END OF PATCH ------
-- 
                                 Tomas 'ebi' Ebenlendr
                                 http://get.to/ebik
                                 PF 2004.49926055581




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: normal mode chainloader
  2004-07-01 13:30                       ` Marco Gerards
  2004-07-01 16:03                         ` history, autoloading was: " Tomas Ebenlendr
@ 2004-09-10 22:05                         ` Marco Gerards
  1 sibling, 0 replies; 37+ messages in thread
From: Marco Gerards @ 2004-09-10 22:05 UTC (permalink / raw)
  To: The development of GRUB 2

Marco Gerards <metgerards@student.han.nl> writes:

> ebik@artax.karlin.mff.cuni.cz (Tomas Ebenlendr) writes:
>
>> ad copyright:
>> I will send the copyright snail-mail at this friday. Then I'm leaving to
>> Norway for one month.
>
> I think Okuji will get a message from the FSF about this.  I think it
> is safe to assume the FSF will receive the mail and to apply the
> patch. :)

I assume the assignments are ready now.  I will apply this patch on
saturday or sunday if there are no problems.  I will also write the
same for the linux loader and for multiboot.

Thanks,
Marco




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: normal mode chainloader
  2004-06-23 11:58       ` Tomas Ebenlendr
  2004-06-23 16:49         ` Marco Gerards
@ 2004-09-12 12:46         ` Marco Gerards
  2004-09-17 18:48           ` Tomas Ebenlendr
  1 sibling, 1 reply; 37+ messages in thread
From: Marco Gerards @ 2004-09-12 12:46 UTC (permalink / raw)
  To: The development of GRUB 2

ebik@artax.karlin.mff.cuni.cz (Tomas Ebenlendr) writes:

> Okay, here is the patch without dependency symbol. (I hope it is GCS
> compliant now.)
>
> Changelog:
> 2004-06-21  Tomas Ebenlendr  <ebik@ucw.cz>
>
> 	Added normal mode command `chainloader' as module chain.mod,
> 	which depends on normal.mod and _chain.mod.
>
> 	* conf/i386-pc.rmk (pkgdata_MODULES): Add chain.mod
> 	(chain_mod_SOURCES, chain_mod_CFLAGS): New module.
> 	chain.mod is build from chainloader_normal.c
> 	* include/grub/i386/pc/chainloader.h: New file. Exports
> 	body of chainloader command.
> 	* include/grub/i386/pc/loader.h (grub_rescue_cmd_chainloader):
> 	Deleted prototype.
> 	* loader/i386/pc/chainloader.c (grub_rescue_cmd_chainloader):
> 	all but arguments parsing moved to ...
> 	(grub_chainloader_cmd): ... this.
> 	* loader/i386/pc/chainloader_normal.c: New file. Defines the
> 	command chainloader.

Because no one objected when I said I would commit the patch (and
Okuji told us a long time ago this is the right way), I have committed
this patch with some minor cleanups in the patch and changelog entry.
I am sorry I kept you waiting this long.

Later this week I will do the same as you did for the other loaders
(linux, initrd and multiboot).

Tomas, do you have any pending patches that still need to be applied?
I have the feeling I lost track of some.

Thanks,
Marco




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: normal mode chainloader
  2004-09-12 12:46         ` Marco Gerards
@ 2004-09-17 18:48           ` Tomas Ebenlendr
  2004-09-17 18:53             ` M. Gerards
  0 siblings, 1 reply; 37+ messages in thread
From: Tomas Ebenlendr @ 2004-09-17 18:48 UTC (permalink / raw)
  To: The development of GRUB 2

> Tomas, do you have any pending patches that still need to be applied?
> I have the feeling I lost track of some.
> 
> Thanks,
> Marco

I can apply my patches myself now. But I was doing other work. I will
look at my hostfs patch and will send it here for comments again.

-- 
                                 Tomas 'ebi' Ebenlendr
                                 http://get.to/ebik
                                 PF 2004.71274539567




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: normal mode chainloader
  2004-09-17 18:48           ` Tomas Ebenlendr
@ 2004-09-17 18:53             ` M. Gerards
  2004-09-17 19:32               ` Tomas Ebenlendr
  0 siblings, 1 reply; 37+ messages in thread
From: M. Gerards @ 2004-09-17 18:53 UTC (permalink / raw)
  To: The development of GRUB 2, Tomas Ebenlendr

Quoting Tomas Ebenlendr <ebik@artax.karlin.mff.cuni.cz>:

> > Tomas, do you have any pending patches that still need to be applied?
> > I have the feeling I lost track of some.
> > 
> > Thanks,
> > Marco
> 
> I can apply my patches myself now. But I was doing other work. I will
> look at my hostfs patch and will send it here for comments again.

Oh, ok :)

How about the patch for module loading in grub-emu?  Are you
working on that as well?

Thanks,
Marco



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: normal mode chainloader
  2004-09-17 18:53             ` M. Gerards
@ 2004-09-17 19:32               ` Tomas Ebenlendr
  2004-09-17 19:38                 ` M. Gerards
  0 siblings, 1 reply; 37+ messages in thread
From: Tomas Ebenlendr @ 2004-09-17 19:32 UTC (permalink / raw)
  To: The development of GRUB 2

> Oh, ok :)
> 
> How about the patch for module loading in grub-emu?  Are you
> working on that as well?
> 
> Thanks,
> Marco

Yes, but very slowly. I don't understand binutils and linker very much,
but I want to learn it. Now I want to get executable whith
grub-compatible elf header. (If I fail, I can compile modules with header
compatible to dlopen.)

-- 
                                 Tomas 'ebi' Ebenlendr
                                 http://get.to/ebik
                                 PF 2004.71281822379




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: normal mode chainloader
  2004-09-17 19:32               ` Tomas Ebenlendr
@ 2004-09-17 19:38                 ` M. Gerards
  2004-09-20  6:58                   ` Tomas Ebenlendr
  0 siblings, 1 reply; 37+ messages in thread
From: M. Gerards @ 2004-09-17 19:38 UTC (permalink / raw)
  To: The development of GRUB 2, Tomas Ebenlendr

Quoting Tomas Ebenlendr <ebik@artax.karlin.mff.cuni.cz>:

> > Oh, ok :)
> > 
> > How about the patch for module loading in grub-emu?  Are you
> > working on that as well?
> Yes, but very slowly. I don't understand binutils and linker very much,
> but I want to learn it. Now I want to get executable whith
> grub-compatible elf header. (If I fail, I can compile modules with header
> compatible to dlopen.)

As far as I know you could use normal GRUB modules, no?  so you can use 
the same normal.mod as is used boottime.

Would you have a problem with me trying to implement this or do you have too 
much already?

I have some problems with the implementation of the relocator for the PPC
and I think it is easier to debug if I can use grub-emu for this.

Thanks,
Marco



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: normal mode chainloader
  2004-09-17 19:38                 ` M. Gerards
@ 2004-09-20  6:58                   ` Tomas Ebenlendr
  2004-09-21  8:22                     ` Module loading - grub-emu, bug in kern/dl.c Tomas Ebenlendr
  0 siblings, 1 reply; 37+ messages in thread
From: Tomas Ebenlendr @ 2004-09-20  6:58 UTC (permalink / raw)
  To: The development of GRUB 2


My current status is following: I can _load_ module (with same grub_arch_dl_relocate_symbols()),
and with something similar to symlist.c). But I cannot execute it,
because of i386 specific CFLAGS: -mregparm=3 -mrtd. (calling convetions)
Posible solutions:  1) use another set of modules
		    2) don't use -mregparm=3 -mrtd
		    3) use __atribute__ ((regparm(3), stdcall)) for all
		    functions that may be in modules.

More detail on the third solution:
int EXPORT_FUNC(foo) (int HOOK(*hook) (int))
EXPORT_FUNC(x) will expand on HOOK(x), and HOOK(x) will expand on
    __atribute__ ((regparm(3), stdcall)) x
when on i386.
the hook should be also defined as follows:
int HOOK(my_hook) (int argument) { body; }
There can be special macros HOOK_A (and EXPORT_FUNC_A) for functions,
that already have some __attribute__ (e.g., grub_fatal or grub_printf).


I tried to do a wrapper (fourth solution), but that is impossible
because of hooks. (They may originate in grub_emu as well as in module).

PS.: We can distinguish between modules loadable in grub-emu, and
boottime modules (and modules wich can be used both ways). I propose to
have some flags (as variable or somewhere in elf header).

> As far as I know you could use normal GRUB modules, no?  so you can use 
> the same normal.mod as is used boottime.
> 
> Would you have a problem with me trying to implement this or do you have too 
> much already?
> 
> I have some problems with the implementation of the relocator for the PPC
> and I think it is easier to debug if I can use grub-emu for this.
> 
> Thanks,
> Marco

-- 
                                 Tomas 'ebi' Ebenlendr
                                 http://get.to/ebik
                                 PF 2004.71955727586



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Module loading - grub-emu, bug in kern/dl.c
  2004-09-20  6:58                   ` Tomas Ebenlendr
@ 2004-09-21  8:22                     ` Tomas Ebenlendr
  2004-11-17 15:43                       ` Marco Gerards
  0 siblings, 1 reply; 37+ messages in thread
From: Tomas Ebenlendr @ 2004-09-21  8:22 UTC (permalink / raw)
  To: The development of GRUB 2


So I started to use solution no. 2 just to see if it really works. And
it doesn't! At least for normal.mod (fs modules are working well).
The problem is following:

$ readelf normal.mod:
...
Symbol table '.symtab' contains 88 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
...
    26: 00000f13   370 FUNC    GLOBAL DEFAULT    1 grub_command_execute
    27: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND grub_realloc
    28: 00000004    24 OBJECT  GLOBAL DEFAULT  COM grub_exit_env
...                                            ^^^
					       here is section index
COM == 65522, so it means some special section. (I don't understand elf
well), grub_dl_get_section_addr(mod, 65522) simply returns zero. Because
this is the only such symbol among all modules, this works at boottime,
where nothing wants the adress 0x4 (size 0x18). But this doesn't work in
grub_emu, because this address is unallocated.

If anyone have read and understands elf specification, please tell how
it should be fixed correctly. Otherwise I will learn how to fix it in
one month (maybe earlier).


> 
> My current status is following: I can _load_ module (with same grub_arch_dl_relocate_symbols()),
> and with something similar to symlist.c). But I cannot execute it,
> because of i386 specific CFLAGS: -mregparm=3 -mrtd. (calling convetions)
> Posible solutions:  1) use another set of modules
> 		    2) don't use -mregparm=3 -mrtd
> 		    3) use __atribute__ ((regparm(3), stdcall)) for all
> 		    functions that may be in modules.
> 
> More detail on the third solution:
> int EXPORT_FUNC(foo) (int HOOK(*hook) (int))
> EXPORT_FUNC(x) will expand on HOOK(x), and HOOK(x) will expand on
>     __atribute__ ((regparm(3), stdcall)) x
> when on i386.
> the hook should be also defined as follows:
> int HOOK(my_hook) (int argument) { body; }
> There can be special macros HOOK_A (and EXPORT_FUNC_A) for functions,
> that already have some __attribute__ (e.g., grub_fatal or grub_printf).
> 
> 
> I tried to do a wrapper (fourth solution), but that is impossible
> because of hooks. (They may originate in grub_emu as well as in module).
> 
> PS.: We can distinguish between modules loadable in grub-emu, and
> boottime modules (and modules wich can be used both ways). I propose to
> have some flags (as variable or somewhere in elf header).
> 

-- 
                                 Tomas 'ebi' Ebenlendr
                                 http://get.to/ebik
                                 PF 2004.72244639876




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Module loading - grub-emu, bug in kern/dl.c
  2004-09-21  8:22                     ` Module loading - grub-emu, bug in kern/dl.c Tomas Ebenlendr
@ 2004-11-17 15:43                       ` Marco Gerards
  2004-11-17 20:30                         ` Tomas Ebenlendr
  2004-11-22 15:18                         ` Timothy Baldwin
  0 siblings, 2 replies; 37+ messages in thread
From: Marco Gerards @ 2004-11-17 15:43 UTC (permalink / raw)
  To: The development of GRUB 2

Tomas Ebenlendr <ebik@artax.karlin.mff.cuni.cz> writes:

> If anyone have read and understands elf specification, please tell how
> it should be fixed correctly. Otherwise I will learn how to fix it in
> one month (maybe earlier).

What is the status of this?  On the powerpc the missing module loader
is becoming a big problem and this is something I'd like to solve
ASAP.  Is it possible to make a clean patch of what you have so far or
can I work on module loading for grub-emu?

Thanks,
Marco




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Module loading - grub-emu, bug in kern/dl.c
  2004-11-17 15:43                       ` Marco Gerards
@ 2004-11-17 20:30                         ` Tomas Ebenlendr
  2004-11-17 20:45                           ` Marco Gerards
  2004-11-22 15:18                         ` Timothy Baldwin
  1 sibling, 1 reply; 37+ messages in thread
From: Tomas Ebenlendr @ 2004-11-17 20:30 UTC (permalink / raw)
  To: The development of GRUB 2


I'm busy with school since my hd broke down (2 months ago?). I didn't
fully installed my system yet. I did not any work on the patch since
last version I posted here. I'l try to look at it, but I have only little
time now.

I think the only 'problem' is the mregparm stuff, so there must be
generated another set of modules for grub-emu.

> Tomas Ebenlendr <ebik@artax.karlin.mff.cuni.cz> writes:
> 
> > If anyone have read and understands elf specification, please tell how
> > it should be fixed correctly. Otherwise I will learn how to fix it in
> > one month (maybe earlier).
> 
> What is the status of this?  On the powerpc the missing module loader
> is becoming a big problem and this is something I'd like to solve
> ASAP.  Is it possible to make a clean patch of what you have so far or
> can I work on module loading for grub-emu?
> 
> Thanks,
> Marco

-- 
                                 Tomas 'ebi' Ebenlendr
                                 http://get.to/ebik
                                 PF 2004.87948628188




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Module loading - grub-emu, bug in kern/dl.c
  2004-11-17 20:30                         ` Tomas Ebenlendr
@ 2004-11-17 20:45                           ` Marco Gerards
  0 siblings, 0 replies; 37+ messages in thread
From: Marco Gerards @ 2004-11-17 20:45 UTC (permalink / raw)
  To: The development of GRUB 2

Tomas Ebenlendr <ebik@artax.karlin.mff.cuni.cz> writes:

> I'm busy with school since my hd broke down (2 months ago?). I didn't
> fully installed my system yet. I did not any work on the patch since
> last version I posted here. I'l try to look at it, but I have only little
> time now.
>
> I think the only 'problem' is the mregparm stuff, so there must be
> generated another set of modules for grub-emu.

If you don't use the same modules for grub-emu as for the real thing
it will not be a problem.  It is not a problem to use other modules,
other than the mregparm stuff there are other issues as well...

Thanks,
Marco




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Module loading - grub-emu, bug in kern/dl.c
  2004-11-17 15:43                       ` Marco Gerards
  2004-11-17 20:30                         ` Tomas Ebenlendr
@ 2004-11-22 15:18                         ` Timothy Baldwin
  1 sibling, 0 replies; 37+ messages in thread
From: Timothy Baldwin @ 2004-11-22 15:18 UTC (permalink / raw)
  To: The development of GRUB 2

[-- Attachment #1: Type: text/plain, Size: 737 bytes --]

On Wednesday 17 Nov 2004 15:43, Marco Gerards wrote:
> Tomas Ebenlendr <ebik@artax.karlin.mff.cuni.cz> writes:
> > If anyone have read and understands elf specification, please tell how
> > it should be fixed correctly. Otherwise I will learn how to fix it in
> > one month (maybe earlier).
>
> What is the status of this?  On the powerpc the missing module loader
> is becoming a big problem and this is something I'd like to solve
> ASAP.  Is it possible to make a clean patch of what you have so far or
> can I work on module loading for grub-emu?

My patch fixes that bug.

-- 
Member AFFS, WYLUG, SWP (UK), ANL, RESPECT, Leeds SA, Leeds Anti-war coalition
No to software patents!    Victory to the iraqi resistance!

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 37+ messages in thread

end of thread, other threads:[~2004-11-22 15:29 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-21 18:00 normal mode chainloader Tomas Ebenlendr
2004-06-22  9:00 ` Marco Gerards
2004-06-22 11:33   ` Tomas Ebenlendr
2004-06-22 19:52     ` Marco Gerards
2004-06-23  7:10       ` Tomas Ebenlendr
2004-06-23 10:34         ` Yoshinori K. Okuji
2004-06-23 10:40           ` Tomas Ebenlendr
2004-06-22 11:41   ` Tomas Ebenlendr
2004-06-22 20:25     ` Marco Gerards
2004-06-23  7:29       ` Tomas Ebenlendr
2004-06-23 10:55         ` Marco Gerards
2004-06-23 17:20           ` Jeroen Dekkers
2004-06-23  8:11       ` Copyright crap Was: " Tomas Ebenlendr
2004-06-23  8:59         ` Jeroen Dekkers
2004-06-23 10:43           ` Tomas Ebenlendr
2004-06-23 11:58       ` Tomas Ebenlendr
2004-06-23 16:49         ` Marco Gerards
2004-06-24  8:44           ` Tomas Ebenlendr
2004-06-24 15:26             ` Marco Gerards
2004-06-24 16:51               ` Tomas Ebenlendr
2004-07-01 10:54                 ` Marco Gerards
2004-07-01 11:17                   ` Yoshinori K. Okuji
2004-07-01 11:53                     ` Tomas Ebenlendr
2004-07-01 13:30                       ` Marco Gerards
2004-07-01 16:03                         ` history, autoloading was: " Tomas Ebenlendr
2004-09-10 22:05                         ` Marco Gerards
2004-09-12 12:46         ` Marco Gerards
2004-09-17 18:48           ` Tomas Ebenlendr
2004-09-17 18:53             ` M. Gerards
2004-09-17 19:32               ` Tomas Ebenlendr
2004-09-17 19:38                 ` M. Gerards
2004-09-20  6:58                   ` Tomas Ebenlendr
2004-09-21  8:22                     ` Module loading - grub-emu, bug in kern/dl.c Tomas Ebenlendr
2004-11-17 15:43                       ` Marco Gerards
2004-11-17 20:30                         ` Tomas Ebenlendr
2004-11-17 20:45                           ` Marco Gerards
2004-11-22 15:18                         ` Timothy Baldwin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.