-
Notifications
You must be signed in to change notification settings - Fork 561
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
External ARM9 payload chainloading for a9lh, cleaned up the sdmmc lib…
…rary (from the dark-samus a9lh fork)
- Loading branch information
1 parent
04978eb
commit 09380a1
Showing
30 changed files
with
7,152 additions
and
732 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ out | |
CakeHax | ||
CakeBrah | ||
build | ||
data | ||
loader/build | ||
*.bin | ||
*.3dsx | ||
*.smdh | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
#--------------------------------------------------------------------------------- | ||
.SUFFIXES: | ||
#--------------------------------------------------------------------------------- | ||
|
||
ifeq ($(strip $(DEVKITARM)),) | ||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM") | ||
endif | ||
|
||
include $(DEVKITARM)/3ds_rules | ||
|
||
#--------------------------------------------------------------------------------- | ||
# 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 | ||
# DATA is a list of directories containing data files | ||
# INCLUDES is a list of directories containing header files | ||
# SPECS is the directory containing the important build and link files | ||
#--------------------------------------------------------------------------------- | ||
export TARGET := $(shell basename $(CURDIR)) | ||
BUILD := build | ||
SOURCES := source source/fatfs source/fatfs/sdmmc | ||
DATA := data | ||
INCLUDES := include source/fatfs source/fatfs/sdmmc | ||
|
||
#--------------------------------------------------------------------------------- | ||
# Setup some defines | ||
#--------------------------------------------------------------------------------- | ||
|
||
#--------------------------------------------------------------------------------- | ||
# options for code generation | ||
#--------------------------------------------------------------------------------- | ||
ARCH := -mthumb -mthumb-interwork | ||
|
||
CFLAGS := -g -Wall -O2\ | ||
-march=armv5te -mtune=arm946e-s -fomit-frame-pointer\ | ||
-ffast-math -std=c99\ | ||
$(ARCH) | ||
|
||
CFLAGS += $(INCLUDE) -DARM9 | ||
|
||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions | ||
|
||
ASFLAGS := -g $(ARCH) | ||
LDFLAGS = -nostartfiles -g --specs=../stub.specs $(ARCH) -Wl,-Map,$(TARGET).map | ||
|
||
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 OUTPUT := $(CURDIR)/$(TARGET) | ||
|
||
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 := $(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) \ | ||
-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).elf arm9loaderhax.bin | ||
|
||
|
||
#--------------------------------------------------------------------------------- | ||
else | ||
|
||
DEPENDS := $(OFILES:.o=.d) | ||
|
||
#--------------------------------------------------------------------------------- | ||
# main targets | ||
#--------------------------------------------------------------------------------- | ||
$(OUTPUT).bin : $(OUTPUT).elf | ||
$(OUTPUT).elf : $(OFILES) | ||
|
||
|
||
#--------------------------------------------------------------------------------- | ||
%.bin: %.elf | ||
@$(OBJCOPY) -O binary $< $@ | ||
@echo built ... $(notdir $@) | ||
|
||
|
||
-include $(DEPENDS) | ||
|
||
|
||
#--------------------------------------------------------------------------------------- | ||
endif | ||
#--------------------------------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
FatFs Module Source Files R0.11 | ||
|
||
|
||
FILES | ||
|
||
00readme.txt This file. | ||
history.txt Revision history. | ||
ffconf.h Configuration file for FatFs module. | ||
ff.h Common include file for FatFs and application module. | ||
ff.c FatFs module. | ||
diskio.h Common include file for FatFs and disk I/O module. | ||
diskio.c An example of glue function to attach existing disk I/O module to FatFs. | ||
integer.h Integer type definitions for FatFs. | ||
option Optional external functions. | ||
|
||
|
||
Low level disk I/O module is not included in this archive because the FatFs | ||
module is only a generic file system layer and not depend on any specific | ||
storage device. You have to provide a low level disk I/O module that written | ||
to control the target storage device. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/*-----------------------------------------------------------------------*/ | ||
/* Low level disk I/O module skeleton for FatFs (C)ChaN, 2014 */ | ||
/*-----------------------------------------------------------------------*/ | ||
/* If a working storage control module is available, it should be */ | ||
/* attached to the FatFs via a glue function rather than modifying it. */ | ||
/* This is an example of glue functions to attach various exsisting */ | ||
/* storage control modules to the FatFs module with a defined API. */ | ||
/*-----------------------------------------------------------------------*/ | ||
|
||
#include "diskio.h" /* FatFs lower layer API */ | ||
#include "sdmmc/sdmmc.h" | ||
|
||
|
||
/*-----------------------------------------------------------------------*/ | ||
/* Get Drive Status */ | ||
/*-----------------------------------------------------------------------*/ | ||
|
||
DSTATUS disk_status ( | ||
__attribute__((unused)) | ||
BYTE pdrv /* Physical drive nmuber to identify the drive */ | ||
) | ||
{ | ||
return RES_OK; | ||
} | ||
|
||
|
||
|
||
/*-----------------------------------------------------------------------*/ | ||
/* Inidialize a Drive */ | ||
/*-----------------------------------------------------------------------*/ | ||
|
||
DSTATUS disk_initialize ( | ||
__attribute__((unused)) | ||
BYTE pdrv /* Physical drive nmuber to identify the drive */ | ||
) | ||
{ | ||
sdmmc_sdcard_init(); | ||
return RES_OK; | ||
} | ||
|
||
|
||
|
||
/*-----------------------------------------------------------------------*/ | ||
/* Read Sector(s) */ | ||
/*-----------------------------------------------------------------------*/ | ||
|
||
DRESULT disk_read ( | ||
__attribute__((unused)) | ||
BYTE pdrv, /* Physical drive nmuber to identify the drive */ | ||
BYTE *buff, /* Data buffer to store read data */ | ||
DWORD sector, /* Sector address in LBA */ | ||
UINT count /* Number of sectors to read */ | ||
) | ||
{ | ||
if (sdmmc_sdcard_readsectors(sector, count, buff)) { | ||
return RES_PARERR; | ||
} | ||
|
||
return RES_OK; | ||
} | ||
|
||
|
||
|
||
/*-----------------------------------------------------------------------*/ | ||
/* Write Sector(s) */ | ||
/*-----------------------------------------------------------------------*/ | ||
|
||
#if _USE_WRITE | ||
DRESULT disk_write ( | ||
__attribute__((unused)) | ||
BYTE pdrv, /* Physical drive nmuber to identify the drive */ | ||
const BYTE *buff, /* Data to be written */ | ||
DWORD sector, /* Sector address in LBA */ | ||
UINT count /* Number of sectors to write */ | ||
) | ||
{ | ||
if (sdmmc_sdcard_writesectors(sector, count, (BYTE *)buff)) { | ||
return RES_PARERR; | ||
} | ||
|
||
return RES_OK; | ||
} | ||
#endif | ||
|
||
|
||
|
||
/*-----------------------------------------------------------------------*/ | ||
/* Miscellaneous Functions */ | ||
/*-----------------------------------------------------------------------*/ | ||
|
||
#if _USE_IOCTL | ||
DRESULT disk_ioctl ( | ||
__attribute__((unused)) | ||
BYTE pdrv, /* Physical drive nmuber (0..) */ | ||
__attribute__((unused)) | ||
BYTE cmd, /* Control code */ | ||
__attribute__((unused)) | ||
void *buff /* Buffer to send/receive control data */ | ||
) | ||
{ | ||
return RES_PARERR; | ||
} | ||
#endif |
Oops, something went wrong.