/*
 *               Copyright (C) 2005, BroadOn Communications Corp.
 *
 *  These coded instructions, statements, and computer programs contain
 *  unpublished  proprietary information of BroadOn Communications Corp.,
 *  and  are protected by Federal copyright law. They may not be disclosed
 *  to  third  parties or copied or duplicated in any form, in whole or in
 *  part, without the prior written consent of BroadOn Communications Corp.
 *
 */

#include <types.h>
#include <sc/sc.h>
#include <sc/addr_map.h>
#include <ioslibc.h>
#include "../test.h"

// stacks;

u32 stack0[256];		// cpu0
u32 stack1[256];		// cpu1

// the list of tests;

#define	TEST_NLOOP		100		// # of test loops;
#define	TEST_L2
#define	TEST_SD
#define	TEST_TAP				// tap sweep 0..15;
#undef	TEST_MTAP				// manual tap set via jtag;

// list of test functions;

extern void test_l2_init(test_t *, u32);
extern void test_l2_dbit(test_t *, u32);
extern void test_l2_8(test_t *, u32);
extern void test_l2_16(test_t *, u32);
extern void test_l2_32(test_t *, u32);

extern void test_sd_init(test_t *, u32);
extern void test_sd_dbit(test_t *, u32);
extern void test_sd_8(test_t *, u32);
extern void test_sd_16(test_t *, u32);
extern void test_sd_32(test_t *, u32);
extern void test_sd_tap(test_t *, u32);

test_t Tests[] = {
	// l2 sram tests;
#ifdef	TEST_L2
	{ TNAME, test_l2_init },
	{ TNAME, test_l2_dbit },
	{ TNAME, test_l2_8 },
	{ TNAME, test_l2_16 },
	{ TNAME, test_l2_32 },
#endif	// TEST_L2

	// sdram tests;
#ifdef	TEST_SD
	{ TNAME, test_sd_init,
		0, 0, 0, { SYS_CACHE_CONF_DA_64_SC_256, 0 }, },
	{ TNAME, test_sd_dbit },
	{ TNAME, test_sd_8 },
	{ TNAME, test_sd_16 },
	{ TNAME, test_sd_32 },
	{ TNAME, test_sd_init,
		0, 0, 0, { SYS_CACHE_CONF_DA_64_CC_128_SC_128, 0 }, },
	{ TNAME, test_sd_dbit },
	{ TNAME, test_sd_8 },
	{ TNAME, test_sd_16 },
	{ TNAME, test_sd_32 },
	{ TNAME, test_sd_init,
		0, 0, 0, { SYS_CACHE_CONF_DA_192_CC_64_SC_64, 0 }, },
	{ TNAME, test_sd_dbit },
	{ TNAME, test_sd_8 },
	{ TNAME, test_sd_16 },
	{ TNAME, test_sd_32 },
#endif	// TEST_SD
#ifdef	TEST_TAP
	{ TNAME, test_sd_init,
		0, 0, 0, { SYS_CACHE_CONF_DA_192_CC_64_SC_64, 0 }, },
	{ TNAME, test_sd_tap },
#endif	// TEST_TAP

	// manual tap setting for qual;
#ifdef	TEST_MTAP
	{ TNAME, test_sd_init,
		0, 0, 0, { SYS_CACHE_CONF_DA_192_CC_64_SC_64, 1 }, },
	{ TNAME, test_sd_32 },
#endif	// TEST_MTAP

	{ TNAME, 0 },
};

// simulator exports;

sim_t Sim = { 0, Tests };

/*
 * cpu0 c-code entry;
 */
void
main0(void)
{
	int nth;

	// run through list of tests;

	Sim.sema = 1;
	for(nth = 1; nth <= TEST_NLOOP; nth++)
		test_loop(Tests, nth);
}

/*
 * cpu1 c-code entry;
 * cpu 1 is kept in reset;
 */
void
main1(void)
{
}

