boot.c 1.65 KB
/*============================================================================

		NINTENDO64 TECHNICAL SUPPORT CENTER 
		
		    NINTENDO64 SAMPLE PROGRAM 1

		Copyright (C) 1997, NINTENDO Co,Ltd.

============================================================================*/
#include <ultra64.h>
#include <PR/ramrom.h>
#include <assert.h>

#include "def.h"
#include "vram.h"
#include "segment.h"
#include "message.h"

u64 bootStack[STACKSIZE/sizeof(u64)];
static void idle(void *);      /* Idle Thead */

OSPiHandle	*handler;

/* スレッド構造体の定義 */
static OSThread idleThread;
static OSThread mainThread;


/* スレッドスタックの定義 */
static u64 idleThreadStack[STACKSIZE/sizeof(u64)];
static u64 mainThreadStack[STACKSIZE/sizeof(u64)];

/* 外部関数 */
extern void mainproc(void *);

/*-----------------------
  Boot                
  Program start here   
-----------------------*/
void boot(void)
{
  /* initilize software and hardware */
  osInitialize();

  handler = osCartRomInit();

  /* PARTNER-N64用のソース */

  /* create and start idle thread */
  osCreateThread(&idleThread,IDLE_THREAD_ID, idle, (void *)0,
		 (idleThreadStack+STACKSIZE/sizeof(u64)), IDLE_THREAD_PRI);
  osStartThread(&idleThread);
}

/*--------------------------
  Idle Thread
---------------------------*/
static void idle(void *arg)
{
  /* create and start PI mangaer thread */
  osCreatePiManager((OSPri)OS_PRIORITY_PIMGR, &PiMessageQ, PiMessages,
		    NUM_PI_MSGS);


  /* メインスレッドの起動 */
  osCreateThread(&mainThread, MAIN_THREAD_ID, mainproc,arg,
		 (mainThreadStack+STACKSIZE/sizeof(u64)),MAIN_THREAD_PRI);
  osStartThread(&mainThread);

  /* Here is idle loop */
  for(;;);
}