Index: kernel/arch/xen32/include/boot/boot.h
===================================================================
--- kernel/arch/xen32/include/boot/boot.h	(revision c049309818d0a3eca8aa6dfecad99aa1f06ee0d6)
+++ kernel/arch/xen32/include/boot/boot.h	(revision e12ccc58f0ffb42cd6c2b5def689f4d61e526d1d)
@@ -37,20 +37,70 @@
 
 #define GUEST_CMDLINE	1024
+#define VIRT_CPUS		32
 #define START_INFO_SIZE	1104
+
 #define BOOT_OFFSET		0x0000
+#define XEN_VIRT_START	0xFC000000
+
+#define TEMP_STACK_SIZE 0x1000
 
 #ifndef __ASM__
 
+#define mp_map ((pfn_t *) XEN_VIRT_START)
+
 #include <arch/types.h>
+
+typedef uint32_t evtchn_t;
+
+typedef struct {
+	uint32_t version;
+	uint32_t pad0;
+	uint64_t tsc_timestamp;   /**< TSC at last update of time vals */
+	uint64_t system_time;     /**< Time, in nanosecs, since boot */
+	uint32_t tsc_to_system_mul;
+	int8_t tsc_shift;
+	int8_t pad1[3];
+} vcpu_time_info_t;
+
+typedef struct {
+	uint32_t cr2;
+	uint32_t pad[5];
+} arch_vcpu_info_t;
+
+typedef struct arch_shared_info {
+	pfn_t max_pfn;                  /**< max pfn that appears in table */
+	uint32_t pfn_to_mfn_frame_list_list;
+    uint32_t nmi_reason;
+} arch_shared_info_t;
+
+typedef struct {
+	uint8_t evtchn_upcall_pending;
+	uint8_t evtchn_upcall_mask;
+	evtchn_t evtchn_pending_sel;
+	arch_vcpu_info_t arch;
+	vcpu_time_info_t time;
+} vcpu_info_t;
+
+typedef struct {
+	vcpu_info_t vcpu_info[VIRT_CPUS];
+	evtchn_t evtchn_pending[32];
+	evtchn_t evtchn_mask[32];
+	
+	uint32_t wc_version;                  /**< Version counter */
+	uint32_t wc_sec;                      /**< Secs  00:00:00 UTC, Jan 1, 1970 */
+	uint32_t wc_nsec;                     /**< Nsecs 00:00:00 UTC, Jan 1, 1970 */
+	
+	arch_shared_info_t arch;
+} shared_info_t;
 
 typedef struct {
 	int8_t magic[32];           /**< "xen-<version>-<platform>" */
 	uint32_t frames;            /**< Available frames */
-	void *shared_info;          /**< Shared info structure (machine address) */
+	shared_info_t *shared_info; /**< Shared info structure (machine address) */
 	uint32_t flags;             /**< SIF_xxx flags */
 	pfn_t store_mfn;            /**< Shared page (machine page) */
-	uint32_t store_evtchn;      /**< Event channel for store communication */
+	evtchn_t store_evtchn;      /**< Event channel for store communication */
 	void *console_mfn;          /**< Console page (machine address) */
-	uint32_t console_evtchn;    /**< Event channel for console messages */
+	evtchn_t console_evtchn;    /**< Event channel for console messages */
 	pte_t *ptl0;                /**< Boot PTL0 (kernel address) */
 	uint32_t pt_frames;         /**< Number of bootstrap page table frames */
@@ -61,5 +111,13 @@
 } start_info_t;
 
+typedef struct {
+	pfn_t start;
+	pfn_t size;
+	pfn_t reserved;
+} memzone_t;
+
 extern start_info_t start_info;
+extern shared_info_t shared_info;
+extern memzone_t meminfo;
 
 #endif
Index: kernel/arch/xen32/include/hypercall.h
===================================================================
--- kernel/arch/xen32/include/hypercall.h	(revision c049309818d0a3eca8aa6dfecad99aa1f06ee0d6)
+++ kernel/arch/xen32/include/hypercall.h	(revision e12ccc58f0ffb42cd6c2b5def689f4d61e526d1d)
@@ -36,25 +36,10 @@
 typedef uint16_t domid_t;
 
