-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathFakeIrisXEAccelShared.h
More file actions
197 lines (153 loc) · 3.91 KB
/
FakeIrisXEAccelShared.h
File metadata and controls
197 lines (153 loc) · 3.91 KB
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
#ifndef FAKE_IRIS_XE_ACCEL_SHARED_H
#define FAKE_IRIS_XE_ACCEL_SHARED_H
#include <IOKit/IOService.h>
#include <IOKit/IOTypes.h> // basic IOKit typedefs
#include <IOKit/IOService.h>
enum {
kFakeIris_Method_GetCaps = 0,
kFakeIris_Method_CreateContext = 1,
kFakeIris_Method_DestroyContext = 2,
kFakeIris_Method_BindSurfaceUserMapped = 3,
kFakeIris_Method_PresentContext = 4,
// New for Phase 8:
kFakeIris_Method_SubmitExeclistFenceTest = 5,
};
#define kFakeIris_Method_SubmitExeclistFenceTest 7
//
// ===== ACCEL Selec
enum {
kAccelSel_Ping = 0,
kAccelSel_GetCaps = 1,
kAccelSel_CreateContext = 2,
kAccelSel_Submit = 3,
kAccelSel_Flush = 4,
kAccelSel_DestroyContext = 5,
kAccelSel_BindSurface = 6,
kAccelSel_InjectTest = 10, // debug
};
struct XECtx {
uint32_t ctxId;
bool alive;
uintptr_t surf_vaddr; // kernel-side pointer (mapped via clientMemory / IOConnectMapMemory64)
size_t surf_bytes;
uint32_t surf_rowbytes; // bytes per row in source
uint32_t surf_w;
uint32_t surf_h;
// optional: more flags
};
//
// ===== Capability struct =====
//
struct XEAccelCaps {
uint32_t version; // = 1
uint32_t metalSupported; // 0 or 1
uint32_t reserved0;
uint32_t reserved1;
};
//
// ===== Context Create =====
//
struct XECreateCtxIn {
uint32_t flags;
uint32_t pad;
uint64_t sharedGPUPtr;
};
struct XECreateCtxOut {
uint32_t ctxId;
uint32_t pad;
};
//
// ===== Submit =====
//
struct XESubmitIn {
uint32_t ctxId;
uint32_t numBytes;
};
//
// ===== Surface Bind =====
//
struct XEBindSurfaceIn {
uint32_t ctxId;
uint32_t ioSurfaceID;
uint32_t width;
uint32_t height;
uint32_t bytesPerRow;
uint32_t surfaceID; // <<< THIS EXISTS!
void* cpuPtr;
uint64_t gpuAddr;
uint32_t pixelFormat;
bool valid;
};
struct XEPresentPayload {
uint32_t ioSurfaceID; // IOSurface ID created in userspace
uint32_t x; // dest x in fb
uint32_t y; // dest y in fb
uint32_t w; // width
uint32_t h; // height
};
struct XEBindSurfaceOut {
uint64_t gpuAddr; // not used
uint32_t status;
uint32_t reserved;
};
//
// ===== Command Opcodes =====
//
enum : uint32_t {
XE_CMD_NOP = 0,
XE_CMD_CLEAR = 1, // payload: uint32_t colorARGB
XE_CMD_RECT = 2, // payload: XERectPayload
XE_CMD_COPY = 3, // payload: XECopyPayload
XE_CMD_FLUSH = 4, // no payload
XE_CMD_PRESENT = 5 // (future use)
};
//
// ===== Command Payloads =====
//
struct XERectPayload {
uint32_t x, y;
uint32_t w, h;
uint32_t colorARGB;
};
struct XECopyPayload {
uint32_t sx, sy;
uint32_t dx, dy;
uint32_t w, h;
};
//
// ===== Ring Header (simple linear ring) =====
//
struct __attribute__((packed)) XEHdr {
uint32_t magic; // XE_MAGIC
uint32_t version; // XE_VERSION
uint32_t capacity; // usable payload size (bytes)
uint32_t head; // producer offset (user)
uint32_t tail; // consumer offset (kernel)
uint32_t reserved[3];
};
//
// ===== Command Header =====
//
struct __attribute__((packed)) XECmd {
uint32_t opcode; // XE_CMD_*
uint32_t bytes; // payload size
uint32_t ctxId; // context
uint32_t reserved; // padding/alignment
};
struct XEClearPayload { uint32_t color; };
struct XEContext {
void* surfCPU; // mapped CPU pointer from IOSurfaceInKernelMemory
uint32_t surfWidth;
uint32_t surfHeight;
uint32_t surfRowBytes;
};
//
// ===== Constants =====
//
static constexpr uint32_t XE_MAGIC = 0x53524558u; // 'XERS'
static constexpr uint32_t XE_VERSION = 1;
static constexpr uint32_t XE_PAGE = 4096;
static inline uint32_t xe_align(uint32_t v) {
return (v + 3u) & ~3u; // 4-byte align
}
#endif