Skip to content

Commit cfe7c19

Browse files
ez5n: clean up comments in header
1 parent a0ce996 commit cfe7c19

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

blocksds/source/platform/ez5n/ez5n.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void EZ5N_SDWriteSectors(u32 sector, u32 num_sectors, const void* buffer) {
5757

5858
// Flush to disk
5959
// Should return 0 when done
60-
while (EZ5N_SendCommand(EZ5N_CMD_SD_WRITE_FLUSH(sector, sector_count), 0x190))
60+
while (EZ5N_SendCommand(EZ5N_CMD_SD_FLUSH_BUFFER(sector, sector_count), 0x190))
6161
;
6262
sector += sector_count;
6363
num_sectors -= sector_count;

blocksds/source/platform/ez5n/ez5n.h

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,36 +16,51 @@
1616
#define NULL 0
1717
#endif
1818

19-
// EZParallel defines
2019
// EZParallel MCCNT1 flags
20+
21+
// Common flags set by all commands
2122
#define EZ5N_CTRL_BASE \
2223
(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.
2326
#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))
2727

28+
// Flags when reading blocks of data.
29+
#define EZ5N_CTRL_READ_SD (EZ5N_CTRL_BASE | MCCNT1_LATENCY2(26))
2830
#define EZ5N_CTRL_READ_SD_512 (EZ5N_CTRL_READ_SD | MCCNT1_LEN_512)
2931
#define EZ5N_CTRL_READ_SD_1024 (EZ5N_CTRL_READ_SD | MCCNT1_LEN_1024)
3032
#define EZ5N_CTRL_READ_SD_2048 (EZ5N_CTRL_READ_SD | MCCNT1_LEN_2048)
3133

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+
3240
// EZParallel MCCMDs
41+
42+
// Retrieves the card hardware version.
3343
#define EZ5N_CMD_CARD_VERSION 0x3E00000000000000ull
44+
45+
// Sends a FAT offset table to be used with hardware-backed retail cartridge emulation.
3446
#define EZ5N_CMD_SD_SEND_FAT_ENTRY 0xB100000100000000ull
35-
#define EZ5N_CMD_SD_READ_DATA 0xBA00000000000000ull
3647

37-
// this reads 4 sectors???
48+
// Requests block reads from the SD card up to 4 sectors at a time.
3849
static inline u64 EZ5N_CMD_SD_READ_REQUEST(u32 sector, u32 num_sectors) {
3950
return (0xB9ull << 56) | ((u64)(num_sectors & 0xFF) << 32) | ((u64)sector);
4051
}
4152

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.
4458
static inline u64 EZ5N_CMD_SD_WRITE_BUFFER(u32 buffer_index) {
4559
return (0xBBull << 56) | (1ull << 32) | ((u64)(buffer_index & 0xFF));
4660
}
4761

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) {
4964
return (0xBCull << 56) | ((u64)(num_sectors & 0xFF) << 32) | ((u64)sector);
5065
}
5166

0 commit comments

Comments
 (0)