Index: arch/amd64/_link.ld
===================================================================
--- arch/amd64/_link.ld	(revision 7ce9284bc15563efd319a02a5e85675909c33208)
+++ arch/amd64/_link.ld	(revision 8fc0d4553a1a8e382979ca225a7ae2d3e376d1a2)
@@ -41,4 +41,3 @@
 	_hardcoded_kdata_size = kdata_end - kdata_start + (unmapped_kdata_end - unmapped_kdata_start);
 	_hardcoded_load_address = 0xffffffff80008000;
-	_ka_start = 0xffffffff80000000;
 }
Index: arch/amd64/include/barrier.h
===================================================================
--- arch/amd64/include/barrier.h	(revision 7ce9284bc15563efd319a02a5e85675909c33208)
+++ arch/amd64/include/barrier.h	(revision 8fc0d4553a1a8e382979ca225a7ae2d3e376d1a2)
@@ -27,6 +27,6 @@
  */
 
-#ifndef __ppc_BARRIER_H__
-#define __ppc_BARRIER_H__
+#ifndef __amd64_BARRIER_H__
+#define __amd64_BARRIER_H__
 
 #define CS_ENTER_BARRIER()	__asm__ volatile ("" ::: "memory")
Index: arch/amd64/include/boot/memmap.h
===================================================================
--- arch/amd64/include/boot/memmap.h	(revision 7ce9284bc15563efd319a02a5e85675909c33208)
+++ arch/amd64/include/boot/memmap.h	(revision 8fc0d4553a1a8e382979ca225a7ae2d3e376d1a2)
@@ -27,6 +27,6 @@
  */
 
-#ifndef __ia32_MEMMAP_H__
-#define __ia32_MEMMAP_H__
+#ifndef __amd64_MEMMAP_H__
+#define __amd64_MEMMAP_H__
 
 
Index: arch/amd64/include/boot/memmapasm.h
===================================================================
--- arch/amd64/include/boot/memmapasm.h	(revision 7ce9284bc15563efd319a02a5e85675909c33208)
+++ arch/amd64/include/boot/memmapasm.h	(revision 8fc0d4553a1a8e382979ca225a7ae2d3e376d1a2)
@@ -27,6 +27,6 @@
  */
 
-#ifndef __ia32_MEMMAPASM_H__
-#define __ia32_MEMMAPASM_H__
+#ifndef __amd64_MEMMAPASM_H__
+#define __amd64_MEMMAPASM_H__
 
 
Index: arch/amd64/include/interrupt.h
===================================================================
--- arch/amd64/include/interrupt.h	(revision 7ce9284bc15563efd319a02a5e85675909c33208)
+++ arch/amd64/include/interrupt.h	(revision 8fc0d4553a1a8e382979ca225a7ae2d3e376d1a2)
@@ -27,6 +27,6 @@
  */
 
-#ifndef __INTERRUPT_H__
-#define __INTERRUPT_H__
+#ifndef __amd64_INTERRUPT_H__
+#define __amd64_INTERRUPT_H__
 
 extern void interrupt(void);
Index: arch/amd64/include/mm/frame.h
===================================================================
--- arch/amd64/include/mm/frame.h	(revision 7ce9284bc15563efd319a02a5e85675909c33208)
+++ arch/amd64/include/mm/frame.h	(revision 8fc0d4553a1a8e382979ca225a7ae2d3e376d1a2)
@@ -32,5 +32,7 @@
 #define FRAME_SIZE		4096
 
+#ifndef __ASM__
 extern void frame_arch_init(void);
+#endif
 
 #endif
Index: arch/amd64/include/mm/page.h
===================================================================
--- arch/amd64/include/mm/page.h	(revision 7ce9284bc15563efd319a02a5e85675909c33208)
+++ arch/amd64/include/mm/page.h	(revision 8fc0d4553a1a8e382979ca225a7ae2d3e376d1a2)
@@ -30,10 +30,19 @@
 #define __amd64_PAGE_H__
 
-#include <mm/page.h>
-#include <arch/mm/frame.h>
-#include <arch/types.h>
-#include <arch/mm/ptl.h>
+#ifndef __ASM__
+#  include <mm/page.h>
+#  include <arch/mm/frame.h>
+#  include <arch/types.h>
+#endif
 
 #define PAGE_SIZE	FRAME_SIZE
+
+#ifndef __ASM__
+# define KA2PA(x)	(((__address) (x)) + 0x80000000)
+# define PA2KA(x)	(((__address) (x)) - 0x80000000)
+#else
+# define KA2PA(x)	((x) + 0x80000000)
+# define PA2KA(x)	((x)) - 0x80000000)
+#endif
 
 #define PTL0_INDEX_ARCH(vaddr)		0
