main.c
2.72 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
/**************************************************************************
* *
* 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 */
}