66 */
77
88#include <uefildr.h>
9+ #include <drivers/bootvid/framebuf.h>
910
1011#include <debug.h>
1112DBG_DEFAULT_CHANNEL (WARNING );
@@ -24,12 +25,14 @@ extern UCHAR BitmapFont8x16[256 * 16];
2425UCHAR MachDefaultTextColor = COLOR_GRAY ;
2526REACTOS_INTERNAL_BGCONTEXT framebufferData ;
2627EFI_GUID EfiGraphicsOutputProtocol = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID ;
28+ EFI_GUID AppleScreenInfoGUID = APPLE_SCREEN_INFO_PROTOCOL_GUID ;
2729/****/ EFI_PIXEL_BITMASK UefiGopPixelBitmask ;/****/
2830
2931/* FUNCTIONS ******************************************************************/
3032
33+ static
3134EFI_STATUS
32- UefiInitializeVideo (VOID )
35+ UefiInitializeGop (VOID )
3336{
3437 EFI_STATUS Status ;
3538 EFI_GRAPHICS_OUTPUT_PROTOCOL * gop = NULL ;
@@ -43,7 +46,7 @@ UefiInitializeVideo(VOID)
4346 }
4447
4548 /* We don't need high resolutions for freeldr */
46- // gop->SetMode(gop, LOWEST_SUPPORTED_RES);
49+ gop -> SetMode (gop , LOWEST_SUPPORTED_RES );
4750
4851 framebufferData .BaseAddress = (ULONG_PTR )gop -> Mode -> FrameBufferBase ;
4952 framebufferData .BufferSize = gop -> Mode -> FrameBufferSize ;
@@ -55,6 +58,73 @@ UefiInitializeVideo(VOID)
5558 return Status ;
5659}
5760
61+ static
62+ EFI_STATUS
63+ UefiInitializeAppleScreen (VOID )
64+ {
65+ EFI_STATUS Status ;
66+ APPLE_SCREEN_INFO_PROTOCOL * AppleScreen = NULL ;
67+ UINT64 BaseAddress , FrameBufferSize ;
68+ UINT32 BytesPerRow , Width , Height , Depth ;
69+
70+ RtlZeroMemory (& framebufferData , sizeof (framebufferData ));
71+
72+ Status = GlobalSystemTable -> BootServices -> LocateProtocol (& AppleScreenInfoGUID , 0 , (void * * )& AppleScreen );
73+ if (Status != EFI_SUCCESS )
74+ {
75+ TRACE ("Failed to find Apple Screen Info Protocol with status %d\n" , Status );
76+ return Status ;
77+ }
78+
79+ Status = AppleScreen -> GetInfo (AppleScreen ,
80+ & BaseAddress ,
81+ & FrameBufferSize ,
82+ & BytesPerRow ,
83+ & Width ,
84+ & Height ,
85+ & Depth );
86+
87+ if (Status != EFI_SUCCESS )
88+ {
89+ TRACE ("Failed to get screen info from Apple EFI with status %d\n" , Status );
90+ return Status ;
91+ }
92+
93+ ASSERT (Depth == 32 );
94+
95+ framebufferData .BaseAddress = (ULONG_PTR ) BaseAddress ;
96+ framebufferData .BufferSize = (ULONG_PTR ) FrameBufferSize ;
97+ framebufferData .ScreenWidth = Width ;
98+ framebufferData .ScreenHeight = Height ;
99+ framebufferData .PixelsPerScanLine = BytesPerRow / 4 ;
100+ framebufferData .PixelFormat = PixelBlueGreenRedReserved8BitPerColor ;
101+ UefiGopPixelBitmask = EfiPixelMasks [PixelBlueGreenRedReserved8BitPerColor ];
102+
103+ return Status ;
104+ }
105+
106+ EFI_STATUS
107+ UefiInitializeVideo (VOID )
108+ {
109+ EFI_STATUS Status ;
110+
111+ // First try UEFI GOP.
112+ Status = UefiInitializeGop ();
113+ if (Status == EFI_SUCCESS )
114+ {
115+ return Status ;
116+ }
117+
118+ // Fall back to Apple Screen Info Protocol if GOP is unavailable.
119+ Status = UefiInitializeAppleScreen ();
120+ if (Status != EFI_SUCCESS )
121+ {
122+ ERR ("Unable to find any suitable video modes!\n" );
123+ }
124+
125+ return Status ;
126+ }
127+
58128VOID
59129UefiPrintFramebufferData (VOID )
60130{
0 commit comments