]> git.proxmox.com Git - mirror_edk2.git/blame - SecurityPkg/Tcg/Opal/OpalPassword/OpalHiiCallbacks.c
SecurityPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / SecurityPkg / Tcg / Opal / OpalPassword / OpalHiiCallbacks.c
CommitLineData
112e584b
SZ
1/** @file\r
2 Callbacks required by the HII of the Opal UEFI Driver to help display\r
3 Opal device information.\r
4\r
31587395 5Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.<BR>\r
289b714b 6SPDX-License-Identifier: BSD-2-Clause-Patent\r
112e584b
SZ
7\r
8**/\r
9\r
10#include "OpalHii.h"\r
11\r
112e584b
SZ
12/**\r
13 Get the driver image handle.\r
14\r
15 @retval the driver image handle.\r
16\r
17**/\r
18EFI_HANDLE\r
19HiiGetDriverImageHandleCB(\r
20 VOID\r
21 )\r
22{\r
23 return gImageHandle;\r
24}\r
25\r
112e584b
SZ
26/**\r
27 Returns the opaque pointer to a physical disk context.\r
28\r
29 @param DiskIndex Input the disk index.\r
30\r
31 @retval The device pointer.\r
32\r
33**/\r
34VOID *\r
35HiiGetDiskContextCB(\r
36 UINT8 DiskIndex\r
37 )\r
38{\r
39 OPAL_DRIVER_DEVICE* Dev;\r
40 UINT8 CurrentDisk;\r
41\r
42 Dev = OpalDriverGetDeviceList();\r
43 CurrentDisk = 0;\r
44\r
45 if (DiskIndex >= GetDeviceCount()) {\r
46 return NULL;\r
47 }\r
48\r
49 while (Dev != NULL) {\r
50 if (CurrentDisk == DiskIndex) {\r
51 return Dev;\r
52 } else {\r
53 Dev = Dev->Next;\r
54 CurrentDisk++;\r
55 }\r
56 }\r
57\r
58 return NULL;\r
59}\r
60\r
61/**\r
62 Returns the opaque pointer to a physical disk context.\r
63\r
64 @param DiskIndex Input the disk index.\r
65\r
66 @retval The device pointer.\r
67\r
68**/\r
69OPAL_DISK*\r
70HiiGetOpalDiskCB(\r
71 UINT8 DiskIndex\r
72 )\r
73{\r
74 VOID *Ctx;\r
75 OPAL_DRIVER_DEVICE *Tmp;\r
76\r
77 Ctx = HiiGetDiskContextCB (DiskIndex);\r
78\r
79 if (Ctx == NULL) {\r
80 return NULL;\r
81 }\r
82\r
83 Tmp = (OPAL_DRIVER_DEVICE*) Ctx;\r
84\r
85 return &Tmp->OpalDisk;\r
86}\r
87\r
88/**\r
89 Returns the disk name.\r
90\r
91 @param DiskIndex Input the disk index.\r
92\r
93 @retval Returns the disk name.\r
94\r
95**/\r
96CHAR8*\r
97HiiDiskGetNameCB(\r
98 UINT8 DiskIndex\r
99 )\r
100{\r
101 OPAL_DRIVER_DEVICE* Ctx;\r
102\r
103 Ctx = (OPAL_DRIVER_DEVICE*) HiiGetDiskContextCB (DiskIndex);\r
104\r
105 if (Ctx != NULL) {\r
106 if (Ctx->NameZ == NULL) {\r
107 OpalDriverGetDriverDeviceName (Ctx);\r
108 }\r
109 return Ctx->NameZ;\r
110 }\r
111 return NULL;\r
f4c52009 112}\r