]> git.proxmox.com Git - mirror_edk2.git/blame - SecurityPkg/Tcg/Opal/OpalPassword/OpalHiiCallbacks.c
SecurityPkg: Apply uncrustify changes
[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
c411b485 19HiiGetDriverImageHandleCB (\r
112e584b
SZ
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
c411b485
MK
35HiiGetDiskContextCB (\r
36 UINT8 DiskIndex\r
112e584b
SZ
37 )\r
38{\r
c411b485
MK
39 OPAL_DRIVER_DEVICE *Dev;\r
40 UINT8 CurrentDisk;\r
112e584b 41\r
c411b485 42 Dev = OpalDriverGetDeviceList ();\r
112e584b
SZ
43 CurrentDisk = 0;\r
44\r
c411b485 45 if (DiskIndex >= GetDeviceCount ()) {\r
112e584b
SZ
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
c411b485
MK
69OPAL_DISK *\r
70HiiGetOpalDiskCB (\r
71 UINT8 DiskIndex\r
112e584b
SZ
72 )\r
73{\r
c411b485
MK
74 VOID *Ctx;\r
75 OPAL_DRIVER_DEVICE *Tmp;\r
112e584b
SZ
76\r
77 Ctx = HiiGetDiskContextCB (DiskIndex);\r
78\r
79 if (Ctx == NULL) {\r
80 return NULL;\r
81 }\r
82\r
c411b485 83 Tmp = (OPAL_DRIVER_DEVICE *)Ctx;\r
112e584b
SZ
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
c411b485
MK
96CHAR8 *\r
97HiiDiskGetNameCB (\r
98 UINT8 DiskIndex\r
112e584b
SZ
99 )\r
100{\r
c411b485 101 OPAL_DRIVER_DEVICE *Ctx;\r
112e584b 102\r
c411b485 103 Ctx = (OPAL_DRIVER_DEVICE *)HiiGetDiskContextCB (DiskIndex);\r
112e584b
SZ
104\r
105 if (Ctx != NULL) {\r
106 if (Ctx->NameZ == NULL) {\r
107 OpalDriverGetDriverDeviceName (Ctx);\r
108 }\r
c411b485 109\r
112e584b
SZ
110 return Ctx->NameZ;\r
111 }\r
c411b485 112\r
112e584b 113 return NULL;\r
f4c52009 114}\r