17ec681f3Smrg/* 27ec681f3Smrg * Copyright © 2018 Intel Corporation 37ec681f3Smrg * 47ec681f3Smrg * Permission is hereby granted, free of charge, to any person obtaining a 57ec681f3Smrg * copy of this software and associated documentation files (the "Software"), 67ec681f3Smrg * to deal in the Software without restriction, including without limitation 77ec681f3Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 87ec681f3Smrg * and/or sell copies of the Software, and to permit persons to whom the 97ec681f3Smrg * Software is furnished to do so, subject to the following conditions: 107ec681f3Smrg * 117ec681f3Smrg * The above copyright notice and this permission notice (including the next 127ec681f3Smrg * paragraph) shall be included in all copies or substantial portions of the 137ec681f3Smrg * Software. 147ec681f3Smrg * 157ec681f3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 167ec681f3Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 177ec681f3Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 187ec681f3Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 197ec681f3Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 207ec681f3Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 217ec681f3Smrg * IN THE SOFTWARE. 227ec681f3Smrg */ 237ec681f3Smrg 247ec681f3Smrg#ifndef GFX10_CONTEXT_H 257ec681f3Smrg#define GFX10_CONTEXT_H 267ec681f3Smrg 277ec681f3Smrgstatic inline void gfx10_render_context_init(const struct intel_context_parameters *params, 287ec681f3Smrg uint32_t *data, uint32_t *size) 297ec681f3Smrg{ 307ec681f3Smrg *size = CONTEXT_RENDER_SIZE; 317ec681f3Smrg if (!data) 327ec681f3Smrg return; 337ec681f3Smrg 347ec681f3Smrg *data++ = 0; /* MI_NOOP */ 357ec681f3Smrg MI_LOAD_REGISTER_IMM_vals(data, MI_LRI_FORCE_POSTED, 367ec681f3Smrg 0x2244 /* CONTEXT_CONTROL */, 0x90009 /* Inhibit Synchronous Context Switch | Engine Context Restore Inhibit */, 377ec681f3Smrg 0x2034 /* RING_HEAD */, 0, 387ec681f3Smrg 0x2030 /* RING_TAIL */, 0, 397ec681f3Smrg 0x2038 /* RING_BUFFER_START */, params->ring_addr, 407ec681f3Smrg 0x203C /* RING_BUFFER_CONTROL */, (params->ring_size - 4096) | 1 /* Buffer Length | Ring Buffer Enable */, 417ec681f3Smrg 0x2168 /* BB_HEAD_U */, 0, 427ec681f3Smrg 0x2140 /* BB_HEAD_L */, 0, 437ec681f3Smrg 0x2110 /* BB_STATE */, 0, 447ec681f3Smrg 0x211C /* SECOND_BB_HEAD_U */, 0, 457ec681f3Smrg 0x2114 /* SECOND_BB_HEAD_L */, 0, 467ec681f3Smrg 0x2118 /* SECOND_BB_STATE */, 0, 477ec681f3Smrg 0x21C0 /* BB_PER_CTX_PTR */, 0, 487ec681f3Smrg 0x21C4 /* RCS_INDIRECT_CTX */, 0, 497ec681f3Smrg 0x21C8 /* RCS_INDIRECT_CTX_OFFSET */, 0, 507ec681f3Smrg 0x2180 /* CCID */, 0); 517ec681f3Smrg *data++ = 0; /* MI_NOOP */ 527ec681f3Smrg 537ec681f3Smrg MI_LOAD_REGISTER_IMM_vals(data, MI_LRI_FORCE_POSTED, 547ec681f3Smrg 0x23A8 /* CTX_TIMESTAMP */, 0, 557ec681f3Smrg 0x228C /* PDP3_UDW */, 0, 567ec681f3Smrg 0x2288 /* PDP3_LDW */, 0, 577ec681f3Smrg 0x2284 /* PDP2_UDW */, 0, 587ec681f3Smrg 0x2280 /* PDP2_LDW */, 0, 597ec681f3Smrg 0x227C /* PDP1_UDW */, 0, 607ec681f3Smrg 0x2278 /* PDP1_LDW */, 0, 617ec681f3Smrg 0x2274 /* PDP0_UDW */, params->pml4_addr >> 32, 627ec681f3Smrg 0x2270 /* PDP0_LDW */, params->pml4_addr & 0xffffffff); 637ec681f3Smrg for (int i = 0; i < 12; i++) 647ec681f3Smrg *data++ = 0; /* MI_NOOP */ 657ec681f3Smrg 667ec681f3Smrg *data++ = 0; /* MI_NOOP */ 677ec681f3Smrg MI_LOAD_REGISTER_IMM_vals(data, 0, 687ec681f3Smrg 0x20C8 /* R_PWR_CLK_STATE */, 0x7FFFFFFF, 697ec681f3Smrg 0, /* GPGPU_CSR_BASE_ADDRESS ? */ 0); 707ec681f3Smrg *data++ = 0; /* MI_NOOP */ 717ec681f3Smrg 727ec681f3Smrg for (int i = 0; i < 9; i++) 737ec681f3Smrg *data++ = 0; 747ec681f3Smrg 757ec681f3Smrg *data++ = MI_BATCH_BUFFER_END | 1 /* End Context */; 767ec681f3Smrg} 777ec681f3Smrg 787ec681f3Smrgstatic inline void gfx10_blitter_context_init(const struct intel_context_parameters *params, 797ec681f3Smrg uint32_t *data, uint32_t *size) 807ec681f3Smrg{ 817ec681f3Smrg *size = CONTEXT_OTHER_SIZE; 827ec681f3Smrg if (!data) 837ec681f3Smrg return; 847ec681f3Smrg 857ec681f3Smrg *data++ = 0 /* MI_NOOP */; 867ec681f3Smrg MI_LOAD_REGISTER_IMM_vals(data, MI_LRI_FORCE_POSTED, 877ec681f3Smrg 0x22244 /* CONTEXT_CONTROL */, 0x90009 /* Inhibit Synchronous Context Switch | Engine Context Restore Inhibit */, 887ec681f3Smrg 0x22034 /* RING_HEAD */, 0, 897ec681f3Smrg 0x22030 /* RING_TAIL */, 0, 907ec681f3Smrg 0x22038 /* RING_BUFFER_START */, params->ring_addr, 917ec681f3Smrg 0x2203C /* RING_BUFFER_CONTROL */, (params->ring_size - 4096) | 1 /* Buffer Length | Ring Buffer Enable */, 927ec681f3Smrg 0x22168 /* BB_HEAD_U */, 0, 937ec681f3Smrg 0x22140 /* BB_HEAD_L */, 0, 947ec681f3Smrg 0x22110 /* BB_STATE */, 0, 957ec681f3Smrg 0x2211C /* SECOND_BB_HEAD_U */, 0, 967ec681f3Smrg 0x22114 /* SECOND_BB_HEAD_L */, 0, 977ec681f3Smrg 0x22118 /* SECOND_BB_STATE */, 0, 987ec681f3Smrg 0x221C0 /* BB_PER_CTX_PTR */, 0, 997ec681f3Smrg 0x221C4 /* INDIRECT_CTX */, 0, 1007ec681f3Smrg 0x221C8 /* INDIRECT_CTX_OFFSET */, 0); 1017ec681f3Smrg *data++ = 0 /* MI_NOOP */; 1027ec681f3Smrg *data++ = 0 /* MI_NOOP */; 1037ec681f3Smrg 1047ec681f3Smrg *data++ = 0 /* MI_NOOP */; 1057ec681f3Smrg MI_LOAD_REGISTER_IMM_vals(data, MI_LRI_FORCE_POSTED, 1067ec681f3Smrg 0x223A8 /* CTX_TIMESTAMP */, 0, 1077ec681f3Smrg 0x2228C /* PDP3_UDW */, 0, 1087ec681f3Smrg 0x22288 /* PDP3_LDW */, 0, 1097ec681f3Smrg 0x22284 /* PDP2_UDW */, 0, 1107ec681f3Smrg 0x22280 /* PDP2_LDW */, 0, 1117ec681f3Smrg 0x2227C /* PDP1_UDW */, 0, 1127ec681f3Smrg 0x22278 /* PDP1_LDW */, 0, 1137ec681f3Smrg 0x22274 /* PDP0_UDW */, params->pml4_addr >> 32, 1147ec681f3Smrg 0x22270 /* PDP0_LDW */, params->pml4_addr & 0xffffffff); 1157ec681f3Smrg for (int i = 0; i < 13; i++) 1167ec681f3Smrg *data++ = 0 /* MI_NOOP */; 1177ec681f3Smrg 1187ec681f3Smrg MI_LOAD_REGISTER_IMM_vals(data, 0, 1197ec681f3Smrg 0x22200 /* BCS_SWCTRL */, 0); 1207ec681f3Smrg 1217ec681f3Smrg for (int i = 0; i < 12; i++) 1227ec681f3Smrg *data++ = 0 /* MI_NOOP */; 1237ec681f3Smrg 1247ec681f3Smrg 1257ec681f3Smrg *data++ = MI_BATCH_BUFFER_END | 1 /* End Context */; 1267ec681f3Smrg} 1277ec681f3Smrg 1287ec681f3Smrgstatic inline void gfx10_video_context_init(const struct intel_context_parameters *params, 1297ec681f3Smrg uint32_t *data, uint32_t *size) 1307ec681f3Smrg{ 1317ec681f3Smrg *size = CONTEXT_OTHER_SIZE; 1327ec681f3Smrg if (!data) 1337ec681f3Smrg return; 1347ec681f3Smrg 1357ec681f3Smrg *data++ = 0 /* MI_NOOP */; 1367ec681f3Smrg MI_LOAD_REGISTER_IMM_vals(data, MI_LRI_FORCE_POSTED, 1377ec681f3Smrg 0x1C244 /* CONTEXT_CONTROL */, 0x90009 /* Inhibit Synchronous Context Switch | Engine Context Restore Inhibit */, 1387ec681f3Smrg 0x1C034 /* RING_HEAD */, 0, 1397ec681f3Smrg 0x1C030 /* RING_TAIL */, 0, 1407ec681f3Smrg 0x1C038 /* RING_BUFFER_START */, params->ring_addr, 1417ec681f3Smrg 0x1C03C /* RING_BUFFER_CONTROL */, (params->ring_size - 4096) | 1 /* Buffer Length | Ring Buffer Enable */, 1427ec681f3Smrg 0x1C168 /* BB_HEAD_U */, 0, 1437ec681f3Smrg 0x1C140 /* BB_HEAD_L */, 0, 1447ec681f3Smrg 0x1C110 /* BB_STATE */, 0, 1457ec681f3Smrg 0x1C11C /* SECOND_BB_HEAD_U */, 0, 1467ec681f3Smrg 0x1C114 /* SECOND_BB_HEAD_L */, 0, 1477ec681f3Smrg 0x1C118 /* SECOND_BB_STATE */, 0); 1487ec681f3Smrg for (int i = 0; i < 8; i++) 1497ec681f3Smrg *data++ = 0 /* MI_NOOP */; 1507ec681f3Smrg 1517ec681f3Smrg *data++ = 0 /* MI_NOOP */; 1527ec681f3Smrg MI_LOAD_REGISTER_IMM_vals(data, MI_LRI_FORCE_POSTED, 1537ec681f3Smrg 0x1C3A8 /* CTX_TIMESTAMP */, 0, 1547ec681f3Smrg 0x1C28C /* PDP3_UDW */, 0, 1557ec681f3Smrg 0x1C288 /* PDP3_LDW */, 0, 1567ec681f3Smrg 0x1C284 /* PDP2_UDW */, 0, 1577ec681f3Smrg 0x1C280 /* PDP2_LDW */, 0, 1587ec681f3Smrg 0x1C27C /* PDP1_UDW */, 0, 1597ec681f3Smrg 0x1C278 /* PDP1_LDW */, 0, 1607ec681f3Smrg 0x1C274 /* PDP0_UDW */, params->pml4_addr >> 32, 1617ec681f3Smrg 0x1C270 /* PDP0_LDW */, params->pml4_addr & 0xffffffff); 1627ec681f3Smrg for (int i = 0; i < 12; i++) 1637ec681f3Smrg *data++ = 0 /* MI_NOOP */; 1647ec681f3Smrg 1657ec681f3Smrg *data++ = MI_BATCH_BUFFER_END | 1 /* End Context */; 1667ec681f3Smrg} 1677ec681f3Smrg 1687ec681f3Smrg#endif /* GFX10_CONTEXT_H */ 169