All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch] Move multiboot helpers out of the kernel
@ 2009-02-11 10:42 phcoder
  2009-03-13 23:35 ` phcoder
  0 siblings, 1 reply; 9+ messages in thread
From: phcoder @ 2009-02-11 10:42 UTC (permalink / raw)
  To: The development of GRUB 2

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

Hello. multiboot helpers have no real reason to stay in kernel. So here 
is the proposition to move them out of it to _multiboot.mod.
Changelog:
2009-02-11  Vladimir Serbinenko  <phcoder@gmail.com>

	Move multiboot helper out of kernel

	* conf/i386-pc.rmk: Add loader/i386/multiboot.S to
	_multiboot.mod
	* conf/i386-coreboot.rmk: Likewise
	* conf/i386-ieee1275.rmk: Likewise
	* kern/i386/loader.S: Move multiboot helpers from here...
	* loader/i386/multiboot.S: ...moved here
	* include/grub/i386/loader.h: Move declarations of multiboot
	helpers from here...
	* include/grub/i386/multiboot.h: ...moved here
	* loader/i386/pc/multiboot.c: Added include of
	grub/cpu/multiboot.h

Thanks
Vladimir 'phcoder' Serbinenko

[-- Attachment #2: mb.patch --]
[-- Type: text/x-diff, Size: 11265 bytes --]

Index: conf/i386-pc.rmk
===================================================================
--- conf/i386-pc.rmk	(revision 1989)
+++ conf/i386-pc.rmk	(working copy)
@@ -236,11 +248,13 @@
 
 # For _multiboot.mod.
 _multiboot_mod_SOURCES = loader/i386/pc/multiboot.c \
+			 loader/i386/multiboot.S \
                          loader/i386/pc/multiboot2.c \
                          loader/multiboot2.c \
                          loader/multiboot_loader.c
 _multiboot_mod_CFLAGS = $(COMMON_CFLAGS)
 _multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
+_multiboot_mod_ASFLAGS = $(COMMON_ASFLAGS)
 
 # For multiboot.mod.
 multiboot_mod_SOURCES = loader/multiboot_loader_normal.c 
Index: conf/i386-coreboot.rmk
===================================================================
--- conf/i386-coreboot.rmk	(revision 1989)
+++ conf/i386-coreboot.rmk	(working copy)
@@ -150,10 +150,12 @@
 # For _multiboot.mod.
 _multiboot_mod_SOURCES = loader/i386/pc/multiboot.c \
                          loader/i386/pc/multiboot2.c \
+			 loader/i386/multiboot.S \
                          loader/multiboot2.c \
                          loader/multiboot_loader.c
 _multiboot_mod_CFLAGS = $(COMMON_CFLAGS)
 _multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
+_multiboot_mod_ASFLAGS = $(COMMON_ASFLAGS)
 
 # For multiboot.mod.
 multiboot_mod_SOURCES = loader/multiboot_loader_normal.c 
Index: conf/i386-ieee1275.rmk
===================================================================
--- conf/i386-ieee1275.rmk	(revision 1989)
+++ conf/i386-ieee1275.rmk	(working copy)
@@ -124,10 +124,12 @@
 
 # For _multiboot.mod.
 _multiboot_mod_SOURCES = loader/ieee1275/multiboot2.c \
+			 loader/i386/multiboot.S \
 			 loader/multiboot2.c \
 			 loader/multiboot_loader.c
 _multiboot_mod_CFLAGS = $(COMMON_CFLAGS)
 _multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
+_multiboot_mod_ASFLAGS = $(COMMON_ASFLAGS)
 
 # For multiboot.mod.
 multiboot_mod_SOURCES = loader/multiboot_loader_normal.c 
Index: kern/i386/loader.S
===================================================================
--- kern/i386/loader.S	(revision 1989)
+++ kern/i386/loader.S	(working copy)
@@ -117,104 +117,3 @@
 linux_setup_seg:
 	.word	0
 	.code32
-
-
-/*
- * This starts the multiboot kernel.
- */
-
-VARIABLE(grub_multiboot_payload_size)
-	.long	0
-VARIABLE(grub_multiboot_payload_orig)
-	.long	0
-VARIABLE(grub_multiboot_payload_dest)
-	.long	0
-VARIABLE(grub_multiboot_payload_entry_offset)
-	.long	0
-
-/*
- * The relocators below understand the following parameters:
- * ecx:	Size of the block to be copied.
- * esi:	Where to copy from (always lowest address, even if we're relocating
- *      backwards).
- * edi:	Where to copy to (likewise).
- * edx:	Offset of the entry point (relative to the beginning of the block).
- */
-VARIABLE(grub_multiboot_forward_relocator)
-	/* Add entry offset.  */
-	addl	%edi, %edx
-
-	/* Forward copy.  */
-	cld
-	rep
-	movsb
-
-	jmp	*%edx
-VARIABLE(grub_multiboot_forward_relocator_end)
-
-VARIABLE(grub_multiboot_backward_relocator)
-	/* Add entry offset (before %edi is mangled).  */
-	addl	%edi, %edx
-
-	/* Backward movsb is implicitly off-by-one.  compensate that.  */
-	decl	%esi
-	decl	%edi
-
-	/* Backward copy.  */
-	std
-	addl	%ecx, %esi
-	addl	%ecx, %edi
-	rep
-	movsb
-
-	jmp	*%edx
-VARIABLE(grub_multiboot_backward_relocator_end)
-
-FUNCTION(grub_multiboot_real_boot)
-	/* Push the entry address on the stack.  */
-	pushl	%eax
-	/* Move the address of the multiboot information structure to ebx.  */
-	movl	%edx,%ebx
-
-	/* Unload all modules and stop the floppy driver.  */
-	call	EXT_C(grub_dl_unload_all)
-	call	EXT_C(grub_stop_floppy)
-
-	/* Interrupts should be disabled.  */
-	cli
-
-	/* Where do we copy what from.  */
-	movl	EXT_C(grub_multiboot_payload_size), %ecx
-	movl	EXT_C(grub_multiboot_payload_orig), %esi
-	movl	EXT_C(grub_multiboot_payload_dest), %edi
-	movl	EXT_C(grub_multiboot_payload_entry_offset), %edx
-
-	/* Move the magic value into eax.  */
-	movl	$MULTIBOOT_MAGIC2, %eax
-				
-	/* Jump to the relocator.  */
-	popl	%ebp
-	jmp 	*%ebp
-	
-/*
- * This starts the multiboot 2 kernel.
- */
-
-FUNCTION(grub_multiboot2_real_boot)
-        /* Push the entry address on the stack.  */
-        pushl   %eax
-        /* Move the address of the multiboot information structure to ebx.  */
-        movl    %edx,%ebx
-
-        /* Unload all modules and stop the floppy driver.  */
-        call    EXT_C(grub_dl_unload_all)
-        call    EXT_C(grub_stop_floppy)
-
-        /* Interrupts should be disabled.  */
-        cli
-
-        /* Move the magic value into eax and jump to the kernel.  */
-        movl    $MULTIBOOT2_BOOTLOADER_MAGIC,%eax
-        popl    %ecx
-        jmp     *%ecx
-
Index: include/grub/i386/multiboot.h
===================================================================
--- include/grub/i386/multiboot.h	(revision 0)
+++ include/grub/i386/multiboot.h	(revision 0)
@@ -0,0 +1,24 @@
+#ifndef GRUB_MULTIBOOT_CPU_HEADER
+#define GRUB_MULTIBOOT_CPU_HEADER	1
+
+/* The asm part of the multiboot loader.  */
+void grub_multiboot_real_boot (grub_addr_t entry,
+			       struct grub_multiboot_info *mbi)
+     __attribute__ ((noreturn));
+void grub_multiboot2_real_boot (grub_addr_t entry,
+				struct grub_multiboot_info *mbi)
+     __attribute__ ((noreturn));
+
+extern grub_addr_t grub_multiboot_payload_orig;
+extern grub_addr_t grub_multiboot_payload_dest;
+extern grub_size_t grub_multiboot_payload_size;
+extern grub_uint32_t grub_multiboot_payload_entry_offset;
+
+extern grub_uint8_t grub_multiboot_forward_relocator;
+extern grub_uint8_t grub_multiboot_forward_relocator_end;
+extern grub_uint8_t grub_multiboot_backward_relocator;
+extern grub_uint8_t grub_multiboot_backward_relocator_end;
+
+#define RELOCATOR_SIZEOF(x)	(&grub_multiboot_##x##_relocator_end - &grub_multiboot_##x##_relocator)
+
+#endif /* ! GRUB_MULTIBOOT_CPU_HEADER */
Index: include/grub/i386/loader.h
===================================================================
--- include/grub/i386/loader.h	(revision 1989)
+++ include/grub/i386/loader.h	(working copy)
@@ -22,7 +22,6 @@
 #include <grub/types.h>
 #include <grub/err.h>
 #include <grub/symbol.h>
-#include <grub/multiboot.h>
 
 extern grub_uint32_t EXPORT_VAR(grub_linux_prot_size);
 extern char *EXPORT_VAR(grub_linux_tmp_addr);
@@ -33,31 +32,15 @@
 
 grub_err_t EXPORT_FUNC(grub_linux_boot) (void);
 
-/* The asm part of the multiboot loader.  */
-void EXPORT_FUNC(grub_multiboot_real_boot) (grub_addr_t entry,
-					    struct grub_multiboot_info *mbi)
-     __attribute__ ((noreturn));
-void EXPORT_FUNC(grub_multiboot2_real_boot) (grub_addr_t entry,
-                                             struct grub_multiboot_info *mbi)
-     __attribute__ ((noreturn));
 void EXPORT_FUNC(grub_unix_real_boot) (grub_addr_t entry, ...)
      __attribute__ ((cdecl,noreturn));
 
-extern grub_addr_t EXPORT_VAR(grub_multiboot_payload_orig);
-extern grub_addr_t EXPORT_VAR(grub_multiboot_payload_dest);
-extern grub_size_t EXPORT_VAR(grub_multiboot_payload_size);
-extern grub_uint32_t EXPORT_VAR(grub_multiboot_payload_entry_offset);
-
 /* It is necessary to export these functions, because normal mode commands
    reuse rescue mode commands.  */
 void grub_rescue_cmd_linux (int argc, char *argv[]);
 void grub_rescue_cmd_initrd (int argc, char *argv[]);
 
-extern grub_uint8_t EXPORT_VAR(grub_multiboot_forward_relocator);
-extern grub_uint8_t EXPORT_VAR(grub_multiboot_forward_relocator_end);
-extern grub_uint8_t EXPORT_VAR(grub_multiboot_backward_relocator);
-extern grub_uint8_t EXPORT_VAR(grub_multiboot_backward_relocator_end);
+void EXPORT_FUNC(grub_stop_floppy) (void);
 
-#define RELOCATOR_SIZEOF(x)	(&grub_multiboot_##x##_relocator_end - &grub_multiboot_##x##_relocator)
 
 #endif /* ! GRUB_LOADER_CPU_HEADER */
Index: loader/i386/multiboot.S
===================================================================
--- loader/i386/multiboot.S	(revision 0)
+++ loader/i386/multiboot.S	(revision 0)
@@ -0,0 +1,97 @@
+#include <grub/symbol.h>
+#include <multiboot.h>
+#include <multiboot2.h>
+	
+	.p2align	2	/* force 4-byte alignment */
+
+/*
+ * This starts the multiboot kernel.
+ */
+
+VARIABLE(grub_multiboot_payload_size)
+	.long	0
+VARIABLE(grub_multiboot_payload_orig)
+	.long	0
+VARIABLE(grub_multiboot_payload_dest)
+	.long	0
+VARIABLE(grub_multiboot_payload_entry_offset)
+	.long	0
+
+/*
+ * The relocators below understand the following parameters:
+ * ecx:	Size of the block to be copied.
+ * esi:	Where to copy from (always lowest address, even if we're relocating
+ *      backwards).
+ * edi:	Where to copy to (likewise).
+ * edx:	Offset of the entry point (relative to the beginning of the block).
+ */
+
+VARIABLE(grub_multiboot_forward_relocator)
+	/* Add entry offset.  */
+	addl	%edi, %edx
+
+	/* Forward copy.  */
+	cld
+	rep
+	movsb
+
+	jmp	*%edx
+VARIABLE(grub_multiboot_forward_relocator_end)
+
+VARIABLE(grub_multiboot_backward_relocator)
+	/* Add entry offset (before %edi is mangled).  */
+	addl	%edi, %edx
+
+	/* Backward movsb is implicitly off-by-one.  compensate that.  */
+	decl	%esi
+	decl	%edi
+
+	/* Backward copy.  */
+	std
+	addl	%ecx, %esi
+	addl	%ecx, %edi
+	rep
+	movsb
+
+	jmp	*%edx
+VARIABLE(grub_multiboot_backward_relocator_end)
+
+FUNCTION(grub_multiboot_real_boot)
+	/* Push the entry address on the stack.  */
+	pushl	%eax
+	/* Move the address of the multiboot information structure to ebx.  */
+	movl	%edx,%ebx
+
+	/* Interrupts should be disabled.  */
+	cli
+
+	/* Where do we copy what from.  */
+	movl	EXT_C(grub_multiboot_payload_size), %ecx
+	movl	EXT_C(grub_multiboot_payload_orig), %esi
+	movl	EXT_C(grub_multiboot_payload_dest), %edi
+	movl	EXT_C(grub_multiboot_payload_entry_offset), %edx
+
+	/* Move the magic value into eax.  */
+	movl	$MULTIBOOT_MAGIC2, %eax
+				
+	/* Jump to the relocator.  */
+	popl	%ebp
+	jmp 	*%ebp
+
+/*
+ * This starts the multiboot 2 kernel.
+ */
+
+FUNCTION(grub_multiboot2_real_boot)
+        /* Push the entry address on the stack.  */
+        pushl   %eax
+        /* Move the address of the multiboot information structure to ebx.  */
+        movl    %edx,%ebx
+
+        /* Interrupts should be disabled.  */
+        cli
+
+        /* Move the magic value into eax and jump to the kernel.  */
+        movl    $MULTIBOOT2_BOOTLOADER_MAGIC,%eax
+        popl    %ecx
+        jmp     *%ecx
Index: loader/i386/pc/multiboot.c
===================================================================
--- loader/i386/pc/multiboot.c	(revision 1989)
+++ loader/i386/pc/multiboot.c	(working copy)
@@ -32,6 +32,7 @@
 #include <grub/multiboot.h>
 #include <grub/machine/init.h>
 #include <grub/machine/memory.h>
+#include <grub/cpu/multiboot.h>
 #include <grub/elf.h>
 #include <grub/aout.h>
 #include <grub/file.h>
@@ -52,6 +53,7 @@
 static grub_err_t
 grub_multiboot_boot (void)
 {
+  grub_stop_floppy ();
   grub_multiboot_real_boot (entry, mbi);
 
   /* Not reached.  */
Index: loader/i386/pc/multiboot2.c
===================================================================
--- loader/i386/pc/multiboot2.c	(revision 1989)
+++ loader/i386/pc/multiboot2.c	(working copy)
@@ -73,6 +73,7 @@
 void
 grub_mb2_arch_boot (grub_addr_t entry, void *tags)
 {
+  grub_stop_floppy ();
   grub_multiboot2_real_boot (entry, tags);
 }
 

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

* Re: [Patch] Move multiboot helpers out of the kernel
  2009-02-11 10:42 [Patch] Move multiboot helpers out of the kernel phcoder
@ 2009-03-13 23:35 ` phcoder
  2009-03-14 14:48   ` Robert Millan
  2009-03-21 23:08   ` Robert Millan
  0 siblings, 2 replies; 9+ messages in thread
