Skip to content

Commit 2ca2d96

Browse files
committed
(WiiU) Port to wut toolchain
This commit is enough to compile RetroArch using wut and more modern versions of devkitPPC. Among the requisite ports and bugfixes, the wiiu code has been switched to use wut's headers (where possible). There's a handful of headers where RA's are more precise, and these have been put into the `wiiu/include/` hierarchy mirroring WUT's folder structure, but with `ra_` prepended to the filename to avoid include directory priority fighting. Other changes are related to the header changes: - update defines to use WUT's new definition - replace custom integer types with standard ones (eg u8 -> uint8_t) - remove some workarounds/hacks in favor of more precise handling in WUT. Cut features that will be re-added later: - Current rpx symbol names in the exception handler - somemopt networking optimisations - Core loading - libfat support - always uses fs:/vol/external01 (WiiU) memory: handle being in the background properly Quitting on Aroma works a little differently to HBL - we need to use a ProcUI loop and go into the background before quitting. This patch prepares the MEM1 and bucket allocators so they won't crash when this happens. (WiiU) aroma: fix conflict with FTPiiU plug-in == DETAILS The HID polling thread was written to be run on a single core, and basically completely occupies it, not allowing any other threads to run on it. It turns out, this is a problem in Aroma, because other things can be running on your cores. For instance, the FTPiiU server thread runs on the same core as the HID polling thread, which explains why FTPiiU stopped working when RetroArch was running. The other problem, is that if FTPiiU is holding the IPC BufPool mutex when RA is started, a deadlock will eventually happen because RA will try to acquire the mutex and the FTPii thread, being suspended, won't be able to release it. So! To fix it: - add a 500-microsecond sleep to the HID polling thread - update to WUT's HID headers, which makes some minor changes to structure member names
1 parent f7975fc commit 2ca2d96

68 files changed

Lines changed: 9311 additions & 14216 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Makefile.wiiu

Lines changed: 18 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
TARGET := retroarch_wiiu
22

3-
BUILD_HBL_ELF = 1
4-
BUILD_RPX = 1
53
DEBUG = 0
64
GRIFFIN_BUILD = 0
7-
SALAMANDER_BUILD = 0
5+
SALAMANDER_BUILD ?= 0
86
HAVE_STATIC_DUMMY ?= 0
97
WHOLE_ARCHIVE_LINK = 0
108
WIIU_HID = 1
@@ -37,18 +35,10 @@ INCDIRS :=
3735
#-----------------------------
3836
# Features and object files
3937

40-
OBJ += wiiu/main.o
4138
OBJ += wiiu/system/memory.o
4239
OBJ += wiiu/system/atomic.o
4340
OBJ += wiiu/system/exception_handler.o
4441
OBJ += wiiu/system/missing_libc_functions.o
45-
OBJ += wiiu/fs/sd_fat_devoptab.o
46-
OBJ += wiiu/fs/fs_utils.o
47-
OBJ += wiiu/hbl.o
48-
49-
RPX_OBJ = $(BUILD_DIR)/wiiu/system/stubs_rpl.o
50-
HBL_ELF_OBJ = $(BUILD_DIR)/wiiu/system/dynamic.o \
51-
$(BUILD_DIR)/wiiu/system/stubs_elf.o
5242

5343
ifeq ($(SALAMANDER_BUILD),1)
5444
DEFINES += -DRARCH_CONSOLE -DIS_SALAMANDER
@@ -248,15 +238,6 @@ ifeq ($(HAVE_BUILTINZLIB),0)
248238
endif
249239
endif
250240

251-
LDFLAGS += -Wl,--gc-sections
252-
253-
RPX_LDFLAGS := -pie -fPIE
254-
RPX_LDFLAGS += -z common-page-size=64 -z max-page-size=64
255-
RPX_LDFLAGS += -T wiiu/link_rpl.ld
256-
RPX_LDFLAGS += -nostartfiles
257-
258-
HBL_ELF_LDFLAGS := -T wiiu/link_elf.ld
259-
260241
#-----------------------------
261242
# Compiler setup
262243

