Index: corebootv3-via_car/arch/x86/via/stage1.c
===================================================================
--- corebootv3-via_car/arch/x86/via/stage1.c	(Revision 978)
+++ corebootv3-via_car/arch/x86/via/stage1.c	(Arbeitskopie)
@@ -29,6 +29,7 @@
 #include <string.h>
 #include <mtrr.h>
 #include <via_c7.h>
+#include <uart8250.h>
 
 /**
  * Disable Cache As RAM (CAR) after memory is setup.
@@ -53,26 +54,163 @@
 	printk(BIOS_DEBUG, "disable_car global_vars pointer adjusted\n");
 	printk(BIOS_DEBUG, "entering asm code now\n");
 
+#define HALT_AFTER 5
 	__asm__ __volatile__(
+
+	"	movb	$0xC1,	%%al\n"
+	"	outb	%%al,	$0x80\n"
+
 	"	movl	%[newesp], %%esp	\n"
 
-#if ENABLE_BROKEN_CAR_DISABLING
+	"	movb	$0xC3,	%%al\n"
+	"	outb	%%al,	$0x80\n"
+
 	/* We don't need cache as ram for now on */
 	/* disable cache */
 	"	movl    %%cr0, %%eax		\n"
 	"	orl    $(0x1<<30),%%eax		\n"
 	"	movl    %%eax, %%cr0		\n"
 
-	/* The MTRR setup below causes the machine to reset. Must investigate. */
+	"	movb	$0xC4,	%%al\n"
+	"	outb	%%al,	$0x80\n"
+
+	"	movl	$99, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$97, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$99, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$104, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$101, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$32, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$100, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$105, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$115, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$97, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$98, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$108, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$101, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$100, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$10, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+
+	"	movb	$0xC5,	%%al\n"
+	"	outb	%%al,	$0x80\n"
+
+#if HALT_AFTER == 5
+	"	hlt\n"
+#endif
+
 	/* disable fixed mtrr from now on, it will be enabled by coreboot_ram again*/
-	"	movl    %[_SYSCFG_MSR], %%ecx	\n"
-	"	rdmsr				\n"
-	"	andl    %[_SYSCFG_MSR_newval], %%eax\n"
-//	"	andl    $(~(SYSCFG_MSR_MtrrFixDramModEn | SYSCFG_MSR_MtrrFixDramEn)), %%eax\n"
 	/* clear sth */
+	"	xorl    %%eax, %%eax		\n"
+	"	xorl    %%edx, %%edx		\n"
+	"	movl    $0x201, %%ecx		\n"
 	"	wrmsr				\n"
-#warning Must clear MTRR 0x200 and 0x201
+	"	movl    $0x200, %%ecx		\n"
+	"	wrmsr				\n"
 
+	"	movb	$0xC6,	%%al\n"
+	"	outb	%%al,	$0x80\n"
+
+#if HALT_AFTER == 6
+	"	hlt\n"
+#endif
+
+	"	movl	$102, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$105, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$120, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$101, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$100, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$32, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$109, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$116, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$114, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$114, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$32, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$100, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$105, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$115, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$97, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$98, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$108, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$101, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$100, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$10, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+
+	"	movb	$0xC7,	%%al\n"
+	"	outb	%%al,	$0x80\n"
+
+#if HALT_AFTER == 7
+	"	hlt\n"
+#endif
+
 	/* Set the default memory type and disable fixed and enable variable MTRRs */
 	"	movl    %[_MTRRdefType_MSR], %%ecx	\n"
 	"	xorl    %%edx, %%edx		\n"
@@ -80,20 +218,212 @@
 	"	movl    $0x00000800, %%eax	\n"
 	"	wrmsr				\n"
 
+	"	movb	$0xC8,	%%al\n"
+	"	outb	%%al,	$0x80\n"
+
+#if HALT_AFTER == 8
+	"	hlt\n"
+#endif
+
+	"	movl	$118, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$97, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$114, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$105, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$97, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$98, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$108, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$101, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$32, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$109, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$116, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$114, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$114, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$115, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$32, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$101, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$110, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$97, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$98, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$108, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$101, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$100, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$10, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+
+	"	movb	$0xC9,	%%al\n"
+	"	outb	%%al,	$0x80\n"
+
+#if HALT_AFTER == 9
+	"	hlt\n"
+#endif
+
 	/* enable cache */
 	"	movl    %%cr0, %%eax		\n"
 	"	andl    $0x9fffffff,%%eax	\n"
 	"	movl    %%eax, %%cr0		\n"
+
+	"	movb	$0xCA,	%%al\n"
+	"	outb	%%al,	$0x80\n"
+
+#if HALT_AFTER == 10
+	"	hlt\n"
 #endif
 
+	"	movl	$99, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$97, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$99, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$104, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$101, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$32, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$101, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$110, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$97, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$98, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$108, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$101, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$100, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$10, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+
+	"	movb	$0xCB,	%%al\n"
+	"	outb	%%al,	$0x80\n"
+
+#if HALT_AFTER == 11
+	"	hlt\n"
+#endif
+
 	"	wbinvd				\n"
 
+	"	movb	$0xCC,	%%al\n"
+	"	outb	%%al,	$0x80\n"
+
+#if HALT_AFTER == 12
+	"	hlt\n"
+#endif
+
+	"	movl	$119, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$98, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$105, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$110, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$118, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$100, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$32, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$100, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$111, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$110, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$101, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+	"	movl	$10, %%edx\n"
+	"	movl	%[_TTYSx_BASE], %%eax\n"
+	"	call	uart8250_tx_byte\n"
+
+	"	movb	$0xCD,	%%al\n"
+	"	outb	%%al,	$0x80\n"
+
+#if HALT_AFTER == 13
+	"	hlt\n"
+#endif
+
 	"	call stage1_phase3		\n"
 	:: [newesp] "i" (newlocation),
 	 [_SYSCFG_MSR] "i" (SYSCFG_MSR),
 	 [_SYSCFG_MSR_newval] "i" (~(SYSCFG_MSR_MtrrFixDramModEn | SYSCFG_MSR_MtrrFixDramEn)),
 	 [_SYSCFG_MSR_MtrrFixDramModEn] "i" (SYSCFG_MSR_MtrrFixDramModEn),
 	 [_SYSCFG_MSR_MtrrFixDramEn] "i" (SYSCFG_MSR_MtrrFixDramEn),
-	 [_MTRRdefType_MSR] "i" (MTRRdefType_MSR)
+	 [_MTRRdefType_MSR] "i" (MTRRdefType_MSR),
+	 [_TTYSx_BASE] "i" (TTYSx_BASE)
 	: "memory");
 }
