xref: /illumos-gate/usr/src/boot/efi/include/efidevp.h (revision b62492765b5c32c36300b63e3e8107ccd93bd312)
1 /*
2  * Copyright (c)  1999 - 2002 Intel Corporation. All rights reserved
3  * This software and associated documentation (if any) is furnished
4  * under a license and may only be used or copied in accordance
5  * with the terms of the license. Except as permitted by such
6  * license, no part of this software or documentation may be
7  * reproduced, stored in a retrieval system, or transmitted in any
8  * form or by any means without the express written consent of
9  * Intel Corporation.
10  *
11  * Module Name:
12  *
13  *     devpath.h
14  *
15  * Abstract:
16  *
17  *     Defines for parsing the EFI Device Path structures
18  *
19  * Revision History
20  */
21 
22 #ifndef _DEVPATH_H
23 #define	_DEVPATH_H
24 
25 #include <Protocol/DevicePath.h>
26 
27 #define	EFI_DP_TYPE_MASK		0x7F
28 #define	EFI_DP_TYPE_UNPACKED		0x80
29 
30 #define	END_DEVICE_PATH_LENGTH		(sizeof (EFI_DEVICE_PATH))
31 
32 #define	DP_IS_END_TYPE(a)
33 #define	DP_IS_END_SUBTYPE(a)	\
34 	(((a)->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE)
35 
36 #define	DevicePathType(a)	(((a)->Type) & EFI_DP_TYPE_MASK)
37 #define	DevicePathSubType(a)	((a)->SubType)
38 #define	DevicePathNodeLength(a)	\
39 	((size_t)(((a)->Length[0]) |((a)->Length[1] << 8)))
40 #define	NextDevicePathNode(a)	\
41 	((EFI_DEVICE_PATH *)(((UINT8 *)(a)) + DevicePathNodeLength(a)))
42 #define	IsDevicePathType(a, t)	(DevicePathType(a) == t)
43 #define	IsDevicePathEndType(a)	IsDevicePathType(a, END_DEVICE_PATH_TYPE)
44 #define	IsDevicePathEndSubType(a)	\
45 	((a)->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE)
46 #define	IsDevicePathEnd(a)	\
47 	(IsDevicePathEndType(a) && IsDevicePathEndSubType(a))
48 #define	IsDevicePathUnpacked(a)	((a)->Type & EFI_DP_TYPE_UNPACKED)
49 
50 #define	SetDevicePathNodeLength(a, l) {                  \
51 		(a)->Length[0] = (UINT8)(l);               \
52 		(a)->Length[1] = (UINT8)((l) >> 8);        \
53 	}
54 
55 #define	SetDevicePathEndNode(a)  {                      \
56 		(a)->Type = END_DEVICE_PATH_TYPE;           \
57 		(a)->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE;     \
58 		(a)->Length[0] = sizeof (EFI_DEVICE_PATH);   \
59 		(a)->Length[1] = 0;                         \
60 	}
61 
62 #endif /* _DEVPATH_H */
63