mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-11-09 22:56:35 +00:00
Don't pass the mmc struct around
This commit is contained in:
parent
8c7492654c
commit
4265dc7b65
9 changed files with 18 additions and 35 deletions
|
@ -5,6 +5,7 @@
|
|||
#include "sd_utils.h"
|
||||
#include "stage2.h"
|
||||
#include "sdmmc.h"
|
||||
#include "lib/fatfs/ff.h"
|
||||
#include "lib/printk.h"
|
||||
#include "display/video_fb.h"
|
||||
|
||||
|
@ -115,7 +116,6 @@ int main(void) {
|
|||
args->lfb = (uint32_t *)lfb_base;
|
||||
args->console_col = video_get_col();
|
||||
args->console_row = video_get_row();
|
||||
save_sd_state(&args->sd_mmc);
|
||||
f_unmount("");
|
||||
|
||||
/* Jump to Stage 2. */
|
||||
|
|
|
@ -10,15 +10,6 @@ FATFS sd_fs;
|
|||
static int initialized_sd = 0;
|
||||
static int mounted_sd = 0;
|
||||
|
||||
void save_sd_state(void **mmc) {
|
||||
*mmc = &sd_mmc;
|
||||
}
|
||||
|
||||
void resume_sd_state(void *mmc) {
|
||||
sd_mmc = *(struct mmc *)mmc;
|
||||
initialized_sd = 1;
|
||||
}
|
||||
|
||||
int initialize_sd(void) {
|
||||
if (initialized_sd) {
|
||||
return 1;
|
||||
|
|
|
@ -3,11 +3,8 @@
|
|||
|
||||
#include "utils.h"
|
||||
#include "sdmmc.h"
|
||||
#include "lib/fatfs/ff.h"
|
||||
|
||||
void save_sd_state(void **mmc);
|
||||
void resume_sd_state(void *mmc);
|
||||
|
||||
int initialize_sd(void);
|
||||
size_t read_sd_file(void *dst, size_t dst_size, const char *filename);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -26,7 +26,6 @@ typedef struct {
|
|||
uint32_t *lfb;
|
||||
uint32_t console_row;
|
||||
uint32_t console_col;
|
||||
void *sd_mmc;
|
||||
} stage2_args_t;
|
||||
|
||||
const char *stage2_get_program_path(void);
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include "utils.h"
|
||||
#include "hwinit.h"
|
||||
#include "loader.h"
|
||||
|
@ -34,8 +36,10 @@ int main(int argc, void **argv) {
|
|||
/* Setup console/stdout. */
|
||||
console_resume(args.lfb, args.console_row, args.console_col);
|
||||
|
||||
resume_sd_state((struct mmc *)args.sd_mmc);
|
||||
fsdev_mount_all();
|
||||
initialize_sd();
|
||||
if(fsdev_mount_all() == -1) {
|
||||
perror("Failed to mount at least one FAT parition");
|
||||
}
|
||||
fsdev_set_default_device("sdmc");
|
||||
|
||||
/* Copy the BCT0 from unsafe primary memory into our memory. */
|
||||
|
|
|
@ -7,14 +7,6 @@
|
|||
struct mmc sd_mmc;
|
||||
static int initialized_sd = 0;
|
||||
|
||||
void save_sd_state(void **mmc) {
|
||||
*mmc = &sd_mmc;
|
||||
}
|
||||
void resume_sd_state(void *mmc) {
|
||||
sd_mmc = *(struct mmc *)mmc;
|
||||
initialized_sd = 1;
|
||||
}
|
||||
|
||||
int initialize_sd(void) {
|
||||
if (initialized_sd) {
|
||||
return 1;
|
||||
|
@ -23,6 +15,9 @@ int initialize_sd(void) {
|
|||
if (sdmmc_init(&sd_mmc, SWITCH_MICROSD) == 0) {
|
||||
printf("Initialized SD card!\n");
|
||||
initialized_sd = 1;
|
||||
} else {
|
||||
printf("Failed to initialize the SD card!\n");
|
||||
return 0;
|
||||
}
|
||||
return initialized_sd;
|
||||
}
|
||||
|
|
|
@ -4,9 +4,7 @@
|
|||
#include "utils.h"
|
||||
#include "sdmmc.h"
|
||||
|
||||
void save_sd_state(void **mmc);
|
||||
void resume_sd_state(void *mmc);
|
||||
|
||||
int initialize_sd(void);
|
||||
size_t read_sd_file(void *dst, size_t dst_size, const char *filename);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -14,7 +14,6 @@ typedef struct {
|
|||
uint32_t *lfb;
|
||||
uint32_t console_row;
|
||||
uint32_t console_col;
|
||||
void *sd_mmc;
|
||||
} stage2_args_t;
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue