task.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
/*
task.c
Copyright (C) 1999, NINTENDO Co,Ltd., MONEGI CORPORATION.
Jan. 28, 1999.
*/
#include <ultra64.h>
#include <PR/gs2dex.h>
#include "Task.h"
#define RDP_OUTPUT_LEN ( 4096 * 16 )
#if __GNUC__ /* { */
u64 rdp_output_len __attribute__((aligned (16))); /* RDP DL length returned by RSP */
#else /* }{ */
u64 rdp_output_len; /* RDP DL length returned by RSP */
#endif /* } */
u64 rdp_output[ RDP_OUTPUT_LEN ]; /* buffer for RDP DL */
/*
* RSP Task descriptor.
*/
OSTask task_list =
{
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) */
};
static OSMesgQueue rspMessageQ;
static OSMesg rspMessageBuf;
static OSMesgQueue rdpMessageQ;
static OSMesg rdpMessageBuf;
void init_task( void )
{
osCreateMesgQueue( &rspMessageQ, &rspMessageBuf, 1 );
osSetEventMesg( OS_EVENT_SP, &rspMessageQ, NULL );
osCreateMesgQueue( &rdpMessageQ, &rdpMessageBuf, 1 );
osSetEventMesg( OS_EVENT_DP, &rdpMessageQ, NULL );
}
void start_task( Gfx *glist_ptr, Dynamic *dynamic_ptr )
{
OSTask *task_ptr;
task_ptr = &task_list;
task_ptr->t.ucode_boot = (u64 *) rspbootTextStart;
task_ptr->t.ucode_boot_size = (u32) rspbootTextEnd - (u32) rspbootTextStart;
task_ptr->t.ucode = (u64 *) gspS2DEX2_fifoTextStart;
task_ptr->t.ucode_data = (u64 *) gspS2DEX2_fifoDataStart;
task_ptr->t.output_buff_size = (u64 *)((int)rdp_output +
(int)(RDP_OUTPUT_LEN*sizeof(u64)));
/*
* initial display list:
*/
task_ptr->t.data_ptr = (u64 *) dynamic_ptr->glist;
task_ptr->t.data_size = (u32)((glist_ptr - dynamic_ptr->glist) * sizeof(Gfx));
/*
* Write back dirty cache lines that need to be read by the RCP.
*/
osWritebackDCache(dynamic_ptr, sizeof( Dynamic ) );
/*
* start up the RSP task
*/
osSpTaskStart( task_ptr );
/*
* wait for SP,DP completion
*/
(void)osRecvMesg( &rspMessageQ, NULL, OS_MESG_BLOCK );
(void)osRecvMesg( &rdpMessageQ, NULL, OS_MESG_BLOCK );
}