components/shim/patches/03-netboot.patch
changeset 7222 37e367b978c0
equal deleted inserted replaced
7221:0e3ebbcfc116 7222:37e367b978c0
       
     1 # Source: Internal
       
     2 # Info: Written internally so this component can be built and run on Solaris.
       
     3 # Status: This patch is offered at https://github.com/rhinstaller/shim/issues/54
       
     4 
       
     5 --- ORIGINAL/netboot.h  2016-06-29 02:22:41.249041492 +0000
       
     6 +++ shim-0.9/netboot.h  2016-06-29 02:22:48.250540430 +0000
       
     7 @@ -3,7 +3,11 @@
       
     8 
       
     9  extern BOOLEAN findNetboot(EFI_HANDLE image_handle);
       
    10 
       
    11 +#ifndef __sun
       
    12  extern EFI_STATUS parseNetbootinfo(EFI_HANDLE image_handle);
       
    13 +#else
       
    14 +extern EFI_STATUS parseNetbootinfo(EFI_HANDLE image_handle, UINT8 boot_grub);
       
    15 +#endif
       
    16 
       
    17  extern EFI_STATUS FetchNetbootimage(EFI_HANDLE image_handle, VOID **buffer, UINT64 *bufsiz);
       
    18  #endif
       
    19 
       
    20 --- ORIGINAL/netboot.c	2016-06-28 04:01:44.455712794 +0000
       
    21 +++ shim-0.9/netboot.c	2016-06-29 02:17:31.667622371 +0000
       
    22 @@ -42,6 +42,10 @@
       
    23  
       
    24  #define ntohs(x) __builtin_bswap16(x)	/* supported both by GCC and clang */
       
    25  #define htons(x) ntohs(x)
       
    26 +#ifdef __sun
       
    27 +# define GRUB_BOOT_FILE ".grub2netx64.uefi"
       
    28 +# define MOK_BOOT_FILE ".MokManager.uefi"
       
    29 +#endif
       
    30  
       
    31  static EFI_PXE_BASE_CODE *pxe;
       
    32  static EFI_IP_ADDRESS tftp_addr;
       
    33 @@ -273,14 +277,25 @@
       
    34  	return EFI_SUCCESS;
       
    35  }
       
    36  
       
    37 +#ifndef __sun
       
    38  static EFI_STATUS parseDhcp4()
       
    39 +#else
       
    40 +static EFI_STATUS parseDhcp4(UINT8 boot_grub)
       
    41 +#endif
       
    42  {
       
    43 +#ifndef __sun
       
    44  	CHAR8 *template = (CHAR8 *)translate_slashes(DEFAULT_LOADER_CHAR);
       
    45 +#else
       
    46 +	CHAR8 *template = boot_grub ? (CHAR8 *)GRUB_BOOT_FILE:(CHAR8 *)MOK_BOOT_FILE;
       
    47 +#endif
       
    48  	INTN template_len = strlen(template) + 1;
       
    49  
       
    50  	INTN dir_len = strnlena(pxe->Mode->DhcpAck.Dhcpv4.BootpBootFile, 127);
       
    51  	INTN i;
       
    52  	UINT8 *dir = pxe->Mode->DhcpAck.Dhcpv4.BootpBootFile;
       
    53 +#ifdef __sun
       
    54 +	UINT8 BootpHwAddrLen = pxe->Mode->DhcpAck.Dhcpv4.BootpHwAddrLen;
       
    55 +#endif
       
    56  
       
    57  	for (i = dir_len; i >= 0; i--) {
       
    58  		if (dir[i] == '/')
       
    59 @@ -288,7 +303,11 @@
       
    60  	}
       
    61  	dir_len = (i >= 0) ? i + 1 : 0;
       
    62  
       
    63 +#ifndef __sun
       
    64  	full_path = AllocateZeroPool(dir_len + template_len);
       
    65 +#else
       
    66 +	full_path = AllocateZeroPool(dir_len + template_len + BootpHwAddrLen*2 + 2);
       
    67 +#endif
       
    68  
       
    69  	if (!full_path)
       
    70  		return EFI_OUT_OF_RESOURCES;
       
    71 @@ -298,6 +317,12 @@
       
    72  		if (full_path[dir_len-1] == '/' && template[0] == '/')
       
    73  			full_path[dir_len-1] = '\0';
       
    74  	}
       
    75 +#ifdef __sun
       
    76 +	else {
       
    77 +		strncpya(full_path, dir, BootpHwAddrLen*2 + 2);
       
    78 +	}
       
    79 +#endif
       
    80 +
       
    81  	if (dir_len == 0 && dir[0] != '/' && template[0] == '/')
       
    82  		template++;
       
    83  	strcata(full_path, template);
       
    84 @@ -306,7 +331,11 @@
       
    85  	return EFI_SUCCESS;
       
    86  }
       
    87  
       
    88 +#ifndef __sun
       
    89  EFI_STATUS parseNetbootinfo(EFI_HANDLE image_handle)
       
    90 +#else
       
    91 +EFI_STATUS parseNetbootinfo(EFI_HANDLE image_handle, UINT8 boot_grub)
       
    92 +#endif
       
    93  {
       
    94  
       
    95  	EFI_STATUS rc;
       
    96 @@ -323,7 +352,11 @@
       
    97  	if (pxe->Mode->UsingIpv6){
       
    98  		rc = parseDhcp6();
       
    99  	} else
       
   100 +#ifndef __sun
       
   101  		rc = parseDhcp4();
       
   102 +#else
       
   103 +		rc = parseDhcp4(boot_grub);
       
   104 +#endif
       
   105  	return rc;
       
   106  }
       
   107