42#define NUM_VBE_MODES 3
50#define VBE_MODE_ENABLED 0x00BB
51#define VBE_MODE_DISABLED 0x00BA
56 VBE_MODE_DISABLED, 0x07, 0x00, 0x40, 0x40, 0xA000, 0x00, 0x0000, 640*4,
58 640, 480, 16, 8, 1, 32, 1, 0x06, 0, 0, 1,
60 0x08, 0x10, 0x08, 0x08, 0x08, 0x00, 0x08, 0x18, 0x00,
62 0xdeadbeef, 0x0000, 0x0000
66 VBE_MODE_DISABLED, 0x07, 0x00, 0x40, 0x40, 0xA000, 0x00, 0x0000, 800*4,
68 800, 600, 16, 8, 1, 32, 1, 0x06, 0, 0, 1,
70 0x08, 0x10, 0x08, 0x08, 0x08, 0x00, 0x08, 0x18, 0x00,
72 0xdeadbeef, 0x0000, 0x0000
76 VBE_MODE_ENABLED, 0x07, 0x00, 0x40, 0x40, 0xA000, 0x00, 0x0000, 1024*4,
78 1024, 768, 16, 8, 1, 32, 1, 0x06, 0, 0, 1,
80 0x08, 0x10, 0x08, 0x08, 0x08, 0x00, 0x08, 0x18, 0x00,
82 0xdeadbeef, 0x0000, 0x0000
130 Status =
gBS->AllocatePages (
137 if (EFI_ERROR (Status)) {
145 Handler = (Int0x10->Segment << 4) + Int0x10->Offset;
146 if ((Handler >= SegmentC) && (Handler < SegmentF)) {
149 "%a: Video BIOS handler found at %04x:%04x\n",
163 "%a: failed to allocate page at zero: %r\n",
172 ASSERT (Int0x10->Segment == 0x0000);
173 ASSERT (Int0x10->Offset == 0x0000);
187 PciWrite8 (Pam1Address, Pam1 | (BIT1 | BIT0));
197 CopyMem ((VOID *)(
UINTN)SegmentC, mVbeShim,
sizeof mVbeShim);
203 VbeInfo = &VbeInfoFull->Base;
204 Ptr = VbeInfoFull->Buffer;
206 CopyMem (VbeInfo->Signature,
"VESA", 4);
207 VbeInfo->VesaVersion = 0x0200;
209 VbeInfo->OemNameAddress = (UINT32)SegmentC << 12 | (UINT16)((
UINTN)Ptr-SegmentC);
213 VbeInfo->Capabilities = BIT1 | BIT0;
215 VbeInfo->ModeListAddress = (UINT32)SegmentC << 12 | (UINT16)((
UINTN)Ptr-SegmentC);
216 for (i = 0; i < NUM_VBE_MODES; i++) {
217 *(UINT16 *)Ptr = vbeModeIds[i];
221 *(UINT16 *)Ptr = 0xFFFF;
224 VbeInfo->VideoMem64K = (UINT16)((1024 * 768 * 4 + 65535) / 65536);
225 VbeInfo->OemSoftwareVersion = 0x0200;
227 VbeInfo->VendorNameAddress = (UINT32)SegmentC << 12 | (UINT16)((
UINTN)Ptr-SegmentC);
231 VbeInfo->ProductNameAddress = (UINT32)SegmentC << 12 | (UINT16)((
UINTN)Ptr-SegmentC);
234 sizeof VbeInfoFull->Buffer - (Ptr - VbeInfoFull->Buffer),
240 VbeInfo->ProductRevAddress = (UINT32)SegmentC << 12 | (UINT16)((
UINTN)Ptr-SegmentC);
241 CopyMem (Ptr, mProductRevision,
sizeof mProductRevision);
242 Ptr +=
sizeof mProductRevision;
244 ASSERT (
sizeof VbeInfoFull->Buffer >= Ptr - VbeInfoFull->Buffer);
245 ZeroMem (Ptr,
sizeof VbeInfoFull->Buffer - (Ptr - VbeInfoFull->Buffer));
251 Ptr = (UINT8 *)VbeModeInfo;
252 for (i = 0; i < NUM_VBE_MODES; i++) {
253 vbeModes[i].LfbAddress = (UINT32)FrameBufferBase;
254 CopyMem (Ptr, &vbeModes[i], 0x32);
263 PciWrite8 (Pam1Address, (Pam1 & ~BIT1) | BIT0);
268 Int0x10->Segment = (UINT16)((UINT32)SegmentC >> 4);
269 Int0x10->Offset = (UINT16)((
UINTN)(VbeModeInfo + 1) - SegmentC);
273 "%a: VBE shim installed to %x:%x\n",
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
UINTN EFIAPI AsciiSPrint(OUT CHAR8 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR8 *FormatString,...)
#define DEBUG(Expression)
UINT8 EFIAPI PciRead8(IN UINTN Address)
#define PCI_LIB_ADDRESS(Bus, Device, Function, Register)
UINT8 EFIAPI PciWrite8(IN UINTN Address, IN UINT8 Value)
UINT64 EFI_PHYSICAL_ADDRESS
#define EFI_PAGES_TO_SIZE(Pages)
VOID InstallVbeShim(IN CONST CHAR16 *CardName, IN EFI_PHYSICAL_ADDRESS FrameBufferBase)