Introduce grub_efi_packed_guid and use it where alignment is not
guaranteed.
This commit is contained in:
parent
219401b8b9
commit
316dda716c
6 changed files with 82 additions and 70 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2013-12-11 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Introduce grub_efi_packed_guid and use it where alignment is not
|
||||||
|
guaranteed.
|
||||||
|
|
||||||
2013-12-11 Vladimir Serbinenko <phcoder@gmail.com>
|
2013-12-11 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* include/grub/efi/api.h (grub_efi_device_path): Define length as
|
* include/grub/efi/api.h (grub_efi_device_path): Define length as
|
||||||
|
|
|
@ -26,14 +26,14 @@ struct grub_acpi_rsdp_v10 *
|
||||||
grub_machine_acpi_get_rsdpv1 (void)
|
grub_machine_acpi_get_rsdpv1 (void)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
static grub_efi_guid_t acpi_guid = GRUB_EFI_ACPI_TABLE_GUID;
|
static grub_efi_packed_guid_t acpi_guid = GRUB_EFI_ACPI_TABLE_GUID;
|
||||||
|
|
||||||
for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
|
for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
|
||||||
{
|
{
|
||||||
grub_efi_guid_t *guid =
|
grub_efi_packed_guid_t *guid =
|
||||||
&grub_efi_system_table->configuration_table[i].vendor_guid;
|
&grub_efi_system_table->configuration_table[i].vendor_guid;
|
||||||
|
|
||||||
if (! grub_memcmp (guid, &acpi_guid, sizeof (grub_efi_guid_t)))
|
if (! grub_memcmp (guid, &acpi_guid, sizeof (grub_efi_packed_guid_t)))
|
||||||
return (struct grub_acpi_rsdp_v10 *)
|
return (struct grub_acpi_rsdp_v10 *)
|
||||||
grub_efi_system_table->configuration_table[i].vendor_table;
|
grub_efi_system_table->configuration_table[i].vendor_table;
|
||||||
}
|
}
|
||||||
|
@ -44,14 +44,14 @@ struct grub_acpi_rsdp_v20 *
|
||||||
grub_machine_acpi_get_rsdpv2 (void)
|
grub_machine_acpi_get_rsdpv2 (void)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
static grub_efi_guid_t acpi20_guid = GRUB_EFI_ACPI_20_TABLE_GUID;
|
static grub_efi_packed_guid_t acpi20_guid = GRUB_EFI_ACPI_20_TABLE_GUID;
|
||||||
|
|
||||||
for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
|
for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
|
||||||
{
|
{
|
||||||
grub_efi_guid_t *guid =
|
grub_efi_packed_guid_t *guid =
|
||||||
&grub_efi_system_table->configuration_table[i].vendor_guid;
|
&grub_efi_system_table->configuration_table[i].vendor_guid;
|
||||||
|
|
||||||
if (! grub_memcmp (guid, &acpi20_guid, sizeof (grub_efi_guid_t)))
|
if (! grub_memcmp (guid, &acpi20_guid, sizeof (grub_efi_packed_guid_t)))
|
||||||
return (struct grub_acpi_rsdp_v20 *)
|
return (struct grub_acpi_rsdp_v20 *)
|
||||||
grub_efi_system_table->configuration_table[i].vendor_table;
|
grub_efi_system_table->configuration_table[i].vendor_table;
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,7 @@ grub_cmd_lsefi (grub_command_t cmd __attribute__ ((unused)),
|
||||||
grub_efi_handle_t handle = handles[i];
|
grub_efi_handle_t handle = handles[i];
|
||||||
grub_efi_status_t status;
|
grub_efi_status_t status;
|
||||||
grub_efi_uintn_t num_protocols;
|
grub_efi_uintn_t num_protocols;
|
||||||
grub_efi_guid_t **protocols;
|
grub_efi_packed_guid_t **protocols;
|
||||||
grub_efi_device_path_t *dp;
|
grub_efi_device_path_t *dp;
|
||||||
|
|
||||||
grub_printf ("Handle %p\n", handle);
|
grub_printf ("Handle %p\n", handle);
|
||||||
|
|
|
@ -135,12 +135,12 @@ grub_cmd_lssal (struct grub_command *cmd __attribute__ ((unused)),
|
||||||
const grub_efi_system_table_t *st = grub_efi_system_table;
|
const grub_efi_system_table_t *st = grub_efi_system_table;
|
||||||
grub_efi_configuration_table_t *t = st->configuration_table;
|
grub_efi_configuration_table_t *t = st->configuration_table;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
grub_efi_guid_t guid = GRUB_EFI_SAL_TABLE_GUID;
|
grub_efi_packed_guid_t guid = GRUB_EFI_SAL_TABLE_GUID;
|
||||||
|
|
||||||
for (i = 0; i < st->num_table_entries; i++)
|
for (i = 0; i < st->num_table_entries; i++)
|
||||||
{
|
{
|
||||||
if (grub_memcmp (&guid, &t->vendor_guid,
|
if (grub_memcmp (&guid, &t->vendor_guid,
|
||||||
sizeof (grub_efi_guid_t)) == 0)
|
sizeof (grub_efi_packed_guid_t)) == 0)
|
||||||
{
|
{
|
||||||
disp_sal (t->vendor_table);
|
disp_sal (t->vendor_table);
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
|
|
|
@ -445,20 +445,19 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
|
||||||
break;
|
break;
|
||||||
case GRUB_EFI_VENDOR_DEVICE_PATH_SUBTYPE:
|
case GRUB_EFI_VENDOR_DEVICE_PATH_SUBTYPE:
|
||||||
{
|
{
|
||||||
grub_efi_vendor_device_path_t vendor;
|
grub_efi_vendor_device_path_t *vendor = (grub_efi_vendor_device_path_t *) dp;
|
||||||
grub_memcpy (&vendor, dp, sizeof (vendor));
|
|
||||||
grub_printf ("/Vendor(%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x)",
|
grub_printf ("/Vendor(%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x)",
|
||||||
(unsigned) vendor.vendor_guid.data1,
|
(unsigned) vendor->vendor_guid.data1,
|
||||||
(unsigned) vendor.vendor_guid.data2,
|
(unsigned) vendor->vendor_guid.data2,
|
||||||
(unsigned) vendor.vendor_guid.data3,
|
(unsigned) vendor->vendor_guid.data3,
|
||||||
(unsigned) vendor.vendor_guid.data4[0],
|
(unsigned) vendor->vendor_guid.data4[0],
|
||||||
(unsigned) vendor.vendor_guid.data4[1],
|
(unsigned) vendor->vendor_guid.data4[1],
|
||||||
(unsigned) vendor.vendor_guid.data4[2],
|
(unsigned) vendor->vendor_guid.data4[2],
|
||||||
(unsigned) vendor.vendor_guid.data4[3],
|
(unsigned) vendor->vendor_guid.data4[3],
|
||||||
(unsigned) vendor.vendor_guid.data4[4],
|
(unsigned) vendor->vendor_guid.data4[4],
|
||||||
(unsigned) vendor.vendor_guid.data4[5],
|
(unsigned) vendor->vendor_guid.data4[5],
|
||||||
(unsigned) vendor.vendor_guid.data4[6],
|
(unsigned) vendor->vendor_guid.data4[6],
|
||||||
(unsigned) vendor.vendor_guid.data4[7]);
|
(unsigned) vendor->vendor_guid.data4[7]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GRUB_EFI_CONTROLLER_DEVICE_PATH_SUBTYPE:
|
case GRUB_EFI_CONTROLLER_DEVICE_PATH_SUBTYPE:
|
||||||
|
@ -665,20 +664,20 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
|
||||||
break;
|
break;
|
||||||
case GRUB_EFI_VENDOR_MESSAGING_DEVICE_PATH_SUBTYPE:
|
case GRUB_EFI_VENDOR_MESSAGING_DEVICE_PATH_SUBTYPE:
|
||||||
{
|
{
|
||||||
grub_efi_vendor_messaging_device_path_t vendor;
|
grub_efi_vendor_messaging_device_path_t *vendor
|
||||||
grub_memcpy (&vendor, dp, sizeof (vendor));
|
= (grub_efi_vendor_messaging_device_path_t *) dp;
|
||||||
grub_printf ("/Vendor(%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x)",
|
grub_printf ("/Vendor(%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x)",
|
||||||
(unsigned) vendor.vendor_guid.data1,
|
(unsigned) vendor->vendor_guid.data1,
|
||||||
(unsigned) vendor.vendor_guid.data2,
|
(unsigned) vendor->vendor_guid.data2,
|
||||||
(unsigned) vendor.vendor_guid.data3,
|
(unsigned) vendor->vendor_guid.data3,
|
||||||
(unsigned) vendor.vendor_guid.data4[0],
|
(unsigned) vendor->vendor_guid.data4[0],
|
||||||
(unsigned) vendor.vendor_guid.data4[1],
|
(unsigned) vendor->vendor_guid.data4[1],
|
||||||
(unsigned) vendor.vendor_guid.data4[2],
|
(unsigned) vendor->vendor_guid.data4[2],
|
||||||
(unsigned) vendor.vendor_guid.data4[3],
|
(unsigned) vendor->vendor_guid.data4[3],
|
||||||
(unsigned) vendor.vendor_guid.data4[4],
|
(unsigned) vendor->vendor_guid.data4[4],
|
||||||
(unsigned) vendor.vendor_guid.data4[5],
|
(unsigned) vendor->vendor_guid.data4[5],
|
||||||
(unsigned) vendor.vendor_guid.data4[6],
|
(unsigned) vendor->vendor_guid.data4[6],
|
||||||
(unsigned) vendor.vendor_guid.data4[7]);
|
(unsigned) vendor->vendor_guid.data4[7]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -692,22 +691,21 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
|
||||||
{
|
{
|
||||||
case GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE:
|
case GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE:
|
||||||
{
|
{
|
||||||
grub_efi_hard_drive_device_path_t hd;
|
grub_efi_hard_drive_device_path_t *hd = (grub_efi_hard_drive_device_path_t *) dp;
|
||||||
grub_memcpy (&hd, dp, len);
|
|
||||||
grub_printf ("/HD(%u,%llx,%llx,%02x%02x%02x%02x%02x%02x%02x%02x,%x,%x)",
|
grub_printf ("/HD(%u,%llx,%llx,%02x%02x%02x%02x%02x%02x%02x%02x,%x,%x)",
|
||||||
hd.partition_number,
|
hd->partition_number,
|
||||||
(unsigned long long) hd.partition_start,
|
(unsigned long long) hd->partition_start,
|
||||||
(unsigned long long) hd.partition_size,
|
(unsigned long long) hd->partition_size,
|
||||||
(unsigned) hd.partition_signature[0],
|
(unsigned) hd->partition_signature[0],
|
||||||
(unsigned) hd.partition_signature[1],
|
(unsigned) hd->partition_signature[1],
|
||||||
(unsigned) hd.partition_signature[2],
|
(unsigned) hd->partition_signature[2],
|
||||||
(unsigned) hd.partition_signature[3],
|
(unsigned) hd->partition_signature[3],
|
||||||
(unsigned) hd.partition_signature[4],
|
(unsigned) hd->partition_signature[4],
|
||||||
(unsigned) hd.partition_signature[5],
|
(unsigned) hd->partition_signature[5],
|
||||||
(unsigned) hd.partition_signature[6],
|
(unsigned) hd->partition_signature[6],
|
||||||
(unsigned) hd.partition_signature[7],
|
(unsigned) hd->partition_signature[7],
|
||||||
(unsigned) hd.mbr_type,
|
(unsigned) hd->mbr_type,
|
||||||
(unsigned) hd.signature_type);
|
(unsigned) hd->signature_type);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE:
|
case GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE:
|
||||||
|
@ -722,20 +720,20 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
|
||||||
break;
|
break;
|
||||||
case GRUB_EFI_VENDOR_MEDIA_DEVICE_PATH_SUBTYPE:
|
case GRUB_EFI_VENDOR_MEDIA_DEVICE_PATH_SUBTYPE:
|
||||||
{
|
{
|
||||||
grub_efi_vendor_media_device_path_t vendor;
|
grub_efi_vendor_device_path_t *vendor = (grub_efi_vendor_device_path_t *) dp;
|
||||||
grub_memcpy (&vendor, dp, sizeof (vendor));
|
|
||||||
grub_printf ("/Vendor(%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x)",
|
grub_printf ("/Vendor(%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x)",
|
||||||
(unsigned) vendor.vendor_guid.data1,
|
(unsigned) vendor->vendor_guid.data1,
|
||||||
(unsigned) vendor.vendor_guid.data2,
|
(unsigned) vendor->vendor_guid.data2,
|
||||||
(unsigned) vendor.vendor_guid.data3,
|
(unsigned) vendor->vendor_guid.data3,
|
||||||
(unsigned) vendor.vendor_guid.data4[0],
|
(unsigned) vendor->vendor_guid.data4[0],
|
||||||
(unsigned) vendor.vendor_guid.data4[1],
|
(unsigned) vendor->vendor_guid.data4[1],
|
||||||
(unsigned) vendor.vendor_guid.data4[2],
|
(unsigned) vendor->vendor_guid.data4[2],
|
||||||
(unsigned) vendor.vendor_guid.data4[3],
|
(unsigned) vendor->vendor_guid.data4[3],
|
||||||
(unsigned) vendor.vendor_guid.data4[4],
|
(unsigned) vendor->vendor_guid.data4[4],
|
||||||
(unsigned) vendor.vendor_guid.data4[5],
|
(unsigned) vendor->vendor_guid.data4[5],
|
||||||
(unsigned) vendor.vendor_guid.data4[6],
|
(unsigned) vendor->vendor_guid.data4[6],
|
||||||
(unsigned) vendor.vendor_guid.data4[7]);
|
(unsigned) vendor->vendor_guid.data4[7]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GRUB_EFI_FILE_PATH_DEVICE_PATH_SUBTYPE:
|
case GRUB_EFI_FILE_PATH_DEVICE_PATH_SUBTYPE:
|
||||||
|
|
|
@ -526,6 +526,15 @@ struct grub_efi_guid
|
||||||
} __attribute__ ((aligned(8)));
|
} __attribute__ ((aligned(8)));
|
||||||
typedef struct grub_efi_guid grub_efi_guid_t;
|
typedef struct grub_efi_guid grub_efi_guid_t;
|
||||||
|
|
||||||
|
struct grub_efi_packed_guid
|
||||||
|
{
|
||||||
|
grub_uint32_t data1;
|
||||||
|
grub_uint16_t data2;
|
||||||
|
grub_uint16_t data3;
|
||||||
|
grub_uint8_t data4[8];
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
typedef struct grub_efi_packed_guid grub_efi_packed_guid_t;
|
||||||
|
|
||||||
/* XXX although the spec does not specify the padding, this actually
|
/* XXX although the spec does not specify the padding, this actually
|
||||||
must have the padding! */
|
must have the padding! */
|
||||||
struct grub_efi_memory_descriptor
|
struct grub_efi_memory_descriptor
|
||||||
|
@ -608,7 +617,7 @@ typedef struct grub_efi_memory_mapped_device_path grub_efi_memory_mapped_device_
|
||||||
struct grub_efi_vendor_device_path
|
struct grub_efi_vendor_device_path
|
||||||
{
|
{
|
||||||
grub_efi_device_path_t header;
|
grub_efi_device_path_t header;
|
||||||
grub_efi_guid_t vendor_guid;
|
grub_efi_packed_guid_t vendor_guid;
|
||||||
grub_efi_uint8_t vendor_defined_data[0];
|
grub_efi_uint8_t vendor_defined_data[0];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
typedef struct grub_efi_vendor_device_path grub_efi_vendor_device_path_t;
|
typedef struct grub_efi_vendor_device_path grub_efi_vendor_device_path_t;
|
||||||
|
@ -802,7 +811,7 @@ typedef struct grub_efi_uart_device_path grub_efi_uart_device_path_t;
|
||||||
struct grub_efi_vendor_messaging_device_path
|
struct grub_efi_vendor_messaging_device_path
|
||||||
{
|
{
|
||||||
grub_efi_device_path_t header;
|
grub_efi_device_path_t header;
|
||||||
grub_efi_guid_t vendor_guid;
|
grub_efi_packed_guid_t vendor_guid;
|
||||||
grub_efi_uint8_t vendor_defined_data[0];
|
grub_efi_uint8_t vendor_defined_data[0];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
typedef struct grub_efi_vendor_messaging_device_path grub_efi_vendor_messaging_device_path_t;
|
typedef struct grub_efi_vendor_messaging_device_path grub_efi_vendor_messaging_device_path_t;
|
||||||
|
@ -840,7 +849,7 @@ typedef struct grub_efi_cdrom_device_path grub_efi_cdrom_device_path_t;
|
||||||
struct grub_efi_vendor_media_device_path
|
struct grub_efi_vendor_media_device_path
|
||||||
{
|
{
|
||||||
grub_efi_device_path_t header;
|
grub_efi_device_path_t header;
|
||||||
grub_efi_guid_t vendor_guid;
|
grub_efi_packed_guid_t vendor_guid;
|
||||||
grub_efi_uint8_t vendor_defined_data[0];
|
grub_efi_uint8_t vendor_defined_data[0];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
typedef struct grub_efi_vendor_media_device_path grub_efi_vendor_media_device_path_t;
|
typedef struct grub_efi_vendor_media_device_path grub_efi_vendor_media_device_path_t;
|
||||||
|
@ -859,7 +868,7 @@ typedef struct grub_efi_file_path_device_path grub_efi_file_path_device_path_t;
|
||||||
struct grub_efi_protocol_device_path
|
struct grub_efi_protocol_device_path
|
||||||
{
|
{
|
||||||
grub_efi_device_path_t header;
|
grub_efi_device_path_t header;
|
||||||
grub_efi_guid_t guid;
|
grub_efi_packed_guid_t guid;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
typedef struct grub_efi_protocol_device_path grub_efi_protocol_device_path_t;
|
typedef struct grub_efi_protocol_device_path grub_efi_protocol_device_path_t;
|
||||||
|
|
||||||
|
@ -868,7 +877,7 @@ typedef struct grub_efi_protocol_device_path grub_efi_protocol_device_path_t;
|
||||||
struct grub_efi_piwg_device_path
|
struct grub_efi_piwg_device_path
|
||||||
{
|
{
|
||||||
grub_efi_device_path_t header;
|
grub_efi_device_path_t header;
|
||||||
grub_efi_guid_t guid __attribute__ ((packed));
|
grub_efi_packed_guid_t guid;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
typedef struct grub_efi_piwg_device_path grub_efi_piwg_device_path_t;
|
typedef struct grub_efi_piwg_device_path grub_efi_piwg_device_path_t;
|
||||||
|
|
||||||
|
@ -1126,7 +1135,7 @@ struct grub_efi_boot_services
|
||||||
|
|
||||||
grub_efi_status_t
|
grub_efi_status_t
|
||||||
(*protocols_per_handle) (grub_efi_handle_t handle,
|
(*protocols_per_handle) (grub_efi_handle_t handle,
|
||||||
grub_efi_guid_t ***protocol_buffer,
|
grub_efi_packed_guid_t ***protocol_buffer,
|
||||||
grub_efi_uintn_t *protocol_buffer_count);
|
grub_efi_uintn_t *protocol_buffer_count);
|
||||||
|
|
||||||
grub_efi_status_t
|
grub_efi_status_t
|
||||||
|
@ -1225,7 +1234,7 @@ typedef struct grub_efi_runtime_services grub_efi_runtime_services_t;
|
||||||
|
|
||||||
struct grub_efi_configuration_table
|
struct grub_efi_configuration_table
|
||||||
{
|
{
|
||||||
grub_efi_guid_t vendor_guid;
|
grub_efi_packed_guid_t vendor_guid;
|
||||||
void *vendor_table;
|
void *vendor_table;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
typedef struct grub_efi_configuration_table grub_efi_configuration_table_t;
|
typedef struct grub_efi_configuration_table grub_efi_configuration_table_t;
|
||||||
|
|
Loading…
Reference in a new issue