@@ -267,7 +248,7 @@ ifeq ($(strip $(DEVKITPRO)),)
267248
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPRO")
268249
endif
269250

270-
export PATH := $(PATH):$(DEVKITPPC)/bin
251+
export PATH := $(PATH):$(DEVKITPPC)/bin:$(DEVKITPRO)/tools/bin
271252

272253
PREFIX := powerpc-eabi-
273254

@@ -280,25 +261,19 @@ STRIP := $(PREFIX)strip
280261
NM := $(PREFIX)nm
281262
LD := $(CXX)
282263

283-
ELF2RPL := wiiu/wut/elf2rpl/elf2rpl
264+
WUT_ROOT ?= $(DEVKITPRO)/wut
284265

285-
ifneq ($(findstring Linux,$(shell uname -a)),)
286-
else ifneq ($(findstring Darwin,$(shell uname -a)),)
287-
else
288-
ELF2RPL := $(ELF2RPL).exe
289-
endif
266+
RPXSPECS := -specs=$(WUT_ROOT)/share/wut.specs
267+
RPLSPECS := -specs=$(WUT_ROOT)/share/wut.specs -specs=$(WUT_ROOT)/share/rpl.specs
268+
269+
INCDIRS += -I$(WUT_ROOT)/include
270+
LIBDIRS += -L$(WUT_ROOT)/lib
271+
LIBS += -lwut
290272

291273
#-----------------------------
292274
# Targets and build rules
293275

294-
TARGETS :=
295-
ifeq ($(BUILD_RPX), 1)
296-
TARGETS += $(TARGET).rpx
297-
endif
298-
299-
ifeq ($(BUILD_HBL_ELF), 1)
300-
TARGETS += $(TARGET).elf
301-
endif
276+
TARGETS := $(TARGET).rpx
302277

303278
DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.depend
304279

@@ -334,38 +309,21 @@ $(BUILD_DIR)/%.o: %.s %.depend
334309
%.depend: ;
335310
%.last: ;
336311

337-
$(ELF2RPL):
338-
@$(if $(Q), echo MAKE $@,)
339-
$(Q)$(MAKE) -C wiiu/wut/elf2rpl/
340-
341-
$(BUILD_DIR)/$(TARGET).elf: $(OBJ) $(HBL_ELF_OBJ) libretro_wiiu.a wiiu/link_elf.ld .$(TARGET).elf.last
312+
$(BUILD_DIR)/$(TARGET).rpx.elf: $(OBJ) libretro_wiiu.a
342313
@$(if $(Q), echo LD $@,)
343-
@touch .$(TARGET).elf.last
344-
$(Q)$(LD) $(OBJ) $(HBL_ELF_OBJ) $(LDFLAGS) $(HBL_ELF_LDFLAGS) $(LIBDIRS) $(LIBS) -o $@
314+
$(Q)$(LD) $(OBJ) $(RPXSPECS) $(LDFLAGS) $(LIBDIRS) $(LIBS) -o $@
345315

346-
$(BUILD_DIR)/$(TARGET).rpx.elf: $(OBJ) $(RPX_OBJ) libretro_wiiu.a wiiu/link_elf.ld
347-
@$(if $(Q), echo LD $@,)
348-
$(Q)$(LD) $(OBJ) $(RPX_OBJ) $(LDFLAGS) $(RPX_LDFLAGS) $(LIBDIRS) $(LIBS) -o $@
349-
350-
$(BUILD_DIR)/$(TARGET).large.rpx: $(BUILD_DIR)/$(TARGET).rpx.elf $(ELF2RPL) .$(TARGET).rpx.large.last
316+
$(BUILD_DIR)/$(TARGET).rpx: $(BUILD_DIR)/$(TARGET).rpx.elf
351317
@$(if $(Q), echo ELF2RPL $@,)
352-
@touch .$(TARGET).rpx.large.last
353-
$(Q)-$(ELF2RPL) $< $@
354-
355-
$(BUILD_DIR)/$(TARGET).rpx: $(BUILD_DIR)/$(TARGET).large.rpx .$(TARGET).rpx.last
356-
@$(if $(Q), echo COMPRESS $@,)
357-
@touch .$(TARGET).rpx.large.last
358-
$(Q)wiiurpxtool -c $< $@
318+
$(Q)elf2rpl $< $@
359319

