blob: e1091fed675234a2baa527e1497410e7ed628a51 [file] [log] [blame]
zbao7d94cf92012-07-02 14:19:14 +08001/**
2 * @file
3 *
4 * Misc common definition
5 *
6 *
7 *
8 * @xrefitem bom "File Content Label" "Release Content"
9 * @e project: AGESA
10 * @e sub-project: GNB
11 * @e \$Revision: 63425 $ @e \$Date: 2011-12-22 11:24:10 -0600 (Thu, 22 Dec 2011) $
12 *
13 */
14/*
15*****************************************************************************
16*
Siyuan Wang641f00c2013-06-08 11:50:55 +080017 * Copyright (c) 2008 - 2012, Advanced Micro Devices, Inc.
18 * All rights reserved.
19 *
20 * Redistribution and use in source and binary forms, with or without
21 * modification, are permitted provided that the following conditions are met:
22 * * Redistributions of source code must retain the above copyright
23 * notice, this list of conditions and the following disclaimer.
24 * * Redistributions in binary form must reproduce the above copyright
25 * notice, this list of conditions and the following disclaimer in the
26 * documentation and/or other materials provided with the distribution.
27 * * Neither the name of Advanced Micro Devices, Inc. nor the names of
28 * its contributors may be used to endorse or promote products derived
29 * from this software without specific prior written permission.
30 *
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
32 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
33 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
34 * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
35 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
36 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
37 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
38 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
40 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
zbao7d94cf92012-07-02 14:19:14 +080041* ***************************************************************************
42*
43*/
44#ifndef _GNBIOMMU_H_
45#define _GNBIOMMU_H_
46
47#pragma pack (push, 1)
48
49
50/// IVRS block
51typedef enum {
52 IvrsIvhdBlock = 0x10, ///< I/O Virtualization Hardware Definition Block
53 IvrsIvmdBlock = 0x20, ///< I/O Virtualization Memory Definition Block for all peripherals
54 IvrsIvmdBlockSingle = 0x21, ///< IVMD block for specified peripheral
55 IvrsIvmdBlockRange = 0x22, ///< IVMD block for peripheral range
56 IvrsIvhdrBlock = 0x40, ///< IVHDR (Relative) block
57 IvrsIvmdrBlock = 0x50, ///< IVMDR (Relative) block for all peripherals
58 IvrsIvmdrBlockSingle = 0x51 ///< IVMDR block for last IVHDR
59} IVRS_BLOCK_TYPE;
60
61#define DEVICE_ID(PciAddress) (UINT16) (((PciAddress).Address.Bus << 8) | ((PciAddress).Address.Device << 3) | (PciAddress).Address.Function)
62
63/// IVHD entry types
64typedef enum {
65 IvhdEntryPadding = 0, ///< Table padding
66 IvhdEntrySelect = 2, ///< Select
67 IvhdEntryStartRange = 3, ///< Start Range
68 IvhdEntryEndRange = 4, ///< End Range
69 IvhdEntryAliasSelect = 66, ///< Alias select
70 IvhdEntryAliasStartRange = 67, ///< Alias start range
71 IvhdEntryExtendedSelect = 70, ///< Extended select
72 IvhdEntryExtendedStartRange = 71, ///< Extended Start range
73 IvhdEntrySpecialDevice = 72 ///< Special device
74} IVHD_ENTRY_TYPE;
75
76/// Special device variety
77typedef enum {
78 IvhdSpecialDeviceIoapic = 0x1, ///< IOAPIC
79 IvhdSpecialDeviceHpet = 0x2 ///< HPET
80} IVHD_SPECIAL_DEVICE;
81
82
83#define IVHD_FLAG_COHERENT BIT5
84#define IVHD_FLAG_IOTLBSUP BIT4
85#define IVHD_FLAG_ISOC BIT3
86#define IVHD_FLAG_RESPASSPW BIT2
87#define IVHD_FLAG_PASSPW BIT1
88#define IVHD_FLAG_PPRSUB BIT7
89#define IVHD_FLAG_PREFSUP BIT6
90
91#define IVHD_EFR_XTSUP_OFFSET 0
92#define IVHD_EFR_NXSUP_OFFSET 1
93#define IVHD_EFR_GTSUP_OFFSET 2
94#define IVHD_EFR_GLXSUP_OFFSET 3
95#define IVHD_EFR_IASUP_OFFSET 5
96#define IVHD_EFR_GASUP_OFFSET 6
97#define IVHD_EFR_HESUP_OFFSET 7
98#define IVHD_EFR_PASMAX_OFFSET 8
99#define IVHD_EFR_PNCOUNTERS_OFFSET 13
100#define IVHD_EFR_PNBANKS_OFFSET 17
101#define IVHD_EFR_MSINUMPPR_OFFSET 23
102#define IVHD_EFR_GATS_OFFSET 28
103#define IVHD_EFR_HATS_OFFSET 30
104
105#define IVINFO_HTATSRESV_MASK 0x00400000ul
106#define IVINFO_VASIZE_MASK 0x003F8000ul
107#define IVINFO_PASIZE_MASK 0x00007F00ul
108#define IVINFO_GASIZE_MASK 0x000000E0ul
109
110#define IVHD_INFO_MSINUM_OFFSET 0
111#define IVHD_INFO_UNITID_OFFSET 8
112
113#define IVMD_FLAG_EXCLUSION_RANGE BIT3
114#define IVMD_FLAG_IW BIT2
115#define IVMD_FLAG_IR BIT1
116#define IVMD_FLAG_UNITY BIT0
117
118/// IVRS header
119typedef struct {
120 UINT8 Sign[4]; ///< Signature
121 UINT32 TableLength; ///< Table Length
122 UINT8 Revision; ///< Revision
123 UINT8 Checksum; ///< Checksum
124 UINT8 OemId[6]; ///< OEM ID
125 UINT8 OemTableId[8]; ///< OEM Tabled ID
126 UINT32 OemRev; ///< OEM Revision
127 UINT8 CreatorId[4]; ///< Creator ID
128 UINT32 CreatorRev; ///< Creator Revision
129 UINT32 IvInfo; ///< IvInfo
130 UINT64 Reserved; ///< Reserved
131} IOMMU_IVRS_HEADER;
132
133/// IVRS IVHD Entry
134typedef struct {
135 UINT8 Type; ///< Type
136 UINT8 Flags; ///< Flags
137 UINT16 Length; ///< Length
138 UINT16 DeviceId; ///< DeviceId
139 UINT16 CapabilityOffset; ///< CapabilityOffset
140 UINT64 BaseAddress; ///< BaseAddress
141 UINT16 PciSegment; ///< Pci segment
142 UINT16 IommuInfo; ///< IOMMU info
143 UINT32 IommuEfr; ///< reserved
144} IVRS_IVHD_ENTRY;
145
146/// IVHD generic entry
147typedef struct {
148 UINT8 Type; ///< Type
149 UINT16 DeviceId; ///< Device id
150 UINT8 DataSetting; ///< Data settings
151} IVHD_GENERIC_ENTRY;
152
153///IVHD alias entry
154typedef struct {
155 UINT8 Type; ///< Type
156 UINT16 DeviceId; ///< Device id
157 UINT8 DataSetting; ///< Data settings
158 UINT8 Reserved; ///< Reserved
159 UINT16 AliasDeviceId; ///< Alias device id
160 UINT8 Reserved2; ///< Reserved
161} IVHD_ALIAS_ENTRY;
162
163///IVHD extended entry
164typedef struct {
165 UINT8 Type; ///< Type
166 UINT16 DeviceId; ///< Device id
167 UINT8 DataSetting; ///< Data settings
168 UINT32 ExtSetting; ///< Extended settings
169} IVHD_EXT_ENTRY;
170
171/// IVHD special entry
172typedef struct {
173 UINT8 Type; ///< Type
174 UINT16 Reserved; ///< Reserved
175 UINT8 DataSetting; ///< Data settings
176 UINT8 Handle; ///< Handle
177 UINT16 AliasDeviceId; ///< Alis device id
178 UINT8 Variety; ///< Variety
179} IVHD_SPECIAL_ENTRY;
180
181/// IVRS IVMD Entry
182typedef struct {
183 UINT8 Type; ///< Type
184 UINT8 Flags; ///< Flags
185 UINT16 Length; ///< Length
186 UINT16 DeviceId; ///< DeviceId
187 UINT16 AuxiliaryData; ///< Auxiliary data
188 UINT64 Reserved; ///< Reserved (0000_0000_0000_0000)
189 UINT64 BlockStart; ///< IVMD start address
190 UINT64 BlockLength; ///< IVMD memory block length
191} IVRS_IVMD_ENTRY;
192
193#pragma pack (pop)
194
195#endif