#include <ios.h>
#include <hw.h>
#include <iostypes.h>
#include <ioslibc.h>

#define STACK_SIZE 4096
const u8 _initStack[STACK_SIZE];
const u32 _initStackSize = sizeof(_initStack);
const u32 _initPriority = 10;

/* Thread created by idle process */
u8 testthrStack[1024]; /* 1024 is hardwired as stack size for this thread
                        * when the idle thread starts it. Please change
                        * it if you change this.
                        */

char dst[4096] __attribute__((aligned(32)));

void
__test(char *dst, char b, u32 z)
{
  u32 start, end, i;
  memset(dst, 0xa, z);
  start = busRd32(SYS_TIMER_REG);
  for (i = 0; i < 100; ++i) {
      memset(dst, b, z);
      memset(dst, b, z);
      memset(dst, b, z);
      memset(dst, b, z);
      memset(dst, b, z);
  }
  end = busRd32(SYS_TIMER_REG);
  printf("%u %u\n", z, end - start);
}

void
main(u32 arg)
{
    u32 z;
    for (z = 0; z <= 2048; z += 4) {
        __test(dst + 4, 0xab, z);
    }
    IOS_DestroyThread(0, NULL);
}
