Skip to content

Commit 36f11d4

Browse files
Enhance cmd parser for custom commands parsing
Change-Id: I54bd48db5c99e0196d556fe14882a071c3f04b3b Signed-off-by: Dunajski, Bartosz <[email protected]>
1 parent 76400ff commit 36f11d4

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

unit_tests/gen_common/cmd_parse_base.inl

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2019 Intel Corporation
2+
* Copyright (C) 2018-2020 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -297,7 +297,13 @@ size_t CmdParse<T>::getCommandLength(void *cmd) {
297297
if (pCmd)
298298
return pCmd->TheStructure.Common.DwordLength + 2;
299299
}
300-
return getCommandLengthHwSpecific(cmd);
300+
301+
auto commandLengthHwSpecific = getCommandLengthHwSpecific(cmd);
302+
303+
if (commandLengthHwSpecific != 0) {
304+
return commandLengthHwSpecific;
305+
}
306+
return getAdditionalCommandLength(cmd);
301307
}
302308

303309
template <class T>
@@ -327,5 +333,20 @@ const char *CmdParse<T>::getCommandName(void *cmd) {
327333

328334
#undef RETURN_NAME_IF
329335

330-
return getCommandNameHwSpecific(cmd);
336+
auto commandNameHwSpecific = getCommandNameHwSpecific(cmd);
337+
if (strcmp(commandNameHwSpecific, "UNKNOWN") != 0) {
338+
return commandNameHwSpecific;
339+
}
340+
341+
return getAdditionalCommandName(cmd);
342+
}
343+
344+
template <class T>
345+
size_t CmdParse<T>::getAdditionalCommandLength(void *cmd) {
346+
return 0;
347+
}
348+
349+
template <class T>
350+
const char *CmdParse<T>::getAdditionalCommandName(void *cmd) {
351+
return "UNKNOWN";
331352
}

unit_tests/gen_common/gen_cmd_parse.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017-2019 Intel Corporation
2+
* Copyright (C) 2017-2020 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -90,6 +90,7 @@ template <class T>
9090
struct CmdParse : public T {
9191
static size_t getCommandLength(void *cmd);
9292
static size_t getCommandLengthHwSpecific(void *cmd);
93+
static size_t getAdditionalCommandLength(void *cmd);
9394

9495
static bool parseCommandBuffer(GenCmdList &_cmds, void *_buffer, size_t _length);
9596

@@ -98,4 +99,5 @@ struct CmdParse : public T {
9899

99100
static const char *getCommandName(void *cmd);
100101
static const char *getCommandNameHwSpecific(void *cmd);
102+
static const char *getAdditionalCommandName(void *cmd);
101103
};

0 commit comments

Comments
 (0)