[coreboot-gerrit] Patch set updated for coreboot: 66068c9 Enable pages. Tested and working on QEMU.

Ronald G. Minnich (rminnich@gmail.com) gerrit at coreboot.org
Wed Mar 12 16:18:07 CET 2014


Ronald G. Minnich (rminnich at gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/5354

-gerrit

commit 66068c9854f15979a10bcf5c77a9af3fcfff9c48
Author: Ronald G. Minnich <rminnich at gmail.com>
Date:   Sat Mar 8 17:33:12 2014 +0100

    Enable pages. Tested and working on QEMU.
    
    Now breaking on an attempt to set up paging in the bootblock:
    
    Script started on Wed 12 Mar 2014 08:15:35 AM PDT
    /home/rminnich/coreboot/util/crossgcc/xgcc/lib/gcc/i386-elf/4.7.3/../../../../i386-elf/bin/ld: address 0x100000032 of build/cbfs/fallback/bootblock.debug section `.rom' is not within region `rom'
    /home/rminnich/coreboot/util/crossgcc/xgcc/lib/gcc/i386-elf/4.7.3/../../../../i386-elf/bin/ld: address 0x100000032 of build/cbfs/fallback/bootblock.debug section `.rom' is not within region `rom'
    /home/rminnich/coreboot/util/crossgcc/xgcc/lib/gcc/i386-elf/4.7.3/../../../../i386-elf/bin/ld: section .id loaded at [00000000ffffff38,00000000ffffff7f] overlaps section .rom loaded at [00000000ffffcd80,0000000100000031]
    collect2: error: ld returned 1 exit status
    make: *** [build/cbfs/fallback/bootblock.debug] Error 1
    ]0;rminnich at localhost:~/coreboot[rminnich at localhost coreboot]$ exit
    
    Enable page tables in coreboot. We're going to have to do this at some point,
    when we hit x86_64; the ARM ports do paging in both 32- and 64-bit modes;
    MTRR is a PITA; and it's easy. The non-paging architectures are outnumbered
    by the paging architectures!
    
    This trial example just sets up a 4G identity map using 4M pages.
    It works for QEMU just fine to boot tinycore linux.
    The next step is to map the low 4M much more finely, with 4K pages,
    so we can catch NULL pointers. This will require reworking VGA bios
    support, which uses page 0.
    
    For SMP, we'll need to add code to let them also load page tables,
    but one thing at a time.
    
    Next I'll add code to support page table manipulation. With luck,
    we can stop using the MTRRs with all their pain and suffering.
    For now we use this for machines where coreboot can live in the low 4G.
    For other cases, it's time to start thinking about 64-bit mode; since
    entering Long Mode requires page tables, we need to figure it out. The
    ARM V8 port is carving the way so this is as good a time as any.
    
    This code is enabled by CONFIG_PGE, which defaults to n.
    To turn it on navigate to architecture options in
    menuconfig.
    
    A remaining question is whether to turn off paging when we start the payload.
    For now, we turn it off.
    
    Change-Id: Iea0192e5187c47e63d25f88eaa3e88cb6c58feb1
    Signed-off-by: Ronald G. Minnich <rminnich at gmail.com>
---
 src/arch/x86/Kconfig          |  11 ++
 src/arch/x86/Makefile.inc     |   3 +
 src/arch/x86/boot/boot.c      |  17 +++
 src/arch/x86/lib/c_start.S    |   3 +-
 src/arch/x86/lib/makepg.c     |  26 +++++
 src/arch/x86/lib/pagetables.S | 262 ++++++++++++++++++++++++++++++++++++++++++
 src/arch/x86/lib/paging.S     |  27 +++++
 src/include/bootstate.h       |   2 +-
 src/lib/cbfs.c                |   5 +
 9 files changed, 354 insertions(+), 2 deletions(-)

diff --git a/src/arch/x86/Kconfig b/src/arch/x86/Kconfig
index 8854e6b..0c0f91c 100644
--- a/src/arch/x86/Kconfig
+++ b/src/arch/x86/Kconfig
@@ -78,6 +78,17 @@ config UPDATE_IMAGE
 	  is a suitable file for further processing.
 	  The bootblock will not be modified.
 
+config PGE
+	bool "Enable x86 page tables."
+	default n
+	help
+	  In original coreboot we did not use page tables. The
+	  MTRR code just keeps getting messier and if we turn
+	  on paging it gets very easy. We can enable disable
+	  caching on anything down to a 4k boundary. We can
+	  control cache disable and write-back/writethrough
+	  on each page. For now, this code creates an identity
+	  map for 4G using 4M pages.
 config ROMCC
 	bool
 	default n
diff --git a/src/arch/x86/Makefile.inc b/src/arch/x86/Makefile.inc
index 4b28697..ac96e9c 100644
--- a/src/arch/x86/Makefile.inc
+++ b/src/arch/x86/Makefile.inc
@@ -344,6 +344,9 @@ bootblock_inc = $(src)/arch/x86/init/prologue.inc
 bootblock_inc += $(src)/cpu/x86/16bit/entry16.inc
 bootblock_inc += $(src)/cpu/x86/16bit/reset16.inc
 bootblock_inc += $(src)/cpu/x86/32bit/entry32.inc
+ifeq ($(CONFIG_PGE),y)
+bootblock_inc += $(src)/arch/x86/lib/paging.S
+endif
 bootblock_inc += $(src)/arch/x86/lib/id.inc
 ifeq ($(CONFIG_CPU_INTEL_FIRMWARE_INTERFACE_TABLE),y)
 bootblock_inc += $(src)/cpu/intel/fit/fit.inc
