2017-01-13 14:20:42 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "common.h"
|
2019-07-27 20:22:39 +02:00
|
|
|
#include "card_spi.h"
|
2017-01-13 14:20:42 +01:00
|
|
|
|
|
|
|
#define CART_NONE 0
|
|
|
|
#define CART_CTR (1<<0)
|
|
|
|
#define CART_NTR (1<<1)
|
|
|
|
#define CART_TWL (1<<2)
|
|
|
|
|
2019-07-10 22:09:58 +02:00
|
|
|
#define MODC_AREA_SIZE 0x4000
|
|
|
|
#define PRIV_HDR_SIZE 0x50
|
|
|
|
#define JEDECID_AND_SREG_SIZE 0x4
|
2017-01-13 14:20:42 +01:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
u8 header[0x8000]; // NTR header + secure area / CTR header + private header
|
|
|
|
u8 twl_header[0x8000]; // TWL header + modcrypt area / unused
|
|
|
|
u32 cart_type;
|
|
|
|
u32 cart_id;
|
|
|
|
u64 cart_size;
|
|
|
|
u64 data_size;
|
2017-04-28 01:24:36 +02:00
|
|
|
u32 save_size;
|
2019-07-27 20:22:39 +02:00
|
|
|
CardSPIType save_type;
|
2017-01-13 14:20:42 +01:00
|
|
|
u32 arm9i_rom_offset; // TWL specific
|
2019-07-23 14:09:18 -03:00
|
|
|
} PACKED_ALIGN(16) CartData;
|
2017-01-13 14:20:42 +01:00
|
|
|
|
|
|
|
u32 GetCartName(char* name, CartData* cdata);
|
2017-04-28 01:24:36 +02:00
|
|
|
u32 InitCartRead(CartData* cdata);
|
2017-06-01 15:11:41 +02:00
|
|
|
u32 ReadCartSectors(void* buffer, u32 sector, u32 count, CartData* cdata);
|
|
|
|
u32 ReadCartBytes(void* buffer, u64 offset, u64 count, CartData* cdata);
|
|
|
|
u32 ReadCartPrivateHeader(void* buffer, u64 offset, u64 count, CartData* cdata);
|
2017-04-28 01:24:36 +02:00
|
|
|
u32 ReadCartSave(u8* buffer, u64 offset, u64 count, CartData* cdata);
|
2019-07-13 02:14:46 +02:00
|
|
|
u32 WriteCartSave(const u8* buffer, u64 offset, u64 count, CartData* cdata);
|
2019-07-10 22:09:58 +02:00
|
|
|
u32 ReadCartSaveJedecId(u8* buffer, u64 offset, u64 count, CartData* cdata);
|