360320
clean:
361321
@$(if $(Q), echo $@,)
362-
$(Q)rm -f $(OBJ) $(RPX_OBJ) $(HBL_ELF_OBJ) $(TARGET).elf $(TARGET).rpx.elf $(TARGET).rpx
363-
$(Q)rm -f $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).rpx.elf $(BUILD_DIR)/$(TARGET).large.rpx $(BUILD_DIR)/$(TARGET).rpx
364-
$(Q)rm -f .$(TARGET).elf.last .$(TARGET).rpx.elf.last .$(TARGET).rpx.large.last .$(TARGET).rpx.last
365-
$(Q)rm -f $(OBJ:.o=.depend) $(RPX_OBJ:.o=.depend) $(HBL_ELF_OBJ:.o=.depend)
366-
$(Q)$(MAKE) -C wiiu/wut/elf2rpl/ clean
322+
$(Q)rm -f $(OBJ) $(TARGET).rpx.elf $(TARGET).rpx
323+
$(Q)rm -f $(BUILD_DIR)/$(TARGET).rpx.elf $(BUILD_DIR)/$(TARGET).rpx
324+
$(Q)rm -f $(OBJ:.o=.depend)
367325

368326
.PHONY: clean all
369327
.PRECIOUS: %.depend %.last
370328

371-
-include $(OBJ:.o=.depend) $(RPX_OBJ:.o=.depend) $(HBL_ELF_OBJ:.o=.depend)
329+
-include $(OBJ:.o=.depend)

audio/drivers/wiiu_audio.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@
1818
#include <malloc.h>
1919
#include <stdint.h>
2020

21-
#include <wiiu/os.h>
22-
#include <wiiu/ax.h>
21+
22+
#include <sndcore2/core.h>
23+
#include <sndcore2/ra_multivoice.h>
24+
#include <coreinit/cache.h>
25+
#include <coreinit/spinlock.h>
26+
#include <coreinit/thread.h>
2327

2428
#include "../../wiiu/wiiu_dbg.h"
2529
#include "../../wiiu/system/memory.h"
@@ -75,16 +79,15 @@ void wiiu_ax_callback(void)
7579
}
7680
}
7781

78-
extern void AXRegisterFrameCallback(void *cb);
79-
8082
static void* ax_audio_init(const char* device, unsigned rate, unsigned latency,
8183
unsigned block_frames,
8284
unsigned *new_rate)
8385
{
8486
AXVoiceOffsets offsets[2];
85-
u16 setup_buf[0x30] = {0};
86-
setup_buf[0x25] = 2; /* we request 2 channels */
87-
AXInitParams init = {AX_INIT_RENDERER_48KHZ, 0, 0};
87+
DspConfig setup_buf = {0};
88+
setup_buf.multi_ch_count = 2;
89+
90+
AXInitParams init = {AX_INIT_RENDERER_48KHZ, {0, 0}};
8891
AXVoiceVeData ve = {0x8000, 0};
8992
ax_audio_t* ax = (ax_audio_t*)calloc(1, sizeof(ax_audio_t));
9093

@@ -93,7 +96,7 @@ static void* ax_audio_init(const char* device, unsigned rate, unsigned latency,
9396

9497
AXInitWithParams(&init);
9598

96-
AXAcquireMultiVoice(31, NULL, 0, setup_buf, &ax->mvoice);
99+
AXAcquireMultiVoice(31, NULL, 0, &setup_buf, &ax->mvoice);
97100

98101
if (!ax->mvoice || ax->mvoice->channels != 2)
99102
{

0 commit comments

Comments
 (0)