1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright © 2018 Intel Corporation 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 10bf215546Sopenharmony_ci * 11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 13bf215546Sopenharmony_ci * Software. 14bf215546Sopenharmony_ci * 15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21bf215546Sopenharmony_ci * IN THE SOFTWARE. 22bf215546Sopenharmony_ci */ 23bf215546Sopenharmony_ci 24bf215546Sopenharmony_ci#ifndef GFX10_CONTEXT_H 25bf215546Sopenharmony_ci#define GFX10_CONTEXT_H 26bf215546Sopenharmony_ci 27bf215546Sopenharmony_cistatic inline void gfx10_render_context_init(const struct intel_context_parameters *params, 28bf215546Sopenharmony_ci uint32_t *data, uint32_t *size) 29bf215546Sopenharmony_ci{ 30bf215546Sopenharmony_ci *size = CONTEXT_RENDER_SIZE; 31bf215546Sopenharmony_ci if (!data) 32bf215546Sopenharmony_ci return; 33bf215546Sopenharmony_ci 34bf215546Sopenharmony_ci *data++ = 0; /* MI_NOOP */ 35bf215546Sopenharmony_ci MI_LOAD_REGISTER_IMM_vals(data, MI_LRI_FORCE_POSTED, 36bf215546Sopenharmony_ci 0x2244 /* CONTEXT_CONTROL */, 0x90009 /* Inhibit Synchronous Context Switch | Engine Context Restore Inhibit */, 37bf215546Sopenharmony_ci 0x2034 /* RING_HEAD */, 0, 38bf215546Sopenharmony_ci 0x2030 /* RING_TAIL */, 0, 39bf215546Sopenharmony_ci 0x2038 /* RING_BUFFER_START */, params->ring_addr, 40bf215546Sopenharmony_ci 0x203C /* RING_BUFFER_CONTROL */, (params->ring_size - 4096) | 1 /* Buffer Length | Ring Buffer Enable */, 41bf215546Sopenharmony_ci 0x2168 /* BB_HEAD_U */, 0, 42bf215546Sopenharmony_ci 0x2140 /* BB_HEAD_L */, 0, 43bf215546Sopenharmony_ci 0x2110 /* BB_STATE */, 0, 44bf215546Sopenharmony_ci 0x211C /* SECOND_BB_HEAD_U */, 0, 45bf215546Sopenharmony_ci 0x2114 /* SECOND_BB_HEAD_L */, 0, 46bf215546Sopenharmony_ci 0x2118 /* SECOND_BB_STATE */, 0, 47bf215546Sopenharmony_ci 0x21C0 /* BB_PER_CTX_PTR */, 0, 48bf215546Sopenharmony_ci 0x21C4 /* RCS_INDIRECT_CTX */, 0, 49bf215546Sopenharmony_ci 0x21C8 /* RCS_INDIRECT_CTX_OFFSET */, 0, 50bf215546Sopenharmony_ci 0x2180 /* CCID */, 0); 51bf215546Sopenharmony_ci *data++ = 0; /* MI_NOOP */ 52bf215546Sopenharmony_ci 53bf215546Sopenharmony_ci MI_LOAD_REGISTER_IMM_vals(data, MI_LRI_FORCE_POSTED, 54bf215546Sopenharmony_ci 0x23A8 /* CTX_TIMESTAMP */, 0, 55bf215546Sopenharmony_ci 0x228C /* PDP3_UDW */, 0, 56bf215546Sopenharmony_ci 0x2288 /* PDP3_LDW */, 0, 57bf215546Sopenharmony_ci 0x2284 /* PDP2_UDW */, 0, 58bf215546Sopenharmony_ci 0x2280 /* PDP2_LDW */, 0, 59bf215546Sopenharmony_ci 0x227C /* PDP1_UDW */, 0, 60bf215546Sopenharmony_ci 0x2278 /* PDP1_LDW */, 0, 61bf215546Sopenharmony_ci 0x2274 /* PDP0_UDW */, params->pml4_addr >> 32, 62bf215546Sopenharmony_ci 0x2270 /* PDP0_LDW */, params->pml4_addr & 0xffffffff); 63bf215546Sopenharmony_ci for (int i = 0; i < 12; i++) 64bf215546Sopenharmony_ci *data++ = 0; /* MI_NOOP */ 65bf215546Sopenharmony_ci 66bf215546Sopenharmony_ci *data++ = 0; /* MI_NOOP */ 67bf215546Sopenharmony_ci MI_LOAD_REGISTER_IMM_vals(data, 0, 68bf215546Sopenharmony_ci 0x20C8 /* R_PWR_CLK_STATE */, 0x7FFFFFFF, 69bf215546Sopenharmony_ci 0, /* GPGPU_CSR_BASE_ADDRESS ? */ 0); 70bf215546Sopenharmony_ci *data++ = 0; /* MI_NOOP */ 71bf215546Sopenharmony_ci 72bf215546Sopenharmony_ci for (int i = 0; i < 9; i++) 73bf215546Sopenharmony_ci *data++ = 0; 74bf215546Sopenharmony_ci 75bf215546Sopenharmony_ci *data++ = MI_BATCH_BUFFER_END | 1 /* End Context */; 76bf215546Sopenharmony_ci} 77bf215546Sopenharmony_ci 78bf215546Sopenharmony_cistatic inline void gfx10_blitter_context_init(const struct intel_context_parameters *params, 79bf215546Sopenharmony_ci uint32_t *data, uint32_t *size) 80bf215546Sopenharmony_ci{ 81bf215546Sopenharmony_ci *size = CONTEXT_OTHER_SIZE; 82bf215546Sopenharmony_ci if (!data) 83bf215546Sopenharmony_ci return; 84bf215546Sopenharmony_ci 85bf215546Sopenharmony_ci *data++ = 0 /* MI_NOOP */; 86bf215546Sopenharmony_ci MI_LOAD_REGISTER_IMM_vals(data, MI_LRI_FORCE_POSTED, 87bf215546Sopenharmony_ci 0x22244 /* CONTEXT_CONTROL */, 0x90009 /* Inhibit Synchronous Context Switch | Engine Context Restore Inhibit */, 88bf215546Sopenharmony_ci 0x22034 /* RING_HEAD */, 0, 89bf215546Sopenharmony_ci 0x22030 /* RING_TAIL */, 0, 90bf215546Sopenharmony_ci 0x22038 /* RING_BUFFER_START */, params->ring_addr, 91bf215546Sopenharmony_ci 0x2203C /* RING_BUFFER_CONTROL */, (params->ring_size - 4096) | 1 /* Buffer Length | Ring Buffer Enable */, 92bf215546Sopenharmony_ci 0x22168 /* BB_HEAD_U */, 0, 93bf215546Sopenharmony_ci 0x22140 /* BB_HEAD_L */, 0, 94bf215546Sopenharmony_ci 0x22110 /* BB_STATE */, 0, 95bf215546Sopenharmony_ci 0x2211C /* SECOND_BB_HEAD_U */, 0, 96bf215546Sopenharmony_ci 0x22114 /* SECOND_BB_HEAD_L */, 0, 97bf215546Sopenharmony_ci 0x22118 /* SECOND_BB_STATE */, 0, 98bf215546Sopenharmony_ci 0x221C0 /* BB_PER_CTX_PTR */, 0, 99bf215546Sopenharmony_ci 0x221C4 /* INDIRECT_CTX */, 0, 100bf215546Sopenharmony_ci 0x221C8 /* INDIRECT_CTX_OFFSET */, 0); 101bf215546Sopenharmony_ci *data++ = 0 /* MI_NOOP */; 102bf215546Sopenharmony_ci *data++ = 0 /* MI_NOOP */; 103bf215546Sopenharmony_ci 104bf215546Sopenharmony_ci *data++ = 0 /* MI_NOOP */; 105bf215546Sopenharmony_ci MI_LOAD_REGISTER_IMM_vals(data, MI_LRI_FORCE_POSTED, 106bf215546Sopenharmony_ci 0x223A8 /* CTX_TIMESTAMP */, 0, 107bf215546Sopenharmony_ci 0x2228C /* PDP3_UDW */, 0, 108bf215546Sopenharmony_ci 0x22288 /* PDP3_LDW */, 0, 109bf215546Sopenharmony_ci 0x22284 /* PDP2_UDW */, 0, 110bf215546Sopenharmony_ci 0x22280 /* PDP2_LDW */, 0, 111bf215546Sopenharmony_ci 0x2227C /* PDP1_UDW */, 0, 112bf215546Sopenharmony_ci 0x22278 /* PDP1_LDW */, 0, 113bf215546Sopenharmony_ci 0x22274 /* PDP0_UDW */, params->pml4_addr >> 32, 114bf215546Sopenharmony_ci 0x22270 /* PDP0_LDW */, params->pml4_addr & 0xffffffff); 115bf215546Sopenharmony_ci for (int i = 0; i < 13; i++) 116bf215546Sopenharmony_ci *data++ = 0 /* MI_NOOP */; 117bf215546Sopenharmony_ci 118bf215546Sopenharmony_ci MI_LOAD_REGISTER_IMM_vals(data, 0, 119bf215546Sopenharmony_ci 0x22200 /* BCS_SWCTRL */, 0); 120bf215546Sopenharmony_ci 121bf215546Sopenharmony_ci for (int i = 0; i < 12; i++) 122bf215546Sopenharmony_ci *data++ = 0 /* MI_NOOP */; 123bf215546Sopenharmony_ci 124bf215546Sopenharmony_ci 125bf215546Sopenharmony_ci *data++ = MI_BATCH_BUFFER_END | 1 /* End Context */; 126bf215546Sopenharmony_ci} 127bf215546Sopenharmony_ci 128bf215546Sopenharmony_cistatic inline void gfx10_video_context_init(const struct intel_context_parameters *params, 129bf215546Sopenharmony_ci uint32_t *data, uint32_t *size) 130bf215546Sopenharmony_ci{ 131bf215546Sopenharmony_ci *size = CONTEXT_OTHER_SIZE; 132bf215546Sopenharmony_ci if (!data) 133bf215546Sopenharmony_ci return; 134bf215546Sopenharmony_ci 135bf215546Sopenharmony_ci *data++ = 0 /* MI_NOOP */; 136bf215546Sopenharmony_ci MI_LOAD_REGISTER_IMM_vals(data, MI_LRI_FORCE_POSTED, 137bf215546Sopenharmony_ci 0x1C244 /* CONTEXT_CONTROL */, 0x90009 /* Inhibit Synchronous Context Switch | Engine Context Restore Inhibit */, 138bf215546Sopenharmony_ci 0x1C034 /* RING_HEAD */, 0, 139bf215546Sopenharmony_ci 0x1C030 /* RING_TAIL */, 0, 140bf215546Sopenharmony_ci 0x1C038 /* RING_BUFFER_START */, params->ring_addr, 141bf215546Sopenharmony_ci 0x1C03C /* RING_BUFFER_CONTROL */, (params->ring_size - 4096) | 1 /* Buffer Length | Ring Buffer Enable */, 142bf215546Sopenharmony_ci 0x1C168 /* BB_HEAD_U */, 0, 143bf215546Sopenharmony_ci 0x1C140 /* BB_HEAD_L */, 0, 144bf215546Sopenharmony_ci 0x1C110 /* BB_STATE */, 0, 145bf215546Sopenharmony_ci 0x1C11C /* SECOND_BB_HEAD_U */, 0, 146bf215546Sopenharmony_ci 0x1C114 /* SECOND_BB_HEAD_L */, 0, 147bf215546Sopenharmony_ci 0x1C118 /* SECOND_BB_STATE */, 0); 148bf215546Sopenharmony_ci for (int i = 0; i < 8; i++) 149bf215546Sopenharmony_ci *data++ = 0 /* MI_NOOP */; 150bf215546Sopenharmony_ci 151bf215546Sopenharmony_ci *data++ = 0 /* MI_NOOP */; 152bf215546Sopenharmony_ci MI_LOAD_REGISTER_IMM_vals(data, MI_LRI_FORCE_POSTED, 153bf215546Sopenharmony_ci 0x1C3A8 /* CTX_TIMESTAMP */, 0, 154bf215546Sopenharmony_ci 0x1C28C /* PDP3_UDW */, 0, 155bf215546Sopenharmony_ci 0x1C288 /* PDP3_LDW */, 0, 156bf215546Sopenharmony_ci 0x1C284 /* PDP2_UDW */, 0, 157bf215546Sopenharmony_ci 0x1C280 /* PDP2_LDW */, 0, 158bf215546Sopenharmony_ci 0x1C27C /* PDP1_UDW */, 0, 159bf215546Sopenharmony_ci 0x1C278 /* PDP1_LDW */, 0, 160bf215546Sopenharmony_ci 0x1C274 /* PDP0_UDW */, params->pml4_addr >> 32, 161bf215546Sopenharmony_ci 0x1C270 /* PDP0_LDW */, params->pml4_addr & 0xffffffff); 162bf215546Sopenharmony_ci for (int i = 0; i < 12; i++) 163bf215546Sopenharmony_ci *data++ = 0 /* MI_NOOP */; 164bf215546Sopenharmony_ci 165bf215546Sopenharmony_ci *data++ = MI_BATCH_BUFFER_END | 1 /* End Context */; 166bf215546Sopenharmony_ci} 167bf215546Sopenharmony_ci 168bf215546Sopenharmony_ci#endif /* GFX10_CONTEXT_H */ 169