/*-1* Copyright (c) 2017 Netflix, Inc.2*3* Redistribution and use in source and binary forms, with or without4* modification, are permitted provided that the following conditions5* are met:6* 1. Redistributions of source code must retain the above copyright7* notice, this list of conditions and the following disclaimer.8* 2. Redistributions in binary form must reproduce the above copyright9* notice, this list of conditions and the following disclaimer in the10* documentation and/or other materials provided with the distribution.11*12* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND13* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE14* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE15* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE16* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL17* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS18* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)19* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT20* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY21* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF22* SUCH DAMAGE.23*/2425#ifndef _EFIVAR_DP_H_26#define _EFIVAR_DP_H_2728/*29* "Linux compatible" efivar-dp.h header. At the moment, it's really a30* very thin, minimal interface.31*/3233/*34* Generic EFI_DEVICE_PATH, spelled the Linux way. We use this35* interface to the outside world and type-pun to the EFI EDK2 code36* we use to implement it.37*/38typedef struct {39uint8_t type;40uint8_t subtype;41uint16_t length;42} __packed efidp_header;4344/* NB: Linux has shadow types for all dp type */4546typedef union {47efidp_header header;48} efidp_data;49typedef efidp_data *efidp;50typedef const efidp_data *const_efidp;5152/** format a device path into UEFI standard conforming output.53*54* NB: FreeBSD's implementation is taken from EDK2, while Linux's55* was hand-rolled. There may be differences as a result.56*/57ssize_t efidp_format_device_path(char *buf, size_t len, const_efidp dp,58ssize_t max);59ssize_t efidp_format_device_path_node(char *buf, size_t len, const_efidp dp);60ssize_t efidp_parse_device_path(char *path, efidp out, size_t max);61char * efidp_extract_file_path(const_efidp dp);6263size_t efidp_size(const_efidp);6465int efivar_device_path_to_unix_path(const_efidp dp, char **dev, char **relpath, char **abspath);66int efivar_unix_path_to_device_path(const char *path, efidp *dp);6768#endif /* _EFIVAR_DP_H_ */697071