xref: /illumos-gate/usr/src/boot/efi/include/efidevp.h (revision f334afcf)
1*f334afcfSToomas Soome /*
2*f334afcfSToomas Soome  * Copyright (c)  1999 - 2002 Intel Corporation. All rights reserved
3*f334afcfSToomas Soome  * This software and associated documentation (if any) is furnished
4*f334afcfSToomas Soome  * under a license and may only be used or copied in accordance
5*f334afcfSToomas Soome  * with the terms of the license. Except as permitted by such
6*f334afcfSToomas Soome  * license, no part of this software or documentation may be
7*f334afcfSToomas Soome  * reproduced, stored in a retrieval system, or transmitted in any
8*f334afcfSToomas Soome  * form or by any means without the express written consent of
9*f334afcfSToomas Soome  * Intel Corporation.
10*f334afcfSToomas Soome  *
11*f334afcfSToomas Soome  * Module Name:
12*f334afcfSToomas Soome  *
13*f334afcfSToomas Soome  *     devpath.h
14*f334afcfSToomas Soome  *
15*f334afcfSToomas Soome  * Abstract:
16*f334afcfSToomas Soome  *
17*f334afcfSToomas Soome  *     Defines for parsing the EFI Device Path structures
18*f334afcfSToomas Soome  *
19*f334afcfSToomas Soome  * Revision History
20*f334afcfSToomas Soome  */
21*f334afcfSToomas Soome 
2222028508SToomas Soome #ifndef _DEVPATH_H
2322028508SToomas Soome #define	_DEVPATH_H
2422028508SToomas Soome 
25*f334afcfSToomas Soome #include <Protocol/DevicePath.h>
2622028508SToomas Soome 
2722028508SToomas Soome #define	EFI_DP_TYPE_MASK		0x7F
2822028508SToomas Soome #define	EFI_DP_TYPE_UNPACKED		0x80
2922028508SToomas Soome 
3022028508SToomas Soome #define	END_DEVICE_PATH_LENGTH		(sizeof (EFI_DEVICE_PATH))
3122028508SToomas Soome 
3222028508SToomas Soome #define	DP_IS_END_TYPE(a)
33*f334afcfSToomas Soome #define	DP_IS_END_SUBTYPE(a)	\
34*f334afcfSToomas Soome 	(((a)->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE)
3522028508SToomas Soome 
3622028508SToomas Soome #define	DevicePathType(a)	(((a)->Type) & EFI_DP_TYPE_MASK)
3722028508SToomas Soome #define	DevicePathSubType(a)	((a)->SubType)
38*f334afcfSToomas Soome #define	DevicePathNodeLength(a)	\
39*f334afcfSToomas Soome 	((size_t)(((a)->Length[0]) |((a)->Length[1] << 8)))
40*f334afcfSToomas Soome #define	NextDevicePathNode(a)	\
41*f334afcfSToomas Soome 	((EFI_DEVICE_PATH *)(((UINT8 *)(a)) + DevicePathNodeLength(a)))
4222028508SToomas Soome #define	IsDevicePathType(a, t)	(DevicePathType(a) == t)
4322028508SToomas Soome #define	IsDevicePathEndType(a)	IsDevicePathType(a, END_DEVICE_PATH_TYPE)
44*f334afcfSToomas Soome #define	IsDevicePathEndSubType(a)	\
45*f334afcfSToomas Soome 	((a)->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE)
46*f334afcfSToomas Soome #define	IsDevicePathEnd(a)	\
47*f334afcfSToomas Soome 	(IsDevicePathEndType(a) && IsDevicePathEndSubType(a))
4822028508SToomas Soome #define	IsDevicePathUnpacked(a)	((a)->Type & EFI_DP_TYPE_UNPACKED)
4922028508SToomas Soome 
5022028508SToomas Soome #define	SetDevicePathNodeLength(a, l) {                  \
5122028508SToomas Soome 		(a)->Length[0] = (UINT8)(l);               \
5222028508SToomas Soome 		(a)->Length[1] = (UINT8)((l) >> 8);        \
5322028508SToomas Soome 	}
5422028508SToomas Soome 
5522028508SToomas Soome #define	SetDevicePathEndNode(a)  {                      \
5622028508SToomas Soome 		(a)->Type = END_DEVICE_PATH_TYPE;           \
5722028508SToomas Soome 		(a)->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE;     \
5822028508SToomas Soome 		(a)->Length[0] = sizeof (EFI_DEVICE_PATH);   \
5922028508SToomas Soome 		(a)->Length[1] = 0;                         \
6022028508SToomas Soome 	}
6122028508SToomas Soome 
62*f334afcfSToomas Soome #endif /* _DEVPATH_H */
63