|
16 | 16 | #define NULL 0 |
17 | 17 | #endif |
18 | 18 |
|
19 | | -// EZParallel defines |
20 | 19 | // EZParallel MCCNT1 flags |
| 20 | + |
| 21 | +// Common flags set by all commands |
21 | 22 | #define EZ5N_CTRL_BASE \ |
22 | 23 | (MCCNT1_RESET_OFF | MCCNT1_CMD_SCRAMBLE | MCCNT1_CLOCK_SCRAMBLER | MCCNT1_READ_DATA_DESCRAMBLE) |
| 24 | + |
| 25 | +// Flags when sending a command and retrieving a 4-byte response. |
23 | 26 | #define EZ5N_CTRL_SEND_CMD (EZ5N_CTRL_BASE | MCCNT1_LATENCY2(24) | MCCNT1_LEN_4) |
24 | | -#define EZ5N_CTRL_READ_SD (EZ5N_CTRL_BASE | MCCNT1_LATENCY2(26)) |
25 | | -#define EZ5N_CTRL_WRITE_SD \ |
26 | | - (EZ5N_CTRL_BASE | MCCNT1_DIR_WRITE | MCCNT1_LATENCY2(26) | MCCNT1_LATENCY1(0x1FFF)) |
27 | 27 |
|
| 28 | +// Flags when reading blocks of data. |
| 29 | +#define EZ5N_CTRL_READ_SD (EZ5N_CTRL_BASE | MCCNT1_LATENCY2(26)) |
28 | 30 | #define EZ5N_CTRL_READ_SD_512 (EZ5N_CTRL_READ_SD | MCCNT1_LEN_512) |
29 | 31 | #define EZ5N_CTRL_READ_SD_1024 (EZ5N_CTRL_READ_SD | MCCNT1_LEN_1024) |
30 | 32 | #define EZ5N_CTRL_READ_SD_2048 (EZ5N_CTRL_READ_SD | MCCNT1_LEN_2048) |
31 | 33 |
|
| 34 | +// Flags when writing blocks of data. |
| 35 | +// The original kernel did not set any LATENCY1; however, without it, intermittent |
| 36 | +// corruption occurs, therefore the maximum latency was added. |
| 37 | +#define EZ5N_CTRL_WRITE_SD \ |
| 38 | + (EZ5N_CTRL_BASE | MCCNT1_DIR_WRITE | MCCNT1_LATENCY2(26) | MCCNT1_LATENCY1(0x1FFF)) |
| 39 | + |
32 | 40 | // EZParallel MCCMDs |
| 41 | + |
| 42 | +// Retrieves the card hardware version. |
33 | 43 | #define EZ5N_CMD_CARD_VERSION 0x3E00000000000000ull |
| 44 | + |
| 45 | +// Sends a FAT offset table to be used with hardware-backed retail cartridge emulation. |
34 | 46 | #define EZ5N_CMD_SD_SEND_FAT_ENTRY 0xB100000100000000ull |
35 | | -#define EZ5N_CMD_SD_READ_DATA 0xBA00000000000000ull |
36 | 47 |
|
37 | | -// this reads 4 sectors??? |
| 48 | +// Requests block reads from the SD card up to 4 sectors at a time. |
38 | 49 | static inline u64 EZ5N_CMD_SD_READ_REQUEST(u32 sector, u32 num_sectors) { |
39 | 50 | return (0xB9ull << 56) | ((u64)(num_sectors & 0xFF) << 32) | ((u64)sector); |
40 | 51 | } |
41 | 52 |
|
42 | | -// Writing seems to support up to 0x800 bytes |
43 | | -// It appears to work from an internal buffer, and flushes afterwards. |
| 53 | +// Retrieve data blocks requested by EZ5N_CMD_SD_READ_REQUEST |
| 54 | +#define EZ5N_CMD_SD_READ_DATA 0xBA00000000000000ull |
| 55 | + |
| 56 | +// Sends data blocks to an index in the internal write buffer. |
| 57 | +// Up to 4 indices are supported; this means that 4 sectors can be written at a time. |
44 | 58 | static inline u64 EZ5N_CMD_SD_WRITE_BUFFER(u32 buffer_index) { |
45 | 59 | return (0xBBull << 56) | (1ull << 32) | ((u64)(buffer_index & 0xFF)); |
46 | 60 | } |
47 | 61 |
|
48 | | -static inline u64 EZ5N_CMD_SD_WRITE_FLUSH(u32 sector, u32 num_sectors) { |
| 62 | +// Flushes the internal buffer to a given sector on the SD card. |
| 63 | +static inline u64 EZ5N_CMD_SD_FLUSH_BUFFER(u32 sector, u32 num_sectors) { |
49 | 64 | return (0xBCull << 56) | ((u64)(num_sectors & 0xFF) << 32) | ((u64)sector); |
50 | 65 | } |
51 | 66 |
|
|
0 commit comments