Print this page
10570 Need workaround to EFI boot on AMI BIOS

@@ -20,16 +20,18 @@
  */
 /*
  * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2012 Nexenta Systems, Inc.  All rights reserved.
  * Copyright 2014 Toomas Soome <tsoome@me.com>
+ * Copyright (c) 2019, Joyent, Inc.
  */
 
 #ifndef _SYS_EFI_PARTITION_H
 #define _SYS_EFI_PARTITION_H
 
 #include <sys/uuid.h>
+#include <sys/stddef.h>
 
 #ifdef  __cplusplus
 extern "C" {
 #endif
 

@@ -44,10 +46,20 @@
                             (8 * sizeof (char)) + \
                             (1 * (sizeof (struct uuid)))))
 
 #define EFI_SIGNATURE   0x5452415020494645ULL
 
+/*
+ * Although the EFI spec is clear that sizeof (efi_gpt_t) is a valid value
+ * (512), at least one EFI system (AMI v4.6.4.1) incorrectly expects this to be
+ * exactly the size of the structure defined in the spec, that is, 92.
+ *
+ * As the reserved section is never used, the modified value works fine
+ * everywhere else.
+ */
+#define EFI_HEADER_SIZE (offsetof(efi_gpt_t, efi_gpt_Reserved2))
+
 /* EFI Guid Partition Table Header -- little endian on-disk format */
 typedef struct efi_gpt {
         uint64_t        efi_gpt_Signature;
         uint_t          efi_gpt_Revision;
         uint_t          efi_gpt_HeaderSize;