]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Library/ExtendedHiiLib/ExtendedHiiLib.c
22b9763fad099c20bc2c745bc956015042a709c5
[mirror_edk2.git] / MdeModulePkg / Library / ExtendedHiiLib / ExtendedHiiLib.c
1 /** @file
2 HII Library implementation that uses DXE protocols and services.
3
4 Copyright (c) 2006, Intel Corporation<BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15
16 #include <PiDxe.h>
17
18 #include <Protocol/DevicePath.h>
19
20 #include <Library/BaseMemoryLib.h>
21 #include <Library/DebugLib.h>
22 #include <Library/MemoryAllocationLib.h>
23 #include <Library/UefiBootServicesTableLib.h>
24 #include <MdeModuleHii.h>
25
26
27 //
28 // Hii vendor device path template
29 //
30 HII_VENDOR_DEVICE_PATH mHiiVendorDevicePathTemplate = {
31 {
32 {
33 {
34 HARDWARE_DEVICE_PATH,
35 HW_VENDOR_DP,
36 {
37 (UINT8) (sizeof (HII_VENDOR_DEVICE_PATH_NODE)),
38 (UINT8) ((sizeof (HII_VENDOR_DEVICE_PATH_NODE)) >> 8)
39 }
40 },
41 EFI_IFR_TIANO_GUID
42 },
43 0
44 },
45 {
46 END_DEVICE_PATH_TYPE,
47 END_ENTIRE_DEVICE_PATH_SUBTYPE,
48 {
49 END_DEVICE_PATH_LENGTH
50 }
51 }
52 };
53
54
55 EFI_STATUS
56 EFIAPI
57 HiiLibCreateHiiDriverHandle (
58 OUT EFI_HANDLE *DriverHandle
59 )
60 {
61 EFI_STATUS Status;
62 HII_VENDOR_DEVICE_PATH_NODE *VendorDevicePath;
63 UINT64 MonotonicCount;
64
65 VendorDevicePath = AllocateCopyPool (sizeof (HII_VENDOR_DEVICE_PATH), &mHiiVendorDevicePathTemplate);
66 if (VendorDevicePath == NULL) {
67 return EFI_OUT_OF_RESOURCES;
68 }
69
70 gBS->GetNextMonotonicCount (&MonotonicCount);
71 VendorDevicePath->MonotonicCount = (UINT32) MonotonicCount;
72
73 *DriverHandle = NULL;
74 Status = gBS->InstallProtocolInterface (
75 DriverHandle,
76 &gEfiDevicePathProtocolGuid,
77 EFI_NATIVE_INTERFACE,
78 VendorDevicePath
79 );
80 if (EFI_ERROR (Status)) {
81 return Status;
82 }
83
84 return EFI_SUCCESS;
85 }
86
87
88 VOID
89 EFIAPI
90 HiiLibDestroyHiiDriverHandle (
91 IN EFI_HANDLE DriverHandle
92 )
93 {
94 EFI_STATUS Status;
95 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
96
97 Status = gBS->HandleProtocol (
98 DriverHandle,
99 &gEfiDevicePathProtocolGuid,
100 (VOID **) &DevicePath
101 );
102 ASSERT_EFI_ERROR (Status);
103
104 Status = gBS->UninstallProtocolInterface (
105 DriverHandle,
106 &gEfiDevicePathProtocolGuid,
107 DevicePath
108 );
109 ASSERT_EFI_ERROR (Status);
110
111 FreePool (DevicePath);
112
113 }
114
115
116