1*385cc6b4SJerry Jelinek /****************************************************************************** 2*385cc6b4SJerry Jelinek * 3*385cc6b4SJerry Jelinek * Module Name: utuuid -- UUID support functions 4*385cc6b4SJerry Jelinek * 5*385cc6b4SJerry Jelinek *****************************************************************************/ 6*385cc6b4SJerry Jelinek 7*385cc6b4SJerry Jelinek /* 8*385cc6b4SJerry Jelinek * Copyright (C) 2000 - 2016, Intel Corp. 9*385cc6b4SJerry Jelinek * All rights reserved. 10*385cc6b4SJerry Jelinek * 11*385cc6b4SJerry Jelinek * Redistribution and use in source and binary forms, with or without 12*385cc6b4SJerry Jelinek * modification, are permitted provided that the following conditions 13*385cc6b4SJerry Jelinek * are met: 14*385cc6b4SJerry Jelinek * 1. Redistributions of source code must retain the above copyright 15*385cc6b4SJerry Jelinek * notice, this list of conditions, and the following disclaimer, 16*385cc6b4SJerry Jelinek * without modification. 17*385cc6b4SJerry Jelinek * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18*385cc6b4SJerry Jelinek * substantially similar to the "NO WARRANTY" disclaimer below 19*385cc6b4SJerry Jelinek * ("Disclaimer") and any redistribution must be conditioned upon 20*385cc6b4SJerry Jelinek * including a substantially similar Disclaimer requirement for further 21*385cc6b4SJerry Jelinek * binary redistribution. 22*385cc6b4SJerry Jelinek * 3. Neither the names of the above-listed copyright holders nor the names 23*385cc6b4SJerry Jelinek * of any contributors may be used to endorse or promote products derived 24*385cc6b4SJerry Jelinek * from this software without specific prior written permission. 25*385cc6b4SJerry Jelinek * 26*385cc6b4SJerry Jelinek * Alternatively, this software may be distributed under the terms of the 27*385cc6b4SJerry Jelinek * GNU General Public License ("GPL") version 2 as published by the Free 28*385cc6b4SJerry Jelinek * Software Foundation. 29*385cc6b4SJerry Jelinek * 30*385cc6b4SJerry Jelinek * NO WARRANTY 31*385cc6b4SJerry Jelinek * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32*385cc6b4SJerry Jelinek * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33*385cc6b4SJerry Jelinek * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34*385cc6b4SJerry Jelinek * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35*385cc6b4SJerry Jelinek * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36*385cc6b4SJerry Jelinek * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37*385cc6b4SJerry Jelinek * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38*385cc6b4SJerry Jelinek * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39*385cc6b4SJerry Jelinek * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40*385cc6b4SJerry Jelinek * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41*385cc6b4SJerry Jelinek * POSSIBILITY OF SUCH DAMAGES. 42*385cc6b4SJerry Jelinek */ 43*385cc6b4SJerry Jelinek 44*385cc6b4SJerry Jelinek #include "acpi.h" 45*385cc6b4SJerry Jelinek #include "accommon.h" 46*385cc6b4SJerry Jelinek 47*385cc6b4SJerry Jelinek #define _COMPONENT ACPI_COMPILER 48*385cc6b4SJerry Jelinek ACPI_MODULE_NAME ("utuuid") 49*385cc6b4SJerry Jelinek 50*385cc6b4SJerry Jelinek 51*385cc6b4SJerry Jelinek #if (defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP || defined ACPI_HELP_APP) 52*385cc6b4SJerry Jelinek /* 53*385cc6b4SJerry Jelinek * UUID support functions. 54*385cc6b4SJerry Jelinek * 55*385cc6b4SJerry Jelinek * This table is used to convert an input UUID ascii string to a 16 byte 56*385cc6b4SJerry Jelinek * buffer and the reverse. The table maps a UUID buffer index 0-15 to 57*385cc6b4SJerry Jelinek * the index within the 36-byte UUID string where the associated 2-byte 58*385cc6b4SJerry Jelinek * hex value can be found. 59*385cc6b4SJerry Jelinek * 60*385cc6b4SJerry Jelinek * 36-byte UUID strings are of the form: 61*385cc6b4SJerry Jelinek * aabbccdd-eeff-gghh-iijj-kkllmmnnoopp 62*385cc6b4SJerry Jelinek * Where aa-pp are one byte hex numbers, made up of two hex digits 63*385cc6b4SJerry Jelinek * 64*385cc6b4SJerry Jelinek * Note: This table is basically the inverse of the string-to-offset table 65*385cc6b4SJerry Jelinek * found in the ACPI spec in the description of the ToUUID macro. 66*385cc6b4SJerry Jelinek */ 67*385cc6b4SJerry Jelinek const UINT8 AcpiGbl_MapToUuidOffset[UUID_BUFFER_LENGTH] = 68*385cc6b4SJerry Jelinek { 69*385cc6b4SJerry Jelinek 6,4,2,0,11,9,16,14,19,21,24,26,28,30,32,34 70*385cc6b4SJerry Jelinek }; 71*385cc6b4SJerry Jelinek 72*385cc6b4SJerry Jelinek 73*385cc6b4SJerry Jelinek /******************************************************************************* 74*385cc6b4SJerry Jelinek * 75*385cc6b4SJerry Jelinek * FUNCTION: AcpiUtConvertStringToUuid 76*385cc6b4SJerry Jelinek * 77*385cc6b4SJerry Jelinek * PARAMETERS: InString - 36-byte formatted UUID string 78*385cc6b4SJerry Jelinek * UuidBuffer - Where the 16-byte UUID buffer is returned 79*385cc6b4SJerry Jelinek * 80*385cc6b4SJerry Jelinek * RETURN: None. Output data is returned in the UuidBuffer 81*385cc6b4SJerry Jelinek * 82*385cc6b4SJerry Jelinek * DESCRIPTION: Convert a 36-byte formatted UUID string to 16-byte UUID buffer 83*385cc6b4SJerry Jelinek * 84*385cc6b4SJerry Jelinek ******************************************************************************/ 85*385cc6b4SJerry Jelinek 86*385cc6b4SJerry Jelinek void 87*385cc6b4SJerry Jelinek AcpiUtConvertStringToUuid ( 88*385cc6b4SJerry Jelinek char *InString, 89*385cc6b4SJerry Jelinek UINT8 *UuidBuffer) 90*385cc6b4SJerry Jelinek { 91*385cc6b4SJerry Jelinek UINT32 i; 92*385cc6b4SJerry Jelinek 93*385cc6b4SJerry Jelinek 94*385cc6b4SJerry Jelinek for (i = 0; i < UUID_BUFFER_LENGTH; i++) 95*385cc6b4SJerry Jelinek { 96*385cc6b4SJerry Jelinek UuidBuffer[i] = (AcpiUtAsciiCharToHex ( 97*385cc6b4SJerry Jelinek InString[AcpiGbl_MapToUuidOffset[i]]) << 4); 98*385cc6b4SJerry Jelinek 99*385cc6b4SJerry Jelinek UuidBuffer[i] |= AcpiUtAsciiCharToHex ( 100*385cc6b4SJerry Jelinek InString[AcpiGbl_MapToUuidOffset[i] + 1]); 101*385cc6b4SJerry Jelinek } 102*385cc6b4SJerry Jelinek } 103*385cc6b4SJerry Jelinek #endif 104