Index: kernel/arch/ia32/include/bios/bios.h
===================================================================
--- kernel/arch/ia32/include/bios/bios.h	(revision 22a28a696141d62f28e48ed72d1d255ff519795c)
+++ kernel/arch/ia32/include/bios/bios.h	(revision e3038b41e1f6e1ef905bbc80916933e18d3e3008)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup ia32	
+/** @addtogroup ia32
  * @{
  */
@@ -38,5 +38,5 @@
 #include <typedefs.h>
 
-#define BIOS_EBDA_PTR	0x40e
+#define BIOS_EBDA_PTR  0x40e
 
 extern uintptr_t ebda;
Index: kernel/arch/ia32/include/drivers/i8259.h
===================================================================
--- kernel/arch/ia32/include/drivers/i8259.h	(revision 22a28a696141d62f28e48ed72d1d255ff519795c)
+++ kernel/arch/ia32/include/drivers/i8259.h	(revision e3038b41e1f6e1ef905bbc80916933e18d3e3008)
@@ -48,6 +48,6 @@
 
 extern void i8259_init(void);
-extern void pic_enable_irqs(uint16_t irqmask);
-extern void pic_disable_irqs(uint16_t irqmask);
+extern void pic_enable_irqs(uint16_t);
+extern void pic_disable_irqs(uint16_t);
 extern void pic_eoi(void);
 
Index: kernel/arch/ia32/include/fpu_context.h
===================================================================
--- kernel/arch/ia32/include/fpu_context.h	(revision 22a28a696141d62f28e48ed72d1d255ff519795c)
+++ kernel/arch/ia32/include/fpu_context.h	(revision e3038b41e1f6e1ef905bbc80916933e18d3e3008)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup ia32	
+/** @addtogroup ia32
  * @{
  */
@@ -38,13 +38,12 @@
 #include <typedefs.h>
 
-#define FPU_CONTEXT_ALIGN 16
-
-void fpu_fxsr(void);
-void fpu_fsr(void);
-
+#define FPU_CONTEXT_ALIGN  16
 
 typedef struct {
-	uint8_t fpu[512]; 		/* FXSAVE & FXRSTOR storage area */
+	uint8_t fpu[512];  /* FXSAVE & FXRSTOR storage area */
 } fpu_context_t;
+
+extern void fpu_fxsr(void);
+extern void fpu_fsr(void);
 
 #endif
Index: kernel/arch/ia32/include/mm/asid.h
===================================================================
--- kernel/arch/ia32/include/mm/asid.h	(revision 22a28a696141d62f28e48ed72d1d255ff519795c)
+++ kernel/arch/ia32/include/mm/asid.h	(revision e3038b41e1f6e1ef905bbc80916933e18d3e3008)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup ia32mm	
+/** @addtogroup ia32mm
  * @{
  */
@@ -47,7 +47,7 @@
 typedef int32_t asid_t;
 
-#define ASID_MAX_ARCH		3
+#define ASID_MAX_ARCH  3
 
-#define asid_get()		(ASID_START + 1)
+#define asid_get()  (ASID_START + 1)
 #define asid_put(asid)
 
Index: kernel/arch/ia32/src/bios/bios.c
===================================================================
--- kernel/arch/ia32/src/bios/bios.c	(revision 22a28a696141d62f28e48ed72d1d255ff519795c)
+++ kernel/arch/ia32/src/bios/bios.c	(revision e3038b41e1f6e1ef905bbc80916933e18d3e3008)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup ia32	
+/** @addtogroup ia32
  * @{
  */
Index: kernel/arch/ia32/src/mm/as.c
===================================================================
--- kernel/arch/ia32/src/mm/as.c	(revision 22a28a696141d62f28e48ed72d1d255ff519795c)
+++ kernel/arch/ia32/src/mm/as.c	(revision e3038b41e1f6e1ef905bbc80916933e18d3e3008)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup ia32mm	
+/** @addtogroup ia32mm
  * @{
  */
Index: kernel/arch/ia32/src/mm/frame.c
===================================================================
--- kernel/arch/ia32/src/mm/frame.c	(revision 22a28a696141d62f28e48ed72d1d255ff519795c)
+++ kernel/arch/ia32/src/mm/frame.c	(revision e3038b41e1f6e1ef905bbc80916933e18d3e3008)
@@ -47,4 +47,7 @@
 #include <print.h>
 
+#define PHYSMEM_LIMIT32  0x07c000000ull
+#define PHYSMEM_LIMIT64  0x200000000ull
+
 size_t hardcoded_unmapped_ktext_size = 0;
 size_t hardcoded_unmapped_kdata_size = 0;
