]> Chaos Git - corbenik/corbenik.git/commitdiff
Minor updates - fix locemu path, start work on reverse (back of disk) emunand
authorchaoskagami <chaos.kagami@gmail.com>
Thu, 16 Jun 2016 21:34:58 +0000 (17:34 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Thu, 16 Jun 2016 21:34:58 +0000 (17:34 -0400)
external/loader/source/exheader.h
external/loader/source/loader.c
source/config.h
source/menu.c
source/patch/emunand.c
source/patch_format.h

index c1bf9be07d34051458264a597be553f1def417b0..8ea6792b8bea0ca926ccb2f9a08d6a23147381f5 100644 (file)
@@ -17,7 +17,7 @@ typedef struct
 typedef struct
 {
     u8 reserved[5];
-    u8 flag;
+    u8 flag; // Maybe a feature - Bits 2-7 are unused. We could allow uh, custom flags here. Like zlib compression on code rather than lzss.
     u8 remasterversion[2];
 } PACKED exheader_systeminfoflags;
 
@@ -67,7 +67,11 @@ typedef struct
 typedef struct
 {
     u64 programid;
-    u8 flags[8];
+    u8 coreVersion[4]; // Kernel version required for this.
+    u8 flag2;
+    u8 flag1;
+    u8 flag0; // CPU speed settings.
+    u8 priority;
     u16 resourcelimitdescriptor[0x10];
     exheader_storageinfo storageinfo;
     u64 serviceaccesscontrol[0x20];
index 2a35ef3121268373c1a9fc947e44230452599b04..535307368cce632750c64d90288379221c59d108 100644 (file)
@@ -114,14 +114,6 @@ loader_GetProgramInfo(exheader_header *exheader, u64 prog_handle)
     }
 }
 
