]> glassweightruler.freedombox.rocks Git - Ventoy.git/blob - wimboot/wimboot-2.7.3/src/efipath.h
1.1.07 release
[Ventoy.git] / wimboot / wimboot-2.7.3 / src / efipath.h
1 #ifndef _EFIPATH_H
2 #define _EFIPATH_H
3
4 /*
5 * Copyright (C) 2014 Michael Brown <mbrown@fensystems.co.uk>.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 */
22
23 /**
24 * @file
25 *
26 * EFI device paths
27 *
28 */
29
30 #include "efi.h"
31 #include "efi/Protocol/DevicePath.h"
32
33 /**
34 * Initialise device path
35 *
36 * @v name Variable name
37 * @v type Type
38 * @v subtype Subtype
39 */
40 #define EFI_DEVPATH_INIT( name, type, subtype ) { \
41 .Type = (type), \
42 .SubType = (subtype), \
43 .Length[0] = ( sizeof (name) & 0xff ), \
44 .Length[1] = ( sizeof (name) >> 8 ), \
45 }
46
47 /**
48 * Initialise device path
49 *
50 * @v path Device path
51 * @v type Type
52 * @v subtype Subtype
53 * @v len Length
54 */
55 static inline __attribute__ (( always_inline )) void
56 efi_devpath_init ( EFI_DEVICE_PATH_PROTOCOL *path, unsigned int type,
57 unsigned int subtype, size_t len ) {
58
59 path->Type = type;
60 path->SubType = subtype;
61 path->Length[0] = ( len & 0xff );
62 path->Length[1] = ( len >> 8 );
63 }
64
65 /**
66 * Initialise device path end
67 *
68 * @v name Variable name
69 */
70 #define EFI_DEVPATH_END_INIT( name ) \
71 EFI_DEVPATH_INIT ( name, END_DEVICE_PATH_TYPE, \
72 END_ENTIRE_DEVICE_PATH_SUBTYPE )
73
74 /**
75 * Initialise device path end
76 *
77 * @v path Device path
78 */
79 static inline __attribute__ (( always_inline )) void
80 efi_devpath_end_init ( EFI_DEVICE_PATH_PROTOCOL *path ) {
81
82 efi_devpath_init ( path, END_DEVICE_PATH_TYPE,
83 END_ENTIRE_DEVICE_PATH_SUBTYPE, sizeof ( *path ) );
84 }
85
86 extern EFI_DEVICE_PATH_PROTOCOL *
87 efi_devpath_end ( EFI_DEVICE_PATH_PROTOCOL *path );
88
89 #endif /* _EFIPATH_H */