first commit

This commit is contained in:
Dan Peori
2010-10-18 12:54:49 -03:00
commit 8a3bef9012
612 changed files with 74685 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
TARGET = prxloader
OBJS = main.o MyLib.o
USE_PSPSDK_LIBC = 1
INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LDFLAGS =
LIBS =
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Sample PRX Loader
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak

View File

@@ -0,0 +1,7 @@
.set noreorder
#include "pspstub.s"
STUB_START "MyLib",0x00090000,0x00010005
STUB_FUNC 0x563FF2B2,getModuleInfo
STUB_END

View File

@@ -0,0 +1,131 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* main.c - Basic harness for loading prxes (for proving a point)
*
* 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 <pspsdk.h>
#include <string.h>
PSP_MODULE_INFO("PRXLOADER", 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 *arg)
{
sceKernelExitGame();
return 0;
}
/* Callback thread */
void CallbackThread(void *arg)
{
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
}
/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void)
{
int thid = 0;
thid = sceKernelCreateThread("update_thread", (void*) CallbackThread, 0x11, 0xFA0, 0xa0000000, 0);
if(thid >= 0)
{
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
SceUID load_module(const char *path, int flags, int type)
{
SceKernelLMOption option;
SceUID mpid;
/* If the type is 0, then load the module in the kernel partition, otherwise load it
in the user partition. */
if (type == 0) {
mpid = 1;
} else {
mpid = 2;
}
memset(&option, 0, sizeof(option));
option.size = sizeof(option);
option.mpidtext = mpid;
option.mpiddata = mpid;
option.position = 0;
option.access = 1;
return sceKernelLoadModule(path, flags, type > 0 ? &option : NULL);
}
/* Imported function */
void *getModuleInfo(void);
int main(void)
{
SceUID modid;
SceModule *mod;
int i;
int ret;
int fd;
pspDebugScreenInit();
/* Install all our funky err thingamybobs */
pspDebugInstallKprintfHandler(NULL);
pspDebugInstallErrorHandler(NULL);
pspDebugInstallStdoutHandler(pspDebugScreenPrintData);
pspSdkInstallNoPlainModuleCheckPatch();
SetupCallbacks();
/* Start mymodule.prx and dump its information */
printf("\nStart my module\n");
modid = load_module("ms0:/mymodule.prx", 0, 0);
printf("Module ID %08X\n", modid);
mod = sceKernelFindModuleByUID(modid);
printf("mod %p\n", mod);
if(mod != NULL)
{
printf("Attr %04X, Version %x.%x\n", mod->attribute, mod->version[0], mod->version[1]);
printf("Name %s\n", mod->modname);
printf("Text %08X, Size %08X, Data Size %08X\n", mod->text_addr, mod->text_size, mod->data_size);
printf("Entry Addr %08X\n", mod->entry_addr);
printf("Stub %p %08X, Ent %p %08X\n", mod->stub_top, mod->stub_size, mod->ent_top, mod->ent_size);
for(i = 0; i < mod->nsegment; i++)
{
printf("Segment[%d] %08X %08X\n", i, mod->segmentaddr[i], mod->segmentsize[i]);
}
ret = sceKernelStartModule(modid, 0, NULL, &fd, NULL);
/* Let's test the module's exports */
printf("Module Info %p\n", getModuleInfo());
}
/* Let's bug out */
sceKernelExitDeleteThread(0);
return 0;
}

View File

@@ -0,0 +1,19 @@
TARGET = mymodule
OBJS = main.o
# Define to build this as a prx (instead of a static elf)
BUILD_PRX=1
# Define the name of our custom exports (minus the .exp extension)
PRX_EXPORTS=exports.exp
USE_PSPSDK_LIBC = 1
INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak

View File

@@ -0,0 +1,16 @@
# Define the exports for the prx
PSP_BEGIN_EXPORTS
# These four lines are mandatory (although you can add other functions like module_stop)
# syslib is a psynonym for the single mandatory export.
PSP_EXPORT_START(syslib, 0, 0x8000)
PSP_EXPORT_FUNC_HASH(module_start)
PSP_EXPORT_VAR_HASH(module_info)
PSP_EXPORT_END
# Export our function
PSP_EXPORT_START(MyLib, 0, 0x0001)
PSP_EXPORT_FUNC_HASH(getModuleInfo)
PSP_EXPORT_END
PSP_END_EXPORTS

View File

@@ -0,0 +1,39 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* main.c - Simple PRX example.
*
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
*
* $Id: main.c 1531 2005-12-07 18:27:12Z tyranid $
*/
#include <pspkernel.h>
#include <stdio.h>
PSP_MODULE_INFO("TESTPRX", 0x1000, 1, 1);
#define WELCOME_MESSAGE "Hello from the PRX\n"
int main(int argc, char **argv)
{
int i;
printf(WELCOME_MESSAGE);
for(i = 0; i < argc; i++)
{
printf("Arg %d: %s\n", i, argv[i]);
}
sceKernelSleepThread();
return 0;
}
/* Exported function returns the address of module_info */
void* getModuleInfo(void)
{
return (void *) &module_info;
}