logtest.c
3.85 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
/*====================================================================
* logtest.c
*
* Copyright 1995, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
* Inc.; the contents of this file may not be disclosed to third
* parties, copied or duplicated in any form, in whole or in part,
* without the prior written permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights
* in Technical Data and Computer Software clause at DFARS
* 252.227-7013, and/or in similar or successor clauses in the FAR,
* DOD or NASA FAR Supplement. Unpublished - rights reserved under the
* Copyright Laws of the United States.
*====================================================================*/
#include <ultralog.h>
#include <ultra64.h>
#include "logtest.h"
#include <os_internal.h>
#include <rmon.h>
#define LOG_LEN 0x1000
#define MY_RMON_STACKSIZE 16384
#define DMA_QUEUE_SIZE 200
u64 bootStack[STACKSIZE/8];
static u64 rmonStack[MY_RMON_STACKSIZE/8];
static OSThread rmonThread;
static OSThread mainThread;
static u64 mainThreadStack[STACKSIZE/8];
static void mainproc(char *);
static OSThread gameThread;
static u64 gameThreadStack[STACKSIZE/8];
static void gameproc(void *);
static OSMesg PiMessages[DMA_QUEUE_SIZE];
static OSMesgQueue PiMessageQ;
u32 logData[LOG_LEN/sizeof(long)];
int printOnly = 0;
int debugger = 0;
#if defined( _HW_VERSION_1 )
#define PRINTF rmonPrintf
#else
#define PRINTF osSyncPrintf
#endif
boot(void *arg)
{
osInitialize();
osCreateThread(&mainThread, 1, (void(*)(void *))mainproc, arg,
mainThreadStack+STACKSIZE/8, (OSPri)10);
osStartThread(&mainThread);
}
static void mainproc(char *argv)
{
int printOnly;
osCreateThread(&gameThread, 6, gameproc, argv, gameThreadStack+STACKSIZE/8,
(OSPri)10);
/*
* Start PI Mgr for access to cartridge - start before debugger?
*/
osCreatePiManager((OSPri) OS_PRIORITY_PIMGR, &PiMessageQ, PiMessages,
DMA_QUEUE_SIZE);
/*
* determine what mode to start up in.
*/
printOnly = 1;
if (printOnly) {
osCreateThread(&rmonThread, 0, rmonMain, (void *)0,
rmonStack+MY_RMON_STACKSIZE/8,
(OSPri)OS_PRIORITY_RMON );
osStartThread(&rmonThread);
osStartThread(&gameThread);
} else if (debugger) {
osCreateThread(&rmonThread, 0, rmonMain, (void *)0,
rmonStack+MY_RMON_STACKSIZE/8,
(OSPri) OS_PRIORITY_RMON );
osStartThread(&rmonThread);
} else {
osStartThread(&gameThread);
}
osSetThreadPri(0, 0);
for(;;);
}
static void gameproc(void *arg)
{
OSLog logger;
OSLog *log = &logger;
int x_int = 1;
short x_short = 5;
char x_char = 10;
float x_float = 1.0;
u32 start,end;
int i;
x_float = 1.0; /* hack around bug */
x_float = 1.0;
PRINTF("---- <start logtest> ----\n");
osCreateLog(log, logData, LOG_LEN);
PRINTF("created log\n");
osLogEvent(log, 0, 0);
osLogEvent(log, 1, 1, x_int);
osLogEvent(log, 2, 1, x_short);
osLogEvent(log, 3, 1, x_char);
osLogEvent(log, 4, 1, OS_LOG_FLOAT(x_float));
osLogEvent(log, 5, 2, x_int, OS_LOG_FLOAT(x_float));
osLogEvent(log, 6, 4, 0, 1, 2, 3);
PRINTF("logged events\n");
for(i = 0; i < 5; i++) {
start = osGetCount();
osDelay(100000);
end = osGetCount();
osLogEvent(log, 7, 1, end - start);
PRINTF("end 0x%x, start 0x%x\n", end, start);
}
PRINTF("flushing log...\n");
osFlushLog(log);
PRINTF("flushed log\n");
while(1);
}