All of lore.kernel.org
 help / color / mirror / Atom feed
* Normal mode linux and multiboot loaders
@ 2004-09-13 18:11 Marco Gerards
  2004-09-13 21:43 ` Yoshinori K. Okuji
  2004-09-15  0:34 ` Marco Gerards
  0 siblings, 2 replies; 5+ messages in thread
From: Marco Gerards @ 2004-09-13 18:11 UTC (permalink / raw)
  To: grub-devel

Hi,

As I have promised, I have written two modules to make it possible to
use the linux and multiboot loaders in GNU/Linux.  It is a really
simple patch so I assume it is ok and check it in Wednesday.

It also fixed a bug in ext2 that I noticed when using a GNU/Hurd ext2
filesystem.  And I noticed `__attribute__ ((unused))' in linux.c for
the initrd function.  The arguments are used so I removed this.

Thanks,
Marco

2004-09-13  Marco Gerards  <metgerards@student.han.nl>

	Add `linux.mod' and `multiboot.mod' so linux and multiboot kernels
	can be loaded from normal mode.
	
	* conf/i386-pc.mk (pkgdata_MODULES): Add `linux.mod' and
	`multiboot.mod'.
	(linux_mod_SOURCES, linux_mod_CFLAGS, multiboot_mod_SOURCES)
	(multiboot_mod_CFLAGS): New variables.
	* loader/i386/pc/linux_normal.c: New file.
	* loader/i386/pc/multiboot_normal.c: Likewise.	
	
	* loader/i386/pc/linux.c (grub_rescue_cmd_initrd): Don't use the
	attribute `unused'.
	
	* fs/ext2.c (grub_ext2_iterate_dir): Fix typos in inode type.  Use
	`fdiro' to read the mode information from instead of `diro'.


Index: conf/i386-pc.rmk
===================================================================
RCS file: /cvsroot/grub/grub2/conf/i386-pc.rmk,v
retrieving revision 1.20
diff -u -p -u -p -r1.20 i386-pc.rmk
--- conf/i386-pc.rmk	12 Sep 2004 12:20:52 -0000	1.20
+++ conf/i386-pc.rmk	13 Sep 2004 18:06:19 -0000
@@ -78,9 +78,9 @@ grub_emu_LDFLAGS = -lncurses
 genmoddep_SOURCES = util/genmoddep.c
 
 # Modules.
-pkgdata_MODULES = _chain.mod _linux.mod fat.mod ufs.mod ext2.mod minix.mod \
+pkgdata_MODULES = _chain.mod _linux.mod linux.mod fat.mod ufs.mod ext2.mod minix.mod \
 	hfs.mod jfs.mod normal.mod hello.mod vga.mod font.mod _multiboot.mod ls.mod \
-	boot.mod cmp.mod cat.mod terminal.mod fshelp.mod chain.mod
+	boot.mod cmp.mod cat.mod terminal.mod fshelp.mod chain.mod multiboot.mod
 
 # For _chain.mod.
 _chain_mod_SOURCES = loader/i386/pc/chainloader.c
@@ -121,6 +121,10 @@ jfs_mod_CFLAGS = $(COMMON_CFLAGS)
 # For _linux.mod.
 _linux_mod_SOURCES = loader/i386/pc/linux.c
 _linux_mod_CFLAGS = $(COMMON_CFLAGS)
+ 
+# For linux.mod.
+linux_mod_SOURCES = loader/i386/pc/linux_normal.c
+linux_mod_CFLAGS = $(COMMON_CFLAGS)
 
 # For normal.mod.
 normal_mod_SOURCES = normal/cmdline.c normal/command.c normal/main.c \
@@ -163,3 +167,7 @@ font_mod_CFLAGS = $(COMMON_CFLAGS)
 # For _multiboot.mod.
 _multiboot_mod_SOURCES = loader/i386/pc/multiboot.c
 _multiboot_mod_CFLAGS = $(COMMON_CFLAGS)
