Permalink
Browse files

initial commit

  • Loading branch information...
0 parents commit f458982ab1c20bd0f5c8d72a089541006afcd04d @dimok789 dimok789 committed Feb 29, 2016
Showing with 6,410 additions and 0 deletions.
  1. +13 −0 .gitignore
  2. +19 −0 LICENSE.txt
  3. +215 −0 Makefile
  4. +36 −0 src/common/common.h
  5. +62 −0 src/common/fs_defs.h
  6. +25 −0 src/common/os_defs.h
  7. +7 −0 src/common/types.h
  8. +74 −0 src/dynamic_libs/ax_functions.c
  9. +59 −0 src/dynamic_libs/ax_functions.h
  10. +120 −0 src/dynamic_libs/fs_functions.c
  11. +87 −0 src/dynamic_libs/fs_functions.h
  12. +162 −0 src/dynamic_libs/gx2_functions.c
  13. +205 −0 src/dynamic_libs/gx2_functions.h
  14. +699 −0 src/dynamic_libs/gx2_types.h
  15. +166 −0 src/dynamic_libs/os_functions.c
  16. +128 −0 src/dynamic_libs/os_functions.h
  17. +50 −0 src/dynamic_libs/padscore_functions.c
  18. +122 −0 src/dynamic_libs/padscore_functions.h
  19. +82 −0 src/dynamic_libs/socket_functions.c
  20. +95 −0 src/dynamic_libs/socket_functions.h
  21. +40 −0 src/dynamic_libs/sys_functions.c
  22. +42 −0 src/dynamic_libs/sys_functions.h
  23. +39 −0 src/dynamic_libs/vpad_functions.c
  24. +102 −0 src/dynamic_libs/vpad_functions.h
  25. +14 −0 src/entry.c
  26. +182 −0 src/fs/fs_utils.c
  27. +23 −0 src/fs/fs_utils.h
  28. +1,019 −0 src/fs/sd_fat_devoptab.c
  29. +38 −0 src/fs/sd_fat_devoptab.h
  30. +913 −0 src/ftp.c
  31. +42 −0 src/ftp.h
  32. +40 −0 src/link.ld
  33. +190 −0 src/main.c
  34. +19 −0 src/main.h
  35. +263 −0 src/net.c
  36. +62 −0 src/net.h
  37. +198 −0 src/system/memory.c
  38. +42 −0 src/system/memory.h
  39. +89 −0 src/utils/logger.c
  40. +26 −0 src/utils/logger.h
  41. +47 −0 src/utils/utils.h
  42. +116 −0 src/virtualpath.c
  43. +58 −0 src/virtualpath.h
  44. +322 −0 src/vrt.c
  45. +58 −0 src/vrt.h
