Index: arch/amd64/Makefile.inc
===================================================================
--- arch/amd64/Makefile.inc	(revision 73838ed8e5c99d4b785497a5fa7d0909fded4f9f)
+++ arch/amd64/Makefile.inc	(revision 7df54dfbadf9cb199bd5b3a268869566c733e2bb)
@@ -33,3 +33,4 @@
 	arch/mm/tlb.c \
 	arch/asm_utils.S \
-	arch/fmath.c
+	arch/fmath.c \
+	arch/mm/memory_init.c
Index: arch/amd64/include/cpuid.h
===================================================================
--- arch/amd64/include/cpuid.h	(revision 7df54dfbadf9cb199bd5b3a268869566c733e2bb)
+++ arch/amd64/include/cpuid.h	(revision 7df54dfbadf9cb199bd5b3a268869566c733e2bb)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2001-2004 Ondrej Palkovsky
+ * 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.
+ */
+
+#ifndef __CPUID_H__
+#define __CPUID_H__
+
+#include <arch/types.h>
+
+struct cpu_info {
+	__u32 cpuid_eax;
+	__u32 cpuid_ebx;
+	__u32 cpuid_ecx;
+	__u32 cpuid_edx;
+} __attribute__ ((packed));
+
+extern int has_cpuid(void);
+
+static inline void cpuid(__u32 cmd, cpu_info_t *info)
+{
+	__asm__ (
+		"movl %1, %eax"
+		"cpuid"
+		"movl %eax, 0(%0)"
+		"movl %ebx, 4(%0)"
+		"movl %ecx, 8(%0)"
+		"movl %edx, 12(%0)"
+		: "=m"(info)
+		: "r"(cmd)
+		: "%eax","%ebx","%ecx","%edx"
+		);
+}
+
+extern __u64 rdtsc(void);
+
+#endif
Index: arch/amd64/src/amd64.c
===================================================================
--- arch/amd64/src/amd64.c	(revision 73838ed8e5c99d4b785497a5fa7d0909fded4f9f)
+++ arch/amd64/src/amd64.c	(revision 7df54dfbadf9cb199bd5b3a268869566c733e2bb)
@@ -39,4 +39,5 @@
 
 #include <arch/bios/bios.h>
+#include <arch/mm/memory_init.h>
 
 void arch_pre_mm_init(void)
@@ -65,2 +66,20 @@
 	}
 }
+
+void arch_late_init(void)
+{
+	if (config.cpu_active == 1) {
+		memory_print_map();
+		
+		#ifdef __SMP__
+		acpi_init();
+		#endif /* __SMP__ */
+	}
+}
+
+void calibrate_delay_loop(void)
+{
+	return;
+	i8254_calibrate_delay_loop();
+	i8254_normal_operation();
+}
Index: arch/amd64/src/asm_utils.S
===================================================================
--- arch/amd64/src/asm_utils.S	(revision 73838ed8e5c99d4b785497a5fa7d0909fded4f9f)
+++ arch/amd64/src/asm_utils.S	(revision 7df54dfbadf9cb199bd5b3a268869566c733e2bb)
@@ -44,4 +44,37 @@
 	movq $halt, (%rsp)
 	jmp printf
+
+.global has_cpuid
+.global rdtsc
+
+
+## Determine CPUID support
+#
+# Return 0 in EAX if CPUID is not support, 1 if supported.
+#
+has_cpuid:
+	pushq %rbx
+	
+	pushfq			# store flags
+	popq %rax		# read flags
+	movq %rax,%rbx		# copy flags
+	btcl $21,%ebx		# swap the ID bit
+	pushq %rbx
+	popfq			# propagate the change into flags
+	pushfq
+	popq %rbx		# read flags	
+	andl $(1<<21),%eax	# interested only in ID bit
+	andl $(1<<21),%ebx
+	xorl %ebx,%eax		# 0 if not supported, 1 if supported
+	
+	popq %rbx
+	ret
+
+
+rdtsc:
+	xorq %rax,%rax
+	rdtsc
+	ret
+	
 
 # Push all general purpose registers on stack except %rbp, %rsp
