mirror of
https://github.com/pspdev/pspsdk.git
synced 2025-12-25 04:54:59 +00:00
first commit
This commit is contained in:
17
src/samples/debug/debugkb/Makefile.sample
Normal file
17
src/samples/debug/debugkb/Makefile.sample
Normal file
@@ -0,0 +1,17 @@
|
||||
TARGET = debugkb
|
||||
OBJS = main.o
|
||||
LIBS = -lpspdebugkb
|
||||
|
||||
INCDIR =
|
||||
CFLAGS = -O2 -G0 -Wall
|
||||
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
ASFLAGS = $(CFLAGS)
|
||||
|
||||
LIBDIR =
|
||||
LDFLAGS =
|
||||
|
||||
EXTRA_TARGETS = EBOOT.PBP
|
||||
PSP_EBOOT_TITLE = Debug Screen Keyboard Example
|
||||
|
||||
PSPSDK=$(shell psp-config --pspsdk-path)
|
||||
include $(PSPSDK)/lib/build.mak
|
||||
105
src/samples/debug/debugkb/main.c
Normal file
105
src/samples/debug/debugkb/main.c
Normal file
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* PSP Software Development Kit - http://www.pspdev.org
|
||||
* -----------------------------------------------------------------------
|
||||
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
|
||||
*
|
||||
* debugkb.c - Example of a simple screen debug keyboard
|
||||
*
|
||||
* Copyright (c) 2006 Mike Mallett <mike@nerdcore.net>
|
||||
*
|
||||
* $Id: main.c 2110 2006-12-19 14:50:27Z tyranid $
|
||||
*/
|
||||
|
||||
#include <pspkernel.h>
|
||||
#include <pspdebug.h>
|
||||
#include <pspctrl.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <pspdebugkb.h>
|
||||
|
||||
/* Define the module info section */
|
||||
PSP_MODULE_INFO("Debug Screen Text Input", 0, 1, 1);
|
||||
|
||||
/* Define the main thread's attribute value (optional) */
|
||||
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
|
||||
|
||||
#define printf pspDebugScreenPrintf
|
||||
#define setXY pspDebugScreenSetXY
|
||||
#define setTextColor pspDebugScreenSetTextColor
|
||||
#define setBackColor pspDebugScreenSetBackColor
|
||||
|
||||
/* Exit callback */
|
||||
int exit_callback()
|
||||
{
|
||||
sceKernelExitGame();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Callback thread */
|
||||
int CallbackThread(SceSize args, void *argp)
|
||||
{
|
||||
int cbid;
|
||||
|
||||
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
|
||||
sceKernelRegisterExitCallback(cbid);
|
||||
|
||||
sceKernelSleepThreadCB();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Sets up the callback thread and returns its thread id */
|
||||
int SetupCallbacks(void)
|
||||
{
|
||||
int thid = 0;
|
||||
|
||||
thid = sceKernelCreateThread("update_thread", CallbackThread,
|
||||
0x11, 0xFA0, 0, 0);
|
||||
if(thid >= 0)
|
||||
{
|
||||
sceKernelStartThread(thid, 0, 0);
|
||||
}
|
||||
|
||||
return thid;
|
||||
}
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
SetupCallbacks();
|
||||
|
||||
pspDebugScreenInit();
|
||||
|
||||
printf ("Debug Screen Text Input Box\n");
|
||||
printf("Press Left Trigger and Right Trigger to bring up the keyboard.\n");
|
||||
|
||||
char str[PSP_DEBUG_KB_MAXLEN];
|
||||
bzero(str, PSP_DEBUG_KB_MAXLEN);
|
||||
|
||||
sceCtrlSetSamplingCycle(0);
|
||||
sceCtrlSetSamplingMode(PSP_CTRL_MODE_DIGITAL);
|
||||
|
||||
SceCtrlData input;
|
||||
|
||||
while (1) {
|
||||
sceCtrlReadBufferPositive(&input, 1);
|
||||
|
||||
if (input.Buttons & PSP_CTRL_LTRIGGER && input.Buttons & PSP_CTRL_RTRIGGER) {
|
||||
pspDebugKbInit(str);
|
||||
|
||||
setTextColor(0xffffffff);
|
||||
setBackColor(0x00000000);
|
||||
setXY(0, 3);
|
||||
printf("str = \"%s\"", str);
|
||||
setXY(0, 4);
|
||||
printf("str is %d characters long", strlen(str));
|
||||
}
|
||||
}
|
||||
|
||||
sceKernelSleepThread();
|
||||
|
||||
sceKernelExitGame();
|
||||
return 0;
|
||||
}
|
||||
16
src/samples/debug/exception/Makefile.sample
Normal file
16
src/samples/debug/exception/Makefile.sample
Normal file
@@ -0,0 +1,16 @@
|
||||
TARGET = exception
|
||||
OBJS = main.o
|
||||
|
||||
INCDIR =
|
||||
CFLAGS = -O2 -G0 -Wall
|
||||
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
ASFLAGS = $(CFLAGS)
|
||||
|
||||
LIBDIR =
|
||||
LDFLAGS =
|
||||
|
||||
EXTRA_TARGETS = EBOOT.PBP
|
||||
PSP_EBOOT_TITLE = Exception Example
|
||||
|
||||
PSPSDK=$(shell psp-config --pspsdk-path)
|
||||
include $(PSPSDK)/lib/build.mak
|
||||
120
src/samples/debug/exception/main.c
Normal file
120
src/samples/debug/exception/main.c
Normal file
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* PSP Software Development Kit - http://www.pspdev.org
|
||||
* -----------------------------------------------------------------------
|
||||
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
|
||||
*
|
||||
* main.c - Basic sample to demonstrate installing an exception handler.
|
||||
*
|
||||
* Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
|
||||
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
|
||||
* Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
|
||||
*
|
||||
* $Id: main.c 1095 2005-09-27 21:02:16Z jim $
|
||||
*/
|
||||
#include <pspkernel.h>
|
||||
#include <pspdebug.h>
|
||||
#include <pspctrl.h>
|
||||
#include <pspdisplay.h>
|
||||
|
||||
PSP_MODULE_INFO("EXTEST", 0x1000, 1, 1);
|
||||
/* Define the main thread's attribute value (optional) */
|
||||
PSP_MAIN_THREAD_ATTR(0);
|
||||
|
||||
/* Define printf, just to make typing easier */
|
||||
#define printf pspDebugScreenPrintf
|
||||
|
||||
/* Exit callback */
|
||||
int exit_callback(int arg1, int arg2, void *common)
|
||||
{
|
||||
sceKernelExitGame();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Callback thread */
|
||||
int CallbackThread(SceSize args, void *argp)
|
||||
{
|
||||
int cbid;
|
||||
|
||||
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
|
||||
sceKernelRegisterExitCallback(cbid);
|
||||
|
||||
sceKernelSleepThreadCB();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Sets up the callback thread and returns its thread id */
|
||||
int SetupCallbacks(void)
|
||||
{
|
||||
int thid = 0;
|
||||
|
||||
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, THREAD_ATTR_USER, 0);
|
||||
if(thid >= 0)
|
||||
{
|
||||
sceKernelStartThread(thid, 0, 0);
|
||||
}
|
||||
|
||||
return thid;
|
||||
}
|
||||
|
||||
/* Example custom exception handler */
|
||||
void MyExceptionHandler(PspDebugRegBlock *regs)
|
||||
{
|
||||
/* Do normal initial dump, setup screen etc */
|
||||
pspDebugScreenInit();
|
||||
|
||||
/* I always felt BSODs were more interesting that white on black */
|
||||
pspDebugScreenSetBackColor(0x00FF0000);
|
||||
pspDebugScreenSetTextColor(0xFFFFFFFF);
|
||||
pspDebugScreenClear();
|
||||
|
||||
pspDebugScreenPrintf("I regret to inform you your psp has just crashed\n");
|
||||
pspDebugScreenPrintf("Please contact Sony technical support for further information\n\n");
|
||||
pspDebugScreenPrintf("Exception Details:\n");
|
||||
pspDebugDumpException(regs);
|
||||
pspDebugScreenPrintf("\nBlame the 3rd party software, it cannot possibly be our fault!\n");
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
SceCtrlData pad;
|
||||
pspDebugScreenInit();
|
||||
SetupCallbacks();
|
||||
|
||||
/* Install our custom exception handler. If this was NULL then the default would be used */
|
||||
pspDebugInstallErrorHandler(MyExceptionHandler);
|
||||
sceCtrlSetSamplingCycle(0);
|
||||
sceCtrlSetSamplingMode(PSP_CTRL_MODE_DIGITAL);
|
||||
|
||||
pspDebugScreenPrintf("Exception Sample\n\n");
|
||||
pspDebugScreenPrintf("You have two choices, press O for a bus error or X for a breakpoint\n\n");
|
||||
|
||||
while(1)
|
||||
{
|
||||
sceCtrlReadBufferPositive(&pad, 1);
|
||||
if(pad.Buttons & PSP_CTRL_CIRCLE)
|
||||
{
|
||||
/* Cause a bus error */
|
||||
_sw(0, 0);
|
||||
}
|
||||
|
||||
if(pad.Buttons & PSP_CTRL_CROSS)
|
||||
{
|
||||
/* Cause a break exception */
|
||||
asm(
|
||||
"break\r\n"
|
||||
);
|
||||
}
|
||||
|
||||
sceDisplayWaitVblankStart();
|
||||
}
|
||||
|
||||
|
||||
/* We will never end up here, hopefully */
|
||||
printf("End\n");
|
||||
|
||||
sceKernelExitDeleteThread(0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
21
src/samples/debug/gdb/Makefile.sample
Normal file
21
src/samples/debug/gdb/Makefile.sample
Normal file
@@ -0,0 +1,21 @@
|
||||
TARGET = gdb
|
||||
OBJS = main.o
|
||||
|
||||
USE_PSPSDK_LIBC = 1
|
||||
|
||||
INCDIR =
|
||||
CFLAGS = -O0 -G0 -Wall -ggdb
|
||||
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
ASFLAGS = $(CFLAGS)
|
||||
|
||||
LIBS = -lpspgdb -lpspgdb_user
|
||||
LIBDIR =
|
||||
LDFLAGS =
|
||||
|
||||
EXTRA_TARGETS = EBOOT.PBP
|
||||
PSP_EBOOT_TITLE = GDB
|
||||
|
||||
PSPSDK=$(shell psp-config --pspsdk-path)
|
||||
include $(PSPSDK)/lib/build.mak
|
||||
|
||||
LIBS += -lpsphprm_driver
|
||||
114
src/samples/debug/gdb/main.c
Normal file
114
src/samples/debug/gdb/main.c
Normal file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* PSP Software Development Kit - http://www.pspdev.org
|
||||
* -----------------------------------------------------------------------
|
||||
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
|
||||
*
|
||||
* main.c - Basic sample to demonstrate installing an exception handler.
|
||||
*
|
||||
* Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
|
||||
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
|
||||
* Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
|
||||
*
|
||||
* $Id: main.c 1095 2005-09-27 21:02:16Z jim $
|
||||
*/
|
||||
#include <pspkernel.h>
|
||||
#include <pspdebug.h>
|
||||
#include <pspctrl.h>
|
||||
#include <pspdisplay.h>
|
||||
#include <stdio.h>
|
||||
|
||||
PSP_MODULE_INFO("EXTEST", 0x1000, 1, 1);
|
||||
/* Define the main thread's attribute value (optional) */
|
||||
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
|
||||
|
||||
/* Exit callback */
|
||||
int exit_callback(int arg1, int arg2, void *common)
|
||||
{
|
||||
sceKernelExitGame();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Callback thread */
|
||||
int CallbackThread(SceSize args, void *argp)
|
||||
{
|
||||
int cbid;
|
||||
|
||||
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
|
||||
sceKernelRegisterExitCallback(cbid);
|
||||
|
||||
sceKernelSleepThreadCB();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Sets up the callback thread and returns its thread id */
|
||||
int SetupCallbacks(void)
|
||||
{
|
||||
int thid = 0;
|
||||
|
||||
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, THREAD_ATTR_USER, 0);
|
||||
if(thid >= 0)
|
||||
{
|
||||
sceKernelStartThread(thid, 0, 0);
|
||||
}
|
||||
|
||||
return thid;
|
||||
}
|
||||
|
||||
/* Initialise SIO and GDB */
|
||||
__attribute__((constructor))
|
||||
void loaderInit()
|
||||
{
|
||||
pspDebugScreenInit();
|
||||
pspDebugScreenPrintf("Initialising serial port\n");
|
||||
pspKernelSetKernelPC();
|
||||
pspDebugSioSetBaud(38400);
|
||||
pspDebugSioInit();
|
||||
pspDebugGdbStubInit();
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
SceCtrlData pad;
|
||||
|
||||
pspDebugScreenPrintf("App Started\n");
|
||||
SetupCallbacks();
|
||||
|
||||
/* Generate a breakpoint to trap into GDB */
|
||||
pspDebugBreakpoint();
|
||||
|
||||
sceCtrlSetSamplingCycle(0);
|
||||
sceCtrlSetSamplingMode(PSP_CTRL_MODE_DIGITAL);
|
||||
|
||||
printf("Exception Sample\n\n");
|
||||
printf("You have two choices, press O for a bus error or X for a breakpoint\n\n");
|
||||
|
||||
while(1)
|
||||
{
|
||||
sceCtrlReadBufferPositive(&pad, 1);
|
||||
if(pad.Buttons & PSP_CTRL_CIRCLE)
|
||||
{
|
||||
/* Cause a bus error */
|
||||
_sw(0, 0);
|
||||
}
|
||||
|
||||
if(pad.Buttons & PSP_CTRL_CROSS)
|
||||
{
|
||||
/* Cause a break exception */
|
||||
asm(
|
||||
"break\r\n"
|
||||
);
|
||||
}
|
||||
|
||||
sceDisplayWaitVblankStart();
|
||||
}
|
||||
|
||||
|
||||
/* We will never end up here, hopefully */
|
||||
printf("End\n");
|
||||
|
||||
sceKernelSleepThread();
|
||||
|
||||
return 0;
|
||||
}
|
||||
16
src/samples/debug/kprintf/Makefile.sample
Normal file
16
src/samples/debug/kprintf/Makefile.sample
Normal file
@@ -0,0 +1,16 @@
|
||||
TARGET = kptest
|
||||
OBJS = main.o
|
||||
|
||||
INCDIR =
|
||||
CFLAGS = -O2 -G0 -Wall
|
||||
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
ASFLAGS = $(CFLAGS)
|
||||
|
||||
LIBDIR =
|
||||
LDFLAGS =
|
||||
|
||||
EXTRA_TARGETS = EBOOT.PBP
|
||||
PSP_EBOOT_TITLE = Kprintf Test
|
||||
|
||||
PSPSDK=$(shell psp-config --pspsdk-path)
|
||||
include $(PSPSDK)/lib/build.mak
|
||||
81
src/samples/debug/kprintf/main.c
Normal file
81
src/samples/debug/kprintf/main.c
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* PSP Software Development Kit - http://www.pspdev.org
|
||||
* -----------------------------------------------------------------------
|
||||
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
|
||||
*
|
||||
* main.c - Basic sample to demonstrate the kprintf handler.
|
||||
*
|
||||
* Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
|
||||
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
|
||||
* Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
|
||||
*
|
||||
* $Id: main.c 1095 2005-09-27 21:02:16Z jim $
|
||||
*/
|
||||
#include <pspkernel.h>
|
||||
#include <pspdebug.h>
|
||||
|
||||
PSP_MODULE_INFO("KPTEST", 0x1000, 1, 1);
|
||||
/* Define the main thread's attribute value (optional) */
|
||||
PSP_MAIN_THREAD_ATTR(0);
|
||||
|
||||
/* Define printf, just to make typing easier */
|
||||
#define printf pspDebugScreenPrintf
|
||||
|
||||
/* Exit callback */
|
||||
int exit_callback(int arg1, int arg2, void *common)
|
||||
{
|
||||
sceKernelExitGame();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Callback thread */
|
||||
int CallbackThread(SceSize args, void *argp)
|
||||
{
|
||||
int cbid;
|
||||
|
||||
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
|
||||
sceKernelRegisterExitCallback(cbid);
|
||||
|
||||
sceKernelSleepThreadCB();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Sets up the callback thread and returns its thread id */
|
||||
int SetupCallbacks(void)
|
||||
{
|
||||
int thid = 0;
|
||||
|
||||
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, THREAD_ATTR_USER, 0);
|
||||
if(thid >= 0)
|
||||
{
|
||||
sceKernelStartThread(thid, 0, 0);
|
||||
}
|
||||
|
||||
return thid;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
pspDebugScreenInit();
|
||||
SetupCallbacks();
|
||||
|
||||
printf("Kprintf Example:\n\n");
|
||||
|
||||
pspDebugInstallKprintfHandler(NULL);
|
||||
|
||||
printf("Lets test a kernel function error report\n");
|
||||
pspDebugScreenSetTextColor(0xFF);
|
||||
/* Try and load a module, this should print an error to the screen */
|
||||
sceKernelLoadModule("test:/this/is/not/a/file.prx", 0, NULL);
|
||||
pspDebugScreenSetTextColor(0xFFFFFFFF);
|
||||
printf("\nLets call Kprintf directly\n");
|
||||
pspDebugScreenSetTextColor(0xFF);
|
||||
Kprintf("Hello from Kprintf\n");
|
||||
|
||||
/* Let's bug out */
|
||||
sceKernelExitDeleteThread(0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
16
src/samples/debug/profiler/Makefile.sample
Normal file
16
src/samples/debug/profiler/Makefile.sample
Normal file
@@ -0,0 +1,16 @@
|
||||
TARGET = profiler
|
||||
OBJS = main.o
|
||||
|
||||
INCDIR =
|
||||
CFLAGS = -O2 -G0 -Wall
|
||||
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
ASFLAGS = $(CFLAGS)
|
||||
|
||||
LIBDIR =
|
||||
LDFLAGS =
|
||||
|
||||
EXTRA_TARGETS = EBOOT.PBP
|
||||
PSP_EBOOT_TITLE = Profiler Test
|
||||
|
||||
PSPSDK=$(shell psp-config --pspsdk-path)
|
||||
include $(PSPSDK)/lib/build.mak
|
||||
85
src/samples/debug/profiler/main.c
Normal file
85
src/samples/debug/profiler/main.c
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* PSP Software Development Kit - http://www.pspdev.org
|
||||
* -----------------------------------------------------------------------
|
||||
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
|
||||
*
|
||||
* main.c - Basic sample to demonstrate the profiler
|
||||
*
|
||||
* Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
|
||||
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
|
||||
* Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
|
||||
*
|
||||
* $Id: main.c 1095 2005-09-27 21:02:16Z jim $
|
||||
*/
|
||||
#include <pspkernel.h>
|
||||
#include <pspdebug.h>
|
||||
#include <pspdisplay.h>
|
||||
#include <string.h>
|
||||
|
||||
PSP_MODULE_INFO("PROFILER", 0x1000, 1, 1);
|
||||
/* Define the main thread's attribute value (optional) */
|
||||
PSP_MAIN_THREAD_ATTR(0);
|
||||
|
||||
/* Define printf, just to make typing easier */
|
||||
#define printf pspDebugScreenPrintf
|
||||
|
||||
/* Exit callback */
|
||||
int exit_callback(int arg1, int arg2, void *common)
|
||||
{
|
||||
sceKernelExitGame();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Callback thread */
|
||||
int CallbackThread(SceSize args, void *argp)
|
||||
{
|
||||
int cbid;
|
||||
|
||||
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
|
||||
sceKernelRegisterExitCallback(cbid);
|
||||
|
||||
sceKernelSleepThreadCB();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Sets up the callback thread and returns its thread id */
|
||||
int SetupCallbacks(void)
|
||||
{
|
||||
int thid = 0;
|
||||
|
||||
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, THREAD_ATTR_USER, 0);
|
||||
if(thid >= 0)
|
||||
{
|
||||
sceKernelStartThread(thid, 0, 0);
|
||||
}
|
||||
|
||||
return thid;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
pspDebugScreenInit();
|
||||
SetupCallbacks();
|
||||
|
||||
/* Clear the existing profile regs */
|
||||
pspDebugProfilerClear();
|
||||
/* Enable profiling */
|
||||
pspDebugProfilerEnable();
|
||||
|
||||
for(i = 0; i < 600; i++)
|
||||
{
|
||||
pspDebugScreenSetXY(0, 0);
|
||||
/* Print profile information to the screen */
|
||||
pspDebugProfilerPrint();
|
||||
sceDisplayWaitVblankStart();
|
||||
}
|
||||
|
||||
/* Let's bug out */
|
||||
sceKernelExitDeleteThread(0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
16
src/samples/debug/prxdecrypt/Makefile.sample
Normal file
16
src/samples/debug/prxdecrypt/Makefile.sample
Normal file
@@ -0,0 +1,16 @@
|
||||
TARGET = prxdecrypt
|
||||
OBJS = main.o
|
||||
|
||||
INCDIR =
|
||||
CFLAGS = -O2 -G0 -Wall
|
||||
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
ASFLAGS = $(CFLAGS)
|
||||
|
||||
LIBDIR =
|
||||
LDFLAGS =
|
||||
|
||||
EXTRA_TARGETS = EBOOT.PBP
|
||||
PSP_EBOOT_TITLE = PRX Decrypter
|
||||
|
||||
PSPSDK=$(shell psp-config --pspsdk-path)
|
||||
include $(PSPSDK)/lib/build.mak
|
||||
179
src/samples/debug/prxdecrypt/main.c
Normal file
179
src/samples/debug/prxdecrypt/main.c
Normal file
@@ -0,0 +1,179 @@
|
||||
/*
|
||||
* PSP Software Development Kit - http://www.pspdev.org
|
||||
* -----------------------------------------------------------------------
|
||||
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
|
||||
*
|
||||
* main.c - Basic sample to erm do something.
|
||||
*
|
||||
* Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
|
||||
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
|
||||
* Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
|
||||
*
|
||||
* $Id: main.c 1095 2005-09-27 21:02:16Z jim $
|
||||
*/
|
||||
#include <pspkernel.h>
|
||||
#include <pspdebug.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Define the module info section */
|
||||
PSP_MODULE_INFO("PRXDecryptor", 0x1000, 1, 0);
|
||||
|
||||
/* Define the main thread's attribute value (optional) */
|
||||
PSP_MAIN_THREAD_ATTR(0);
|
||||
|
||||
/* Define printf, just to make typing easier */
|
||||
#define printf pspDebugScreenPrintf
|
||||
|
||||
/* Exit callback */
|
||||
int exit_callback(int arg1, int arg2, void *common)
|
||||
{
|
||||
sceKernelExitGame();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Callback thread */
|
||||
int CallbackThread(SceSize args, void *argp)
|
||||
{
|
||||
int cbid;
|
||||
|
||||
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
|
||||
sceKernelRegisterExitCallback(cbid);
|
||||
|
||||
sceKernelSleepThreadCB();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Sets up the callback thread and returns its thread id */
|
||||
int SetupCallbacks(void)
|
||||
{
|
||||
int thid = 0;
|
||||
|
||||
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, THREAD_ATTR_USER, 0);
|
||||
if(thid >= 0)
|
||||
{
|
||||
sceKernelStartThread(thid, 0, 0);
|
||||
}
|
||||
|
||||
return thid;
|
||||
}
|
||||
|
||||
/* ptr is a pointer to the file to decrypt, check is undocumented, look at decrypt_file to see how to use */
|
||||
int sceKernelCheckExecFile(void *ptr, void *check);
|
||||
|
||||
char g_data[0x400000] __attribute__((aligned(64)));
|
||||
char g_decrypt_buf[0x400000] __attribute__((aligned(64)));
|
||||
|
||||
/* Decrypt a single PRX file */
|
||||
int extract_file(const char* name, const char* dstname)
|
||||
{
|
||||
int fd;
|
||||
int ret = 0;
|
||||
|
||||
fd = sceIoOpen(name, PSP_O_RDONLY, 0777);
|
||||
if(fd >= 0)
|
||||
{
|
||||
int bytes_read;
|
||||
bytes_read = sceIoRead(fd, g_data, 4*1024*1024);
|
||||
sceIoClose(fd);
|
||||
if(bytes_read > 0)
|
||||
{
|
||||
u8 check[0x100];
|
||||
u32 size;
|
||||
char *output;
|
||||
|
||||
memset(check, 0, sizeof(check));
|
||||
sceKernelCheckExecFile(g_data, check);
|
||||
/* Get size of data block */
|
||||
size = *(unsigned int *) (check+0x5C);
|
||||
|
||||
/* Check if we managed to decrypt the file */
|
||||
if(*(unsigned short *)(check+0x5a) & 1)
|
||||
{
|
||||
/* Set decrypt buffer pointer */
|
||||
*(unsigned int*)(check+0x24) = (unsigned int) g_decrypt_buf;
|
||||
sceKernelCheckExecFile(g_data, check);
|
||||
output = g_decrypt_buf;
|
||||
}
|
||||
else
|
||||
{
|
||||
output = g_data;
|
||||
}
|
||||
|
||||
if(size >= 0)
|
||||
{
|
||||
printf("Extracted file - size %d\n", size);
|
||||
fd = sceIoOpen(dstname, PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC, 0777);
|
||||
if(fd >= 0)
|
||||
{
|
||||
sceIoWrite(fd, output, size);
|
||||
sceIoClose(fd);
|
||||
ret = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Extract failed %s\n", name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Couldn't read file\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Couldn't open file\n");
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
SceIoDirent g_dir;
|
||||
char g_infile[256];
|
||||
char g_outfile[256];
|
||||
|
||||
void decrypt_files(const char *basedir, const char *destdir)
|
||||
{
|
||||
int fd;
|
||||
|
||||
printf("%s\n", basedir);
|
||||
fd = sceIoDopen(basedir);
|
||||
if(fd >= 0)
|
||||
{
|
||||
while(sceIoDread(fd, &g_dir) > 0)
|
||||
{
|
||||
if((g_dir.d_stat.st_attr & FIO_SO_IFDIR) == 0)
|
||||
{
|
||||
strcpy(g_infile, basedir);
|
||||
strcat(g_infile, g_dir.d_name);
|
||||
strcpy(g_outfile, destdir);
|
||||
strcat(g_outfile, g_dir.d_name);
|
||||
printf("Decrypting %s to %s\n", g_infile, g_outfile);
|
||||
extract_file(g_infile, g_outfile);
|
||||
}
|
||||
}
|
||||
|
||||
sceIoDclose(fd);
|
||||
}
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
pspDebugScreenInit();
|
||||
SetupCallbacks();
|
||||
|
||||
/* Decrypt kernel modules */
|
||||
sceIoMkdir("ms0:/kd", 0777);
|
||||
decrypt_files("flash0:/kd/", "ms0:/kd/");
|
||||
/* Decrypt VShell modules */
|
||||
sceIoMkdir("ms0:/vsh", 0777);
|
||||
decrypt_files("flash0:/vsh/module/", "ms0:/vsh/");
|
||||
|
||||
printf("Done\n");
|
||||
sceKernelExitDeleteThread(0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
21
src/samples/debug/sio/Makefile.sample
Normal file
21
src/samples/debug/sio/Makefile.sample
Normal file
@@ -0,0 +1,21 @@
|
||||
TARGET = sio
|
||||
OBJS = main.o
|
||||
|
||||
USE_PSPSDK_LIBC = 1
|
||||
|
||||
INCDIR =
|
||||
CFLAGS = -O2 -G0 -Wall
|
||||
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
ASFLAGS = $(CFLAGS)
|
||||
|
||||
LIBDIR =
|
||||
LDFLAGS =
|
||||
|
||||
|
||||
EXTRA_TARGETS = EBOOT.PBP
|
||||
PSP_EBOOT_TITLE = SIO Test
|
||||
|
||||
PSPSDK=$(shell psp-config --pspsdk-path)
|
||||
include $(PSPSDK)/lib/build.mak
|
||||
|
||||
LIBS += -lpsphprm_driver
|
||||
76
src/samples/debug/sio/main.c
Normal file
76
src/samples/debug/sio/main.c
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* PSP Software Development Kit - http://www.pspdev.org
|
||||
* -----------------------------------------------------------------------
|
||||
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
|
||||
*
|
||||
* main.c - Basic sample to demonstrate the remote port sio.
|
||||
*
|
||||
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
|
||||
*
|
||||
* $Id: main.c 1095 2005-09-27 21:02:16Z jim $
|
||||
*/
|
||||
#include <pspkernel.h>
|
||||
#include <pspdebug.h>
|
||||
#include <pspdisplay.h>
|
||||
#include <pspsdk.h>
|
||||
#include <pspctrl.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
PSP_MODULE_INFO("REMOTE", 0x1000, 1, 1);
|
||||
/* Define the main thread's attribute value (optional) */
|
||||
PSP_MAIN_THREAD_ATTR(0);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
pspDebugScreenInit();
|
||||
|
||||
sceCtrlSetSamplingCycle(0);
|
||||
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
|
||||
|
||||
/* Initialise SIO and install a kprintf handler */
|
||||
pspDebugSioInit();
|
||||
pspDebugSioInstallKprintf();
|
||||
|
||||
/* Install a stdout handler */
|
||||
pspDebugInstallStdoutHandler(pspDebugSioPutData);
|
||||
|
||||
Kprintf("Hi from %s!\n", "Kprintf");
|
||||
printf("Also hi from stdio\r\n");
|
||||
|
||||
pspDebugScreenPrintf("Press X to exit, tap away on your terminal to echo\n");
|
||||
sceDisplayWaitVblankStart();
|
||||
|
||||
while(1)
|
||||
{
|
||||
SceCtrlData pad;
|
||||
int ch;
|
||||
|
||||
sceCtrlReadBufferPositive(&pad, 1);
|
||||
if(pad.Buttons & PSP_CTRL_CROSS)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
ch = pspDebugSioGetchar();
|
||||
if(ch >= 0)
|
||||
{
|
||||
pspDebugScreenPrintf("Received %d\n", ch);
|
||||
if(ch == '\r')
|
||||
{
|
||||
pspDebugSioPutchar('\r');
|
||||
pspDebugSioPutchar('\n');
|
||||
}
|
||||
else
|
||||
{
|
||||
pspDebugSioPutchar(ch);
|
||||
}
|
||||
}
|
||||
|
||||
sceDisplayWaitVblankStart();
|
||||
}
|
||||
|
||||
sceKernelExitGame();
|
||||
|
||||
return 0;
|
||||
}
|
||||
7
src/samples/debug/sio/readme.txt
Normal file
7
src/samples/debug/sio/readme.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
This is a simple demo of the SIO code.
|
||||
|
||||
The serial interface used is the remote control port, see http://nil.rpc1.org/psp/remote.html
|
||||
for how to build the interface. You should setup your local terminal software to 4800 baud
|
||||
8N1 to communicate.
|
||||
|
||||
Note this comes with no warranty, if it blows up your psp it is not my resposibility.
|
||||
Reference in New Issue
Block a user