1 /* 2 * Copyright © 2018 Intel Corporation 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 (including the next 12 * paragraph) shall be included in all copies or substantial portions of the 13 * Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 * IN THE SOFTWARE. 22 */ 23 24 #ifndef INTEL_CONTEXT_H 25 #define INTEL_CONTEXT_H 26 27 #include <stdint.h> 28 29 #include "util/macros.h" 30 31 #define RING_SIZE (1 * 4096) 32 #define PPHWSP_SIZE (1 * 4096) 33 34 #define GFX11_LR_CONTEXT_RENDER_SIZE (14 * 4096) 35 #define GFX10_LR_CONTEXT_RENDER_SIZE (19 * 4096) 36 #define GFX9_LR_CONTEXT_RENDER_SIZE (22 * 4096) 37 #define GFX8_LR_CONTEXT_RENDER_SIZE (20 * 4096) 38 #define GFX8_LR_CONTEXT_OTHER_SIZE (2 * 4096) 39 40 #define CONTEXT_RENDER_SIZE GFX9_LR_CONTEXT_RENDER_SIZE /* largest size */ 41 #define CONTEXT_OTHER_SIZE GFX8_LR_CONTEXT_OTHER_SIZE 42 43 #define MI_LOAD_REGISTER_IMM_n(n) ((0x22 << 23) | (2 * (n) - 1)) 44 #define MI_LRI_FORCE_POSTED (1<<12) 45 46 #define MI_BATCH_BUFFER_END (0xA << 23) 47 48 #define RCSUNIT_START 0x2000 49 #define RCSUNIT_END 0x3fff 50 51 #define VCSUNIT0_START 0x12000 52 #define VCSUNIT0_END 0x13fff 53 54 #define GFX12_VCSUNIT0_START 0x1c0000 55 #define GFX12_VCSUNIT0_END 0x1c07ff 56 57 #define BCSUNIT0_START 0x22000 58 #define BCSUNIT0_END 0x23fff 59 60 #define HWS_PGA 0x080 61 #define EXECLIST_SUBMITPORT 0x230 62 #define EXECLIST_STATUS 0x234 63 #define GFX_MODE 0x29c 64 #define EXECLIST_SQ_CONTENTS 0x510 65 #define EXECLIST_CONTROL 0x550 66 67 #define RCSUNIT(reg) (RCSUNIT_START + reg) 68 #define VCSUNIT0(reg) (VCSUNIT0_START + reg) 69 #define GFX12_VCSUNIT0(reg) (GFX12_VCSUNIT0_START + reg) 70 #define BCSUNIT0(reg) (BCSUNIT0_START + reg) 71 72 #define MEMORY_MAP_SIZE (64 /* MiB */ * 1024 * 1024) 73 74 #define PTE_SIZE 4 75 #define GFX8_PTE_SIZE 8 76 77 #define NUM_PT_ENTRIES (ALIGN_POT(MEMORY_MAP_SIZE, 4096) / 4096) 78 #define PT_SIZE ALIGN_POT(NUM_PT_ENTRIES * GFX8_PTE_SIZE, 4096) 79 80 #define CONTEXT_FLAGS (0x339) /* Normal Priority | L3-LLC Coherency | 81 * PPGTT Enabled | 82 * Legacy Context with 64 bit VA support | 83 * Valid 84 */ 85 86 #define MI_LOAD_REGISTER_IMM_vals(data, flags, ...) do { \ 87 uint32_t __regs[] = { __VA_ARGS__ }; \ 88 assert((ARRAY_SIZE(__regs) % 2) == 0); \ 89 *(data)++ = MI_LOAD_REGISTER_IMM_n(ARRAY_SIZE(__regs) / 2) | (flags); \ 90 for (unsigned __e = 0; __e < ARRAY_SIZE(__regs); __e++) \ 91 *(data)++ = __regs[__e]; \ 92 } while (0) 93 94 95 struct intel_context_parameters { 96 uint64_t pml4_addr; 97 uint64_t ring_addr; 98 uint32_t ring_size; 99 }; 100 101 typedef void (*intel_context_init_t)(const struct intel_context_parameters *, uint32_t *, uint32_t *); 102 103 #include "gfx8_context.h" 104 #include "gfx10_context.h" 105 106 #endif /* INTEL_CONTEXT_H */ 107