From 195e686a507b1ff7e0bc9a08a8fdbfd75c35a09c Mon Sep 17 00:00:00 2001 From: Maschell Date: Wed, 29 Apr 2020 17:53:53 +0200 Subject: [PATCH] - Plugins now will be provided in RPX format and have the extension ".wps" - Remove the fs function wrapper --- .gitignore | 7 + Makefile | 185 +++---- {wups_include => include}/wups.h | 0 {wups_include => include}/wups/common.h | 0 {wups_include => include}/wups/config.h | 0 .../wups/config/WUPSConfig.h | 0 .../wups/config/WUPSConfigCategory.h | 0 .../wups/config/WUPSConfigItem.h | 0 .../wups/config/WUPSConfigItemBoolean.h | 0 .../wups/config/WUPSConfigItemIntegerRange.h | 0 .../config/WUPSConfigItemMultipleValues.h | 0 .../wups/function_patching.h | 0 {wups_include => include}/wups/hooks.h | 0 {wups_include => include}/wups/utils.h | 27 +- .../libwups}/config/WUPSConfigItemBoolean.cpp | 0 .../config/WUPSConfigItemIntegerRange.cpp | 0 .../config/WUPSConfigItemMultipleValues.cpp | 0 {src => libraries/libwups}/kernel.cpp | 0 libraries/libwups/main.cpp | 6 + {src => libraries/libwups}/memory.cpp | 0 {src => libraries/libwups}/overlay.cpp | 3 + plugins/example_plugin/Makefile | 322 ++++-------- plugins/example_plugin/makefile.mk | 47 -- share/wups.ld | 476 ++++++++++++++++++ share/wups.specs | 4 + share/wups_rules | 38 ++ src/fs_function_wrapper.cpp | 97 ---- wups.ld | 345 ------------- 28 files changed, 723 insertions(+), 834 deletions(-) rename {wups_include => include}/wups.h (100%) rename {wups_include => include}/wups/common.h (100%) rename {wups_include => include}/wups/config.h (100%) rename {wups_include => include}/wups/config/WUPSConfig.h (100%) rename {wups_include => include}/wups/config/WUPSConfigCategory.h (100%) rename {wups_include => include}/wups/config/WUPSConfigItem.h (100%) rename {wups_include => include}/wups/config/WUPSConfigItemBoolean.h (100%) rename {wups_include => include}/wups/config/WUPSConfigItemIntegerRange.h (100%) rename {wups_include => include}/wups/config/WUPSConfigItemMultipleValues.h (100%) rename {wups_include => include}/wups/function_patching.h (100%) rename {wups_include => include}/wups/hooks.h (100%) rename {wups_include => include}/wups/utils.h (82%) rename {src => libraries/libwups}/config/WUPSConfigItemBoolean.cpp (100%) rename {src => libraries/libwups}/config/WUPSConfigItemIntegerRange.cpp (100%) rename {src => libraries/libwups}/config/WUPSConfigItemMultipleValues.cpp (100%) rename {src => libraries/libwups}/kernel.cpp (100%) create mode 100644 libraries/libwups/main.cpp rename {src => libraries/libwups}/memory.cpp (100%) rename {src => libraries/libwups}/overlay.cpp (99%) delete mode 100644 plugins/example_plugin/makefile.mk create mode 100644 share/wups.ld create mode 100644 share/wups.specs create mode 100644 share/wups_rules delete mode 100644 src/fs_function_wrapper.cpp delete mode 100644 wups.ld diff --git a/.gitignore b/.gitignore index 7bf9c7d..b312c53 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,10 @@ release/* *.layout wups.cbp tools/udp_debug_reader/GeckoLog.txt +*.bz2 +debug/ +*.elf +*.wps +*.save-failed +*.jekyll-metadata +*.cbp diff --git a/Makefile b/Makefile index 051f088..dbefa07 100644 --- a/Makefile +++ b/Makefile @@ -1,70 +1,44 @@ -DO_LOGGING := 0 - -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- -ifeq ($(strip $(DEVKITPPC)),) -$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=devkitPPC) -endif -ifeq ($(strip $(DEVKITPRO)),) -$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=DEVKITPRO) -endif - -export PATH := $(DEVKITPPC)/bin:$(PORTLIBS)/bin:$(PATH) -export PORTLIBS := $(DEVKITPRO)/portlibs/ppc - -PREFIX := powerpc-eabi- - -export AS := $(PREFIX)as -export CC := $(PREFIX)gcc -export CXX := $(PREFIX)g++ -export AR := $(PREFIX)ar -export OBJCOPY := $(PREFIX)objcopy - -include $(DEVKITPPC)/base_rules +TOPDIR ?= $(CURDIR) +include $(TOPDIR)/share/wups_rules + +export WUT_MAJOR := 0 +export WUT_MINOR := 3 +export WUT_PATCH := 0 + +VERSION := $(WUT_MAJOR).$(WUT_MINOR).$(WUT_PATCH) #--------------------------------------------------------------------------------- +# TARGET is the name of the output # BUILD is the directory where object files & intermediate files will be placed # SOURCES is a list of directories containing source code -# INCLUDES is a list of directories containing extra header files -# DATA is a list of directories containing binary files -# LIBDIR is where the built library will be placed -# all directories are relative to this makefile +# DATA is a list of directories containing data files +# INCLUDES is a list of directories containing header files #--------------------------------------------------------------------------------- -BUILD ?= release -SOURCES := src \ - src/config - -INCLUDES := src \ - wups_include -DATA := -LIB := lib +TARGET := wups +#BUILD := build +SOURCES := libraries/libwups/ +DATA := data +INCLUDES := include #--------------------------------------------------------------------------------- # options for code generation #--------------------------------------------------------------------------------- -CFLAGS = -g -Os -Wall -D__wiiu__ -D_GNU_SOURCE $(MACHDEP) $(INCLUDE) -CXXFLAGS = $(CFLAGS) +CFLAGS := -g -Wall -Werror -save-temps \ + -ffunction-sections -fdata-sections \ + $(MACHDEP) \ + $(BUILD_CFLAGS) -ifeq ($(DO_LOGGING), 1) - CFLAGS += -D__LOGGING__ - CXXFLAGS += -D__LOGGING__ -endif +CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__ -D__WUPS__ -ASFLAGS := -mregnames +CXXFLAGS := $(CFLAGS) -std=gnu++17 -export WIIUBIN := $(LIB)/libwups.a - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project -#--------------------------------------------------------------------------------- -LIBS := +ASFLAGS := -g $(MACHDEP) #--------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level containing # include and lib #--------------------------------------------------------------------------------- -LIBDIRS := +LIBDIRS := #--------------------------------------------------------------------------------- # no real need to edit anything past this point unless you need to add additional @@ -73,56 +47,87 @@ LIBDIRS := ifneq ($(BUILD),$(notdir $(CURDIR))) #--------------------------------------------------------------------------------- -export TOPDIR ?= $(CURDIR)/.. -export DEPSDIR := $(CURDIR)/$(BUILD) - -export INCLUDEDIR := $(PORTLIBS)/include/ +export TOPDIR := $(CURDIR) export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ $(foreach dir,$(DATA),$(CURDIR)/$(dir)) CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) -sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) -SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S))) +SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) +DEFFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.def))) BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) +#--------------------------------------------------------------------------------- +# use CXX for linking C++ projects, CC for standard C +#--------------------------------------------------------------------------------- +ifeq ($(strip $(CPPFILES)),) +#--------------------------------------------------------------------------------- + export LD := $(CC) +#--------------------------------------------------------------------------------- +else +#--------------------------------------------------------------------------------- + export LD := $(CXX) +#--------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------- -export OFILES := $(addsuffix .o,$(BINFILES)) \ - $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) $(sFILES:.s=.o) +export OFILES_BIN := $(addsuffix .o,$(BINFILES)) +export OFILES_SRC := $(DEFFILES:.def=.o) $(SFILES:.s=.o) $(CFILES:.c=.o) $(CPPFILES:.cpp=.o) +export OFILES := $(OFILES_BIN) $(OFILES_SRC) +export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES))) export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ - -I$(CURDIR)/$(BUILD) -I$(PORTLIBS)/include + -I. -export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) - -.PHONY: $(BUILD) clean +.PHONY: all dist-bin dist-src dist install clean #--------------------------------------------------------------------------------- -$(BUILD): +all: lib/libwups.a lib/libwupsd.a + +dist-bin: all + @tar --exclude=*~ -cjf wups-$(VERSION).tar.bz2 include lib share + +dist-src: + @tar --exclude=*~ -cjf wups-src-$(VERSION).tar.bz2 include libraries share Makefile + +dist: dist-src dist-bin + +install: dist-bin + mkdir -p $(DESTDIR)$(DEVKITPRO)/wups + bzip2 -cd wups-$(VERSION).tar.bz2 | tar -xf - -C $(DESTDIR)$(DEVKITPRO)/wups + +lib: @[ -d $@ ] || mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile + +release: + @[ -d $@ ] || mkdir -p $@ + +debug: + @[ -d $@ ] || mkdir -p $@ + +lib/libwups.a : lib release $(SOURCES) $(INCLUDES) + @$(MAKE) BUILD=release OUTPUT=$(CURDIR)/$@ \ + BUILD_CFLAGS="-DNDEBUG=1 -O2" \ + DEPSDIR=$(CURDIR)/release \ + --no-print-directory -C release \ + -f $(CURDIR)/Makefile + +lib/libwupsd.a : lib debug $(SOURCES) $(INCLUDES) + @$(MAKE) BUILD=debug OUTPUT=$(CURDIR)/$@ \ + BUILD_CFLAGS="-DDEBUG=1 -Og" \ + DEPSDIR=$(CURDIR)/debug \ + --no-print-directory -C debug \ + -f $(CURDIR)/Makefile + +# Cancel .a rule from devkitPPC/base_rules +%.a: #--------------------------------------------------------------------------------- clean: @echo clean ... - @rm -fr debug release $(LIB) include - -all: $(WIIUBIN) - -WUPSDIR := $(DEVKITPRO)/wups - -# Rule to install wups. -PHONY += install -install : wups.ld - $(addprefix $Qrm -rf ,$(wildcard $(WUPSDIR))) - $Qmkdir $(WUPSDIR) - $Qmkdir $(WUPSDIR)/lib/ - $Qcp -r wups_include $(WUPSDIR)/include - $Qcp -r wups.ld $(WUPSDIR) - $Qcp -r plugin_makefile.mk $(WUPSDIR) - @cp $(BUILD)/lib/libwups.a $(WUPSDIR)/lib/ + @rm -rf release debug lib #--------------------------------------------------------------------------------- else @@ -132,17 +137,19 @@ DEPENDS := $(OFILES:.o=.d) #--------------------------------------------------------------------------------- # main targets #--------------------------------------------------------------------------------- -$(WIIUBIN) : $(OFILES) $(LIB) - @rm -f "$(WIIUBIN)" - @$(AR) rcs "$(WIIUBIN)" $(OFILES) - @echo built ... $(notdir $@) - -$(LIB): - mkdir $(LIB) +$(OUTPUT) : $(OFILES) + +$(OFILES_SRC) : $(HFILES) + +#--------------------------------------------------------------------------------- +%_bin.h %.bin.o : %.bin +#--------------------------------------------------------------------------------- + @echo $(notdir $<) + @$(bin2o) + -include $(DEPENDS) #--------------------------------------------------------------------------------------- endif -#--------------------------------------------------------------------------------------- - +#--------------------------------------------------------------------------------------- \ No newline at end of file diff --git a/wups_include/wups.h b/include/wups.h similarity index 100% rename from wups_include/wups.h rename to include/wups.h diff --git a/wups_include/wups/common.h b/include/wups/common.h similarity index 100% rename from wups_include/wups/common.h rename to include/wups/common.h diff --git a/wups_include/wups/config.h b/include/wups/config.h similarity index 100% rename from wups_include/wups/config.h rename to include/wups/config.h diff --git a/wups_include/wups/config/WUPSConfig.h b/include/wups/config/WUPSConfig.h similarity index 100% rename from wups_include/wups/config/WUPSConfig.h rename to include/wups/config/WUPSConfig.h diff --git a/wups_include/wups/config/WUPSConfigCategory.h b/include/wups/config/WUPSConfigCategory.h similarity index 100% rename from wups_include/wups/config/WUPSConfigCategory.h rename to include/wups/config/WUPSConfigCategory.h diff --git a/wups_include/wups/config/WUPSConfigItem.h b/include/wups/config/WUPSConfigItem.h similarity index 100% rename from wups_include/wups/config/WUPSConfigItem.h rename to include/wups/config/WUPSConfigItem.h diff --git a/wups_include/wups/config/WUPSConfigItemBoolean.h b/include/wups/config/WUPSConfigItemBoolean.h similarity index 100% rename from wups_include/wups/config/WUPSConfigItemBoolean.h rename to include/wups/config/WUPSConfigItemBoolean.h diff --git a/wups_include/wups/config/WUPSConfigItemIntegerRange.h b/include/wups/config/WUPSConfigItemIntegerRange.h similarity index 100% rename from wups_include/wups/config/WUPSConfigItemIntegerRange.h rename to include/wups/config/WUPSConfigItemIntegerRange.h diff --git a/wups_include/wups/config/WUPSConfigItemMultipleValues.h b/include/wups/config/WUPSConfigItemMultipleValues.h similarity index 100% rename from wups_include/wups/config/WUPSConfigItemMultipleValues.h rename to include/wups/config/WUPSConfigItemMultipleValues.h diff --git a/wups_include/wups/function_patching.h b/include/wups/function_patching.h similarity index 100% rename from wups_include/wups/function_patching.h rename to include/wups/function_patching.h diff --git a/wups_include/wups/hooks.h b/include/wups/hooks.h similarity index 100% rename from wups_include/wups/hooks.h rename to include/wups/hooks.h diff --git a/wups_include/wups/utils.h b/include/wups/utils.h similarity index 82% rename from wups_include/wups/utils.h rename to include/wups/utils.h index 935cf30..ff5656c 100644 --- a/wups_include/wups/utils.h +++ b/include/wups/utils.h @@ -45,31 +45,6 @@ typedef struct wups_loader_init_overlay_args_t { DrawTextureFunction drawtexturefunction_ptr; } wups_loader_init_overlay_args_t; -typedef int (*OpenFunction) (const char *pathname, int flags); -typedef ssize_t (*WriteFunction) (int fd, const void *buf, size_t count); -typedef int (*CloseFunction) (int fd); -typedef ssize_t (*ReadFunction) (int fd, void *buf, size_t count); -typedef off_t (*LSeekFunction) (int fd, off_t offset, int whence); -typedef int (*StatFunction) (const char *pathname, struct stat *statbuf); -typedef int (*FStatFunction) (int fd, struct stat *statbuf); -typedef DIR* (*OpenDirFunction) (const char * arg); -typedef int (*CloseDirFunction) (DIR *dirp); -typedef struct dirent * (*ReadDirFunction) (DIR *dirp); -typedef int (*MKDirFunction) (const char *path, mode_t mode); - -typedef struct wups_loader_init_fs_args_t { - OpenFunction open_repl; - CloseFunction close_repl; - WriteFunction write_repl; - ReadFunction read_repl; - LSeekFunction lseek_repl; - StatFunction stat_repl; - FStatFunction fstat_repl; - OpenDirFunction opendir_repl; - CloseDirFunction closedir_repl; - ReadDirFunction readdir_repl; - MKDirFunction mkdir_repl; -} wups_loader_init_fs_args_t; typedef uint32_t (*KernelReadFunction)(const void *addr); typedef void (*KernelWriteFunction)(void *addr, uint32_t value); @@ -98,7 +73,7 @@ typedef struct wups_loader_init_vid_mem_args_t_ { The whole point of replacing the fs functions is to inherit SD/USB access. The argument of the ON_APPLICATION_START hook provides information on the state of SD or USB access. **/ -void WUPS_InitFS(wups_loader_init_fs_args_t args); +//void WUPS_InitFS(wups_loader_init_fs_args_t args); /** Sets the function pointer for opening the overlay. diff --git a/src/config/WUPSConfigItemBoolean.cpp b/libraries/libwups/config/WUPSConfigItemBoolean.cpp similarity index 100% rename from src/config/WUPSConfigItemBoolean.cpp rename to libraries/libwups/config/WUPSConfigItemBoolean.cpp diff --git a/src/config/WUPSConfigItemIntegerRange.cpp b/libraries/libwups/config/WUPSConfigItemIntegerRange.cpp similarity index 100% rename from src/config/WUPSConfigItemIntegerRange.cpp rename to libraries/libwups/config/WUPSConfigItemIntegerRange.cpp diff --git a/src/config/WUPSConfigItemMultipleValues.cpp b/libraries/libwups/config/WUPSConfigItemMultipleValues.cpp similarity index 100% rename from src/config/WUPSConfigItemMultipleValues.cpp rename to libraries/libwups/config/WUPSConfigItemMultipleValues.cpp diff --git a/src/kernel.cpp b/libraries/libwups/kernel.cpp similarity index 100% rename from src/kernel.cpp rename to libraries/libwups/kernel.cpp diff --git a/libraries/libwups/main.cpp b/libraries/libwups/main.cpp new file mode 100644 index 0000000..93a324f --- /dev/null +++ b/libraries/libwups/main.cpp @@ -0,0 +1,6 @@ +extern "C" void OSFatal(const char *msg); + +extern "C" void __wups_start(){ + OSFatal("This file needs to be run with the Wii U Plugin System."); +} + \ No newline at end of file diff --git a/src/memory.cpp b/libraries/libwups/memory.cpp similarity index 100% rename from src/memory.cpp rename to libraries/libwups/memory.cpp diff --git a/src/overlay.cpp b/libraries/libwups/overlay.cpp similarity index 99% rename from src/overlay.cpp rename to libraries/libwups/overlay.cpp index 4f6d054..31d1115 100644 --- a/src/overlay.cpp +++ b/libraries/libwups/overlay.cpp @@ -1,3 +1,5 @@ + +#define _GNU_SOURCE #include #include #include @@ -15,6 +17,7 @@ extern "C" { #endif + void OSScreenInit(void); void OSScreenShutdown(void); uint32_t OSScreenGetBufferSizeEx(uint32_t bufferNum); diff --git a/plugins/example_plugin/Makefile b/plugins/example_plugin/Makefile index d83c8d3..885bc98 100644 --- a/plugins/example_plugin/Makefile +++ b/plugins/example_plugin/Makefile @@ -1,272 +1,134 @@ -# You probably never need to adjust this Makefile. -# All changes can be done in the makefile.mk - -#--------------------------------------------------------------------------------- -# Clear the implicit built in rules -#--------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- .SUFFIXES: -#--------------------------------------------------------------------------------- -ifeq ($(strip $(DEVKITPPC)),) -$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=devkitPPC") -endif +#------------------------------------------------------------------------------- + ifeq ($(strip $(DEVKITPRO)),) -$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=devkitPRO") +$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=/devkitpro") endif -export PATH := $(DEVKITPPC)/bin:$(PORTLIBS)/bin:$(PATH) -export PORTLIBS := $(DEVKITPRO)/portlibs/ppc -export WUPSDIR := $(DEVKITPRO)/wups -export GCC_VER := $(shell $(DEVKITPPC)/bin/powerpc-eabi-gcc -dumpversion) +TOPDIR ?= $(CURDIR) -PREFIX := powerpc-eabi- +include $(DEVKITPRO)/wups/share/wups_rules -export AS := $(PREFIX)as -export CC := $(PREFIX)gcc -export CXX := $(PREFIX)g++ -export LD := $(PREFIX)ld -export AR := $(PREFIX)ar -export OBJCOPY := $(PREFIX)objcopy - -#--------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- # TARGET is the name of the output # BUILD is the directory where object files & intermediate files will be placed # SOURCES is a list of directories containing source code -# INCLUDES is a list of directories containing extra header files -#--------------------------------------------------------------------------------- +# DATA is a list of directories containing data files +# INCLUDES is a list of directories containing header files +#------------------------------------------------------------------------------- TARGET := $(notdir $(CURDIR)) -BUILD := build +BUILD := build +SOURCES := src src/utils +DATA := data +INCLUDES := src -ifeq ($(notdir $(CURDIR)),$(BUILD)) - include ../makefile.mk -else - include makefile.mk -endif - -include $(WUPSDIR)/plugin_makefile.mk - - -#MAP ?= $(TARGET:.mod=.map) - -#--------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- # options for code generation -#--------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- +CFLAGS := -g -Wall -O2 -ffunction-sections \ + $(MACHDEP) -MACHDEP = -DESPRESSO -mcpu=750 -meabi -mhard-float +CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__ -D__WUPS__ -# -Os: optimise size -# -Wall: generate lots of warnings -# -D__wiiu__: define the symbol __wiiu__ (used in some headers) -# -mcpu=750: enable processor specific compilation -# -meabi: enable eabi specific compilation -# -mhard-float: enable hardware floating point instructions -# -nostartfiles: Do not use the standard system startup files when linking -# -ffunction-sections: split up functions so linker can garbage collect -# -fdata-sections: split up data so linker can garbage collect -COMMON_CFLAGS := -O0 -Wall $(MACHDEP) -meabi -ffunction-sections -fdata-sections -Wl,-q $(COMMON_CFLAGS) +CXXFLAGS := $(CFLAGS) -CFLAGS += -D__WIIU__ -D__WUT__ +ASFLAGS := -g $(ARCH) +LDFLAGS = -g $(ARCH) $(WUPSSPECS) -Wl,-Map,$(notdir $*.map) -# -x c: compile as c code -# -std=c11: use the c11 standard -CFLAGS := $(COMMON_CFLAGS) -x c -std=gnu11 $(CFLAGS) +LIBS := -lwups -lwut -# -x c++: compile as c++ code -# -std=gnu++11: use the c++11 standard -CXXFLAGS := $(COMMON_CFLAGS) -x c++ -std=gnu++11 $(CXXFLAGS) +#------------------------------------------------------------------------------- +# list of directories containing libraries, this must be the top level +# containing include and lib +#------------------------------------------------------------------------------- +LIBDIRS := $(PORTLIBS) $(WUPS_ROOT) $(WUT_ROOT) -#--------------------------------------------------------------------------------- -# any extra ld flags -#-------------------------------------------------------------------------------- -# --gc-sections: remove unneeded symbols -# -Map: generate a map file -LDFLAGS += $(ARCH) -Wl,-Map,$(notdir $@).map,--gc-sections,-wrap,__gxx_personality_v0 - - -#--------------------------------------------------------------------------------- -Q := @ -MAKEFLAGS += --no-print-directory -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project -#--------------------------------------------------------------------------------- -LIBS += -# -#--------------------------------------------------------------------------------- -# list of directories containing libraries, this must be the top level containing -# include and lib -#--------------------------------------------------------------------------------- -LIBDIRS += - -#--------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- # no real need to edit anything past this point unless you need to add additional # rules for different file extensions -#--------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- -export PROJECTDIR := $(CURDIR) -export OUTPUT := $(CURDIR)/$(TARGETDIR)/$(TARGET) -export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ - $(foreach dir,$(DATA),$(CURDIR)/$(dir)) -export DEPSDIR := $(CURDIR)/$(BUILD) - -#--------------------------------------------------------------------------------- -# automatically build a list of object files for our project -#--------------------------------------------------------------------------------- -CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) -CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) -sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) -SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S))) -BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) -TTFFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.ttf))) -PNGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.png))) - -#--------------------------------------------------------------------------------- -# use CXX for linking C++ projects, CC for standard C -#--------------------------------------------------------------------------------- -ifeq ($(strip $(CPPFILES)),) - export REAL_LD := $(CC) -else - export REAL_LD := $(CXX) -endif - -export OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \ - $(sFILES:.s=.o) $(SFILES:.S=.o) \ - $(PNGFILES:.png=.png.o) $(addsuffix .o,$(BINFILES)) - -#--------------------------------------------------------------------------------- -# build a list of include paths -#--------------------------------------------------------------------------------- -export INCLUDE_FULL += $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ - $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ - $(EXTERNAL_INCLUDE) - -#--------------------------------------------------------------------------------- -# build a list of library paths -#--------------------------------------------------------------------------------- -export LIBPATHS_FULL += $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \ - $(EXTERNAL_LIBPATHS) - +#------------------------------------------------------------------------------- export OUTPUT := $(CURDIR)/$(TARGET) -.PHONY: $(BUILD) clean install +export TOPDIR := $(CURDIR) + +export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ + $(foreach dir,$(DATA),$(CURDIR)/$(dir)) + +export DEPSDIR := $(CURDIR)/$(BUILD) + +CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) +CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) +SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) +BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) + +#------------------------------------------------------------------------------- +# use CXX for linking C++ projects, CC for standard C +#------------------------------------------------------------------------------- +ifeq ($(strip $(CPPFILES)),) +#------------------------------------------------------------------------------- + export LD := $(CC) +#------------------------------------------------------------------------------- +else +#------------------------------------------------------------------------------- + export LD := $(CXX) +#------------------------------------------------------------------------------- +endif +#------------------------------------------------------------------------------- + +export OFILES_BIN := $(addsuffix .o,$(BINFILES)) +export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) +export OFILES := $(OFILES_BIN) $(OFILES_SRC) +export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES))) + +export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ + $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ + -I$(CURDIR)/$(BUILD) + +export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) + +.PHONY: $(BUILD) clean all + +#------------------------------------------------------------------------------- +all: $(BUILD) -#--------------------------------------------------------------------------------- $(BUILD): @[ -d $@ ] || mkdir -p $@ @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- clean: @echo clean ... - @rm -fr $(BUILD) $(OUTPUT).mod $(OUTPUT) + @rm -fr $(BUILD) $(TARGET).wps $(TARGET).elf -#--------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- else +.PHONY: all DEPENDS := $(OFILES:.o=.d) -THIS_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) +#------------------------------------------------------------------------------- +# main targets +#------------------------------------------------------------------------------- +all : $(OUTPUT).wps -############################################################################### -# Rule to make everything. -PHONY += all +$(OUTPUT).wps : $(OUTPUT).elf +$(OUTPUT).elf : $(OFILES) -all : $(OUTPUT) -############################################################################### -# Special build rules +$(OFILES_SRC) : $(HFILES_BIN) - -# Rule to make the module file. -$(OUTPUT) : $(OFILES) - @echo "linking ... " $@ - @$(REAL_LD) $(OFILES) $(LDFLAGS) $(LIBS) $(LIBPATHS_FULL) -o $@ - -############################################################################### -# Standard build rules -#--------------------------------------------------------------------------------- -%.a: -#--------------------------------------------------------------------------------- - @echo $(notdir $@) - @rm -f $@ - @$(AR) -rc $@ $^ - -#--------------------------------------------------------------------------------- -%.o: %.cpp +#------------------------------------------------------------------------------- +# you need a rule like this for each extension you use as binary data +#------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.bin +#------------------------------------------------------------------------------- @echo $(notdir $<) - @$(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) $(INCLUDE_FULL) -c $< -o $@ $(ERROR_FILTER) + @$(bin2o) -#--------------------------------------------------------------------------------- -%.o: %.c - @echo $(notdir $<) - @$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) $(INCLUDE_FULL) -c $< -o $@ $(ERROR_FILTER) - -#--------------------------------------------------------------------------------- -%.o: %.S - @echo $(notdir $<) - @$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(INCLUDE_FULL) -c $< -o $@ $(ERROR_FILTER) - -#--------------------------------------------------------------------------------- -%.png.o : %.png - @echo $(notdir $<) - @bin2s -a 32 $< | $(AS) -o $(@) - -#--------------------------------------------------------------------------------- -%.jpg.o : %.jpg - @echo $(notdir $<) - @bin2s -a 32 $< | $(AS) -o $(@) - -#--------------------------------------------------------------------------------- -%.ttf.o : %.ttf - @echo $(notdir $<) - @bin2s -a 32 $< | $(AS) -o $(@) - -#--------------------------------------------------------------------------------- -%.bin.o : %.bin - @echo $(notdir $<) - @bin2s -a 32 $< | $(AS) -o $(@) - -#--------------------------------------------------------------------------------- -%.wav.o : %.wav - @echo $(notdir $<) - @bin2s -a 32 $< | $(AS) -o $(@) - -#--------------------------------------------------------------------------------- -%.mp3.o : %.mp3 - @echo $(notdir $<) - @bin2s -a 32 $< | $(AS) -o $(@) - -#--------------------------------------------------------------------------------- -%.ogg.o : %.ogg - @echo $(notdir $<) - @bin2s -a 32 $< | $(AS) -o $(@) - -############################################################################### -# Assembly listing rules - -# Rule to make assembly listing. -PHONY += list -list : $(LIST) - -# Rule to make the listing file. -%.list : $(TARGET) - $(LOG) - -$Qmkdir -p $(dir $@) - $Q$(OBJDUMP) -d $< > $@ - -############################################################################### -# Clean rule - -# Rule to clean files. -PHONY += clean -clean : - $Qrm -rf $(wildcard $(BUILD) $(BIN)) - -############################################################################### -# Phony targets - -.PHONY : $(PHONY) - -include $(DEPENDS) -#--------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- endif -#--------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- diff --git a/plugins/example_plugin/makefile.mk b/plugins/example_plugin/makefile.mk deleted file mode 100644 index 2f66458..0000000 --- a/plugins/example_plugin/makefile.mk +++ /dev/null @@ -1,47 +0,0 @@ -# Target filename -TARGET := $(notdir $(CURDIR)).mod - -# Source directories -SOURCES := src src/utils - -# Data directories -DATA := - -# Include directories -INCLUDES := src - -#--------------------------------------------------------------------------------- -# options for code generation and linking -#--------------------------------------------------------------------------------- -# Extra C AND C++ compiler flags -COMMON_CFLAGS := -# Extra C compiler flags -CFLAGS := -# Extra C++ compiler flags -CXXFLAGS := -# Extra linking flags for all linking steps -LDFLAGS := - -#--------------------------------------------------------------------------------- -# list of directories containing libraries, this must be the top level containing -# include and lib -#--------------------------------------------------------------------------------- -LIBDIRS := $(WUPSDIR) $(WUT_ROOT) $(PORTLIBS) - -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project -#--------------------------------------------------------------------------------- -LIBS := -lwut -lwups - -#--------------------------------------------------------------------------------- -# Will be added to the final lib paths -# example: -# -L$C:/library1/lib -#--------------------------------------------------------------------------------- -EXTERNAL_LIBPATHS := - -#--------------------------------------------------------------------------------- -# Will be added to the final include paths -# -IC:/library1/include -#--------------------------------------------------------------------------------- -EXTERNAL_INCLUDE := diff --git a/share/wups.ld b/share/wups.ld new file mode 100644 index 0000000..11470d0 --- /dev/null +++ b/share/wups.ld @@ -0,0 +1,476 @@ +OUTPUT_FORMAT("elf32-powerpc") +OUTPUT_ARCH(powerpc:common) + +MEMORY { + relmem (rw) : ORIGIN = 0x00000000, LENGTH = 32M + codemem (rwx) : ORIGIN = 0x02000000, LENGTH = 224M + datamem (rw) : ORIGIN = 0x10000000, LENGTH = 800M + loadmem (rwx) : ORIGIN = 0xC0000000, LENGTH = 128M +} + +ENTRY(__rpx_start) + +SECTIONS +{ + . = ORIGIN(codemem); + .syscall ALIGN(32) : { + *(.syscall .syscall.*) + } > codemem + + .text ALIGN(32) : { + KEEP (*crt0.o(*.init)) + KEEP (*(.init)) + + *(.text) + *(.text.*) + *(.gnu.warning) + *(.gnu.linkonce.t.*) + + KEEP (*(.fini)) + } > codemem + + . = ORIGIN(datamem); + .rodata : { + *(.rodata) + *(.rodata.*) + *(.gnu.linkonce.r.*) + + *(.preinit_array) + *(.init_array) + *(.fini_array) + + KEEP (*crtbegin.o(.ctors)) + KEEP (*(EXCLUDE_FILE (*crtend.o ) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + + KEEP (*crtbegin.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o ) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + + *(.jcr) + *(.dynamic) + *(.eh_frame_hdr) + KEEP (*(.eh_frame)) + *(.fixup) + *(.gcc_except_table) + *(.gcc_except_table.*) + *(.got) + *(.got1) + *(.got2) + *(.got.plt) + *(.plt) + *(.tm_clone_table) + } > datamem + + .data : { + *(.data) + *(.data.*) + *(.gnu.linkonce.d.*) + SORT(CONSTRUCTORS) + + __sdata_start = .; + *(.sdata) + *(.sdata.*) + *(.gnu.linkonce.s.*) + __sdata_end = .; + + __sdata2_start = .; + *(.sdata2) + *(.sdata2.*) + *(.gnu.linkonce.s2.*) + __sdata2_end = .; + } > datamem + + __bss_start = .; + .bss (NOLOAD) : { + *(.dynbss) + *(.bss) + *(.bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + + __sbss_start = .; + *(.dynsbss) + *(.sbss) + *(.sbss.*) + *(.gnu.linkonce.sb.*) + *(.scommon) + __sbss_end = .; + + __sbss2_start = .; + *(.sbss2) + *(.sbss2.*) + *(.gnu.linkonce.sb2.*) + __sbss2_end = .; + } > datamem + __bss_end = .; + + . = ORIGIN(relmem); + .rela.text ALIGN(4) : { + *(.rela.text) + *(.rela.text.*) + *(.rela.gnu.linkonce.t.*) + *(.rela.init) + *(.rela.fini) + } > relmem + .rela.data ALIGN(4) : { + *(.rela.data) + *(.rela.data.*) + *(.rela.gnu.linkonce.d.*) + *(.rela.sdata) + *(.rela.gnu.linkonce.s.*) + *(.rela.sdata2) + *(.rela.gnu.linkonce.s2.*) + *(.rela.init_array) + *(.rela.fini_array) + *(.rela.gcc_except_table .rela.gcc_except_table.*) + *(.rela.eh_frame) + *(.rela.got) + *(.rela.got1) + *(.rela.got2) + *(.rela.got.plt) + *(.rela.plt) + } > relmem + .rela.rodata ALIGN(4) : { + *(.rela.rodata) + *(.rela.rodata.*) + *(.rel.gnu.linkonce.r.*) + *(.rela.ctors) + *(.rela.dtors) + } > relmem + + . = ORIGIN(loadmem); + .fexports ALIGN(32) : { KEEP( *(.fexports) ) } > loadmem + .dexports ALIGN(32) : { KEEP( *(.dexports) ) } > loadmem + + .fimport_avm ALIGN(16) : { + KEEP ( *(.fimport_avm) ) + *(.fimport_avm.*) + } > loadmem + .fimport_camera ALIGN(16) : { + KEEP ( *(.fimport_camera) ) + *(.fimport_camera.*) + } > loadmem + .fimport_coreinit ALIGN(16) : { + KEEP ( *(.fimport_coreinit) ) + *(.fimport_coreinit.*) + } > loadmem + .fimport_dc ALIGN(16) : { + KEEP ( *(.fimport_dc) ) + *(.fimport_dc.*) + } > loadmem + .fimport_dmae ALIGN(16) : { + KEEP ( *(.fimport_dmae) ) + *(.fimport_dmae.*) + } > loadmem + .fimport_drmapp ALIGN(16) : { + KEEP ( *(.fimport_drmapp) ) + *(.fimport_drmapp.*) + } > loadmem + .fimport_erreula ALIGN(16) : { + KEEP ( *(.fimport_erreula) ) + *(.fimport_erreula.*) + } > loadmem + .fimport_gx2 ALIGN(16) : { + KEEP ( *(.fimport_gx2) ) + *(.fimport_gx2.*) + } > loadmem + .fimport_h264 ALIGN(16) : { + KEEP ( *(.fimport_h264) ) + *(.fimport_h264.*) + } > loadmem + .fimport_lzma920 ALIGN(16) : { + KEEP ( *(.fimport_lzma920) ) + *(.fimport_lzma920.*) + } > loadmem + .fimport_mic ALIGN(16) : { + KEEP ( *(.fimport_mic) ) + *(.fimport_mic.*) + } > loadmem + .fimport_nfc ALIGN(16) : { + KEEP ( *(.fimport_nfc) ) + *(.fimport_nfc.*) + } > loadmem + .fimport_nio_prof ALIGN(16) : { + KEEP ( *(.fimport_nio_prof) ) + *(.fimport_nio_prof.*) + } > loadmem + .fimport_nlibcurl ALIGN(16) : { + KEEP ( *(.fimport_nlibcurl) ) + *(.fimport_nlibcurl.*) + } > loadmem + .fimport_nlibnss2 ALIGN(16) : { + KEEP ( *(.fimport_nlibnss2) ) + *(.fimport_nlibnss2.*) + } > loadmem + .fimport_nlibnss ALIGN(16) : { + KEEP ( *(.fimport_nlibnss) ) + *(.fimport_nlibnss.*) + } > loadmem + .fimport_nn_ac ALIGN(16) : { + KEEP ( *(.fimport_nn_ac) ) + *(.fimport_nn_ac.*) + } > loadmem + .fimport_nn_acp ALIGN(16) : { + KEEP ( *(.fimport_nn_acp) ) + *(.fimport_nn_acp.*) + } > loadmem + .fimport_nn_act ALIGN(16) : { + KEEP ( *(.fimport_nn_act) ) + *(.fimport_nn_act.*) + } > loadmem + .fimport_nn_aoc ALIGN(16) : { + KEEP ( *(.fimport_nn_aoc) ) + *(.fimport_nn_aoc.*) + } > loadmem + .fimport_nn_boss ALIGN(16) : { + KEEP ( *(.fimport_nn_boss) ) + *(.fimport_nn_boss.*) + } > loadmem + .fimport_nn_ccr ALIGN(16) : { + KEEP ( *(.fimport_nn_ccr) ) + *(.fimport_nn_ccr.*) + } > loadmem + .fimport_nn_cmpt ALIGN(16) : { + KEEP ( *(.fimport_nn_cmpt) ) + *(.fimport_nn_cmpt.*) + } > loadmem + .fimport_nn_dlp ALIGN(16) : { + KEEP ( *(.fimport_nn_dlp) ) + *(.fimport_nn_dlp.*) + } > loadmem + .fimport_nn_ec ALIGN(16) : { + KEEP ( *(.fimport_nn_ec) ) + *(.fimport_nn_ec.*) + } > loadmem + .fimport_nn_fp ALIGN(16) : { + KEEP ( *(.fimport_nn_fp) ) + *(.fimport_nn_fp.*) + } > loadmem + .fimport_nn_hai ALIGN(16) : { + KEEP ( *(.fimport_nn_hai) ) + *(.fimport_nn_hai.*) + } > loadmem + .fimport_nn_hpad ALIGN(16) : { + KEEP ( *(.fimport_nn_hpad) ) + *(.fimport_nn_hpad.*) + } > loadmem + .fimport_nn_idbe ALIGN(16) : { + KEEP ( *(.fimport_nn_idbe) ) + *(.fimport_nn_idbe.*) + } > loadmem + .fimport_nn_ndm ALIGN(16) : { + KEEP ( *(.fimport_nn_ndm) ) + *(.fimport_nn_ndm.*) + } > loadmem + .fimport_nn_nets2 ALIGN(16) : { + KEEP ( *(.fimport_nn_nets2) ) + *(.fimport_nn_nets2.*) + } > loadmem + .fimport_nn_nfp ALIGN(16) : { + KEEP ( *(.fimport_nn_nfp) ) + *(.fimport_nn_nfp.*) + } > loadmem + .fimport_nn_nim ALIGN(16) : { + KEEP ( *(.fimport_nn_nim) ) + *(.fimport_nn_nim.*) + } > loadmem + .fimport_nn_olv ALIGN(16) : { + KEEP ( *(.fimport_nn_olv) ) + *(.fimport_nn_olv.*) + } > loadmem + .fimport_nn_pdm ALIGN(16) : { + KEEP ( *(.fimport_nn_pdm) ) + *(.fimport_nn_pdm.*) + } > loadmem + .fimport_nn_save ALIGN(16) : { + KEEP ( *(.fimport_nn_save) ) + *(.fimport_nn_save.*) + } > loadmem + .fimport_nn_sl ALIGN(16) : { + KEEP ( *(.fimport_nn_sl) ) + *(.fimport_nn_sl.*) + } > loadmem + .fimport_nn_spm ALIGN(16) : { + KEEP ( *(.fimport_nn_spm) ) + *(.fimport_nn_spm.*) + } > loadmem + .fimport_nn_temp ALIGN(16) : { + KEEP ( *(.fimport_nn_temp) ) + *(.fimport_nn_temp.*) + } > loadmem + .fimport_nn_uds ALIGN(16) : { + KEEP ( *(.fimport_nn_uds) ) + *(.fimport_nn_uds.*) + } > loadmem + .fimport_nn_vctl ALIGN(16) : { + KEEP ( *(.fimport_nn_vctl) ) + *(.fimport_nn_vctl.*) + } > loadmem + .fimport_nsysccr ALIGN(16) : { + KEEP ( *(.fimport_nsysccr) ) + *(.fimport_nsysccr.*) + } > loadmem + .fimport_nsyshid ALIGN(16) : { + KEEP ( *(.fimport_nsyshid) ) + *(.fimport_nsyshid.*) + } > loadmem + .fimport_nsyskbd ALIGN(16) : { + KEEP ( *(.fimport_nsyskbd) ) + *(.fimport_nsyskbd.*) + } > loadmem + .fimport_nsysnet ALIGN(16) : { + KEEP ( *(.fimport_nsysnet) ) + *(.fimport_nsysnet.*) + } > loadmem + .fimport_nsysuhs ALIGN(16) : { + KEEP ( *(.fimport_nsysuhs) ) + *(.fimport_nsysuhs.*) + } > loadmem + .fimport_nsysuvd ALIGN(16) : { + KEEP ( *(.fimport_nsysuvd) ) + *(.fimport_nsysuvd.*) + } > loadmem + .fimport_ntag ALIGN(16) : { + KEEP ( *(.fimport_ntag) ) + *(.fimport_ntag.*) + } > loadmem + .fimport_padscore ALIGN(16) : { + KEEP ( *(.fimport_padscore) ) + *(.fimport_padscore.*) + } > loadmem + .fimport_proc_ui ALIGN(16) : { + KEEP ( *(.fimport_proc_ui) ) + *(.fimport_proc_ui.*) + } > loadmem + .fimport_sndcore2 ALIGN(16) : { + KEEP ( *(.fimport_sndcore2) ) + *(.fimport_sndcore2.*) + } > loadmem + .fimport_snd_core ALIGN(16) : { + KEEP ( *(.fimport_snd_core) ) + *(.fimport_snd_core.*) + } > loadmem + .fimport_snduser2 ALIGN(16) : { + KEEP ( *(.fimport_snduser2) ) + *(.fimport_snduser2.*) + } > loadmem + .fimport_snd_user ALIGN(16) : { + KEEP ( *(.fimport_snd_user) ) + *(.fimport_snd_user.*) + } > loadmem + .fimport_swkbd ALIGN(16) : { + KEEP ( *(.fimport_swkbd) ) + *(.fimport_swkbd.*) + } > loadmem + .fimport_sysapp ALIGN(16) : { + KEEP ( *(.fimport_sysapp) ) + *(.fimport_sysapp.*) + } > loadmem + .fimport_tcl ALIGN(16) : { + KEEP ( *(.fimport_tcl) ) + *(.fimport_tcl.*) + } > loadmem + .fimport_tve ALIGN(16) : { + KEEP ( *(.fimport_tve) ) + *(.fimport_tve.*) + } > loadmem + .fimport_uac ALIGN(16) : { + KEEP ( *(.fimport_uac) ) + *(.fimport_uac.*) + } > loadmem + .fimport_uac_rpl ALIGN(16) : { + KEEP ( *(.fimport_uac_rpl) ) + *(.fimport_uac_rpl.*) + } > loadmem + .fimport_usb_mic ALIGN(16) : { + KEEP ( *(.fimport_usb_mic) ) + *(.fimport_usb_mic.*) + } > loadmem + .fimport_uvc ALIGN(16) : { + KEEP ( *(.fimport_uvc) ) + *(.fimport_uvc.*) + } > loadmem + .fimport_uvd ALIGN(16) : { + KEEP ( *(.fimport_uvd) ) + *(.fimport_uvd.*) + } > loadmem + .fimport_vpadbase ALIGN(16) : { + KEEP ( *(.fimport_vpadbase) ) + *(.fimport_vpadbase.*) + } > loadmem + .fimport_vpad ALIGN(16) : { + KEEP ( *(.fimport_vpad) ) + *(.fimport_vpad.*) + } > loadmem + .fimport_zlib125 ALIGN(16) : { + KEEP ( *(.fimport_zlib125) ) + *(.fimport_zlib125.*) + } > loadmem + + .dimport_coreinit ALIGN(16) : { + KEEP ( *(.dimport_coreinit) ) + *(.dimport_coreinit.*) + } > loadmem + .dimport_nn_act ALIGN(16) : { + KEEP ( *(.dimport_nn_act) ) + *(.dimport_nn_act.*) + } > loadmem + .dimport_nn_boss ALIGN(16) : { + KEEP ( *(.dimport_nn_boss) ) + *(.dimport_nn_boss.*) + } > loadmem + .dimport_nn_ec ALIGN(16) : { + KEEP ( *(.dimport_nn_ec) ) + *(.dimport_nn_ec.*) + } > loadmem + .dimport_nn_nim ALIGN(16) : { + KEEP ( *(.dimport_nn_nim) ) + *(.dimport_nn_nim.*) + } > loadmem + .dimport_nn_sl ALIGN(16) : { + KEEP ( *(.dimport_nn_sl) ) + *(.dimport_nn_sl.*) + } > loadmem + .dimport_nn_uds ALIGN(16) : { + KEEP ( *(.dimport_nn_uds) ) + *(.dimport_nn_uds.*) + } > loadmem + + .symtab ALIGN(4) : { *(.symtab) } > loadmem + .strtab ALIGN(1) : { *(.strtab) } > loadmem + .shstrtab ALIGN(1) : { *(.shstrtab) } > loadmem + + __SDATA_START__ = __sdata_start; + __SBSS_END__ = __sbss_end; + + __SDATA2_START__ = __sdata2_start; + __SBSS2_END__ = __sbss2_end; + + _SDA_BASE_ = __sbss_end; + _SDA2_BASE_ = __sdata2_start + ((__sbss2_end - __sdata2_start) / 2); + + .wups.meta : { + *(.wups.meta*) + KEEP(*(.wups.meta*)) + } > datamem + .wups.load : { + *(.wups.load*) + KEEP(*(.wups.load*)) + } > datamem + .wups.hooks : { + *(.wups.hooks*) + KEEP(*(.wups.hooks*)) + } > datamem + + /DISCARD/ : { + *(.abs) + *(.comment) + *(.gnu.attributes) + *(.gnu.version) + *(.gnu.version_d) + *(.gnu.version_r) + } +} \ No newline at end of file diff --git a/share/wups.specs b/share/wups.specs new file mode 100644 index 0000000..b27fa1d --- /dev/null +++ b/share/wups.specs @@ -0,0 +1,4 @@ +%rename link old_link + +*link: +%(old_link) -T %:getenv(DEVKITPRO /wups/share/wups.ld) --gc-sections --emit-relocs -z nocopyreloc -wrap __gxx_personality_v0 --entry=__wups_start \ No newline at end of file diff --git a/share/wups_rules b/share/wups_rules new file mode 100644 index 0000000..cc2a6ac --- /dev/null +++ b/share/wups_rules @@ -0,0 +1,38 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITPRO)),) +$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=/devkitPro") +endif + +ifeq ($(strip $(DEVKITPPC)),) +$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=/devkitPro/devkitPPC") +endif + +include $(DEVKITPPC)/base_rules + +PORTLIBS := $(PORTLIBS_PATH)/wiiu $(PORTLIBS_PATH)/ppc + +export PATH := $(PORTLIBS_PATH)/wiiu/bin:$(PORTLIBS_PATH)/ppc/bin:$(PATH) + +WUPS_ROOT ?= $(DEVKITPRO)/wups + +WUPSSPECS := -specs=$(WUPS_ROOT)/share/wups.specs + +MACHDEP = -DESPRESSO -mcpu=750 -meabi -mhard-float + +#--------------------------------------------------------------------------------- +%.wps: %.elf + @cp $< $*.strip.elf + @$(STRIP) -g $*.strip.elf + @elf2rpl $*.strip.elf $@ + @printf '\xDE\xAD' | dd of=$@ bs=1 seek=9 count=2 conv=notrunc status=none + @rm $*.strip.elf + @echo built ... $(notdir $@) + +#--------------------------------------------------------------------------------- +%.elf: + @echo linking ... $(notdir $@) + @$(LD) $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@ + @$(NM) -CSn $@ > $(notdir $*.lst) diff --git a/src/fs_function_wrapper.cpp b/src/fs_function_wrapper.cpp deleted file mode 100644 index d7c9bd3..0000000 --- a/src/fs_function_wrapper.cpp +++ /dev/null @@ -1,97 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -static OpenFunction new_open_ptr __attribute__((section(".data"))) = NULL; -static CloseFunction new_close_ptr __attribute__((section(".data"))) = NULL; -static WriteFunction new_write_ptr __attribute__((section(".data"))) = NULL; -static ReadFunction new_read_ptr __attribute__((section(".data"))) = NULL; -static LSeekFunction new_lseek_ptr __attribute__((section(".data"))) = NULL; -static StatFunction new_stat_ptr __attribute__((section(".data"))) = NULL; -static FStatFunction new_fstat_ptr __attribute__((section(".data"))) = NULL; -static OpenDirFunction new_opendir_ptr __attribute__((section(".data"))) = NULL; -static CloseDirFunction new_closedir_ptr __attribute__((section(".data"))) = NULL; -static ReadDirFunction new_readdir_ptr __attribute__((section(".data"))) = NULL; -static MKDirFunction new_mkdir_ptr __attribute__((section(".data"))) = NULL; - -#ifdef __cplusplus -extern "C" { -#endif -void WUPS_InitFS(wups_loader_init_fs_args_t args) { - new_open_ptr = args.open_repl; - new_close_ptr = args.close_repl; - new_write_ptr = args.write_repl; - new_read_ptr = args.read_repl; - new_lseek_ptr = args.lseek_repl; - new_stat_ptr = args.stat_repl; - new_fstat_ptr = args.fstat_repl; - new_opendir_ptr = args.opendir_repl; - new_closedir_ptr = args.closedir_repl; - new_readdir_ptr = args.readdir_repl; - new_mkdir_ptr = args.mkdir_repl; -} - -int __real_open(const char *pathname, int flags); -int __wrap_open(const char *pathname, int flags) { - if(new_open_ptr == NULL) return __real_open(pathname,flags); - return new_open_ptr(pathname,flags); -} -int __real_close(int fd); -int __wrap_close(int fd) { - if(new_close_ptr == NULL) return __real_close(fd); - return new_close_ptr(fd); -} -ssize_t __real_write(int fd, const void *buf, size_t count); -ssize_t __wrap_write(int fd, const void *buf, size_t count) { - if(new_write_ptr == NULL) return __real_write(fd,buf,count); - return new_write_ptr(fd,buf,count); -} -ssize_t __real_read(int fd, void *buf, size_t count); -ssize_t __wrap_read(int fd, void *buf, size_t count) { - if(new_read_ptr == NULL) return __real_read(fd,buf,count); - return new_read_ptr(fd,buf,count); -} -off_t __real_lseek(int fd, off_t offset, int whence); -off_t __wrap_lseek(int fd, off_t offset, int whence) { - if(new_lseek_ptr == NULL) return __real_lseek(fd, offset, whence); - return new_lseek_ptr(fd, offset, whence); -} -int __real_stat(const char *pathname, struct stat *statbuf); -int __wrap_stat(const char *pathname, struct stat *statbuf) { - if(new_stat_ptr == NULL) return __real_stat(pathname,statbuf); - return new_stat_ptr(pathname,statbuf); -} -int __real_fstat(int fd, struct stat *statbuf); -int __wrap_fstat(int fd, struct stat *statbuf) { - if(new_fstat_ptr == NULL) return __real_fstat(fd,statbuf); - return new_fstat_ptr(fd,statbuf); -} -DIR* __real_opendir(const char * arg); -DIR* __wrap_opendir(const char * arg) { - if(new_opendir_ptr == NULL) return __real_opendir(arg); - return new_opendir_ptr(arg); -} -int __real_closedir(DIR *dirp); -int __wrap_closedir(DIR *dirp) { - if(new_closedir_ptr == NULL) return __real_closedir(dirp); - return new_closedir_ptr(dirp); -} -struct dirent * __real_readdir(DIR *dirp); -struct dirent * __wrap_readdir(DIR *dirp) { - if(new_readdir_ptr == NULL) return __real_readdir(dirp); - return new_readdir_ptr(dirp); -} -int __real_mkdir(const char *path, mode_t mode); -int __wrap_mkdir(const char *path, mode_t mode) { - if(new_mkdir_ptr == NULL) return __real_mkdir(path, mode); - return new_mkdir_ptr(path, mode); -} - -#ifdef __cplusplus -} -#endif diff --git a/wups.ld b/wups.ld deleted file mode 100644 index 23033b9..0000000 --- a/wups.ld +++ /dev/null @@ -1,345 +0,0 @@ -OUTPUT_FORMAT("elf32-powerpc") -OUTPUT_ARCH(powerpc:common) - -SECTIONS { - .text : { - *(.text*) - } - .sdata : { - *(.sdata*) - } - .data : { - *(.data*) - } - .rodata : { - *(.rodata*) - } - .sbss : { - *(.sbss*) - } - .bss : { - *(.bss*) - } - .got2 : { - *(.got2*) - } - .gcc_except_table : { - *(.gcc_except_table*) - } - - .fimport_avm ALIGN(16) : { - KEEP ( *(.fimport_avm) ) - *(.fimport_avm.*) - } - .fimport_camera ALIGN(16) : { - KEEP ( *(.fimport_camera) ) - *(.fimport_camera.*) - } - .fimport_coreinit ALIGN(16) : { - KEEP ( *(.fimport_coreinit) ) - *(.fimport_coreinit.*) - } - .fimport_dc ALIGN(16) : { - KEEP ( *(.fimport_dc) ) - *(.fimport_dc.*) - } - .fimport_dmae ALIGN(16) : { - KEEP ( *(.fimport_dmae) ) - *(.fimport_dmae.*) - } - .fimport_drmapp ALIGN(16) : { - KEEP ( *(.fimport_drmapp) ) - *(.fimport_drmapp.*) - } - .fimport_erreula ALIGN(16) : { - KEEP ( *(.fimport_erreula) ) - *(.fimport_erreula.*) - } - .fimport_gx2 ALIGN(16) : { - KEEP ( *(.fimport_gx2) ) - *(.fimport_gx2.*) - } - .fimport_h264 ALIGN(16) : { - KEEP ( *(.fimport_h264) ) - *(.fimport_h264.*) - } - .fimport_lzma920 ALIGN(16) : { - KEEP ( *(.fimport_lzma920) ) - *(.fimport_lzma920.*) - } - .fimport_mic ALIGN(16) : { - KEEP ( *(.fimport_mic) ) - *(.fimport_mic.*) - } - .fimport_nfc ALIGN(16) : { - KEEP ( *(.fimport_nfc) ) - *(.fimport_nfc.*) - } - .fimport_nio_prof ALIGN(16) : { - KEEP ( *(.fimport_nio_prof) ) - *(.fimport_nio_prof.*) - } - .fimport_nlibcurl ALIGN(16) : { - KEEP ( *(.fimport_nlibcurl) ) - *(.fimport_nlibcurl.*) - } - .fimport_nlibnss2 ALIGN(16) : { - KEEP ( *(.fimport_nlibnss2) ) - *(.fimport_nlibnss2.*) - } - .fimport_nlibnss ALIGN(16) : { - KEEP ( *(.fimport_nlibnss) ) - *(.fimport_nlibnss.*) - } - .fimport_nn_ac ALIGN(16) : { - KEEP ( *(.fimport_nn_ac) ) - *(.fimport_nn_ac.*) - } - .fimport_nn_acp ALIGN(16) : { - KEEP ( *(.fimport_nn_acp) ) - *(.fimport_nn_acp.*) - } - .fimport_nn_act ALIGN(16) : { - KEEP ( *(.fimport_nn_act) ) - *(.fimport_nn_act.*) - } - .fimport_nn_aoc ALIGN(16) : { - KEEP ( *(.fimport_nn_aoc) ) - *(.fimport_nn_aoc.*) - } - .fimport_nn_boss ALIGN(16) : { - KEEP ( *(.fimport_nn_boss) ) - *(.fimport_nn_boss.*) - } - .fimport_nn_ccr ALIGN(16) : { - KEEP ( *(.fimport_nn_ccr) ) - *(.fimport_nn_ccr.*) - } - .fimport_nn_cmpt ALIGN(16) : { - KEEP ( *(.fimport_nn_cmpt) ) - *(.fimport_nn_cmpt.*) - } - .fimport_nn_dlp ALIGN(16) : { - KEEP ( *(.fimport_nn_dlp) ) - *(.fimport_nn_dlp.*) - } - .fimport_nn_ec ALIGN(16) : { - KEEP ( *(.fimport_nn_ec) ) - *(.fimport_nn_ec.*) - } - .fimport_nn_fp ALIGN(16) : { - KEEP ( *(.fimport_nn_fp) ) - *(.fimport_nn_fp.*) - } - .fimport_nn_hai ALIGN(16) : { - KEEP ( *(.fimport_nn_hai) ) - *(.fimport_nn_hai.*) - } - .fimport_nn_hpad ALIGN(16) : { - KEEP ( *(.fimport_nn_hpad) ) - *(.fimport_nn_hpad.*) - } - .fimport_nn_idbe ALIGN(16) : { - KEEP ( *(.fimport_nn_idbe) ) - *(.fimport_nn_idbe.*) - } - .fimport_nn_ndm ALIGN(16) : { - KEEP ( *(.fimport_nn_ndm) ) - *(.fimport_nn_ndm.*) - } - .fimport_nn_nets2 ALIGN(16) : { - KEEP ( *(.fimport_nn_nets2) ) - *(.fimport_nn_nets2.*) - } - .fimport_nn_nfp ALIGN(16) : { - KEEP ( *(.fimport_nn_nfp) ) - *(.fimport_nn_nfp.*) - } - .fimport_nn_nim ALIGN(16) : { - KEEP ( *(.fimport_nn_nim) ) - *(.fimport_nn_nim.*) - } - .fimport_nn_olv ALIGN(16) : { - KEEP ( *(.fimport_nn_olv) ) - *(.fimport_nn_olv.*) - } - .fimport_nn_pdm ALIGN(16) : { - KEEP ( *(.fimport_nn_pdm) ) - *(.fimport_nn_pdm.*) - } - .fimport_nn_save ALIGN(16) : { - KEEP ( *(.fimport_nn_save) ) - *(.fimport_nn_save.*) - } - .fimport_nn_sl ALIGN(16) : { - KEEP ( *(.fimport_nn_sl) ) - *(.fimport_nn_sl.*) - } - .fimport_nn_spm ALIGN(16) : { - KEEP ( *(.fimport_nn_spm) ) - *(.fimport_nn_spm.*) - } - .fimport_nn_temp ALIGN(16) : { - KEEP ( *(.fimport_nn_temp) ) - *(.fimport_nn_temp.*) - } - .fimport_nn_uds ALIGN(16) : { - KEEP ( *(.fimport_nn_uds) ) - *(.fimport_nn_uds.*) - } - .fimport_nn_vctl ALIGN(16) : { - KEEP ( *(.fimport_nn_vctl) ) - *(.fimport_nn_vctl.*) - } - .fimport_nsysccr ALIGN(16) : { - KEEP ( *(.fimport_nsysccr) ) - *(.fimport_nsysccr.*) - } - .fimport_nsyshid ALIGN(16) : { - KEEP ( *(.fimport_nsyshid) ) - *(.fimport_nsyshid.*) - } - .fimport_nsyskbd ALIGN(16) : { - KEEP ( *(.fimport_nsyskbd) ) - *(.fimport_nsyskbd.*) - } - .fimport_nsysnet ALIGN(16) : { - KEEP ( *(.fimport_nsysnet) ) - *(.fimport_nsysnet.*) - } - .fimport_nsysuhs ALIGN(16) : { - KEEP ( *(.fimport_nsysuhs) ) - *(.fimport_nsysuhs.*) - } - .fimport_nsysuvd ALIGN(16) : { - KEEP ( *(.fimport_nsysuvd) ) - *(.fimport_nsysuvd.*) - } - .fimport_ntag ALIGN(16) : { - KEEP ( *(.fimport_ntag) ) - *(.fimport_ntag.*) - } - .fimport_padscore ALIGN(16) : { - KEEP ( *(.fimport_padscore) ) - *(.fimport_padscore.*) - } - .fimport_proc_ui ALIGN(16) : { - KEEP ( *(.fimport_proc_ui) ) - *(.fimport_proc_ui.*) - } - .fimport_sndcore2 ALIGN(16) : { - KEEP ( *(.fimport_sndcore2) ) - *(.fimport_sndcore2.*) - } - .fimport_snd_core ALIGN(16) : { - KEEP ( *(.fimport_snd_core) ) - *(.fimport_snd_core.*) - } - .fimport_snduser2 ALIGN(16) : { - KEEP ( *(.fimport_snduser2) ) - *(.fimport_snduser2.*) - } - .fimport_snd_user ALIGN(16) : { - KEEP ( *(.fimport_snd_user) ) - *(.fimport_snd_user.*) - } - .fimport_swkbd ALIGN(16) : { - KEEP ( *(.fimport_swkbd) ) - *(.fimport_swkbd.*) - } - .fimport_sysapp ALIGN(16) : { - KEEP ( *(.fimport_sysapp) ) - *(.fimport_sysapp.*) - } - .fimport_tcl ALIGN(16) : { - KEEP ( *(.fimport_tcl) ) - *(.fimport_tcl.*) - } - .fimport_tve ALIGN(16) : { - KEEP ( *(.fimport_tve) ) - *(.fimport_tve.*) - } - .fimport_uac ALIGN(16) : { - KEEP ( *(.fimport_uac) ) - *(.fimport_uac.*) - } - .fimport_uac_rpl ALIGN(16) : { - KEEP ( *(.fimport_uac_rpl) ) - *(.fimport_uac_rpl.*) - } - .fimport_usb_mic ALIGN(16) : { - KEEP ( *(.fimport_usb_mic) ) - *(.fimport_usb_mic.*) - } - .fimport_uvc ALIGN(16) : { - KEEP ( *(.fimport_uvc) ) - *(.fimport_uvc.*) - } - .fimport_uvd ALIGN(16) : { - KEEP ( *(.fimport_uvd) ) - *(.fimport_uvd.*) - } - .fimport_vpadbase ALIGN(16) : { - KEEP ( *(.fimport_vpadbase) ) - *(.fimport_vpadbase.*) - } - .fimport_vpad ALIGN(16) : { - KEEP ( *(.fimport_vpad) ) - *(.fimport_vpad.*) - } - .fimport_zlib125 ALIGN(16) : { - KEEP ( *(.fimport_zlib125) ) - *(.fimport_zlib125.*) - } - - .dimport_coreinit ALIGN(16) : { - KEEP ( *(.dimport_coreinit) ) - *(.dimport_coreinit.*) - } - .dimport_nn_act ALIGN(16) : { - KEEP ( *(.dimport_nn_act) ) - *(.dimport_nn_act.*) - } - .dimport_nn_boss ALIGN(16) : { - KEEP ( *(.dimport_nn_boss) ) - *(.dimport_nn_boss.*) - } - .dimport_nn_ec ALIGN(16) : { - KEEP ( *(.dimport_nn_ec) ) - *(.dimport_nn_ec.*) - } - .dimport_nn_nim ALIGN(16) : { - KEEP ( *(.dimport_nn_nim) ) - *(.dimport_nn_nim.*) - } - .dimport_nn_sl ALIGN(16) : { - KEEP ( *(.dimport_nn_sl) ) - *(.dimport_nn_sl.*) - } - .dimport_nn_uds ALIGN(16) : { - KEEP ( *(.dimport_nn_uds) ) - *(.dimport_nn_uds.*) - } - - .wups.meta : { - *(.wups.meta*) - KEEP(*(.wups.meta*)) - } - .wups.load : { - *(.wups.load*) - KEEP(*(.wups.load*)) - } - .wups.hooks : { - *(.wups.hooks*) - KEEP(*(.wups.hooks*)) - } - - /DISCARD/ : { - *(.abs) - *(.comment) - *(.gnu.attributes) - *(.gnu.version) - *(.gnu.version_d) - *(.gnu.version_r) - } -} \ No newline at end of file