Index: arch/amd64/src/boot/boot.S
===================================================================
--- arch/amd64/src/boot/boot.S	(revision 73838ed8e5c99d4b785497a5fa7d0909fded4f9f)
+++ arch/amd64/src/boot/boot.S	(revision 7df54dfbadf9cb199bd5b3a268869566c733e2bb)
@@ -34,5 +34,5 @@
 
 #define START_STACK     0x7c00	
-#define START_STACK_64  $0xffffffff80007c00
+#define START_STACK_64  0xffffffff80007c00
 					
 #
@@ -52,7 +52,7 @@
 	movw %ax,%ds
 	movw %ax,%ss            # initialize stack segment register
-	movl START_STACK,%esp	# initialize stack pointer
+	movl $(START_STACK),%esp	# initialize stack pointer
 	
-#	call memmap_arch_init
+	call memmap_arch_init
 	
 	movl $0x80000000, %eax  
@@ -117,5 +117,5 @@
 .code64
 start64:
-	movq START_STACK_64, %rsp
+	movq $(START_STACK_64), %rsp
 	
 	call main_bsp   # never returns
Index: ch/amd64/src/boot/memmap.S
===================================================================
--- arch/amd64/src/boot/memmap.S	(revision 73838ed8e5c99d4b785497a5fa7d0909fded4f9f)
+++ 	(revision )
@@ -1,125 +1,0 @@
-/*
- * Copyright (C) 2005 Josef Cejka
- * 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.
- */
-
-
-#include <arch/boot/memmapasm.h>
-
-E820_RECORD_SIZE = MEMMAP_E820_RECORD_SIZE
-E820_MAX_RECORDS = MEMMAP_E820_MAX_RECORDS
-E820_SMAP = 0x534d4150
-
-.global memmap_arch_init
-.global e820counter
-.global e820table
-.global e801memorysize
-
-.code16
-.section K_TEXT_START_2
-
-memmap_arch_init:
-
-e820begin:
-	xorl	%ebx,%ebx	# during first call, ebx must be 0
-	movw	%bx,%ds
-	movw	%bx,%es
-	movw	$e820table,%di
-	movb	$E820_MAX_RECORDS,e820counter
-e820loop:	
-	movl	$E820_SMAP,%edx 	# control sequence "SMAP"
-
-	movl	$0x0000e820,%eax	# service
-	movl	$E820_RECORD_SIZE,%ecx
-	int 	$0x15
-	jc	e820err
-	
-	cmpl	$E820_SMAP,%eax		# verifying BIOS
-	jne	e820err
-
-	cmpl	$E820_RECORD_SIZE,%ecx
-	jne	e820err			# bad record size - bug in bios
-	
-	movw	%di,%ax		# next record
-	addw	$E820_RECORD_SIZE,%ax
-	movw	%ax,%di
-		
-	decb	e820counter # buffer is full
-	jz	e820end
-	
-	cmpl	$0,%ebx	
-	jne	e820loop
-	
-e820end:
-	movb	$E820_MAX_RECORDS,%al
-	subb	e820counter,%al
-	movb	%al,e820counter # store # of valid entries in e820counter
-
-	jmp	e801begin
-
-e820err:
-	movb	$0,e820counter
-
-# method e801 - get size of memory
-
-e801begin:
-	xorw	%dx,%dx
-	xorw	%cx,%cx
-	xorw	%bx,%bx
-	movw	$0xe801,%ax
-	stc
-	int	$0x15
-	
-	jc	e801end
-	
-			# fix problem with some BIOSes which use ax:bx rather than cx:dx
-	testw	%cx,%cx
-	jnz	e801cxdx
-	testw	%dx,%dx
-	jnz	e801cxdx
-
-	movw	%ax,%cx
-	movw	%bx,%dx
-	
-e801cxdx:
-	andl	$0xffff,%edx
-	shll	$6,%edx
-	andl	$0xffff,%ecx
-	addl	%ecx,%edx
-	addl	$0x0400,%edx  # add lower 1 MB - it's not included by e801 method
-	movl	%edx,e801memorysize
-e801end:
-	ret
-
-	#memory size in 1 kb chunks
-e801memorysize:
-	.long 0x0
-
-e820counter:
-	.byte 0x0
-
-e820table:
-	.space  (32*E820_RECORD_SIZE),0x0 # space for 32 records, each E820_RECORD_SIZE bytes long
Index: arch/amd64/src/dummy.s
===================================================================
--- arch/amd64/src/dummy.s	(revision 73838ed8e5c99d4b785497a5fa7d0909fded4f9f)
+++ arch/amd64/src/dummy.s	(revision 7df54dfbadf9cb199bd5b3a268869566c733e2bb)
@@ -35,31 +35,16 @@
 .global cpu_sleep
 .global cpu_print_report