-static void
-ConfigureNew3DSCPU(u8 mode)
-{
-       // Note that this is untested as of yet - I haven't got around to it.
-
-    svcKernelSetState(10, mode, 0, 0); // Set N3DS CPU speed.
-}
-
 static Result
 loader_LoadProcess(Handle *process, u64 prog_handle)
 {
@@ -172,19 +164,6 @@ loader_LoadProcess(Handle *process, u64 prog_handle)
     logu64(progid);
     logstr("  validated params\n");
 
-    // Check and set the CPU mode. Possible values: 0 - Keep o3ds speed, 1 -
-    // n3ds speed, -1 force o3ds
-    // This is A-OK because the CPU speed parameter isn't passed through to any
-    // kernel function; meaning it has already been set.
-    u8 n3ds_mode = g_exheader.arm11systemlocalcaps.flags[1] & 0x3; // 0x3 -> L2+800Mhz
-    u8 cpu_mode = get_cpumode(progid);
-    if (cpu_mode != 0xFF) {             // Skip?
-        u8 mode = n3ds_mode | cpu_mode; // Keep flags set by exheader.
-        ConfigureNew3DSCPU(mode);       // We do not use PXIPM because we are a
-                                        // sysmodule. It doesn't make sense.
-                                        // Therefore, we directly call CPU setup.
-    }
-
     // TODO - clean up this shit below. Not only is it unoptimized but it reads like garbage.
 
     // What the addressing info would be if not for expansion. This is passed to
@@ -229,10 +208,12 @@ loader_LoadProcess(Handle *process, u64 prog_handle)
         codesetinfo.rw_size_total = data_mem_size;
         res = svcCreateCodeSet(&codeset, &codesetinfo, (void *)shared_addr.text_addr, (void *)shared_addr.ro_addr, (void *)shared_addr.data_addr);
         if (res >= 0) {
-            closeLogger();
-
             res = svcCreateProcess(process, codeset, g_exheader.arm11kernelcaps.descriptors, count);
 
+            logstr("Created process\n");
+
+            closeLogger();
+
             svcCloseHandle(codeset);
             if (res >= 0) {
                 return 0; // Succeeded in loading process.
index 1a8f58fb6986d9e5feed23db12c3a952667c57a9..c96092582ecb84a7da912d50ec6973405f8da117 100644 (file)
@@ -110,6 +110,17 @@ struct options_s
 // (e.g. SaltySD)
 #define OPTION_LOADER_LOADCODE 21
 
+// Calculate EmuNAND at the back of the disk, rather than the front.
+// There's many good reasons for this to be supported:
+//   - Resizable FAT partition
+//     - Shrink to add EmuNAND
+//     = Grow to delete EmuNAND
+//   - Doesn't require copying fucktons of data to manage multiemunand
+// This isn't supported by ANY tools like D9 at the moment
+// (Though I hope they'll consider it -
+//  there's only benefits to users with multiple EmuNANDs)
+#define OPTION_EMUNAND_REVERSE 22
+
 // Save log files during boot and from loader.
 // This will slow things down a bit.
 #define OPTION_SAVE_LOGS 253
index 6d9b8741dbd16bbceacf7a0c7c97064d12b0ed79..c8b55bbb0629c042152d8480f79da25fbf9689b7 100644 (file)
@@ -16,6 +16,7 @@ static struct options_s options[] = {
 
     { OPTION_EMUNAND, "Use EmuNAND", "Redirects NAND write/read to the SD.", boolean_val, 0, 0 },
     { OPTION_EMUNAND_INDEX, "  Index", "Which EmuNAND to use. Currently, 10 maximum (but this is arbitrary)", ranged_val, 0, 0x9 },
+    { OPTION_EMUNAND_REVERSE, "  Reverse mode", "EmuNAND is at the back of the disk, not the front.", boolean_val, 0, 0x9 },
 
     { OPTION_AUTOBOOT, "Autoboot", "Boot the system automatically, unless the R key is held.", boolean_val, 0, 0 },
     { OPTION_SILENCE, "  Silent mode", "Suppress all debug output during autoboot. You'll see the screen turn on, then off.", boolean_val, 0, 0 },
index 7b451534757db9d547fd587e8498e9ddda55a17a..fc796da897ea850a0ffa263d0d3e0e466152edc2 100644 (file)
@@ -12,6 +12,7 @@
 #include "../fatfs/sdmmc.h"
 #include "../firm/headers.h"
 #include "../patch_format.h"
+#include "../config.h"
 
 uint8_t *emunand_temp = (uint8_t *)FCRAM_JUNK_LOC;
 
@@ -20,6 +21,7 @@ verify_loop_emunand(char *filename)
 {
     // FIXME - This won't work unless the NAND file is completely contiguous on disk, sadly.
     // Technically speaking if I were to defrag my SD this would work, I suspect.
+    // For now, this will remain as dead code.
 
     uint32_t offset = get_file_sector(filename); // Get the sector of the file
 
@@ -42,6 +44,10 @@ verify_emunand(uint32_t index, uint32_t *off, uint32_t *head)
     else
         offset = 0x200000 * index;
 
+    if (config.options[OPTION_EMUNAND_REVERSE]) {
+        // Subtract offset from back of disk.
+    }
+
     // Check for RedNAND/Normal physical layout on SD
     if (!sdmmc_sdcard_readsectors(offset + 1, 1, emunand_temp) && *(uint32_t *)(emunand_temp + 0x100) == NCSD_MAGIC) {
         *off = offset + 1;
index d217a0d0726b07506daa1be10b00559d1d989852..02e63aea5139fa6244b938174ac572d6d6ad8ec9 100644 (file)
 
 #define PATH_CONFIG_DIR PATH_CFW "/config"       // Config file directory.
 #define PATH_CONFIG PATH_CONFIG_DIR "/main.conf" // Config file.
-#define PATH_LOCEMU PATH_CONFIG_DIR "/locale"    // Locale emulation config
 #define PATH_CPU_CFG PATH_CONFIG_DIR "/cpu.conf" // CPU settings config
 
+#define PATH_LOCEMU PATH_CFW "/locale"    // Locale emulation config
+
 #define PATH_PATCHES PATH_CFW "/patch"      // Patch binary folder.
 #define PATH_FIRMWARES PATH_CFW "/firmware" // Firmware folder.
 #define PATH_MODULES PATH_CFW "/module"     // Sysmodule location