2021-10-31 16:35:33 +01:00
|
|
|
#include <wums.h>
|
|
|
|
#include <coreinit/ios.h>
|
|
|
|
#include <coreinit/debug.h>
|
|
|
|
#include <coreinit/cache.h>
|
|
|
|
#include <kernel/kernel.h>
|
|
|
|
#include <whb/log_udp.h>
|
|
|
|
#include "kernel.h"
|
|
|
|
|
|
|
|
WUMS_MODULE_EXPORT_NAME("homebrew_usbseriallogging");
|
2022-01-26 14:20:14 +01:00
|
|
|
WUMS_MODULE_SKIP_INIT_FINI();
|
2021-10-31 16:35:33 +01:00
|
|
|
|
|
|
|
extern "C" void SC_0x51();
|
|
|
|
|
2021-12-07 20:57:22 +01:00
|
|
|
WUMS_INITIALIZE() {
|
2021-10-31 16:35:33 +01:00
|
|
|
WHBLogUdpInit();
|
|
|
|
|
|
|
|
// Start syslogging on iosu side
|
|
|
|
int mcpFd = IOS_Open("/dev/mcp", (IOSOpenMode) 0);
|
|
|
|
if (mcpFd >= 0) {
|
|
|
|
int in = 0xFA; // IPC_CUSTOM_START_USB_LOGGING
|
|
|
|
int out = 0;
|
|
|
|
IOS_Ioctl(mcpFd, 100, &in, sizeof(in), &out, sizeof(out));
|
|
|
|
IOS_Close(mcpFd);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Patch loader.elf to spit out less warnings when loading .rpx built with wut
|
|
|
|
KernelNOPAtPhysicalAddress(0x0100b770 - 0x01000000 + 0x32000000);
|
|
|
|
KernelNOPAtPhysicalAddress(0x0100b800 - 0x01000000 + 0x32000000);
|
|
|
|
KernelNOPAtPhysicalAddress(0x0100b7b8 - 0x01000000 + 0x32000000);
|
|
|
|
ICInvalidateRange(reinterpret_cast<void *>(0x0100b770), 0x04);
|
|
|
|
ICInvalidateRange(reinterpret_cast<void *>(0x0100b800), 0x04);
|
|
|
|
ICInvalidateRange(reinterpret_cast<void *>(0x0100b7b8), 0x04);
|
|
|
|
|
|
|
|
KernelPatchSyscall(0x51, (uint32_t) &IopShellInitInternal);
|
|
|
|
|
|
|
|
// Start iopshell on kernel
|
|
|
|
SC_0x51();
|
|
|
|
}
|
|
|
|
|
|
|
|
#define IopShell_UserCallback (0x101C400 + 0x1926c)
|
|
|
|
#define IopShell_RegisterCallback ((void (*)( uint32_t,uint32_t,uint32_t,uint32_t))(0x101C400 + 0x19638))
|
|
|
|
#define IopShell_CreateThread ((void (*)( void))(0x101C400 + 0x19504))
|
|
|
|
|
|
|
|
WUMS_APPLICATION_STARTS(){
|
|
|
|
IopShell_RegisterCallback(IopShell_UserCallback, 0x100978f8, 0x10097900, 0x10097c40);
|
|
|
|
IopShell_CreateThread();
|
|
|
|
}
|
|
|
|
|