1/*
2 * Copyright (c) 2012 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License").  You may not use this file except in compliance with the
9 * License.  Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22
23/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24
25typedef struct acpi_table_header
26{
27    uint8_t                   Reserved[0x24];
28} ACPI_TABLE_HEADER;
29
30/*******************************************************************************
31 *
32 * DMAR - DMA Remapping table
33 *        Version 1
34 *
35 * Conforms to "Intel Virtualization Technology for Directed I/O",
36 * Version 1.2, Sept. 2008
37 *
38 ******************************************************************************/
39
40typedef struct acpi_table_dmar
41{
42    ACPI_TABLE_HEADER         Header;             /* Common ACPI table header */
43    uint8_t                   Width;              /* Host Address Width */
44    uint8_t                   Flags;
45    uint8_t                   Reserved[10];
46
47} ACPI_TABLE_DMAR;
48
49/* Masks for Flags field above */
50
51#define ACPI_DMAR_INTR_REMAP        (1)
52
53
54/* DMAR subtable header */
55
56typedef struct acpi_dmar_header
57{
58    uint16_t                  Type;
59    uint16_t                  Length;
60
61} ACPI_DMAR_HEADER;
62
63/* Values for subtable type in ACPI_DMAR_HEADER */
64
65enum AcpiDmarType
66{
67    ACPI_DMAR_TYPE_HARDWARE_UNIT        = 0,
68    ACPI_DMAR_TYPE_RESERVED_MEMORY      = 1,
69    ACPI_DMAR_TYPE_ATSR                 = 2,
70    ACPI_DMAR_HARDWARE_AFFINITY         = 3,
71    ACPI_DMAR_TYPE_RESERVED             = 4     /* 4 and greater are reserved */
72};
73
74
75/* DMAR Device Scope structure */
76
77typedef struct acpi_dmar_device_scope
78{
79    uint8_t                   EntryType;
80    uint8_t                   Length;
81    uint16_t                  Reserved;
82    uint8_t                   EnumerationId;
83    uint8_t                   Bus;
84
85} ACPI_DMAR_DEVICE_SCOPE;
86
87/* Values for EntryType in ACPI_DMAR_DEVICE_SCOPE */
88
89enum AcpiDmarScopeType
90{
91    ACPI_DMAR_SCOPE_TYPE_NOT_USED       = 0,
92    ACPI_DMAR_SCOPE_TYPE_ENDPOINT       = 1,
93    ACPI_DMAR_SCOPE_TYPE_BRIDGE         = 2,
94    ACPI_DMAR_SCOPE_TYPE_IOAPIC         = 3,
95    ACPI_DMAR_SCOPE_TYPE_HPET           = 4,
96    ACPI_DMAR_SCOPE_TYPE_RESERVED       = 5     /* 5 and greater are reserved */
97};
98
99typedef struct acpi_dmar_pci_path
100{
101    uint8_t                   Device;
102    uint8_t                   Function;
103
104} ACPI_DMAR_PCI_PATH;
105
106
107/*
108 * DMAR Sub-tables, correspond to Type in ACPI_DMAR_HEADER
109 */
110
111/* 0: Hardware Unit Definition */
112
113typedef struct acpi_dmar_hardware_unit
114{
115    ACPI_DMAR_HEADER          Header;
116    uint8_t                   Flags;
117    uint8_t                   Reserved;
118    uint16_t                  Segment;
119    uint64_t                  Address;            /* Register Base Address */
120
121} ACPI_DMAR_HARDWARE_UNIT;
122
123/* Masks for Flags field above */
124
125#define ACPI_DMAR_INCLUDE_ALL       (1)
126
127
128/* 1: Reserved Memory Definition */
129
130typedef struct acpi_dmar_reserved_memory
131{
132    ACPI_DMAR_HEADER          Header;
133    uint16_t                  Reserved;
134    uint16_t                  Segment;
135    uint64_t                  BaseAddress;        /* 4K aligned base address */
136    uint64_t                  EndAddress;         /* 4K aligned limit address */
137
138} ACPI_DMAR_RESERVED_MEMORY;
139
140/* Masks for Flags field above */
141
142#define ACPI_DMAR_ALLOW_ALL         (1)
143
144
145/* 2: Root Port ATS Capability Reporting Structure */
146
147typedef struct acpi_dmar_atsr
148{
149    ACPI_DMAR_HEADER          Header;
150    uint8_t                   Flags;
151    uint8_t                   Reserved;
152    uint16_t                  Segment;
153
154} ACPI_DMAR_ATSR;
155
156/* Masks for Flags field above */
157
158#define ACPI_DMAR_ALL_PORTS         (1)
159
160
161/* 3: Remapping Hardware Static Affinity Structure */
162
163typedef struct acpi_dmar_rhsa
164{
165    ACPI_DMAR_HEADER          Header;
166    uint32_t                  Reserved;
167    uint64_t                  BaseAddress;
168    uint32_t                  ProximityDomain;
169
170} ACPI_DMAR_RHSA;
171
172