Sound Open Firmware
Loading...
Searching...
No Matches
uuid.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 *
3 * Copyright(c) 2020 Intel Corporation. All rights reserved.
4 *
5 * Author: Marcin Maka <marcin.maka@linux.intel.com>
6 */
7
8#ifndef __SOF_LIB_UUID_H__
9#define __SOF_LIB_UUID_H__
10
11#include <sof/common.h>
12#include <uuid-registry.h>
13
14#ifdef __ZEPHYR__
15#include <zephyr/sys/iterable_sections.h>
16#endif
17
18#include <stdint.h>
19
24
26#define UUID_SIZE 16
27
29#define UUID_NAME_MAX_LEN 32
30
60struct sof_uuid {
61 uint32_t a;
62 uint16_t b;
63 uint16_t c;
64 uint8_t d[8];
66
67#define _UUID_INIT(va, vb, vc, d0, d1, d2, d3, d4, d5, d6, d7) \
68 { va, vb, vc, { d0, d1, d2, d3, d4, d5, d6, d7 } }
69
78 struct sof_uuid id;
80};
81
82#ifdef __ZEPHYR__
83/* Zephyr puts all the UUID structs into the firmware .rodata as an
84 * ITERABLE array. Note the alias emitted to get the typing correct,
85 * Zephyr defines the full suf_uuid_entry struct, where the API
86 * demands that the symbol name refer to a struct sof_uuid.
87 */
88#define _UUID(uuid_name) (&_##uuid_name)
89#define _RT_UUID(uuid_name) (&uuid_name)
90#define _DEF_UUID(entity_name, uuid_name, initializer) \
91 const STRUCT_SECTION_ITERABLE(sof_uuid_entry, _##uuid_name) = \
92 { .id = initializer, .name = entity_name }; \
93 extern const struct sof_uuid \
94 __attribute__((alias("_" #uuid_name))) uuid_name
95
96#else
97/* XTOS SOF emits two definitions, one into the runtime (which may not
98 * be linked if unreferenced) and a separate one that goes into a
99 * special section via handling in the linker script.
100 */
101#define _UUID(uuid_name) (&(uuid_name ## _ldc))
102#define _RT_UUID(uuid_name) (&(uuid_name))
103#define _DEF_UUID(entity_name, uuid_name, initializer) \
104 __section(".static_uuids") \
105 static const struct sof_uuid_entry uuid_name ## _ldc \
106 = { .id = initializer, .name = entity_name }; \
107 const struct sof_uuid uuid_name = initializer
108
109#endif /* __ZEPHYR__ */
110
130#define SOF_DEFINE_UUID(entity_name, uuid_name, va, vb, vc, \
131 vd0, vd1, vd2, vd3, vd4, vd5, vd6, vd7) \
132 _DEF_UUID(entity_name, uuid_name, \
133 _UUID_INIT(va, vb, vc, vd0, vd1, vd2, vd3, vd4, vd5, vd6, vd7))
134
141#define SOF_REG_UUID(name) _UUIDREG_##name
142
153#define SOF_DEFINE_REG_UUID(name) _DEF_UUID(#name, name##_uuid, SOF_REG_UUID(name))
154
164#define SOF_UUID(uuid_name) _UUID(uuid_name)
165
170#define SOF_RT_UUID(uuid_name) _RT_UUID(uuid_name)
171
173
174#endif /* __SOF_LIB_UUID_H__ */
#define __packed
Definition ext_manifest.h:43
#define UUID_NAME_MAX_LEN
UUID name string max length in bytes, including null termination.
Definition uuid.h:29
Connects UUID with component description.
Definition uuid.h:77
const char name[UUID_NAME_MAX_LEN]
Definition uuid.h:79
struct sof_uuid id
Definition uuid.h:78
UUID (Universally Unique IDentifier) structure.
Definition uuid.h:60
uint16_t b
Definition uuid.h:62
uint8_t d[8]
Definition uuid.h:64
uint16_t c
Definition uuid.h:63
uint32_t a
Definition uuid.h:61