195857638SErik Schmauss // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 273bbca04SBob Moore /****************************************************************************** 373bbca04SBob Moore * 473bbca04SBob Moore * Module Name: utuuid -- UUID support functions 573bbca04SBob Moore * 6da6f8320SBob Moore * Copyright (C) 2000 - 2018, Intel Corp. 773bbca04SBob Moore * 895857638SErik Schmauss *****************************************************************************/ 973bbca04SBob Moore 1073bbca04SBob Moore #include <acpi/acpi.h> 1173bbca04SBob Moore #include "accommon.h" 1273bbca04SBob Moore 1373bbca04SBob Moore #define _COMPONENT ACPI_COMPILER 1473bbca04SBob Moore ACPI_MODULE_NAME("utuuid") 1573bbca04SBob Moore 166306bf88SLv Zheng #if (defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP || defined ACPI_HELP_APP) 1773bbca04SBob Moore /* 1873bbca04SBob Moore * UUID support functions. 1973bbca04SBob Moore * 2073bbca04SBob Moore * This table is used to convert an input UUID ascii string to a 16 byte 2173bbca04SBob Moore * buffer and the reverse. The table maps a UUID buffer index 0-15 to 2273bbca04SBob Moore * the index within the 36-byte UUID string where the associated 2-byte 2373bbca04SBob Moore * hex value can be found. 2473bbca04SBob Moore * 2573bbca04SBob Moore * 36-byte UUID strings are of the form: 2673bbca04SBob Moore * aabbccdd-eeff-gghh-iijj-kkllmmnnoopp 2773bbca04SBob Moore * Where aa-pp are one byte hex numbers, made up of two hex digits 2873bbca04SBob Moore * 2973bbca04SBob Moore * Note: This table is basically the inverse of the string-to-offset table 3073bbca04SBob Moore * found in the ACPI spec in the description of the to_UUID macro. 3173bbca04SBob Moore */ 3273bbca04SBob Moore const u8 acpi_gbl_map_to_uuid_offset[UUID_BUFFER_LENGTH] = { 3373bbca04SBob Moore 6, 4, 2, 0, 11, 9, 16, 14, 19, 21, 24, 26, 28, 30, 32, 34 3473bbca04SBob Moore }; 3573bbca04SBob Moore 3673bbca04SBob Moore /******************************************************************************* 3773bbca04SBob Moore * 3873bbca04SBob Moore * FUNCTION: acpi_ut_convert_string_to_uuid 3973bbca04SBob Moore * 4073bbca04SBob Moore * PARAMETERS: in_string - 36-byte formatted UUID string 4173bbca04SBob Moore * uuid_buffer - Where the 16-byte UUID buffer is returned 4273bbca04SBob Moore * 4373bbca04SBob Moore * RETURN: None. Output data is returned in the uuid_buffer 4473bbca04SBob Moore * 4573bbca04SBob Moore * DESCRIPTION: Convert a 36-byte formatted UUID string to 16-byte UUID buffer 4673bbca04SBob Moore * 4773bbca04SBob Moore ******************************************************************************/ 4873bbca04SBob Moore 4973bbca04SBob Moore void acpi_ut_convert_string_to_uuid(char *in_string, u8 *uuid_buffer) 5073bbca04SBob Moore { 5173bbca04SBob Moore u32 i; 5273bbca04SBob Moore 5373bbca04SBob Moore for (i = 0; i < UUID_BUFFER_LENGTH; i++) { 5473bbca04SBob Moore uuid_buffer[i] = 5573bbca04SBob Moore (acpi_ut_ascii_char_to_hex 5673bbca04SBob Moore (in_string[acpi_gbl_map_to_uuid_offset[i]]) << 4); 5773bbca04SBob Moore 5873bbca04SBob Moore uuid_buffer[i] |= 5973bbca04SBob Moore acpi_ut_ascii_char_to_hex(in_string 6073bbca04SBob Moore [acpi_gbl_map_to_uuid_offset[i] + 6173bbca04SBob Moore 1]); 6273bbca04SBob Moore } 6373bbca04SBob Moore } 646306bf88SLv Zheng #endif 65