@@ -0,0 +1,13 @@
+/fs/build
+/installer/bin
+/loader/build
+/menu/build
+/server/logs/*.txt
+/build
+/*.elf
+/fs/*.elf
+/loader/*.elf
+/sd_loader/build
+/sd_loader/*.elf
+/udp_debug_reader/obj
+/udp_debug_reader/GeckoLog.txt
@@ -0,0 +1,19 @@
+Copyright (C) 2008 Joseph Jordan <joe.ftpii@psychlaw.com.au>
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from
+the use of this software.
+
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it
+freely, subject to the following restrictions:
+
+1.The origin of this software must not be misrepresented; you must not
+claim that you wrote the original software. If you use this software in a
+product, an acknowledgment in the product documentation would be
+appreciated but is not required.
+
+2.Altered source versions must be plainly marked as such, and must not be
+misrepresented as being the original software.
+
+3.This notice may not be removed or altered from any source distribution.
@@ -0,0 +1,215 @@
+#---------------------------------------------------------------------------------
+# Clear the implicit built in rules
+#---------------------------------------------------------------------------------
+.SUFFIXES:
+#---------------------------------------------------------------------------------
+ifeq ($(strip $(DEVKITPPC)),)
+$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
+endif
+ifeq ($(strip $(DEVKITPRO)),)
+$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPRO")
+endif
+export PATH := $(DEVKITPPC)/bin:$(PORTLIBS)/bin:$(PATH)
+export LIBOGC_INC := $(DEVKITPRO)/libogc/include
+export LIBOGC_LIB := $(DEVKITPRO)/libogc/lib/wii
+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
+
+#---------------------------------------------------------------------------------
+# 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
+#---------------------------------------------------------------------------------
+TARGET := ftpiiu
+BUILD := build
+BUILD_DBG := $(TARGET)_dbg
+SOURCES := src \
+ src/dynamic_libs \
+ src/fs \
+ src/system \
+ src/utils
+DATA :=
+
+INCLUDES := src
+
+#---------------------------------------------------------------------------------
+# options for code generation
+#---------------------------------------------------------------------------------
+CFLAGS := -std=gnu11 -mrvl -mcpu=750 -meabi -mhard-float -ffast-math \
+ -O3 -Wall -Wextra -Wno-unused-parameter -Wno-strict-aliasing $(INCLUDE)
+CXXFLAGS := -std=gnu++11 -mrvl -mcpu=750 -meabi -mhard-float -ffast-math \
+ -O3 -Wall -Wextra -Wno-unused-parameter -Wno-strict-aliasing $(INCLUDE)
+ASFLAGS := -mregnames
+LDFLAGS := -nostartfiles -Wl,-Map,$(notdir $@).map,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc,-wrap,malloc_usable_size,-wrap,_malloc_r,-wrap,_free_r,-wrap,_realloc_r,-wrap,_calloc_r,-wrap,_memalign_r,-wrap,_malloc_usable_size_r,-wrap,valloc,-wrap,_valloc_r,-wrap,_pvalloc_r,--gc-sections
+
+#---------------------------------------------------------------------------------
+Q := @
+MAKEFLAGS += --no-print-directory
+#---------------------------------------------------------------------------------
+# any extra libraries we wish to link with the project
+#---------------------------------------------------------------------------------
+LIBS := -lgcc -lgd -lpng -lz -lfreetype -lvorbisidec
+
+#---------------------------------------------------------------------------------
+# list of directories containing libraries, this must be the top level containing
+# include and lib
+#---------------------------------------------------------------------------------
+LIBDIRS := $(CURDIR) \
+ $(DEVKITPPC)/lib \
+ $(DEVKITPPC)/lib/gcc/powerpc-eabi/4.8.2
+
+
+#---------------------------------------------------------------------------------
+# 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 LD := $(CC)
+else
+ export 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 := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
+ $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
+ -I$(CURDIR)/$(BUILD) -I$(LIBOGC_INC) \
+ -I$(PORTLIBS)/include -I$(PORTLIBS)/include/freetype2
+
+#---------------------------------------------------------------------------------
+# build a list of library paths
+#---------------------------------------------------------------------------------
+export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
+ -L$(LIBOGC_LIB) -L$(PORTLIBS)/lib
+
+export OUTPUT := $(CURDIR)/$(TARGET)
+.PHONY: $(BUILD) clean install
+
+#---------------------------------------------------------------------------------
+$(BUILD):
+ @[ -d $@ ] || mkdir -p $@
+ @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
+
+#---------------------------------------------------------------------------------
+clean:
+ @echo clean ...
+ @rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).bin $(BUILD_DBG).elf
+
+#---------------------------------------------------------------------------------
+else
+
+DEPENDS := $(OFILES:.o=.d)
+
+#---------------------------------------------------------------------------------
+# main targets
+#---------------------------------------------------------------------------------
+$(OUTPUT).elf: $(OFILES)
+
+#---------------------------------------------------------------------------------
+# This rule links in binary data with the .jpg extension
+#---------------------------------------------------------------------------------
+%.elf: link.ld $(OFILES)
+ @echo "linking ... $(TARGET).elf"
+ $(Q)$(LD) -n -T $^ $(LDFLAGS) -o ../$(BUILD_DBG).elf $(LIBPATHS) $(LIBS)
+ $(Q)$(OBJCOPY) -S -R .comment -R .gnu.attributes ../$(BUILD_DBG).elf $@
+
+../data/loader.bin:
+ $(MAKE) -C ../loader clean
+ $(MAKE) -C ../loader
+#---------------------------------------------------------------------------------
+%.a:
+#---------------------------------------------------------------------------------
+ @echo $(notdir $@)
+ @rm -f $@
+ @$(AR) -rc $@ $^
+
+#---------------------------------------------------------------------------------
+%.o: %.cpp
+ @echo $(notdir $<)
+ @$(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) -c $< -o $@ $(ERROR_FILTER)
+
+#---------------------------------------------------------------------------------
+%.o: %.c
+ @echo $(notdir $<)
+ @$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) -c $< -o $@ $(ERROR_FILTER)
+
+#---------------------------------------------------------------------------------
+%.o: %.S
+ @echo $(notdir $<)
+ @$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(ASFLAGS) -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 $(@)
+
+-include $(DEPENDS)
+
+#---------------------------------------------------------------------------------
+endif
+#---------------------------------------------------------------------------------
@@ -0,0 +1,36 @@
+#ifndef COMMON_H
+#define COMMON_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "os_defs.h"
+
+#define CAFE_OS_SD_PATH "/vol/external01"
+#define SD_PATH "sd:"
+#define WIIU_PATH "/wiiu"
+
+#ifndef MEM_BASE
+#define MEM_BASE (0x00800000)
+#endif
+
+#define ELF_DATA_ADDR (*(volatile unsigned int*)(MEM_BASE + 0x1300 + 0x00))
+#define ELF_DATA_SIZE (*(volatile unsigned int*)(MEM_BASE + 0x1300 + 0x04))
+#define MAIN_ENTRY_ADDR (*(volatile unsigned int*)(MEM_BASE + 0x1400 + 0x00))
+#define OS_FIRMWARE (*(volatile unsigned int*)(MEM_BASE + 0x1400 + 0x04))
+
+#define OS_SPECIFICS ((OsSpecifics*)(MEM_BASE + 0x1500))
+
+#ifndef EXIT_SUCCESS
+#define EXIT_SUCCESS 0
+#endif
+#define EXIT_HBL_EXIT 0xFFFFFFFE
+#define EXIT_RELAUNCH_ON_LOAD 0xFFFFFFFD
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* COMMON_H */
+
@@ -0,0 +1,62 @@
+#ifndef FS_DEFS_H
+#define FS_DEFS_H
+
+#include "types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* FS defines and types */
+#define FS_MAX_LOCALPATH_SIZE 511
+#define FS_MAX_MOUNTPATH_SIZE 128
+#define FS_MAX_FULLPATH_SIZE (FS_MAX_LOCALPATH_SIZE + FS_MAX_MOUNTPATH_SIZE)
+#define FS_MAX_ARGPATH_SIZE FS_MAX_FULLPATH_SIZE
+
+#define FS_STATUS_OK 0
+#define FS_RET_UNSUPPORTED_CMD 0x0400
+#define FS_RET_NO_ERROR 0x0000
+#define FS_RET_ALL_ERROR (unsigned int)(-1)
+
+#define FS_STAT_FLAG_IS_DIRECTORY 0x80000000
+
+/* max length of file/dir name */
+#define FS_MAX_ENTNAME_SIZE 256
+
+#define FS_SOURCETYPE_EXTERNAL 0
+#define FS_SOURCETYPE_HFIO 1
+#define FS_SOURCETYPE_HFIO 1
+
+#define FS_MOUNT_SOURCE_SIZE 0x300
+#define FS_CLIENT_SIZE 0x1700
+#define FS_CMD_BLOCK_SIZE 0xA80
+
+typedef struct
+{
+ uint32_t flag;
+ uint32_t permission;
+ uint32_t owner_id;
+ uint32_t group_id;
+ uint32_t size;
+ uint32_t alloc_size;
+ uint64_t quota_size;
+ uint32_t ent_id;
+ uint64_t ctime;
+ uint64_t mtime;
+ uint8_t attributes[48];
+} __attribute__((packed)) FSStat;
+
+typedef struct
+{
+ FSStat stat;
+ char name[FS_MAX_ENTNAME_SIZE];
+} FSDirEntry;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FS_DEFS_H */
+
@@ -0,0 +1,25 @@
+#ifndef __OS_DEFS_H_
+#define __OS_DEFS_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct _OsSpecifics
+{
+ unsigned int addr_OSDynLoad_Acquire;
+ unsigned int addr_OSDynLoad_FindExport;
+ unsigned int addr_OSTitle_main_entry;
+
+ unsigned int addr_KernSyscallTbl1;
+ unsigned int addr_KernSyscallTbl2;
+ unsigned int addr_KernSyscallTbl3;
+ unsigned int addr_KernSyscallTbl4;
+ unsigned int addr_KernSyscallTbl5;
+} OsSpecifics;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __OS_DEFS_H_
@@ -0,0 +1,7 @@
+#ifndef TYPES_H
+#define TYPES_H
+
+#include <gctypes.h>
+
+#endif /* TYPES_H */
+
Oops, something went wrong.

0 comments on commit f458982

Please sign in to comment.