forked from AerialX/PSL1GHT
-
Notifications
You must be signed in to change notification settings - Fork 67
/
main.c
59 lines (43 loc) · 1.64 KB
/
main.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
#include <psl1ght/lv2.h>
#include <psl1ght/lv2/spu.h>
#include <lv2/spu.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "spu.bin.h"
#define ptr2ea(x) ((u64)(void *)(x))
int main(int argc, const char* argv[])
{
sysSpuImage image;
u32 thread_id;
u32 group_id;
Lv2SpuThreadAttributes attr = { ptr2ea("mythread"), 8+1, LV2_SPU_THREAD_ATTRIBUTE_NONE };
Lv2SpuThreadArguments arg = { 0, 0, 0, 0 };
static vu32 ret __attribute__((aligned(16)));
u32 cause, status;
Lv2SpuThreadGroupAttributes grpattr = { 7+1, ptr2ea("mygroup"), 0, 0 };
static char text[17] __attribute__((aligned(16))) = "abCdefGhIJklMnOP";
printf("Initializing 6 SPUs... ");
printf("%08x\n", lv2SpuInitialize(6, 0));
printf("Loading ELF image... ");
printf("%08x\n", sysSpuImageImport(&image, spu_bin, 0));
printf("Creating thread group... ");
printf("%08x\n", lv2SpuThreadGroupCreate(&group_id, 1, 100, &grpattr));
arg.argument1 = ptr2ea(text);
arg.argument2 = ptr2ea(&ret);
printf("ptrvl = %lu, value = %016lx\n", sizeof(char *), arg.argument1);
printf("input string = \"%s\"\n", text);
printf("Creating SPU thread... ");
printf("%08x\n", lv2SpuThreadInitialize(&thread_id, group_id, 0, &image, &attr, &arg));
printf("Starting SPU thread group... ");
printf("%08x\n", lv2SpuThreadGroupStart(group_id));
printf("Waiting for SPU to return...\n");
while (ret == 0);
printf("Joining SPU thread group... ");
printf("%08x\n", lv2SpuThreadGroupJoin(group_id, &cause, &status));
printf("cause=%d status=%d\n", cause, status);
printf("Closing image... ");
printf("%08x\n", sysSpuImageClose(&image));
printf("output string = \"%s\"\n", text);
return 0;
}