diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2022-12-22 19:23:29 +0000 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2024-03-31 16:57:19 +0100 |
commit | 6ffd42548bf10cda13a01555ff4fa56d4213cdf2 (patch) | |
tree | 975d6a4f88a0a3469c1450476e841ef0bf8fbb85 /firmware/include/dircache_redirect.h | |
parent | af644e02a151bb6d4c229cc1d4846c7ffe952135 (diff) | |
download | rockbox-6ffd42548bf10cda13a01555ff4fa56d4213cdf2.tar.gz rockbox-6ffd42548bf10cda13a01555ff4fa56d4213cdf2.zip |
multiboot: Refactor boot data validation, add version numbers
Instead of verifying the CRC before every access of the boot data,
verify the CRC once at startup and set a flag to indicate the boot
data is valid.
Also add a framework to support multiple boot protocol versions.
Firmware declares the maximum supported protocol version using a
version byte in the boot data header. The bootloader chooses the
highest version supported by it and the firmware when deciding
what boot protocol to use.
Change-Id: I810194625dc0833f026d2a23b8d64ed467fa6aca
Diffstat (limited to 'firmware/include/dircache_redirect.h')
-rw-r--r-- | firmware/include/dircache_redirect.h | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/firmware/include/dircache_redirect.h b/firmware/include/dircache_redirect.h index f51ce70690..d4d72978c0 100644 --- a/firmware/include/dircache_redirect.h +++ b/firmware/include/dircache_redirect.h | |||
@@ -29,7 +29,6 @@ | |||
29 | #include "rb-loader.h" | 29 | #include "rb-loader.h" |
30 | #include "multiboot.h" | 30 | #include "multiboot.h" |
31 | #include "bootdata.h" | 31 | #include "bootdata.h" |
32 | #include "crc32.h" | ||
33 | #endif | 32 | #endif |
34 | 33 | ||
35 | #ifndef RB_ROOT_VOL_HIDDEN | 34 | #ifndef RB_ROOT_VOL_HIDDEN |
@@ -144,8 +143,7 @@ static inline void volume_onmount_internal(IF_MV_NONVOID(int volume)) | |||
144 | char rtpath[MAX_PATH / 2]; | 143 | char rtpath[MAX_PATH / 2]; |
145 | make_volume_root(volume, path); | 144 | make_volume_root(volume, path); |
146 | 145 | ||
147 | unsigned int crc = crc_32(boot_data.payload, boot_data.length, 0xffffffff); | 146 | if (boot_data_valid) |
148 | if (crc > 0 && crc == boot_data.crc) | ||
149 | { | 147 | { |
150 | /* we need to mount the drive before we can access it */ | 148 | /* we need to mount the drive before we can access it */ |
151 | root_mount_path(path, 0); /* root could be different folder don't hide */ | 149 | root_mount_path(path, 0); /* root could be different folder don't hide */ |
@@ -174,7 +172,7 @@ static inline void volume_onmount_internal(IF_MV_NONVOID(int volume)) | |||
174 | root_mount_path(rtpath, NSITEM_CONTENTS); | 172 | root_mount_path(rtpath, NSITEM_CONTENTS); |
175 | } | 173 | } |
176 | 174 | ||
177 | } /*CRC OK*/ | 175 | } |
178 | else | 176 | else |
179 | { | 177 | { |
180 | standard_redirect: | 178 | standard_redirect: |