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