From: phcoder @ 2009-03-13 23:35 UTC (permalink / raw)
  To: The development of GRUB 2

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

Rediffed
2009-03-14  Vladimir Serbinenko  <phcoder@gmail.com>

      Move multiboot helper out of kernel

      * conf/i386-pc.rmk: Add loader/i386/multiboot_helper.S to
      _multiboot.mod
      * conf/i386-coreboot.rmk: Likewise
      * conf/i386-ieee1275.rmk: Likewise
      * kern/i386/loader.S: Move multiboot helpers from here...
      * loader/i386/multiboot_helper.S: ...moved here
      * include/grub/i386/loader.h: Move declarations of multiboot
      helpers from here...
      * include/grub/i386/multiboot.h: ...moved here
      * loader/i386/multiboot.c: Added include of
      grub/cpu/multiboot.h

phcoder wrote:
> Hello. multiboot helpers have no real reason to stay in kernel. So here 
> is the proposition to move them out of it to _multiboot.mod.
> Changelog:
> 2009-02-11  Vladimir Serbinenko  <phcoder@gmail.com>
> 
>     Move multiboot helper out of kernel
> 
>     * conf/i386-pc.rmk: Add loader/i386/multiboot.S to
>     _multiboot.mod
>     * conf/i386-coreboot.rmk: Likewise
>     * conf/i386-ieee1275.rmk: Likewise
>     * kern/i386/loader.S: Move multiboot helpers from here...
>     * loader/i386/multiboot.S: ...moved here
>     * include/grub/i386/loader.h: Move declarations of multiboot
>     helpers from here...
>     * include/grub/i386/multiboot.h: ...moved here
>     * loader/i386/pc/multiboot.c: Added include of
>     grub/cpu/multiboot.h
> 
> Thanks
> Vladimir 'phcoder' Serbinenko
> 


-- 

Regards
Vladimir 'phcoder' Serbinenko