@@ -65,7 +74,9 @@
 #define SET_FRAME_FLAGS_ARCH(ptl3, i, x)
 
+#ifndef __ASM__
 extern void page_arch_init(void);
 
-typedef __u32 pte_t;
+typedef __u64 pte_t;
+#endif
 
 #endif
Index: arch/amd64/include/mm/ptl.h
===================================================================
--- arch/amd64/include/mm/ptl.h	(revision 7ce9284bc15563efd319a02a5e85675909c33208)
+++ arch/amd64/include/mm/ptl.h	(revision 8fc0d4553a1a8e382979ca225a7ae2d3e376d1a2)
@@ -40,7 +40,4 @@
 #define PTL_2MB_PAGE      (1<<7)
 
-#define KA2PA(x)	(((__address) (x)) + 0x80000000)
-#define PA2KA(x)	(((__address) (x)) - 0x80000000)
-
 
 #endif
Index: arch/amd64/include/pm.h
===================================================================
--- arch/amd64/include/pm.h	(revision 7ce9284bc15563efd319a02a5e85675909c33208)
+++ arch/amd64/include/pm.h	(revision 8fc0d4553a1a8e382979ca225a7ae2d3e376d1a2)
@@ -27,10 +27,12 @@
  */
 
-#ifndef __PM_H__
-#define __PM_H__
+#ifndef __amd64_PM_H__
+#define __amd64_PM_H__
 
-#include <arch/types.h>
-#include <typedefs.h>
-#include <arch/context.h>
+#ifndef __ASM__
+# include <arch/types.h>
+# include <typedefs.h>
+# include <arch/context.h>
+#endif
 
 #define IDT_ITEMS 64
@@ -42,5 +44,6 @@
 #define UTEXT_DES	3
 #define UDATA_DES	4
-#define TSS_DES		5
+#define KTEXT32_DES     5
+#define TSS_DES		6
 
 #define selector(des)	((des)<<3)
@@ -61,4 +64,6 @@
 
 #define IO_MAP_BASE	(104)
+
+#ifndef __ASM__
 
 struct ptr_16_32 {
@@ -146,3 +151,5 @@
 extern void tss_initialize(struct tss *t);
 
+#endif /* __ASM__ */
+
 #endif
Index: arch/amd64/src/boot/boot.S
===================================================================
--- arch/amd64/src/boot/boot.S	(revision 7ce9284bc15563efd319a02a5e85675909c33208)
+++ arch/amd64/src/boot/boot.S	(revision 8fc0d4553a1a8e382979ca225a7ae2d3e376d1a2)
@@ -1,4 +1,4 @@
 #
-# Copyright (C) 2001-2004 Jakub Jermar
+# Copyright (C) 2001-2004 Ondrej Palkovsky
 # All rights reserved.
 #
@@ -27,5 +27,9 @@
 #
 
+#define __ASM__
+
+#include <arch/mm/page.h>	
 #include <arch/mm/ptl.h>
+#include <arch/pm.h>
 
 #define START_STACK     0x7c00	
@@ -52,9 +56,9 @@
 #	call memmap_arch_init
 	
-	mov $0x80000000, %eax  
+	movl $0x80000000, %eax  
 	cpuid
 	cmp $0x80000000, %eax 	# any function > 80000000h?
 	jbe no_long_mode
-	mov $0x80000001, %eax	# Extended function code 80000001
+	movl $0x80000001, %eax	# Extended function code 80000001
 	cpuid
 	bt $29, %edx 		# Test if long mode is supported.
@@ -69,5 +73,5 @@
 	movl %eax,%cr0			# switch to protected mode
 
-	jmpl $40, $now_in_prot
+	jmpl $selector(KTEXT32_DES), $now_in_prot
 
 no_long_mode:
@@ -79,5 +83,5 @@
 now_in_prot:  
 	# Set up stack & data descriptors
-	movw $16, %ax
+	movw $selector(KDATA_DES), %ax
 	movw %ax, %ds
 	movw %ax, %fs
@@ -107,5 +111,5 @@
 	
 	# At this point we are in compatibility mode
-	jmpl $8, $start64
+	jmpl $selector(KTEXT_DES), $start64
 
 .code64
@@ -150,9 +154,9 @@
 .global gdtr_inst				
 gdtr_inst:
-	.word 7*8  # GDT_ITEMS * 8
-	.long gdt + 0x80000000
+	.word selector(GDT_ITEMS)
+	.long KA2PA(gdt)
 
 .global idtr_inst
 idtr_inst:
 	.word 0
-	.long idt + 0x80000000
+	.long KA2PA(idt)
