From 492bad43823a4850a9413cc2ba53677b00ef5ca2 Mon Sep 17 00:00:00 2001 From: CreeperMario Date: Sun, 6 Aug 2017 16:56:17 +0930 Subject: [PATCH 1/3] crt: **Really** fix newlib lock --- src/crt/newlib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crt/newlib.c b/src/crt/newlib.c index 339b4ed..5b12428 100644 --- a/src/crt/newlib.c +++ b/src/crt/newlib.c @@ -70,7 +70,7 @@ static int __libwut_lock_close(int *lock) static int __libwut_lock_acquire(int *lock) { - OSMutex *mutex = (OSMutex *)lock; + OSMutex *mutex = (OSMutex *)*lock; if (!lock || *lock == 0) { return -1; } @@ -81,7 +81,7 @@ static int __libwut_lock_acquire(int *lock) static int __libwut_lock_release(int *lock) { - OSMutex *mutex = (OSMutex *)lock; + OSMutex *mutex = (OSMutex *)*lock; if (!lock || *lock == 0) { return -1; } From c0c1faa1e943b549ff3ae84a0767e506a917c6b5 Mon Sep 17 00:00:00 2001 From: CreeperMario Date: Sun, 6 Aug 2017 17:11:15 +0930 Subject: [PATCH 2/3] libwhb: Initialize FSCmdBlock in WHBUnmountSdCard --- samples/gx2/triangle/CMakeLists.txt | 4 +++- samples/gx2/triangle/src/main.c | 2 +- src/libwhb/src/sdcard.c | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/samples/gx2/triangle/CMakeLists.txt b/samples/gx2/triangle/CMakeLists.txt index 8ef4b23..a86a9fd 100644 --- a/samples/gx2/triangle/CMakeLists.txt +++ b/samples/gx2/triangle/CMakeLists.txt @@ -11,4 +11,6 @@ target_link_libraries(triangle defaultheap gx2 gfd - proc_ui) + nsysnet + proc_ui + sysapp) diff --git a/samples/gx2/triangle/src/main.c b/samples/gx2/triangle/src/main.c index c93277e..02deaee 100644 --- a/samples/gx2/triangle/src/main.c +++ b/samples/gx2/triangle/src/main.c @@ -113,7 +113,7 @@ exit: WHBLogPrintf("Exiting..."); GX2RDestroyBufferEx(&positionBuffer, 0); GX2RDestroyBufferEx(&colourBuffer, 0); - //WHBUnmountSdCard(); !! freezes on unmount for unkown reason !! + WHBUnmountSdCard(); WHBGfxShutdown(); WHBProcShutdown(); return result; diff --git a/src/libwhb/src/sdcard.c b/src/libwhb/src/sdcard.c index 3e2e129..83dfe52 100644 --- a/src/libwhb/src/sdcard.c +++ b/src/libwhb/src/sdcard.c @@ -67,6 +67,8 @@ WHBUnmountSdCard() return TRUE; } + FSInitCmdBlock(&cmd); + result = FSUnmount(&sClient, &cmd, sMountPath, -1); if (result < 0) { WHBLogPrintf("%s: FSUnmount error %d", __FUNCTION__, result); From 90d13e57085942b7b193088f18193e9228b0173e Mon Sep 17 00:00:00 2001 From: CreeperMario Date: Sun, 6 Aug 2017 17:42:43 +0930 Subject: [PATCH 3/3] libwhb: Add a simplistic Cafe Log handler --- src/libwhb/include/whb/log_cafe.h | 21 +++++++++++++++++++++ src/libwhb/src/log_cafe.c | 15 +++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/libwhb/include/whb/log_cafe.h create mode 100644 src/libwhb/src/log_cafe.c diff --git a/src/libwhb/include/whb/log_cafe.h b/src/libwhb/include/whb/log_cafe.h new file mode 100644 index 0000000..bc40515 --- /dev/null +++ b/src/libwhb/include/whb/log_cafe.h @@ -0,0 +1,21 @@ +#pragma once +#include + +/** + * \defgroup whb_log_cafe Cafe OS System Log Output + * \ingroup whb + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +BOOL +WHBLogCafeInit(); + +#ifdef __cplusplus +} +#endif + +/** @} */ diff --git a/src/libwhb/src/log_cafe.c b/src/libwhb/src/log_cafe.c new file mode 100644 index 0000000..a1367d3 --- /dev/null +++ b/src/libwhb/src/log_cafe.c @@ -0,0 +1,15 @@ +#include +#include + +static void +cafeLogHandler(const char * msg) +{ + OSReport("%s\n", msg); +} + +BOOL +WHBLogCafeInit() +{ + WHBAddLogHandler(cafeLogHandler); + return TRUE; +}