]> git.ipfire.org Git - thirdparty/u-boot.git/blame - include/uuid.h
Merge branch '2020-05-15-misc-bugfixes'
[thirdparty/u-boot.git] / include / uuid.h
CommitLineData
83d290c5 1/* SPDX-License-Identifier: GPL-2.0+ */
d718ded0
PM
2/*
3 * Copyright (C) 2014 Samsung Electronics
4 * Przemyslaw Marczak <p.marczak@samsung.com>
d718ded0
PM
5 */
6#ifndef __UUID_H__
7#define __UUID_H__
8
3bad256f
HS
9#include <linux/bitops.h>
10
4e4815fe
PM
11/* This is structure is in big-endian */
12struct uuid {
13 unsigned int time_low;
14 unsigned short time_mid;
15 unsigned short time_hi_and_version;
16 unsigned char clock_seq_hi_and_reserved;
17 unsigned char clock_seq_low;
18 unsigned char node[6];
19} __packed;
20
3bad256f
HS
21/* Bits of a bitmask specifying the output format for GUIDs */
22#define UUID_STR_FORMAT_STD 0
23#define UUID_STR_FORMAT_GUID BIT(0)
24#define UUID_STR_UPPER_CASE BIT(1)
d718ded0
PM
25
26#define UUID_STR_LEN 36
4e4815fe
PM
27#define UUID_BIN_LEN sizeof(struct uuid)
28
29#define UUID_VERSION_MASK 0xf000
30#define UUID_VERSION_SHIFT 12
31#define UUID_VERSION 0x4
32
33#define UUID_VARIANT_MASK 0xc0
34#define UUID_VARIANT_SHIFT 7
35#define UUID_VARIANT 0x1
d718ded0
PM
36
37int uuid_str_valid(const char *uuid);
2c2ca207
SG
38int uuid_str_to_bin(const char *uuid_str, unsigned char *uuid_bin,
39 int str_format);
40void uuid_bin_to_str(const unsigned char *uuid_bin, char *uuid_str,
41 int str_format);
bcb41dca
PD
42#ifdef CONFIG_PARTITION_TYPE_GUID
43int uuid_guid_get_bin(const char *guid_str, unsigned char *guid_bin);
2c2ca207 44int uuid_guid_get_str(const unsigned char *guid_bin, char *guid_str);
bcb41dca 45#endif
4e4815fe
PM
46void gen_rand_uuid(unsigned char *uuid_bin);
47void gen_rand_uuid_str(char *uuid_str, int str_format);
d718ded0 48#endif