diff --git a/include/lowio_gpio.h b/include/lowio_gpio.h new file mode 100644 index 0000000..683b097 --- /dev/null +++ b/include/lowio_gpio.h @@ -0,0 +1,9 @@ +/* Copyright (C) 2011, 2012 The uOFW team + See the file COPYING for copying permission. +*/ + +int sceGpioPortSet(int); +int sceGpioPortClear(int); +int sceGpioSetPortMode(int, int); +int sceGpioDisableTimerCapture(int, int); + diff --git a/include/lowio_i2c.h b/include/lowio_i2c.h new file mode 100644 index 0000000..f30885f --- /dev/null +++ b/include/lowio_i2c.h @@ -0,0 +1,6 @@ +/* Copyright (C) 2011, 2012 The uOFW team + See the file COPYING for copying permission. +*/ + +int sceI2cMasterTransmit(int reg, void *buf, int bufSize); + diff --git a/include/lowio_sysreg.h b/include/lowio_sysreg.h index f195827..f25f6d3 100644 --- a/include/lowio_sysreg.h +++ b/include/lowio_sysreg.h @@ -47,6 +47,8 @@ int sceSysregAudioClkSelect(int, int); int sceSysregAudioBusClockEnable(int); int sceSysregAudioIoEnable(int); int sceSysregAudioIoDisable(int); +int sceSysregAudioClkoutClkEnable(void); +int sceSysregAudioClkoutClkDisable(void); int sceSysregAudioClkoutClkSelect(int); int sceSysregAudioClkoutIoEnable(void); int sceSysregAudioClkoutIoDisable(void); diff --git a/include/threadman_kernel.h b/include/threadman_kernel.h index a4c2600..5dfd714 100644 --- a/include/threadman_kernel.h +++ b/include/threadman_kernel.h @@ -56,6 +56,7 @@ int sceKernelCreateMutex(char *, int, int, int); int sceKernelTryLockMutex(int, int); int sceKernelLockMutex(int, int, int); int sceKernelUnlockMutex(int, int); +int sceKernelDeleteMutex(int); /* Event flags */ diff --git a/lib/build.mak b/lib/build.mak index 46af939..707a7ee 100644 --- a/lib/build.mak +++ b/lib/build.mak @@ -16,7 +16,7 @@ EXPORT_OBJ=$(patsubst %.exp,%.o,$(PRX_EXPORTS)) ifdef DEBUG CFLAGS += -DDEBUG -LIBS := -ldebug -lpspdebug $(LIBS) -lSysclibForKernel -lsceDisplay -lsceGe_user -lIoFileMgrForUser -lsceSyscon_driver +LIBS := -ldebug -lpspdebug $(LIBS) -lSysclibForKernel -lsceDisplay -lsceGe_user -lIoFileMgrForKernel -lsceSyscon_driver endif MODULE_STUBS=$(foreach mod,$(MODULES), $($(mod)_STUBS)) diff --git a/lib/libsceDdr_driver.a b/lib/libsceDdr_driver.a index fc8b51d..eb0a1a4 100644 Binary files a/lib/libsceDdr_driver.a and b/lib/libsceDdr_driver.a differ diff --git a/lib/libsceDmac.a b/lib/libsceDmac.a index d7d6966..528efc2 100644 Binary files a/lib/libsceDmac.a and b/lib/libsceDmac.a differ diff --git a/lib/libsceDmacplus_driver.a b/lib/libsceDmacplus_driver.a index 13896d9..b7c1529 100644 Binary files a/lib/libsceDmacplus_driver.a and b/lib/libsceDmacplus_driver.a differ diff --git a/lib/libsceGpio_driver.a b/lib/libsceGpio_driver.a index 5906313..d5aba62 100644 Binary files a/lib/libsceGpio_driver.a and b/lib/libsceGpio_driver.a differ diff --git a/lib/libsceI2c_driver.a b/lib/libsceI2c_driver.a index cae443d..5777b48 100644 Binary files a/lib/libsceI2c_driver.a and b/lib/libsceI2c_driver.a differ diff --git a/lib/libsceLcdc_driver.a b/lib/libsceLcdc_driver.a index d382c03..812d2af 100644 Binary files a/lib/libsceLcdc_driver.a and b/lib/libsceLcdc_driver.a differ diff --git a/lib/libsceNand_driver.a b/lib/libsceNand_driver.a index 35d2b81..cfa8674 100644 Binary files a/lib/libsceNand_driver.a and b/lib/libsceNand_driver.a differ diff --git a/lib/libscePwm_driver.a b/lib/libscePwm_driver.a index a266171..4dc7752 100644 Binary files a/lib/libscePwm_driver.a and b/lib/libscePwm_driver.a differ diff --git a/lib/libsceSysreg_driver.a b/lib/libsceSysreg_driver.a index 4abebff..f436b4c 100644 Binary files a/lib/libsceSysreg_driver.a and b/lib/libsceSysreg_driver.a differ diff --git a/src/audio/audio.c b/src/audio/audio.c index 1efa089..53dcbeb 100644 --- a/src/audio/audio.c +++ b/src/audio/audio.c @@ -855,7 +855,7 @@ int sceAudioInit() { //dbg_init(1, FB_AFTER_DISPLAY, FAT_AFTER_FATMS); //dbg_init(1, FB_NONE, FAT_AFTER_FATMS); - dbg_init(1, FB_NONE, FAT_HARDWARE); + dbg_init(1, FB_NONE, FAT_AFTER_FATMS); dbg_printf("Running %s\n", __FUNCTION__); memset(&g_audio, 0, sizeof(g_audio)); // 1558 diff --git a/src/codec/Makefile b/src/codec/Makefile index b84f5f3..0d7f765 100644 --- a/src/codec/Makefile +++ b/src/codec/Makefile @@ -4,5 +4,7 @@ TARGET = codec OBJS = codec.o +LIBS = -lThreadManForKernel -lsceSysEventForKernel -lsceI2c_driver -lsceSysreg_driver -lsceGpio_driver + include ../../lib/build.mak diff --git a/src/codec/codec.c b/src/codec/codec.c index fbcc0ce..510cf3c 100644 --- a/src/codec/codec.c +++ b/src/codec/codec.c @@ -1,6 +1,11 @@ #include "common.h" +#include "codec.h" +#include "lowio_gpio.h" +#include "lowio_i2c.h" +#include "lowio_sysreg.h" #include "sysmem_sysevent.h" +#include "threadman_kernel.h" typedef struct { @@ -66,6 +71,8 @@ SceSysEventHandler g_sysEv = { }; PSP_MODULE_INFO("sceWM8750_Driver", PSP_MODULE_NO_STOP | PSP_MODULE_SINGLE_LOAD | PSP_MODULE_SINGLE_START | PSP_MODULE_KERNEL, 1, 7); +PSP_MODULE_BOOTSTART("sceCodecInitEntry"); +PSP_MODULE_REBOOT_BEFORE("sceCodecStopEntry"); PSP_SDK_VERSION(0x06060010); int sub_0000(int reg, int set) @@ -466,8 +473,10 @@ void sceCodec_driver_376399B6(int enable) sceSysregAudioClkoutClkEnable(); } -int module_start() +int sceCodecInitEntry() { + for (;;) + ; sub_0110(); sub_0150(1); g_codec.mutexId = sceKernelCreateMutex("SceCodec", 1, 0, 0); @@ -496,7 +505,7 @@ int sceCodec_driver_FC355DE0() return 0; } -int module_reboot_before() +int sceCodecStopEntry() { sub_01FC(-1, -1, -1, -1); sceKernelUnregisterSysEventHandler(&g_sysEv); diff --git a/src/codec/exports.exp b/src/codec/exports.exp index e2b148f..3ebc0a8 100644 --- a/src/codec/exports.exp +++ b/src/codec/exports.exp @@ -5,7 +5,7 @@ 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_NID(syslib_11B97506, 0x11B97506) +PSP_EXPORT_VAR_HASH(module_sdk_version) PSP_EXPORT_END PSP_EXPORT_START(sceCodec_driver, 0x0011, 0x0001) @@ -22,7 +22,7 @@ PSP_EXPORT_FUNC_HASH(sceCodecInitEntry) PSP_EXPORT_FUNC_NID(sceCodecSetVolumeOffset, 0xD27707A8) PSP_EXPORT_FUNC_NID(sceCodecSelectVolumeTable, 0xE4456BC3) PSP_EXPORT_FUNC_NID(sceCodec_driver_E61A4623, 0xE61A4623) -PSP_EXPORT_FUNC_NID(sceCodec_driver_EACF7284, 0xEACF7284) +PSP_EXPORT_FUNC_NID(sceCodecSetSpeakerVolume, 0xEACF7284) PSP_EXPORT_FUNC_NID(sceCodec_driver_FC355DE0, 0xFC355DE0) PSP_EXPORT_FUNC_NID(sceCodec_driver_FCA6D35B, 0xFCA6D35B) PSP_EXPORT_END diff --git a/src/ctrl/ctrl.c b/src/ctrl/ctrl.c index d15b3d5..a083a01 100644 --- a/src/ctrl/ctrl.c +++ b/src/ctrl/ctrl.c @@ -1214,17 +1214,17 @@ static int _sceCtrlVblankIntr(int subIntNm __attribute__((unused)), void *arg __ int suspendFlag; int retVal; - dbg_printf("In function: %s\n", __FUNCTION__); + //dbg_printf("In function: %s\n", __FUNCTION__); suspendFlag = sceKernelCpuSuspendIntr(); //0x00000454 if (ctrl.btnCycle == 0) { //0x00000464 - dbg_printf("sysconHwDataTransferBusy VALUE: %d in function: %s\n", ctrl.sysconHwDataTransferBusy, __FUNCTION__); + //dbg_printf("sysconHwDataTransferBusy VALUE: %d in function: %s\n", ctrl.sysconHwDataTransferBusy, __FUNCTION__); if (ctrl.sysconHwDataTransferBusy == FALSE) { //0x00000470 if (ctrl.pollMode != PSP_CTRL_POLL_NO_POLLING) { //0x0000047C ctrl.sysconHwDataTransferBusy = TRUE; //0x000004E0 - dbg_printf("receiving SYSCON data: %s\n", __FUNCTION__); + //dbg_printf("receiving SYSCON data: %s\n", __FUNCTION__); if ((ctrl.samplingMode[USER_MODE] | ctrl.samplingMode[KERNEL_MODE]) == PSP_CTRL_INPUT_DIGITAL_ONLY) { //0x000004E4 ctrl.sysPacket[0].tx_cmd = SYSCON_CTRL_TRANSFER_DATA_DIGITAL_ONLY; //0x000004E8 } @@ -1233,35 +1233,35 @@ static int _sceCtrlVblankIntr(int subIntNm __attribute__((unused)), void *arg __ } ctrl.sysPacket[0].tx_len = 2; //0x00000514 - dbg_printf("calling sceSysconCmdExecAsync: %s\n", __FUNCTION__); + //dbg_printf("calling sceSysconCmdExecAsync: %s\n", __FUNCTION__); retVal = sceSysconCmdExecAsync(&ctrl.sysPacket[0], 1, _sceCtrlSysconCmdIntr1, 0); //0x00000510 - dbg_printf("called sceSysconCmdExecAsync returns: 0x%08X in function: %s\n", retVal, __FUNCTION__); + //dbg_printf("called sceSysconCmdExecAsync returns: 0x%08X in function: %s\n", retVal, __FUNCTION__); if (retVal < 0) { //0x00000518 ctrl.sysconHwDataTransferBusy = FALSE; //0x0000051C } } else { - dbg_printf("set alarm handler_1: %s\n", __FUNCTION__); + //dbg_printf("set alarm handler_1: %s\n", __FUNCTION__); //register an alarm occurring every 700 micro seconds sceKernelSetAlarm(700, _sceCtrlDummyAlarm, NULL); //0x00000490 } } else { - dbg_printf("set alarm handler_2: %s\n", __FUNCTION__); + //dbg_printf("set alarm handler_2: %s\n", __FUNCTION__); sceKernelSetAlarm(700, _sceCtrlDummyAlarm, NULL); //0x00000490 } } if (ctrl.unk_Byte_2 != 0) { //0x000004A0 - dbg_printf("calling sceKernelPowerTick: %s\n", __FUNCTION__); + //dbg_printf("calling sceKernelPowerTick: %s\n", __FUNCTION__); ctrl.unk_Byte_2 = 0; //0x000004A4 sceKernelPowerTick(SCE_KERNEL_POWER_TICK_DEFAULT); //0x000004CC } - dbg_printf("resuming all interrupts: %s\n", __FUNCTION__); + //dbg_printf("resuming all interrupts: %s\n", __FUNCTION__); sceKernelCpuResumeIntr(suspendFlag); //0x000004A8 - dbg_printf("returning from %s.\n", __FUNCTION__); + //dbg_printf("returning from %s.\n", __FUNCTION__); return -1; } @@ -1964,6 +1964,7 @@ static int _sceCtrlReadBuf(SceCtrlDataExt *pad, u8 reqBufReads, int arg3, u8 mod return SCE_ERROR_NOT_SUPPORTED; } oldK1 = pspShiftK1(); + dbg_printf("%d\n", __LINE__); if (!pspK1PtrOk(pad)) { //0x00001EF0 -- protect kernel address from user mode pspSetK1(oldK1); @@ -1980,9 +1981,12 @@ static int _sceCtrlReadBuf(SceCtrlDataExt *pad, u8 reqBufReads, int arg3, u8 mod return SCE_ERROR_NOT_SUPPORTED; } } + dbg_printf("%d\n", __LINE__); //waiting for the VSYNC callback when using the "read" functions. if (mode & 2) { //0x00001F10 && 0x00001F28 + dbg_printf("%d\n", __LINE__); res = sceKernelWaitEventFlag(ctrl.eventFlag, 1, SCE_EVENT_WAITOR, NULL, NULL); //0x00001F44 + dbg_printf("%d\n", __LINE__); if (res < 0) { //0x00001F4C pspSetK1(oldK1); //0x00001F50 return res; @@ -1992,30 +1996,37 @@ static int _sceCtrlReadBuf(SceCtrlDataExt *pad, u8 reqBufReads, int arg3, u8 mod /* Clear the event flag to wait for the VBlank interrupt the next call. */ sceKernelClearEventFlag(ctrl.eventFlag, 0xFFFFFFFE); //0x00001F64 + dbg_printf("%d\n", __LINE__); startBufIndex = intDataPtr->ctrlBufStartIndex; //0x00001F70 readIntBufs = intDataPtr->ctrlBufIndex - startBufIndex; //0x00001F74 if (readIntBufs < 0) { //0x00001F7C readIntBufs += 64; //0x00001F78 & 0x00001F80 } + dbg_printf("%d\n", __LINE__); intDataPtr->ctrlBufStartIndex = intDataPtr->ctrlBufIndex; //0x00001F8C if (reqBufReads < readIntBufs) { //0x00001F88 + dbg_printf("%d\n", __LINE__); startBufIndex = intDataPtr->ctrlBufIndex - reqBufReads; //0x00001F90 startBufIndex = (startBufIndex < 0) ? startBufIndex + CTRL_INTERNAL_CONTROLLER_BUFFERS : startBufIndex; //0x00001F98 & 0x00001F9C readIntBufs = reqBufReads; } } else { + dbg_printf("%d\n", __LINE__); suspendFlag = sceKernelCpuSuspendIntr(); //0x0000216C bufIndex = intDataPtr->ctrlBufIndex; //0x00002174 startBufIndex = bufIndex; //0x00002184 + dbg_printf("%d\n", __LINE__); if (reqBufReads < 64) { //0x00002178 + dbg_printf("%d\n", __LINE__); startBufIndex = bufIndex - reqBufReads; //0x0000218C startBufIndex = (startBufIndex < 0) ? startBufIndex + CTRL_INTERNAL_CONTROLLER_BUFFERS : startBufIndex; //0x00001F98 & 0x00001F9C readIntBufs = reqBufReads; //0x00001FA0 } } + dbg_printf("%d\n", __LINE__); if (arg3 != 0) { //0x00001FA4 ctrlBuf = (SceCtrlDataExt *)intDataPtr->sceCtrlBuf[arg3] + startBufIndex; //0x00002160 } @@ -2027,6 +2038,7 @@ static int _sceCtrlReadBuf(SceCtrlDataExt *pad, u8 reqBufReads, int arg3, u8 mod pspSetK1(oldK1); //0x000020B0 return readIntBufs; } + dbg_printf("%d\n", __LINE__); /* read internal data buffers. */ while (reqBufReads-- > 0) { //0x0000209C & 0x000020A0 pad->activeTime = ctrlBuf->activeTime; //0x00001FE4 & 0x00001FF0 @@ -2099,6 +2111,7 @@ static int _sceCtrlReadBuf(SceCtrlDataExt *pad, u8 reqBufReads, int arg3, u8 mod } } } + dbg_printf("%d\n", __LINE__); sceKernelCpuResumeIntr(suspendFlag); //0x000020A8 pspSetK1(oldK1); //0x000020B0 @@ -2110,11 +2123,11 @@ static int _sceCtrlReadBuf(SceCtrlDataExt *pad, u8 reqBufReads, int arg3, u8 mod * Exported in syslib */ int CtrlInit(void) { - dbg_init(1, FB_NONE, FAT_AFTER_SYSCON); + dbg_init(1, FB_AFTER_DISPLAY, FAT_NONE); dbg_printf("Ctrl_Start: %s\n", __FUNCTION__); - sceCtrlInit(); + //sceCtrlInit(); return SCE_ERROR_OK; } diff --git a/src/ctrl/ctrl_custom_VB_handler.c b/src/ctrl/ctrl_custom_VB_handler.c index 4c88781..bf0939b 100644 --- a/src/ctrl/ctrl_custom_VB_handler.c +++ b/src/ctrl/ctrl_custom_VB_handler.c @@ -2121,7 +2121,7 @@ static int _sceCtrlReadBuf(SceCtrlDataExt *pad, u8 reqBufReads, int arg3, u8 mod * Exported in syslib */ int CtrlInit(void) { - dbg_init(1, FB_NONE, FAT_AFTER_SYSCON); + dbg_init(1, FB_AFTER_DISPLAY, FAT_NONE); dbg_printf("Ctrl_Start: %s\n", __FUNCTION__); diff --git a/src/iofilemgr/iofilemgr.c b/src/iofilemgr/iofilemgr.c index 2e4330e..1bc9fba 100644 --- a/src/iofilemgr/iofilemgr.c +++ b/src/iofilemgr/iofilemgr.c @@ -727,6 +727,19 @@ int sceIoDevctl(const char *dev, unsigned int cmd, void *indata, int inlen, void int sceIoAssign(const char *dev, const char *blockDev, const char *fs, int mode, void* unk1, int unk2) { + int oldIntr; + asm("mfic %0, $0" : "=r" (oldIntr)); + asm("mtic $zero, $0"); + asm("nop"); + asm("nop"); + asm("nop"); + asm("nop"); + asm("nop"); + asm("nop"); + asm("nop"); + asm("nop"); + asm("nop"); + asm("nop"); dbg_printf("Calling %s\n", __FUNCTION__); dbg_printf("Calling %s\n", __FUNCTION__); dbg_printf("Calling %s\n", __FUNCTION__); @@ -739,6 +752,7 @@ int sceIoAssign(const char *dev, const char *blockDev, const char *fs, int mode, dbg_printf("Calling %s\n", __FUNCTION__); dbg_printf("Calling %s\n", __FUNCTION__); dbg_printf("Calling %s\n", __FUNCTION__); + asm("mtic %0, $0" : : "r" (oldIntr)); return 0; char outDev[32]; char blkAliasName[32];