]> Chaos Git - console/XDS.git/commitdiff
Multi. master
authorchaoskagami <chaos.kagami@gmail.com>
Sat, 16 Jul 2016 13:30:52 +0000 (09:30 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Sat, 16 Jul 2016 13:31:07 +0000 (09:31 -0400)
 * Fix up some debugging messages to be less convoluted and cryptic
 * Embed glfw as submodule. Has use, since no outside deps aside from GL/windowing

.gitmodules
Makefile
README.md
external/glfw [new submodule]
source/Bootloader.cpp
source/Main.cpp
source/kernel/Thread.cpp
source/process9/fs.cpp

index 883ae49b3dfc3810dc77a958856d2646cdcd1e29..07e62360581bf56bc1a1b18a2ce9b00d99aa5afa 100644 (file)
@@ -4,3 +4,6 @@
 [submodule "external/gl3w"]
        path = external/gl3w
        url = https://github.com/skaslev/gl3w
+[submodule "external/glfw"]
+       path = external/glfw
+       url = https://github.com/glfw/glfw
index 3032ae2c0356b9e12f2487528df6a6aa2d47a5f8..8823c24b56448dd4cff83b468be1a14366d9b549 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -10,9 +10,11 @@ UTIL_FILES := source/util/*.cpp
 #COMMON_FILES := source/Bootloader.cpp source/arm/*.cpp $(ARM_FILES) $(KERNEL_FILES) $(HARDWARE_FILES) $(PROCESS9_FILES) $(UTIL_FILES)
 SOURCE_FILES := source/citraimport/glad/src/glad.o external/imgui/imgui.o external/imgui/examples/opengl3_example/imgui_impl_glfw_gl3.o $(shell for file in `find source -name *.cpp`; do echo $$file ; done)
 
-CFLAGS := -I$(PWD)/include -I$(PWD)/source/citraimport -I$(PWD)/external/gl3w/include -I$(PWD)/external/imgui -g --std=c11 $(ARM_FLAGS) -mtune=native -msse4.1 -Wfatal-errors
-CXXFLAGS := -I$(PWD)/include -I$(PWD)/source/citraimport -I$(PWD)/source/citraimport/GPU -I$(PWD)/external/gl3w/include -I$(PWD)/external/imgui -g --std=c++14 $(ARM_FLAGS) -mtune=native -msse4.1 -Wfatal-errors -fpermissive
-LDFLAGS := -L/opt/local/lib -Lexternal/gl3w -lpthread -lX11 -lXxf86vm -lXrender -lXcursor -lXrandr -lXinerama -lglfw3 -lgl3w -lGL -ldl
+ARCH := -m32
+
+CFLAGS := $(ARCH) -I$(PWD)/external/glfw/include -I$(PWD)/include -I$(PWD)/source/citraimport -I$(PWD)/external/gl3w/include -I$(PWD)/external/imgui -g --std=c11 $(ARM_FLAGS) -mtune=native -msse4.1 -Wfatal-errors
+CXXFLAGS := $(ARCH) -I$(PWD)/external/glfw/include -I$(PWD)/include -I$(PWD)/source/citraimport -I$(PWD)/source/citraimport/GPU -I$(PWD)/external/gl3w/include -I$(PWD)/external/imgui -g --std=c++14 $(ARM_FLAGS) -mtune=native -msse4.1 -Wfatal-errors -fpermissive
+LDFLAGS := $(ARCH) -L/opt/local/lib -L$(PWD)/external/gl3w -L$(PWD)/external/glfw/src -lpthread -lX11 -lXxf86vm -lXrender -lXcursor -lXrandr -lXinerama -lglfw3 -lgl3w -lGL -ldl
 
 COMMON_FILES := $(patsubst %.cpp,%.o,$(patsubst %.c,%.o,$(SOURCE_FILES)))
 
@@ -21,7 +23,12 @@ xds: deps $(COMMON_FILES) source/Main.cpp
        g++ -o xds $(TEST_DEFS) $(BUILD_FLAGS) $(COMMON_FILES) $(LDFLAGS)
 
 deps:
-       cd external/gl3w && ./gl3w_gen.py && CFLAGS= CXXFLAGS= LDFLAGS= cmake . && make
+       cd external/gl3w && ./gl3w_gen.py && CFLAGS= CXXFLAGS= LDFLAGS= CC="gcc $(ARCH)" CXX="g++ $(ARCH)" cmake . && make
+       cd external/glfw && CFLAGS= CXXFLAGS= LDFLAGS= CC="gcc $(ARCH)" CXX="g++ $(ARCH)" cmake . && make
+
+clean-deps:
+       cd external/gl3w && git clean -fxd
+       cd external/glfw && git clean -fxd
 
 %.o: %.c
        gcc $(CFLAGS) -c -o $@ $<
@@ -43,5 +50,5 @@ runtests:
        ./xds_test_resourcelimit
        ./xds_test_mutex
 
-clean:
+clean: clean-deps
        rm -f $(COMMON_FILES) ./xds ./xds_test_memorymap ./xds_test_handletable ./xds_test_linkedlist ./xds_test_resourcelimit ./xds_test_mutex
index 061f818fd3d841137cc85f3206dc3e9031d549c7..f4f918e29b70806ccd7b33cceccdc5de7557d5fd 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-xds; Gör om, gör rätt.
+xds; もう一回、上から始めましょ!
 
 thanks to
 plutooo
@@ -6,11 +6,6 @@ Normmatt
 Bond697
 who helped me create XDS
 
-To build XDS, first build external/gl3w
-On Windows, use windows/xds.sln
-On OSX, install libglfw3 (Makefile assumes its installed with MacPorts), then 
-run `make`
+To build XDS, run `make`. Yes, you can pass -jwhatever here. The goal is to hopefully clean up *some* of this mess (which is...hard, to say the least.)
 
-To generate a NAND dump of the firmware, decrypt all CIAs for the firmware and 
-run `python NAND/title/build_nand.py dir/to/cias` and the decrypted firmware 
-will be placed into the correct directories. You also need ctrtool for this.
+To generate a NAND dump of the firmware, decrypt all CIAs for the firmware and run `python NAND/title/build_nand.py dir/to/cias` and the decrypted firmware will be placed into the correct directories. You also need ctrtool for this.
diff --git a/external/glfw b/external/glfw
new file mode 160000 (submodule)
index 0000000..4888d7d
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit 4888d7d410f3a613dbf8d8e24d3bf7ad61042a12
index 0b0b990a21053497ab4b209446d1349786abf183..98d0ba75ca8fe6fa4fd2005979d2ef740160f8a9 100644 (file)
@@ -4,9 +4,8 @@
 
 #include "Bootloader.h"
 
-//they are in mem in that order fs loader pm sm pix
-
-
+// they are in mem in that order fs loader pm sm pix
+// FIXME ^ Not necessarily true, assumption (@chaoskagami)
 
 //tools
 static u32 Read32revers(uint8_t p[4])
@@ -120,7 +119,7 @@ KProcess* Boot_LoadFileFast(FILE* fd, u32 offset, u32* out_offset, KKernel * Ker
 
     if (fseek(fd, offset, SEEK_SET) != 0)
     {
-        XDSERROR("failed to seek.");
+        XDSERROR("Failed to seek to origin in file. Handle valid?");
         return NULL;
     }
 
@@ -130,19 +129,19 @@ KProcess* Boot_LoadFileFast(FILE* fd, u32 offset, u32* out_offset, KKernel * Ker
 
     // Read header.
     if (fread(&loader_h, sizeof(loader_h), 1, fd) != 1) {
-        XDSERROR("failed to read header.");
+        XDSERROR("Failed to read header from file.");
         return NULL;
     }
 
     // Load NCCH
     if (memcmp(&loader_h.magic, "NCCH", 4) != 0) {
-        XDSERROR("invalid magic.. wrong file?");
+        XDSERROR("Invalid magic. Is this an NCCH?");
         return NULL;
     }
 
     // Read Exheader.
     if (fread(&ex, sizeof(ex), 1, fd) != 1) {
-        XDSERROR("failed to read exheader.");
+        XDSERROR("Failed to read exheader.");
         return NULL;
     }
 
@@ -156,13 +155,13 @@ KProcess* Boot_LoadFileFast(FILE* fd, u32 offset, u32* out_offset, KKernel * Ker
 
     if (fseek(fd, exefs_off + ncch_off + offset, SEEK_SET) != 0)
     {
-        XDSERROR("failed to seek.");
+        XDSERROR("Failed to seek to offset of ExeFs.");
         return NULL;
     }
 
     exefs_header eh;
     if (fread(&eh, sizeof(eh), 1, fd) != 1) {
-        XDSERROR("failed to read ExeFS header.");
+        XDSERROR("Failed to read ExeFS header.");
         return NULL;
     }
 
@@ -179,18 +178,18 @@ KProcess* Boot_LoadFileFast(FILE* fd, u32 offset, u32* out_offset, KKernel * Ker
             sec_off += exefs_off + sizeof(eh);
             if (fseek(fd, sec_off + ncch_off + offset, SEEK_SET) != 0)
             {
-                XDSERROR("failed to seek.");
+                XDSERROR("Failed to seek to .code offset.");
                 return NULL;
             }
 
             u8* sec = (u8*)malloc(AlignPage(sec_size));
             if (sec == NULL) {
-                XDSERROR("section malloc failed.");
+                XDSERROR("Failed to allocate memory for section.");
                 return NULL;
             }
 
             if (fread(sec, sec_size, 1, fd) != 1) {
-                XDSERROR("section fread failed.");
+                XDSERROR("Failed to read section to memory.");
                 free(sec);
                 return NULL;
             }
@@ -202,7 +201,7 @@ KProcess* Boot_LoadFileFast(FILE* fd, u32 offset, u32* out_offset, KKernel * Ker
                 u8* dec = (u8*)malloc(AlignPage(dec_size));
 
                 if (!dec) {
-                    XDSERROR("decompressed data block allocation failed.");
+                    XDSERROR("Failed to allocate memory for decompression.");
                     free(sec);
                     return NULL;
                 }
@@ -210,7 +209,7 @@ KProcess* Boot_LoadFileFast(FILE* fd, u32 offset, u32* out_offset, KKernel * Ker
                 u32 firmexpected = Read32(ex.codesetinfo.text.codesize) + Read32(ex.codesetinfo.ro.codesize) + Read32(ex.codesetinfo.data.codesize);
 
                 if (Decompress(sec, sec_size, dec, dec_size) == 0) {
-                    XDSERROR("section decompression failed.");
+                    XDSERROR("Decompression of .code failed.");
                     free(sec);
                     free(dec);
                     return NULL;
@@ -234,7 +233,7 @@ KProcess* Boot_LoadFileFast(FILE* fd, u32 offset, u32* out_offset, KKernel * Ker
             u32 codesize = AlignPage(realcodesize);
             u8* code = (u8*)malloc(codesize);
             if (!code) {
-                XDSERROR("text data block allocation failed.");
+                XDSERROR("Text segment allocation failed.");
                 free(sec);
                 return NULL;
             }
@@ -245,7 +244,7 @@ KProcess* Boot_LoadFileFast(FILE* fd, u32 offset, u32* out_offset, KKernel * Ker
             u32 rodatasize = AlignPage(realrodatasize);
             u8* rodata = (u8*)malloc(rodatasize);
             if (!rodata) {
-                XDSERROR("rodata data block allocation failed.");
+                XDSERROR("ROData segment allocation failed.");
                 free(code);
                 free(sec);
                 return NULL;
@@ -257,7 +256,7 @@ KProcess* Boot_LoadFileFast(FILE* fd, u32 offset, u32* out_offset, KKernel * Ker
             u32 datasize = AlignPage(realdatasize);
             u8* data = (u8*)malloc(datasize);
             if (!data) {
-                XDSERROR("data data block allocation failed.");
+                XDSERROR("Data segment allocation failed.");
                 free(code);
                 free(sec);
                 free(rodata);
@@ -321,7 +320,7 @@ FILE* openapp(u32 titlehigh, u32 titlelow) //used by pm
             u8 temp[4];
             if (fread(temp, 4, 1, fd) != 1)
             {
-                XDSERROR("reading tmd Signature Type");
+                XDSERROR("Failed to retrieve signature type from TMD.");
                 return NULL;
             }
             u32 Signature_Type = Read32revers(temp);
@@ -347,18 +346,18 @@ FILE* openapp(u32 titlehigh, u32 titlelow) //used by pm
                 y = 0x80;
                 break;
             default:
-                LOG("unknown Signature Type fallback");
+                LOG("Warning: Signature type is unknown. Falling back to 0x140.");
                 y = 0x140;
                 break;
             }
             if (fseek(fd, y + 0x9C4, SEEK_SET) != 0)
             {
-                XDSERROR("reading tmd Signature Type");
+                XDSERROR("Failed to retrieve signature type from TMD.");
                 return NULL;
             }
             if (fread(temp, 4, 1, fd) != 1)
             {
-                XDSERROR("reading tmd Signature Type");
+                XDSERROR("Failed to retrieve signature type from TMD.");
                 return NULL;
             }
             u32 index = Read32revers(temp);
@@ -372,7 +371,7 @@ FILE* openapp(u32 titlehigh, u32 titlelow) //used by pm
             fd = fopen(string, "rb");
             if (fd == NULL)
             {
-                XDSERROR("opening the container %s", string);
+                XDSERROR("Failed to open app container: `%s`", string);
                 return NULL;
             }
             return fd;
@@ -397,18 +396,18 @@ s64 FindRomFSOffset(FILE* fd, char* name, u64 &out_size, u8* hash_out)
 
        // Read header.
        if (fread(&loader_h, sizeof(loader_h), 1, fd) != 1) {
-               XDSERROR("failed to read header.");
+               XDSERROR("Failed to read header.");
                return -1;
        }
        // Load NCCH
        if (memcmp(&loader_h.magic, "NCCH", 4) != 0) {
-               XDSERROR("invalid magic.. wrong file?");
+               XDSERROR("Invalid magic. Is this an NCCH file?");
                return -1;
        }
 
        // Read Exheader.
        if (fread(&ex, sizeof(ex), 1, fd) != 1) {
-               XDSERROR("failed to read exheader.");
+               XDSERROR("Failed to read exheader.");
                return -1;
        }
 
@@ -436,18 +435,18 @@ s64 FindTableOffset(FILE* fd,char* name,u64 &out_size, u8* hash_out)
 
        // Read header.
        if (fread(&loader_h, sizeof(loader_h), 1, fd) != 1) {
-               XDSERROR("failed to read header.");
+               XDSERROR("Failed to read header.");
                return -1;
        }
        // Load NCCH
        if (memcmp(&loader_h.magic, "NCCH", 4) != 0) {
-               XDSERROR("invalid magic.. wrong file?");
+               XDSERROR("Invalid magic. Is this an NCCH file?");
                return -1;
        }
 
        // Read Exheader.
        if (fread(&ex, sizeof(ex), 1, fd) != 1) {
-               XDSERROR("failed to read exheader.");
+               XDSERROR("Failed to read exheader.");
                return -1;
        }
 
@@ -457,13 +456,13 @@ s64 FindTableOffset(FILE* fd,char* name,u64 &out_size, u8* hash_out)
 
        if (fseek(fd, exefs_off + ncch_off, SEEK_SET) != 0)
        {
-               XDSERROR("failed to seek.");
+               XDSERROR("Failed to seek.");
                return -2;
        }
 
        exefs_header eh;
        if (fread(&eh, sizeof(eh), 1, fd) != 1) {
-               XDSERROR("failed to read ExeFS header.");
+               XDSERROR("Failed to read ExeFS header.");
                return -1;
        }
 
@@ -487,20 +486,22 @@ s64 FindTableOffset(FILE* fd,char* name,u64 &out_size, u8* hash_out)
                        return exefs_off + sizeof(eh) + sec_off;
                }
        }
-       XDSERROR("finding section");
+       XDSERROR("Finding section");
        return -1;
 }
 
 int Boot(KKernel* kernel)
 {
-    FILE* fd = openapp(0x00040138, 0x00000002);//this is firm
+    FILE* fd = openapp(0x00040138, 0x00000002); //this is firm
     //open the firm to extrect the core modules
        u64 temp;
        s64 sec_off = FindTableOffset(fd, ".firm", temp, NULL);
     u32 out_offset;
        if (sec_off > 0)
        {
-               KProcess* process = Boot_LoadFileFast(fd, sec_off + 0x200, &out_offset, kernel);//The first is most likely the NCCH container but that may change I don't know how to detect the correct container so I just do it by a static offset TODO
+               // TODO - The first is most likely the NCCH container but that may change
+               //        I don't know how to detect the correct container so I just do it by a static offset
+               KProcess* process = Boot_LoadFileFast(fd, sec_off + 0x200, &out_offset, kernel);
                for (int j = 0; j < 4; j++) //boot all 5
                {
                        process = Boot_LoadFileFast(fd, (out_offset + 0x1FF)&~0x1FF, &out_offset, kernel);
@@ -508,10 +509,8 @@ int Boot(KKernel* kernel)
                fclose(fd);
                return 0; //it worked
        }
-    if (fd) fclose(fd);
-    XDSERROR("finding .firm section");
-    return -1;
-    XDSERROR("finding firm");
+    if (fd)
+               fclose(fd);
+    XDSERROR("Failed to boot. Couldn't load FIRM. Do you have NAND files?");
     return -1;
-
 }
index 00a8779b3551e50a8059496bc89ac52ea47a4ff5..7c867c5318b0f4109267036ed2ad07f4f14df102 100644 (file)
@@ -44,9 +44,9 @@ int main(int argc, char* argv[]) {
 }
 extern "C" void citraFireInterrupt(int id)
 {
-       LOG("cirta fire %02x",id);
+       LOG("Citra core fired interrupt %02x",id);
        mykernel->FireInterrupt(id);
 }
 bool novideo = true;
 extern "C" int citraPressedkey = 0;
-extern "C" bool citraSettingSkipGSP = true;
\ No newline at end of file
+extern "C" bool citraSettingSkipGSP = true;
index 0474aa6c5764be8414228a2baee717c697a3359c..23ecf23eac5acf6f84a28f25da4f86edf69b20bf 100644 (file)
@@ -16,11 +16,13 @@ KThread::KThread(s32 core, KProcess *owner) : m_running(true)
     Threadwaitlist = NULL;
     m_corenumb = core;
 }
+
 void KThread::stop()
 {
        SynFreeAll(0);
        m_running = false;
 }
+
 void KThread::trigger_event()
 {
        KLinkedListNode<KTimeedEvent> *t = m_owner->m_Kernel->m_Timedevent.list;
@@ -32,6 +34,7 @@ void KThread::trigger_event()
        }
        SynFree(0, this);//the system is waiting for itself so free it
 }
+
 bool KThread::IsInstanceOf(ClassName name) {
     if (name == KThread::name)
         return true;
@@ -58,6 +61,7 @@ void KThread::SyncStall(KLinkedList<KSynchronizationObject>* objects, bool waitA
         {
             current = current->next;
         }
+
                while (current != NULL) //check if this is correct but it looks like it is TODO
                {
                        if (current->data->m_killed == true)
@@ -78,7 +82,7 @@ void KThread::SyncStall(KLinkedList<KSynchronizationObject>* objects, bool waitA
                        sorce++;
                        current = current->prev;
                }
-               
+
                m_waitAll = waitAll;
         m_owner->m_Kernel->ReScheduler();
 
@@ -175,4 +179,4 @@ void KThread::SyncFree(s32 errorCode, KSynchronizationObject* obj)
             //todo speek to Scheduler here
         }
     }
-}
\ No newline at end of file
+}
index 6f02942c7261717cb16fb651ce5e158d166b1b57..b644a29d9439cc57354fe0d4c2b7cba6eef0fc82 100644 (file)
@@ -413,7 +413,7 @@ void P9FS::Command(u32 data[], u32 numb)
                        case 0x1234567c: // SystemSaveData
                                a->Archobj = new Archive1234567c(this->m_owner, lowpath);
                                break;
-                       case 0x1234567d: // NAND RW 
+                       case 0x1234567d: // NAND RW
                                a->Archobj = new Archive1234567d(this->m_owner, lowpath);
                                break;
                        case 0x1234567e: // NAND RO