sd fs: Move sd init/mount/helpers to their own object

This commit is contained in:
CTCaer
2020-04-29 23:20:18 +03:00
parent 7d17e34dee
commit 034f680a8e
34 changed files with 339 additions and 299 deletions

View File

@@ -32,6 +32,7 @@
#include "../sec/se_t210.h"
#include "../storage/mbr_gpt.h"
#include "../storage/nx_emmc.h"
#include "../storage/nx_sd.h"
#include "../storage/sdmmc.h"
#include "../utils/btn.h"
#include "../utils/sprintf.h"
@@ -42,13 +43,8 @@
#define HASH_FILENAME_SZ (OUT_FILENAME_SZ + 11) // 11 == strlen(".sha256sums")
#define SHA256_SZ 0x20
extern sdmmc_t sd_sdmmc;
extern sdmmc_storage_t sd_storage;
extern FATFS sd_fs;
extern hekate_config h_cfg;
extern bool sd_mount();
extern void sd_unmount(bool deinit);
extern void emmcsn_path_impl(char *path, char *sub_dir, char *filename, sdmmc_storage_t *storage);
static void get_valid_partition(u32 *sector_start, u32 *sector_size, u32 *part_idx, bool backup)

View File

@@ -29,6 +29,7 @@
#include "../sec/se.h"
#include "../storage/mbr_gpt.h"
#include "../storage/nx_emmc.h"
#include "../storage/nx_sd.h"
#include "../storage/sdmmc.h"
#include "../utils/btn.h"
#include "../utils/sprintf.h"
@@ -37,16 +38,8 @@
#define NUM_SECTORS_PER_ITER 8192 // 4MB Cache.
#define OUT_FILENAME_SZ 128
#define MBR_1ST_PART_TYPE_OFF 0x1C2
extern sdmmc_t sd_sdmmc;
extern sdmmc_storage_t sd_storage;
extern FATFS sd_fs;
extern hekate_config h_cfg;
extern bool sd_mount();
extern void sd_unmount(bool deinit);
void load_emummc_cfg(emummc_cfg_t *emu_info)
{
memset(emu_info, 0, sizeof(emummc_cfg_t));

View File

@@ -39,6 +39,7 @@
#include "../soc/bpmp.h"
#include "../soc/hw_init.h"
#include "../soc/t210.h"
#include "../storage/nx_sd.h"
#include "../storage/sdmmc.h"
#include "../thermal/fan.h"
#include "../thermal/tmp451.h"
@@ -52,11 +53,6 @@ extern volatile nyx_storage_t *nyx_str;
extern volatile boot_cfg_t *b_cfg;
extern lv_res_t launch_payload(lv_obj_t *list);
extern bool get_sd_card_removed();
extern bool sd_mount();
extern void sd_unmount(bool deinit);
void *sd_file_read(const char *path, u32 *fsize);
int sd_save_to_file(void *buf, u32 size, const char *filename);
static bool disp_init_done = false;
static bool do_reload = false;
@@ -504,7 +500,7 @@ static void _check_sd_card_removed(void *params)
// The following checks if SDMMC_1 is initialized.
// If yes and card was removed, shows a message box,
// that will reload Nyx, when the card is inserted again.
if (!do_reload && get_sd_card_removed())
if (!do_reload && sd_get_card_removed())
{
lv_obj_t *dark_bg = lv_obj_create(lv_scr_act(), NULL);
lv_obj_set_style(dark_bg, &mbox_darken);
@@ -525,7 +521,7 @@ static void _check_sd_card_removed(void *params)
}
// If in reload state and card was inserted, reload nyx.
if (do_reload && !get_sd_card_removed())
if (do_reload && !sd_get_card_removed())
_reload_nyx();
}

View File

@@ -37,8 +37,6 @@
extern boot_cfg_t b_cfg;
extern hekate_config h_cfg;
extern bool sd_mount();
extern int sd_save_to_file(void *buf, u32 size, const char *filename);
extern void emmcsn_path_impl(char *path, char *sub_dir, char *filename, sdmmc_storage_t *storage);
typedef struct _emmc_backup_buttons_t

View File

@@ -22,17 +22,13 @@
#include "../libs/fatfs/ff.h"
#include "../mem/heap.h"
#include "../storage/mbr_gpt.h"
#include "../storage/nx_sd.h"
#include "../storage/sdmmc.h"
#include "../utils/dirlist.h"
#include "../utils/list.h"
#include "../utils/sprintf.h"
#include "../utils/types.h"
extern sdmmc_t sd_sdmmc;
extern sdmmc_storage_t sd_storage;
extern bool sd_mount();
extern void sd_unmount(bool deinit);
extern void emmcsn_path_impl(char *path, char *sub_dir, char *filename, sdmmc_storage_t *storage);
typedef struct _mbr_ctxt_t

View File

@@ -31,18 +31,13 @@
#include "../soc/t210.h"
#include "../storage/mmc.h"
#include "../storage/nx_emmc.h"
#include "../storage/nx_sd.h"
#include "../storage/sdmmc.h"
#include "../utils/sprintf.h"
#include "../utils/util.h"
#define SECTORS_TO_MIB_COEFF 11
extern sdmmc_storage_t sd_storage;
extern FATFS sd_fs;
extern bool sd_mount();
extern void sd_unmount(bool deinit);
extern int sd_save_to_file(void *buf, u32 size, const char *filename);
extern void emmcsn_path_impl(char *path, char *sub_dir, char *filename, sdmmc_storage_t *storage);
static lv_res_t _create_window_dump_done(int error, char *dump_filenames)

View File

@@ -19,14 +19,13 @@
#include "../config/ini.h"
#include "../gfx/di.h"
#include "../libs/lvgl/lvgl.h"
#include "../mem/heap.h"
#include "../storage/nx_sd.h"
#include "../utils/list.h"
#include "../utils/types.h"
extern hekate_config h_cfg;
extern bool sd_mount();
extern void sd_unmount(bool deinit);
static lv_obj_t *autoboot_btn;
static bool autoboot_first_time = true;

View File

@@ -29,6 +29,7 @@
#include "../sec/se.h"
#include "../soc/fuse.h"
#include "../storage/nx_emmc.h"
#include "../storage/nx_sd.h"
#include "../storage/sdmmc.h"
#include "../utils/sprintf.h"
#include "../utils/util.h"
@@ -36,9 +37,6 @@
extern volatile boot_cfg_t *b_cfg;
extern hekate_config h_cfg;
extern bool sd_mount();
extern void sd_unmount(bool deinit);
extern int sd_save_to_file(void *buf, u32 size, const char *filename);
extern void emmcsn_path_impl(char *path, char *sub_dir, char *filename, sdmmc_storage_t *storage);
bool get_autorcm_status(bool change)