From 5ffbc41b2c6fec365e52422bfd9171c3631fae49 Mon Sep 17 00:00:00 2001 From: Trevor Rudolph Date: Sat, 11 Jan 2025 00:36:28 -0500 Subject: [PATCH] move from types back to type+attrib --- cubeboot/source/flippy_sync.c | 4 ++-- cubeboot/source/ipc.h | 27 ++++++++++++++------------- cubeboot/source/sram.c | 4 ++-- cubeboot/source/uff.c | 2 +- patches/source/boot.c | 10 +++++----- patches/source/dolphin_dvd.c | 2 +- patches/source/flippy_sync.c | 4 ++-- patches/source/games.c | 14 +++++++------- 8 files changed, 34 insertions(+), 33 deletions(-) diff --git a/cubeboot/source/flippy_sync.c b/cubeboot/source/flippy_sync.c index 842094e..0e8fe0b 100644 --- a/cubeboot/source/flippy_sync.c +++ b/cubeboot/source/flippy_sync.c @@ -451,7 +451,7 @@ int dvd_custom_open(const char *path, uint8_t type, uint8_t flags) { strncpy(entry.name, path, 256); entry.name[255] = 0; - entry.types = type; + entry.type = type; entry.flags = flags; DCFlushRange(&entry, sizeof(file_entry_t)); @@ -482,7 +482,7 @@ int dvd_custom_open_flash(const char *path, uint8_t type, uint8_t flags) { strncpy(entry.name, path, 256); entry.name[255] = 0; - entry.types = type; + entry.type = type; entry.flags = flags; DCFlushRange(&entry, sizeof(file_entry_t)); diff --git a/cubeboot/source/ipc.h b/cubeboot/source/ipc.h index 75a3e8c..418ddf9 100644 --- a/cubeboot/source/ipc.h +++ b/cubeboot/source/ipc.h @@ -114,31 +114,32 @@ enum { }; enum { - FILE_TYPE_FLAG_FILE = 0x00, - FILE_TYPE_FLAG_RDO = 0x01, // AM_RDO - FILE_TYPE_FLAG_HIDDEN = 0x02, // AM_HID - FILE_TYPE_FLAG_SYSTEM = 0x04, // AM_SYS - FILE_TYPE_FLAG_DIR = 0x10, // AM_DIR - FILE_TYPE_FLAG_ARC = 0x20, // AM_ARC + FILE_ENTRY_TYPE_FILE = 0, + FILE_ENTRY_TYPE_DIR = 1, + + FILE_ENTRY_TYPE_BAD = 0xFF, + FILE_ENTRY_TYPE_MAX = 0xFF }; enum { - INTERNAL_FD_TYPE_FILE = 0, - INTERNAL_FD_TYPE_DIR = 1, - - INTERNAL_FD_TYPE_BAD = 0xFF, - INTERNAL_FD_TYPE_MAX = 0xFF + FILE_ATTRIB_FLAG_FILE = 0x00, + FILE_ATTRIB_FLAG_RDO = 0x01, // AM_RDO + FILE_ATTRIB_FLAG_HIDDEN = 0x02, // AM_HID + FILE_ATTRIB_FLAG_SYSTEM = 0x04, // AM_SYS + FILE_ATTRIB_FLAG_DIR = 0x10, // AM_DIR + FILE_ATTRIB_FLAG_ARC = 0x20, // AM_ARC }; typedef struct { char name[MAX_FILE_NAME]; - uint8_t types; + uint8_t type; uint8_t flags; uint64_t size; uint32_t date; uint32_t time; uint32_t last_status; - uint8_t pad[10]; + uint8_t attrib; + uint8_t pad[9]; } file_entry_t; ASSERT_SIZE_MULTIPLE_OF_32(file_entry_t); diff --git a/cubeboot/source/sram.c b/cubeboot/source/sram.c index d08bfe4..7093b8b 100644 --- a/cubeboot/source/sram.c +++ b/cubeboot/source/sram.c @@ -33,7 +33,7 @@ void create_swiss_config() { dvd_custom_mkdir("/swiss/settings"); // check swiss global config - dvd_custom_open(SWISS_GLOBAL_CONFIG_PATH, FILE_TYPE_FLAG_FILE, IPC_FILE_FLAG_DISABLESPEEDEMU); + dvd_custom_open(SWISS_GLOBAL_CONFIG_PATH, FILE_ENTRY_TYPE_FILE, IPC_FILE_FLAG_DISABLESPEEDEMU); GCN_ALIGNED(file_status_t) status; int ret = dvd_custom_status(&status); @@ -46,7 +46,7 @@ void create_swiss_config() { } // create swiss global config - ret = dvd_custom_open(SWISS_GLOBAL_CONFIG_PATH, FILE_TYPE_FLAG_FILE, IPC_FILE_FLAG_DISABLESPEEDEMU | IPC_FILE_FLAG_WRITE); + ret = dvd_custom_open(SWISS_GLOBAL_CONFIG_PATH, FILE_ENTRY_TYPE_FILE, IPC_FILE_FLAG_DISABLESPEEDEMU | IPC_FILE_FLAG_WRITE); if (ret != 0) return; // TODO: what do we put in this file? diff --git a/cubeboot/source/uff.c b/cubeboot/source/uff.c index c1c201e..01a6c2b 100644 --- a/cubeboot/source/uff.c +++ b/cubeboot/source/uff.c @@ -138,7 +138,7 @@ FRESULT uf_open(const char* path) { } __file_offset = 0; - int ret = dvd_custom_open((char*)path, FILE_TYPE_FLAG_FILE, IPC_FILE_FLAG_DISABLECACHE | IPC_FILE_FLAG_DISABLEFASTSEEK); + int ret = dvd_custom_open((char*)path, FILE_ENTRY_TYPE_FILE, IPC_FILE_FLAG_DISABLECACHE | IPC_FILE_FLAG_DISABLEFASTSEEK); iprintf("dvd_custom_open ret: %08x\n", ret); if (ret != 0) return FR_NOT_OPENED; diff --git a/patches/source/boot.c b/patches/source/boot.c index f50e820..b0a8210 100644 --- a/patches/source/boot.c +++ b/patches/source/boot.c @@ -16,7 +16,7 @@ void load_stub() { custom_OSReport("Loading stub...\n"); - dvd_custom_open_flash("/stub.bin", FILE_TYPE_FLAG_FILE, 0); + dvd_custom_open_flash("/stub.bin", FILE_ENTRY_TYPE_FILE, 0); file_status_t *file_status = dvd_custom_status(); if (file_status == NULL || file_status->result != 0) { custom_OSReport("Failed to open stub\n"); @@ -38,9 +38,9 @@ __attribute__((aligned(32))) static DOLHEADER dol_hdr; dol_info_t load_dol(char *path, bool flash) { uint8_t flags = IPC_FILE_FLAG_DISABLECACHE | IPC_FILE_FLAG_DISABLEFASTSEEK | IPC_FILE_FLAG_DISABLESPEEDEMU; if (flash) { - dvd_custom_open_flash(path, FILE_TYPE_FLAG_FILE, flags); + dvd_custom_open_flash(path, FILE_ENTRY_TYPE_FILE, flags); } else { - dvd_custom_open(path, FILE_TYPE_FLAG_FILE, flags); + dvd_custom_open(path, FILE_ENTRY_TYPE_FILE, flags); } file_status_t *file_status = dvd_custom_status(); @@ -157,7 +157,7 @@ void legacy_chainload_boot_game(gm_file_entry_t *boot_entry, bool passthrough) { if (!passthrough) { // open file - dvd_custom_open(boot_entry->path, FILE_TYPE_FLAG_FILE, 0); + dvd_custom_open(boot_entry->path, FILE_ENTRY_TYPE_FILE, 0); file_status_t *file_status = dvd_custom_status(); if (file_status == NULL || file_status->result != 0) { custom_OSReport("Failed to open file %s\n", boot_entry->path); @@ -169,7 +169,7 @@ void legacy_chainload_boot_game(gm_file_entry_t *boot_entry, bool passthrough) { custom_OSReport("Boot entry: %s\n", boot_entry->path); if (boot_entry->second != NULL) { custom_OSReport("Second entry: %s (valid: %d, %p)\n", boot_entry->second->path, boot_entry->second->second == boot_entry, boot_entry->second); - dvd_custom_open(boot_entry->second->path, FILE_TYPE_FLAG_FILE, 0); + dvd_custom_open(boot_entry->second->path, FILE_ENTRY_TYPE_FILE, 0); file_status_t *file_status = dvd_custom_status(); if (file_status == NULL || file_status->result != 0) { custom_OSReport("Failed to open file %s\n", boot_entry->second->path); diff --git a/patches/source/dolphin_dvd.c b/patches/source/dolphin_dvd.c index a27e43b..6b67030 100644 --- a/patches/source/dolphin_dvd.c +++ b/patches/source/dolphin_dvd.c @@ -87,7 +87,7 @@ dolphin_game_into_t get_game_info(char *game_path) { __attribute__((aligned(32))) static u32 small_buf[8]; // for BNR reads const uint8_t flags = IPC_FILE_FLAG_DISABLECACHE | IPC_FILE_FLAG_DISABLESPEEDEMU; - int ret = dvd_custom_open(game_path, FILE_TYPE_FLAG_FILE, flags); + int ret = dvd_custom_open(game_path, FILE_ENTRY_TYPE_FILE, flags); if (ret != 0) { OSReport("ERROR: Failed to open %s\n", game_path); return (dolphin_game_into_t) { .valid = false }; diff --git a/patches/source/flippy_sync.c b/patches/source/flippy_sync.c index e5dfe23..95733c1 100644 --- a/patches/source/flippy_sync.c +++ b/patches/source/flippy_sync.c @@ -265,7 +265,7 @@ int dvd_custom_open(const char *path, uint8_t type, uint8_t flags) { strncpy(entry.name, path, 256); entry.name[255] = 0; - entry.types = type; + entry.type = type; entry.flags = flags; DCFlushRange(&entry, sizeof(file_entry_t)); @@ -296,7 +296,7 @@ int dvd_custom_open_flash(const char *path, uint8_t type, uint8_t flags) { strncpy(entry.name, path, 256); entry.name[255] = 0; - entry.types = type; + entry.type = type; entry.flags = flags; DCFlushRange(&entry, sizeof(file_entry_t)); diff --git a/patches/source/games.c b/patches/source/games.c index 31a7519..adb63aa 100644 --- a/patches/source/games.c +++ b/patches/source/games.c @@ -489,7 +489,7 @@ gm_list_info gm_list_files(const char *target_dir) { OSReport("Listing files in %s\n", target_dir); u64 start_time = gettime(); - int res = dvd_custom_open(target_dir, FILE_TYPE_FLAG_DIR, 0); + int res = dvd_custom_open(target_dir, FILE_ENTRY_TYPE_DIR, 0); if (res != 0) { OSReport("PANIC: SD Card could not be opened\n"); while(1); @@ -515,12 +515,12 @@ gm_list_info gm_list_files(const char *target_dir) { int ret = dvd_custom_readdir(&ent, dir_fd); if (ret != 0) ipl_panic(); if (ent.name[0] == 0) break; // end of directory - if (ent.types & FILE_TYPE_FLAG_HIDDEN) continue; // skip hidden files + if (ent.attrib & FILE_ATTRIB_FLAG_HIDDEN) continue; // skip hidden files if (check_file_hidden(ent.name)) continue; // skip hidden files // only check file ext for now gm_file_type_t file_type = GM_FILE_TYPE_UNKNOWN; - if (ent.types & FILE_TYPE_FLAG_DIR) { + if (ent.type == FILE_ENTRY_TYPE_DIR) { file_type = GM_FILE_TYPE_DIRECTORY; } else { file_type = gm_get_file_type(ent.name); @@ -530,7 +530,7 @@ gm_list_info gm_list_files(const char *target_dir) { #ifdef PRINT_READDIR_NAMES // logging - OSReport("READDIR ent(%u): %s [len=%d]\n", ent.types, ent.name, strlen(ent.name)); + OSReport("READDIR ent(%u): %s [len=%d]\n", ent.type, ent.name, strlen(ent.name)); #endif // combine the path @@ -538,7 +538,7 @@ gm_list_info gm_list_files(const char *target_dir) { strcat(file_full_path_buf, ent.name); #ifdef PRINT_READDIR_NAMES // logging - OSReport("PATH ent(%u): %s\n", ent.types, file_full_path_buf); + OSReport("PATH ent(%u): %s\n", ent.type, file_full_path_buf); #endif // store the path @@ -579,7 +579,7 @@ static int gm_load_banner(gm_file_entry_t *entry, u32 aram_offset, bool force_un if (entry->extra.dvd_bnr_offset == 0) return false; // load the banner - dvd_custom_open(entry->path, FILE_TYPE_FLAG_FILE, IPC_FILE_FLAG_DISABLECACHE | IPC_FILE_FLAG_DISABLESPEEDEMU); + dvd_custom_open(entry->path, FILE_ENTRY_TYPE_FILE, IPC_FILE_FLAG_DISABLECACHE | IPC_FILE_FLAG_DISABLESPEEDEMU); file_status_t *status = dvd_custom_status(); if (status == NULL || status->result != 0) { OSReport("ERROR: could not open file\n"); @@ -622,7 +622,7 @@ static bool gm_load_icon(gm_file_entry_t *entry, u32 aram_offset, bool force_unl strcpy(ext, ".png"); // load the icon - dvd_custom_open(icon_path, FILE_TYPE_FLAG_FILE, IPC_FILE_FLAG_DISABLECACHE | IPC_FILE_FLAG_DISABLEFASTSEEK); + dvd_custom_open(icon_path, FILE_ENTRY_TYPE_FILE, IPC_FILE_FLAG_DISABLECACHE | IPC_FILE_FLAG_DISABLEFASTSEEK); file_status_t *status = dvd_custom_status(); if (status == NULL || status->result != 0) { // OSReport("ERROR: could not open icon file\n");