Index: kernel/arch/xen32/src/mm/frame.c
===================================================================
--- kernel/arch/xen32/src/mm/frame.c	(revision c049309818d0a3eca8aa6dfecad99aa1f06ee0d6)
+++ kernel/arch/xen32/src/mm/frame.c	(revision deaa22f01020fc8d432df92b990024d02d453083)
@@ -35,118 +35,12 @@
 
 #include <mm/frame.h>
-#include <arch/mm/frame.h>
-#include <mm/as.h>
 #include <config.h>
-#include <arch/boot/boot.h>
-#include <arch/hypercall.h>
-#include <panic.h>
-#include <debug.h>
-#include <align.h>
-#include <macros.h>
-
-#include <console/cmd.h>
-#include <console/kconsole.h>
-
-uintptr_t last_frame = 0;
-
-#define L0_PT_SHIFT	10
-#define L3_PT_SHIFT	0
-
-#define L0_PT_ENTRIES	1024
-#define L3_PT_ENTRIES	1024
-
-#define L0_INDEX_MASK			(L0_PT_ENTRIES - 1)
-#define L3_INDEX_MASK			(L3_PT_ENTRIES - 1)
-
-#define PFN2PTL0_INDEX(pfn)	((pfn >> L0_PT_SHIFT) & L0_INDEX_MASK)
-#define PFN2PTL3_INDEX(pfn)	((pfn >> L3_PT_SHIFT) & L3_INDEX_MASK)
-
-#define PAGE_MASK	(~(PAGE_SIZE - 1))
-
-#define _PAGE_PRESENT	0x001UL
-#define _PAGE_RW		0x002UL
-#define _PAGE_USER		0x004UL
-#define _PAGE_PWT		0x008UL
-#define _PAGE_PCD		0x010UL
-#define _PAGE_ACCESSED	0x020UL
-#define _PAGE_DIRTY		0x040UL
-#define _PAGE_PAT		0x080UL
-#define _PAGE_PSE		0x080UL
-#define _PAGE_GLOBAL	0x100UL
-
-#define L0_PROT	(_PAGE_PRESENT | _PAGE_ACCESSED)
-#define L3_PROT	(_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED)
 
 void frame_arch_init(void)
 {
 	if (config.cpu_active == 1) {
-		/* The only memory zone starts just after page table */
-		pfn_t start = ADDR2PFN(ALIGN_UP(KA2PA(start_info.ptl0), PAGE_SIZE)) + start_info.pt_frames;
-		size_t size = start_info.frames - start;
-		
-		/* Create identity mapping */
-		pfn_t phys;
-		count_t count = 0;
-		for (phys = start; phys < start + size; phys++) {
-			mmu_update_t updates[L3_PT_ENTRIES];
-			pfn_t virt = ADDR2PFN(PA2KA(PFN2ADDR(phys)));
-			
-			size_t ptl0_index = PFN2PTL0_INDEX(virt);
-			size_t ptl3_index = PFN2PTL3_INDEX(virt);
-			
-			pte_t *ptl3 = (pte_t *) PFN2ADDR(start_info.ptl0[ptl0_index].frame_address);
-			
-			if (ptl3 == 0) {
-				mmuext_op_t mmu_ext;
-				
-				pfn_t virt2 = ADDR2PFN(PA2KA(PFN2ADDR(start)));
-				
-				/* New L1 page table entry needed */
-				memsetb(PFN2ADDR(virt2), PAGE_SIZE, 0);
-				
-				size_t ptl0_index2 = PFN2PTL0_INDEX(virt2);
-				size_t ptl3_index2 = PFN2PTL3_INDEX(virt2);
-				pte_t *ptl3_2 = (pte_t *) PFN2ADDR(start_info.ptl0[ptl0_index2].frame_address);
-				
-				if (ptl3_2 == 0)
-					panic("Unable to find page table reference");
-				
-				updates[count].ptr = (uintptr_t) &ptl3_2[ptl3_index2];
-				updates[count].val = PA2MA(PFN2ADDR(start)) | L0_PROT;
-				if (xen_mmu_update(updates, count + 1, NULL, DOMID_SELF) < 0)
-					panic("Unable to map new page table");
-				count = 0;
-				
-				mmu_ext.cmd = MMUEXT_PIN_L1_TABLE;
-				mmu_ext.arg1.mfn = ADDR2PFN(PA2MA(PFN2ADDR(start)));
-				if (xen_mmuext_op(&mmu_ext, 1, NULL, DOMID_SELF) < 0)
-					panic("Error pinning new page table");
-				
-				pte_t *ptl0 = (pte_t *) PA2MA(KA2PA(start_info.ptl0));
-				
-				updates[count].ptr = (uintptr_t) &ptl0[ptl0_index];
-				updates[count].val = PA2MA(PFN2ADDR(start)) | L3_PROT;
-				if (xen_mmu_update(updates, count + 1, NULL, DOMID_SELF) < 0)
-					panic("Unable to update PTE for page table");
-				count = 0;
-				
-				ptl3 = (pte_t *) PFN2ADDR(start_info.ptl0[ptl0_index].frame_address);
-				start++;
-				size--;
-			}
-			
-			updates[count].ptr = (uintptr_t) &ptl3[ptl3_index];
-			updates[count].val = PA2MA(PFN2ADDR(phys)) | L3_PROT;
-			count++;
-			
-			if ((count == L3_PT_ENTRIES) || (phys + 1 == start + size)) {
-				if (xen_mmu_update(updates, count, NULL, DOMID_SELF) < 0)
-					panic("Unable to update PTE");
-				count = 0;
-			}
-		}
-		
-		zone_create(start, size, start, 0);
-		last_frame = start + size;
+		/* The only memory zone */
+		zone_create(meminfo.start, meminfo.size, meminfo.start + meminfo.reserved, 0);
+		frame_mark_unavailable(meminfo.start, meminfo.reserved);
 	}
 }
