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;
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];
}
}
-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)
{
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
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.
// (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
{ 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 },
#include "../fatfs/sdmmc.h"
#include "../firm/headers.h"
#include "../patch_format.h"
+#include "../config.h"
uint8_t *emunand_temp = (uint8_t *)FCRAM_JUNK_LOC;
{
// 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
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;
#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