1 /* 2 * Copyright 2018 Advanced Micro Devices, Inc. 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 shall be included in 12 * all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 * OTHER DEALINGS IN THE SOFTWARE. 21 * 22 */ 23 24 #ifndef _DISCOVERY_H_ 25 #define _DISCOVERY_H_ 26 27 #define PSP_HEADER_SIZE 256 28 #define BINARY_MAX_SIZE (64 << 10) 29 #define BINARY_SIGNATURE 0x28211407 30 #define DISCOVERY_TABLE_SIGNATURE 0x53445049 31 32 typedef enum 33 { 34 IP_DISCOVERY = 0, 35 GC, 36 HARVEST_INFO, 37 TABLE_4, 38 RESERVED_1, 39 RESERVED_2, 40 TOTAL_TABLES = 6 41 } table; 42 43 #pragma pack(1) 44 45 typedef struct table_info 46 { 47 uint16_t offset; /* Byte offset */ 48 uint16_t checksum; /* Byte sum of the table */ 49 uint16_t size; /* Table size */ 50 uint16_t padding; 51 } table_info; 52 53 typedef struct binary_header 54 { 55 /* psp structure should go at the top of this structure */ 56 uint32_t binary_signature; /* 0x7, 0x14, 0x21, 0x28 */ 57 uint16_t version_major; 58 uint16_t version_minor; 59 uint16_t binary_checksum; /* Byte sum of the binary after this field */ 60 uint16_t binary_size; /* Binary Size*/ 61 table_info table_list[TOTAL_TABLES]; 62 } binary_header; 63 64 typedef struct die_info 65 { 66 uint16_t die_id; 67 uint16_t die_offset; /* Points to the corresponding die_header structure */ 68 } die_info; 69 70 71 typedef struct ip_discovery_header 72 { 73 uint32_t signature; /* Table Signature */ 74 uint16_t version; /* Table Version */ 75 uint16_t size; /* Table Size */ 76 uint32_t id; /* Table ID */ 77 uint16_t num_dies; /* Number of Dies */ 78 die_info die_info[16]; /* list die information for up to 16 dies */ 79 uint16_t padding[1]; /* padding */ 80 } ip_discovery_header; 81 82 typedef struct ip 83 { 84 uint16_t hw_id; /* Hardware ID */ 85 uint8_t number_instance; /* instance of the IP */ 86 uint8_t num_base_address; /* Number of Base Addresses */ 87 uint8_t major; /* HCID Major */ 88 uint8_t minor; /* HCID Minor */ 89 uint8_t revision; /* HCID Revision */ 90 #if defined(__BIG_ENDIAN) 91 uint8_t reserved : 4; /* Placeholder field */ 92 uint8_t harvest : 4; /* Harvest */ 93 #else 94 uint8_t harvest : 4; /* Harvest */ 95 uint8_t reserved : 4; /* Placeholder field */ 96 #endif 97 uint32_t base_address[1]; /* variable number of Addresses */ 98 } ip; 99 100 typedef struct die_header 101 { 102 uint16_t die_id; 103 uint16_t num_ips; 104 } die_header; 105 106 typedef struct ip_structure 107 { 108 ip_discovery_header* header; 109 struct die 110 { 111 die_header *die_header; 112 ip *ip_list; 113 } die; 114 } ip_structure; 115 116 struct gpu_info_header { 117 uint32_t table_id; /* table ID */ 118 uint16_t version_major; /* table version */ 119 uint16_t version_minor; /* table version */ 120 uint32_t size; /* size of the entire header+data in bytes */ 121 }; 122 123 struct gc_info_v1_0 { 124 struct gpu_info_header header; 125 126 uint32_t gc_num_se; 127 uint32_t gc_num_wgp0_per_sa; 128 uint32_t gc_num_wgp1_per_sa; 129 uint32_t gc_num_rb_per_se; 130 uint32_t gc_num_gl2c; 131 uint32_t gc_num_gprs; 132 uint32_t gc_num_max_gs_thds; 133 uint32_t gc_gs_table_depth; 134 uint32_t gc_gsprim_buff_depth; 135 uint32_t gc_parameter_cache_depth; 136 uint32_t gc_double_offchip_lds_buffer; 137 uint32_t gc_wave_size; 138 uint32_t gc_max_waves_per_simd; 139 uint32_t gc_max_scratch_slots_per_cu; 140 uint32_t gc_lds_size; 141 uint32_t gc_num_sc_per_se; 142 uint32_t gc_num_sa_per_se; 143 uint32_t gc_num_packer_per_sc; 144 uint32_t gc_num_gl2a; 145 }; 146 147 typedef struct harvest_info_header { 148 uint32_t signature; /* Table Signature */ 149 uint32_t version; /* Table Version */ 150 } harvest_info_header; 151 152 typedef struct harvest_info { 153 uint16_t hw_id; /* Hardware ID */ 154 uint8_t number_instance; /* Instance of the IP */ 155 uint8_t reserved; /* Reserved for alignment */ 156 } harvest_info; 157 158 typedef struct harvest_table { 159 harvest_info_header header; 160 harvest_info list[32]; 161 } harvest_table; 162 163 #pragma pack() 164 165 #endif 166