1d722e3fbSopenharmony_ci/*
2d722e3fbSopenharmony_ci * Copyright © 2010 Intel Corporation
3d722e3fbSopenharmony_ci *
4d722e3fbSopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
5d722e3fbSopenharmony_ci * copy of this software and associated documentation files (the "Software"),
6d722e3fbSopenharmony_ci * to deal in the Software without restriction, including without limitation
7d722e3fbSopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8d722e3fbSopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
9d722e3fbSopenharmony_ci * Software is furnished to do so, subject to the following conditions:
10d722e3fbSopenharmony_ci *
11d722e3fbSopenharmony_ci * The above copyright notice and this permission notice (including the next
12d722e3fbSopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the
13d722e3fbSopenharmony_ci * Software.
14d722e3fbSopenharmony_ci *
15d722e3fbSopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16d722e3fbSopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17d722e3fbSopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18d722e3fbSopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19d722e3fbSopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20d722e3fbSopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21d722e3fbSopenharmony_ci * IN THE SOFTWARE.
22d722e3fbSopenharmony_ci *
23d722e3fbSopenharmony_ci * Authors:
24d722e3fbSopenharmony_ci *    Eric Anholt <eric@anholt.net>
25d722e3fbSopenharmony_ci *
26d722e3fbSopenharmony_ci */
27d722e3fbSopenharmony_ci
28d722e3fbSopenharmony_ci/** @file intel_aub.h
29d722e3fbSopenharmony_ci *
30d722e3fbSopenharmony_ci * The AUB file is a file format used by Intel's internal simulation
31d722e3fbSopenharmony_ci * and other validation tools.  It can be used at various levels by a
32d722e3fbSopenharmony_ci * driver to input state to the simulated hardware or a replaying
33d722e3fbSopenharmony_ci * debugger.
34d722e3fbSopenharmony_ci *
35d722e3fbSopenharmony_ci * We choose to dump AUB files using the trace block format for ease
36d722e3fbSopenharmony_ci * of implementation -- dump out the blocks of memory as plain blobs
37d722e3fbSopenharmony_ci * and insert ring commands to execute the batchbuffer blob.
38d722e3fbSopenharmony_ci */
39d722e3fbSopenharmony_ci
40d722e3fbSopenharmony_ci#ifndef _INTEL_AUB_H
41d722e3fbSopenharmony_ci#define _INTEL_AUB_H
42d722e3fbSopenharmony_ci
43d722e3fbSopenharmony_ci#define AUB_MI_NOOP			(0)
44d722e3fbSopenharmony_ci#define AUB_MI_BATCH_BUFFER_START 	(0x31 << 23)
45d722e3fbSopenharmony_ci#define AUB_PIPE_CONTROL		(0x7a000002)
46d722e3fbSopenharmony_ci
47d722e3fbSopenharmony_ci/* DW0: instruction type. */
48d722e3fbSopenharmony_ci
49d722e3fbSopenharmony_ci#define CMD_AUB			(7 << 29)
50d722e3fbSopenharmony_ci
51d722e3fbSopenharmony_ci#define CMD_AUB_HEADER		(CMD_AUB | (1 << 23) | (0x05 << 16))
52d722e3fbSopenharmony_ci/* DW1 */
53d722e3fbSopenharmony_ci# define AUB_HEADER_MAJOR_SHIFT		24
54d722e3fbSopenharmony_ci# define AUB_HEADER_MINOR_SHIFT		16
55d722e3fbSopenharmony_ci
56d722e3fbSopenharmony_ci#define CMD_AUB_TRACE_HEADER_BLOCK (CMD_AUB | (1 << 23) | (0x41 << 16))
57d722e3fbSopenharmony_ci#define CMD_AUB_DUMP_BMP           (CMD_AUB | (1 << 23) | (0x9e << 16))
58d722e3fbSopenharmony_ci
59d722e3fbSopenharmony_ci/* DW1 */
60d722e3fbSopenharmony_ci#define AUB_TRACE_OPERATION_MASK	0x000000ff
61d722e3fbSopenharmony_ci#define AUB_TRACE_OP_COMMENT		0x00000000
62d722e3fbSopenharmony_ci#define AUB_TRACE_OP_DATA_WRITE		0x00000001
63d722e3fbSopenharmony_ci#define AUB_TRACE_OP_COMMAND_WRITE	0x00000002
64d722e3fbSopenharmony_ci#define AUB_TRACE_OP_MMIO_WRITE		0x00000003
65d722e3fbSopenharmony_ci// operation = TRACE_DATA_WRITE, Type
66d722e3fbSopenharmony_ci#define AUB_TRACE_TYPE_MASK		0x0000ff00
67d722e3fbSopenharmony_ci#define AUB_TRACE_TYPE_NOTYPE		(0 << 8)
68d722e3fbSopenharmony_ci#define AUB_TRACE_TYPE_BATCH		(1 << 8)
69d722e3fbSopenharmony_ci#define AUB_TRACE_TYPE_VERTEX_BUFFER	(5 << 8)
70d722e3fbSopenharmony_ci#define AUB_TRACE_TYPE_2D_MAP		(6 << 8)
71d722e3fbSopenharmony_ci#define AUB_TRACE_TYPE_CUBE_MAP		(7 << 8)
72d722e3fbSopenharmony_ci#define AUB_TRACE_TYPE_VOLUME_MAP	(9 << 8)
73d722e3fbSopenharmony_ci#define AUB_TRACE_TYPE_1D_MAP		(10 << 8)
74d722e3fbSopenharmony_ci#define AUB_TRACE_TYPE_CONSTANT_BUFFER	(11 << 8)
75d722e3fbSopenharmony_ci#define AUB_TRACE_TYPE_CONSTANT_URB	(12 << 8)
76d722e3fbSopenharmony_ci#define AUB_TRACE_TYPE_INDEX_BUFFER	(13 << 8)
77d722e3fbSopenharmony_ci#define AUB_TRACE_TYPE_GENERAL		(14 << 8)
78d722e3fbSopenharmony_ci#define AUB_TRACE_TYPE_SURFACE		(15 << 8)
79d722e3fbSopenharmony_ci
80d722e3fbSopenharmony_ci
81d722e3fbSopenharmony_ci// operation = TRACE_COMMAND_WRITE, Type =
82d722e3fbSopenharmony_ci#define AUB_TRACE_TYPE_RING_HWB		(1 << 8)
83d722e3fbSopenharmony_ci#define AUB_TRACE_TYPE_RING_PRB0	(2 << 8)
84d722e3fbSopenharmony_ci#define AUB_TRACE_TYPE_RING_PRB1	(3 << 8)
85d722e3fbSopenharmony_ci#define AUB_TRACE_TYPE_RING_PRB2	(4 << 8)
86d722e3fbSopenharmony_ci
87d722e3fbSopenharmony_ci// Address space
88d722e3fbSopenharmony_ci#define AUB_TRACE_ADDRESS_SPACE_MASK	0x00ff0000
89d722e3fbSopenharmony_ci#define AUB_TRACE_MEMTYPE_GTT		(0 << 16)
90d722e3fbSopenharmony_ci#define AUB_TRACE_MEMTYPE_LOCAL		(1 << 16)
91d722e3fbSopenharmony_ci#define AUB_TRACE_MEMTYPE_NONLOCAL	(2 << 16)
92d722e3fbSopenharmony_ci#define AUB_TRACE_MEMTYPE_PCI		(3 << 16)
93d722e3fbSopenharmony_ci#define AUB_TRACE_MEMTYPE_GTT_ENTRY     (4 << 16)
94d722e3fbSopenharmony_ci
95d722e3fbSopenharmony_ci/* DW2 */
96d722e3fbSopenharmony_ci
97d722e3fbSopenharmony_ci/**
98d722e3fbSopenharmony_ci * aub_state_struct_type enum values are encoded with the top 16 bits
99d722e3fbSopenharmony_ci * representing the type to be delivered to the .aub file, and the bottom 16
100d722e3fbSopenharmony_ci * bits representing the subtype.  This macro performs the encoding.
101d722e3fbSopenharmony_ci */
102d722e3fbSopenharmony_ci#define ENCODE_SS_TYPE(type, subtype) (((type) << 16) | (subtype))
103d722e3fbSopenharmony_ci
104d722e3fbSopenharmony_cienum aub_state_struct_type {
105d722e3fbSopenharmony_ci   AUB_TRACE_VS_STATE =			ENCODE_SS_TYPE(AUB_TRACE_TYPE_GENERAL, 1),
106d722e3fbSopenharmony_ci   AUB_TRACE_GS_STATE =			ENCODE_SS_TYPE(AUB_TRACE_TYPE_GENERAL, 2),
107d722e3fbSopenharmony_ci   AUB_TRACE_CLIP_STATE =		ENCODE_SS_TYPE(AUB_TRACE_TYPE_GENERAL, 3),
108d722e3fbSopenharmony_ci   AUB_TRACE_SF_STATE =			ENCODE_SS_TYPE(AUB_TRACE_TYPE_GENERAL, 4),
109d722e3fbSopenharmony_ci   AUB_TRACE_WM_STATE =			ENCODE_SS_TYPE(AUB_TRACE_TYPE_GENERAL, 5),
110d722e3fbSopenharmony_ci   AUB_TRACE_CC_STATE =			ENCODE_SS_TYPE(AUB_TRACE_TYPE_GENERAL, 6),
111d722e3fbSopenharmony_ci   AUB_TRACE_CLIP_VP_STATE =		ENCODE_SS_TYPE(AUB_TRACE_TYPE_GENERAL, 7),
112d722e3fbSopenharmony_ci   AUB_TRACE_SF_VP_STATE =		ENCODE_SS_TYPE(AUB_TRACE_TYPE_GENERAL, 8),
113d722e3fbSopenharmony_ci   AUB_TRACE_CC_VP_STATE =		ENCODE_SS_TYPE(AUB_TRACE_TYPE_GENERAL, 0x9),
114d722e3fbSopenharmony_ci   AUB_TRACE_SAMPLER_STATE =		ENCODE_SS_TYPE(AUB_TRACE_TYPE_GENERAL, 0xa),
115d722e3fbSopenharmony_ci   AUB_TRACE_KERNEL_INSTRUCTIONS =	ENCODE_SS_TYPE(AUB_TRACE_TYPE_GENERAL, 0xb),
116d722e3fbSopenharmony_ci   AUB_TRACE_SCRATCH_SPACE =		ENCODE_SS_TYPE(AUB_TRACE_TYPE_GENERAL, 0xc),
117d722e3fbSopenharmony_ci   AUB_TRACE_SAMPLER_DEFAULT_COLOR =	ENCODE_SS_TYPE(AUB_TRACE_TYPE_GENERAL, 0xd),
118d722e3fbSopenharmony_ci
119d722e3fbSopenharmony_ci   AUB_TRACE_SCISSOR_STATE =		ENCODE_SS_TYPE(AUB_TRACE_TYPE_GENERAL, 0x15),
120d722e3fbSopenharmony_ci   AUB_TRACE_BLEND_STATE =		ENCODE_SS_TYPE(AUB_TRACE_TYPE_GENERAL, 0x16),
121d722e3fbSopenharmony_ci   AUB_TRACE_DEPTH_STENCIL_STATE =	ENCODE_SS_TYPE(AUB_TRACE_TYPE_GENERAL, 0x17),
122d722e3fbSopenharmony_ci
123d722e3fbSopenharmony_ci   AUB_TRACE_VERTEX_BUFFER =		ENCODE_SS_TYPE(AUB_TRACE_TYPE_VERTEX_BUFFER, 0),
124d722e3fbSopenharmony_ci   AUB_TRACE_BINDING_TABLE =		ENCODE_SS_TYPE(AUB_TRACE_TYPE_SURFACE, 0x100),
125d722e3fbSopenharmony_ci   AUB_TRACE_SURFACE_STATE =		ENCODE_SS_TYPE(AUB_TRACE_TYPE_SURFACE, 0x200),
126d722e3fbSopenharmony_ci   AUB_TRACE_VS_CONSTANTS =		ENCODE_SS_TYPE(AUB_TRACE_TYPE_CONSTANT_BUFFER, 0),
127d722e3fbSopenharmony_ci   AUB_TRACE_WM_CONSTANTS =		ENCODE_SS_TYPE(AUB_TRACE_TYPE_CONSTANT_BUFFER, 1),
128d722e3fbSopenharmony_ci};
129d722e3fbSopenharmony_ci
130d722e3fbSopenharmony_ci#undef ENCODE_SS_TYPE
131d722e3fbSopenharmony_ci
132d722e3fbSopenharmony_ci/**
133d722e3fbSopenharmony_ci * Decode a aub_state_struct_type value to determine the type that should be
134d722e3fbSopenharmony_ci * stored in the .aub file.
135d722e3fbSopenharmony_ci */
136d722e3fbSopenharmony_cistatic inline uint32_t AUB_TRACE_TYPE(enum aub_state_struct_type ss_type)
137d722e3fbSopenharmony_ci{
138d722e3fbSopenharmony_ci   return (ss_type & 0xFFFF0000) >> 16;
139d722e3fbSopenharmony_ci}
140d722e3fbSopenharmony_ci
141d722e3fbSopenharmony_ci/**
142d722e3fbSopenharmony_ci * Decode a state_struct_type value to determine the subtype that should be
143d722e3fbSopenharmony_ci * stored in the .aub file.
144d722e3fbSopenharmony_ci */
145d722e3fbSopenharmony_cistatic inline uint32_t AUB_TRACE_SUBTYPE(enum aub_state_struct_type ss_type)
146d722e3fbSopenharmony_ci{
147d722e3fbSopenharmony_ci   return ss_type & 0xFFFF;
148d722e3fbSopenharmony_ci}
149d722e3fbSopenharmony_ci
150d722e3fbSopenharmony_ci/* DW3: address */
151d722e3fbSopenharmony_ci/* DW4: len */
152d722e3fbSopenharmony_ci
153d722e3fbSopenharmony_ci#endif /* _INTEL_AUB_H */
154