Add GP2X support to libfat (#18)

This commit is contained in:
Adan 2020-06-27 17:03:02 +01:00 committed by GitHub
parent 1087f6ed6d
commit 69543f058c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 205 additions and 7 deletions

3
.gitignore vendored
View File

@ -6,7 +6,10 @@ libogc/lib
libogc/wii_release libogc/wii_release
nds/lib nds/lib
nds/release nds/release
gp2x/lib
gp2x/gp2x_release
distribute distribute
gba/include gba/include
libogc/include libogc/include
nds/include nds/include
gp2x/include

View File

@ -16,7 +16,7 @@ default: release
all: release dist all: release dist
release: nds-release gba-release cube-release wii-release release: nds-release gba-release cube-release wii-release gp2x-release
ogc-release: include/libfatversion.h cube-release wii-release ogc-release: include/libfatversion.h cube-release wii-release
@ -32,7 +32,10 @@ cube-release: include/libfatversion.h
wii-release: include/libfatversion.h wii-release: include/libfatversion.h
$(MAKE) -C libogc PLATFORM=wii BUILD=wii_release $(MAKE) -C libogc PLATFORM=wii BUILD=wii_release
debug: nds-debug gba-debug cube-debug wii-debug gp2x-release: include/libfatversion.h
$(MAKE) -C gp2x PLATFORM=gp2x BUILD=gp2x_release
debug: nds-debug gba-debug cube-debug wii-debug gp2x-debug
ogc-debug: cube-debug wii-debug ogc-debug: cube-debug wii-debug
@ -42,14 +45,16 @@ nds-debug: include/libfatversion.h
gba-debug: include/libfatversion.h gba-debug: include/libfatversion.h
$(MAKE) -C gba BUILD=debug $(MAKE) -C gba BUILD=debug
cube-debug: include/libfatversion.h cube-debug: include/libfatversion.h
$(MAKE) -C libogc PLATFORM=cube BUILD=wii_debug $(MAKE) -C libogc PLATFORM=cube BUILD=wii_debug
wii-debug: include/libfatversion.h wii-debug: include/libfatversion.h
$(MAKE) -C libogc PLATFORM=wii BUILD=cube_debug $(MAKE) -C libogc PLATFORM=wii BUILD=cube_debug
clean: nds-clean gba-clean ogc-clean gp2x-debug: include/libfatversion.h
$(MAKE) -C gp2x BUILD=debug
clean: nds-clean gba-clean ogc-clean gp2x-clean
nds-clean: nds-clean:
$(MAKE) -C nds clean $(MAKE) -C nds clean
@ -60,7 +65,10 @@ gba-clean:
ogc-clean: ogc-clean:
$(MAKE) -C libogc clean $(MAKE) -C libogc clean
dist-bin: nds-dist-bin gba-dist-bin ogc-dist-bin gp2x-clean:
$(MAKE) -C gp2x clean
dist-bin: nds-dist-bin gba-dist-bin ogc-dist-bin gp2x-dist-bin
nds-dist-bin: include/libfatversion.h nds-release distribute/$(VERSTRING) nds-dist-bin: include/libfatversion.h nds-release distribute/$(VERSTRING)
$(MAKE) -C nds dist-bin $(MAKE) -C nds dist-bin
@ -71,12 +79,16 @@ gba-dist-bin: include/libfatversion.h gba-release distribute/$(VERSTRING)
ogc-dist-bin: include/libfatversion.h ogc-release distribute/$(VERSTRING) ogc-dist-bin: include/libfatversion.h ogc-release distribute/$(VERSTRING)
$(MAKE) -C libogc dist-bin $(MAKE) -C libogc dist-bin
gp2x-dist-bin: include/libfatversion.h gp2x-release distribute/$(VERSTRING)
$(MAKE) -C gp2x dist-bin
dist-src: distribute/$(VERSTRING) dist-src: distribute/$(VERSTRING)
@tar --exclude=.svn --exclude=*CVS* -cvjf distribute/$(VERSTRING)/libfat-src-$(VERSTRING).tar.bz2 \ @tar --exclude=.svn --exclude=*CVS* -cvjf distribute/$(VERSTRING)/libfat-src-$(VERSTRING).tar.bz2 \
source include Makefile \ source include Makefile \
nds/Makefile \ nds/Makefile \
gba/Makefile \ gba/Makefile \
libogc/Makefile libogc/Makefile \
gp2x/Makefile
dist: dist-bin dist-src dist: dist-bin dist-src
@ -95,7 +107,7 @@ include/libfatversion.h : Makefile
@echo >> $@ @echo >> $@
@echo "#endif // __LIBFATVERSION_H__" >> $@ @echo "#endif // __LIBFATVERSION_H__" >> $@
install: nds-install gba-install ogc-install install: nds-install gba-install ogc-install gp2x-install
nds-install: nds-release nds-install: nds-release
$(MAKE) -C nds install $(MAKE) -C nds install
@ -105,3 +117,6 @@ gba-install: gba-release
ogc-install: cube-release wii-release ogc-install: cube-release wii-release
$(MAKE) -C libogc install $(MAKE) -C libogc install
gp2x-install: gp2x-release
$(MAKE) -C gp2x install

164
gp2x/Makefile Normal file
View File

@ -0,0 +1,164 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM)
endif
include $(DEVKITARM)/gp2x_rules
#---------------------------------------------------------------------------------
# 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
# LIB is where the built library will be placed
# all directories are relative to this makefile
#---------------------------------------------------------------------------------
BUILD ?= release
SOURCES := ../source
INCLUDES := ../include
DATA :=
LIB := $(TOPDIR)/gp2x/lib
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -mthumb -mthumb-interwork
CFLAGS := -g -Wall -O2\
-mcpu=arm9tdmi -mtune=arm9tdmi\
-fomit-frame-pointer\
-ffast-math \
$(ARCH)
CFLAGS += $(INCLUDE) -DGP2X
CXXFLAGS := $(CFLAGS)
ASFLAGS := -g $(ARCH)
ifneq ($(BUILD),debug)
export GP2XBIN := $(LIB)/libfat.a
else
export GP2XBIN := $(LIB)/libfatd.a
CFLAGS += -DFAT_DEBUG
endif
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS :=
#-lnds9
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(LIBORCUS)
#---------------------------------------------------------------------------------
# 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 TOPDIR ?= $(CURDIR)/..
export DEPSDIR := $(CURDIR)/$(BUILD)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export CC := $(PREFIX)gcc
export CXX := $(PREFIX)g++
export AR := $(PREFIX)ar
export OBJCOPY := $(PREFIX)objcopy
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 := $(addsuffix .o,$(BINFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
.PHONY: $(BUILD) clean
#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr debug gp2x_release $(LIB) include
all: $(GP2XBIN)
dist-bin:
@mkdir -p include
@cp $(TOPDIR)/include/fat.h $(TOPDIR)/include/libfatversion.h include
@tar --exclude=.svn --exclude=*CVS* -cvjf $(TOPDIR)/distribute/$(VERSTRING)/libfat-gp2x-$(VERSTRING).tar.bz2 include lib
install:
@mkdir -p $(DESTDIR)$(DEVKITPRO)/liborcus/lib
@mkdir -p $(DESTDIR)$(DEVKITPRO)/liborcus/include
@cp lib/libfat.a $(DESTDIR)$(DEVKITPRO)/liborcus/lib
@cp $(TOPDIR)/include/fat.h $(TOPDIR)/include/libfatversion.h $(DESTDIR)$(DEVKITPRO)/liborcus/include
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(GP2XBIN) : $(OFILES) $(LIB)
@rm -f "$(GP2XBIN)"
@$(AR) rcs "$(GP2XBIN)" $(OFILES)
@echo built ... $(notdir $@)
$(LIB):
mkdir $(LIB)
#---------------------------------------------------------------------------------
# you need a rule like this for each extension you use as binary data
#---------------------------------------------------------------------------------
%.bin.o : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

View File

@ -52,6 +52,9 @@
#elif defined(GBA) #elif defined(GBA)
#include <gba_types.h> #include <gba_types.h>
#include <disc_io.h> #include <disc_io.h>
#elif defined(GP2X)
#include <gp2xtypes.h>
#include <disc_io.h>
#endif #endif
// Platform specific options // Platform specific options
@ -73,6 +76,9 @@
#define DEFAULT_CACHE_PAGES 2 #define DEFAULT_CACHE_PAGES 2
#define DEFAULT_SECTORS_PAGE 8 #define DEFAULT_SECTORS_PAGE 8
#define LIMIT_SECTORS 128 #define LIMIT_SECTORS 128
#elif defined (GP2X)
#define DEFAULT_CACHE_PAGES 16
#define DEFAULT_SECTORS_PAGE 8
#endif #endif
#endif // _COMMON_H #endif // _COMMON_H

View File

@ -111,5 +111,15 @@ const INTERFACE_ID _FAT_disc_interfaces[] = {
{NULL, NULL} {NULL, NULL}
}; };
/* ====================== GP2X ====================== */
#elif defined (GP2X)
#include <disc_io.h>
const INTERFACE_ID _FAT_disc_interfaces[] = {
{"sd", get_io_gp2xsd},
{NULL, NULL}
};
#endif #endif