OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
Eg2Info.c
Go to the documentation of this file.
1
16
17#include <Guid/AppleVariable.h>
18
20
21#include <Library/BaseLib.h>
22#include <Library/DebugLib.h>
24#include <Library/OcMiscLib.h>
25#include <Library/UefiBootServicesTableLib.h>
26#include <Library/UefiRuntimeServicesTableLib.h>
27
29
30STATIC
31EFI_STATUS
32EFIAPI
35 IN EFI_HANDLE GpuHandle
36 )
37{
38 return EFI_UNSUPPORTED;
39}
40
41STATIC
42EFI_STATUS
43EFIAPI
46 IN EFI_HANDLE GpuHandle,
47 OUT VOID *Data,
48 OUT UINTN *Size
49 )
50{
51 return EFI_UNSUPPORTED;
52}
53
54STATIC
55EFI_STATUS
56EFIAPI
59 IN EFI_HANDLE GpuHandle,
60 OUT VOID *Unk1,
61 OUT VOID *Unk2,
62 OUT VOID *Unk3
63 )
64{
65 return EFI_UNSUPPORTED;
66}
67
68STATIC
69EFI_STATUS
70EFIAPI
73 OUT BOOLEAN *Hibernated
74 )
75{
76 return EFI_UNSUPPORTED;
77}
78
79STATIC
80EFI_STATUS
81EFIAPI
84 OUT UINT32 *Rotation
85 )
86{
87 if ((This == NULL) || (Rotation == NULL)) {
88 return EFI_INVALID_PARAMETER;
89 }
90
91 *Rotation = mRotation;
92 return EFI_SUCCESS;
93}
94
95STATIC
106
109 IN BOOLEAN Reinstall
110 )
111{
112 EFI_STATUS Status;
113 APPLE_EG2_INFO_PROTOCOL *Protocol;
114 EFI_HANDLE NewHandle;
115 UINTN Size;
116 UINT32 Attributes;
117 UINT32 Rotation;
118
119 DEBUG ((DEBUG_VERBOSE, "OcAppleEg2InfoInstallProtocol\n"));
120
121 if (Reinstall) {
123 if (EFI_ERROR (Status)) {
124 DEBUG ((DEBUG_ERROR, "OCEG: Uninstall failed - %r\n", Status));
125 return NULL;
126 }
127 } else {
128 Status = gBS->LocateProtocol (
130 NULL,
131 (VOID *)&Protocol
132 );
133
134 if (!EFI_ERROR (Status)) {
135 return Protocol;
136 }
137 }
138
139 Attributes = 0;
140 Size = sizeof (Rotation);
141 Status = gRT->GetVariable (
144 &Attributes,
145 &Size,
146 &Rotation
147 );
148 if (!EFI_ERROR (Status)) {
149 DEBUG ((DEBUG_INFO, "OCEG: Discovered rotate NVRAM override to %u\n", Rotation));
150 if (Rotation == 90) {
152 } else if (Rotation == 180) {
154 } else if (Rotation == 270) {
156 }
157 }
158
159 NewHandle = NULL;
160 Status = gBS->InstallMultipleProtocolInterfaces (
161 &NewHandle,
163 (VOID *)&mAppleEg2Info,
164 NULL
165 );
166
167 if (EFI_ERROR (Status)) {
168 return NULL;
169 }
170
171 return &mAppleEg2Info;
172}
#define APPLE_EG2_INFO_PROTOCOL_REVISION
EFI_GUID gAppleEg2InfoProtocolGuid
@ AppleDisplayRotate90
@ AppleDisplayRotate270
@ AppleDisplayRotate180
@ AppleDisplayRotate0
EFI_GUID gAppleBootVariableGuid
#define APPLE_FORCE_DISPLAY_ROTATION_VARIABLE_NAME
STATIC EFI_STATUS EFIAPI AppleEg2GetHibernation(IN APPLE_EG2_INFO_PROTOCOL *This, OUT BOOLEAN *Hibernated)
Definition Eg2Info.c:71
STATIC EFI_STATUS EFIAPI AppleEg2GetRotation(IN APPLE_EG2_INFO_PROTOCOL *This, OUT UINT32 *Rotation)
Definition Eg2Info.c:82
STATIC UINT32 mRotation
Definition Eg2Info.c:28
STATIC EFI_STATUS EFIAPI AppleEg2GetPlatformInfo(IN APPLE_EG2_INFO_PROTOCOL *This, IN EFI_HANDLE GpuHandle, OUT VOID *Data, OUT UINTN *Size)
Definition Eg2Info.c:44
APPLE_EG2_INFO_PROTOCOL * OcAppleEg2InfoInstallProtocol(IN BOOLEAN Reinstall)
Definition Eg2Info.c:108
STATIC APPLE_EG2_INFO_PROTOCOL mAppleEg2Info
Definition Eg2Info.c:97
STATIC EFI_STATUS EFIAPI AppleEg2Unknown1(IN APPLE_EG2_INFO_PROTOCOL *This, IN EFI_HANDLE GpuHandle)
Definition Eg2Info.c:33
STATIC EFI_STATUS EFIAPI AppleEg2StartupDisplay(IN APPLE_EG2_INFO_PROTOCOL *This, IN EFI_HANDLE GpuHandle, OUT VOID *Unk1, OUT VOID *Unk2, OUT VOID *Unk3)
Definition Eg2Info.c:57
DMG_SIZE_DEVICE_PATH Size
EFI_BOOT_SERVICES * gBS
EFI_STATUS OcUninstallAllProtocolInstances(EFI_GUID *Protocol)
EFI_RUNTIME_SERVICES * gRT