@@ -477,7 +477,9 @@ static ssize_t gunzip(void *dst, size_t dstlen, uint8_t *src,
477
477
478
478
/* Load a U-Boot image. */
479
479
static int load_uboot_image (const char * filename , hwaddr * ep , hwaddr * loadaddr ,
480
- int * is_linux , uint8_t image_type )
480
+ int * is_linux , uint8_t image_type ,
481
+ uint64_t (* translate_fn )(void * , uint64_t ),
482
+ void * translate_opaque )
481
483
{
482
484
int fd ;
483
485
int size ;
@@ -511,6 +513,9 @@ static int load_uboot_image(const char *filename, hwaddr *ep, hwaddr *loadaddr,
511
513
switch (hdr -> ih_type ) {
512
514
case IH_TYPE_KERNEL :
513
515
address = hdr -> ih_load ;
516
+ if (translate_fn ) {
517
+ address = translate_fn (translate_opaque , address );
518
+ }
514
519
if (loadaddr ) {
515
520
* loadaddr = hdr -> ih_load ;
516
521
}
@@ -587,15 +592,19 @@ static int load_uboot_image(const char *filename, hwaddr *ep, hwaddr *loadaddr,
587
592
}
588
593
589
594
int load_uimage (const char * filename , hwaddr * ep , hwaddr * loadaddr ,
590
- int * is_linux )
595
+ int * is_linux ,
596
+ uint64_t (* translate_fn )(void * , uint64_t ),
597
+ void * translate_opaque )
591
598
{
592
- return load_uboot_image (filename , ep , loadaddr , is_linux , IH_TYPE_KERNEL );
599
+ return load_uboot_image (filename , ep , loadaddr , is_linux , IH_TYPE_KERNEL ,
600
+ translate_fn , translate_opaque );
593
601
}
594
602
595
603
/* Load a ramdisk. */
596
604
int load_ramdisk (const char * filename , hwaddr addr , uint64_t max_sz )
597
605
{
598
- return load_uboot_image (filename , NULL , & addr , NULL , IH_TYPE_RAMDISK );
606
+ return load_uboot_image (filename , NULL , & addr , NULL , IH_TYPE_RAMDISK ,
607
+ NULL , NULL );
599
608
}
600
609
601
610
/* This simply prevents g_malloc in the function below from allocating
0 commit comments