173bbca04SBob Moore /****************************************************************************** 273bbca04SBob Moore * 373bbca04SBob Moore * Module Name: utuuid -- UUID support functions 473bbca04SBob Moore * 573bbca04SBob Moore *****************************************************************************/ 673bbca04SBob Moore 773bbca04SBob Moore /* 882a80941SDavid E. Box * Copyright (C) 2000 - 2015, Intel Corp. 973bbca04SBob Moore * All rights reserved. 1073bbca04SBob Moore * 1173bbca04SBob Moore * Redistribution and use in source and binary forms, with or without 1273bbca04SBob Moore * modification, are permitted provided that the following conditions 1373bbca04SBob Moore * are met: 1473bbca04SBob Moore * 1. Redistributions of source code must retain the above copyright 1573bbca04SBob Moore * notice, this list of conditions, and the following disclaimer, 1673bbca04SBob Moore * without modification. 1773bbca04SBob Moore * 2. Redistributions in binary form must reproduce at minimum a disclaimer 1873bbca04SBob Moore * substantially similar to the "NO WARRANTY" disclaimer below 1973bbca04SBob Moore * ("Disclaimer") and any redistribution must be conditioned upon 2073bbca04SBob Moore * including a substantially similar Disclaimer requirement for further 2173bbca04SBob Moore * binary redistribution. 2273bbca04SBob Moore * 3. Neither the names of the above-listed copyright holders nor the names 2373bbca04SBob Moore * of any contributors may be used to endorse or promote products derived 2473bbca04SBob Moore * from this software without specific prior written permission. 2573bbca04SBob Moore * 2673bbca04SBob Moore * Alternatively, this software may be distributed under the terms of the 2773bbca04SBob Moore * GNU General Public License ("GPL") version 2 as published by the Free 2873bbca04SBob Moore * Software Foundation. 2973bbca04SBob Moore * 3073bbca04SBob Moore * NO WARRANTY 3173bbca04SBob Moore * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 3273bbca04SBob Moore * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 3373bbca04SBob Moore * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 3473bbca04SBob Moore * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 3573bbca04SBob Moore * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3673bbca04SBob Moore * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3773bbca04SBob Moore * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3873bbca04SBob Moore * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 3973bbca04SBob Moore * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 4073bbca04SBob Moore * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 4173bbca04SBob Moore * POSSIBILITY OF SUCH DAMAGES. 4273bbca04SBob Moore */ 4373bbca04SBob Moore 4473bbca04SBob Moore #include <acpi/acpi.h> 4573bbca04SBob Moore #include "accommon.h" 4673bbca04SBob Moore 4773bbca04SBob Moore #define _COMPONENT ACPI_COMPILER 4873bbca04SBob Moore ACPI_MODULE_NAME("utuuid") 4973bbca04SBob Moore 506306bf88SLv Zheng #if (defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP || defined ACPI_HELP_APP) 5173bbca04SBob Moore /* 5273bbca04SBob Moore * UUID support functions. 5373bbca04SBob Moore * 5473bbca04SBob Moore * This table is used to convert an input UUID ascii string to a 16 byte 5573bbca04SBob Moore * buffer and the reverse. The table maps a UUID buffer index 0-15 to 5673bbca04SBob Moore * the index within the 36-byte UUID string where the associated 2-byte 5773bbca04SBob Moore * hex value can be found. 5873bbca04SBob Moore * 5973bbca04SBob Moore * 36-byte UUID strings are of the form: 6073bbca04SBob Moore * aabbccdd-eeff-gghh-iijj-kkllmmnnoopp 6173bbca04SBob Moore * Where aa-pp are one byte hex numbers, made up of two hex digits 6273bbca04SBob Moore * 6373bbca04SBob Moore * Note: This table is basically the inverse of the string-to-offset table 6473bbca04SBob Moore * found in the ACPI spec in the description of the to_UUID macro. 6573bbca04SBob Moore */ 6673bbca04SBob Moore const u8 acpi_gbl_map_to_uuid_offset[UUID_BUFFER_LENGTH] = { 6773bbca04SBob Moore 6, 4, 2, 0, 11, 9, 16, 14, 19, 21, 24, 26, 28, 30, 32, 34 6873bbca04SBob Moore }; 6973bbca04SBob Moore 7073bbca04SBob Moore /******************************************************************************* 7173bbca04SBob Moore * 7273bbca04SBob Moore * FUNCTION: acpi_ut_convert_string_to_uuid 7373bbca04SBob Moore * 7473bbca04SBob Moore * PARAMETERS: in_string - 36-byte formatted UUID string 7573bbca04SBob Moore * uuid_buffer - Where the 16-byte UUID buffer is returned 7673bbca04SBob Moore * 7773bbca04SBob Moore * RETURN: None. Output data is returned in the uuid_buffer 7873bbca04SBob Moore * 7973bbca04SBob Moore * DESCRIPTION: Convert a 36-byte formatted UUID string to 16-byte UUID buffer 8073bbca04SBob Moore * 8173bbca04SBob Moore ******************************************************************************/ 8273bbca04SBob Moore 8373bbca04SBob Moore void acpi_ut_convert_string_to_uuid(char *in_string, u8 *uuid_buffer) 8473bbca04SBob Moore { 8573bbca04SBob Moore u32 i; 8673bbca04SBob Moore 8773bbca04SBob Moore for (i = 0; i < UUID_BUFFER_LENGTH; i++) { 8873bbca04SBob Moore uuid_buffer[i] = 8973bbca04SBob Moore (acpi_ut_ascii_char_to_hex 9073bbca04SBob Moore (in_string[acpi_gbl_map_to_uuid_offset[i]]) << 4); 9173bbca04SBob Moore 9273bbca04SBob Moore uuid_buffer[i] |= 9373bbca04SBob Moore acpi_ut_ascii_char_to_hex(in_string 9473bbca04SBob Moore [acpi_gbl_map_to_uuid_offset[i] + 9573bbca04SBob Moore 1]); 9673bbca04SBob Moore } 9773bbca04SBob Moore } 986306bf88SLv Zheng #endif 99