/* * SPDX-FileCopyrightText: 2022 Unisoc (Shanghai) Technologies Co., Ltd * SPDX-License-Identifier: LicenseRef-Unisoc-General-1.0 * * Copyright 2022 Unisoc (Shanghai) Technologies Co., Ltd. * * Licensed under the Unisoc General Software License, version 1.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.unisoc.com/en_us/license/UNISOC_GENERAL_LICENSE_V1.0-EN_US * * Software distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OF ANY KIND, either express or implied. * See the Unisoc General Software License, version 1.0 for more details. */ #include #include #define SHIFT_U32(v, shift) ((uint32_t)(v) << (shift)) void tee_uuid_to_octets(uint8_t *d, const gptee_uuid_t *s) { d[0] = s->time_low >> 24; d[1] = s->time_low >> 16; d[2] = s->time_low >> 8; d[3] = s->time_low; d[4] = s->time_mid >> 8; d[5] = s->time_mid; d[6] = s->time_hi_and_version >> 8; d[7] = s->time_hi_and_version; memcpy(d + 8, s->clock_seq_and_node, sizeof(s->clock_seq_and_node)); } void tee_uuid_from_octets(gptee_uuid_t *d, const uint8_t *s) { d->time_low = SHIFT_U32(s[0], 24) | SHIFT_U32(s[1], 16) | SHIFT_U32(s[2], 8) | s[3]; d->time_mid = SHIFT_U32(s[4], 8) | s[5]; d->time_hi_and_version = SHIFT_U32(s[6], 8) | s[7]; memcpy(d->clock_seq_and_node, s + 8, sizeof(d->clock_seq_and_node)); }