| 1 |
/*========================== begin_copyright_notice ============================ |
| 2 |
|
| 3 |
Copyright (C) 2019-2021 Intel Corporation |
| 4 |
|
| 5 |
SPDX-License-Identifier: MIT |
| 6 |
|
| 7 |
============================= end_copyright_notice ===========================*/ |
| 8 |
|
| 9 |
#ifndef GPTIN_DRIVER_COMMON_BTI_H |
| 10 |
#define GPTIN_DRIVER_COMMON_BTI_H |
| 11 |
|
| 12 |
#include <stdint.h> |
| 13 |
|
| 14 |
#include "gtpin_driver_common.h" |
| 15 |
|
| 16 |
/************************************************************************/ |
| 17 |
/* Data Types */ |
| 18 |
/************************************************************************/ |
| 19 |
namespace gtpin { |
| 20 |
/*! |
| 21 |
* GTPin <-> Driver Interface Changelog: |
| 22 |
* 1. File reordering |
| 23 |
*/ |
| 24 |
static const uint8_t GTPIN_COMMON_BTI_INTERFACE_VERSION = 1; |
| 25 |
|
| 26 |
#define GENERATE_SPECIFIC_VERSION(PLATFORM_INTERFACE_VERSION) \ |
| 27 |
((GTPIN_COMMON_BTI_INTERFACE_VERSION << 8) | PLATFORM_INTERFACE_VERSION) |
| 28 |
|
| 29 |
typedef struct command_buffer_handle_s *command_buffer_handle_t; /// driver's handle to the command buffer |
| 30 |
|
| 31 |
/*! |
| 32 |
* Resource addressing mode |
| 33 |
*/ |
| 34 |
typedef enum { |
| 35 |
GTPIN_BUFFER_BINDFULL, /// using binding table index |
| 36 |
GTPIN_BUFFER_BINDLESS, /// using an offset to the surface table in a register |
| 37 |
GTPIN_BUFFER_STATELESS, /// using an address to the resource in a register |
| 38 |
} GTPIN_BUFFER_TYPE; |
| 39 |
|
| 40 |
/*! |
| 41 |
* The offest of the register in the GRF. |
| 42 |
* e.g. r2.5(dw) will be represented as 2*256 + 5*4 |
| 43 |
*/ |
| 44 |
typedef struct reg_desc_s { |
| 45 |
uint32_t reg_offset; /// the location of the register in the GRF (in bytes) |
| 46 |
uint32_t size; /// size of the register in bytes |
| 47 |
} reg_desc_t; |
| 48 |
|
| 49 |
/*! |
| 50 |
* Buffer's descriptor - could be: |
| 51 |
* 1. BTI - binding table index (in bindfull buffer addressing) |
| 52 |
* 2. register (in bindless / stateless buffer addressing) |
| 53 |
*/ |
| 54 |
typedef union buffer_desc_s { |
| 55 |
uint32_t BTI; /// Binding table index |
| 56 |
reg_desc_t reg_desc; |
| 57 |
} buffer_desc_t; |
| 58 |
|
| 59 |
/*! |
| 60 |
* kernel instrumentation parameters structure: |
| 61 |
*/ |
| 62 |
typedef struct instrument_params_s { |
| 63 |
GTPIN_KERNEL_TYPE kernel_type; |
| 64 |
GTPIN_SIMD_WIDTH simd; |
| 65 |
const uint8_t *orig_kernel_binary; /// the original kernel binary |
| 66 |
uint32_t orig_kernel_size; /// size of the kernel binary in bytes |
| 67 |
|
| 68 |
GTPIN_BUFFER_TYPE buffer_type; |
| 69 |
buffer_desc_t buffer_desc; |
| 70 |
uint64_t igc_hash_id; |
| 71 |
|
| 72 |
char *kernel_name; /// the kernel name |
| 73 |
const igc_info_t *igc_info; /// information form IGC |
| 74 |
|
| 75 |
/// START Exists only from COMMON_SUPPORTED_FEATURE_SOURCELINE_MAPPING |
| 76 |
const void *debug_data; /// debug data including the elf file |
| 77 |
uint32_t debug_data_size; /// size of the elf file in bytes |
| 78 |
/// End Exists only from COMMON_SUPPORTED_FEATURE_SOURCELINE_MAPPING |
| 79 |
} instrument_params_in_t; |
| 80 |
|
| 81 |
/*! |
| 82 |
* kernel instrumented data structure: |
| 83 |
*/ |
| 84 |
typedef struct instrument_params_out_s { |
| 85 |
uint8_t *inst_kernel_binary; /// the instrumented binary |
| 86 |
uint32_t inst_kernel_size; /// size in bytes on the instrumented binary |
| 87 |
uint64_t kernel_id; /// GTPin's associated kernel id |
| 88 |
} instrument_params_out_t; |
| 89 |
|
| 90 |
/*! |
| 91 |
* Allocate a buffer(resource) for GTPin |
| 92 |
* |
| 93 |
* @param[in] deviceHandle The handle to the device |
| 94 |
* @param[in] size Size of the buffer to allocate |
| 95 |
* @param[out] resource The handle to the created resource |
| 96 |
*/ |
| 97 |
typedef GTPIN_DI_STATUS(GTPIN_DRIVER_CALLCONV *BufferAllocateFPTR)(device_handle_t deviceHandle, uint32_t size, |
| 98 |
resource_handle_t *resource); |
| 99 |
|
| 100 |
/*! |
| 101 |
* Deallocate GTPin's buffer |
| 102 |
* |
| 103 |
* @param[in] deviceHandle The handle to the device |
| 104 |
* @param[in] resource The handle to the resource |
| 105 |
*/ |
| 106 |
typedef GTPIN_DI_STATUS(GTPIN_DRIVER_CALLCONV *BufferDeallocateFPTR)(device_handle_t deviceHandle, |
| 107 |
resource_handle_t resource); |
| 108 |
|
| 109 |
/*! |
| 110 |
* Map GTPin's buffer to obtain the virtual address |
| 111 |
* |
| 112 |
* @param[in] deviceHandle The handle to the device |
| 113 |
* @param[in] resource The handle to the resource |
| 114 |
* @param[out] address The virtual address of the resource |
| 115 |
*/ |
| 116 |
typedef GTPIN_DI_STATUS(GTPIN_DRIVER_CALLCONV *BufferMapFPTR)(device_handle_t deviceHandle, resource_handle_t resource, |
| 117 |
uint8_t **address); |
| 118 |
|
| 119 |
/*! |
| 120 |
* UnMap GTPin's allocated buffer |
| 121 |
* |
| 122 |
* @param[in] deviceHandle The handle to the device |
| 123 |
* @param[in] resource The handle to the resource |
| 124 |
*/ |
| 125 |
typedef GTPIN_DI_STATUS(GTPIN_DRIVER_CALLCONV *BufferUnMapFPTR)(device_handle_t deviceHandle, |
| 126 |
resource_handle_t resource); |
| 127 |
|
| 128 |
/************************************************************************/ |
| 129 |
/* Services (GTPin -> Driver) */ |
| 130 |
/* The following functions are implemented by the driver */ |
| 131 |
/* and called by GTPin */ |
| 132 |
/************************************************************************/ |
| 133 |
|
| 134 |
typedef struct driver_services_s { |
| 135 |
BufferAllocateFPTR bufferAllocate; /// request the Driver to allocate a buffer |
| 136 |
BufferDeallocateFPTR bufferDeallocate; /// request the Driver to de-allocate a buffer |
| 137 |
BufferMapFPTR bufferMap; /// request the Driver to map a buffer |
| 138 |
BufferUnMapFPTR bufferUnMap; /// request the Driver to unmap a buffer |
| 139 |
} driver_services_t; |
| 140 |
|
| 141 |
} // namespace gtpin |
| 142 |
|
| 143 |
#endif /// GPTIN_DRIVER_COMMON_BTI_H |