sptask.h
4.43 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/**************************************************************************
* *
* 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. *
* *
**************************************************************************/
#ifndef _SPTASK_H_
#define _SPTASK_H_
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
#endif
#include <PR/ultratypes.h>
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Type definitions
*
*/
/*
* Task List Structure.
*
* Things an app might pass to the SP via the task list.
* Not every task ucode would need/use every field, but
*
* - type (audio, gfx, video, ...)
* - flags
* - wait for DP to drain before running new task
* - SEE BIT DEFINITIONS UNDER "Task Flags field"
* - pointer to boot ucode
* - size of boot ucode
* - pointer to ucode
* - size of ucode
* - pointer to initial DMEM data
* - size of initial DMEM data
* - pointer to DRAM stack
* - size of DRAM stack (max)
* - pointer to output buffer
* - pointer to store output buffer length
* - generic data pointer (for display list, etc.)
* - generic data length (for display list, etc.)
* - pointer to buffer where to store saved DMEM (in yield case)
* - size of buffer to store saved DMEM.
*
* IMPORTANT!!! Watch alignment issues.
*
* IMPORTANT!!! Watch data cache issues. The RCP may write data into the
* dram_stack, output_buff, output_buff_size, and the yield_data_ptr areas.
* These buffers should be cache aligned and use the entire line (16 bytes) to
* avoid corruption by writebacks by the CPU (cache tearing).
*
* IMPORTANT!!! all addresses are virtual addresses. Library does
* any necessary translation.
*
*/
typedef struct {
u32 type;
u32 flags;
u64 *ucode_boot;
u32 ucode_boot_size;
u64 *ucode;
u32 ucode_size;
u64 *ucode_data;
u32 ucode_data_size;
u64 *dram_stack;
u32 dram_stack_size;
u64 *output_buff;
u64 *output_buff_size;
u64 *data_ptr;
u32 data_size;
u64 *yield_data_ptr;
u32 yield_data_size;
} OSTask_t;
typedef union {
OSTask_t t;
long long int force_structure_alignment;
} OSTask;
typedef u32 OSYieldResult;
#endif /* _LANGUAGE_C */
#ifdef _LANGUAGE_ASSEMBLY
/*
* For the RSP ucode:
* offsets into the task structure
*/
#include <PR/sptaskoff.h>
#endif
/*
* Task Flags field
*/
#define OS_TASK_YIELDED 0x0001
#define OS_TASK_DP_WAIT 0x0002
#define OS_TASK_LOADABLE 0x0004
#define OS_TASK_USR0 0x0010
#define OS_TASK_USR1 0x0020
#define OS_TASK_USR2 0x0040
#define OS_TASK_USR3 0x0080
/*
* Size of Yield buffer. The taskHdrPtr->t.yield_data_ptr must point to a
* buffer of this size. (The size is in bytes). ONLY If the task will NEVER
* yield it may be a null pointer. The buffer must be aligned to a 64 bit
* boundary. The taskHdrPtr->t.yield_data_ptr must be set to point to the
* buffer BEFORE the task is started.
*/
#if (defined(F3DEX_GBI)||defined(F3DLP_GBI))
#define OS_YIELD_DATA_SIZE 0xc00
#define OS_YIELD_SPRITE_SIZE 0xc00
#else
#define OS_YIELD_DATA_SIZE 0xba0
#define OS_YIELD_SPRITE_SIZE 0xba0
#endif
#define OS_YIELD_AUDIO_SIZE 0x400
/**************************************************************************
*
* Global definitions
*
*/
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/**************************************************************************
*
* Macro definitions
*
*/
/*
* this macro simulates atomic action.
*/
#define osSpTaskStart(tp) \
{ \
osSpTaskLoad((tp)); \
osSpTaskStartGo((tp)); \
}
/**************************************************************************
*
* Extern variables
*
*/
/**************************************************************************
*
* Function prototypes
*
*/
/*
* break this up into two steps for debugging.
*/
extern void osSpTaskLoad(OSTask *tp);
extern void osSpTaskStartGo(OSTask *tp);
extern void osSpTaskYield(void);
extern OSYieldResult osSpTaskYielded(OSTask *tp);
#endif /* _LANGUAGE_C */
#ifdef _LANGUAGE_C_PLUS_PLUS
}
#endif
#endif /* !_SPTASK_H */