removed unused files, accidently copied wrong license header in them.
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
# SCE CONFIDENTIAL
|
||||
# PLAYSTATION(R)3 Programmer Tool Runtime Library 085.007
|
||||
# Copyright (C) 2005 Sony Computer Entertainment Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
|
||||
CELL_MK_DIR ?= $(CELL_SDK)/samples/mk
|
||||
include $(CELL_MK_DIR)/sdk.makedef.mk
|
||||
|
||||
MK_TARGET = spu_thr_printf.ppu.mk hello.spu.mk
|
||||
|
||||
include $(CELL_MK_DIR)/sdk.target.mk
|
||||
|
||||
|
||||
@@ -1,239 +0,0 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Name="SPU_printf"
|
||||
ProjectGUID="{47EE939D-CB3D-4600-B8B6-79FDF607E133}"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="PS3 Debug|Win32"
|
||||
OutputDirectory="PS3_Debug"
|
||||
IntermediateDirectory="PS3_Debug"
|
||||
ConfigurationType="1"
|
||||
DeleteExtensionsOnClean="*.obj;*.d;*.map;*.lst;*.pch;$(TargetPath);$(TargetDir)$(TargetName).self"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions="-g -O0 -Wall -fno-exceptions"
|
||||
AdditionalIncludeDirectories=""$(SN_PS3_PATH)\spu\include\sn";"$(SCE_PS3_ROOT)\target\spu\include";"$(SCE_PS3_ROOT)\target\common\include";"$(TargetDir)/cache/include""
|
||||
PreprocessorDefinitions="SN_TARGET_PS3_SPU;_DEBUG;__GCC__;SPU"
|
||||
ProgramDataBaseFileName="$(IntDir)/"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions=""
|
||||
AdditionalDependencies=""
|
||||
OutputFile="../$(ProjectName).spu.elf"
|
||||
AdditionalLibraryDirectories=""
|
||||
GenerateManifest="false"
|
||||
GenerateDebugInformation="true"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
Description="Fake Signing ELF "$(TargetDir)$(TargetName).self""
|
||||
CommandLine="$(SCE_PS3_ROOT)\host-win32\bin\make_fself "$(TargetPath)" "$(TargetDir)$(TargetName).self""
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="PS3 Release|Win32"
|
||||
OutputDirectory="PS3_Release"
|
||||
IntermediateDirectory="PS3_Release"
|
||||
ConfigurationType="1"
|
||||
DeleteExtensionsOnClean="*.obj;*.d;*.map;*.lst;*.pch;$(TargetPath);$(TargetDir)$(TargetName).self"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions="-O2 -Wall -fno-exceptions"
|
||||
AdditionalIncludeDirectories=""$(SN_PS3_PATH)\spu\include\sn";"$(SCE_PS3_ROOT)\target\spu\include";"$(SCE_PS3_ROOT)\target\common\include";"$(TargetDir)/cache/include""
|
||||
PreprocessorDefinitions="SN_TARGET_PS3_SPU;NDEBUG;__GCC__;SPU"
|
||||
ProgramDataBaseFileName="$(IntDir)/"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions=""
|
||||
AdditionalDependencies=""
|
||||
OutputFile="../$(ProjectName).spu.elf"
|
||||
AdditionalLibraryDirectories=""
|
||||
GenerateManifest="false"
|
||||
GenerateDebugInformation="true"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
Description="Fake Signing ELF "$(TargetDir)$(TargetName).self""
|
||||
CommandLine="$(SCE_PS3_ROOT)\host-win32\bin\make_fself "$(TargetPath)" "$(TargetDir)$(TargetName).self""
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;cc;s;asm"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\hello.spu.c"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\cache\include\api.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\cache\include\cbe_mfc.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\cache\include\defs.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\cache\include\dma.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\cache\include\ilog2.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\cache\include\memset.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\cache\include\nway-lookup.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\cache\include\nway-miss.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\cache\include\nway-opt.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\cache\include\nway-replace.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\cache\include\nway.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\cache\include\spe_cache.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\cache\include\vec_literal.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
@@ -1,83 +0,0 @@
|
||||
/*
|
||||
* SCE CONFIDENTIAL
|
||||
* PLAYSTATION(R)3 Programmer Tool Runtime Library 085.007
|
||||
* Copyright (C) 2005 Sony Computer Entertainment Inc.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
#include <sys/spu_thread.h>
|
||||
#include <spu_printf.h>
|
||||
|
||||
#include <spu_intrinsics.h>
|
||||
#include <sys/spu_thread.h>
|
||||
#include <sys/spu_event.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define SPE_CACHE_NWAY 4
|
||||
#define SPE_CACHE_NSETS 32
|
||||
#define SPE_CACHELINE_SIZE 512
|
||||
#define SPE_CACHE_SET_TAGID(set) 16
|
||||
|
||||
#define USE_SOFTWARE_CACHE 1
|
||||
#ifdef USE_SOFTWARE_CACHE
|
||||
|
||||
#include "cache/include/spe_cache.h"
|
||||
|
||||
void * spe_readcache(unsigned int ea)
|
||||
{
|
||||
|
||||
int set, idx, line, byte;
|
||||
_spe_cache_nway_lookup_(ea, set, idx);
|
||||
|
||||
if (unlikely(idx < 0)) {
|
||||
idx = _spe_cache_miss_(ea, set, -1);
|
||||
spu_writech(22, SPE_CACHE_SET_TAGMASK(set));
|
||||
spu_mfcstat(MFC_TAG_UPDATE_ALL);
|
||||
}
|
||||
line = _spe_cacheline_num_(set, idx);
|
||||
byte = _spe_cacheline_byte_offset_(ea);
|
||||
return (void *) &spe_cache_mem[line + byte];
|
||||
}
|
||||
#endif //USE_SOFTWARE_CACHE
|
||||
|
||||
int main(int spu_num,uint64_t mainmemPtr)
|
||||
{
|
||||
int memPtr = (int) mainmemPtr;
|
||||
|
||||
|
||||
#define MAX_BUF 256
|
||||
char spuBuffer[MAX_BUF];
|
||||
spuBuffer[0] = 0;
|
||||
|
||||
char* result,*result2; //= spe_cache_rd(mainmemPtr);
|
||||
|
||||
#ifdef USE_SOFTWARE_CACHE
|
||||
|
||||
//this is a brute-force sample.
|
||||
//you can use the software cache more efficient using __spe_cache_rd_x4 to read 4 elements at a time
|
||||
|
||||
int i=0;
|
||||
do
|
||||
{
|
||||
result = spe_readcache(mainmemPtr+i);
|
||||
//spe_readcache is the expanded version of spe_cache_rd MACRO
|
||||
|
||||
spuBuffer[i] = result[0];
|
||||
i++;
|
||||
} while (result[0] && (i<MAX_BUF)); //assume that the buffer ends with [0] in main memory
|
||||
|
||||
|
||||
//result = _spe_cache_lookup_xfer_wait_(mainmemPtr, 0, 1);
|
||||
|
||||
result = spe_readcache(mainmemPtr);
|
||||
result2 = spe_readcache(mainmemPtr);
|
||||
#endif //USE_SOFTWARE_CACHE
|
||||
|
||||
if (i>= MAX_BUF)
|
||||
{
|
||||
spu_printf("spe_readcache buffer overflow. is the buffer 0-terminated?\n");
|
||||
}
|
||||
spu_printf("spe_cache_rd(%x) = %s\n", memPtr,spuBuffer);
|
||||
|
||||
sys_spu_thread_exit(0);
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
# SCE CONFIDENTIAL
|
||||
# PLAYSTATION(R)3 Programmer Tool Runtime Library 085.007
|
||||
# Copyright (C) 2005 Sony Computer Entertainment Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
|
||||
CELL_MK_DIR ?= $(CELL_SDK)/samples/mk
|
||||
|
||||
|
||||
include $(CELL_MK_DIR)/sdk.makedef.mk
|
||||
|
||||
SPU_INCDIRS += -Icache/include
|
||||
SPU_SRCS = hello.spu.c
|
||||
SPU_TARGET = hello.spu.elf
|
||||
SPU_OPTIMIZE_LV=-O0
|
||||
|
||||
include $(CELL_MK_DIR)/sdk.target.mk
|
||||
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
/* SCE CONFIDENTIAL */
|
||||
/* PLAYSTATION(R)3 Programmer Tool Runtime Library 085.007 */
|
||||
/* Copyright (C) 2005 Sony Computer Entertainment Inc. */
|
||||
/* All Rights Reserved. */
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
void spu_printf_server_entry(uint64_t arg);
|
||||
int spu_printf_server_initialize(void);
|
||||
int spu_printf_server_finalize(void);
|
||||
int spu_printf_server_register(sys_spu_thread_t spu);
|
||||
int spu_printf_server_unregister(sys_spu_thread_t spu);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
@@ -1,204 +0,0 @@
|
||||
/*
|
||||
* SCE CONFIDENTIAL
|
||||
* PLAYSTATION(R)3 Programmer Tool Runtime Library 085.007
|
||||
* Copyright (C) 2005 Sony Computer Entertainment Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* The SPU printf server is a PPU thread which collaborates with an SPU to
|
||||
* output strings.
|
||||
*
|
||||
* On SPU-side, spu_printf() places the output string and arguments on a stack
|
||||
* in the local storage, and passes its local-storage address with an SPU
|
||||
* thread user event from SPU port 1 to PPU. On PPU-side,
|
||||
* spu_thread_sprintf fetches the stack in the local stroage by DMA, and parse
|
||||
* it to string-format.
|
||||
*
|
||||
* The SPU printf server takes charge of the tasks on PPU-side. The sequence
|
||||
* of its task is as follows.
|
||||
* 1. Receive events by sys_event_queue_receive()
|
||||
* 2. Parse the received spu_printf stack address by spu_thread_snprintf.
|
||||
* 3. Output the parsed string by printf(), and go back to step 1.
|
||||
*
|
||||
* Initialization of the SPU printf server and registeration of SPU threads to
|
||||
* the SPU printf server is required. These can be done by
|
||||
* spu_printf_server_initilize() and spu_printf_server_register().
|
||||
* What they actually do is to create a PPU thread and event queue, and
|
||||
* connect the SPU thread to the event queue.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/ppu_thread.h>
|
||||
#include <sys/spu_thread.h>
|
||||
#include <sys/event.h>
|
||||
#include <spu_printf.h>
|
||||
#include "spu_printf_server.h"
|
||||
|
||||
#define STACK_SIZE 4096
|
||||
#define PRIO 200
|
||||
|
||||
static sys_ppu_thread_t thread;
|
||||
static sys_event_queue_t equeue;
|
||||
static sys_event_queue_attribute_t eattr;
|
||||
static sys_event_port_t terminating_port;
|
||||
|
||||
#define TERMINATING_PORT_NAME 0xFEE1DEAD
|
||||
#define SPU_PORT_PRINTF 0x1
|
||||
|
||||
int spu_printf_server_initialize()
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* Create event */
|
||||
sys_event_queue_attribute_initialize(eattr);
|
||||
ret = sys_event_queue_create(&equeue, &eattr, SYS_EVENT_PORT_LOCAL, 127);
|
||||
if (ret) {
|
||||
printf("sys_event_queue_create faild %d\n", ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Create PPU thread */
|
||||
ret = sys_ppu_thread_create(&thread, spu_printf_server_entry, 0UL, PRIO,
|
||||
STACK_SIZE,
|
||||
SYS_PPU_THREAD_CREATE_JOINABLE,
|
||||
(char*)"spu_printf_server");
|
||||
if (ret) {
|
||||
printf ("spu_printf_server_initialize: sys_ppu_thread_create failed %d\n", ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Create the terminating port. This port is used only in
|
||||
* sys_printf_server_finalize().
|
||||
*/
|
||||
ret = sys_event_port_create(&terminating_port,
|
||||
SYS_EVENT_PORT_LOCAL,
|
||||
TERMINATING_PORT_NAME);
|
||||
if (ret) {
|
||||
printf ("spu_printf_server_initialize: sys_event_port_create failed %d\n", ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = sys_event_port_connect_local(terminating_port, equeue);
|
||||
if (ret) {
|
||||
printf ("spu_printf_server_initialize: sys_event_port_connect_local failed %d\n", ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Before call this, SPU threads which are registered finishes to send
|
||||
* printf event.
|
||||
*/
|
||||
int spu_printf_server_finalize()
|
||||
{
|
||||
int ret;
|
||||
|
||||
/*
|
||||
* Send an event from the terminating port to notify the termination to
|
||||
* the SPU printf server
|
||||
*/
|
||||
ret = sys_event_port_send(terminating_port, 0, 0, 0);
|
||||
if (ret) {
|
||||
printf("sys_event_queue_cancel failed %d\n", ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Wait for the termination of the SPU printf server */
|
||||
uint64_t exit_status;
|
||||
ret = sys_ppu_thread_join(thread, &exit_status);
|
||||
if (ret) {
|
||||
printf("sys_ppu_thread_join failed %d\n", ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Disconnect and destroy the terminating port */
|
||||
ret = sys_event_port_disconnect(terminating_port);
|
||||
if (ret) {
|
||||
printf("sys_event_disconnect failed %d\n", ret);
|
||||
}
|
||||
ret = sys_event_port_destroy(terminating_port);
|
||||
if (ret) {
|
||||
printf("sys_event_port_destroy failed %d\n", ret);
|
||||
}
|
||||
|
||||
/* Destroy the event queue */
|
||||
ret = sys_event_queue_destroy(equeue, 0);
|
||||
if (ret) {
|
||||
printf("sys_event_queue_destroy failed %d\n", ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int spu_printf_server_register(sys_spu_thread_t spu)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = sys_spu_thread_connect_event(spu, equeue,
|
||||
SYS_SPU_THREAD_EVENT_USER, SPU_PORT_PRINTF);
|
||||
if (ret) {
|
||||
printf("sys_spu_thread_connect_event faild %d\n", ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int spu_printf_server_unregister(sys_spu_thread_t spu)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = sys_spu_thread_disconnect_event(spu,
|
||||
SYS_SPU_THREAD_EVENT_USER, SPU_PORT_PRINTF);
|
||||
if (ret) {
|
||||
printf("sys_spu_thread_disconnect_event faild %d\n", ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void spu_printf_server_entry(uint64_t arg)
|
||||
{
|
||||
(void)arg; /* This thread does not use the argument */
|
||||
|
||||
int ret;
|
||||
sys_event_t event;
|
||||
sys_spu_thread_t spu;
|
||||
|
||||
for (;;) {
|
||||
ret = sys_event_queue_receive(equeue, &event, SYS_NO_TIMEOUT);
|
||||
if (ret) {
|
||||
printf("sys_event_queue_receive failed %d\n", ret);
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* If an event is sent from the terminating port, the SPU printf
|
||||
* server exits.
|
||||
*/
|
||||
if (event.source == TERMINATING_PORT_NAME) {
|
||||
printf("Finalize the SPU printf server.\n");
|
||||
break;
|
||||
}
|
||||
|
||||
spu = event.data1;
|
||||
|
||||
int sret = spu_thread_printf(spu, event.data3);
|
||||
ret = sys_spu_thread_write_spu_mb(spu, sret);
|
||||
if (ret) {
|
||||
printf("sys_spu_thread_write_spu_mb failed %d\n", ret);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
sys_ppu_thread_exit(0);
|
||||
}
|
||||
|
||||
@@ -1,243 +0,0 @@
|
||||
/*
|
||||
* SCE CONFIDENTIAL
|
||||
* PLAYSTATION(R)3 Programmer Tool Runtime Library 085.007
|
||||
* Copyright (C) 2005 Sony Computer Entertainment Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* File: spu_thr_printf.c
|
||||
* Description:
|
||||
* This sample shows how to output strings by SPU programs. spu_printf()
|
||||
* called by
|
||||
*
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/spu_initialize.h>
|
||||
#include <sys/spu_image.h>
|
||||
#include <sys/spu_thread.h>
|
||||
#include <sys/spu_thread_group.h>
|
||||
#include <sys/spu_utility.h>
|
||||
#include <sys/paths.h>
|
||||
#include "spu_printf_server.h" /* SPU printf server */
|
||||
|
||||
#define MAX_PHYSICAL_SPU 4
|
||||
#define MAX_RAW_SPU 0
|
||||
#define NUM_SPU_THREADS 4 /* The number of SPU threads in the group */
|
||||
#define PRIORITY 100
|
||||
#ifdef SN_TARGET_PS3
|
||||
#define SPU_PROG (SYS_APP_HOME "/SPU_printf.spu.self")
|
||||
#else
|
||||
#define SPU_PROG (SYS_APP_HOME "/hello.spu.self")
|
||||
#endif
|
||||
|
||||
#define IN_BUF_SIZE 256
|
||||
#define OUT_BUF_SIZE 256
|
||||
|
||||
volatile uint8_t in_buf[IN_BUF_SIZE];
|
||||
volatile uint8_t out_buf[OUT_BUF_SIZE];
|
||||
uint32_t in_size = IN_BUF_SIZE;
|
||||
uint32_t out_size = OUT_BUF_SIZE;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
||||
|
||||
|
||||
sprintf(in_buf,"hello world");
|
||||
|
||||
sys_spu_thread_group_t group; /* SPU thread group ID */
|
||||
const char *group_name = "Group";
|
||||
sys_spu_thread_group_attribute_t group_attr;/* SPU thread group attribute*/
|
||||
sys_spu_thread_t threads[NUM_SPU_THREADS]; /* SPU thread IDs */
|
||||
sys_spu_thread_attribute_t thread_attr; /* SPU thread attribute */
|
||||
const char *thread_names[NUM_SPU_THREADS] =
|
||||
{"SPU Thread 0",
|
||||
"SPU Thread 1",
|
||||
"SPU Thread 2",
|
||||
"SPU Thread 3"}; /* The names of SPU threads */
|
||||
sys_spu_image_t spu_img;
|
||||
int ret;
|
||||
|
||||
/*
|
||||
* Initialize SPUs
|
||||
*/
|
||||
printf("Initializing SPUs\n");
|
||||
ret = sys_spu_initialize(MAX_PHYSICAL_SPU, MAX_RAW_SPU);
|
||||
if (ret != CELL_OK) {
|
||||
fprintf(stderr, "sys_spu_initialize failed: %#.8x\n", ret);
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
/*
|
||||
* Create an SPU thread group
|
||||
*/
|
||||
printf("Creating an SPU thread group.\n");
|
||||
group_attr.name = group_name;
|
||||
group_attr.nsize = strlen(group_attr.name) + 1; /* Add 1 for '\0' */
|
||||
group_attr.type = SYS_SPU_THREAD_GROUP_TYPE_NORMAL;
|
||||
ret = sys_spu_thread_group_create(&group,
|
||||
NUM_SPU_THREADS,
|
||||
PRIORITY,
|
||||
&group_attr);
|
||||
if (ret != CELL_OK) {
|
||||
fprintf(stderr, "sys_spu_thread_group_create failed: %#.8x\n", ret);
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
ret = sys_spu_image_open(&spu_img, SPU_PROG);
|
||||
if (ret != CELL_OK) {
|
||||
fprintf(stderr, "sys_spu_image_open failed: %#.8x\n", ret);
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize the SPU printf server
|
||||
*
|
||||
* What spu_printf_server_initialize() actually does is to create an
|
||||
* PPU thread and an event queue which handle the events sent by
|
||||
* spu_printf().
|
||||
*/
|
||||
ret = spu_printf_server_initialize();
|
||||
if (ret != SUCCEEDED) {
|
||||
fprintf(stderr, "spu_printf_server_initialize failed: %#.8x\n", ret);
|
||||
exit(ret);
|
||||
}
|
||||
/*
|
||||
* In this loop, all SPU threads in the SPU thread group are initialized
|
||||
* with the loaded SPU ELF image.
|
||||
*/
|
||||
for (int i = 0; i < NUM_SPU_THREADS; i++) {
|
||||
sys_spu_thread_argument_t thread_args;
|
||||
int spu_num = i;
|
||||
|
||||
printf("Initializing SPU thread %d\n", i);
|
||||
|
||||
/*
|
||||
* nsegs, segs and entry_point have already been initialized by
|
||||
* sys_spu_thread_elf_loader().
|
||||
*/
|
||||
thread_attr.name = thread_names[i];
|
||||
thread_attr.nsize = strlen(thread_names[i]) + 1;
|
||||
thread_attr.option = SYS_SPU_THREAD_OPTION_NONE;
|
||||
|
||||
/*
|
||||
* Pass the SPU number to the SPU thread as the first parameter.
|
||||
*/
|
||||
thread_args.arg1 = SYS_SPU_THREAD_ARGUMENT_LET_32(spu_num);
|
||||
thread_args.arg2 = SYS_SPU_THREAD_ARGUMENT_LET_64((uint64_t)in_buf);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* The third argument specifies the SPU number.
|
||||
* The SPU number of each SPU thread must be unique within the SPU
|
||||
* thread group.
|
||||
*/
|
||||
ret = sys_spu_thread_initialize(&threads[i],
|
||||
group,
|
||||
spu_num,
|
||||
&spu_img,
|
||||
&thread_attr,
|
||||
&thread_args);
|
||||
if (ret != CELL_OK) {
|
||||
fprintf(stderr, "sys_spu_thread_initialize failed: %#.8x\n", ret);
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
/*
|
||||
* Register the SPU thread to the SPU printf server.
|
||||
*
|
||||
* spu_printf_server_register() establishes the connection between
|
||||
* the SPU thread and the SPU printf server's event queue.
|
||||
*/
|
||||
ret = spu_printf_server_register(threads[i]);
|
||||
if (ret != CELL_OK) {
|
||||
fprintf(stderr, "spu_printf_server_register failed: %#.8x\n", ret);
|
||||
exit(ret);
|
||||
}
|
||||
}
|
||||
|
||||
printf("All SPU threads have been successfully initialized.\n");
|
||||
|
||||
/*
|
||||
* Start the SPU thread group
|
||||
*
|
||||
* The SPU thread group will be in the READY state, and will become in
|
||||
* the RUNNING state when the kernel assigns and executes it onto SPUs.
|
||||
*/
|
||||
printf("Starting the SPU thread group.\n");
|
||||
ret = sys_spu_thread_group_start(group);
|
||||
if (ret != CELL_OK) {
|
||||
fprintf(stderr, "sys_spu_thread_group_start failed: %#.8x\n", ret);
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
/*
|
||||
* Wait for the termination of the SPU thread group.
|
||||
*/
|
||||
printf("Waiting for the SPU thread group to be terminated.\n");
|
||||
int cause, status;
|
||||
ret = sys_spu_thread_group_join(group, &cause, &status);
|
||||
if (ret != CELL_OK) {
|
||||
fprintf(stderr, "sys_spu_thread_group_join failed: %#.8x\n", ret);
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
/*
|
||||
* Show the exit cause and status.
|
||||
*/
|
||||
switch(cause) {
|
||||
case SYS_SPU_THREAD_GROUP_JOIN_GROUP_EXIT:
|
||||
printf("The SPU thread group exited by sys_spu_thread_group_exit().\n");
|
||||
printf("The group's exit status = %d\n", status);
|
||||
break;
|
||||
case SYS_SPU_THREAD_GROUP_JOIN_ALL_THREADS_EXIT:
|
||||
printf("All SPU thread exited by sys_spu_thread_exit().\n");
|
||||
for (int i = 0; i < NUM_SPU_THREADS; i++) {
|
||||
int thr_exit_status;
|
||||
ret = sys_spu_thread_get_exit_status(threads[i], &thr_exit_status);
|
||||
if (ret != CELL_OK) {
|
||||
fprintf(stderr, "sys_spu_thread_get_exit_status failed: %#.8x\n", ret);
|
||||
}
|
||||
printf("SPU thread %d's exit status = %d\n", i, thr_exit_status);
|
||||
}
|
||||
break;
|
||||
case SYS_SPU_THREAD_GROUP_JOIN_TERMINATED:
|
||||
printf("The SPU thread group is terminated by sys_spu_thread_terminate().\n");
|
||||
printf("The group's exit status = %d\n", status);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Unknown exit cause: %d\n", cause);
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Destroy the SPU thread group and clean up resources.
|
||||
*/
|
||||
ret = sys_spu_thread_group_destroy(group);
|
||||
if (ret != CELL_OK) {
|
||||
fprintf(stderr, "sys_spu_thread_group_destroy failed: %#.8x\n", ret);
|
||||
}
|
||||
|
||||
ret = sys_spu_image_close(&spu_img);
|
||||
if (ret != CELL_OK) {
|
||||
fprintf(stderr, "sys_spu_image_close failed: %.8x\n", ret);
|
||||
}
|
||||
|
||||
/*
|
||||
* Finalize the SPU printf server.
|
||||
*
|
||||
* This function let the PPU thread exit.
|
||||
* The event queue will be destroyed.
|
||||
*/
|
||||
ret = spu_printf_server_finalize();
|
||||
if (ret != CELL_OK) {
|
||||
fprintf(stderr, "spu_printf_server_finalize failed: %#.8x\n", ret);
|
||||
}
|
||||
|
||||
printf("Exiting.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
# SCE CONFIDENTIAL
|
||||
# PLAYSTATION(R)3 Programmer Tool Runtime Library 085.007
|
||||
# Copyright (C) 2005 Sony Computer Entertainment Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
|
||||
CELL_MK_DIR ?= $(CELL_SDK)/samples/mk
|
||||
|
||||
include $(CELL_MK_DIR)/sdk.makedef.mk
|
||||
|
||||
PPU_SRCS = spu_thr_printf.ppu.c spu_printf_server.ppu.c
|
||||
PPU_TARGET = spu_thr_printf.ppu.elf
|
||||
|
||||
include $(CELL_MK_DIR)/sdk.target.mk
|
||||
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 9.00
|
||||
# Visual Studio 2005
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "spu_thr_printf_2", "spu_thr_printf_2.vcproj", "{3494AF8B-FDA7-4CEA-B775-4C5C45599D5F}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{47EE939D-CB3D-4600-B8B6-79FDF607E133} = {47EE939D-CB3D-4600-B8B6-79FDF607E133}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SPU_printf", "SPU_printf\SPU_printf.vcproj", "{47EE939D-CB3D-4600-B8B6-79FDF607E133}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
PS3 Debug|Win32 = PS3 Debug|Win32
|
||||
PS3 Release|Win32 = PS3 Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{3494AF8B-FDA7-4CEA-B775-4C5C45599D5F}.PS3 Debug|Win32.ActiveCfg = PS3 Debug|Win32
|
||||
{3494AF8B-FDA7-4CEA-B775-4C5C45599D5F}.PS3 Debug|Win32.Build.0 = PS3 Debug|Win32
|
||||
{3494AF8B-FDA7-4CEA-B775-4C5C45599D5F}.PS3 Release|Win32.ActiveCfg = PS3 Release|Win32
|
||||
{3494AF8B-FDA7-4CEA-B775-4C5C45599D5F}.PS3 Release|Win32.Build.0 = PS3 Release|Win32
|
||||
{47EE939D-CB3D-4600-B8B6-79FDF607E133}.PS3 Debug|Win32.ActiveCfg = PS3 Debug|Win32
|
||||
{47EE939D-CB3D-4600-B8B6-79FDF607E133}.PS3 Debug|Win32.Build.0 = PS3 Debug|Win32
|
||||
{47EE939D-CB3D-4600-B8B6-79FDF607E133}.PS3 Release|Win32.ActiveCfg = PS3 Release|Win32
|
||||
{47EE939D-CB3D-4600-B8B6-79FDF607E133}.PS3 Release|Win32.Build.0 = PS3 Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -1,200 +0,0 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Name="spu_thr_printf_2"
|
||||
ProjectGUID="{3494AF8B-FDA7-4CEA-B775-4C5C45599D5F}"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="PS3 Debug|Win32"
|
||||
OutputDirectory="PS3_PPU_Debug"
|
||||
IntermediateDirectory="PS3_PPU_Debug"
|
||||
ConfigurationType="1"
|
||||
DeleteExtensionsOnClean="*.obj;*.d;*.map;*.lst;*.pch;$(TargetPath);$(TargetDir)$(TargetName).self"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions="-g -Wall -fno-exceptions"
|
||||
AdditionalIncludeDirectories=""$(SN_PS3_PATH)\ppu\include\sn";"$(SCE_PS3_ROOT)\target\ppu\include";"$(SCE_PS3_ROOT)\target\common\include""
|
||||
PreprocessorDefinitions="SN_TARGET_PS3;_DEBUG;__GCC__"
|
||||
ProgramDataBaseFileName="$(IntDir)/"
|
||||
CompileAs="0"
|
||||
ForcedIncludeFiles=""
|
||||
ForcedUsingFiles=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions="-fno-exceptions"
|
||||
AdditionalDependencies=""$(SN_PS3_PATH)\ppu\lib\sn\libsn.a" "$(SCE_PS3_ROOT)\target\ppu\lib\libm.a" "$(SCE_PS3_ROOT)\target\ppu\lib\libio.a""
|
||||
OutputFile="$(ProjectName).ppu.elf"
|
||||
AdditionalLibraryDirectories=""
|
||||
GenerateManifest="false"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile=""
|
||||
ImportLibrary=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
Description="Fake Signing ELF "$(TargetDir)$(TargetName).self""
|
||||
CommandLine="$(SCE_PS3_ROOT)\host-win32\bin\make_fself "$(TargetPath)" "$(TargetDir)$(TargetName).self""
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="PS3 Release|Win32"
|
||||
OutputDirectory="PS3_PPU_Release"
|
||||
IntermediateDirectory="PS3_PPU_Release"
|
||||
ConfigurationType="1"
|
||||
DeleteExtensionsOnClean="*.obj;*.d;*.map;*.lst;*.pch;$(TargetPath);$(TargetDir)$(TargetName).self"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions="-O2 -Wall -fno-exceptions"
|
||||
AdditionalIncludeDirectories=""$(SN_PS3_PATH)\ppu\include\sn";"$(SCE_PS3_ROOT)\target\ppu\include";"$(SCE_PS3_ROOT)\target\common\include""
|
||||
PreprocessorDefinitions="SN_TARGET_PS3;NDEBUG;__GCC__"
|
||||
ProgramDataBaseFileName="$(IntDir)/"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions="-fno-exceptions"
|
||||
AdditionalDependencies=""$(SN_PS3_PATH)\ppu\lib\sn\libsn.a" "$(SCE_PS3_ROOT)\target\ppu\lib\libm.a" "$(SCE_PS3_ROOT)\target\ppu\lib\libio.a""
|
||||
OutputFile="$(ProjectName).ppu.elf"
|
||||
AdditionalLibraryDirectories=""
|
||||
GenerateManifest="false"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
Description="Fake Signing ELF "$(TargetDir)$(TargetName).self""
|
||||
CommandLine="$(SCE_PS3_ROOT)\host-win32\bin\make_fself "$(TargetPath)" "$(TargetDir)$(TargetName).self""
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;cc;s;asm"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\spu_printf_server.ppu.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\spu_thr_printf.ppu.c"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\spu_printf_server.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
Reference in New Issue
Block a user