summaryrefslogtreecommitdiff
path: root/firmware/common
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/common')
-rw-r--r--firmware/common/devicedata.c88
-rw-r--r--firmware/common/disk.c118
-rw-r--r--firmware/common/disk_cache.c8
-rw-r--r--firmware/common/pathfuncs.c66
-rw-r--r--firmware/common/rb-loader.c8
5 files changed, 243 insertions, 45 deletions
diff --git a/firmware/common/devicedata.c b/firmware/common/devicedata.c
new file mode 100644
index 0000000000..75fe79d7fa
--- /dev/null
+++ b/firmware/common/devicedata.c
@@ -0,0 +1,88 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2024 by William Wilgus
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
15 *
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
18 *
19 ****************************************************************************/
20
21#include "devicedata.h"
22#include "crc32.h"
23#include <stddef.h>
24#include <string.h>
25#include "debug.h"
26
27#ifndef BOOTLOADER
28void verify_device_data(void) INIT_ATTR;
29void verify_device_data(void)
30{
31 DEBUGF("%s", __func__);
32 /* verify payload with checksum */
33 uint32_t crc = crc_32(device_data.payload, device_data.length, 0xffffffff);
34 if (crc == device_data.crc)
35 return; /* return if data is valid */
36
37 /* Write the default if data is invalid */
38 memset(device_data.payload, 0xff, DEVICE_DATA_PAYLOAD_SIZE); /* Invalid data */
39 device_data.length = DEVICE_DATA_PAYLOAD_SIZE;
40 device_data.crc = crc_32(device_data.payload, device_data.length, 0xffffffff);
41
42}
43
44/******************************************************************************/
45#endif /* ndef BOOTLOADER ******************************************************/
46/******************************************************************************/
47
48#if defined(HAVE_DEVICEDATA)
49void __attribute__((weak)) fill_devicedata(struct device_data_t *data)
50{
51 memset(data->payload, 0xff, data->length);
52}
53#endif
54
55/* Write bootdata into location in FIRMWARE marked by magic header
56 * Assumes buffer is already loaded with the firmware image
57 * We just need to find the location and write data into the
58 * payload region along with the crc for later verification and use.
59 * Returns payload len on success,
60 * On error returns false
61 */
62bool write_devicedata(unsigned char* buf, int len)
63{
64 int search_len = MIN(len, DEVICE_DATA_SEARCH_SIZE) - sizeof(struct device_data_t);
65
66 /* search for decvice data header prior to search_len */
67 for(int i = 0; i < search_len; i++)
68 {
69 struct device_data_t *data = (struct device_data_t *)&buf[i];
70 if (data->magic[0] != DEVICE_DATA_MAGIC0 ||
71 data->magic[1] != DEVICE_DATA_MAGIC1)
72 continue;
73
74 /* Ignore it if the length extends past the end of the buffer. */
75 int data_len = offsetof(struct device_data_t, payload) + data->length;
76 if (i + data_len > len)
77 continue;
78
79 fill_devicedata(data);
80
81 /* Calculate payload CRC */
82 data->crc = crc_32(data->payload, data->length, 0xffffffff);
83 return true;
84 }
85
86 return false;
87}
88
diff --git a/firmware/common/disk.c b/firmware/common/disk.c
index 9b6454c9a2..958f09755a 100644
--- a/firmware/common/disk.c
+++ b/firmware/common/disk.c
@@ -29,6 +29,7 @@
29#include "dir.h" 29#include "dir.h"
30#include "rb_namespace.h" 30#include "rb_namespace.h"
31#include "disk.h" 31#include "disk.h"
32#include "panic.h"
32 33
33#if defined(HAVE_BOOTDATA) && !defined(SIMULATOR) && !defined(BOOTLOADER) 34#if defined(HAVE_BOOTDATA) && !defined(SIMULATOR) && !defined(BOOTLOADER)
34#include "bootdata.h" 35#include "bootdata.h"
@@ -110,7 +111,7 @@ static void init_volume(struct volumeinfo *vi, int drive, int part)
110} 111}
111 112
112#ifdef MAX_LOG_SECTOR_SIZE 113#ifdef MAX_LOG_SECTOR_SIZE
113static int disk_sector_multiplier[NUM_DRIVES] = 114static uint16_t disk_sector_multiplier[NUM_DRIVES] =
114 { [0 ... NUM_DRIVES-1] = 1 }; 115 { [0 ... NUM_DRIVES-1] = 1 };
115 116
116int disk_get_sector_multiplier(IF_MD_NONVOID(int drive)) 117int disk_get_sector_multiplier(IF_MD_NONVOID(int drive))
@@ -125,6 +126,33 @@ int disk_get_sector_multiplier(IF_MD_NONVOID(int drive))
125} 126}
126#endif /* MAX_LOG_SECTOR_SIZE */ 127#endif /* MAX_LOG_SECTOR_SIZE */
127 128
129#if (CONFIG_STORAGE & STORAGE_ATA) // XXX make this more generic?
130static uint16_t disk_log_sector_size[NUM_DRIVES] =
131 { [0 ... NUM_DRIVES-1] = SECTOR_SIZE }; /* Updated from STORAGE_INFO */
132int disk_get_log_sector_size(IF_MD_NONVOID(int drive))
133{
134 if (!CHECK_DRV(drive))
135 return 0;
136
137 disk_reader_lock();
138 int size = disk_log_sector_size[IF_MD_DRV(drive)];
139 disk_reader_unlock();
140 return size;
141}
142#ifdef HAVE_MULTIDRIVE
143#define LOG_SECTOR_SIZE(__drive) disk_log_sector_size[__drive]
144#else
145#define LOG_SECTOR_SIZE(__drive) disk_log_sector_size[0]
146#endif /* HAVE_MULTIDRIVE */
147#else /* !STORAGE_ATA */
148#define LOG_SECTOR_SIZE(__drive) SECTOR_SIZE
149int disk_get_log_sector_size(IF_MD_NONVOID(int drive))
150{
151 IF_MD((void)drive);
152 return SECTOR_SIZE;
153}
154#endif /* !CONFIG_STORAGE & STORAGE_ATA */
155
128bool disk_init(IF_MD_NONVOID(int drive)) 156bool disk_init(IF_MD_NONVOID(int drive))
129{ 157{
130 if (!CHECK_DRV(drive)) 158 if (!CHECK_DRV(drive))
@@ -134,7 +162,30 @@ bool disk_init(IF_MD_NONVOID(int drive))
134 if (!sector) 162 if (!sector)
135 return false; 163 return false;
136 164
137 memset(sector, 0, SECTOR_SIZE); 165#if (CONFIG_STORAGE & STORAGE_ATA)
166 /* Query logical sector size */
167 struct storage_info *info = (struct storage_info*) sector;
168 storage_get_info(IF_MD_DRV(drive), info);
169 disk_writer_lock();
170#ifdef MAX_LOG_SECTOR_SIZE
171 disk_log_sector_size[IF_MD_DRV(drive)] = info->sector_size;
172#endif
173 disk_writer_unlock();
174
175#ifdef MAX_LOG_SECTOR_SIZE
176 if (info->sector_size > MAX_LOG_SECTOR_SIZE) {
177 panicf("Unsupported logical sector size: %d",
178 info->sector_size);
179 }
180#else
181 if (info->sector_size != SECTOR_SIZE) {
182 panicf("Unsupported logical sector size: %d",
183 info->sector_size);
184 }
185#endif
186#endif /* CONFIG_STORAGE & STORAGE_ATA */
187
188 memset(sector, 0, LOG_SECTOR_SIZE(drive));
138 storage_read_sectors(IF_MD(drive,) 0, 1, sector); 189 storage_read_sectors(IF_MD(drive,) 0, 1, sector);
139 190
140 bool init = false; 191 bool init = false;
@@ -172,6 +223,8 @@ bool disk_init(IF_MD_NONVOID(int drive))
172 } 223 }
173 } 224 }
174 225
226 // XXX backup GPT header at final LBA of drive...
227
175 while (is_gpt) { 228 while (is_gpt) {
176 /* Re-start partition parsing using GPT */ 229 /* Re-start partition parsing using GPT */
177 uint64_t part_lba; 230 uint64_t part_lba;
@@ -211,11 +264,11 @@ bool disk_init(IF_MD_NONVOID(int drive))
211reload: 264reload:
212 storage_read_sectors(IF_MD(drive,) part_lba, 1, sector); 265 storage_read_sectors(IF_MD(drive,) part_lba, 1, sector);
213 uint8_t *pptr = ptr; 266 uint8_t *pptr = ptr;
214 while (part < MAX_PARTITIONS_PER_DRIVE && part_entries) { 267 while (part < MAX_PARTITIONS_PER_DRIVE && part_entries) {
215 if (pptr - ptr >= SECTOR_SIZE) { 268 if (pptr - ptr >= LOG_SECTOR_SIZE(drive)) {
216 part_lba++; 269 part_lba++;
217 goto reload; 270 goto reload;
218 } 271 }
219 272
220 /* Parse GPT entry. We only care about the "General Data" type, ie: 273 /* Parse GPT entry. We only care about the "General Data" type, ie:
221 EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 274 EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
@@ -243,20 +296,24 @@ reload:
243 goto skip; /* Any flag makes us ignore this */ 296 goto skip; /* Any flag makes us ignore this */
244 } 297 }
245 tmp = BYTES2INT64(pptr, 32); /* FIRST LBA */ 298 tmp = BYTES2INT64(pptr, 32); /* FIRST LBA */
246 if (tmp > UINT32_MAX) { // XXX revisit when we resize struct partinfo! 299#ifndef STORAGE_64BIT_SECTOR
247 DEBUGF("GPT: partition starts after 2GiB mark\n"); 300 if (tmp > UINT32_MAX) {
301 DEBUGF("GPT: partition starts after 2TiB mark\n");
248 goto skip; 302 goto skip;
249 } 303 }
304#endif
250 if (tmp < 34) { 305 if (tmp < 34) {
251 DEBUGF("GPT: Invalid start LBA\n"); 306 DEBUGF("GPT: Invalid start LBA\n");
252 goto skip; 307 goto skip;
253 } 308 }
254 pinfo[part].start = tmp; 309 pinfo[part].start = tmp;
255 tmp = BYTES2INT64(pptr, 40); /* LAST LBA */ 310 tmp = BYTES2INT64(pptr, 40); /* LAST LBA */
256 if (tmp > UINT32_MAX) { // XXX revisit when we resize struct partinfo! 311#ifndef STORAGE_64BIT_SECTOR
257 DEBUGF("GPT: partition ends after 2GiB mark\n"); 312 if (tmp > UINT32_MAX) {
313 DEBUGF("GPT: partition ends after 2TiB mark\n");
258 goto skip; 314 goto skip;
259 } 315 }
316#endif
260 if (tmp <= pinfo[part].start) { 317 if (tmp <= pinfo[part].start) {
261 DEBUGF("GPT: Invalid end LBA\n"); 318 DEBUGF("GPT: Invalid end LBA\n");
262 goto skip; 319 goto skip;
@@ -264,7 +321,7 @@ reload:
264 pinfo[part].size = tmp - pinfo[part].start + 1; 321 pinfo[part].size = tmp - pinfo[part].start + 1;
265 pinfo[part].type = PARTITION_TYPE_FAT32_LBA; 322 pinfo[part].type = PARTITION_TYPE_FAT32_LBA;
266 323
267 DEBUGF("GPart%d: start: %08lx size: %08lx\n", 324 DEBUGF("GPart%d: start: %016lx size: %016lx\n",
268 part,pinfo[part].start,pinfo[part].size); 325 part,pinfo[part].start,pinfo[part].size);
269 part++; 326 part++;
270 327
@@ -325,19 +382,18 @@ int disk_mount(int drive)
325 disk_sector_multiplier[IF_MD_DRV(drive)] = 1; 382 disk_sector_multiplier[IF_MD_DRV(drive)] = 1;
326#endif 383#endif
327 384
328 /* try "superfloppy" mode */ 385 /* try "superfloppy" mode */
329 DEBUGF("Trying to mount sector 0.\n"); 386 DEBUGF("Trying to mount sector 0.\n");
330 387
331 if (!fat_mount(IF_MV(volume,) IF_MD(drive,) 0)) 388 if (!fat_mount(IF_MV(volume,) IF_MD(drive,) 0))
332 { 389 {
333 #ifdef MAX_LOG_SECTOR_SIZE 390#ifdef MAX_LOG_SECTOR_SIZE
334 disk_sector_multiplier[drive] = 391 disk_sector_multiplier[drive] = fat_get_bytes_per_sector(IF_MV(volume)) / LOG_SECTOR_SIZE(drive);
335 fat_get_bytes_per_sector(IF_MV(volume)) / SECTOR_SIZE; 392#endif
336 #endif 393 mounted = 1;
337 mounted = 1; 394 init_volume(&volumes[volume], drive, 0);
338 init_volume(&volumes[volume], drive, 0); 395 volume_onmount_internal(IF_MV(volume));
339 volume_onmount_internal(IF_MV(volume)); 396 }
340 }
341 397
342 if (mounted == 0 && volume != -1) /* not a "superfloppy"? */ 398 if (mounted == 0 && volume != -1) /* not a "superfloppy"? */
343 { 399 {
@@ -348,10 +404,10 @@ int disk_mount(int drive)
348 if (pinfo[i].type == 0 || pinfo[i].type == 5) 404 if (pinfo[i].type == 0 || pinfo[i].type == 5)
349 continue; /* skip free/extended partitions */ 405 continue; /* skip free/extended partitions */
350 406
351 DEBUGF("Trying to mount partition %d.\n", i); 407 DEBUGF("Trying to mount partition %d.\n", i);
352 408
353 #ifdef MAX_LOG_SECTOR_SIZE 409#ifdef MAX_LOG_SECTOR_SIZE
354 for (int j = 1; j <= (MAX_LOG_SECTOR_SIZE/SECTOR_SIZE); j <<= 1) 410 for (int j = 1; j <= (MAX_LOG_SECTOR_SIZE/LOG_SECTOR_SIZE(drive)); j <<= 1)
355 { 411 {
356 if (!fat_mount(IF_MV(volume,) IF_MD(drive,) pinfo[i].start * j)) 412 if (!fat_mount(IF_MV(volume,) IF_MD(drive,) pinfo[i].start * j))
357 { 413 {
@@ -365,7 +421,7 @@ int disk_mount(int drive)
365 break; 421 break;
366 } 422 }
367 } 423 }
368 #else /* ndef MAX_LOG_SECTOR_SIZE */ 424#else /* ndef MAX_LOG_SECTOR_SIZE */
369 if (!fat_mount(IF_MV(volume,) IF_MD(drive,) pinfo[i].start)) 425 if (!fat_mount(IF_MV(volume,) IF_MD(drive,) pinfo[i].start))
370 { 426 {
371 mounted++; 427 mounted++;
@@ -373,7 +429,7 @@ int disk_mount(int drive)
373 volume_onmount_internal(IF_MV(volume)); 429 volume_onmount_internal(IF_MV(volume));
374 volume = get_free_volume(); /* prepare next entry */ 430 volume = get_free_volume(); /* prepare next entry */
375 } 431 }
376 #endif /* MAX_LOG_SECTOR_SIZE */ 432#endif /* MAX_LOG_SECTOR_SIZE */
377 } 433 }
378 } 434 }
379 435
@@ -499,13 +555,13 @@ unsigned int volume_get_cluster_size(IF_MV_NONVOID(int volume))
499 return clustersize; 555 return clustersize;
500} 556}
501 557
502void volume_size(IF_MV(int volume,) unsigned long *sizep, unsigned long *freep) 558void volume_size(IF_MV(int volume,) sector_t *sizep, sector_t *freep)
503{ 559{
504 disk_reader_lock(); 560 disk_reader_lock();
505 561
506 if (!CHECK_VOL(volume) || !fat_size(IF_MV(volume,) sizep, freep)) 562 if (!CHECK_VOL(volume) || !fat_size(IF_MV(volume,) sizep, freep))
507 { 563 {
508 if (freep) *sizep = 0; 564 if (sizep) *sizep = 0;
509 if (freep) *freep = 0; 565 if (freep) *freep = 0;
510 } 566 }
511 567
diff --git a/firmware/common/disk_cache.c b/firmware/common/disk_cache.c
index 9e4dee6a91..74c4d5f35b 100644
--- a/firmware/common/disk_cache.c
+++ b/firmware/common/disk_cache.c
@@ -71,12 +71,12 @@ struct disk_cache_entry
71#ifdef HAVE_MULTIVOLUME 71#ifdef HAVE_MULTIVOLUME
72 unsigned char volume; /* volume of sector */ 72 unsigned char volume; /* volume of sector */
73#endif 73#endif
74 unsigned long sector; /* cached disk sector number */ 74 sector_t sector; /* cached disk sector number */
75}; 75};
76 76
77BITARRAY_TYPE_DECLARE(cache_map_entry_t, cache_map, DC_NUM_ENTRIES) 77BITARRAY_TYPE_DECLARE(cache_map_entry_t, cache_map, DC_NUM_ENTRIES)
78 78
79static inline unsigned int map_sector(unsigned long sector) 79static inline unsigned int map_sector(sector_t sector)
80{ 80{
81 /* keep sector hash simple for now */ 81 /* keep sector hash simple for now */
82 return sector % DC_MAP_NUM_ENTRIES; 82 return sector % DC_MAP_NUM_ENTRIES;
@@ -172,7 +172,7 @@ static inline void cache_discard_entry(struct disk_cache_entry *dce,
172/* search the cache for the specified sector, returning a buffer, either 172/* search the cache for the specified sector, returning a buffer, either
173 to the specified sector, if it exists, or a new/evicted entry that must 173 to the specified sector, if it exists, or a new/evicted entry that must
174 be filled */ 174 be filled */
175void * dc_cache_probe(IF_MV(int volume,) unsigned long sector, 175void * dc_cache_probe(IF_MV(int volume,) sector_t sector,
176 unsigned int *flagsp) 176 unsigned int *flagsp)
177{ 177{
178 unsigned int mapnum = map_sector(sector); 178 unsigned int mapnum = map_sector(sector);
@@ -200,7 +200,7 @@ void * dc_cache_probe(IF_MV(int volume,) unsigned long sector,
200 if (old_flags) 200 if (old_flags)
201 { 201 {
202 int old_volume = IF_MV_VOL(dce->volume); 202 int old_volume = IF_MV_VOL(dce->volume);
203 unsigned long sector = dce->sector; 203 sector_t sector = dce->sector;
204 unsigned int old_mapnum = map_sector(sector); 204 unsigned int old_mapnum = map_sector(sector);
205 205
206 if (old_flags & DCE_DIRTY) 206 if (old_flags & DCE_DIRTY)
diff --git a/firmware/common/pathfuncs.c b/firmware/common/pathfuncs.c
index db3abe6940..b5e5ecb0cf 100644
--- a/firmware/common/pathfuncs.c
+++ b/firmware/common/pathfuncs.c
@@ -24,10 +24,14 @@
24#include "pathfuncs.h" 24#include "pathfuncs.h"
25#include "string-extra.h" 25#include "string-extra.h"
26#include <stdio.h> 26#include <stdio.h>
27#include "file_internal.h"
28#include "debug.h"
27 29
28#ifdef HAVE_MULTIVOLUME 30#ifdef HAVE_MULTIVOLUME
29#include "storage.h" 31#include "storage.h"
30 32
33static char vol_dec_strings[NUM_VOLUMES][ALIGN_UP(VOL_MAX_LEN+2, 4)] = {{0}};
34
31enum storage_name_dec_indexes 35enum storage_name_dec_indexes
32{ 36{
33#if (CONFIG_STORAGE & STORAGE_ATA) 37#if (CONFIG_STORAGE & STORAGE_ATA)
@@ -106,6 +110,54 @@ static const unsigned char storage_dec_indexes[STORAGE_NUM_TYPES+1] =
106#endif 110#endif
107}; 111};
108 112
113/* builds a list of drive/volume specifiers <volstr#> */
114void init_volume_names(void)
115{
116 DEBUGF("%s: ", __func__);
117 FOR_EACH_VOLUME(-1, volume)
118 {
119 const char *voldec = "";
120 char *buffer = vol_dec_strings[volume];
121
122 int type = storage_driver_type(volume_drive(volume));
123 if (type < 0 || type > STORAGE_NUM_TYPES)
124 type = STORAGE_NUM_TYPES;
125 voldec = storage_dec_names[storage_dec_indexes[type]];
126 snprintf(buffer, VOL_MAX_LEN + 1, "%c%s%d%c",
127 VOL_START_TOK, voldec, volume, VOL_END_TOK);
128 DEBUGF("vol<%d> = %s ", volume, buffer);
129 }
130 DEBUGF("\n");
131}
132
133#include <stdio.h>
134
135int path_get_volume_id(const char *name)
136{
137 int v = -1;
138
139 if (!name || *name != VOL_START_TOK)
140 goto bail;
141
142 do {
143 switch (*name)
144 {
145 case '0' ... '9': /* digit; parse volume number */
146 v = (v * 10 + *name - '0') % VOL_NUM_MAX;
147 break;
148 case '\0':
149 case PATH_SEPCH: /* no closing bracket; no volume */
150 v = -1;
151 goto bail;
152 default: /* something else; reset volume */
153 v = 0;
154 }
155 } while (*++name != VOL_END_TOK); /* found end token? */
156
157bail:
158 return v;
159}
160
109/* Returns on which volume this is and sets *nameptr to the portion of the 161/* Returns on which volume this is and sets *nameptr to the portion of the
110 * path after the volume specifier, which could be the null if the path is 162 * path after the volume specifier, which could be the null if the path is
111 * just a volume root. If *nameptr > name, then a volume specifier was 163 * just a volume root. If *nameptr > name, then a volume specifier was
@@ -203,7 +255,8 @@ int path_strip_last_volume(const char *name, const char **nameptr, bool greedy)
203} 255}
204 256
205/* Returns the volume specifier decorated with the storage type name. 257/* Returns the volume specifier decorated with the storage type name.
206 * Assumes the supplied buffer size is at least {VOL_MAX_LEN}+1. 258 * Assumes the supplied buffer size is at least {VOL_MAX_LEN}+1,
259 * vol_dec_strings has been initialized by init_volume_names().
207 */ 260 */
208int get_volume_name(int volume, char *buffer) 261int get_volume_name(int volume, char *buffer)
209{ 262{
@@ -218,17 +271,12 @@ int get_volume_name(int volume, char *buffer)
218 271
219 volume %= VOL_NUM_MAX; /* as path parser would have it */ 272 volume %= VOL_NUM_MAX; /* as path parser would have it */
220 273
221 int type = storage_driver_type(volume_drive(volume)); 274 return strlcpy(buffer, vol_dec_strings[volume], VOL_MAX_LEN + 1);
222 if (type < 0 || type > STORAGE_NUM_TYPES)
223 type = STORAGE_NUM_TYPES;
224
225 const char *voldec = storage_dec_names[storage_dec_indexes[type]];
226 return snprintf(buffer, VOL_MAX_LEN + 1, "%c%s%d%c",
227 VOL_START_TOK, voldec, volume, VOL_END_TOK);
228} 275}
229 276
230/* Returns volume name formatted with the root. Assumes buffer size is at 277/* Returns volume name formatted with the root. Assumes buffer size is at
231 * least {VOL_MAX_LEN}+2 */ 278 * least {VOL_MAX_LEN}+2, vol_dec_strings has been initialized by init_volume_names().
279 */
232int make_volume_root(int volume, char *buffer) 280int make_volume_root(int volume, char *buffer)
233{ 281{
234 char *t = buffer; 282 char *t = buffer;
diff --git a/firmware/common/rb-loader.c b/firmware/common/rb-loader.c
index 61d8b1ddd2..2f5e06e165 100644
--- a/firmware/common/rb-loader.c
+++ b/firmware/common/rb-loader.c
@@ -30,6 +30,9 @@
30#include "multiboot.h" 30#include "multiboot.h"
31#endif 31#endif
32 32
33#ifdef HAVE_DEVICEDATA
34#include "devicedata.h"
35#endif
33/* loads a firmware file from supplied filename 36/* loads a firmware file from supplied filename
34 * file opened, checks firmware size and checksum 37 * file opened, checks firmware size and checksum
35 * if no error, firmware loaded to supplied buffer 38 * if no error, firmware loaded to supplied buffer
@@ -118,7 +121,6 @@ int load_firmware(unsigned char* buf, const char* firmware, int buffer_size)
118 /* if ret is valid breaks from loop to continue loading */ 121 /* if ret is valid breaks from loop to continue loading */
119 } 122 }
120#endif 123#endif
121
122 if (ret < 0) /* Check default volume, no valid firmware file loaded yet */ 124 if (ret < 0) /* Check default volume, no valid firmware file loaded yet */
123 { 125 {
124 /* First check in BOOTDIR */ 126 /* First check in BOOTDIR */
@@ -141,5 +143,9 @@ int load_firmware(unsigned char* buf, const char* firmware, int buffer_size)
141 else /* full path passed ROLO etc.*/ 143 else /* full path passed ROLO etc.*/
142 ret = load_firmware_filename(buf, firmware, buffer_size); 144 ret = load_firmware_filename(buf, firmware, buffer_size);
143 145
146#ifdef HAVE_DEVICEDATA
147 write_devicedata(buf, ret);
148#endif
149
144 return ret; 150 return ret;
145} 151}