Commit Graph

156 Commits

Author SHA1 Message Date
Maschell
028899ecd3 wutcrt: Add a trapword in case a debugger is initialized to allow debugging 2022-07-27 23:40:43 +02:00
Maschell
215adf35bc wutcrt: Make sure main is called with a 8 byte aligned stack pointer 2022-07-27 23:12:03 +02:00
Crementif
d621766b2f
devoptab: Implement various functions and fixes (#223)
- Improved error codes for unlink and rmdir regarding non-empty directories.
- Return ENOENT on empty strings since it softlocks the Wii U. Since the devoptab relies on the cwd it's pretty easy to run into with stuff like recursive path creation for example.
- Clean up open_r mode_t->string conversion
- Improved FSStat->mode_t conversion
- Add FSOpenFileEx and flags
2022-07-23 12:03:07 +02:00
GaryOderNichts
f1b5da996f
Replace the CafeOS default heap with a custom one (#221) 2022-06-30 21:05:11 +02:00
Maschell
0c4d7685f1 wutdevoptab: Add stub implemenation of utimes and implement lstat via stub to avoid undefined behaviour. 2022-06-18 16:55:34 +02:00
Maschell
8a2bf09800 wutdevoptab: Fix setting mode flags 2022-06-18 12:47:04 +02:00
Maschell
89b396d373 wutdevoptab: Only update the file->offset on a successful seek. 2022-06-18 12:46:45 +02:00
Dave Murphy
6494a30c3d wutdevoptab: Make sure to always read into/write from a properly aligned buffer 2022-06-04 21:35:58 +02:00
Maschell
c0e4eb7ae8 wutdevoptab: simplify the __wut_fs_translate_time implementation 2022-06-04 19:23:30 +02:00
Maschell
f0da3d7236
wutdevoptab: Add time and mode information for stat and fstat (#218)
* wutdevoptab: Add time and mode information for stat and fstat

* wutdevoptab: rename __wut_translate_mode to __wut_fs_translate_mode
2022-05-07 11:26:11 +01:00
Maschell
cd6b4fb45d Fix syscall_clock implementation 2022-04-15 17:02:03 +01:00
Maschell
578674a336 wutdevoptab: Replace FSError usage with FSStatus in __wut_fs_translate_error 2022-04-15 16:59:42 +01:00
fincs
03c3d42d38
wutnewlib: replace dynamic allocation of OSMutex with static table 2022-03-05 17:58:51 +01:00
Maschell
b23f9bde00
libwhb: Use an aligned buffer size for WHBReadWholeFile to avoid potential heap corruption (#212) 2022-03-04 11:52:40 +00:00
Maschell
616ebe1a06 wutdevoptab: Only call FSUnmount if FSMount was successful 2022-02-27 16:06:22 +01:00
Maschell
62b78f7b9f
coreinit: Add missing parameter to FSChangeMode/FSChangeModeAsync (#199) 2022-02-26 16:55:47 +01:00
Maschell
920c8ad3d6
wutdevoptab: Add missing FSUnmount on fini (#207) 2022-02-26 16:54:18 +01:00
Maschell
58fabd79a2 libwhb: Add missing close() call on WHBLogUdpDeinit reset socket val 2022-02-19 17:28:53 +01:00
Maschell
fefde021b9
wutmalloc: Fix memalign to ensure the size is aligned (#196)
This fixes situations that can arise in places such as FSReadFile/FSWriteFile, in which buffer sizes need to be aligned to 0x40; otherwise heap corruptions could happen when multithreading.
2022-02-12 20:49:16 +01:00
James Benton
432c895f75 Add nn::erreula library. 2022-01-20 00:38:36 +01:00
James Benton
e11ded4992 nn_swkbd: Fix potential memory leaks. 2022-01-20 00:38:36 +01:00
Maschell
ce2cd4e843 libwhb: Add option to log to the LoggingModule 2021-11-06 17:28:09 +01:00
Maschell
563b9d6c89 libwhb: return true if a log handler is already present 2021-11-06 17:28:09 +01:00
fincs
eb0306184d
wutsocket: Revise automatic initialization, see details:
- __init/fini_wut_socket have been simplified and are now weak,
  this is intended to allow users to customize their behaviour
- socket_lib_init/exit have been restored as regular imports and are
  no longer using RPLWRAP
- __wut_socket_init/fini_devoptab are now exposed as global symbols,
  intended to be used in custom socket init/deinit logic
2021-09-18 16:57:29 +02:00
GaryOderNichts
d0dc9869e5 wutsocket: avoid aliasing issues 2021-03-07 16:40:55 +01:00
GaryOderNichts
174b0c0a86 wutsocket: implement gethostid and gethostname 2021-03-07 16:40:55 +01:00
GaryOderNichts
f1e9cbd58a wutsocket: implement missing functions 2021-03-07 16:40:55 +01:00
fincs
efc1bd47ff
wutsocket: only link in networking layer if actually used 2021-03-07 13:36:59 +01:00
rw-r-r-0644
c377cffe13
Network socket changes (#136) 2021-03-07 13:09:12 +01:00
fincs
6c168606a3
wutstdc++: Remove link-time dependency on libstdc++ 2021-03-06 19:31:09 +01:00
fincs
d04f68f8b1
Minor linkscript cleanup 2021-03-04 19:48:45 +01:00
GaryOderNichts
712843cd58 wutnewlib: fix gettod 2021-02-09 20:17:56 +00:00
Maschell
af99d5acbd libwhb: Use FS_ERROR_FLAG_ALL instead of -1 2021-01-01 17:21:44 +01:00
Maschell
510409db7a wutdevoptab: Use FS_ERROR_FLAG_ALL instead of -1 2021-01-01 17:21:44 +01:00
Maschell
79b8597a68
wutdevoptab: Only allocate a new buffer if the given buffer is not aligned properly (#159) 2021-01-01 17:16:40 +01:00
Maschell
bc6ee14ca3
WHB: Fix missing FSDelClient (#158) 2020-11-28 16:18:34 +00:00
V10lator
83ca413027
Translate more FSErrors to errnos (#150) 2020-07-22 03:23:29 +01:00
Maschell
545ea62e11 devoptab: add missing S_IFREG flag in the fstat return value 2020-06-23 10:45:50 +01:00
Dave Murphy
b168032339 fix exit sequence 2020-06-07 13:09:11 +01:00
Dave Murphy
e096dad4c5 reworked syscalls interface 2020-06-07 13:09:11 +01:00
Maschell
9796ca64b2 wutdevoptab: Add missing RemoveDevice in __fini_wut_devoptab 2020-06-04 10:29:19 +01:00
Maschell
d659fd98d4 wutdevoptab: Reset __wut_fs_initialised and __wut_devoptab_fs_client in __fini_wut_devoptab 2020-06-04 10:29:19 +01:00
Maschell
aaa045af97
libwhb: Don't add a LogHandler if it's already in the list. (#140) 2020-06-03 21:05:08 +01:00
GaryOderNichts
27fbfd55fb
Add WHBLogConsoleSetColor (#138) 2020-05-26 09:03:19 +10:00
Ash Logan
1df3d9a40d whb/gfx: Capitalise v in WHBGfxGetTVColourBuffer
All the other public whb/gfx functions capitalise DRC and TV, so do that 
here.
2020-02-10 15:12:22 +11:00
James Benton
d39e7cad4a wutstdc++: Use OSSetThreadRunQuantum in gthread implementation.
To emulate pre-emptive scheduling which is what would be expected from
gthread.
2020-01-18 10:58:02 +00:00
James Benton
b895e7b56d whb: Fix WHB console for foreground releasing and acquire. 2019-11-24 12:25:17 +00:00
James Benton
cd6e74fd17 whb: Fix WHBGfxShutdown when app is in background. 2019-11-24 11:52:47 +00:00
James Benton
ac17c9a885 whb/gfx: Add some functions to access colour / depth / context. 2019-11-23 11:39:43 +00:00
James Benton
e9f8b191e5 whb: Only register home button denied callback when booted from HBL. 2019-11-23 11:32:13 +00:00
James Benton
7d0f02b5e6 whb: Remove useless command server code.
Not sure why this was ever in WHB....
2019-11-23 11:31:57 +00:00
Ash Logan
28ffb89c02 Merge 'build-refactor' attempt #1; get upstream changes 2019-04-23 18:37:05 +10:00
Ash Logan
f92657e8b5 coreinit: Use rplwrap for exit (__rplwrap_exit) 2019-04-22 12:43:37 +10:00
Ash Logan
fb9b7ab3fb wutstdc++: remove volatile keyword
Who knows? not me. Seems to work okay without it
wut_stdcpp.cpp
/home/ash/src/wut/libraries/wutstdc++/wut_stdcpp.cpp:3:9: error: 
expected '(' before '__volatile__'
 __asm__ __volatile__(
         ^~~~~~~~~~~~
         (
/home/ash/src/wut/libraries/wutstdc++/wut_stdcpp.cpp:4:4: error: 
expected unqualified-id before string constant
    "\t.section\t.text.__wrap___gxx_personality_v0,\"ax\",@progbits\n"
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/ash/src/wut/libraries/wutstdc++/wut_stdcpp.cpp:3:22: error: 
expected ')' before string constant
 __asm__ __volatile__(
                     ~^
                      )
    "\t.section\t.text.__wrap___gxx_personality_v0,\"ax\",@progbits\n"
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[1]: *** [/opt/devkitpro/devkitPPC/base_rules:13: wut_stdcpp.o] 
Error 1
2019-04-09 20:41:45 +10:00
Ash Logan
869fe709ea Revert "wutstdc++: Move __gxx_personality to dedicated Assembly file"
This reverts commit 370eeb28e9.
I didn't know what this did, sorry.
2019-04-09 20:26:35 +10:00
Ash Logan
370eeb28e9 wutstdc++: Move __gxx_personality to dedicated Assembly file
I was getting issues with __volatile__ for unknown reason, so moving 
this to a dedicated file sidesteps the issue entirely and passes this 
straight to GAS.
2019-04-09 16:44:42 +10:00
rw-r-r-0644
6ea6625b78 devoptab: Fix double free in __wut_fs_stat
The double free caused apps to crash when attempting to run stat on a directory
2019-02-24 15:48:46 +00:00
fincs
0b920cf9b9 Automatically link wutstdc++ when C++ is used 2019-02-12 12:46:34 +01:00
fincs
26ac7b3ff2 wutmalloc: Bugfixes, see details:
- Added (dummy) __init/fini_wut_malloc stubs called by wutcrt
  in order to ensure that wutmalloc gets linked in
- malloc/realloc/calloc now properly set errno to ENOMEM during failure
- realloc no longer fails if ptr==NULL (in this case it works
  like a regular malloc)
- realloc no longer does an out of bounds copy if the new size
  is smaller than the old size
- free(NULL) is now supported as per the C standard
- Disabled sbrk/malloc-lock support code in wutnewlib because
  newlib's malloc is replaced with wutmalloc
2019-02-12 12:46:34 +01:00
fincs
ee3bb10df4 First pass at adopting a devkitPro-style build system, see details:
- Added wut_rules and wut/rpx/rpl.specs to share/
- Replaced wut's CMake-based buildsystem with a standard Makefile
- Conflated all wut libraries into a single libwut.a library
- wut's old buildsystems (CMake & plain make) are broken as a result,
  this will be fixed in the future
- Docs, tests and samples are not buildable either at the moment
- wutcrt/wutnewlib:
  - RPX start function is __rpx_start, while RPL is __rpl_start
  - __init/fini_wut_* functions are no longer weak
  - __init_wut/__fini_wut are instead weak
  - Removed _exit implementation
  - exit syscall now points to _Exit instead of pointing to itself
- wutstdc++:
  - Renamed .cc files to .cpp
  - Temporarily disabled, due to an issue that will be addressed shortly
- wutdevoptab:
  - Fixed uninitialized variable warnings in __wut_fs_read/write
2019-02-12 12:46:28 +01:00
James Benton
fb4a54fc4c Rename GX2_SQ_SELMASK macro to GX2_SEL_MASK. 2018-10-21 15:24:25 +01:00
James Benton
857fcd8eea Build libraries with -Wall and -Werror. 2018-10-06 10:50:32 +01:00
James Benton
069e28acec Make the devoptab code more consistent. 2018-10-06 10:41:24 +01:00
James Benton
ea009ce10b wutcrt: Forward newlib _exit to the coreinit.rpl _Exit 2018-09-30 08:40:38 +01:00
James Benton
400318c3d1 Rename rpl_main to rpl_entry. 2018-09-30 08:40:38 +01:00
James Benton
690bd6ccbd Revert "Rename wutdevoptab to wutdevoptab_sd"
This reverts commit 865af4609c.
Turns out it is for whole filesystem. oops.
2018-07-19 08:51:40 +01:00
James Benton
6f014e48d2 Remove last usages of GLOB_RECURSE. 2018-06-28 16:01:16 +01:00
James Benton
5f1b1902f6 Prefix structsize macros with WUT_ 2018-06-20 11:05:16 +01:00
James Benton
b4619783ca Remove sized types from wut_types.h
stdint.h exists for a reason.
2018-06-20 11:05:16 +01:00
James Benton
39429c0cbc cmake: Cleanup some CMake stuff. 2018-06-15 13:59:55 +01:00
James Benton
f9799cf3dd Fix __init_wut_sbrk_heap. 2018-06-15 13:59:30 +01:00
James Benton
d315b4bb34 Add new wutmalloc library.
This overwrites malloc and redirects it to alloc from default heap.
Also sets __wut_heap_max_size to limit sbrk heap now that malloc no longer
uses it.
2018-06-14 09:33:16 +01:00
James Benton
98b6f6ec2f wutnewlib: Allow custom fixed sbrk heap size.
So now either uses 90% of the available base heap, or allocates a fixed
sized heap from the default heap.
2018-06-14 09:32:37 +01:00
James Benton
1471ea4338 Change wutnewlib to implement malloc family of functions.
This allows us to forward them straight to default heap functions, this
is better than having to allocate a fixed heap for sbrk as it allows
people to better mix usage malloc & default heap functions.
2018-06-13 18:38:53 +01:00
James Benton
c4214cef35 sysapp: Change unknown structure to a struct typedef. 2018-06-13 17:36:12 +01:00
James Benton
865af4609c Rename wutdevoptab to wutdevoptab_sd 2018-06-13 13:36:15 +01:00
James Benton
75784dbb52 Add nn::swkbd library. 2018-06-13 12:12:22 +01:00
James Benton
3c054375db wutstdc++: Fix __wut_key_t. 2018-06-02 10:36:28 +01:00
James Benton
f11112ca0f Change LATTE_SQ_SEL to GX2_SQ_SEL.
latte is private stuff yo.
2018-05-31 11:19:39 +01:00
James Benton
4e2099a2e4 whb: Add missing GX2Invalidate call.
GX2RUnlockBuffer is supposed to be calling invalidate for us.... but it
does not seem to work and we require an explicit invalidate instead?!?!
2018-05-31 10:10:10 +01:00
James Benton
1c3d26ab1b wutcrt: Setup a proper stack frame for _start. 2018-05-30 22:13:49 +01:00
James Benton
699aa5ca99 wutcrt: Fix call to __fini_wut instead of __init_wut for rpl on load entry. 2018-05-30 22:00:58 +01:00
James Benton
f281be50ab Add support for generating RPL files.
RPL files are shared libraries (like a .dll file), as opposed to the RPX
files which are executables (like a .exe file).

Use rpl_main as defined in dynload.h like one would DllMain on Windows.
2018-05-30 21:56:18 +01:00
James Benton
4220023511 wutstdc++: Use malloc / free instead of MEM functions. 2018-05-30 14:42:42 +01:00
James Benton
d5effaaf88 coreinit: Cleanup memory heap functions.
Move files to mem*heap.h.
Use MEMHeapHandle everywhere to reduce need for unecessary casts.
Rename types to match the function names better (e.g. Frame -> Frm).
2018-05-30 13:13:37 +01:00
James Benton
a5d15a7a3a Remove libdefaultheap.
Replaced by coreinit data exports.
2018-05-29 10:52:40 +01:00
dibas
45e0904a69 WHBGfx - Separate ClearColor() and allow custom colors. 2018-05-28 11:42:13 +01:00
James Benton
f7a698388c wutnewlib: Implement the new __syscalls from upcoming devkitPPC release. 2018-05-28 11:40:22 +01:00
James Benton
2b165bf887 Improve time conversion macros. 2018-05-28 11:39:36 +01:00
James Benton
b4a6eb2f78 Split out crt from wutnewlib to wutcrt.
Can now optionally link newlib, stdc++, devoptab.
2018-05-27 12:12:49 +01:00
James Benton
479e9ad677 Add devoptab support for sdcard. 2018-05-27 12:11:45 +01:00
James Benton
ac8a42fa7c Change to using new gthreads implementation.
Assuming that --enable-threads=dkp gets merged into devkitPPC r31... :)
2018-05-26 18:25:36 +01:00
James Benton
37228a095d Disable call to __fini as it breaks stuff. 2018-05-26 18:18:16 +01:00
James Benton
9a3cbcd2ef wutnewlib: Call __fini for global dtors.
main calls __eabi which calls __init, but main doesn't call __fini?
y u do this
2018-05-25 21:20:39 +01:00
James Benton
33bff6ccb9 whb: Fix exception handlers to be globally registered.
Was previously only registered for current thread.
2018-05-25 18:59:29 +01:00
James Benton
710ce964c8 wutstdc++: Add remaining gthreads reliant std code. 2018-05-25 18:47:11 +01:00
James Benton
ec59508010 wutstdc++: Implement __gthread_cond_timedwait. 2018-05-25 18:45:19 +01:00
James Benton
750a2370d8 wutstdc++: Move gthread code to source files. 2018-05-25 18:15:39 +01:00
James Benton
675549474a wutstdc++: Implement gthread keys. 2018-05-25 18:06:54 +01:00
James Benton
3336fbaf5d Implement __gthread_once. 2018-05-25 17:35:21 +01:00