Provide framebuffer information via system resource
This commit is contained in:
parent
2103b2dafd
commit
34cc81c446
@ -37,33 +37,36 @@ XTBL_BOOT_PROTOCOL XtBootProtocol;
|
|||||||
*/
|
*/
|
||||||
XTCDECL
|
XTCDECL
|
||||||
VOID
|
VOID
|
||||||
XtGetDisplayInformation(OUT PLOADER_GRAPHICS_INFORMATION_BLOCK InformationBlock,
|
XtGetDisplayInformation(OUT PSYSTEM_RESOURCE_FRAMEBUFFER FrameBufferResource,
|
||||||
IN PEFI_PHYSICAL_ADDRESS FrameBufferBase,
|
IN PEFI_PHYSICAL_ADDRESS FrameBufferBase,
|
||||||
IN PULONG_PTR FrameBufferSize,
|
IN PULONG_PTR FrameBufferSize,
|
||||||
IN PXTBL_FRAMEBUFFER_MODE_INFORMATION FrameBufferModeInfo)
|
IN PXTBL_FRAMEBUFFER_MODE_INFORMATION FrameBufferModeInfo)
|
||||||
{
|
{
|
||||||
InformationBlock->Initialized = TRUE;
|
/* Fill in frame buffer resource */
|
||||||
InformationBlock->Address = (PVOID)*FrameBufferBase;
|
FrameBufferResource->Header.PhysicalAddress = (PVOID)*FrameBufferBase;
|
||||||
InformationBlock->BufferSize = *FrameBufferSize;
|
FrameBufferResource->Header.ResourceType = SystemResourceFrameBuffer;
|
||||||
InformationBlock->Width = FrameBufferModeInfo->Width;
|
FrameBufferResource->Header.ResourceSize = sizeof(SYSTEM_RESOURCE_FRAMEBUFFER);
|
||||||
InformationBlock->Height = FrameBufferModeInfo->Height;
|
FrameBufferResource->BufferSize = *FrameBufferSize;
|
||||||
InformationBlock->BitsPerPixel = FrameBufferModeInfo->BitsPerPixel;
|
FrameBufferResource->Width = FrameBufferModeInfo->Width;
|
||||||
InformationBlock->PixelsPerScanLine = FrameBufferModeInfo->PixelsPerScanLine;
|
FrameBufferResource->Height = FrameBufferModeInfo->Height;
|
||||||
InformationBlock->Pitch = FrameBufferModeInfo->Pitch;
|
FrameBufferResource->Depth = FrameBufferModeInfo->Depth;
|
||||||
InformationBlock->Pixels.BlueShift = FrameBufferModeInfo->PixelInformation.BlueShift;
|
FrameBufferResource->BitsPerPixel = FrameBufferModeInfo->BitsPerPixel;
|
||||||
InformationBlock->Pixels.BlueSize = FrameBufferModeInfo->PixelInformation.BlueSize;
|
FrameBufferResource->PixelsPerScanLine = FrameBufferModeInfo->PixelsPerScanLine;
|
||||||
InformationBlock->Pixels.GreenShift = FrameBufferModeInfo->PixelInformation.GreenShift;
|
FrameBufferResource->Pitch = FrameBufferModeInfo->Pitch;
|
||||||
InformationBlock->Pixels.GreenSize = FrameBufferModeInfo->PixelInformation.GreenSize;
|
FrameBufferResource->Pixels.BlueShift = FrameBufferModeInfo->PixelInformation.BlueShift;
|
||||||
InformationBlock->Pixels.RedShift = FrameBufferModeInfo->PixelInformation.RedShift;
|
FrameBufferResource->Pixels.BlueSize = FrameBufferModeInfo->PixelInformation.BlueSize;
|
||||||
InformationBlock->Pixels.RedSize = FrameBufferModeInfo->PixelInformation.RedSize;
|
FrameBufferResource->Pixels.GreenShift = FrameBufferModeInfo->PixelInformation.GreenShift;
|
||||||
InformationBlock->Pixels.ReservedShift = FrameBufferModeInfo->PixelInformation.ReservedShift;
|
FrameBufferResource->Pixels.GreenSize = FrameBufferModeInfo->PixelInformation.GreenSize;
|
||||||
InformationBlock->Pixels.ReservedSize = FrameBufferModeInfo->PixelInformation.ReservedSize;
|
FrameBufferResource->Pixels.RedShift = FrameBufferModeInfo->PixelInformation.RedShift;
|
||||||
|
FrameBufferResource->Pixels.RedSize = FrameBufferModeInfo->PixelInformation.RedSize;
|
||||||
|
FrameBufferResource->Pixels.ReservedShift = FrameBufferModeInfo->PixelInformation.ReservedShift;
|
||||||
|
FrameBufferResource->Pixels.ReservedSize = FrameBufferModeInfo->PixelInformation.ReservedSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
XTCDECL
|
XTCDECL
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
XtGetMemoryDescriptorList(IN PXTBL_PAGE_MAPPING PageMap,
|
XtGetMemoryDescriptorList(IN PXTBL_PAGE_MAPPING PageMap,
|
||||||
IN PVOID VirtualAddress,
|
IN PVOID *VirtualAddress,
|
||||||
OUT PLIST_ENTRY MemoryDescriptorList)
|
OUT PLIST_ENTRY MemoryDescriptorList)
|
||||||
{
|
{
|
||||||
EFI_PHYSICAL_ADDRESS Address;
|
EFI_PHYSICAL_ADDRESS Address;
|
||||||
@ -78,7 +81,7 @@ XtGetMemoryDescriptorList(IN PXTBL_PAGE_MAPPING PageMap,
|
|||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = XtLdrProtocol->Memory.MapVirtualMemory(PageMap, VirtualAddress, (PVOID)Address, Pages, LoaderMemoryData);
|
Status = XtLdrProtocol->Memory.MapVirtualMemory(PageMap, *VirtualAddress, (PVOID)Address, Pages, LoaderMemoryData);
|
||||||
if(Status != STATUS_EFI_SUCCESS)
|
if(Status != STATUS_EFI_SUCCESS)
|
||||||
{
|
{
|
||||||
XtLdrProtocol->Memory.FreePages(Address, Pages);
|
XtLdrProtocol->Memory.FreePages(Address, Pages);
|
||||||
@ -104,7 +107,90 @@ XtGetMemoryDescriptorList(IN PXTBL_PAGE_MAPPING PageMap,
|
|||||||
ListEntry = ListEntry->Flink;
|
ListEntry = ListEntry->Flink;
|
||||||
}
|
}
|
||||||
|
|
||||||
XtLdrProtocol->Memory.PhysicalListToVirtual(PageMap, MemoryDescriptorList, PhysicalBase, VirtualAddress);
|
XtLdrProtocol->Memory.PhysicalListToVirtual(PageMap, MemoryDescriptorList, PhysicalBase, *VirtualAddress);
|
||||||
|
|
||||||
|
return STATUS_EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
XTCDECL
|
||||||
|
EFI_STATUS
|
||||||
|
XtGetSystemResourcesList(IN PXTBL_PAGE_MAPPING PageMap,
|
||||||
|
IN PVOID *VirtualAddress,
|
||||||
|
OUT PLIST_ENTRY SystemResourcesList)
|
||||||
|
{
|
||||||
|
XTSTATUS Status;
|
||||||
|
EFI_HANDLE ProtocolHandle;
|
||||||
|
EFI_GUID FrameBufGuid = XT_FRAMEBUFFER_PROTOCOL_GUID;
|
||||||
|
PXTBL_FRAMEBUFFER_PROTOCOL FrameBufProtocol;
|
||||||
|
XTBL_FRAMEBUFFER_MODE_INFORMATION FbModeInfo;
|
||||||
|
EFI_PHYSICAL_ADDRESS FbAddress;
|
||||||
|
ULONG_PTR FbSize;
|
||||||
|
UINT FrameBufferPages;
|
||||||
|
PSYSTEM_RESOURCE_FRAMEBUFFER FrameBufferResource;
|
||||||
|
ULONGLONG Pages;
|
||||||
|
EFI_PHYSICAL_ADDRESS Address;
|
||||||
|
PVOID VirtualBase;
|
||||||
|
|
||||||
|
Pages = (ULONGLONG)EFI_SIZE_TO_PAGES(3 * sizeof(SYSTEM_RESOURCE_FRAMEBUFFER));
|
||||||
|
|
||||||
|
Status = XtLdrProtocol->Memory.AllocatePages(Pages, &Address);
|
||||||
|
if(Status != STATUS_EFI_SUCCESS)
|
||||||
|
{
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
Status = XtLdrProtocol->Memory.MapVirtualMemory(PageMap, *VirtualAddress, (PVOID)Address, Pages, LoaderFirmwarePermanent);
|
||||||
|
if(Status != STATUS_EFI_SUCCESS)
|
||||||
|
{
|
||||||
|
XtLdrProtocol->Memory.FreePages(Address, Pages);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
FrameBufferResource = (PSYSTEM_RESOURCE_FRAMEBUFFER)Address;
|
||||||
|
PVOID PhysicalBase = (PVOID)Address;
|
||||||
|
VirtualBase = *VirtualAddress;
|
||||||
|
|
||||||
|
/* Calculate next valid virtual address */
|
||||||
|
*VirtualAddress += (UINT_PTR)(Pages * EFI_PAGE_SIZE);
|
||||||
|
|
||||||
|
RtlZeroMemory(FrameBufferResource, sizeof(SYSTEM_RESOURCE_FRAMEBUFFER));
|
||||||
|
|
||||||
|
/* Load FrameBuffer protocol */
|
||||||
|
Status = XtLdrProtocol->Protocol.Open(&ProtocolHandle, (PVOID*)&FrameBufProtocol, &FrameBufGuid);
|
||||||
|
if(Status == STATUS_EFI_SUCCESS)
|
||||||
|
{
|
||||||
|
/* Get FrameBuffer information */
|
||||||
|
Status = FrameBufProtocol->GetDisplayInformation(&FbAddress, &FbSize, &FbModeInfo);
|
||||||
|
if(Status == STATUS_EFI_SUCCESS)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* Store information about FrameBuffer device */
|
||||||
|
XtGetDisplayInformation(FrameBufferResource, &FbAddress, &FbSize, &FbModeInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(Status != STATUS_EFI_SUCCESS)
|
||||||
|
{
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Calculate pages needed to map framebuffer */
|
||||||
|
FrameBufferPages = EFI_SIZE_TO_PAGES(FbSize);
|
||||||
|
|
||||||
|
/* Rewrite framebuffer address by using virtual address */
|
||||||
|
FrameBufferResource->Header.VirtualAddress = *VirtualAddress;
|
||||||
|
|
||||||
|
/* Map frame buffer memory */
|
||||||
|
XtLdrProtocol->Memory.MapVirtualMemory(PageMap, FrameBufferResource->Header.VirtualAddress,
|
||||||
|
FrameBufferResource->Header.PhysicalAddress,
|
||||||
|
FrameBufferPages, LoaderFirmwarePermanent);
|
||||||
|
|
||||||
|
/* Close FrameBuffer protocol */
|
||||||
|
XtLdrProtocol->Protocol.Close(ProtocolHandle, &FrameBufGuid);
|
||||||
|
|
||||||
|
*VirtualAddress += (UINT_PTR)(FrameBufferPages * EFI_PAGE_SIZE);
|
||||||
|
|
||||||
|
RtlInsertTailList(SystemResourcesList, &FrameBufferResource->Header.ListEntry);
|
||||||
|
|
||||||
|
XtLdrProtocol->Memory.PhysicalListToVirtual(PageMap, SystemResourcesList, PhysicalBase, VirtualBase);
|
||||||
|
|
||||||
return STATUS_EFI_SUCCESS;
|
return STATUS_EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -424,16 +510,11 @@ XtpInitializeLoaderBlock(IN PXTBL_PAGE_MAPPING PageMap,
|
|||||||
IN PVOID *VirtualAddress,
|
IN PVOID *VirtualAddress,
|
||||||
IN PXTBL_BOOT_PARAMETERS Parameters)
|
IN PXTBL_BOOT_PARAMETERS Parameters)
|
||||||
{
|
{
|
||||||
EFI_GUID FrameBufGuid = XT_FRAMEBUFFER_PROTOCOL_GUID;
|
|
||||||
PXTBL_FRAMEBUFFER_PROTOCOL FrameBufProtocol;
|
|
||||||
XTBL_FRAMEBUFFER_MODE_INFORMATION FbModeInfo;
|
|
||||||
PKERNEL_INITIALIZATION_BLOCK LoaderBlock;
|
PKERNEL_INITIALIZATION_BLOCK LoaderBlock;
|
||||||
EFI_PHYSICAL_ADDRESS Address, FbAddress;
|
EFI_PHYSICAL_ADDRESS Address;
|
||||||
// PVOID RuntimeServices;
|
// PVOID RuntimeServices;
|
||||||
ULONG_PTR FbSize;
|
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_HANDLE ProtocolHandle;
|
UINT BlockPages;
|
||||||
UINT BlockPages, FrameBufferPages;
|
|
||||||
|
|
||||||
/* Calculate number of pages needed for initialization block */
|
/* Calculate number of pages needed for initialization block */
|
||||||
BlockPages = EFI_SIZE_TO_PAGES(sizeof(KERNEL_INITIALIZATION_BLOCK));
|
BlockPages = EFI_SIZE_TO_PAGES(sizeof(KERNEL_INITIALIZATION_BLOCK));
|
||||||
@ -458,30 +539,9 @@ XtpInitializeLoaderBlock(IN PXTBL_PAGE_MAPPING PageMap,
|
|||||||
/* Set LoaderInformation block properties */
|
/* Set LoaderInformation block properties */
|
||||||
LoaderBlock->LoaderInformation.DbgPrint = XtLdrProtocol->Debug.Print;
|
LoaderBlock->LoaderInformation.DbgPrint = XtLdrProtocol->Debug.Print;
|
||||||
|
|
||||||
/* Load FrameBuffer protocol */
|
|
||||||
Status = XtLdrProtocol->Protocol.Open(&ProtocolHandle, (PVOID*)&FrameBufProtocol, &FrameBufGuid);
|
|
||||||
if(Status == STATUS_EFI_SUCCESS)
|
|
||||||
{
|
|
||||||
/* Get FrameBuffer information */
|
|
||||||
Status = FrameBufProtocol->GetDisplayInformation(&FbAddress, &FbSize, &FbModeInfo);
|
|
||||||
if(Status == STATUS_EFI_SUCCESS)
|
|
||||||
{
|
|
||||||
/* Store information about FrameBuffer device */
|
|
||||||
XtGetDisplayInformation(&LoaderBlock->LoaderInformation.FrameBuffer, &FbAddress, &FbSize, &FbModeInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(Status != STATUS_EFI_SUCCESS)
|
|
||||||
{
|
|
||||||
/* No FrameBuffer available */
|
|
||||||
LoaderBlock->LoaderInformation.FrameBuffer.Initialized = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Store page map level */
|
/* Store page map level */
|
||||||
LoaderBlock->LoaderInformation.PageMapLevel = 3;
|
LoaderBlock->LoaderInformation.PageMapLevel = 3;
|
||||||
|
|
||||||
/* Close FrameBuffer protocol */
|
|
||||||
XtLdrProtocol->Protocol.Close(ProtocolHandle, &FrameBufGuid);
|
|
||||||
|
|
||||||
/* Attempt to find virtual address of the EFI Runtime Services */
|
/* Attempt to find virtual address of the EFI Runtime Services */
|
||||||
// Status = XtLdrProtocol->GetVirtualAddress(MemoryMappings, &EfiSystemTable->RuntimeServices->Hdr, &RuntimeServices);
|
// Status = XtLdrProtocol->GetVirtualAddress(MemoryMappings, &EfiSystemTable->RuntimeServices->Hdr, &RuntimeServices);
|
||||||
// if(Status == STATUS_EFI_SUCCESS)
|
// if(Status == STATUS_EFI_SUCCESS)
|
||||||
@ -508,27 +568,12 @@ XtpInitializeLoaderBlock(IN PXTBL_PAGE_MAPPING PageMap,
|
|||||||
/* Calculate next valid virtual address */
|
/* Calculate next valid virtual address */
|
||||||
*VirtualAddress += (UINT_PTR)(BlockPages * EFI_PAGE_SIZE);
|
*VirtualAddress += (UINT_PTR)(BlockPages * EFI_PAGE_SIZE);
|
||||||
|
|
||||||
/* Check if framebuffer initialized */
|
RtlInitializeListHead(&LoaderBlock->SystemResourcesListHead);
|
||||||
if(LoaderBlock->LoaderInformation.FrameBuffer.Initialized)
|
XtGetSystemResourcesList(PageMap, VirtualAddress, &LoaderBlock->SystemResourcesListHead);
|
||||||
{
|
|
||||||
/* Calculate pages needed to map framebuffer */
|
|
||||||
FrameBufferPages = EFI_SIZE_TO_PAGES(LoaderBlock->LoaderInformation.FrameBuffer.BufferSize);
|
|
||||||
|
|
||||||
/* Map frame buffer memory */
|
|
||||||
XtLdrProtocol->Memory.MapVirtualMemory(PageMap, *VirtualAddress,
|
|
||||||
LoaderBlock->LoaderInformation.FrameBuffer.Address,
|
|
||||||
FrameBufferPages, LoaderFirmwarePermanent);
|
|
||||||
|
|
||||||
/* Rewrite framebuffer address by using virtual address */
|
|
||||||
LoaderBlock->LoaderInformation.FrameBuffer.Address = *VirtualAddress;
|
|
||||||
|
|
||||||
/* Calcualate next valid virtual address */
|
|
||||||
*VirtualAddress += (UINT_PTR)(FrameBufferPages * EFI_PAGE_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Initialize memory descriptor list */
|
/* Initialize memory descriptor list */
|
||||||
RtlInitializeListHead(&LoaderBlock->MemoryDescriptorListHead);
|
RtlInitializeListHead(&LoaderBlock->MemoryDescriptorListHead);
|
||||||
XtGetMemoryDescriptorList(PageMap, *VirtualAddress, &LoaderBlock->MemoryDescriptorListHead);
|
XtGetMemoryDescriptorList(PageMap, VirtualAddress, &LoaderBlock->MemoryDescriptorListHead);
|
||||||
|
|
||||||
/* Return success */
|
/* Return success */
|
||||||
return STATUS_EFI_SUCCESS;
|
return STATUS_EFI_SUCCESS;
|
||||||
|
Loading…
Reference in New Issue
Block a user