-typedef struct {
-    uint64_t ptr;  /**< Machine address of PTE */
-    uint64_t val;  /**< New contents of PTE */
-} mmu_update_t;
-
-typedef struct {
-    unsigned int cmd;
-    union {
-        unsigned long mfn;
-        unsigned long linear_addr;
-    } arg1;
-    union {
-        unsigned int nr_ents;
-        void *vcpumask;
-    } arg2;
-} mmuext_op_t;
-
-
-#define XEN_MMU_UPDATE	1
-#define XEN_CONSOLE_IO	18
-#define XEN_MMUEXT_OP	26
+
+#define XEN_MMU_UPDATE			1
+#define XEN_UPDATE_VA_MAPPING	14
+#define XEN_CONSOLE_IO			18
+#define XEN_VM_ASSIST			21
+#define XEN_MMUEXT_OP			26
 
 
@@ -83,4 +68,23 @@
 
 
+#define UVMF_NONE				0        /**< No flushing at all */
+#define UVMF_TLB_FLUSH			1        /**< Flush entire TLB(s) */
+#define UVMF_INVLPG				2        /**< Flush only one entry */
+#define UVMF_FLUSHTYPE_MASK		3
+#define UVMF_MULTI				0        /**< Flush subset of TLBs */
+#define UVMF_LOCAL				0        /**< Flush local TLB */
+#define UVMF_ALL				(1 << 2) /**< Flush all TLBs */
+
+
+/*
+ * Commands to XEN_VM_ASSIST
+ */
+#define VMASST_CMD_ENABLE				0
+#define VMASST_CMD_DISABLE				1
+#define VMASST_TYPE_4GB_SEGMENTS		0
+#define VMASST_TYPE_4GB_SEGMENTS_NOTIFY	1
+#define VMASST_TYPE_WRITABLE_PAGETABLES	2
+
+
 #define DOMID_SELF (0x7FF0U)
 #define DOMID_IO   (0x7FF1U)
@@ -190,13 +194,8 @@
 }
 
-static inline int xen_mmu_update(const mmu_update_t *req, const unsigned int count, unsigned int *success_count, domid_t domid)
+static inline int xen_vm_assist(const unsigned int cmd, const unsigned int type)
 {
-	return hypercall4(XEN_MMU_UPDATE, req, count, success_count, domid);
+    return hypercall2(XEN_VM_ASSIST, cmd, type);
 }
 
-static inline int xen_mmuext_op(const mmuext_op_t *op, const unsigned int count, unsigned int *success_count, domid_t domid)
-{
-	return hypercall4(XEN_MMUEXT_OP, op, count, success_count, domid);
-}
-
 #endif
Index: kernel/arch/xen32/include/mm/frame.h
===================================================================
--- kernel/arch/xen32/include/mm/frame.h	(revision c049309818d0a3eca8aa6dfecad99aa1f06ee0d6)
+++ kernel/arch/xen32/include/mm/frame.h	(revision e12ccc58f0ffb42cd6c2b5def689f4d61e526d1d)
@@ -47,6 +47,5 @@
 
 #define PA2MA(x)	((start_info.pm_map[((uintptr_t) (x)) >> 12] << 12) + (((uintptr_t) (x)) & 0xfff))
-
-extern uintptr_t last_frame;
+#define MA2PA(x)	((mp_map[((uintptr_t) (x)) >> 12] << 12) + (((uintptr_t) (x)) & 0xfff))
 
 extern void frame_arch_init(void);
Index: kernel/arch/xen32/include/mm/page.h
===================================================================
--- kernel/arch/xen32/include/mm/page.h	(revision c049309818d0a3eca8aa6dfecad99aa1f06ee0d6)
+++ kernel/arch/xen32/include/mm/page.h	(revision e12ccc58f0ffb42cd6c2b5def689f4d61e526d1d)
@@ -44,5 +44,4 @@
 
 #ifndef __ASM__
-#	include <arch/hypercall.h>
 #	define KA2PA(x)	(((uintptr_t) (x)) - 0x80000000)
 #	define PA2KA(x)	(((uintptr_t) (x)) + 0x80000000)
@@ -66,39 +65,37 @@
 #define PTL3_INDEX_ARCH(vaddr)	(((vaddr) >> 12) & 0x3ff)
 
-#define GET_PTL1_ADDRESS_ARCH(ptl0, i)		((pte_t *)((((pte_t *)(ptl0))[(i)].frame_address) << 12))
+#define GET_PTL1_ADDRESS_ARCH(ptl0, i)		((pte_t *) MA2PA((((pte_t *) (ptl0))[(i)].frame_address) << 12))
 #define GET_PTL2_ADDRESS_ARCH(ptl1, i)		(ptl1)
 #define GET_PTL3_ADDRESS_ARCH(ptl2, i)		(ptl2)
-#define GET_FRAME_ADDRESS_ARCH(ptl3, i)		((uintptr_t)((((pte_t *)(ptl3))[(i)].frame_address) << 12))
+#define GET_FRAME_ADDRESS_ARCH(ptl3, i)		((uintptr_t) MA2PA((((pte_t *) (ptl3))[(i)].frame_address) << 12))
 
 #define SET_PTL0_ADDRESS_ARCH(ptl0) { \
 	mmuext_op_t mmu_ext; \
