/*
 * Simple test for power estimation:  one cpu doing large bzero in DA space
 */

/*
 *              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>

void *
__memset(void *s, int c, size_t n)
{
    u8 *p = s;

    /* optimization for the word aligned case */
    if ((((u32)s & 3) == 0) && ((n & 3) == 0) && (n > 8)) {
        u32 *w = (u32 *)s;
        u32 v = (u32) (c & 0xff);

        v |= (v << 24) | (v << 16) | (v << 8);

        while (n > 0) {
            *w++ = v;
            n -= sizeof *w;
        }
    } else {
        /* byte at a time */
        while (n--) {
            *p++ = (u8) c;
        }
    }
    return s;
}

#define CLEAR_ADDR_DA (96 * 1024)
#define CLEAR_SIZE_DA (8 * 1024)

int 
cpu0main(void)
{
    volatile exit_comm_area *ecap = EXIT_COMM_AREA;
    u32 *daxp;
    int count;

    /*
     * Use an area not in BSS or DATA to save initialization time.
     * Set RW permissions on the target area.
     */
    daxp = (u32 *) (DAX_START + CLEAR_ADDR_DA);
    count = CLEAR_SIZE_DA >> 4;		/* number of cachelines */
    while (count-- > 0) {
        *daxp = PT_ACCESS_RW << PT_SC_PROT_SHIFT;
        daxp += 4;
    }
    
    ecap->arg++;	/* tell framework to turn on dump */

    __memset((void *)CLEAR_ADDR_DA, 0, CLEAR_SIZE_DA);
    
    ecap->arg++;	/* turn off dump */
    return 0;
}

int 
cpu1main(void)
{
    return 0;
}
