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