efivar-dp.h revision 318576
113459Sbde/*-
213436Sphk * Copyright (c) 2017 Netflix, Inc.
313436Sphk * All rights reserved.
413436Sphk *
513436Sphk * Redistribution and use in source and binary forms, with or without
613459Sbde * modification, are permitted provided that the following conditions
713436Sphk * are met:
813459Sbde * 1. Redistributions of source code must retain the above copyright
913459Sbde *    notice, this list of conditions and the following disclaimer
1013459Sbde *    in this position and unchanged.
1113459Sbde * 2. Redistributions in binary form must reproduce the above copyright
1213459Sbde *    notice, this list of conditions and the following disclaimer in the
1313459Sbde *    documentation and/or other materials provided with the distribution.
1413459Sbde *
1513459Sbde * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1613459Sbde * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1713459Sbde * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1813459Sbde * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
1913436Sphk * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2013436Sphk * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2113459Sbde * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2213459Sbde * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2313459Sbde * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2413459Sbde * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2513459Sbde *
2613459Sbde * $FreeBSD: stable/11/lib/libefivar/efivar-dp.h 318576 2017-05-20 16:12:44Z kib $
2713459Sbde */
2813459Sbde
2913459Sbde#ifndef	_EFIVAR_DP_H_
3013459Sbde#define	_EFIVAR_DP_H_
3113459Sbde
3213436Sphk/*
3313436Sphk * "Linux compatible" efivar-dp.h header. At the moment, it's really a
3413459Sbde * very thin, minimal interface.
35 */
36
37/*
38 * Generic EFI_DEVICE_PATH, spelled the Linux way. We use this
39 * interface to the outside world and type-pun to the EFI EDK2 code
40 * we use to implement it.
41 */
42typedef struct {
43	uint8_t type;
44	uint8_t subtype;
45	uint16_t length;
46} __packed efidp_header;
47
48/* NB: Linux has shadow types for all dp type */
49
50typedef union {
51        efidp_header header;
52} efidp_data;
53typedef efidp_data *efidp;
54typedef const efidp_data *const_efidp;
55
56/** format a device path into UEFI standard conforming output.
57 *
58 * NB: FreeBSD's implementation is taken from EDK2, while Linux's
59 * was hand-rolled. There may be differences as a result.
60 */
61ssize_t efidp_format_device_path(char *buf, size_t len, const_efidp dp,
62    ssize_t max);
63ssize_t efidp_parse_device_path(char *path, efidp out, size_t max);
64
65#endif /* _EFIVAR_DP_H_ */
66