diff options
author | Ward Vandewege <ward@gnu.org> | 2008-08-06 20:37:38 +0000 |
---|---|---|
committer | Ward Vandewege <ward@gnu.org> | 2008-08-06 20:37:38 +0000 |
commit | ebc92186cc9144aaacd37ca1ae94fcff60ec577a (patch) | |
tree | 8e92e08dd0d4df91416ee6f50afbaf2921d84663 /util/mkelfImage/linux-i386/head.S | |
parent | a70872cfde84863637dba1fb00498dc8a61dba48 (diff) | |
download | coreboot-ebc92186cc9144aaacd37ca1ae94fcff60ec577a.tar.xz |
Add the contents of buildrom's
packages/mkelfimage/mkelfimage-autoconf.patch
packages/mkelfimage/mkelfImage-2.7-x86_64.patch
to our svn copy of mkelfimage.
Signed-off-by: Ward Vandewege <ward@gnu.org>
Acked-by: Jordan Crouse <jordan.crouse@amd.com>
These are the original commit messages from the buildrom svn tree:
-----------------------------------------------------------------------
r61 | jcrouse | 2007-11-28 13:06:23 -0500 (Wed, 28 Nov 2007) | 9 lines
[BUILDROM] Fixup mkelfimage
My patch makes it so all targets use vmlinux and 2.7. Including
the mkelfimage patch from Yhinghai Lu.
Signed-off-by: Myles Watson <myles@pel.cs.byu.edu>
Acked-by: Jordan Crouse <jordan.crouse@amd.com>
------------------------------------------------------------------------
r80 | jcrouse | 2007-12-10 13:56:40 -0500 (Mon, 10 Dec 2007) | 8 lines
[BUILDROM] Fix breakage in the new mkelfimage autoconf scripts
Whack the autoconf scripts in mkelfimage to allow us to pass our
stack protection flags in.
Signed-off-by: Jordan Crouse <jordan.crouse@amd.com>
Acked-by: Corey Osgood <corey.osgood@gmail.com>
------------------------------------------------------------------------
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3473 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'util/mkelfImage/linux-i386/head.S')
-rw-r--r-- | util/mkelfImage/linux-i386/head.S | 123 |
1 files changed, 114 insertions, 9 deletions
diff --git a/util/mkelfImage/linux-i386/head.S b/util/mkelfImage/linux-i386/head.S index c3990ac801..b35c62a983 100644 --- a/util/mkelfImage/linux-i386/head.S +++ b/util/mkelfImage/linux-i386/head.S @@ -59,7 +59,7 @@ startup_32: movl $GDTLOC, %edi movl $(gdt_end - gdt), %ecx rep movsb - + # Linux makes stupid assumptions about the segments # that are already setup, so setup a new gdt & ldt # and then reload the segment registers. @@ -95,22 +95,113 @@ startup_32: # Flag to indicate we are the bootstrap processor xorl %ebx, %ebx + movl switch_64, %eax + cmp $1, %eax + jz switch_to_64 + # Clear the unspecified registers for good measure xorl %eax, %eax xorl %ecx, %ecx xorl %edx, %edx xorl %edi, %edi - xorl %esp, %esp xorl %ebp, %ebp - - # Jump to the linux kernel - ljmp $ PROT_CODE_SEG , $ 0x100000 + # do not clear esp, we still need to use lret later + + pushl $PROT_CODE_SEG + movl entry, %eax + pushl %eax + + lret + +switch_to_64: + + /* We need to switch to 64bit before use startup_64 entry go to kernel */ + /* + * Prepare for entering 64 bit mode + */ + # Move the gdt64 where Linux will not smash it during decompression + movl %esi, %eax # save the real mode pointer + movl $gdt64, %esi + movl $GDT64LOC, %edi + movl $(gdt64_end - gdt64), %ecx + rep movsb + movl %eax, %esi + + /* Load new GDT with the 64bit segments using 32bit descriptor */ + lgdt gdt64 + + /* Enable PAE mode */ + xorl %eax, %eax + btsl $5, %eax + movl %eax, %cr4 + + /* + * Build early 4G boot pagetable + */ + /* Initialize Page tables to 0*/ + movl $PGTLOC, %edi + xorl %eax, %eax + movl $((4096*6)/4), %ecx + rep stosl + + /* Build Level 4 */ + movl $(PGTLOC + 0), %edi + leal 0x1007 (%edi), %eax + movl %eax, 0(%edi) + + /* Build Level 3 */ + movl $(PGTLOC + 0x1000), %edi + leal 0x1007(%edi), %eax + movl $4, %ecx +1: movl %eax, 0x00(%edi) + addl $0x00001000, %eax + addl $8, %edi + decl %ecx + jnz 1b + + /* Build Level 2 */ + movl $(PGTLOC + 0x2000), %edi + movl $0x00000183, %eax + movl $2048, %ecx +1: movl %eax, 0(%edi) + addl $0x00200000, %eax + addl $8, %edi + decl %ecx + jnz 1b + + /* Enable the boot page tables */ + movl $PGTLOC, %eax + movl %eax, %cr3 + + /* Enable Long mode in EFER (Extended Feature Enable Register) */ + movl $0xc0000080, %ecx + rdmsr + btsl $8, %eax + wrmsr + + /* Preparing for 64bit jmp */ + pushl $PROT_CODE_SEG + movl entry, %eax + pushl %eax + + /* Enter paged protected Mode, activating Long Mode */ + xorl %eax, %eax + btsl $31, %eax + btsl $0, %eax + movl %eax, %cr0 + + /* + * At this point we're in long mode but in 32bit compatibility mode + * with EFER.LME = 1, CS.L = 0, CS.D = 1 (and in turn + * EFER.LMA = 1). Now we want to jump in 64bit mode, to do that we use + * the new gdt/idt that has __KERNEL_CS with CS.L = 1. + */ + + lret /* Routines to query the BIOS... */ - - /************************************************************************** E820_MEMSIZE - Get a listing of memory regions **************************************************************************/ @@ -409,6 +500,7 @@ gdt: .word 0x9200 # data read/write .word 0x00CF # granularity = 4096, 386 # (+5th nibble of limit) + /* * The layout of the per-CPU GDT under Linux: * @@ -446,7 +538,14 @@ gdt: */ gdt_end: - +gdt64: + .word gdt64_end - gdt64 + .long GDT64LOC + .word 0 + .quad 0x0000000000000000 /* NULL descriptor */ + .quad 0x00af9a000000ffff /* __KERNEL_CS */ + .quad 0x00cf92000000ffff /* __KERNEL_DS */ +gdt64_end: .section ".trailer", "a" /* Constants set at build time, these are at the very end of my image */ @@ -458,14 +557,20 @@ convert_magic: .long CONVERT_MAGIC gdt_size: .long gdt_end - gdt +gdt64_size: + .long gdt64_end - gdt64 +pgt_size: + .long 4096*6 bss_size: - .long bss_size + .long bss_sizex ramdisk_flags: .word 0 root_dev: .word DEFAULT_ROOT_DEV entry: .long 0 +switch_64: + .long 0 initrd_start: .long 0 initrd_size: |