]> git.ipfire.org Git - people/ms/u-boot.git/blame - include/uuid.h
dfu: Fix up the Kconfig mess
[people/ms/u-boot.git] / include / uuid.h
CommitLineData
d718ded0
PM
1/*
2 * Copyright (C) 2014 Samsung Electronics
3 * Przemyslaw Marczak <p.marczak@samsung.com>
4 *
5 * SPDX-License-Identifier: GPL-2.0+
6 */
7#ifndef __UUID_H__
8#define __UUID_H__
9
4e4815fe
PM
10/* This is structure is in big-endian */
11struct uuid {
12 unsigned int time_low;
13 unsigned short time_mid;
14 unsigned short time_hi_and_version;
15 unsigned char clock_seq_hi_and_reserved;
16 unsigned char clock_seq_low;
17 unsigned char node[6];
18} __packed;
19
d718ded0
PM
20enum {
21 UUID_STR_FORMAT_STD,
22 UUID_STR_FORMAT_GUID
23};
24
25#define UUID_STR_LEN 36
4e4815fe
PM
26#define UUID_BIN_LEN sizeof(struct uuid)
27
28#define UUID_VERSION_MASK 0xf000
29#define UUID_VERSION_SHIFT 12
30#define UUID_VERSION 0x4
31
32#define UUID_VARIANT_MASK 0xc0
33#define UUID_VARIANT_SHIFT 7
34#define UUID_VARIANT 0x1
d718ded0
PM
35
36int uuid_str_valid(const char *uuid);
37int uuid_str_to_bin(char *uuid_str, unsigned char *uuid_bin, int str_format);
38void uuid_bin_to_str(unsigned char *uuid_bin, char *uuid_str, int str_format);
bcb41dca
PD
39#ifdef CONFIG_PARTITION_TYPE_GUID
40int uuid_guid_get_bin(const char *guid_str, unsigned char *guid_bin);
41int uuid_guid_get_str(unsigned char *guid_bin, char *guid_str);
42#endif
4e4815fe
PM
43void gen_rand_uuid(unsigned char *uuid_bin);
44void gen_rand_uuid_str(char *uuid_str, int str_format);
d718ded0 45#endif