[2358] 2009-06-22 Robert Millan <[email protected]>

Robert Millan <[email protected]> Mon, 22 Jun 2009 10:42:37 +0000
Newsgroups gmane.comp.boot-loaders.grub.cvs
Message-ID <[email protected]>
Revision: 2358
          http://svn.sv.gnu.org/viewvc/?view=rev&root=grub&revision=2358
Author:   robertmh
Date:     2009-06-22 10:42:37 +0000 (Mon, 22 Jun 2009)
Log Message:
-----------
2009-06-22  Robert Millan  <[email protected]>

        * kern/i386/pc/startup.S (real_to_prot): Move from here ...
        * kern/i386/realmode.S (real_to_prot): ... to here.

Modified Paths:
--------------
    trunk/grub2/ChangeLog
    trunk/grub2/kern/i386/pc/startup.S
    trunk/grub2/kern/i386/realmode.S

Modified: trunk/grub2/ChangeLog
===================================================================
--- trunk/grub2/ChangeLog	2009-06-22 10:27:26 UTC (rev 2357)
+++ trunk/grub2/ChangeLog	2009-06-22 10:42:37 UTC (rev 2358)
@@ -1,5 +1,10 @@
 2009-06-22  Robert Millan  <[email protected]>
 
+	* kern/i386/pc/startup.S (real_to_prot): Move from here ...
+	* kern/i386/realmode.S (real_to_prot): ... to here.
+
+2009-06-22  Robert Millan  <[email protected]>
+
 	* conf/i386-ieee1275.rmk (pkglib_PROGRAMS): Replace `kernel.elf'
 	with `kernel.img'.
 	(kernel_elf_SOURCES): Rename to ...

Modified: trunk/grub2/kern/i386/pc/startup.S
===================================================================
--- trunk/grub2/kern/i386/pc/startup.S	2009-06-22 10:27:26 UTC (rev 2357)
+++ trunk/grub2/kern/i386/pc/startup.S	2009-06-22 10:42:37 UTC (rev 2358)
@@ -290,8 +290,6 @@
 	 */
 	call EXT_C(grub_main)
 
-#include "../realmode.S"
-
 /*
  *  This is the area for all of the special variables.
  */
@@ -301,63 +299,8 @@
 
 	.p2align	2	/* force 4-byte alignment */
 
-/*
- *  These next two routines, "real_to_prot" and "prot_to_real" are structured
- *  in a very specific way.  Be very careful when changing them.
- *
- *  NOTE:  Use of either one messes up %eax and %ebp.
- */
+#include "../realmode.S"
 
-real_to_prot:
-	.code16
-	cli
-
-	/* load the GDT register */
-#ifdef APPLE_CC
-	mov %cs, %ax
-	mov %ax, %ds
-	DATA32	ADDR32	lgdt	gdtdesc
-#else
-	DATA32	ADDR32	lgdt	%cs:gdtdesc
-#endif
-
-	/* turn on protected mode */
-	movl	%cr0, %eax
-	orl	$GRUB_MEMORY_MACHINE_CR0_PE_ON, %eax
-	movl	%eax, %cr0
-
-	/* jump to relocation, flush prefetch queue, and reload %cs */
-	DATA32	ljmp	$GRUB_MEMORY_MACHINE_PROT_MODE_CSEG, $protcseg
-
-	.code32
-protcseg:
-	/* reload other segment registers */
-	movw	$GRUB_MEMORY_MACHINE_PROT_MODE_DSEG, %ax
-	movw	%ax, %ds
-	movw	%ax, %es
-	movw	%ax, %fs
-	movw	%ax, %gs
-	movw	%ax, %ss
-
-	/* put the return address in a known safe location */
-	movl	(%esp), %eax
-	movl	%eax, GRUB_MEMORY_MACHINE_REAL_STACK
-
-	/* get protected mode stack */
-	movl	protstack, %eax
-	movl	%eax, %esp
-	movl	%eax, %ebp
-
-	/* get return address onto the right stack */
-	movl	GRUB_MEMORY_MACHINE_REAL_STACK, %eax
-	movl	%eax, (%esp)
-
-	/* zero %eax */
-	xorl	%eax, %eax
-
-	/* return on the old (or initialized) stack! */
-	ret
-
 /*
  * grub_gate_a20(int on)
  *

Modified: trunk/grub2/kern/i386/realmode.S
===================================================================
--- trunk/grub2/kern/i386/realmode.S	2009-06-22 10:27:26 UTC (rev 2357)
+++ trunk/grub2/kern/i386/realmode.S	2009-06-22 10:42:37 UTC (rev 2358)
@@ -110,12 +110,62 @@
 	.long	gdt			/* addr */
 
 /*
- *  These next routine, "prot_to_real" is structured in a very
- *  specific way.  Be very careful when changing it.
+ *  These next two routines, "real_to_prot" and "prot_to_real" are structured
+ *  in a very specific way.  Be very careful when changing them.
  *
- *  NOTE:  Use of it messes up %eax and %ebp.
+ *  NOTE:  Use of either one messes up %eax and %ebp.
  */
 
+real_to_prot:
+	.code16
+	cli
+
+	/* load the GDT register */
+#ifdef APPLE_CC
+	mov %cs, %ax
+	mov %ax, %ds
+	DATA32	ADDR32	lgdt	gdtdesc
+#else
+	DATA32	ADDR32	lgdt	%cs:gdtdesc
+#endif
+
+	/* turn on protected mode */
+	movl	%cr0, %eax
+	orl	$GRUB_MEMORY_MACHINE_CR0_PE_ON, %eax
+	movl	%eax, %cr0
+
+	/* jump to relocation, flush prefetch queue, and reload %cs */
+	DATA32	ljmp	$GRUB_MEMORY_MACHINE_PROT_MODE_CSEG, $protcseg
+
+	.code32
+protcseg:
+	/* reload other segment registers */
+	movw	$GRUB_MEMORY_MACHINE_PROT_MODE_DSEG, %ax
+	movw	%ax, %ds
+	movw	%ax, %es
+	movw	%ax, %fs
+	movw	%ax, %gs
+	movw	%ax, %ss
+
+	/* put the return address in a known safe location */
+	movl	(%esp), %eax
+	movl	%eax, GRUB_MEMORY_MACHINE_REAL_STACK
+
+	/* get protected mode stack */
+	movl	protstack, %eax
+	movl	%eax, %esp
+	movl	%eax, %ebp
+
+	/* get return address onto the right stack */
+	movl	GRUB_MEMORY_MACHINE_REAL_STACK, %eax
+	movl	%eax, (%esp)
+
+	/* zero %eax */
+	xorl	%eax, %eax
+
+	/* return on the old (or initialized) stack! */
+	ret
+
 prot_to_real:
 	/* just in case, set GDT */
 	lgdt	gdtdesc