-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofiler.c
114 lines (97 loc) · 3.07 KB
/
profiler.c
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
/*
* PSP Software Development Kit - https://github.com/pspdev
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* profiler.c - Debug profiler functions.
*
* Copyright (c) 2005 Marcus R. Brown <[email protected]>
* Copyright (c) 2005 James Forshaw <[email protected]>
* Copyright (c) 2005 John Kelley <[email protected]>
*
*/
#include <pspkernel.h>
#include <pspdebug.h>
#include <stdio.h>
#define PROFILER_REG_BASE 0xBC400000
#define PROFILER_REG_COUNT 21
PSP_MODULE_INFO("KernelModule", 0x1000, 1, 1);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
void ProfileEnable(void)
{
_sw(1, PROFILER_REG_BASE);
}
void ProfileDisable(void)
{
_sw(0, PROFILER_REG_BASE);
asm("sync\r\n");
}
void ProfileClear(void)
{
u32 addr;
int i;
addr = PROFILER_REG_BASE;
/* Don't clear the enable register */
for(i = 1; i < PROFILER_REG_COUNT; i++)
{
addr += 4;
_sw(0, addr);
}
}
void ProfileGetRegs(PspDebugProfilerRegs *regs)
{
u32 *p_regs;
u32 addr;
int i;
if(regs == NULL)
{
return;
}
p_regs = (u32 *) regs;
addr = PROFILER_REG_BASE;
for(i = 0; i < PROFILER_REG_COUNT; i++)
{
p_regs[i] = _lw(addr);
addr += 4;
}
}
#define WELCOME_MESSAGE "\n"
int module_start(SceSize args, void *argp)
{
printf(WELCOME_MESSAGE);
return 0;
}
int module_stop()
{
return 0;
}
/*
void pspDebugProfilerPrint(void)
{
PspDebugProfilerRegs regs;
pspDebugProfilerGetRegs(®s);
pspDebugScreenPrintf("********** Profile ***********\n");
pspDebugScreenPrintf("enable : %10u\n", regs.enable);
pspDebugScreenPrintf("systemck : %10u [cycles]\n", regs.systemck);
pspDebugScreenPrintf("cpu ck : %10u [cycles]\n", regs.cpuck);
pspDebugScreenPrintf("stall : %10u [cycles]\n", regs.internal + regs.memory +
regs.copz + regs.vfpu);
pspDebugScreenPrintf("+(internal) : %10u [cycles]\n", regs.internal);
pspDebugScreenPrintf("+--(memory) : %10u [cycles]\n", regs.memory);
pspDebugScreenPrintf("+----(COPz) : %10u [cycles]\n", regs.copz);
pspDebugScreenPrintf("+----(VFPU) : %10u [cycles]\n", regs.vfpu);
pspDebugScreenPrintf("sleep : %10u [cycles]\n", regs.sleep);
pspDebugScreenPrintf("bus access : %10u [cycles]\n", regs.bus_access);
pspDebugScreenPrintf("uncached load : %10u [times]\n", regs.uncached_load);
pspDebugScreenPrintf("uncached store : %10u [times]\n", regs.uncached_store);
pspDebugScreenPrintf("cached load : %10u [times]\n", regs.cached_load);
pspDebugScreenPrintf("cached store : %10u [times]\n", regs.cached_store);
pspDebugScreenPrintf("I cache miss : %10u [times]\n", regs.i_miss);
pspDebugScreenPrintf("D cache miss : %10u [times]\n", regs.d_miss);
pspDebugScreenPrintf("D cache wb : %10u [times]\n", regs.d_writeback);
pspDebugScreenPrintf("COP0 inst. : %10u [inst.]\n", regs.cop0_inst);
pspDebugScreenPrintf("FPU inst. : %10u [inst.]\n", regs.fpu_inst);
pspDebugScreenPrintf("VFPU inst. : %10u [inst.]\n", regs.vfpu_inst);
pspDebugScreenPrintf("local bus : %10u [cycles]\n", regs.local_bus);
}
*/