summaryrefslogtreecommitdiff
path: root/ReferenceCode/Chipset/SystemAgent/SaInit/Pei/GraphicsInit.h
blob: 6d060cbbc259ed2b54e74d9070409a683a480db2 (plain)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
/** @file
  Graphics header file

@copyright
  Copyright (c) 1999 - 2013 Intel Corporation. All rights reserved
  This software and associated documentation (if any) is furnished
  under a license and may only be used or copied in accordance
  with the terms of the license. Except as permitted by such
  license, no part of this software or documentation may be
  reproduced, stored in a retrieval system, or transmitted in any
  form or by any means without the express written consent of
  Intel Corporation.

  This file contains an 'Intel Peripheral Driver' and uniquely
  identified as "Intel Reference Module" and is
  licensed for Intel CPUs and chipsets under the terms of your
  license agreement with Intel or your vendor.  This file may
  be modified by the user, subject to additional terms of the
  license agreement
**/
#ifndef _GRAPHICS_INIT_H_
#define _GRAPHICS_INIT_H_

#include "EdkIIGluePeim.h"
#include "SaAccess.h"
#include "PchAccess.h"
#include "EdkIIGluePcdPciExpressLib.h"
#include "EdkIIGlueConfig.h"
#include "Pci22.h"
#include "PchPlatformLib.h"
#include "CpuRegs.h"
#include "CpuPlatformLib.h"

///
/// Driver Consumed PPI Prototypes
///
#include EFI_PPI_DEPENDENCY (SaPlatformPolicy)

typedef struct {
  UINT8   Bus;
  UINT8   Device;
  UINT8   Function;
  UINT16  DevenMask;
} PEG_DEVEN;

typedef enum {
  IGD               = 0,
  PEG,
  PCI,
  DISPLAY_DEVICE_MAX
} DISPLAY_DEVICE;

typedef enum {
  VBIOS_DEFAULT     = 0,
  CRT,
  LFP,
  CRT_LFP,
  TV,
  LFPSDVO,
  EFP,
  TVSDVO,
  CRT_LFPSDVO,
  CRT_EFP,
  IGD_BOOT_TYPE_MAX
} IGD_BOOT_TYPE;

typedef enum {
  GMS_FIXED         = 0,
  GMS_DVMT,
  GMS_FIXED_DVMT,
  GMS_MAX
} GRAPHICS_MEMORY_SELECTION;

typedef enum {
  GM_32M            = 1,
  GM_64M            = 2,
  GM_128M           = 4,
  GM_MAX
} STOLEN_MEMORY;

typedef enum {
  PAVP_DISABLED     = 0,
  PAVP_LITE,
  PAVP_HIGH
} PAVP_MODE;

#define GTTMMADR_SIZE_4MB   0x400000
#define GTT_SIZE_2MB        2
#define GT_WAIT_TIMEOUT     3000     ///< ~3 seconds

#define APERTURE_SIZE_128MB 1
#define APERTURE_SIZE_256MB 2
#define APERTURE_SIZE_512MB 3

/**
  CheckAndInitializePegVga:  Check if PEG card is present and configure accordingly

  @param[in] PeiServices             - Pointer to the PEI services table
  @param[in] AlwaysEnablePeg         - 0 - Peg is not always enabled.
  @param[in, out] PrimaryDisplay     - Primary Display - default is IGD
  @param[in] PrimaryDisplaySelection - Primary display selection from BIOS Setup
  @param[in, out] PegMmioLength      - Total PEG MMIO length on all PEG ports
**/
VOID
CheckAndInitializePegVga (
  IN     EFI_PEI_SERVICES                   **PeiServices,
  IN     UINT8                              AlwaysEnablePeg,
  IN OUT DISPLAY_DEVICE                     *PrimaryDisplay,
  IN     UINT8                              PrimaryDisplaySelection,
  IN OUT UINT32                             *PegMmioLength
  )
;

/**
  CheckOffboardPciVga: Check if off board PCI graphics Card is present

  @param[in] PeiServices          - Pointer to the PEI services table
  @param[in, out] PciMmioLength   - PCI MMIO length
  @param[in, out] PrimaryDisplay  - Primary Display - default is IGD
**/
VOID
CheckOffboardPciVga (
  IN     EFI_PEI_SERVICES                   **PeiServices,
  IN OUT UINT32                             *PciMmioLength,
  IN OUT DISPLAY_DEVICE                     *PrimaryDisplay
  )
;

/**
  CheckOffboardPcieVga: Check if off board PCIe graphics Card is present

  @param[in] PeiServices             - Pointer to the PEI services table
  @param[in, out] PchPcieMmioLength  - Total PCIe MMIO length on all PCH root ports
  @param[in, out] PrimaryDisplay     - Primary Display - default is IGD
**/
VOID
CheckOffboardPcieVga (
  IN     EFI_PEI_SERVICES     **PeiServices,
  IN OUT UINT32               *PchPcieMmioLength,
  IN OUT DISPLAY_DEVICE       *PrimaryDisplay
  )
;

/**
  Find the MMIO size that a given PCI device requires

  @param[in] BusNum      - Bus number of the device
  @param[in] DevNum      - device Number of the device
  @param[in] FunNum      - Function number of the device
  @param[out] MmioLength - MMIO Length in bytes
**/
VOID
FindPciDeviceMmioLength (
  IN UINT32  BusNum,
  IN UINT32  DevNum,
  IN UINT32  FunNum,
  OUT UINT32 *MmioLength
  )
;

/**
  This function enumerate all downstream bridge.

  @param[in] BusNum  - Primary bus number of current bridge

  @retval Current bus number: if current bus is an enpoint device
  @retval subordinate bus number: if current bus is a bridge
**/
UINT8
EnumerateDownstream (
  IN UINT8 BusNum
  )
;

/**
  This function enumerate the bridge on the device

  @param[in] PegBus             - Particular Bus number
  @param[in] PegDev             - Particular Device number
  @param[in] PegFunc            - Particular Func number
  @param[in, out] PegMmioLength - PEG MMIO length

  @retval CardDetect : TRUE if current bridge device has a Graphics card.
  @retval CardDetect : FALSE if current bridge device has no Graphics card.
**/
BOOLEAN
EnumerateBridgeDevice (
  IN UINT8                                  PegBus,
  IN UINT8                                  PegDev,
  IN UINT8                                  PegFunc,
  IN OUT UINT32                             *PegMmioLength
  )
;

/**

  "Poll Status" for GT Readiness

  @param[in] PeiServices     - Pointer to the PEI services table
  @param[in] StallPpi        - Pointer to Stall PPI
  @param[in] Base            - Base address of MMIO
  @param[in] Offset          - MMIO Offset
  @param[in] Mask            - Mask
  @param[in] Result          - Value to wait for


**/
VOID
PollGtReady (
  IN EFI_PEI_SERVICES     **PeiServices,
  IN PEI_STALL_PPI        *StallPpi,
  UINT64 Base,
  UINT32 Offset,
  UINT32 Mask,
  UINT32 Result
  )
;

#endif