Skip to content

Commit

Permalink
Change some API functions and add more docs, move to WUT_ROOT by default
Browse files Browse the repository at this point in the history
  • Loading branch information
rw-r-r-0644 committed Oct 9, 2018
1 parent 31c0ea3 commit b6f385e
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 42 deletions.
9 changes: 3 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SHARE := ./share
SOURCES := source
CFILES := $(foreach dir,$(SOURCES),$(wildcard $(dir)/*.c))
OFILES := $(CFILES:.c=.o)
INSTALLDIR ?= $(PORTLIBS)
INSTALLDIR ?= $(WUT_ROOT)
CFLAGS += -O3

#---------------------------------------------------------------------------------
Expand All @@ -29,9 +29,6 @@ clean:
rm -rf $(OFILES) $(CFILES:.c=.d) $(TARGET)

#---------------------------------------------------------------------------------
# wut and portlibs
# wut
#---------------------------------------------------------------------------------
include $(WUT_ROOT)/share/wut.mk
PORTLIBS := $(DEVKITPRO)/portlibs/ppc
LDFLAGS += -L$(PORTLIBS)/lib
CFLAGS += -I$(PORTLIBS)/include
include $(WUT_ROOT)/share/wut.mk
45 changes: 34 additions & 11 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,54 @@
libromfs-wiiu
---------------------------------------------------------------------------------

* Informations
**** Informations ****
This library provides a romfs partition implementation for the Nintendo Wii U.
It's a special filesystem where files needed by applications can be stored in a
read-only manner and embedded into the executable (removing the need for additional
files on the sdcard).
It provides provides low latency and access times since files, once the app has loaded,
are stored in memory instead of being loaded from the sdcard.
This library is made for use with WUT


* Usage
Usage may vary over time, as the current implementation isn't optimal. Currently:
**** API ****
<romfs-wiiu.h> is the main header

int romfsInit(void)
Mounts app's romfs. Returns 0 if succesfull or a negative
value if there was an error

int romfsExit(void)
Unmounts app's romfs. Returns 0 if succesfull or a negative
value if there was an error

romfs can be accessed trough normal file functions,
at the mountpoint "romfs:/"


**** Usage ****
[Usage may vary over time]
- Create a romfs folder in the source tree
- Edit your Makefile and add:
1. A ROMFS variable, specifying the relative path to the romfs folder
2. An "include $(DEVKITPRO)/portlibs/ppc/share/romfs-wiiu.mk" (make sure
2. An "include $(WUT_ROOT)/share/romfs-wiiu.mk" (make sure
it's included *after* exporting the ROMFS variable or it won't work)
3. $(ROMFS_TARGET) to target dependencies and linked objects
3. $(ROMFS_TARGET) to target's dependencies and linked objects
4. $(ROMFS_LDFLAGS) to app's LDFLAGS
- Add calls to romfsInit() and romfsExit() in your application's code


**** Installation ****
The library can be installed by running "make install" in this repo's root.

By default the library will be installed to $WUT_ROOT. The installation path
can be customized with the INSTALLDIR parameter.

* Installing
Run "make install" in this repository's root.
Make sure you exported the $DEVKITPRO envrivrioment variable and that $DEVKITPRO/portlibs is writable.
Make sure you exported the $DEVKITPRO and $WUT_ROOT envrivrioment variables and
that $WUT_ROOT is writable.


* Implementation
The library is currently implemented by having a tar filesystem compressed from a romfs folder
**** Implementation ****
The library is currently implemented by having a tar filesystem built from a romfs folder
at compile time and then stored as a variable in .data with a fixed name (this is not an optimal
solution, and may change in the future).
solution, and may change in the future). No compression is currently used.
13 changes: 7 additions & 6 deletions include/romfs-wiiu.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#ifndef __WIIU_ROMFS
#define __WIIU_ROMFS
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

uint32_t romfsInit();
uint32_t romfsExit();

int romfsInit(void);


int romfsExit(void);


#ifdef __cplusplus
}
#endif

#endif
22 changes: 9 additions & 13 deletions share/romfs-wiiu.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,20 @@ ifneq ($(strip $(V)), 1)
Q ?= @
endif

#---------------------------------------------------------------------------------
# romfs folder (should be set by app's makefile)
#---------------------------------------------------------------------------------
ROMFS ?= romfs
ROMFS_LDFLAGS := -lromfs-wiiu

#---------------------------------------------------------------------------------
# romfs target (must be added to obj files that'll be linked in app's makefile)
#---------------------------------------------------------------------------------
ROMFS_TARGET := app.romfs.o
ifneq ($(strip $(ROMFS)),)

#---------------------------------------------------------------------------------
# You probably don't need anything from there
#---------------------------------------------------------------------------------
ROMFS_LDFLAGS := -lromfs-wiiu
LDFLAGS += $(ROMFS_LDFLAGS)
ROMFS_TARGET := app.romfs.o

%.romfs.o: $(ROMFS)
@echo ROMFS $(notdir $@)
$(Q)tar -H ustar -cvf romfs.tar -C $(ROMFS) .
$(Q)$(OBJCOPY) --input binary --output elf32-powerpc --binary-architecture powerpc:common romfs.tar $@
@rm -f romfs.tar

else

ROMFS_TARGET :=

endif
14 changes: 8 additions & 6 deletions source/romfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,26 +416,28 @@ static devoptab_t romfs_devoptab = {
//! Library functions
//!----------------------------------------------------------------------

extern char _binary_romfs_tar_start[];
extern char _binary_romfs_tar_end[];
extern char _binary_romfs_tar_start[] __attribute__((weak));
extern char _binary_romfs_tar_end[] __attribute__((weak));

static int romfs_initialised = 0;

uint32_t romfsInit() {
int romfsInit(void) {
if (romfs_initialised)
return 0;
if (!_binary_romfs_tar_start || !_binary_romfs_tar_end)
return -2;
tar_create_entries(_binary_romfs_tar_start, _binary_romfs_tar_end);
if (AddDevice(&romfs_devoptab) == -1) {
node_destroytree(NULL, 0);
return 1;
return -1;
}
romfs_initialised = 1;
return 0;
}

uint32_t romfsExit() {
int romfsExit(void) {
if (!romfs_initialised)
return 1;
return -1;
RemoveDevice("romfs:");
node_destroytree(NULL, 0);
romfs_initialised = 0;
Expand Down

0 comments on commit b6f385e

Please sign in to comment.