Added complete IoFileMgr*, fixed Stdio*

Added static libraries for function/variable imports linking
Fixed import linking file so it doesn't crash when there are variables
Made the 3rd argument of basic-decompiler facultative
Fixed psp-build-exports (it didn't want to use variable of 'void' type)
Cleanups/fixes/added exports file/headers/Makefile in audio, me_wrapper, avcodec, libatrac3plus, codec, sysmem, interruptman, exceptionman
Don't use kprxgen anymore: it can't work and is useless anyway
Use the PSPSDK header files for the prototypes/structures which are defined in them and not in an already RE'ed module
This commit is contained in:
artart78 2012-04-17 19:03:41 +00:00
parent b1a79b929e
commit 198caa981d
62 changed files with 4051 additions and 528 deletions

View File

@ -13,7 +13,7 @@ __stub_modulestr_\module:
__stub_module_\module:
.word __stub_modulestr_\module
.word \flags_ver
.word 0x5
.word 0x6
.word __executable_start
.word __executable_start
.word __executable_start

View File

@ -3,8 +3,9 @@
include ../../lib/common.mak
CFLAGS := -I../../include -O1 -fno-toplevel-reorder -G0 -Wall -Wextra -Werror -nostdlib
LDFLAGS := -specs=../../lib/prxspecs -Wl,-q,-T../../lib/linkfile.prx
PSPSDK = `psp-config --pspsdk-path`
CFLAGS := -I../../include -O1 -fno-toplevel-reorder -G0 -Wall -Wextra -Werror -fno-builtin -nostdlib -I$(PSPSDK)/include
LDFLAGS := -L../../lib -specs=../../lib/prxspecs -Wl,-q,-T../../lib/linkfile.prx
# Setup default exports if needed
ifdef PRX_EXPORTS
@ -25,7 +26,8 @@ $(TARGET).elf: $(OBJS) $(EXPORT_OBJ)
$(CC) -c $^ -o $@ $(CFLAGS)
%.prx: %.elf
../../utils/kprxgen/psp-kprxgen $< $@
#../../utils/kprxgen/psp-kprxgen $< $@
psp-prxgen $< $@
$(PRX_EXPORTS:.exp=.c): $(PRX_EXPORTS)
../../utils/build-exports/psp-build-exports -b $< > $@

BIN
lib/libDmacManForKernel.a Normal file

Binary file not shown.

BIN
lib/libInterruptManager.a Normal file

Binary file not shown.

Binary file not shown.

BIN
lib/libKDebugForKernel.a Normal file

Binary file not shown.

BIN
lib/libSysMemForKernel.a Normal file

Binary file not shown.

BIN
lib/libSysMemUserForUser.a Normal file

Binary file not shown.

BIN
lib/libSysclibForKernel.a Normal file

Binary file not shown.

BIN
lib/libThreadManForKernel.a Normal file

Binary file not shown.

BIN
lib/libThreadManForUser.a Normal file

Binary file not shown.

BIN
lib/libUtilsForKernel.a Normal file

Binary file not shown.

BIN
lib/libUtilsForUser.a Normal file

Binary file not shown.

BIN
lib/libsceClockgen_driver.a Normal file

Binary file not shown.

BIN
lib/libsceCodec_driver.a Normal file

Binary file not shown.

BIN
lib/libsceDdr_driver.a Normal file

Binary file not shown.

BIN
lib/libsceDmac.a Normal file

Binary file not shown.

BIN
lib/libsceDmacplus_driver.a Normal file

Binary file not shown.

BIN
lib/libsceGpio_driver.a Normal file

Binary file not shown.

BIN
lib/libsceI2c_driver.a Normal file

Binary file not shown.

BIN
lib/libsceLcdc_driver.a Normal file

Binary file not shown.

BIN
lib/libsceNand_driver.a Normal file

Binary file not shown.

BIN
lib/libscePwm_driver.a Normal file

Binary file not shown.

Binary file not shown.

BIN
lib/libsceSuspendForUser.a Normal file

Binary file not shown.

Binary file not shown.

BIN
lib/libsceSysreg_driver.a Normal file

Binary file not shown.

12
src/audio/Makefile Normal file
View File

@ -0,0 +1,12 @@
# Copyright (C) 2011, 2012 The uOFW team
# See the file COPYING for copying permission.
TARGET = audio
OBJS = audio.o
LIBS=-lsceCodec_driver -lInterruptManager -lInterruptManagerForKernel -lSysclibForKernel -lThreadManForUser -lsceSysEventForKernel -lSysMemForKernel -lDmacManForKernel -lsceDdr_driver -lsceSysreg_driver -lsceClockgen_driver -lUtilsForKernel
PRX_EXPORTS=exports.exp
include ../../lib/build.mak

View File

@ -3,12 +3,21 @@
*/
#include "../global.h"
#include "../sysmem/sysmem.h"
#include "../codec/codec.h"
#include "audio.h"
asm(".set noat"); // needed for AUDIO_SET_BUSY()
/* Sets the audio controller busy state. */
#define AUDIO_SET_BUSY(busy) asm("lui $at, 0xBE00; sw %0, 0($at)" : : "r" (busy))
PSP_SDK_VERSION(0x06060010);
PSP_MODULE_BOOTSTART("sceAudioInit");
PSP_MODULE_REBOOT_BEFORE("sceAudioEnd");
PSP_MODULE_STOP("sceAudioEnd");
PSP_MODULE_INFO("sceAudio_Driver", 0x1007, 1, 13);
/* The audio channel structure. */
typedef struct
{
@ -69,11 +78,16 @@ typedef struct
// end: 1400
} SceAudio;
void audioHwInit();
int audioOutputDmaCb(int unused, int arg1);
int audioOutput(SceAudioChannel *channel, short leftVol, short rightVol, void *buf);
int audioIntrHandler();
int audioEventHandler(int ev_id, char* ev_name, void* param, int* result);
int audioSRCOutput(int vol, void *buf);
int audioSRCOutputDmaCb(int arg0, int arg1);
int audioInputSetup();
int audioInputInit(int arg0, int gain, int arg2, int arg3, int arg4, int arg5);
int audioInput(int sampleCount, int freq, void *buf);
int audioInputThread();
int audioInputDmaCb(int arg0, int arg1);
@ -268,7 +282,7 @@ int audioMixerThread()
* unused: ?
* arg1: ?
*/
int audioOutputDmaCb(int unused, int arg1)
int audioOutputDmaCb(int __attribute__((unused)) unused, int arg1)
{
sceKernelSetEventFlag(g_audio.evFlagId, 0x20000000);
if (arg1 != 0) {
@ -530,7 +544,7 @@ int sceAudioOneshotOutput(int chanId, int sampleCount, int fmt, int leftVol, int
// 0D28
chan->leftVol = leftVol;
chan->rightVol = rightVol;
chan->bytesPerSample;
chan->bytesPerSample = bytesPerSample;
chan->curSampleCnt = sampleCount;
chan->buf = buf;
if (((g_audio.flags & 1) == 0) && (buf != NULL))
@ -808,9 +822,11 @@ int sceAudioInit()
memset(&g_audio, 0, sizeof(g_audio));
// 1558
int i;
for (i = 0; i < 480 * 272 * 2; i++)
((int*)0x44000000)[i] = 0x00FF0000;
for (i = 0; i < 3; i++)
g_audio.dmaPtr[i] = sceKernelDmaOpAlloc();
g_audio.evFlagId = sceKernelCreateEventFlag(0x34E4, 513, 0, 0);
g_audio.evFlagId = sceKernelCreateEventFlag("SceAudio", 513, 0, 0);
g_audio.freq = 44100;
g_audio.volumeOffset = 8;
i = 0;
@ -818,7 +834,7 @@ int sceAudioInit()
do
{
int shift = ((i + (i >> 31)) >> 1) << 8;
int *buf = &g_audio.hwBuf[i * 4];
u32 *buf = &g_audio.hwBuf[i * 4];
buf[0] = (int)UCACHED(g_audio.buf0 + shift);
buf[1] = (int)UCACHED(0xBE000060);
buf[2] = (int)UCACHED(g_audio.hwBuf[i * 4 + 4]);
@ -854,11 +870,11 @@ int sceAudioInit()
SceUID id2 = sceKernelCreateThread("SceAudioInput", audioInputThread, 6, 0x400, 0x100000, 0);
if (id2 < 0 || sceKernelStartThread(id2, 0, 0) != 0)
return 1;
sceKernelRegisterSysEventHandler(g_audioEvent);
sceKernelRegisterSysEventHandler(&g_audioEvent);
sceKernelRegisterIntrHandler(10, 2, audioIntrHandler, 0, 0);
sceKernelEnableIntr(10);
sceKernelDcacheWritebackInvalidateRange(g_audio, 1400);
*(int*)(g_audio.dmaPtr[0] + 8) = UCACHED(&g_audio);
sceKernelDcacheWritebackInvalidateRange(&g_audio, 1400);
*(int*)(g_audio.dmaPtr[0] + 8) = (int)UCACHED(&g_audio);
g_audio.unkCodecArg = 1;
g_audio.unkCodecArgSet = 0;
g_audio.inputInited = 0;
@ -895,10 +911,10 @@ int sceAudioEnd()
{
sceCodecOutputEnable(0, 0);
sceCodec_driver_277DFFB6();
sceKernelUnregisterSysEventHandler(g_audioEvent);
sceKernelUnregisterSysEventHandler(&g_audioEvent);
int oldIntr = sceKernelCpuSuspendIntr();
sceKernelDeleteEventFlag(g_audio.evFlagId);
sceKernelReleaseIntrHandler();
sceKernelReleaseIntrHandler(10);
// 18CC
int i;
for (i = 0; i < 3; i++) {
@ -909,7 +925,7 @@ int sceAudioEnd()
return 0;
}
int sceAudio_driver_306D18F1(int arg)
int sceAudio_driver_FF298CE7(int arg)
{
g_audio.delayShift = (arg != 0) ? 2 : 0;
return 0;
@ -1045,7 +1061,7 @@ void audioHwInit()
*
* Returns 0.
*/
int audioEventHandler(int ev_id, char* ev_name, void* param, int* result)
int audioEventHandler(int ev_id, char* ev_name __attribute__((unused)), void* param __attribute__((unused)), int* result __attribute__((unused)))
{
switch (ev_id)
{
@ -1373,12 +1389,12 @@ int audioInputThread()
sceKernelExitThread(0);
return 0;
}
int *ptr1 = g_audio.dmaPtr[2];
u32 *ptr1 = g_audio.dmaPtr[2];
int curSampleCount = g_audio.inputCurSampleCnt;
int unk = (ptr1[9] < g_audio.buf752[0x80000000 + 16]); // yes, it's correct, it reverses the kernel mode
short *uncached1 = KUNCACHED(&g_audio.buf512[unk << 8]);
char unk2 = g_audio.inputHwFreq;
short *ptr3 = g_audio.inputBuf;
u16 *ptr3 = g_audio.inputBuf;
if (curSampleCount == 0)
{
// 2648
@ -1434,10 +1450,10 @@ int audioInputThread()
{
// 257C
int shift = unk * 8;
int *uncached2 = KUNCACHED(&g_audio.hwBuf[34 + shift]);
int *uncached3 = KUNCACHED(&g_audio.hwBuf[38 + shift]);
int *uncached2 = (int*)KUNCACHED(&g_audio.hwBuf[34 + shift]);
int *uncached3 = (int*)KUNCACHED(&g_audio.hwBuf[38 + shift]);
*uncached3 = 0;
*uncached2 = UCACHED(&g_audio.hwBuf[36 + shift]);
*uncached2 = (int)UCACHED(&g_audio.hwBuf[36 + shift]);
if (DmacManForKernel_E18A93A5(ptr1, UCACHED(&g_audio.hwBuf[32 + shift])) < 0)
{
*(int*)(0xBE000004) = (int)(char)(g_audio.flags & 0xFB);
@ -1509,9 +1525,9 @@ int sceAudioInputBlocking(int sampleCount, int freq, void *buf)
return audioInput(sampleCount, freq, buf);
}
int sceAudioInput(int unk1, int gain, int unk2)
int sceAudioInput(int sampleCount, int freq, void *buf)
{
return audioInput(unk1, gain, unk2);
return audioInput(sampleCount, freq, buf);
}
int sceAudioGetInputLength()
@ -1560,7 +1576,7 @@ int audioInputSetup()
// 29C8
int i;
for (i = 0; i < 3; i++)
ptr[i * 4 + 2] = UCACHED(&g_audio.hwBuf[36 + i * 4]);
ptr[i * 4 + 2] = (int)UCACHED(&g_audio.hwBuf[36 + i * 4]);
ptr[14] = 0;
ret = sceKernelDmaOpSetupLink(g_audio.dmaPtr[2], 0xD00F, &g_audio.hwBuf[32]);
if (ret != 0)

View File

@ -233,7 +233,7 @@ int sceAudioEnd();
*
* @return 0.
*/
int sceAudio_driver_306D18F1(int arg);
int sceAudio_driver_FF298CE7(int arg);
/**
* Sets the volume offset/shifting.
@ -313,13 +313,13 @@ int sceAudioInputBlocking(int sampleCount, int freq, void *buf);
/**
* Store input.
*
* @param unk1 \todo ?
* @param gain The input gain.
* @param unk2 \todo ?
* @param sampleCount The number of samples to read.
* @param freq The input frequency.
* @param buf The audio PCM input buffer.
*
* @return The number of played samples on success, otherwise less than zero.
*/
int sceAudioInput(int unk1, int gain, int unk2);
int sceAudioInput(int sampleCount, int freq, void *buf);
/**
* Get the number of samples read from input.

View File

@ -1,3 +1,6 @@
// valid for 0x08......, 0x48......, 0x88...... and 0xA8...... addresses
#define IS_MAIN_MEMORY(addr) (((0x00220202 >> (((int)addr >> 27) & 0x1F)) & 1) != 0)
// retValues
int g_retValues[] = { 0x807F00FC, 0x807F00FD, 0x80000002, 0x807F00FF, 0x807F0001 };
@ -16,19 +19,19 @@ short g_freqs[][4] = {
{ 11025, 12000, 8000, 0 }
};
int sceAudiocodecCheckNeedMem(u32 *codec_buffer, u32 codec)
int sceAudiocodecCheckNeedMem(SceAudiocodecCodec *info, int codec)
{
if (((0x00220202 >> (((int)codec_buffer >> 27) & 0x1F)) & 1) == 0)
if (!IS_MAIN_MEMORY(info))
return 0x807F0002;
if (codec < 0x1000 || codec >= 0x1006)
return 0x80000004;
// 0148
K1_BACKUP();
int ret = 0x80000023;
if (K1_USER_BUF_STA_SZ(codec_buffer, 104))
if (K1_USER_BUF_STA_SZ(info, 104))
{
*codec_buffer = 0x05100601;
int id = sceMeAudio_driver_81956A0B(codec, codec_buffer);
info->unk0 = 0x05100601;
int id = sceMeAudio_driver_81956A0B(codec, info);
ret = 0;
if (id != 0)
{
@ -42,15 +45,15 @@ int sceAudiocodecCheckNeedMem(u32 *codec_buffer, u32 codec)
return ret;
}
int sceAudiocodecInit(void *codec_buf, int codec)
int sceAudiocodecInit(SceAudiocodecCodec *info, int codec)
{
if (((0x00220202 >> (((int)codec_buf >> 27) & 0x1F)) & 1) == 0)
if (!IS_MAIN_MEMORY(info))
return 0x807F0002;
if (codec < 0x1000 || codec >= 0x1006)
return 0x80000004;
// 0214
K1_BACKUP();
if (!K1_USER_BUF_STA_SZ(codec_buf, 104) || !K1_USER_BUF_DYN_SZ(*(int*)(codec_buf + 12), *(int*)(codec_buf + 16))) {
if (!K1_USER_BUF_STA_SZ(info, 104) || !K1_USER_BUF_DYN_SZ(info->edramAddr, info->neededMem)) {
K1_RESET();
return 0x80000023;
}
@ -58,16 +61,16 @@ int sceAudiocodecInit(void *codec_buf, int codec)
if (codec == 0x1002)
{
// 02CC
*(int*)(codec_buf + 56) = 9999;
info->unk56 = 9999;
}
// 0264
if (((0x00220202 >> ((*(int*)(codec_buf + 12) >> 27) & 0x1F)) & 1) != 0) {
if (IS_MAIN_MEMORY(info->edramAddr))
// 02BC
sceKernelDcacheWritebackInvalidateRange(*(int*)(codec_buf + 12), *(int*)(codec_buf + 16));
sceKernelDcacheWritebackInvalidateRange(info->edramAddr, info->neededMem);
}
// 027C
*(int*)(codec_buf + 0) = 0x05100601;
int id = sceMeAudio_driver_6AD33F60(codec, codec_buf);
info->unk0 = 0x05100601;
int id = sceMeAudio_driver_6AD33F60(codec, info);
int ret = 0;
if (id != 0)
{
@ -79,15 +82,15 @@ int sceAudiocodecInit(void *codec_buf, int codec)
return ret;
}
int sceAudiocodec_3DD7EE1A(void *codec_buf, int codec)
int sceAudiocodec_3DD7EE1A(SceAudiocodecCodec *info, int codec)
{
if (((0x00220202 >> (((int)codec_buf >> 27) & 0x1F)) & 1) == 0)
if (!IS_MAIN_MEMORY(info))
return 0x807F0002;
if (codec < 0x1000 || codec >= 0x1006)
return 0x80000004;
// 0344
K1_BACKUP();
if (!K1_USER_BUF_STA_SZ(codec_buf, 104) || !K1_USER_BUF_DYN_SZ(*(int*)(codec_buf + 12), *(int*)(codec_buf + 16))) {
if (!K1_USER_BUF_STA_SZ(info, 104) || !K1_USER_BUF_DYN_SZ(info->edramAddr, info->neededMem)) {
K1_RESET();
return 0x80000023;
}
@ -95,16 +98,16 @@ int sceAudiocodec_3DD7EE1A(void *codec_buf, int codec)
if (codec == 0x1002)
{
// 03FC
*(int*)(codec_buf + 56) = 9999;
info->unk56 = 9999;
}
// 0394
if (((0x00220202 >> ((*(int*)(codec_buf + 12) >> 27) & 0x1F)) & 1) != 0) {
if (IS_MAIN_MEMORY(info->edramAddr))
// 03EC
sceKernelDcacheWritebackInvalidateRange(*(int*)(codec_buf + 12), *(int*)(codec_buf + 16));
sceKernelDcacheWritebackInvalidateRange(info->edramAddr, info->neededMem);
}
// 03AC
*(int*)(codec_buf + 0) = 0x05100601;
int id = sceMeAudio_driver_B57F033A(codec, codec_buf);
info->unk0 = 0x05100601;
int id = sceMeAudio_driver_B57F033A(codec, info);
int ret = 0;
if (id != 0)
{
@ -116,18 +119,18 @@ int sceAudiocodec_3DD7EE1A(void *codec_buf, int codec)
return ret;
}
int sceAudiocodecDecode(void *codec_buf, int codec)
int sceAudiocodecDecode(SceAudiocodecCodec *info, int codec)
{
if (((0x00220202 >> (((int)codec_buf >> 27) & 0x1F)) & 1) == 0)
if (!IS_MAIN_MEMORY(info))
return 0x807F0002;
if (codec < 0x1000 || codec >= 0x1006)
return 0x80000004;
// 0474
K1_BACKUP();
if (!K1_USER_BUF_STA_SZ(codec_buf, 104)
|| !K1_USER_BUF_DYN_SZ(*(int*)(codec_buf + 12), *(int*)(codec_buf + 16))
|| !K1_USER_BUF_STA_SZ(*(int*)(codec_buf + 24), 0x10000)
|| !K1_USER_BUF_STA_SZ(*(int*)(codec_buf + 32), 0x10000)) {
if (!K1_USER_BUF_STA_SZ(info, 104)
|| !K1_USER_BUF_DYN_SZ(info->edramAddr, info->neededMem)
|| !K1_USER_BUF_STA_SZ(info->inBuf, 0x10000)
|| !K1_USER_BUF_STA_SZ(info->outBuf, 0x10000)) {
// (04E0)
// 04E4
K1_RESET();
@ -138,25 +141,25 @@ int sceAudiocodecDecode(void *codec_buf, int codec)
if (codec == 0x1002 || codec == 0x1004)
{
// 0570
size = *(int*)(codec_buf + 40);
size = *(int*)&info->unk40;
}
else
{
size = getBufSize(codec_buf, codec);
size = getBufSize(info, codec);
if (size < 0) {
K1_RESET();
return size;
}
}
// 0510
sceKernelDcacheWritebackRange(*(int*)(codec_buf + 24), size);
size = sub_0A40(codec_buf, codec);
sceKernelDcacheWritebackRange(info->inBuf, size);
size = sub_0A40(info, codec);
if (size < 0) {
K1_RESET();
return size;
}
sceKernelDcacheWritebackInvalidateRange(*(int*)(codec_buf + 32), size);
int id = sceMeAudio_driver_9A9E21EE(codec, codec_buf);
sceKernelDcacheWritebackInvalidateRange(info->outBuf, size);
int id = sceMeAudio_driver_9A9E21EE(codec, info);
int ret = 0;
if (id != 0)
{
@ -168,22 +171,22 @@ int sceAudiocodecDecode(void *codec_buf, int codec)
return ret;
}
int sceAudiocodecGetInfo(void *codec_buf, int codec)
int sceAudiocodecGetInfo(SceAudiocodecCodec *info, int codec)
{
if (((0x00220202 >> (((int)codec_buf >> 27) & 0x1F)) & 1) == 0)
if (!IS_MAIN_MEMORY(info))
return 0x807F0002;
if (codec < 0x1000 || codec >= 0x1006)
return 0x80000004;
// 05D4
K1_BACKUP();
if (!K1_USER_BUF_STA_SZ(codec_buf, 104) || !K1_USER_BUF_DYN_SZ(*(int*)(codec_buf + 12), *(int*)(codec_buf + 16)))
if (!K1_USER_BUF_STA_SZ(info, 104) || !K1_USER_BUF_DYN_SZ(info->edramAddr, info->neededMem))
{
// 060C
K1_RESET();
return 0x80000023;
}
// 0620
if ((codec == 0x1002 || codec == 0x1004) && !K1_USER_BUF_DYN_SZ(*(int*)(codec_buf + 24), *(int*)(codec_buf + 40))) {
if ((codec == 0x1002 || codec == 0x1004) && !K1_USER_BUF_DYN_SZ(info->inBuf, (int*)&info->unk40)) {
K1_RESET();
return 0x80000023;
}
@ -206,8 +209,8 @@ int sceAudiocodecGetInfo(void *codec_buf, int codec)
return 0;
}
// 0684
*(int*)(codec_buf + 0) = 0x05100601;
int id = sceMeAudio_driver_C300D466(codec, opt, codec_buf);
info->unk0 = 0x05100601;
int id = sceMeAudio_driver_C300D466(codec, opt, info);
int ret = 0;
if (id != 0)
{
@ -221,22 +224,22 @@ int sceAudiocodecGetInfo(void *codec_buf, int codec)
return ret;
}
int sceAudiocodecAlcExtendParameter(void *codec_buf, int codec, int *sizeOut)
int sceAudiocodecAlcExtendParameter(SceAudiocodecCodec *info, int codec, int *sizeOut)
{
if (((0x00220202 >> (((int)codec_buf >> 27) & 0x1F)) & 1) == 0)
if (!IS_MAIN_MEMORY(info))
return 0x807F0002;
if (codec < 0x1000 || codec >= 0x1006)
return 0x80000004;
// 0744
K1_BACKUP();
if (!K1_USER_BUF_STA_SZ(codec_buf, 104) || !K1_USER_BUF_STA_SZ(sizeOut, 4))
if (!K1_USER_BUF_STA_SZ(info, 104) || !K1_USER_BUF_STA_SZ(sizeOut, 4))
{
// 0770
K1_RESET();
return 0x80000023;
}
// 0780
int size = sub_0A40(codec_buf, codec);
int size = sub_0A40(info, codec);
if (size < 0) {
K1_RESET();
return size;
@ -246,57 +249,57 @@ int sceAudiocodecAlcExtendParameter(void *codec_buf, int codec, int *sizeOut)
return 0;
}
int sceAudiocodecGetEDRAM(void *codec_buf, int codec)
int sceAudiocodecGetEDRAM(SceAudiocodecCodec *info, int codec)
{
if (((0x00220202 >> (((int)codec_buf >> 27) & 0x1F)) & 1) == 0)
if (!IS_MAIN_MEMORY(info))
return 0x807F0002;
if (codec < 0x1000 || codec >= 0x1006)
return 0x80000004;
// 0808
K1_BACKUP();
int ret = 0;
if (!K1_USER_BUF_STA_SZ(codec_buf, 108)) {
if (!K1_USER_BUF_STA_SZ(info, 108)) {
K1_RESET();
return 0x80000023;
}
// 0838
int cnt = sceMeMalloc((*(int*)(codec_buf + 16) + 0x3F) | 0x3F)
*(int*)(codec_buf + 104) = cnt;
if (cnt == 0 || (cnt & 0x1FFFFFFF) > 0x003FFFFF)
void *alloc = sceMeMalloc((info->neededMem + 0x3F) | 0x3F)
info->allocMem = alloc;
if (alloc == NULL || ((int)alloc & 0x1FFFFFFF) > 0x003FFFFF)
{
// (087C)
// 0880
ret = 0x807F0003;
sceMeFree(*(int*)(codec_buf + 104));
*(int*)(codec_buf + 104) = 0;
*(int*)(codec_buf + 12) = 0;
sceMeFree(info->allocMem);
info->allocMem = NULL;
info->edramAddr = 0;
}
else
*(int*)(codec_buf + 12) = (cnt + 0x3F) & 0xFFFFFFC0;
info->edramAddr = ((int)alloc + 0x3F) & 0xFFFFFFC0;
K1_RESET();
return ret;
}
int sceAudiocodecReleaseEDRAM(void *codec_buf)
int sceAudiocodecReleaseEDRAM(SceAudiocodecInfo *info)
{
K1_BACKUP();
if (!K1_USER_BUF_STA_SZ(codec_buf, 108) || !K1_USER_BUF_DYN_SZ(*(int*)(codec_buf + 12), *(int*)(codec_buf + 16))) {
if (!K1_USER_BUF_STA_SZ(info, 108) || !K1_USER_BUF_DYN_SZ(info->edramAddr, info->neededMem)) {
K1_RESET();
return 0x80000023;
}
if (*(int*)(codec_buf + 104) == 0 || *(int*)(codec_buf + 104) & 0x1FFFFFFF > 0x3FFFFF) {
if (info->allocMem == NULL || ((int)info->allocMem & 0x1FFFFFFF) > 0x3FFFFF) {
K1_RESET();
return 0x807F0004;
}
// 0938
sceMeFree(*(int*)(codec_buf + 104));
*(int*)(codec_buf + 104) = 0;
*(int*)(codec_buf + 12) = 0;
sceMeFree(info->allocMem);
info->allocMem = NULL;
info->edramAddr = 0;
K1_RESET();
return 0;
}
int getBufSize(void *codec_buf, int codec)
int getBufSize(SceAudiocodecCodec *info, int codec)
{
if (codec < 0x1000 || codec >= 0x1006)
return 0x80000004;
@ -305,37 +308,37 @@ int getBufSize(void *codec_buf, int codec)
{
case 0x1000:
// 0990
if (*(int*)(codec_buf + 48) == 0)
return *(int*)(codec_buf + 64) + 2;
if (info->unk48 == 0)
return info->unk64 + 2;
return 0x100A;
case 0x1001:
// 09B8
return *(int*)(codec_buf + 48) * 2 + 1;
return info->unk48 * 2 + 1;
case 0x1002:
// 09C8
if (*(int*)(codec_buf + 56) == 9999)
if (info->unk56 == 9999)
{
// 09F8
int ret = sceAudiocodecGetInfo(codec_buf, 0x1002);
int ret = sceAudiocodecGetInfo(info, 0x1002);
if (ret < 0)
return ret;
}
// 09D8
// 09E8 dup
return sub_0B18(*(int*)(codec_buf + 56), *(int*)(codec_buf + 60), *(int*)(codec_buf + 68), *(int*)(codec_buf + 72), codec_buf + 40);
return sub_0B18(info->unk56, info->unk60, info->unk68, info->unk72, &info->unk40);
case 0x1003:
// 0A10
if (*(u8*)(codec_buf + 44) == 0)
if (info->unk44 == 0)
return 0x600;
return 0x609;
case 0x1004:
// 0A24
// 09E8 dup
return sub_0B18(*(int*)(codec_buf + 48), *(int*)(codec_buf + 52), *(int*)(codec_buf + 60), *(int*)(codec_buf + 64), codec_buf + 40);
return sub_0B18(info->unk48, info->unk52, info->unk60, info->unk64, &info->unk40);
case 0x1005:
// 0A38
@ -343,7 +346,7 @@ int getBufSize(void *codec_buf, int codec)
}
}
int sub_0A40(void *codec_buf, int codec)
int sub_0A40(SceAudiocodecCodec *info, int codec)
{
if (codec < 0x1000 || codec >= 0x1006)
return 0x1000;
@ -351,10 +354,10 @@ int sub_0A40(void *codec_buf, int codec)
{
case 0x1000:
// 0A7C
if (*(int*)(codec_buf + 56) == 1 && *(int*)(s0 + 72) != *(int*)(s0 + 56)) // 0AA4
if (info->unk56 == 1 && info->unk72 != info->unk56)
return 0x2000;
// 0A8C
return *(int*)(codec_buf + 72) << 12;
return info->unk72 << 12;
case 0x1001:
// 0AB4
@ -362,23 +365,23 @@ int sub_0A40(void *codec_buf, int codec)
case 0x1002:
// 0ABC
if (*(int*)(codec_buf + 56) == 9999)
if (info->unk56 == 9999)
{
// 0AE0
int ret = sceAudiocodecGetInfo(codec_buf, 0x1002);
int ret = sceAudiocodecGetInfo(info, 0x1002);
if (ret < 0)
return ret;
}
// 0ACC
// 0AD8 dup
if (*(int*)(codec_buf + 56) == 1)
if (info->unk56 == 1)
return 0x1200;
return 0x900;
case 0x1003:
// 0AF8
// 0AD8 dup
if (*(u8*)(codec_buf + 45) == 0)
if (info->unk45 == 0)
return 0x1000;
return 0x2000;

31
src/avcodec/audiocodec.h Normal file
View File

@ -0,0 +1,31 @@
typedef struct
{
int unk0;
int unk4;
int err; // 8
int edramAddr; // 12
int neededMem; // 16
int unk20;
void *inBuf; // 24
int unk28;
void *outBuf; // 32
int unk36;
char unk40;
char unk41;
char unk42;
char unk43;
char unk44;
char unk45;
char unk46;
char unk47;
int unk48;
int unk52;
int unk56;
int unk60;
int unk64;
int unk68;
int unk72;
// ...
void *allocMem; // 104
} SceAudiocodecCodec;

View File

@ -355,7 +355,7 @@ int sceCodec_driver_FCA6D35B(int freq)
return ret;
}
int sceCodec_driver_6FFC0FA4(void)
int sceCodec_driver_6FFC0FA4(char __attribute__((unused)) arg0)
{
int ret = sub_01FC(0, 0, 1, 1);
if (ret < 0)

15
src/codec/codec.h Normal file
View File

@ -0,0 +1,15 @@
int sceCodecOutputEnable(int arg0, int arg1);
int sceCodec_driver_261C6EE8(int reg);
int sceCodec_driver_49C13ACF(int arg0);
int sceCodec_driver_EACF7284(int arg0);
int sceCodec_driver_D27707A8(char arg0);
int sceCodec_driver_359C2B9F(void);
int sceCodec_driver_FCA6D35B(int freq);
int sceCodec_driver_6FFC0FA4(char __attribute__((unused)) arg0);
int sceCodec_driver_A88FD064(int arg0, int arg1, int arg2, int arg3, int arg4, int arg5);
int sceCodec_driver_277DFFB6(void);
void sceCodec_driver_376399B6(int enable);
int sceCodec_driver_E4456BC3(int arg0);
int sceCodec_driver_E61A4623();
int sceCodec_driver_FC355DE0();

View File

@ -5,20 +5,20 @@ PSP_EXPORT_START(syslib, 0x0000, 0x8000)
PSP_EXPORT_FUNC_HASH(module_start)
PSP_EXPORT_FUNC_HASH(module_reboot_before)
PSP_EXPORT_VAR_HASH(module_info)
PSP_EXPORT_VAR_HASH(module_sdk_version)
PSP_EXPORT_VAR_NID(syslib_11B97506, 0x11B97506)
PSP_EXPORT_END
PSP_EXPORT_START(sceCodec_driver, 0x0011, 0x0001)
PSP_EXPORT_FUNC_NID(sceCodec_driver_02133959, 0x02133959)
PSP_EXPORT_FUNC_NID(sceCodec_driver_261C6EE8, 0x261C6EE8)
PSP_EXPORT_FUNC_HASH(sceCodecStopEntry)
PSP_EXPORT_FUNC_HASH(sceCodecSetOutputVolume)
PSP_EXPORT_FUNC_NID(sceCodec_driver_277DFFB6, 0x277DFFB6)
PSP_EXPORT_FUNC_NID(sceCodec_driver_359C2B9F, 0x359C2B9F)
PSP_EXPORT_FUNC_HASH(sceCodecOutputDisable)
PSP_EXPORT_FUNC_NID(sceCodec_driver_376399B6, 0x376399B6)
PSP_EXPORT_FUNC_NID(sceCodec_driver_49C13ACF, 0x49C13ACF)
PSP_EXPORT_FUNC_NID(sceCodec_driver_6FFC0FA4, 0x6FFC0FA4)
PSP_EXPORT_FUNC_NID(sceCodecOutputEnable, 0x856E7487)
PSP_EXPORT_FUNC_HASH(sceCodecOutputEnable)
PSP_EXPORT_FUNC_NID(sceCodec_driver_A88FD064, 0xA88FD064)
PSP_EXPORT_FUNC_NID(sceCodec_driver_BD8E0977, 0xBD8E0977)
PSP_EXPORT_FUNC_HASH(sceCodecInitEntry)
PSP_EXPORT_FUNC_NID(sceCodec_driver_D27707A8, 0xD27707A8)
PSP_EXPORT_FUNC_NID(sceCodec_driver_E4456BC3, 0xE4456BC3)
PSP_EXPORT_FUNC_NID(sceCodec_driver_E61A4623, 0xE61A4623)

View File

@ -18,6 +18,8 @@
#define ERROR_AUDIO_INVALID_VOLUME 0x8026000B
#define ERROR_AUDIO_INPUT_BUSY 0x80260010
#define ERROR_SIZE 0x80000104
/** SCE errors */
#define SCE_ERROR_NOT_SUPPORTED 0x80000004
#define SCE_ERROR_PRIV_REQUIRED 0x80000023

View File

@ -7,8 +7,8 @@
.globl sub_0000
sub_0000:
lui $a0, %hi(sub_00F8)
addiu $a0, $a0, %lo(sub_00F8)
lui $a0, %hi(execNmiHandler)
addiu $a0, $a0, %lo(execNmiHandler)
ctc0 $a0, $9
lui $a0, %hi(sub_0040)
addiu $a0, $a0, %lo(sub_0040)
@ -16,6 +16,7 @@ sub_0000:
mtc0 $a0, $25
# At 0x0000001C
# get threadman exception vector?
.globl ExceptionManagerForKernel_96D47F7E
ExceptionManagerForKernel_96D47F7E:
lui $v0, %hi(sub_0070)
@ -40,9 +41,10 @@ sub_0040:
bne $v0, $v1, loc_00000098
mfc0 $v1, $14
.globl sub_0068
sub_0068:
j sub_0068
# 0068
.globl syscallHandler
syscallHandler:
j syscallHandler
ctc0 $v1, $0
sub_0070:
@ -65,7 +67,7 @@ loc_0000009C:
ins $v1, $v0, 0, 7
lw $v0, %lo(ExcepManCB)($v1)
cfc0 $v1, $25
bnezl $v1, loc_000000BC
bnezl $v1, loc_000000BC # profiler
sw $v0, 12($v1)
jr $v0
nop
@ -89,7 +91,7 @@ loc_000000E0:
jr $v0
nop
sub_00F8:
execNmiHandler:
ctc0 $v1, $7
mfc0 $v0, $13
mfc0 $v1, $30
@ -105,7 +107,7 @@ sub_00F8:
sub_0120:
ctc0 $v0, $6
mfc0 $v0, $22
bne $0, $v0, ExceptionManagerForKernel_79454858
bne $0, $v0, FUCK#ExceptionManagerForKernel_79454858
nop
.globl sub_0130
@ -127,6 +129,7 @@ sub_0140:
nop
# At 0x00000160
FUCK:
.globl ExceptionManagerForKernel_79454858
ExceptionManagerForKernel_79454858:
li $v0, 92
@ -143,8 +146,9 @@ loc_00000174:
nop
nop
.globl sub_0180
sub_0180:
# 0180
.globl nmiInit
nmiInit:
lui $v0, 0xBC10
lui $v1, 0xFFFF
ori $v1, $v1, 0xFFFF
@ -154,14 +158,15 @@ sub_0180:
lui $v1, %hi(g_0D44)
jr $ra
sw $0, %lo(g_0D44)($v1)
nop
nop
.globl sub_01A4
sub_01A4:
# 01A4
.globl nmiHandler
nmiHandler:
nop
nop
lui $v1, %hi(g_0D40)
lw $v0, %lo(g_0D40)($v1)
bnez $v0, loc_000004E0
bnez $v0, loc_000004E0 # handler was already called!
addi $v0, $v0, 1
sw $v0, %lo(g_0D40)($v1)
lui $v0, %hi(g_0D44)
@ -377,8 +382,8 @@ loc_000003D4:
nop
loc_000004CC:
lui $v0, %hi(sub_01A4)
lw $v0, %lo(sub_01A4)($v0)
lui $v0, %hi(nmiHandler)
lw $v0, %lo(nmiHandler)($v0)
jr $v0
nop

View File

@ -3,12 +3,12 @@
*/
void sub_0000();
void sub_0068();
void syscallHandler();
void sub_0120();
void sub_0130();
void sub_0140();
void ExceptionManagerForKernel_79454858();
void sub_016C();
void sub_0180();
void sub_01A4();
void nmiInit();
void nmiHandler();

View File

@ -2,6 +2,33 @@
See the file COPYING for copying permission.
*/
// interruption
#define EXCEP_INT 1
// load or instruction fetch exception
#define EXCEP_ADEL 4
// address store exception
#define EXCEP_ADES 5
// instruction fetch bus error
#define EXCEP_IBE 6
// load/store bus error
#define EXCEP_DBE 7
// syscall
#define EXCEP_SYS 8
// breakpoint
#define EXCEP_BP 9
// reserved instruction
#define EXCEP_RI 10
// coprocessor unusable
#define EXCEP_CPU 11
// arithmetic overflow
#define EXCEP_OV 12
// floating-point exception
#define EXCEP_FPE 15
// watch (reference to WatchHi/WatchLo)
#define EXCEP_WATCH 23
// "Virtual Coherency Exception data" (used for NMI handling apparently)
#define EXCEP_VCED 31
int sceKernelRegisterPriorityExceptionHandler(int exno, int prio, void (*func)());
int sceKernelRegisterDefaultExceptionHandler(void *func);
int sceKernelReleaseExceptionHandler(int exno, void (*func)());

View File

@ -34,17 +34,17 @@ SceExceptionHandler *newExcepCB(void);
void FreeExcepCB(SceExceptionHandler *ex);
void Allocexceppool(void);
int g_0D40;
int g_0D44;
int g_0D40 = 0;
int g_0D44 = 0;
// 0D48 (?)
char g_stack[2108];
char g_stack[2108] = {0};
// 1580
char g_stackCtx[192];
char g_stackCtx[192] = {0};
// 1640
SceExceptions ExcepManCB;
SceExceptions ExcepManCB = { { NULL }, { NULL }, NULL, NULL, { { NULL, NULL } }};
int ExcepManInit(void)
{
@ -98,6 +98,7 @@ int sceKernelRegisterPriorityExceptionHandler(int exno, int prio, void (*func)()
resumeIntr(oldIntr);
return 0x80020032;
}
int i;
prio &= 0x3;
SceExceptionHandler *newEx = newExcepCB();
SceExceptionHandler *ex = ExcepManCB.hdlr1[exno];
@ -220,7 +221,7 @@ void build_exectbl(void)
}
// 0918
}
int op = *(int*)(sub_0068);
int op = *(int*)(syscallHandler);
// 0948
for (i = 0; i < 32; i++)
{
@ -238,11 +239,11 @@ void build_exectbl(void)
{
// 097C
op = (((int)ExcepManCB.hdlr1[8] >> 2) & 0x03FFFFFF) + 0x08000000;
CACHE(0x1A, &sub_0068);
CACHE(0x1A, &syscallHandler);
}
// 0964
}
*(int*)(sub_0068) = op;
*(int*)(syscallHandler) = op;
}
SceExceptionHandler *newExcepCB(void)

View File

@ -9,19 +9,19 @@
#include "intr.h"
// 1848
void *g_nmiHandlers[16];
void *g_nmiHandlers[16] = { NULL };
int NmiManInit(void)
{
int oldIntr = suspendIntr();
int i;
COP0_CTRL_SET(18, 0);
// 0AEC
int i;
for (i = 0; i < 16; i++)
g_nmiHandlers[i] = NULL;
sub_0180();
nmiInit();
COP0_CTRL_SET(18, g_nmiHandlers);
sceKernelRegisterPriorityExceptionHandler(31, 1, sub_01A4);
sceKernelRegisterPriorityExceptionHandler(31, 1, nmiHandler);
resumeIntr(oldIntr);
return 0;
}

View File

@ -5,134 +5,21 @@
#ifndef GLOBAL_H
#define GLOBAL_H
#include <stdint.h>
typedef uint64_t u64;
typedef uint32_t u32;
typedef uint16_t u16;
typedef uint8_t u8;
typedef int64_t s64;
typedef int32_t s32;
typedef int16_t s16;
typedef int8_t s8;
typedef s64 SceInt64;
typedef s32 SceUID;
typedef s32 SceMode;
typedef u32 SceSize;
typedef SceInt64 SceOff;
typedef int clock_t;
typedef int time_t;
typedef struct
{
unsigned short modattribute;
unsigned char modversion[2];
char modname[27];
char terminal;
void * gp_value;
void * ent_top;
void * ent_end;
void * stub_top;
void * stub_end;
} _sceModuleInfo;
typedef const _sceModuleInfo SceModuleInfo;
extern char _gp[];
enum PspModuleInfoAttr
{
PSP_MODULE_USER = 0,
PSP_MODULE_NO_STOP = 0x0001,
PSP_MODULE_SINGLE_LOAD = 0x0002,
PSP_MODULE_SINGLE_START = 0x0004,
PSP_MODULE_KERNEL = 0x1000,
};
/* Declare a module. This must be specified in the source of a library or executable. */
#define PSP_MODULE_INFO(name, attributes, major_version, minor_version) \
__asm__ ( \
" .set push\n" \
" .section .lib.ent.top, \"a\", @progbits\n" \
" .align 2\n" \
" .word 0\n" \
"__lib_ent_top:\n" \
" .section .lib.ent.btm, \"a\", @progbits\n" \
" .align 2\n" \
"__lib_ent_bottom:\n" \
" .word 0\n" \
" .section .lib.stub.top, \"a\", @progbits\n" \
" .align 2\n" \
" .word 0\n" \
"__lib_stub_top:\n" \
" .section .lib.stub.btm, \"a\", @progbits\n" \
" .align 2\n" \
"__lib_stub_bottom:\n" \
" .word 0\n" \
" .set pop\n" \
" .text\n" \
); \
extern char __lib_ent_top[], __lib_ent_bottom[]; \
extern char __lib_stub_top[], __lib_stub_bottom[]; \
SceModuleInfo module_info \
__attribute__((section(".rodata.sceModuleInfo"), unused)) \
= { attributes, { minor_version, major_version }, name, 0, \
_gp, __lib_ent_top, __lib_ent_bottom, \
__lib_stub_top, __lib_stub_bottom } \
#include "errors.h"
#define PSP_SDK_VERSION(ver) const int module_sdk_version = ver
#define PSP_MODULE_BOOTSTART(name) int module_start(int arglen, void *argp) __attribute__((alias(name))); \
int module_bootstart(int arglen, void *argp) __attribute__((alias(name)))
#define PSP_MODULE_REBOOT_BEFORE(name) int module_reboot_before(void) __attribute__((alias(name)))
#define PSP_MODULE_STOP(name) int module_stop(void) __attribute__((alias(name)))
/********** TEMPORARY: it'll be in their corresponding module's header *********/
typedef int (*SceKernelCallbackFunction)(int arg1, int arg2, void *arg);
typedef struct
{
int size;
char name[32];
SceUID threadId;
SceKernelCallbackFunction callback;
void *common;
int notifyCount;
int notifyArg;
} SceKernelCallbackInfo;
typedef struct
{
unsigned short year;
unsigned short month;
unsigned short day;
unsigned short hour;
unsigned short minute;
unsigned short second;
unsigned int microsecond;
} ScePspDateTime;
typedef struct
{
SceMode st_mode;
unsigned int st_attr;
SceOff st_size;
ScePspDateTime st_ctime;
ScePspDateTime st_atime;
ScePspDateTime st_mtime;
unsigned int st_private[6];
} SceIoStat;
typedef struct
{
SceSize size;
u32 startAddr;
u32 memSize;
u32 attr;
} SceSysmemPartitionInfo;
#include <pspintrman.h>
#include <pspintrman_kernel.h>
#include <pspsysmem.h>
#include <pspthreadman.h>
#include <pspthreadman_kernel.h>
#include <psputils.h>
typedef struct
{
@ -140,12 +27,12 @@ typedef struct
int (*func)(void *, int, int funcid, void *args);
} SceSysmemUIDLookupFunction;
struct SceSysmemUIDControlBlock
typedef struct SceSysmemUIDControlBlock
{
struct SceSysmemUIDControlBlock *parent; // 0
struct SceSysmemUIDControlBlock *nextChild; // 4
struct SceSysmemUIDControlBlock *type; // 8
SceUID id; // 12
SceUID UID; // 12
char *name; // 16
unsigned char unk; // 20
unsigned char size; // size in words
@ -153,43 +40,14 @@ struct SceSysmemUIDControlBlock
struct SceSysmemUIDControlBlock *nextEntry; // 24
struct SceSysmemUIDControlBlock *inherited; // 28
SceSysmemUIDLookupFunction *func_table; // 32
} __attribute__((packed));
typedef struct SceSysmemUIDControlBlock SceSysmemUIDControlBlock;
} __attribute__((packed)) SceSysmemUIDControlBlock;
typedef struct
{
SceSize size;
char name[32];
u32 attr;
int bufSize;
int freeSize;
int numSendWaitThreads;
int numReceiveWaitThreads;
} SceKernelMppInfo;
int sceKernelDeci2pRegisterOperations(void *op);
void *sceKernelDeci2pReferOperations();
typedef struct
{
int size;
void (*ops[14])();
} SceKernelDeci2Ops;
int sceKernelRenameUID(SceUID uid, const char *name);
int sceKernelRegisterLibrary(char **name); // LoadCoreForKernel_211FEA3D
int sceKernelGetModuleGPByAddressForKernel(void *func); // LoadCoreForKernel_18CFDAA0
SceUID sceKernelCreateHeap(SceUID partitionid, SceSize size, int unk, const char *name); // SysMemForKernel_AF85EB1B
void *sceKernelAllocHeapMemory(SceUID heapid, SceSize size); // SysMemForKernel_6D161EE2
int sceKernelFreeHeapMemory(SceUID heapid, void *block); // SysMemForKernel_DB836ADB
void *sceKernelGetGameInfo(); // SysMemForKernel_EF29061C
// unsure
int sceCodec_driver_B2EF6B19(int);
int sceCodec_driver_431C0C8E(int freq);
int sceCodecOutputEnable(int, int);
int sceCodec_driver_E4D7F914(void);
int sceCodec_driver_F071BF60(int);
int sceCodec_driver_9681738F(int);
int sceCodec_driver_B0141A1B(char, char, char, char, char, char);
int sceCodec_driver_55F1788B(void);
int InterruptManagerForKernel_A0F88036(void);
// unsure
int sceKernelDmaOpQuit(u32*);
@ -200,13 +58,68 @@ int sceKernelDmaOpEnQueue(u32*);
int sceKernelDmaOpDeQueue(u32*);
u32 *sceKernelDmaOpAlloc(void);
int sceKernelDmaOpFree(u32*);
int sceDdrFlush(int);
int sceClockgenAudioClkSetFreq(int);
int sceSysregAudioClkEnable(int);
int sceSysregAudioClkSelect(int, int);
int sceSysregAudioBusClockEnable(int);
int sceSysregAudioIoEnable(int);
int sceSysregAudioIoDisable(int);
int sceSysregAudioClkoutClkSelect(int);
int sceSysregAudioClkoutIoEnable(void);
int sceSysregAudioClkoutIoDisable();
int DmacManForKernel_E18A93A5(void*, void*);
SceUID sceKernelCreateHeap(SceUID partitionid, SceSize size, int unk, const char *name);
void *sceKernelAllocHeapMemory(SceUID heapid, SceSize size);
int sceKernelFreeHeapMemory(SceUID heapid, void *block);
int sceKernelDeleteHeap(SceUID heapid);
SceSize sceKernelHeapTotalFreeSize(SceUID heapid);
typedef struct
{
int id;
int (*func)();
} SceSysmemUIDLookupFunc;
int sceKernelGetUIDcontrolBlockWithType(SceUID uid, SceSysmemUIDControlBlock *type, SceSysmemUIDControlBlock **block);
int sceKernelGetUIDcontrolBlock(SceUID uid, SceSysmemUIDControlBlock **block);
SceSysmemUIDControlBlock *sceKernelCreateUIDtype(const char *name, int attr, SceSysmemUIDLookupFunc *funcs, int unk, SceSysmemUIDControlBlock **type);
SceUID sceKernelCreateUID(SceSysmemUIDControlBlock *type, const char *name, short attr, SceSysmemUIDControlBlock **block);
int sceKernelDeleteUID(SceUID uid);
int sceKernelCallUIDObjCommonFunction(SceSysmemUIDControlBlock *cb, int funcid, void *arg1, void *arg2, void *arg3, void *arg4, void *arg5, void *arg6);
void Kprintf(const char *format, ...);
int sceKernelGetUserLevel(void);
int sceKernelDipsw(int);
int sceKernelDebugWrite(SceUID fd, const void *data, SceSize size);
int sceKernelDebugRead(SceUID fd, const void *data, SceSize size);
int sceKernelDebugEcho(void);
int sceKernelPowerLock(int);
int sceKernelPowerLockForUser(int);
int sceKernelPowerUnlock(int);
int sceKernelPowerUnlockForUser(int);
/********************************/
#if 0
#define NULL ((void*)0)
#endif
#define K1 27
#define GP 28
#define SP 29
#define RA 31
#define GET_REG(val, reg) asm("move %0, $%1" : "=r" (val) : "ri" (reg))
#define SET_REG(reg, val) asm("move $%1, %0" : : "r" (val), "ri" (reg))
@ -243,11 +156,13 @@ GET_REG(_k1, K1);
#define COP0_CTRL_V0 4
#define COP0_CTRL_V1 5
#define COP0_CTRL_EXC_TABLE 8
#define COP0_CTRL_NMI_HANDLER 9
#define COP0_CTRL_SC_TABLE 12
#define COP0_CTRL_IS_INTERRUPT 13
#define COP0_CTRL_SP_KERNEL 14
#define COP0_CTRL_SP_USER 15
#define COP0_CTRL_TCB 16
#define COP0_CTRL_NMI_TABLE 18
#define COP0_CTRL_23 23
#define COP0_CTRL_PROFILER_BASE 25

8
src/interruptman/end.h Normal file
View File

@ -0,0 +1,8 @@
/* Copyright (C) 2011 The uOFW team
See the file COPYING for copying permission.
*/
int sceKernelCpuSuspendIntr();
void sceKernelCpuResumeIntrWithSync(int state);
void sceKernelCpuResumeIntr(int state);

View File

@ -95,9 +95,9 @@ int IntrManInit()
intInfo.intr[i].u16 = -1;
intInfo.intr[i].u20 = -1;
}
sceKernelRegisterExceptionHandler(0, (void*)sub_0038);
sceKernelRegisterPriorityExceptionHandler(0, 3, (void*)sub_0924);
sceKernelRegisterExceptionHandler(8, (void*)sub_0CF8);
sceKernelRegisterExceptionHandler(EXCEP_INT, (void*)sub_0038);
sceKernelRegisterPriorityExceptionHandler(EXCEP_INT, 3, (void*)sub_0924);
sceKernelRegisterExceptionHandler(EXCEP_SYS, (void*)sub_0CF8);
sceKernelRegisterIntrHandler(67, 0, sub_0000, 0, 0);
sceKernelRegisterSuspendHandler(29, SuspendIntc, 0);
sceKernelRegisterResumeHandler(29, ResumeIntc, 0);
@ -1062,9 +1062,9 @@ int IntrManTerminate()
COP0_STATE_GET(st, COP0_STATE_STATUS);
COP0_STATE_SET(COP0_STATE_STATUS, st & 0xFFFF7BFF);
sceKernelReleaseIntrHandler(67);
sceKernelReleaseExceptionHandler(0, (void*)sub_0038);
sceKernelReleaseExceptionHandler(0, (void*)sub_0924);
sceKernelReleaseExceptionHandler(8, (void*)sub_0CF8);
sceKernelReleaseExceptionHandler(EXCEP_INT, (void*)sub_0038);
sceKernelReleaseExceptionHandler(EXCEP_INT, (void*)sub_0924);
sceKernelReleaseExceptionHandler(EXCEP_SYS, (void*)sub_0CF8);
return 0;
}

View File

@ -966,7 +966,6 @@ InterruptManagerForKernel_1373F20E:
.globl sub_0CC0
sub_0CC0:
loc_00000CC0:
cfc0 $v0, $0
mtc0 $v0, $14
lui $v0, %hi(sub_0CF8)
@ -974,8 +973,8 @@ loc_00000CC0:
jr $v0
nop
.globl InterruptManagerForKernel_A0F88036
InterruptManagerForKernel_A0F88036:
.globl sceKernelGetSyscallRA
sceKernelGetSyscallRA:
cfc0 $v0, $16
beqz $v0, loc_00000CF0
nop
@ -1018,7 +1017,7 @@ loc_00000D40:
lw $t5, 4($t4)
mtc0 $v0, $14
lw $t6, 8($t4)
beqz $t5, loc_00000CC0
beqz $t5, sub_0CC0
subu $t5, $t7, $t5
sltu $at, $t5, $t6
beqzl $at, loc_00000D40

44
src/interruptman/start.h Normal file
View File

@ -0,0 +1,44 @@
/* Copyright (C) 2011 The uOFW team
See the file COPYING for copying permission.
*/
void sub_0000();
void sub_0038();
void InterruptManagerForKernel_551097F2();
int sceKernelIsIntrContext();
void SaveThreadContext();
int sceKernelCallUserIntrHandler(int, int, int, int, int, int);
void sub_0864();
int sub_091C();
void sub_0924();
void InterruptManagerForKernel_A6978B70();
void InterruptManagerForKernel_1373F20E();
void sub_0CC0();
int InterruptManagerForKernel_A0F88036();
void sub_0CF8();
void loc_00000DDC();
void sub_0EC0();
void sub_0ECC();
void sub_0EF8();
void sub_0F20();
void sub_0F58();
void sub_0F64();
void sub_0FA4();
void sub_0FE4();
void sub_0FF0();
void sub_0FF8();
void sub_1000();
void sub_1008();
void sub_1010();
void sub_1020();
void sub_1030();
void sub_1050(int*);
void sub_1080(int*);
void sub_10A8(int*);
int mod_0400;
int mod_0468;
int mod_0DC4;
int mod_0E48;
int mod_0E50;

12
src/iofilemgr/Makefile Normal file
View File

@ -0,0 +1,12 @@
# Copyright (C) 2011, 2012 The uOFW team
# See the file COPYING for copying permission.
TARGET = iofilemgr
OBJS = stdio.o iofilemgr.o
LIBS = -lThreadManForUser -lThreadManForKernel -lSysclibForKernel -lSysMemUserForUser -lSysMemForKernel -lKDebugForKernel -lInterruptManagerForKernel -lsceSuspendForKernel
PRX_EXPORTS=exports.exp
include ../../lib/build.mak

View File

@ -93,16 +93,16 @@ PSP_EXPORT_FUNC_HASH(sceIoGetDevType)
PSP_EXPORT_FUNC_HASH(sceIoWriteAsync)
PSP_EXPORT_FUNC_HASH(sceIoOpen)
PSP_EXPORT_FUNC_HASH(sceIoRmdir)
PSP_EXPORT_FUNC_NID(IoFileMgrForKernel_18881E58, 0x18881E58)
PSP_EXPORT_FUNC_NID(sceIoGetFdDebugInfo, 0x18881E58)
PSP_EXPORT_FUNC_HASH(sceIoLseek32Async)
PSP_EXPORT_FUNC_NID(sceIoGetThreadCwd, 0x1FC0620B)
PSP_EXPORT_FUNC_NID(sceIoAddHook, 0x22F15793)
PSP_EXPORT_FUNC_HASH(sceIoLseek)
PSP_EXPORT_FUNC_NID(IoFileMgrForKernel_30E8ABB3, 0x2B6A9B21)
PSP_EXPORT_FUNC_NID(sceIoValidateFd, 0x2B6A9B21)
PSP_EXPORT_FUNC_HASH(sceIoPollAsync)
PSP_EXPORT_FUNC_HASH(sceIoWaitAsyncCB)
PSP_EXPORT_FUNC_HASH(sceIoWrite)
PSP_EXPORT_FUNC_NID(IoFileMgrForKernel_BD17474F, 0x49356C12)
PSP_EXPORT_FUNC_NID(sceIoGetIobUserLevel, 0x49356C12)
PSP_EXPORT_FUNC_HASH(sceIoDevctl)
PSP_EXPORT_FUNC_HASH(sceIoChdir)
PSP_EXPORT_FUNC_HASH(sceIoGetFdList)
@ -111,7 +111,7 @@ PSP_EXPORT_FUNC_HASH(sceIoLseek32)
PSP_EXPORT_FUNC_HASH(sceIoRead)
PSP_EXPORT_FUNC_HASH(sceIoUnassign)
PSP_EXPORT_FUNC_HASH(sceIoLseekAsync)
PSP_EXPORT_FUNC_NID(IoFileMgrForKernel_76DA16E3, 0x76DA16E3)
PSP_EXPORT_FUNC_NID(sceIoTerminateFd, 0x76DA16E3)
PSP_EXPORT_FUNC_HASH(sceIoRename)
PSP_EXPORT_FUNC_HASH(sceIoClose)
PSP_EXPORT_FUNC_HASH(sceIoOpenAsync)
@ -139,7 +139,7 @@ PSP_EXPORT_FUNC_NID(IoFileMgrForKernel_E972F70B, 0xE972F70B)
PSP_EXPORT_FUNC_HASH(sceIoDclose)
PSP_EXPORT_FUNC_HASH(sceIoRemove)
PSP_EXPORT_FUNC_HASH(sceIoCloseAsync)
PSP_EXPORT_VAR_NID(IoFileMgrForKernel_E4D75BC0, 0xE4D75BC0)
PSP_EXPORT_VAR_NID(g_deleted_error, 0xE4D75BC0)
PSP_EXPORT_END
PSP_END_EXPORTS

3174
src/iofilemgr/iofilemgr.c Normal file

File diff suppressed because it is too large Load Diff

212
src/iofilemgr/iofilemgr.h Normal file
View File

@ -0,0 +1,212 @@
struct SceIoDeviceArg;
typedef struct SceIoDeviceArg SceIoDeviceArg;
struct SceIoIob;
typedef struct SceIoIob SceIoIob;
typedef struct
{
SceMode st_mode;
u32 st_attr;
SceOff st_size;
ScePspDateTime st_ctime;
ScePspDateTime st_atime;
ScePspDateTime st_mtime;
u32 st_private[6];
} SceIoStat;
typedef struct
{
SceIoStat d_stat;
char d_name[256];
void *d_private;
int dummy;
} SceIoDirent;
typedef struct
{
int (*IoInit)(SceIoDeviceArg *dev);
int (*IoExit)(SceIoDeviceArg *dev);
int (*IoOpen)(SceIoIob *iob, char *file, int flags, SceMode mode);
int (*IoClose)(SceIoIob *iob);
int (*IoRead)(SceIoIob *iob, char *data, int len);
int (*IoWrite)(SceIoIob *iob, const char *data, int len);
SceOff (*IoLseek)(SceIoIob *iob, SceOff ofs, int whence);
int (*IoIoctl)(SceIoIob *iob, unsigned int cmd, void *indata, int inlen, void *outdata, int outlen);
int (*IoRemove)(SceIoIob *iob, const char *name);
int (*IoMkdir)(SceIoIob *iob, const char *name, SceMode mode);
int (*IoRmdir)(SceIoIob *iob, const char *name);
int (*IoDopen)(SceIoIob *iob, const char *dirname);
int (*IoDclose)(SceIoIob *iob);
int (*IoDread)(SceIoIob *iob, SceIoDirent *dir);
int (*IoGetstat)(SceIoIob *iob, const char *file, SceIoStat *stat);
int (*IoChstat)(SceIoIob *iob, const char *file, SceIoStat *stat, int bits);
int (*IoRename)(SceIoIob *iob, const char *oldname, const char *newname);
int (*IoChdir)(SceIoIob *iob, const char *dir);
int (*IoMount)(SceIoIob *iob, const char *fs, const char *blockDev, int mode, void *unk1, int unk2);
int (*IoUmount)(SceIoIob *iob, const char *blockDev);
int (*IoDevctl)(SceIoIob *iob, const char *devname, unsigned int cmd, void *indata, int inlen, void *outdata, int outlen);
int (*IoCancel)(SceIoIob *iob);
} SceIoDrvFuncs;
typedef struct
{
const char *name;
u32 dev_type;
u32 unk2;
const char *name2;
SceIoDrvFuncs *funcs;
} SceIoDrv;
struct SceIoDeviceArg
{
SceIoDrv *drv;
void *argp;
int openedFiles;
};
struct SceIoHookType;
typedef struct SceIoHookType SceIoHookType;
struct SceIoHook;
typedef struct SceIoHook SceIoHook;
typedef struct
{
void (*Add)(SceIoHookType **hook);
int unused4;
int (*Preobe)(SceIoHook *hook, char *file, int flags, SceMode mode);
int (*Open)(SceIoHook *hook, char *file, int flags, SceMode mode);
int (*Close)(SceIoHook *hook);
int (*Read)(SceIoHook *hook, void *data, SceSize size);
int (*Write)(SceIoHook *hook, const void *data, SceSize size);
SceOff (*Lseek)(SceIoHook *hook, SceOff ofs, int whence);
int (*Ioctl)(SceIoHook *iob, unsigned int cmd, void *indata, int inlen, void *outdata, int outlen);
} SceIoHookFuncs;
struct SceIoHookType
{
char *name;
int unk4;
int unk8;
char *name2;
SceIoHookFuncs *funcs;
};
typedef struct
{
int size; // 0
char name[32]; // 4
int attribute; // 36
int unk40; // 40
const char *drvName; // 44
int fsNum; // 48
char *newPath; // 52
int retAddr; // 56
int curThread; // 60
int asyncThread; // 64
int isAsync; // 68
int asyncCmd; // 72
SceIoIob *iob; // 76
int unk80; // 80
int unk84; // 84
} SceIoFdDebugInfo;
typedef struct
{
SceIoHookType *hook;
void *argp;
} SceIoHookArg;
struct SceIoHook
{
SceIoHookArg *arg;
SceIoIob *iob;
SceIoDrvFuncs *funcs;
};
struct SceIoIob
{
int unk000; // some ID
int fsNum; // 4
SceIoDeviceArg *dev; // 8
int dev_type; // 12
int unk016; // 16
int unk020; // 20
int unk024; // 24
int unk028; // 28
int unk032; // 32
int unk036; // 36
int unk040; // 40
SceUID curThread; // 44
char userMode; // 48
char powerLocked; // 49
char unk050;
char asyncPrio; // 51
SceUID asyncThread; // 52
SceUID asyncSema; // 56
SceUID asyncEvFlag; // 60
SceUID asyncCb; // 64
void *asyncCbArgp; // 68
int unused72; // 72
int k1; // 76
s64 asyncRet; // 80
int asyncArgs[6]; // 88
int asyncCmd; // 112
int userLevel; // 116
SceIoHook hook; // 120
int unk132; // 132
char *newPath; // 136
int retAddr; // 140
};
int sceIoGetUID(int fd);;
int sceIoChangeAsyncPriority(int fd, int prio);
void sceIoCloseAll();
int sceIoReopen(const char *file, int flags, SceMode mode, int fd);
SceUID sceIoDopen(const char *dirname);
int sceIoDread(int fd, SceIoDirent *dir);
int sceIoDclose(int fd);
int sceIoRemove(const char *file);
int sceIoRename(const char *oldname, const char *newname);
int sceIoDevctl(const char *dev, unsigned int cmd, void *indata, int inlen, void *outdata, int outlen);
int sceIoAssign(const char *dev, const char *blockDev, const char *fs, int mode, void* unk1, int unk2);
int sceIoUnassign(const char *dev);
int sceIoChangeThreadCwd(SceUID threadId, const char *path);
int sceIoCancel(int fd);
int sceIoGetFdList(SceUID *fds, int numFd, int *count);
int sceIoGetFdDebugInfo(int fd, SceIoFdDebugInfo *outInfo);
int sceIoAddDrv(SceIoDrv *drv);
int sceIoDelDrv(const char *drv);
int sceIoGetUID(int fd);
int sceIoPollAsync(SceUID fd, SceInt64 *res);
int sceIoWaitAsync(SceUID fd, SceInt64 *res);
int sceIoWaitAsyncCB(SceUID fd, SceInt64 *res);
int sceIoGetAsyncStat(SceUID fd, int poll, SceInt64 *res);
int sceIoSetAsyncCallback(SceUID fd, SceUID cb, void *argp);
int sceIoValidateFd(SceUID fd, int arg1);
int sceIoClose(SceUID fd);
int sceIoCloseAsync(SceUID fd);
SceUID sceIoOpen(const char *file, int flags, SceMode mode);
SceUID sceIoOpenAsync(const char *file, int flags, SceMode mode);
int sceIoRead(SceUID fd, void *data, SceSize size);
int sceIoReadAsync(SceUID fd, void *data, SceSize size);
int sceIoWrite(SceUID fd, void *data, SceSize size);
int sceIoWriteAsync(SceUID fd, void *data, SceSize size);
SceOff sceIoLseek(SceUID fd, SceOff offset, int whence);
SceOff sceIoLseekAsync(SceUID fd, SceOff offset, int whence);
int sceIoLseek32(SceUID fd, int offset, int whence);
int sceIoLseek32Async(SceUID fd, int offset, int whence);
int sceIoIoctl(SceUID fd, unsigned int cmd, void *indata, int inlen, void *outdata, int outlen);
int sceIoIoctlAsync(SceUID fd, unsigned int cmd, void *indata, int inlen, void *outdata, int outlen);
int sceIoMkdir(const char *path, SceMode mode);
int sceIoRmdir(const char *path);
int sceIoChdir(const char *path);
int sceIoGetstat(const char *file, SceIoStat *stat);
int sceIoChstat(const char *file, SceIoStat *stat, int bits);
int sceIoSync(const char *device, unsigned int unk);
int sceIoGetDevType(SceUID fd);
int sceIoGetThreadCwd(SceUID uid, char *dir, int len);
int sceIoTerminateFd(char *drive);
int sceIoAddHook(SceIoHookType *hook);
int sceIoGetIobUserLevel(SceIoIob *iob);

View File

@ -6,19 +6,21 @@
#include "../global.h"
#include "../sysmem/sysclib.h"
#include "iofilemgr.h"
#define STDIN 0
#define STDOUT 1
#define STDERR 2
const char g_dummy[] = "dummy_drv_iofile:"; // 6700
const char g_tty[] = "tty0:"; // 6714
const char g_return[] = "\r\n"; // 671C
const char g_tab[] = " "; // 6720
const char g_null[] = "<NULL>"; // 672C
const char g_ttyDevName[] = "ttyproxy"; // 6734
const char g_ttyDevDesc[] = "TTY2MsgPipe PROXY"; // 6740
const char g_tty1[] = "ttyproxy1:"; // 6754
const char g_tty2[] = "ttyproxy2:"; // 6760
int _sceTtyProxyDevRead(SceIoIob *iob, char *buf, int size);
int _sceTtyProxyDevWrite(SceIoIob *iob, const char *buf, int size);
int _sceTtyProxyDevInit(SceIoDeviceArg *dev);
int _sceTtyProxyDevExit(SceIoDeviceArg *dev);
int _sceTtyProxyDevOpen(SceIoIob *iob, char *file, int flags, SceMode mode);
int _sceTtyProxyDevClose(SceIoIob *iob);
SceOff _sceTtyProxyDevLseek();
int _sceTtyProxyDevIoctl(SceIoIob *iob, unsigned int cmd, void *indata, int inlen, void *outdata, int outlen);
SceIoDrvFuncs g_TtyOps = // 6948
{
@ -46,17 +48,21 @@ SceIoDrvFuncs g_TtyOps = // 6948
NULL
};
SceIoDrv g_TtyDevTbl = {g_ttyDevName, 0x00000003, 0x00000001, g_ttyDevDesc, g_TtyOps}; // 69A0
SceIoDrv g_TtyDevTbl = { "ttyproxy", 0x00000003, 0x00000001, "TTY2MsgPipe PROXY", &g_TtyOps }; // 69A0
int g_stdin = -1; // 6AD0
int g_stdout = -1; // 6AD4
int g_stderr = -1; // 6AD8
int g_debugRead; // 6AF0
int *g_pipeList; // 6AF4
int g_pipeList[6]; // 6AF4
int g_linePos; // 6C34
int sceTtyProxyInit();
int stdoutReset(int flags, SceMode mode);
int _sceKernelRegisterStdPipe(int fd, SceUID id);
// 0000
int StdioReInit()
{
@ -67,7 +73,7 @@ int StdioReInit()
// 0044
int i;
for (i = 0; i < 3; i++)
*fds[i] = sceIoOpen(g_dummy, 3, 0x1FF);
*fds[i] = sceIoOpen("dummy_drv_iofile:", 3, 0x1FF);
g_debugRead = 1;
sceTtyProxyInit();
return 0;
@ -138,12 +144,12 @@ int stdoutReset(int flags, SceMode mode)
if (openDummy)
{
// 0214
int ret = sceIoOpen(g_tty, flags, mode);
int ret = sceIoOpen("tty0:", flags, mode);
if (ret >= 0)
return ret;
}
// 01E8
return sceIoOpen(g_dummy, flags, mode);
return sceIoOpen("dummy_drv_iofile:", flags, mode);
}
// 0244
@ -208,25 +214,25 @@ void printf_char(void *ctx, int ch)
int fdprintf(int fd, const char *fmt, ...)
{
va_list ap;
int ret;
char sp[168];
va_start(ap, fmt);
*(short*)((int)sp + 0) = fd;
*(short*)((int)sp + 2) = 0;
int n = prnt(printf_char, sp, fmt, ap);
va_end(ap);
return n;
}
int printf(const char *fmt, ...)
{
va_list ap;
int ret;
char sp[164];
va_start(ap, fmt);
*(short*)((int)sp + 0) = STDOUT;
*(short*)((int)sp + 2) = 0;
int n = prnt(printf_char, sp, fmt, ap);
va_end(ap);
return n;
}
int fdputc(int c, int fd)
@ -238,7 +244,7 @@ int fdputc(int c, int fd)
// 0574
if (sceKernelDipsw(59) == 1) {
// 05E4
sceKernelDebugWrite(fd, g_tab, 8 - (g_linePos & 7)); // " "
sceKernelDebugWrite(fd, " ", 8 - (g_linePos & 7));
}
else
{
@ -248,7 +254,7 @@ int fdputc(int c, int fd)
if (fd == STDERR)
fd = g_stderr;
// 059C
sceIoWrite(fd, g_tab, 8 - (g_linePos & 7));
sceIoWrite(fd, " ", 8 - (g_linePos & 7));
}
// 05C4
g_linePos = (g_linePos & 0xFFFFFFF8) + 8;
@ -257,7 +263,7 @@ int fdputc(int c, int fd)
{
// 0504
if (sceKernelDipsw(59) == 1)
sceKernelDebugWrite(fd, g_return, sizeof(g_return));
sceKernelDebugWrite(fd, "\r\n", 2);
else
{
if (fd == STDOUT)
@ -266,7 +272,7 @@ int fdputc(int c, int fd)
if (fd == STDERR)
fd = g_stderr;
// 052C
sceIoWrite(fd, g_return, sizeof(g_return));
sceIoWrite(fd, "\r\n", 2);
}
// 0544
g_linePos = 0;
@ -385,7 +391,7 @@ int fdputs(const char *s, int fd)
{
char c;
if (s == NULL) // 089C
s = g_null;
s = "<NULL>";
// 085C, 0880
while ((c = *(s++)) != '\0')
fdputc(c, fd);
@ -396,7 +402,7 @@ int puts(const char *s)
{
char c;
if (s == NULL) // 089C
s = g_null;
s = "<NULL>";
// 085C, 0880
while ((c = *(s++)) != '\0')
fdputc(c, STDOUT);
@ -442,7 +448,7 @@ int sceKernelStdioOpen()
return 0x80020001;
}
int _sceTtyProxyDevRead(void *iob, void *buf, int size)
int _sceTtyProxyDevRead(SceIoIob *iob, char *buf, int size)
{
int cnt;
K1_BACKUP();
@ -452,15 +458,16 @@ int _sceTtyProxyDevRead(void *iob, void *buf, int size)
k1 = 24;
// 09D0
SET_REG(K1, k1);
int unk1 = g_pipeList[*(int*)(iob + 4) + 3];
int unk2 = g_pipeList[*(int*)(iob + 4) + 0];
int size2 = g_pipeList[iob->fsNum + 3];
SceUID id = g_pipeList[iob->fsNum + 0];
int min;
// 09F8
do
{
int min = unk1;
if (unk1 >= size)
min = size2;
if (size2 >= size)
min = size;
int ret = sceKernelReceiveMsgPipe(unk2, buf, min, 1, &cnt, 0);
int ret = sceKernelReceiveMsgPipe(id, buf, min, 1, &cnt, 0);
if (ret < 0) {
K1_RESET();
return ret;
@ -473,7 +480,7 @@ int _sceTtyProxyDevRead(void *iob, void *buf, int size)
return count;
}
int _sceTtyProxyDevWrite(void *iob, void *buf, int size)
int _sceTtyProxyDevWrite(SceIoIob *iob, const char *buf, int size)
{
K1_BACKUP();
int count = 0;
@ -483,15 +490,15 @@ int _sceTtyProxyDevWrite(void *iob, void *buf, int size)
k1 = 24;
// 0AC4
SET_REG(K1, k1);
int size2 = g_pipeList[*(int*)(iob + 4) + 3];
SceUID id = g_pipeList[*(int*)(iob + 4) + 0];
int size2 = g_pipeList[iob->fsNum + 3];
SceUID id = g_pipeList[iob->fsNum + 0];
// 0AE8
do
{
int minSize = size2;
if (size2 >= size)
minSize = size;
int ret = sceKernelSendMsgPipe(id, buf, minSize, 0, &curCnt, 0);
int ret = sceKernelSendMsgPipe(id, (void*)buf, minSize, 0, &curCnt, 0);
if (ret < 0) {
K1_RESET();
return ret;
@ -507,7 +514,7 @@ int _sceTtyProxyDevWrite(void *iob, void *buf, int size)
// 0B58
int sceTtyProxyInit()
{
sceIoAddDrv(g_TtyOps);
sceIoAddDrv(&g_TtyDevTbl);
return 0;
}
@ -528,37 +535,37 @@ int sceKernelRegisterStderrPipe(SceUID id)
}
// 0BE4
int _sceTtyProxyDevInit()
int _sceTtyProxyDevInit(SceIoDeviceArg *dev __attribute__((unused)))
{
return 0;
}
// 0BEC
int _sceTtyProxyDevExit()
int _sceTtyProxyDevExit(SceIoDeviceArg *dev __attribute__((unused)))
{
return 0;
}
int _sceTtyProxyDevOpen(void *iob)
int _sceTtyProxyDevOpen(SceIoIob *iob, char *file __attribute__((unused)), int flags __attribute__((unused)), SceMode mode __attribute__((unused)))
{
if (*(int*)(iob + 4) < 3)
if (iob->fsNum < 3)
return 0;
return 0x80010006;
}
int _sceTtyProxyDevClose(void *iob)
int _sceTtyProxyDevClose(SceIoIob *iob)
{
if (*(int*)(iob + 4) < 3)
if (iob->fsNum < 3)
return 0;
return 0x80010006;
}
long long _sceTtyProxyDevLseek()
SceOff _sceTtyProxyDevLseek()
{
return 0x80020323;
}
int _sceTtyProxyDevIoctl(void *iob, int cmd)
int _sceTtyProxyDevIoctl(SceIoIob *iob, unsigned int cmd, void *indata __attribute__((unused)), int inlen __attribute__((unused)), void *outdata __attribute__((unused)), int outlen __attribute__((unused)))
{
if (cmd != 0x00134002)
return 0x80020324;
@ -567,7 +574,7 @@ int _sceTtyProxyDevIoctl(void *iob, int cmd)
if (sceIoGetIobUserLevel(iob) == 8)
k1 = 0;
SET_REG(K1, k1);
sceKernelCancelMsgPipe(g_pipeList[*(int*)(iob + 4)], 0, 0);
sceKernelCancelMsgPipe(g_pipeList[iob->fsNum], 0, 0);
K1_RESET();
return 0;
}
@ -591,11 +598,11 @@ int _sceKernelRegisterStdPipe(int fd, SceUID id)
}
if (sceKernelGetThreadmanIdType(id) == 7)
return 0x800200D2;
SceSysmemUIDControlBlock blk;
SceSysmemUIDControlBlock *blk;
if (sceKernelGetUIDcontrolBlock(id, &blk) != 0)
return 0x800200D1;
K1_GET();
if (K1_USER_MODE() && (blk.parent->attribute & 2) != 0)
if (K1_USER_MODE() && (blk->parent->attribute & 2) != 0)
return 0x800200D1;
SceKernelMppInfo mpp;
mpp.size = 56;
@ -604,11 +611,11 @@ int _sceKernelRegisterStdPipe(int fd, SceUID id)
return ret;
if (STDOUT == 1) {
// 0DB8
ret = sceKernelStdoutReopen(g_tty1, 2, 0x1FF);
ret = sceKernelStdoutReopen("ttyproxy1:", 2, 0x1FF);
}
else if (STDERR == 2) {
// 0DA0
ret = sceKernelStderrReopen(g_tty2, 2, 0x1FF);
ret = sceKernelStderrReopen("ttyproxy2:", 2, 0x1FF);
}
// 0D58
if (ret < 0)

View File

@ -1169,7 +1169,7 @@ int setBuffer(SceAtracId *id, u8 *buffer, u32 readByte, u32 bufferByte, SceAtrac
int ret = setBufferSize(&id->info, readByte, bufferByte);
if (ret != 0)
return ret;
if (id->info.codec == 0x1001)
if (id->info.codec == 0x1001) // AT3
{
// 25BC
SceAtracUnk *cur = &g_3F08[4];

View File

@ -41,33 +41,6 @@ typedef struct
// ...
} SceAtracIdInfo;
typedef struct
{
// ...
int err; // 8
int edramAddr; // 12
int neededMem; // 16
int unk20;
void *inBuf;
int unk28;
void *outBuf;
int unk36;
char unk40;
char unk41;
char unk42;
char unk43;
char unk44;
char unk45;
char unk46;
char unk47;
int unk48;
int unk52;
int unk56;
// ...
int unk72;
// ...
} SceAudiocodecCodec;
typedef struct
{
SceAudiocodecCodec codec __attribute__((aligned(256))); // size: 128

View File

@ -677,96 +677,94 @@ int sub_00001240(int codec, unsigned long *codec_buffer, int error)
}
//decode
int sceMeAudio_driver_9A9E21EE(u32 codec, unsigned long *codec_buffer){ //same -310C9CDA
unsigned long *cb17 = &codec_buffer[17];
unsigned long *cb16 = &codec_buffer[16];
void *memory = (void*)codec_buffer[3];
void *data = (void*)codec_buffer[6];
u32 samples = codec_buffer[8];
if (codec_buffer[0] > 0x05100601)
int sceMeAudio_driver_9A9E21EE(u32 codec, SceAudiocodecCodec *info) //same -310C9CDA
{
if (info->unk0 != 0x05100601)
return -2;
if (codec_buffer[3] == 0)
if (info->edramAddr == 0)
return 0x80000103;
codec_buffer[9] = 0;
codec_buffer[2] = 0;
sceKernelDcacheWritebackInvalidateRange(codec_buffer, 104);
info->unk36 = 0;
info->err = 0;
sceKernelDcacheWritebackInvalidateRange(info, 104);
int ret = 0;
if (codec < 0x1000 || codec >= 0x1006)
return -1;
int ret = 0;
switch (codec)
{
case 0x1000:
ret = sceMeCore_driver_FA398D71(96, codec_buffer);
case 0x1000: // AT3+
ret = sceMeCore_driver_FA398D71(96, info);
break;
case 0x1001:
ret = sceMeCore_driver_FA398D71(112, codec_buffer);
case 0x1001: // AT3
ret = sceMeCore_driver_FA398D71(112, info);
break;
case 0x1002:
ret = sceMeCore_driver_FA398D71(140, codec_buffer);
ret = sceMeCore_driver_FA398D71(140, info);
break;
case 0x1003:
ret = sceMeCore_driver_FA398D71(144, data, &codec_buffer[7], samples, &codec_buffer[9], memory);
ret = sceMeCore_driver_FA398D71(144, info->inBuf, &info->unk28, info->outBuf, &info->unk36, info->unk12);
break;
case 0x1005:
ret = sceMeCore_driver_FA398D71(229, data, codec_buffer[15], cb16, samples, &codec_buffer[9], cb17, memory);
ret = sceMeCore_driver_FA398D71(229, info->inBuf, info->unk60, &info->unk64, info->outBuf, &info->unk36, &info->unk68, info->unk12);
break;
default:
return -1;
break;
}
if (ret < 0){
return sub_00001240(codec, codec_buffer, ret);
}
if (ret < 0)
return sub_00001240(codec, info, ret);
return 0;
}
//check need memory
int sceMeAudio_driver_81956A0B(u32 codec, unsigned long *codec_buffer){
if (0x5100601 < codec_buffer[0]) return -2;
u32 codecIndex = codec - 0x1000;
if (codecIndex > 5) return -1;
int sceMeAudio_driver_81956A0B(u32 codec, SceAudiocodecCodec *info)
{
if (info->unk0 != 0x05100601)
return -2;
int ret = 0;
switch (codecIndex){
case 0://at3+
ret = sceMeCore_driver_635397BB(99, &codec_buffer[13], &codec_buffer[15], &codec_buffer[16], &codec_buffer[10]);
if (ret >= 0){
codec_buffer[2] = 0;
ret = sceMeCore_driver_635397BB(102, codec_buffer[15], &codec_buffer[4], &codec_buffer[2]);
if (ret == 0){
if (codec < 0x1000 || codec >= 0x1006)
return -1;
switch (codec)
{
case 0x1000: //at3+
ret = sceMeCore_driver_635397BB(99, &info->unk52, &info->unk60, &info->unk64, &info->unk40);
if (ret >= 0)
{
info->err = 0;
ret = sceMeCore_driver_635397BB(102, info->unk60, &info->neededMem, &info->err);
if (ret == 0)
return 0;
}
return -3;
}
break;
case 1://at3
ret = sceMeCore_driver_635397BB(114, 2, &codec_buffer[4], &codec_buffer[2]);
if (ret == 0){
return 0;
}
return -3;
break;
case 2://mp3
ret = sceMeCore_driver_635397BB(138, 2, &codec_buffer[4], &codec_buffer[2]);
if (ret == 0){
return 0;
}
return -3;
break;
case 3://aac
codec_buffer[4] = sceMeCore_driver_FA398D71(146);//=0x648c
codec_buffer[2] = 0;
return 0;
break;
case 4://not supported
return -1;
case 0x1001: //at3
ret = sceMeCore_driver_635397BB(114, 2, &info->neededMem, &info->err);
if (ret == 0)
return 0;
return -3;
break;
case 5://wma
codec_buffer[4] = sceMeCore_driver_FA398D71(226);
codec_buffer[2] = 0;
case 0x1002: //mp3
ret = sceMeCore_driver_635397BB(138, 2, &info->neededMem, &info->err);
if (ret == 0)
return 0;
return -3;
case 0x1003: //aac
info->neededMem = sceMeCore_driver_FA398D71(146);
info->err = 0;
return 0;
break;
case 0x1005: //wma
info->neededMem = sceMeCore_driver_FA398D71(226);
info->err = 0;
return 0;
default:
return -1;
}
return sub_00001240(codec, codec_buffer, ret);
return sub_00001240(codec, info, ret);
}
int unk[] = {//guessed, codec_buffer[10] should be 4 or 6, got 8744 from a snd0 file
0x00000000,
0x00000100,
@ -800,22 +798,26 @@ int unk[] = {//guessed, codec_buffer[10] should be 4 or 6, got 8744 from a snd0
0x000000C0,
0x00000002,
0x00000098};
//init
int sceMeAudio_driver_6AD33F60(u32 codec, unsigned long *codec_buffer){
if (0x05100601 < codec_buffer[0]) return -2;
u32 codecIndex = codec - 0x1000;
codec_buffer[2] = 0;
if (codecIndex > 5) return -1;
int sceMeAudio_driver_6AD33F60(u32 codec, SceAudiocodecInit *info)
{
if (info->unk0 != 0x05100601)
return -2;
info->err = 0;
if (codec < 0x1000 || codec >= 0x1006)
return -1;
int ret = 0;
switch (codecIndex){
case 0://at3+
ret = sceMeCore_driver_635397BB(99, &codec_buffer[13], &codec_buffer[15], &codec_buffer[16], &codec_buffer[10]);
switch (codec)
{
case 0x1000://at3+
ret = sceMeCore_driver_635397BB(99, &info->unk52, &info->unk60, &info->unk64, &info->unk40); // set options (sets unk52, unk60, unk64 with the help of unk40)
if (ret >= 0){
int val = codec_buffer[15];
int val = info->unk60; // check http://wiki.multimedia.cx/index.php?title=ATRAC3plus#Multichannel_ATRAC3plus_.28ATRAC-X.29 : it's probably this!
switch (val){
case 0:
default :
codec_buffer[2] = 514;
info->err = 514;
return -3;
break;
case 1:
@ -831,32 +833,31 @@ int sceMeAudio_driver_6AD33F60(u32 codec, unsigned long *codec_buffer){
val++;
break;
}
codec_buffer[18] = 2;
ret = sceMeCore_driver_635397BB(103, codec_buffer[13], codec_buffer[15], codec_buffer[16], 2, codec_buffer[3]);
info->unk72 = 2;
ret = sceMeCore_driver_635397BB(103, info->unk52, info->unk60, info->unk64, 2, info->edramAddr); // setup channels, probably
if (ret >= 0){
ret = sceMeCore_driver_635397BB(105, &codec_buffer[11], codec_buffer[3]);
ret = sceMeCore_driver_635397BB(105, &info->unk44, info->edramAddr); // probably sets unk44
if (ret >= 0){
ret = sceMeCore_driver_635397BB(100, &codec_buffer[17], codec_buffer[3]);
ret = sceMeCore_driver_635397BB(100, &info->unk68, info->edramAddr); // probably sets unk68
if (ret >= 0){
ret = sceMeCore_driver_FA398D71(104, codec_buffer[5], codec_buffer[3]);
ret = sceMeCore_driver_FA398D71(104, info->unk20, info->edramAddr); // check unk20 (where is it set???)
}
}
}
}
break;
case 1://at3
codec_buffer[11] = 44100;
codec_buffer[12] = unk[codec_buffer[10]*2+1];
ret = sceMeCore_driver_635397BB(115, unk[codec_buffer[10]*2], 44100, unk[codec_buffer[10]*2+1], codec_buffer[3]);
if ((codec_buffer[10]-14)<2){
codec_buffer[13] = 2;
}
case 0x1001://at3
*(int*)&info->unk44 = 44100;
info->unk48 = unk[*(int*)&info->unk40 * 2 + 1];
ret = sceMeCore_driver_635397BB(115, unk[*(int*)&info->unk40 * 2], 44100, unk[*(int*)&info->unk40 * 2 + 1], info->edramAddr);
if (*(int*)&info->unk40 >= 14 && *(int*)&info->unk40 < 16)
info->unk52 = 2;
break;
case 2://mp3
ret = sceMeCore_driver_635397BB(139, codec_buffer[3]);
case 0x1002://mp3
ret = sceMeCore_driver_635397BB(139, info->unk12);
break;
case 3://aac
switch (codec_buffer[10]){
case 0x1003://aac
switch (*(int*)&info->unk40){
case 96000:
case 88200:
case 64000:
@ -868,21 +869,17 @@ int sceMeAudio_driver_6AD33F60(u32 codec, unsigned long *codec_buffer){
case 16000:
case 11050:
case 8000:
ret = sceMeCore_driver_635397BB(147, codec_buffer[10], codec_buffer[3]);
if (ret >= 0){
if (((short*)codec_buffer)[22] != 0){
ret = sceMeCore_driver_635397BB(149, ((u8*)codec_buffer)[44], codec_buffer[3]);
if (ret >= 0){
if (((char*)codec_buffer)[45] != 0){
ret = sceMeCore_driver_635397BB(151, 0, 2, 0, codec_buffer[3]);
}
}
}
else{
if (((char*)codec_buffer)[45] != 0){
ret = sceMeCore_driver_635397BB(151, 0, 2, 0, codec_buffer[3]);
}
ret = sceMeCore_driver_635397BB(147, *(int*)&info->unk40, info->edramAddr);
if (ret >= 0)
{
if (*(short*)&info->unk44 != 0)
{
ret = sceMeCore_driver_635397BB(149, info->unk44, info->edramAddr);
if (ret >= 0 && info->unk45 != 0)
ret = sceMeCore_driver_635397BB(151, 0, 2, 0, info->edramAddr);
}
else if (info->unk45 != 0)
ret = sceMeCore_driver_635397BB(151, 0, 2, 0, info->edramAddr);
}
break;
default:
@ -890,16 +887,15 @@ int sceMeAudio_driver_6AD33F60(u32 codec, unsigned long *codec_buffer){
break;
}
break;
case 4://not used
case 0x1004://not used
return -1;
break;
case 5://wma
ret = sceMeCore_driver_635397BB(227, &codec_buffer[10], codec_buffer[3]);
case 0x1005://wma
ret = sceMeCore_driver_635397BB(227, &info->unk40, info->edramAddr);
break;
}
if (ret < 0){
return sub_00001240(codec, codec_buffer, ret);
}
if (ret < 0)
return sub_00001240(codec, info, ret);
return ret;
}
//probably for umd(only at3/+)

View File

@ -2,15 +2,7 @@
#include "../global.h"
#define CTYPE_DOWNCASE_LETTER 0x01
#define CTYPE_UPCASE_LETTER 0x02
#define CTYPE_CIPHER 0x04
#define CTYPE_TRANSPARENT 0x08
#define CTYPE_PUNCTUATION 0x10
#define CTYPE_CTRL 0x20
#define CTYPE_HEX_CIPHER 0x40
#define CTYPE_LETTER (CTYPE_DOWNCASE_LETTER | CTYPE_UPCASE_LETTER)
#include "sysclib.h"
char g_ctypeTbl[] =
{
@ -145,8 +137,6 @@ char g_ctypeTbl[] =
CTYPE_CTRL
};
typedef void (*prnt_callback)(void *ctx, int ch);
int bcmp(void *s1, void *s2, int n)
{
return memcmp(s1, s2, n);
@ -944,7 +934,7 @@ char *strcat(char *dst, const char *src)
return dst;
}
char *strchr(char *s, char c)
char *strchr(const char *s, char c)
{
if (s == NULL)
return NULL;
@ -1155,6 +1145,30 @@ int strncmp(const char *s1, const char *s2, int n)
return -1;
}
char *strncpy(char *dest, const char *src, int n)
{
char *curDst = dest;
if (dest == NULL || src == NULL)
return 0;
int i;
// E92C
for (i = 0; i < n; i++)
{
char c = *(src++);
*(curDst++) = c;
if (c == '\0')
{
// E958, E968
while ((++i) < n)
*(curDst++) = '\0';
// E97C
break;
}
}
// E94C
return dest;
}
u32 strnlen(const char *s, int maxlen)
{
int len = 0;

48
src/sysmem/sysclib.h Normal file
View File

@ -0,0 +1,48 @@
#include <stdarg.h>
#define CTYPE_DOWNCASE_LETTER 0x01
#define CTYPE_UPCASE_LETTER 0x02
#define CTYPE_CIPHER 0x04
#define CTYPE_TRANSPARENT 0x08
#define CTYPE_PUNCTUATION 0x10
#define CTYPE_CTRL 0x20
#define CTYPE_HEX_CIPHER 0x40
#define CTYPE_LETTER (CTYPE_DOWNCASE_LETTER | CTYPE_UPCASE_LETTER)
typedef void (*prnt_callback)(void *ctx, int ch);
int bcmp(void *s1, void *s2, int n);
int bcopy(void *src, void *dst, int n);
int bzero(void *s, int n);
int toupper(int c);
int tolower(int c);
int look_ctype_table(int c);
char *index(char *s, int c);
u64 __udivmoddi4(u64 arg01, u64 arg23, u64 *v);
u64 __udivdi3(u64 arg01, u64 arg23);
u64 __umoddi3(u64 arg01, u64 arg23);
const void *memchr(const void *s, int c, int n);
int memcmp(const void *s1, const void *s2, int n);
void *sceKernelMemcpy(void *dst, const void *src, u32 n);
void *memcpy(void *dst, const void *src, u32 n);
void *memmove(void *dst, const void *src, int n);
int prnt(prnt_callback cb, void *ctx, const char *fmt, va_list args);
int sprintf(char *str, const char *format, ...);
int snprintf(char *str, u32 size, const char *format, ...);
void sprintf_char(int *ctx, int c);
void snprintf_char(int *ctx, int c);
char *strcat(char *dst, const char *src);
char *strchr(const char *s, char c);
int strcmp(const char *s1, const char *s2);
char *strcpy(char *dest, const char *src);
int strtol(const char *nptr, char **endptr, int base);
u32 strtoul(char *nptr, char **endptr, int base);
int strncmp(const char *s1, const char *s2, int n);
char *strncpy(char *dest, const char *src, int n);
u32 strnlen(const char *s, int maxlen);
u32 strlen(const char *s);
char *strrchr(char *s, int c);
char *strpbrk(char *s, const char *accept);
char *strstr(char *haystack, const char *needle);

View File

@ -1,17 +1,5 @@
#include "../global.h"
typedef struct SceSysEventHandler
{
int size;
char* name;
int type_mask;
int (*handler)(int ev_id, char* ev_name, void* param, int* result);
int gp;
int busy;
struct SceSysEventHandler *next;
int reserved[9];
} SceSysEventHandler;
// 140F0
SceSysEventHandler *g_sysEvHandlers;

19
src/sysmem/sysmem.h Normal file
View File

@ -0,0 +1,19 @@
typedef struct SceSysEventHandler
{
int size;
char* name;
int type_mask;
int (*handler)(int ev_id, char* ev_name, void* param, int* result);
int gp;
int busy;
struct SceSysEventHandler *next;
int reserved[9];
} SceSysEventHandler;
int sceKernelUnregisterSysEventHandler(SceSysEventHandler *handler);
int sceKernelSysEventDispatch(int ev_type_mask, int ev_id, char* ev_name, void* param, int* result, int break_nonzero, SceSysEventHandler **break_handler);
int sceKernelSysEventInit(void);
int sceKernelIsRegisterSysEventHandler(SceSysEventHandler* handler);
int sceKernelRegisterSysEventHandler(SceSysEventHandler* handler);
SceSysEventHandler *sceKernelReferSysEventHandler(void);

View File

@ -11,7 +11,7 @@ all: $(TARGET)
$(TARGET): $(OBJECTS)
@echo "Creating binary $(TARGET)"
@$(CPP) $(OBJECTS) -o $@ $(LDFLAGS)
$(CPP) $(OBJECTS) -o $@ $(LDFLAGS)
%.o: %.cpp
@echo "Compiling $^"

View File

@ -333,8 +333,8 @@ void showInstr(std::string line, std::string &dataRef)
int main(int argc, char *argv[])
{
if (argc < 3) {
std::cout << "Usage: " << argv[0] << " FILENAME ENDADDR" << std::endl;
if (argc < 2) {
std::cout << "Usage: " << argv[0] << " FILENAME [ENDADDR]" << std::endl;
return 1;
}
std::ifstream f(argv[1]);
@ -342,7 +342,7 @@ int main(int argc, char *argv[])
std::cout << "Couldn't open file!" << std::endl;
return 1;
}
std::string addr(argv[2]);
std::string addr(argc >= 3 ? argv[2] : "");
std::string line;
std::string dataRef("");
bool inText = false;
@ -356,7 +356,7 @@ int main(int argc, char *argv[])
std::string jumpDest;
while (getline(f, line) && !stop)
{
if (line.find(addr) != std::string::npos)
if (addr != "" && line.find(addr) != std::string::npos)
stop = true;
if (!inText && line.find("Section .text") != std::string::npos)
@ -371,7 +371,7 @@ int main(int argc, char *argv[])
std::cout << "}" << std::endl << std::endl;
std::string func = line.substr(13);
func = func.substr(0, func.find_first_of(' '));
std::cout << func << "(...)" << std::endl;
std::cout << func << "(...) // at " << line.substr(line.find("Address ") + 8) << std::endl;
std::cout << "{" << std::endl;
firstFunc = false;
}

View File

@ -276,7 +276,7 @@ int parse_string(char *line, char **params, int max_params)
param_start = pos;
/* Scan parameters */
while((isalnum(line[pos])) || (line[pos] == '_') || (line[pos] == ','))
while((isalnum(line[pos])) || (line[pos] == '_') || (line[pos] == ',') || (line[pos] == '.'))
{
pos++;
}
@ -325,7 +325,7 @@ void build_exports_output_extern(struct psp_export *pHead)
pExp = pHead;
while(pExp != NULL)
{
fprintf(stdout, "extern void %s;\n", pExp->name);
fprintf(stdout, "extern int %s;\n", pExp->name);
pExp = pExp->pNext;
}
}

View File

@ -673,7 +673,7 @@ void output_ph(unsigned char *data)
dataSize = get_sh(".data")->iSize;
}
else {
dataAddr = g_relocbase;
dataAddr = g_relocbase - g_allocbase;
dataSize = 0;
}
SW(&phdr->p_type, 1);