From ea609e68d3341316ee896ae246dab988c8d51c39 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Thu, 26 Apr 2018 04:47:22 -0600 Subject: [PATCH] Change read_sd_file semantics to return size read. --- fusee/fusee-primary/src/sd_utils.c | 2 +- fusee/fusee-primary/src/sd_utils.h | 2 +- fusee/fusee-secondary/src/loader.c | 4 +++- fusee/fusee-secondary/src/loader.h | 1 + fusee/fusee-secondary/src/sd_utils.c | 2 +- fusee/fusee-secondary/src/sd_utils.h | 2 +- 6 files changed, 8 insertions(+), 5 deletions(-) diff --git a/fusee/fusee-primary/src/sd_utils.c b/fusee/fusee-primary/src/sd_utils.c index a2f8bae9f..b66ff84d8 100644 --- a/fusee/fusee-primary/src/sd_utils.c +++ b/fusee/fusee-primary/src/sd_utils.c @@ -1,6 +1,6 @@ #include "sd_utils.h" -int read_sd_file(void *dst, size_t dst_size, const char *filename) { +size_t read_sd_file(void *dst, size_t dst_size, const char *filename) { /* TODO: Implement this function. */ (void)(dst); (void)(dst_size); diff --git a/fusee/fusee-primary/src/sd_utils.h b/fusee/fusee-primary/src/sd_utils.h index f1f23da7f..d9774b9d1 100644 --- a/fusee/fusee-primary/src/sd_utils.h +++ b/fusee/fusee-primary/src/sd_utils.h @@ -3,6 +3,6 @@ #include "utils.h" -int read_sd_file(void *dst, size_t dst_size, const char *filename); +size_t read_sd_file(void *dst, size_t dst_size, const char *filename); #endif \ No newline at end of file diff --git a/fusee/fusee-secondary/src/loader.c b/fusee/fusee-secondary/src/loader.c index d58788ff3..0c72411e4 100644 --- a/fusee/fusee-secondary/src/loader.c +++ b/fusee/fusee-secondary/src/loader.c @@ -71,7 +71,9 @@ void load_list_entry(const char *key) { generic_panic(); } - if (!read_sd_file((void *)load_file_ctx.load_address, LOADER_FILESIZE_MAX, load_file_ctx.path)) { + /* Read file off of SD. */ + load_file_ctx.load_size = read_sd_file((void *)load_file_ctx.load_address, LOADER_FILESIZE_MAX, load_file_ctx.path); + if (load_file_ctx.load_size == 0) { printk("Error: Failed to read %s!\n", load_file_ctx.path); generic_panic(); } diff --git a/fusee/fusee-secondary/src/loader.h b/fusee/fusee-secondary/src/loader.h index 2bc67e455..7e7a48cfa 100644 --- a/fusee/fusee-secondary/src/loader.h +++ b/fusee/fusee-secondary/src/loader.h @@ -9,6 +9,7 @@ typedef struct { char path[0x300]; const char *key; uintptr_t load_address; + size_t load_size; } load_file_t; typedef struct { diff --git a/fusee/fusee-secondary/src/sd_utils.c b/fusee/fusee-secondary/src/sd_utils.c index a2f8bae9f..b66ff84d8 100644 --- a/fusee/fusee-secondary/src/sd_utils.c +++ b/fusee/fusee-secondary/src/sd_utils.c @@ -1,6 +1,6 @@ #include "sd_utils.h" -int read_sd_file(void *dst, size_t dst_size, const char *filename) { +size_t read_sd_file(void *dst, size_t dst_size, const char *filename) { /* TODO: Implement this function. */ (void)(dst); (void)(dst_size); diff --git a/fusee/fusee-secondary/src/sd_utils.h b/fusee/fusee-secondary/src/sd_utils.h index f1f23da7f..d9774b9d1 100644 --- a/fusee/fusee-secondary/src/sd_utils.h +++ b/fusee/fusee-secondary/src/sd_utils.h @@ -3,6 +3,6 @@ #include "utils.h" -int read_sd_file(void *dst, size_t dst_size, const char *filename); +size_t read_sd_file(void *dst, size_t dst_size, const char *filename); #endif \ No newline at end of file