mirror of
https://github.com/d0k3/SafeB9SInstaller.git
synced 2025-06-26 13:42:45 +00:00
Improved unit detection routines
This commit is contained in:
parent
e20ec690b9
commit
2e9659e36a
@ -1,15 +0,0 @@
|
|||||||
#include "common.h"
|
|
||||||
#include "platform.h"
|
|
||||||
|
|
||||||
#define CONFIG_PLATFORM_REG ((volatile u32*)0x10140FFC)
|
|
||||||
|
|
||||||
Platform GetUnitPlatform()
|
|
||||||
{
|
|
||||||
switch (*CONFIG_PLATFORM_REG) {
|
|
||||||
case 7:
|
|
||||||
return PLATFORM_N3DS;
|
|
||||||
case 1:
|
|
||||||
default:
|
|
||||||
return PLATFORM_3DS;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
PLATFORM_3DS,
|
|
||||||
PLATFORM_N3DS,
|
|
||||||
} Platform;
|
|
||||||
|
|
||||||
Platform GetUnitPlatform();
|
|
13
source/common/unittype.h
Normal file
13
source/common/unittype.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
|
// see: https://3dbrew.org/wiki/CONFIG11_Registers
|
||||||
|
#define IS_O3DS ((*(vu32*) 0x10140FFC) != 0x7)
|
||||||
|
|
||||||
|
// see: https://www.3dbrew.org/wiki/Memory_layout#ARM9_ITCM
|
||||||
|
// see: https://www.3dbrew.org/wiki/OTP_Registers#Plaintext_OTP
|
||||||
|
#define IS_DEVKIT ((*(vu8*) (0x01FFB800+0x19)) != 0x0)
|
||||||
|
|
||||||
|
// see: https://3dbrew.org/wiki/CONFIG11_Registers
|
||||||
|
#define IS_A9LH ((*(vu32*) 0x101401C0) == 0)
|
@ -326,7 +326,7 @@ u32 CheckNandHeader(void* header)
|
|||||||
// header type check
|
// header type check
|
||||||
u8* header_enc = header;
|
u8* header_enc = header;
|
||||||
if (memcmp(header_enc + 0x100, nand_magic_n3ds, sizeof(nand_magic_n3ds) == 0) == 0)
|
if (memcmp(header_enc + 0x100, nand_magic_n3ds, sizeof(nand_magic_n3ds) == 0) == 0)
|
||||||
return (GetUnitPlatform() == PLATFORM_3DS) ? 0 : NAND_TYPE_N3DS;
|
return (IS_O3DS) ? 0 : NAND_TYPE_N3DS;
|
||||||
else if (memcmp(header_enc + 0x100, nand_magic_o3ds, sizeof(nand_magic_o3ds) == 0) == 0)
|
else if (memcmp(header_enc + 0x100, nand_magic_o3ds, sizeof(nand_magic_o3ds) == 0) == 0)
|
||||||
return NAND_TYPE_O3DS;
|
return NAND_TYPE_O3DS;
|
||||||
|
|
||||||
@ -338,12 +338,12 @@ u32 CheckNandType(void)
|
|||||||
if (ReadNandSectors(NAND_BUFFER, 0, 1, 0xFF) != 0)
|
if (ReadNandSectors(NAND_BUFFER, 0, 1, 0xFF) != 0)
|
||||||
return 0;
|
return 0;
|
||||||
if (memcmp(NAND_BUFFER + 0x100, nand_magic_n3ds, 0x60) == 0) {
|
if (memcmp(NAND_BUFFER + 0x100, nand_magic_n3ds, 0x60) == 0) {
|
||||||
return (GetUnitPlatform() == PLATFORM_3DS) ? 0 : NAND_TYPE_N3DS;
|
return (IS_O3DS) ? 0 : NAND_TYPE_N3DS;
|
||||||
} else if (memcmp(NAND_BUFFER + 0x100, nand_magic_o3ds, 0x60) == 0) {
|
} else if (memcmp(NAND_BUFFER + 0x100, nand_magic_o3ds, 0x60) == 0) {
|
||||||
u8 magic[8] = {0xE9, 0x00, 0x00, 0x43, 0x54, 0x52, 0x20, 0x20};
|
u8 magic[8] = {0xE9, 0x00, 0x00, 0x43, 0x54, 0x52, 0x20, 0x20};
|
||||||
if (ReadNandSectors(NAND_BUFFER, 0x5CAE5, 1, 0x04) != 0)
|
if (ReadNandSectors(NAND_BUFFER, 0x5CAE5, 1, 0x04) != 0)
|
||||||
return 0;
|
return 0;
|
||||||
return ((GetUnitPlatform() == PLATFORM_3DS) || (memcmp(magic, NAND_BUFFER, 8) == 0)) ?
|
return ((IS_O3DS) || (memcmp(magic, NAND_BUFFER, 8) == 0)) ?
|
||||||
NAND_TYPE_O3DS : NAND_TYPE_NO3DS;
|
NAND_TYPE_O3DS : NAND_TYPE_NO3DS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "platform.h"
|
#include "unittype.h"
|
||||||
|
|
||||||
#define NAND_MIN_SECTORS ((GetUnitPlatform() == PLATFORM_N3DS) ? NAND_MIN_SECTORS_N3DS : NAND_MIN_SECTORS_O3DS)
|
#define NAND_MIN_SECTORS ((!IS_O3DS) ? NAND_MIN_SECTORS_N3DS : NAND_MIN_SECTORS_O3DS)
|
||||||
|
|
||||||
#define NAND_SYSNAND (1<<0)
|
#define NAND_SYSNAND (1<<0)
|
||||||
#define NAND_ZERONAND (1<<3)
|
#define NAND_ZERONAND (1<<3)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user