+	\
 	mmu_ext.cmd = MMUEXT_NEW_BASEPTR; \
-	mmu_ext.arg1.mfn = ADDR2PFN(PA2MA(ptl0)); \
+	mmu_ext.mfn = ADDR2PFN(PA2MA(ptl0)); \
 	xen_mmuext_op(&mmu_ext, 1, NULL, DOMID_SELF); \
 }
+
 #define SET_PTL1_ADDRESS_ARCH(ptl0, i, a) { \
 	mmu_update_t update; \
+	\
 	update.ptr = PA2MA(KA2PA(&((pte_t *) (ptl0))[(i)])); \
-	update.val = PA2MA(a); \
+	update.val = PA2MA(a) | 0x0003; \
 	xen_mmu_update(&update, 1, NULL, DOMID_SELF); \
 }
 #define SET_PTL2_ADDRESS_ARCH(ptl1, i, a)
 #define SET_PTL3_ADDRESS_ARCH(ptl2, i, a)
-#define SET_FRAME_ADDRESS_ARCH(ptl3, i, a) { \
-	mmu_update_t update; \
-	update.ptr = PA2MA(KA2PA(&((pte_t *) (ptl3))[(i)])); \
-	update.val = PA2MA(a); \
-	xen_mmu_update(&update, 1, NULL, DOMID_SELF); \
-}
-
-#define GET_PTL1_FLAGS_ARCH(ptl0, i)		get_pt_flags((pte_t *)(ptl0), (index_t)(i))
+#define SET_FRAME_ADDRESS_ARCH(ptl3, i, a)	(((pte_t *) (ptl3))[(i)].frame_address = PA2MA(a) >> 12)
+
+#define GET_PTL1_FLAGS_ARCH(ptl0, i)		get_pt_flags((pte_t *) (ptl0), (index_t)(i))
 #define GET_PTL2_FLAGS_ARCH(ptl1, i)		PAGE_PRESENT
 #define GET_PTL3_FLAGS_ARCH(ptl2, i)		PAGE_PRESENT
-#define GET_FRAME_FLAGS_ARCH(ptl3, i)		get_pt_flags((pte_t *)(ptl3), (index_t)(i))
-
-#define SET_PTL1_FLAGS_ARCH(ptl0, i, x)		set_pt_flags((pte_t *)(ptl0), (index_t)(i), (x))
+#define GET_FRAME_FLAGS_ARCH(ptl3, i)		get_pt_flags((pte_t *) (ptl3), (index_t)(i))
+
+#define SET_PTL1_FLAGS_ARCH(ptl0, i, x)		set_pt_flags((pte_t *) (ptl0), (index_t)(i), (x))
 #define SET_PTL2_FLAGS_ARCH(ptl1, i, x)
 #define SET_PTL3_FLAGS_ARCH(ptl2, i, x)
-#define SET_FRAME_FLAGS_ARCH(ptl3, i, x)	set_pt_flags((pte_t *)(ptl3), (index_t)(i), (x))
+#define SET_FRAME_FLAGS_ARCH(ptl3, i, x)		set_pt_flags((pte_t *) (ptl3), (index_t)(i), (x))
 
 #define PTE_VALID_ARCH(p)			(*((uint32_t *) (p)) != 0)
@@ -114,4 +111,5 @@
 #include <arch/mm/frame.h>
 #include <typedefs.h>
+#include <arch/hypercall.h>
 
 /* Page fault error codes. */
@@ -145,4 +143,39 @@
 } __attribute__ ((packed));
 
+typedef struct {
+	uint64_t ptr;      /**< Machine address of PTE */
+	union {            /**< New contents of PTE */
+		uint64_t val;
+		pte_t pte;
+	};
+} mmu_update_t;
+
+typedef struct {
+	unsigned int cmd;
+	union {
+		unsigned long mfn;
+		unsigned long linear_addr;
+	};
+	union {
+		unsigned int nr_ents;
+		void *vcpumask;
+	};
+} mmuext_op_t;
+
+static inline int xen_update_va_mapping(const void *va, const pte_t pte, const unsigned int flags)
+{
+	return hypercall4(XEN_UPDATE_VA_MAPPING, va, pte, 0, flags);
+}
+
+static inline int xen_mmu_update(const mmu_update_t *req, const unsigned int count, unsigned int *success_count, domid_t domid)
+{
+	return hypercall4(XEN_MMU_UPDATE, req, count, success_count, domid);
+}
+
+static inline int xen_mmuext_op(const mmuext_op_t *op, const unsigned int count, unsigned int *success_count, domid_t domid)
+{
+	return hypercall4(XEN_MMUEXT_OP, op, count, success_count, domid);
+}
+
 static inline int get_pt_flags(pte_t *pt, index_t i)
 {
