/* EFI library includes */
#include <EfiBind.h>
#include <EfiTypes.h>
#include <EfiCommon.h>
#include <EfiApi.h>
#include <EfiDriverLib.h>
#include <EfiDevicePath.h>
/* Protocol headers */
#include EFI_PROTOCOL_DEFINITION (ConsoleControl)
#include EFI_PROTOCOL_DEFINITION (LoadedImage)
#include EFI_PROTOCOL_DEFINITION (DevicePath)
#include EFI_PROTOCOL_DEFINITION (BlockIO)
/* Utility functions */
static void InitScreen();
static EFI_STATUS InstallMBR();
static void ReadCD();
static void InstallIVT();
UINT32 peek32(UINT32 address);
void poke32(UINT32 address, UINT32 value);
UINT16 peek16(UINT32 address);
void poke16(UINT32 address, UINT16 value);
UINT8 peek8(UINT32 address);
void poke8(UINT32 address, UINT8 value);
void Set80x25();
void Set80x50();
/* Macros */
#ifdef __DEBUG__
#define Debug(...) Print(__VA_ARGS__)
#define Pause(...) { int i; for (i = 0; i < 1000000000; i++); }
#else
#define Debug(...)
#define Pause(...)
#endif
#define HANG { for (;;); }
/* Globals */
extern EFI_BLOCK_IO_PROTOCOL *BootDrive;
extern EFI_BLOCK_IO_PROTOCOL *CD;
extern EFI_BLOCK_IO_PROTOCOL *HD;
extern EFI_HANDLE *gIH;
/* PCI, PCI Express, and i945 GMCH registers */
/* These are used to get/set PCI configuration */
#define PCI_CONFIG_ADDRESS 0x0cf8
#define PCI_CONFIG_DATA 0x0cfc
#define PCI_CONFIG_ENABLE 0x80000000
/* These are used to get the PCI Express configuration base address */
#define PCI_PCIEXBAR 0x00000048 // PCI Express base address
#define PCI_PCIEXBAR_MASK 0xFC000000 // Used to mask out address
/* These are various Bus 0/Device 0/Function 0 registers and their values */
#define PCI_GCC 0x52 // GMCH Graphics Control
#define PCI_GCC_DISABLE_IGD 0x02 // IGD VGA Disable
#define PCI_DEVEN 0x54 // Device enable
#define PCI_DEVEN_DISABLE_IGD 0x03 // Maybe 0x3 is good :)
#define PCI_LAC 0x97 // Legacy Access Control
#define PCI_LAC_DISABLE_MDA 0x00 // Monochrome (MDA) not present
/* These are various Bus 0/Device 1/Function 0 registers and their values */
#define PCI_BCTRL1 0x3E // Bridge control
#define PCI_BCTRL1_VGA_ENABLE 0x0c // Enables VGA and ISA