• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2014 LunarG, Inc.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included
12  * in all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20  * DEALINGS IN THE SOFTWARE.
21  */
22 
23 #ifndef GENHW_H
24 #define GENHW_H
25 
26 #include <stdbool.h>
27 #include <stdint.h>
28 #include <assert.h>
29 
30 #include "gen_regs.xml.h"
31 #include "gen_mi.xml.h"
32 #include "gen_blitter.xml.h"
33 #include "gen_render.xml.h"
34 #include "gen_render_surface.xml.h"
35 #include "gen_render_dynamic.xml.h"
36 #include "gen_render_3d.xml.h"
37 #include "gen_render_media.xml.h"
38 #include "gen_eu_isa.xml.h"
39 #include "gen_eu_message.xml.h"
40 
41 #define GEN_MI_CMD(gen, op) (GEN6_MI_TYPE_MI | gen ## _MI_OPCODE_ ## op)
42 #define GEN6_MI_CMD(op) GEN_MI_CMD(GEN6, op)
43 #define GEN7_MI_CMD(op) GEN_MI_CMD(GEN7, op)
44 
45 #define GEN_BLITTER_CMD(gen, op) \
46    (GEN6_BLITTER_TYPE_BLITTER | gen ## _BLITTER_OPCODE_ ## op)
47 #define GEN6_BLITTER_CMD(op) GEN_BLITTER_CMD(GEN6, op)
48 
49 #define GEN_RENDER_CMD(subtype, gen, op)  \
50    (GEN6_RENDER_TYPE_RENDER |             \
51     GEN6_RENDER_SUBTYPE_ ## subtype |     \
52     gen ## _RENDER_OPCODE_ ## op)
53 #define GEN6_RENDER_CMD(subtype, op) GEN_RENDER_CMD(subtype, GEN6, op)
54 #define GEN7_RENDER_CMD(subtype, op) GEN_RENDER_CMD(subtype, GEN7, op)
55 #define GEN75_RENDER_CMD(subtype, op) GEN_RENDER_CMD(subtype, GEN75, op)
56 #define GEN8_RENDER_CMD(subtype, op) GEN_RENDER_CMD(subtype, GEN8, op)
57 
58 #define GEN_EXTRACT(bits, field) (((bits) & field ## __MASK) >> field ## __SHIFT)
59 #define GEN_SHIFT32(bits, field) gen_shift32(bits, field ## __MASK, field ## __SHIFT)
60 
61 static inline uint32_t
gen_shift32(uint32_t bits,uint32_t mask,int shift)62 gen_shift32(uint32_t bits, uint32_t mask, int shift)
63 {
64    bits <<= shift;
65 
66    assert((bits & mask) == bits);
67    return bits & mask;
68 }
69 
70 static inline bool
gen_is_snb(int devid)71 gen_is_snb(int devid)
72 {
73    return (devid == 0x0102 || /* GT1 desktop */
74            devid == 0x0112 || /* GT2 desktop */
75            devid == 0x0122 || /* GT2_PLUS desktop */
76            devid == 0x0106 || /* GT1 mobile */
77            devid == 0x0116 || /* GT2 mobile */
78            devid == 0x0126 || /* GT2_PLUS mobile */
79            devid == 0x010a);  /* GT1 server */
80 }
81 
82 static inline int
gen_get_snb_gt(int devid)83 gen_get_snb_gt(int devid)
84 {
85    assert(gen_is_snb(devid));
86    return (devid & 0x30) ? 2 : 1;
87 }
88 
89 static inline bool
gen_is_ivb(int devid)90 gen_is_ivb(int devid)
91 {
92    return (devid == 0x0152 || /* GT1 desktop */
93            devid == 0x0162 || /* GT2 desktop */
94            devid == 0x0156 || /* GT1 mobile */
95            devid == 0x0166 || /* GT2 mobile */
96            devid == 0x015a || /* GT1 server */
97            devid == 0x016a);  /* GT2 server */
98 }
99 
100 static inline int
gen_get_ivb_gt(int devid)101 gen_get_ivb_gt(int devid)
102 {
103    assert(gen_is_ivb(devid));
104    return (devid & 0x30) >> 4;
105 }
106 
107 static inline bool
gen_is_hsw(int devid)108 gen_is_hsw(int devid)
109 {
110    return (devid == 0x0402 || /* GT1 desktop */
111            devid == 0x0412 || /* GT2 desktop */
112            devid == 0x0422 || /* GT3 desktop */
113            devid == 0x0406 || /* GT1 mobile */
114            devid == 0x0416 || /* GT2 mobile */
115            devid == 0x0426 || /* GT2 mobile */
116            devid == 0x040a || /* GT1 server */
117            devid == 0x041a || /* GT2 server */
118            devid == 0x042a || /* GT3 server */
119            devid == 0x040b || /* GT1 reserved */
120            devid == 0x041b || /* GT2 reserved */
121            devid == 0x042b || /* GT3 reserved */
122            devid == 0x040e || /* GT1 reserved */
123            devid == 0x041e || /* GT2 reserved */
124            devid == 0x042e || /* GT3 reserved */
125            devid == 0x0c02 || /* SDV */
126            devid == 0x0c12 ||
127            devid == 0x0c22 ||
128            devid == 0x0c06 ||
129            devid == 0x0c16 ||
130            devid == 0x0c26 ||
131            devid == 0x0c0a ||
132            devid == 0x0c1a ||
133            devid == 0x0c2a ||
134            devid == 0x0c0b ||
135            devid == 0x0c1b ||
136            devid == 0x0c2b ||
137            devid == 0x0c0e ||
138            devid == 0x0c1e ||
139            devid == 0x0c2e ||
140            devid == 0x0a02 || /* ULT */
141            devid == 0x0a12 ||
142            devid == 0x0a22 ||
143            devid == 0x0a06 ||
144            devid == 0x0a16 ||
145            devid == 0x0a26 ||
146            devid == 0x0a0a ||
147            devid == 0x0a1a ||
148            devid == 0x0a2a ||
149            devid == 0x0a0b ||
150            devid == 0x0a1b ||
151            devid == 0x0a2b ||
152            devid == 0x0a0e ||
153            devid == 0x0a1e ||
154            devid == 0x0a2e ||
155            devid == 0x0d02 || /* CRW */
156            devid == 0x0d12 ||
157            devid == 0x0d22 ||
158            devid == 0x0d06 ||
159            devid == 0x0d16 ||
160            devid == 0x0d26 ||
161            devid == 0x0d0a ||
162            devid == 0x0d1a ||
163            devid == 0x0d2a ||
164            devid == 0x0d0b ||
165            devid == 0x0d1b ||
166            devid == 0x0d2b ||
167            devid == 0x0d0e ||
168            devid == 0x0d1e ||
169            devid == 0x0d2e);
170 }
171 
172 static inline int
gen_get_hsw_gt(int devid)173 gen_get_hsw_gt(int devid)
174 {
175    assert(gen_is_hsw(devid));
176    return ((devid & 0x30) >> 4) + 1;
177 }
178 
179 static inline bool
gen_is_bdw(int devid)180 gen_is_bdw(int devid)
181 {
182    return (devid == 0x1602 || /* GT1 ULT */
183            devid == 0x1606 || /* GT1 ULT */
184            devid == 0x160a || /* GT1 server */
185            devid == 0x160b || /* GT1 Iris */
186            devid == 0x160d || /* GT1 workstation */
187            devid == 0x160e || /* GT1 ULX */
188            devid == 0x1612 || /* GT2 */
189            devid == 0x1616 ||
190            devid == 0x161a ||
191            devid == 0x161b ||
192            devid == 0x161d ||
193            devid == 0x161e ||
194            devid == 0x1622 || /* GT3 */
195            devid == 0x1626 ||
196            devid == 0x162a ||
197            devid == 0x162b ||
198            devid == 0x162d ||
199            devid == 0x162e);
200 }
201 
202 static inline int
gen_get_bdw_gt(int devid)203 gen_get_bdw_gt(int devid)
204 {
205    assert(gen_is_bdw(devid));
206    return ((devid & 0x30) >> 4) + 1;
207 }
208 
209 static inline bool
gen_is_vlv(int devid)210 gen_is_vlv(int devid)
211 {
212    return (devid == 0x0f30 ||
213            devid == 0x0f31 ||
214            devid == 0x0f32 ||
215            devid == 0x0f33 ||
216            devid == 0x0157 ||
217            devid == 0x0155);
218 }
219 
220 static inline bool
gen_is_chv(int devid)221 gen_is_chv(int devid)
222 {
223    return (devid == 0x22b0 ||
224            devid == 0x22b1 ||
225            devid == 0x22b2 ||
226            devid == 0x22b3);
227 }
228 
229 static inline bool
gen_is_atom(int devid)230 gen_is_atom(int devid)
231 {
232    return (gen_is_vlv(devid) ||
233            gen_is_chv(devid));
234 }
235 
236 static inline bool
gen_is_desktop(int devid)237 gen_is_desktop(int devid)
238 {
239    assert(!gen_is_atom(devid));
240    return ((devid & 0xf) == 0x2);
241 }
242 
243 static inline bool
gen_is_mobile(int devid)244 gen_is_mobile(int devid)
245 {
246    assert(!gen_is_atom(devid));
247    return ((devid & 0xf) == 0x6);
248 }
249 
250 static inline bool
gen_is_server(int devid)251 gen_is_server(int devid)
252 {
253    assert(!gen_is_atom(devid));
254    return ((devid & 0xf) == 0xa);
255 }
256 
257 #endif /* GENHW_H */
258