efi/dev-path-parser: Add struct definition for vendor type device path nodes

In preparation of adding support for loading the initrd via a special
device path, add the struct definition of a vendor GUIDed device path
node to efi.h.

Since we will be producing these data structures rather than just
consumsing the ones instantiated by the firmware, refactor the various
device path node definitions so we can take the size of each node using
sizeof() rather than having to resort to opaque arithmetic in the static
initializers.

While at it, drop the #if IS_ENABLED() check for the declaration of
efi_get_device_by_path(), which is unnecessary, and constify its first
argument as well.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
This commit is contained in:
Ard Biesheuvel
2020-02-10 08:46:57 +00:00
parent a570b0624b
commit db8952e709
3 changed files with 52 additions and 42 deletions

View File

@@ -855,30 +855,40 @@ extern int efi_status_to_err(efi_status_t status);
#define EFI_DEV_END_ENTIRE 0xFF
struct efi_generic_dev_path {
u8 type;
u8 sub_type;
u16 length;
} __attribute ((packed));
u8 type;
u8 sub_type;
u16 length;
} __packed;
struct efi_acpi_dev_path {
struct efi_generic_dev_path header;
u32 hid;
u32 uid;
} __packed;
struct efi_pci_dev_path {
struct efi_generic_dev_path header;
u8 fn;
u8 dev;
} __packed;
struct efi_vendor_dev_path {
struct efi_generic_dev_path header;
efi_guid_t vendorguid;
u8 vendordata[];
} __packed;
struct efi_dev_path {
u8 type; /* can be replaced with unnamed */
u8 sub_type; /* struct efi_generic_dev_path; */
u16 length; /* once we've moved to -std=c11 */
union {
struct {
u32 hid;
u32 uid;
} acpi;
struct {
u8 fn;
u8 dev;
} pci;
struct efi_generic_dev_path header;
struct efi_acpi_dev_path acpi;
struct efi_pci_dev_path pci;
struct efi_vendor_dev_path vendor;
};
} __attribute ((packed));
} __packed;
#if IS_ENABLED(CONFIG_EFI_DEV_PATH_PARSER)
struct device *efi_get_device_by_path(struct efi_dev_path **node, size_t *len);
#endif
struct device *efi_get_device_by_path(const struct efi_dev_path **node,
size_t *len);
static inline void memrange_efi_to_native(u64 *addr, u64 *npages)
{