From 20541736ebddbdd97be8a6c190945398bf5527f0 Mon Sep 17 00:00:00 2001 From: Subv Date: Thu, 5 Jan 2017 11:56:35 -0500 Subject: [PATCH] Updated the toolchain and fixed the build with the latest ctrulib. --- Makefile | 43 ++++++++++---- source/main.cpp | 2 +- source/tests/cpu/integer.cpp | 4 +- source/tests/fs/fs_sdmc.cpp | 84 ++++++++++++++-------------- source/tests/gpu/displaytransfer.cpp | 6 +- source/tests/gpu/gpu.cpp | 3 - source/tests/gpu/memoryfills.cpp | 6 +- source/tests/kernel/waitsynch.cpp | 8 +-- 8 files changed, 87 insertions(+), 69 deletions(-) diff --git a/Makefile b/Makefile index 7d2293e..2a49fdf 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,7 @@ include $(DEVKITARM)/3ds_rules # INCLUDES is a list of directories containing header files # # NO_SMDH: if set to anything, no SMDH file is generated. +# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional) # APP_TITLE is the name of the app stored in the SMDH file (Optional) # APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional) # APP_AUTHOR is the author of the app stored in the SMDH file (Optional) @@ -31,14 +32,15 @@ BUILD := build SOURCES := source source/common source/tests source/tests/fs source/tests/cpu source/tests/kernel source/tests/gpu DATA := data INCLUDES := source +#ROMFS := romfs #--------------------------------------------------------------------------------- # options for code generation #--------------------------------------------------------------------------------- -ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard +ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft CFLAGS := -g -Wall -O2 -mword-relocations \ - -fomit-frame-pointer -ffast-math \ + -fomit-frame-pointer -ffunction-sections \ $(ARCH) CFLAGS += $(INCLUDE) -DARM11 -D_3DS @@ -75,6 +77,8 @@ 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))) +PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica))) +SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist))) BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) #--------------------------------------------------------------------------------- @@ -92,6 +96,7 @@ endif #--------------------------------------------------------------------------------- export OFILES := $(addsuffix .o,$(BINFILES)) \ + $(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o) \ $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ @@ -117,6 +122,10 @@ ifeq ($(strip $(NO_SMDH)),) export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh endif +ifneq ($(ROMFS),) + export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS) +endif + .PHONY: $(BUILD) clean all #--------------------------------------------------------------------------------- @@ -156,20 +165,32 @@ $(OUTPUT).elf : $(OFILES) @echo $(notdir $<) @$(bin2o) -# WARNING: This is not the right way to do this! TODO: Do it right! #--------------------------------------------------------------------------------- -%.vsh.o : %.vsh +# rules for assembling GPU shaders #--------------------------------------------------------------------------------- +define shader-as + $(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@))) + picasso -o $(CURBIN) $1 + bin2s $(CURBIN) | $(AS) -o $@ + echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h + echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h + echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h +endef + +%.shbin.o : %.v.pica %.g.pica + @echo $(notdir $^) + @$(call shader-as,$^) + +%.shbin.o : %.v.pica @echo $(notdir $<) - @python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin - @bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@ - @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h - @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h - @echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h - @rm ../$(notdir $<).shbin + @$(call shader-as,$<) + +%.shbin.o : %.shlist + @echo $(notdir $<) + @$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file))) -include $(DEPENDS) #--------------------------------------------------------------------------------------- endif -#--------------------------------------------------------------------------------------- +#--------------------------------------------------------------------------------------- \ No newline at end of file diff --git a/source/main.cpp b/source/main.cpp index f3448ab..11cef99 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -45,7 +45,7 @@ int main(int argc, char** argv) Print("Press A to continue...\n"); } - gspWaitForEvent(GSPEVENT_VBlank0, false); + gspWaitForVBlank(); } consoleClear(); diff --git a/source/tests/cpu/integer.cpp b/source/tests/cpu/integer.cpp index b506cb6..ee72115 100644 --- a/source/tests/cpu/integer.cpp +++ b/source/tests/cpu/integer.cpp @@ -55,9 +55,9 @@ static bool Sub() { unsigned int output; // Generic subtraction. - asm volatile ("LDR r0, =489\n" + asm volatile ("MOV r0, #488\n" "SUB %[out], r0, #69" : [out] "=r"(output)); - if (output != 420) + if (output != 419) return false; // Subtract overflow (0 - 1). diff --git a/source/tests/fs/fs_sdmc.cpp b/source/tests/fs/fs_sdmc.cpp index a888a3a..127fd19 100644 --- a/source/tests/fs/fs_sdmc.cpp +++ b/source/tests/fs/fs_sdmc.cpp @@ -9,84 +9,84 @@ namespace FS { namespace SDMC { -static bool TestFileCreateDelete(FS_archive sdmcArchive) +static bool TestFileCreateDelete(FS_Archive sdmcArchive) { Handle fileHandle, fileHandle2; - const static FS_path filePath = FS_makePath(PATH_CHAR, "/test_file_create_delete.txt"); - const static FS_path filePath2 = FS_makePath(PATH_CHAR, "/test_file_create_2.txt"); + const static FS_Path filePath = fsMakePath(PATH_ASCII, "/test_file_create_delete.txt"); + const static FS_Path filePath2 = fsMakePath(PATH_ASCII, "/test_file_create_2.txt"); // Create file with OpenFile (not interested in opening the handle) - SoftAssert(FSUSER_OpenFile(NULL, &fileHandle, sdmcArchive, filePath, FS_OPEN_CREATE | FS_OPEN_WRITE, 0) == 0); + SoftAssert(FSUSER_OpenFile(&fileHandle, sdmcArchive, filePath, FS_OPEN_CREATE | FS_OPEN_WRITE, 0) == 0); FSFILE_Close(fileHandle); // Make sure the new file exists - SoftAssert(FSUSER_OpenFile(NULL, &fileHandle, sdmcArchive, filePath, FS_OPEN_READ, 0) == 0); + SoftAssert(FSUSER_OpenFile(&fileHandle, sdmcArchive, filePath, FS_OPEN_READ, 0) == 0); FSFILE_Close(fileHandle); - SoftAssert(FSUSER_DeleteFile(NULL, sdmcArchive, filePath) == 0); + SoftAssert(FSUSER_DeleteFile(sdmcArchive, filePath) == 0); // Should fail to make sure the file no longer exists - SoftAssert(FSUSER_OpenFile(NULL, &fileHandle, sdmcArchive, filePath, FS_OPEN_READ, 0) != 0); + SoftAssert(FSUSER_OpenFile(&fileHandle, sdmcArchive, filePath, FS_OPEN_READ, 0) != 0); FSFILE_Close(fileHandle); // Create file with CreateFile - SoftAssert(FSUSER_CreateFile(NULL, sdmcArchive, filePath2, 0) == 0); + SoftAssert(FSUSER_CreateFile(sdmcArchive, filePath2, 0, 0) == 0); SCOPE_EXIT({ FSFILE_Close(fileHandle2); - FSUSER_DeleteFile(NULL, sdmcArchive, filePath2); + FSUSER_DeleteFile(sdmcArchive, filePath2); }); // Make sure the new file exists - SoftAssert(FSUSER_OpenFile(NULL, &fileHandle2, sdmcArchive, filePath2, FS_OPEN_READ, 0) == 0); + SoftAssert(FSUSER_OpenFile(&fileHandle2, sdmcArchive, filePath2, FS_OPEN_READ, 0) == 0); // Try and create a file over an already-existing file (Should fail) - SoftAssert(FSUSER_CreateFile(NULL, sdmcArchive, filePath2, 0) != 0); + SoftAssert(FSUSER_CreateFile(sdmcArchive, filePath2, 0, 0) != 0); return true; } -static bool TestFileRename(FS_archive sdmcArchive) +static bool TestFileRename(FS_Archive sdmcArchive) { Handle fileHandle; - const static FS_path filePath = FS_makePath(PATH_CHAR, "/test_file_rename.txt"); - const static FS_path newFilePath = FS_makePath(PATH_CHAR, "/test_file_rename_new.txt"); + const static FS_Path filePath = fsMakePath(PATH_ASCII, "/test_file_rename.txt"); + const static FS_Path newFilePath = fsMakePath(PATH_ASCII, "/test_file_rename_new.txt"); // Create file - FSUSER_CreateFile(NULL, sdmcArchive, filePath, 0); + FSUSER_CreateFile(sdmcArchive, filePath, 0, 0); - SoftAssert(FSUSER_RenameFile(NULL, sdmcArchive, filePath, sdmcArchive, newFilePath) == 0); + SoftAssert(FSUSER_RenameFile(sdmcArchive, filePath, sdmcArchive, newFilePath) == 0); // Should fail to make sure the old file no longer exists - if (FSUSER_OpenFile(NULL, &fileHandle, sdmcArchive, filePath, FS_OPEN_READ, 0) == 0) { - FSUSER_DeleteFile(NULL, sdmcArchive, filePath); + if (FSUSER_OpenFile(&fileHandle, sdmcArchive, filePath, FS_OPEN_READ, 0) == 0) { + FSUSER_DeleteFile(sdmcArchive, filePath); return false; } FSFILE_Close(fileHandle); // Make sure the new file exists - SoftAssert(FSUSER_OpenFile(NULL, &fileHandle, sdmcArchive, newFilePath, FS_OPEN_READ, 0) == 0); + SoftAssert(FSUSER_OpenFile(&fileHandle, sdmcArchive, newFilePath, FS_OPEN_READ, 0) == 0); FSFILE_Close(fileHandle); - SoftAssert(FSUSER_DeleteFile(NULL, sdmcArchive, newFilePath) == 0); + SoftAssert(FSUSER_DeleteFile(sdmcArchive, newFilePath) == 0); return true; } -static bool TestFileWriteRead(FS_archive sdmcArchive) +static bool TestFileWriteRead(FS_Archive sdmcArchive) { Handle fileHandle; u32 bytesWritten; u32 bytesRead; u64 fileSize; - const static FS_path filePath = FS_makePath(PATH_CHAR, "/test_file_write_read.txt"); + const static FS_Path filePath = fsMakePath(PATH_ASCII, "/test_file_write_read.txt"); const static char* stringWritten = "A string\n"; // Create file - FSUSER_OpenFile(NULL, &fileHandle, sdmcArchive, filePath, FS_OPEN_CREATE | FS_OPEN_WRITE, 0); + FSUSER_OpenFile(&fileHandle, sdmcArchive, filePath, FS_OPEN_CREATE | FS_OPEN_WRITE, 0); SCOPE_EXIT({ // Close and delete file no matter what happens FSFILE_Close(fileHandle); - FSUSER_DeleteFile(NULL, sdmcArchive, filePath); + FSUSER_DeleteFile(sdmcArchive, filePath); }); // Write to file @@ -108,65 +108,65 @@ static bool TestFileWriteRead(FS_archive sdmcArchive) return true; } -static bool TestDirCreateDelete(FS_archive sdmcArchive) +static bool TestDirCreateDelete(FS_Archive sdmcArchive) { Handle dirHandle; - const static FS_path dirPath = FS_makePath(PATH_CHAR, "/test_dir_create_delete"); + const static FS_Path dirPath = fsMakePath(PATH_ASCII, "/test_dir_create_delete"); // Create directory - SoftAssert(FSUSER_CreateDirectory(NULL, sdmcArchive, dirPath) == 0); + SoftAssert(FSUSER_CreateDirectory(sdmcArchive, dirPath, 0) == 0); // Make sure the new dir exists - SoftAssert(FSUSER_OpenDirectory(NULL, &dirHandle, sdmcArchive, dirPath) == 0); + SoftAssert(FSUSER_OpenDirectory(&dirHandle, sdmcArchive, dirPath) == 0); FSDIR_Close(dirHandle); - SoftAssert(FSUSER_DeleteDirectory(NULL, sdmcArchive, dirPath) == 0); + SoftAssert(FSUSER_DeleteDirectory(sdmcArchive, dirPath) == 0); // Should fail to make sure the dir no longer exists - SoftAssert(FSUSER_OpenDirectory(NULL, &dirHandle, sdmcArchive, dirPath) != 0); + SoftAssert(FSUSER_OpenDirectory(&dirHandle, sdmcArchive, dirPath) != 0); FSDIR_Close(dirHandle); return true; } -static bool TestDirRename(FS_archive sdmcArchive) +static bool TestDirRename(FS_Archive sdmcArchive) { Handle dirHandle; - const static FS_path dirPath = FS_makePath(PATH_CHAR, "/test_dir_rename"); - const static FS_path newDirPath = FS_makePath(PATH_CHAR, "/test_dir_rename_new"); + const static FS_Path dirPath = fsMakePath(PATH_ASCII, "/test_dir_rename"); + const static FS_Path newDirPath = fsMakePath(PATH_ASCII, "/test_dir_rename_new"); // Create dir - FSUSER_CreateDirectory(NULL, sdmcArchive, dirPath); + FSUSER_CreateDirectory(sdmcArchive, dirPath, 0); - SoftAssert(FSUSER_RenameDirectory(NULL, sdmcArchive, dirPath, sdmcArchive, newDirPath) == 0); + SoftAssert(FSUSER_RenameDirectory(sdmcArchive, dirPath, sdmcArchive, newDirPath) == 0); // Should fail to make sure the old dir no longer exists - if (FSUSER_OpenDirectory(NULL, &dirHandle, sdmcArchive, dirPath) == 0) { - FSUSER_DeleteDirectory(NULL, sdmcArchive, dirPath); + if (FSUSER_OpenDirectory(&dirHandle, sdmcArchive, dirPath) == 0) { + FSUSER_DeleteDirectory(sdmcArchive, dirPath); return false; } FSDIR_Close(dirHandle); // Make sure the new dir exists - SoftAssert(FSUSER_OpenDirectory(NULL, &dirHandle, sdmcArchive, newDirPath) == 0); + SoftAssert(FSUSER_OpenDirectory(&dirHandle, sdmcArchive, newDirPath) == 0); FSDIR_Close(dirHandle); - SoftAssert(FSUSER_DeleteDirectory(NULL, sdmcArchive, newDirPath) == 0); + SoftAssert(FSUSER_DeleteDirectory(sdmcArchive, newDirPath) == 0); return true; } void TestAll() { - FS_archive sdmcArchive = { 0x00000009, { PATH_EMPTY, 1, (u8*) "" } }; + FS_Archive sdmcArchive; - Test("SDMC", "Opening archive", FSUSER_OpenArchive(NULL, &sdmcArchive), 0L); + Test("SDMC", "Opening archive", FSUSER_OpenArchive(&sdmcArchive, ARCHIVE_SDMC, fsMakePath(PATH_EMPTY, "")), 0L); Test("SDMC", "Creating and deleting file", TestFileCreateDelete(sdmcArchive), true); Test("SDMC", "Renaming file", TestFileRename(sdmcArchive), true); Test("SDMC", "Writing and reading file", TestFileWriteRead(sdmcArchive), true); Test("SDMC", "Creating and deleting directory", TestDirCreateDelete(sdmcArchive), true); Test("SDMC", "Renaming directory", TestDirRename(sdmcArchive), true); - Test("SDMC", "Closing archive", FSUSER_CloseArchive(NULL, &sdmcArchive), 0L); + Test("SDMC", "Closing archive", FSUSER_CloseArchive(sdmcArchive), 0L); } } // namespace diff --git a/source/tests/gpu/displaytransfer.cpp b/source/tests/gpu/displaytransfer.cpp index cf59e7f..2380de1 100644 --- a/source/tests/gpu/displaytransfer.cpp +++ b/source/tests/gpu/displaytransfer.cpp @@ -45,9 +45,9 @@ union Dimensions { }; static void DisplayTransferAndWait(u32* input, u32* output, Dimensions input_dimensions, Dimensions output_dimensions, u32 flags) { - GSPGPU_FlushDataCache(nullptr, (u8*)input, sizeof(u32)); - GSPGPU_InvalidateDataCache(nullptr, (u8*)output, sizeof(u32)); - Result res = GX_SetDisplayTransfer(nullptr, (u32*)input, input_dimensions.raw, (u32*)output, output_dimensions.raw, flags); + GSPGPU_FlushDataCache(input, sizeof(u32)); + GSPGPU_InvalidateDataCache(output, sizeof(u32)); + Result res = GX_DisplayTransfer(input, input_dimensions.raw, output, output_dimensions.raw, flags); if ((u32)res != 0) { Log(Common::FormatString("Something went wrong: %u\n", (u32)res)); return; diff --git a/source/tests/gpu/gpu.cpp b/source/tests/gpu/gpu.cpp index eae9af0..3054a39 100644 --- a/source/tests/gpu/gpu.cpp +++ b/source/tests/gpu/gpu.cpp @@ -6,9 +6,6 @@ namespace GPU { void TestAll() { - // Initialize GPU - GPU_Init(nullptr); - DisplayTransfer::TestAll(); MemoryFills::TestAll(); } diff --git a/source/tests/gpu/memoryfills.cpp b/source/tests/gpu/memoryfills.cpp index 82d1082..6665d95 100644 --- a/source/tests/gpu/memoryfills.cpp +++ b/source/tests/gpu/memoryfills.cpp @@ -11,13 +11,13 @@ namespace MemoryFills { static void FillAndWait(u8* buffer, u32 value, u32 size, u32 control, bool first_engine = true) { if (first_engine) { - GX_SetMemoryFill(nullptr, (u32*)buffer, value, (u32*)(buffer + size), control, 0, 0, 0, 0); + GX_MemoryFill((u32*)buffer, value, (u32*)(buffer + size), control, 0, 0, 0, 0); gspWaitForPSC0(); } else { - GX_SetMemoryFill(nullptr, 0, 0, 0, control, (u32*)buffer, value, (u32*)(buffer + size), control); + GX_MemoryFill(0, 0, 0, control, (u32*)buffer, value, (u32*)(buffer + size), control); gspWaitForPSC1(); } - GSPGPU_InvalidateDataCache(nullptr, buffer, size); + GSPGPU_InvalidateDataCache(buffer, size); } static bool Fill32Bits(u8* buffer) { diff --git a/source/tests/kernel/waitsynch.cpp b/source/tests/kernel/waitsynch.cpp index fffe562..024b313 100644 --- a/source/tests/kernel/waitsynch.cpp +++ b/source/tests/kernel/waitsynch.cpp @@ -1077,10 +1077,10 @@ bool Test_WaitSynch_KernelType_AddressArbiter() { } void TestAll() { - svcCreateEvent(&events[0], 1); - svcCreateEvent(&events[1], 1); - svcCreateEvent(&events[2], 1); - svcCreateEvent(&events[3], 1); + svcCreateEvent(&events[0], RESET_STICKY); + svcCreateEvent(&events[1], RESET_STICKY); + svcCreateEvent(&events[2], RESET_STICKY); + svcCreateEvent(&events[3], RESET_STICKY); svcCreateMutex(&mutexes[0], false); svcCreateMutex(&mutexes[1], false);