]>
git.proxmox.com Git - mirror_edk2.git/blob - SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHiiCallbacks.c
6f2eaeb4c3fe6dbffb27bebd4c1854afb97a81f7
2 Callbacks required by the HII of the Opal UEFI Driver to help display
3 Opal device information and to send password to SMM handler.
5 Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #include "OpalDriver.h"
18 #include "OpalDriverPrivate.h"
22 The return Value must be freed by caller if not NULL
24 @param OpalDisk The disk.
25 @param Prefix The prefix string.
27 @retval The var name string.
31 OpalDriverGetOpalVarName(
36 OPAL_DRIVER_DEVICE
* Dev
;
42 Dev
= DRIVER_DEVICE_FROM_OPALDISK(OpalDisk
);
47 PrefixLen
= StrLen(Prefix
);
50 if (Dev
->Name16
!= NULL
) {
51 NameLen
= StrLen(Dev
->Name16
);
54 VarNameLen
= PrefixLen
+ NameLen
;
56 VarName
= (CHAR16
*)AllocateZeroPool((VarNameLen
+ 1) * sizeof(CHAR16
));
57 if (VarName
== NULL
) {
61 CopyMem(VarName
, Prefix
, PrefixLen
* sizeof(CHAR16
));
62 if (Dev
->Name16
!= NULL
) {
63 CopyMem(VarName
+ PrefixLen
, Dev
->Name16
, NameLen
* sizeof(CHAR16
));
65 VarName
[VarNameLen
] = 0;
71 Get the driver image handle.
73 @retval the driver image handle.
77 HiiGetDriverImageHandleCB(
85 Check whether enable feature or not.
87 @retval Return the disk number.
91 HiiGetNumConfigRequiredOpalDisksCB(
96 UINT8 NumLockedOpalDisks
;
100 NumLockedOpalDisks
= 0;
102 NumDisks
= GetDeviceCount();
104 for (Index
= 0; Index
< NumDisks
; Index
++) {
105 OpalDisk
= HiiGetOpalDiskCB(Index
);
107 if (OpalDisk
!= NULL
) {
108 if (!OpalFeatureEnabled (&OpalDisk
->SupportedAttributes
, &OpalDisk
->LockingFeature
)) {
109 DEBUG ((DEBUG_INFO
, "Ignoring disk %u because feature is disabled or health has already been inspected\n", Index
));
110 } else if (OpalDeviceLocked (&OpalDisk
->SupportedAttributes
, &OpalDisk
->LockingFeature
)) {
111 NumLockedOpalDisks
++;
116 return NumLockedOpalDisks
;
122 Returns the opaque pointer to a physical disk context.
124 @param DiskIndex Input the disk index.
126 @retval The device pointer.
134 OPAL_DRIVER_DEVICE
* Dev
;
137 Dev
= OpalDriverGetDeviceList();
140 if (DiskIndex
>= GetDeviceCount()) {
144 while (Dev
!= NULL
) {
145 if (CurrentDisk
== DiskIndex
) {
157 Returns the opaque pointer to a physical disk context.
159 @param DiskIndex Input the disk index.
161 @retval The device pointer.
170 OPAL_DRIVER_DEVICE
*Tmp
;
172 Ctx
= HiiGetDiskContextCB (DiskIndex
);
178 Tmp
= (OPAL_DRIVER_DEVICE
*) Ctx
;
180 return &Tmp
->OpalDisk
;
184 Returns the disk name.
186 @param DiskIndex Input the disk index.
188 @retval Returns the disk name.
196 OPAL_DRIVER_DEVICE
* Ctx
;
198 Ctx
= (OPAL_DRIVER_DEVICE
*) HiiGetDiskContextCB (DiskIndex
);
201 if (Ctx
->NameZ
== NULL
) {
202 OpalDriverGetDriverDeviceName (Ctx
);
210 Returns the driver name.
212 @retval Returns the driver name.
220 return (CHAR16
*)EFI_DRIVER_NAME_UNICODE
;