/*
 * Top level of example main program to do DV tests running on
 * the verilog model that includes the real ARM7TDMI model
 */

/*
 *              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 <ioslibc.h>
#include <sc/dv_boot.h>

volatile int done = 0;

int 
cpu0main(void)
{
    u32 val;
    int mycpu;

    val = IO_READ(SYS_SMP_REG);
    mycpu = ((val & SYS_SMP_CPU_ID) != 0);
    printf("This is cpu%d ... starting cpu1\n", mycpu);
    DVStartCpu1();

    /* wait for cpu1 to come up */
    while (!done) ;

    printf("cpu%d calling DVExit ...\n", mycpu);
    DVExit(0);

    /*
     * The DVExit is really superfluous:  returning from
     * cpu0main or cpu1main causes DVExit to be called.
     */
    return(0);
}

int 
cpu1main(void)
{
    u32 val;
    int mycpu;

    val = IO_READ(SYS_SMP_REG);
    mycpu = ((val & SYS_SMP_CPU_ID) != 0);
    printf("Hello from cpu%d ...\n", mycpu);
    done = 1;

    /* wait for cpu0 to exit */
    while (1) ;
    return 0;
}
