/*
 * Test interaction of L1 D-cache between the two processors
 */

#include <types.h>
#include <sc/sc.h>
#include <ioslibc.h>
#include <sc/dv_boot.h>
#include "dv_cpu_local.h"

volatile u32 flag;

int 
cpu0main(void)
{
    u32 next = 1;
    volatile int i;

    flag = 0;

    printf("Starting cpu1 ...\n");
    DVStartCpu1();

    while (1) {
        i = 0;
        while (1) {
            if (flag == next)
                break;
            if (++i > 110)
                DVExit(-2);
        }
        flag = ++next;
        /* Quit with good status after a while */
        if (next++ > 25600)
            break;
    }

    printf("Exiting with next == %d\n", next);
    return 0;
}

int 
cpu1main(void)
{
    u32 next = 0;
    volatile int i;

    while (1) {
        i = 0;
        while (1) {
            if (flag == next)
                break;
            if (++i > 100)
                DVExit(-3);
        }
        flag = ++next;
        next++;
    }

    return 0;
}
