Index: trunk/softs/tests_cc_vcache/Makefile.inc
===================================================================
--- trunk/softs/tests_cc_vcache/Makefile.inc	(revision 520)
+++ trunk/softs/tests_cc_vcache/Makefile.inc	(revision 520)
@@ -0,0 +1,27 @@
+all: test.elf
+
+COMMON= ../common
+LDSCRIPT?= ../common/ldscript
+
+CC= mipsel-unknown-elf-gcc
+LD= mipsel-unknown-elf-ld
+DU= mipsel-unknown-elf-objdump
+
+CFLAGS= -mips32 -nostdinc -I. -I${COMMON} -mno-abicalls
+### LDFLAGS=-mips32 -nostdlib -Wl,-T${LDSCRIPT} -Ttext=0xbfc00000
+
+#### object files generation
+test.o: test.S 
+	${CC} ${CFLAGS} -c -o $@ $<
+	${DU} -D $@ > $@.txt
+
+subr.o: ${COMMON}/subr.S
+	${CC} ${CFLAGS} -c -o $@ $<
+	${DU} -D $@ > $@.txt
+
+### linking : test.o has to be the first object 
+test.elf: test.o subr.o ${EXTRA_OBJ}
+	${LD} -o $@ -T ${LDSCRIPT} -Ttext 0xbfc00000 $^
+	${DU} -D $@ > $@.txt
+clean:
+	rm -f *.o test.elf *.txt run.out temp
Index: trunk/softs/tests_cc_vcache/README
===================================================================
--- trunk/softs/tests_cc_vcache/README	(revision 520)
+++ trunk/softs/tests_cc_vcache/README	(revision 520)
@@ -0,0 +1,46 @@
+This is a very basic framework for running regression tests against
+a mips32+ccvcache TSAR platform. Here's the layout of this directory:
+
+../../../platforms/tsarv4_mono_mmu
+	contains the soclib platform description and simulation executable.
+	It should be compiled before starting tests.
+	it uses the vci_simhelper component, used to stop the simulation
+	with an exit value.  The framework uses this exit status
+	(with other things, see below) to determine if a test
+	is successfull. The simulator will exit with a non-0 exit status
+	after 100000 cycles (and a message to stderr), so the tests are
+	expected to be simple.
+	The platform has a tty, which is redirected to a file along with
+	the simlulator's output. The test framework may search for specific
+	strings in this file to determine if a test was successfull.
+common/
+	Some common functions, ldscripts, etc ... used by the tests.
+	It has a subr.S which holds usefull subroutines, such as
+	print() and printx().
+Makefile.inc
+	included from the test's Makefiles. Basic stuff to compile a
+	mips32 ELF executable for a test. It expects a test.S,
+	add the subr.S from common and eventually additionnal object
+	files.
+test_*/
+	these directories holds the test themselves. They have a run
+	script which does what is needed to compile and run a test,
+	print "test failed" or "test passed" on stdout, and clean the
+	directory if it's successfull. A sample script will call
+	make, then run the simulator with srdout/stderr redirected
+	to a file. If the simulator exists with a 0 status, this
+	script search for some strings in the output (that the
+	test program would have printed). This is an additionnal way
+	to check that all worked properly.
+	Tests are written in assembly; as we're testing for very specific
+	conditions (such as an instruction in a branch's delay slot on
+	a page boundary), we don't want the compiler to optimise things
+	or otherwise reorder instructions.
+	If the test was successfull, the 'run' script cleanups the
+	directory. Otherwise the 'run.out' file is available to
+	start looking at what's wrong.
+run_tests
+	runs all the test_*/run scripts - the goal being that
+	all of them print "test passsed" :). Directories are explicitely
+	listed in the run_tests script (order does matter to have a readable
+	output)
Index: trunk/softs/tests_cc_vcache/common/common.sh
===================================================================
--- trunk/softs/tests_cc_vcache/common/common.sh	(revision 520)
+++ trunk/softs/tests_cc_vcache/common/common.sh	(revision 520)
@@ -0,0 +1,3 @@
+SIMUL=../../../platforms/tsar_mono_mmu/simul.x
+
+#SIMUL=../../../../soclib-svn-june-2009/soclib/soclib/platform/topcells/caba_vgsb_almo_mmu/simul.x
Index: trunk/softs/tests_cc_vcache/common/ldscript
===================================================================
--- trunk/softs/tests_cc_vcache/common/ldscript	(revision 520)
+++ trunk/softs/tests_cc_vcache/common/ldscript	(revision 520)
@@ -0,0 +1,65 @@
+/*
+ *
+ * SOCLIB_GPL_HEADER_BEGIN
+ * 
+ * This file is part of SoCLib, GNU GPLv2.
+ * 
+ * SoCLib is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ * 
+ * SoCLib is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with SoCLib; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ * 
+ * SOCLIB_GPL_HEADER_END
+ *
+ * Copyright (c) UPMC, Lip6, SoC
+ *         Nicolas Pouillon <nipo@ssji.net>, 2006-2007
+ *
+ * Maintainers: abdelmalek.si-merabet@lip6.fr
+ */
+
+ENTRY(_start)
+
+SECTIONS
+{
+   . = 0xbfc00000;
+   .text : {
+      *(.text)
+   }
+   .rodata : {
+      *(.rodata)
+      . = ALIGN(4);
+   }
+   . = 0x00000000;
+   .data  : {
+      *(.data)
+   }
+   .sdata : {
+      *(.lit8)
+      *(.lit4)
+      *(.sdata)
+   }
+   _gp = .;
+   . = ALIGN(4);
+   _edata = .;
+   .sbss  : {
+      *(.sbss)
+      *(.scommon)
+   }
+   .bss   : {
+      *(.bss)
+      *(COMMON)
+   }
+   . = ALIGN(4);
+   _end = .;
+   _heap = .;
+   _stack = 0x00400000-16;
+}
Index: trunk/softs/tests_cc_vcache/common/misc.h
===================================================================
--- trunk/softs/tests_cc_vcache/common/misc.h	(revision 520)
+++ trunk/softs/tests_cc_vcache/common/misc.h	(revision 520)
@@ -0,0 +1,56 @@
+/* multi-tty definitions */
+#define TTY_BASE 0xd0200000
+#define TTY_WRITE  0
+#define TTY_STATUS 1
+#define TTY_READ 2
+
+/* vci_exit definitions */
+#define EXIT_BASE 0xe0000000
+
+#define BOOT_ADDRESS 0xbfc00000
+#define EXCEP_ADDRESS 0xbfc00380
+
+/* vci dma */
+#define DMA_BASE 	0xe8000000
+#define DMA_SRC  	0
+#define DMA_DST  	4
+#define DMA_LEN  	8
+#define DMA_RESET	12
+
+/* cop0 definitions */
+#define COP_0_BADVADDR	$8
+#define COP0_STATUS	$12
+#define COP0_CAUSE	$13
+#define COP0_EXPC	$14
+
+/* easy print macros */
+#define PRINT(str) \
+        la      a0, str;\
+	jal     print; \
+	nop
+
+#define PRINT_SYNC(str) \
+        la      a0, str;\
+	jal     print_sync; \
+	nop
+
+
+
+#define PRINTX \
+	jal     printx;\
+	nop
+
+#define PUTCHAR(c) li a0, c; sb a0, 0(k0)
+
+#define EXIT(a) \
+	li a0, a; \
+	sw a0, 4(k1); \
+	1:      j 1b; \
+	nop
+
+/* some magic numers to test */
+#define MAGIC1	0xdead
+#define MAGIC2	0xbeef
+#define MAGIC3	0x900d
+#define MAGIC4	0xf00d
+
Index: trunk/softs/tests_cc_vcache/common/registers.h
===================================================================
--- trunk/softs/tests_cc_vcache/common/registers.h	(revision 520)
+++ trunk/softs/tests_cc_vcache/common/registers.h	(revision 520)
@@ -0,0 +1,32 @@
+#define zero	$0
+#define at	$at
+#define v0	$2
+#define v1	$3
+#define a0	$4
+#define a1	$5
+#define a2	$6
+#define a3	$7
+#define t0	$8
+#define t1	$9
+#define t2	$10
+#define t3	$11
+#define t4	$12
+#define t5	$13
+#define t6	$14
+#define t7	$15
+#define s0	$16
+#define s1	$17
+#define s2	$18
+#define s3	$19
+#define s4	$20
+#define s5	$21
+#define s6	$22
+#define s7	$23
+#define t8	$24
+#define t9	$25
+#define k0	$26
+#define k1	$27
+#define gp	$28
+#define sp	$29
+#define fp	$30
+#define ra	$31
Index: trunk/softs/tests_cc_vcache/common/subr.S
===================================================================
--- trunk/softs/tests_cc_vcache/common/subr.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/common/subr.S	(revision 520)
@@ -0,0 +1,78 @@
+#include <registers.h>
+/* test common subroutines
+
+	.text
+/*
+ * void print(char *): print a string to the multitty.
+ * assumes k0 points to the tty base.
+ */
+	.globl print
+print:
+	.set noreorder
+	move	t0, a0
+1:
+	lb	t1, 0(t0);
+	beq	t1, zero, end
+	nop
+	sb	t1, 0(k0)
+	addiu	t0, t0, 1
+	j	1b
+	nop
+end:
+	jr	ra
+	nop
+
+/*
+ * void print_sync(char *): print a string to the multitty with a sync instruction for each character.
+ * assumes k0 points to the tty base.
+ */
+	.globl print_sync
+print_sync:
+	.set noreorder
+	move	t0, a0
+1:
+	lb	t1, 0(t0);
+	beq	t1, zero, end_print_sync
+	nop
+	sb	t1, 0(k0)
+    sync
+	addiu	t0, t0, 1
+	j	1b
+	nop
+end_print_sync:
+	jr	ra
+	nop
+
+
+/*
+ * void printx(uint32_t): print a number in hex to the multitty
+ * assumes points to the tty base.
+ */
+	.globl printx
+printx:
+	.set noreorder
+	move	t0, a0
+	li	t1, '0'
+	sb	t1, 0(k0)
+	li	t1, 'x'
+	sb	t1, 0(k0)
+	li	t1, 8
+1:
+	lui	t2, 0xf000;
+	and	t2, t0, t2
+	srl	t2, t2, 28
+	slti	t3, t2, 0xa
+	beq	t3, zero, 2f /* in range A-F */
+	nop
+	addi	t2, t2, '0'
+	j	3f
+	nop
+2:
+	addi    t2, t2, 'A' - 0xa
+3:
+	sb      t2, 0(k0)
+	addi	t1, t1, -1
+	bgtz	t1, 1b
+	sll	t0, t0, 4
+	jr	ra
+	nop
Index: trunk/softs/tests_cc_vcache/common/vcache.h
===================================================================
--- trunk/softs/tests_cc_vcache/common/vcache.h	(revision 520)
+++ trunk/softs/tests_cc_vcache/common/vcache.h	(revision 520)
@@ -0,0 +1,66 @@
+/* cop2/vcache definitions */
+#define VC_PTPR			$0 		/* set Page Table Pointer Register */
+#define VC_TLB_EN		$1 		/* set Data & Inst TLBs Mode Register */
+#define	  VC_TLB_EN_ITLB		0x8 	/* enable instruction TLB */
+#define	  VC_TLB_EN_DTLB		0x4 	/* enable data TLB */
+#define	  VC_TLB_EN_ICACHE		0x2 	/* enable instruction cache */
+#define	  VC_TLB_EN_DCACHE		0x1 	/* enable data cache */
+#define VC_ICACHE_FLUSH 	$2 		/* Instruction Cache flush */
+#define VC_DCACHE_FLUSH 	$3 		/* Data Cache flush */
+#define VC_ITLB_INVAL		$4 		/* Instruction TLB line invalidate */
+#define VC_DTLB_INVAL		$5 		/* Data TLB line invalidate */
+#define VC_ICACHE_INVAL 	$6 		/* Instruction Cache line invalidate */
+#define VC_DCACHE_INVAL 	$7 		/* Data Cache line invalidate */
+#define VC_ICACHE_PREFETCH 	$8 		/* Instruction Cache line prefetch */
+#define VC_DCACHE_PREFETCH 	$9 		/* Data Cache line prefetch */
+#define VC_SYNC			$10 		/* Complete pending writes */
+#define VC_IERR_TYPE		$11 		/* Instruction Exception type Register */
+#define VC_DERR_TYPE		$12 		/* Data Exception type Register */
+#define VC_DATA_LO		$17 		/* misc register low */
+#define VC_DATA_HI		$18 		/* misc register hight */
+#define VC_ICACHE_INVAL_PA 	$19 		/* misc register hight */
+#define VC_DCACHE_INVAL_PA 	$20 		/* misc register hight */
+#define	  VC_ERR_PT1_UNMAPPED		0x001 	/* Page fault on Table1 (invalid PTE) */
+#define	  VC_ERR_PT2_UNMAPPED		0x002 	/* Page fault on Table 2 (invalid PTE) */
+#define	  VC_ERR_PRIVILEGE_VIOLATION	0x004 	/* Protected access in user mode */
+#define	  VC_ERR_WRITE_VIOLATION	0x008 	/* Write access to a non write page */
+#define	  VC_ERR_EXEC_VIOLATION		0x010 	/* Exec access to a non exec page */
+#define	  VC_ERR_UNDEFINED_XTN		0x020 	/* Undefined external access address */
+#define	  VC_ERR_PT1_ILLEGAL_ACCESS	0x040 	/* Bus Error in Table1 access */
+#define	  VC_ERR_PT2_ILLEGAL_ACCESS	0x080 	/* Bus Error in Table2 access */
+#define	  VC_ERR_CACHE_ILLEGAL_ACCESS	0x100 	/* Bus Error during the cache access */
+#define VC_I_BAD_VADDR		$13 		/* Instruction Bad Virtual Address Register */
+#define VC_D_BAD_VADDR		$14 		/* Data Bad Virtual Address Register */
+#define VC_DATA_L		$17 		/* cache parameters */
+#define VC_DATA_H		$18 		/* cache parameters */
+#define VC_ICACHE_INVAL_PA	$19 		/* icache inval per physical address */
+#define VC_DCACHE_INVAL_PA	$20 		/* dcache inval per physical address */
+
+/* vcache page level 1 format */
+#define PTE1_V  (1 << 31)       		/* entry valid */
+#define PTE1_T  (1 << 30)       		/* 0 == entry is a PTE1 (maps a 2M page) */
+#define PTE1_L  (1 << 29)       		/* accessed by local CPU */
+#define PTE1_R  (1 << 28)       		/* accessed by remote CPU */
+#define PTE1_C  (1 << 27)       		/* cachable */
+#define PTE1_W  (1 << 26)       		/* writable */
+#define PTE1_X  (1 << 25)       		/* executable */
+#define PTE1_U  (1 << 24)       		/* user-accessible */
+#define PTE1_G  (1 << 23)       		/* global */
+#define PTE1_D  (1 << 22)       		/* dirty */
+
+/* vcache page level 2 format: same as level 1, PTE1_T  */
+#define PTE2_V  (1 << 31)       		/* entry valid */
+						/* reserved, 0 */
+#define PTE2_L  (1 << 29)       		/* accessed by local CPU */
+#define PTE2_R  (1 << 28)       		/* accessed by remote CPU */
+#define PTE2_C  (1 << 27)       		/* cachable */
+#define PTE2_W  (1 << 26)       		/* writable */
+#define PTE2_X  (1 << 25)       		/* executable */
+#define PTE2_U  (1 << 24)       		/* user-accessible */
+#define PTE2_G  (1 << 23)       		/* global */
+#define PTE2_D  (1 << 22)       		/* dirty */
+#define PTE2_os 0xff				/* OS-reserved bits */
+
+#define PTE2_SHIFT 	12
+#define PTE2_MASK 	0x0001ff000
+#define VADDR_TO_PTE2I(va) (((va) & PTE2_MASK) >> PTE2_SHIFT)
Index: trunk/softs/tests_cc_vcache/common/xicu.h
===================================================================
--- trunk/softs/tests_cc_vcache/common/xicu.h	(revision 520)
+++ trunk/softs/tests_cc_vcache/common/xicu.h	(revision 520)
@@ -0,0 +1,96 @@
+#define XICU_BASE 0xd8200000
+#define __XICU_FUNC_SHIFT 7
+#define __XICU_IDX_SHIFT 2
+#define __XICU_RIDX(func, idx) \
+    ((((func) & 0x1f) << __XICU_FUNC_SHIFT) + \
+     (((idx) & 0x1f) << __XICU_IDX_SHIFT))
+
+/* triggers the wtiidx interrupt. R/W */
+#define XICU_WTI_REG_FUNC 0x00
+#define XICU_WTI_REG(wtiidx) __XICU_RIDX(XICU_WTI_REG_FUNC, wtiidx)
+
+/* Timer period R/W */
+#define XICU_PTI_PER_FUNC 0x01
+#define XICU_PTI_PER(ptiidx) __XICU_RIDX(XICU_PTI_PER_FUNC, ptiidx)
+
+/* timer value R/W */
+#define XICU_PTI_VAL_FUNC 0x02
+#define XICU_PTI_VAL(ptiidx) __XICU_RIDX(XICU_PTI_VAL_FUNC, ptiidx)
+
+/* Timer interrupt acknowledge. R */
+#define XICU_PTI_ACK_FUNC 0x03
+#define XICU_PTI_ACK(ptiidx) __XICU_RIDX(XICU_PTI_ACK_FUNC, ptiidx)
+
+/*
+ * remaining registers define the way interrupt sources are mutiplexed to
+ * the output lines. Indexed by output line number.
+ */
+/*
+ * Multiplex timers to output lines:
+ * XICU_MSK_PTI mask register for outidx line (bit to 1 enable interrupt)
+ * XICU_MSK_PTI_E atomically add a set of bits to XICU_MSK_PTI
+ * XICU_MSK_PTI_D atomically clear a set of bits from XICU_MSK_PTI
+ * XICU_PTI_ACT get active PTI lines for this output line
+ */
+#define XICU_MSK_PTI_FUNC 0x04 /* R/W */
+#define XICU_MSK_PTI(outidx) __XICU_RIDX(XICU_MSK_PTI_FUNC, outidx)
+
+#define XICU_MSK_PTI_E_FUNC 0x05 /* W */
+#define XICU_MSK_PTI_E(outidx) __XICU_RIDX(XICU_MSK_PTI_E_FUNC, outidx)
+
+#define XICU_MSK_PTI_D_FUNC 0x06 /* W */
+#define XICU_MSK_PTI_D(outidx) __XICU_RIDX(XICU_MSK_PTI_D_FUNC, outidx)
+
+#define XICU_PTI_ACT_FUNC 0x06 /* R */
+#define XICU_PTI_ACT(outidx) __XICU_RIDX(XICU_PTI_ACT_FUNC, outidx)
+
+/*
+ * Multiplex hardware input lines to output lines:
+ * XICU_MSK_HWI mask register for outidx line (bit to 1 enable interrupt)
+ * XICU_MSK_HWI_E atomically add a set of bits to XICU_MSK_HWI
+ * XICU_MSK_HWI_D atomically clear a set of bits from XICU_MSK_HWI
+ * XICU_HWI_ACT get active HWI lines for this output line
+ */
+#define XICU_MSK_HWI_FUNC 0x08 /* R/W */
+#define XICU_MSK_HWI(outidx) __XICU_RIDX(XICU_MSK_HWI_FUNC, outidx)
+
+#define XICU_MSK_HWI_E_FUNC 0x09 /* W */
+#define XICU_MSK_HWI_E(outidx) __XICU_RIDX(XICU_MSK_HWI_E_FUNC, outidx)
+
+#define XICU_MSK_HWI_D_FUNC 0x0a /* W */
+#define XICU_MSK_HWI_D(outidx) __XICU_RIDX(XICU_MSK_HWI_D_FUNC, outidx)
+
+#define XICU_HWI_ACT_FUNC 0x0a /* R */
+#define XICU_HWI_ACT(outidx) __XICU_RIDX(XICU_HWI_ACT_FUNC, outidx)
+
+/*
+ * Multiplex hardware input lines to output lines:
+ * XICU_MSK_WTI mask register for outidx line (bit to 1 enable interrupt)
+ * XICU_MSK_WTI_E atomically add a set of bits to XICU_MSK_WTI
+ * XICU_MSK_WTI_D atomically clear a set of bits from XICU_MSK_WTI
+ * XICU_WTI_ACT get active WTI lines for this output line
+ */
+#define XICU_MSK_WTI_FUNC 0x0c /* R/W */
+#define XICU_MSK_WTI(outidx) __XICU_RIDX(XICU_MSK_WTI_FUNC, outidx)
+
+#define XICU_MSK_WTI_E_FUNC 0x0d /* W */
+#define XICU_MSK_WTI_E(outidx) __XICU_RIDX(XICU_MSK_WTI_E_FUNC, outidx)
+
+#define XICU_MSK_WTI_D_FUNC 0x0e /* W */
+#define XICU_MSK_WTI_D(outidx) __XICU_RIDX(XICU_MSK_WTI_D_FUNC, outidx)
+
+#define XICU_WTI_ACT_FUNC 0x0e /* R */
+#define XICU_WTI_ACT(outidx) __XICU_RIDX(XICU_WTI_ACT_FUNC, outidx)
+
+/* source priority encoder for outpout lines */
+#define XICU_PRIO_FUNC 0x0f
+#define XICU_PRIO(outidx) __XICU_RIDX(XICU_PRIO_FUNC, outidx)
+
+#define XICU_PRIO_PTI 0x00000001 /* Timer interrrupt pending */
+#define XICU_PRIO_PTII(val) ((val) >> 8 & 0x1f) /* first PTI pending */
+#define XICU_PRIO_HWI 0x00000002 /* Hardware interrrupt pending */
+#define XICU_PRIO_HWII(val) ((val) >> 16 & 0x1f) /* first HWI pending */
+#define XICU_PRIO_WTI 0x00000004 /* write-triggered interrrupt pending */
+#define XICU_PRIO_WTII(val) ((val) >> 24 & 0x1f) /* first WTI pending */
+
+#define XICU_PRIO_PENDING (XICU_PRIO_PTI|XICU_PRIO_HWI|XICU_PRIO_WTI)
Index: trunk/softs/tests_cc_vcache/run_tests
===================================================================
--- trunk/softs/tests_cc_vcache/run_tests	(revision 520)
+++ trunk/softs/tests_cc_vcache/run_tests	(revision 520)
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+PATH=${PATH}:/dsk/l1/misc/bouyer/tmp/tsarmips/obj/netbsd-5/tooldir/bin
+export PATH
+SOCLIB_TTY=TERM
+export SOCLIB_TTY
+
+for dir in test_sanity test_exceptions test_mmu_basic \
+   test_excep_ls test_excep_ls_delayslot test_excep_ls_llsc \
+   test_excep_if test_excep_if_delayslot test_excep_if_llsc \
+   test_exception_epc_modify	\
+   test_dtlb_inval test_dtlb_inval2 test_dtlb_inval3 \
+   test_itlb_inval test_itlb_inval2 \
+   test_idtlb_inval test_idtlb_inval2 test_idtlb_inval3 test_idtlb_inval4 \
+   test_dtlb_ptprinval test_itlb_ptprinval test_idtlb_ptprinval \
+   test_sync \
+   test_llsc test_sc_no_ll test_sc_update_cache test_pte_llsc \
+   test_interrupt \
+   test_interrupt_epc_modify \
+   test_xicu_timer \
+   test_interrupt_delayslot \
+   test_interrupt_mask \
+   test_interrupt_external_mask \
+   test_excep_cop test_excep_cop_delayslot test_excep_cop1 \
+   test_syscall test_syscall_delayslot \
+   test_breakpoint test_breakpoint_delayslot \
+   test_ri test_ri_delayslot \
+   test_ao test_ao_delayslot \
+   test_trap test_trap_delayslot \
+   test_dcache_inval_pa test_icache_inval_pa \
+   test_pte2i_ref test_pte2lw_ref test_pte2ll_ref test_pte2sw_dirty test_pte2sc_dirty \
+   test_dma_basic test_dma_unaligned \
+   ; do
+	echo -n ${dir}": "
+	(cd $dir && ./run)
+done
Index: trunk/softs/tests_cc_vcache/test_ao/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_ao/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_ao/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_ao/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_ao/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_ao/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^status 0x00400002 cause 0x00000030 pc 0xBFC00034 badva 0x00000000$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 1 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_ao/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_ao/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_ao/test.S	(revision 520)
@@ -0,0 +1,63 @@
+/*
+ * arithmetic overflow test: check that a add can generates an exception
+ */
+#include <registers.h>
+#include <misc.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+	la	sp, 0x00400000 - 16
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+	la	a0, 0x7fffffff
+	li	a1, 0x02
+	add	a0, a0, a1
+	EXIT(2)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+	PUTCHAR('\n')
+#we should end there
+	EXIT(0)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+startstr: .ascii "start\n\0"
+usrstr: .ascii "usrmode\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+	.data
+	.word MAGIC1
+testval:
+	.word MAGIC2
Index: trunk/softs/tests_cc_vcache/test_ao_delayslot/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_ao_delayslot/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_ao_delayslot/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_ao_delayslot/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_ao_delayslot/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_ao_delayslot/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^status 0x00400002 cause 0x80000030 pc 0xBFC00034 badva 0x00000000$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 1 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_ao_delayslot/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_ao_delayslot/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_ao_delayslot/test.S	(revision 520)
@@ -0,0 +1,84 @@
+/*
+ * arithmetic overflow test: check that a overflow in a delay slot is
+ * properly handled
+ */
+#include <registers.h>
+#include <misc.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+	la	sp, 0x00400000 - 16
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+	la	a0, 0x7fffffff
+	li	a1, 0x02
+	j	exit
+	add	a0, a0, a1
+	/* we should not get there, */
+	EXIT(2)
+	.globl exit
+exit:
+	move	a0, v0
+	PRINTX
+	PUTCHAR(' ')
+	move	a0, v1
+	PRINTX
+	PUTCHAR('\n')
+	/* we should get there */
+	EXIT(0)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+	PUTCHAR('\n')
+	la	a0, exit
+	mtc0	a0, COP0_EXPC
+	li	v0, MAGIC1
+	li	v1, MAGIC2
+	li	a3, 1
+	eret
+	nop
+
+#we should not end there
+	EXIT(1)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+startstr: .ascii "start\n\0"
+usrstr: .ascii "usrmode\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+	.data
+	.word MAGIC1
+testval:
+	.word MAGIC2
Index: trunk/softs/tests_cc_vcache/test_breakpoint/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_breakpoint/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_breakpoint/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_breakpoint/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_breakpoint/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_breakpoint/run	(revision 520)
@@ -0,0 +1,33 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^status 0x00400002 cause 0x00000024 pc 0xBFC00034 badva 0x00000000$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 1 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	egrep "^0x0000DEAD 0x0000BEEF$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 2 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_breakpoint/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_breakpoint/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_breakpoint/test.S	(revision 520)
@@ -0,0 +1,86 @@
+/*
+ * breakpoint test: check that a breakpoint generates an exception, and we can
+ * return 
+ */
+#include <registers.h>
+#include <misc.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+	la	sp, 0x00400000 - 16
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+	nop
+	nop
+	nop
+	break
+	bne a3, zero, exit
+	nop
+	/* we should not get there, a3 is not 0 */
+	EXIT(2)
+exit:
+	move	a0, v0
+	PRINTX
+	PUTCHAR(' ')
+	move	a0, v1
+	PRINTX
+	PUTCHAR('\n')
+	/* we should get there */
+	EXIT(0)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+	PUTCHAR('\n')
+	mfc0	a0, COP0_EXPC
+	addiu	a0, a0, 4
+	mtc0	a0, COP0_EXPC
+	li	v0, MAGIC1
+	li	v1, MAGIC2
+	li	a3, 1
+	eret
+	nop
+
+#we should not end there
+	EXIT(1)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+startstr: .ascii "start\n\0"
+usrstr: .ascii "usrmode\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+	.data
+	.word MAGIC1
+testval:
+	.word MAGIC2
Index: trunk/softs/tests_cc_vcache/test_breakpoint_delayslot/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_breakpoint_delayslot/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_breakpoint_delayslot/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_breakpoint_delayslot/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_breakpoint_delayslot/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_breakpoint_delayslot/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^status 0x00400002 cause 0x80000024 pc 0xBFC00034 badva 0x00000000$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 1 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_breakpoint_delayslot/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_breakpoint_delayslot/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_breakpoint_delayslot/test.S	(revision 520)
@@ -0,0 +1,85 @@
+/*
+ * breakpoint test: check that a breakpoint in a delay slot is properly handled
+ */
+#include <registers.h>
+#include <misc.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+	la	sp, 0x00400000 - 16
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+	nop
+	nop
+	nop
+	j	exit
+	break
+	nop
+	/* we should not get there, */
+	EXIT(2)
+	.globl exit
+exit:
+	move	a0, v0
+	PRINTX
+	PUTCHAR(' ')
+	move	a0, v1
+	PRINTX
+	PUTCHAR('\n')
+	/* we should get there */
+	EXIT(0)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+	PUTCHAR('\n')
+	la	a0, exit
+	mtc0	a0, COP0_EXPC
+	li	v0, MAGIC1
+	li	v1, MAGIC2
+	li	a3, 1
+	eret
+	nop
+
+#we should not end there
+	EXIT(1)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+startstr: .ascii "start\n\0"
+usrstr: .ascii "usrmode\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+	.data
+	.word MAGIC1
+testval:
+	.word MAGIC2
Index: trunk/softs/tests_cc_vcache/test_dcache_inval_pa/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_dcache_inval_pa/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_dcache_inval_pa/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_dcache_inval_pa/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_dcache_inval_pa/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_dcache_inval_pa/run	(revision 520)
@@ -0,0 +1,38 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^mmu started before DMA 0x0000BEEF$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 1 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	egrep "^mmu started after DMA 0x0000F00D$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 2 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	egrep "^mmu started after FLUSH 0x0000F00D$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 3 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_dcache_inval_pa/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_dcache_inval_pa/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_dcache_inval_pa/test.S	(revision 520)
@@ -0,0 +1,136 @@
+/*
+ * cache inval test: check that VC_DCACHE_INVAL_PA does the job
+ * on a cc_vcache, the cache invalidation/update should be done by hardware
+ * and VC_DCACHE_INVAL_PA should not be needed.
+ */
+#include <registers.h>
+#include <misc.h>
+#include <vcache.h>
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+
+	la	a0, pte1_a
+	srl	a0, a0, 13
+	mtc2	a0, VC_PTPR
+	nop
+
+	li	a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
+	mtc2 	a0, VC_TLB_EN
+
+	PRINT(mmustr_a)
+	la	t0, testval
+	lw 	a0, 0(t0);
+	PRINTX
+	PUTCHAR('\n')
+	la	a1, DMA_BASE
+	la	a0, testval2
+	sw	a0, DMA_SRC(a1)
+	la	a0, testval
+	sw	a0, DMA_DST(a1)
+	li	a0, 4
+	sw	a0, DMA_LEN(a1) /* start DMA */
+loop:
+	lw	a0, DMA_LEN(a1)
+	bne	a0, zero, loop;
+	nop
+
+	PRINT(mmustr_b)
+	la	t0, testval
+	lw 	a0, 0(t0);
+	PRINTX
+	PUTCHAR('\n')
+
+	la      a0, testval
+	mtc2	a0, VC_DATA_LO
+	mtc2	zero, VC_DATA_HI
+	mtc2	zero, VC_DCACHE_INVAL_PA
+	nop
+
+	PRINT(mmustr_c)
+	la	t0, testval
+	lw 	a0, 0(t0);
+	PRINTX
+	PUTCHAR('\n')
+
+	/* we should get there */
+	EXIT(0)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PUTCHAR('\n')
+	/* we should not get there */
+	EXIT(3)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+mmustr_a: .ascii "mmu started before DMA \0"
+mmustr_b: .ascii "mmu started after DMA \0"
+mmustr_c: .ascii "mmu started after FLUSH \0"
+startstr: .ascii "start\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+
+	.data
+data_a:
+	.word MAGIC1
+testval:
+	.word MAGIC2
+data_b:
+	.word MAGIC3
+testval2:
+	.word MAGIC4
+	.globl pte2_a
+
+pte2_a:
+	.align 12
+	.word PTE2_V | PTE2_C | PTE2_X
+	.word 0x0000 >> 12 /* check real value of data_a */
+	.org pte2_a + 4092
+	.word 0
+	.globl pte1_a
+pte1_a:
+	.align 13
+	.word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */
+	.word PTE1_V | PTE1_T | (0x2000 >> 12) /* map PA 0x0 at VA 0x00200000 via pte2_a */
+	.org pte1_a + (BOOT_ADDRESS >> 21) * 4
+	.word PTE1_V | PTE1_C | PTE1_X | (BOOT_ADDRESS >> 21) /* map PA 0xbfc00000 at VA 0xbfc00000 */
+	.org pte1_a + (TTY_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
+	.org pte1_a + (EXIT_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
+	.org pte1_a + (DMA_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (DMA_BASE >> 21) /* map PA 0xe8000000 at VA 0xe0000000 */
Index: trunk/softs/tests_cc_vcache/test_dma_basic/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_dma_basic/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_dma_basic/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_dma_basic/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_dma_basic/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_dma_basic/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^after DMA 0x0000F00D 0x0000F00D 0x0000BEEF 0x0000DEAD 0x0000DEAD$" run.out > /dev/null
+	if [ $? -eq 0 ]; then
+		return 0;
+	fi
+	echo "couldn't find string in output - mtty not working ?" >> run.out
+	return 1
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_dma_basic/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_dma_basic/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_dma_basic/test.S	(revision 520)
@@ -0,0 +1,135 @@
+/*
+ * basic DMA check: check that the DMA engine works and and doens't
+ * clobbers memory
+ */
+#include <registers.h>
+#include <misc.h>
+#include <vcache.h>
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	PRINT(mmustr_a)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+
+	la	t0, testval
+	lw 	a0, 0(t0);
+	PRINTX
+	PUTCHAR(' ')
+	la	t0, testval2
+	lw 	a0, 0(t0);
+	PRINTX
+	PUTCHAR('\n')
+	la	t0, testval
+	la	t1, testval3
+	lw 	a0, 0(t0);
+	sw	a0, 0(t1)
+
+	la	a1, DMA_BASE
+	la	a0, tstsrc
+	sw	a0, DMA_SRC(a1)
+	la	a0, tstdst
+	sw	a0, DMA_DST(a1)
+	la	a0, 0x18
+	sw	a0, DMA_LEN(a1) /* start DMA */
+loop:
+	lw	a0, DMA_LEN(a1)
+	bne	a0, zero, loop;
+	nop
+	sw	a0, DMA_RESET(a1) /* reset DMA */
+
+	la	a0, testval2
+	sw	a0, DMA_SRC(a1)
+	la	a0, testval 
+	sw	a0, DMA_DST(a1)
+	la	a0, 0x4
+	sw	a0, DMA_LEN(a1) /* start DMA */
+loop2:
+	lw	a0, DMA_LEN(a1)
+	bne	a0, zero, loop2;
+	nop
+	sw	a0, DMA_RESET(a1) /* reset DMA */
+
+	PRINT(mmustr_b)
+	la	t0, testval
+	lw 	a0, 0(t0);
+	PRINTX
+	PUTCHAR(' ')
+	la	t0, testval2
+	lw 	a0, 0(t0);
+	PRINTX
+	PUTCHAR(' ')
+	la	t0, testval3
+	lw 	a0, 0(t0);
+	PRINTX
+	PUTCHAR(' ')
+	la	t0, tstsrc
+	lw 	a0, 0(t0);
+	PRINTX
+	PUTCHAR(' ')
+	la	t0, tstdst
+	lw 	a0, 0(t0);
+	PRINTX
+	PUTCHAR('\n')
+
+	/* we should get there */
+	EXIT(0)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PUTCHAR('\n')
+	/* we should not get there */
+	EXIT(3)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+mmustr_a: .ascii "before DMA \0"
+mmustr_b: .ascii "after DMA \0"
+startstr: .ascii "start\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+
+	.data
+testval:
+	.word MAGIC2
+testval2:
+	.word MAGIC4
+testval3:
+	.word MAGIC4
+tstdst:
+	.word 0
+	.org 0x1000
+	.word 0
+tstsrc:
+	.word MAGIC1
+
Index: trunk/softs/tests_cc_vcache/test_dma_unaligned/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_dma_unaligned/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_dma_unaligned/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_dma_unaligned/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_dma_unaligned/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_dma_unaligned/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^after DMA this is the test string unaligned and more than 64 chars long abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 123456789      abcdefghijklmnopqrstuvwxyz$" run.out > /dev/null
+	if [ $? -eq 0 ]; then
+		return 0;
+	fi
+	echo "couldn't find string in output - mtty not working ?" >> run.out
+	return 1
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_dma_unaligned/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_dma_unaligned/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_dma_unaligned/test.S	(revision 520)
@@ -0,0 +1,96 @@
+/*
+ * basic DMA check: check that the DMA engine works and and doens't
+ * clobbers memory
+ */
+#include <registers.h>
+#include <misc.h>
+#include <vcache.h>
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	PRINT(mmustr_a)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+
+	la	t0, tstdst
+	sw 	zero, 0(t0);
+	PRINT(tstdst)
+	PUTCHAR('E')
+	PUTCHAR('\n')
+
+	la	a1, DMA_BASE
+	la	a0, tstsrc
+	sw	a0, DMA_SRC(a1)
+	la	a0, tstdst
+	sw	a0, DMA_DST(a1)
+	la	a0, 160 #strlen(tstsrc)
+	sw	a0, DMA_LEN(a1) /* start DMA */
+loop:
+	lw	a0, DMA_LEN(a1)
+	bne	a0, zero, loop;
+	nop
+
+	PRINT(mmustr_b)
+	PRINT(tstdst)
+
+	/* we should get there */
+	EXIT(0)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PUTCHAR('\n')
+	/* we should not get there */
+	EXIT(3)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+mmustr_a: .ascii "before DMA \0"
+mmustr_b: .ascii "after DMA \0"
+startstr: .ascii "start\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+
+	.data
+testval:
+	.word MAGIC2
+testval2:
+	.word MAGIC4
+testval3:
+	.word MAGIC4
+tstdst:
+	.word 0
+	.org 0x1000
+testval4:
+	.word MAGIC1
+tstsrc:
+	.ascii "this is the test string unaligned and more than 64 chars long abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 123456789      abcdefghijklmnopqrstuvwxyz\n\0"
Index: trunk/softs/tests_cc_vcache/test_dtlb_inval/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_dtlb_inval/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_dtlb_inval/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_dtlb_inval/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_dtlb_inval/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_dtlb_inval/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+
+.  ../common/common.sh
+
+check_output()
+{
+	egrep "^mmu started 0x0000BEEF status 0x00400002 cause 0x0000001C pc 0xBFC00080 badva 0x00200004$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_dtlb_inval/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_dtlb_inval/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_dtlb_inval/test.S	(revision 520)
@@ -0,0 +1,117 @@
+/*
+ * dtlb inval: a write to VC_DTLB_INVAL should invalidate the corresponding
+ * dtlb entry. On a ccvcache, VC_DTLB_INVAL should not be needed, and
+ * the first access after clearing pte2_a should fail
+ */
+#include <registers.h>
+#include <misc.h>
+#include <vcache.h>
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+
+	la	a0, pte1_a
+	srl	a0, a0, 13
+	mtc2	a0, VC_PTPR
+	nop
+
+	li	a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
+	mtc2 	a0, VC_TLB_EN
+
+	PRINT(mmustr)
+	la	t0, testval + 0x00200000
+	lw 	a0, 0(t0);
+	PRINTX
+	PUTCHAR(' ')
+	la 	a0, pte2_a
+	sw	zero, 0(a0) /* invalidate PTE2 entry */
+	sync
+	la	t0, testval + 0x00200000
+	lw 	a0, 0(t0); /* TLB entry not invalidated yet, we can do this */
+	PRINTX
+	PUTCHAR('\n')
+	la	t0, testval + 0x00200000
+	mtc2	t0, VC_DTLB_INVAL /* invalidate VA */
+	lw 	a0, 0(t0); /* now this should fail */
+	PRINTX
+	PUTCHAR('\n')
+
+	/* we should not get there */
+	EXIT(1)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PUTCHAR('\n')
+	/* we should get there */
+	EXIT(0)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+mmustr: .ascii "mmu started \0"
+startstr: .ascii "start\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+
+	.data
+	/* first 2 pages is data that will be switched my mmu switch */
+data_a:
+	.word MAGIC1
+testval:
+	.word MAGIC2
+	.globl pte2_a
+/*
+ * one PD with a level 2 PTP: we invalidate an entry in the PTP and
+ * check that the VA is no longer accessible
+ */
+pte2_a:
+	.align 12
+	.word PTE2_V | PTE2_C | PTE2_X
+	.word 0x0000 >> 12 /* check real value of data_a */
+	.org pte2_a + 4092
+	.word 0
+	.globl pte2_b
+	.globl pte1_a
+pte1_a:
+	.align 13
+	.word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */
+	.word PTE1_V | PTE1_T | (0x1000 >> 12) /* map PA 0x0 at VA 0x00200000 via pte2_a */
+	.org pte1_a + (BOOT_ADDRESS >> 21) * 4
+	.word PTE1_V | PTE1_C | PTE1_X | (BOOT_ADDRESS >> 21) /* map PA 0xbfc00000 at VA 0xbfc00000 */
+	.org pte1_a + (TTY_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
+	.org pte1_a + (EXIT_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
+	.org pte1_a + 8192
Index: trunk/softs/tests_cc_vcache/test_dtlb_inval2/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_dtlb_inval2/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_dtlb_inval2/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_dtlb_inval2/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_dtlb_inval2/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_dtlb_inval2/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^mmu started 0x0000BEEF 0x0000DEAD$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_dtlb_inval2/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_dtlb_inval2/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_dtlb_inval2/test.S	(revision 520)
@@ -0,0 +1,121 @@
+/*
+ * dtlb inval: a write to a PTE2 should invalidate the corresponding
+ * dtlb entry. 
+ */
+#include <registers.h>
+#include <misc.h>
+#include <vcache.h>
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+
+	la	a0, pte1_a
+	srl	a0, a0, 13
+	mtc2	a0, VC_PTPR
+	nop
+
+	li	a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
+	mtc2 	a0, VC_TLB_EN
+
+	PRINT(mmustr)
+	la	t0, testval + 0x00200000
+	lw 	a0, 0(t0);
+	PRINTX
+	PUTCHAR(' ')
+	la 	t0, pte2_a
+	la	a0, 0x1000 >> 12 
+	sw	a0, 4(t0) /* swap PTE2 entry */
+1:
+	ll	a0, 0(t0)
+	la	a0, PTE2_V | PTE2_C | PTE2_X
+	sc	a0, 0(t0)
+	beqz	a0, 1b
+	nop
+
+	la	t0, testval + 0x00200000
+	lw 	a0, 0(t0); /* should get MAGIC1 */
+	PRINTX
+	PUTCHAR('\n')
+
+	/* we should get there */
+	EXIT(0)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PUTCHAR('\n')
+	/* we should not get there */
+	EXIT(1)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+mmustr: .ascii "mmu started \0"
+startstr: .ascii "start\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+
+	.data
+	/* first 2 pages is data that will be switched my mmu switch */
+data_a:
+	.word MAGIC1
+testval:
+	.word MAGIC2
+	.align 12
+	.word MAGIC2
+	.word MAGIC1
+	.globl pte2_a
+/*
+ * one PD with a level 2 PTP: we switch an entry in the PTP and
+ * check that the dtlb is invalidated
+ */
+pte2_a:
+	.align 12
+	.word PTE2_V | PTE2_C | PTE2_X
+	.word 0x0000 >> 12 /* check real value of data_a */
+	.org pte2_a + 4092
+	.word 0
+	.globl pte2_b
+	.globl pte1_a
+pte1_a:
+	.align 13
+	.word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */
+	.word PTE1_V | PTE1_T | (0x2000 >> 12) /* map PA 0x0 at VA 0x00200000 via pte2_a */
+	.org pte1_a + (BOOT_ADDRESS >> 21) * 4
+	.word PTE1_V | PTE1_C | PTE1_X | (BOOT_ADDRESS >> 21) /* map PA 0xbfc00000 at VA 0xbfc00000 */
+	.org pte1_a + (TTY_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
+	.org pte1_a + (EXIT_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
+	.org pte1_a + 8192
Index: trunk/softs/tests_cc_vcache/test_dtlb_inval3/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_dtlb_inval3/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_dtlb_inval3/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_dtlb_inval3/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_dtlb_inval3/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_dtlb_inval3/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "mmu started 0x0000BEEF 0xAC400000 0x0000900D status 0x00400002 cause 0x0000001C pc 0xBFC000D4 badva 0x00200004" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_dtlb_inval3/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_dtlb_inval3/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_dtlb_inval3/test.S	(revision 520)
@@ -0,0 +1,128 @@
+/*
+ * dtlb inval: a write to a PTE2 should invalidate the corresponding
+ * dtlb entry. Check that this is true is we change only the write flag
+ */
+#include <registers.h>
+#include <misc.h>
+#include <vcache.h>
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+
+	la	a0, pte1_a
+	srl	a0, a0, 13
+	mtc2	a0, VC_PTPR
+	nop
+
+	li	a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
+	mtc2 	a0, VC_TLB_EN
+
+	PRINT(mmustr)
+	la	t0, testval + 0x00200000
+	lw 	a0, 0(t0);
+	PRINTX
+	PUTCHAR(' ')
+	la	t0, testval + 0x00200000
+	la	a0, MAGIC3
+	sw	a0, 0(t0)
+	la 	t0, pte2_a
+1:
+	ll	a0, 0(t0)
+	la	a1, ~PTE2_W
+	and	a1, a0, a1
+	sc	a1, 0(t0)
+	beqz	a1, 1b
+	nop
+	PRINTX
+	PUTCHAR(' ')
+
+	la	t0, testval + 0x00200000
+	lw 	a0, 0(t0); /* should get MAGIC3 */
+	PRINTX
+	PUTCHAR(' ')
+	la	t0, testval + 0x00200000
+	la	a0, MAGIC1
+	sw	a0, 0(t0)
+
+	/* we should not get there */
+	EXIT(1)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PUTCHAR('\n')
+	/* we should get there */
+	EXIT(0)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+mmustr: .ascii "mmu started \0"
+startstr: .ascii "start\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+
+	.data
+	/* first 2 pages is data that will be switched my mmu switch */
+data_a:
+	.word MAGIC1
+testval:
+	.word MAGIC2
+	.align 12
+	.word MAGIC2
+	.word MAGIC1
+	.globl pte2_a
+/*
+ * one PD with a level 2 PTP: we switch an entry in the PTP and
+ * check that the dtlb is invalidated
+ */
+pte2_a:
+	.align 12
+	.word PTE2_V | PTE2_C | PTE2_W
+	.word 0x0000 >> 12 /* check real value of data_a */
+	.org pte2_a + 4092
+	.word 0
+	.globl pte2_b
+	.globl pte1_a
+pte1_a:
+	.align 13
+	.word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */
+	.word PTE1_V | PTE1_T | (0x2000 >> 12) /* map PA 0x0 at VA 0x00200000 via pte2_a */
+	.org pte1_a + (BOOT_ADDRESS >> 21) * 4
+	.word PTE1_V | PTE1_C | PTE1_X | (BOOT_ADDRESS >> 21) /* map PA 0xbfc00000 at VA 0xbfc00000 */
+	.org pte1_a + (TTY_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
+	.org pte1_a + (EXIT_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
+	.org pte1_a + 8192
Index: trunk/softs/tests_cc_vcache/test_dtlb_ptprinval/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_dtlb_ptprinval/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_dtlb_ptprinval/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_dtlb_ptprinval/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_dtlb_ptprinval/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_dtlb_ptprinval/run	(revision 520)
@@ -0,0 +1,33 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^mmu started ptpr_b 0x0000F00D$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 1 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	egrep "^mmu started ptpr_a 0x0000BEEF$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 2 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_dtlb_ptprinval/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_dtlb_ptprinval/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_dtlb_ptprinval/test.S	(revision 520)
@@ -0,0 +1,145 @@
+/*
+ * dtlb inval on PTPR write: check that no stale entry exists in the dtlb
+ * after MMU context swicth
+ */
+#include <registers.h>
+#include <misc.h>
+#include <vcache.h>
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+
+	la	a0, pte1_b
+	srl	a0, a0, 13
+	mtc2	a0, VC_PTPR	# PTPR <= pte1_b
+	nop
+
+	li	a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
+	mtc2 	a0, VC_TLB_EN
+
+	PRINT(mmustr_b)
+	la	t0, testval + 0x00200000
+	lw 	a0, 0(t0);
+	PRINTX			# print MAGIC3
+	PUTCHAR('\n')
+
+	la	a0, pte1_a
+	srl	a0, a0, 13
+	mtc2	a0, VC_PTPR	# PTPR <= pte1_a
+	nop
+	PRINT(mmustr_a)
+	la	t0, testval + 0x00200000
+	lw 	a0, 0(t0);
+	PRINTX			# print MAGIC1
+	PUTCHAR('\n')
+
+	/* we should get there */
+	EXIT(0)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PUTCHAR('\n')
+	/* we should not get there */
+	EXIT(3)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+mmustr_a: .ascii "mmu started ptpr_a \0"
+mmustr_b: .ascii "mmu started ptpr_b \0"
+startstr: .ascii "start\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+
+	.data
+	/* first 2 pages is data that will be switched my mmu switch */
+data_a:
+	.word MAGIC1
+testval:
+	.word MAGIC2
+	.org data_a + 0x1000
+data_b:
+	.word MAGIC3
+	.word MAGIC4
+
+/*
+ * two PD with two different PTE2 for code: check that dtlb points to
+ * the right one by loading 2 different data at the same virtual address
+ */
+	.globl pte2_a
+pte2_a:
+	.align 12
+	.word PTE2_V | PTE2_C | PTE2_X
+	.word 0x0000 >> 12 /* check real value of data_a */
+
+	.org pte2_a + 4092
+	.word 0
+	.globl pte2_b
+pte2_b:
+	.align 12
+	.word PTE2_V | PTE2_C | PTE2_X
+	.word 0x1000 >> 12 /* check real value of data_b */
+
+	.org pte2_b + 4092
+	.word 0
+
+	.globl pte1_a
+pte1_a:
+	.align 13
+	.word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */
+	.word PTE1_V | PTE1_T | (0x2000 >> 12) /* map PA 0x0 at VA 0x00200000 via pte2_a */
+
+	.org pte1_a + (BOOT_ADDRESS >> 21) * 4
+	.word PTE1_V | PTE1_C | PTE1_X | (BOOT_ADDRESS >> 21) /* map PA 0xbfc00000 at VA 0xbfc00000 */
+
+	.org pte1_a + (TTY_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
+
+	.org pte1_a + (EXIT_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
+	.org pte1_a + 8192
+	.globl pte1_b
+pte1_b:
+	.align 13
+	.word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */
+	.word PTE1_V | PTE1_T | (0x3000 >> 12) /* map PA 0x1000 at VA 0x00200000 via pte2_b */
+	.org pte1_b + (BOOT_ADDRESS >> 21) * 4
+	.word PTE1_V | PTE1_C | PTE1_X | (BOOT_ADDRESS >> 21) /* map PA 0xbfc00000 at VA 0xbfc00000 */
+	.org pte1_b + (TTY_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
+	.org pte1_b + (EXIT_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
+	.org pte1_b + 8188
+	.word 0
Index: trunk/softs/tests_cc_vcache/test_excep_cop/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_excep_cop/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_excep_cop/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_excep_cop/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_excep_cop/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_excep_cop/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^status 0x00400002 cause 0x1000002C pc 0xBFC0002C badva 0x00000000$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 1 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_excep_cop/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_excep_cop/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_excep_cop/test.S	(revision 520)
@@ -0,0 +1,71 @@
+/*
+ * coproc unusable exception test: we take an exception on COP1 use
+ */
+#include <registers.h>
+#include <misc.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+	la	sp, 0x00400000 - 16
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+	li	t3, MAGIC1
+	mtc1    t3,$f2
+	mfc1	a0,$f2
+	PRINTX
+	PUTCHAR('\n')
+	nop
+	nop
+	nop
+	nop
+
+1:
+	/* we should not get there */
+	EXIT(1)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+	PUTCHAR('\n')
+
+	EXIT(0)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+startstr: .ascii "start\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+	.data
+	.word MAGIC1
+testval:
+	.word MAGIC2
Index: trunk/softs/tests_cc_vcache/test_excep_cop1/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_excep_cop1/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_excep_cop1/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_excep_cop1/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_excep_cop1/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_excep_cop1/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^status 0x00400002 cause 0x1000002C pc 0xBFC00030 badva 0x00000000$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 1 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_excep_cop1/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_excep_cop1/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_excep_cop1/test.S	(revision 520)
@@ -0,0 +1,71 @@
+/*
+ * trap test: check that we get a trap on FPU access though [ls][dw]c1
+ */
+#include <registers.h>
+#include <misc.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+	la	sp, 0x00400000 - 16
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV), enable cop1 */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+
+	la	a0, div1;
+	lwc1	$f0, 0(a0)
+	PRINTX
+	PUTCHAR('\n')
+	EXIT(2)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+	PUTCHAR('\n')
+#we should end there
+	EXIT(0)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+startstr: .ascii "start\n\0"
+usrstr: .ascii "usrmode\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+	.data
+	.word MAGIC1
+testval:
+	.word MAGIC2
+	.globl div1
+div1:
+	.float	10.0
+	.globl div2
+div2:
+	.float	0.0
Index: trunk/softs/tests_cc_vcache/test_excep_cop_delayslot/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_excep_cop_delayslot/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_excep_cop_delayslot/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_excep_cop_delayslot/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_excep_cop_delayslot/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_excep_cop_delayslot/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^status 0x00400002 cause 0x9000002C pc 0xBFC00028 badva 0x00000000$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 1 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_excep_cop_delayslot/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_excep_cop_delayslot/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_excep_cop_delayslot/test.S	(revision 520)
@@ -0,0 +1,65 @@
+/*
+ * coproc unusable exception test: 0x80000000 bit is set in cause register
+ */
+#include <registers.h>
+#include <misc.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+	la	sp, 0x00400000 - 16
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+	j	1f
+	mtc1    t3,$f2
+	nop
+
+1:
+	/* we should not get there */
+	EXIT(1)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+	PUTCHAR('\n')
+
+	EXIT(0)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+startstr: .ascii "start\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+	.data
+	.word MAGIC1
+testval:
+	.word MAGIC2
Index: trunk/softs/tests_cc_vcache/test_excep_if/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_excep_if/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_excep_if/Makefile	(revision 520)
@@ -0,0 +1,2 @@
+LDSCRIPT=./ldscript
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_excep_if/ldscript
===================================================================
--- trunk/softs/tests_cc_vcache/test_excep_if/ldscript	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_excep_if/ldscript	(revision 520)
@@ -0,0 +1,67 @@
+/*
+ *
+ * SOCLIB_GPL_HEADER_BEGIN
+ * 
+ * This file is part of SoCLib, GNU GPLv2.
+ * 
+ * SoCLib is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ * 
+ * SoCLib is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with SoCLib; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ * 
+ * SOCLIB_GPL_HEADER_END
+ *
+ * Copyright (c) UPMC, Lip6, SoC
+ *         Nicolas Pouillon <nipo@ssji.net>, 2006-2007
+ *
+ * Maintainers: abdelmalek.si-merabet@lip6.fr
+ */
+ENTRY(_start)
+
+SECTIONS
+{
+   . = 0xbfc00000;
+   .text : {
+      *(.text)
+/* load .text2 one page after .text */
+      . = ALIGN(0x1000);
+      *(.text2)
+   }
+   .rodata : {
+      *(.rodata)
+      . = ALIGN(4);
+   }
+   . = 0x00000000;
+   .data  : {
+      *(.data)
+   }
+   .sdata : {
+      *(.lit8)
+      *(.lit4)
+      *(.sdata)
+   }
+   _gp = .;
+   . = ALIGN(4);
+   _edata = .;
+   .sbss  : {
+      *(.sbss)
+      *(.scommon)
+   }
+   .bss   : {
+      *(.bss)
+      *(COMMON)
+   }
+   . = ALIGN(4);
+   _end = .;
+   _heap = .;
+   _stack = 0x00400000-16;
+}
Index: trunk/softs/tests_cc_vcache/test_excep_if/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_excep_if/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_excep_if/run	(revision 520)
@@ -0,0 +1,33 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^0x00000004: 0x0000BEEF$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 1 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	egrep "^status 0x00400002 cause 0x00000018 pc 0xBFC01000 badva 0x00000000$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 2 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_excep_if/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_excep_if/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_excep_if/test.S	(revision 520)
@@ -0,0 +1,135 @@
+/*
+ * ifetch bus fault exception test: we can restart the faulting instruction
+ * We use the MMU to cause fault.
+ */
+#include <registers.h>
+#include <misc.h>
+#include <vcache.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+	la	sp, 0x00200000 - 16
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+
+	la	a0, pte1
+	srl	a0, a0, 13
+	mtc2	a0, VC_PTPR
+	nop
+
+	li	a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
+	mtc2 	a0, VC_TLB_EN
+
+	PRINT(mmustr)
+
+	move	a1, zero
+	la	s0, testval
+	jal	doload
+	move	a0, s0
+	PRINTX
+	PUTCHAR(':')
+	PUTCHAR(' ')
+	move	a0, a1
+	PRINTX
+	PUTCHAR('\n')
+
+	/* we should get there */
+	EXIT(0)
+
+	.globl excep
+excep:
+	.set noreorder
+	/* don't clobber a0 and ra */
+	addiu   sp, sp, -8
+	sw      a0, 4(sp)
+	sw      ra, 8(sp)
+
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PUTCHAR('\n')
+	/* map VA 0xbfc01000 at PA 0xbfc01000 */
+	la	t0, pte2 + VADDR_TO_PTE2I(0xbfc01000) * 8
+	la	a0, (0xbfc01000 >> PTE2_SHIFT)
+	sw	a0, 4(t0)
+	la	a0, (PTE2_V | PTE2_C | PTE2_X)
+	sw	a0, 0(t0)
+	/* la	a0, 0xbfc01000
+	mtc2	a0, VC_ITLB_INVAL */
+
+	lw      a0, 4(sp)
+	lw      ra, 8(sp)
+	addiu   sp, sp, 8
+	eret
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+mmustr:	.ascii "mmu started\n\0"
+startstr: .ascii "start\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+	/*
+	 * we use a ldscript trick here, to load this function at
+	 * the appropriate address
+	 */
+	.section .text2, "ax"
+	.globl doload
+doload:
+	jr      ra
+	lw      a1, 0(s0) /* this should trigger the exception */
+
+	/* we should not get there */
+	nop
+	nop
+	EXIT(1)
+
+	.data
+	.word MAGIC1
+testval:
+	.word MAGIC2
+	.globl pte2
+pte2:
+	.align 12
+	.word PTE2_V | PTE2_C | PTE2_X
+	.word BOOT_ADDRESS >> 12
+	.org pte2 + 4092
+	.globl pte1
+pte1:
+	.align 13
+	.word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */
+	.word 0x0
+	.org pte1 + (BOOT_ADDRESS >> 21) * 4
+	.word PTE1_V | PTE1_T | (0x1000 >> 12) /* map PA 0xbfc00000 at VA 0xbfc00000 with 4k page: check real address of PTE2 !!! */
+	.org pte1 + (TTY_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
+	.org pte1 + (EXIT_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
+	.org pte1 + 8192
Index: trunk/softs/tests_cc_vcache/test_excep_if_delayslot/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_excep_if_delayslot/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_excep_if_delayslot/Makefile	(revision 520)
@@ -0,0 +1,2 @@
+LDSCRIPT=./ldscript
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_excep_if_delayslot/ldscript
===================================================================
--- trunk/softs/tests_cc_vcache/test_excep_if_delayslot/ldscript	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_excep_if_delayslot/ldscript	(revision 520)
@@ -0,0 +1,67 @@
+/*
+ *
+ * SOCLIB_GPL_HEADER_BEGIN
+ * 
+ * This file is part of SoCLib, GNU GPLv2.
+ * 
+ * SoCLib is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ * 
+ * SoCLib is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with SoCLib; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ * 
+ * SOCLIB_GPL_HEADER_END
+ *
+ * Copyright (c) UPMC, Lip6, SoC
+ *         Nicolas Pouillon <nipo@ssji.net>, 2006-2007
+ *
+ * Maintainers: abdelmalek.si-merabet@lip6.fr
+ */
+ENTRY(_start)
+
+SECTIONS
+{
+   . = 0xbfc00000;
+   .text : {
+      *(.text)
+/* load .text2 one page after .text */
+      . = ALIGN(0x1000) - 4;
+      *(.text2)
+   }
+   .rodata : {
+      *(.rodata)
+      . = ALIGN(4);
+   }
+   . = 0x00000000;
+   .data  : {
+      *(.data)
+   }
+   .sdata : {
+      *(.lit8)
+      *(.lit4)
+      *(.sdata)
+   }
+   _gp = .;
+   . = ALIGN(4);
+   _edata = .;
+   .sbss  : {
+      *(.sbss)
+      *(.scommon)
+   }
+   .bss   : {
+      *(.bss)
+      *(COMMON)
+   }
+   . = ALIGN(4);
+   _end = .;
+   _heap = .;
+   _stack = 0x00400000-16;
+}
Index: trunk/softs/tests_cc_vcache/test_excep_if_delayslot/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_excep_if_delayslot/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_excep_if_delayslot/run	(revision 520)
@@ -0,0 +1,33 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^0x00000004: 0x0000BEEF$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 1 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	egrep "^status 0x00400002 cause 0x80000018 pc 0xBFC00FFC badva 0x00000000$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 2 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_excep_if_delayslot/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_excep_if_delayslot/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_excep_if_delayslot/test.S	(revision 520)
@@ -0,0 +1,135 @@
+/*
+ * ifetch bus fault exception test: we can restart the faulting instruction
+ * when the fault occurs in the branch delay slot.
+ * We use the MMU to cause fault.
+ */
+#include <registers.h>
+#include <misc.h>
+#include <vcache.h>
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+	la	sp, 0x00200000 - 16
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+
+	la	a0, pte1
+	srl	a0, a0, 13
+	mtc2	a0, VC_PTPR
+	nop
+
+	li	a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
+	mtc2 	a0, VC_TLB_EN
+
+	PRINT(mmustr)
+
+	move	a1, zero
+	la	s0, testval
+	jal	doload
+	move	a0, s0
+	PRINTX
+	PUTCHAR(':')
+	PUTCHAR(' ')
+	move	a0, a1
+	PRINTX
+	PUTCHAR('\n')
+
+	/* we should get there */
+	EXIT(0)
+
+	.globl excep
+excep:
+	.set noreorder
+	/* don't clobber a0 and ra */
+	addiu   sp, sp, -8
+	sw      a0, 4(sp)
+	sw      ra, 8(sp)
+
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PUTCHAR('\n')
+	/* map VA 0xbfc01000 at PA 0xbfc01000 */
+	la	t0, pte2 + VADDR_TO_PTE2I(0xbfc01000) * 8
+	la	a0, (0xbfc01000 >> PTE2_SHIFT)
+	sw	a0, 4(t0)
+	la	a0, (PTE2_V | PTE2_C | PTE2_X)
+	sw	a0, 0(t0)
+	/* la	a0, 0xbfc01000
+	mtc2	a0, VC_ITLB_INVAL */
+
+	lw      a0, 4(sp)
+	lw      ra, 8(sp)
+	addiu   sp, sp, 8
+	eret
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+mmustr:	.ascii "mmu started\n\0"
+startstr: .ascii "start\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+	/*
+	 * we use a ldscript trick here, to load this function at
+	 * the appropriate address
+	 */
+	.section .text2, "ax"
+	.globl doload
+doload:
+	jr      ra
+	lw      a1, 0(s0) /* this should trigger the exception */
+
+	/* we should not get there */
+	nop
+	nop
+	EXIT(1)
+
+	.data
+	.word MAGIC1
+testval:
+	.word MAGIC2
+	.globl pte2
+pte2:
+	.align 12
+	.word PTE2_V | PTE2_C | PTE2_X
+	.word BOOT_ADDRESS >> 12
+	.org pte2 + 4092
+	.globl pte1
+pte1:
+	.align 13
+	.word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */
+	.word 0x0
+	.org pte1 + (BOOT_ADDRESS >> 21) * 4
+	.word PTE1_V | PTE1_T | (0x1000 >> 12) /* map PA 0xbfc00000 at VA 0xbfc00000 with 4k page: check real address of PTE2 !!! */
+	.org pte1 + (TTY_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
+	.org pte1 + (EXIT_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
+	.org pte1 + 8192
Index: trunk/softs/tests_cc_vcache/test_excep_if_llsc/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_excep_if_llsc/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_excep_if_llsc/Makefile	(revision 520)
@@ -0,0 +1,2 @@
+LDSCRIPT=./ldscript
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_excep_if_llsc/ldscript
===================================================================
--- trunk/softs/tests_cc_vcache/test_excep_if_llsc/ldscript	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_excep_if_llsc/ldscript	(revision 520)
@@ -0,0 +1,67 @@
+/*
+ *
+ * SOCLIB_GPL_HEADER_BEGIN
+ * 
+ * This file is part of SoCLib, GNU GPLv2.
+ * 
+ * SoCLib is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ * 
+ * SoCLib is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with SoCLib; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ * 
+ * SOCLIB_GPL_HEADER_END
+ *
+ * Copyright (c) UPMC, Lip6, SoC
+ *         Nicolas Pouillon <nipo@ssji.net>, 2006-2007
+ *
+ * Maintainers: abdelmalek.si-merabet@lip6.fr
+ */
+ENTRY(_start)
+
+SECTIONS
+{
+   . = 0xbfc00000;
+   .text : {
+      *(.text)
+/* load .text2 one page after .text */
+      . = ALIGN(0x1000);
+      *(.text2)
+   }
+   .rodata : {
+      *(.rodata)
+      . = ALIGN(4);
+   }
+   . = 0x00000000;
+   .data  : {
+      *(.data)
+   }
+   .sdata : {
+      *(.lit8)
+      *(.lit4)
+      *(.sdata)
+   }
+   _gp = .;
+   . = ALIGN(4);
+   _edata = .;
+   .sbss  : {
+      *(.sbss)
+      *(.scommon)
+   }
+   .bss   : {
+      *(.bss)
+      *(COMMON)
+   }
+   . = ALIGN(4);
+   _end = .;
+   _heap = .;
+   _stack = 0x00400000-16;
+}
Index: trunk/softs/tests_cc_vcache/test_excep_if_llsc/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_excep_if_llsc/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_excep_if_llsc/run	(revision 520)
@@ -0,0 +1,33 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^0x00000004: 0x0000BEEF$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 1 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	egrep "^status 0x00400002 cause 0x00000018 pc 0xBFC01000 badva 0x00000000$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 2 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_excep_if_llsc/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_excep_if_llsc/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_excep_if_llsc/test.S	(revision 520)
@@ -0,0 +1,136 @@
+/*
+ * ifetch bus fault exception test: we can restart the faulting instruction
+ * We use the MMU to cause fault.
+ * Match what NetBSD does for page table update: sw for ppn, ll/sc for flags
+ */
+#include <registers.h>
+#include <misc.h>
+#include <vcache.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+	la	sp, 0x00200000 - 16
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+
+	la	a0, pte1
+	srl	a0, a0, 13
+	mtc2	a0, VC_PTPR
+	nop
+
+	li	a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
+	mtc2 	a0, VC_TLB_EN
+
+	PRINT(mmustr)
+
+	move	a1, zero
+	la	s0, testval
+	jal	doload
+	move	a0, s0
+	PRINTX
+	PUTCHAR(':')
+	PUTCHAR(' ')
+	move	a0, a1
+	PRINTX
+	PUTCHAR('\n')
+
+	/* we should get there */
+	EXIT(0)
+
+	.globl excep
+excep:
+	.set noreorder
+	/* don't clobber a0 and ra */
+	addiu   sp, sp, -8
+	sw      a0, 4(sp)
+	sw      ra, 8(sp)
+
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PUTCHAR('\n')
+	/* map VA 0xbfc01000 at PA 0xbfc01000 */
+	la	t0, pte2 + VADDR_TO_PTE2I(0xbfc01000) * 8
+	la	a0, (0xbfc01000 >> PTE2_SHIFT)
+	sw	a0, 4(t0)
+1:
+	ll	a0, 0(t0)
+	la	a0, (PTE2_V | PTE2_C | PTE2_X)
+	sc	a0, 0(t0)
+	beqz	a0, 1b
+
+	lw      a0, 4(sp)
+	lw      ra, 8(sp)
+	addiu   sp, sp, 8
+	eret
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+mmustr:	.ascii "mmu started\n\0"
+startstr: .ascii "start\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+	/*
+	 * we use a ldscript trick here, to load this function at
+	 * the appropriate address
+	 */
+	.section .text2, "ax"
+	.globl doload
+doload:
+	jr      ra
+	lw      a1, 0(s0) /* this should trigger the exception */
+	/* we should not get there */
+	nop
+	nop
+	EXIT(1)
+
+	.data
+	.word MAGIC1
+testval:
+	.word MAGIC2
+	.globl pte2
+pte2:
+	.align 12
+	.word PTE2_V | PTE2_C | PTE2_X
+	.word BOOT_ADDRESS >> 12
+	.org pte2 + 4092
+	.globl pte1
+pte1:
+	.align 13
+	.word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */
+	.word 0x0
+	.org pte1 + (BOOT_ADDRESS >> 21) * 4
+	.word PTE1_V | PTE1_T | (0x1000 >> 12) /* map PA 0xbfc00000 at VA 0xbfc00000 with 4k page: check real address of PTE2 !!! */
+	.org pte1 + (TTY_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
+	.org pte1 + (EXIT_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
+	.org pte1 + 8192
Index: trunk/softs/tests_cc_vcache/test_excep_intr/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_excep_intr/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_excep_intr/Makefile	(revision 520)
@@ -0,0 +1,3 @@
+LDSCRIPT=./ldscript
+include ../Makefile.inc
+CFLAGS+= -DINTERRUPT_DELAY=${INTERRUPT_DELAY}
Index: trunk/softs/tests_cc_vcache/test_excep_intr/ldscript
===================================================================
--- trunk/softs/tests_cc_vcache/test_excep_intr/ldscript	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_excep_intr/ldscript	(revision 520)
@@ -0,0 +1,67 @@
+/*
+ *
+ * SOCLIB_GPL_HEADER_BEGIN
+ * 
+ * This file is part of SoCLib, GNU GPLv2.
+ * 
+ * SoCLib is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ * 
+ * SoCLib is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with SoCLib; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ * 
+ * SOCLIB_GPL_HEADER_END
+ *
+ * Copyright (c) UPMC, Lip6, SoC
+ *         Nicolas Pouillon <nipo@ssji.net>, 2006-2007
+ *
+ * Maintainers: abdelmalek.si-merabet@lip6.fr
+ */
+ENTRY(_start)
+
+SECTIONS
+{
+   . = 0xbfc00000;
+   .text : {
+      *(.text)
+/* load .text2 one page after .text */
+      . = ALIGN(0x1000);
+      *(.text2)
+   }
+   .rodata : {
+      *(.rodata)
+      . = ALIGN(4);
+   }
+   . = 0x00000000;
+   .data  : {
+      *(.data)
+   }
+   .sdata : {
+      *(.lit8)
+      *(.lit4)
+      *(.sdata)
+   }
+   _gp = .;
+   . = ALIGN(4);
+   _edata = .;
+   .sbss  : {
+      *(.sbss)
+      *(.scommon)
+   }
+   .bss   : {
+      *(.bss)
+      *(COMMON)
+   }
+   . = ALIGN(4);
+   _end = .;
+   _heap = .;
+   _stack = 0x00400000-16;
+}
Index: trunk/softs/tests_cc_vcache/test_excep_intr/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_excep_intr/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_excep_intr/run	(revision 520)
@@ -0,0 +1,44 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^end 0x0000BEEF 0x00000001$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 1 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	egrep "^status 0x00400403 cause 0x00000018 pc 0x80000000 badva 0x00000000 xicu 0x00000000$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 2 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	egrep "^status 0x00400403 cause 0x00000400 pc 0x80000000 badva 0x00000000 xicu 0x00000001$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 3 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+echo 
+i=1180
+while true; do
+	echo -n "    DELAY=$i: "
+	make INTERRUPT_DELAY=$i --quiet || exit 1
+	${SIMUL} > run.out 2>&1 
+	if [ $? -eq 0 ]; then
+		if check_output; then
+			echo "test passsed";
+			make --quiet clean
+		else
+			echo "test FAILED"
+			exit 1
+		fi
+	else 
+		echo "test FAILED"
+		exit 1
+	fi
+	i=$((i+1))
+done
+
Index: trunk/softs/tests_cc_vcache/test_excep_intr/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_excep_intr/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_excep_intr/test.S	(revision 520)
@@ -0,0 +1,201 @@
+/*
+ * Check interrupt while in trap handler.
+ * Cache is enabled so we have one instruction/cycle
+ */
+#include <registers.h>
+#include <misc.h>
+#include <vcache.h>
+#include <xicu.h>
+
+#define DOLOAD_ADDR 0x80000000
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+	la	sp, 0x00200000 - 16
+
+	/* reset cause, make sure IV is off */
+	mtc0	zero, COP0_CAUSE
+
+	la	a0, pte1
+	srl	a0, a0, 13
+	mtc2	a0, VC_PTPR
+	nop
+	nop
+
+	li	a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
+	mtc2 	a0, VC_TLB_EN
+
+	PRINT(startstr)
+
+	/* program xicu */
+	la	t0, XICU_BASE
+	/* clear pending interrupt */
+	lw	a0, XICU_PTI_ACK(0)(t0)
+	/* route PTI0 to irq 0 */
+	li	a0, 1 << 0
+	sw	a0, XICU_MSK_PTI_E(0)(t0)
+	/* init s0 */
+	li	s0, MAGIC2
+	/*
+	 * interrupt in INTERRUPT_DELAY cycles.
+	 */
+	li	a0, INTERRUPT_DELAY
+	sw	a0, XICU_PTI_PER(0)(t0)
+	/* clear pending interrupt */
+	lw	a0, XICU_PTI_ACK(0)(t0)
+	/* reset cop0 status (keep BEV), enable interrupt 0 */
+	lui     a0, 0x0040;
+	addiu	a0, 0x0401;
+	mtc0    a0, COP0_STATUS
+	nop
+	nop
+	nop
+	nop
+	nop
+
+	nop
+	move	a1, zero
+	la	s0, DOLOAD_ADDR
+	jalr	s0
+	nop
+	j	end
+	nop
+	/* we should not end there */
+	EXIT(1)
+
+end:
+	PRINT(endstr)
+	move	a0, a1
+	PRINTX
+	PUTCHAR(' ')
+	la	a0, myvar
+	lw	a0, 0(a0)
+	PRINTX
+	PUTCHAR('\n')
+	EXIT(0)
+
+	.globl excep
+excep:
+	.set noreorder
+        /* don't clobber a0 and ra */
+	addiu   sp, sp, -8
+	sw      a0, 4(sp)
+	sw      ra, 8(sp)
+
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	move	s0, a0
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PRINT(xicustr)
+	la	t0, XICU_BASE
+	lw	a0, XICU_PRIO(0)(t0)
+	PRINTX
+	PUTCHAR('\n')
+	/* map VA DOLOAD_ADDR at PA 0xbfc01000 */
+	la	t0, pte22 + VADDR_TO_PTE2I(DOLOAD_ADDR) * 8
+	la	a0, (0xbfc01000 >> PTE2_SHIFT)
+	sw	a0, 4(t0)
+	la	a0, (PTE2_V | PTE2_C | PTE2_X)
+	sw	a0, 0(t0)
+	mtc2	zero, VC_DCACHE_FLUSH /* flush the whole data cache */
+
+	andi	a0, s0, 0xff00
+	beq	a0, zero, notintr
+	nop
+
+	/* disable timer0 */
+	la	t0, XICU_BASE
+	sw	zero, XICU_PTI_PER(0)(t0)
+notintr:
+	la	a1, myvar
+	la	a0, 0(a1)
+	beq	a0, zero, noex
+	nop
+	EXIT(2)
+noex:
+	li	a0, 1
+	sw	a0, 0(a1)
+	lw	a0, 4(sp)
+	lw	ra, 8(sp)
+	addiu	sp, sp, 8
+	eret
+	/* we should not end there */
+	EXIT(1)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+xicustr: .ascii " xicu \0"
+startstr: .ascii "start\n\0"
+endstr: .ascii "end \0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+	/*
+	 * we use a ldscript trick here, to load this function at
+	 * the appropriate address
+	 */
+	.section .text2, "ax"
+	.globl doload
+doload:
+	la	s0, testval
+	jr	ra
+	lw	a1, 0(s0) /* this should trigger the exception */
+	/* we should not get there */
+	EXIT(1)
+	nop
+	.data
+myvar:	.word 0
+testval:
+	.word MAGIC2
+	.globl pte2
+pte2:
+        .align 12
+        .word PTE2_V | PTE2_C | PTE2_X
+        .word BOOT_ADDRESS >> 12
+        .org pte2 + 4092
+	.globl pte22
+pte22:
+        .align 12
+        .word 0
+        .word 0
+        .org pte22 + 4092
+        .globl pte1
+pte1:
+	.align 13
+	.word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */
+	.org pte1 + (DOLOAD_ADDR >> 21) * 4
+        .word PTE1_V | PTE1_T | (0x2000 >> 12) /* map VA DOLOAD_ADDR with 4k page: check real address of PTE22 !!! */
+	.org pte1 + (BOOT_ADDRESS >> 21) * 4
+        .word PTE1_V | PTE1_T | (0x1000 >> 12) /* map PA 0xbfc00000 at VA 0xbfc00000 with 4k page: check real address of PTE2 !!! */
+	.org pte1 + (TTY_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
+	.org pte1 + (XICU_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (XICU_BASE >> 21) /* map PA 0xd2000000 at VA 0xd2000000 */
+	.org pte1 + (EXIT_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
+	.org pte1 + 8192
+	.word 0
+
Index: trunk/softs/tests_cc_vcache/test_excep_ls/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_excep_ls/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_excep_ls/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_excep_ls/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_excep_ls/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_excep_ls/run	(revision 520)
@@ -0,0 +1,33 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^0x00000004: 0x0000BEEF$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 1 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	egrep "^status 0x00400002 cause 0x0000001C pc 0xBFC00058 badva 0x00000004$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 2 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_excep_ls/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_excep_ls/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_excep_ls/test.S	(revision 520)
@@ -0,0 +1,103 @@
+/*
+ * load/store bus fault exception test: we can restart the faulting instruction
+ * We use the MMU to cause fault
+ */
+#include <registers.h>
+#include <misc.h>
+#include <vcache.h>
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+
+	la	a0, pte1
+	srl	a0, a0, 13
+	mtc2	a0, VC_PTPR
+	nop
+
+	li	a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
+	mtc2 	a0, VC_TLB_EN
+
+	PRINT(mmustr)
+
+	/* 0x00000000 not mapped yet: we fault, load the MMU and retry */
+	move	a1, zero
+	la	s0, testval
+	lw	a1, 0(s0) /* this should trigger the exception */
+	move	a0, s0
+	PRINTX
+	PUTCHAR(':')
+	PUTCHAR(' ')
+	move	a0, a1
+	PRINTX
+	PUTCHAR('\n')
+
+	/* we should get there */
+	EXIT(0)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PUTCHAR('\n')
+	/* map VA 0 at PA 0: just copy entry for 0x00200000 */
+	la	t0, pte1 + 0x00200000
+	lw	a0, 4(t0)
+	sw	a0, 0(t0)
+	/* mtc2	zero, VC_DTLB_INVAL */
+	eret
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+mmustr:	.ascii "mmu started\n\0"
+startstr: .ascii "start\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+	.data
+	.word MAGIC1
+testval:
+	.word MAGIC2
+	.globl pte1
+pte1:
+	.align 13
+	.word 0x0                            /* map PA 0 at VA 0 */
+	.word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0x00200000 */
+	.org pte1 + (BOOT_ADDRESS >> 21) * 4
+	.word PTE1_V | PTE1_C | PTE1_X | (BOOT_ADDRESS >> 21) /* map PA 0xbfc00000 at VA 0xbfc00000 */
+	.org pte1 + (TTY_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
+	.org pte1 + (EXIT_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
+	.org pte1 + 8192
+	.word 0
+
Index: trunk/softs/tests_cc_vcache/test_excep_ls_delayslot/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_excep_ls_delayslot/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_excep_ls_delayslot/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_excep_ls_delayslot/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_excep_ls_delayslot/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_excep_ls_delayslot/run	(revision 520)
@@ -0,0 +1,33 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^0x00000004: 0x0000BEEF$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 1 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	egrep "^status 0x00400002 cause 0x8000001C pc 0xBFC000AC badva 0x00000004$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 2 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_excep_ls_delayslot/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_excep_ls_delayslot/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_excep_ls_delayslot/test.S	(revision 520)
@@ -0,0 +1,123 @@
+/*
+ * load/store bus fault exception test: we can restart the jump when the
+ * instruction in the delay slot takes a fault.
+ * We use the MMU to cause fault
+ */
+#include <registers.h>
+#include <misc.h>
+#include <vcache.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+	la	sp, 0x00400000 - 16
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+
+	la	a0, pte1
+	srl	a0, a0, 13
+	mtc2	a0, VC_PTPR
+	nop
+
+	li	a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
+	mtc2 	a0, VC_TLB_EN
+
+	PRINT(mmustr)
+
+	/* 0x00000000 not mapped yet: we fault, load the MMU and retry */
+	move	a1, zero
+	la	s0, testval
+	jal	doload
+	move	a0, s0
+	PRINTX
+	PUTCHAR(':')
+	PUTCHAR(' ')
+	move	a0, a1
+	PRINTX
+	PUTCHAR('\n')
+
+	/* we should get there */
+	EXIT(0)
+
+	.globl doload
+doload:
+	nop
+	nop
+	jr 	ra
+	lw	a1, 0(s0) /* this should trigger the exception */
+
+	/* we should not get there */
+	EXIT(1)
+
+	.globl excep
+excep:
+	.set noreorder
+	/* don't clobber a0 and ra */
+	addiu	sp, sp, -8
+	sw	a0, 4(sp)
+	sw	ra, 8(sp)
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PUTCHAR('\n')
+	/* map VA 0 at PA 0: just copy entry for 0x00200000 */
+	la	t0, pte1 + 0x00200000
+	lw	a0, 4(t0)
+	sw	a0, 0(t0)
+	/* mtc2	zero, VC_DTLB_INVAL */
+	lw	a0, 4(sp)
+	lw	ra, 8(sp)
+	addiu	sp, sp, 8
+	eret
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+mmustr:	.ascii "mmu started\n\0"
+startstr: .ascii "start\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+	.data
+	.word MAGIC1
+testval:
+	.word MAGIC2
+	.globl pte1
+pte1:
+	.align 13
+	.word 0x0                            /* map PA 0 at VA 0 */
+	.word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0x00200000 */
+	.org pte1 + (BOOT_ADDRESS >> 21) * 4
+	.word PTE1_V | PTE1_C | PTE1_X | (BOOT_ADDRESS >> 21) /* map PA 0xbfc00000 at VA 0xbfc00000 */
+	.org pte1 + (TTY_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
+	.org pte1 + (EXIT_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
+	.org pte1 + 8192
+	.word 0
+
Index: trunk/softs/tests_cc_vcache/test_excep_ls_llsc/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_excep_ls_llsc/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_excep_ls_llsc/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_excep_ls_llsc/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_excep_ls_llsc/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_excep_ls_llsc/run	(revision 520)
@@ -0,0 +1,33 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^0x00000004: 0x0000BEEF$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 1 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	egrep "^status 0x00400002 cause 0x0000001C pc 0xBFC00058 badva 0x00000004$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 2 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_excep_ls_llsc/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_excep_ls_llsc/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_excep_ls_llsc/test.S	(revision 520)
@@ -0,0 +1,107 @@
+/*
+ * load/store bus fault exception test: we can restart the faulting instruction
+ * We use the MMU to cause fault
+ * Match what NetBSD does for page table update: sw for ppn, ll/sc for flags
+ */
+#include <registers.h>
+#include <misc.h>
+#include <vcache.h>
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+
+	la	a0, pte1
+	srl	a0, a0, 13
+	mtc2	a0, VC_PTPR
+	nop
+
+	li	a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
+	mtc2 	a0, VC_TLB_EN
+
+	PRINT(mmustr)
+
+	/* 0x00000000 not mapped yet: we fault, load the MMU and retry */
+	move	a1, zero
+	la	s0, testval
+	lw	a1, 0(s0) /* this should trigger the exception */
+	move	a0, s0
+	PRINTX
+	PUTCHAR(':')
+	PUTCHAR(' ')
+	move	a0, a1
+	PRINTX
+	PUTCHAR('\n')
+
+	/* we should get there */
+	EXIT(0)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PUTCHAR('\n')
+	/* map VA 0 at PA 0: just copy entry for 0x00200000 */
+	la	t0, pte1 + 0x00200000
+1:
+	ll	a0, 0(t0)
+	lw	a0, 4(t0)
+	sc	a0, 0(t0)
+	beqz	a0, 1b
+	/* mtc2	zero, VC_DTLB_INVAL */
+	eret
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+mmustr:	.ascii "mmu started\n\0"
+startstr: .ascii "start\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+	.data
+	.word MAGIC1
+testval:
+	.word MAGIC2
+	.globl pte1
+pte1:
+	.align 13
+	.word 0x0                            /* map PA 0 at VA 0 */
+	.word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0x00200000 */
+	.org pte1 + (BOOT_ADDRESS >> 21) * 4
+	.word PTE1_V | PTE1_C | PTE1_X | (BOOT_ADDRESS >> 21) /* map PA 0xbfc00000 at VA 0xbfc00000 */
+	.org pte1 + (TTY_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
+	.org pte1 + (EXIT_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
+	.org pte1 + 8192
+	.word 0
+
Index: trunk/softs/tests_cc_vcache/test_exception_epc_modify/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_exception_epc_modify/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_exception_epc_modify/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_exception_epc_modify/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_exception_epc_modify/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_exception_epc_modify/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^eret$" run.out > /dev/null
+	if [ $? -eq 0 ]; then
+		return 0;
+	fi
+	echo "couldn't find string in output - mtty not working ?" >> run.out
+	return 1
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_exception_epc_modify/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_exception_epc_modify/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_exception_epc_modify/test.S	(revision 520)
@@ -0,0 +1,71 @@
+/*
+ * Check that on return from exception the modified EPC is handled.
+ * We use a load to an unaligned address to trigger the exception.
+ */
+#include <registers.h>
+#include <misc.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+
+	li	a0, 1
+	lw	a0, 0(a0) /* fault */
+
+	/* we shouldn't get there */
+	EXIT(1)
+
+	.globl exret
+
+exret:
+	PRINT(eretstr)
+	EXIT(0)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PUTCHAR('\n')
+	la	a0, exret
+	mtc0	a0, COP0_EXPC
+	eret
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+startstr: .ascii "start\n\0"
+eretstr: .ascii "eret\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+	.data
+myvar:	.word 0
Index: trunk/softs/tests_cc_vcache/test_exceptions/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_exceptions/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_exceptions/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_exceptions/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_exceptions/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_exceptions/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^status 0x00400006 cause 0x00000010 pc 0xBFC0001C badva 0x00000001$" run.out > /dev/null
+	if [ $? -eq 0 ]; then
+		return 0;
+	fi
+	echo "couldn't find string in output - mtty not working ?" >> run.out
+	return 1
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_exceptions/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_exceptions/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_exceptions/test.S	(revision 520)
@@ -0,0 +1,60 @@
+/*
+ * Check that the exeption vector is called on exception.
+ * We use a load to an unaligned address to trigger the exception.
+ */
+#include <registers.h>
+#include <misc.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	PRINT(startstr)
+
+	li	a0, 1
+	lw	a0, 0(a0) /* fault */
+
+	/* we shouldn't get there */
+        EXIT(1)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	li	a0, '\n'
+	sb	a0, 0(k0)
+
+	EXIT(0)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+startstr: .ascii "start\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+	.data
+myvar:	.word 0
Index: trunk/softs/tests_cc_vcache/test_fpe_delayslot/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_fpe_delayslot/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_fpe_delayslot/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_fpe_delayslot/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_fpe_delayslot/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_fpe_delayslot/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^status 0x00400002 cause 0x80000034 pc 0xBFC00034 badva 0x00000000$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 1 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_fpe_delayslot/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_fpe_delayslot/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_fpe_delayslot/test.S	(revision 520)
@@ -0,0 +1,92 @@
+/*
+ * trap test: check that a trap in a delay slot is
+ * properly handled
+ */
+#include <registers.h>
+#include <misc.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+	la	sp, 0x00400000 - 16
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV), enable cop1 */
+	lui	a0, 0x2040;
+	mtc0	a0, COP0_STATUS
+
+	la	a0, div1
+	lwc1	$f2, 0(a0)
+	la	a0, div2
+	lwc1	$f0, 0(a0)
+	j exit
+	div.s	$f0, $f0, $f2
+	/* we should not get there, */
+	EXIT(2)
+	.globl exit
+exit:
+	move	a0, v0
+	PRINTX
+	PUTCHAR(' ')
+	move	a0, v1
+	PRINTX
+	PUTCHAR('\n')
+	/* we should get there */
+	EXIT(0)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+	PUTCHAR('\n')
+	la	a0, exit
+	mtc0	a0, COP0_EXPC
+	li	v0, MAGIC1
+	li	v1, MAGIC2
+	li	a3, 1
+	eret
+	nop
+
+#we should not end there
+	EXIT(1)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+startstr: .ascii "start\n\0"
+usrstr: .ascii "usrmode\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+	.data
+	.word MAGIC1
+testval:
+	.word MAGIC2
+div1:
+	.float	10.0
+	.globl div2
+div2:
+	.float	0.0
Index: trunk/softs/tests_cc_vcache/test_fpediv/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_fpediv/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_fpediv/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_fpediv/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_fpediv/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_fpediv/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^status 0x00400002 cause 0x00000038 pc 0xBFC00034 badva 0x00000000$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 1 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_fpediv/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_fpediv/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_fpediv/test.S	(revision 520)
@@ -0,0 +1,81 @@
+/*
+ * trap test: check that a we can generate a trap from FPE instruction
+ */
+#include <registers.h>
+#include <misc.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+	la	sp, 0x00400000 - 16
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV), enable cop1 */
+	lui	a0, 0x2040;
+	mtc0	a0, COP0_STATUS
+	/* enable COP1 exceptions */
+	li	a0, 0x0f80
+	ctc1	a0, $31
+#if 0
+	li	a0, 0xf000
+	ctc1	a0, $26
+#endif
+	la	a0, div1
+	lwc1	$f2, 0(a0)
+	la	a0, div2
+	lwc1	$f0, 0(a0)
+	div.s	$f0, $f2, $f0
+	cfc1	a0, $31
+	PRINTX
+	PUTCHAR('\n')
+	EXIT(2)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+	PUTCHAR('\n')
+#we should end there
+	EXIT(0)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+startstr: .ascii "start\n\0"
+usrstr: .ascii "usrmode\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+	.data
+	.word MAGIC1
+testval:
+	.word MAGIC2
+	.globl div1
+div1:
+	.float	10.0
+	.globl div2
+div2:
+	.float	0.0
Index: trunk/softs/tests_cc_vcache/test_icache_inval_pa/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_icache_inval_pa/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_icache_inval_pa/Makefile	(revision 520)
@@ -0,0 +1,2 @@
+LDSCRIPT=./ldscript
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_icache_inval_pa/ldscript
===================================================================
--- trunk/softs/tests_cc_vcache/test_icache_inval_pa/ldscript	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_icache_inval_pa/ldscript	(revision 520)
@@ -0,0 +1,67 @@
+/*
+ *
+ * SOCLIB_GPL_HEADER_BEGIN
+ * 
+ * This file is part of SoCLib, GNU GPLv2.
+ * 
+ * SoCLib is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ * 
+ * SoCLib is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with SoCLib; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ * 
+ * SOCLIB_GPL_HEADER_END
+ *
+ * Copyright (c) UPMC, Lip6, SoC
+ *         Nicolas Pouillon <nipo@ssji.net>, 2006-2007
+ *
+ * Maintainers: abdelmalek.si-merabet@lip6.fr
+ */
+ENTRY(_start)
+
+SECTIONS
+{
+   . = 0xbfc00000;
+   .text : {
+      *(.text)
+/* load .text2 one page after .text */
+      . = ALIGN(0x1000);
+      *(.text2)
+   }
+   .rodata : {
+      *(.rodata)
+      . = ALIGN(4);
+   }
+   . = 0x00000000;
+   .data  : {
+      *(.data)
+   }
+   .sdata : {
+      *(.lit8)
+      *(.lit4)
+      *(.sdata)
+   }
+   _gp = .;
+   . = ALIGN(4);
+   _edata = .;
+   .sbss  : {
+      *(.sbss)
+      *(.scommon)
+   }
+   .bss   : {
+      *(.bss)
+      *(COMMON)
+   }
+   . = ALIGN(4);
+   _end = .;
+   _heap = .;
+   _stack = 0x00400000-16;
+}
Index: trunk/softs/tests_cc_vcache/test_icache_inval_pa/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_icache_inval_pa/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_icache_inval_pa/run	(revision 520)
@@ -0,0 +1,38 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^mmu started before DMA 0x0000DEAD$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 1 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	egrep "^mmu started after DMA 0x0000BEEF$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 2 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	egrep "^mmu started after FLUSH 0x0000BEEF$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 3 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_icache_inval_pa/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_icache_inval_pa/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_icache_inval_pa/test.S	(revision 520)
@@ -0,0 +1,167 @@
+/*
+ * cache inval test: check that VC_ICACHE_INVAL_PA does the job
+ * on a cc_vcache, the cache invalidation/update should be done by hardware
+ * and VC_ICACHE_INVAL_PA should not be needed.
+ */
+#include <registers.h>
+#include <misc.h>
+#include <vcache.h>
+
+#define TEST_ADDRESS 0x200000
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+
+	la	a0, pte1_a
+	srl	a0, a0, 13
+	mtc2	a0, VC_PTPR
+	nop
+
+	li	a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
+	mtc2 	a0, VC_TLB_EN
+
+	PRINT(mmustr_a)
+	#copy 'doload' to TEST_ADDRESS 
+	la	a1, DMA_BASE
+	la	a0, doload 
+	sw      a0, DMA_SRC(a1)
+	la	a0, TEST_ADDRESS
+	sw      a0, DMA_DST(a1)
+        li      a0, 8
+	sw      a0, DMA_LEN(a1) /* start DMA */
+loop1:
+	lw      a0, DMA_LEN(a1)
+	bne     a0, zero, loop1;
+	nop
+	sw	zero, DMA_RESET(a1)
+
+	la	a0, TEST_ADDRESS
+	jalr	a0
+	nop
+	PRINTX
+	PUTCHAR('\n')
+	#copy 'doload2' to TEST_ADDRESS 
+	la	a1, DMA_BASE
+	la	a0, doload2
+	sw      a0, DMA_SRC(a1)
+	la	a0, TEST_ADDRESS
+	sw      a0, DMA_DST(a1)
+        li      a0, 8
+	sw      a0, DMA_LEN(a1) /* start DMA */
+loop2:
+	lw      a0, DMA_LEN(a1)
+	bne     a0, zero, loop2;
+	nop
+	sw	zero, DMA_RESET(a1)
+
+	PRINT(mmustr_b)
+	la	a0, TEST_ADDRESS
+	jalr	a0
+	nop
+	PRINTX
+	PUTCHAR('\n')
+
+        la      a0, TEST_ADDRESS
+	mtc2    a0, VC_DATA_LO
+	mtc2    zero, VC_DATA_HI
+	mtc2    zero, VC_ICACHE_INVAL_PA
+	addi	a0, a0, 4
+	mtc2    a0, VC_DATA_LO
+	mtc2    zero, VC_DATA_HI
+	mtc2    zero, VC_ICACHE_INVAL_PA
+	nop
+
+	PRINT(mmustr_c)
+	la	a0, TEST_ADDRESS
+	jalr	a0
+	nop
+	PRINTX
+	PUTCHAR('\n')
+	/* we should get there */
+	EXIT(0)
+
+	.globl doload
+doload:
+	jr      ra
+	li      a0, MAGIC1
+	/* we should not get there */
+	EXIT(1)
+	nop
+
+	.globl doload2
+doload2:
+	jr ra
+	li      a0, MAGIC2
+	/* we should not get there */
+	EXIT(2)
+	nop
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PUTCHAR('\n')
+	/* we should not get there */
+	EXIT(3)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+mmustr_a: .ascii "mmu started before DMA \0"
+mmustr_b: .ascii "mmu started after DMA \0"
+mmustr_c: .ascii "mmu started after FLUSH \0"
+startstr: .ascii "start\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+
+	.data
+	.word MAGIC1
+testval:
+	.word MAGIC2
+
+	.globl pte1_a
+pte1_a:
+	.align 13
+	.word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */
+	.org pte1_a + (TEST_ADDRESS >> 21) * 4
+	.word PTE1_V | PTE1_C | PTE1_X | (TEST_ADDRESS >> 21) /* map PA 0x200000 at VA 0x200000, read-only/exec */
+	.word 0x0
+	.org pte1_a + (BOOT_ADDRESS >> 21) * 4
+	.word PTE1_V | PTE1_C | PTE1_X | (BOOT_ADDRESS >> 21) /* map PA 0xbfc00000 at VA 0xbfc00000 */
+	.org pte1_a + (TTY_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
+	.org pte1_a + (EXIT_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
+	.org pte1_a + (DMA_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (DMA_BASE >> 21) /* map PA 0xe8000000 at VA 0xe0000000 */
Index: trunk/softs/tests_cc_vcache/test_idtlb_inval/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_idtlb_inval/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_idtlb_inval/Makefile	(revision 520)
@@ -0,0 +1,2 @@
+LDSCRIPT=./ldscript
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_idtlb_inval/ldscript
===================================================================
--- trunk/softs/tests_cc_vcache/test_idtlb_inval/ldscript	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_idtlb_inval/ldscript	(revision 520)
@@ -0,0 +1,67 @@
+/*
+ *
+ * SOCLIB_GPL_HEADER_BEGIN
+ * 
+ * This file is part of SoCLib, GNU GPLv2.
+ * 
+ * SoCLib is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ * 
+ * SoCLib is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with SoCLib; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ * 
+ * SOCLIB_GPL_HEADER_END
+ *
+ * Copyright (c) UPMC, Lip6, SoC
+ *         Nicolas Pouillon <nipo@ssji.net>, 2006-2007
+ *
+ * Maintainers: abdelmalek.si-merabet@lip6.fr
+ */
+ENTRY(_start)
+
+SECTIONS
+{
+   . = 0xbfc00000;
+   .text : {
+      *(.text)
+/* load .text2 one page after .text */
+      . = ALIGN(0x1000);
+      *(.text2)
+   }
+   .rodata : {
+      *(.rodata)
+      . = ALIGN(4);
+   }
+   . = 0x00000000;
+   .data  : {
+      *(.data)
+   }
+   .sdata : {
+      *(.lit8)
+      *(.lit4)
+      *(.sdata)
+   }
+   _gp = .;
+   . = ALIGN(4);
+   _edata = .;
+   .sbss  : {
+      *(.sbss)
+      *(.scommon)
+   }
+   .bss   : {
+      *(.bss)
+      *(COMMON)
+   }
+   . = ALIGN(4);
+   _end = .;
+   _heap = .;
+   _stack = 0x00400000-16;
+}
Index: trunk/softs/tests_cc_vcache/test_idtlb_inval/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_idtlb_inval/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_idtlb_inval/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^mmu started 0x0000BEEF 0x0000DEAD 0x0000DEAD 0x0000BEEF$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_idtlb_inval/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_idtlb_inval/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_idtlb_inval/test.S	(revision 520)
@@ -0,0 +1,158 @@
+/*
+ * itlb inval: a write to a PTE2 should invalidate the corresponding
+ * itlb and dtlb entries. 
+ */
+#include <registers.h>
+#include <misc.h>
+#include <vcache.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+
+	la	a0, pte1_a
+	srl	a0, a0, 13
+	mtc2	a0, VC_PTPR
+	nop
+
+	li	a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
+	mtc2 	a0, VC_TLB_EN
+
+	PRINT(mmustr)
+	/* cause a DTLB miss */
+	la	t0, roval
+	lw	a0, 0(t0)
+	PRINTX
+	PUTCHAR(' ')
+
+	/* cause a itlb miss */
+	jal	doload
+	nop
+	PRINTX
+	PUTCHAR(' ')
+
+	la	t0, pte2_a
+	la	a0, (BOOT_ADDRESS+0x2000) >> 12
+	sw	a0, 12(t0) /* change PTE2 */
+	sync
+1:
+	ll	a0, 8(t0)
+	la	a0, PTE2_V | PTE2_C | PTE2_X
+	sc	a0, 8(t0)
+	beqz	a0, 1b
+	nop
+
+	/* now we should get the second values */
+	la	t0, roval
+	lw	a0, 0(t0)
+	PRINTX
+	PUTCHAR(' ')
+
+	jal	doload 
+	nop
+	PRINTX
+	PUTCHAR('\n')
+	/* we should get there */
+	EXIT(0)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PUTCHAR('\n')
+	/* we should not get there */
+	EXIT(1)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+mmustr: .ascii "mmu started \0"
+startstr: .ascii "start\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+
+	/*
+	 * code that will be switched by MMU switch.
+	 * we use a ldscript trick here, to load this function at
+	 * the appropriate address
+	 */
+	.section .text2, "ax"
+	.globl doload
+doload:
+	jr      ra
+	li      a0, MAGIC1
+	/* we should not get there */
+	EXIT(1)
+	nop
+roval:	.word MAGIC2
+	.align 12
+	.globl doload2
+doload2:
+	jr      ra
+	li      a0, MAGIC2
+	/* we should not get there */
+	EXIT(1)
+	nop
+roval2:	.word MAGIC1
+
+	.data
+	.word MAGIC1
+testval:
+	.word MAGIC2
+	.globl pte2_a
+
+/*
+ * one PD with a level 2 PTP: we change an entry in the PTP and
+ * check that the ITLB has been invalidated
+ */
+pte2_a:
+	.align 12
+	.word PTE2_V | PTE2_C | PTE2_X
+	.word BOOT_ADDRESS >> 12
+	.word PTE2_V | PTE2_C | PTE2_X
+	.word (BOOT_ADDRESS+0x1000) >> 12
+	.org pte2_a + 4092
+	.word 0
+	.globl pte2_b
+	.globl pte1_a
+pte1_a:
+	.align 13
+	.word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */
+	.word 0x0
+	.org pte1_a + (BOOT_ADDRESS >> 21) * 4
+	.word PTE1_V | PTE1_T | (0x1000 >> 12) /* map PA 0xbfc00000 at VA 0xbfc00000 with 4k page: check real address of pte2_a !!! */
+	.org pte1_a + (TTY_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
+	.org pte1_a + (EXIT_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
+	.org pte1_a + 8192
Index: trunk/softs/tests_cc_vcache/test_idtlb_inval2/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_idtlb_inval2/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_idtlb_inval2/Makefile	(revision 520)
@@ -0,0 +1,2 @@
+LDSCRIPT=./ldscript
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_idtlb_inval2/ldscript
===================================================================
--- trunk/softs/tests_cc_vcache/test_idtlb_inval2/ldscript	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_idtlb_inval2/ldscript	(revision 520)
@@ -0,0 +1,67 @@
+/*
+ *
+ * SOCLIB_GPL_HEADER_BEGIN
+ * 
+ * This file is part of SoCLib, GNU GPLv2.
+ * 
+ * SoCLib is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ * 
+ * SoCLib is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with SoCLib; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ * 
+ * SOCLIB_GPL_HEADER_END
+ *
+ * Copyright (c) UPMC, Lip6, SoC
+ *         Nicolas Pouillon <nipo@ssji.net>, 2006-2007
+ *
+ * Maintainers: abdelmalek.si-merabet@lip6.fr
+ */
+ENTRY(_start)
+
+SECTIONS
+{
+   . = 0xbfc00000;
+   .text : {
+      *(.text)
+/* load .text2 one page after .text */
+      . = ALIGN(0x1000);
+      *(.text2)
+   }
+   .rodata : {
+      *(.rodata)
+      . = ALIGN(4);
+   }
+   . = 0x00000000;
+   .data  : {
+      *(.data)
+   }
+   .sdata : {
+      *(.lit8)
+      *(.lit4)
+      *(.sdata)
+   }
+   _gp = .;
+   . = ALIGN(4);
+   _edata = .;
+   .sbss  : {
+      *(.sbss)
+      *(.scommon)
+   }
+   .bss   : {
+      *(.bss)
+      *(COMMON)
+   }
+   . = ALIGN(4);
+   _end = .;
+   _heap = .;
+   _stack = 0x00400000-16;
+}
Index: trunk/softs/tests_cc_vcache/test_idtlb_inval2/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_idtlb_inval2/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_idtlb_inval2/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^mmu started 0x0000BEEF 0x0000DEAD 0x0000DEAD 0x0000BEEF$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_idtlb_inval2/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_idtlb_inval2/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_idtlb_inval2/test.S	(revision 520)
@@ -0,0 +1,160 @@
+/*
+ * itlb inval: a write to a PTE2 should invalidate the corresponding
+ * itlb and dtlb entries. 
+ */
+#include <registers.h>
+#include <misc.h>
+#include <vcache.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+
+	la	a0, pte1_a
+	srl	a0, a0, 13
+	mtc2	a0, VC_PTPR
+	nop
+
+	li	a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
+	mtc2 	a0, VC_TLB_EN
+
+	PRINT(mmustr)
+	/* cause a DTLB miss */
+	la	t0, roval
+	lw	a0, 0(t0)
+	PRINTX
+	PUTCHAR(' ')
+
+	/* cause a itlb miss */
+	jal	doload
+	nop
+	PRINTX
+	PUTCHAR(' ')
+
+	la	t0, pte2_a
+	mtc2 	t0, VC_DTLB_INVAL /* force tlb miss on write */
+	la	a0, (BOOT_ADDRESS+0x2000) >> 12
+	sw	a0, 12(t0) /* change PTE2 */
+	sync
+1:
+	ll	a0, 8(t0)
+	mtc2 	t0, VC_DTLB_INVAL /* force tlb miss on write */
+	la	a0, PTE2_V | PTE2_C | PTE2_X
+	sc	a0, 8(t0)
+	beqz	a0, 1b
+	nop
+
+	/* now we should get the second values */
+	la	t0, roval
+	lw	a0, 0(t0)
+	PRINTX
+	PUTCHAR(' ')
+
+	jal	doload 
+	nop
+	PRINTX
+	PUTCHAR('\n')
+	/* we should get there */
+	EXIT(0)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PUTCHAR('\n')
+	/* we should not get there */
+	EXIT(1)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+mmustr: .ascii "mmu started \0"
+startstr: .ascii "start\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+
+	/*
+	 * code that will be switched by MMU switch.
+	 * we use a ldscript trick here, to load this function at
+	 * the appropriate address
+	 */
+	.section .text2, "ax"
+	.globl doload
+doload:
+	jr      ra
+	li      a0, MAGIC1
+	/* we should not get there */
+	EXIT(1)
+	nop
+roval:	.word MAGIC2
+	.align 12
+	.globl doload2
+doload2:
+	jr      ra
+	li      a0, MAGIC2
+	/* we should not get there */
+	EXIT(1)
+	nop
+roval2:	.word MAGIC1
+
+	.data
+	.word MAGIC1
+testval:
+	.word MAGIC2
+	.globl pte2_a
+
+/*
+ * one PD with a level 2 PTP: we change an entry in the PTP and
+ * check that the ITLB has been invalidated
+ */
+pte2_a:
+	.align 12
+	.word PTE2_V | PTE2_C | PTE2_X
+	.word BOOT_ADDRESS >> 12
+	.word PTE2_V | PTE2_C | PTE2_X
+	.word (BOOT_ADDRESS+0x1000) >> 12
+	.org pte2_a + 4092
+	.word 0
+	.globl pte2_b
+	.globl pte1_a
+pte1_a:
+	.align 13
+	.word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */
+	.word 0x0
+	.org pte1_a + (BOOT_ADDRESS >> 21) * 4
+	.word PTE1_V | PTE1_T | (0x1000 >> 12) /* map PA 0xbfc00000 at VA 0xbfc00000 with 4k page: check real address of pte2_a !!! */
+	.org pte1_a + (TTY_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
+	.org pte1_a + (EXIT_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
+	.org pte1_a + 8192
Index: trunk/softs/tests_cc_vcache/test_idtlb_inval3/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_idtlb_inval3/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_idtlb_inval3/Makefile	(revision 520)
@@ -0,0 +1,2 @@
+LDSCRIPT=./ldscript
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_idtlb_inval3/ldscript
===================================================================
--- trunk/softs/tests_cc_vcache/test_idtlb_inval3/ldscript	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_idtlb_inval3/ldscript	(revision 520)
@@ -0,0 +1,67 @@
+/*
+ *
+ * SOCLIB_GPL_HEADER_BEGIN
+ * 
+ * This file is part of SoCLib, GNU GPLv2.
+ * 
+ * SoCLib is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ * 
+ * SoCLib is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with SoCLib; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ * 
+ * SOCLIB_GPL_HEADER_END
+ *
+ * Copyright (c) UPMC, Lip6, SoC
+ *         Nicolas Pouillon <nipo@ssji.net>, 2006-2007
+ *
+ * Maintainers: abdelmalek.si-merabet@lip6.fr
+ */
+ENTRY(_start)
+
+SECTIONS
+{
+   . = 0xbfc00000;
+   .text : {
+      *(.text)
+/* load .text2 one page after .text */
+      . = ALIGN(0x1000);
+      *(.text2)
+   }
+   .rodata : {
+      *(.rodata)
+      . = ALIGN(4);
+   }
+   . = 0x00000000;
+   .data  : {
+      *(.data)
+   }
+   .sdata : {
+      *(.lit8)
+      *(.lit4)
+      *(.sdata)
+   }
+   _gp = .;
+   . = ALIGN(4);
+   _edata = .;
+   .sbss  : {
+      *(.sbss)
+      *(.scommon)
+   }
+   .bss   : {
+      *(.bss)
+      *(COMMON)
+   }
+   . = ALIGN(4);
+   _end = .;
+   _heap = .;
+   _stack = 0x00400000-16;
+}
Index: trunk/softs/tests_cc_vcache/test_idtlb_inval3/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_idtlb_inval3/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_idtlb_inval3/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^mmu started 0x0000BEEF 0x0000DEAD 0x0000DEAD 0x0000BEEF$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_idtlb_inval3/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_idtlb_inval3/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_idtlb_inval3/test.S	(revision 520)
@@ -0,0 +1,162 @@
+/*
+ * itlb inval: a write to a PTE2 should invalidate the corresponding
+ * itlb and dtlb entries. 
+ */
+#include <registers.h>
+#include <misc.h>
+#include <vcache.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+
+	la	a0, pte1_a
+	srl	a0, a0, 13
+	mtc2	a0, VC_PTPR
+	nop
+
+	li	a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
+	mtc2 	a0, VC_TLB_EN
+
+	PRINT(mmustr)
+	/* cause a DTLB miss */
+	la	t0, roval
+	lw	a0, 0(t0)
+	PRINTX
+	PUTCHAR(' ')
+
+	/* cause a itlb miss */
+	jal	doload
+	nop
+	PRINTX
+	PUTCHAR(' ')
+
+	la	t0, pte2_a
+	mtc2 	t0, VC_DATA_L /* force dcache miss on write */
+	mtc2	zero, VC_DATA_H
+	mtc2	zero, VC_DCACHE_INVAL_PA
+	la	a0, (BOOT_ADDRESS+0x2000) >> 12
+	sw	a0, 12(t0) /* change PTE2 */
+	sync
+1:
+	ll	a0, 8(t0)
+	mtc2 	t0, VC_DTLB_INVAL /* force tlb miss on write */
+	la	a0, PTE2_V | PTE2_C | PTE2_X
+	sc	a0, 8(t0)
+	beqz	a0, 1b
+	nop
+
+	/* now we should get the second values */
+	la	t0, roval
+	lw	a0, 0(t0)
+	PRINTX
+	PUTCHAR(' ')
+
+	jal	doload 
+	nop
+	PRINTX
+	PUTCHAR('\n')
+	/* we should get there */
+	EXIT(0)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PUTCHAR('\n')
+	/* we should not get there */
+	EXIT(1)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+mmustr: .ascii "mmu started \0"
+startstr: .ascii "start\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+
+	/*
+	 * code that will be switched by MMU switch.
+	 * we use a ldscript trick here, to load this function at
+	 * the appropriate address
+	 */
+	.section .text2, "ax"
+	.globl doload
+doload:
+	jr      ra
+	li      a0, MAGIC1
+	/* we should not get there */
+	EXIT(1)
+	nop
+roval:	.word MAGIC2
+	.align 12
+	.globl doload2
+doload2:
+	jr      ra
+	li      a0, MAGIC2
+	/* we should not get there */
+	EXIT(1)
+	nop
+roval2:	.word MAGIC1
+
+	.data
+	.word MAGIC1
+testval:
+	.word MAGIC2
+	.globl pte2_a
+
+/*
+ * one PD with a level 2 PTP: we change an entry in the PTP and
+ * check that the ITLB has been invalidated
+ */
+pte2_a:
+	.align 12
+	.word PTE2_V | PTE2_C | PTE2_X
+	.word BOOT_ADDRESS >> 12
+	.word PTE2_V | PTE2_C | PTE2_X
+	.word (BOOT_ADDRESS+0x1000) >> 12
+	.org pte2_a + 4092
+	.word 0
+	.globl pte2_b
+	.globl pte1_a
+pte1_a:
+	.align 13
+	.word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */
+	.word 0x0
+	.org pte1_a + (BOOT_ADDRESS >> 21) * 4
+	.word PTE1_V | PTE1_T | (0x1000 >> 12) /* map PA 0xbfc00000 at VA 0xbfc00000 with 4k page: check real address of pte2_a !!! */
+	.org pte1_a + (TTY_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
+	.org pte1_a + (EXIT_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
+	.org pte1_a + 8192
Index: trunk/softs/tests_cc_vcache/test_idtlb_inval4/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_idtlb_inval4/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_idtlb_inval4/Makefile	(revision 520)
@@ -0,0 +1,2 @@
+LDSCRIPT=./ldscript
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_idtlb_inval4/ldscript
===================================================================
--- trunk/softs/tests_cc_vcache/test_idtlb_inval4/ldscript	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_idtlb_inval4/ldscript	(revision 520)
@@ -0,0 +1,67 @@
+/*
+ *
+ * SOCLIB_GPL_HEADER_BEGIN
+ * 
+ * This file is part of SoCLib, GNU GPLv2.
+ * 
+ * SoCLib is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ * 
+ * SoCLib is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with SoCLib; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ * 
+ * SOCLIB_GPL_HEADER_END
+ *
+ * Copyright (c) UPMC, Lip6, SoC
+ *         Nicolas Pouillon <nipo@ssji.net>, 2006-2007
+ *
+ * Maintainers: abdelmalek.si-merabet@lip6.fr
+ */
+ENTRY(_start)
+
+SECTIONS
+{
+   . = 0xbfc00000;
+   .text : {
+      *(.text)
+/* load .text2 one page after .text */
+      . = ALIGN(0x1000);
+      *(.text2)
+   }
+   .rodata : {
+      *(.rodata)
+      . = ALIGN(4);
+   }
+   . = 0x00000000;
+   .data  : {
+      *(.data)
+   }
+   .sdata : {
+      *(.lit8)
+      *(.lit4)
+      *(.sdata)
+   }
+   _gp = .;
+   . = ALIGN(4);
+   _edata = .;
+   .sbss  : {
+      *(.sbss)
+      *(.scommon)
+   }
+   .bss   : {
+      *(.bss)
+      *(COMMON)
+   }
+   . = ALIGN(4);
+   _end = .;
+   _heap = .;
+   _stack = 0x00400000-16;
+}
Index: trunk/softs/tests_cc_vcache/test_idtlb_inval4/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_idtlb_inval4/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_idtlb_inval4/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^mmu started 0x0000BEEF 0x0000DEAD 0x0000DEAD 0x0000BEEF$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_idtlb_inval4/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_idtlb_inval4/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_idtlb_inval4/test.S	(revision 520)
@@ -0,0 +1,166 @@
+/*
+ * itlb inval: a write to a PTD1 should invalidate the corresponding
+ * itlb and dtlb entries. 
+ */
+#include <registers.h>
+#include <misc.h>
+#include <vcache.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+
+	la	a0, pte1_a
+	srl	a0, a0, 13
+	mtc2	a0, VC_PTPR
+	nop
+
+	li	a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
+	mtc2 	a0, VC_TLB_EN
+
+	PRINT(mmustr)
+	/* cause a DTLB miss */
+	la	t0, roval
+	lw	a0, 0(t0)
+	PRINTX
+	PUTCHAR(' ')
+
+	/* cause a itlb miss */
+	jal	doload
+	nop
+	PRINTX
+	PUTCHAR(' ')
+
+	la	t0, pte1_ac
+1:
+	ll	a0, 0(t0)
+	la	a0, (0x2000 >> 12) | PTE1_V | PTE1_T /* check real address of pet2_b */
+	sc	a0, 0(t0) /* change PTD1 */
+	beqz	a0, 1b
+	nop
+
+	/* now we should get the second values */
+	la	t0, roval
+	lw	a0, 0(t0)
+	PRINTX
+	PUTCHAR(' ')
+
+	jal	doload 
+	nop
+	PRINTX
+	PUTCHAR('\n')
+	/* we should get there */
+	EXIT(0)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PUTCHAR('\n')
+	/* we should not get there */
+	EXIT(1)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+mmustr: .ascii "mmu started \0"
+startstr: .ascii "start\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+
+	/*
+	 * code that will be switched by MMU switch.
+	 * we use a ldscript trick here, to load this function at
+	 * the appropriate address
+	 */
+	.section .text2, "ax"
+	.globl doload
+doload:
+	jr      ra
+	li      a0, MAGIC1
+	/* we should not get there */
+	EXIT(1)
+	nop
+roval:	.word MAGIC2
+	.align 12
+	.globl doload2
+doload2:
+	jr      ra
+	li      a0, MAGIC2
+	/* we should not get there */
+	EXIT(1)
+	nop
+roval2:	.word MAGIC1
+
+	.data
+	.word MAGIC1
+testval:
+	.word MAGIC2
+	.globl pte2_a
+
+/*
+ * one PD with a level 2 PTP: we change an entry in the PD and
+ * check that the TLBs has been invalidated
+ */
+pte2_a:
+	.align 12
+	.word PTE2_V | PTE2_C | PTE2_X
+	.word BOOT_ADDRESS >> 12
+	.word PTE2_V | PTE2_C | PTE2_X
+	.word (BOOT_ADDRESS+0x1000) >> 12 /* address of doload */
+	.org pte2_a + 4092
+	.word 0
+	.globl pte2_b
+	.globl pte1_a
+pte2_b:
+	.align 12
+	.word PTE2_V | PTE2_C | PTE2_X
+	.word BOOT_ADDRESS >> 12
+	.word PTE2_V | PTE2_C | PTE2_X
+	.word (BOOT_ADDRESS+0x2000) >> 12 /* address of doload2 */
+	.org pte2_b + 4092
+	.word 0
+	.globl pte2_b
+	.globl pte1_a
+pte1_a:
+	.align 13
+	.word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */
+	.word 0x0
+	.org pte1_a + (BOOT_ADDRESS >> 21) * 4
+pte1_ac:
+	.word PTE1_V | PTE1_T | (0x1000 >> 12) /* map PA 0xbfc00000 at VA 0xbfc00000 with 4k page: check real address of pte2_a !!! */
+	.org pte1_a + (TTY_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
+	.org pte1_a + (EXIT_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
+	.org pte1_a + 8192
Index: trunk/softs/tests_cc_vcache/test_idtlb_ptprinval/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_idtlb_ptprinval/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_idtlb_ptprinval/Makefile	(revision 520)
@@ -0,0 +1,2 @@
+LDSCRIPT=./ldscript
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_idtlb_ptprinval/ldscript
===================================================================
--- trunk/softs/tests_cc_vcache/test_idtlb_ptprinval/ldscript	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_idtlb_ptprinval/ldscript	(revision 520)
@@ -0,0 +1,67 @@
+/*
+ *
+ * SOCLIB_GPL_HEADER_BEGIN
+ * 
+ * This file is part of SoCLib, GNU GPLv2.
+ * 
+ * SoCLib is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ * 
+ * SoCLib is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with SoCLib; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ * 
+ * SOCLIB_GPL_HEADER_END
+ *
+ * Copyright (c) UPMC, Lip6, SoC
+ *         Nicolas Pouillon <nipo@ssji.net>, 2006-2007
+ *
+ * Maintainers: abdelmalek.si-merabet@lip6.fr
+ */
+ENTRY(_start)
+
+SECTIONS
+{
+   . = 0xbfc00000;
+   .text : {
+      *(.text)
+/* load .text2 one page after .text */
+      . = ALIGN(0x1000);
+      *(.text2)
+   }
+   .rodata : {
+      *(.rodata)
+      . = ALIGN(4);
+   }
+   . = 0x00000000;
+   .data  : {
+      *(.data)
+   }
+   .sdata : {
+      *(.lit8)
+      *(.lit4)
+      *(.sdata)
+   }
+   _gp = .;
+   . = ALIGN(4);
+   _edata = .;
+   .sbss  : {
+      *(.sbss)
+      *(.scommon)
+   }
+   .bss   : {
+      *(.bss)
+      *(COMMON)
+   }
+   . = ALIGN(4);
+   _end = .;
+   _heap = .;
+   _stack = 0x00400000-16;
+}
Index: trunk/softs/tests_cc_vcache/test_idtlb_ptprinval/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_idtlb_ptprinval/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_idtlb_ptprinval/run	(revision 520)
@@ -0,0 +1,33 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^mmu started ptpr_b 0x0000DEAD 0x0000BEEF$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 1 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	egrep "^mmu started ptpr_a 0x0000BEEF 0x0000DEAD$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 2 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_idtlb_ptprinval/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_idtlb_ptprinval/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_idtlb_ptprinval/test.S	(revision 520)
@@ -0,0 +1,173 @@
+/*
+ * itlb inval on PTPR write: check that no stale entry exists in the itlb
+ * after MMU context swicth
+ */
+#include <registers.h>
+#include <misc.h>
+#include <vcache.h>
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+
+	la	a0, pte1_b
+	srl	a0, a0, 13
+	mtc2	a0, VC_PTPR
+	nop
+
+	li	a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
+	mtc2 	a0, VC_TLB_EN
+
+	PRINT(mmustr_b)
+	la	t0, rodata
+	lw	a0, 0(t0)
+	PRINTX
+	PUTCHAR(' ')
+	jal	doload
+	nop
+	PRINTX
+	PUTCHAR('\n')
+	la	a0, pte1_a
+	srl	a0, a0, 13
+	mtc2	a0, VC_PTPR
+	nop
+#if 0 /* works with this - this shows the old pte2 address is cached */
+	la	a0, pte2_a
+	lw	a1, 12(a0)
+	la	a0, pte2_b
+	sw	a1, 12(a0)
+#endif
+	PRINT(mmustr_a)
+	la	t0, rodata
+	lw	a0, 0(t0)
+	PRINTX
+	PUTCHAR(' ')
+	jal	doload
+	nop
+	PRINTX
+	PUTCHAR('\n')
+
+	/* we should get there */
+	EXIT(0)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PUTCHAR('\n')
+	/* we should not get there */
+	EXIT(3)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+mmustr_a: .ascii "mmu started ptpr_a \0"
+mmustr_b: .ascii "mmu started ptpr_b \0"
+startstr: .ascii "start\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+
+	/*
+	 * code that will be switched by MMU switch.
+	 * we use a ldscript trick here, to load this function at
+	 * the appropriate address
+	 */
+	.section .text2, "ax"
+	.globl doload
+doload:
+	jr      ra
+	li      a0, MAGIC1
+	/* we should not get there */
+	EXIT(1)
+	nop
+rodata:
+	.word MAGIC2
+	.org doload + 0x1000 /* in the second page, mapped by pte1_b */
+	jr ra
+	li      a0, MAGIC2
+	/* we should not get there */
+	EXIT(2)
+	nop
+	.word MAGIC1
+
+	.data
+	.word MAGIC1
+testval:
+	.word MAGIC2
+	.globl pte2_a
+
+/*
+ * two PD with two different PTE2 for code: check that itlb points to
+ * the right one by executing 2 different code at the same address
+ */
+pte2_a:
+	.align 12
+	.word PTE2_V | PTE2_C | PTE2_X
+	.word BOOT_ADDRESS >> 12
+	.word PTE2_V | PTE2_C | PTE2_X
+	.word (BOOT_ADDRESS+0x1000) >> 12
+	.org pte2_a + 4092
+	.word 0
+	.globl pte2_b
+pte2_b:
+	.align 12
+	.word PTE2_V | PTE2_C | PTE2_X
+	.word BOOT_ADDRESS >> 12
+	.word PTE2_V | PTE2_C | PTE2_X
+	.word (BOOT_ADDRESS+0x2000) >> 12
+	.org pte2_b + 4092
+	.word 0
+	.globl pte1_a
+pte1_a:
+	.align 13
+	.word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */
+	.word 0x0
+	.org pte1_a + (BOOT_ADDRESS >> 21) * 4
+	.word PTE1_V | PTE1_T | (0x1000 >> 12) /* map PA 0xbfc00000 at VA 0xbfc00000 with 4k page: check real address of pte2_a !!! */
+	.org pte1_a + (TTY_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
+	.org pte1_a + (EXIT_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
+	.org pte1_a + 8192
+	.globl pte1_b
+pte1_b:
+	.align 13
+	.word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */
+	.word 0x0
+	.org pte1_b + (BOOT_ADDRESS >> 21) * 4
+	.word PTE1_V | PTE1_T | (0x2000 >> 12) /* map PA 0xbfc00000 at VA 0xbfc00000 with 4k page: check real address of pte2_b !!! */
+	.org pte1_b + (TTY_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
+	.org pte1_b + (EXIT_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
+	.org pte1_b + 8188
+	.word 0
Index: trunk/softs/tests_cc_vcache/test_interrupt/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_interrupt/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_interrupt/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_interrupt/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_interrupt/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_interrupt/run	(revision 520)
@@ -0,0 +1,33 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^0x0000DEAD$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 1 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	egrep "^status 0x00400103 cause 0x00000100 pc 0xBFC00038 badva 0x00000000$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 2 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_interrupt/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_interrupt/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_interrupt/test.S	(revision 520)
@@ -0,0 +1,80 @@
+/*
+ * Check that we can take an interrupt, and return from it.
+ * We use a software-triggerted interrupt.
+ */
+#include <registers.h>
+#include <misc.h>
+
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	/* reset cop0 status (keep BEV), enbale soft interrupt 0 */
+	lui     a0, 0x0040;
+	addiu	a0, 0x0101;
+	mtc0    a0, COP0_STATUS
+
+	/* reset cause, make sure IV is off */
+	mtc0	zero, COP0_CAUSE
+
+	PRINT(startstr)
+
+	/* generate an interrupt */
+	mfc0	a0, COP0_CAUSE
+	nop
+	ori	a0, 0x0100
+	mtc0	a0, COP0_CAUSE
+	li	a0, MAGIC1
+	PRINTX
+	PUTCHAR('\n')
+	/* we should end here after taking the exeption */
+	EXIT(0)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PUTCHAR('\n')
+	/* clear interrupt */
+	mfc0	a0, COP0_CAUSE
+	xori	a0, 0x100
+	mtc0	a0, COP0_CAUSE
+	nop
+	eret
+	/* we should not end there */
+	EXIT(1)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+startstr: .ascii "start\n\0"
+eretstr: .ascii "eret\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+	.data
+myvar:	.word 0
Index: trunk/softs/tests_cc_vcache/test_interrupt_delayslot/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_interrupt_delayslot/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_interrupt_delayslot/Makefile	(revision 520)
@@ -0,0 +1,2 @@
+include ../Makefile.inc
+CFLAGS+= -DINTERRUPT_DELAY=${INTERRUPT_DELAY}
Index: trunk/softs/tests_cc_vcache/test_interrupt_delayslot/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_interrupt_delayslot/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_interrupt_delayslot/run	(revision 520)
@@ -0,0 +1,36 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^end 0x0000DEAD$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 1 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	egrep "^status 0x00400403 cause 0x80000000 pc 0xBFC00054 badva 0x00000000 xicu 0x[01][0-9A-F][01][0-9A-F][01][0-9A-F]00$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 2 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+
+for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70; do
+	make clean --quiet
+	make INTERRUPT_DELAY=$i --quiet || exit 1
+    ${SIMUL} > run.out 2>&1 
+	if [ $? -eq 0 ]; then
+		if check_output; then
+			echo "test $i passed";
+			make --quiet clean
+		    exit 0;
+		fi
+	else
+		echo "test FAILED"
+		exit 1
+	fi
+done
+echo "test FAILED"
Index: trunk/softs/tests_cc_vcache/test_interrupt_delayslot/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_interrupt_delayslot/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_interrupt_delayslot/test.S	(revision 520)
@@ -0,0 +1,112 @@
+/*
+ * Check that we can take an interrupt from the xicu timer0
+ */
+#include <registers.h>
+#include <misc.h>
+#include <xicu.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	/* reset cause, make sure IV is off */
+	mtc0	zero, COP0_CAUSE
+
+	PRINT(startstr)
+
+	/* program xicu */
+	la	t0, XICU_BASE
+	/* clear pending interrupt */
+	lw	a0, XICU_PTI_ACK(0)(t0)
+	/* route PTI0 to irq 0 */
+	li	a0, 1 << 0
+	sw	a0, XICU_MSK_PTI_E(0)(t0)
+	/* init s0 */
+	li	s0, MAGIC2
+	/*
+	 * interrupt in INTERRUPT_DELAY cycles.
+	 * Without cache this takes us to the delay slot of the jump.
+	 */
+
+	li	a0, INTERRUPT_DELAY
+	//li	a0, 38
+	sw	a0, XICU_PTI_PER(0)(t0)
+	/* clear pending interrupt */
+	lw	a0, XICU_PTI_ACK(0)(t0)
+	/* reset cop0 status (keep BEV), enable interrupt 0 */
+	lui     a0, 0x0040;
+	addiu	a0, 0x0401;
+	mtc0    a0, COP0_STATUS
+
+	nop
+	nop
+	nop
+	j	end
+	li 	s0, MAGIC1
+	nop
+	/* we should not end there */
+	EXIT(1)
+
+end:
+	PRINT(endstr)
+	move	a0, s0
+	PRINTX
+	PUTCHAR('\n')
+	EXIT(0)
+
+	.globl excep
+excep:
+	.set noreorder
+	/* disable timer0 */
+	la	t0, XICU_BASE
+	sw	zero, XICU_PTI_PER(0)(t0)
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PRINT(xicustr)
+	la	t0, XICU_BASE
+	lw	a0, XICU_PRIO(0)(t0)
+	PRINTX
+
+	PUTCHAR('\n')
+	/* clear interrupt */
+	mfc0	a0, COP0_CAUSE
+	andi	t0, a0, 0xff00
+	xor	a0, a0, t0
+	mtc0	a0, COP0_CAUSE
+	eret
+	/* we should not end there */
+	EXIT(1)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+xicustr: .ascii " xicu \0"
+startstr: .ascii "start\n\0"
+endstr: .ascii "end \0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+	.data
+myvar:	.word 0
Index: trunk/softs/tests_cc_vcache/test_interrupt_epc_modify/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_interrupt_epc_modify/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_interrupt_epc_modify/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_interrupt_epc_modify/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_interrupt_epc_modify/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_interrupt_epc_modify/run	(revision 520)
@@ -0,0 +1,33 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^eret$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 1 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	egrep "^status 0x00400103 cause 0x00000100 pc 0xBFC00038 badva 0x00000000$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 2 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_interrupt_epc_modify/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_interrupt_epc_modify/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_interrupt_epc_modify/test.S	(revision 520)
@@ -0,0 +1,85 @@
+/*
+ * Check that we can take an interrupt, and return to a different address.
+ * We use a software-triggerted interrupt.
+ */
+#include <registers.h>
+#include <misc.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	/* reset cop0 status (keep BEV), enbale soft interrupt 0 */
+	lui     a0, 0x0040;
+	addiu	a0, 0x0101;
+	mtc0    a0, COP0_STATUS
+
+	/* reset cause, make sure IV is off */
+	mtc0	zero, COP0_CAUSE
+
+	PRINT(startstr)
+
+	/* generate an interrupt */
+	mfc0	a0, COP0_CAUSE
+	nop
+	ori	a0, 0x0100
+	mtc0	a0, COP0_CAUSE
+	nop
+	/* we should not end there */
+	EXIT(1)
+
+exret:
+	PRINT(eretstr)
+	EXIT(0)
+
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PUTCHAR('\n')
+	/* clear interrupt */
+	mfc0	a0, COP0_CAUSE
+	xori	a0, 0x100
+	mtc0	a0, COP0_CAUSE
+	nop
+	la	a0, exret
+	mtc0	a0, COP0_EXPC
+	nop
+	eret
+	/* we should not end there */
+	EXIT(1)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+startstr: .ascii "start\n\0"
+eretstr: .ascii "eret\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+	.data
+myvar:	.word 0
Index: trunk/softs/tests_cc_vcache/test_interrupt_extended/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_interrupt_extended/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_interrupt_extended/Makefile	(revision 520)
@@ -0,0 +1,2 @@
+include ../Makefile.inc
+CFLAGS+= -DINTERRUPT_DELAY=${INTERRUPT_DELAY}
Index: trunk/softs/tests_cc_vcache/test_interrupt_extended/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_interrupt_extended/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_interrupt_extended/run	(revision 520)
@@ -0,0 +1,31 @@
+#!/bin/sh 
+
+check_output()
+{
+	egrep "^end 0x0000DEAE$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 1 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	egrep ^status run.out
+	return 0;
+}
+echo 
+for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70; do
+	echo -n "    DELAY=$i: "
+	make INTERRUPT_DELAY=$i --quiet || exit 1
+	../platform/simulation.x > run.out 2>&1 
+	if [ $? -eq 0 ]; then
+		if check_output; then
+			echo "test passsed";
+			make --quiet clean
+		else
+			echo "test FAILED"
+			exit 1
+		fi
+	else 
+		echo "test FAILED"
+		exit 1
+	fi
+done
+
Index: trunk/softs/tests_cc_vcache/test_interrupt_extended/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_interrupt_extended/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_interrupt_extended/test.S	(revision 520)
@@ -0,0 +1,137 @@
+/*
+ * Check interrupt/return with interrup occuring at various points in
+ * the software. Cache is enabled to we have on interrupt/cycle
+ */
+#include <registers.h>
+#include <misc.h>
+#include <vcache.h>
+#include <xicu.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	/* reset cause, make sure IV is off */
+	mtc0	zero, COP0_CAUSE
+
+	la	a0, pte1
+	srl	a0, a0, 13
+	mtc2	a0, VC_PTPR
+	nop
+	nop
+
+	li	a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
+	mtc2 	a0, VC_TLB_EN
+
+	PRINT(startstr)
+
+	/* program xicu */
+	la	t0, XICU_BASE
+	/* clear pending interrupt */
+	lw	a0, XICU_PTI_ACK(0)(t0)
+	/* route PTI0 to irq 0 */
+	li	a0, 1 << 0
+	sw	a0, XICU_MSK_PTI_E(0)(t0)
+	/* init s0 */
+	li	s0, MAGIC2
+	/*
+	 * interrupt in INTERRUPT_DELAY cycles.
+	 */
+	li	a0, INTERRUPT_DELAY
+	sw	a0, XICU_PTI_PER(0)(t0)
+	/* clear pending interrupt */
+	lw	a0, XICU_PTI_ACK(0)(t0)
+	/* reset cop0 status (keep BEV), enable interrupt 0 */
+	lui     a0, 0x0040;
+	addiu	a0, 0x0401;
+	mtc0    a0, COP0_STATUS
+
+	li      s0, MAGIC1
+	addiu	s0, s0, -1
+	addiu	s0, s0, -1
+	addiu	s0, s0, -1
+	addiu	s0, s0, -1
+	nop
+	j	end
+	addiu	s0, s0, 5
+	nop
+	/* we should not end there */
+	EXIT(1)
+
+end:
+	PRINT(endstr)
+	move	a0, s0
+	PRINTX
+	PUTCHAR('\n')
+	EXIT(0)
+
+	.globl excep
+excep:
+	.set noreorder
+	/* disable timer0 */
+	la	t0, XICU_BASE
+	sw	zero, XICU_PTI_PER(0)(t0)
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PRINT(xicustr)
+	la	t0, XICU_BASE
+	lw	a0, XICU_PRIO(0)(t0)
+	PRINTX
+
+	PUTCHAR('\n')
+	/* clear interrupt */
+	mfc0	a0, COP0_CAUSE
+	andi	t0, a0, 0xff00
+	xor	a0, a0, t0
+	mtc0	a0, COP0_CAUSE
+	eret
+	/* we should not end there */
+	EXIT(1)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+xicustr: .ascii " xicu \0"
+startstr: .ascii "start\n\0"
+endstr: .ascii "end \0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+	.data
+myvar:	.word 0
+pte1:
+	.align 13
+	.word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */
+	.org pte1 + (BOOT_ADDRESS >> 21) * 4
+	.word PTE1_V | PTE1_C | PTE1_X | (BOOT_ADDRESS >> 21) /* map PA 0xbfc00000 at VA 0xbfc00000 */
+	.org pte1 + (TTY_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
+	.org pte1 + (XICU_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (XICU_BASE >> 21) /* map PA 0xd2000000 at VA 0xd2000000 */
+	.org pte1 + (EXIT_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
+	.org pte1 + 8192
+	.word 0
+
Index: trunk/softs/tests_cc_vcache/test_interrupt_extended2/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_interrupt_extended2/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_interrupt_extended2/Makefile	(revision 520)
@@ -0,0 +1,2 @@
+include ../Makefile.inc
+CFLAGS+= -DINTERRUPT_DELAY=${INTERRUPT_DELAY}
Index: trunk/softs/tests_cc_vcache/test_interrupt_extended2/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_interrupt_extended2/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_interrupt_extended2/run	(revision 520)
@@ -0,0 +1,31 @@
+#!/bin/sh 
+
+check_output()
+{
+	egrep "^end 0x0000DEAD 0x0000BEF0$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 1 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	egrep "^status 0x00400403" run.out
+	return 0;
+}
+echo 
+for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99; do
+	echo -n "    DELAY=$i: "
+	make INTERRUPT_DELAY=$i --quiet || exit 1
+	../platform/simulation.x > run.out 2>&1 
+	if [ $? -eq 0 ]; then
+		if check_output; then
+			echo "test passsed";
+			make --quiet clean
+		else
+			echo "test FAILED"
+			exit 1
+		fi
+	else 
+		echo "test FAILED"
+		exit 1
+	fi
+done
+
Index: trunk/softs/tests_cc_vcache/test_interrupt_extended2/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_interrupt_extended2/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_interrupt_extended2/test.S	(revision 520)
@@ -0,0 +1,181 @@
+/*
+ * Check interrupt/return with interrup occuring at various points in
+ * the software. Cache is enabled to we have on interrupt/cycle
+ */
+#include <registers.h>
+#include <misc.h>
+#include <vcache.h>
+#include <xicu.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	/* reset cause, make sure IV is off */
+	mtc0	zero, COP0_CAUSE
+
+	la	a0, pte1
+	srl	a0, a0, 13
+	mtc2	a0, VC_PTPR
+	nop
+	nop
+
+	li	a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
+	mtc2 	a0, VC_TLB_EN
+
+	PRINT(startstr)
+
+	/* program xicu */
+	la	t0, XICU_BASE
+	/* clear pending interrupt */
+	lw	a0, XICU_PTI_ACK(0)(t0)
+	/* route PTI0 to irq 0 */
+	li	a0, 1 << 0
+	sw	a0, XICU_MSK_PTI_E(0)(t0)
+	/* init s0 */
+	li	s0, MAGIC2
+
+	/* reset cop0 status (keep BEV), enable soft interrupt 0 */
+	lui     a0, 0x0040;
+	addiu	a0, 0x0101;
+	mtc0    a0, COP0_STATUS
+#if 1
+	/* trigger soft interrupt, so that exept is in cache */
+	mfc0    a0, COP0_CAUSE
+	ori     a0, 0x0100
+	mtc0    a0, COP0_CAUSE
+	nop
+#endif
+
+	/*
+	 * interrupt in INTERRUPT_DELAY cycles.
+	 */
+	la	t0, XICU_BASE
+	li	a0, INTERRUPT_DELAY
+	sw	a0, XICU_PTI_PER(0)(t0)
+	/* clear pending interrupt */
+	lw	a0, XICU_PTI_ACK(0)(t0)
+	/* reset cop0 status (keep BEV), enable interrupt 0 */
+	lui     a0, 0x0040;
+	addiu	a0, 0x0401;
+	mtc0    a0, COP0_STATUS
+
+	li      s0, MAGIC1
+	li      s1, MAGIC2
+	addiu	s0, s0, -1
+	jal	incr
+	nop
+	addiu	s0, s0, -1
+	jal	incr
+	nop
+	addiu	s0, s0, -1
+	jal	incr
+	nop
+	addiu	s0, s0, -1
+	jal	incr
+	nop
+	j	end
+	addiu	s1, s1, 5
+	nop
+	/* we should not end there */
+	EXIT(1)
+
+	.align 6
+	nop
+incr:
+	addiu	s1, s1, -1
+	j	ra
+	addiu	s0, s0, 1
+
+	.align 6
+end:
+	PRINT(endstr)
+	move	a0, s0
+	PRINTX
+	PUTCHAR(' ')
+	move	a0, s1
+	PRINTX
+	PUTCHAR('\n')
+	EXIT(0)
+fail:
+	EXIT(4)
+
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+xicustr: .ascii " xicu \0"
+startstr: .ascii "start\n\0"
+endstr: .ascii "end \0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl excep
+excep:
+	.set noreorder
+	move	s2, ra
+	mfc0	a0, COP0_CAUSE
+	andi	a0, a0, 0x0400
+	beq	a0, zero, softint
+	nop
+	/* disable timer0 */
+	la	t0, XICU_BASE
+	sw	zero, XICU_PTI_PER(0)(t0)
+
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PRINT(xicustr)
+	la	t0, XICU_BASE
+	lw	a0, XICU_PRIO(0)(t0)
+	PRINTX
+
+	PUTCHAR('\n')
+softint:
+	/* clear interrupt */
+	mfc0	a0, COP0_CAUSE
+	andi	t0, a0, 0xff00
+	xor	a0, a0, t0
+	mtc0	a0, COP0_CAUSE
+	/* fluch cache line of incr */
+	la	a0, incr
+	mtc2	a0, VC_ICACHE_INVAL
+	//mtc2	a0, VC_ITLB_INVAL
+	move	ra, s2
+	la	s2, fail
+	eret
+	/* we should not end there */
+	EXIT(3)
+	.data
+myvar:	.word 0
+pte1:
+	.align 13
+	.word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */
+	.org pte1 + (BOOT_ADDRESS >> 21) * 4
+	.word PTE1_V | PTE1_C | PTE1_X | (BOOT_ADDRESS >> 21) /* map PA 0xbfc00000 at VA 0xbfc00000 */
+	.org pte1 + (TTY_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
+	.org pte1 + (XICU_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (XICU_BASE >> 21) /* map PA 0xd2000000 at VA 0xd2000000 */
+	.org pte1 + (EXIT_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
+	.org pte1 + 8192
+	.word 0
+
Index: trunk/softs/tests_cc_vcache/test_interrupt_external_mask/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_interrupt_external_mask/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_interrupt_external_mask/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_interrupt_external_mask/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_interrupt_external_mask/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_interrupt_external_mask/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^status 0x0040CC03 cause 0x00000400 pc 0xBFC00088 badva 0x00000000 xicu 0x[01][0-9A-F][01][0-9A-F]0001$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_interrupt_external_mask/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_interrupt_external_mask/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_interrupt_external_mask/test.S	(revision 520)
@@ -0,0 +1,110 @@
+/*
+ * Check that we can mask an external interrupt
+ */
+#include <registers.h>
+#include <misc.h>
+#include <xicu.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	/* reset cop0 status (keep BEV), enable interrupt 0 */
+	lui     a0, 0x0040;
+	ori	a0, 0xc801;
+	mtc0    a0, COP0_STATUS
+
+	/* reset cause, make sure IV is off */
+	mtc0	zero, COP0_CAUSE
+
+	PRINT(startstr)
+
+	/* program xicu */
+	la	t0, XICU_BASE
+	/* clear pending interrupt */
+	lw	a0, XICU_PTI_ACK(0)(t0)
+	/* route PTI0 to irq 0 */
+	li	a0, 1 << 0
+	sw	a0, XICU_MSK_PTI_E(0)(t0)
+	/* interrupt in 10 cycles */
+	li	a0, 10
+	sw	a0, XICU_PTI_PER(0)(t0)
+	/* interrupts still disabled at the MIPS level */
+	li	a0, MAGIC1
+	PRINTX
+	PUTCHAR('\n')
+	nop
+	nop
+	nop
+	nop
+	nop
+	nop
+	nop
+	nop
+	nop
+	nop
+	/* enable interrupt from timer0 */
+	mfc0	a0, COP0_STATUS
+	ori	a0, 0x0400
+	mtc0	a0, COP0_STATUS
+
+	nop
+	nop
+
+1:	j 1b
+	nop
+	/* we should not end there */
+	EXIT(1)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PRINT(xicustr)
+	la	t0, XICU_BASE
+	lw	a0, XICU_PRIO(0)(t0)
+	PRINTX
+
+	PUTCHAR('\n')
+	/* clear interrupt */
+	mfc0	a0, COP0_CAUSE
+	andi	t0, a0, 0xff00
+	xor	a0, a0, t0
+	mtc0	a0, COP0_CAUSE
+	/* we should end there */
+	EXIT(0)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+xicustr: .ascii " xicu \0"
+startstr: .ascii "start\n\0"
+eretstr: .ascii "eret\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+	.data
+myvar:	.word 0
Index: trunk/softs/tests_cc_vcache/test_interrupt_loop_tmp/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_interrupt_loop_tmp/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_interrupt_loop_tmp/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_interrupt_loop_tmp/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_interrupt_loop_tmp/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_interrupt_loop_tmp/run	(revision 520)
@@ -0,0 +1,12 @@
+#!/bin/sh 
+
+make --quiet || exit 1
+../platform/simulation.x > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	echo "test passsed";
+	make --quiet clean
+	exit 0;
+fi
+echo "test failed"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_interrupt_loop_tmp/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_interrupt_loop_tmp/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_interrupt_loop_tmp/test.S	(revision 520)
@@ -0,0 +1,166 @@
+/*
+ * Check interrupt/return with interrup occuring at various points in
+ * the software. Cache is enabled to we have on interrupt/cycle
+ */
+#include <registers.h>
+#include <misc.h>
+#include <vcache.h>
+#include <xicu.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	/* reset cause, make sure IV is off */
+	mtc0	zero, COP0_CAUSE
+
+	la	a0, pte1
+	srl	a0, a0, 13
+	mtc2	a0, VC_PTPR
+	nop
+
+	li	a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
+	mtc2 	a0, VC_TLB_EN
+
+	PRINT(startstr)
+
+	/* program xicu */
+	la	t0, XICU_BASE
+	/* clear pending interrupt */
+	lw	a0, XICU_PTI_ACK(0)(t0)
+	/* route PTI0 to irq 0 */
+	li	a0, 1 << 0
+	sw	a0, XICU_MSK_PTI_E(0)(t0)
+	/* init s0 */
+	li	s0, MAGIC2
+	/*
+	 * interrupt in INTERRUPT_DELAY cycles.
+	 */
+	li	s2, 1
+	sw	s2, XICU_PTI_PER(0)(t0)
+	/* clear pending interrupt */
+	lw	a0, XICU_PTI_ACK(0)(t0)
+	/* reset cop0 status (keep BEV), enable interrupt 0 */
+	lui     a0, 0x0040;
+	addiu	a0, 0x0401;
+	mtc0    a0, COP0_STATUS
+
+	nop
+	li      s0, MAGIC1
+	addiu	s0, s0, -1
+loop:	
+	addiu	s0, s0, -1
+	addiu	s0, s0, -1
+	addiu	s0, s0, -1
+	j	bla
+	addiu	s0, s0, 5
+	EXIT(1)
+	addiu	s0, s0, -1
+	.align 6
+bla:
+	addiu	s0, s0, -1
+	li		s1, MAGIC1
+	beq	    s0, s1, loop
+	addiu	s0, s0, -1
+
+	/* we should not end there */
+	EXIT(1)
+
+	.align 6
+end:
+	PRINT(endstr)
+	move	a0, s0
+	PRINTX
+	PUTCHAR('\n')
+	EXIT(0)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+xicustr: .ascii " xicu \0"
+startstr: .ascii "start\n\0"
+perstr: .ascii " period \0"
+endstr: .ascii "end \0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl excep
+excep:
+	.set noreorder
+	addiu	s0, s0, -10
+	/* disable timer0 */
+	la	t0, XICU_BASE
+	sw	zero, XICU_PTI_PER(0)(t0)
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PRINT(xicustr)
+	la	t0, XICU_BASE
+	lw	a0, XICU_PRIO(0)(t0)
+	PRINTX
+
+//	PRINT(perstr)
+//	move a0, s2
+//	PRINTX
+//
+	PUTCHAR('\n')
+
+#if 0
+	andi s3, s2, 1
+	beqz s3, noflush
+#endif
+	addiu	s0, s0, 10
+
+#if 1
+	// Flush cache of jump routine
+	la s3, bla
+	mtc2 s3, VC_ICACHE_INVAL
+	mtc2 s3, VC_ITLB_INVAL
+#endif
+		
+noflush:
+	addiu s2, s2, 1
+	li s3, 194*2
+	beq s2, s3, end2
+	srl s3, s2, 1
+	la	t0, XICU_BASE
+	sw	s3, XICU_PTI_PER(0)(t0)
+	eret
+	/* we should not end there */
+	EXIT(1)
+end2:
+	EXIT(0)
+
+	.data
+myvar:	.word 0
+pte1:
+	.align 13
+	.word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */
+	.org pte1 + (BOOT_ADDRESS >> 21) * 4
+	.word PTE1_V | PTE1_C | PTE1_X | (BOOT_ADDRESS >> 21) /* map PA 0xbfc00000 at VA 0xbfc00000 */
+	.org pte1 + (TTY_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
+	.org pte1 + (XICU_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (XICU_BASE >> 21) /* map PA 0xd2000000 at VA 0xd2000000 */
+	.org pte1 + (EXIT_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
+	.org pte1 + 8192
+	.word 0
+
Index: trunk/softs/tests_cc_vcache/test_interrupt_mask/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_interrupt_mask/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_interrupt_mask/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_interrupt_mask/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_interrupt_mask/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_interrupt_mask/run	(revision 520)
@@ -0,0 +1,33 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^0x0000BEEF$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 1 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	egrep "^status 0x0040FF03 cause 0x00000100 pc 0xBFC00074 badva 0x00000000$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 2 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_interrupt_mask/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_interrupt_mask/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_interrupt_mask/test.S	(revision 520)
@@ -0,0 +1,95 @@
+/*
+ * Check that the interrupt mask in status is properly handled:
+ * we generate a software-triggerted interrupt with interrupt enabled but
+ * the software interrupt masked. Later we unmask it.
+ */
+#include <registers.h>
+#include <misc.h>
+
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	/* reset cop0 status (keep BEV), enbale interrupts but mask IM0 */
+	lui     a0, 0x0040;
+	ori	a0, 0xfe01;
+	mtc0    a0, COP0_STATUS
+
+	/* reset cause, make sure IV is off */
+	mtc0	zero, COP0_CAUSE
+
+	PRINT(startstr)
+
+	/* generate an interrupt */
+	mfc0	a0, COP0_CAUSE
+	nop
+	ori	a0, 0x0100
+	mtc0	a0, COP0_CAUSE
+	li	a0, MAGIC1
+	PRINTX
+	PUTCHAR('\n')
+	nop
+	nop
+	nop
+	nop
+	nop
+	nop
+	/* unmask the interrupt */
+	mfc0	a0, COP0_STATUS
+	nop
+	ori	a0, 0x0100
+	mtc0	a0, COP0_STATUS
+	/* we should end here after taking the exeption */
+	li	a0, MAGIC2
+	PRINTX
+	PUTCHAR('\n')
+	EXIT(0)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PUTCHAR('\n')
+	/* clear interrupt */
+	mfc0	a0, COP0_CAUSE
+	xori	a0, 0x100
+	mtc0	a0, COP0_CAUSE
+	nop
+	eret
+	/* we should not end there */
+	EXIT(1)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+startstr: .ascii "start\n\0"
+eretstr: .ascii "eret\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+	.data
+myvar:	.word 0
Index: trunk/softs/tests_cc_vcache/test_itlb_inval/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_itlb_inval/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_itlb_inval/Makefile	(revision 520)
@@ -0,0 +1,2 @@
+LDSCRIPT=./ldscript
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_itlb_inval/ldscript
===================================================================
--- trunk/softs/tests_cc_vcache/test_itlb_inval/ldscript	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_itlb_inval/ldscript	(revision 520)
@@ -0,0 +1,67 @@
+/*
+ *
+ * SOCLIB_GPL_HEADER_BEGIN
+ * 
+ * This file is part of SoCLib, GNU GPLv2.
+ * 
+ * SoCLib is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ * 
+ * SoCLib is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with SoCLib; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ * 
+ * SOCLIB_GPL_HEADER_END
+ *
+ * Copyright (c) UPMC, Lip6, SoC
+ *         Nicolas Pouillon <nipo@ssji.net>, 2006-2007
+ *
+ * Maintainers: abdelmalek.si-merabet@lip6.fr
+ */
+ENTRY(_start)
+
+SECTIONS
+{
+   . = 0xbfc00000;
+   .text : {
+      *(.text)
+/* load .text2 one page after .text */
+      . = ALIGN(0x1000);
+      *(.text2)
+   }
+   .rodata : {
+      *(.rodata)
+      . = ALIGN(4);
+   }
+   . = 0x00000000;
+   .data  : {
+      *(.data)
+   }
+   .sdata : {
+      *(.lit8)
+      *(.lit4)
+      *(.sdata)
+   }
+   _gp = .;
+   . = ALIGN(4);
+   _edata = .;
+   .sbss  : {
+      *(.sbss)
+      *(.scommon)
+   }
+   .bss   : {
+      *(.bss)
+      *(COMMON)
+   }
+   . = ALIGN(4);
+   _end = .;
+   _heap = .;
+   _stack = 0x00400000-16;
+}
Index: trunk/softs/tests_cc_vcache/test_itlb_inval/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_itlb_inval/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_itlb_inval/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^mmu started 0x0000DEAD status 0x00400002 cause 0x00000018 pc 0xBFC01000 badva 0x00000000$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_itlb_inval/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_itlb_inval/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_itlb_inval/test.S	(revision 520)
@@ -0,0 +1,135 @@
+/*
+ * itlb inval: a write to VC_ITLB_INVAL should invalidate the corresponding
+ * itlb entry. On a ccvcache, VC_ITLB_INVAL should not be needed, and
+ * the first access after clearing pte2_a should fail
+ */
+#include <registers.h>
+#include <misc.h>
+#include <vcache.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+
+	la	a0, pte1_a
+	srl	a0, a0, 13
+	mtc2	a0, VC_PTPR
+	nop
+
+	li	a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
+	mtc2 	a0, VC_TLB_EN
+
+	PRINT(mmustr)
+	jal	doload
+	nop
+	PRINTX
+	PUTCHAR(' ')
+	la	a0, pte2_a
+	sw	zero, 8(a0) /* invalidate PTE2 */
+	sync
+	la      a0, pte2_a /* make the sync synchronous */
+	jal	doload /* TLB entry not invalidated yet, we can do this */
+	nop
+	PRINTX
+	PUTCHAR('\n')
+	la	a0, doload
+	mtc2	a0, VC_ITLB_INVAL /* invalidate VA */
+	jal	doload /* this should fail now */
+	nop
+	PRINTX
+	PUTCHAR('\n')
+
+	/* we should not get there */
+	EXIT(1)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PUTCHAR('\n')
+	/* we should get there */
+	EXIT(0)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+mmustr: .ascii "mmu started \0"
+startstr: .ascii "start\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+
+	/*
+	 * code that will be switched by MMU switch.
+	 * we use a ldscript trick here, to load this function at
+	 * the appropriate address
+	 */
+	.section .text2, "ax"
+	.globl doload
+doload:
+	jr      ra
+	li      a0, MAGIC1
+	/* we should not get there */
+	EXIT(1)
+	nop
+
+	.data
+	.word MAGIC1
+testval:
+	.word MAGIC2
+	.globl pte2_a
+
+/*
+ * one PD with a level 2 PTP: we invalidate an entry in the PTP and
+ * check that the VA is no longer accessible
+ */
+pte2_a:
+	.align 12
+	.word PTE2_V | PTE2_C | PTE2_X
+	.word BOOT_ADDRESS >> 12
+	.word PTE2_V | PTE2_C | PTE2_X
+	.word (BOOT_ADDRESS+0x1000) >> 12
+	.org pte2_a + 4092
+	.word 0
+	.globl pte2_b
+	.globl pte1_a
+pte1_a:
+	.align 13
+	.word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */
+	.word 0x0
+	.org pte1_a + (BOOT_ADDRESS >> 21) * 4
+	.word PTE1_V | PTE1_T | (0x1000 >> 12) /* map PA 0xbfc00000 at VA 0xbfc00000 with 4k page: check real address of pte2_a !!! */
+	.org pte1_a + (TTY_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
+	.org pte1_a + (EXIT_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
+	.org pte1_a + 8192
Index: trunk/softs/tests_cc_vcache/test_itlb_inval2/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_itlb_inval2/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_itlb_inval2/Makefile	(revision 520)
@@ -0,0 +1,2 @@
+LDSCRIPT=./ldscript
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_itlb_inval2/ldscript
===================================================================
--- trunk/softs/tests_cc_vcache/test_itlb_inval2/ldscript	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_itlb_inval2/ldscript	(revision 520)
@@ -0,0 +1,67 @@
+/*
+ *
+ * SOCLIB_GPL_HEADER_BEGIN
+ * 
+ * This file is part of SoCLib, GNU GPLv2.
+ * 
+ * SoCLib is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ * 
+ * SoCLib is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with SoCLib; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ * 
+ * SOCLIB_GPL_HEADER_END
+ *
+ * Copyright (c) UPMC, Lip6, SoC
+ *         Nicolas Pouillon <nipo@ssji.net>, 2006-2007
+ *
+ * Maintainers: abdelmalek.si-merabet@lip6.fr
+ */
+ENTRY(_start)
+
+SECTIONS
+{
+   . = 0xbfc00000;
+   .text : {
+      *(.text)
+/* load .text2 one page after .text */
+      . = ALIGN(0x1000);
+      *(.text2)
+   }
+   .rodata : {
+      *(.rodata)
+      . = ALIGN(4);
+   }
+   . = 0x00000000;
+   .data  : {
+      *(.data)
+   }
+   .sdata : {
+      *(.lit8)
+      *(.lit4)
+      *(.sdata)
+   }
+   _gp = .;
+   . = ALIGN(4);
+   _edata = .;
+   .sbss  : {
+      *(.sbss)
+      *(.scommon)
+   }
+   .bss   : {
+      *(.bss)
+      *(COMMON)
+   }
+   . = ALIGN(4);
+   _end = .;
+   _heap = .;
+   _stack = 0x00400000-16;
+}
Index: trunk/softs/tests_cc_vcache/test_itlb_inval2/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_itlb_inval2/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_itlb_inval2/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^mmu started 0x0000DEAD 0x0000BEEF$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_itlb_inval2/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_itlb_inval2/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_itlb_inval2/test.S	(revision 520)
@@ -0,0 +1,142 @@
+/*
+ * itlb inval: a write to a PTE2 should invalidate the corresponding
+ * itlb entry. 
+ */
+#include <registers.h>
+#include <misc.h>
+#include <vcache.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+
+	la	a0, pte1_a
+	srl	a0, a0, 13
+	mtc2	a0, VC_PTPR
+	nop
+
+	li	a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
+	mtc2 	a0, VC_TLB_EN
+
+	PRINT(mmustr)
+	jal	doload
+	nop
+	PRINTX
+	PUTCHAR(' ')
+	la	t0, pte2_a
+	la	a0, (BOOT_ADDRESS+0x2000) >> 12
+	sw	a0, 12(t0) /* change PTE2 */
+	sync
+1:
+	ll	a0, 8(t0)
+	la	a0, PTE2_V | PTE2_C | PTE2_X
+	sc	a0, 8(t0)
+	beqz	a0, 1b
+	nop
+
+	jal	doload /* now we should get the second value */
+	nop
+	PRINTX
+	PUTCHAR('\n')
+	/* we should get there */
+	EXIT(0)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PUTCHAR('\n')
+	/* we should not get there */
+	EXIT(1)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+mmustr: .ascii "mmu started \0"
+startstr: .ascii "start\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+
+	/*
+	 * code that will be switched by MMU switch.
+	 * we use a ldscript trick here, to load this function at
+	 * the appropriate address
+	 */
+	.section .text2, "ax"
+	.globl doload
+doload:
+	jr      ra
+	li      a0, MAGIC1
+	/* we should not get there */
+	EXIT(1)
+	nop
+	.align 12
+	.globl doload2
+doload2:
+	jr      ra
+	li      a0, MAGIC2
+	/* we should not get there */
+	EXIT(1)
+	nop
+
+	.data
+	.word MAGIC1
+testval:
+	.word MAGIC2
+	.globl pte2_a
+
+/*
+ * one PD with a level 2 PTP: we change an entry in the PTP and
+ * check that the ITLB has been invalidated
+ */
+pte2_a:
+	.align 12
+	.word PTE2_V | PTE2_C | PTE2_X
+	.word BOOT_ADDRESS >> 12
+	.word PTE2_V | PTE2_C | PTE2_X
+	.word (BOOT_ADDRESS+0x1000) >> 12
+	.org pte2_a + 4092
+	.word 0
+	.globl pte2_b
+	.globl pte1_a
+pte1_a:
+	.align 13
+	.word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */
+	.word 0x0
+	.org pte1_a + (BOOT_ADDRESS >> 21) * 4
+	.word PTE1_V | PTE1_T | (0x1000 >> 12) /* map PA 0xbfc00000 at VA 0xbfc00000 with 4k page: check real address of pte2_a !!! */
+	.org pte1_a + (TTY_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
+	.org pte1_a + (EXIT_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
+	.org pte1_a + 8192
Index: trunk/softs/tests_cc_vcache/test_itlb_ptprinval/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_itlb_ptprinval/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_itlb_ptprinval/Makefile	(revision 520)
@@ -0,0 +1,2 @@
+LDSCRIPT=./ldscript
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_itlb_ptprinval/ldscript
===================================================================
--- trunk/softs/tests_cc_vcache/test_itlb_ptprinval/ldscript	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_itlb_ptprinval/ldscript	(revision 520)
@@ -0,0 +1,67 @@
+/*
+ *
+ * SOCLIB_GPL_HEADER_BEGIN
+ * 
+ * This file is part of SoCLib, GNU GPLv2.
+ * 
+ * SoCLib is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ * 
+ * SoCLib is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with SoCLib; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ * 
+ * SOCLIB_GPL_HEADER_END
+ *
+ * Copyright (c) UPMC, Lip6, SoC
+ *         Nicolas Pouillon <nipo@ssji.net>, 2006-2007
+ *
+ * Maintainers: abdelmalek.si-merabet@lip6.fr
+ */
+ENTRY(_start)
+
+SECTIONS
+{
+   . = 0xbfc00000;
+   .text : {
+      *(.text)
+/* load .text2 one page after .text */
+      . = ALIGN(0x1000);
+      *(.text2)
+   }
+   .rodata : {
+      *(.rodata)
+      . = ALIGN(4);
+   }
+   . = 0x00000000;
+   .data  : {
+      *(.data)
+   }
+   .sdata : {
+      *(.lit8)
+      *(.lit4)
+      *(.sdata)
+   }
+   _gp = .;
+   . = ALIGN(4);
+   _edata = .;
+   .sbss  : {
+      *(.sbss)
+      *(.scommon)
+   }
+   .bss   : {
+      *(.bss)
+      *(COMMON)
+   }
+   . = ALIGN(4);
+   _end = .;
+   _heap = .;
+   _stack = 0x00400000-16;
+}
Index: trunk/softs/tests_cc_vcache/test_itlb_ptprinval/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_itlb_ptprinval/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_itlb_ptprinval/run	(revision 520)
@@ -0,0 +1,33 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^mmu started ptpr_b 0x0000BEEF$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 1 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	egrep "^mmu started ptpr_a 0x0000DEAD$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 2 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_itlb_ptprinval/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_itlb_ptprinval/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_itlb_ptprinval/test.S	(revision 520)
@@ -0,0 +1,162 @@
+/*
+ * itlb inval on PTPR write: check that no stale entry exists in the itlb
+ * after MMU context swicth
+ */
+#include <registers.h>
+#include <misc.h>
+#include <vcache.h>
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+
+	la	a0, pte1_b
+	srl	a0, a0, 13
+	mtc2	a0, VC_PTPR
+	nop
+
+	li	a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
+	mtc2 	a0, VC_TLB_EN
+
+	PRINT(mmustr_b)
+	jal	doload
+	nop
+	PRINTX
+	PUTCHAR('\n')
+	la	a0, pte1_a
+	srl	a0, a0, 13
+	mtc2	a0, VC_PTPR
+	nop
+#if 0 /* works with this - this shows the old pte2 address is cached */
+	la	a0, pte2_a
+	lw	a1, 12(a0)
+	la	a0, pte2_b
+	sw	a1, 12(a0)
+#endif
+	PRINT(mmustr_a)
+	jal	doload
+	nop
+	PRINTX
+	PUTCHAR('\n')
+
+	/* we should get there */
+	EXIT(0)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PUTCHAR('\n')
+	/* we should not get there */
+	EXIT(3)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+mmustr_a: .ascii "mmu started ptpr_a \0"
+mmustr_b: .ascii "mmu started ptpr_b \0"
+startstr: .ascii "start\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+
+	/*
+	 * code that will be switched by MMU switch.
+	 * we use a ldscript trick here, to load this function at
+	 * the appropriate address
+	 */
+	.section .text2, "ax"
+	.globl doload
+doload:
+	jr      ra
+	li      a0, MAGIC1
+	/* we should not get there */
+	EXIT(1)
+	nop
+	.org doload + 0x1000 /* in the second page, mapped by pte1_b */
+	jr ra
+	li      a0, MAGIC2
+	/* we should not get there */
+	EXIT(2)
+	nop
+
+	.data
+	.word MAGIC1
+testval:
+	.word MAGIC2
+	.globl pte2_a
+
+/*
+ * two PD with two different PTE2 for code: check that itlb points to
+ * the right one by executing 2 different code at the same address
+ */
+pte2_a:
+	.align 12
+	.word PTE2_V | PTE2_C | PTE2_X
+	.word BOOT_ADDRESS >> 12
+	.word PTE2_V | PTE2_C | PTE2_X
+	.word (BOOT_ADDRESS+0x1000) >> 12
+	.org pte2_a + 4092
+	.word 0
+	.globl pte2_b
+pte2_b:
+	.align 12
+	.word PTE2_V | PTE2_C | PTE2_X
+	.word BOOT_ADDRESS >> 12
+	.word PTE2_V | PTE2_C | PTE2_X
+	.word (BOOT_ADDRESS+0x2000) >> 12
+	.org pte2_b + 4092
+	.word 0
+	.globl pte1_a
+pte1_a:
+	.align 13
+	.word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */
+	.word 0x0
+	.org pte1_a + (BOOT_ADDRESS >> 21) * 4
+	.word PTE1_V | PTE1_T | (0x1000 >> 12) /* map PA 0xbfc00000 at VA 0xbfc00000 with 4k page: check real address of pte2_a !!! */
+	.org pte1_a + (TTY_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
+	.org pte1_a + (EXIT_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
+	.org pte1_a + 8192
+	.globl pte1_b
+pte1_b:
+	.align 13
+	.word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */
+	.word 0x0
+	.org pte1_b + (BOOT_ADDRESS >> 21) * 4
+	.word PTE1_V | PTE1_T | (0x2000 >> 12) /* map PA 0xbfc00000 at VA 0xbfc00000 with 4k page: check real address of pte2_b !!! */
+	.org pte1_b + (TTY_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
+	.org pte1_b + (EXIT_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
+	.org pte1_b + 8188
+	.word 0
Index: trunk/softs/tests_cc_vcache/test_llsc/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_llsc/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_llsc/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_llsc/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_llsc/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_llsc/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^0x0000DEAD 0x0000DEAD 0x0000BEEF 0x0000DEAD$" run.out > /dev/null
+	if [ $? -eq 0 ]; then
+		return 0;
+	fi
+	echo "couldn't find string in output - mtty not working ?" >> run.out
+	return 1
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_llsc/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_llsc/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_llsc/test.S	(revision 520)
@@ -0,0 +1,113 @@
+/*
+ * Check interraction between cached read/write and ll/sc
+ */
+#include <registers.h>
+#include <misc.h>
+#include <vcache.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+
+	la	a0, pte1
+	srl	a0, a0, 13
+	mtc2	a0, VC_PTPR
+	nop
+
+	li	a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
+	mtc2 	a0, VC_TLB_EN
+
+	/* make sure myvar is in cache */
+	la	s1, myvar 
+	lw	a0, 0(s1)
+	PRINTX
+	PUTCHAR(' ')
+
+	/* now write to myvar via ll/sc */
+	la	s1, myvar 
+1:
+	ll	a0, 0(s1)
+	li	a1, MAGIC2
+	sc	a1, 0(s1)
+	beqz	a1, 1b
+	nop
+
+	PRINTX /* print what we read with ll */
+	PUTCHAR(' ')
+
+	la	s1, myvar 
+	lw	a0, 0(s1) /* print the new value */
+	PRINTX
+	PUTCHAR(' ')
+
+	/* restore myvar value via normal write */
+	la	s1, myvar 
+	li	a1, MAGIC1
+	sw	a1, 0(s1)
+
+	/* read myvar */
+	lw	a0, 0(s1)
+	PRINTX
+	PUTCHAR('\n');
+	
+	EXIT(0)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PUTCHAR('\n')
+	/* we should not get there */
+	EXIT(1)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+value:	.word 0x1234abcd
+string: .ascii "hello world \0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+
+	.data
+myvar:	.word MAGIC1
+	.globl pte1
+pte1:
+	.align 13
+	.word PTE1_V | PTE1_W | 0x0 /* map PA 0 at VA 0 */
+	.org pte1 + (BOOT_ADDRESS >> 21) * 4
+	.word PTE1_V | PTE1_C | PTE1_X | (BOOT_ADDRESS >> 21) /* map PA 0xbfc00000 at VA 0xbfc00000 */
+	.org pte1 + (TTY_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
+	.org pte1 + (EXIT_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
+	.org pte1 + 8192
+	.word 0
+
Index: trunk/softs/tests_cc_vcache/test_mmu_basic/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_mmu_basic/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_mmu_basic/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_mmu_basic/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_mmu_basic/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_mmu_basic/run	(revision 520)
@@ -0,0 +1,33 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^0x00200000: 0x0000DEAD$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 1 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	egrep "^0x00000000: status 0x00400006 cause 0x0000001C pc 0xBFC00098 badva 0x00000000$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 2 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_mmu_basic/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_mmu_basic/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_mmu_basic/test.S	(revision 520)
@@ -0,0 +1,102 @@
+/*
+ * Basic MMU checks: we can read mapped addresses, we can't read unmapped
+ * addresses
+ */
+#include <registers.h>
+#include <misc.h>
+#include <vcache.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	PRINT(startstr)
+
+	la	a0, pte1
+	srl	a0, a0, 13
+	mtc2	a0, VC_PTPR
+	nop
+
+	li	a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
+	mtc2 	a0, VC_TLB_EN
+
+	PRINT(mmustr)
+
+	/* we can read our magic number at 0x00200000 */
+	la	s0, 0x00200000
+	move	a0, s0
+	PRINTX
+	PUTCHAR(':')
+	PUTCHAR(' ')
+	lw	a0, 0(s0)
+	PRINTX
+	PUTCHAR('\n')
+	/* but not at 0x00000000 */
+	la	s0, 0x00000000
+	move	a0, s0
+	PRINTX
+	PUTCHAR(':')
+	PUTCHAR(' ')
+	lw	a0, 0(s0) /* this should trigger the exception */
+	PRINTX
+
+	/* we shouldn't get there */
+        EXIT(1)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	li	a0, '\n'
+	sb	a0, 0(k0)
+
+        EXIT(0)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+mmustr:	.ascii "mmu started\n\0"
+startstr: .ascii "start\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+	.data
+testval:
+	.word MAGIC1
+	.align 13
+	.globl pte1
+pte1:
+	.word 0x0                            /* map PA 0 at VA 0 */
+	.word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0x00200000 */
+	.org pte1 + (BOOT_ADDRESS >> 21) * 4
+	.word PTE1_V | PTE1_C | PTE1_X | (BOOT_ADDRESS >> 21) /* map PA 0xbfc00000 at VA 0xbfc00000 */
+	.org pte1 + (TTY_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
+	.org pte1 + (EXIT_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
+	.org pte1 + 8192
+	.word 0
+
Index: trunk/softs/tests_cc_vcache/test_pte2i_ref/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_pte2i_ref/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_pte2i_ref/Makefile	(revision 520)
@@ -0,0 +1,2 @@
+LDSCRIPT=./ldscript
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_pte2i_ref/ldscript
===================================================================
--- trunk/softs/tests_cc_vcache/test_pte2i_ref/ldscript	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_pte2i_ref/ldscript	(revision 520)
@@ -0,0 +1,67 @@
+/*
+ *
+ * SOCLIB_GPL_HEADER_BEGIN
+ * 
+ * This file is part of SoCLib, GNU GPLv2.
+ * 
+ * SoCLib is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ * 
+ * SoCLib is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with SoCLib; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ * 
+ * SOCLIB_GPL_HEADER_END
+ *
+ * Copyright (c) UPMC, Lip6, SoC
+ *         Nicolas Pouillon <nipo@ssji.net>, 2006-2007
+ *
+ * Maintainers: abdelmalek.si-merabet@lip6.fr
+ */
+ENTRY(_start)
+
+SECTIONS
+{
+   . = 0xbfc00000;
+   .text : {
+      *(.text)
+/* load .text2 one page after .text */
+      . = ALIGN(0x1000);
+      *(.text2)
+   }
+   .rodata : {
+      *(.rodata)
+      . = ALIGN(4);
+   }
+   . = 0x00000000;
+   .data  : {
+      *(.data)
+   }
+   .sdata : {
+      *(.lit8)
+      *(.lit4)
+      *(.sdata)
+   }
+   _gp = .;
+   . = ALIGN(4);
+   _edata = .;
+   .sbss  : {
+      *(.sbss)
+      *(.scommon)
+   }
+   .bss   : {
+      *(.bss)
+      *(COMMON)
+   }
+   . = ALIGN(4);
+   _end = .;
+   _heap = .;
+   _stack = 0x00400000-16;
+}
Index: trunk/softs/tests_cc_vcache/test_pte2i_ref/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_pte2i_ref/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_pte2i_ref/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^mmu started 0x8A000000 0xAA000000 0xAA000000$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_pte2i_ref/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_pte2i_ref/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_pte2i_ref/test.S	(revision 520)
@@ -0,0 +1,144 @@
+/*
+ * instruction fetch causes the PTE_L bit to be set
+ */
+#include <registers.h>
+#include <misc.h>
+#include <vcache.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+
+	la	a0, pte1_a
+	srl	a0, a0, 13
+	mtc2	a0, VC_PTPR
+	nop
+
+	li	a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
+	mtc2 	a0, VC_TLB_EN
+
+	PRINT(mmustr)
+	la	s0, pte2_a
+	lw	s1, 8(s0)
+	move	a0, s1
+	PRINTX
+	PUTCHAR(' ')
+	la	a1, PTE2_L
+	and	a0, s1, a1
+	beq	a0, a1, fail /* PTE2_L already set, not good */
+	nop
+	jal	doload /* cause page to be referenced */
+	nop
+	lw	s1, 8(s0)
+	move	a0, s1
+	PRINTX
+	PUTCHAR(' ')
+	la	a1, PTE2_L
+	and	a0, s1, a1
+	bne	a0, a1, fail /* PTE2_L not set not good */
+	nop
+	/* check again, using ll */
+	ll	s1, 8(s0)
+	move	a0, s1
+	PRINTX
+	PUTCHAR('\n')
+	la	a1, PTE2_L
+	and	a0, s1, a1
+	bne	a0, a1, fail /* PTE2_L not set not good */
+	nop
+	EXIT(0)
+fail:
+	/* we should not get there */
+	EXIT(1)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PUTCHAR('\n')
+	/* we should get there */
+	EXIT(0)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+mmustr: .ascii "mmu started \0"
+startstr: .ascii "start\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+
+	/*
+	 * code that will be switched by MMU switch.
+	 * we use a ldscript trick here, to load this function at
+	 * the appropriate address
+	 */
+	.section .text2, "ax"
+	.globl doload
+doload:
+	jr      ra
+	li      a0, MAGIC1
+	/* we should not get there */
+	EXIT(1)
+	nop
+
+	.data
+	.word MAGIC1
+testval:
+	.word MAGIC2
+	.globl pte2_a
+
+/*
+ * one PD with a level 2 PTP: we invalidate an entry in the PTP and
+ * check that the VA is no longer accessible
+ */
+pte2_a:
+	.align 12
+	.word PTE2_V | PTE2_C | PTE2_X
+	.word BOOT_ADDRESS >> 12
+	.word PTE2_V | PTE2_C | PTE2_X
+	.word (BOOT_ADDRESS+0x1000) >> 12
+	.org pte2_a + 4092
+	.word 0
+	.globl pte2_b
+	.globl pte1_a
+pte1_a:
+	.align 13
+	.word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */
+	.word 0x0
+	.org pte1_a + (BOOT_ADDRESS >> 21) * 4
+	.word PTE1_V | PTE1_T | (0x1000 >> 12) /* map PA 0xbfc00000 at VA 0xbfc00000 with 4k page: check real address of pte2_a !!! */
+	.org pte1_a + (TTY_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
+	.org pte1_a + (EXIT_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
+	.org pte1_a + 8192
Index: trunk/softs/tests_cc_vcache/test_pte2ll_ref/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_pte2ll_ref/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_pte2ll_ref/Makefile	(revision 520)
@@ -0,0 +1,2 @@
+LDSCRIPT=./ldscript
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_pte2ll_ref/ldscript
===================================================================
--- trunk/softs/tests_cc_vcache/test_pte2ll_ref/ldscript	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_pte2ll_ref/ldscript	(revision 520)
@@ -0,0 +1,67 @@
+/*
+ *
+ * SOCLIB_GPL_HEADER_BEGIN
+ * 
+ * This file is part of SoCLib, GNU GPLv2.
+ * 
+ * SoCLib is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ * 
+ * SoCLib is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with SoCLib; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ * 
+ * SOCLIB_GPL_HEADER_END
+ *
+ * Copyright (c) UPMC, Lip6, SoC
+ *         Nicolas Pouillon <nipo@ssji.net>, 2006-2007
+ *
+ * Maintainers: abdelmalek.si-merabet@lip6.fr
+ */
+ENTRY(_start)
+
+SECTIONS
+{
+   . = 0xbfc00000;
+   .text : {
+      *(.text)
+/* load .text2 one page after .text */
+      . = ALIGN(0x1000);
+      *(.text2)
+   }
+   .rodata : {
+      *(.rodata)
+      . = ALIGN(4);
+   }
+   . = 0x00000000;
+   .data  : {
+      *(.data)
+   }
+   .sdata : {
+      *(.lit8)
+      *(.lit4)
+      *(.sdata)
+   }
+   _gp = .;
+   . = ALIGN(4);
+   _edata = .;
+   .sbss  : {
+      *(.sbss)
+      *(.scommon)
+   }
+   .bss   : {
+      *(.bss)
+      *(COMMON)
+   }
+   . = ALIGN(4);
+   _end = .;
+   _heap = .;
+   _stack = 0x00400000-16;
+}
Index: trunk/softs/tests_cc_vcache/test_pte2ll_ref/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_pte2ll_ref/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_pte2ll_ref/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^mmu started 0x8A000000 0xAA000000 0xAA000000$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_pte2ll_ref/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_pte2ll_ref/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_pte2ll_ref/test.S	(revision 520)
@@ -0,0 +1,132 @@
+/*
+ * pte2d_ref: a ll to data should set referenced bit in PTE
+ */
+#include <registers.h>
+#include <misc.h>
+#include <vcache.h>
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+
+	la	a0, pte1_a
+	srl	a0, a0, 13
+	mtc2	a0, VC_PTPR
+	nop
+
+	li	a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
+	mtc2 	a0, VC_TLB_EN
+
+	PRINT(mmustr)
+	la 	s0, pte2_a
+	lw	s1, 0(s0) /* get PTE */
+	move	a0, s1
+	PRINTX
+	PUTCHAR(' ')
+	la	a1, PTE2_L
+	and	a0, s1, a1
+	beq	a0, a1, fail /* PTE2_L already set, not good */
+	nop
+
+	la	t0, testval + 0x00200000
+	ll 	a0, 0(t0); /* cause page to be referenced */
+
+	lw	s1, 0(s0) /* get PTE */
+	move	a0, s1
+	PRINTX
+	PUTCHAR(' ')
+	la	a1, PTE2_L
+	and	a0, s1, a1
+	bne	a0, a1, fail /* PTE2_L not set, not good */
+	nop
+
+	/* check again, using ll */
+	ll	s1, 0(s0) /* get PTE */
+	move	a0, s1
+	PRINTX
+	PUTCHAR('\n')
+	la	a1, PTE2_L
+	and	a0, s1, a1
+	bne	a0, a1, fail /* PTE2_L not set, not good */
+	nop
+
+	EXIT(0)
+fail:
+	/* we should not get there */
+	EXIT(1)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PUTCHAR('\n')
+	/* we should get there */
+	EXIT(0)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+mmustr: .ascii "mmu started \0"
+startstr: .ascii "start\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+
+	.data
+	/* first 2 pages is data that will be switched my mmu switch */
+data_a:
+	.word MAGIC1
+testval:
+	.word MAGIC2
+	.globl pte2_a
+/*
+ * one PD with a level 2 PTP: we invalidate an entry in the PTP and
+ * check that the VA is no longer accessible
+ */
+pte2_a:
+	.align 12
+	.word PTE2_V | PTE2_C | PTE2_X
+	.word 0x0000 >> 12 /* check real value of data_a */
+	.org pte2_a + 4092
+	.word 0
+	.globl pte2_b
+	.globl pte1_a
+pte1_a:
+	.align 13
+	.word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */
+	.word PTE1_V | PTE1_T | (0x1000 >> 12) /* map PA 0x0 at VA 0x00200000 via pte2_a */
+	.org pte1_a + (BOOT_ADDRESS >> 21) * 4
+	.word PTE1_V | PTE1_C | PTE1_X | (BOOT_ADDRESS >> 21) /* map PA 0xbfc00000 at VA 0xbfc00000 */
+	.org pte1_a + (TTY_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
+	.org pte1_a + (EXIT_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
+	.org pte1_a + 8192
Index: trunk/softs/tests_cc_vcache/test_pte2lw_ref/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_pte2lw_ref/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_pte2lw_ref/Makefile	(revision 520)
@@ -0,0 +1,2 @@
+LDSCRIPT=./ldscript
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_pte2lw_ref/ldscript
===================================================================
--- trunk/softs/tests_cc_vcache/test_pte2lw_ref/ldscript	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_pte2lw_ref/ldscript	(revision 520)
@@ -0,0 +1,67 @@
+/*
+ *
+ * SOCLIB_GPL_HEADER_BEGIN
+ * 
+ * This file is part of SoCLib, GNU GPLv2.
+ * 
+ * SoCLib is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ * 
+ * SoCLib is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with SoCLib; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ * 
+ * SOCLIB_GPL_HEADER_END
+ *
+ * Copyright (c) UPMC, Lip6, SoC
+ *         Nicolas Pouillon <nipo@ssji.net>, 2006-2007
+ *
+ * Maintainers: abdelmalek.si-merabet@lip6.fr
+ */
+ENTRY(_start)
+
+SECTIONS
+{
+   . = 0xbfc00000;
+   .text : {
+      *(.text)
+/* load .text2 one page after .text */
+      . = ALIGN(0x1000);
+      *(.text2)
+   }
+   .rodata : {
+      *(.rodata)
+      . = ALIGN(4);
+   }
+   . = 0x00000000;
+   .data  : {
+      *(.data)
+   }
+   .sdata : {
+      *(.lit8)
+      *(.lit4)
+      *(.sdata)
+   }
+   _gp = .;
+   . = ALIGN(4);
+   _edata = .;
+   .sbss  : {
+      *(.sbss)
+      *(.scommon)
+   }
+   .bss   : {
+      *(.bss)
+      *(COMMON)
+   }
+   . = ALIGN(4);
+   _end = .;
+   _heap = .;
+   _stack = 0x00400000-16;
+}
Index: trunk/softs/tests_cc_vcache/test_pte2lw_ref/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_pte2lw_ref/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_pte2lw_ref/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^mmu started 0x8A000000 0xAA000000 0xAA000000$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_pte2lw_ref/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_pte2lw_ref/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_pte2lw_ref/test.S	(revision 520)
@@ -0,0 +1,132 @@
+/*
+ * pte2d_ref: a lw to data should set referenced bit in PTE
+ */
+#include <registers.h>
+#include <misc.h>
+#include <vcache.h>
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+
+	la	a0, pte1_a
+	srl	a0, a0, 13
+	mtc2	a0, VC_PTPR
+	nop
+
+	li	a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
+	mtc2 	a0, VC_TLB_EN
+
+	PRINT(mmustr)
+	la 	s0, pte2_a
+	lw	s1, 0(s0) /* get PTE */
+	move	a0, s1
+	PRINTX
+	PUTCHAR(' ')
+	la	a1, PTE2_L
+	and	a0, s1, a1
+	beq	a0, a1, fail /* PTE2_L already set, not good */
+	nop
+
+	la	t0, testval + 0x00200000
+	lw 	a0, 0(t0); /* cause page to be referenced */
+
+	lw	s1, 0(s0) /* get PTE */
+	move	a0, s1
+	PRINTX
+	PUTCHAR(' ')
+	la	a1, PTE2_L
+	and	a0, s1, a1
+	bne	a0, a1, fail /* PTE2_L not set, not good */
+	nop
+
+	/* check again, using ll */
+	ll	s1, 0(s0) /* get PTE */
+	move	a0, s1
+	PRINTX
+	PUTCHAR('\n')
+	la	a1, PTE2_L
+	and	a0, s1, a1
+	bne	a0, a1, fail /* PTE2_L not set, not good */
+	nop
+
+	EXIT(0)
+fail:
+	/* we should not get there */
+	EXIT(1)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PUTCHAR('\n')
+	/* we should get there */
+	EXIT(0)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+mmustr: .ascii "mmu started \0"
+startstr: .ascii "start\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+
+	.data
+	/* first 2 pages is data that will be switched my mmu switch */
+data_a:
+	.word MAGIC1
+testval:
+	.word MAGIC2
+	.globl pte2_a
+/*
+ * one PD with a level 2 PTP: we invalidate an entry in the PTP and
+ * check that the VA is no longer accessible
+ */
+pte2_a:
+	.align 12
+	.word PTE2_V | PTE2_C | PTE2_X
+	.word 0x0000 >> 12 /* check real value of data_a */
+	.org pte2_a + 4092
+	.word 0
+	.globl pte2_b
+	.globl pte1_a
+pte1_a:
+	.align 13
+	.word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */
+	.word PTE1_V | PTE1_T | (0x1000 >> 12) /* map PA 0x0 at VA 0x00200000 via pte2_a */
+	.org pte1_a + (BOOT_ADDRESS >> 21) * 4
+	.word PTE1_V | PTE1_C | PTE1_X | (BOOT_ADDRESS >> 21) /* map PA 0xbfc00000 at VA 0xbfc00000 */
+	.org pte1_a + (TTY_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
+	.org pte1_a + (EXIT_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
+	.org pte1_a + 8192
Index: trunk/softs/tests_cc_vcache/test_pte2sc_dirty/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_pte2sc_dirty/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_pte2sc_dirty/Makefile	(revision 520)
@@ -0,0 +1,2 @@
+LDSCRIPT=./ldscript
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_pte2sc_dirty/ldscript
===================================================================
--- trunk/softs/tests_cc_vcache/test_pte2sc_dirty/ldscript	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_pte2sc_dirty/ldscript	(revision 520)
@@ -0,0 +1,67 @@
+/*
+ *
+ * SOCLIB_GPL_HEADER_BEGIN
+ * 
+ * This file is part of SoCLib, GNU GPLv2.
+ * 
+ * SoCLib is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ * 
+ * SoCLib is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with SoCLib; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ * 
+ * SOCLIB_GPL_HEADER_END
+ *
+ * Copyright (c) UPMC, Lip6, SoC
+ *         Nicolas Pouillon <nipo@ssji.net>, 2006-2007
+ *
+ * Maintainers: abdelmalek.si-merabet@lip6.fr
+ */
+ENTRY(_start)
+
+SECTIONS
+{
+   . = 0xbfc00000;
+   .text : {
+      *(.text)
+/* load .text2 one page after .text */
+      . = ALIGN(0x1000);
+      *(.text2)
+   }
+   .rodata : {
+      *(.rodata)
+      . = ALIGN(4);
+   }
+   . = 0x00000000;
+   .data  : {
+      *(.data)
+   }
+   .sdata : {
+      *(.lit8)
+      *(.lit4)
+      *(.sdata)
+   }
+   _gp = .;
+   . = ALIGN(4);
+   _edata = .;
+   .sbss  : {
+      *(.sbss)
+      *(.scommon)
+   }
+   .bss   : {
+      *(.bss)
+      *(COMMON)
+   }
+   . = ALIGN(4);
+   _end = .;
+   _heap = .;
+   _stack = 0x00400000-16;
+}
Index: trunk/softs/tests_cc_vcache/test_pte2sc_dirty/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_pte2sc_dirty/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_pte2sc_dirty/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^mmu started 0x8E000000 0xAE400000 0xAE400000$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_pte2sc_dirty/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_pte2sc_dirty/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_pte2sc_dirty/test.S	(revision 520)
@@ -0,0 +1,137 @@
+/*
+ * pte2d_ref: a sc to data should set the dirty bits in PTE
+ */
+#include <registers.h>
+#include <misc.h>
+#include <vcache.h>
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+
+	la	a0, pte1_a
+	srl	a0, a0, 13
+	mtc2	a0, VC_PTPR
+	nop
+
+	li	a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
+	mtc2 	a0, VC_TLB_EN
+
+	PRINT(mmustr)
+	la 	s0, pte2_a
+	lw	s1, 0(s0) /* get PTE */
+	move	a0, s1
+	PRINTX
+	PUTCHAR(' ')
+	la	a1, (PTE2_L | PTE2_D)
+	and	a0, s1, a1
+	bne	a0, zero, fail /* PTE2_L or PTE2_D already set, not good */
+	nop
+
+	la	t0, testval + 0x00200000
+	la	a1, MAGIC3
+1:
+	ll	a0, 0(t0)
+	sc 	a1, 0(t0); /* cause page to be referenced and dirty */
+	beqz	a1, 1b
+	nop
+
+	lw	s1, 0(s0) /* get PTE */
+	move	a0, s1
+	PRINTX
+	PUTCHAR(' ')
+	la	a1, (PTE2_L | PTE2_D)
+	and	a0, s1, a1
+	bne	a0, a1, fail /* PTE2_L not set, not good */
+	nop
+
+	/* check again, using ll */
+	ll	s1, 0(s0) /* get PTE */
+	move	a0, s1
+	PRINTX
+	PUTCHAR('\n')
+	la	a1, (PTE2_L | PTE2_D)
+	and	a0, s1, a1
+	bne	a0, a1, fail /* PTE2_L not set, not good */
+	nop
+
+	EXIT(0)
+fail:
+	/* we should not get there */
+	EXIT(1)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PUTCHAR('\n')
+	/* we should get there */
+	EXIT(0)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+mmustr: .ascii "mmu started \0"
+startstr: .ascii "start\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+
+	.data
+	/* first 2 pages is data that will be switched my mmu switch */
+data_a:
+	.word MAGIC1
+testval:
+	.word MAGIC2
+	.globl pte2_a
+/*
+ * one PD with a level 2 PTP: we invalidate an entry in the PTP and
+ * check that the VA is no longer accessible
+ */
+pte2_a:
+	.align 12
+	.word PTE2_V | PTE2_C | PTE2_X | PTE2_W
+	.word 0x0000 >> 12 /* check real value of data_a */
+	.org pte2_a + 4092
+	.word 0
+	.globl pte2_b
+	.globl pte1_a
+pte1_a:
+	.align 13
+	.word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */
+	.word PTE1_V | PTE1_T | (0x1000 >> 12) /* map PA 0x0 at VA 0x00200000 via pte2_a */
+	.org pte1_a + (BOOT_ADDRESS >> 21) * 4
+	.word PTE1_V | PTE1_C | PTE1_X | (BOOT_ADDRESS >> 21) /* map PA 0xbfc00000 at VA 0xbfc00000 */
+	.org pte1_a + (TTY_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
+	.org pte1_a + (EXIT_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
+	.org pte1_a + 8192
Index: trunk/softs/tests_cc_vcache/test_pte2sw_dirty/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_pte2sw_dirty/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_pte2sw_dirty/Makefile	(revision 520)
@@ -0,0 +1,2 @@
+LDSCRIPT=./ldscript
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_pte2sw_dirty/ldscript
===================================================================
--- trunk/softs/tests_cc_vcache/test_pte2sw_dirty/ldscript	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_pte2sw_dirty/ldscript	(revision 520)
@@ -0,0 +1,67 @@
+/*
+ *
+ * SOCLIB_GPL_HEADER_BEGIN
+ * 
+ * This file is part of SoCLib, GNU GPLv2.
+ * 
+ * SoCLib is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ * 
+ * SoCLib is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with SoCLib; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ * 
+ * SOCLIB_GPL_HEADER_END
+ *
+ * Copyright (c) UPMC, Lip6, SoC
+ *         Nicolas Pouillon <nipo@ssji.net>, 2006-2007
+ *
+ * Maintainers: abdelmalek.si-merabet@lip6.fr
+ */
+ENTRY(_start)
+
+SECTIONS
+{
+   . = 0xbfc00000;
+   .text : {
+      *(.text)
+/* load .text2 one page after .text */
+      . = ALIGN(0x1000);
+      *(.text2)
+   }
+   .rodata : {
+      *(.rodata)
+      . = ALIGN(4);
+   }
+   . = 0x00000000;
+   .data  : {
+      *(.data)
+   }
+   .sdata : {
+      *(.lit8)
+      *(.lit4)
+      *(.sdata)
+   }
+   _gp = .;
+   . = ALIGN(4);
+   _edata = .;
+   .sbss  : {
+      *(.sbss)
+      *(.scommon)
+   }
+   .bss   : {
+      *(.bss)
+      *(COMMON)
+   }
+   . = ALIGN(4);
+   _end = .;
+   _heap = .;
+   _stack = 0x00400000-16;
+}
Index: trunk/softs/tests_cc_vcache/test_pte2sw_dirty/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_pte2sw_dirty/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_pte2sw_dirty/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^mmu started 0x8E000000 0xAE400000 0xAE400000$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_pte2sw_dirty/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_pte2sw_dirty/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_pte2sw_dirty/test.S	(revision 520)
@@ -0,0 +1,132 @@
+/*
+ * pte2d_ref: a sw to data should set referenced and dirty bits in PTE
+ */
+#include <registers.h>
+#include <misc.h>
+#include <vcache.h>
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+
+	la	a0, pte1_a
+	srl	a0, a0, 13
+	mtc2	a0, VC_PTPR
+	nop
+
+	li	a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
+	mtc2 	a0, VC_TLB_EN
+
+	PRINT(mmustr)
+	la 	s0, pte2_a
+	lw	s1, 0(s0) /* get PTE */
+	move	a0, s1
+	PRINTX
+	PUTCHAR(' ')
+	la	a1, (PTE2_L | PTE2_D)
+	and	a0, s1, a1
+	bne	a0, zero, fail /* PTE2_L or PTE2_D already set, not good */
+	nop
+
+	la	t0, testval + 0x00200000
+	sw 	a0, 0(t0); /* cause page to be referenced and dirty */
+
+	lw	s1, 0(s0) /* get PTE */
+	move	a0, s1
+	PRINTX
+	PUTCHAR(' ')
+	la	a1, (PTE2_L | PTE2_D)
+	and	a0, s1, a1
+	bne	a0, a1, fail /* PTE2_L not set, not good */
+	nop
+
+	/* check again, using ll */
+	ll	s1, 0(s0) /* get PTE */
+	move	a0, s1
+	PRINTX
+	PUTCHAR('\n')
+	la	a1, (PTE2_L | PTE2_D)
+	and	a0, s1, a1
+	bne	a0, a1, fail /* PTE2_L not set, not good */
+	nop
+
+	EXIT(0)
+fail:
+	/* we should not get there */
+	EXIT(1)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PUTCHAR('\n')
+	/* we should get there */
+	EXIT(0)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+mmustr: .ascii "mmu started \0"
+startstr: .ascii "start\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+
+	.data
+	/* first 2 pages is data that will be switched my mmu switch */
+data_a:
+	.word MAGIC1
+testval:
+	.word MAGIC2
+	.globl pte2_a
+/*
+ * one PD with a level 2 PTP: we invalidate an entry in the PTP and
+ * check that the VA is no longer accessible
+ */
+pte2_a:
+	.align 12
+	.word PTE2_V | PTE2_C | PTE2_X | PTE2_W
+	.word 0x0000 >> 12 /* check real value of data_a */
+	.org pte2_a + 4092
+	.word 0
+	.globl pte2_b
+	.globl pte1_a
+pte1_a:
+	.align 13
+	.word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */
+	.word PTE1_V | PTE1_T | (0x1000 >> 12) /* map PA 0x0 at VA 0x00200000 via pte2_a */
+	.org pte1_a + (BOOT_ADDRESS >> 21) * 4
+	.word PTE1_V | PTE1_C | PTE1_X | (BOOT_ADDRESS >> 21) /* map PA 0xbfc00000 at VA 0xbfc00000 */
+	.org pte1_a + (TTY_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
+	.org pte1_a + (EXIT_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
+	.org pte1_a + 8192
Index: trunk/softs/tests_cc_vcache/test_pte_llsc/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_pte_llsc/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_pte_llsc/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_pte_llsc/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_pte_llsc/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_pte_llsc/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^0x00000000 0xAC4000FF 0xAC4000FF 0x00000000$" run.out > /dev/null
+	if [ $? -eq 0 ]; then
+		return 0;
+	fi
+	echo "couldn't find string in output - mtty not working ?" >> run.out
+	return 1
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_pte_llsc/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_pte_llsc/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_pte_llsc/test.S	(revision 520)
@@ -0,0 +1,124 @@
+/*
+ * Check that the MMU doens't clobber the OS bits in PTEs, and interraction
+ * with ll/sc
+ */
+#include <registers.h>
+#include <misc.h>
+#include <vcache.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+
+	la	a0, pte1
+	srl	a0, a0, 13
+	mtc2	a0, VC_PTPR
+	nop
+
+	li	a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
+	mtc2 	a0, VC_TLB_EN
+
+	/* do a swap of pte2[0] to make the entry valid */
+	la	s0, pte2 + 0x00200000
+1:	la	a1, PTE2_V | PTE2_C | PTE2_W | PTE2_os
+	ll	a0, 0(s0)
+	sc	a1, 0(s0)
+	beqz	a1, 1b
+	nop
+	PRINTX
+	PUTCHAR(' ')
+	/* now write to myvar via pte2[0] */
+	li	a0, MAGIC2
+	la	s1, myvar + 0x00200000
+	sw	a0, 0(s1)
+	/*
+	 * and invalidate pte2[0], again using a swap
+	 * check that we get the same value with lw and ll
+	 */
+	lw	s1, 0(s0)
+2:
+	move	a1, zero
+	ll	a0, 0(s0)
+	sc	a1, 0(s0)
+	beqz	a1, 2b
+	PRINTX
+	PUTCHAR(' ')
+	move	a0, s1
+	PRINTX
+	PUTCHAR(' ')
+	/* finally check what lw tells us now */
+	lw	a0, 0(s0)
+	PRINTX
+	PUTCHAR('\n')
+
+	EXIT(0)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PUTCHAR('\n')
+	/* we should not get there */
+	EXIT(1)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+value:	.word 0x1234abcd
+string: .ascii "hello world \0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+
+	.data
+myvar:	.word MAGIC1
+	.globl pte1
+pte2:
+	.align 12
+	.word 0	/* invalid for now */
+	.word 0x0000 >> 12 /* check real value of myvar */
+	.word PTE2_V | PTE2_C | PTE2_W | PTE2_os /* map pte2 too */
+	.word 0x1000 >> 12 /* check real address of pte2 */
+	.org pte2 + 4092
+	.word 0
+	.globl pte1
+pte1:
+	.align 13
+	.word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */
+	.word PTE1_V | PTE1_T | (0x1000 >> 12) /* map PA 0x0 at VA 0x00200000 via pte2 */
+	.org pte1 + (BOOT_ADDRESS >> 21) * 4
+	.word PTE1_V | PTE1_C | PTE1_X | (BOOT_ADDRESS >> 21) /* map PA 0xbfc00000 at VA 0xbfc00000 */
+	.org pte1 + (TTY_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
+	.org pte1 + (EXIT_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
+	.org pte1 + 8192
+	.word 0
+
Index: trunk/softs/tests_cc_vcache/test_ri/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_ri/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_ri/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_ri/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_ri/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_ri/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^status 0x00400002 cause 0x00000028 pc 0xBFC00034 badva 0x00000000$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 1 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_ri/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_ri/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_ri/test.S	(revision 520)
@@ -0,0 +1,65 @@
+/*
+ * reserved instruction exception test: check that a reserved instruction
+ * generates an exception.
+ */
+#include <registers.h>
+#include <misc.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+	la	sp, 0x00400000 - 16
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+	nop
+	nop
+	nop
+	.word 0x60000000
+	EXIT(2)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+	PUTCHAR('\n')
+#we should end there
+	EXIT(0)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+startstr: .ascii "start\n\0"
+usrstr: .ascii "usrmode\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+	.data
+	.word MAGIC1
+testval:
+	.word MAGIC2
Index: trunk/softs/tests_cc_vcache/test_ri_delayslot/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_ri_delayslot/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_ri_delayslot/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_ri_delayslot/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_ri_delayslot/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_ri_delayslot/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^status 0x00400002 cause 0x80000028 pc 0xBFC00034 badva 0x00000000$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 1 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_ri_delayslot/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_ri_delayslot/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_ri_delayslot/test.S	(revision 520)
@@ -0,0 +1,86 @@
+/*
+ * reserved instruction exception test: check that a reserved instruction
+ * in a delay slot is properly handled
+ */
+#include <registers.h>
+#include <misc.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+	la	sp, 0x00400000 - 16
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+	nop
+	nop
+	nop
+	j	exit
+	.word 0x60000000
+	nop
+	/* we should not get there, */
+	EXIT(2)
+	.globl exit
+exit:
+	move	a0, v0
+	PRINTX
+	PUTCHAR(' ')
+	move	a0, v1
+	PRINTX
+	PUTCHAR('\n')
+	/* we should get there */
+	EXIT(0)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+	PUTCHAR('\n')
+	la	a0, exit
+	mtc0	a0, COP0_EXPC
+	li	v0, MAGIC1
+	li	v1, MAGIC2
+	li	a3, 1
+	eret
+	nop
+
+#we should not end there
+	EXIT(1)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+startstr: .ascii "start\n\0"
+usrstr: .ascii "usrmode\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+	.data
+	.word MAGIC1
+testval:
+	.word MAGIC2
Index: trunk/softs/tests_cc_vcache/test_sanity/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_sanity/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_sanity/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_sanity/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_sanity/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_sanity/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^hello world 0x1234ABCD$" run.out > /dev/null
+	if [ $? -eq 0 ]; then
+		return 0;
+	fi
+	echo "couldn't find string in output - mtty not working ?" >> run.out
+	return 1
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_sanity/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_sanity/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_sanity/test.S	(revision 520)
@@ -0,0 +1,42 @@
+/*
+ * Basic sanity checks:
+ *   we can run a program
+ *   we can write to ram
+ *   we can write to the tty
+ *   we can make the simulator exit
+ */
+#include <registers.h>
+#include <misc.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	la	t0, value
+	lw	t0, 0(t0)
+	la	t1, myvar
+	sw	t0, 0(t1)
+
+	la	a0, string
+	jal	print
+	nop
+
+	la	t1, myvar
+	lw	a0, 0(t1)
+	jal	printx
+	nop
+
+	li	a0, '\n'
+	sb	a0, 0(k0)
+
+	EXIT(0)
+
+	.rodata:
+value:	.word 0x1234abcd
+string: .ascii "hello world \0"
+
+	.data
+myvar:	.word 0
Index: trunk/softs/tests_cc_vcache/test_sc_no_ll/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_sc_no_ll/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_sc_no_ll/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_sc_no_ll/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_sc_no_ll/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_sc_no_ll/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^0x0000DEAD 0x00000000$" run.out > /dev/null
+	if [ $? -eq 0 ]; then
+		return 0;
+	fi
+	echo "couldn't find string in output - mtty not working ?" >> run.out
+	return 1
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_sc_no_ll/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_sc_no_ll/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_sc_no_ll/test.S	(revision 520)
@@ -0,0 +1,104 @@
+/*
+ * check that a sc without ll does fail
+ */
+#include <registers.h>
+#include <misc.h>
+#include <vcache.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+
+	la	a0, pte1
+	srl	a0, a0, 13
+	mtc2	a0, VC_PTPR
+	nop
+
+	li	a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
+	mtc2 	a0, VC_TLB_EN
+
+	/* make sure myvar is in cache */
+	la	s1, myvar 
+	lw	a0, 0(s1)
+	PRINTX
+	PUTCHAR(' ')
+
+	/* now write to myvar with sc, without ll first */
+	la	s1, myvar 
+1:
+	li	a1, MAGIC2
+	sc	a1, 0(s1)
+	beqz	a1, 2f
+	nop
+	
+	move a0, a1
+	PRINTX
+	/* we should not get there */
+	EXIT(1)
+
+2:
+	/* we jump here when the sc failed */
+	move a0, a1
+	PRINTX
+	PUTCHAR('\n');
+	EXIT(0)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PUTCHAR('\n')
+	/* we should not get there */
+	EXIT(1)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+value:	.word 0x1234abcd
+string: .ascii "hello world \0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+
+	.data
+myvar:	.word MAGIC1
+	.globl pte1
+pte1:
+	.align 13
+	.word PTE1_V | PTE1_W | 0x0 /* map PA 0 at VA 0 */
+	.org pte1 + (BOOT_ADDRESS >> 21) * 4
+	.word PTE1_V | PTE1_C | PTE1_X | (BOOT_ADDRESS >> 21) /* map PA 0xbfc00000 at VA 0xbfc00000 */
+	.org pte1 + (TTY_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */
+	.org pte1 + (EXIT_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
+	.org pte1 + 8192
+	.word 0
+
Index: trunk/softs/tests_cc_vcache/test_sc_update_cache/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_sc_update_cache/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_sc_update_cache/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_sc_update_cache/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_sc_update_cache/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_sc_update_cache/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^0x0000DEAD 0x0000BEEF$" run.out > /dev/null
+	if [ $? -eq 0 ]; then
+		return 0;
+	fi
+	echo "couldn't find string in output - mtty not working ?" >> run.out
+	return 1
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_sc_update_cache/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_sc_update_cache/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_sc_update_cache/test.S	(revision 520)
@@ -0,0 +1,80 @@
+/*
+ * Check that lc also updates the local L1 cache.
+ */
+#include <registers.h>
+#include <misc.h>
+#include <vcache.h>
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+
+	/* enable caches */
+	li	a0, VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
+	mtc2 	a0, VC_TLB_EN
+
+	/* fetch data in cache */
+	la	s0, myvar
+	lw	a0, 0(s0)
+	/* write magic value */
+	li	a0, MAGIC1
+	sw	a0, 0(s0)
+	/* ll/sc another value on the same address */
+2:
+	ll	a0, 0(s0)
+	PRINTX
+	PUTCHAR(' ')
+	li	a0, MAGIC2
+	sc	a0, 0(s0)
+	beqz	a0, 2b
+	/* now check that we got the right value in cache */
+	lw	a0, 0(s0)
+	PRINTX
+	PUTCHAR('\n')
+	EXIT(0)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PUTCHAR('\n')
+	/* we should not get there */
+	EXIT(1)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+value:	.word 0x1234abcd
+string: .ascii "hello world \0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+
+	.data
+myvar:	.word 0
Index: trunk/softs/tests_cc_vcache/test_sync/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_sync/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_sync/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_sync/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_sync/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_sync/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+
+. ../common/common.sh 
+
+check_output()
+{
+	egrep "^@@@@@@$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_sync/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_sync/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_sync/test.S	(revision 520)
@@ -0,0 +1,101 @@
+/*
+ * sync test: we map the tty cached. If sync doesn't work some chars will be
+ * lost because writes are combined in the write buffer.
+ */
+#include <registers.h>
+#include <misc.h>
+#include <vcache.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	PRINT_SYNC(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+
+	la	a0, pte1
+	srl	a0, a0, 13
+	mtc2	a0, VC_PTPR
+	nop
+
+	li	a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE
+	mtc2 	a0, VC_TLB_EN
+
+	PRINT_SYNC(mmustr)
+
+	/*
+	 * print several chars quickly: without sync not all of them will
+	 * show up
+	 */
+#define WRITE_TTY sb a0, 0(k0); sync
+	la a0, '@'
+	WRITE_TTY
+	WRITE_TTY
+	WRITE_TTY
+	WRITE_TTY
+	WRITE_TTY
+	WRITE_TTY
+	PUTCHAR('\n')
+
+	/* we should get there */
+	EXIT(0)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PUTCHAR('\n')
+	/* we should not get there */
+	EXIT(1)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+mmustr:	.ascii "mmu started\n\0"
+startstr: .ascii "start\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+	.data
+	.word MAGIC1
+testval:
+	.word MAGIC2
+	.globl pte1
+pte1:
+	.align 13
+	.word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */
+	.org pte1 + (BOOT_ADDRESS >> 21) * 4
+	.word PTE1_V | PTE1_C | PTE1_X | (BOOT_ADDRESS >> 21) /* map PA 0xbfc00000 at VA 0xbfc00000 */
+	.org pte1 + (TTY_BASE >> 21) * 4
+	.word PTE1_V | PTE1_C | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 *cached!* */
+	.org pte1 + (EXIT_BASE >> 21) * 4
+	.word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */
+	.org pte1 + 8192
+	.word 0
+
Index: trunk/softs/tests_cc_vcache/test_syscall/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_syscall/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_syscall/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_syscall/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_syscall/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_syscall/run	(revision 520)
@@ -0,0 +1,33 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^status 0x00400012 cause 0x00000020 pc 0xBFC00050 badva 0x00000000$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 1 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	egrep "^0x0000DEAD 0x0000BEEF$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 2 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_syscall/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_syscall/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_syscall/test.S	(revision 520)
@@ -0,0 +1,91 @@
+/*
+ * syscall test: check that a syscall generates an exception, and we can
+ * return 
+ */
+#include <registers.h>
+#include <misc.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+	la	sp, 0x00400000 - 16
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+	/* switch to user mode */
+	mfc0	a0, COP0_STATUS
+	ori	a0, 0x10
+	mtc0	a0, COP0_STATUS
+	nop
+	nop
+	nop
+	PRINT(usrstr)
+	syscall
+	bne a3, zero, exit
+	nop
+	/* we should not get there, a3 is not 0 */
+	EXIT(2)
+exit:
+	move	a0, v0
+	PRINTX
+	PUTCHAR(' ')
+	move	a0, v1
+	PRINTX
+	PUTCHAR('\n')
+	/* we should get there */
+	EXIT(0)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+	PUTCHAR('\n')
+	mfc0	a0, COP0_EXPC
+	addiu	a0, a0, 4
+	mtc0	a0, COP0_EXPC
+	li	v0, MAGIC1
+	li	v1, MAGIC2
+	li	a3, 1
+	eret
+	nop
+
+#we should not end there
+	EXIT(1)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+startstr: .ascii "start\n\0"
+usrstr: .ascii "usrmode\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+	.data
+	.word MAGIC1
+testval:
+	.word MAGIC2
Index: trunk/softs/tests_cc_vcache/test_syscall_delayslot/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_syscall_delayslot/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_syscall_delayslot/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_syscall_delayslot/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_syscall_delayslot/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_syscall_delayslot/run	(revision 520)
@@ -0,0 +1,33 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^status 0x00400012 cause 0x80000020 pc 0xBFC00050 badva 0x00000000$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 1 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	egrep "^usrmode$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 2 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_syscall_delayslot/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_syscall_delayslot/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_syscall_delayslot/test.S	(revision 520)
@@ -0,0 +1,90 @@
+/*
+ * syscall test: check that a syscall in a delay slot is properly handled
+ */
+#include <registers.h>
+#include <misc.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+	la	sp, 0x00400000 - 16
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+	/* switch to user mode */
+	mfc0	a0, COP0_STATUS
+	ori	a0, 0x10
+	mtc0	a0, COP0_STATUS
+	nop
+	nop
+	nop
+	PRINT(usrstr)
+	j	exit
+	syscall
+	nop
+	/* we should not get there, */
+	EXIT(2)
+	.globl exit
+exit:
+	move	a0, v0
+	PRINTX
+	PUTCHAR(' ')
+	move	a0, v1
+	PRINTX
+	PUTCHAR('\n')
+	/* we should get there */
+	EXIT(0)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+	PUTCHAR('\n')
+	la	a0, exit
+	mtc0	a0, COP0_EXPC
+	li	v0, MAGIC1
+	li	v1, MAGIC2
+	li	a3, 1
+	eret
+	nop
+
+#we should not end there
+	EXIT(1)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+startstr: .ascii "start\n\0"
+usrstr: .ascii "usrmode\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+	.data
+	.word MAGIC1
+testval:
+	.word MAGIC2
Index: trunk/softs/tests_cc_vcache/test_trap/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_trap/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_trap/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_trap/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_trap/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_trap/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^status 0x00400002 cause 0x00000034 pc 0xBFC00034 badva 0x00000000$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 1 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_trap/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_trap/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_trap/test.S	(revision 520)
@@ -0,0 +1,64 @@
+/*
+ * trap test: check that a we can generate a trap
+ */
+#include <registers.h>
+#include <misc.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+	la	sp, 0x00400000 - 16
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+	nop
+	nop
+	nop
+	teq	zero, zero
+	EXIT(2)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+	PUTCHAR('\n')
+#we should end there
+	EXIT(0)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+startstr: .ascii "start\n\0"
+usrstr: .ascii "usrmode\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+	.data
+	.word MAGIC1
+testval:
+	.word MAGIC2
Index: trunk/softs/tests_cc_vcache/test_trap_delayslot/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_trap_delayslot/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_trap_delayslot/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_trap_delayslot/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_trap_delayslot/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_trap_delayslot/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^status 0x00400002 cause 0x80000034 pc 0xBFC00034 badva 0x00000000$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string 1 in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_trap_delayslot/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_trap_delayslot/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_trap_delayslot/test.S	(revision 520)
@@ -0,0 +1,85 @@
+/*
+ * trap test: check that a trap in a delay slot is
+ * properly handled
+ */
+#include <registers.h>
+#include <misc.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+	la	sp, 0x00400000 - 16
+
+	PRINT(startstr)
+
+	/* reset cop0 status (keep BEV) */
+	lui	a0, 0x0040;
+	mtc0	a0, COP0_STATUS
+	nop
+	nop
+	nop
+	j exit
+	teq	zero, zero
+	/* we should not get there, */
+	EXIT(2)
+	.globl exit
+exit:
+	move	a0, v0
+	PRINTX
+	PUTCHAR(' ')
+	move	a0, v1
+	PRINTX
+	PUTCHAR('\n')
+	/* we should get there */
+	EXIT(0)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+	PUTCHAR('\n')
+	la	a0, exit
+	mtc0	a0, COP0_EXPC
+	li	v0, MAGIC1
+	li	v1, MAGIC2
+	li	a3, 1
+	eret
+	nop
+
+#we should not end there
+	EXIT(1)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+startstr: .ascii "start\n\0"
+usrstr: .ascii "usrmode\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+	.data
+	.word MAGIC1
+testval:
+	.word MAGIC2
Index: trunk/softs/tests_cc_vcache/test_xicu_timer/Makefile
===================================================================
--- trunk/softs/tests_cc_vcache/test_xicu_timer/Makefile	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_xicu_timer/Makefile	(revision 520)
@@ -0,0 +1,1 @@
+include ../Makefile.inc
Index: trunk/softs/tests_cc_vcache/test_xicu_timer/run
===================================================================
--- trunk/softs/tests_cc_vcache/test_xicu_timer/run	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_xicu_timer/run	(revision 520)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+
+. ../common/common.sh
+
+check_output()
+{
+	egrep "^status 0x00400403 cause 0x[08]0000400 pc 0xBFC00040 badva 0x00000000 xicu 0x[01][0-9A-F][01][0-9A-F]0001$" run.out > /dev/null
+	if [ $? -ne 0 ]; then
+		echo "couldn't find string in output - mtty not working ?" >> run.out
+		return 1
+	fi
+	return 0;
+}
+
+make --quiet || exit 1
+${SIMUL} > run.out 2>&1 
+if [ $? -eq 0 ]; then
+	if check_output; then
+		echo "test passsed";
+		make --quiet clean
+		exit 0;
+	fi
+	echo "test FAILED"
+	exit 1
+fi
+echo "test FAILED"
+exit 1
+
Index: trunk/softs/tests_cc_vcache/test_xicu_timer/test.S
===================================================================
--- trunk/softs/tests_cc_vcache/test_xicu_timer/test.S	(revision 520)
+++ trunk/softs/tests_cc_vcache/test_xicu_timer/test.S	(revision 520)
@@ -0,0 +1,89 @@
+/*
+ * Check that we can take an interrupt from the xicu timer0
+ */
+#include <registers.h>
+#include <misc.h>
+#include <xicu.h>
+
+	.text
+	.globl  _start
+_start:
+	.set noreorder
+	la	k0, TTY_BASE
+	la	k1, EXIT_BASE
+
+	/* reset cop0 status (keep BEV), enable interrupt 0 */
+	lui     a0, 0x0040;
+	addiu	a0, 0x0401;
+	mtc0    a0, COP0_STATUS
+
+	/* reset cause, make sure IV is off */
+	mtc0	zero, COP0_CAUSE
+
+	PRINT(startstr)
+
+	/* program xicu */
+	la	t0, XICU_BASE
+	/* clear pending interrupt */
+	lw	a0, XICU_PTI_ACK(0)(t0)
+	/* route PTI0 to irq 0 */
+	li	a0, 1 << 0
+	sw	a0, XICU_MSK_PTI_E(0)(t0)
+	/* interrupt in 10 cycles */
+	li	a0, 10
+	sw	a0, XICU_PTI_PER(0)(t0)
+
+1:	j 1b
+	nop
+	/* we should not end there */
+	EXIT(1)
+
+	.globl excep
+excep:
+	.set noreorder
+	PRINT(statusstr)
+	mfc0	a0, COP0_STATUS
+	PRINTX
+
+	PRINT(causestr)
+	mfc0	a0, COP0_CAUSE
+	PRINTX
+
+	PRINT(pcstr)
+	mfc0	a0, COP0_EXPC
+	PRINTX
+
+	PRINT(badvastr)
+	mfc0	a0, COP_0_BADVADDR
+	PRINTX
+
+	PRINT(xicustr)
+	la	t0, XICU_BASE
+	lw	a0, XICU_PRIO(0)(t0)
+	PRINTX
+
+	PUTCHAR('\n')
+	/* clear interrupt */
+	mfc0	a0, COP0_CAUSE
+	andi	t0, a0, 0xff00
+	xor	a0, a0, t0
+	mtc0	a0, COP0_CAUSE
+	/* we should end there */
+	EXIT(0)
+
+	.rodata:
+statusstr: .ascii "status \0"
+causestr: .ascii " cause \0"
+pcstr: .ascii " pc \0"
+badvastr: .ascii " badva \0"
+xicustr: .ascii " xicu \0"
+startstr: .ascii "start\n\0"
+eretstr: .ascii "eret\n\0"
+
+	.org EXCEP_ADDRESS - BOOT_ADDRESS
+	.globl evect
+evect:
+	j	excep
+	nop
+	.data
+myvar:	.word 0
