mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-01-07 22:23:55 -05:00
* amd pkt3 refactor * replace this * linter * fix * cmt * fast * simpler * linter * smth * missing
248 lines
6.4 KiB
C
248 lines
6.4 KiB
C
/* SPDX-License-Identifier: GPL-2.0 OR MIT */
|
|
/*
|
|
* Copyright 2016-2022 Advanced Micro Devices, Inc.
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
* to deal in the Software without restriction, including without limitation
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in
|
|
* all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
|
*
|
|
*/
|
|
|
|
#ifndef F32_MES_PM4_PACKETS_H
|
|
#define F32_MES_PM4_PACKETS_H
|
|
|
|
#define uint32_t unsigned int
|
|
#define int32_t int
|
|
|
|
#ifndef PM4_MES_HEADER_DEFINED
|
|
#define PM4_MES_HEADER_DEFINED
|
|
union PM4_MES_TYPE_3_HEADER {
|
|
struct {
|
|
uint32_t reserved1 : 8; /* < reserved */
|
|
uint32_t opcode : 8; /* < IT opcode */
|
|
uint32_t count : 14;/* < number of DWORDs - 1 in the
|
|
* information body.
|
|
*/
|
|
uint32_t type : 2; /* < packet identifier.
|
|
* It should be 3 for type 3 packets
|
|
*/
|
|
};
|
|
uint32_t u32All;
|
|
};
|
|
#endif /* PM4_MES_HEADER_DEFINED */
|
|
|
|
#ifndef PM4_MEC_RELEASE_MEM_DEFINED
|
|
#define PM4_MEC_RELEASE_MEM_DEFINED
|
|
|
|
enum mec_release_mem_event_index_enum {
|
|
event_index__mec_release_mem__end_of_pipe = 5,
|
|
event_index__mec_release_mem__shader_done = 6
|
|
};
|
|
|
|
enum mec_release_mem_cache_policy_enum {
|
|
cache_policy__mec_release_mem__lru = 0,
|
|
cache_policy__mec_release_mem__stream = 1
|
|
};
|
|
|
|
enum mec_release_mem_pq_exe_status_enum {
|
|
pq_exe_status__mec_release_mem__default = 0,
|
|
pq_exe_status__mec_release_mem__phase_update = 1
|
|
};
|
|
|
|
enum mec_release_mem_dst_sel_enum {
|
|
dst_sel__mec_release_mem__memory_controller = 0,
|
|
dst_sel__mec_release_mem__tc_l2 = 1,
|
|
dst_sel__mec_release_mem__queue_write_pointer_register = 2,
|
|
dst_sel__mec_release_mem__queue_write_pointer_poll_mask_bit = 3
|
|
};
|
|
|
|
enum mec_release_mem_int_sel_enum {
|
|
int_sel__mec_release_mem__none = 0,
|
|
int_sel__mec_release_mem__send_interrupt_only = 1,
|
|
int_sel__mec_release_mem__send_interrupt_after_write_confirm = 2,
|
|
int_sel__mec_release_mem__send_data_after_write_confirm = 3,
|
|
int_sel__mec_release_mem__unconditionally_send_int_ctxid = 4,
|
|
int_sel__mec_release_mem__conditionally_send_int_ctxid_based_on_32_bit_compare = 5,
|
|
int_sel__mec_release_mem__conditionally_send_int_ctxid_based_on_64_bit_compare = 6
|
|
};
|
|
|
|
enum mec_release_mem_data_sel_enum {
|
|
data_sel__mec_release_mem__none = 0,
|
|
data_sel__mec_release_mem__send_32_bit_low = 1,
|
|
data_sel__mec_release_mem__send_64_bit_data = 2,
|
|
data_sel__mec_release_mem__send_gpu_clock_counter = 3,
|
|
data_sel__mec_release_mem__send_cp_perfcounter_hi_lo = 4,
|
|
data_sel__mec_release_mem__store_gds_data_to_memory = 5
|
|
};
|
|
|
|
struct pm4_mec_release_mem {
|
|
union {
|
|
union PM4_MES_TYPE_3_HEADER header; /*header */
|
|
unsigned int ordinal1;
|
|
};
|
|
|
|
union {
|
|
struct {
|
|
unsigned int event_type:6;
|
|
unsigned int reserved1:2;
|
|
enum mec_release_mem_event_index_enum event_index:4;
|
|
unsigned int tcl1_vol_action_ena:1;
|
|
unsigned int tc_vol_action_ena:1;
|
|
unsigned int reserved2:1;
|
|
unsigned int tc_wb_action_ena:1;
|
|
unsigned int tcl1_action_ena:1;
|
|
unsigned int tc_action_ena:1;
|
|
uint32_t reserved3:1;
|
|
uint32_t tc_nc_action_ena:1;
|
|
uint32_t tc_wc_action_ena:1;
|
|
uint32_t tc_md_action_ena:1;
|
|
uint32_t reserved4:3;
|
|
enum mec_release_mem_cache_policy_enum cache_policy:2;
|
|
uint32_t reserved5:2;
|
|
enum mec_release_mem_pq_exe_status_enum pq_exe_status:1;
|
|
uint32_t reserved6:2;
|
|
} bitfields2;
|
|
unsigned int ordinal2;
|
|
};
|
|
|
|
union {
|
|
struct {
|
|
uint32_t reserved7:16;
|
|
enum mec_release_mem_dst_sel_enum dst_sel:2;
|
|
uint32_t reserved8:6;
|
|
enum mec_release_mem_int_sel_enum int_sel:3;
|
|
uint32_t reserved9:2;
|
|
enum mec_release_mem_data_sel_enum data_sel:3;
|
|
} bitfields3;
|
|
unsigned int ordinal3;
|
|
};
|
|
|
|
union {
|
|
struct {
|
|
uint32_t reserved10:2;
|
|
unsigned int address_lo_32b:30;
|
|
} bitfields4;
|
|
struct {
|
|
uint32_t reserved11:3;
|
|
uint32_t address_lo_64b:29;
|
|
} bitfields4b;
|
|
uint32_t reserved12;
|
|
unsigned int ordinal4;
|
|
};
|
|
|
|
union {
|
|
uint32_t address_hi;
|
|
uint32_t reserved13;
|
|
uint32_t ordinal5;
|
|
};
|
|
|
|
union {
|
|
uint32_t data_lo;
|
|
uint32_t cmp_data_lo;
|
|
struct {
|
|
uint32_t dw_offset:16;
|
|
uint32_t num_dwords:16;
|
|
} bitfields6c;
|
|
uint32_t reserved14;
|
|
uint32_t ordinal6;
|
|
};
|
|
|
|
union {
|
|
uint32_t data_hi;
|
|
uint32_t cmp_data_hi;
|
|
uint32_t reserved15;
|
|
uint32_t reserved16;
|
|
uint32_t ordinal7;
|
|
};
|
|
|
|
uint32_t int_ctxid;
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
#ifndef PM4_MEC_WRITE_DATA_DEFINED
|
|
#define PM4_MEC_WRITE_DATA_DEFINED
|
|
|
|
enum WRITE_DATA_dst_sel_enum {
|
|
dst_sel___write_data__mem_mapped_register = 0,
|
|
dst_sel___write_data__tc_l2 = 2,
|
|
dst_sel___write_data__gds = 3,
|
|
dst_sel___write_data__memory = 5,
|
|
dst_sel___write_data__memory_mapped_adc_persistent_state = 6,
|
|
};
|
|
|
|
enum WRITE_DATA_addr_incr_enum {
|
|
addr_incr___write_data__increment_address = 0,
|
|
addr_incr___write_data__do_not_increment_address = 1
|
|
};
|
|
|
|
enum WRITE_DATA_wr_confirm_enum {
|
|
wr_confirm___write_data__do_not_wait_for_write_confirmation = 0,
|
|
wr_confirm___write_data__wait_for_write_confirmation = 1
|
|
};
|
|
|
|
enum WRITE_DATA_cache_policy_enum {
|
|
cache_policy___write_data__lru = 0,
|
|
cache_policy___write_data__stream = 1
|
|
};
|
|
|
|
|
|
struct pm4_mec_write_data_mmio {
|
|
union {
|
|
union PM4_MES_TYPE_3_HEADER header; /*header */
|
|
unsigned int ordinal1;
|
|
};
|
|
|
|
union {
|
|
struct {
|
|
unsigned int reserved1:8;
|
|
unsigned int dst_sel:4;
|
|
unsigned int reserved2:4;
|
|
unsigned int addr_incr:1;
|
|
unsigned int reserved3:2;
|
|
unsigned int resume_vf:1;
|
|
unsigned int wr_confirm:1;
|
|
unsigned int reserved4:4;
|
|
unsigned int cache_policy:2;
|
|
unsigned int reserved5:5;
|
|
} bitfields2;
|
|
unsigned int ordinal2;
|
|
};
|
|
|
|
union {
|
|
struct {
|
|
unsigned int dst_mmreg_addr:18;
|
|
unsigned int reserved6:14;
|
|
} bitfields3;
|
|
unsigned int ordinal3;
|
|
};
|
|
|
|
uint32_t reserved7;
|
|
|
|
uint32_t data;
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
enum {
|
|
CACHE_FLUSH_AND_INV_TS_EVENT = 0x00000014
|
|
};
|
|
#endif
|
|
|