summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/Bhyve/BhyveRfbDxe/VbeShim.c
diff options
context:
space:
mode:
Diffstat (limited to 'OvmfPkg/Bhyve/BhyveRfbDxe/VbeShim.c')
-rw-r--r--OvmfPkg/Bhyve/BhyveRfbDxe/VbeShim.c141
1 files changed, 80 insertions, 61 deletions
diff --git a/OvmfPkg/Bhyve/BhyveRfbDxe/VbeShim.c b/OvmfPkg/Bhyve/BhyveRfbDxe/VbeShim.c
index 740b966794..41f0180001 100644
--- a/OvmfPkg/Bhyve/BhyveRfbDxe/VbeShim.c
+++ b/OvmfPkg/Bhyve/BhyveRfbDxe/VbeShim.c
@@ -28,8 +28,8 @@
#pragma pack (1)
typedef struct {
- UINT16 Offset;
- UINT16 Segment;
+ UINT16 Offset;
+ UINT16 Segment;
} IVT_ENTRY;
#pragma pack ()
@@ -37,52 +37,49 @@ typedef struct {
// This string is displayed by Windows 2008 R2 SP1 in the Screen Resolution,
// Advanced Settings dialog. It should be short.
//
-STATIC CONST CHAR8 mProductRevision[] = "2.0";
+STATIC CONST CHAR8 mProductRevision[] = "2.0";
-#define NUM_VBE_MODES 3
-STATIC CONST UINT16 vbeModeIds[] = {
+#define NUM_VBE_MODES 3
+STATIC CONST UINT16 vbeModeIds[] = {
0x13f, // 640x480x32
0x140, // 800x600x32
0x141 // 1024x768x32
};
// Modes can be toggled with bit-0
-#define VBE_MODE_ENABLED 0x00BB
-#define VBE_MODE_DISABLED 0x00BA
+#define VBE_MODE_ENABLED 0x00BB
+#define VBE_MODE_DISABLED 0x00BA
-STATIC VBE2_MODE_INFO vbeModes[] = {
+STATIC VBE2_MODE_INFO vbeModes[] = {
{ // 0x13f 640x480x32
-
// ModeAttr - BytesPerScanLine
- VBE_MODE_DISABLED, 0x07, 0x00, 0x40, 0x40, 0xA000, 0x00, 0x0000, 640*4,
+ VBE_MODE_DISABLED, 0x07, 0x00, 0x40, 0x40, 0xA000, 0x00, 0x0000, 640*4,
// Width, Height..., Vbe3
- 640, 480, 16, 8, 1, 32, 1, 0x06, 0, 0, 1,
+ 640, 480, 16, 8, 1, 32, 1, 0x06, 0, 0, 1,
// Masks
- 0x08, 0x10, 0x08, 0x08, 0x08, 0x00, 0x08, 0x18, 0x00,
+ 0x08, 0x10, 0x08, 0x08, 0x08, 0x00, 0x08, 0x18, 0x00,
// Framebuffer
- 0xdeadbeef, 0x0000, 0x0000
+ 0xdeadbeef, 0x0000, 0x0000
},
{ // 0x140 800x600x32
-
// ModeAttr - BytesPerScanLine
- VBE_MODE_DISABLED, 0x07, 0x00, 0x40, 0x40, 0xA000, 0x00, 0x0000, 800*4,
+ VBE_MODE_DISABLED, 0x07, 0x00, 0x40, 0x40, 0xA000, 0x00, 0x0000, 800*4,
// Width, Height..., Vbe3
- 800, 600, 16, 8, 1, 32, 1, 0x06, 0, 0, 1,
+ 800, 600, 16, 8, 1, 32, 1, 0x06, 0, 0, 1,
// Masks
- 0x08, 0x10, 0x08, 0x08, 0x08, 0x00, 0x08, 0x18, 0x00,
+ 0x08, 0x10, 0x08, 0x08, 0x08, 0x00, 0x08, 0x18, 0x00,
// Framebuffer
- 0xdeadbeef, 0x0000, 0x0000
+ 0xdeadbeef, 0x0000, 0x0000
},
{ // 0x141 1024x768x32
-
// ModeAttr - BytesPerScanLine
- VBE_MODE_ENABLED, 0x07, 0x00, 0x40, 0x40, 0xA000, 0x00, 0x0000, 1024*4,
+ VBE_MODE_ENABLED, 0x07, 0x00, 0x40, 0x40, 0xA000, 0x00, 0x0000, 1024*4,
// Width, Height..., Vbe3
- 1024, 768, 16, 8, 1, 32, 1, 0x06, 0, 0, 1,
+ 1024, 768, 16, 8, 1, 32, 1, 0x06, 0, 0, 1,
// Masks
- 0x08, 0x10, 0x08, 0x08, 0x08, 0x00, 0x08, 0x18, 0x00,
+ 0x08, 0x10, 0x08, 0x08, 0x08, 0x00, 0x08, 0x18, 0x00,
// Framebuffer
- 0xdeadbeef, 0x0000, 0x0000
+ 0xdeadbeef, 0x0000, 0x0000
}
};
@@ -98,23 +95,23 @@ STATIC VBE2_MODE_INFO vbeModes[] = {
**/
VOID
InstallVbeShim (
- IN CONST CHAR16 *CardName,
- IN EFI_PHYSICAL_ADDRESS FrameBufferBase
+ IN CONST CHAR16 *CardName,
+ IN EFI_PHYSICAL_ADDRESS FrameBufferBase
)
{
- EFI_PHYSICAL_ADDRESS Segment0, SegmentC, SegmentF;
- UINTN Segment0Pages;
- IVT_ENTRY *Int0x10;
- EFI_STATUS Status;
- UINTN Pam1Address;
- UINT8 Pam1;
- UINTN SegmentCPages;
- VBE_INFO *VbeInfoFull;
- VBE_INFO_BASE *VbeInfo;
- UINT8 *Ptr;
- UINTN Printed;
- VBE_MODE_INFO *VbeModeInfo;
- UINTN i;
+ EFI_PHYSICAL_ADDRESS Segment0, SegmentC, SegmentF;
+ UINTN Segment0Pages;
+ IVT_ENTRY *Int0x10;
+ EFI_STATUS Status;
+ UINTN Pam1Address;
+ UINT8 Pam1;
+ UINTN SegmentCPages;
+ VBE_INFO *VbeInfoFull;
+ VBE_INFO_BASE *VbeInfo;
+ UINT8 *Ptr;
+ UINTN Printed;
+ VBE_MODE_INFO *VbeModeInfo;
+ UINTN i;
Segment0 = 0x00000;
SegmentC = 0xC0000;
@@ -130,11 +127,15 @@ InstallVbeShim (
//
Segment0Pages = 1;
Int0x10 = (IVT_ENTRY *)(UINTN)Segment0 + 0x10;
- Status = gBS->AllocatePages (AllocateAddress, EfiBootServicesCode,
- Segment0Pages, &Segment0);
+ Status = gBS->AllocatePages (
+ AllocateAddress,
+ EfiBootServicesCode,
+ Segment0Pages,
+ &Segment0
+ );
if (EFI_ERROR (Status)) {
- EFI_PHYSICAL_ADDRESS Handler;
+ EFI_PHYSICAL_ADDRESS Handler;
//
// Check if a video BIOS handler has been installed previously -- we
@@ -142,9 +143,14 @@ InstallVbeShim (
// it's already present.
//
Handler = (Int0x10->Segment << 4) + Int0x10->Offset;
- if (Handler >= SegmentC && Handler < SegmentF) {
- DEBUG ((DEBUG_VERBOSE, "%a: Video BIOS handler found at %04x:%04x\n",
- __FUNCTION__, Int0x10->Segment, Int0x10->Offset));
+ if ((Handler >= SegmentC) && (Handler < SegmentF)) {
+ DEBUG ((
+ DEBUG_VERBOSE,
+ "%a: Video BIOS handler found at %04x:%04x\n",
+ __FUNCTION__,
+ Int0x10->Segment,
+ Int0x10->Offset
+ ));
return;
}
@@ -152,8 +158,12 @@ InstallVbeShim (
// Otherwise we'll overwrite the Int10h vector, even though we may not own
// the page at zero.
//
- DEBUG ((DEBUG_VERBOSE, "%a: failed to allocate page at zero: %r\n",
- __FUNCTION__, Status));
+ DEBUG ((
+ DEBUG_VERBOSE,
+ "%a: failed to allocate page at zero: %r\n",
+ __FUNCTION__,
+ Status
+ ));
} else {
//
// We managed to allocate the page at zero. SVN r14218 guarantees that it
@@ -203,14 +213,15 @@ InstallVbeShim (
VbeInfo->Capabilities = BIT1 | BIT0; // DAC can be switched into 8-bit mode
VbeInfo->ModeListAddress = (UINT32)SegmentC << 12 | (UINT16)((UINTN)Ptr-SegmentC);
- for (i = 0; i < NUM_VBE_MODES; i ++) {
- *(UINT16*)Ptr = vbeModeIds[i]; // mode number
- Ptr += 2;
+ for (i = 0; i < NUM_VBE_MODES; i++) {
+ *(UINT16 *)Ptr = vbeModeIds[i]; // mode number
+ Ptr += 2;
}
- *(UINT16*)Ptr = 0xFFFF; // mode list terminator
- Ptr += 2;
- VbeInfo->VideoMem64K = (UINT16)((1024 * 768 * 4 + 65535) / 65536);
+ *(UINT16 *)Ptr = 0xFFFF; // mode list terminator
+ Ptr += 2;
+
+ VbeInfo->VideoMem64K = (UINT16)((1024 * 768 * 4 + 65535) / 65536);
VbeInfo->OemSoftwareVersion = 0x0200;
VbeInfo->VendorNameAddress = (UINT32)SegmentC << 12 | (UINT16)((UINTN)Ptr-SegmentC);
@@ -218,9 +229,12 @@ InstallVbeShim (
Ptr += 5;
VbeInfo->ProductNameAddress = (UINT32)SegmentC << 12 | (UINT16)((UINTN)Ptr-SegmentC);
- Printed = AsciiSPrint ((CHAR8 *)Ptr,
- sizeof VbeInfoFull->Buffer - (Ptr - VbeInfoFull->Buffer), "%s",
- CardName);
+ Printed = AsciiSPrint (
+ (CHAR8 *)Ptr,
+ sizeof VbeInfoFull->Buffer - (Ptr - VbeInfoFull->Buffer),
+ "%s",
+ CardName
+ );
Ptr += Printed + 1;
VbeInfo->ProductRevAddress = (UINT32)SegmentC << 12 | (UINT16)((UINTN)Ptr-SegmentC);
@@ -234,7 +248,7 @@ InstallVbeShim (
// Fill in the VBE MODE INFO structure list
//
VbeModeInfo = (VBE_MODE_INFO *)(VbeInfoFull + 1);
- Ptr = (UINT8 *)VbeModeInfo;
+ Ptr = (UINT8 *)VbeModeInfo;
for (i = 0; i < NUM_VBE_MODES; i++) {
vbeModes[i].LfbAddress = (UINT32)FrameBufferBase;
CopyMem (Ptr, &vbeModes[i], 0x32);
@@ -251,9 +265,14 @@ InstallVbeShim (
//
// Second, point the Int10h vector at the shim.
//
- Int0x10->Segment = (UINT16) ((UINT32)SegmentC >> 4);
- Int0x10->Offset = (UINT16) ((UINTN) (VbeModeInfo + 1) - SegmentC);
-
- DEBUG ((DEBUG_INFO, "%a: VBE shim installed to %x:%x\n",
- __FUNCTION__, Int0x10->Segment, Int0x10->Offset));
+ Int0x10->Segment = (UINT16)((UINT32)SegmentC >> 4);
+ Int0x10->Offset = (UINT16)((UINTN)(VbeModeInfo + 1) - SegmentC);
+
+ DEBUG ((
+ DEBUG_INFO,
+ "%a: VBE shim installed to %x:%x\n",
+ __FUNCTION__,
+ Int0x10->Segment,
+ Int0x10->Offset
+ ));
}