diff options
author | William Wilgus <wilgus.william@gmail.com> | 2020-08-20 19:19:55 -0400 |
---|---|---|
committer | William Wilgus <wilgus.william@gmail.com> | 2020-08-20 19:19:55 -0400 |
commit | bd744059cf959c8b9086978b32660efef5925b7d (patch) | |
tree | c445741c74a6312b5b8a2c64452ac48e20b182eb | |
parent | 5ef28cccf92f5eada6d502fa4b0e16a13e94be5b (diff) | |
download | rockbox-bd744059cf959c8b9086978b32660efef5925b7d.tar.gz rockbox-bd744059cf959c8b9086978b32660efef5925b7d.zip |
Multiboot Firmware Root Redirect
Firmware now includes rudimentary redirect functionality
but this only supports /.rockbox in the root of the device
This patch allows loading external drive and directory into root namespace
Root Redirects can now be put into different folders
For instance placing '/_test' into SD1/rockbox_main.<playername>
will redirect to /<1>/_test/.rockbox
Debug menu>Bootdata now has root directory listed in addition to RAW Bootdata
Redirect root work from Michael Sevakis g#1556
Redirect will be updated if code refactor is ever done
Requires Multiboot bootloader (already in main)
Change-Id: I697b3d0499f85e789c3020bc2133fbe0023f72a2
-rw-r--r-- | apps/debug_menu.c | 22 | ||||
-rw-r--r-- | firmware/common/disk.c | 18 | ||||
-rw-r--r-- | firmware/include/dircache_redirect.h | 42 |
3 files changed, 78 insertions, 4 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index b93fb45c8f..eae389d049 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c | |||
@@ -2451,10 +2451,26 @@ static bool dbg_boot_data(void) | |||
2451 | info.scroll_all = true; | 2451 | info.scroll_all = true; |
2452 | simplelist_info_init(&info, "Boot data", 1, NULL); | 2452 | simplelist_info_init(&info, "Boot data", 1, NULL); |
2453 | simplelist_set_line_count(0); | 2453 | simplelist_set_line_count(0); |
2454 | simplelist_addline("Magic: %.8s", boot_data.magic); | 2454 | crc = crc_32(boot_data.payload, boot_data.length, 0xffffffff); |
2455 | #if defined(HAVE_MULTIBOOT) | ||
2456 | char rootpath[VOL_MAX_LEN+2] = RB_ROOT_CONTENTS_DIR; | ||
2457 | int boot_volume = 0; | ||
2458 | if(crc == boot_data.crc) | ||
2459 | { | ||
2460 | boot_volume = boot_data.boot_volume; /* boot volume contained in uint8_t payload */ | ||
2461 | get_redirect_dir(rootpath, sizeof(rootpath), boot_volume, "", ""); | ||
2462 | rootpath[path_strip_trailing_separators(rootpath,NULL)] = '\0'; | ||
2463 | } | ||
2464 | simplelist_addline("Boot Volume: <%lu>", boot_volume); | ||
2465 | simplelist_addline("Root:"); | ||
2466 | simplelist_addline("%s", rootpath); | ||
2467 | simplelist_addline(""); | ||
2468 | #endif | ||
2469 | simplelist_addline("Bootdata RAW:"); | ||
2470 | if (crc != boot_data.crc) | ||
2471 | simplelist_addline("Magic: %.8s", boot_data.magic); | ||
2455 | simplelist_addline("Length: %lu", boot_data.length); | 2472 | simplelist_addline("Length: %lu", boot_data.length); |
2456 | simplelist_addline("CRC: %lx", boot_data.crc); | 2473 | simplelist_addline("CRC: %lx", boot_data.crc); |
2457 | crc = crc_32(boot_data.payload, boot_data.length, 0xffffffff); | ||
2458 | (crc == boot_data.crc) ? simplelist_addline("CRC: OK!") : | 2474 | (crc == boot_data.crc) ? simplelist_addline("CRC: OK!") : |
2459 | simplelist_addline("CRC: BAD"); | 2475 | simplelist_addline("CRC: BAD"); |
2460 | for (unsigned i = 0; i < boot_data.length; i += 4) | 2476 | for (unsigned i = 0; i < boot_data.length; i += 4) |
@@ -2466,7 +2482,7 @@ static bool dbg_boot_data(void) | |||
2466 | info.hide_selection = true; | 2482 | info.hide_selection = true; |
2467 | return simplelist_show_list(&info); | 2483 | return simplelist_show_list(&info); |
2468 | } | 2484 | } |
2469 | #endif | 2485 | #endif /* defined(HAVE_BOOTDATA) && !defined(SIMULATOR) */ |
2470 | 2486 | ||
2471 | /****** The menu *********/ | 2487 | /****** The menu *********/ |
2472 | static const struct { | 2488 | static const struct { |
diff --git a/firmware/common/disk.c b/firmware/common/disk.c index 3bd88f66a8..49137286a3 100644 --- a/firmware/common/disk.c +++ b/firmware/common/disk.c | |||
@@ -27,7 +27,7 @@ | |||
27 | #include "disk_cache.h" | 27 | #include "disk_cache.h" |
28 | #include "fileobj_mgr.h" | 28 | #include "fileobj_mgr.h" |
29 | #include "dir.h" | 29 | #include "dir.h" |
30 | #include "rb_namespace.h" | 30 | #include "dircache_redirect.h" |
31 | #include "disk.h" | 31 | #include "disk.h" |
32 | 32 | ||
33 | 33 | ||
@@ -249,7 +249,23 @@ int disk_mount_all(void) | |||
249 | for (int i = 0; i < NUM_VOLUMES; i++) | 249 | for (int i = 0; i < NUM_VOLUMES; i++) |
250 | vol_drive[i] = -1; /* mark all as unassigned */ | 250 | vol_drive[i] = -1; /* mark all as unassigned */ |
251 | 251 | ||
252 | #if defined(HAVE_BOOTDATA) && !defined(SIMULATOR) && !defined(BOOTLOADER) | ||
253 | unsigned int crc = 0; | ||
254 | int boot_volume = 0; | ||
255 | crc = crc_32(boot_data.payload, boot_data.length, 0xffffffff); | ||
256 | if(crc == boot_data.crc) | ||
257 | { | ||
258 | boot_volume = boot_data.boot_volume; /* boot volume contained in uint8_t payload */ | ||
259 | } | ||
260 | #ifdef HAVE_HOTSWAP | ||
261 | if (storage_present(boot_volume)) | ||
262 | #endif | ||
263 | mounted += disk_mount(boot_volume); /* mount boot volume first */ | ||
264 | for (int i = 0; i < NUM_DRIVES; i++) | ||
265 | if (i != boot_volume) | ||
266 | #else | ||
252 | for (int i = 0; i < NUM_DRIVES; i++) | 267 | for (int i = 0; i < NUM_DRIVES; i++) |
268 | #endif | ||
253 | { | 269 | { |
254 | #ifdef HAVE_HOTSWAP | 270 | #ifdef HAVE_HOTSWAP |
255 | if (storage_present(i)) | 271 | if (storage_present(i)) |
diff --git a/firmware/include/dircache_redirect.h b/firmware/include/dircache_redirect.h index 9a8de2fecd..e8cf8dc8f5 100644 --- a/firmware/include/dircache_redirect.h +++ b/firmware/include/dircache_redirect.h | |||
@@ -25,6 +25,12 @@ | |||
25 | #include "dir.h" | 25 | #include "dir.h" |
26 | #include "dircache.h" | 26 | #include "dircache.h" |
27 | 27 | ||
28 | #if defined(HAVE_MULTIBOOT) && !defined(SIMULATOR) | ||
29 | #include "rb-loader.h" | ||
30 | #include "bootdata.h" | ||
31 | #include "crc32.h" | ||
32 | #endif | ||
33 | |||
28 | /*** | 34 | /*** |
29 | ** Internal redirects that depend upon whether or not dircache is made | 35 | ** Internal redirects that depend upon whether or not dircache is made |
30 | ** | 36 | ** |
@@ -132,11 +138,47 @@ static inline void volume_onmount_internal(IF_MV_NONVOID(int volume)) | |||
132 | #else | 138 | #else |
133 | const char *path = PATH_ROOTSTR; | 139 | const char *path = PATH_ROOTSTR; |
134 | #endif | 140 | #endif |
141 | |||
142 | #if defined(HAVE_MULTIBOOT) && !defined(SIMULATOR) | ||
143 | static char rtpath[VOL_MAX_LEN+2] = RB_ROOT_CONTENTS_DIR; | ||
144 | static bool redirected = false; | ||
145 | int boot_volume = 0; | ||
146 | unsigned int crc = 0; | ||
147 | |||
148 | crc = crc_32(boot_data.payload, boot_data.length, 0xffffffff); | ||
149 | if (crc == boot_data.crc) | ||
150 | { | ||
151 | root_mount_path(path, 0); /*root could be different folder don't hide*/ | ||
152 | boot_volume = boot_data.boot_volume; /* boot volume contained in uint8_t payload */ | ||
153 | //root_mount_path(path, volume == boot_volume ? NSITEM_HIDDEN : 0); | ||
154 | if (!redirected && volume == boot_volume) | ||
155 | { | ||
156 | if (get_redirect_dir(rtpath, sizeof(rtpath), volume, "", "") < 0) | ||
157 | { /* Error occurred, card removed? Set root to default */ | ||
158 | root_mount_path(RB_ROOT_CONTENTS_DIR, NSITEM_CONTENTS); | ||
159 | } | ||
160 | else | ||
161 | redirected = true; | ||
162 | } | ||
163 | if (redirected && volume == boot_volume) | ||
164 | root_mount_path(rtpath, NSITEM_CONTENTS); | ||
165 | } /*CRC OK*/ | ||
166 | else | ||
167 | { | ||
168 | root_mount_path(path, RB_ROOT_VOL_HIDDEN(volume) ? NSITEM_HIDDEN : 0); | ||
169 | if (volume == path_strip_volume(RB_ROOT_CONTENTS_DIR, NULL, false)) | ||
170 | root_mount_path(RB_ROOT_CONTENTS_DIR, NSITEM_CONTENTS); | ||
171 | } | ||
172 | #else | ||
173 | |||
135 | root_mount_path(path, RB_ROOT_VOL_HIDDEN(volume) ? NSITEM_HIDDEN : 0); | 174 | root_mount_path(path, RB_ROOT_VOL_HIDDEN(volume) ? NSITEM_HIDDEN : 0); |
136 | #ifdef HAVE_MULTIVOLUME | 175 | #ifdef HAVE_MULTIVOLUME |
137 | if (volume == path_strip_volume(RB_ROOT_CONTENTS_DIR, NULL, false)) | 176 | if (volume == path_strip_volume(RB_ROOT_CONTENTS_DIR, NULL, false)) |
138 | #endif | 177 | #endif |
139 | root_mount_path(RB_ROOT_CONTENTS_DIR, NSITEM_CONTENTS); | 178 | root_mount_path(RB_ROOT_CONTENTS_DIR, NSITEM_CONTENTS); |
179 | |||
180 | #endif /* HAVE_MULTIBOOT */ | ||
181 | |||
140 | #ifdef HAVE_DIRCACHE | 182 | #ifdef HAVE_DIRCACHE |
141 | dircache_mount(); | 183 | dircache_mount(); |
142 | #endif | 184 | #endif |