[ipxe-devel] [PATCH] wimboot syslinux kludge 2/4: provide common read_mem_file cpio handler

ValdikSS iam at valdikss.org.ru
Mon Mar 11 13:10:11 UTC 2019


Correct EFI handover also require xloadflags modification. You need to set both LINUX_XLF_KERNEL_64 and LINUX_XLF_EFI_HANDOVER_64, not only the latter.

But even with this modification, wimboot.efi can't be booted with GRUB2 linuxefi command for some reason. It crashes GRUB2 loader.


On 11.03.2019 15:51, ValdikSS wrote:
> The patchset does not compile.
>
> efimain.c: In function ‘efi_main’:
> efimain.c:102:38: error: ‘efi_add_file’ undeclared (first use in this function); did you mean ‘efi_cmdline’?
>    cpio_extract ( initrd, initrd_len, efi_add_file );
>                                       ^~~~~~~~~~~~
>                                       efi_cmdline
> efimain.c:102:38: note: each undeclared identifier is reported only once for each function it appears in
> make: *** [Makefile:141: efimain.x86_64.s] Error 1
>
>
> On 11.03.2019 13:52, Friedemann Gerold wrote:
>> VladikSS informed me that the patch was accidentally pasted twice:
>> "wimboot syslinux kludge 2/4: provide common read_mem_file cpio handler"
>>
>> Attached are all the changes again as diffs which can be applied in order
>> with patch -p2 in the wimboot/src directory.
>>
>> Submitting the broken patch in question again for reference:
>> -- 
>> For the next patch that will add cpio support for efi,
>> we want to use a common read_mem_file() as cpio handler.
>> This patch moves the private read_file() from main.c to
>> vdisk.c as read_mem_file() so it can shared.
>>
>> Signed-off-by: Friedemann Gerold <f.gerold at b-c-s.de>
>> --- wimbootorig/src/vdisk.h    2018-11-02 12:29:14.343297008 +0100
>> +++ wimboot/src/vdisk.h    2018-11-02 12:28:48.071166732 +0100
>> @@ -610,11 +610,15 @@
>>
>>  extern struct vdisk_file vdisk_files[VDISK_MAX_FILES];
>>
>> +
>>  extern void vdisk_read ( uint64_t lba, unsigned int count, void *data );
>>  extern struct vdisk_file *
>>  vdisk_add_file ( const char *name, void *opaque, size_t len,
>>           void ( * read ) ( struct vdisk_file *file, void *data,
>>                     size_t offset, size_t len ) );
>> +
>> +extern void read_mem_file ( struct vdisk_file *file, void *data, size_t offset, size_t len );
>> +
>>  extern void
>>  vdisk_patch_file ( struct vdisk_file *file,
>>             void ( * patch ) ( struct vdisk_file *file, void *data,
>> --- wimbootorig/src/vdisk.c    2018-11-02 12:29:14.343297008 +0100
>> +++ wimboot/src/vdisk.c    2018-11-02 12:28:48.071166732 +0100
>> @@ -614,6 +614,19 @@
>>  }
>>
>>  /**
>> + * Read from file
>> + *
>> + * @v file              Virtual file
>> + * @v data              Data buffer
>> + * @v offset            Offset
>> + * @v len               Length
>> + */
>> +void read_mem_file ( struct vdisk_file *file, void *data, size_t offset, size_t len ) {
>> +        memcpy ( data, ( file->opaque + offset ), len );
>> +}
>> +
>> +
>> +/**
>>   * Add file to virtual disk
>>   *
>>   * @v name        Name
>> --- wimbootorig/src/main.c    2018-11-02 12:29:14.343297008 +0100
>> +++ wimboot/src/main.c    2018-11-02 12:28:48.071166732 +0100
>> @@ -197,20 +197,6 @@
>>  }
>>
>>  /**
>> - * Read from file
>> - *
>> - * @v file        Virtual file
>> - * @v data        Data buffer
>> - * @v offset        Offset
>> - * @v len        Length
>> - */
>> -static void read_file ( struct vdisk_file *file, void *data, size_t offset,
>> -            size_t len ) {
>> -
>> -    memcpy ( data, ( file->opaque + offset ), len );
>> -}
>> -
>> -/**
>>   * Add embedded bootmgr.exe extracted from bootmgr
>>   *
>>   * @v data        File data
>> @@ -305,8 +291,7 @@
>>          decompress ( compressed, compressed_len, initrd );
>>
>>          /* Add decompressed image */
>> -        return vdisk_add_file ( "bootmgr.exe", initrd,
>> -                    decompressed_len, read_file );
>> +        return vdisk_add_file ( "bootmgr.exe", initrd, decompressed_len, read_mem_file );
>>      }
>>
>>      DBG ( "...no embedded bootmgr.exe found\n" );
>> @@ -325,7 +310,7 @@
>>      struct vdisk_file *file;
>>
>>      /* Store file */
>> -    file = vdisk_add_file ( name, data, len, read_file );
>> +    file = vdisk_add_file ( name, data, len, read_mem_file );
>>
>>      /* Check for special-case files */
>>      if ( strcasecmp ( name, "bootmgr.exe" ) == 0 ) {
>> @@ -378,7 +363,7 @@
>>      /* Read bootmgr.exe into memory */
>>      if ( ! bootmgr )
>>          die ( "FATAL: no bootmgr.exe\n" );
>> -    if ( bootmgr->read == read_file ) {
>> +    if ( bootmgr->read == read_mem_file ) {
>>          raw_pe = bootmgr->opaque;
>>      } else {
>>          padded_len = ( ( bootmgr->len + PAGE_SIZE - 1 ) &

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 868 bytes
Desc: OpenPGP digital signature
URL: <http://lists.ipxe.org/pipermail/ipxe-devel/attachments/20190311/648166ed/attachment.sig>


More information about the ipxe-devel mailing list