system.c
2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*---------------------------------------------------------------------*
Copyright (C) 1997, Nintendo.
File system.c
Coded by Yoshitaka Yasumoto. Sep 12, 1997.
Modified by
$Id: system.c,v 1.1.1.1 2002/05/02 03:27:17 blythe Exp $
*---------------------------------------------------------------------*/
#include <ultra64.h>
#include "system.h"
/*
* システムに必要な初期設定を行なってから main 関数を呼び出す
*/
u64 bootStack[STACKSIZE/sizeof(u64)];
extern void Main(void *);
static OSThread idleThread;
static u64 idleThreadStack[STACKSIZE/sizeof(u64)];
static OSThread mainThread;
static u64 mainThreadStack[STACKSIZE/sizeof(u64)];
OSMesgQueue piMessageQ;
OSMesgQueue siMessageQ;
OSMesgQueue dmaMessageQ;
OSMesgQueue rspMessageQ;
OSMesgQueue rspBrkMessageQ;
OSMesgQueue rdpMessageQ;
OSMesgQueue retraceMessageQ;
static OSMesg piMessages[NUM_PI_MSGS];
static OSMesg siMessageBuf;
static OSMesg dmaMessageBuf;
static OSMesg rspMessageBuf;
static OSMesg rspBrkMessageBuf;
static OSMesg rdpMessageBuf;
static OSMesg retraceMessageBuf;
OSIoMesg dmaIOMessageBuf;
OSContStatus contStatus[MAXCONTROLLERS];
OSContPad contPad[MAXCONTROLLERS];
u8 contExist;
void mainproc(void *arg)
{
/* メッセージキュー作成 */
osCreateMesgQueue(&dmaMessageQ, &dmaMessageBuf, 1);
osCreateMesgQueue(&rspMessageQ, &rspMessageBuf, 1);
osCreateMesgQueue(&rspBrkMessageQ, &rspBrkMessageBuf, 1);
osCreateMesgQueue(&rdpMessageQ, &rdpMessageBuf, 1);
osCreateMesgQueue(&siMessageQ, &siMessageBuf, 1);
osCreateMesgQueue(&retraceMessageQ, &retraceMessageBuf, 1);
/* イベントとメッセージキューとの接続 */
osSetEventMesg(OS_EVENT_SP, &rspMessageQ, NULL);
osSetEventMesg(OS_EVENT_SP_BREAK, &rspBrkMessageQ, NULL);
osSetEventMesg(OS_EVENT_DP, &rdpMessageQ, NULL);
osSetEventMesg(OS_EVENT_SI, &siMessageQ, NULL);
osViSetEvent(&retraceMessageQ, NULL, 1);
/* コントローラの初期化 */
osContInit(&siMessageQ, &contExist, contStatus);
/* Main 関数の呼び出し */
Main(arg);
}
static void idle(void *arg)
{
/* Vi マネージャ起動 */
osCreateViManager(OS_PRIORITY_VIMGR);
osViSetMode(&osViModeTable[OS_VI_NTSC_LPN1]);
/* GAMMA 補正を OFF にする */
osViSetSpecialFeatures( OS_VI_GAMMA_OFF | OS_VI_GAMMA_DITHER_OFF |
OS_VI_DIVOT_ON | OS_VI_DITHER_FILTER_ON );
/* Pi マネージャ起動 */
osCreatePiManager((OSPri)OS_PRIORITY_PIMGR,
&piMessageQ, piMessages, NUM_PI_MSGS);
/* Main Thread 起動 */
osCreateThread(&mainThread, 3, mainproc, arg,
mainThreadStack+STACKSIZE/sizeof(u64), 10);
osStartThread(&mainThread);
osSetThreadPri(0,0);
/* Idle ループ開始 */
while (1);
}
void boot(void)
{
osInitialize();
osCreateThread(&idleThread, 1, idle, (void *)0,
idleThreadStack+STACKSIZE/sizeof(u64), 10);
osStartThread(&idleThread);
}
/*======== End of system.c ========*/