main.c 3.93 KB
#include <os.h>
#include <rmon.h>
#include "corefunc.h"

char	bootStack[STACKSIZE];

static void	idle(void *);
static void	main(void *);

static OSThread	idleThread;
static char	idleThreadStack[STACKSIZE];

static OSThread	mainThread;
static char	mainThreadStack[STACKSIZE];

static OSThread	rmonThread;
static char	rmonThreadStack[RMON_STACKSIZE];

boot(void)
{
    osInitialize();
    osCreateThread(&idleThread, 1, idle, (void *)0,
		   idleThreadStack+STACKSIZE, 10);
    osStartThread(&idleThread);
}

static void
idle(void *arg)
{
    /*
     * Create rmon thread
     */
    osCreateThread(&rmonThread, 0, rmonMain, (void *)0,
		rmonThreadStack+RMON_STACKSIZE, OS_PRIORITY_RMON);
    osStartThread(&rmonThread);

    /*
     * Create main thread
     */
    osCreateThread(&mainThread, 2, main, (void *)0,
		   mainThreadStack+STACKSIZE, 10);
    osStartThread(&mainThread);

    /*
     * Go dormant
     */
    osSetThreadPri(NULL, 0);

    for (;;);
}

static void
main(void *arg)
{
    int totalFailures = 0;

    /*
     * Tests are ordered so that succeeding tests
     * use functionality verified by preceding tests.
    */
    osSyncPrintf("mesg0\n");
    totalFailures += mesg0();		/* non blocking message passing */

    osSyncPrintf("thread0\n");
    totalFailures += thread0();		/* thread creation */

    osSyncPrintf("mesg1\n");
    totalFailures += mesg1();		/* blocking message receives */

    osSyncPrintf("mesg2\n");
    totalFailures += mesg2();		/* blocking message sends */

    osSyncPrintf("thread1\n");
    totalFailures += thread1();		/* stop runnable threads */

    osSyncPrintf("thread2\n");
    totalFailures += thread2();		/* destroy runnable threads */

    osSyncPrintf("thread3\n");
    totalFailures += thread3();		/* set priority of runnable threads */

    osSyncPrintf("mesg3\n");
    totalFailures += mesg3();		/* message/priority interaction */

    osSyncPrintf("int0\n");
    totalFailures += int0();		/* nonblocking interrupt messages */

    osSyncPrintf("int1\n");
    totalFailures += int1();		/* blocking interrupt messages */

    osSyncPrintf("thread4\n");
    totalFailures += thread4();		/* context switching */

    osSyncPrintf("int2\n");
    totalFailures += int2();		/* multiple pending interrupts */

    osSyncPrintf("event0\n");
    totalFailures += event0();		/* break event messages */

    osSyncPrintf("mesg4\n");
    totalFailures += mesg4();		/* non blocking message jamming */

    osSyncPrintf("mesg5\n");
    totalFailures += mesg5();		/* blocking message receives (w/jam) */

    osSyncPrintf("mesg6\n");
    totalFailures += mesg6();		/* blocking message jams */

    osSyncPrintf("thread5\n");
    totalFailures += thread5();		/* stop waiting threads */

    osSyncPrintf("thread6\n");
    totalFailures += thread6();		/* destroy waiting threads */

    osSyncPrintf("thread7\n");
    totalFailures += thread7();		/* set priority of waiting threads */

    osSyncPrintf("thread8\n");
    totalFailures += thread8();		/* destroy stopped threads */

    osSyncPrintf("thread9\n");
    totalFailures += thread9();		/* set priority of stopped threads */

    osSyncPrintf("tlb0\n");
    totalFailures += tlb0();		/* TLB functionality - all indexes */

    osSyncPrintf("tlb1\n");
    totalFailures += tlb1();		/* TLB functionality - ASIDS */

    osSyncPrintf("int3\n");
    totalFailures += int3();		/* rcp interrupt messages */

    osSyncPrintf("int4\n");
    totalFailures += int4();		/* multiple rcp interrupts */

    osSyncPrintf("bitfll\n");
    totalFailures += bitfll();		/* long long operations */

    osSyncPrintf("cconst\n");
    totalFailures += cconst();		/* long long operations */

    osSyncPrintf("lltest\n");
    totalFailures += lltest();		/* long long operations */

    osSyncPrintf("longlong\n");
    totalFailures += longlong();		/* long long operations */

    osSyncPrintf("div\n");
    totalFailures += div();		/* long long operations */

    osSyncPrintf("corefunc: total number of failures: %d\n", totalFailures);
}