]>
git.proxmox.com Git - mirror_edk2.git/blob - SecurityPkg/Tcg/Opal/OpalPassword/OpalHiiCallbacks.c
b07e38c1449d64569a0f5019b5d775028e8eee6d
2 Callbacks required by the HII of the Opal UEFI Driver to help display
3 Opal device information.
5 Copyright (c) 2016 - 2018, 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.
20 The return Value must be freed by caller if not NULL
22 @param OpalDisk The disk.
23 @param Prefix The prefix string.
25 @retval The var name string.
29 OpalDriverGetOpalVarName(
34 OPAL_DRIVER_DEVICE
* Dev
;
40 Dev
= DRIVER_DEVICE_FROM_OPALDISK(OpalDisk
);
45 PrefixLen
= StrLen(Prefix
);
48 if (Dev
->Name16
!= NULL
) {
49 NameLen
= StrLen(Dev
->Name16
);
52 VarNameLen
= PrefixLen
+ NameLen
;
54 VarName
= (CHAR16
*)AllocateZeroPool((VarNameLen
+ 1) * sizeof(CHAR16
));
55 if (VarName
== NULL
) {
59 CopyMem(VarName
, Prefix
, PrefixLen
* sizeof(CHAR16
));
60 if (Dev
->Name16
!= NULL
) {
61 CopyMem(VarName
+ PrefixLen
, Dev
->Name16
, NameLen
* sizeof(CHAR16
));
63 VarName
[VarNameLen
] = 0;
69 Get the driver image handle.
71 @retval the driver image handle.
75 HiiGetDriverImageHandleCB(
83 Check whether enable feature or not.
85 @retval Return the disk number.
89 HiiGetNumConfigRequiredOpalDisksCB(
94 UINT8 NumLockedOpalDisks
;
98 NumLockedOpalDisks
= 0;
100 NumDisks
= GetDeviceCount();
102 for (Index
= 0; Index
< NumDisks
; Index
++) {
103 OpalDisk
= HiiGetOpalDiskCB(Index
);
105 if (OpalDisk
!= NULL
) {
106 if (!OpalFeatureEnabled (&OpalDisk
->SupportedAttributes
, &OpalDisk
->LockingFeature
)) {
107 DEBUG ((DEBUG_INFO
, "Ignoring disk %u because feature is disabled or health has already been inspected\n", Index
));
108 } else if (OpalDeviceLocked (&OpalDisk
->SupportedAttributes
, &OpalDisk
->LockingFeature
)) {
109 NumLockedOpalDisks
++;
114 return NumLockedOpalDisks
;
120 Returns the opaque pointer to a physical disk context.
122 @param DiskIndex Input the disk index.
124 @retval The device pointer.
132 OPAL_DRIVER_DEVICE
* Dev
;
135 Dev
= OpalDriverGetDeviceList();
138 if (DiskIndex
>= GetDeviceCount()) {
142 while (Dev
!= NULL
) {
143 if (CurrentDisk
== DiskIndex
) {
155 Returns the opaque pointer to a physical disk context.
157 @param DiskIndex Input the disk index.
159 @retval The device pointer.
168 OPAL_DRIVER_DEVICE
*Tmp
;
170 Ctx
= HiiGetDiskContextCB (DiskIndex
);
176 Tmp
= (OPAL_DRIVER_DEVICE
*) Ctx
;
178 return &Tmp
->OpalDisk
;
182 Returns the disk name.
184 @param DiskIndex Input the disk index.
186 @retval Returns the disk name.
194 OPAL_DRIVER_DEVICE
* Ctx
;
196 Ctx
= (OPAL_DRIVER_DEVICE
*) HiiGetDiskContextCB (DiskIndex
);
199 if (Ctx
->NameZ
== NULL
) {
200 OpalDriverGetDriverDeviceName (Ctx
);
208 Returns the driver name.
210 @retval Returns the driver name.
218 return (CHAR16
*)EFI_DRIVER_NAME_UNICODE
;