Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Przemyslaw Marczak | 0c81336 | 2014-04-02 10:20:03 +0200 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2014 Samsung Electronics |
| 4 | * Przemyslaw Marczak <p.marczak@samsung.com> |
Przemyslaw Marczak | 0c81336 | 2014-04-02 10:20:03 +0200 | [diff] [blame] | 5 | */ |
| 6 | #ifndef __UUID_H__ |
| 7 | #define __UUID_H__ |
| 8 | |
Przemyslaw Marczak | b428514 | 2014-04-02 10:20:04 +0200 | [diff] [blame] | 9 | /* This is structure is in big-endian */ |
| 10 | struct uuid { |
| 11 | unsigned int time_low; |
| 12 | unsigned short time_mid; |
| 13 | unsigned short time_hi_and_version; |
| 14 | unsigned char clock_seq_hi_and_reserved; |
| 15 | unsigned char clock_seq_low; |
| 16 | unsigned char node[6]; |
| 17 | } __packed; |
| 18 | |
Przemyslaw Marczak | 0c81336 | 2014-04-02 10:20:03 +0200 | [diff] [blame] | 19 | enum { |
| 20 | UUID_STR_FORMAT_STD, |
| 21 | UUID_STR_FORMAT_GUID |
| 22 | }; |
| 23 | |
| 24 | #define UUID_STR_LEN 36 |
Przemyslaw Marczak | b428514 | 2014-04-02 10:20:04 +0200 | [diff] [blame] | 25 | #define UUID_BIN_LEN sizeof(struct uuid) |
| 26 | |
| 27 | #define UUID_VERSION_MASK 0xf000 |
| 28 | #define UUID_VERSION_SHIFT 12 |
| 29 | #define UUID_VERSION 0x4 |
| 30 | |
| 31 | #define UUID_VARIANT_MASK 0xc0 |
| 32 | #define UUID_VARIANT_SHIFT 7 |
| 33 | #define UUID_VARIANT 0x1 |
Przemyslaw Marczak | 0c81336 | 2014-04-02 10:20:03 +0200 | [diff] [blame] | 34 | |
| 35 | int uuid_str_valid(const char *uuid); |
| 36 | int uuid_str_to_bin(char *uuid_str, unsigned char *uuid_bin, int str_format); |
| 37 | void uuid_bin_to_str(unsigned char *uuid_bin, char *uuid_str, int str_format); |
Patrick Delaunay | 65f94ed | 2015-10-27 11:00:28 +0100 | [diff] [blame] | 38 | #ifdef CONFIG_PARTITION_TYPE_GUID |
| 39 | int uuid_guid_get_bin(const char *guid_str, unsigned char *guid_bin); |
| 40 | int uuid_guid_get_str(unsigned char *guid_bin, char *guid_str); |
| 41 | #endif |
Przemyslaw Marczak | b428514 | 2014-04-02 10:20:04 +0200 | [diff] [blame] | 42 | void gen_rand_uuid(unsigned char *uuid_bin); |
| 43 | void gen_rand_uuid_str(char *uuid_str, int str_format); |
Przemyslaw Marczak | 0c81336 | 2014-04-02 10:20:03 +0200 | [diff] [blame] | 44 | #endif |