-.global arch_late_init
-.global calibrate_delay_loop
 .global dummy
-.global rdtsc
 .global reset_TS_flag
 .global fpu_init
 	
-.global memory_print_map
-.global get_memory_size
-
-get_memory_size:
-	movq $4*1024*1024, %rax
-	ret
-
-rdtsc:
 before_thread_runs_arch:
 userspace:
-calibrate_delay_loop:
 cpu_identify:
 cpu_arch_init:
 cpu_sleep:
 cpu_print_report:
-arch_late_init:
-calibrate_delay_loop:
 reset_TS_flag:
 fpu_init:
-memory_print_map:	
 	
 dummy:
Index: arch/mips/include/debug.h
===================================================================
--- arch/mips/include/debug.h	(revision 7df54dfbadf9cb199bd5b3a268869566c733e2bb)
+++ arch/mips/include/debug.h	(revision 7df54dfbadf9cb199bd5b3a268869566c733e2bb)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2005 Ondrej Palkovsky
+ * 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.
+ */
+
+#ifndef __mips_DEBUG_H__
+#define __mips_DEBUG_H__
+
+
+
+/**	simulator enters the trace mode */
+#define ___traceon()	asm volatile ( "\t.word\t0x39\n");
+/** 	simulator leaves the trace mode */
+#define ___traceoff()	asm volatile ( "\t.word\t0x3d\n");
+/** 	register dump */
+#define ___regview()	asm volatile ( "\t.word\t0x37\n");
+/** 	halt the simulator */
+#define ___halt()	asm volatile ( "\t.word\t0x28\n");
+/**     simulator enters interactive mode */
+#define ___intmode()	asm volatile ( "\t.word\t0x29\n");
+
+#endif
Index: src/build.amd64
===================================================================
--- src/build.amd64	(revision 73838ed8e5c99d4b785497a5fa7d0909fded4f9f)
+++ src/build.amd64	(revision 7df54dfbadf9cb199bd5b3a268869566c733e2bb)
@@ -5,16 +5,18 @@
 (cd ../arch/amd64/src;make gencontext;./gencontext)
 # Create links to ia32 architecture
-for a in drivers bios; do
-  ln -sf ../../ia32/src/$a ../arch/amd64/src/
-done
-for a in frame.c tlb.c; do
-  ln -sf ../../../ia32/src/mm/$a ../arch/amd64/src/mm
+
+(
+set -e
+cd ../arch
+for a in drivers bios mm/frame.c mm/tlb.c mm/memory_init.c boot/memmap.S; do
+  echo ln -sf `pwd`/ia32/src/$a amd64/src/$a
+  ln -sf `pwd`/ia32/src/$a amd64/src/$a
 done
 
-for a in ega.h i8042.h i8259.h i8254.h cpuid.h interrupt.h bios; do
-  ln -sf ../../ia32/include/$a ../arch/amd64/include/
+for a in ega.h i8042.h i8259.h i8254.h interrupt.h bios mm/memory_init.h; do
+  echo ln -sf `pwd`/ia32/include/$a amd64/include/$a
+  ln -sf `pwd`/ia32/include/$a amd64/include/$a
 done
-ln -sf ../../../ia32/include/mm/memory_init.h ../arch/amd64/include/mm/
-
+)
 make dist-clean ARCH=ia32
 make all ARCH=amd64
Index: src/main/main.c
===================================================================
--- src/main/main.c	(revision 73838ed8e5c99d4b785497a5fa7d0909fded4f9f)
+++ src/main/main.c	(revision 7df54dfbadf9cb199bd5b3a268869566c733e2bb)
@@ -187,5 +187,4 @@
 		panic("can't create kinit thread\n");
 	thread_ready(t);
-
 	/*
 	 * This call to scheduler() will return to kinit,
