4343#include "printf.h"
4444#include "wolfboot/wolfboot.h"
4545#include "disk.h"
46+ #ifdef WOLFBOOT_ELF
47+ #include "elf.h"
48+ #endif
4649
4750#include <stdint.h>
4851#include <string.h>
5356#include "x86/ahci.h"
5457#include "x86/ata.h"
5558#include "pci.h"
56-
57- #ifdef WOLFBOOT_TGL
5859#include "x86/tgl_fsp.h"
59- #endif
6060
6161#ifdef TARGET_kontron_vx3060_s2
6262 #define BOOT_PART_A 5
@@ -117,7 +117,6 @@ void RAMFUNCTION wolfBoot_start(void)
117117#ifdef WOLFBOOT_FSP
118118 struct stage2_parameter * stage2_params ;
119119 uint32_t sata_bar ;
120-
121120 ret = x86_fsp_tgl_init_sata (& sata_bar );
122121 if (ret != 0 )
123122 wolfBoot_panic ();
@@ -265,14 +264,7 @@ void RAMFUNCTION wolfBoot_start(void)
265264
266265 load_address = (uint32_t * )os_image .fw_base ;
267266
268- #ifdef WOLFBOOT_ELF
269- /* Load elf */
270- if (elf_load_image_mmu ((uint8_t * )load_address , (uintptr_t * )& load_address , NULL ) != 0 ){
271- wolfBoot_printf ("Invalid elf, falling back to raw binary\n" );
272- }
273- #endif
274-
275- #ifdef MMU
267+ #ifdef WOLFBOOT_FDT
276268 /* Is this a Flattened uImage Tree (FIT) image (FDT format) */
277269 if (wolfBoot_get_dts_size (load_address ) > 0 ) {
278270 void * fit = (void * )load_address ;
@@ -296,42 +288,14 @@ void RAMFUNCTION wolfBoot_start(void)
296288 }
297289 }
298290 }
299- else {
300- /* Load DTS to RAM */
301- #ifdef EXT_FLASH
302- if (PART_IS_EXT (& os_image ) &&
303- wolfBoot_open_image (& os_image , PART_DTS_BOOT ) >= 0 ) {
304- dts_addr = (uint8_t * )WOLFBOOT_LOAD_DTS_ADDRESS ;
305- dts_size = (uint32_t )os_image .fw_size ;
306-
307- wolfBoot_printf ("Loading DTS (size %lu) to RAM at %08lx\n" ,
308- (long unsigned int )dts_size , (long unsigned int )dts_addr );
309- ext_flash_check_read ((uintptr_t )os_image .fw_base ,
310- (uint8_t * )dts_addr , dts_size );
311- }
312- else
313- #endif /* EXT_FLASH */
314- {
315- dts_addr = hal_get_dts_address ();
316- if (dts_addr ) {
317- ret = wolfBoot_get_dts_size (dts_addr );
318- if (ret < 0 ) {
319- wolfBoot_printf ("Failed parsing DTB to load\n" );
320- /* Allow failure, continue booting */
321- }
322- else {
323- /* relocate DTS to RAM */
324- uint8_t * dts_dst = (uint8_t * )WOLFBOOT_LOAD_DTS_ADDRESS ;
325- dts_size = (uint32_t )ret ;
326- wolfBoot_printf ("Loading DTB (size %d) from %p to RAM at %p\n" ,
327- dts_size , dts_addr , (void * )WOLFBOOT_LOAD_DTS_ADDRESS );
328- memcpy (dts_dst , dts_addr , dts_size );
329- dts_addr = dts_dst ;
330- }
331- }
332- }
291+ #endif
292+
293+ #ifdef WOLFBOOT_ELF
294+ /* Load elf */
295+ if (elf_load_image_mmu ((uint8_t * )load_address , (uintptr_t * )& load_address , NULL ) != 0 ){
296+ wolfBoot_printf ("Invalid elf, falling back to raw binary\n" );
333297 }
334- #endif /* MMU */
298+ #endif
335299
336300 wolfBoot_printf ("Booting at %08lx\r\n" , load_address );
337301
0 commit comments