@@ -16,6 +16,7 @@ DBG_DEFAULT_CHANNEL(UI);
1616extern EFI_SYSTEM_TABLE * GlobalSystemTable ;
1717extern EFI_HANDLE GlobalImageHandle ;
1818EFI_GUID EfiGraphicsOutputProtocol = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID ;
19+ EFI_GUID AppleGraphInfoProtocol = APPLE_GRAPH_INFO_PROTOCOL_GUID ;
1920
2021ULONG_PTR VramAddress ;
2122ULONG VramSize ;
@@ -52,8 +53,9 @@ static EFI_PIXEL_BITMASK EfiPixelMasks[] =
5253
5354#endif /* UEFI */
5455
56+ static
5557EFI_STATUS
56- UefiInitializeVideo (VOID )
58+ UefiInitializeGop (VOID )
5759{
5860 EFI_STATUS Status ;
5961 EFI_GRAPHICS_OUTPUT_PROTOCOL * gop = NULL ;
@@ -128,6 +130,81 @@ UefiInitializeVideo(VOID)
128130 return Status ;
129131}
130132
133+ static
134+ EFI_STATUS
135+ UefiInitializeAppleGraphics (VOID )
136+ {
137+ EFI_STATUS Status ;
138+ APPLE_GRAPH_INFO_PROTOCOL * AppleGraph = NULL ;
139+ EFI_PIXEL_BITMASK * pPixelBitmask ;
140+
141+ UINT64 BaseAddress , FrameBufferSize ;
142+ UINT32 BytesPerRow , Width , Height , Depth ;
143+
144+ Status = GlobalSystemTable -> BootServices -> LocateProtocol (& AppleGraphInfoProtocol , 0 , (VOID * * )& AppleGraph );
145+ if (Status != EFI_SUCCESS )
146+ {
147+ ERR ("Failed to find Apple Graphics Info with status %d\n" , Status );
148+ return Status ;
149+ }
150+
151+ Status = AppleGraph -> GetInfo (AppleGraph ,
152+ & BaseAddress ,
153+ & FrameBufferSize ,
154+ & BytesPerRow ,
155+ & Width ,
156+ & Height ,
157+ & Depth );
158+
159+ if (Status != EFI_SUCCESS )
160+ {
161+ ERR ("Failed to get graphics info from Apple Scren Info: %d\n" , Status );
162+ return Status ;
163+ }
164+
165+ /* All devices requiring Apple Graphics Info use PixelBlueGreenRedReserved8BitPerColor. */
166+ pPixelBitmask = & EfiPixelMasks [PixelBlueGreenRedReserved8BitPerColor ];
167+
168+ VramAddress = (ULONG_PTR )BaseAddress ;
169+ VramSize = (ULONG )FrameBufferSize ;
170+ if (!VidFbInitializeVideo (& FrameBufferData ,
171+ VramAddress ,
172+ VramSize ,
173+ Width ,
174+ Height ,
175+ (BytesPerRow / 4 ),
176+ Depth ,
177+ (PPIXEL_BITMASK )pPixelBitmask ))
178+ {
179+ ERR ("Couldn't initialize video framebuffer\n" );
180+ Status = EFI_UNSUPPORTED ;
181+ }
182+
183+ return Status ;
184+ }
185+
186+ EFI_STATUS
187+ UefiInitializeVideo (VOID )
188+ {
189+ EFI_STATUS Status ;
190+
191+ /* First, try GOP */
192+ Status = UefiInitializeGop ();
193+ if (Status == EFI_SUCCESS )
194+ return Status ;
195+
196+ /* Try Apple Graphics Info if that fails */
197+ TRACE ("Failed to detect GOP, trying Apple Graphics Info\n" );
198+ Status = UefiInitializeAppleGraphics ();
199+ if (Status == EFI_SUCCESS )
200+ return Status ;
201+
202+ /* We didn't find GOP or Apple Graphics Info, probably a UGA-only system */
203+ ERR ("Cannot find framebuffer!\n" );
204+ return Status ;
205+ }
206+
207+
131208VOID
132209UefiVideoClearScreen (UCHAR Attr )
133210{
0 commit comments