main.c 2.72 KB
/**************************************************************************
 *                                                                        *
 *               Copyright (C) 1995, Silicon Graphics, Inc.               *
 *                                                                        *
 *  These coded instructions, statements, and computer programs  contain  *
 *  unpublished  proprietary  information of Silicon Graphics, Inc., 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 Silicon Graphics, Inc.  *
 *                                                                        *
 *************************************************************************/

#include <ultra64.h>
#include <assert.h>

#include "main.h"

#define VIDEO_MSG	411
#define MAX_MESGS	1

#ifndef ABS
#define ABS(x)		(((x) < 0) ? -(x) : (x))
#endif

extern	u32 rdramCheck(u32);

u64	bootStack[STACKSIZE/sizeof(u64)];

static void	idle(void *);
static void	mainproc(void *);

static OSThread	idleThread;
static u64	idleThreadStack[STACKSIZE/sizeof(u64)];

static OSThread	mainThread;
static u64	mainThreadStack[STACKSIZE/sizeof(u64)];

#ifdef _HW_VERSION_1
static OSThread	rmonThread;
static u64      rmonStack[RMON_STACKSIZE/sizeof(u64)];
#endif /* _HW_VERSION_1 */

static OSMesgQueue	interruptQ;
static OSMesg		intBuf[MAX_MESGS];


/*
 *  Color Frame Bufs from cfb.c
 */
extern unsigned short cfb_A[];
extern unsigned short cfb_B[];

void
boot(void)
{
    osInitialize();

    osCreateThread(&idleThread, 1, idle, (void *)0,
		   idleThreadStack+STACKSIZE/sizeof(u64), 10);
    osStartThread(&idleThread);

    /* never reached */
}

static void
idle(void *arg)
{
    /* Initialize video for timing clock */
    osCreateMesgQueue(&interruptQ, intBuf, MAX_MESGS);
    osCreateViManager(OS_PRIORITY_VIMGR);
    osViSetMode(&osViModeTable[OS_VI_NTSC_LAN1]);
    osViSetEvent(&interruptQ, (OSMesg)VIDEO_MSG, 1);
    osViSwapBuffer(cfb_A);

#ifdef _HW_VERSION_1
    osCreateThread(&rmonThread, 0, rmonMain, (void *)0,
		   (void *)(rmonStack+RMON_STACKSIZE/8), 
		   (OSPri) OS_PRIORITY_RMON );
    osStartThread(&rmonThread);
#endif /* _HW_VERSION_1 */

    osCreateThread(&mainThread, 3, mainproc, arg,
		   mainThreadStack+STACKSIZE/sizeof(u64), 10);
    
    osStartThread(&mainThread);


    osSetThreadPri(0, 0);

    for (;;);
}

static void mainproc(void *arg)
{
  rdramCheck(1);		/* This argument (1) means that the test is for the last */
				/* 1MBytes of the 4Mbytes.                               */
  
	/* osExit interacts poorly with the SOAKPRINTF */
#ifdef _HW_VERSION_1
    osExit();
#endif /* _HW_VERSION_1 */

}