Rework of EFI FrameBuffer module

This commit is contained in:
Rafal Kupiec 2024-01-28 15:03:55 +01:00
parent 4a67bc1230
commit 3c0a43d55a
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
13 changed files with 622 additions and 504 deletions

View File

@ -71,6 +71,9 @@ typedef EFI_STATUS (*PBL_EXECIMAGE_RELOCATE_IMAGE)(IN PVOID ImagePointer, IN EFI
typedef EFI_STATUS (*PBL_EXECIMAGE_VERIFY_IMAGE)(IN PVOID ImagePointer); typedef EFI_STATUS (*PBL_EXECIMAGE_VERIFY_IMAGE)(IN PVOID ImagePointer);
typedef EFI_STATUS (*PBL_EXIT_BOOT_SERVICES)(); typedef EFI_STATUS (*PBL_EXIT_BOOT_SERVICES)();
typedef EFI_STATUS (*PBL_FIND_BOOT_PROTOCOL)(IN PWCHAR SystemType, OUT PEFI_GUID BootProtocolGuid); typedef EFI_STATUS (*PBL_FIND_BOOT_PROTOCOL)(IN PWCHAR SystemType, OUT PEFI_GUID BootProtocolGuid);
typedef EFI_STATUS (*PBL_FRAMEBUFFER_GET_DISPLAY_DRIVER)(OUT PEFI_GRAPHICS_PROTOCOL Protocol);
typedef EFI_STATUS (*PBL_FRAMEBUFFER_GET_DISPLAY_INFORMATION)(OUT PXTBL_FRAMEBUFFER_INFORMATION FbInfo);
typedef EFI_STATUS (*PBL_FRAMEBUFFER_INITIALIZE)();
typedef EFI_STATUS (*PBL_FREE_PAGES)(IN UINT64 Size, IN EFI_PHYSICAL_ADDRESS Memory); typedef EFI_STATUS (*PBL_FREE_PAGES)(IN UINT64 Size, IN EFI_PHYSICAL_ADDRESS Memory);
typedef EFI_STATUS (*PBL_FREE_POOL)(IN PVOID Memory); typedef EFI_STATUS (*PBL_FREE_POOL)(IN PVOID Memory);
typedef EFI_STATUS (*PBL_GET_MEMORY_MAP)(OUT PEFI_MEMORY_MAP MemoryMap); typedef EFI_STATUS (*PBL_GET_MEMORY_MAP)(OUT PEFI_MEMORY_MAP MemoryMap);
@ -203,6 +206,33 @@ typedef struct _XTBL_STATUS
CPPORT SerialPort; CPPORT SerialPort;
} XTBL_STATUS, *PXTBL_STATUS; } XTBL_STATUS, *PXTBL_STATUS;
/* XT framebuffer information structure definition */
typedef struct _XTBL_FRAMEBUFFER_INFORMATION
{
BOOLEAN Initialized;
EFI_GRAPHICS_PROTOCOL Protocol;
EFI_PHYSICAL_ADDRESS FrameBufferBase;
ULONG_PTR FrameBufferSize;
UINT Width;
UINT Height;
UINT BitsPerPixel;
UINT BytesPerPixel;
UINT PixelsPerScanLine;
UINT Pitch;
EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;
struct
{
USHORT BlueMask;
USHORT BlueShift;
USHORT GreenMask;
USHORT GreenShift;
USHORT RedMask;
USHORT RedShift;
USHORT ReservedMask;
USHORT ReservedShift;
} PixelInformation;
} XTBL_FRAMEBUFFER_INFORMATION, *PXTBL_FRAMEBUFFER_INFORMATION;
/* XTLDR Boot protocol structure */ /* XTLDR Boot protocol structure */
typedef struct _XTBL_BOOT_PROTOCOL typedef struct _XTBL_BOOT_PROTOCOL
{ {
@ -222,7 +252,15 @@ typedef struct _XTBL_EXECUTABLE_IMAGE_PROTOCOL
PBL_EXECIMAGE_VERIFY_IMAGE VerifyImage; PBL_EXECIMAGE_VERIFY_IMAGE VerifyImage;
} XTBL_EXECUTABLE_IMAGE_PROTOCOL, *PXTBL_EXECUTABLE_IMAGE_PROTOCOL; } XTBL_EXECUTABLE_IMAGE_PROTOCOL, *PXTBL_EXECUTABLE_IMAGE_PROTOCOL;
/* XTLDR Loader protocol */ /* XT framebuffer support protocol structure */
typedef struct _XTBL_FRAMEBUFFER_PROTOCOL
{
PBL_FRAMEBUFFER_GET_DISPLAY_DRIVER GetDisplayDriver;
PBL_FRAMEBUFFER_GET_DISPLAY_INFORMATION GetDisplayInformation;
PBL_FRAMEBUFFER_INITIALIZE Initialize;
} XTBL_FRAMEBUFFER_PROTOCOL, *PXTBL_FRAMEBUFFER_PROTOCOL;
/* XTLDR Loader protocol structure */
typedef struct _XTBL_LOADER_PROTOCOL typedef struct _XTBL_LOADER_PROTOCOL
{ {
struct struct

View File

@ -277,6 +277,8 @@ typedef struct _XTBL_CONFIG_ENTRY XTBL_CONFIG_ENTRY, *PXTBL_CONFIG_ENTRY;
typedef struct _XTBL_CONFIG_SECTION XTBL_CONFIG_SECTION, *PXTBL_CONFIG_SECTION; typedef struct _XTBL_CONFIG_SECTION XTBL_CONFIG_SECTION, *PXTBL_CONFIG_SECTION;
typedef struct _XTBL_DIALOG_HANDLE XTBL_DIALOG_HANDLE, *PXTBL_DIALOG_HANDLE; typedef struct _XTBL_DIALOG_HANDLE XTBL_DIALOG_HANDLE, *PXTBL_DIALOG_HANDLE;
typedef struct _XTBL_EXECUTABLE_IMAGE_PROTOCOL XTBL_EXECUTABLE_IMAGE_PROTOCOL, *PXTBL_EXECUTABLE_IMAGE_PROTOCOL; typedef struct _XTBL_EXECUTABLE_IMAGE_PROTOCOL XTBL_EXECUTABLE_IMAGE_PROTOCOL, *PXTBL_EXECUTABLE_IMAGE_PROTOCOL;
typedef struct _XTBL_FRAMEBUFFER_INFORMATION XTBL_FRAMEBUFFER_INFORMATION, *PXTBL_FRAMEBUFFER_INFORMATION;
typedef struct _XTBL_FRAMEBUFFER_PROTOCOL XTBL_FRAMEBUFFER_PROTOCOL, *PXTBL_FRAMEBUFFER_PROTOCOL;
typedef struct _XTBL_KNOWN_BOOT_PROTOCOL XTBL_KNOWN_BOOT_PROTOCOL, *PXTBL_KNOWN_BOOT_PROTOCOL; typedef struct _XTBL_KNOWN_BOOT_PROTOCOL XTBL_KNOWN_BOOT_PROTOCOL, *PXTBL_KNOWN_BOOT_PROTOCOL;
typedef struct _XTBL_LOADER_PROTOCOL XTBL_LOADER_PROTOCOL, *PXTBL_LOADER_PROTOCOL; typedef struct _XTBL_LOADER_PROTOCOL XTBL_LOADER_PROTOCOL, *PXTBL_LOADER_PROTOCOL;
typedef struct _XTBL_MODULE_DEPS XTBL_MODULE_DEPS, *PXTBL_MODULE_DEPS; typedef struct _XTBL_MODULE_DEPS XTBL_MODULE_DEPS, *PXTBL_MODULE_DEPS;

View File

@ -1,6 +1,6 @@
add_subdirectory(beep) add_subdirectory(beep)
add_subdirectory(chainldr) add_subdirectory(chainldr)
add_subdirectory(dummy) add_subdirectory(dummy)
add_subdirectory(fb_o) add_subdirectory(framebuf)
add_subdirectory(pecoff) add_subdirectory(pecoff)
add_subdirectory(xtos_o) add_subdirectory(xtos_o)

View File

@ -1,27 +0,0 @@
# XT Boot Loader
PROJECT(XTLDR_FB_O)
# Specify include directories
include_directories(
${EXECTOS_SOURCE_DIR}/sdk/xtdk
${XTLDR_FB_O_SOURCE_DIR}/includes)
# Specify list of source code files
list(APPEND XTLDR_FB_O_SOURCE
${XTLDR_FB_O_SOURCE_DIR}/framebuf.c
${XTLDR_FB_O_SOURCE_DIR}/gop.c)
# Link bootloader executable
add_executable(fb_o ${XTLDR_FB_O_SOURCE})
# Add linker libraries
target_link_libraries(fb_o libxtldr)
# Set proper binary name and install target
set_target_properties(fb_o PROPERTIES SUFFIX .efi)
set_install_target(fb_o efi/boot/xtldr/modules)
# Set module entrypoint and subsystem
set_entrypoint(fb_o "XtLdrModuleMain")
set_linker_map(fb_o TRUE)
set_subsystem(fb_o efi_boot_service_driver)

View File

@ -1,337 +0,0 @@
/**
* PROJECT: ExectOS
* COPYRIGHT: See COPYING.md in the top level directory
* FILE: xtldr/modules/framebuf/framebuf.c
* DESCRIPTION: Boot loader framebuffer support
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
*/
#include <framebuf.h>
/* PE/COFF_O module information */
XTBL_MODINFO = L"EFI FB (FrameBuffer) support";
/* EFI XT Loader Protocol */
PXTBL_LOADER_PROTOCOL XtLdrProtocol;
/* XT FrameBuffer Information */
XT_FRAMEBUFFER_INFORMATION FrameBufferInfo;
/* XT FrameBuffer Protocol */
XT_FRAMEBUFFER_PROTOCOL XtFramebufferProtocol;
/**
* Provides a current FrameBuffer driver name.
*
* @param DriverName
* Supplies a pointer to the memory area where FB driver name will be stored.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTCDECL
VOID
FbGetDisplayDriver(OUT PWCHAR DriverName)
{
switch(FrameBufferInfo.Protocol)
{
case GOP:
DriverName = L"GOP";
break;
case UGA:
DriverName = L"UGA";
break;
default:
DriverName = L"NONE";
break;
}
}
/**
* Returns information about frame buffer in XTOS compatible format.
*
* @param InformationBlock
* A pointer to memory area containing XT structure where all the information will be stored.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTCDECL
VOID
FbGetDisplayInformation(OUT PLOADER_GRAPHICS_INFORMATION_BLOCK InformationBlock)
{
InformationBlock->Initialized = FrameBufferInfo.Initialized;
InformationBlock->Protocol = FrameBufferInfo.Protocol;
InformationBlock->Address = (PVOID)(ULONG_PTR)FrameBufferInfo.FrameBufferBase;
InformationBlock->BufferSize = FrameBufferInfo.FrameBufferSize;
InformationBlock->Width = FrameBufferInfo.HorizontalResolution;
InformationBlock->Height = FrameBufferInfo.VerticalResolution;
InformationBlock->BitsPerPixel = FrameBufferInfo.BitsPerPixel;
InformationBlock->PixelsPerScanLine = FrameBufferInfo.PixelsPerScanLine;
InformationBlock->Pitch = FrameBufferInfo.Pitch;
}
/**
* Initializes FrameBuffer device on GOP and UGA compatible adapters.
*
* @return This routine returns a status code.
*
* @since XT 1.0
*/
XTCDECL
EFI_STATUS
FbInitializeDisplay()
{
EFI_GUID GopGuid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
EFI_GUID UgaGuid = EFI_UNIVERSAL_GRAPHICS_ADAPTER_PROTOCOL_GUID;
UINT32 Parameter1, Parameter2;
EFI_HANDLE Handle;
EFI_STATUS Status;
/* Check if framebuffer already initialized */
if(!FrameBufferInfo.Initialized)
{
/* Initialize framebuffer */
XtLdrProtocol->Debug.Print(L"Initializing framebuffer device\n");
FrameBufferInfo.Protocol = NONE;
FrameBufferInfo.Initialized = FALSE;
/* Attempt to open GOP protocol */
Status = XtLdrProtocol->Protocol.Open(&Handle, (PVOID*)&FrameBufferInfo.Adapter.GOP, &GopGuid);
/* Check if Graphics Output Protocol is available */
if(Status == STATUS_EFI_SUCCESS)
{
/* Found GOP */
XtLdrProtocol->Debug.Print(L"Found GOP compatible display adapter\n");
/* Set framebuffer parameters */
FrameBufferInfo.HorizontalResolution = FrameBufferInfo.Adapter.GOP->Mode->Info->HorizontalResolution;
FrameBufferInfo.VerticalResolution = FrameBufferInfo.Adapter.GOP->Mode->Info->VerticalResolution;
FrameBufferInfo.BitsPerPixel = GoppGetBitsPerPixel();
FrameBufferInfo.BytesPerPixel = FrameBufferInfo.BitsPerPixel >> 3;
FrameBufferInfo.PixelsPerScanLine = FrameBufferInfo.Adapter.GOP->Mode->Info->PixelsPerScanLine;
FrameBufferInfo.PixelFormat = FrameBufferInfo.Adapter.GOP->Mode->Info->PixelFormat;
FrameBufferInfo.Pitch = FrameBufferInfo.PixelsPerScanLine * (FrameBufferInfo.BitsPerPixel / 8);
FrameBufferInfo.FrameBufferBase = FrameBufferInfo.Adapter.GOP->Mode->FrameBufferBase;
FrameBufferInfo.FrameBufferSize = FrameBufferInfo.Adapter.GOP->Mode->FrameBufferSize;
FrameBufferInfo.Protocol = GOP;
FrameBufferInfo.Initialized = TRUE;
/* Close GOP protocol */
Status = XtLdrProtocol->Protocol.Close(Handle, &GopGuid);
}
else
{
/* GOP is unavailable */
FrameBufferInfo.Adapter.GOP = NULL;
/* Attempt to open UGA protocol */
Status = XtLdrProtocol->Protocol.Open(&Handle, (PVOID*)&FrameBufferInfo.Adapter.UGA, &UgaGuid);
/* Check if Universal Graphics Adapter is available */
if(Status == STATUS_EFI_SUCCESS)
{
/* Found UGA */
XtLdrProtocol->Debug.Print(L"Found UGA compatible display adapter\n");
/* Get current mode */
Status = FrameBufferInfo.Adapter.UGA->GetMode(FrameBufferInfo.Adapter.UGA,
&FrameBufferInfo.HorizontalResolution,
&FrameBufferInfo.VerticalResolution,
&Parameter1, &Parameter2);
if(Status != STATUS_EFI_SUCCESS)
{
/* Unable to get current UGA mode */
XtLdrProtocol->Debug.Print(L"Failed to get current UGA mode (Status code: %lx)\n", Status);
FrameBufferInfo.Adapter.UGA = NULL;
}
else
{
/* Set framebuffer parameters */
FrameBufferInfo.BitsPerPixel = 32;
FrameBufferInfo.BytesPerPixel = 4;
FrameBufferInfo.PixelsPerScanLine = FrameBufferInfo.HorizontalResolution;
FrameBufferInfo.PixelFormat = PixelBlueGreenRedReserved8BitPerColor;
FrameBufferInfo.Pitch = FrameBufferInfo.PixelsPerScanLine * (FrameBufferInfo.BitsPerPixel / 8);
FrameBufferInfo.FrameBufferBase = 0;
FrameBufferInfo.FrameBufferSize = FrameBufferInfo.HorizontalResolution *
FrameBufferInfo.VerticalResolution *
FrameBufferInfo.BytesPerPixel + 1024;
FrameBufferInfo.Protocol = UGA;
/* Temporarily set this to FALSE, as we don't set FB base and we cannot use it anyway */
FrameBufferInfo.Initialized = FALSE;
}
/* Close UGA protocol */
XtLdrProtocol->Protocol.Close(Handle, &UgaGuid);
}
}
/* Make sure framebuffer initialized properly */
if(!FrameBufferInfo.Initialized)
{
/* GOP and UGA unavailable */
XtLdrProtocol->Debug.Print(L"No display adapter found\n");
return STATUS_EFI_NOT_FOUND;
}
}
/* Return success */
return STATUS_SUCCESS;
}
/**
* Prints important information about framebuffer.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTCDECL
VOID
FbPrintDisplayInformation()
{
PWCHAR DriverName = NULL;
PULONG Address;
/* Make sure frame buffer is initialized */
if(!FrameBufferInfo.Initialized)
{
/* No FrameBuffer */
XtLdrProtocol->Debug.Print(L"No display adapters initialized, unable to print video information\n");
return;
}
/* Get display driver name */
FbGetDisplayDriver(DriverName);
XtLdrTestGetFramebufferAddress(&Address);
/* Print video information */
XtLdrProtocol->Debug.Print(L"XTLDR Framebuffer information:\n"
L" FrameBuffer Address: 0x%lx\n"
L" FrameBuffer Size: %lu\n"
L" FrameBuffer Driver: %S\n",
FrameBufferInfo.FrameBufferBase, FrameBufferInfo.FrameBufferSize, DriverName);
XtLdrProtocol->Debug.Print(L" Current Resolution: %dx%dx%d\n"
L" Pixel Format: %u\n"
L" Pixels Per ScanLine: %u\n",
FrameBufferInfo.HorizontalResolution, FrameBufferInfo.VerticalResolution,
FrameBufferInfo.BitsPerPixel, FrameBufferInfo.PixelFormat,
FrameBufferInfo.PixelsPerScanLine);
XtLdrProtocol->Debug.Print(L" Hardware FB Address: 0x%lx\n", Address);
}
/**
* This routine is the entry point of the XT EFI boot loader module.
*
* @param ImageHandle
* Firmware-allocated handle that identifies the image.
*
* @param SystemTable
* Provides the EFI system table.
*
* @return This routine returns status code.
*
* @since XT 1.0
*/
XTCDECL
EFI_STATUS
XtLdrModuleMain(IN EFI_HANDLE ImageHandle,
IN PEFI_SYSTEM_TABLE SystemTable)
{
EFI_GUID Guid = XT_FRAMEBUFFER_PROTOCOL_GUID;
EFI_STATUS Status;
/* Open the XTLDR protocol */
Status = BlGetXtLdrProtocol(SystemTable, ImageHandle, &XtLdrProtocol);
if(Status != STATUS_EFI_SUCCESS)
{
/* Failed to open loader protocol */
return STATUS_EFI_PROTOCOL_ERROR;
}
XtFramebufferProtocol.GetDisplayDriver = FbGetDisplayDriver;
XtFramebufferProtocol.GetDisplayInformation = FbGetDisplayInformation;
XtFramebufferProtocol.Initialize = FbInitializeDisplay;
XtFramebufferProtocol.PrintDisplayInformation = FbPrintDisplayInformation;
/* Register XTOS boot protocol */
return XtLdrProtocol->Protocol.Install(&XtFramebufferProtocol, &Guid);
}
XTCDECL
EFI_STATUS
XtLdrTestGetFramebufferAddress(OUT PULONG *Address)
{
EFI_GUID PciIoGuid = EFI_PCI_IO_PROTOCOL_GUID;
PEFI_PCI_IO_PROTOCOL Io;
UINT_PTR HandlesCount;
EFI_HANDLE *Handles;
EFI_STATUS Status;
UINT Index;
Handles = NULL;
PEFI_ACPI_ADDRESS_SPACE_DESCRIPTOR BarInfo;
PVOID Addr;
UINT64 Size = 0;
PCI_TYPE0_DEVICE Pci;
Status = XtLdrProtocol->Protocol.LocateHandles(&Handles, &HandlesCount, &PciIoGuid);
if(Status != STATUS_EFI_SUCCESS)
{
XtLdrProtocol->Debug.Print(L"ERROR: Failed to get handles (Status Code: 0x%lx)\n", Status);
return Status;
}
for(Index = 0; Index < HandlesCount; Index++)
{
Status = XtLdrProtocol->Protocol.OpenHandle(Handles[Index], (PVOID *)&Io, &PciIoGuid);
if(Status != STATUS_EFI_SUCCESS)
{
XtLdrProtocol->Debug.Print(L"ERROR: Failed to open protocol (Status Code: 0x%lx)\n", Status);
continue;
}
Status = Io->Pci.Read(Io, EfiPciIoWidthUint32, 0, sizeof(Pci) / sizeof(UINT32), &Pci);
if(Status != STATUS_EFI_SUCCESS)
{
XtLdrProtocol->Debug.Print(L"ERROR: Failed to read class (Status Code: 0x%lx)\n", Status);
}
XtLdrProtocol->Debug.Print(L"Found device class: %u:%u.%u\n", Pci.Hdr.ClassCode[0], Pci.Hdr.ClassCode[1], Pci.Hdr.ClassCode[2]);
if(Pci.Hdr.ClassCode[2] != 0x03)
{
XtLdrProtocol->Protocol.Close(Handles[Index], &PciIoGuid);
continue;
}
for(UINT Bars = 0; Bars < 6; Bars++)
{
Status = Io->GetBarAttributes(Io, Bars, NULL, (VOID **)&BarInfo);
if(Status != STATUS_EFI_SUCCESS)
{
continue;
}
if(BarInfo->SpaceDescriptor == EFI_ACPI_ADDRESS64_SPACE_DESCRIPTOR &&
BarInfo->ResourceType == EFI_ACPI_ADDRESS_SPACE_TYPE_MEMORY)
{
if(BarInfo->AddressLength > Size)
{
Addr = (PVOID)(ULONG_PTR)(BarInfo->AddressRangeMin << 16);
Size = BarInfo->AddressLength;
}
}
}
}
*Address = (PULONG)Addr;
return STATUS_EFI_SUCCESS;
}

View File

@ -1,51 +0,0 @@
/**
* PROJECT: ExectOS
* COPYRIGHT: See COPYING.md in the top level directory
* FILE: xtldr/modules/fb_o/gop.c
* DESCRIPTION: Graphical Output Protocol (GOP) support
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
*/
#include <framebuf.h>
/**
* Returns a number of bits per pixel (BPP) in the current video mode.
*
* @return A number of bits per pixel.
*
* @since XT 1.0
*/
XTCDECL
UINT32
GoppGetBitsPerPixel()
{
UINT32 BitsPerPixel, CompoundMask;
switch(FrameBufferInfo.Adapter.GOP->Mode->Info->PixelFormat)
{
case PixelBlueGreenRedReserved8BitPerColor:
case PixelRedGreenBlueReserved8BitPerColor:
case PixelBltOnly:
BitsPerPixel = 32;
break;
case PixelBitMask:
BitsPerPixel = 32;
CompoundMask = FrameBufferInfo.Adapter.GOP->Mode->Info->PixelInformation.RedMask |
FrameBufferInfo.Adapter.GOP->Mode->Info->PixelInformation.GreenMask |
FrameBufferInfo.Adapter.GOP->Mode->Info->PixelInformation.BlueMask |
FrameBufferInfo.Adapter.GOP->Mode->Info->PixelInformation.ReservedMask;
while((CompoundMask & (1 << 31)) == 0)
{
BitsPerPixel--;
CompoundMask <<= 1;
}
break;
default:
BitsPerPixel = 0;
break;
}
/* Return bpp */
return BitsPerPixel;
}

View File

@ -1,83 +0,0 @@
/**
* PROJECT: ExectOS
* COPYRIGHT: See COPYING.md in the top level directory
* FILE: xtldr/modules/fb_o/includes/framebuf.h
* DESCRIPTION: Framebuffer support module header file
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
*/
#ifndef __XTLDR_MODULES_FRAMEBUF_H
#define __XTLDR_MODULES_FRAMEBUF_H
#include <xtblapi.h>
typedef VOID (*PXT_FRAMEBUFFER_GET_DISPLAY_DRIVER)(OUT PWCHAR DriverName);
typedef VOID (*PXT_FRAMEBUFFER_GET_DISPLAY_INFORMATION)(OUT PLOADER_GRAPHICS_INFORMATION_BLOCK InformationBlock);
typedef EFI_STATUS (*PXT_FRAMEBUFFER_INITIALIZE)();
typedef VOID (*PXT_FRAMEBUFFER_PRINT_DISPLAY_INFORMATION)();
/* XT framebuffer support protocol */
typedef struct _XT_FRAMEBUFFER_PROTOCOL
{
PXT_FRAMEBUFFER_GET_DISPLAY_DRIVER GetDisplayDriver;
PXT_FRAMEBUFFER_GET_DISPLAY_INFORMATION GetDisplayInformation;
PXT_FRAMEBUFFER_INITIALIZE Initialize;
PXT_FRAMEBUFFER_PRINT_DISPLAY_INFORMATION PrintDisplayInformation;
} XT_FRAMEBUFFER_PROTOCOL, *PXT_FRAMEBUFFER_PROTOCOL;
/* XT framebuffer information structure definition */
typedef struct _XT_FRAMEBUFFER_INFORMATION
{
BOOLEAN Initialized;
EFI_GRAPHICS_PROTOCOL Protocol;
union
{
PEFI_GRAPHICS_OUTPUT_PROTOCOL GOP;
PEFI_UNIVERSAL_GRAPHICS_ADAPTER_PROTOCOL UGA;
} Adapter;
UINT HorizontalResolution;
UINT VerticalResolution;
UINT BitsPerPixel;
UINT BytesPerPixel;
UINT PixelsPerScanLine;
UINT Pitch;
EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;
EFI_PHYSICAL_ADDRESS FrameBufferBase;
ULONG_PTR FrameBufferSize;
} XT_FRAMEBUFFER_INFORMATION, *PXT_FRAMEBUFFER_INFORMATION;
/* XT FrameBuffer Information */
EXTERN XT_FRAMEBUFFER_INFORMATION FrameBufferInfo;
/* FrameBuffer support protocol related routines forward references */
XTCDECL
VOID
FbGetDisplayDriver(OUT PWCHAR DriverName);
XTCDECL
VOID
FbGetDisplayInformation(OUT PLOADER_GRAPHICS_INFORMATION_BLOCK InformationBlock);
XTCDECL
EFI_STATUS
FbInitializeDisplay();
XTCDECL
VOID
FbPrintDisplayInformation();
XTCDECL
UINT32
GoppGetBitsPerPixel();
XTCDECL
EFI_STATUS
BlXtLdrModuleMain(IN EFI_HANDLE ImageHandle,
IN PEFI_SYSTEM_TABLE SystemTable);
XTCDECL
EFI_STATUS
XtLdrTestGetFramebufferAddress(OUT PULONG *Address);
#endif /* __XTLDR_MODULES_FRAMEBUF_H */

View File

@ -0,0 +1,27 @@
# XTLDR FrameBuffer support module
PROJECT(XTLDR_FRAMEBUF)
# Specify include directories
include_directories(
${EXECTOS_SOURCE_DIR}/sdk/xtdk
${XTLDR_FRAMEBUF_SOURCE_DIR}/includes)
# Specify list of source code files
list(APPEND XTLDR_FRAMEBUF_SOURCE
${XTLDR_FRAMEBUF_SOURCE_DIR}/framebuf.c
${XTLDR_FRAMEBUF_SOURCE_DIR}/globals.c)
# Link bootloader executable
add_executable(framebuf ${XTLDR_FRAMEBUF_SOURCE})
# Add linker libraries
target_link_libraries(framebuf libxtldr)
# Set proper binary name and install target
set_target_properties(framebuf PROPERTIES SUFFIX .efi)
set_install_target(framebuf efi/boot/xtldr/modules)
# Set module entrypoint and subsystem
set_entrypoint(framebuf "XtLdrModuleMain")
set_linker_map(framebuf TRUE)
set_subsystem(framebuf efi_boot_service_driver)

View File

@ -0,0 +1,438 @@
/**
* PROJECT: ExectOS
* COPYRIGHT: See COPYING.md in the top level directory
* FILE: xtldr/modules/framebuf/framebuf.c
* DESCRIPTION: EFI framebuffer support module for XTLDR
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
*/
#include <framebuf.h>
/* PE/COFF_O module information */
XTBL_MODINFO = L"EFI FB (FrameBuffer) support";
XTCDECL
EFI_STATUS
FbGetDisplayDriver(OUT PEFI_GRAPHICS_PROTOCOL Protocol)
{
/* Check if framebuffer is initialized */
if(!FbpDisplayInfo.Initialized)
{
/* Return error if framebuffer is not initialized */
return STATUS_EFI_NOT_READY;
}
/* Copy framebuffer driver information */
*Protocol = FbpDisplayInfo.Protocol;
/* Return success */
return STATUS_EFI_SUCCESS;
}
XTCDECL
EFI_STATUS
FbGetDisplayInformation(OUT PXTBL_FRAMEBUFFER_INFORMATION FbInfo)
{
/* Check if framebuffer is initialized */
if(!FbpDisplayInfo.Initialized)
{
/* Return error if framebuffer is not initialized */
return STATUS_EFI_NOT_READY;
}
/* Copy framebuffer information */
FbInfo->BitsPerPixel = FbpDisplayInfo.BitsPerPixel;
FbInfo->BytesPerPixel = FbpDisplayInfo.BytesPerPixel;
FbInfo->PixelFormat = FbpDisplayInfo.PixelFormat;
FbInfo->PixelInformation = FbpDisplayInfo.PixelInformation;
FbInfo->PixelsPerScanLine = FbpDisplayInfo.PixelsPerScanLine;
FbInfo->Width = FbpDisplayInfo.Width;
FbInfo->Height = FbpDisplayInfo.Height;
FbInfo->Pitch = FbpDisplayInfo.Pitch;
FbInfo->FrameBufferBase = FbpDisplayInfo.FrameBufferBase;
FbInfo->FrameBufferSize = FbpDisplayInfo.FrameBufferSize;
FbInfo->Protocol = FbpDisplayInfo.Protocol;
FbInfo->Initialized = FbpDisplayInfo.Initialized;
/* Return success */
return STATUS_EFI_SUCCESS;
}
/**
* Initializes FrameBuffer device on GOP and UGA compatible adapters.
*
* @return This routine returns a status code.
*
* @since XT 1.0
*/
XTCDECL
EFI_STATUS
FbInitializeDisplay()
{
EFI_GUID GopGuid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
EFI_GUID UgaGuid = EFI_UNIVERSAL_GRAPHICS_ADAPTER_PROTOCOL_GUID;
PEFI_UNIVERSAL_GRAPHICS_ADAPTER_PROTOCOL Uga;
PEFI_GRAPHICS_OUTPUT_PROTOCOL Gop;
EFI_PIXEL_BITMASK PixelBitMask;
UINT32 Depth, Refresh;
EFI_HANDLE Handle;
EFI_STATUS Status;
/* Check if framebuffer already initialized */
if(!FbpDisplayInfo.Initialized)
{
/* Set initial framebuffer state */
XtLdrProtocol->Debug.Print(L"Initializing framebuffer device\n");
FbpDisplayInfo.Protocol = NONE;
FbpDisplayInfo.Initialized = FALSE;
/* Attempt to open EFI GOP protocol */
Status = XtLdrProtocol->Protocol.Open(&Handle, (PVOID*)&Gop, &GopGuid);
/* Check if Graphics Output Protocol (GOP) is available */
if(Status == STATUS_EFI_SUCCESS)
{
/* Found GOP */
XtLdrProtocol->Debug.Print(L"Found EFI-GOP compatible display adapter\n");
/* Set framebuffer information */
FbpDisplayInfo.Protocol = GOP;
FbpDisplayInfo.Width = Gop->Mode->Info->HorizontalResolution;
FbpDisplayInfo.Height = Gop->Mode->Info->VerticalResolution;
FbpDisplayInfo.PixelsPerScanLine = Gop->Mode->Info->PixelsPerScanLine;
FbpDisplayInfo.PixelFormat = Gop->Mode->Info->PixelFormat;
/* Get pixel bit mask information */
PixelBitMask = Gop->Mode->Info->PixelInformation;
/* Set framebuffer address and size */
FbpDisplayInfo.FrameBufferBase = Gop->Mode->FrameBufferBase;
FbpDisplayInfo.FrameBufferSize = Gop->Mode->FrameBufferSize;
/* Close GOP protocol */
Status = XtLdrProtocol->Protocol.Close(Handle, &GopGuid);
}
else
{
/* GOP is unavailable, attempt to open UGA protocol */
Status = XtLdrProtocol->Protocol.Open(&Handle, (PVOID*)&Uga, &UgaGuid);
/* Check if Universal Graphics Adapter (UGA) is available */
if(Status == STATUS_EFI_SUCCESS)
{
/* Get current video mode */
Status = Uga->GetMode(Uga, &FbpDisplayInfo.Width, &FbpDisplayInfo.Height, &Depth, &Refresh);
if(Status != STATUS_EFI_SUCCESS)
{
/* Unable to get current UGA mode */
XtLdrProtocol->Debug.Print(L"ERROR: Failed to get current UGA mode (Status Code: 0x%lx)\n", Status);
/* Close UGA protocol and return error */
XtLdrProtocol->Protocol.Close(Handle, &UgaGuid);
return STATUS_EFI_DEVICE_ERROR;
}
/* Set framebuffer information */
FbpDisplayInfo.Protocol = UGA;
FbpDisplayInfo.PixelsPerScanLine = FbpDisplayInfo.Width;
FbpDisplayInfo.PixelFormat = PixelBlueGreenRedReserved8BitPerColor;
/* Get pixel bit mask information */
PixelBitMask = (EFI_PIXEL_BITMASK){0, 0, 0, 0};
/* Set framebuffer address */
Status = FbpFindFramebufferAddress(&FbpDisplayInfo.FrameBufferBase);
if(Status != STATUS_EFI_SUCCESS)
{
/* Unable to find framebuffer address */
XtLdrProtocol->Debug.Print(L"ERROR: Failed to get EFI FB address (Status Code: 0x%lx)\n", Status);
/* Close UGA protocol and return error */
XtLdrProtocol->Protocol.Close(Handle, &UgaGuid);
return STATUS_EFI_DEVICE_ERROR;
}
/* Set framebuffer size */
FbpDisplayInfo.FrameBufferSize = FbpDisplayInfo.Width *
FbpDisplayInfo.Height *
FbpDisplayInfo.BytesPerPixel + 1024;
/* Close UGA protocol */
XtLdrProtocol->Protocol.Close(Handle, &UgaGuid);
}
}
/* Make sure framebuffer initialized properly */
if(FbpDisplayInfo.Protocol == NONE)
{
/* GOP and UGA unavailable */
XtLdrProtocol->Debug.Print(L"WARNING: No display adapter found!\n");
return STATUS_EFI_NOT_FOUND;
}
/* Get pixel information */
FbpGetPixelInformation(&FbpDisplayInfo, &PixelBitMask);
/* Set additional framebuffer information */
FbpDisplayInfo.BytesPerPixel = FbpDisplayInfo.BitsPerPixel >> 3;
FbpDisplayInfo.Pitch = FbpDisplayInfo.PixelsPerScanLine * (FbpDisplayInfo.BitsPerPixel / 8);
/* Set framebuffer initialization flag */
FbpDisplayInfo.Initialized = TRUE;
}
/* Return success */
return STATUS_SUCCESS;
}
/**
* Finds a PCI Display Adapter and returns its framebuffer address.
*
* @param Address
* Supplies a pointer to the memory area where framebuffer address will be stored.
*
* @return This routine returns a status code.
*
* @since XT 1.0
*/
XTCDECL
EFI_STATUS
FbpFindFramebufferAddress(OUT PEFI_PHYSICAL_ADDRESS Address)
{
EFI_GUID PciIoGuid = EFI_PCI_IO_PROTOCOL_GUID;
PEFI_ACPI_ADDRESS_SPACE_DESCRIPTOR BarInfo;
PEFI_PCI_IO_PROTOCOL IoProtocol;
ULONGLONG FramebufAddressLength;
PCI_TYPE0_DEVICE PciDevice;
PVOID FramebufAddress;
UINT_PTR HandlesCount;
EFI_HANDLE *Handles;
EFI_STATUS Status;
UINT Index;
/* Initialize variables */
FramebufAddressLength = 0;
Handles = NULL;
/* Locate EFI_PCI_IO_PROTOCOL handles */
Status = XtLdrProtocol->Protocol.LocateHandles(&Handles, &HandlesCount, &PciIoGuid);
if(Status != STATUS_EFI_SUCCESS)
{
/* Failed to get handles, return error code */
XtLdrProtocol->Debug.Print(L"ERROR: Failed to get handles (Status Code: 0x%lx)\n", Status);
return Status;
}
/* Iterate through handles */
for(Index = 0; Index < HandlesCount; Index++)
{
/* Open EFI_PCI_IO_PROTOCOL handle */
Status = XtLdrProtocol->Protocol.OpenHandle(Handles[Index], (PVOID *)&IoProtocol, &PciIoGuid);
if(Status != STATUS_EFI_SUCCESS)
{
/* Failed to open protocol, continue with next handle */
XtLdrProtocol->Debug.Print(L"ERROR: Failed to open protocol (Status Code: 0x%lx)\n", Status);
continue;
}
/* Read PCI controller registers from PCI configuration space */
Status = IoProtocol->Pci.Read(IoProtocol, EfiPciIoWidthUint32, 0, sizeof(PciDevice) / sizeof(UINT), &PciDevice);
if(Status != STATUS_EFI_SUCCESS)
{
/* Failed to read PCI device class */
XtLdrProtocol->Debug.Print(L"ERROR: Failed to read class (Status Code: 0x%lx)\n", Status);
/* Close protocol and continue with next handle */
XtLdrProtocol->Protocol.Close(Handles[Index], &PciIoGuid);
continue;
}
/* Check if device is a graphics adapter */
if(PciDevice.Hdr.ClassCode[2] != 0x03)
{
/* Not a graphics adapter, close protocol and continue with next handle */
XtLdrProtocol->Protocol.Close(Handles[Index], &PciIoGuid);
continue;
}
/* Iterate through all PCI device's Base Address Registers (BARs) */
for(UINT Bars = 0; Bars < 6; Bars++)
{
/* Get BAR attributes */
Status = IoProtocol->GetBarAttributes(IoProtocol, Bars, NULL, (VOID **)&BarInfo);
if(Status != STATUS_EFI_SUCCESS)
{
/* Failed to get BAR attributes, continue with next BAR */
continue;
}
/* Check if this BAR is 'Memory Range' of 'ACPI QWORD Address Space' */
if(BarInfo->SpaceDescriptor == EFI_ACPI_ADDRESS64_SPACE_DESCRIPTOR &&
BarInfo->ResourceType == EFI_ACPI_ADDRESS_SPACE_TYPE_MEMORY)
{
/* Check if this BAR is the biggest we've seen so far */
if(BarInfo->AddressLength > FramebufAddressLength)
{
/* The biggest BAR should be the framebuffer; save its address and length */
FramebufAddress = (PVOID)(ULONG_PTR)(BarInfo->AddressRangeMin << 16);
FramebufAddressLength = BarInfo->AddressLength;
}
}
}
/* Close handle and continue with next one */
XtLdrProtocol->Protocol.Close(Handles[Index], &PciIoGuid);
}
/* Set framebuffer address and return success */
*Address = (EFI_PHYSICAL_ADDRESS)FramebufAddress;
return STATUS_EFI_SUCCESS;
}
XTCDECL
VOID
FbpGetColorMask(IN UINT EfiMask,
OUT PUSHORT ColorMask,
OUT PUSHORT ColorShift)
{
UINT Index, Mask;
/* Initialize variables */
Index = 0;
Mask = 1;
/* Make sure EfiMask is not zero */
if(EfiMask)
{
while((Index < 32) && ((EfiMask & Mask) == 0))
{
Index++;
Mask <<= 1;
}
/* Set color mask and shift */
*ColorShift = Index;
*ColorMask = (Mask >> Index);
}
else
{
/* Set default color mask and shift */
*ColorMask = 0;
*ColorShift = 0;
}
}
XTCDECL
VOID
FbpGetPixelInformation(IN OUT PXTBL_FRAMEBUFFER_INFORMATION FrameBufferInfo,
IN PEFI_PIXEL_BITMASK PixelsBitMask)
{
UINT CompoundMask;
/* Check reported pixel format */
switch(FrameBufferInfo->PixelFormat)
{
case PixelBlueGreenRedReserved8BitPerColor:
/* BGRR, 32 bits per pixel */
FrameBufferInfo->BitsPerPixel = 32;
FrameBufferInfo->PixelInformation.BlueMask = 0xFF;
FrameBufferInfo->PixelInformation.BlueShift = 0;
FrameBufferInfo->PixelInformation.GreenMask = 0xFF;
FrameBufferInfo->PixelInformation.GreenShift = 8;
FrameBufferInfo->PixelInformation.RedMask = 0xFF;
FrameBufferInfo->PixelInformation.RedShift = 16;
FrameBufferInfo->PixelInformation.ReservedMask = 0xFF;
FrameBufferInfo->PixelInformation.ReservedShift = 24;
break;
case PixelRedGreenBlueReserved8BitPerColor:
/* RGBR, 32 bits per pixel */
FrameBufferInfo->BitsPerPixel = 32;
FrameBufferInfo->PixelInformation.BlueMask = 0xFF;
FrameBufferInfo->PixelInformation.BlueShift = 16;
FrameBufferInfo->PixelInformation.GreenMask = 0xFF;
FrameBufferInfo->PixelInformation.GreenShift = 8;
FrameBufferInfo->PixelInformation.RedMask = 0xFF;
FrameBufferInfo->PixelInformation.RedShift = 0;
FrameBufferInfo->PixelInformation.ReservedMask = 0xFF;
FrameBufferInfo->PixelInformation.ReservedShift = 24;
break;
case PixelBitMask:
/* Assume 32 bits per pixel */
FrameBufferInfo->BitsPerPixel = 32;
/* Calculate compound mask */
CompoundMask = PixelsBitMask->RedMask |
PixelsBitMask->GreenMask |
PixelsBitMask->BlueMask |
PixelsBitMask->ReservedMask;
/* Recalculate bits per pixel */
while((CompoundMask & (1 << 31)) == 0)
{
FrameBufferInfo->BitsPerPixel--;
CompoundMask <<= 1;
}
/* Set pixel information */
FbpGetColorMask(PixelsBitMask->RedMask, &FrameBufferInfo->PixelInformation.RedMask,
&FrameBufferInfo->PixelInformation.RedShift);
FbpGetColorMask(PixelsBitMask->GreenMask, &FrameBufferInfo->PixelInformation.GreenMask,
&FrameBufferInfo->PixelInformation.GreenShift);
FbpGetColorMask(PixelsBitMask->BlueMask, &FrameBufferInfo->PixelInformation.BlueMask,
&FrameBufferInfo->PixelInformation.BlueShift);
FbpGetColorMask(PixelsBitMask->ReservedMask, &FrameBufferInfo->PixelInformation.ReservedMask,
&FrameBufferInfo->PixelInformation.ReservedShift);
break;
default:
/* Unknown pixel format */
FrameBufferInfo->BitsPerPixel = 0;
FrameBufferInfo->PixelInformation.BlueMask = 0x0;
FrameBufferInfo->PixelInformation.BlueShift = 0;
FrameBufferInfo->PixelInformation.GreenMask = 0x0;
FrameBufferInfo->PixelInformation.GreenShift = 0;
FrameBufferInfo->PixelInformation.RedMask = 0x0;
FrameBufferInfo->PixelInformation.RedShift = 0;
FrameBufferInfo->PixelInformation.ReservedMask = 0x0;
FrameBufferInfo->PixelInformation.ReservedShift = 0;
break;
}
}
/**
* This routine is the entry point of the XT EFI boot loader module.
*
* @param ImageHandle
* Firmware-allocated handle that identifies the image.
*
* @param SystemTable
* Provides the EFI system table.
*
* @return This routine returns status code.
*
* @since XT 1.0
*/
XTCDECL
EFI_STATUS
XtLdrModuleMain(IN EFI_HANDLE ImageHandle,
IN PEFI_SYSTEM_TABLE SystemTable)
{
EFI_GUID Guid = XT_FRAMEBUFFER_PROTOCOL_GUID;
EFI_STATUS Status;
/* Open the XTLDR protocol */
Status = BlGetXtLdrProtocol(SystemTable, ImageHandle, &XtLdrProtocol);
if(Status != STATUS_EFI_SUCCESS)
{
/* Failed to open loader protocol */
return STATUS_EFI_PROTOCOL_ERROR;
}
/* Set routines available via XTLDR framebuffer protocol */
FbpFrameBufferProtocol.GetDisplayDriver = FbGetDisplayDriver;
FbpFrameBufferProtocol.GetDisplayInformation = FbGetDisplayInformation;
FbpFrameBufferProtocol.Initialize = FbInitializeDisplay;
/* Register XTOS boot protocol */
return XtLdrProtocol->Protocol.Install(&FbpFrameBufferProtocol, &Guid);
}

View File

@ -0,0 +1,19 @@
/**
* PROJECT: ExectOS
* COPYRIGHT: See COPYING.md in the top level directory
* FILE: xtldr/modules/framebuf/globals.c
* DESCRIPTION: EFI framebuffer module global variables
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
*/
#include <framebuf.h>
/* Framebuffer display information */
XTBL_FRAMEBUFFER_INFORMATION FbpDisplayInfo;
/* Framebuffer protocol handler */
XTBL_FRAMEBUFFER_PROTOCOL FbpFrameBufferProtocol;
/* XTLDR protocol handler */
PXTBL_LOADER_PROTOCOL XtLdrProtocol;

View File

@ -0,0 +1,41 @@
/**
* PROJECT: ExectOS
* COPYRIGHT: See COPYING.md in the top level directory
* FILE: xtldr/modules/framebuf/includes/framebuf.h
* DESCRIPTION: EFI Framebuffer support module header file
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
*/
#ifndef __XTLDR_MODULES_FRAMEBUF_H
#define __XTLDR_MODULES_FRAMEBUF_H
#include <xtblapi.h>
#include <globals.h>
/* FrameBuffer support protocol related routines forward references */
XTCDECL
EFI_STATUS
FbInitializeDisplay();
XTCDECL
EFI_STATUS
FbpFindFramebufferAddress(OUT PEFI_PHYSICAL_ADDRESS Address);
XTCDECL
VOID
FbpGetColorMask(IN UINT EfiMask,
OUT PUSHORT ColorMask,
OUT PUSHORT ColorShift);
XTCDECL
VOID
FbpGetPixelInformation(IN OUT PXTBL_FRAMEBUFFER_INFORMATION FrameBufferInfo,
IN PEFI_PIXEL_BITMASK PixelsBitMask);
XTCDECL
EFI_STATUS
XtLdrModuleMain(IN EFI_HANDLE ImageHandle,
IN PEFI_SYSTEM_TABLE SystemTable);
#endif /* __XTLDR_MODULES_FRAMEBUF_H */

View File

@ -0,0 +1,24 @@
/**
* PROJECT: ExectOS
* COPYRIGHT: See COPYING.md in the top level directory
* FILE: xtldr/modules/framebuf/includes/globals.h
* DESCRIPTION: EFI Framebuffer module global variables
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
*/
#ifndef __XTLDR_MODULES_GLOBALS_H
#define __XTLDR_MODULES_GLOBALS_H
#include <xtblapi.h>
/* Framebuffer display information */
EXTERN XTBL_FRAMEBUFFER_INFORMATION FbpDisplayInfo;
/* Framebuffer protocol handler */
EXTERN XTBL_FRAMEBUFFER_PROTOCOL FbpFrameBufferProtocol;
/* XTLDR protocol handler */
EXTERN PXTBL_LOADER_PROTOCOL XtLdrProtocol;
#endif /* __XTLDR_MODULES_GLOBALS_H */

View File

@ -11,7 +11,7 @@
/* XTOS module information */ /* XTOS module information */
XTBL_MODINFO = L"XTOS boot protocol support"; XTBL_MODINFO = L"XTOS boot protocol support";
XTBL_MODDEPS = {L"fb_o", L"pecoff"}; XTBL_MODDEPS = {L"framebuf", L"pecoff"};
/* EFI XT Loader Protocol */ /* EFI XT Loader Protocol */
PXTBL_LOADER_PROTOCOL XtLdrProtocol; PXTBL_LOADER_PROTOCOL XtLdrProtocol;
@ -22,6 +22,32 @@ PXTBL_EXECUTABLE_IMAGE_PROTOCOL XtPeCoffProtocol;
/* XTOS Boot Protocol */ /* XTOS Boot Protocol */
XTBL_BOOT_PROTOCOL XtBootProtocol; XTBL_BOOT_PROTOCOL XtBootProtocol;
/**
* Returns information about frame buffer in XTOS compatible format.
*
* @param InformationBlock
* A pointer to memory area containing XT structure where all the information will be stored.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTCDECL
VOID
XtGetDisplayInformation(OUT PLOADER_GRAPHICS_INFORMATION_BLOCK InformationBlock,
IN PXTBL_FRAMEBUFFER_INFORMATION FrameBufferInfo)
{
InformationBlock->Initialized = FrameBufferInfo->Initialized;
InformationBlock->Protocol = FrameBufferInfo->Protocol;
InformationBlock->Address = (PVOID)(ULONG_PTR)FrameBufferInfo->FrameBufferBase;
InformationBlock->BufferSize = FrameBufferInfo->FrameBufferSize;
InformationBlock->Width = FrameBufferInfo->Width;
InformationBlock->Height = FrameBufferInfo->Height;
InformationBlock->BitsPerPixel = FrameBufferInfo->BitsPerPixel;
InformationBlock->PixelsPerScanLine = FrameBufferInfo->PixelsPerScanLine;
InformationBlock->Pitch = FrameBufferInfo->Pitch;
}
/** /**
* Starts the operating system according to the provided parameters using XTOS boot protocol. * Starts the operating system according to the provided parameters using XTOS boot protocol.
* *
@ -324,7 +350,8 @@ XtpInitializeLoaderBlock(IN PXTBL_PAGE_MAPPING PageMap,
IN PXTBL_BOOT_PARAMETERS Parameters) IN PXTBL_BOOT_PARAMETERS Parameters)
{ {
EFI_GUID FrameBufGuid = XT_FRAMEBUFFER_PROTOCOL_GUID; EFI_GUID FrameBufGuid = XT_FRAMEBUFFER_PROTOCOL_GUID;
PXT_FRAMEBUFFER_PROTOCOL FrameBufProtocol; PXTBL_FRAMEBUFFER_PROTOCOL FrameBufProtocol;
PXTBL_FRAMEBUFFER_INFORMATION FrameBufInfo = NULL;
PKERNEL_INITIALIZATION_BLOCK LoaderBlock; PKERNEL_INITIALIZATION_BLOCK LoaderBlock;
EFI_PHYSICAL_ADDRESS Address; EFI_PHYSICAL_ADDRESS Address;
// PVOID RuntimeServices; // PVOID RuntimeServices;
@ -361,10 +388,10 @@ XtpInitializeLoaderBlock(IN PXTBL_PAGE_MAPPING PageMap,
{ {
/* Make sure FrameBuffer is initialized */ /* Make sure FrameBuffer is initialized */
FrameBufProtocol->Initialize(); FrameBufProtocol->Initialize();
FrameBufProtocol->GetDisplayInformation(FrameBufInfo);
/* Store information about FrameBuffer device */ /* Store information about FrameBuffer device */
FrameBufProtocol->GetDisplayInformation(&LoaderBlock->LoaderInformation.FrameBuffer); XtGetDisplayInformation(&LoaderBlock->LoaderInformation.FrameBuffer, FrameBufInfo);
// FrameBufProtocol->PrintDisplayInformation();
} }
else else
{ {