boot1.c
3.46 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*---------------------------------------------------------------------*
Copyright (C) 1998 Nintendo. (Originated by SGI)
$RCSfile: boot1.c,v $
$Revision: 1.1.1.1 $
$Date: 2002/05/02 03:27:20 $
*---------------------------------------------------------------------*/
#include <ultra64.h>
#include "reboot.h"
static void idle(void *);
static void main(void *);
static OSThread idleThread;
static char idleThreadStack[STACKSIZE];
static OSThread mainThread;
static char mainThreadStack[STACKSIZE];
static OSThread rmonThread;
static char rmonThreadStack[RMON_STACKSIZE];
OSMesgQueue rspMessageQ, rdpMessageQ;
OSMesg rspMessageBuf, rdpMessageBuf;
/*
* necessary for RSP tasks:
*/
u64 dram_stack[SP_DRAM_STACK_SIZE64]; /* used for matrix stack */
u64 rdp_output_len; /* RSP writes back size of RDP data */
u64 rdp_output[4096]; /* RSP writes back RDP data */
/*
* Task descriptor.
*/
OSTask tlist =
{
M_GFXTASK, /* task type */
OS_TASK_DP_WAIT, /* task flags */
NULL, /* boot ucode pointer (fill in later) */
0, /* boot ucode size (fill in later) */
NULL, /* task ucode pointer (fill in later) */
SP_UCODE_SIZE, /* task ucode size */
NULL, /* task ucode data pointer (fill in later) */
SP_UCODE_DATA_SIZE, /* task ucode data size */
&(dram_stack[0]), /* task dram stack pointer */
SP_DRAM_STACK_SIZE8, /* task dram stack size */
&(rdp_output[0]), /* task output buffer ptr (not always used) */
&rdp_output_len, /* task output buffer size ptr */
NULL, /* task data pointer (fill in later) */
0, /* task data size (fill in later) */
NULL, /* task yield buffer ptr (not used here) */
0 /* task yield buffer size (not used here) */
};
Gfx *glistp; /* global for test case procs */
Gfx gbuffer[10];
boot1(void)
{
osInitialize();
osCreateThread(&mainThread, 1, main, (void *)0,
mainThreadStack+STACKSIZE, 10);
osStartThread(&mainThread);
}
static void
main(void *arg)
{
OSTask *tlistp;
/*
* Create idle thread
*/
osCreateThread(&idleThread, 3, idle, (void *)0,
idleThreadStack+STACKSIZE, 0);
osStartThread(&idleThread);
/*
* Create rmon thread
*/
osCreateThread(&rmonThread, 0, rmonMain, (void *)0,
rmonThreadStack+RMON_STACKSIZE, OS_PRIORITY_RMON);
osStartThread(&rmonThread);
rmonPrintf("in operational code\n");
osCreateMesgQueue(&rspMessageQ, &rspMessageBuf, 1);
osSetEventMesg(OS_EVENT_SP, &rspMessageQ, NULL);
osCreateMesgQueue(&rdpMessageQ, &rdpMessageBuf, 1);
osSetEventMesg(OS_EVENT_DP, &rdpMessageQ, NULL);
for(;;) {
glistp = &gbuffer[0];
tlistp = &tlist;
gSPSegment(glistp++, 0, 0x0);
gDPFullSync(glistp++);
gSPEndDisplayList(glistp++);
tlistp->t.ucode_boot = (u64 *) rspbootTextStart;
tlistp->t.ucode_boot_size = (u32)rspbootTextEnd - (u32)rspbootTextStart;
tlistp->t.ucode = (u64 *) gspFast3D_dramTextStart;
tlistp->t.ucode_data = (u64 *) gspFast3D_dramDataStart;
tlistp->t.data_ptr = (u64 *) &gbuffer[0];
tlistp->t.data_size = (u32)((glistp - &gbuffer[0]) * sizeof(Gfx));
osWritebackDCache(gbuffer, sizeof(gbuffer));
rmonPrintf("starting Rsp task\n");
osSpTaskStart(tlistp);
(void)osRecvMesg(&rspMessageQ, NULL, OS_MESG_BLOCK);
rmonPrintf("received Rsp message\n");
}
}
static void
idle(void *arg)
{
for (;;);
}