utuuid.c revision 281687
1271440Sjkim/****************************************************************************** 2271440Sjkim * 3271440Sjkim * Module Name: utuuid -- UUID support functions 4271440Sjkim * 5271440Sjkim *****************************************************************************/ 6271440Sjkim 7271440Sjkim/* 8281075Sdim * Copyright (C) 2000 - 2015, Intel Corp. 9271440Sjkim * All rights reserved. 10271440Sjkim * 11271440Sjkim * Redistribution and use in source and binary forms, with or without 12271440Sjkim * modification, are permitted provided that the following conditions 13271440Sjkim * are met: 14271440Sjkim * 1. Redistributions of source code must retain the above copyright 15271440Sjkim * notice, this list of conditions, and the following disclaimer, 16271440Sjkim * without modification. 17271440Sjkim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18271440Sjkim * substantially similar to the "NO WARRANTY" disclaimer below 19271440Sjkim * ("Disclaimer") and any redistribution must be conditioned upon 20271440Sjkim * including a substantially similar Disclaimer requirement for further 21271440Sjkim * binary redistribution. 22271440Sjkim * 3. Neither the names of the above-listed copyright holders nor the names 23271440Sjkim * of any contributors may be used to endorse or promote products derived 24271440Sjkim * from this software without specific prior written permission. 25271440Sjkim * 26271440Sjkim * Alternatively, this software may be distributed under the terms of the 27271440Sjkim * GNU General Public License ("GPL") version 2 as published by the Free 28271440Sjkim * Software Foundation. 29271440Sjkim * 30271440Sjkim * NO WARRANTY 31271440Sjkim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32271440Sjkim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33271440Sjkim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34271440Sjkim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35271440Sjkim * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36271440Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37271440Sjkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38271440Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39271440Sjkim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40271440Sjkim * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41271440Sjkim * POSSIBILITY OF SUCH DAMAGES. 42271440Sjkim */ 43271440Sjkim 44272444Sjkim#include <contrib/dev/acpica/include/acpi.h> 45272444Sjkim#include <contrib/dev/acpica/include/accommon.h> 46271440Sjkim 47271440Sjkim#define _COMPONENT ACPI_COMPILER 48271440Sjkim ACPI_MODULE_NAME ("utuuid") 49271440Sjkim 50271440Sjkim 51281687Sjkim#if (defined ACPI_ASL_COMPILER || defined ACPI_DISASSEMBLER || defined ACPI_EXEC_APP || defined ACPI_HELP_APP) 52271440Sjkim/* 53271440Sjkim * UUID support functions. 54271440Sjkim * 55271440Sjkim * This table is used to convert an input UUID ascii string to a 16 byte 56271440Sjkim * buffer and the reverse. The table maps a UUID buffer index 0-15 to 57271440Sjkim * the index within the 36-byte UUID string where the associated 2-byte 58271440Sjkim * hex value can be found. 59271440Sjkim * 60271440Sjkim * 36-byte UUID strings are of the form: 61271440Sjkim * aabbccdd-eeff-gghh-iijj-kkllmmnnoopp 62271440Sjkim * Where aa-pp are one byte hex numbers, made up of two hex digits 63271440Sjkim * 64271440Sjkim * Note: This table is basically the inverse of the string-to-offset table 65271440Sjkim * found in the ACPI spec in the description of the ToUUID macro. 66271440Sjkim */ 67271440Sjkimconst UINT8 AcpiGbl_MapToUuidOffset[UUID_BUFFER_LENGTH] = 68271440Sjkim{ 69271440Sjkim 6,4,2,0,11,9,16,14,19,21,24,26,28,30,32,34 70271440Sjkim}; 71271440Sjkim 72271440Sjkim 73271440Sjkim/******************************************************************************* 74271440Sjkim * 75271440Sjkim * FUNCTION: AcpiUtConvertStringToUuid 76271440Sjkim * 77271440Sjkim * PARAMETERS: InString - 36-byte formatted UUID string 78271440Sjkim * UuidBuffer - Where the 16-byte UUID buffer is returned 79271440Sjkim * 80271440Sjkim * RETURN: None. Output data is returned in the UuidBuffer 81271440Sjkim * 82271440Sjkim * DESCRIPTION: Convert a 36-byte formatted UUID string to 16-byte UUID buffer 83271440Sjkim * 84271440Sjkim ******************************************************************************/ 85271440Sjkim 86271440Sjkimvoid 87271440SjkimAcpiUtConvertStringToUuid ( 88271440Sjkim char *InString, 89271440Sjkim UINT8 *UuidBuffer) 90271440Sjkim{ 91271440Sjkim UINT32 i; 92271440Sjkim 93271440Sjkim 94271440Sjkim for (i = 0; i < UUID_BUFFER_LENGTH; i++) 95271440Sjkim { 96271440Sjkim UuidBuffer[i] = 97271440Sjkim (AcpiUtAsciiCharToHex (InString[AcpiGbl_MapToUuidOffset[i]]) << 4); 98271440Sjkim 99271440Sjkim UuidBuffer[i] |= 100271440Sjkim AcpiUtAsciiCharToHex (InString[AcpiGbl_MapToUuidOffset[i] + 1]); 101271440Sjkim } 102271440Sjkim} 103281687Sjkim#endif 104