Index: kernel/arch/amd64/Makefile.inc
===================================================================
--- kernel/arch/amd64/Makefile.inc	(revision 0637ddb37d7e3d5dd0479648840f57e5a3cce14a)
+++ kernel/arch/amd64/Makefile.inc	(revision 7ba16eb2305f77c05ab9260d09fae55d5c25fa4f)
@@ -93,3 +93,4 @@
 	arch/$(KARCH)/include/arch/istate_struct.ag \
 	arch/$(KARCH)/include/arch/context_struct.ag \
-	arch/$(KARCH)/include/arch/kseg_struct.ag
+	arch/$(KARCH)/include/arch/kseg_struct.ag \
+	arch/$(KARCH)/include/arch/boot/memmap_struct.ag
Index: kernel/arch/amd64/include/arch/boot/memmap_struct.ag
===================================================================
--- kernel/arch/amd64/include/arch/boot/memmap_struct.ag	(revision 7ba16eb2305f77c05ab9260d09fae55d5c25fa4f)
+++ kernel/arch/amd64/include/arch/boot/memmap_struct.ag	(revision 7ba16eb2305f77c05ab9260d09fae55d5c25fa4f)
@@ -0,0 +1,1 @@
+../../../../ia32/include/arch/boot/memmap_struct.ag
Index: kernel/arch/ia32/Makefile.inc
===================================================================
--- kernel/arch/ia32/Makefile.inc	(revision 0637ddb37d7e3d5dd0479648840f57e5a3cce14a)
+++ kernel/arch/ia32/Makefile.inc	(revision 7ba16eb2305f77c05ab9260d09fae55d5c25fa4f)
@@ -110,4 +110,5 @@
 ARCH_AUTOGENS_AG = \
 	arch/$(KARCH)/include/arch/istate_struct.ag \
-	arch/$(KARCH)/include/arch/context_struct.ag
+	arch/$(KARCH)/include/arch/context_struct.ag \
+	arch/$(KARCH)/include/arch/boot/memmap_struct.ag
 
Index: kernel/arch/ia32/include/arch/boot/memmap.h
===================================================================
--- kernel/arch/ia32/include/arch/boot/memmap.h	(revision 0637ddb37d7e3d5dd0479648840f57e5a3cce14a)
+++ kernel/arch/ia32/include/arch/boot/memmap.h	(revision 7ba16eb2305f77c05ab9260d09fae55d5c25fa4f)
@@ -36,4 +36,6 @@
 #define KERN_ia32_MEMMAP_H_
 
+#include <arch/boot/memmap_struct.h>
+
 /* E820h memory range types */
 
@@ -63,10 +65,4 @@
 #include <typedefs.h>
 
-typedef struct {
-	uint64_t base_address;
-	uint64_t size;
-	uint32_t type;
-} __attribute__ ((packed)) e820memmap_t;
-
 extern e820memmap_t e820table[MEMMAP_E820_MAX_RECORDS];
 extern uint8_t e820counter;
Index: kernel/arch/ia32/include/arch/boot/memmap_struct.ag
===================================================================
--- kernel/arch/ia32/include/arch/boot/memmap_struct.ag	(revision 7ba16eb2305f77c05ab9260d09fae55d5c25fa4f)
+++ kernel/arch/ia32/include/arch/boot/memmap_struct.ag	(revision 7ba16eb2305f77c05ab9260d09fae55d5c25fa4f)
@@ -0,0 +1,52 @@
+# Copyright (c) 2016 Jakub Jermar 
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+{
+        name : e820memmap,
+        packed : true,
+
+        includes : [
+                {
+                        include : <typedefs.h>
+                },
+        ],
+
+        members : [
+                {
+                        name : base_address,
+                        type : uint64_t
+                },
+                {
+                        name : size,
+                        type : uint64_t
+                },
+                {
+                        name : type,
+                        type : uint32_t
+                }
+        ]
+}
Index: kernel/arch/ia32/src/boot/multiboot.S
===================================================================
--- kernel/arch/ia32/src/boot/multiboot.S	(revision 0637ddb37d7e3d5dd0479648840f57e5a3cce14a)
+++ kernel/arch/ia32/src/boot/multiboot.S	(revision 7ba16eb2305f77c05ab9260d09fae55d5c25fa4f)
@@ -31,4 +31,5 @@
 #include <abi/asmtool.h>
 #include <arch/boot/boot.h>
+#include <arch/boot/memmap.h>
 #include <arch/mm/page.h>
 #include <arch/pm.h>
@@ -315,5 +316,5 @@
 		/* Check if memory map flag is present */
 		movl (%ebx), %edx
-		andl $(1 << 6), %edx
+		andl $MULTIBOOT_INFO_FLAGS_MMAP, %edx
 		jnz use_multiboot_map
 			
@@ -323,8 +324,8 @@
 		
 		/* Copy address of the memory map to edx */
-		movl 48(%ebx), %edx
+		movl MULTIBOOT_INFO_OFFSET_MMAP_ADDR(%ebx), %edx
 		movl %edx, %ecx
 		
-		addl 44(%ebx), %ecx
+		addl MULTIBOOT_INFO_OFFSET_MMAP_LENGTH(%ebx), %ecx
 		
 		/* Find a free region at least 2M in size */
@@ -332,15 +333,14 @@
 			
 			/* Is this a free region? */
-			cmp $1, 20(%edx)
+			cmpl $MEMMAP_MEMORY_AVAILABLE, MULTIBOOT_MEMMAP_OFFSET_MM_INFO + E820MEMMAP_OFFSET_TYPE(%edx)
 			jnz next_region
 			
 			/* Check size */
-			cmp $0, 16(%edx)
+			cmpl $0, MULTIBOOT_MEMMAP_OFFSET_MM_INFO + E820MEMMAP_OFFSET_SIZE + 4(%edx)
 			jnz next_region
-			
-			cmpl $(2 * 1024 * 1024 + 4 * 1024), 12(%edx)
+			cmpl $(2 * 1024 * 1024 + PAGE_SIZE), MULTIBOOT_MEMMAP_OFFSET_MM_INFO + E820MEMMAP_OFFSET_SIZE(%edx)
 			jbe next_region
 			
-			cmp $0, 8(%edx)
+			cmpl $0, MULTIBOOT_MEMMAP_OFFSET_MM_INFO + E820MEMMAP_OFFSET_BASE_ADDRESS + 4(%edx)
 			jz found_region
 		
@@ -354,6 +354,6 @@
 		next_region_do:
 			
-			addl (%edx), %edx
-			addl $4, %edx
+			addl MULTIBOOT_MEMMAP_OFFSET_SIZE(%edx), %edx
+			addl $MULTIBOOT_MEMMAP_SIZE_SIZE, %edx
 			jmp check_memmap_loop
 			
@@ -361,6 +361,6 @@
 			
 			/* Use end of the found region */
-			mov 4(%edx), %ecx
-			add 12(%edx), %ecx
+			mov MULTIBOOT_MEMMAP_OFFSET_MM_INFO + E820MEMMAP_OFFSET_BASE_ADDRESS(%edx), %ecx
+			add MULTIBOOT_MEMMAP_OFFSET_MM_INFO + E820MEMMAP_OFFSET_SIZE(%edx), %ecx
 			sub $(2 * 1024 * 1024), %ecx
 			mov %ecx, free_area
