Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / ipxe / src / include / ipxe / uuid.h
1 #ifndef _IPXE_UUID_H
2 #define _IPXE_UUID_H
3
4 /** @file
5  *
6  * Universally unique IDs
7  */
8
9 FILE_LICENCE ( GPL2_OR_LATER );
10
11 #include <stdint.h>
12 #include <byteswap.h>
13
14 /** A universally unique ID */
15 union uuid {
16         /** Canonical form (00000000-0000-0000-0000-000000000000) */
17         struct {
18                 /** 8 hex digits, big-endian */
19                 uint32_t a;
20                 /** 2 hex digits, big-endian */
21                 uint16_t b;
22                 /** 2 hex digits, big-endian */
23                 uint16_t c;
24                 /** 2 hex digits, big-endian */
25                 uint16_t d;
26                 /** 12 hex digits, big-endian */
27                 uint8_t e[6];
28         } canonical;
29         uint8_t raw[16];
30 };
31
32 /**
33  * Change UUID endianness
34  *
35  * @v uuid              UUID
36  *
37  * RFC4122 defines UUIDs as being encoded in network byte order, but
38  * leaves some wriggle room for "explicit application or presentation
39  * protocol specification to the contrary".  PXE, EFI and SMBIOS
40  * (versions 2.6 and above) treat the first three fields as being
41  * little-endian.
42  */
43 static inline void uuid_mangle ( union uuid *uuid ) {
44
45         __bswap_32s ( &uuid->canonical.a );
46         __bswap_16s ( &uuid->canonical.b );
47         __bswap_16s ( &uuid->canonical.c );
48 }
49
50 extern char * uuid_ntoa ( const union uuid *uuid );
51
52 #endif /* _IPXE_UUID_H */