summaryrefslogtreecommitdiff
path: root/firmware/common
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/common')
-rw-r--r--firmware/common/bootdata.c15
-rw-r--r--firmware/common/multiboot.c15
2 files changed, 29 insertions, 1 deletions
diff --git a/firmware/common/bootdata.c b/firmware/common/bootdata.c
index fa74c5fe91..224a48d0c1 100644
--- a/firmware/common/bootdata.c
+++ b/firmware/common/bootdata.c
@@ -42,6 +42,20 @@ static bool verify_boot_data_v0(void)
42 return true; 42 return true;
43} 43}
44 44
45static bool verify_boot_data_v1(void) INIT_ATTR;
46static bool verify_boot_data_v1(void)
47{
48 /* validate protocol version */
49 if (boot_data.version != 1)
50 return false;
51
52 /* validate length */
53 if (boot_data.length != 4)
54 return false;
55
56 return true;
57}
58
45struct verify_bd_entry 59struct verify_bd_entry
46{ 60{
47 int version; 61 int version;
@@ -50,6 +64,7 @@ struct verify_bd_entry
50 64
51static const struct verify_bd_entry verify_bd[] INITDATA_ATTR = { 65static const struct verify_bd_entry verify_bd[] INITDATA_ATTR = {
52 { 0, verify_boot_data_v0 }, 66 { 0, verify_boot_data_v0 },
67 { 1, verify_boot_data_v1 },
53}; 68};
54 69
55void verify_boot_data(void) 70void verify_boot_data(void)
diff --git a/firmware/common/multiboot.c b/firmware/common/multiboot.c
index c292aa1c30..8d6573d2dd 100644
--- a/firmware/common/multiboot.c
+++ b/firmware/common/multiboot.c
@@ -23,6 +23,7 @@
23#include "crc32.h" 23#include "crc32.h"
24#include "loader_strerror.h" 24#include "loader_strerror.h"
25#include "file.h" 25#include "file.h"
26#include "disk.h"
26#include <string.h> 27#include <string.h>
27#include <stdio.h> 28#include <stdio.h>
28 29
@@ -30,10 +31,20 @@ static void write_bootdata_v0(struct boot_data_t *data, unsigned int boot_volume
30{ 31{
31 memset(data->payload, data->length, 0); 32 memset(data->payload, data->length, 0);
32 33
33 data->boot_volume = boot_volume; 34 data->_boot_volume = boot_volume;
34 data->version = 0; 35 data->version = 0;
35} 36}
36 37
38static void write_bootdata_v1(struct boot_data_t *data, unsigned int boot_volume)
39{
40 memset(data->payload, data->length, 0);
41
42 data->_boot_volume = 0xff;
43 data->version = 1;
44 data->boot_drive = volume_drive(boot_volume);
45 data->boot_partition = volume_partition(boot_volume);
46}
47
37/* Write bootdata into location in FIRMWARE marked by magic header 48/* Write bootdata into location in FIRMWARE marked by magic header
38 * Assumes buffer is already loaded with the firmware image 49 * Assumes buffer is already loaded with the firmware image
39 * We just need to find the location and write data into the 50 * We just need to find the location and write data into the
@@ -68,6 +79,8 @@ bool write_bootdata(unsigned char* buf, int len, unsigned int boot_volume)
68 /* Write boot data according to the selected protocol */ 79 /* Write boot data according to the selected protocol */
69 if (proto_version == 0) 80 if (proto_version == 0)
70 write_bootdata_v0(data, boot_volume); 81 write_bootdata_v0(data, boot_volume);
82 else if (proto_version == 1)
83 write_bootdata_v1(data, boot_volume);
71 else 84 else
72 break; 85 break;
73 86