mirror of
https://github.com/libretro/RetroArch
synced 2024-12-26 21:29:08 +00:00
WIIU: cleanup and build-out of wiiu bootstrap code
I used the code in `wiiu/` to bootstrap my own WiiU homebrew app; this PR reflects some changes I needed to make, that might be useful upstream. 1. Clean up filesystem initialization Filesystem driver initialization was lumped in with filesystem mounting; and that was a problem in my project, because I needed to be able to remount the SD card on the fly. So, now it's split up. I've added a callback object named "hooks" that can be used by consuming applications to handle filesystem mounting and unmounting. If these hooks are not provided, then the existing default behavior occurs. 2. Expand socket handling - add `SO_NONBLOCK` flag for non-blocking socket I/O - add normal errno defines like `EWOULDBLOCK` `EAGAIN`. 3. Remove RetroArch dependencies - the exception handler protects usage of version_git with `#ifdef HAVE_GIT_VERSION` but not the include, so I added that. It also technically depends on version.h, but I'm not touching that. It's easy enough to implement and I needed the same functionality. I'm not sure what the best solution for that dependency is. - missing_libc_functions.c included features/features_cpu.h which is a libretro include. This appears to be a stale include though, because everything compiles and works without it. - an ifdef referencing the RA "WIIU" define, rather than the devkitpro "__wiiu__" define
This commit is contained in:
parent
21fd83f766
commit
f22c337cfc
2
Makefile
2
Makefile
@ -219,8 +219,6 @@ $(OBJDIR)/%.o: %.rc $(HEADERS)
|
||||
@$(if $(Q), $(shell echo echo WINDRES $<),)
|
||||
$(Q)$(WINDRES) -o $@ $<
|
||||
|
||||
compile: $(OBJ)
|
||||
|
||||
install: $(TARGET)
|
||||
rm -f $(OBJDIR)/git_version.o
|
||||
mkdir -p $(DESTDIR)$(BIN_DIR) 2>/dev/null || /bin/true
|
||||
|
@ -316,8 +316,6 @@ $(BUILD_DIR)/$(TARGET).rpx: $(BUILD_DIR)/$(TARGET).rpx.elf $(ELF2RPL) .$(TARGET)
|
||||
@touch .$(TARGET).rpx.last
|
||||
$(Q)-$(ELF2RPL) $< $@
|
||||
|
||||
compile: $(OBJ) $(HBL_ELF_OBJ)
|
||||
|
||||
clean:
|
||||
rm -f $(OBJ) $(RPX_OBJ) $(HBL_ELF_OBJ) $(TARGET).elf $(TARGET).rpx.elf $(TARGET).rpx
|
||||
rm -f $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).rpx.elf $(BUILD_DIR)/$(TARGET).rpx
|
||||
|
@ -49,7 +49,7 @@
|
||||
#include "../../retroarch.h"
|
||||
#include "../../gfx/video_driver.h"
|
||||
|
||||
|
||||
#include "wiiu_main.h"
|
||||
#include "hbl.h"
|
||||
#include "wiiu_dbg.h"
|
||||
#include "system/exception_handler.h"
|
||||
@ -68,6 +68,10 @@
|
||||
* The Wii U frontend driver, along with the main() method.
|
||||
*/
|
||||
|
||||
/* TODO: If we want greater control over which filesystems get mounted,
|
||||
* implement callbacks and assign them below. */
|
||||
hooks_t hooks = { NULL, NULL };
|
||||
|
||||
static enum frontend_fork wiiu_fork_mode = FRONTEND_FORK_NONE;
|
||||
static const char *elf_path_cst = WIIU_SD_PATH "retroarch/retroarch.elf";
|
||||
|
||||
|
@ -22,12 +22,16 @@ extern "C" {
|
||||
|
||||
#define SO_REUSEADDR 0x0004
|
||||
#define SO_NBIO 0x1014
|
||||
#define SO_NONBLOCK 0x1016
|
||||
|
||||
|
||||
/* return codes */
|
||||
#define SO_SUCCESS 0
|
||||
#define SO_EWOULDBLOCK 6
|
||||
|
||||
#define EWOULDBLOCK SO_EWOULDBLOCK
|
||||
#define EAGAIN SO_EWOULDBLOCK
|
||||
#define ENOBUFS 105 /* No buffer space available */
|
||||
|
||||
typedef uint32_t socklen_t;
|
||||
typedef uint16_t sa_family_t;
|
||||
|
66
wiiu/main.c
66
wiiu/main.c
@ -22,6 +22,8 @@
|
||||
#include <iosuhax.h>
|
||||
#include <sys/iosupport.h>
|
||||
|
||||
#include "wiiu_main.h"
|
||||
|
||||
#include "hbl.h"
|
||||
|
||||
#include "fs/fs_utils.h"
|
||||
@ -50,7 +52,8 @@ void __init(void);
|
||||
static void fsdev_init(void);
|
||||
static void fsdev_exit(void);
|
||||
|
||||
static int iosuhaxMount = 0;
|
||||
bool iosuhaxMount = 0;
|
||||
|
||||
static int mcp_hook_fd = -1;
|
||||
|
||||
/* HBL elf entry point */
|
||||
@ -163,35 +166,58 @@ void MCPHookClose(void)
|
||||
mcp_hook_fd = -1;
|
||||
}
|
||||
|
||||
static bool try_init_iosuhax(void)
|
||||
{
|
||||
int result = IOSUHAX_Open(NULL);
|
||||
if(result < 0)
|
||||
result = MCPHookOpen();
|
||||
|
||||
return (result < 0) ? false : true;
|
||||
}
|
||||
|
||||
static void try_shutdown_iosuhax(void)
|
||||
{
|
||||
if(!iosuhaxMount)
|
||||
return;
|
||||
|
||||
if (mcp_hook_fd >= 0)
|
||||
MCPHookClose();
|
||||
else
|
||||
IOSUHAX_Close();
|
||||
|
||||
iosuhaxMount = false;
|
||||
}
|
||||
|
||||
static void fsdev_init(void)
|
||||
{
|
||||
iosuhaxMount = 0;
|
||||
int res = IOSUHAX_Open(NULL);
|
||||
iosuhaxMount = try_init_iosuhax();
|
||||
|
||||
if (res < 0)
|
||||
res = MCPHookOpen();
|
||||
|
||||
if (res < 0)
|
||||
mount_sd_fat("sd");
|
||||
if(hooks.fs_mount != NULL && hooks.fs_unmount != NULL)
|
||||
hooks.fs_mount();
|
||||
else
|
||||
{
|
||||
iosuhaxMount = 1;
|
||||
fatInitDefault();
|
||||
if(iosuhaxMount)
|
||||
fatInitDefault();
|
||||
else
|
||||
mount_sd_fat("sd");
|
||||
}
|
||||
}
|
||||
|
||||
static void fsdev_exit(void)
|
||||
{
|
||||
if (iosuhaxMount)
|
||||
{
|
||||
fatUnmount("sd:");
|
||||
fatUnmount("usb:");
|
||||
if(hooks.fs_mount != NULL && hooks.fs_unmount != NULL)
|
||||
|
||||
if (mcp_hook_fd >= 0)
|
||||
MCPHookClose();
|
||||
else
|
||||
IOSUHAX_Close();
|
||||
}
|
||||
hooks.fs_unmount();
|
||||
else
|
||||
unmount_sd_fat("sd");
|
||||
{
|
||||
if (iosuhaxMount)
|
||||
{
|
||||
fatUnmount("sd:");
|
||||
fatUnmount("usb:");
|
||||
}
|
||||
else
|
||||
unmount_sd_fat("sd");
|
||||
}
|
||||
|
||||
try_shutdown_iosuhax();
|
||||
}
|
||||
|
@ -23,8 +23,9 @@
|
||||
#include "wiiu_dbg.h"
|
||||
#include "exception_handler.h"
|
||||
#include "version.h"
|
||||
#ifdef HAVE_GIT_VERSION
|
||||
#include "version_git.h"
|
||||
|
||||
#endif
|
||||
/* Settings */
|
||||
#define NUM_STACK_TRACE_LINES 5
|
||||
|
||||
|
@ -1,6 +1,13 @@
|
||||
/* coreinit */
|
||||
IMPORT_BEGIN(coreinit);
|
||||
|
||||
IMPORT(OSScreenInit);
|
||||
IMPORT(OSScreenGetBufferSizeEx);
|
||||
IMPORT(OSScreenSetBufferEx);
|
||||
IMPORT(OSScreenEnableEx);
|
||||
IMPORT(OSScreenFlipBuffersEx);
|
||||
IMPORT(OSScreenClearBufferEx);
|
||||
IMPORT(OSScreenPutFontEx);
|
||||
IMPORT(OSFatal);
|
||||
IMPORT(OSDynLoad_Acquire);
|
||||
IMPORT(OSDynLoad_FindExport);
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include <stdio.h>
|
||||
#include <wiiu/os.h>
|
||||
#include <pwd.h>
|
||||
#include <features/features_cpu.h>
|
||||
#include <sys/reent.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <stdint.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#ifdef WIIU
|
||||
#ifdef __wiiu__
|
||||
#include <wiiu/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
16
wiiu/wiiu_main.h
Normal file
16
wiiu/wiiu_main.h
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef _MAIN_H
|
||||
#define _MAIN_H
|
||||
|
||||
#include "wiiu/types.h"
|
||||
|
||||
struct main_hooks {
|
||||
void (*fs_mount)(void);
|
||||
void (*fs_unmount)(void);
|
||||
};
|
||||
|
||||
typedef struct main_hooks hooks_t;
|
||||
|
||||
extern hooks_t hooks;
|
||||
extern bool iosuhaxMount;
|
||||
|
||||
#endif /* _MAIN_H */
|
Loading…
Reference in New Issue
Block a user