@@ -55,5 +58,5 @@
 {
 	unsigned int i;
-
+	
 	for (i = 0; i < e820counter; i++) {
 		uint64_t base = e820table[i].base_address;
@@ -61,20 +64,59 @@
 		
 #ifdef __32_BITS__
-		/* Ignore physical memory above 4 GB */
-		if ((base >> 32) != 0)
+		/*
+		 * XXX FIXME:
+		 *
+		 * Ignore zones which start above PHYSMEM_LIMIT32
+		 * or clip zones which go beyond PHYSMEM_LIMIT32.
+		 *
+		 * The PHYSMEM_LIMIT32 (2 GB - 64 MB) is a rather
+		 * arbitrary constant which allows to have at
+		 * least 64 MB in the kernel address space to
+		 * map hardware resources.
+		 *
+		 * The kernel uses fixed 1:1 identity mapping
+		 * of the physical memory with 2:2 GB split.
+		 * This is a severe limitation of the current
+		 * kernel memory management.
+		 *
+		 */
+		
+		if (base > PHYSMEM_LIMIT32)
 			continue;
 		
-		/* Clip regions above 4 GB */
-		if (((base + size) >> 32) != 0)
-			size = 0xffffffff - base;
-#endif
-
-		pfn_t pfn;
-		size_t count;
+		if (base + size > PHYSMEM_LIMIT32)
+			size = PHYSMEM_LIMIT32 - base;
+#endif
+		
+#ifdef __64_BITS__
+		/*
+		 * XXX FIXME:
+		 *
+		 * Ignore zones which start above PHYSMEM_LIMIT64
+		 * or clip zones which go beyond PHYSMEM_LIMIT64.
+		 *
+		 * The PHYSMEM_LIMIT64 (8 GB) is the size of the
+		 * fixed 1:1 identically mapped physical memory
+		 * accessible during the bootstrap process.
+		 * This is a severe limitation of the current
+		 * kernel memory management.
+		 *
+		 */
+		
+		if (base > PHYSMEM_LIMIT64)
+			continue;
+		
+		if (base + size > PHYSMEM_LIMIT64)
+			size = PHYSMEM_LIMIT64 - base;
+#endif
 		
 		if (e820table[i].type == MEMMAP_MEMORY_AVAILABLE) {
-			/* To be safe, make available zone possibly smaller */
-			pfn = ADDR2PFN(ALIGN_UP(base, FRAME_SIZE));
-			count = SIZE2FRAMES(ALIGN_DOWN(size, FRAME_SIZE));
+			/* To be safe, make the available zone possibly smaller */
+			uint64_t new_base = ALIGN_UP(base, FRAME_SIZE);
+			uint64_t new_size = ALIGN_DOWN(size - (new_base - base),
+			    FRAME_SIZE);
+			
+			pfn_t pfn = ADDR2PFN(new_base);
+			size_t count = SIZE2FRAMES(new_size);
 			
 			pfn_t conf;
@@ -87,22 +129,26 @@
 			
 			// XXX this has to be removed
-			if (last_frame < ALIGN_UP(base + size, FRAME_SIZE))
-				last_frame = ALIGN_UP(base + size, FRAME_SIZE);
+			if (last_frame < ALIGN_UP(new_base + new_size, FRAME_SIZE))
+				last_frame = ALIGN_UP(new_base + new_size, FRAME_SIZE);
 		}
 		
 		if (e820table[i].type == MEMMAP_MEMORY_RESERVED) {
-			/* To be safe, make reserved zone possibly larger */
-			pfn = ADDR2PFN(ALIGN_DOWN(base, FRAME_SIZE));
-			count = SIZE2FRAMES(ALIGN_UP(size, FRAME_SIZE));
-			
-			zone_create(pfn, count, 0, ZONE_RESERVED);
+			/* To be safe, make the reserved zone possibly larger */
+			uint64_t new_base = ALIGN_DOWN(base, FRAME_SIZE);
+			uint64_t new_size = ALIGN_UP(size + (base - new_base),
+			    FRAME_SIZE);
+			
+			zone_create(ADDR2PFN(new_base), SIZE2FRAMES(new_size), 0,
+			    ZONE_RESERVED);
 		}
 		
 		if (e820table[i].type == MEMMAP_MEMORY_ACPI) {
-			/* To be safe, make firmware zone possibly larger */
-			pfn = ADDR2PFN(ALIGN_DOWN(base, (uintptr_t) FRAME_SIZE));
-			count = SIZE2FRAMES(ALIGN_UP(size, (uintptr_t) FRAME_SIZE));
-			
-			zone_create(pfn, count, 0, ZONE_FIRMWARE);
+			/* To be safe, make the firmware zone possibly larger */
+			uint64_t new_base = ALIGN_DOWN(base, FRAME_SIZE);
+			uint64_t new_size = ALIGN_UP(size + (base - new_base),
+			    FRAME_SIZE);
+			
+			zone_create(ADDR2PFN(new_base), SIZE2FRAMES(new_size), 0,
+			    ZONE_FIRMWARE);
 		}
 	}
@@ -121,9 +167,9 @@
 {
 	unsigned int i;
-	const char *name;
+	printf("[base            ] [size            ] [name   ]\n");
 	
-	printf("[base            ] [size            ] [name\n");
-		
 	for (i = 0; i < e820counter; i++) {
+		const char *name;
+		
 		if (e820table[i].type <= MEMMAP_MEMORY_UNUSABLE)
 			name = e820names[e820table[i].type];
@@ -131,5 +177,5 @@
 			name = "invalid";
 		
-		printf("%#18llx %#18llx %s\n", e820table[i].base_address,
+		printf("%#018" PRIx64 " %#018" PRIx64" %s\n", e820table[i].base_address,
 		    e820table[i].size, name);
 	}
@@ -149,5 +195,5 @@
 		    hardcoded_unmapped_kdata_size));
 #endif
-
+		
 		init_e820_memory(minconf);
 		
Index: kernel/arch/ia32/src/mm/tlb.c
===================================================================
--- kernel/arch/ia32/src/mm/tlb.c	(revision 22a28a696141d62f28e48ed72d1d255ff519795c)
+++ kernel/arch/ia32/src/mm/tlb.c	(revision e3038b41e1f6e1ef905bbc80916933e18d3e3008)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup ia32mm	
+/** @addtogroup ia32mm
  * @{
  */
