Index: arch/ia32/src/boot/boot.S
===================================================================
--- arch/ia32/src/boot/boot.S	(revision 74b2f5bf70b629eb78cf316e112a0ded34c54ecb)
+++ arch/ia32/src/boot/boot.S	(revision cf27a6cb0e5c7b73e0a1b2d2123ac5792c0c979e)
@@ -214,5 +214,5 @@
 	#
 	# Here we setup mapping for both the unmapped and mapped sections of the kernel.
-	# For simplicity, we set only one 4M page for 0x00000000 and one for 0x80000000.
+	# For simplicity, we map the entire 4G space.
 	#
 	movl %cr4, %ecx
@@ -220,12 +220,20 @@
 	movl %ecx, %cr4							# turn PSE on
 	
+	movl $(page_directory+0), %esi
+	movl $(page_directory+2048), %edi
+	xorl %ecx, %ecx
+	xorl %ebx, %ebx
+0:
 	movl $((1<<7)|(1<<0)), %eax
-	movl %eax, page_directory					# mapping 0x00000000 => 0x00000000
-
-	movl $(page_directory+2048), %edx
-	movl %eax, (%edx)						# mapping 0x80000000 => 0x00000000
-
-	leal page_directory, %eax
-	movl %eax, %cr3
+	orl %ebx, %eax
+	movl %eax, (%esi,%ecx,4)					# mapping 0x00000000+%ecx*4M => 0x00000000+%ecx*4M
+	movl %eax, (%edi,%ecx,4)					# mapping 0x80000000+%ecx*4M => 0x00000000+%ecx*4M
+	addl $(4*1024*1024), %ebx
+
+	incl %ecx
+	cmpl $512, %ecx
+	jl 0b
+
+	movl %esi, %cr3
 	
 	# turn paging on
Index: arch/ia32/src/mm/frame.c
===================================================================
--- arch/ia32/src/mm/frame.c	(revision 74b2f5bf70b629eb78cf316e112a0ded34c54ecb)
+++ arch/ia32/src/mm/frame.c	(revision cf27a6cb0e5c7b73e0a1b2d2123ac5792c0c979e)
@@ -44,9 +44,9 @@
 	
 	if (config.cpu_active == 1) {
-		for (i=e820counter;i>0;i--) {
-			if (e820table[i-1].type==MEMMAP_MEMORY_AVAILABLE) {
-				z = zone_create(e820table[i-1].base_address, e820table[i-1].size & ~(FRAME_SIZE-1), 0);
+		for (i=0;i<e820counter;i++) {
+			if (e820table[i].type==MEMMAP_MEMORY_AVAILABLE) {
+				z = zone_create(e820table[i].base_address, e820table[i].size & ~(FRAME_SIZE-1), 0);
 				if (!z) {
-					panic("Cannot allocate zone (%dB).\n", e820table[i-1].size & ~(FRAME_SIZE-1));
+					panic("Cannot allocate zone (%dB).\n", e820table[i].size & ~(FRAME_SIZE-1));
 				}
 				zone_attach(z);
