mirror of
https://github.com/wiiu-env/wut.git
synced 2024-12-05 03:04:16 +01:00
Build libraries with -Wall and -Werror.
This commit is contained in:
parent
069e28acec
commit
857fcd8eea
@ -7,6 +7,7 @@ set(CMAKE_TOOLCHAIN_FILE $ENV{WUT_ROOT}/share/wut.toolchain.cmake)
|
||||
|
||||
project(libraries C)
|
||||
|
||||
add_definitions(-Wall -Werror)
|
||||
add_subdirectory(libgfd)
|
||||
add_subdirectory(libwhb)
|
||||
add_subdirectory(nn_swkbd)
|
||||
|
@ -12,14 +12,25 @@ static uint32_t _GFDCleanTag(uint32_t tag);
|
||||
static BOOL _GFDCheckTagDAT(uint32_t tag);
|
||||
static BOOL _GFDCheckTagSTR(uint32_t tag);
|
||||
static BOOL _GFDRelocateBlock(const GFDBlockHeader *blockHeader, void *dst);
|
||||
static BOOL _GFDRelocateBlockEx(const GFDRelocationHeader *relocationHeader, const uint32_t *patchTable, uint8_t *dst);
|
||||
static uint32_t _GFDGetBlockDataSize(GFDBlockType type, uint32_t index, const void *file);
|
||||
static BOOL _GFDRelocateBlockEx(const GFDRelocationHeader *relocationHeader,
|
||||
const uint32_t *patchTable, uint8_t *dst);
|
||||
static uint32_t _GFDGetBlockDataSize(GFDBlockType type, uint32_t index,
|
||||
const void *file);
|
||||
static uint32_t _GFDGetBlockCount(GFDBlockType type, const void *file);
|
||||
static BOOL _GFDCheckBlockHeaderMagicVersions(const GFDBlockHeader *header);
|
||||
static BOOL _GFDCheckHeaderVersions(const void *file);
|
||||
static BOOL _GFDGetHeaderVersions(uint32_t *majorVersion, uint32_t *minorVersion, uint32_t *gpuVersion, const void *file);
|
||||
static BOOL _GFDGetBlockPointer(GFDBlockType type, uint32_t index, void *file, GFDBlockHeader **blockHeaderOut, void **blockDataOut);
|
||||
static BOOL _GFDGetBlockPointerConst(GFDBlockType type, uint32_t index, const void *file, const GFDBlockHeader **blockHeaderOut, const void **blockDataOut);
|
||||
static BOOL _GFDGetHeaderVersions(uint32_t *majorVersion,
|
||||
uint32_t *minorVersion, uint32_t *gpuVersion,
|
||||
const void *file);
|
||||
static BOOL _GFDGetBlockPointerConst(GFDBlockType type, uint32_t index,
|
||||
const void *file,
|
||||
const GFDBlockHeader **blockHeaderOut,
|
||||
const void **blockDataOut);
|
||||
#if 0 // Currently unused
|
||||
static BOOL _GFDGetBlockPointer(GFDBlockType type, uint32_t index, void *file,
|
||||
GFDBlockHeader **blockHeaderOut,
|
||||
void **blockDataOut);
|
||||
#endif
|
||||
|
||||
static char
|
||||
sLastError[1024] = { 0 };
|
||||
@ -51,7 +62,8 @@ _GFDGetHeaderVersions(uint32_t *majorVersion,
|
||||
*gpuVersion = 0;
|
||||
|
||||
if (header->magic != GFD_HEADER_MAGIC) {
|
||||
setLastError("%s: header->magic %08X != %08X GFD_HEADER_MAGIC", __FUNCTION__, header->magic, GFD_HEADER_MAGIC);
|
||||
setLastError("%s: header->magic %08X != %08X GFD_HEADER_MAGIC",
|
||||
__FUNCTION__, header->magic, GFD_HEADER_MAGIC);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -71,18 +83,21 @@ _GFDCheckHeaderVersions(const void *file)
|
||||
}
|
||||
|
||||
if (majorVersion != GFD_FILE_VERSION_MAJOR) {
|
||||
setLastError("%s: majorVersion %d != %d GFD_FILE_VERSION_MAJOR", __FUNCTION__, majorVersion, GFD_FILE_VERSION_MAJOR);
|
||||
setLastError("%s: majorVersion %d != %d GFD_FILE_VERSION_MAJOR",
|
||||
__FUNCTION__, majorVersion, GFD_FILE_VERSION_MAJOR);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (minorVersion != GFD_FILE_VERSION_MINOR) {
|
||||
setLastError("%s: minorVersion %d != %d GFD_FILE_VERSION_MINOR", __FUNCTION__, minorVersion, GFD_FILE_VERSION_MINOR);
|
||||
setLastError("%s: minorVersion %d != %d GFD_FILE_VERSION_MINOR",
|
||||
__FUNCTION__, minorVersion, GFD_FILE_VERSION_MINOR);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifdef CHECK_GPU_VERSION
|
||||
if (gpuVersion != GX2TempGetGPUVersion()) {
|
||||
setLastError("%s: gpuVersion %d != %d GX2TempGetGPUVersion()", __FUNCTION__, gpuVersion, GX2TempGetGPUVersion());
|
||||
setLastError("%s: gpuVersion %d != %d GX2TempGetGPUVersion()",
|
||||
__FUNCTION__, gpuVersion, GX2TempGetGPUVersion());
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
@ -94,12 +109,14 @@ static BOOL
|
||||
_GFDCheckBlockHeaderMagicVersions(const GFDBlockHeader *header)
|
||||
{
|
||||
if (header->magic != GFD_BLOCK_HEADER_MAGIC) {
|
||||
setLastError("%s: header->magic %08X != GFD_BLOCK_HEADER_MAGIC", __FUNCTION__, header->magic);
|
||||
setLastError("%s: header->magic %08X != GFD_BLOCK_HEADER_MAGIC",
|
||||
__FUNCTION__, header->magic);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (header->majorVersion != GFD_BLOCK_VERSION_MAJOR) {
|
||||
setLastError("%s: header->majorVersion %d != GFD_BLOCK_VERSION_MAJOR", __FUNCTION__, header->majorVersion);
|
||||
setLastError("%s: header->majorVersion %d != GFD_BLOCK_VERSION_MAJOR",
|
||||
__FUNCTION__, header->majorVersion);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -222,6 +239,7 @@ _GFDGetBlockPointerConst(GFDBlockType type,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static BOOL
|
||||
_GFDGetBlockPointer(GFDBlockType type,
|
||||
uint32_t index,
|
||||
@ -272,6 +290,7 @@ _GFDGetBlockPointer(GFDBlockType type,
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
static uint32_t
|
||||
_GFDCleanTag(uint32_t tag)
|
||||
@ -297,7 +316,6 @@ _GFDRelocateBlockEx(const GFDRelocationHeader *relocationHeader,
|
||||
const uint32_t *patchTable,
|
||||
uint8_t *dst)
|
||||
{
|
||||
uint32_t patchOffset = _GFDCleanTag(relocationHeader->patchOffset);
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < relocationHeader->patchCount; ++i) {
|
||||
@ -309,14 +327,18 @@ _GFDRelocateBlockEx(const GFDRelocationHeader *relocationHeader,
|
||||
}
|
||||
|
||||
if (!_GFDCheckTagDAT(offset) && !_GFDCheckTagSTR(offset)) {
|
||||
setLastError("%s: !_GFDCheckTagDAT(offset = %08X) && !_GFDCheckTagSTR(offset = %08X)", __FUNCTION__, offset, offset);
|
||||
setLastError("%s: !_GFDCheckTagDAT(offset = %08X) && "
|
||||
"!_GFDCheckTagSTR(offset = %08X)",
|
||||
__FUNCTION__, offset, offset);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
target = (uint32_t *)(dst + _GFDCleanTag(offset));
|
||||
|
||||
if (!_GFDCheckTagDAT(*target) && !_GFDCheckTagSTR(*target)) {
|
||||
setLastError("%s: !_GFDCheckTagDAT(*target = %08X) && !_GFDCheckTagSTR(*target = %08X)", __FUNCTION__, *target, *target);
|
||||
setLastError("%s: !_GFDCheckTagDAT(*target = %08X) && "
|
||||
"!_GFDCheckTagSTR(*target = %08X)",
|
||||
__FUNCTION__, *target, *target);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -330,7 +352,8 @@ static BOOL
|
||||
_GFDRelocateBlock(const GFDBlockHeader *blockHeader,
|
||||
void *dst)
|
||||
{
|
||||
const uint8_t *blockData = ((const uint8_t *)blockHeader) + blockHeader->headerSize;
|
||||
const uint8_t *blockData = ((const uint8_t *)blockHeader) +
|
||||
blockHeader->headerSize;
|
||||
const GFDRelocationHeader *relocationHeader;
|
||||
const uint32_t *patchTable;
|
||||
|
||||
@ -343,12 +366,14 @@ _GFDRelocateBlock(const GFDBlockHeader *blockHeader,
|
||||
- sizeof(GFDRelocationHeader));
|
||||
|
||||
if (relocationHeader->magic != GFD_RELOCATION_HEADER_MAGIC) {
|
||||
setLastError("%s: relocationHeader->magic %08X != GFD_RELOCATION_HEADER_MAGIC", __FUNCTION__, relocationHeader->magic);
|
||||
setLastError("%s: relocationHeader->magic %08X != GFD_RELOCATION_HEADER_MAGIC",
|
||||
__FUNCTION__, relocationHeader->magic);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!_GFDCheckTagDAT(relocationHeader->patchOffset)) {
|
||||
setLastError("%s: !_GFDCheckTagDAT(relocationHeader->patchOffset = %08X)", __FUNCTION__, relocationHeader->patchOffset);
|
||||
setLastError("%s: !_GFDCheckTagDAT(relocationHeader->patchOffset = %08X)",
|
||||
__FUNCTION__, relocationHeader->patchOffset);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,8 @@ disassemblyPrintCallback(const char* fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
sDisassemblyLength += vsprintf(sDisassemblyBuffer + sDisassemblyLength, fmt, args);
|
||||
sDisassemblyLength += vsprintf(sDisassemblyBuffer + sDisassemblyLength,
|
||||
fmt, args);
|
||||
sDisassemblyBuffer[sDisassemblyLength] = 0;
|
||||
va_end(args);
|
||||
}
|
||||
@ -91,20 +92,29 @@ getStackTrace(OSContext *context)
|
||||
sStackTraceBuffer[0] = 0;
|
||||
stackPtr = (uint32_t *)context->gpr[1];
|
||||
|
||||
sStackTraceLength += sprintf(sStackTraceBuffer + sStackTraceLength, "Address: Back Chain LR Save\n");
|
||||
sStackTraceLength += sprintf(sStackTraceBuffer + sStackTraceLength,
|
||||
"Address: Back Chain LR Save\n");
|
||||
|
||||
for (i = 0; i < 16; ++i) {
|
||||
uint32_t addr;
|
||||
|
||||
if (!stackPtr || (uintptr_t)stackPtr == 0x1 || (uintptr_t)stackPtr == 0xFFFFFFFF) {
|
||||
if (!stackPtr ||
|
||||
(uintptr_t)stackPtr == 0x1 ||
|
||||
(uintptr_t)stackPtr == 0xFFFFFFFF) {
|
||||
break;
|
||||
}
|
||||
|
||||
sStackTraceLength += sprintf(sStackTraceBuffer + sStackTraceLength, "0x%08x: 0x%08x 0x%08x", stackPtr, stackPtr[0], stackPtr[1]);
|
||||
sStackTraceLength += sprintf(sStackTraceBuffer + sStackTraceLength,
|
||||
"0x%08x: 0x%08x 0x%08x",
|
||||
(uintptr_t)stackPtr,
|
||||
(uintptr_t)stackPtr[0],
|
||||
(uintptr_t)stackPtr[1]);
|
||||
|
||||
addr = OSGetSymbolName(stackPtr[1], name, sizeof(name));
|
||||
if (addr) {
|
||||
sStackTraceLength += sprintf(sStackTraceBuffer + sStackTraceLength, " %s+0x%x", name, stackPtr[1] - addr);
|
||||
sStackTraceLength += sprintf(sStackTraceBuffer + sStackTraceLength,
|
||||
" %s+0x%x", name,
|
||||
(uintptr_t)(stackPtr[1] - addr));
|
||||
}
|
||||
|
||||
sStackTraceLength += sprintf(sStackTraceBuffer + sStackTraceLength, "\n");
|
||||
@ -139,9 +149,11 @@ getRegisters(OSContext *context)
|
||||
writeRegister("--Proc%d-Core%u--------- OSContext 0x%p --------------------\n\n",
|
||||
OSGetUPID(), OSGetCoreId(), context);
|
||||
writeRegister("tag1 = 0x%08X (expecting 0x%08X)\n",
|
||||
(uint32_t)(context->tag >> 32), (uint32_t)(OS_CONTEXT_TAG >> 32));
|
||||
(uint32_t)(context->tag >> 32),
|
||||
(uint32_t)(OS_CONTEXT_TAG >> 32));
|
||||
writeRegister("tag2 = 0x%08X (expecting 0x%08X)\n",
|
||||
(uint32_t)(context->tag & 0xFFFFFFFF), (uint32_t)(OS_CONTEXT_TAG & 0xFFFFFFFF));
|
||||
(uint32_t)(context->tag & 0xFFFFFFFF),
|
||||
(uint32_t)(OS_CONTEXT_TAG & 0xFFFFFFFF));
|
||||
writeRegister("TBR = 0x%08X_%08X\n",
|
||||
(uint32_t)(tbr >> 32), (uint32_t)(tbr & 0xFFFFFFFF));
|
||||
writeRegister("CR = 0x%08X\n", context->cr);
|
||||
@ -180,7 +192,8 @@ getRegisters(OSContext *context)
|
||||
writeRegister("\n--Per-core OSContext runtime ----\n");
|
||||
for (i = 0; i < 3; ++i) {
|
||||
writeRegister("coretime[%d] = 0x%016llX ticks, %lld second(s) elapsed\n",
|
||||
i, context->coretime[i], OSTicksToSeconds(context->coretime[i]));
|
||||
i, context->coretime[i],
|
||||
OSTicksToSeconds(context->coretime[i]));
|
||||
}
|
||||
|
||||
writeRegister("\n--FPRs----------\n");
|
||||
@ -250,9 +263,13 @@ handleProgram(OSContext *context)
|
||||
BOOL
|
||||
WHBInitCrashHandler()
|
||||
{
|
||||
OSSetExceptionCallbackEx(OS_EXCEPTION_MODE_GLOBAL, OS_EXCEPTION_TYPE_ALIGNMENT, handleAlignment);
|
||||
OSSetExceptionCallbackEx(OS_EXCEPTION_MODE_GLOBAL, OS_EXCEPTION_TYPE_DSI, handleDSI);
|
||||
OSSetExceptionCallbackEx(OS_EXCEPTION_MODE_GLOBAL, OS_EXCEPTION_TYPE_ISI, handleISI);
|
||||
OSSetExceptionCallbackEx(OS_EXCEPTION_MODE_GLOBAL, OS_EXCEPTION_TYPE_PROGRAM, handleProgram);
|
||||
OSSetExceptionCallbackEx(OS_EXCEPTION_MODE_GLOBAL,
|
||||
OS_EXCEPTION_TYPE_ALIGNMENT, handleAlignment);
|
||||
OSSetExceptionCallbackEx(OS_EXCEPTION_MODE_GLOBAL,
|
||||
OS_EXCEPTION_TYPE_DSI, handleDSI);
|
||||
OSSetExceptionCallbackEx(OS_EXCEPTION_MODE_GLOBAL,
|
||||
OS_EXCEPTION_TYPE_ISI, handleISI);
|
||||
OSSetExceptionCallbackEx(OS_EXCEPTION_MODE_GLOBAL,
|
||||
OS_EXCEPTION_TYPE_PROGRAM, handleProgram);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -38,7 +38,8 @@ WHBGfxLoadGFDPixelShader(uint32_t index,
|
||||
|
||||
shader = (GX2PixelShader *)GfxHeapAllocMEM2(headerSize, 64);
|
||||
if (!shader) {
|
||||
WHBLogPrintf("%s: GfxHeapAllocMEM2(%u, 64) failed", __FUNCTION__, headerSize);
|
||||
WHBLogPrintf("%s: GfxHeapAllocMEM2(%u, 64) failed", __FUNCTION__,
|
||||
headerSize);
|
||||
goto error;
|
||||
}
|
||||
|
||||
@ -50,7 +51,8 @@ WHBGfxLoadGFDPixelShader(uint32_t index,
|
||||
shader->gx2rBuffer.elemCount = 1;
|
||||
shader->gx2rBuffer.buffer = NULL;
|
||||
if (!GX2RCreateBuffer(&shader->gx2rBuffer)) {
|
||||
WHBLogPrintf("%s: GX2RCreateBuffer failed with programSize = %u", __FUNCTION__, programSize);
|
||||
WHBLogPrintf("%s: GX2RCreateBuffer failed with programSize = %u",
|
||||
__FUNCTION__, programSize);
|
||||
goto error;
|
||||
}
|
||||
|
||||
@ -62,7 +64,9 @@ WHBGfxLoadGFDPixelShader(uint32_t index,
|
||||
|
||||
if (!GFDGetPixelShader(shader, program, index, file)) {
|
||||
WHBLogPrintf("%s: GFDGetPixelShader failed", __FUNCTION__);
|
||||
GX2RUnlockBufferEx(&shader->gx2rBuffer, GX2R_RESOURCE_DISABLE_CPU_INVALIDATE | GX2R_RESOURCE_DISABLE_GPU_INVALIDATE);
|
||||
GX2RUnlockBufferEx(&shader->gx2rBuffer,
|
||||
GX2R_RESOURCE_DISABLE_CPU_INVALIDATE |
|
||||
GX2R_RESOURCE_DISABLE_GPU_INVALIDATE);
|
||||
goto error;
|
||||
}
|
||||
|
||||
@ -93,6 +97,7 @@ WHBGfxFreePixelShader(GX2PixelShader *shader)
|
||||
}
|
||||
|
||||
GfxHeapFreeMEM2(shader);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GX2VertexShader *
|
||||
@ -125,7 +130,8 @@ WHBGfxLoadGFDVertexShader(uint32_t index,
|
||||
|
||||
shader = (GX2VertexShader *)GfxHeapAllocMEM2(headerSize, 64);
|
||||
if (!shader) {
|
||||
WHBLogPrintf("%s: GfxHeapAllocMEM2(%u, 64) failed", __FUNCTION__, headerSize);
|
||||
WHBLogPrintf("%s: GfxHeapAllocMEM2(%u, 64) failed", __FUNCTION__,
|
||||
headerSize);
|
||||
goto error;
|
||||
}
|
||||
|
||||
@ -137,7 +143,8 @@ WHBGfxLoadGFDVertexShader(uint32_t index,
|
||||
shader->gx2rBuffer.elemCount = 1;
|
||||
shader->gx2rBuffer.buffer = NULL;
|
||||
if (!GX2RCreateBuffer(&shader->gx2rBuffer)) {
|
||||
WHBLogPrintf("%s: GX2RCreateBuffer failed with programSize = %u", __FUNCTION__, programSize);
|
||||
WHBLogPrintf("%s: GX2RCreateBuffer failed with programSize = %u",
|
||||
__FUNCTION__, programSize);
|
||||
goto error;
|
||||
}
|
||||
|
||||
@ -149,7 +156,9 @@ WHBGfxLoadGFDVertexShader(uint32_t index,
|
||||
|
||||
if (!GFDGetVertexShader(shader, program, index, file)) {
|
||||
WHBLogPrintf("%s: GFDGetVertexShader failed", __FUNCTION__);
|
||||
GX2RUnlockBufferEx(&shader->gx2rBuffer, GX2R_RESOURCE_DISABLE_CPU_INVALIDATE | GX2R_RESOURCE_DISABLE_GPU_INVALIDATE);
|
||||
GX2RUnlockBufferEx(&shader->gx2rBuffer,
|
||||
GX2R_RESOURCE_DISABLE_CPU_INVALIDATE |
|
||||
GX2R_RESOURCE_DISABLE_GPU_INVALIDATE);
|
||||
goto error;
|
||||
}
|
||||
|
||||
@ -180,6 +189,7 @@ WHBGfxFreeVertexShader(GX2VertexShader *shader)
|
||||
}
|
||||
|
||||
GfxHeapFreeMEM2(shader);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
|
@ -11,7 +11,6 @@ WHBGfxLoadGFDTexture(uint32_t index,
|
||||
{
|
||||
uint32_t headerSize, imageSize;
|
||||
GX2Texture *texture = NULL;
|
||||
void *image = NULL;
|
||||
|
||||
if (index >= GFDGetTextureCount(file)) {
|
||||
WHBLogPrintf("%s: invalid GFD texture index %u", __FUNCTION__, index);
|
||||
@ -27,7 +26,8 @@ WHBGfxLoadGFDTexture(uint32_t index,
|
||||
|
||||
texture = (GX2Texture *)GfxHeapAllocMEM2(headerSize, 64);
|
||||
if (!texture) {
|
||||
WHBLogPrintf("%s: GfxHeapAllocMEM2(0x%X, 64) failed", __FUNCTION__, headerSize);
|
||||
WHBLogPrintf("%s: GfxHeapAllocMEM2(0x%X, 64) failed", __FUNCTION__,
|
||||
headerSize);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -24,9 +24,6 @@ sRunning = FALSE;
|
||||
static BOOL
|
||||
sFromHBL = FALSE;
|
||||
|
||||
static ProcUICallback
|
||||
sAcquireCallback = NULL;
|
||||
|
||||
static uint32_t
|
||||
procSaveCallback(void *context)
|
||||
{
|
||||
@ -65,7 +62,8 @@ WHBProcInit()
|
||||
sMainCore = OSGetCoreId();
|
||||
sRunning = TRUE;
|
||||
ProcUIInitEx(&procSaveCallback, NULL);
|
||||
ProcUIRegisterCallback(PROCUI_CALLBACK_HOME_BUTTON_DENIED, &procHomeButtonDenied, NULL, 100);
|
||||
ProcUIRegisterCallback(PROCUI_CALLBACK_HOME_BUTTON_DENIED,
|
||||
&procHomeButtonDenied, NULL, 100);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -36,7 +36,7 @@ __wut_fs_fixpath(struct _reent *r,
|
||||
int
|
||||
__wut_fs_translate_error(FSStatus error)
|
||||
{
|
||||
switch (error) {
|
||||
switch ((int32_t)error) {
|
||||
case FS_STATUS_END:
|
||||
return ENOENT;
|
||||
case FS_STATUS_CANCELLED:
|
||||
|
Loading…
Reference in New Issue
Block a user