@@ -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,86 @@ 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+ VramAddress = (ULONG_PTR ) BaseAddress ;
166+ VramSize = (ULONG ) FrameBufferSize ;
167+
168+ /* All devices requiring Apple Graphics Info use PixelBlueGreenRedReserved8BitPerColor. */
169+ pPixelBitmask = & EfiPixelMasks [PixelBlueGreenRedReserved8BitPerColor ];
170+
171+ if (!VidFbInitializeVideo (& FrameBufferData ,
172+ VramAddress ,
173+ VramSize ,
174+ Width ,
175+ Height ,
176+ (BytesPerRow / 4 ),
177+ Depth ,
178+ (PPIXEL_BITMASK )pPixelBitmask ))
179+ {
180+ ERR ("Couldn't initialize video framebuffer\n" );
181+ Status = EFI_UNSUPPORTED ;
182+ }
183+
184+ return Status ;
185+ }
186+
187+ EFI_STATUS
188+ UefiInitializeVideo (VOID )
189+ {
190+ EFI_STATUS Status ;
191+
192+ /* First, try GOP */
193+ Status = UefiInitializeGop ();
194+ if (Status == EFI_SUCCESS )
195+ {
196+ return Status ;
197+ }
198+
199+ /* Try Apple Graphics Info if that fails */
200+ TRACE ("Failed to detect GOP, trying Apple Graphics Info\n" );
201+ Status = UefiInitializeAppleGraphics ();
202+ if (Status == EFI_SUCCESS )
203+ {
204+ return Status ;
205+ }
206+
207+ /* We didn't find GOP or Apple Graphics Info, probably a UGA-only system */
208+ ERR ("Cannot find framebuffer!\n" );
209+ return Status ;
210+ }
211+
212+
131213VOID
132214UefiVideoClearScreen (UCHAR Attr )
133215{
0 commit comments