claymation / osxp

EFI boot loader for running Windows XP on Intel Macs, from the 2006 Windows On Mac hacker challenge

This URL has Read+Write access

osxp / OSXP.h
100644 69 lines (57 sloc) 2.153 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/* 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