* 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
[submodule "external/gl3w"]
path = external/gl3w
url = https://github.com/skaslev/gl3w
[submodule "external/gl3w"]
path = external/gl3w
url = https://github.com/skaslev/gl3w
+[submodule "external/glfw"]
+ path = external/glfw
+ url = https://github.com/glfw/glfw
#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)
#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)))
COMMON_FILES := $(patsubst %.cpp,%.o,$(patsubst %.c,%.o,$(SOURCE_FILES)))
g++ -o xds $(TEST_DEFS) $(BUILD_FLAGS) $(COMMON_FILES) $(LDFLAGS)
deps:
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 $@ $<
%.o: %.c
gcc $(CFLAGS) -c -o $@ $<
./xds_test_resourcelimit
./xds_test_mutex
./xds_test_resourcelimit
./xds_test_mutex
rm -f $(COMMON_FILES) ./xds ./xds_test_memorymap ./xds_test_handletable ./xds_test_linkedlist ./xds_test_resourcelimit ./xds_test_mutex
rm -f $(COMMON_FILES) ./xds ./xds_test_memorymap ./xds_test_handletable ./xds_test_linkedlist ./xds_test_resourcelimit ./xds_test_mutex
Bond697
who helped me create XDS
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.
--- /dev/null
+Subproject commit 4888d7d410f3a613dbf8d8e24d3bf7ad61042a12
-//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])
//tools
static u32 Read32revers(uint8_t p[4])
if (fseek(fd, offset, SEEK_SET) != 0)
{
if (fseek(fd, offset, SEEK_SET) != 0)
{
- XDSERROR("failed to seek.");
+ XDSERROR("Failed to seek to origin in file. Handle valid?");
// Read header.
if (fread(&loader_h, sizeof(loader_h), 1, fd) != 1) {
// 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) {
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) {
return NULL;
}
// Read Exheader.
if (fread(&ex, sizeof(ex), 1, fd) != 1) {
- XDSERROR("failed to read exheader.");
+ XDSERROR("Failed to read exheader.");
if (fseek(fd, exefs_off + ncch_off + offset, SEEK_SET) != 0)
{
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) {
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.");
sec_off += exefs_off + sizeof(eh);
if (fseek(fd, sec_off + ncch_off + offset, SEEK_SET) != 0)
{
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) {
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) {
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;
}
free(sec);
return NULL;
}
u8* dec = (u8*)malloc(AlignPage(dec_size));
if (!dec) {
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;
}
free(sec);
return NULL;
}
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) {
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;
free(sec);
free(dec);
return NULL;
u32 codesize = AlignPage(realcodesize);
u8* code = (u8*)malloc(codesize);
if (!code) {
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;
}
free(sec);
return NULL;
}
u32 rodatasize = AlignPage(realrodatasize);
u8* rodata = (u8*)malloc(rodatasize);
if (!rodata) {
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;
free(code);
free(sec);
return NULL;
u32 datasize = AlignPage(realdatasize);
u8* data = (u8*)malloc(datasize);
if (!data) {
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);
free(code);
free(sec);
free(rodata);
u8 temp[4];
if (fread(temp, 4, 1, fd) != 1)
{
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);
return NULL;
}
u32 Signature_Type = Read32revers(temp);
y = 0x80;
break;
default:
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)
{
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)
{
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);
return NULL;
}
u32 index = Read32revers(temp);
fd = fopen(string, "rb");
if (fd == NULL)
{
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;
return NULL;
}
return fd;
// Read header.
if (fread(&loader_h, sizeof(loader_h), 1, fd) != 1) {
// 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) {
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) {
return -1;
}
// Read Exheader.
if (fread(&ex, sizeof(ex), 1, fd) != 1) {
- XDSERROR("failed to read exheader.");
+ XDSERROR("Failed to read exheader.");
// Read header.
if (fread(&loader_h, sizeof(loader_h), 1, fd) != 1) {
// 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) {
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) {
return -1;
}
// Read Exheader.
if (fread(&ex, sizeof(ex), 1, fd) != 1) {
- XDSERROR("failed to read exheader.");
+ XDSERROR("Failed to read exheader.");
if (fseek(fd, exefs_off + ncch_off, SEEK_SET) != 0)
{
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) {
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 exefs_off + sizeof(eh) + sec_off;
}
}
return exefs_off + sizeof(eh) + sec_off;
}
}
- XDSERROR("finding section");
+ XDSERROR("Finding section");
return -1;
}
int Boot(KKernel* kernel)
{
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)
{
//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);
for (int j = 0; j < 4; j++) //boot all 5
{
process = Boot_LoadFileFast(fd, (out_offset + 0x1FF)&~0x1FF, &out_offset, kernel);
fclose(fd);
return 0; //it worked
}
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?");
}
extern "C" void citraFireInterrupt(int id)
{
}
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;
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;
Threadwaitlist = NULL;
m_corenumb = core;
}
Threadwaitlist = NULL;
m_corenumb = core;
}
void KThread::stop()
{
SynFreeAll(0);
m_running = false;
}
void KThread::stop()
{
SynFreeAll(0);
m_running = false;
}
void KThread::trigger_event()
{
KLinkedListNode<KTimeedEvent> *t = m_owner->m_Kernel->m_Timedevent.list;
void KThread::trigger_event()
{
KLinkedListNode<KTimeedEvent> *t = m_owner->m_Kernel->m_Timedevent.list;
}
SynFree(0, this);//the system is waiting for itself so free it
}
}
SynFree(0, this);//the system is waiting for itself so free it
}
bool KThread::IsInstanceOf(ClassName name) {
if (name == KThread::name)
return true;
bool KThread::IsInstanceOf(ClassName name) {
if (name == KThread::name)
return true;
{
current = current->next;
}
{
current = current->next;
}
while (current != NULL) //check if this is correct but it looks like it is TODO
{
if (current->data->m_killed == true)
while (current != NULL) //check if this is correct but it looks like it is TODO
{
if (current->data->m_killed == true)
sorce++;
current = current->prev;
}
sorce++;
current = current->prev;
}
m_waitAll = waitAll;
m_owner->m_Kernel->ReScheduler();
m_waitAll = waitAll;
m_owner->m_Kernel->ReScheduler();
//todo speek to Scheduler here
}
}
//todo speek to Scheduler here
}
}
-}
\ No newline at end of file
case 0x1234567c: // SystemSaveData
a->Archobj = new Archive1234567c(this->m_owner, lowpath);
break;
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
a->Archobj = new Archive1234567d(this->m_owner, lowpath);
break;
case 0x1234567e: // NAND RO