boot.c 2.07 KB

/*---------------------------------------------------------------------*
        Copyright (C) 1998 Nintendo. (Originated by SGI)
        
        $RCSfile: boot.c,v $
        $Revision: 1.1.1.1 $
        $Date: 2002/05/02 03:27:13 $
 *---------------------------------------------------------------------*/
#include <os.h>
#include <ultra64.h>
#include <string.h>
#include <bstring.h>
/*
#include <setjmp.h>
*/
#include "os_internal.h"
#include "cpu.h"

/*
#define _DUMP_THREAD
*/

/**************************************************************************
 *
 * Definitions
 *
 */


/**************************************************************************
 *
 * Global variables
 *
 */
char		bootStack[STACKSIZE];


/**************************************************************************
 *
 * Local variables
 *
 */
static OSThread	idleThread;
static char	idleThreadStack[STACKSIZE];

static OSThread	mainThread;
static char	mainThreadStack[STACKSIZE];


/**************************************************************************
 *
 * Extern references
 *
 */
extern u32	CpuErrorCount;
extern s32	CpuTest(void);


/**************************************************************************
 *
 * Function prototypes
 *
 */
static void	idle(void *);
static void	main(void *);


/**************************************************************************
 *
 * Boot program
 *
 */
boot(void)
{

    osInitialize();

    osCreateThread(&mainThread, 1, main, (void *)0, mainThreadStack+STACKSIZE,
		  (OSPri)MAIN_THREAD_PRI);
    osStartThread(&mainThread);
}


static void
main(void *arg)
{

    OSMesg	mesg;
    int		i;
    u32		saveMask;

    /*
     * Create idle thread
     */
    osCreateThread(&idleThread, 2, idle, (void *)0, idleThreadStack+STACKSIZE,
		  (OSPri)IDLE_THREAD_PRI);
    osStartThread(&idleThread);


    /* Start VI manager */
    osCreateViManager((OSPri)OS_PRIORITY_VIMGR);

    XDEBUG(osSyncPrintf("Starting CpuTest\n"));

    (void)CpuTest();

    XDEBUG(osSyncPrintf("Get control back, errorCount=%d\n", CpuErrorCount));

}  /* main */


static void
idle(void *arg)
{
	for (;;);
}