[-- Attachment #2: mb.patch --]
[-- Type: text/x-diff, Size: 12854 bytes --]

Index: conf/i386-pc.rmk
===================================================================
--- conf/i386-pc.rmk	(revision 2030)
+++ conf/i386-pc.rmk	(working copy)
@@ -238,11 +238,13 @@
 
 # For _multiboot.mod.
 _multiboot_mod_SOURCES = loader/i386/multiboot.c \
+			 loader/i386/multiboot_helper.S \
                          loader/i386/pc/multiboot2.c \
                          loader/multiboot2.c \
                          loader/multiboot_loader.c
 _multiboot_mod_CFLAGS = $(COMMON_CFLAGS)
 _multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
+_multiboot_mod_ASFLAGS = $(COMMON_ASFLAGS)
 
 # For multiboot.mod.
 multiboot_mod_SOURCES = loader/multiboot_loader_normal.c 
Index: conf/i386-coreboot.rmk
===================================================================
--- conf/i386-coreboot.rmk	(revision 2030)
+++ conf/i386-coreboot.rmk	(working copy)
@@ -151,10 +151,12 @@
 # For _multiboot.mod.
 _multiboot_mod_SOURCES = loader/i386/multiboot.c \
                          loader/i386/pc/multiboot2.c \
+			 loader/i386/multiboot_helper.S \
                          loader/multiboot2.c \
                          loader/multiboot_loader.c
 _multiboot_mod_CFLAGS = $(COMMON_CFLAGS)
 _multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
+_multiboot_mod_ASFLAGS = $(COMMON_ASFLAGS)
 
 # For multiboot.mod.
 multiboot_mod_SOURCES = loader/multiboot_loader_normal.c 
Index: conf/i386-ieee1275.rmk
===================================================================
--- conf/i386-ieee1275.rmk	(revision 2030)
+++ conf/i386-ieee1275.rmk	(working copy)
@@ -126,10 +126,12 @@
 
 # For _multiboot.mod.
 _multiboot_mod_SOURCES = loader/ieee1275/multiboot2.c \
+			 loader/i386/multiboot_helper.S \
 			 loader/multiboot2.c \
 			 loader/multiboot_loader.c
 _multiboot_mod_CFLAGS = $(COMMON_CFLAGS)
 _multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
+_multiboot_mod_ASFLAGS = $(COMMON_ASFLAGS)
 
 # For multiboot.mod.
 multiboot_mod_SOURCES = loader/multiboot_loader_normal.c 
Index: kern/i386/loader.S
===================================================================
--- kern/i386/loader.S	(revision 2030)
+++ kern/i386/loader.S	(working copy)
@@ -118,107 +118,7 @@
 	.word	0
 	.code32
 
-
 /*
- * This starts the multiboot kernel.
- */
-
-VARIABLE(grub_multiboot_payload_size)
-	.long	0
-VARIABLE(grub_multiboot_payload_orig)
-	.long	0
-VARIABLE(grub_multiboot_payload_dest)
-	.long	0
-VARIABLE(grub_multiboot_payload_entry_offset)
-	.long	0
-
-/*
- * The relocators below understand the following parameters:
- * ecx:	Size of the block to be copied.
- * esi:	Where to copy from (always lowest address, even if we're relocating
- *      backwards).
- * edi:	Where to copy to (likewise).
- * edx:	Offset of the entry point (relative to the beginning of the block).
- */
-VARIABLE(grub_multiboot_forward_relocator)
-	/* Add entry offset.  */
-	addl	%edi, %edx
-
-	/* Forward copy.  */
-	cld
-	rep
-	movsb
-
-	jmp	*%edx
-VARIABLE(grub_multiboot_forward_relocator_end)
-
-VARIABLE(grub_multiboot_backward_relocator)
-	/* Add entry offset (before %edi is mangled).  */
-	addl	%edi, %edx
-
-	/* Backward movsb is implicitly off-by-one.  compensate that.  */
-	decl	%esi
-	decl	%edi
-
-	/* Backward copy.  */
-	std
-	addl	%ecx, %esi
-	addl	%ecx, %edi
-	rep
-	movsb
-
-	jmp	*%edx
-VARIABLE(grub_multiboot_backward_relocator_end)
-
-FUNCTION(grub_multiboot_real_boot)
-	/* Push the entry address on the stack.  */
-	pushl	%eax
-	/* Move the address of the multiboot information structure to ebx.  */
-	movl	%edx,%ebx
-
-	/* Unload all modules and stop the floppy driver.  */
-	call	EXT_C(grub_dl_unload_all)
-	call	EXT_C(grub_stop_floppy)
-
-	/* Interrupts should be disabled.  */
-	cli
-
-	/* Where do we copy what from.  */
-	movl	EXT_C(grub_multiboot_payload_size), %ecx
-	movl	EXT_C(grub_multiboot_payload_orig), %esi
-	movl	EXT_C(grub_multiboot_payload_dest), %edi
-	movl	EXT_C(grub_multiboot_payload_entry_offset), %edx
-
-	/* Move the magic value into eax.  */
-	movl	$MULTIBOOT_MAGIC2, %eax
-				
-	/* Jump to the relocator.  */
-	popl	%ebp
-	jmp 	*%ebp
-	
-/*
- * This starts the multiboot 2 kernel.
- */
-
-FUNCTION(grub_multiboot2_real_boot)
-        /* Push the entry address on the stack.  */
-        pushl   %eax
-        /* Move the address of the multiboot information structure to ebx.  */
-        movl    %edx,%ebx
-
-        /* Unload all modules and stop the floppy driver.  */
-        call    EXT_C(grub_dl_unload_all)
-        call    EXT_C(grub_stop_floppy)
-
-        /* Interrupts should be disabled.  */
-        cli
-
-        /* Move the magic value into eax and jump to the kernel.  */
-        movl    $MULTIBOOT2_BOOTLOADER_MAGIC,%eax
-        popl    %ecx
-        jmp     *%ecx
-
-/*
  * Use cdecl calling convention for *BSD kernels.
  */
 
Index: include/grub/i386/loader.h
===================================================================
--- include/grub/i386/loader.h	(revision 2030)
+++ include/grub/i386/loader.h	(working copy)
@@ -22,7 +22,6 @@
 #include <grub/types.h>
 #include <grub/err.h>
 #include <grub/symbol.h>
-#include <grub/multiboot.h>
 
 extern grub_uint32_t EXPORT_VAR(grub_linux_prot_size);
 extern char *EXPORT_VAR(grub_linux_tmp_addr);
@@ -33,31 +32,15 @@
 
 grub_err_t EXPORT_FUNC(grub_linux_boot) (void);
 
-/* The asm part of the multiboot loader.  */
-void EXPORT_FUNC(grub_multiboot_real_boot) (grub_addr_t entry,
-					    struct grub_multiboot_info *mbi)
-     __attribute__ ((noreturn));
-void EXPORT_FUNC(grub_multiboot2_real_boot) (grub_addr_t entry,
-                                             struct grub_multiboot_info *mbi)
-     __attribute__ ((noreturn));
 void EXPORT_FUNC(grub_unix_real_boot) (grub_addr_t entry, ...)
      __attribute__ ((cdecl,noreturn));
 
-extern grub_addr_t EXPORT_VAR(grub_multiboot_payload_orig);
-extern grub_addr_t EXPORT_VAR(grub_multiboot_payload_dest);
-extern grub_size_t EXPORT_VAR(grub_multiboot_payload_size);
-extern grub_uint32_t EXPORT_VAR(grub_multiboot_payload_entry_offset);
-
 /* It is necessary to export these functions, because normal mode commands
    reuse rescue mode commands.  */
 void grub_rescue_cmd_linux (int argc, char *argv[]);
 void grub_rescue_cmd_initrd (int argc, char *argv[]);
 
-extern grub_uint8_t EXPORT_VAR(grub_multiboot_forward_relocator);
-extern grub_uint8_t EXPORT_VAR(grub_multiboot_forward_relocator_end);
-extern grub_uint8_t EXPORT_VAR(grub_multiboot_backward_relocator);
-extern grub_uint8_t EXPORT_VAR(grub_multiboot_backward_relocator_end);
+void EXPORT_FUNC(grub_stop_floppy) (void);
 
-#define RELOCATOR_SIZEOF(x)	(&grub_multiboot_##x##_relocator_end - &grub_multiboot_##x##_relocator)
 
 #endif /* ! GRUB_LOADER_CPU_HEADER */
Index: include/grub/i386/multiboot.h
===================================================================
--- include/grub/i386/multiboot.h	(revision 0)
+++ include/grub/i386/multiboot.h	(revision 0)
@@ -0,0 +1,42 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2009  Free Software Foundation, Inc.
+ *
+ *  GRUB 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 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  GRUB 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 GRUB.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GRUB_MULTIBOOT_CPU_HEADER
+#define GRUB_MULTIBOOT_CPU_HEADER	1
+
+/* The asm part of the multiboot loader.  */
+void grub_multiboot_real_boot (grub_addr_t entry,
+			       struct grub_multiboot_info *mbi)
+     __attribute__ ((noreturn));
+void grub_multiboot2_real_boot (grub_addr_t entry,
+				struct grub_multiboot_info *mbi)
+     __attribute__ ((noreturn));
+
+extern grub_addr_t grub_multiboot_payload_orig;
+extern grub_addr_t grub_multiboot_payload_dest;
+extern grub_size_t grub_multiboot_payload_size;
+extern grub_uint32_t grub_multiboot_payload_entry_offset;
+
+extern grub_uint8_t grub_multiboot_forward_relocator;
+extern grub_uint8_t grub_multiboot_forward_relocator_end;
+extern grub_uint8_t grub_multiboot_backward_relocator;
+extern grub_uint8_t grub_multiboot_backward_relocator_end;
+
+#define RELOCATOR_SIZEOF(x)	(&grub_multiboot_##x##_relocator_end - &grub_multiboot_##x##_relocator)
+
+#endif /* ! GRUB_MULTIBOOT_CPU_HEADER */
Index: loader/i386/multiboot.c
===================================================================
--- loader/i386/multiboot.c	(revision 2030)
+++ loader/i386/multiboot.c	(working copy)
@@ -32,6 +32,7 @@
 #include <grub/multiboot.h>
 #include <grub/machine/init.h>
 #include <grub/machine/memory.h>
+#include <grub/cpu/multiboot.h>
 #include <grub/elf.h>
 #include <grub/aout.h>
 #include <grub/file.h>
@@ -53,6 +54,8 @@
 static grub_err_t
 grub_multiboot_boot (void)
 {
+  grub_stop_floppy ();
+
   grub_multiboot_real_boot (entry, mbi_dest);
 
   /* Not reached.  */
Index: loader/i386/pc/multiboot2.c
===================================================================
--- loader/i386/pc/multiboot2.c	(revision 2030)
+++ loader/i386/pc/multiboot2.c	(working copy)
@@ -73,6 +73,7 @@
 void
 grub_mb2_arch_boot (grub_addr_t entry, void *tags)
 {
+  grub_stop_floppy ();
   grub_multiboot2_real_boot (entry, tags);
 }
 
Index: loader/i386/multiboot_helper.S
===================================================================
--- loader/i386/multiboot_helper.S	(revision 0)
+++ loader/i386/multiboot_helper.S	(revision 0)
@@ -0,0 +1,115 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2009  Free Software Foundation, Inc.
+ *
+ *  GRUB 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 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  GRUB 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 GRUB.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/symbol.h>
+#include <multiboot.h>
+#include <multiboot2.h>
+	
+	.p2align	2	/* force 4-byte alignment */
+
+/*
+ * This starts the multiboot kernel.
+ */
+
+VARIABLE(grub_multiboot_payload_size)
+	.long	0
+VARIABLE(grub_multiboot_payload_orig)
+	.long	0
+VARIABLE(grub_multiboot_payload_dest)
+	.long	0
+VARIABLE(grub_multiboot_payload_entry_offset)
+	.long	0
+
+/*
+ * The relocators below understand the following parameters:
+ * ecx:	Size of the block to be copied.
+ * esi:	Where to copy from (always lowest address, even if we're relocating
+ *      backwards).
+ * edi:	Where to copy to (likewise).
+ * edx:	Offset of the entry point (relative to the beginning of the block).
+ */
+
+VARIABLE(grub_multiboot_forward_relocator)
+	/* Add entry offset.  */
+	addl	%edi, %edx
+
+	/* Forward copy.  */
+	cld
+	rep
+	movsb
+
+	jmp	*%edx
+VARIABLE(grub_multiboot_forward_relocator_end)
+
+VARIABLE(grub_multiboot_backward_relocator)
+	/* Add entry offset (before %edi is mangled).  */
+	addl	%edi, %edx
+
+	/* Backward movsb is implicitly off-by-one.  compensate that.  */
+	decl	%esi
+	decl	%edi
+
+	/* Backward copy.  */
+	std
+	addl	%ecx, %esi
+	addl	%ecx, %edi
+	rep
+	movsb
+
+	jmp	*%edx
+VARIABLE(grub_multiboot_backward_relocator_end)
+
+FUNCTION(grub_multiboot_real_boot)
+	/* Push the entry address on the stack.  */
+	pushl	%eax
+	/* Move the address of the multiboot information structure to ebx.  */
+	movl	%edx,%ebx
+
+	/* Interrupts should be disabled.  */
+	cli
+
+	/* Where do we copy what from.  */
+	movl	EXT_C(grub_multiboot_payload_size), %ecx
+	movl	EXT_C(grub_multiboot_payload_orig), %esi
+	movl	EXT_C(grub_multiboot_payload_dest), %edi
+	movl	EXT_C(grub_multiboot_payload_entry_offset), %edx
+
+	/* Move the magic value into eax.  */
+	movl	$MULTIBOOT_MAGIC2, %eax
+				
+	/* Jump to the relocator.  */
+	popl	%ebp
+	jmp 	*%ebp
+
+/*
+ * This starts the multiboot 2 kernel.
+ */
+
+FUNCTION(grub_multiboot2_real_boot)
+        /* Push the entry address on the stack.  */
+        pushl   %eax
+        /* Move the address of the multiboot information structure to ebx.  */
+        movl    %edx,%ebx
+
+        /* Interrupts should be disabled.  */
+        cli
+
+        /* Move the magic value into eax and jump to the kernel.  */
+        movl    $MULTIBOOT2_BOOTLOADER_MAGIC,%eax
+        popl    %ecx
+        jmp     *%ecx

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

* Re: [Patch] Move multiboot helpers out of the kernel
  2009-03-13 23:35 ` phcoder
@ 2009-03-14 14:48   ` Robert Millan
  2009-03-14 17:52     ` phcoder
  2009-03-21 23:08   ` Robert Millan
  1 sibling, 1 reply; 9+ messages in thread
From: Robert Millan @ 2009-03-14 14:48 UTC (permalink / raw)
  To: The development of GRUB 2

On Sat, Mar 14, 2009 at 12:35:09AM +0100, phcoder wrote:
> Index: conf/i386-ieee1275.rmk
> ===================================================================
> --- conf/i386-ieee1275.rmk	(revision 2030)
> +++ conf/i386-ieee1275.rmk	(working copy)
> @@ -126,10 +126,12 @@
>  
>  # For _multiboot.mod.
>  _multiboot_mod_SOURCES = loader/ieee1275/multiboot2.c \
> +			 loader/i386/multiboot_helper.S \

multiboot_helper.S is not being used on i386-ieee1275 AFAICT

> -	/* Unload all modules and stop the floppy driver.  */
> -	call	EXT_C(grub_dl_unload_all)

grub_dl_unload_all() just disappeared.  Is this intentional?  I
tend to agree that grub_dl_unload_all() is a waste of time, but
this should be discussed separately.

> -	call	EXT_C(grub_stop_floppy)

grub_stop_floppy() was moved to grub_multiboot_boot().  I think
grub_machine_fini() would be the more appropiate place.  I'm not
sure why it was in those asm snippets to begin with (does someone
know?).

Also, grub_unix_real_boot() completely disappeared with your patch.
This seems to break *BSD.

-- 
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."



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

* Re: [Patch] Move multiboot helpers out of the kernel
  2009-03-14 14:48   ` Robert Millan
@ 2009-03-14 17:52     ` phcoder
  2009-03-15 15:34       ` Robert Millan
  0 siblings, 1 reply; 9+ messages in thread
From: phcoder @ 2009-03-14 17:52 UTC (permalink / raw)
  To: The development of GRUB 2

Robert Millan wrote:
> On Sat, Mar 14, 2009 at 12:35:09AM +0100, phcoder wrote:
>> Index: conf/i386-ieee1275.rmk
>> ===================================================================
>> --- conf/i386-ieee1275.rmk	(revision 2030)
>> +++ conf/i386-ieee1275.rmk	(working copy)
>> @@ -126,10 +126,12 @@
>>  
>>  # For _multiboot.mod.
>>  _multiboot_mod_SOURCES = loader/ieee1275/multiboot2.c \
>> +			 loader/i386/multiboot_helper.S \
> 
> multiboot_helper.S is not being used on i386-ieee1275 AFAICT

How can it be if multiboot.c is the same for pc and ieee1275?

> 
>> -	/* Unload all modules and stop the floppy driver.  */
>> -	call	EXT_C(grub_dl_unload_all)
> 
> grub_dl_unload_all() just disappeared.  Is this intentional?  I
> tend to agree that grub_dl_unload_all() is a waste of time, but
> this should be discussed separately.

It is intentional because multiboot_real_boot is now in a module so we 
can't unload it

> 
>> -	call	EXT_C(grub_stop_floppy)
> 
> grub_stop_floppy() was moved to grub_multiboot_boot().  I think
> grub_machine_fini() would be the more appropiate place.  I'm not
> sure why it was in those asm snippets to begin with (does someone
> know?).
> 
I'll have a look at it
> Also, grub_unix_real_boot() completely disappeared with your patch.
> This seems to break *BSD.
> 
Last patch doesn't remove grub_unix_real_boot

-- 

Regards
Vladimir 'phcoder' Serbinenko



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

* Re: [Patch] Move multiboot helpers out of the kernel
  2009-03-14 17:52     ` phcoder
@ 2009-03-15 15:34       ` Robert Millan
  2009-03-21 22:51         ` phcoder
  0 siblings, 1 reply; 9+ messages in thread
From: Robert Millan @ 2009-03-15 15:34 UTC (permalink / raw)
  To: The development of GRUB 2

On Sat, Mar 14, 2009 at 06:52:55PM +0100, phcoder wrote:
> Robert Millan wrote:
>> On Sat, Mar 14, 2009 at 12:35:09AM +0100, phcoder wrote:
>>> Index: conf/i386-ieee1275.rmk
>>> ===================================================================
>>> --- conf/i386-ieee1275.rmk	(revision 2030)
>>> +++ conf/i386-ieee1275.rmk	(working copy)
>>> @@ -126,10 +126,12 @@
>>>   # For _multiboot.mod.
>>>  _multiboot_mod_SOURCES = loader/ieee1275/multiboot2.c \
>>> +			 loader/i386/multiboot_helper.S \
>>
>> multiboot_helper.S is not being used on i386-ieee1275 AFAICT
>
> How can it be if multiboot.c is the same for pc and ieee1275?

$ grep multiboot.c conf/*.rmk
conf/i386-coreboot.rmk:_multiboot_mod_SOURCES = loader/i386/multiboot.c \
conf/i386-pc.rmk:_multiboot_mod_SOURCES = loader/i386/multiboot.c \

>> grub_dl_unload_all() just disappeared.  Is this intentional?  I
>> tend to agree that grub_dl_unload_all() is a waste of time, but
>> this should be discussed separately.
>
> It is intentional because multiboot_real_boot is now in a module so we  
> can't unload it

Ok then, I'm fine with disabling the unload.  What does everybody else
think?

-- 
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."



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

* Re: [Patch] Move multiboot helpers out of the kernel
  2009-03-15 15:34       ` Robert Millan
@ 2009-03-21 22:51         ` phcoder
  0 siblings, 0 replies; 9+ messages in thread
From: phcoder @ 2009-03-21 22:51 UTC (permalink / raw)
  To: The development of GRUB 2

Robert Millan wrote:
> On Sat, Mar 14, 2009 at 06:52:55PM +0100, phcoder wrote:
>> Robert Millan wrote:
>>> On Sat, Mar 14, 2009 at 12:35:09AM +0100, phcoder wrote:
>>>> Index: conf/i386-ieee1275.rmk
>>>> ===================================================================
>>>> --- conf/i386-ieee1275.rmk	(revision 2030)
>>>> +++ conf/i386-ieee1275.rmk	(working copy)
>>>> @@ -126,10 +126,12 @@
>>>>   # For _multiboot.mod.
>>>>  _multiboot_mod_SOURCES = loader/ieee1275/multiboot2.c \
>>>> +			 loader/i386/multiboot_helper.S \
>>> multiboot_helper.S is not being used on i386-ieee1275 AFAICT
>> How can it be if multiboot.c is the same for pc and ieee1275?
> 
> $ grep multiboot.c conf/*.rmk
> conf/i386-coreboot.rmk:_multiboot_mod_SOURCES = loader/i386/multiboot.c \
> conf/i386-pc.rmk:_multiboot_mod_SOURCES = loader/i386/multiboot.c \
> 
void
grub_mb2_arch_boot (grub_addr_t entry_addr, void *tags)
{
#if defined(__powerpc__)
   kernel_entry_t entry = (kernel_entry_t) entry_addr;
   entry (MULTIBOOT2_BOOTLOADER_MAGIC, tags, grub_ieee1275_entry_fn, 0, 0);
#elif defined(__i386__)
   grub_multiboot2_real_boot (entry_addr, tags);
#else
#error
#endif
}

As you see it uses grub_multiboot2_real_boot
>>> grub_dl_unload_all() just disappeared.  Is this intentional?  I
>>> tend to agree that grub_dl_unload_all() is a waste of time, but
>>> this should be discussed separately.
>> It is intentional because multiboot_real_boot is now in a module so we  
>> can't unload it
> 
> Ok then, I'm fine with disabling the unload.  What does everybody else
> think?
> 


-- 

Regards
Vladimir 'phcoder' Serbinenko



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

* Re: [Patch] Move multiboot helpers out of the kernel
  2009-03-13 23:35 ` phcoder
  2009-03-14 14:48   ` Robert Millan
@ 2009-03-21 23:08   ` Robert Millan
  2009-03-22  0:15     ` phcoder
  1 sibling, 1 reply; 9+ messages in thread
From: Robert Millan @ 2009-03-21 23:08 UTC (permalink / raw)
  To: The development of GRUB 2


Is this the last patch?  I rechecked this thread, but might have
missed something.

On Sat, Mar 14, 2009 at 12:35:09AM +0100, phcoder wrote:
> Rediffed
> 2009-03-14  Vladimir Serbinenko  <phcoder@gmail.com>
>
>      Move multiboot helper out of kernel
>
>      * conf/i386-pc.rmk: Add loader/i386/multiboot_helper.S to
>      _multiboot.mod

This should be like:

	* conf/i386-pc.rmk (_multiboot_mod_SOURCES): Add
	`loader/i386/multiboot_helper.S'.

Also, the addition of _multiboot_mod_ASFLAGS isn't mentioned.

-- 
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."



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

* Re: [Patch] Move multiboot helpers out of the kernel
  2009-03-21 23:08   ` Robert Millan
@ 2009-03-22  0:15     ` phcoder
  2009-03-22 12:29       ` Robert Millan
  0 siblings, 1 reply; 9+ messages in thread
From: phcoder @ 2009-03-22  0:15 UTC (permalink / raw)
  To: The development of GRUB 2

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

Fixed. I temporarily left grub_stop_floppy in linux code.
2009-03-22  Vladimir Serbinenko  <phcoder@gmail.com>

      Move multiboot helper out of kernel

      * conf/i386-pc.rmk (multiboot_mod_SOURCES): Add 
loader/i386/multiboot_helper.S
      * conf/i386-coreboot.rmk: Likewise
      * conf/i386-ieee1275.rmk: Likewise
      * kern/i386/loader.S: Move multiboot helpers from here...
      * loader/i386/multiboot_helper.S: ...moved here
      * include/grub/i386/loader.h: Move declarations of multiboot
      helpers from here...
      * include/grub/i386/multiboot.h: ...moved here
      * loader/i386/multiboot.c: Added include of
      grub/cpu/multiboot.h

Robert Millan wrote:
> Is this the last patch?  I rechecked this thread, but might have
> missed something.
> 
> On Sat, Mar 14, 2009 at 12:35:09AM +0100, phcoder wrote:
>> Rediffed
>> 2009-03-14  Vladimir Serbinenko  <phcoder@gmail.com>
>>
>>      Move multiboot helper out of kernel
>>
>>      * conf/i386-pc.rmk: Add loader/i386/multiboot_helper.S to
>>      _multiboot.mod
> 
> This should be like:
> 
> 	* conf/i386-pc.rmk (_multiboot_mod_SOURCES): Add
> 	`loader/i386/multiboot_helper.S'.
> 
> Also, the addition of _multiboot_mod_ASFLAGS isn't mentioned.
> 


-- 

Regards
Vladimir 'phcoder' Serbinenko

[-- Attachment #2: mb.patch --]
[-- Type: text/x-diff, Size: 13115 bytes --]

diff --git a/conf/i386-coreboot.rmk b/conf/i386-coreboot.rmk
index 0b4f216..53595de 100644
--- a/conf/i386-coreboot.rmk
+++ b/conf/i386-coreboot.rmk
@@ -145,11 +145,13 @@ serial_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
 # For multiboot.mod.
 multiboot_mod_SOURCES = loader/i386/multiboot.c \
+			loader/i386/multiboot_helper.S \
                          loader/i386/pc/multiboot2.c \
                          loader/multiboot2.c \
                          loader/multiboot_loader.c
 multiboot_mod_CFLAGS = $(COMMON_CFLAGS)
 multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
+multiboot_mod_ASFLAGS = $(COMMON_ASFLAGS)
 
 # For aout.mod.
 aout_mod_SOURCES = loader/aout.c
diff --git a/conf/i386-ieee1275.rmk b/conf/i386-ieee1275.rmk
index dbcbb4a..a84b5aa 100644
--- a/conf/i386-ieee1275.rmk
+++ b/conf/i386-ieee1275.rmk
@@ -127,10 +127,12 @@ normal_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
 # For multiboot.mod.
 multiboot_mod_SOURCES = loader/ieee1275/multiboot2.c \
+			loader/i386/multiboot_helper.S \
 			 loader/multiboot2.c \
 			 loader/multiboot_loader.c
 multiboot_mod_CFLAGS = $(COMMON_CFLAGS)
 multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
+multiboot_mod_ASFLAGS = $(COMMON_ASFLAGS)
 
 # For aout.mod.
 aout_mod_SOURCES = loader/aout.c
diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk
index cc845ed..60d5182 100644
--- a/conf/i386-pc.rmk
+++ b/conf/i386-pc.rmk
@@ -228,11 +228,13 @@ serial_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
 # For multiboot.mod.
 multiboot_mod_SOURCES = loader/i386/multiboot.c \
+			loader/i386/multiboot_helper.S \
                         loader/i386/pc/multiboot2.c \
                         loader/multiboot2.c \
                         loader/multiboot_loader.c
 multiboot_mod_CFLAGS = $(COMMON_CFLAGS)
 multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
+multiboot_mod_ASFLAGS = $(COMMON_ASFLAGS)
 
 # For vbe.mod.
 vbe_mod_SOURCES = video/i386/pc/vbe.c video/i386/pc/vbeblit.c \
diff --git a/include/grub/i386/loader.h b/include/grub/i386/loader.h
index df8b4e3..3052030 100644
--- a/include/grub/i386/loader.h
+++ b/include/grub/i386/loader.h
@@ -1,6 +1,6 @@
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2002,2003,2004,2007,2008  Free Software Foundation, Inc.
+ *  Copyright (C) 2002,2003,2004,2007,2008,2009  Free Software Foundation, Inc.
  *
  *  GRUB is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -22,7 +22,6 @@
 #include <grub/types.h>
 #include <grub/err.h>
 #include <grub/symbol.h>
-#include <grub/multiboot.h>
 
 extern grub_uint32_t EXPORT_VAR(grub_linux_prot_size);
 extern char *EXPORT_VAR(grub_linux_tmp_addr);
@@ -33,26 +32,7 @@ extern grub_size_t EXPORT_VAR(grub_os_area_size);
 
 grub_err_t EXPORT_FUNC(grub_linux_boot) (void);
 
-/* The asm part of the multiboot loader.  */
-void EXPORT_FUNC(grub_multiboot_real_boot) (grub_addr_t entry,
-					    struct grub_multiboot_info *mbi)
-     __attribute__ ((noreturn));
-void EXPORT_FUNC(grub_multiboot2_real_boot) (grub_addr_t entry,
-                                             struct grub_multiboot_info *mbi)
-     __attribute__ ((noreturn));
 void EXPORT_FUNC(grub_unix_real_boot) (grub_addr_t entry, ...)
      __attribute__ ((cdecl,noreturn));
 
-extern grub_addr_t EXPORT_VAR(grub_multiboot_payload_orig);
-extern grub_addr_t EXPORT_VAR(grub_multiboot_payload_dest);
-extern grub_size_t EXPORT_VAR(grub_multiboot_payload_size);
-extern grub_uint32_t EXPORT_VAR(grub_multiboot_payload_entry_offset);
-
-extern grub_uint8_t EXPORT_VAR(grub_multiboot_forward_relocator);
-extern grub_uint8_t EXPORT_VAR(grub_multiboot_forward_relocator_end);
-extern grub_uint8_t EXPORT_VAR(grub_multiboot_backward_relocator);
-extern grub_uint8_t EXPORT_VAR(grub_multiboot_backward_relocator_end);
-
-#define RELOCATOR_SIZEOF(x)	(&grub_multiboot_##x##_relocator_end - &grub_multiboot_##x##_relocator)
-
 #endif /* ! GRUB_LOADER_CPU_HEADER */
diff --git a/include/grub/i386/multiboot.h b/include/grub/i386/multiboot.h
new file mode 100644
index 0000000..ea68640
--- /dev/null
+++ b/include/grub/i386/multiboot.h
@@ -0,0 +1,42 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2009  Free Software Foundation, Inc.
+ *
+ *  GRUB 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 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  GRUB 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 GRUB.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GRUB_MULTIBOOT_CPU_HEADER
+#define GRUB_MULTIBOOT_CPU_HEADER	1
+
+/* The asm part of the multiboot loader.  */
+void grub_multiboot_real_boot (grub_addr_t entry,
+			       struct grub_multiboot_info *mbi)
+     __attribute__ ((noreturn));
+void grub_multiboot2_real_boot (grub_addr_t entry,
+				struct grub_multiboot_info *mbi)
+     __attribute__ ((noreturn));
+
+extern grub_addr_t grub_multiboot_payload_orig;
+extern grub_addr_t grub_multiboot_payload_dest;
+extern grub_size_t grub_multiboot_payload_size;
+extern grub_uint32_t grub_multiboot_payload_entry_offset;
+
+extern grub_uint8_t grub_multiboot_forward_relocator;
+extern grub_uint8_t grub_multiboot_forward_relocator_end;
+extern grub_uint8_t grub_multiboot_backward_relocator;
+extern grub_uint8_t grub_multiboot_backward_relocator_end;
+
+#define RELOCATOR_SIZEOF(x)	(&grub_multiboot_##x##_relocator_end - &grub_multiboot_##x##_relocator)
+
+#endif /* ! GRUB_MULTIBOOT_CPU_HEADER */
diff --git a/kern/i386/coreboot/init.c b/kern/i386/coreboot/init.c
index 9978d4a..1348488 100644
--- a/kern/i386/coreboot/init.c
+++ b/kern/i386/coreboot/init.c
@@ -146,6 +146,7 @@ grub_machine_fini (void)
 {
   grub_at_keyboard_fini ();
   grub_vga_text_fini ();
+  grub_stop_floppy ();
 }
 
 /* Return the end of the core image.  */
diff --git a/kern/i386/loader.S b/kern/i386/loader.S
index cacbbea..0e8ded6 100644
--- a/kern/i386/loader.S
+++ b/kern/i386/loader.S
@@ -118,106 +118,6 @@ linux_setup_seg:
 	.word	0
 	.code32
 
-
-/*
- * This starts the multiboot kernel.
- */
-
-VARIABLE(grub_multiboot_payload_size)
-	.long	0
-VARIABLE(grub_multiboot_payload_orig)
-	.long	0
-VARIABLE(grub_multiboot_payload_dest)
-	.long	0
-VARIABLE(grub_multiboot_payload_entry_offset)
-	.long	0
-
-/*
- * The relocators below understand the following parameters:
- * ecx:	Size of the block to be copied.
- * esi:	Where to copy from (always lowest address, even if we're relocating
- *      backwards).
- * edi:	Where to copy to (likewise).
- * edx:	Offset of the entry point (relative to the beginning of the block).
- */
-VARIABLE(grub_multiboot_forward_relocator)
-	/* Add entry offset.  */
-	addl	%edi, %edx
-
-	/* Forward copy.  */
-	cld
-	rep
-	movsb
-
-	jmp	*%edx
-VARIABLE(grub_multiboot_forward_relocator_end)
-
-VARIABLE(grub_multiboot_backward_relocator)
-	/* Add entry offset (before %edi is mangled).  */
-	addl	%edi, %edx
-
-	/* Backward movsb is implicitly off-by-one.  compensate that.  */
-	decl	%esi
-	decl	%edi
-
-	/* Backward copy.  */
-	std
-	addl	%ecx, %esi
-	addl	%ecx, %edi
-	rep
-	movsb
-
-	jmp	*%edx
-VARIABLE(grub_multiboot_backward_relocator_end)
-
-FUNCTION(grub_multiboot_real_boot)
-	/* Push the entry address on the stack.  */
-	pushl	%eax
-	/* Move the address of the multiboot information structure to ebx.  */
-	movl	%edx,%ebx
-
-	/* Unload all modules and stop the floppy driver.  */
-	call	EXT_C(grub_dl_unload_all)
-	call	EXT_C(grub_stop_floppy)
-
-	/* Interrupts should be disabled.  */
-	cli
-
-	/* Where do we copy what from.  */
-	movl	EXT_C(grub_multiboot_payload_size), %ecx
-	movl	EXT_C(grub_multiboot_payload_orig), %esi
-	movl	EXT_C(grub_multiboot_payload_dest), %edi
-	movl	EXT_C(grub_multiboot_payload_entry_offset), %edx
-
-	/* Move the magic value into eax.  */
-	movl	$MULTIBOOT_MAGIC2, %eax
-				
-	/* Jump to the relocator.  */
-	popl	%ebp
-	jmp 	*%ebp
-	
-/*
- * This starts the multiboot 2 kernel.
- */
-
-FUNCTION(grub_multiboot2_real_boot)
-        /* Push the entry address on the stack.  */
-        pushl   %eax
-        /* Move the address of the multiboot information structure to ebx.  */
-        movl    %edx,%ebx
-
-        /* Unload all modules and stop the floppy driver.  */
-        call    EXT_C(grub_dl_unload_all)
-        call    EXT_C(grub_stop_floppy)
-
-        /* Interrupts should be disabled.  */
-        cli
-
-        /* Move the magic value into eax and jump to the kernel.  */
-        movl    $MULTIBOOT2_BOOTLOADER_MAGIC,%eax
-        popl    %ecx
-        jmp     *%ecx
-
 /*
  * Use cdecl calling convention for *BSD kernels.
  */
@@ -225,7 +125,6 @@ FUNCTION(grub_multiboot2_real_boot)
 FUNCTION(grub_unix_real_boot)
 
         call    EXT_C(grub_dl_unload_all)
-        call    EXT_C(grub_stop_floppy)
 
 	/* Interrupts should be disabled.  */
         cli
diff --git a/kern/i386/pc/init.c b/kern/i386/pc/init.c
index 1d6d22f..6191412 100644
--- a/kern/i386/pc/init.c
+++ b/kern/i386/pc/init.c
@@ -223,6 +223,7 @@ void
 grub_machine_fini (void)
 {
   grub_console_fini ();
+  grub_stop_floppy ();
 }
 
 /* Return the end of the core image.  */
diff --git a/loader/i386/multiboot.c b/loader/i386/multiboot.c
index 4c01d87..27042a5 100644
--- a/loader/i386/multiboot.c
+++ b/loader/i386/multiboot.c
@@ -32,6 +32,7 @@
 #include <grub/multiboot.h>
 #include <grub/machine/init.h>
 #include <grub/machine/memory.h>
+#include <grub/cpu/multiboot.h>
 #include <grub/elf.h>
 #include <grub/aout.h>
 #include <grub/file.h>
diff --git a/loader/i386/multiboot_helper.S b/loader/i386/multiboot_helper.S
new file mode 100644
index 0000000..1e71120
--- /dev/null
+++ b/loader/i386/multiboot_helper.S
@@ -0,0 +1,115 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2009  Free Software Foundation, Inc.
+ *
+ *  GRUB 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 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  GRUB 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 GRUB.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/symbol.h>
+#include <multiboot.h>
+#include <multiboot2.h>
+	
+	.p2align	2	/* force 4-byte alignment */
+
+/*
+ * This starts the multiboot kernel.
+ */
+
+VARIABLE(grub_multiboot_payload_size)
+	.long	0
+VARIABLE(grub_multiboot_payload_orig)
+	.long	0
+VARIABLE(grub_multiboot_payload_dest)
+	.long	0
+VARIABLE(grub_multiboot_payload_entry_offset)
+	.long	0
+
+/*
+ * The relocators below understand the following parameters:
+ * ecx:	Size of the block to be copied.
+ * esi:	Where to copy from (always lowest address, even if we're relocating
+ *      backwards).
+ * edi:	Where to copy to (likewise).
+ * edx:	Offset of the entry point (relative to the beginning of the block).
+ */
+
+VARIABLE(grub_multiboot_forward_relocator)
+	/* Add entry offset.  */
+	addl	%edi, %edx
+
+	/* Forward copy.  */
+	cld
+	rep
+	movsb
+
+	jmp	*%edx
+VARIABLE(grub_multiboot_forward_relocator_end)
+
+VARIABLE(grub_multiboot_backward_relocator)
+	/* Add entry offset (before %edi is mangled).  */
+	addl	%edi, %edx
+
+	/* Backward movsb is implicitly off-by-one.  compensate that.  */
+	decl	%esi
+	decl	%edi
+
+	/* Backward copy.  */
+	std
+	addl	%ecx, %esi
+	addl	%ecx, %edi
+	rep
+	movsb
+
+	jmp	*%edx
+VARIABLE(grub_multiboot_backward_relocator_end)
+
+FUNCTION(grub_multiboot_real_boot)
+	/* Push the entry address on the stack.  */
+	pushl	%eax
+	/* Move the address of the multiboot information structure to ebx.  */
+	movl	%edx,%ebx
+
+	/* Interrupts should be disabled.  */
+	cli
+
+	/* Where do we copy what from.  */
+	movl	EXT_C(grub_multiboot_payload_size), %ecx
+	movl	EXT_C(grub_multiboot_payload_orig), %esi
+	movl	EXT_C(grub_multiboot_payload_dest), %edi
+	movl	EXT_C(grub_multiboot_payload_entry_offset), %edx
+
+	/* Move the magic value into eax.  */
+	movl	$MULTIBOOT_MAGIC2, %eax
+				
+	/* Jump to the relocator.  */
+	popl	%ebp
+	jmp 	*%ebp
+
+/*
+ * This starts the multiboot 2 kernel.
+ */
+
+FUNCTION(grub_multiboot2_real_boot)
+        /* Push the entry address on the stack.  */
+        pushl   %eax
+        /* Move the address of the multiboot information structure to ebx.  */
+        movl    %edx,%ebx
+
+        /* Interrupts should be disabled.  */
+        cli
+
+        /* Move the magic value into eax and jump to the kernel.  */
+        movl    $MULTIBOOT2_BOOTLOADER_MAGIC,%eax
+        popl    %ecx
+        jmp     *%ecx

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

* Re: [Patch] Move multiboot helpers out of the kernel
  2009-03-22  0:15     ` phcoder
@ 2009-03-22 12:29       ` Robert Millan
  0 siblings, 0 replies; 9+ messages in thread
From: Robert Millan @ 2009-03-22 12:29 UTC (permalink / raw)
  To: The development of GRUB 2


Committed.

On Sun, Mar 22, 2009 at 01:15:03AM +0100, phcoder wrote:
> Fixed. I temporarily left grub_stop_floppy in linux code.
> 2009-03-22  Vladimir Serbinenko  <phcoder@gmail.com>
>
>      Move multiboot helper out of kernel
>
>      * conf/i386-pc.rmk (multiboot_mod_SOURCES): Add  
> loader/i386/multiboot_helper.S
>      * conf/i386-coreboot.rmk: Likewise
>      * conf/i386-ieee1275.rmk: Likewise
>      * kern/i386/loader.S: Move multiboot helpers from here...
>      * loader/i386/multiboot_helper.S: ...moved here
>      * include/grub/i386/loader.h: Move declarations of multiboot
>      helpers from here...
>      * include/grub/i386/multiboot.h: ...moved here
>      * loader/i386/multiboot.c: Added include of
>      grub/cpu/multiboot.h
>
> Robert Millan wrote:
>> Is this the last patch?  I rechecked this thread, but might have
>> missed something.
>>
>> On Sat, Mar 14, 2009 at 12:35:09AM +0100, phcoder wrote:
>>> Rediffed
>>> 2009-03-14  Vladimir Serbinenko  <phcoder@gmail.com>
>>>
>>>      Move multiboot helper out of kernel
>>>
>>>      * conf/i386-pc.rmk: Add loader/i386/multiboot_helper.S to
>>>      _multiboot.mod
>>
>> This should be like:
>>
>> 	* conf/i386-pc.rmk (_multiboot_mod_SOURCES): Add
>> 	`loader/i386/multiboot_helper.S'.
>>
>> Also, the addition of _multiboot_mod_ASFLAGS isn't mentioned.
>>
>
>
> -- 
>
> Regards
> Vladimir 'phcoder' Serbinenko

> diff --git a/conf/i386-coreboot.rmk b/conf/i386-coreboot.rmk
> index 0b4f216..53595de 100644
> --- a/conf/i386-coreboot.rmk
> +++ b/conf/i386-coreboot.rmk
> @@ -145,11 +145,13 @@ serial_mod_LDFLAGS = $(COMMON_LDFLAGS)
>  
>  # For multiboot.mod.
>  multiboot_mod_SOURCES = loader/i386/multiboot.c \
> +			loader/i386/multiboot_helper.S \
>                           loader/i386/pc/multiboot2.c \
>                           loader/multiboot2.c \
>                           loader/multiboot_loader.c
>  multiboot_mod_CFLAGS = $(COMMON_CFLAGS)
>  multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
> +multiboot_mod_ASFLAGS = $(COMMON_ASFLAGS)
>  
>  # For aout.mod.
>  aout_mod_SOURCES = loader/aout.c
> diff --git a/conf/i386-ieee1275.rmk b/conf/i386-ieee1275.rmk
> index dbcbb4a..a84b5aa 100644
> --- a/conf/i386-ieee1275.rmk
> +++ b/conf/i386-ieee1275.rmk
> @@ -127,10 +127,12 @@ normal_mod_LDFLAGS = $(COMMON_LDFLAGS)
>  
>  # For multiboot.mod.
>  multiboot_mod_SOURCES = loader/ieee1275/multiboot2.c \
> +			loader/i386/multiboot_helper.S \
>  			 loader/multiboot2.c \
>  			 loader/multiboot_loader.c
>  multiboot_mod_CFLAGS = $(COMMON_CFLAGS)
>  multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
> +multiboot_mod_ASFLAGS = $(COMMON_ASFLAGS)
>  
>  # For aout.mod.
>  aout_mod_SOURCES = loader/aout.c
> diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk
> index cc845ed..60d5182 100644
> --- a/conf/i386-pc.rmk
> +++ b/conf/i386-pc.rmk
> @@ -228,11 +228,13 @@ serial_mod_LDFLAGS = $(COMMON_LDFLAGS)
>  
>  # For multiboot.mod.
>  multiboot_mod_SOURCES = loader/i386/multiboot.c \
> +			loader/i386/multiboot_helper.S \
>                          loader/i386/pc/multiboot2.c \
>                          loader/multiboot2.c \
>                          loader/multiboot_loader.c
>  multiboot_mod_CFLAGS = $(COMMON_CFLAGS)
>  multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
> +multiboot_mod_ASFLAGS = $(COMMON_ASFLAGS)
>  
>  # For vbe.mod.
>  vbe_mod_SOURCES = video/i386/pc/vbe.c video/i386/pc/vbeblit.c \
> diff --git a/include/grub/i386/loader.h b/include/grub/i386/loader.h
> index df8b4e3..3052030 100644
> --- a/include/grub/i386/loader.h
> +++ b/include/grub/i386/loader.h
> @@ -1,6 +1,6 @@
>  /*
>   *  GRUB  --  GRand Unified Bootloader
> - *  Copyright (C) 2002,2003,2004,2007,2008  Free Software Foundation, Inc.
> + *  Copyright (C) 2002,2003,2004,2007,2008,2009  Free Software Foundation, Inc.
>   *
>   *  GRUB is free software: you can redistribute it and/or modify
>   *  it under the terms of the GNU General Public License as published by
> @@ -22,7 +22,6 @@
>  #include <grub/types.h>
>  #include <grub/err.h>
>  #include <grub/symbol.h>
> -#include <grub/multiboot.h>
>  
>  extern grub_uint32_t EXPORT_VAR(grub_linux_prot_size);
>  extern char *EXPORT_VAR(grub_linux_tmp_addr);
> @@ -33,26 +32,7 @@ extern grub_size_t EXPORT_VAR(grub_os_area_size);
>  
>  grub_err_t EXPORT_FUNC(grub_linux_boot) (void);
>  
> -/* The asm part of the multiboot loader.  */
> -void EXPORT_FUNC(grub_multiboot_real_boot) (grub_addr_t entry,
> -					    struct grub_multiboot_info *mbi)
> -     __attribute__ ((noreturn));
> -void EXPORT_FUNC(grub_multiboot2_real_boot) (grub_addr_t entry,
> -                                             struct grub_multiboot_info *mbi)
> -     __attribute__ ((noreturn));
>  void EXPORT_FUNC(grub_unix_real_boot) (grub_addr_t entry, ...)
>       __attribute__ ((cdecl,noreturn));
>  
> -extern grub_addr_t EXPORT_VAR(grub_multiboot_payload_orig);
> -extern grub_addr_t EXPORT_VAR(grub_multiboot_payload_dest);
> -extern grub_size_t EXPORT_VAR(grub_multiboot_payload_size);
> -extern grub_uint32_t EXPORT_VAR(grub_multiboot_payload_entry_offset);
> -
> -extern grub_uint8_t EXPORT_VAR(grub_multiboot_forward_relocator);
> -extern grub_uint8_t EXPORT_VAR(grub_multiboot_forward_relocator_end);
> -extern grub_uint8_t EXPORT_VAR(grub_multiboot_backward_relocator);
> -extern grub_uint8_t EXPORT_VAR(grub_multiboot_backward_relocator_end);
> -
> -#define RELOCATOR_SIZEOF(x)	(&grub_multiboot_##x##_relocator_end - &grub_multiboot_##x##_relocator)
> -
>  #endif /* ! GRUB_LOADER_CPU_HEADER */
> diff --git a/include/grub/i386/multiboot.h b/include/grub/i386/multiboot.h
> new file mode 100644
> index 0000000..ea68640
> --- /dev/null
> +++ b/include/grub/i386/multiboot.h
> @@ -0,0 +1,42 @@
> +/*
> + *  GRUB  --  GRand Unified Bootloader
> + *  Copyright (C) 2009  Free Software Foundation, Inc.
> + *
> + *  GRUB 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 3 of the License, or
> + *  (at your option) any later version.
> + *
> + *  GRUB 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 GRUB.  If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#ifndef GRUB_MULTIBOOT_CPU_HEADER
> +#define GRUB_MULTIBOOT_CPU_HEADER	1
> +
> +/* The asm part of the multiboot loader.  */
> +void grub_multiboot_real_boot (grub_addr_t entry,
> +			       struct grub_multiboot_info *mbi)
> +     __attribute__ ((noreturn));
> +void grub_multiboot2_real_boot (grub_addr_t entry,
> +				struct grub_multiboot_info *mbi)
> +     __attribute__ ((noreturn));
> +
> +extern grub_addr_t grub_multiboot_payload_orig;
> +extern grub_addr_t grub_multiboot_payload_dest;
> +extern grub_size_t grub_multiboot_payload_size;
> +extern grub_uint32_t grub_multiboot_payload_entry_offset;
> +
> +extern grub_uint8_t grub_multiboot_forward_relocator;
> +extern grub_uint8_t grub_multiboot_forward_relocator_end;
> +extern grub_uint8_t grub_multiboot_backward_relocator;
> +extern grub_uint8_t grub_multiboot_backward_relocator_end;
> +
> +#define RELOCATOR_SIZEOF(x)	(&grub_multiboot_##x##_relocator_end - &grub_multiboot_##x##_relocator)
> +
> +#endif /* ! GRUB_MULTIBOOT_CPU_HEADER */
> diff --git a/kern/i386/coreboot/init.c b/kern/i386/coreboot/init.c
> index 9978d4a..1348488 100644
> --- a/kern/i386/coreboot/init.c
> +++ b/kern/i386/coreboot/init.c
> @@ -146,6 +146,7 @@ grub_machine_fini (void)
>  {
>    grub_at_keyboard_fini ();
>    grub_vga_text_fini ();
> +  grub_stop_floppy ();
>  }
>  
>  /* Return the end of the core image.  */
> diff --git a/kern/i386/loader.S b/kern/i386/loader.S
> index cacbbea..0e8ded6 100644
> --- a/kern/i386/loader.S
> +++ b/kern/i386/loader.S
> @@ -118,106 +118,6 @@ linux_setup_seg:
>  	.word	0
>  	.code32
>  
> -
> -/*
> - * This starts the multiboot kernel.
> - */
> -
> -VARIABLE(grub_multiboot_payload_size)
> -	.long	0
> -VARIABLE(grub_multiboot_payload_orig)
> -	.long	0
> -VARIABLE(grub_multiboot_payload_dest)
> -	.long	0
> -VARIABLE(grub_multiboot_payload_entry_offset)
> -	.long	0
> -
> -/*
> - * The relocators below understand the following parameters:
> - * ecx:	Size of the block to be copied.
> - * esi:	Where to copy from (always lowest address, even if we're relocating
> - *      backwards).
> - * edi:	Where to copy to (likewise).
> - * edx:	Offset of the entry point (relative to the beginning of the block).
> - */
> -VARIABLE(grub_multiboot_forward_relocator)
> -	/* Add entry offset.  */
> -	addl	%edi, %edx
> -
> -	/* Forward copy.  */
> -	cld
> -	rep
> -	movsb
> -
> -	jmp	*%edx
> -VARIABLE(grub_multiboot_forward_relocator_end)
> -
> -VARIABLE(grub_multiboot_backward_relocator)
> -	/* Add entry offset (before %edi is mangled).  */
> -	addl	%edi, %edx
> -
> -	/* Backward movsb is implicitly off-by-one.  compensate that.  */
> -	decl	%esi
> -	decl	%edi
> -
> -	/* Backward copy.  */
> -	std
> -	addl	%ecx, %esi
> -	addl	%ecx, %edi
> -	rep
> -	movsb
> -
> -	jmp	*%edx
> -VARIABLE(grub_multiboot_backward_relocator_end)
> -
> -FUNCTION(grub_multiboot_real_boot)
> -	/* Push the entry address on the stack.  */
> -	pushl	%eax
> -	/* Move the address of the multiboot information structure to ebx.  */
> -	movl	%edx,%ebx
> -
> -	/* Unload all modules and stop the floppy driver.  */
> -	call	EXT_C(grub_dl_unload_all)
> -	call	EXT_C(grub_stop_floppy)
> -
> -	/* Interrupts should be disabled.  */
> -	cli
> -
> -	/* Where do we copy what from.  */
> -	movl	EXT_C(grub_multiboot_payload_size), %ecx
> -	movl	EXT_C(grub_multiboot_payload_orig), %esi
> -	movl	EXT_C(grub_multiboot_payload_dest), %edi
> -	movl	EXT_C(grub_multiboot_payload_entry_offset), %edx
> -
> -	/* Move the magic value into eax.  */
> -	movl	$MULTIBOOT_MAGIC2, %eax
> -				
> -	/* Jump to the relocator.  */
> -	popl	%ebp
> -	jmp 	*%ebp
> -	
> -/*
> - * This starts the multiboot 2 kernel.
> - */
> -
> -FUNCTION(grub_multiboot2_real_boot)
> -        /* Push the entry address on the stack.  */
> -        pushl   %eax
> -        /* Move the address of the multiboot information structure to ebx.  */
> -        movl    %edx,%ebx
> -
> -        /* Unload all modules and stop the floppy driver.  */
> -        call    EXT_C(grub_dl_unload_all)
> -        call    EXT_C(grub_stop_floppy)
> -
> -        /* Interrupts should be disabled.  */
> -        cli
> -
> -        /* Move the magic value into eax and jump to the kernel.  */
> -        movl    $MULTIBOOT2_BOOTLOADER_MAGIC,%eax
> -        popl    %ecx
> -        jmp     *%ecx
> -
>  /*
>   * Use cdecl calling convention for *BSD kernels.
>   */
> @@ -225,7 +125,6 @@ FUNCTION(grub_multiboot2_real_boot)
>  FUNCTION(grub_unix_real_boot)
>  
>          call    EXT_C(grub_dl_unload_all)
> -        call    EXT_C(grub_stop_floppy)
>  
>  	/* Interrupts should be disabled.  */
>          cli
> diff --git a/kern/i386/pc/init.c b/kern/i386/pc/init.c
> index 1d6d22f..6191412 100644
> --- a/kern/i386/pc/init.c
> +++ b/kern/i386/pc/init.c
> @@ -223,6 +223,7 @@ void
>  grub_machine_fini (void)
>  {
>    grub_console_fini ();
> +  grub_stop_floppy ();
>  }
>  
>  /* Return the end of the core image.  */
> diff --git a/loader/i386/multiboot.c b/loader/i386/multiboot.c
> index 4c01d87..27042a5 100644
> --- a/loader/i386/multiboot.c
> +++ b/loader/i386/multiboot.c
> @@ -32,6 +32,7 @@
>  #include <grub/multiboot.h>
>  #include <grub/machine/init.h>
>  #include <grub/machine/memory.h>
> +#include <grub/cpu/multiboot.h>
>  #include <grub/elf.h>
>  #include <grub/aout.h>
>  #include <grub/file.h>
> diff --git a/loader/i386/multiboot_helper.S b/loader/i386/multiboot_helper.S
> new file mode 100644
> index 0000000..1e71120
> --- /dev/null
> +++ b/loader/i386/multiboot_helper.S
> @@ -0,0 +1,115 @@
> +/*
> + *  GRUB  --  GRand Unified Bootloader
> + *  Copyright (C) 2009  Free Software Foundation, Inc.
> + *
> + *  GRUB 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 3 of the License, or
> + *  (at your option) any later version.
> + *
> + *  GRUB 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 GRUB.  If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#include <grub/symbol.h>
> +#include <multiboot.h>
> +#include <multiboot2.h>
> +	
> +	.p2align	2	/* force 4-byte alignment */
> +
> +/*
> + * This starts the multiboot kernel.
> + */
> +
> +VARIABLE(grub_multiboot_payload_size)
> +	.long	0
> +VARIABLE(grub_multiboot_payload_orig)
> +	.long	0
> +VARIABLE(grub_multiboot_payload_dest)
> +	.long	0
> +VARIABLE(grub_multiboot_payload_entry_offset)
> +	.long	0
> +
> +/*
> + * The relocators below understand the following parameters:
> + * ecx:	Size of the block to be copied.
> + * esi:	Where to copy from (always lowest address, even if we're relocating
> + *      backwards).
> + * edi:	Where to copy to (likewise).
> + * edx:	Offset of the entry point (relative to the beginning of the block).
> + */
> +
> +VARIABLE(grub_multiboot_forward_relocator)
> +	/* Add entry offset.  */
> +	addl	%edi, %edx
> +
> +	/* Forward copy.  */
> +	cld
> +	rep
> +	movsb
> +
> +	jmp	*%edx
> +VARIABLE(grub_multiboot_forward_relocator_end)
> +
> +VARIABLE(grub_multiboot_backward_relocator)
> +	/* Add entry offset (before %edi is mangled).  */
> +	addl	%edi, %edx
> +
> +	/* Backward movsb is implicitly off-by-one.  compensate that.  */
> +	decl	%esi
> +	decl	%edi
> +
> +	/* Backward copy.  */
> +	std
> +	addl	%ecx, %esi
> +	addl	%ecx, %edi
> +	rep
> +	movsb
> +
> +	jmp	*%edx
> +VARIABLE(grub_multiboot_backward_relocator_end)
> +
> +FUNCTION(grub_multiboot_real_boot)
> +	/* Push the entry address on the stack.  */
> +	pushl	%eax
> +	/* Move the address of the multiboot information structure to ebx.  */
> +	movl	%edx,%ebx
> +
> +	/* Interrupts should be disabled.  */
> +	cli
> +
> +	/* Where do we copy what from.  */
> +	movl	EXT_C(grub_multiboot_payload_size), %ecx
> +	movl	EXT_C(grub_multiboot_payload_orig), %esi
> +	movl	EXT_C(grub_multiboot_payload_dest), %edi
> +	movl	EXT_C(grub_multiboot_payload_entry_offset), %edx
> +
> +	/* Move the magic value into eax.  */
> +	movl	$MULTIBOOT_MAGIC2, %eax
> +				
> +	/* Jump to the relocator.  */
> +	popl	%ebp
> +	jmp 	*%ebp
> +
> +/*
> + * This starts the multiboot 2 kernel.
> + */
> +
> +FUNCTION(grub_multiboot2_real_boot)
> +        /* Push the entry address on the stack.  */
> +        pushl   %eax
> +        /* Move the address of the multiboot information structure to ebx.  */
> +        movl    %edx,%ebx
> +
> +        /* Interrupts should be disabled.  */
> +        cli
> +
> +        /* Move the magic value into eax and jump to the kernel.  */
> +        movl    $MULTIBOOT2_BOOTLOADER_MAGIC,%eax
> +        popl    %ecx
> +        jmp     *%ecx

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


-- 
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."



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

end of thread, other threads:[~2009-03-22 12:29 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-11 10:42 [Patch] Move multiboot helpers out of the kernel phcoder
2009-03-13 23:35 ` phcoder
2009-03-14 14:48   ` Robert Millan
2009-03-14 17:52     ` phcoder
2009-03-15 15:34       ` Robert Millan
2009-03-21 22:51         ` phcoder
2009-03-21 23:08   ` Robert Millan
2009-03-22  0:15     ` phcoder
2009-03-22 12:29       ` Robert Millan

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.