+
+# For multiboot.mod.
+multiboot_mod_SOURCES = loader/i386/pc/multiboot_normal.c
+multiboot_mod_CFLAGS = $(COMMON_CFLAGS)
Index: fs/ext2.c
===================================================================
RCS file: /cvsroot/grub/grub2/fs/ext2.c,v
retrieving revision 1.9
diff -u -p -u -p -r1.9 ext2.c
--- fs/ext2.c	11 Sep 2004 11:42:43 -0000	1.9
+++ fs/ext2.c	13 Sep 2004 18:06:19 -0000
@@ -451,14 +451,14 @@ grub_ext2_iterate_dir (grub_fshelp_node_
 	      
 	      fdiro->inode_read = 1;
 	      
-	      if ((grub_le_to_cpu16 (diro->inode.mode)
+	      if ((grub_le_to_cpu16 (fdiro->inode.mode)
 		   & FILETYPE_INO_MASK) == FILETYPE_INO_DIRECTORY)
 		type = GRUB_FSHELP_DIR;
-	      else if ((grub_le_to_cpu16 (diro->inode.mode)
-			& FILETYPE_INO_MASK) == FILETYPE_INO_DIRECTORY)
+	      else if ((grub_le_to_cpu16 (fdiro->inode.mode)
+			& FILETYPE_INO_MASK) == FILETYPE_INO_SYMLINK)
 		type = GRUB_FSHELP_SYMLINK;
-	      else if ((grub_le_to_cpu16 (diro->inode.mode)
-			& FILETYPE_INO_MASK) == FILETYPE_INO_DIRECTORY)
+	      else if ((grub_le_to_cpu16 (fdiro->inode.mode)
+			& FILETYPE_INO_MASK) == FILETYPE_INO_REG)
 		type = GRUB_FSHELP_REG;
 	    }
 	  
Index: loader/i386/pc/linux.c
===================================================================
RCS file: /cvsroot/grub/grub2/loader/i386/pc/linux.c,v
retrieving revision 1.6
diff -u -p -u -p -r1.6 linux.c
--- loader/i386/pc/linux.c	4 Apr 2004 13:46:02 -0000	1.6
+++ loader/i386/pc/linux.c	13 Sep 2004 18:06:19 -0000
@@ -290,8 +290,7 @@ grub_rescue_cmd_linux (int argc, char *a
 }
 
 void
-grub_rescue_cmd_initrd (int argc __attribute__ ((unused)),
-			char *argv[] __attribute__ ((unused)))
+grub_rescue_cmd_initrd (int argc, char *argv[])
 {
   grub_file_t file = 0;
   grub_ssize_t size;
Index: loader/i386/pc/linux_normal.c
===================================================================
RCS file: loader/i386/pc/linux_normal.c
diff -N loader/i386/pc/linux_normal.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ loader/i386/pc/linux_normal.c	13 Sep 2004 18:06:19 -0000
@@ -0,0 +1,61 @@
+/* linux_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/loader.h>
+#include <grub/err.h>
+#include <grub/normal.h>
+#include <grub/dl.h>
+
+static grub_err_t
+grub_normal_linux_command (struct grub_arg_list *state __attribute__ ((unused)),
+			   int argc, char **args)
+{
+  grub_rescue_cmd_linux (argc, args);
+  return grub_errno;
+}
+
+
+static grub_err_t
+grub_normal_initrd_command (struct grub_arg_list *state __attribute__ ((unused)),
+			    int argc, char **args)
+{
+  grub_rescue_cmd_initrd (argc, args);
+  return grub_errno;
+}
+
+GRUB_MOD_INIT
+{
+  (void) mod; /* To stop warning.  */
+  grub_register_command ("linux", grub_normal_linux_command,
+			 GRUB_COMMAND_FLAG_BOTH,
+			 "linux FILE [ARGS...]",
+			 "Load linux", 0);
+  
+  grub_register_command ("initrd", grub_normal_initrd_command,
+			 GRUB_COMMAND_FLAG_BOTH,
+			 "initrd FILE",
+			 "Load initrd", 0);
+}
+
+GRUB_MOD_FINI
+{
+  grub_unregister_command ("linux");
+  grub_unregister_command ("initrd");
+}
Index: loader/i386/pc/multiboot_normal.c
===================================================================
RCS file: loader/i386/pc/multiboot_normal.c
diff -N loader/i386/pc/multiboot_normal.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ loader/i386/pc/multiboot_normal.c	13 Sep 2004 18:06:19 -0000
@@ -0,0 +1,61 @@
+/* multiboot_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/loader.h>
+#include <grub/err.h>
+#include <grub/normal.h>
+#include <grub/dl.h>
+
+static grub_err_t
+grub_normal_cmd_multiboot (struct grub_arg_list *state __attribute__ ((unused)),
+			   int argc, char **args)
+{
+  grub_rescue_cmd_multiboot (argc, args);
+  return grub_errno;
+}
+
+
+static grub_err_t
+grub_normal_cmd_module (struct grub_arg_list *state __attribute__ ((unused)),
+			int argc, char **args)
+{
+  grub_rescue_cmd_module (argc, args);
+  return grub_errno;
+}
+
+GRUB_MOD_INIT
+{
+  (void) mod; /* To stop warning.  */
+  grub_register_command ("multiboot", grub_normal_cmd_multiboot,
+			 GRUB_COMMAND_FLAG_BOTH,
+			 "multiboot FILE [ARGS...]",
+			 "Load a multiboot kernel", 0);
+  
+  grub_register_command ("module", grub_normal_cmd_module,
+			 GRUB_COMMAND_FLAG_BOTH,
+			 "multiboot FILE [ARGS...]",
+			 "Load a multiboot module", 0);
+}
+
+GRUB_MOD_FINI
+{
+  grub_unregister_command ("multiboot");
+  grub_unregister_command ("module");
+}




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

end of thread, other threads:[~2004-09-15 14:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-13 18:11 Normal mode linux and multiboot loaders Marco Gerards
2004-09-13 21:43 ` Yoshinori K. Okuji
2004-09-15  0:34 ` Marco Gerards
2004-09-15  9:47   ` Yoshinori K. Okuji
2004-09-15 14:40     ` Marco Gerards

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.