diff --git a/src/arch/x86/boot/boot.c b/src/arch/x86/boot/boot.c
index 29070a0..253d2d9 100644
--- a/src/arch/x86/boot/boot.c
+++ b/src/arch/x86/boot/boot.c
@@ -11,6 +11,12 @@ static void jmp_payload_no_bounce_buffer(void *entry)
 	/* Jump to kernel */
 	__asm__ __volatile__(
 		"	cld	\n\t"
+		/* Paging might have been on. We need to turn it off
+		 * right before we jump
+		 */
+		"	movl	%%cr0, %%eax\n\t"
+		"	andl	$0x7fffffff, %%eax\n\t"
+		"	movl	%%edx, %%cr0\n\t"
 		/* Now jump to the loaded image */
 		"	call	*%0\n\t"
 
@@ -73,6 +79,16 @@ static void jmp_payload(void *entry, unsigned long buffer, unsigned long size)
 		"	jmp	*%%eax\n\t"
 		"1:	\n\t"
 
+		/* Paging might have been on. It's ok,
+		 * the bounce buffer runs at same VA and PA.
+		 * So we can turn paging off now.
+		 */
+		"	movl	%%cr0, %%eax\n\t"
+		"	andl	$0x7fffffff, %%eax\n\t"
+		"	movl	%%eax, %%cr0\n\t"
+		"	jmp 1f\n\t"
+		"1:\n\t"
+
 		/* Copy the coreboot bounce buffer over coreboot */
 		/* Move ``longs'' the coreboot size is 4 byte aligned */
 		"	movl	16(%%esp), %%edi\n\t"
@@ -85,6 +101,7 @@ static void jmp_payload(void *entry, unsigned long buffer, unsigned long size)
 		"	movl	%5, %%eax\n\t"
 		"	movl	 0(%%esp), %%ebx\n\t"
 		"	call	*4(%%esp)\n\t"
+		"1: jmp 1b\n\t"
 
 		/* The loaded image returned? */
 		"	cli	\n\t"
diff --git a/src/arch/x86/lib/c_start.S b/src/arch/x86/lib/c_start.S
index 01ffa7c..0442140 100644
--- a/src/arch/x86/lib/c_start.S
+++ b/src/arch/x86/lib/c_start.S
@@ -31,7 +31,8 @@ _start:
 	movl	%eax, %gs
 
 	post_code(POST_ENTRY_C_START)		/* post 13 */
-
+	/* turn on paging (conditional on CONFIG_PGE) */
+#include "paging.S"
 	cld
 
 	/** poison the stack. Code should not count on the
diff --git a/src/arch/x86/lib/makepg.c b/src/arch/x86/lib/makepg.c
new file mode 100644
index 0000000..f5b2317
--- /dev/null
+++ b/src/arch/x86/lib/makepg.c
@@ -0,0 +1,26 @@
+#include <stdio.h>
+main(int argc, char *argv[])
+{
+	int i, j;
+	printf("\t.long 1\n\t.align 4096\npml0:");
+	for(i = 0; i < 1024; i += 8){
+		printf("\t.long ");
+		for(j = 0; j < 8; j++){
+			if (!i && !j)
+				printf("0x%08x,", 0);
+			else
+				printf("0x%08x%s", ((i+j)<<12) + 0x5, j < 7 ? ",":"");
+		}
+		printf("\n");
+	}
+	printf("pml1:\n");
+	for(i = 0; i < 1024; i += 8){
+		printf("\t.long ");
+		for(j = 0; j < 8; j++)
+			if (!i && !j)
+				printf("pml0+5,");
+			else
+				printf("0x%08x%s", ((i+j)<<22) + 0x85,j < 7 ? ",":"");
+		printf("\n");
+	}
+}
diff --git a/src/arch/x86/lib/pagetables.S b/src/arch/x86/lib/pagetables.S
new file mode 100644
index 0000000..3ee40ac
--- /dev/null
+++ b/src/arch/x86/lib/pagetables.S
@@ -0,0 +1,262 @@
+	.long 1
+	.align 4096
+/*
+pml0:	.long 0x00000000,0x00001005,0x00002005,0x00003005,0x00004005,0x00005005,0x00006005,0x00007005
+	.long 0x00008005,0x00009005,0x0000a005,0x0000b005,0x0000c005,0x0000d005,0x0000e005,0x0000f005
+	.long 0x00010005,0x00011005,0x00012005,0x00013005,0x00014005,0x00015005,0x00016005,0x00017005
+	.long 0x00018005,0x00019005,0x0001a005,0x0001b005,0x0001c005,0x0001d005,0x0001e005,0x0001f005
+	.long 0x00020005,0x00021005,0x00022005,0x00023005,0x00024005,0x00025005,0x00026005,0x00027005
+	.long 0x00028005,0x00029005,0x0002a005,0x0002b005,0x0002c005,0x0002d005,0x0002e005,0x0002f005
+	.long 0x00030005,0x00031005,0x00032005,0x00033005,0x00034005,0x00035005,0x00036005,0x00037005
+	.long 0x00038005,0x00039005,0x0003a005,0x0003b005,0x0003c005,0x0003d005,0x0003e005,0x0003f005
+	.long 0x00040005,0x00041005,0x00042005,0x00043005,0x00044005,0x00045005,0x00046005,0x00047005
+	.long 0x00048005,0x00049005,0x0004a005,0x0004b005,0x0004c005,0x0004d005,0x0004e005,0x0004f005
+	.long 0x00050005,0x00051005,0x00052005,0x00053005,0x00054005,0x00055005,0x00056005,0x00057005
+	.long 0x00058005,0x00059005,0x0005a005,0x0005b005,0x0005c005,0x0005d005,0x0005e005,0x0005f005
+	.long 0x00060005,0x00061005,0x00062005,0x00063005,0x00064005,0x00065005,0x00066005,0x00067005
+	.long 0x00068005,0x00069005,0x0006a005,0x0006b005,0x0006c005,0x0006d005,0x0006e005,0x0006f005
+	.long 0x00070005,0x00071005,0x00072005,0x00073005,0x00074005,0x00075005,0x00076005,0x00077005
+	.long 0x00078005,0x00079005,0x0007a005,0x0007b005,0x0007c005,0x0007d005,0x0007e005,0x0007f005
+	.long 0x00080005,0x00081005,0x00082005,0x00083005,0x00084005,0x00085005,0x00086005,0x00087005
+	.long 0x00088005,0x00089005,0x0008a005,0x0008b005,0x0008c005,0x0008d005,0x0008e005,0x0008f005
+	.long 0x00090005,0x00091005,0x00092005,0x00093005,0x00094005,0x00095005,0x00096005,0x00097005
+	.long 0x00098005,0x00099005,0x0009a005,0x0009b005,0x0009c005,0x0009d005,0x0009e005,0x0009f005
+	.long 0x000a0005,0x000a1005,0x000a2005,0x000a3005,0x000a4005,0x000a5005,0x000a6005,0x000a7005
+	.long 0x000a8005,0x000a9005,0x000aa005,0x000ab005,0x000ac005,0x000ad005,0x000ae005,0x000af005
+	.long 0x000b0005,0x000b1005,0x000b2005,0x000b3005,0x000b4005,0x000b5005,0x000b6005,0x000b7005
+	.long 0x000b8005,0x000b9005,0x000ba005,0x000bb005,0x000bc005,0x000bd005,0x000be005,0x000bf005
+	.long 0x000c0005,0x000c1005,0x000c2005,0x000c3005,0x000c4005,0x000c5005,0x000c6005,0x000c7005
+	.long 0x000c8005,0x000c9005,0x000ca005,0x000cb005,0x000cc005,0x000cd005,0x000ce005,0x000cf005
+	.long 0x000d0005,0x000d1005,0x000d2005,0x000d3005,0x000d4005,0x000d5005,0x000d6005,0x000d7005
+	.long 0x000d8005,0x000d9005,0x000da005,0x000db005,0x000dc005,0x000dd005,0x000de005,0x000df005
+	.long 0x000e0005,0x000e1005,0x000e2005,0x000e3005,0x000e4005,0x000e5005,0x000e6005,0x000e7005
+	.long 0x000e8005,0x000e9005,0x000ea005,0x000eb005,0x000ec005,0x000ed005,0x000ee005,0x000ef005
+	.long 0x000f0005,0x000f1005,0x000f2005,0x000f3005,0x000f4005,0x000f5005,0x000f6005,0x000f7005
+	.long 0x000f8005,0x000f9005,0x000fa005,0x000fb005,0x000fc005,0x000fd005,0x000fe005,0x000ff005
+	.long 0x00100005,0x00101005,0x00102005,0x00103005,0x00104005,0x00105005,0x00106005,0x00107005
+	.long 0x00108005,0x00109005,0x0010a005,0x0010b005,0x0010c005,0x0010d005,0x0010e005,0x0010f005
+	.long 0x00110005,0x00111005,0x00112005,0x00113005,0x00114005,0x00115005,0x00116005,0x00117005
+	.long 0x00118005,0x00119005,0x0011a005,0x0011b005,0x0011c005,0x0011d005,0x0011e005,0x0011f005
+	.long 0x00120005,0x00121005,0x00122005,0x00123005,0x00124005,0x00125005,0x00126005,0x00127005
+	.long 0x00128005,0x00129005,0x0012a005,0x0012b005,0x0012c005,0x0012d005,0x0012e005,0x0012f005
+	.long 0x00130005,0x00131005,0x00132005,0x00133005,0x00134005,0x00135005,0x00136005,0x00137005
+	.long 0x00138005,0x00139005,0x0013a005,0x0013b005,0x0013c005,0x0013d005,0x0013e005,0x0013f005
+	.long 0x00140005,0x00141005,0x00142005,0x00143005,0x00144005,0x00145005,0x00146005,0x00147005
+	.long 0x00148005,0x00149005,0x0014a005,0x0014b005,0x0014c005,0x0014d005,0x0014e005,0x0014f005
+	.long 0x00150005,0x00151005,0x00152005,0x00153005,0x00154005,0x00155005,0x00156005,0x00157005
+	.long 0x00158005,0x00159005,0x0015a005,0x0015b005,0x0015c005,0x0015d005,0x0015e005,0x0015f005
+	.long 0x00160005,0x00161005,0x00162005,0x00163005,0x00164005,0x00165005,0x00166005,0x00167005
+	.long 0x00168005,0x00169005,0x0016a005,0x0016b005,0x0016c005,0x0016d005,0x0016e005,0x0016f005
+	.long 0x00170005,0x00171005,0x00172005,0x00173005,0x00174005,0x00175005,0x00176005,0x00177005
+	.long 0x00178005,0x00179005,0x0017a005,0x0017b005,0x0017c005,0x0017d005,0x0017e005,0x0017f005
+	.long 0x00180005,0x00181005,0x00182005,0x00183005,0x00184005,0x00185005,0x00186005,0x00187005
+	.long 0x00188005,0x00189005,0x0018a005,0x0018b005,0x0018c005,0x0018d005,0x0018e005,0x0018f005
+	.long 0x00190005,0x00191005,0x00192005,0x00193005,0x00194005,0x00195005,0x00196005,0x00197005
+	.long 0x00198005,0x00199005,0x0019a005,0x0019b005,0x0019c005,0x0019d005,0x0019e005,0x0019f005
+	.long 0x001a0005,0x001a1005,0x001a2005,0x001a3005,0x001a4005,0x001a5005,0x001a6005,0x001a7005
+	.long 0x001a8005,0x001a9005,0x001aa005,0x001ab005,0x001ac005,0x001ad005,0x001ae005,0x001af005
+	.long 0x001b0005,0x001b1005,0x001b2005,0x001b3005,0x001b4005,0x001b5005,0x001b6005,0x001b7005
+	.long 0x001b8005,0x001b9005,0x001ba005,0x001bb005,0x001bc005,0x001bd005,0x001be005,0x001bf005
+	.long 0x001c0005,0x001c1005,0x001c2005,0x001c3005,0x001c4005,0x001c5005,0x001c6005,0x001c7005
+	.long 0x001c8005,0x001c9005,0x001ca005,0x001cb005,0x001cc005,0x001cd005,0x001ce005,0x001cf005
+	.long 0x001d0005,0x001d1005,0x001d2005,0x001d3005,0x001d4005,0x001d5005,0x001d6005,0x001d7005
+	.long 0x001d8005,0x001d9005,0x001da005,0x001db005,0x001dc005,0x001dd005,0x001de005,0x001df005
+	.long 0x001e0005,0x001e1005,0x001e2005,0x001e3005,0x001e4005,0x001e5005,0x001e6005,0x001e7005
+	.long 0x001e8005,0x001e9005,0x001ea005,0x001eb005,0x001ec005,0x001ed005,0x001ee005,0x001ef005
+	.long 0x001f0005,0x001f1005,0x001f2005,0x001f3005,0x001f4005,0x001f5005,0x001f6005,0x001f7005
+	.long 0x001f8005,0x001f9005,0x001fa005,0x001fb005,0x001fc005,0x001fd005,0x001fe005,0x001ff005
+	.long 0x00200005,0x00201005,0x00202005,0x00203005,0x00204005,0x00205005,0x00206005,0x00207005
+	.long 0x00208005,0x00209005,0x0020a005,0x0020b005,0x0020c005,0x0020d005,0x0020e005,0x0020f005
+	.long 0x00210005,0x00211005,0x00212005,0x00213005,0x00214005,0x00215005,0x00216005,0x00217005
+	.long 0x00218005,0x00219005,0x0021a005,0x0021b005,0x0021c005,0x0021d005,0x0021e005,0x0021f005
+	.long 0x00220005,0x00221005,0x00222005,0x00223005,0x00224005,0x00225005,0x00226005,0x00227005
+	.long 0x00228005,0x00229005,0x0022a005,0x0022b005,0x0022c005,0x0022d005,0x0022e005,0x0022f005
+	.long 0x00230005,0x00231005,0x00232005,0x00233005,0x00234005,0x00235005,0x00236005,0x00237005
+	.long 0x00238005,0x00239005,0x0023a005,0x0023b005,0x0023c005,0x0023d005,0x0023e005,0x0023f005
+	.long 0x00240005,0x00241005,0x00242005,0x00243005,0x00244005,0x00245005,0x00246005,0x00247005
+	.long 0x00248005,0x00249005,0x0024a005,0x0024b005,0x0024c005,0x0024d005,0x0024e005,0x0024f005
+	.long 0x00250005,0x00251005,0x00252005,0x00253005,0x00254005,0x00255005,0x00256005,0x00257005
+	.long 0x00258005,0x00259005,0x0025a005,0x0025b005,0x0025c005,0x0025d005,0x0025e005,0x0025f005
+	.long 0x00260005,0x00261005,0x00262005,0x00263005,0x00264005,0x00265005,0x00266005,0x00267005
+	.long 0x00268005,0x00269005,0x0026a005,0x0026b005,0x0026c005,0x0026d005,0x0026e005,0x0026f005
+	.long 0x00270005,0x00271005,0x00272005,0x00273005,0x00274005,0x00275005,0x00276005,0x00277005
+	.long 0x00278005,0x00279005,0x0027a005,0x0027b005,0x0027c005,0x0027d005,0x0027e005,0x0027f005
+	.long 0x00280005,0x00281005,0x00282005,0x00283005,0x00284005,0x00285005,0x00286005,0x00287005
+	.long 0x00288005,0x00289005,0x0028a005,0x0028b005,0x0028c005,0x0028d005,0x0028e005,0x0028f005
+	.long 0x00290005,0x00291005,0x00292005,0x00293005,0x00294005,0x00295005,0x00296005,0x00297005
+	.long 0x00298005,0x00299005,0x0029a005,0x0029b005,0x0029c005,0x0029d005,0x0029e005,0x0029f005
+	.long 0x002a0005,0x002a1005,0x002a2005,0x002a3005,0x002a4005,0x002a5005,0x002a6005,0x002a7005
+	.long 0x002a8005,0x002a9005,0x002aa005,0x002ab005,0x002ac005,0x002ad005,0x002ae005,0x002af005
+	.long 0x002b0005,0x002b1005,0x002b2005,0x002b3005,0x002b4005,0x002b5005,0x002b6005,0x002b7005
+	.long 0x002b8005,0x002b9005,0x002ba005,0x002bb005,0x002bc005,0x002bd005,0x002be005,0x002bf005
+	.long 0x002c0005,0x002c1005,0x002c2005,0x002c3005,0x002c4005,0x002c5005,0x002c6005,0x002c7005
+	.long 0x002c8005,0x002c9005,0x002ca005,0x002cb005,0x002cc005,0x002cd005,0x002ce005,0x002cf005
+	.long 0x002d0005,0x002d1005,0x002d2005,0x002d3005,0x002d4005,0x002d5005,0x002d6005,0x002d7005
+	.long 0x002d8005,0x002d9005,0x002da005,0x002db005,0x002dc005,0x002dd005,0x002de005,0x002df005
+	.long 0x002e0005,0x002e1005,0x002e2005,0x002e3005,0x002e4005,0x002e5005,0x002e6005,0x002e7005
+	.long 0x002e8005,0x002e9005,0x002ea005,0x002eb005,0x002ec005,0x002ed005,0x002ee005,0x002ef005
+	.long 0x002f0005,0x002f1005,0x002f2005,0x002f3005,0x002f4005,0x002f5005,0x002f6005,0x002f7005
+	.long 0x002f8005,0x002f9005,0x002fa005,0x002fb005,0x002fc005,0x002fd005,0x002fe005,0x002ff005
+	.long 0x00300005,0x00301005,0x00302005,0x00303005,0x00304005,0x00305005,0x00306005,0x00307005
+	.long 0x00308005,0x00309005,0x0030a005,0x0030b005,0x0030c005,0x0030d005,0x0030e005,0x0030f005
+	.long 0x00310005,0x00311005,0x00312005,0x00313005,0x00314005,0x00315005,0x00316005,0x00317005
+	.long 0x00318005,0x00319005,0x0031a005,0x0031b005,0x0031c005,0x0031d005,0x0031e005,0x0031f005
+	.long 0x00320005,0x00321005,0x00322005,0x00323005,0x00324005,0x00325005,0x00326005,0x00327005
+	.long 0x00328005,0x00329005,0x0032a005,0x0032b005,0x0032c005,0x0032d005,0x0032e005,0x0032f005
+	.long 0x00330005,0x00331005,0x00332005,0x00333005,0x00334005,0x00335005,0x00336005,0x00337005
+	.long 0x00338005,0x00339005,0x0033a005,0x0033b005,0x0033c005,0x0033d005,0x0033e005,0x0033f005
+	.long 0x00340005,0x00341005,0x00342005,0x00343005,0x00344005,0x00345005,0x00346005,0x00347005
+	.long 0x00348005,0x00349005,0x0034a005,0x0034b005,0x0034c005,0x0034d005,0x0034e005,0x0034f005
+	.long 0x00350005,0x00351005,0x00352005,0x00353005,0x00354005,0x00355005,0x00356005,0x00357005
+	.long 0x00358005,0x00359005,0x0035a005,0x0035b005,0x0035c005,0x0035d005,0x0035e005,0x0035f005
+	.long 0x00360005,0x00361005,0x00362005,0x00363005,0x00364005,0x00365005,0x00366005,0x00367005
+	.long 0x00368005,0x00369005,0x0036a005,0x0036b005,0x0036c005,0x0036d005,0x0036e005,0x0036f005
+	.long 0x00370005,0x00371005,0x00372005,0x00373005,0x00374005,0x00375005,0x00376005,0x00377005
+	.long 0x00378005,0x00379005,0x0037a005,0x0037b005,0x0037c005,0x0037d005,0x0037e005,0x0037f005
+	.long 0x00380005,0x00381005,0x00382005,0x00383005,0x00384005,0x00385005,0x00386005,0x00387005
+	.long 0x00388005,0x00389005,0x0038a005,0x0038b005,0x0038c005,0x0038d005,0x0038e005,0x0038f005
+	.long 0x00390005,0x00391005,0x00392005,0x00393005,0x00394005,0x00395005,0x00396005,0x00397005
+	.long 0x00398005,0x00399005,0x0039a005,0x0039b005,0x0039c005,0x0039d005,0x0039e005,0x0039f005
+	.long 0x003a0005,0x003a1005,0x003a2005,0x003a3005,0x003a4005,0x003a5005,0x003a6005,0x003a7005
+	.long 0x003a8005,0x003a9005,0x003aa005,0x003ab005,0x003ac005,0x003ad005,0x003ae005,0x003af005
+	.long 0x003b0005,0x003b1005,0x003b2005,0x003b3005,0x003b4005,0x003b5005,0x003b6005,0x003b7005
+	.long 0x003b8005,0x003b9005,0x003ba005,0x003bb005,0x003bc005,0x003bd005,0x003be005,0x003bf005
+	.long 0x003c0005,0x003c1005,0x003c2005,0x003c3005,0x003c4005,0x003c5005,0x003c6005,0x003c7005
+	.long 0x003c8005,0x003c9005,0x003ca005,0x003cb005,0x003cc005,0x003cd005,0x003ce005,0x003cf005
+	.long 0x003d0005,0x003d1005,0x003d2005,0x003d3005,0x003d4005,0x003d5005,0x003d6005,0x003d7005
+	.long 0x003d8005,0x003d9005,0x003da005,0x003db005,0x003dc005,0x003dd005,0x003de005,0x003df005
+	.long 0x003e0005,0x003e1005,0x003e2005,0x003e3005,0x003e4005,0x003e5005,0x003e6005,0x003e7005
+	.long 0x003e8005,0x003e9005,0x003ea005,0x003eb005,0x003ec005,0x003ed005,0x003ee005,0x003ef005
+	.long 0x003f0005,0x003f1005,0x003f2005,0x003f3005,0x003f4005,0x003f5005,0x003f6005,0x003f7005
+	.long 0x003f8005,0x003f9005,0x003fa005,0x003fb005,0x003fc005,0x003fd005,0x003fe005,0x003ff005
+*/
+pml1:
+//	.long pml0+5,
+	.long 0x00000085,0x00400085,0x00800085,0x00c00085,0x01000085,0x01400085,0x01800085,0x01c00085
+	.long 0x02000085,0x02400085,0x02800085,0x02c00085,0x03000085,0x03400085,0x03800085,0x03c00085
+	.long 0x04000085,0x04400085,0x04800085,0x04c00085,0x05000085,0x05400085,0x05800085,0x05c00085
+	.long 0x06000085,0x06400085,0x06800085,0x06c00085,0x07000085,0x07400085,0x07800085,0x07c00085
+	.long 0x08000085,0x08400085,0x08800085,0x08c00085,0x09000085,0x09400085,0x09800085,0x09c00085
+	.long 0x0a000085,0x0a400085,0x0a800085,0x0ac00085,0x0b000085,0x0b400085,0x0b800085,0x0bc00085
+	.long 0x0c000085,0x0c400085,0x0c800085,0x0cc00085,0x0d000085,0x0d400085,0x0d800085,0x0dc00085
+	.long 0x0e000085,0x0e400085,0x0e800085,0x0ec00085,0x0f000085,0x0f400085,0x0f800085,0x0fc00085
+	.long 0x10000085,0x10400085,0x10800085,0x10c00085,0x11000085,0x11400085,0x11800085,0x11c00085
+	.long 0x12000085,0x12400085,0x12800085,0x12c00085,0x13000085,0x13400085,0x13800085,0x13c00085
+	.long 0x14000085,0x14400085,0x14800085,0x14c00085,0x15000085,0x15400085,0x15800085,0x15c00085
+	.long 0x16000085,0x16400085,0x16800085,0x16c00085,0x17000085,0x17400085,0x17800085,0x17c00085
+	.long 0x18000085,0x18400085,0x18800085,0x18c00085,0x19000085,0x19400085,0x19800085,0x19c00085
+	.long 0x1a000085,0x1a400085,0x1a800085,0x1ac00085,0x1b000085,0x1b400085,0x1b800085,0x1bc00085
+	.long 0x1c000085,0x1c400085,0x1c800085,0x1cc00085,0x1d000085,0x1d400085,0x1d800085,0x1dc00085
+	.long 0x1e000085,0x1e400085,0x1e800085,0x1ec00085,0x1f000085,0x1f400085,0x1f800085,0x1fc00085
+	.long 0x20000085,0x20400085,0x20800085,0x20c00085,0x21000085,0x21400085,0x21800085,0x21c00085
+	.long 0x22000085,0x22400085,0x22800085,0x22c00085,0x23000085,0x23400085,0x23800085,0x23c00085
+	.long 0x24000085,0x24400085,0x24800085,0x24c00085,0x25000085,0x25400085,0x25800085,0x25c00085
+	.long 0x26000085,0x26400085,0x26800085,0x26c00085,0x27000085,0x27400085,0x27800085,0x27c00085
+	.long 0x28000085,0x28400085,0x28800085,0x28c00085,0x29000085,0x29400085,0x29800085,0x29c00085
+	.long 0x2a000085,0x2a400085,0x2a800085,0x2ac00085,0x2b000085,0x2b400085,0x2b800085,0x2bc00085
+	.long 0x2c000085,0x2c400085,0x2c800085,0x2cc00085,0x2d000085,0x2d400085,0x2d800085,0x2dc00085
+	.long 0x2e000085,0x2e400085,0x2e800085,0x2ec00085,0x2f000085,0x2f400085,0x2f800085,0x2fc00085
+	.long 0x30000085,0x30400085,0x30800085,0x30c00085,0x31000085,0x31400085,0x31800085,0x31c00085
+	.long 0x32000085,0x32400085,0x32800085,0x32c00085,0x33000085,0x33400085,0x33800085,0x33c00085
+	.long 0x34000085,0x34400085,0x34800085,0x34c00085,0x35000085,0x35400085,0x35800085,0x35c00085
+	.long 0x36000085,0x36400085,0x36800085,0x36c00085,0x37000085,0x37400085,0x37800085,0x37c00085
+	.long 0x38000085,0x38400085,0x38800085,0x38c00085,0x39000085,0x39400085,0x39800085,0x39c00085
+	.long 0x3a000085,0x3a400085,0x3a800085,0x3ac00085,0x3b000085,0x3b400085,0x3b800085,0x3bc00085
+	.long 0x3c000085,0x3c400085,0x3c800085,0x3cc00085,0x3d000085,0x3d400085,0x3d800085,0x3dc00085
+	.long 0x3e000085,0x3e400085,0x3e800085,0x3ec00085,0x3f000085,0x3f400085,0x3f800085,0x3fc00085
+	.long 0x40000085,0x40400085,0x40800085,0x40c00085,0x41000085,0x41400085,0x41800085,0x41c00085
+	.long 0x42000085,0x42400085,0x42800085,0x42c00085,0x43000085,0x43400085,0x43800085,0x43c00085
+	.long 0x44000085,0x44400085,0x44800085,0x44c00085,0x45000085,0x45400085,0x45800085,0x45c00085
+	.long 0x46000085,0x46400085,0x46800085,0x46c00085,0x47000085,0x47400085,0x47800085,0x47c00085
+	.long 0x48000085,0x48400085,0x48800085,0x48c00085,0x49000085,0x49400085,0x49800085,0x49c00085
+	.long 0x4a000085,0x4a400085,0x4a800085,0x4ac00085,0x4b000085,0x4b400085,0x4b800085,0x4bc00085
+	.long 0x4c000085,0x4c400085,0x4c800085,0x4cc00085,0x4d000085,0x4d400085,0x4d800085,0x4dc00085
+	.long 0x4e000085,0x4e400085,0x4e800085,0x4ec00085,0x4f000085,0x4f400085,0x4f800085,0x4fc00085
+	.long 0x50000085,0x50400085,0x50800085,0x50c00085,0x51000085,0x51400085,0x51800085,0x51c00085
+	.long 0x52000085,0x52400085,0x52800085,0x52c00085,0x53000085,0x53400085,0x53800085,0x53c00085
+	.long 0x54000085,0x54400085,0x54800085,0x54c00085,0x55000085,0x55400085,0x55800085,0x55c00085
+	.long 0x56000085,0x56400085,0x56800085,0x56c00085,0x57000085,0x57400085,0x57800085,0x57c00085
+	.long 0x58000085,0x58400085,0x58800085,0x58c00085,0x59000085,0x59400085,0x59800085,0x59c00085
+	.long 0x5a000085,0x5a400085,0x5a800085,0x5ac00085,0x5b000085,0x5b400085,0x5b800085,0x5bc00085
+	.long 0x5c000085,0x5c400085,0x5c800085,0x5cc00085,0x5d000085,0x5d400085,0x5d800085,0x5dc00085
+	.long 0x5e000085,0x5e400085,0x5e800085,0x5ec00085,0x5f000085,0x5f400085,0x5f800085,0x5fc00085
+	.long 0x60000085,0x60400085,0x60800085,0x60c00085,0x61000085,0x61400085,0x61800085,0x61c00085
+	.long 0x62000085,0x62400085,0x62800085,0x62c00085,0x63000085,0x63400085,0x63800085,0x63c00085
+	.long 0x64000085,0x64400085,0x64800085,0x64c00085,0x65000085,0x65400085,0x65800085,0x65c00085
+	.long 0x66000085,0x66400085,0x66800085,0x66c00085,0x67000085,0x67400085,0x67800085,0x67c00085
+	.long 0x68000085,0x68400085,0x68800085,0x68c00085,0x69000085,0x69400085,0x69800085,0x69c00085
+	.long 0x6a000085,0x6a400085,0x6a800085,0x6ac00085,0x6b000085,0x6b400085,0x6b800085,0x6bc00085
+	.long 0x6c000085,0x6c400085,0x6c800085,0x6cc00085,0x6d000085,0x6d400085,0x6d800085,0x6dc00085
+	.long 0x6e000085,0x6e400085,0x6e800085,0x6ec00085,0x6f000085,0x6f400085,0x6f800085,0x6fc00085
+	.long 0x70000085,0x70400085,0x70800085,0x70c00085,0x71000085,0x71400085,0x71800085,0x71c00085
+	.long 0x72000085,0x72400085,0x72800085,0x72c00085,0x73000085,0x73400085,0x73800085,0x73c00085
+	.long 0x74000085,0x74400085,0x74800085,0x74c00085,0x75000085,0x75400085,0x75800085,0x75c00085
+	.long 0x76000085,0x76400085,0x76800085,0x76c00085,0x77000085,0x77400085,0x77800085,0x77c00085
+	.long 0x78000085,0x78400085,0x78800085,0x78c00085,0x79000085,0x79400085,0x79800085,0x79c00085
+	.long 0x7a000085,0x7a400085,0x7a800085,0x7ac00085,0x7b000085,0x7b400085,0x7b800085,0x7bc00085
+	.long 0x7c000085,0x7c400085,0x7c800085,0x7cc00085,0x7d000085,0x7d400085,0x7d800085,0x7dc00085
+	.long 0x7e000085,0x7e400085,0x7e800085,0x7ec00085,0x7f000085,0x7f400085,0x7f800085,0x7fc00085
+	.long 0x80000085,0x80400085,0x80800085,0x80c00085,0x81000085,0x81400085,0x81800085,0x81c00085
+	.long 0x82000085,0x82400085,0x82800085,0x82c00085,0x83000085,0x83400085,0x83800085,0x83c00085
+	.long 0x84000085,0x84400085,0x84800085,0x84c00085,0x85000085,0x85400085,0x85800085,0x85c00085
+	.long 0x86000085,0x86400085,0x86800085,0x86c00085,0x87000085,0x87400085,0x87800085,0x87c00085
+	.long 0x88000085,0x88400085,0x88800085,0x88c00085,0x89000085,0x89400085,0x89800085,0x89c00085
+	.long 0x8a000085,0x8a400085,0x8a800085,0x8ac00085,0x8b000085,0x8b400085,0x8b800085,0x8bc00085
+	.long 0x8c000085,0x8c400085,0x8c800085,0x8cc00085,0x8d000085,0x8d400085,0x8d800085,0x8dc00085
+	.long 0x8e000085,0x8e400085,0x8e800085,0x8ec00085,0x8f000085,0x8f400085,0x8f800085,0x8fc00085
+	.long 0x90000085,0x90400085,0x90800085,0x90c00085,0x91000085,0x91400085,0x91800085,0x91c00085
+	.long 0x92000085,0x92400085,0x92800085,0x92c00085,0x93000085,0x93400085,0x93800085,0x93c00085
+	.long 0x94000085,0x94400085,0x94800085,0x94c00085,0x95000085,0x95400085,0x95800085,0x95c00085
+	.long 0x96000085,0x96400085,0x96800085,0x96c00085,0x97000085,0x97400085,0x97800085,0x97c00085
+	.long 0x98000085,0x98400085,0x98800085,0x98c00085,0x99000085,0x99400085,0x99800085,0x99c00085
+	.long 0x9a000085,0x9a400085,0x9a800085,0x9ac00085,0x9b000085,0x9b400085,0x9b800085,0x9bc00085
+	.long 0x9c000085,0x9c400085,0x9c800085,0x9cc00085,0x9d000085,0x9d400085,0x9d800085,0x9dc00085
+	.long 0x9e000085,0x9e400085,0x9e800085,0x9ec00085,0x9f000085,0x9f400085,0x9f800085,0x9fc00085
+	.long 0xa0000085,0xa0400085,0xa0800085,0xa0c00085,0xa1000085,0xa1400085,0xa1800085,0xa1c00085
+	.long 0xa2000085,0xa2400085,0xa2800085,0xa2c00085,0xa3000085,0xa3400085,0xa3800085,0xa3c00085
+	.long 0xa4000085,0xa4400085,0xa4800085,0xa4c00085,0xa5000085,0xa5400085,0xa5800085,0xa5c00085
+	.long 0xa6000085,0xa6400085,0xa6800085,0xa6c00085,0xa7000085,0xa7400085,0xa7800085,0xa7c00085
+	.long 0xa8000085,0xa8400085,0xa8800085,0xa8c00085,0xa9000085,0xa9400085,0xa9800085,0xa9c00085
+	.long 0xaa000085,0xaa400085,0xaa800085,0xaac00085,0xab000085,0xab400085,0xab800085,0xabc00085
+	.long 0xac000085,0xac400085,0xac800085,0xacc00085,0xad000085,0xad400085,0xad800085,0xadc00085
+	.long 0xae000085,0xae400085,0xae800085,0xaec00085,0xaf000085,0xaf400085,0xaf800085,0xafc00085
+	.long 0xb0000085,0xb0400085,0xb0800085,0xb0c00085,0xb1000085,0xb1400085,0xb1800085,0xb1c00085
+	.long 0xb2000085,0xb2400085,0xb2800085,0xb2c00085,0xb3000085,0xb3400085,0xb3800085,0xb3c00085
+	.long 0xb4000085,0xb4400085,0xb4800085,0xb4c00085,0xb5000085,0xb5400085,0xb5800085,0xb5c00085
+	.long 0xb6000085,0xb6400085,0xb6800085,0xb6c00085,0xb7000085,0xb7400085,0xb7800085,0xb7c00085
+	.long 0xb8000085,0xb8400085,0xb8800085,0xb8c00085,0xb9000085,0xb9400085,0xb9800085,0xb9c00085
+	.long 0xba000085,0xba400085,0xba800085,0xbac00085,0xbb000085,0xbb400085,0xbb800085,0xbbc00085
+	.long 0xbc000085,0xbc400085,0xbc800085,0xbcc00085,0xbd000085,0xbd400085,0xbd800085,0xbdc00085
+	.long 0xbe000085,0xbe400085,0xbe800085,0xbec00085,0xbf000085,0xbf400085,0xbf800085,0xbfc00085
+	.long 0xc0000085,0xc0400085,0xc0800085,0xc0c00085,0xc1000085,0xc1400085,0xc1800085,0xc1c00085
+	.long 0xc2000085,0xc2400085,0xc2800085,0xc2c00085,0xc3000085,0xc3400085,0xc3800085,0xc3c00085
+	.long 0xc4000085,0xc4400085,0xc4800085,0xc4c00085,0xc5000085,0xc5400085,0xc5800085,0xc5c00085
+	.long 0xc6000085,0xc6400085,0xc6800085,0xc6c00085,0xc7000085,0xc7400085,0xc7800085,0xc7c00085
+	.long 0xc8000085,0xc8400085,0xc8800085,0xc8c00085,0xc9000085,0xc9400085,0xc9800085,0xc9c00085
+	.long 0xca000085,0xca400085,0xca800085,0xcac00085,0xcb000085,0xcb400085,0xcb800085,0xcbc00085
+	.long 0xcc000085,0xcc400085,0xcc800085,0xccc00085,0xcd000085,0xcd400085,0xcd800085,0xcdc00085
+	.long 0xce000085,0xce400085,0xce800085,0xcec00085,0xcf000085,0xcf400085,0xcf800085,0xcfc00085
+	.long 0xd0000085,0xd0400085,0xd0800085,0xd0c00085,0xd1000085,0xd1400085,0xd1800085,0xd1c00085
+	.long 0xd2000085,0xd2400085,0xd2800085,0xd2c00085,0xd3000085,0xd3400085,0xd3800085,0xd3c00085
+	.long 0xd4000085,0xd4400085,0xd4800085,0xd4c00085,0xd5000085,0xd5400085,0xd5800085,0xd5c00085
+	.long 0xd6000085,0xd6400085,0xd6800085,0xd6c00085,0xd7000085,0xd7400085,0xd7800085,0xd7c00085
+	.long 0xd8000085,0xd8400085,0xd8800085,0xd8c00085,0xd9000085,0xd9400085,0xd9800085,0xd9c00085
+	.long 0xda000085,0xda400085,0xda800085,0xdac00085,0xdb000085,0xdb400085,0xdb800085,0xdbc00085
+	.long 0xdc000085,0xdc400085,0xdc800085,0xdcc00085,0xdd000085,0xdd400085,0xdd800085,0xddc00085
+	.long 0xde000085,0xde400085,0xde800085,0xdec00085,0xdf000085,0xdf400085,0xdf800085,0xdfc00085
+	.long 0xe0000085,0xe0400085,0xe0800085,0xe0c00085,0xe1000085,0xe1400085,0xe1800085,0xe1c00085
+	.long 0xe2000085,0xe2400085,0xe2800085,0xe2c00085,0xe3000085,0xe3400085,0xe3800085,0xe3c00085
+	.long 0xe4000085,0xe4400085,0xe4800085,0xe4c00085,0xe5000085,0xe5400085,0xe5800085,0xe5c00085
+	.long 0xe6000085,0xe6400085,0xe6800085,0xe6c00085,0xe7000085,0xe7400085,0xe7800085,0xe7c00085
+	.long 0xe8000085,0xe8400085,0xe8800085,0xe8c00085,0xe9000085,0xe9400085,0xe9800085,0xe9c00085
+	.long 0xea000085,0xea400085,0xea800085,0xeac00085,0xeb000085,0xeb400085,0xeb800085,0xebc00085
+	.long 0xec000085,0xec400085,0xec800085,0xecc00085,0xed000085,0xed400085,0xed800085,0xedc00085
+	.long 0xee000085,0xee400085,0xee800085,0xeec00085,0xef000085,0xef400085,0xef800085,0xefc00085
+	.long 0xf0000085,0xf0400085,0xf0800085,0xf0c00085,0xf1000085,0xf1400085,0xf1800085,0xf1c00085
+	.long 0xf2000085,0xf2400085,0xf2800085,0xf2c00085,0xf3000085,0xf3400085,0xf3800085,0xf3c00085
+	.long 0xf4000085,0xf4400085,0xf4800085,0xf4c00085,0xf5000085,0xf5400085,0xf5800085,0xf5c00085
+	.long 0xf6000085,0xf6400085,0xf6800085,0xf6c00085,0xf7000085,0xf7400085,0xf7800085,0xf7c00085
+	.long 0xf8000085,0xf8400085,0xf8800085,0xf8c00085,0xf9000085,0xf9400085,0xf9800085,0xf9c00085
+	.long 0xfa000085,0xfa400085,0xfa800085,0xfac00085,0xfb000085,0xfb400085,0xfb800085,0xfbc00085
+	.long 0xfc000085,0xfc400085,0xfc800085,0xfcc00085,0xfd000085,0xfd400085,0xfd800085,0xfdc00085
+	.long 0xfe000085,0xfe400085,0xfe800085,0xfec00085,0xff000085,0xff400085,0xff800085,0xffc00085
diff --git a/src/arch/x86/lib/paging.S b/src/arch/x86/lib/paging.S
new file mode 100644
index 0000000..37b1da0
--- /dev/null
+++ b/src/arch/x86/lib/paging.S
@@ -0,0 +1,27 @@
+#if CONFIG_PGE==1
+#include <cpu/x86/cr.h>
+
+	jmp code
+
+	.section .rom.data
+#include "pagetables.S"
+	.previous
+
+code:
+	movl	$pml1, %ecx		/* load address of page directory */
+	movl	%ecx, %cr3
+	jmp	1f
+1:
+	movl	%cr4, %edx
+	orl	$CR4_PSE, %edx			/* 4m pages */
+	movl	%edx, %cr4
+
+	movl	%cr0, %edx
+	orl	$CR0_PG, %edx
+
+	movl	$paging, %eax
+	movl	%edx, %cr0
+	jmp	*%eax
+paging:
+#endif
+
diff --git a/src/include/bootstate.h b/src/include/bootstate.h
index 46662d5..80f69d2 100644
--- a/src/include/bootstate.h
+++ b/src/include/bootstate.h
@@ -22,7 +22,7 @@
 #include <string.h>
 
 /* Control debugging of the boot state machine. */
-#define BOOT_STATE_DEBUG 0
+#define BOOT_STATE_DEBUG 1
 
 /*
  * The boot state machine provides a mechanism for calls to be made through-
diff --git a/src/lib/cbfs.c b/src/lib/cbfs.c
index dc08937..2555550 100644
--- a/src/lib/cbfs.c
+++ b/src/lib/cbfs.c
@@ -139,18 +139,23 @@ void * cbfs_load_stage(struct cbfs_media *media, const char *name)
 				     sizeof(struct cbfs_stage),
 				     (void *) (uint32_t) stage->load,
 				     stage->len);
+	LOG("done., final_size is %d\n", final_size);
 	if (!final_size)
 		return (void *) -1;
 
 	/* Stages rely the below clearing so that the bss is initialized. */
 	memset((void *)((uintptr_t)stage->load + final_size), 0,
 	       stage->memlen - final_size);
+	ERROR("memset(%p, 0, %d)\n", (void *)((uintptr_t)stage->load + final_size),
+	       stage->memlen - final_size);
+	LOG("memset done\n");
 
 	DEBUG("stage loaded.\n");
 
 	entry = stage->entry;
 	// entry = ntohll(stage->entry);
 
+	ERROR("CALL %p\n", (void *)entry);
 	return (void *) entry;
 }
 



More information about the coreboot-gerrit mailing list