soc/intel_adsp: common testing code in cavstool.h

The IPC enum definition and WAIT_FOR macro are useful outside of
the board smoke tests for intel_adsp. They can be commonly used
by other board tests for a variety of peripherals that require
DSP and Host interaction (using cavstool).

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
This commit is contained in:
Tom Burdick 2022-03-02 11:40:12 -06:00 committed by Anas Nashif
commit 345a536794
2 changed files with 46 additions and 37 deletions

View file

@ -5,43 +5,7 @@
#define ZEPHYR_TESTS_INTEL_ADSP_TESTS_H
#include <cavs_ipc.h>
/* Helper to escape from infinite polling loops with a test failure
* instead of a hang. Spins with a relaxation loop so that it works
* in interrupt context and doesn't stress shared resources like SRAM
*/
#define WAIT_FOR(expr) do { \
int i; \
for (i = 0; !(expr) && i < 10000; i++) { \
for (volatile int j = 0; j < 1000; j++) { \
} \
} \
zassert_true(i < 10000, "timeout waiting for %s", #expr); \
} while (0)
/* The cavstool.py script that launched us listens for a very simple
* set of IPC commands to help test. Pass one of the following values
* as the "data" argument to cavs_ipc_send_message(CAVS_HOST_DEV, ...):
*/
enum cavstool_cmd {
/* The host takes no action, but signals DONE to complete the message */
IPCCMD_SIGNAL_DONE,
/* The host returns done after a short timeout */
IPCCMD_ASYNC_DONE_DELAY,
/* The host issues a new message with the ext_data value as its "data" */
IPCCMD_RETURN_MSG,
/* The host writes the given value to ADSPCS */
IPCCMD_ADSPCS,
/* The host emits a (real/host time) timestamp into the log stream */
IPCCMD_TIMESTAMP,
/* The host copies OUTBOX[ext_data >> 16] to INBOX[ext_data & 0xffff] */
IPCCMD_WINCOPY,
};
#include <cavstool.h>
void test_post_boot_ipi(void);
void test_smp_boot_delay(void);