-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommandModuleExt.h
More file actions
147 lines (124 loc) · 6.52 KB
/
Copy pathCommandModuleExt.h
File metadata and controls
147 lines (124 loc) · 6.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/* Copyright (C) 2021-2026 Advanced Micro Devices, Inc. All rights reserved. */
#pragma once
#include <stdbool.h>
#include <ddApi.h>
/// Compile time version information
#define COMMAND_EXTENSION_VERSION_MAJOR 0
#define COMMAND_EXTENSION_VERSION_MINOR 7
#define COMMAND_EXTENSION_VERSION_PATCH 0
/// Name of the extension
#define COMMAND_EXTENSION_NAME "Command"
/// Description of the extension
#define COMMAND_EXTENSION_DESCRIPTION "Allows modules to expose generic command execution functionality"
/// Identifier for the extension
/// This identifier is used to acquire access to the extension's interface
// Note: This is "command!" in ASCII
#define COMMAND_EXTENSION_ID 0x636f6d6d616e6421
/// Enumeration of command parameter types
typedef enum
{
COMMAND_PARAMETER_TYPE_UNKNOWN = 0, /// Unknown type
COMMAND_PARAMETER_TYPE_BOOL = 1, /// Boolean type
COMMAND_PARAMETER_TYPE_INT = 2, /// 64-bit signed integer
COMMAND_PARAMETER_TYPE_UINT = 3, /// 64-bit unsigned integer
COMMAND_PARAMETER_TYPE_FLOAT = 4, /// 64-bit floating point number
COMMAND_PARAMETER_TYPE_STRING = 5, /// String type
COMMAND_PARAMETER_TYPE_BLOB = 6, /// Binary blob
COMMAND_PARAMETER_TYPE_DATA_CONTEXT = 7, /// Data context
COMMAND_PARAMETER_TYPE_SYSTEM_CONTEXT = 8, /// System context
COMMAND_PARAMETER_TYPE_CLIENT_CONTEXT = 9, /// Client context
COMMAND_PARAMETER_TYPE_COUNT = 10, /// Count
} COMMAND_PARAMETER_TYPE;
/// Opaque identifier for an individual command
/// Acquired via the QueryCommands interface function
typedef uint32_t CommandId;
/// Structure that contains information about an arbitrary binary blob that's being passed as a command parameter
typedef struct CommandParameterBlobValue
{
const void* pData;
size_t dataSize;
} CommandParameterBlobValue;
/// Tagged union containing a command parameter type and value
typedef struct CommandParameterValue
{
COMMAND_PARAMETER_TYPE type; /// Type of value
uint32_t _padding; /// Padding used to ensure that the entire struct remains 8 byte aligned
union CommandParameterValueDataField
{
uint8_t boolVal;
int64_t i64Val;
uint64_t u64Val;
double f64Val;
const char* pStrVal;
CommandParameterBlobValue blobVal;
DDModuleDataContext hDataContext;
DDModuleSystemContext hSystemContext;
DDModuleClientContext hClientContext;
} data;
} CommandParameterValue;
/// Struct representing a pair of a parameter value and its name.
typedef struct CommandParameter
{
const char* pName;
CommandParameterValue value;
} CommandParameter;
/// Structure that describes a command parameter
typedef struct CommandParameterDescription
{
const char* pName; /// Name of the parameter
const char* pDescription; /// Description of the parameter
COMMAND_PARAMETER_TYPE type; /// Type of the parameter
bool isRequired; /// Whether the parameter is required or optional
const CommandParameterValue* pDefaultValue; /// The default value for the parameter, if no default is supported for the
//< parameter this field will be NULL.
} CommandParameterDescription;
/// Structure that describes a command
typedef struct DDModuleCommandDescription
{
const char* pName; /// Name of the command
/// This string is used to uniquely identify the command
const char* pDescription; /// Description of the command
const char* pOutputHint; /// Output hint string
/// This string is used by commands to indicate the format of their output
/// data. Simple users of the Command API may choose to ignore this field
/// and always treat the output data as binary. Sophisticated users may
/// leverage this field to offer improved data visualization options.
const CommandParameterDescription* pParameters; /// Array of command parameter structures
uint32_t numParameters; /// Number of entries in the pParameters array
} DDModuleCommandDescription;
/// Creation information for a command context
typedef struct DDModuleCommandContextCreateInfo
{
DDLoggerInfo loggerInfo; /// Required logging callbacks used by modules to log events.
} DDModuleCommandContextCreateInfo;
/// Creates a command extension context
typedef DD_RESULT (*PFN_CreateCommandContext)(
const DDModuleCommandContextCreateInfo* pCreateInfo, /// [in] Command context create info
DDModuleCommandContext* phCommandContext /// [out] Handle to the created command context
);
/// Destroys a command extension context
typedef void (*PFN_DestroyCommandContext)(
DDModuleCommandContext hCommandContext /// [out] Handle to command context to be destroyed
);
/// Returns descriptions for all of the supported commands
typedef void (*PFN_CommandQueryCommands)(
DDModuleCommandContext hCommandContext, /// [in] The command context from which the commands will be queried.
uint32_t* pNumCommands, /// [out] Number of commands returned in ppCommands
const DDModuleCommandDescription** ppCommands /// [out] Pointer to an array of the supported command descriptions
);
/// Attempts to execute the command specified by the caller
typedef DD_RESULT (*PFN_CommandExecuteCommand)(
DDModuleCommandContext hCommandContext, /// [in] The command context to execute the command.
const char* pCommandName, /// The name of the command.
uint32_t numParameters, /// Number of parameters in pParameters
const CommandParameter* pParameters, /// [in] Array of parameter to pass to the command
const DDByteWriter* pWriter /// [in] Pointer to the output writer to use for the command
);
/// Command Extension API
typedef struct CommandExtApi_0000
{
PFN_CreateCommandContext pfnCreateContext;
PFN_DestroyCommandContext pfnDestroyContext;
PFN_CommandQueryCommands pfnQueryCommands;
PFN_CommandExecuteCommand pfnExecuteCommand;
} CommandExtApi_0000;