Skip to content

Commit

Permalink
efi_loader: add device-path utils
Browse files Browse the repository at this point in the history
Helpers to construct device-paths from devices, partitions, files, and
for parsing and manipulating device-paths.

For non-legacy devices, this will use u-boot's device-model to construct
device-paths which include bus hierarchy to construct device-paths.  For
legacy devices we still fake it, but slightly more convincingly.

Signed-off-by: Rob Clark <robdclark@gmail.com>
  • Loading branch information
robclark committed Aug 29, 2017
1 parent 38590e9 commit a00519e
Show file tree
Hide file tree
Showing 4 changed files with 520 additions and 1 deletion.
10 changes: 10 additions & 0 deletions include/efi_api.h
Expand Up @@ -314,6 +314,7 @@ struct efi_device_path_acpi_path {
#define DEVICE_PATH_TYPE_MESSAGING_DEVICE 0x03
# define DEVICE_PATH_SUB_TYPE_MSG_USB 0x05
# define DEVICE_PATH_SUB_TYPE_MSG_MAC_ADDR 0x0b
# define DEVICE_PATH_SUB_TYPE_MSG_USB_CLASS 0x0f
# define DEVICE_PATH_SUB_TYPE_MSG_SD 0x1a
# define DEVICE_PATH_SUB_TYPE_MSG_MMC 0x1d

Expand All @@ -329,6 +330,15 @@ struct efi_device_path_mac_addr {
u8 if_type;
} __packed;

struct efi_device_path_usb_class {
struct efi_device_path dp;
u16 vendor_id;
u16 product_id;
u8 device_class;
u8 device_subclass;
u8 device_protocol;
} __packed;

struct efi_device_path_sd_mmc_path {
struct efi_device_path dp;
u8 slot_number;
Expand Down
20 changes: 20 additions & 0 deletions include/efi_loader.h
Expand Up @@ -197,6 +197,26 @@ extern void *efi_bounce_buffer;
#define EFI_LOADER_BOUNCE_BUFFER_SIZE (64 * 1024 * 1024)
#endif


struct efi_device_path *efi_dp_next(struct efi_device_path *dp);
int efi_dp_match(struct efi_device_path *a, struct efi_device_path *b);
struct efi_object *efi_dp_find_obj(struct efi_device_path *dp);
unsigned efi_dp_size(struct efi_device_path *dp);
struct efi_device_path *efi_dp_dup(struct efi_device_path *dp);

struct efi_device_path *efi_dp_from_dev(struct udevice *dev);
struct efi_device_path *efi_dp_from_part(struct blk_desc *desc, int part);
struct efi_device_path *efi_dp_from_file(struct blk_desc *desc, int part,
const char *path);
struct efi_device_path *efi_dp_from_eth(void);
void efi_dp_split_file_path(struct efi_device_path *full_path,
struct efi_device_path **device_path,
struct efi_device_path **file_path);

#define EFI_DP_TYPE(_dp, _type, _subtype) \
(((_dp)->type == DEVICE_PATH_TYPE_##_type) && \
((_dp)->sub_type == DEVICE_PATH_SUB_TYPE_##_subtype))

/* Convert strings from normal C strings to uEFI strings */
static inline void ascii2unicode(u16 *unicode, const char *ascii)
{
Expand Down
2 changes: 1 addition & 1 deletion lib/efi_loader/Makefile
Expand Up @@ -15,7 +15,7 @@ always := $(efiprogs-y)

obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o
obj-y += efi_image_loader.o efi_boottime.o efi_runtime.o efi_console.o
obj-y += efi_memory.o efi_device_path_to_text.o
obj-y += efi_memory.o efi_device_path_to_text.o efi_device_path.o
obj-$(CONFIG_LCD) += efi_gop.o
obj-$(CONFIG_DM_VIDEO) += efi_gop.o
obj-$(CONFIG_PARTITIONS) += efi_disk.o
Expand Down

0 comments on commit a00519e

Please sign in to comment.