]>
Commit | Line | Data |
---|---|---|
af468025 RN |
1 | /** @file\r |
2 | Logo DXE Driver, install Edkii Platform Logo protocol.\r | |
3 | \r | |
4 | Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r | |
5 | This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | #include <Uefi.h>\r | |
15 | #include <Protocol/HiiDatabase.h>\r | |
16 | #include <Protocol/GraphicsOutput.h>\r | |
17 | #include <Protocol/HiiImageEx.h>\r | |
18 | #include <Protocol/PlatformLogo.h>\r | |
19 | #include <Protocol/HiiPackageList.h>\r | |
20 | #include <Library/UefiBootServicesTableLib.h>\r | |
21 | #include <Library/DebugLib.h>\r | |
22 | \r | |
23 | typedef struct {\r | |
24 | EFI_IMAGE_ID ImageId;\r | |
25 | EDKII_PLATFORM_LOGO_DISPLAY_ATTRIBUTE Attribute;\r | |
26 | INTN OffsetX;\r | |
27 | INTN OffsetY;\r | |
28 | } LOGO_ENTRY;\r | |
29 | \r | |
30 | EFI_HII_IMAGE_EX_PROTOCOL *mHiiImageEx;\r | |
31 | EFI_HII_HANDLE mHiiHandle;\r | |
32 | LOGO_ENTRY mLogos[] = {\r | |
33 | {\r | |
34 | IMAGE_TOKEN (IMG_LOGO),\r | |
35 | EdkiiPlatformLogoDisplayAttributeCenter,\r | |
36 | 0,\r | |
37 | 0\r | |
38 | }\r | |
39 | };\r | |
40 | \r | |
41 | /**\r | |
42 | Load a platform logo image and return its data and attributes.\r | |
43 | \r | |
44 | @param This The pointer to this protocol instance.\r | |
45 | @param Instance The visible image instance is found.\r | |
46 | @param Image Points to the image.\r | |
47 | @param Attribute The display attributes of the image returned.\r | |
48 | @param OffsetX The X offset of the image regarding the Attribute.\r | |
49 | @param OffsetY The Y offset of the image regarding the Attribute.\r | |
50 | \r | |
51 | @retval EFI_SUCCESS The image was fetched successfully.\r | |
52 | @retval EFI_NOT_FOUND The specified image could not be found.\r | |
53 | **/\r | |
54 | EFI_STATUS\r | |
55 | EFIAPI\r | |
56 | GetImage (\r | |
57 | IN EDKII_PLATFORM_LOGO_PROTOCOL *This,\r | |
58 | IN OUT UINT32 *Instance,\r | |
59 | OUT EFI_IMAGE_INPUT *Image,\r | |
60 | OUT EDKII_PLATFORM_LOGO_DISPLAY_ATTRIBUTE *Attribute,\r | |
61 | OUT INTN *OffsetX,\r | |
62 | OUT INTN *OffsetY\r | |
63 | )\r | |
64 | {\r | |
65 | UINT32 Current;\r | |
66 | if (Instance == NULL || Image == NULL ||\r | |
67 | Attribute == NULL || OffsetX == NULL || OffsetY == NULL) {\r | |
68 | return EFI_INVALID_PARAMETER;\r | |
69 | }\r | |
70 | \r | |
71 | Current = *Instance;\r | |
72 | if (Current >= sizeof (mLogos) / sizeof (mLogos[0])) {\r | |
73 | return EFI_NOT_FOUND;\r | |
74 | }\r | |
75 | \r | |
76 | (*Instance)++;\r | |
77 | *Attribute = mLogos[Current].Attribute;\r | |
78 | *OffsetX = mLogos[Current].OffsetX;\r | |
79 | *OffsetY = mLogos[Current].OffsetY;\r | |
80 | return mHiiImageEx->GetImageEx (mHiiImageEx, mHiiHandle, mLogos[Current].ImageId, Image);\r | |
81 | }\r | |
82 | \r | |
83 | EDKII_PLATFORM_LOGO_PROTOCOL mPlatformLogo = {\r | |
84 | GetImage\r | |
85 | };\r | |
86 | \r | |
87 | /**\r | |
88 | Entrypoint of this module.\r | |
89 | \r | |
90 | This function is the entrypoint of this module. It installs the Edkii\r | |
91 | Platform Logo protocol.\r | |
92 | \r | |
93 | @param ImageHandle The firmware allocated handle for the EFI image.\r | |
94 | @param SystemTable A pointer to the EFI System Table.\r | |
95 | \r | |
96 | @retval EFI_SUCCESS The entry point is executed successfully.\r | |
97 | \r | |
98 | **/\r | |
99 | EFI_STATUS\r | |
100 | EFIAPI\r | |
101 | InitializeLogo (\r | |
102 | IN EFI_HANDLE ImageHandle,\r | |
103 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
104 | )\r | |
105 | {\r | |
106 | EFI_STATUS Status;\r | |
107 | EFI_HII_PACKAGE_LIST_HEADER *PackageList;\r | |
108 | EFI_HII_DATABASE_PROTOCOL *HiiDatabase;\r | |
109 | EFI_HANDLE Handle;\r | |
110 | \r | |
111 | Status = gBS->LocateProtocol (\r | |
112 | &gEfiHiiDatabaseProtocolGuid,\r | |
113 | NULL,\r | |
114 | (VOID **) &HiiDatabase\r | |
115 | );\r | |
116 | ASSERT_EFI_ERROR (Status);\r | |
117 | \r | |
118 | Status = gBS->LocateProtocol (\r | |
119 | &gEfiHiiImageExProtocolGuid,\r | |
120 | NULL,\r | |
121 | (VOID **) &mHiiImageEx\r | |
122 | );\r | |
123 | ASSERT_EFI_ERROR (Status);\r | |
124 | \r | |
125 | //\r | |
126 | // Retrieve HII package list from ImageHandle\r | |
127 | //\r | |
128 | Status = gBS->OpenProtocol (\r | |
129 | ImageHandle,\r | |
130 | &gEfiHiiPackageListProtocolGuid,\r | |
131 | (VOID **) &PackageList,\r | |
132 | ImageHandle,\r | |
133 | NULL,\r | |
134 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
135 | );\r | |
136 | ASSERT_EFI_ERROR (Status);\r | |
137 | \r | |
138 | //\r | |
139 | // Publish HII package list to HII Database.\r | |
140 | //\r | |
141 | Status = HiiDatabase->NewPackageList (\r | |
142 | HiiDatabase,\r | |
143 | PackageList,\r | |
144 | NULL,\r | |
145 | &mHiiHandle\r | |
146 | );\r | |
147 | if (!EFI_ERROR (Status)) {\r | |
148 | Handle = NULL;\r | |
149 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
150 | &Handle,\r | |
151 | &gEdkiiPlatformLogoProtocolGuid, &mPlatformLogo,\r | |
152 | NULL\r | |
153 | );\r | |
154 | }\r | |
155 | return Status;\r | |
156 | }\r |