boot.c 2.09 KB

/*---------------------------------------------------------------------*
        Copyright (C) 1998 Nintendo. (Originated by SGI)
        
        $RCSfile: boot.c,v $
        $Revision: 1.2 $
        $Date: 2003/04/15 21:44:11 $
 *---------------------------------------------------------------------*/
#include <os.h>
#include <ultra64.h>
#include <string.h>

#ifdef __sgi__
#include <bstring.h>
#endif
/*
#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 (;;);
}