1 | /* $Id: efiguid.cpp 90061 2021-07-06 12:48:53Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * IPRT - EFI GUID conversion helpers.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2021 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * The contents of this file may alternatively be used under the terms
|
---|
18 | * of the Common Development and Distribution License Version 1.0
|
---|
19 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | * CDDL are applicable instead of those of the GPL.
|
---|
22 | *
|
---|
23 | * You may elect to license modified versions of this file under the
|
---|
24 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | */
|
---|
26 |
|
---|
27 |
|
---|
28 | /*********************************************************************************************************************************
|
---|
29 | * Header Files *
|
---|
30 | *********************************************************************************************************************************/
|
---|
31 | #define LOG_GROUP RTLOGGROUP_DEFAULT
|
---|
32 | #include <iprt/efi.h>
|
---|
33 |
|
---|
34 | #include <iprt/cdefs.h>
|
---|
35 | #include <iprt/string.h>
|
---|
36 |
|
---|
37 |
|
---|
38 | /*********************************************************************************************************************************
|
---|
39 | * Defined Constants And Macros *
|
---|
40 | *********************************************************************************************************************************/
|
---|
41 |
|
---|
42 |
|
---|
43 | /*********************************************************************************************************************************
|
---|
44 | * Structures and Typedefs *
|
---|
45 | *********************************************************************************************************************************/
|
---|
46 |
|
---|
47 |
|
---|
48 | /*********************************************************************************************************************************
|
---|
49 | * Internal Functions *
|
---|
50 | *********************************************************************************************************************************/
|
---|
51 |
|
---|
52 | RTDECL(PRTUUID) RTEfiGuidToUuid(PRTUUID pUuid, PCEFI_GUID pEfiGuid)
|
---|
53 | {
|
---|
54 | pUuid->Gen.u32TimeLow = RT_LE2H_U32(pEfiGuid->u32Data1);
|
---|
55 | pUuid->Gen.u16TimeMid = RT_LE2H_U16(pEfiGuid->u16Data2);
|
---|
56 | pUuid->Gen.u16TimeHiAndVersion = RT_LE2H_U16(pEfiGuid->u16Data3);
|
---|
57 | pUuid->Gen.u8ClockSeqHiAndReserved = pEfiGuid->abData4[0];
|
---|
58 | pUuid->Gen.u8ClockSeqLow = pEfiGuid->abData4[1];
|
---|
59 | pUuid->Gen.au8Node[0] = pEfiGuid->abData4[2];
|
---|
60 | pUuid->Gen.au8Node[1] = pEfiGuid->abData4[3];
|
---|
61 | pUuid->Gen.au8Node[2] = pEfiGuid->abData4[4];
|
---|
62 | pUuid->Gen.au8Node[3] = pEfiGuid->abData4[5];
|
---|
63 | pUuid->Gen.au8Node[4] = pEfiGuid->abData4[6];
|
---|
64 | pUuid->Gen.au8Node[5] = pEfiGuid->abData4[7];
|
---|
65 | return pUuid;
|
---|
66 | }
|
---|
67 |
|
---|
68 |
|
---|
69 | RTDECL(PEFI_GUID) RTEfiGuidFromUuid(PEFI_GUID pEfiGuid, PCRTUUID pUuid)
|
---|
70 | {
|
---|
71 | pEfiGuid->u32Data1 = RT_H2LE_U32(pUuid->Gen.u32TimeLow);
|
---|
72 | pEfiGuid->u16Data2 = RT_H2LE_U16(pUuid->Gen.u16TimeMid);
|
---|
73 | pEfiGuid->u16Data3 = RT_H2LE_U16(pUuid->Gen.u16TimeHiAndVersion);
|
---|
74 | pEfiGuid->abData4[0] = pUuid->Gen.u8ClockSeqHiAndReserved;
|
---|
75 | pEfiGuid->abData4[1] = pUuid->Gen.u8ClockSeqLow;
|
---|
76 | pEfiGuid->abData4[2] = pUuid->Gen.au8Node[0];
|
---|
77 | pEfiGuid->abData4[3] = pUuid->Gen.au8Node[1];
|
---|
78 | pEfiGuid->abData4[4] = pUuid->Gen.au8Node[2];
|
---|
79 | pEfiGuid->abData4[5] = pUuid->Gen.au8Node[3];
|
---|
80 | pEfiGuid->abData4[6] = pUuid->Gen.au8Node[4];
|
---|
81 | pEfiGuid->abData4[7] = pUuid->Gen.au8Node[5];
|
---|
82 | return pEfiGuid;
|
---|
83 | }
|
---|
84 |
|
---|