hikey960: HiFi3 DSP firmware and documentation
HiFi3 DSP firmware source code, documentation to build and understand DSP
Change-Id: I752416536cc2165868c56d2a2ba2d60b71c2b9a4
Signed-off-by: Niranjan Yadla <nyadla@cadence.com>
diff --git a/hifi/xaf/hifi-dpf/include/audio/xa-audio-decoder-api.h b/hifi/xaf/hifi-dpf/include/audio/xa-audio-decoder-api.h
new file mode 100644
index 0000000..797bf23
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/audio/xa-audio-decoder-api.h
@@ -0,0 +1,66 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xa-audio-decoder-api.h
+ *
+ * Generic audio decoder API
+ *
+ ******************************************************************************/
+
+#ifndef __XA_ADEC_API_H__
+#define __XA_ADEC_API_H__
+
+/* ...includes */
+#include "xa_type_def.h"
+#include "xa_error_standards.h"
+#include "xa_apicmd_standards.h"
+#include "xa_memory_standards.h"
+
+/* ...generic audio-decoder configuration parameters */
+enum xa_config_param_codec {
+ XA_CODEC_CONFIG_PARAM_CHANNELS = 0x10000 + 0,
+ XA_CODEC_CONFIG_PARAM_SAMPLE_RATE = 0x10000 + 1,
+ XA_CODEC_CONFIG_PARAM_PCM_WIDTH = 0x10000 + 2,
+ XA_CODEC_CONFIG_PARAM_PRODUCED = 0x10000 + 3
+};
+
+/* ...ports indices */
+enum xa_codec_ports {
+ XA_CODEC_INPUT_PORT = 0,
+ XA_CODEC_OUTPUT_PORT = 1
+};
+
+/* ...non-fatal execution errors */
+enum
+{
+ XA_CODEC_EXEC_NO_DATA = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_GENERIC, 0)
+};
+
+/* ...fatal execution errors */
+enum
+{
+ XA_CODEC_EXEC_SEQUENCE = XA_ERROR_CODE(xa_severity_fatal, xa_class_execute, XA_CODEC_GENERIC, 0),
+ XA_CODEC_EXEC_MISBEHAVING = XA_ERROR_CODE(xa_severity_fatal, xa_class_execute, XA_CODEC_GENERIC, 1),
+};
+
+#endif
diff --git a/hifi/xaf/hifi-dpf/include/audio/xa-mixer-api.h b/hifi/xaf/hifi-dpf/include/audio/xa-mixer-api.h
new file mode 100644
index 0000000..0de1745
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/audio/xa-mixer-api.h
@@ -0,0 +1,157 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xa-mixer-api.h
+ *
+ * Mixer component API
+ *
+ ******************************************************************************/
+
+#ifndef __XA_MIXER_API_H__
+#define __XA_MIXER_API_H__
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+#include "xa_type_def.h"
+#include "xa_error_standards.h"
+#include "xa_apicmd_standards.h"
+#include "xa_memory_standards.h"
+
+/*******************************************************************************
+ * Constants definitions
+ ******************************************************************************/
+
+/* ...mixer-specific configuration parameters */
+enum xa_config_param_mixer {
+ XA_MIXER_CONFIG_PARAM_INPUT_TRACKS = 0,
+ XA_MIXER_CONFIG_PARAM_PCM_WIDTH = 1,
+ XA_MIXER_CONFIG_PARAM_CHANNELS = 2,
+ XA_MIXER_CONFIG_PARAM_SAMPLE_RATE = 4,
+ XA_MIXER_CONFIG_PARAM_FRAME_SIZE = 5,
+ XA_MIXER_CONFIG_PARAM_BUFFER_SIZE = 6,
+ XA_MIXER_CONFIG_PARAM_VOLUME = 7,
+ XA_MIXER_CONFIG_PARAM_NUM = 8
+};
+
+/* ...component identifier (informative) */
+#define XA_CODEC_MIXER 1
+
+/* ...global limitation - maximal mixer track number */
+#define XA_MIXER_MAX_TRACK_NUMBER 4
+
+/* ...volume representation */
+#define __XA_MIXER_VOLUME(v) \
+ ({ u32 __v = (u32)((v) * (1 << 12)); (__v > 0xFFFF ? __v = 0xFFFF : 0); (u16)__v; })
+
+/* ...mixer volume setting command encoding */
+#define XA_MIXER_VOLUME(track, channel, volume) \
+ (__XA_MIXER_VOLUME(volume) | ((track) << 16) | ((channel) << 20))
+
+/*******************************************************************************
+ * Class 0: API Errors
+ ******************************************************************************/
+
+#define XA_MIXER_API_NONFATAL(e) \
+ XA_ERROR_CODE(xa_severity_nonfatal, xa_class_api, XA_CODEC_MIXER, (e))
+
+#define XA_MIXER_API_FATAL(e) \
+ XA_ERROR_CODE(xa_severity_fatal, xa_class_api, XA_CODEC_MIXER, (e))
+
+enum xa_error_nonfatal_api_mixer {
+ XA_MIXER_API_NONFATAL_MAX = XA_MIXER_API_NONFATAL(0)
+};
+
+enum xa_error_fatal_api_mixer {
+ XA_MIXER_API_FATAL_MAX = XA_MIXER_API_FATAL(0)
+};
+
+/*******************************************************************************
+ * Class 1: Configuration Errors
+ ******************************************************************************/
+
+#define XA_MIXER_CONFIG_NONFATAL(e) \
+ XA_ERROR_CODE(xa_severity_nonfatal, xa_class_config, XA_CODEC_MIXER, (e))
+
+#define XA_MIXER_CONFIG_FATAL(e) \
+ XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_MIXER, (e))
+
+enum xa_error_nonfatal_config_mixer {
+ XA_MIXER_CONFIG_NONFATAL_RANGE = XA_MIXER_CONFIG_NONFATAL(0),
+ XA_MIXER_CONFIG_NONFATAL_STATE = XA_MIXER_CONFIG_NONFATAL(1),
+ XA_MIXER_CONFIG_NONFATAL_MAX = XA_MIXER_CONFIG_NONFATAL(2)
+};
+
+enum xa_error_fatal_config_mixer {
+ XA_MIXER_CONFIG_FATAL_RANGE = XA_MIXER_CONFIG_FATAL(0),
+ XA_MIXER_CONFIG_FATAL_TRACK_STATE = XA_MIXER_CONFIG_FATAL(0 + XA_MIXER_CONFIG_NONFATAL_MAX),
+ XA_MIXER_CONFIG_FATAL_MAX = XA_MIXER_CONFIG_FATAL(1)
+};
+
+/*******************************************************************************
+ * Class 2: Execution Class Errors
+ ******************************************************************************/
+
+#define XA_MIXER_EXEC_NONFATAL(e) \
+ XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_MIXER, (e))
+
+#define XA_MIXER_EXEC_FATAL(e) \
+ XA_ERROR_CODE(xa_severity_fatal, xa_class_execute, XA_CODEC_MIXER, (e))
+
+enum xa_error_nonfatal_execute_mixer {
+ XA_MIXER_EXEC_NONFATAL_STATE = XA_MIXER_EXEC_NONFATAL(0),
+ XA_MIXER_EXEC_NONFATAL_NO_DATA = XA_MIXER_EXEC_NONFATAL(1),
+ XA_MIXER_EXEC_NONFATAL_INPUT = XA_MIXER_EXEC_NONFATAL(2),
+ XA_MIXER_EXEC_NONFATAL_OUTPUT = XA_MIXER_EXEC_NONFATAL(3),
+ XA_MIXER_EXEC_NONFATAL_MAX = XA_MIXER_EXEC_NONFATAL(4)
+};
+
+enum xa_error_fatal_execute_mixer {
+ XA_MIXER_EXEC_FATAL_STATE = XA_MIXER_EXEC_FATAL(0),
+ XA_MIXER_EXEC_FATAL_INPUT = XA_MIXER_EXEC_FATAL(1),
+ XA_MIXER_EXEC_FATAL_OUTPUT = XA_MIXER_EXEC_FATAL(2),
+ XA_MIXER_EXEC_FATAL_MAX = XA_MIXER_EXEC_FATAL(3)
+};
+
+/*******************************************************************************
+ * API function definition (tbd)
+ ******************************************************************************/
+
+#if defined(USE_DLL) && defined(_WIN32)
+#define DLL_SHARED __declspec(dllimport)
+#elif defined (_WINDLL)
+#define DLL_SHARED __declspec(dllexport)
+#else
+#define DLL_SHARED
+#endif
+
+#if defined(__cplusplus)
+extern "C" {
+#endif /* __cplusplus */
+DLL_SHARED xa_codec_func_t xa_mixer;
+#if defined(__cplusplus)
+}
+#endif /* __cplusplus */
+
+#endif /* __XA_MIXER_API_H__ */
diff --git a/hifi/xaf/hifi-dpf/include/audio/xa_apicmd_standards.h b/hifi/xaf/hifi-dpf/include/audio/xa_apicmd_standards.h
new file mode 100644
index 0000000..eb1b78e
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/audio/xa_apicmd_standards.h
@@ -0,0 +1,107 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+
+******************************************************************************/
+/*******************************************************************************
+*
+* NOTE, ANY CHANGES TO THIS FILE MAY AFFECT UNDERLYING AUDIO / SPEECH CODEC
+* LIBRARY COMPONENT FROM CADENCE DESIGN SYSTEMS, INC.
+*
+******************************************************************************/
+
+
+#ifndef __XA_API_CMD_STANDARDS_H__
+#define __XA_API_CMD_STANDARDS_H__
+
+/*****************************************************************************/
+/* Standard API commands */
+/*****************************************************************************/
+
+enum xa_api_cmd_generic {
+ XA_API_CMD_GET_LIB_ID_STRINGS = 0x0001,
+
+ XA_API_CMD_GET_API_SIZE = 0x0002,
+ XA_API_CMD_INIT = 0x0003,
+
+ XA_API_CMD_SET_CONFIG_PARAM = 0x0004,
+ XA_API_CMD_GET_CONFIG_PARAM = 0x0005,
+
+ XA_API_CMD_GET_MEMTABS_SIZE = 0x0006,
+ XA_API_CMD_SET_MEMTABS_PTR = 0x0007,
+ XA_API_CMD_GET_N_MEMTABS = 0x0008,
+
+ XA_API_CMD_EXECUTE = 0x0009,
+
+ XA_API_CMD_PUT_INPUT_QUERY = 0x000A,
+ XA_API_CMD_GET_CURIDX_INPUT_BUF = 0x000B,
+ XA_API_CMD_SET_INPUT_BYTES = 0x000C,
+ XA_API_CMD_GET_OUTPUT_BYTES = 0x000D,
+ XA_API_CMD_INPUT_OVER = 0x000E,
+
+ XA_API_CMD_GET_MEM_INFO_SIZE = 0x0010,
+ XA_API_CMD_GET_MEM_INFO_ALIGNMENT = 0x0011,
+ XA_API_CMD_GET_MEM_INFO_TYPE = 0x0012,
+ XA_API_CMD_GET_MEM_INFO_PLACEMENT = 0x0013,
+ XA_API_CMD_GET_MEM_INFO_PRIORITY = 0x0014,
+ XA_API_CMD_SET_MEM_PTR = 0x0015,
+ XA_API_CMD_SET_MEM_INFO_SIZE = 0x0016,
+ XA_API_CMD_SET_MEM_PLACEMENT = 0x0017,
+
+ XA_API_CMD_GET_N_TABLES = 0x0018,
+ XA_API_CMD_GET_TABLE_INFO_SIZE = 0x0019,
+ XA_API_CMD_GET_TABLE_INFO_ALIGNMENT = 0x001A,
+ XA_API_CMD_GET_TABLE_INFO_PRIORITY = 0x001B,
+ XA_API_CMD_SET_TABLE_PTR = 0x001C,
+ XA_API_CMD_GET_TABLE_PTR = 0x001D
+};
+
+/*****************************************************************************/
+/* Standard API command indices */
+/*****************************************************************************/
+
+enum xa_cmd_type_generic {
+ /* XA_API_CMD_GET_LIB_ID_STRINGS indices */
+ XA_CMD_TYPE_LIB_NAME = 0x0100,
+ XA_CMD_TYPE_LIB_VERSION = 0x0200,
+ XA_CMD_TYPE_API_VERSION = 0x0300,
+
+ /* XA_API_CMD_INIT indices */
+ XA_CMD_TYPE_INIT_API_PRE_CONFIG_PARAMS = 0x0100,
+ XA_CMD_TYPE_INIT_API_POST_CONFIG_PARAMS = 0x0200,
+ XA_CMD_TYPE_INIT_PROCESS = 0x0300,
+ XA_CMD_TYPE_INIT_DONE_QUERY = 0x0400,
+
+ /* XA_API_CMD_EXECUTE indices */
+ XA_CMD_TYPE_DO_EXECUTE = 0x0100,
+ XA_CMD_TYPE_DONE_QUERY = 0x0200,
+ XA_CMD_TYPE_DO_RUNTIME_INIT = 0x0300
+};
+
+
+/*****************************************************************************/
+/* Standard API configuration parameters */
+/*****************************************************************************/
+
+enum xa_config_param_generic {
+ XA_CONFIG_PARAM_CUR_INPUT_STREAM_POS = 0x0100,
+ XA_CONFIG_PARAM_GEN_INPUT_STREAM_POS = 0x0200,
+};
+
+#endif /* __XA_API_CMD_STANDARDS_H__ */
diff --git a/hifi/xaf/hifi-dpf/include/audio/xa_error_standards.h b/hifi/xaf/hifi-dpf/include/audio/xa_error_standards.h
new file mode 100644
index 0000000..1b67b52
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/audio/xa_error_standards.h
@@ -0,0 +1,79 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+
+******************************************************************************/
+/*******************************************************************************
+*
+* NOTE, ANY CHANGES TO THIS FILE MAY AFFECT UNDERLYING AUDIO / SPEECH CODEC
+* LIBRARY COMPONENT FROM CADENCE DESIGN SYSTEMS, INC.
+*
+******************************************************************************/
+
+
+#ifndef __XA_ERROR_STANDARDS_H__
+#define __XA_ERROR_STANDARDS_H__
+
+/*****************************************************************************/
+/* File includes */
+/* xa_type_def.h */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/* Constant hash defines */
+/*****************************************************************************/
+#define XA_NO_ERROR 0
+#define XA_FATAL_ERROR 0x80000000
+
+enum xa_error_severity {
+ xa_severity_nonfatal = 0,
+ xa_severity_fatal = 0xffffffff
+};
+
+enum xa_error_class {
+ xa_class_api = 0,
+ xa_class_config = 1,
+ xa_class_execute = 2,
+ xa_class_proxy = 3
+};
+
+#define XA_CODEC_GENERIC 0
+
+#define XA_ERROR_CODE(severity, class, codec, index) ((severity << 15) | (class << 11) | (codec << 6) | index)
+#define XA_ERROR_SEVERITY(code) (((code) & XA_FATAL_ERROR) != 0)
+#define XA_ERROR_CLASS(code) (((code) >> 11) & 0x0f)
+#define XA_ERROR_CODEC(code) (((code) >> 6) & 0x1f)
+#define XA_ERROR_SUBCODE(code) (((code) >> 0) & 0x3f)
+
+/* Our convention is that only api-class errors can be generic ones. */
+
+/*****************************************************************************/
+/* Class 0: API Errors */
+/*****************************************************************************/
+/* Non Fatal Errors */
+/* (none) */
+/* Fatal Errors */
+enum xa_error_fatal_api_generic {
+ XA_API_FATAL_MEM_ALLOC = XA_ERROR_CODE(xa_severity_fatal, xa_class_api, XA_CODEC_GENERIC, 0),
+ XA_API_FATAL_MEM_ALIGN = XA_ERROR_CODE(xa_severity_fatal, xa_class_api, XA_CODEC_GENERIC, 1),
+ XA_API_FATAL_INVALID_CMD = XA_ERROR_CODE(xa_severity_fatal, xa_class_api, XA_CODEC_GENERIC, 2),
+ XA_API_FATAL_INVALID_CMD_TYPE = XA_ERROR_CODE(xa_severity_fatal, xa_class_api, XA_CODEC_GENERIC, 3)
+};
+
+#endif /* __XA_ERROR_STANDARDS_H__ */
diff --git a/hifi/xaf/hifi-dpf/include/audio/xa_memory_standards.h b/hifi/xaf/hifi-dpf/include/audio/xa_memory_standards.h
new file mode 100644
index 0000000..27ec455
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/audio/xa_memory_standards.h
@@ -0,0 +1,104 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+
+******************************************************************************/
+/*******************************************************************************
+*
+* NOTE, ANY CHANGES TO THIS FILE MAY AFFECT UNDERLYING AUDIO / SPEECH CODEC
+* LIBRARY COMPONENT FROM CADENCE DESIGN SYSTEMS, INC.
+*
+******************************************************************************/
+
+
+#ifndef __XA_MEMORY_STANDARDS_H__
+#define __XA_MEMORY_STANDARDS_H__
+
+/*****************************************************************************/
+/* Constant hash defines */
+/*****************************************************************************/
+/* when you don't need alignment, pass this to memory library */
+#define XA_MEM_NO_ALIGN 0x01
+
+/* standard memory types */
+/* to be used inter frames */
+#define XA_MEMTYPE_PERSIST 0x00
+/* read write, to be used intra frames */
+#define XA_MEMTYPE_SCRATCH 0x01
+/* read only memory, intra frame */
+#define XA_MEMTYPE_INPUT 0x02
+/* read-write memory, for usable output, intra frame */
+#define XA_MEMTYPE_OUTPUT 0x03
+/* readonly memory, inter frame */
+#define XA_MEMTYPE_TABLE 0x04
+/* input buffer before mem tabs allocation */
+#define XA_MEMTYPE_PRE_FRAME_INPUT 0x05
+/* input buffer before mem tabs allocation */
+#define XA_MEMTYPE_PRE_FRAME_SCRATCH 0x06
+/* for local variables */
+#define XA_MEMTYPE_AUTO_VAR 0x80
+
+/* standard memory priorities */
+#define XA_MEMPRIORITY_ANYWHERE 0x00
+#define XA_MEMPRIORITY_LOWEST 0x01
+#define XA_MEMPRIORITY_LOW 0x02
+#define XA_MEMPRIORITY_NORM 0x03
+#define XA_MEMPRIORITY_ABOVE_NORM 0x04
+#define XA_MEMPRIORITY_HIGH 0x05
+#define XA_MEMPRIORITY_HIGHER 0x06
+#define XA_MEMPRIORITY_CRITICAL 0x07
+
+/* standard memory placements */
+/* placement is defined by 64 bits */
+
+#define XA_MEMPLACE_FAST_RAM_0 0x000001
+#define XA_MEMPLACE_FAST_RAM_1 0x000002
+#define XA_MEMPLACE_FAST_RAM_2 0x000004
+#define XA_MEMPLACE_FAST_RAM_3 0x000008
+#define XA_MEMPLACE_FAST_RAM_4 0x000010
+#define XA_MEMPLACE_FAST_RAM_5 0x000020
+#define XA_MEMPLACE_FAST_RAM_6 0x000040
+#define XA_MEMPLACE_FAST_RAM_7 0x000080
+
+#define XA_MEMPLACE_INT_RAM_0 0x000100
+#define XA_MEMPLACE_INT_RAM_1 0x000200
+#define XA_MEMPLACE_INT_RAM_2 0x000400
+#define XA_MEMPLACE_INT_RAM_3 0x000800
+#define XA_MEMPLACE_INT_RAM_4 0x001000
+#define XA_MEMPLACE_INT_RAM_5 0x002000
+#define XA_MEMPLACE_INT_RAM_6 0x004000
+#define XA_MEMPLACE_INT_RAM_7 0x008000
+
+#define XA_MEMPLACE_EXT_RAM_0 0x010000
+#define XA_MEMPLACE_EXT_RAM_1 0x020000
+#define XA_MEMPLACE_EXT_RAM_2 0x040000
+#define XA_MEMPLACE_EXT_RAM_3 0x080000
+#define XA_MEMPLACE_EXT_RAM_4 0x100000
+#define XA_MEMPLACE_EXT_RAM_5 0x200000
+#define XA_MEMPLACE_EXT_RAM_6 0x400000
+#define XA_MEMPLACE_EXT_RAM_7 0x800000
+
+#define XA_MEMPLACE_DONTCARE_H 0xFFFFFFFF
+#define XA_MEMPLACE_DONTCARE_L 0xFFFFFFFF
+
+/* the simple common PC RAM */
+#define XA_PC_RAM_H 0x00000000
+#define XA_PC_RAM_L XA_MEMPLACE_EXT_RAM_0
+
+#endif /* __XA_MEMORY_STANDARDS_H__ */
diff --git a/hifi/xaf/hifi-dpf/include/audio/xa_type_def.h b/hifi/xaf/hifi-dpf/include/audio/xa_type_def.h
new file mode 100644
index 0000000..e83cdd3
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/audio/xa_type_def.h
@@ -0,0 +1,98 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+
+******************************************************************************/
+/*******************************************************************************
+*
+* NOTE, ANY CHANGES TO THIS FILE MAY AFFECT UNDERLYING AUDIO / SPEECH CODEC
+* LIBRARY COMPONENT FROM CADENCE DESIGN SYSTEMS, INC.
+*
+******************************************************************************/
+
+
+#ifndef __XA_TYPE_DEF_H__
+#define __XA_TYPE_DEF_H__
+
+/****************************************************************************/
+/* types type define prefix examples bytes */
+/************************ *********** ****** **************** ***** */
+typedef signed char WORD8 ;/* b WORD8 b_name 1 */
+typedef signed char * pWORD8 ;/* pb pWORD8 pb_nmae 1 */
+typedef unsigned char UWORD8 ;/* ub UWORD8 ub_count 1 */
+typedef unsigned char * pUWORD8 ;/* pub pUWORD8 pub_count 1 */
+
+typedef signed short WORD16 ;/* s WORD16 s_count 2 */
+typedef signed short * pWORD16 ;/* ps pWORD16 ps_count 2 */
+typedef unsigned short UWORD16 ;/* us UWORD16 us_count 2 */
+typedef unsigned short * pUWORD16;/* pus pUWORD16 pus_count 2 */
+
+typedef signed int WORD24 ;/* k WORD24 k_count 3 */
+typedef signed int * pWORD24 ;/* pk pWORD24 pk_count 3 */
+typedef unsigned int UWORD24 ;/* uk UWORD24 uk_count 3 */
+typedef unsigned int * pUWORD24;/* puk pUWORD24 puk_count 3 */
+
+typedef signed int WORD32 ;/* i WORD32 i_count 4 */
+typedef signed int * pWORD32 ;/* pi pWORD32 pi_count 4 */
+typedef unsigned int UWORD32 ;/* ui UWORD32 ui_count 4 */
+typedef unsigned int * pUWORD32;/* pui pUWORD32 pui_count 4 */
+
+typedef signed long long WORD40 ;/* m WORD40 m_count 5 */
+typedef signed long long * pWORD40 ;/* pm pWORD40 pm_count 5 */
+typedef unsigned long long UWORD40 ;/* um UWORD40 um_count 5 */
+typedef unsigned long long * pUWORD40;/* pum pUWORD40 pum_count 5 */
+
+typedef signed long long WORD64 ;/* h WORD64 h_count 8 */
+typedef signed long long * pWORD64 ;/* ph pWORD64 ph_count 8 */
+typedef unsigned long long UWORD64 ;/* uh UWORD64 uh_count 8 */
+typedef unsigned long long * pUWORD64;/* puh pUWORD64 puh_count 8 */
+
+typedef float FLOAT32 ;/* f FLOAT32 f_count 4 */
+typedef float * pFLOAT32;/* pf pFLOAT32 pf_count 4 */
+typedef double FLOAT64 ;/* d UFLOAT64 d_count 8 */
+typedef double * pFlOAT64;/* pd pFLOAT64 pd_count 8 */
+
+typedef void VOID ;/* v VOID v_flag 4 */
+typedef void * pVOID ;/* pv pVOID pv_flag 4 */
+
+/* variable size types: platform optimized implementation */
+//typedef signed int BOOL ;/* bool BOOL bool_true */
+//typedef unsigned int UBOOL ;/* ubool BOOL ubool_true */
+typedef signed int FLAG ;/* flag FLAG flag_false */
+typedef unsigned int UFLAG ;/* uflag FLAG uflag_false */
+typedef signed int LOOPIDX ;/* lp LOOPIDX lp_index */
+typedef unsigned int ULOOPIDX;/* ulp SLOOPIDX ulp_index */
+typedef signed int WORD ;/* lp LOOPIDX lp_index */
+typedef unsigned int UWORD ;/* ulp SLOOPIDX ulp_index */
+
+typedef LOOPIDX LOOPINDEX; /* lp LOOPIDX lp_index */
+typedef ULOOPIDX ULOOPINDEX;/* ulp SLOOPIDX ulp_index */
+
+#define PLATFORM_INLINE __inline
+
+typedef struct xa_codec_opaque { WORD32 _; } *xa_codec_handle_t;
+
+typedef int XA_ERRORCODE;
+
+typedef XA_ERRORCODE xa_codec_func_t(xa_codec_handle_t p_xa_module_obj,
+ WORD32 i_cmd,
+ WORD32 i_idx,
+ pVOID pv_value);
+
+#endif /* __XA_TYPE_DEF_H__ */
diff --git a/hifi/xaf/hifi-dpf/include/lib/mutex.h b/hifi/xaf/hifi-dpf/include/lib/mutex.h
new file mode 100644
index 0000000..2aef0f6
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/lib/mutex.h
@@ -0,0 +1,59 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * mutex.h
+ *
+ *
+ * Implementation of "non-robust" Szymanski linear-waiting algorithm. Types of
+ * failures tolerated by Szymanski's "robust" algorithm are not specific for
+ * Xtensa DSP cluster and therefore more lightweight version of the algorithm
+ * is used. FIFO servicing property is of low importance, and faster/smaller
+ * version with linear-wait property is preferable.
+ *
+ * We assume there is just a single mutex in the system, and all communication
+ * variables are defined somewhere in board-specific headers and imported here
+ * by means of macros MUTEX_SHARED_READ/WRITE.
+ ******************************************************************************/
+
+#ifndef __MUTEX_H
+#define __MUTEX_H
+
+/*******************************************************************************
+ * Imported macros
+ ******************************************************************************/
+
+#if !defined(MUTEX_SHARED_READ) || !defined(MUTEX_SHARED_WRITE)
+#error "Macros MUTEX_SHARED_READ and/or MUTEX_SHARED_WRITE not defined"
+#endif
+
+/*******************************************************************************
+ * Entry points
+ ******************************************************************************/
+
+/* ...acquire global mutex from i-th core */
+extern void mutex_lock(u32 i);
+
+/* ...release global mutex from i-th core */
+extern void mutex_unlock(u32 i);
+
+#endif /* __MUTEX_H */
diff --git a/hifi/xaf/hifi-dpf/include/lib/rbtree.h b/hifi/xaf/hifi-dpf/include/lib/rbtree.h
new file mode 100644
index 0000000..7f02cdf
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/lib/rbtree.h
@@ -0,0 +1,157 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * rbtree.h
+ *
+ * Generic implmentation of red-black trees
+ *
+ *******************************************************************************/
+
+#ifndef __RBTREE_H
+#define __RBTREE_H
+
+/*******************************************************************************
+ * Red-black tree node definition
+ ******************************************************************************/
+
+/* ...reference to rb-tree node */
+typedef struct rb_node *rb_idx_t;
+
+/* ...rb-tree node */
+typedef struct rb_node
+{
+ /* ...pointers to parent and two children */
+ rb_idx_t parent, left, right;
+
+ /* ...node color (least-significant-bit only) */
+ u32 color;
+
+} rb_node_t;
+
+/* ...rb-tree data */
+typedef struct rb_tree_t
+{
+ /* ...tree sentinel node */
+ rb_node_t root;
+
+} rb_tree_t;
+
+/*******************************************************************************
+ * Helpers
+ ******************************************************************************/
+
+/* ...left child accessor */
+static inline rb_idx_t rb_left(rb_tree_t *tree, rb_idx_t n_idx)
+{
+ return n_idx->left;
+}
+
+/* ...right child accessor */
+static inline rb_idx_t rb_right(rb_tree_t *tree, rb_idx_t n_idx)
+{
+ return n_idx->right;
+}
+
+/* ...parent node accessor */
+static inline rb_idx_t rb_parent(rb_tree_t *tree, rb_idx_t n_idx)
+{
+ return n_idx->parent;
+}
+
+/* ...tree root node accessor */
+static inline rb_idx_t rb_root(rb_tree_t *tree)
+{
+ return rb_left(tree, &tree->root);
+}
+
+/* ...tree data pointer accessor */
+static inline rb_idx_t rb_cache(rb_tree_t *tree)
+{
+ return rb_right(tree, &tree->root);
+}
+
+/* ...tree null node */
+static inline rb_idx_t rb_null(rb_tree_t *tree)
+{
+ return &tree->root;
+}
+
+/* ...get user-bits stored in node color */
+static inline u32 rb_node_data(rb_tree_t *tree, rb_idx_t n_idx)
+{
+ return (n_idx->color >> 1);
+}
+
+/* ...left child assignment */
+static inline void rb_set_left(rb_tree_t *tree, rb_idx_t n_idx, rb_node_t *child)
+{
+ n_idx->left = child;
+}
+
+/* ...right child assignment */
+static inline void rb_set_right(rb_tree_t *tree, rb_idx_t n_idx, rb_node_t *child)
+{
+ n_idx->right = child;
+}
+
+/* ...cache tree client index */
+static inline void rb_set_cache(rb_tree_t *tree, rb_idx_t c_idx)
+{
+ tree->root.right = c_idx;
+}
+
+/* ...get user-bits stored in node color */
+static inline void rb_set_node_data(rb_tree_t *tree, rb_idx_t n_idx, u32 data)
+{
+ n_idx->color = (n_idx->color & 0x1) | (data << 1);
+}
+
+/*******************************************************************************
+ * API functions
+ ******************************************************************************/
+
+/* ...initialize rb-tree */
+extern void rb_init(rb_tree_t *tree);
+
+/* ...insert node into tree as a child of p */
+extern void rb_insert(rb_tree_t *tree, rb_idx_t n_idx, rb_idx_t p_idx);
+
+/* ...replace the node with same-key value and fixup tree pointers */
+extern void rb_replace(rb_tree_t *tree, rb_idx_t n_idx, rb_idx_t t_idx);
+
+/* ...delete node from the tree and return its in-order predecessor/successor */
+extern rb_idx_t rb_delete(rb_tree_t *tree, rb_idx_t n_idx);
+
+/* ...first in-order item in the tree */
+extern rb_idx_t rb_first(rb_tree_t *tree);
+
+/* ...last in-order item in the tree */
+extern rb_idx_t rb_last(rb_tree_t *tree);
+
+/* ...forward tree iterator */
+extern rb_idx_t rb_next(rb_tree_t *tree, rb_idx_t n_idx);
+
+/* ...backward tree iterator */
+extern rb_idx_t rb_prev(rb_tree_t *tree, rb_idx_t n_idx);
+
+#endif /* __RBTREE_H */
diff --git a/hifi/xaf/hifi-dpf/include/lib/tinyput.h b/hifi/xaf/hifi-dpf/include/lib/tinyput.h
new file mode 100644
index 0000000..dadd088
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/lib/tinyput.h
@@ -0,0 +1,31 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+
+******************************************************************************/
+
+/* $Id: //depot/dev/Cottonwood/Xtensa/OS/mpg2/tinyput.h#2 $ */
+
+#include <stdarg.h>
+
+extern void tiny_putc(char c);
+extern int tiny_puts(const char *s);
+extern int tiny_atoi(const char *s);
+extern int tiny_vsprintf(char *out, const char *fmt, va_list ap);
+extern int tiny_sprintf(char *out, const char *fmt, ...);
diff --git a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/arch_hifi330.h b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/arch_hifi330.h
new file mode 100644
index 0000000..74b1222
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/arch_hifi330.h
@@ -0,0 +1,134 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+
+******************************************************************************/
+
+#include <xtensa/simcall.h>
+#include <xtensa/corebits.h>
+#include <xtensa/config/system.h>
+#include <xtensa/config/core.h>
+
+#ifndef __ARCH_HIFI330_H__
+#define __ARCH_HIFI330_H__
+
+#ifdef __ASSEMBLER__
+#include <xtensa/coreasm.h>
+#endif
+
+#include <xtensa/corebits.h>
+#include <xtensa/config/system.h>
+
+/*
+Align a value up to nearest n-byte boundary, where n is a power of 2.
+*/
+#define ALIGNUP(n, val) (((val) + (n)-1) & -(n))
+
+
+/*******************************************************************************
+INTERRUPT STACK FRAME FOR A THREAD OR NESTED INTERRUPT
+*******************************************************************************/
+#define XT_STK_EXIT 0x00 /* (offset 0) exit point for dispatch */
+#define XT_STK_PC 0x04 /* return address */
+#define XT_STK_PS 0x08 /* at level 1 PS.EXCM is set here */
+#define XT_STK_A0 0x0C
+#define XT_STK_A1 0x10 /* stack ptr before interrupt */
+#define XT_STK_A2 0x14
+#define XT_STK_A3 0x18
+#define XT_STK_A4 0x1C
+#define XT_STK_A5 0x20
+#define XT_STK_A6 0x24
+#define XT_STK_A7 0x28
+#define XT_STK_A8 0x2C
+#define XT_STK_A9 0x30
+#define XT_STK_A10 0x34
+#define XT_STK_A11 0x38
+#define XT_STK_A12 0x3C /* Call0 callee-save */
+#define XT_STK_A13 0x40 /* Call0 callee-save */
+#define XT_STK_A14 0x44 /* Call0 callee-save */
+#define XT_STK_A15 0x48 /* Call0 callee-save */
+#define XT_STK_SAR 0x4C
+
+#define XT_STK_LBEG 0x50
+#define XT_STK_LEND 0x54
+#define XT_STK_LCOUNT 0x58
+#define XT_STK_NEXT1 0x5C /* next unused offset */
+
+#define XT_STK_EXTRA ALIGNUP(XCHAL_EXTRA_SA_ALIGN, XT_STK_NEXT1)
+
+#define XT_STK_NEXT2 (XT_STK_EXTRA + XCHAL_EXTRA_SA_SIZE)
+
+#define XT_STK_N_TMP 3 /* # of 4-byte temp. slots */
+#define XT_STK_TMP XT_STK_NEXT2
+#define XT_STK_NEXT3 XT_STK_TMP + (4 * XT_STK_N_TMP)
+#define XT_STK_FRMSZ (ALIGNUP(0x10, XT_STK_NEXT3) + 0x20)
+
+
+/*******************************************************************************
+SIMPLE STACK FRAME FOR A THREAD
+*******************************************************************************/
+#define XT_SOL_EXIT XT_STK_EXIT /* code indicates solicited frame */
+#define XT_SOL_PC 0x04 /* return address (b30-31=callinc) */
+#define XT_SOL_PS 0x08
+#define XT_SOL_NEXT 0x0c /* next unused offset */
+ /* there may be some unused space here */
+#define XT_SOL_A0 ALIGNUP(0x10, XT_SOL_NEXT)
+#define XT_SOL_A1 XT_SOL_A0 + 4
+#define XT_SOL_A2 XT_SOL_A1 + 4
+#define XT_SOL_A3 XT_SOL_A2 + 4
+#define XT_SOL_FRMSZ ALIGNUP(0x10, XT_SOL_A3)
+
+
+/*******************************************************************************
+CO-PROCESSOR STATE SAVE AREA FOR A THREAD
+*******************************************************************************/
+#define XT_CPENABLE 0
+#define XT_CPSTORED (XT_CPENABLE + 1)
+#define XT_CP0_SA ALIGNUP(XCHAL_CP0_SA_ALIGN, XT_CPSTORED + 1)
+#define XT_CP1_SA ALIGNUP(XCHAL_CP1_SA_ALIGN, XT_CP0_SA + XCHAL_CP0_SA_SIZE)
+#define XT_CP2_SA ALIGNUP(XCHAL_CP2_SA_ALIGN, XT_CP1_SA + XCHAL_CP1_SA_SIZE)
+#define XT_CP3_SA ALIGNUP(XCHAL_CP3_SA_ALIGN, XT_CP2_SA + XCHAL_CP2_SA_SIZE)
+#define XT_CP4_SA ALIGNUP(XCHAL_CP4_SA_ALIGN, XT_CP3_SA + XCHAL_CP3_SA_SIZE)
+#define XT_CP5_SA ALIGNUP(XCHAL_CP5_SA_ALIGN, XT_CP4_SA + XCHAL_CP4_SA_SIZE)
+#define XT_CP6_SA ALIGNUP(XCHAL_CP6_SA_ALIGN, XT_CP5_SA + XCHAL_CP5_SA_SIZE)
+#define XT_CP7_SA ALIGNUP(XCHAL_CP7_SA_ALIGN, XT_CP6_SA + XCHAL_CP6_SA_SIZE)
+#define XT_CP_SIZE ALIGNUP(4 , XT_CP7_SA + XCHAL_CP7_SA_SIZE)
+
+#ifdef __ASSEMBLER__
+/* Windowed */
+#define ENTRY(sz) entry sp, sz
+#define ENTRY0 entry sp, 0x10
+#define RET(sz) retw
+#define RET0 retw
+#endif
+
+#define XT_TICK_PER_SEC 100
+#define XT_RTOS_INT_ENTER OS_IntEnter
+#define XT_RTOS_INT_EXIT OS_IntExit
+#define XT_RTOS_CP_STATE OS_GetTaskCoprocState
+
+#ifdef __ASSEMBLER__
+// typedef struct vos_tcb {
+#define OSTCBStkPtr 0x00 // OSTCBStkPtr
+#define OSTCBStkBottom 0x10 // StackAddress
+//...
+// } VOS_TCB;
+#endif /* __ASSEMBLER__ */
+
+#endif /* end of arch_balongV7r1.h */
diff --git a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/cpu_c.h b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/cpu_c.h
new file mode 100644
index 0000000..0cc0da9
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/cpu_c.h
@@ -0,0 +1,109 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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 __CPU_C_H__
+#define __CPU_C_H__
+
+enum OS_HOOK_TYPE_ENUM
+{
+ OS_HOOK_TYPE_ENTER_INTR=0,
+ OS_HOOK_TYPE_EXIT_INTR,
+ OS_HOOK_TYPE_TASK_SWITCH,
+ OS_HOOK_TYPE_MSG_GET,
+ OS_HOOK_TYPE_NMI,
+ OS_HOOK_TYPE_EXCEPTION,
+ OS_HOOK_TYPE_APPINIT,
+ OS_HOOK_TYPE_IDLE,
+ OS_HOOK_TYPE_BUTT
+};
+
+enum OS_INTR_CONNECT_TYPE_ENUM
+{
+ OS_INTR_CONNECT_00=0, /*Int 0 type / priority level NMI / 6 */
+ OS_INTR_CONNECT_01, /*Int 1 type / priority level Software / 3 */
+ OS_INTR_CONNECT_02, /*Int 2 type / priority level ExtLevel / 2 */
+ OS_INTR_CONNECT_03, /*Int 3 type / priority level ExtLevel / 2 */
+ OS_INTR_CONNECT_04, /*Int 4 type / priority level ExtLevel / 2 */
+ OS_INTR_CONNECT_05, /*Int 5 type / priority level Timer / 3 */
+ OS_INTR_CONNECT_06, /*Int 6 type / priority level Timer / 4 */
+ OS_INTR_CONNECT_07, /*Int 7 type / priority level ExtLevel / 3 */
+ OS_INTR_CONNECT_08, /*Int 8 type / priority level ExtLevel / 3 */
+ OS_INTR_CONNECT_09, /*Int 9 type / priority level ExtLevel / 3 */
+ OS_INTR_CONNECT_10, /*Int 10 type / priority level ExtLevel / 2 */
+ OS_INTR_CONNECT_11, /*Int 11 type / priority level ExtLevel / 2 */
+ OS_INTR_CONNECT_12, /*Int 12 type / priority level ExtLevel / 2 */
+ OS_INTR_CONNECT_13, /*Int 13 type / priority level ExtLevel / 2 */
+ OS_INTR_CONNECT_14, /*Int 14 type / priority level ExtLevel / 2 */
+ OS_INTR_CONNECT_15, /*Int 15 type / priority level ExtLevel / 1 */
+ OS_INTR_CONNECT_16, /*Int 16 type / priority level ExtLevel / 1 */
+ OS_INTR_CONNECT_17, /*Int 17 type / priority level ExtLevel / 1 */
+ OS_INTR_CONNECT_18, /*Int 18 type / priority level ExtLevel / 1 */
+ OS_INTR_CONNECT_19, /*Int 19 type / priority level Timer / 2 */
+ OS_INTR_CONNECT_20, /*Int 20 type / priority level ExtLevel / 1 */
+ OS_INTR_CONNECT_21, /*Int 21 type / priority level ExtLevel / 1 */
+ OS_INTR_CONNECT_22, /*Int 22 type / priority level ExtLevel / 1 */
+ OS_INTR_CONNECT_23, /*Int 23 type / priority level ExtLevel / 1 */
+ OS_INTR_CONNECT_24, /*Int 24 type / priority level ExtLevel / 1 */
+ OS_INTR_CONNECT_25, /*Int 25 type / priority level ExtLevel / 1 */
+ OS_INTR_CONNECT_26, /*Int 26 type / priority level ExtLevel / 1 */
+ OS_INTR_CONNECT_27, /*Int 27 type / priority level ExtLevel / 1 */
+ OS_INTR_CONNECT_28, /*Int 28 type / priority level ExtLevel / 1 */
+ OS_INTR_CONNECT_29, /*Int 29 type / priority level ExtLevel / 1 */
+ OS_INTR_CONNECT_30, /*Int 30 type / priority level ExtLevel / 1 */
+ OS_INTR_CONNECT_31, /*Int 31 type / priority level ExtEdge / 1 */
+ OS_INTR_CONNECT_BUTT
+};
+
+#define UCOM_SET_WFI_NMI(var1) asm ("waiti 5": :)
+
+#define UCOM_FlushCache(pAddr, uwSize) \
+ xthal_dcache_region_writeback(pAddr, uwSize)
+
+#define UCOM_FlushCacheAll() \
+ xthal_dcache_all_writeback()
+
+#define UCOM_InvalidateCache(pAddr, uwSize) \
+ xthal_dcache_region_invalidate(pAddr, uwSize)
+
+#define UCOM_InvalidateCacheAll() \
+ xthal_dcache_all_invalidate()
+
+#define ADD_TAG asm("movi a1, 0xdeadbaaf \n movi a2, 0xe8075e80 \n s32i a1, a2, 0": :)
+
+//typedef void (*HOOK_FUN_TYPE)(void);
+typedef void (*HOOK_FUN_TYPE)(unsigned int);
+
+typedef void (*INTR_HOOK_FUN_TYPE )(unsigned int uwIntNo);
+
+typedef void (*VOS_EXCEPTION_HOOK_FUNC)( unsigned int uwExceptionNo);
+
+extern void *g_pfVosHookFuncTable[OS_HOOK_TYPE_BUTT];
+
+extern void VOS_ConnectInterrupt(unsigned int uwIntrNo, HOOK_FUN_TYPE pfnInterruptHook);
+
+extern void VOS_EnableInterrupt(unsigned int uwIntNo);
+extern void VOS_DisableInterrupt(unsigned int uwIntNo);
+
+extern void OS_UserExit(void);
+
+
+#endif /* end of cpu_c.h */
diff --git a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_comm.h b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_comm.h
new file mode 100644
index 0000000..3764677
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_comm.h
@@ -0,0 +1,45 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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 __DSP_COMM_H__
+#define __DSP_COMM_H__
+
+#include <xtensa/config/core.h>
+#include <xtensa/simcall.h>
+
+#define DSP_FLUSH_PIECE_CACHE(addr, size) xthal_dcache_region_writeback(addr, size)
+#define DSP_FLUSH_ALL_CACHE() xthal_dcache_all_writeback()
+#define DSP_INVALIDATE_PIECE_CACHE(addr, size) xthal_dcache_region_invalidate(addr, size)
+#define DSP_INVALIDATE_ALL_CACHE() xthal_dcache_all_invalidate()
+
+#define memset(d,uCData,size) dsp_memset(d,uCData,size)
+#define memcpy(d,s,size) dsp_memcpy(d,s,size)
+#define divsi3(a,b) division(a,b)
+#define _divsi3(a,b) division(a,b)
+
+void dsp_memcpy(void *d, void *s, unsigned int size);
+void dsp_memset(void *d, unsigned char ucData, unsigned int size);
+int division(int a, int b);
+
+#endif /* end of dsp_comm.h */
+
diff --git a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_debug.h b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_debug.h
new file mode 100644
index 0000000..0ca2d37
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_debug.h
@@ -0,0 +1,71 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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 __DSP_DEBUG_H__
+#define __DSP_DEBUG_H__
+
+
+#define DEBUG_LEVEL 0
+#define INFO_LEVEL 1
+#define WARNING_LEVEL 1
+#define ERROR_LEVEL 1
+#define TRACE_DUMP 1
+
+#define LOG_TAG " DSP_LOG"
+
+#if TRACE_DUMP
+#define DSP_TRACE(fmt, ...) print_log(fmt" @%s:%d \n", ##__VA_ARGS__, __FUNCTION__, __LINE__)
+#else
+#define DSP_TRACE(fmt, ...)
+#endif
+
+#if DEBUG_LEVEL
+#define DSP_LOGD(fmt, ...) print_log(LOG_TAG"[D]%s:%d: "fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__)
+#else
+#define DSP_LOGD(fmt, ...)
+#endif
+
+#if INFO_LEVEL
+#define DSP_LOGI(fmt, ...) print_log(LOG_TAG"[I]%s:%d: "fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__)
+#else
+#define DSP_LOGI(fmt, ...)
+#endif
+
+#if WARNING_LEVEL
+#define DSP_LOGW(fmt, ...) print_log(LOG_TAG"[W]%s:%d: "fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__)
+#else
+#define DSP_LOGW(fmt, ...)
+#endif
+
+#if ERROR_LEVEL
+#define DSP_LOGE(fmt, ...) print_log(LOG_TAG"[E]%s:%d: "fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__)
+#else
++#define DSP_LOGE(fmt, ...)
+#endif
+
+
+void print_log(const char *fmt, ...);
+void dsp_debug_init();
+#ifdef HIKEY_XAF_IPC_COMMENT_OUT
+void dsp_om_func_proc(char *om_str, unsigned int str_len);
+#endif
+#endif
diff --git a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_driver_ipc.h b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_driver_ipc.h
new file mode 100644
index 0000000..2228f32
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_driver_ipc.h
@@ -0,0 +1,61 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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 __DSP_DRIVER_IPC_H__
+#define __DSP_DRIVER_IPC_H__
+
+#if 0
+#define DSP_IPC_FROM_AP_INT_NO (3)
+#define DSP_SYS_IPC_BASE_ADDR_NS (0xe896b000)
+#define DSP_AP_TO_DSP_MAILBOX_NO (18)
+#define DSP_DSP_TO_AP_MAILBOX_NO (2)
+#define IPC_BUSY_RETRY_COUNT (1000)
+#define IPC_ACPU_INT_SRC_HIFI_MSG (1)
+#define BIT_MASK(n) (1 << (n))
+
+#define WORD_REF(address) (* ((unsigned int volatile *) (address)))
+
+#define SYS_IPC_LOCK(base) WORD_REF(base + 0xA00)
+#define SYS_IPC_ICLR(base, box) WORD_REF(base + ((box) << 6) + 0x18)
+#define SYS_IPC_DATA(base, box, num) WORD_REF(base + ((box) << 6) + 0x20 + ((num) << 2))
+#define SYS_IPC_CPUIRST(base, core) WORD_REF(base + 0x804 + ((core) << 3))
+#define SYS_IPC_MODE(base, box) WORD_REF(base + ((box) << 6) + 0x10)
+#define SYS_IPC_SOURCE(base, box) WORD_REF(base + ((box) << 6))
+#define SYS_IPC_DEST(base, box) WORD_REF(base + ((box) * 64) + 0x04)
+#define SYS_IPC_SEND(base, box) WORD_REF(base + ((box) << 6) + 0x1c)
+#define SYS_IPC_IMASK(base, box) WORD_REF(base + ((box) << 6) + 0x14)
+#define SYS_IPC_DCLR(base, box) WORD_REF(base + ((box) * 64) + 0x08)
+#define SYS_IPC_CPUIMST(base, core) WORD_REF(base + 0x800 + ((core) * 8))
+#define SYS_IPC_MODE_ACK (7)
+#define SYS_IPC_MODE_IDLE (4)
+#define SYS_IPC_MODE_AUTOACK (0)
+
+#define SYS_IPC_CORE_HIFI (4)
+#define SYS_IPC_CORE_A15 (0)
+#define SYS_IPC_CORE_LPM3 (3)
+#endif
+#if 0
+extern void dsp_ipc_init(void);
+extern void dsp_ipc_wait(void);
+#endif
+#endif
+
diff --git a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_driver_mailbox.h b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_driver_mailbox.h
new file mode 100644
index 0000000..8730df2
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_driver_mailbox.h
@@ -0,0 +1,170 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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 __DSP_DRIVER_MAILBOX_H__
+#define __DSP_DRIVER_MAILBOX_H__
+
+#include <stdint.h>
+
+#define HIKEY_MSG_HEAD_PROTECT_WORD 0xffff1234
+#define HIKEY_MSG_BODY_PROTECT_WORD 0xffff4321
+
+#define HIKEY_MSG_ID_AP_DSP_OM_CMD 0xDDCB
+#define HIKEY_AUDIO_DSP_AP_OM_CMD 0xDDC9
+
+typedef enum HIFI_MSG_ID_ {
+
+ /*DTS command id from ap*/
+ ID_AP_AUDIO_SET_DTS_ENABLE_CMD = 0xDD36,
+ ID_AP_AUDIO_SET_DTS_DEV_CMD = 0xDD38,
+ ID_AP_AUDIO_SET_DTS_GEQ_CMD = 0xDD39,
+ ID_AP_AUDIO_SET_DTS_GEQ_ENABLE_CMD = 0xDD3B,
+
+ /* APºÍHIFIµÄ¿ØÖÆÍâÖöú»úHIFI codecœ»»¥ÏûÏ¢ */
+ ID_AP_AUDIO_SET_EXCODEC_ENABLE_CMD = 0xDD3D,
+
+ /* Voice Record */
+ ID_AP_HIFI_VOICE_RECORD_START_CMD = 0xDD40,
+ ID_AP_HIFI_VOICE_RECORD_STOP_CMD = 0xDD41,
+
+ /* voicePP MSG_ID */
+ ID_AP_VOICEPP_START_REQ = 0xDD42, /* Æô¶¯VOICEPPÍš»° */
+ ID_VOICEPP_MSG_START = ID_AP_VOICEPP_START_REQ,
+ ID_VOICEPP_AP_START_CNF = 0xDD43,
+ ID_AP_VOICEPP_STOP_REQ = 0xDD44, /* ÖÕÖ¹VOICEPPÍš»° */
+ ID_VOICEPP_AP_STOP_CNF = 0xDD45,
+ ID_VOICEPP_MSG_END = 0xDD4A,
+
+ ID_AP_AUDIO_PLAY_START_REQ = 0xDD51,/* APÆô¶¯Hifi audio player requestÃüÁî */
+ ID_AUDIO_AP_PLAY_START_CNF = 0xDD52,/* HifiÆô¶¯audio playerºó»ØžŽAP confirmÃüÁî */
+ ID_AP_AUDIO_PLAY_PAUSE_REQ = 0xDD53,/* APÍ£Ö¹Hifi audio player requestÃüÁî */
+ ID_AUDIO_AP_PLAY_PAUSE_CNF = 0xDD54,/* HifiÍ£Ö¹audio playerºó»ØžŽAP confirmÃüÁî */
+ ID_AUDIO_AP_PLAY_DONE_IND = 0xDD56,/* HifiÍšÖªAP audio playerÒ»¿éÊýŸÝ²¥·ÅÍê±Ï»òÕß²¥·ÅÖжÏindication */
+ ID_AP_AUDIO_PLAY_UPDATE_BUF_CMD = 0xDD57,/* APÍšÖªHifiÐÂÊýŸÝ¿éžüÐÂcommand */
+ ID_AP_AUDIO_PLAY_QUERY_TIME_REQ = 0xDD59,/* AP²éѯHifi audio player²¥·Åœø¶ÈrequestÃüÁî */
+ ID_AP_AUDIO_PLAY_WAKEUPTHREAD_REQ = 0xDD5A,
+ ID_AUDIO_AP_PLAY_QUERY_TIME_CNF = 0xDD60,/* Hifi»ØžŽAP audio player²¥·Åœø¶ÈconfirmÃüÁî */
+ ID_AP_AUDIO_PLAY_QUERY_STATUS_REQ = 0xDD61,/* AP²éѯHifi audio player²¥·Å׎̬requestÃüÁî */
+ ID_AUDIO_AP_PLAY_QUERY_STATUS_CNF = 0xDD62,/* Hifi»ØžŽAP audio player²¥·Å׎̬confirmÃüÁî */
+ ID_AP_AUDIO_PLAY_SEEK_REQ = 0xDD63,/* AP seek Hifi audio playerµœÄ³Ò»Î»ÖÃrequestÃüÁî */
+ ID_AUDIO_AP_PLAY_SEEK_CNF = 0xDD64,/* Hifi»ØžŽAP seekœá¹ûconfirmÃüÁî */
+ ID_AP_AUDIO_PLAY_SET_VOL_CMD = 0xDD70,/* APÉèÖÃÒôÁ¿ÃüÁî */
+ ID_AP_AUDIO_RECORD_PCM_HOOK_CMD = 0xDD7A,/* AP ÍšÖªHIFI¿ªÊŒ×¥È¡PCMÊýŸÝ */
+ ID_AUDIO_AP_UPDATE_PCM_BUFF_CMD = 0xDD7C,
+ ID_AP_AUDIO_DYN_EFFECT_GET_PARAM = 0xDD7D,
+ ID_AP_AUDIO_DYN_EFFECT_GET_PARAM_CNF = 0xDD7E,
+ ID_AP_AUDIO_DYN_EFFECT_TRIGGER = 0xDD7F,
+ /* enhance msgid between ap and hifi */
+ ID_AP_HIFI_ENHANCE_START_REQ = 0xDD81,
+ ID_HIFI_AP_ENHANCE_START_CNF = 0xDD82,
+ ID_AP_HIFI_ENHANCE_STOP_REQ = 0xDD83,
+ ID_HIFI_AP_ENHANCE_STOP_CNF = 0xDD84,
+ ID_AP_HIFI_ENHANCE_SET_DEVICE_REQ = 0xDD85,
+ ID_HIFI_AP_ENHANCE_SET_DEVICE_CNF = 0xDD86,
+
+ /* audio enhance msgid between ap and hifi */
+ ID_AP_AUDIO_ENHANCE_SET_DEVICE_IND = 0xDD91,
+ ID_AP_AUDIO_MLIB_SET_PARA_IND = 0xDD92,
+ ID_AP_AUDIO_CMD_SET_SOURCE_CMD = 0xDD95,
+ ID_AP_AUDIO_CMD_SET_DEVICE_CMD = 0xDD96,
+ ID_AP_AUDIO_CMD_SET_MODE_CMD = 0xDD97,
+ ID_AP_AUDIO_CMD_SET_ANGLE_CMD = 0xDD99,
+
+ /* for 3mic */
+ ID_AP_AUDIO_ROUTING_COMPLETE_REQ = 0xDDC0,/*AP ÍšÖªHIFI 3Mic/4Mic ͚·ÒÑœšÁ¢*/
+ ID_AUDIO_AP_DP_CLK_EN_IND = 0xDDC1,/* HIFI ÍšÖªAºËŽò¿ª»ò¹Ø±ÕCodec DPʱÖÓ */
+ ID_AP_AUDIO_DP_CLK_STATE_IND = 0xDDC2,/* AºËÍšÖªHIFI £¬Codec DPʱÖÓ׎̬( Žò¿ª»ò¹Ø±Õ) */
+ ID_AUDIO_AP_OM_DUMP_CMD = 0xDDC3,/* HIFI ÍšÖªAºËdumpÈÕÖŸ */
+ ID_AUDIO_AP_FADE_OUT_REQ = 0xDDC4,/* HIFIÍšÖªAP×öµ³öŽŠÀí */
+ ID_AP_AUDIO_FADE_OUT_IND = 0xDDC5,/* APÍšÖªHIFIµ³öÍê±Ï */
+
+ ID_AUDIO_AP_OM_CMD = 0xDDC9,
+ ID_AP_AUDIO_STR_CMD = 0xDDCB,/* APžøHIFI·¢ËÍһžö×Ö·ûŽ®£¬ŸßÌ庬ÒåhifiÖÐœâÎö */
+ ID_AUDIO_AP_VOICE_BSD_PARAM_CMD = 0xDDCC,/* VOICE BSD ²ÎÊýÉϱš */
+
+ ID_AP_ENABLE_MODEM_LOOP_REQ = 0xDDCD,/* the audio hal notify HIFI to start/stop MODEM LOOP*/
+ ID_AP_HIFI_REQUEST_VOICE_PARA_REQ = 0xDF00, /*AP REQUEST VOICE MSG*/
+ ID_HIFI_AP_REQUEST_VOICE_PARA_CNF = 0xDF01, /*HIFI REPLAY VOICE MSG*/
+
+ /* XAF message IDs */
+ ID_XAF_AP_TO_DSP = 0xDF10,
+ ID_XAF_DSP_TO_AP = 0xDF11,
+} HIFI_MSG_ID;
+
+#define HIKEY_AP2DSP_MSG_QUEUE_ADDR HIFI_HIKEY_SHARE_MEM_ADDR
+
+#define HIKEY_AP2DSP_MSG_QUEUE_SIZE 0x1800
+#define HIKEY_DSP2AP_MSG_QUEUE_ADDR (HIKEY_AP2DSP_MSG_QUEUE_ADDR + HIKEY_AP2DSP_MSG_QUEUE_SIZE)
+#define HIKEY_DSP2AP_MSG_QUEUE_SIZE 0x1800
+
+#define HIKEY_AP_DSP_MSG_MAX_LEN 100
+/////////////////////////////////////////////////////////////////////
+// XAF STRUCTURES //
+/////////////////////////////////////////////////////////////////////
+#ifdef GJB_CHANGE
+/* ...command/response message */
+typedef struct xf_proxy_msg {
+ /* ...session ID */
+ uint32_t id;
+
+ /* ...proxy API command/reponse code */
+ uint32_t opcode;
+
+ /* ...length of attached buffer */
+ uint32_t length;
+
+ /* ...shared logical address of message buffer */
+ uint64_t address;
+
+} __attribute__((__packed__)) xf_proxy_msg_t;
+
+struct hikey_ap_dsp_msg_head {
+ unsigned int head_protect_word;
+ unsigned int msg_num;
+ unsigned int read_pos;
+ unsigned int write_pos;
+};
+
+/*struct hikey_ap_dsp_msg_body {
+ unsigned short msg_id;
+ unsigned short msg_len;
+ char msg_content[0];
+};*/
+
+struct hikey_ap_dsp_msg_body {
+ unsigned short msg_id;
+ unsigned short msg_len;
+ union {
+ char msg_content[0];
+ struct xf_proxy_msg xf_dsp_msg;
+ };
+};
+struct hikey_msg_with_content {
+ struct hikey_ap_dsp_msg_body msg_info;
+ char msg_content[HIKEY_AP_DSP_MSG_MAX_LEN];
+};
+void dsp_init_share_mem(char *share_mem_addr, unsigned int share_mem_size);
+int dsp_mailbox_read(struct hikey_msg_with_content *hikey_msg);
+void dsp_msg_process(struct hikey_msg_with_content *hikey_msg);
+#else
+#endif
+#endif
diff --git a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_memory_config.h b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_memory_config.h
new file mode 100644
index 0000000..fd5a93d
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_memory_config.h
@@ -0,0 +1,96 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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 __DSP_MEMORY_CONFIG_H__
+#define __DSP_MEMORY_CONFIG_H__
+
+/** for chicago only **/
+/**Non Secure 3.5M **/
+/* |0x8B300000|0x8B432000|0x8B532000|0x8B5B1000|0x8B5B2000|0x8B5C5000|0x8B5C6000|0x8B5C7000|0x8B5F9800|~~0x8B609800~~|~~0x8B618800~~|~0x8B618880~|0x8B627880|~0x8B629880~|0x8B62C880~~~| */
+/* |Music data|~~PCM data|~hifi uart|panicstack|icc debug~|flag data~|DDRsechead|~~AP NV ~~|AP&HIFIMB~|codec dma buff|codecdmaconfig|soundtrigger|pcm upload|~hikey share|unsec reserve| */
+/* |~~~~1.2M~~|~~~~1M~~~~|~~508k~~~~|~~~~~4k~~~|~~76k~~~~~|~~~4k~~~~~|~~~4k~~~~~|~~202k~~~~|~~~64k~~~~|~~~~60k~~~~~~~|~~~~128b~~~~~~|~~~~60k~~~~~|~~~8k~~~~~|~~~~~12k~~~~|~~334k-128b~~| */
+/* |0x8B431fff|0x8B531fff|0x8B5B0fff|0x8B5B1fff|0x8B5C4fff|0x8B5C5fff|0x8B5C6fff|0x8B5F97ff|0x8B6097ff|~~0x8B6187FF~~|~~0x8B61887F~~|~0x8B62787F~|0x8B62987F|0x8B62C87F~~|~~0x8B67FFFF~| */
+
+/** Secure9.5M **/
+/* |~~~0x89200000~~~|~~~0x89800000~~~|~~~0x89830000~~|~~~0x89864000~~~| */
+/* |~~HIFI RUNNING~~|~OCRAM img bak~~|~~TCM img bak~~|~~~~IMG bak~~~~~| */
+/* |~~~~~~~6M~~~~~~~|~~~~~~192K~~~~~~|~~~~~208k~~~~~~|~~~~~~3.1M ~~~~~| */
+/* |~~~0x897fffff~~~|~~~0x8982ffff~~~|~~~0x89863fff~~|~~~0x89B80000~~~| */
+
+
+#define HIFI_UNSEC_REGION_SIZE (0x380000)
+#define HIFI_MUSIC_DATA_SIZE (0x132000)
+#define PCM_PLAY_BUFF_SIZE (0x100000)
+#define DRV_DSP_UART_TO_MEM_SIZE (0x7f000)
+#define DRV_DSP_UART_TO_MEM_RESERVE_SIZE (0x100)
+#define DRV_DSP_STACK_TO_MEM_SIZE (0x1000)
+#define HIFI_ICC_DEBUG_SIZE (0x13000)
+#define HIFI_FLAG_DATA_SIZE (0x1000)
+#define HIFI_SEC_HEAD_SIZE (0x1000)
+#define HIFI_AP_NV_DATA_SIZE (0x32800)
+#define HIFI_AP_MAILBOX_TOTAL_SIZE (0x10000)
+#define CODEC_DSP_OM_DMA_BUFFER_SIZE (0xF000)
+#define CODEC_DSP_OM_DMA_CONFIG_SIZE (0x80)
+#define CODEC_DSP_SOUNDTRIGGER_TOTAL_SIZE (0xF000)
+#define HIFI_PCM_UPLOAD_BUFFER_SIZE (0x2000)
+#define HIFI_HIKEY_SHARE_SIZE (0x1800 * 2)
+#define HIFI_UNSEC_RESERVE_SIZE (0x53780)
+
+#define HIFI_UNSEC_BASE_ADDR (0x8B300000)
+#define HIFI_MUSIC_DATA_LOCATION (HIFI_UNSEC_BASE_ADDR)
+#define PCM_PLAY_BUFF_LOCATION (HIFI_MUSIC_DATA_LOCATION + HIFI_MUSIC_DATA_SIZE)
+#define DRV_DSP_UART_TO_MEM (PCM_PLAY_BUFF_LOCATION + PCM_PLAY_BUFF_SIZE)
+#define DRV_DSP_STACK_TO_MEM (DRV_DSP_UART_TO_MEM + DRV_DSP_UART_TO_MEM_SIZE)
+#define HIFI_ICC_DEBUG_LOCATION (DRV_DSP_STACK_TO_MEM + DRV_DSP_STACK_TO_MEM_SIZE)
+#define HIFI_FLAG_DATA_ADDR (HIFI_ICC_DEBUG_LOCATION + HIFI_ICC_DEBUG_SIZE)
+#define HIFI_SEC_HEAD_BACKUP (HIFI_FLAG_DATA_ADDR + HIFI_FLAG_DATA_SIZE)
+#define HIFI_AP_NV_DATA_ADDR (HIFI_SEC_HEAD_BACKUP + HIFI_SEC_HEAD_SIZE)
+#define HIFI_AP_MAILBOX_BASE_ADDR (HIFI_AP_NV_DATA_ADDR + HIFI_AP_NV_DATA_SIZE)
+#define CODEC_DSP_OM_DMA_BUFFER_ADDR (HIFI_AP_MAILBOX_BASE_ADDR + HIFI_AP_MAILBOX_TOTAL_SIZE)
+#define CODEC_DSP_OM_DMA_CONFIG_ADDR (CODEC_DSP_OM_DMA_BUFFER_ADDR + CODEC_DSP_OM_DMA_BUFFER_SIZE)
+#define CODEC_DSP_SOUNDTRIGGER_BASE_ADDR (CODEC_DSP_OM_DMA_CONFIG_ADDR + CODEC_DSP_OM_DMA_CONFIG_SIZE)
+#define HIFI_PCM_UPLOAD_BUFFER_ADDR (CODEC_DSP_SOUNDTRIGGER_BASE_ADDR + CODEC_DSP_SOUNDTRIGGER_TOTAL_SIZE)
+#define HIFI_HIKEY_SHARE_MEM_ADDR (HIFI_PCM_UPLOAD_BUFFER_ADDR+HIFI_AP_MAILBOX_TOTAL_SIZE)
+#define HIFI_UNSEC_RESERVE_ADDR (HIFI_HIKEY_SHARE_MEM_ADDR + HIFI_HIKEY_SHARE_SIZE)
+
+#define DRV_DSP_PANIC_MARK (HIFI_FLAG_DATA_ADDR)
+#define DRV_DSP_UART_LOG_LEVEL (DRV_DSP_PANIC_MARK + 4)
+#define DRV_DSP_UART_TO_MEM_CUR_ADDR (DRV_DSP_UART_LOG_LEVEL + 4)
+
+#define HIFI_SEC_REGION_SIZE (0x980000)
+#define HIFI_IMAGE_OCRAMBAK_SIZE (0x30000)
+#define HIFI_RUN_SIZE (0x600000)
+#define HIFI_IMAGE_TCMBAK_SIZE (0x34000)
+#define HIFI_IMAGE_SIZE (0x31C000)
+#define HIFI_RUN_ITCM_BASE (0xe8080000)
+#define HIFI_RUN_ITCM_SIZE (0x9000)
+#define HIFI_RUN_DTCM_BASE (0xe8058000)
+#define HIFI_RUN_DTCM_SIZE (0x28000)
+
+
+#define HIFI_SEC_REGION_ADDR (0x89200000) /* chciago */
+#define HIFI_RUN_LOCATION (HIFI_SEC_REGION_ADDR)
+#define HIFI_IMAGE_OCRAMBAK_LOCATION (HIFI_RUN_LOCATION + HIFI_RUN_SIZE)
+#define HIFI_IMAGE_TCMBAK_LOCATION (HIFI_IMAGE_OCRAMBAK_LOCATION + HIFI_IMAGE_OCRAMBAK_SIZE)
+#define HIFI_IMAGE_LOCATION (HIFI_IMAGE_TCMBAK_LOCATION + HIFI_IMAGE_TCMBAK_SIZE)
+
+#endif
diff --git a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_pcm_gain.h b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_pcm_gain.h
new file mode 100644
index 0000000..24f94ec
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_pcm_gain.h
@@ -0,0 +1,37 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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 DSP_PCM_GAIN_H
+#define __DSP_PCM_GAIN_H__
+#include "dsp_memory_config.h"
+#define FRAME_SIZE 480 // 10 ms @ 48 KHz.
+#define HOLD_BUF_SIZE 228404
+#define MSG_RECV 1 // Msg received
+#define MSG_PROC 2 // Msg processed.
+#define MSG_COMP 8
+#define MSG_INCOMP 9
+#define MUSIC_DATA_MEM_READ_ADDR HIFI_MUSIC_DATA_LOCATION // Address of the Music data memory.. !!! change this if necessary..
+#define PCM_DATA_MEM_WRITE_ADDR PCM_PLAY_BUFF_LOCATION // Address of some random element in PCM data memory.. !!! change this if necessary..
+int ReadData( char *pDst, int Size );
+int WriteData( char *pSrc, int Size );
+int processAudio( int *pDst, int *pSrc, int Size );
+#endif
diff --git a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/reset.h b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/reset.h
new file mode 100644
index 0000000..5a77a97
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/reset.h
@@ -0,0 +1,62 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+
+******************************************************************************/
+
+
+#include <xtensa/coreasm.h>
+#include <xtensa/simcall.h>
+#define PIF_CACHED 1
+#define PIF_BYPASS 2
+#define PIF_CACHED_WBA 4
+#define PIF_CACHED_WBNA 5
+#define PIF_INVALID 15
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif
+#endif
+
+
+
+/*set memory mapping attribute*/
+.macro set_access_mode am
+ rdtlb1 a4, a3
+ ritlb1 a5, a3
+ srli a4, a4, 4
+ slli a4, a4, 4
+ srli a5, a5, 4
+ slli a5, a5, 4
+ addi a4, a4, \am
+ addi a5, a5, \am
+ wdtlb a4, a3
+ witlb a5, a3
+.endm
+
+
+
+
+#ifdef __cplusplus
+ #if __cplusplus
+ }
+ #endif
+#endif
+
diff --git a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/xf-board.h b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/xf-board.h
new file mode 100644
index 0000000..e42ab1b
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/xf-board.h
@@ -0,0 +1,180 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * board-hikey/xf-board.h
+ *
+ * HiKey960-specific definitions
+ *
+ *******************************************************************************/
+
+#ifndef __XF_H
+#error "xf-board.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Global constants definitions
+ ******************************************************************************/
+
+/* ...shared memory interface address */
+#define XF_CFG_SHMEM_ADDRESS(core) HIFI_HIKEY_SHARE_MEM_ADDR
+
+/* ...tracing buffer configuration (place at the end of memory) */
+#define XF_CFG_TRACE_START(core) 0x78000000
+#define XF_CFG_TRACE_END(core) 0x7FFFFFFF
+#if 1
+#define DSP_IPC_FROM_AP_INT_NO (3)
+#define DSP_SYS_IPC_BASE_ADDR_NS (0xe896b000)
+#define DSP_AP_TO_DSP_MAILBOX_NO (18)
+#define DSP_DSP_TO_AP_MAILBOX_NO (2)
+#define IPC_BUSY_RETRY_COUNT (1000)
+#define IPC_ACPU_INT_SRC_HIFI_MSG (1)
+#define BIT_MASK(n) (1 << (n))
+
+#define WORD_REF(address) (* ((unsigned int volatile *) (address)))
+
+#define SYS_IPC_LOCK(base) WORD_REF(base + 0xA00)
+#define SYS_IPC_ICLR(base, box) WORD_REF(base + ((box) << 6) + 0x18)
+#define SYS_IPC_DATA(base, box, num) WORD_REF(base + ((box) << 6) + 0x20 + ((num) << 2))
+#define SYS_IPC_CPUIRST(base, core) WORD_REF(base + 0x804 + ((core) << 3))
+#define SYS_IPC_MODE(base, box) WORD_REF(base + ((box) << 6) + 0x10)
+#define SYS_IPC_SOURCE(base, box) WORD_REF(base + ((box) << 6))
+#define SYS_IPC_DEST(base, box) WORD_REF(base + ((box) * 64) + 0x04)
+#define SYS_IPC_SEND(base, box) WORD_REF(base + ((box) << 6) + 0x1c)
+#define SYS_IPC_IMASK(base, box) WORD_REF(base + ((box) << 6) + 0x14)
+#define SYS_IPC_DCLR(base, box) WORD_REF(base + ((box) * 64) + 0x08)
+#define SYS_IPC_CPUIMST(base, core) WORD_REF(base + 0x800 + ((core) * 8))
+#define SYS_IPC_MODE_ACK (7)
+#define SYS_IPC_MODE_IDLE (4)
+#define SYS_IPC_MODE_AUTOACK (0)
+
+#define SYS_IPC_CORE_HIFI (4)
+#define SYS_IPC_CORE_A15 (0)
+#define SYS_IPC_CORE_LPM3 (3)
+#endif
+/* ...inter-processor interrupt number (SEL:10 - LEVEL:15) */
+#define XF_PROXY_IPI_NUM(core) 15
+
+/*******************************************************************************
+ * External functions
+ ******************************************************************************/
+
+/* ...gdb stub initialization */
+extern void init_gdbstub(void);
+
+/* ...emit breakpoint */
+extern void breakpoint(void);
+#if 0// def HIKEY_XAF_IPC_COMMENT_OUT
+/*******************************************************************************
+ * Public proxy API
+ ******************************************************************************/
+
+/* ...notify remote side about status change */
+#define XF_PROXY_NOTIFY_PEER(core) h2_wake_core()
+
+/* ...clear pending interrupt mask */
+#define XF_PROXY_SYNC_PEER(core) h2_local_ack()
+
+/*******************************************************************************
+ * Auxiliary helper functions
+ ******************************************************************************/
+
+/* ...generate inter-processor interrupt for remote core */
+static inline void h2_wake_core(void)
+{
+ /* ...we have single INPUT-interrupt pin */
+ *(volatile unsigned int *)0xec800044 = 1;
+}
+
+/* ...acknowledge pending IPI interrupt */
+static inline void h2_local_ack(void)
+{
+ /* ...asserted interrupt cannot be cleared */
+}
+
+/*******************************************************************************
+ * Board specific init
+ ******************************************************************************/
+
+static inline void xf_board_init(void)
+{
+ /* ...initialize GDB debugging interface */
+ init_gdbstub();
+
+ /* ...indicate the board has started */
+ *(volatile unsigned int *)0xec800100 = 1;
+}
+#else
+//#define XF_PROXY_NOTIFY_PEER(core) dsp_ipc_send_irq_to_ap()
+#define XF_PROXY_NOTIFY_PEER(core) h2_wake_core()
+/* ...clear pending interrupt mask */
+#define XF_PROXY_SYNC_PEER(core) h2_local_ack()
+
+/* ...generate inter-processor interrupt for remote core */
+static inline void h2_wake_core(void)
+{
+ unsigned int mode = 0;
+ unsigned int mode_1 = 0;
+
+ // mode = SYS_IPC_MODE(DSP_SYS_IPC_BASE_ADDR_NS, DSP_DSP_TO_AP_MAILBOX_NO);
+ //mode = (* ((unsigned int volatile *) (0xe896b000 + ((2) << 6) + 0x10)));
+ mode = * (volatile unsigned int*) 0xe896b090;
+
+ //if (mode & BIT_MASK(SYS_IPC_MODE_IDLE)) {
+ //if (mode & (1 << (4))) {
+ if (mode & 0x10) {
+ mode_1=0;
+ } else {
+ return;
+ }
+
+ //SYS_IPC_SOURCE(DSP_SYS_IPC_BASE_ADDR_NS, DSP_DSP_TO_AP_MAILBOX_NO) = BIT_MASK(SYS_IPC_CORE_HIFI);
+ //(* ((unsigned int volatile *) (0xe896b000 + ((2) << 6))))= (1 << (4));
+ * (volatile unsigned int *) 0xe896b080 = (0x10);
+
+ //SYS_IPC_IMASK(DSP_SYS_IPC_BASE_ADDR_NS, DSP_DSP_TO_AP_MAILBOX_NO) = ~((unsigned int)(BIT_MASK(SYS_IPC_CORE_HIFI)|BIT_MASK(SYS_IPC_CORE_A15)));
+ //(* ((unsigned int volatile *) (0xe896b000 + ((2) << 6) + 0x14))) = ~ ((unsigned int)((1 << (4))|(1 << (0))));
+ * (volatile unsigned int *)0xe896b094 = ~ ((unsigned int)(0x11));
+
+ //SYS_IPC_DATA(DSP_SYS_IPC_BASE_ADDR_NS, DSP_DSP_TO_AP_MAILBOX_NO, 0) = IPC_ACPU_INT_SRC_HIFI_MSG;
+ //(* ((unsigned int volatile *) (0xe896b000 + ((2) << 6) + 0x20 + ((0) << 2)))) = 1;
+ * (volatile unsigned int *) 0xe896b0A0 = 1;
+
+ //SYS_IPC_MODE(DSP_SYS_IPC_BASE_ADDR_NS, DSP_DSP_TO_AP_MAILBOX_NO) = BIT_MASK(SYS_IPC_MODE_AUTOACK);
+ //(* ((unsigned int volatile *) (0xe896b000 + ((2) << 6) + 0x10))) = (1 << (0));
+ * (volatile unsigned int *) 0xe896b090 = 1;
+
+ //SYS_IPC_SEND(DSP_SYS_IPC_BASE_ADDR_NS, DSP_DSP_TO_AP_MAILBOX_NO) = BIT_MASK(SYS_IPC_CORE_HIFI);
+ //(* ((unsigned int volatile *) (0xe896b000 + ((2) << 6) + 0x1c))) = (1 << (4));
+ * (volatile unsigned int *) 0xe896b09C = 0x10;
+
+ return;
+}
+
+/* ...acknowledge pending IPI interrupt */
+static inline void h2_local_ack(void)
+{
+ /* ...asserted interrupt cannot be cleared */
+}
+
+#endif
+
diff --git a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-config.h b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-config.h
new file mode 100644
index 0000000..4775e80
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-config.h
@@ -0,0 +1,63 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-config.h
+ *
+ * Xtensa target configuration parameters
+ *
+ *******************************************************************************/
+
+/* ...number of DSP cores */
+#define XF_CFG_CORES_NUM 1
+
+/* ...size of the internal message pool (make it equal to at least ring-buffer) */
+#define XF_CFG_MESSAGE_POOL_SIZE 256
+
+/* ...local IPC is coherent (say) */
+#define XF_LOCAL_IPC_NON_COHERENT 0
+
+/* ...remote IPC is non coherent (say) */
+#define XF_REMOTE_IPC_NON_COHERENT 1
+
+/* ...size of the local memory pool (in bytes) */
+#define XF_CFG_LOCAL_POOL_SIZE (1024 << 10)
+
+/* ...size of the shared memory pool (in bytes) */
+#if 1//def XAF_ENABLE_NON_HIKEY
+#define XF_CFG_REMOTE_IPC_POOL_SIZE (256 << 10)
+#else
+#define XF_CFG_REMOTE_IPC_POOL_SIZE (HIFI_MUSIC_DATA_SIZE)
+#endif
+
+/* ...size of the local memory pool (in bytes) */
+#define XF_CFG_LOCAL_IPC_POOL_SIZE (1024 << 10)
+#ifdef XAF_ENABLE_NON_HIKEY
+/* ...maximal size of scratch memory is 80 KB */
+#define XF_CFG_CODEC_SCRATCHMEM_SIZE (80 << 10)
+#else
+/* ...maximal size of scratch memory is 56 KB */
+#define XF_CFG_CODEC_SCRATCHMEM_SIZE (56 << 10)
+#endif
+
+/* ...scratch memory is 8-bytes aligned */
+#define XF_CFG_CODEC_SCRATCHMEM_ALIGN 8
diff --git a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-hal.h b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-hal.h
new file mode 100644
index 0000000..82cf3c1
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-hal.h
@@ -0,0 +1,151 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-hal.h
+ *
+ * Platform-specific HAL definitions
+ *
+ *******************************************************************************/
+
+#ifndef __XF_H
+#error "xf-hal.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+/* ...primitive types */
+#include "xf-types.h"
+
+/* ...XTOS runtime */
+#include <xtensa/xtruntime.h>
+
+/*******************************************************************************
+ * Auxilliary macros definitions
+ ******************************************************************************/
+
+/* ...use system-specific cache-line size */
+#define XF_PROXY_ALIGNMENT XCHAL_DCACHE_LINESIZE
+
+/* ...properly aligned shared memory structure */
+#define __xf_shmem__ __attribute__((__aligned__(XF_PROXY_ALIGNMENT)))
+
+/*******************************************************************************
+ * Interrupt control
+ ******************************************************************************/
+
+/* ...disable interrupts on given core */
+static inline u32 xf_isr_disable(u32 core)
+{
+ /* ...no actual dependency on the core identifier */
+ return XTOS_SET_INTLEVEL(XCHAL_EXCM_LEVEL);
+}
+
+/* ...enable interrupts on given core */
+static inline void xf_isr_restore(u32 core, u32 status)
+{
+ /* ...no actual dependency on the core identifier */
+ XTOS_RESTORE_INTLEVEL(status);
+}
+
+/*******************************************************************************
+ * Auxiliary system-specific functions
+ ******************************************************************************/
+
+#if XF_CFG_CORES_NUM > 1
+/* ...current core identifier (from HW) */
+static inline u32 xf_core_id(void)
+{
+ /* ...retrieve core identifier from HAL */
+ return (u32) xthal_get_prid();
+}
+#else
+#define xf_core_id() 0
+#endif
+
+/*******************************************************************************
+ * Atomic operations (atomicity is assured on local core only)
+ ******************************************************************************/
+
+static inline int xf_atomic_test_and_set(volatile u32 *bitmap, u32 mask)
+{
+ u32 status;
+ u32 v;
+
+ /* ...atomicity is assured by interrupts masking */
+ status = XTOS_DISABLE_ALL_INTERRUPTS;
+ v = *bitmap, *bitmap = v | mask;
+ XTOS_RESTORE_INTLEVEL(status);
+
+ return !(v & mask);
+}
+
+static inline int xf_atomic_test_and_clear(volatile u32 *bitmap, u32 mask)
+{
+ u32 status;
+ u32 v;
+
+ /* ...atomicity is assured by interrupts masking */
+ status = XTOS_DISABLE_ALL_INTERRUPTS;
+ v = *bitmap, *bitmap = v & ~mask;
+ XTOS_RESTORE_INTLEVEL(status);
+
+ return (v & mask);
+}
+
+static inline u32 xf_atomic_set(volatile u32 *bitmap, u32 mask)
+{
+ u32 status;
+ u32 v;
+
+ /* ...atomicity is assured by interrupts masking */
+ status = XTOS_DISABLE_ALL_INTERRUPTS;
+ v = *bitmap, *bitmap = (v |= mask);
+ XTOS_RESTORE_INTLEVEL(status);
+
+ return v;
+}
+
+static inline u32 xf_atomic_clear(volatile u32 *bitmap, u32 mask)
+{
+ u32 status;
+ u32 v;
+
+ /* ...atomicity is assured by interrupts masking */
+ status = XTOS_DISABLE_ALL_INTERRUPTS;
+ v = *bitmap, *bitmap = (v &= ~mask);
+ XTOS_RESTORE_INTLEVEL(status);
+
+ return v;
+}
+
+/*******************************************************************************
+ * Abortion macro (debugger should be configured)
+ ******************************************************************************/
+
+/* ...breakpoint function */
+extern void breakpoint(void);
+
+/* ...abort execution (enter into debugger) */
+#define __xf_abort() breakpoint()
diff --git a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-ipc.h b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-ipc.h
new file mode 100644
index 0000000..3ce5bd6
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-ipc.h
@@ -0,0 +1,345 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-ipc.h
+ *
+ * Xtensa IPC mechanism
+ *
+ *******************************************************************************/
+
+#ifndef __XF_H
+#error "xf-ipc.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+/* ...system-specific shared memory configuration */
+#include "xf-shmem.h"
+#ifndef XAF_ENABLE_NON_HIKEY
+#include <xtensa/xtruntime.h>
+extern volatile int waitstate;
+#endif
+
+#ifdef XAF_ENABLE_NON_HIKEY
+/*******************************************************************************
+ * Macros definitions (should better go to some other header)
+ ******************************************************************************/
+
+/*
+ * Execute WAITI 0 (enabling interrupts) only if *(ptr) is zero.
+ * The decision to execute WAITI is done atomically by disabling
+ * interrupts at level 'level' (level must be a constant)
+ * before checking the pointer. Interrupts are always re-enabled
+ * on exit from this macro.
+ */
+#define _WAITI_ON_PTR(ptr, level) \
+do { \
+ int __tmp; \
+ __asm__ (" rsil %0, " #level " \n" \
+ " l32i %0, %1, 0 \n" \
+ " bnez %0, 1f \n" \
+ " waiti 0 \n" \
+ "1:rsil %0, 0 \n" \
+ : "=a" (__tmp) : "a" (ptr) : "memory"); \
+} while(0)
+
+/* ...enable gdbstub */
+//#define XF_CFG_USE_GDBSTUB 0
+
+#ifndef XF_CFG_USE_GDBSTUB
+/* ...maybe "level" should be hidden here - we always magically set 15 */
+#define WAITI_ON_PTR(ptr, level) _WAITI_ON_PTR(ptr, level)
+#else
+/* ...if debugger is enabled, do polling instead of waiting */
+static inline void WAITI_ON_PTR(volatile u32 *ptr, u32 level)
+{
+ extern void poll_debug_ring(void);
+
+ while (*ptr == 0)
+ {
+ /* ...should be called with interrupts disabled - tbd */
+ poll_debug_ring();
+ }
+}
+#endif
+
+/*******************************************************************************
+ * Remote IPI interrupt mode
+ ******************************************************************************/
+
+/* ...enable/disable IPI interrupt */
+static inline void xf_ipi_enable(u32 core, int on)
+{
+ if (on)
+ _xtos_ints_on(1 << XF_PROXY_IPI_NUM(core));
+ else
+ _xtos_ints_off(1 << XF_PROXY_IPI_NUM(core));
+}
+
+/* ...wait in low-power mode for interrupt arrival if "ptr" is 0 */
+static inline void xf_ipi_wait(u32 core)
+{
+ xf_core_ro_data_t *ro = XF_CORE_RO_DATA(core);
+
+ /* ...enable IPI interrupt before sleeping */
+ xf_ipi_enable(core, 1);
+
+ /* ...wait in low-power mode, atomically checking *ipc != 0 */
+ WAITI_ON_PTR(&ro->ipc.wait, 15);
+
+ /* ...force disabling of IPI interrupts */
+ xf_ipi_enable(core, 0);
+
+ /* ...reset waiting object upon leaving */
+ ro->ipc.wait = 0;
+}
+#else
+#define _WAITI_ON_PTR(ptr, level) \
+ do { \
+ int __tmp; \
+ __asm__ (" rsil %0, " #level " \n" \
+ " l32i %0, %1, 0 \n" \
+ " bnez %0, 1f \n" \
+ " waiti 0 \n" \
+ "1:rsil %0, 0 \n" \
+ : "=a" (__tmp) : "a" (ptr) : "memory"); \
+ } while(0)
+
+#define WAITI_ON_PTR(ptr, level) _WAITI_ON_PTR(ptr, level)
+static inline void xf_ipi_wait(u32 core)
+{
+#if 0
+ // VOS_EnableInterrupt(DSP_IPC_FROM_AP_INT_NO);
+ _xtos_ints_on(1 << DSP_IPC_FROM_AP_INT_NO);
+ while(1)
+ {
+ if(waitstate ==1)
+ {
+ // VOS_DisableInterrupt(DSP_IPC_FROM_AP_INT_NO);
+ _xtos_ints_off(1 << DSP_IPC_FROM_AP_INT_NO);
+ waitstate = 0;
+ break;
+ }
+ }
+#else
+
+ _xtos_ints_on(1 << DSP_IPC_FROM_AP_INT_NO);
+ /* ...wait in low-power mode, atomically checking *ipc != 0 */
+ WAITI_ON_PTR(&waitstate, 15);
+
+ /* ...force disabling of IPI interrupts */
+
+ _xtos_ints_off(1 << DSP_IPC_FROM_AP_INT_NO);
+ /* ...reset waiting object upon leaving */
+ waitstate = 0;
+
+#endif
+}
+#endif
+#ifdef XAF_ENABLE_NON_HIKEY
+/* ...complete IPI waiting (may be called from any context on local core) */
+static inline void xf_ipi_resume(u32 core)
+{
+ xf_core_ro_data_t *ro = XF_CORE_RO_DATA(core);
+
+ /* ...single instruction is written atomically; no need to mask interrupts */
+ ro->ipc.wait = 1;
+}
+#else
+/* ...complete IPI waiting (may be called from any context on local core) */
+static inline void xf_ipi_resume(u32 core)
+{
+ unsigned int ipc_int_state = 0;
+ unsigned int ipc_data = 0;
+
+ _xtos_ints_off(1 << DSP_IPC_FROM_AP_INT_NO);
+
+ //process message
+ ipc_int_state = SYS_IPC_CPUIRST(DSP_SYS_IPC_BASE_ADDR_NS, SYS_IPC_CORE_HIFI);
+
+ if (ipc_int_state & BIT_MASK(DSP_AP_TO_DSP_MAILBOX_NO)) { //mailbox-18
+ SYS_IPC_ICLR(DSP_SYS_IPC_BASE_ADDR_NS, DSP_AP_TO_DSP_MAILBOX_NO) = BIT_MASK(SYS_IPC_CORE_HIFI);
+ waitstate = 1;
+ }
+
+ //_xtos_ints_on(1 << DSP_IPC_FROM_AP_INT_NO);
+
+ return;
+}
+#endif
+#if 0//ndef HIKEY_XAF_IPC_COMMENT_OUT
+/* ...notify remote side about status change */
+//#define XF_PROXY_NOTIFY_PEER(core) dsp_ipc_send_irq_to_ap()
+
+static inline void dsp_ipc_send_irq_to_ap(void)
+{
+ unsigned int mode = 0;
+ unsigned int mode_1 = 0;
+
+ mode = SYS_IPC_MODE(DSP_SYS_IPC_BASE_ADDR_NS, DSP_DSP_TO_AP_MAILBOX_NO);
+
+ if (mode & BIT_MASK(SYS_IPC_MODE_IDLE)) {
+ mode_1=0;
+ } else {
+ return;
+ }
+
+
+ SYS_IPC_SOURCE(DSP_SYS_IPC_BASE_ADDR_NS, DSP_DSP_TO_AP_MAILBOX_NO) = BIT_MASK(SYS_IPC_CORE_HIFI);
+ SYS_IPC_IMASK(DSP_SYS_IPC_BASE_ADDR_NS, DSP_DSP_TO_AP_MAILBOX_NO) = ~((unsigned int)(BIT_MASK(SYS_IPC_CORE_HIFI)|BIT_MASK(SYS_IPC_CORE_A15)));
+ SYS_IPC_DATA(DSP_SYS_IPC_BASE_ADDR_NS, DSP_DSP_TO_AP_MAILBOX_NO, 0) = IPC_ACPU_INT_SRC_HIFI_MSG;
+ SYS_IPC_MODE(DSP_SYS_IPC_BASE_ADDR_NS, DSP_DSP_TO_AP_MAILBOX_NO) = BIT_MASK(SYS_IPC_MODE_AUTOACK);
+ SYS_IPC_SEND(DSP_SYS_IPC_BASE_ADDR_NS, DSP_DSP_TO_AP_MAILBOX_NO) = BIT_MASK(SYS_IPC_CORE_HIFI);
+
+ return;
+}
+#endif
+/* ...assert IPI interrupt on remote core - board-specific */
+static inline void xf_ipi_assert(u32 core)
+{
+ XF_PROXY_NOTIFY_PEER(core);
+}
+
+#ifdef XAF_ENABLE_NON_HIKEY
+/* ...initialize IPI subsystem */
+static inline int xf_ipi_init(u32 core)
+{
+ xf_core_ro_data_t *ro = XF_CORE_RO_DATA(core);
+ extern void (* const xf_ipi_handlers[])(void);
+
+ /* ...reset IPC data - no interrupt yet */
+ ro->ipc.wait = 0;
+
+ /* ...install interrupt handler */
+ _xtos_set_interrupt_handler(XF_PROXY_IPI_NUM(core), xf_ipi_handlers[core]);
+
+ return 0;
+}
+#else
+/* ...initialize IPI subsystem */
+static inline int xf_ipi_init(u32 core)
+{
+
+ waitstate =0;
+
+ dsp_debug_init();
+ //dsp_init_share_mem(HIKEY_AP2DSP_MSG_QUEUE_ADDR,HIKEY_DSP2AP_MSG_QUEUE_SIZE);
+ /* unlock reg */
+ SYS_IPC_LOCK(DSP_SYS_IPC_BASE_ADDR_NS) = 0x1ACCE551;
+ //VOS_ConnectInterrupt(DSP_IPC_FROM_AP_INT_NO, _ap_to_dsp_ipc_irq_proc);
+ VOS_ConnectInterrupt(DSP_IPC_FROM_AP_INT_NO, xf_ipi_resume);
+
+// VOS_EnableInterrupt(DSP_IPC_FROM_AP_INT_NO);
+
+ return;
+}
+#endif
+
+/*******************************************************************************
+ * Shared memory operations
+ ******************************************************************************/
+
+/* ...NULL-address specification */
+#define XF_PROXY_NULL (~0U)
+
+/* ...invalid proxy address */
+#define XF_PROXY_BADADDR XF_CFG_REMOTE_IPC_POOL_SIZE
+/* ...translate buffer address to shared proxy address */
+static inline u32 xf_ipc_b2a(u32 core, void *b)
+{
+ xf_shmem_data_t *shmem = XF_CORE_DATA(core)->shmem;
+ void *start = shmem->buffer;
+
+ if (b == NULL)
+ return XF_PROXY_NULL;
+ else if ((s32)(b - start) < XF_CFG_REMOTE_IPC_POOL_SIZE)
+ return (u32)(b - start);
+ else
+ return XF_PROXY_BADADDR;
+}
+/* ...translate shared proxy address to local pointer */
+static inline void * xf_ipc_a2b(u32 core, u32 address)
+{
+ xf_shmem_data_t *shmem = XF_CORE_DATA(core)->shmem;
+ void *start = shmem->buffer;
+
+ if (address < XF_CFG_REMOTE_IPC_POOL_SIZE)
+ return start + address;
+ else if (address == XF_PROXY_NULL)
+ return NULL;
+ else
+ return (void *)-1;
+}
+
+/* ...component association with remote IPC client */
+static inline void xf_ipc_component_addref(u32 session)
+{
+}
+
+/* ...delete record about component association with remote IPC client */
+static inline void xf_ipc_component_rmref(u32 id)
+{
+}
+
+/* ...system-specific IPC layer initialization */
+extern int xf_ipc_init(u32 core);
+
+/*******************************************************************************
+ * Mutex definitions
+ ******************************************************************************/
+
+/* ...export shared memory access macros */
+#define MUTEX_SHARED_READ(core) \
+ ({ xf_core_ro_data_t *__ro = XF_CORE_RO_DATA(core); __ro->lock[0]; })
+
+#define MUTEX_SHARED_WRITE(core, val) \
+ ({ xf_core_ro_data_t *__ro = XF_CORE_RO_DATA(core); __ro->lock[0] = (val); })
+
+/* ...include library header */
+#include "lib/mutex.h"
+
+#if XF_CFG_CORES_NUM > 1
+/* ...rename API functions */
+static inline void xf_mutex_lock(u32 core)
+{
+ mutex_lock(core);
+}
+
+static inline void xf_mutex_unlock(u32 core)
+{
+ mutex_unlock(core);
+}
+
+#else
+/* ...for single-core setting no locking is actually needed */
+static inline void xf_mutex_lock(u32 core)
+{
+}
+
+static inline void xf_mutex_unlock(u32 core)
+{
+}
+
+#endif /* XF_CFG_CORES_NUM > 1 */
diff --git a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-mem.h b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-mem.h
new file mode 100644
index 0000000..dc27787
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-mem.h
@@ -0,0 +1,180 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-mem.h
+ *
+ * System-specific memory allocator
+ *
+ *******************************************************************************/
+
+#ifndef __XF_H
+#error "xf-mem.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * System specific memory pools
+ ******************************************************************************/
+
+#if XF_CFG_CORES_NUM > 1
+/* ...shared memory pool for communication within DSP-cluster */
+extern xf_mm_pool_t xf_dsp_shmem_pool;
+#endif
+
+/*******************************************************************************
+ * Platform-specific SHMEM allocation registering functions
+ ******************************************************************************/
+
+/* ...register shmem allocation address */
+static inline void xf_shmem_alloc_addref(u32 core, xf_message_t *m)
+{
+}
+
+/* ...unregister shmem allocation address */
+static inline void xf_shmem_alloc_rmref(u32 core, xf_message_t *m)
+{
+}
+
+/*******************************************************************************
+ * API functions
+ ******************************************************************************/
+
+/* ...allocate aligned memory on particular core specifying if it is shared */
+static inline void * xf_mem_alloc(u32 size, u32 align, u32 core, u32 shared)
+{
+#if XF_CFG_CORES_NUM > 1
+ if (shared)
+ {
+ /* ...if memory is shared, core is dropped */
+ return xf_mm_alloc(&xf_dsp_shmem_pool, size);
+ }
+#endif
+
+ /* ...select local memory pool basing on core specification */
+ return xf_mm_alloc(&XF_CORE_DATA(core)->local_pool, size);
+}
+#ifdef XAF_ENABLE_NON_HIKEY
+/* ...redefine macro to add bugchecks */
+#define xf_mem_alloc(size, align, core, shared) \
+({ \
+ void *__data; \
+ /* ...size must be properly aligned */ \
+ BUG(!XF_MM_ALIGNED(size), _x("Bad size: %u"), size); \
+ __data = (xf_mem_alloc)(size, align, core, shared); \
+ TRACE(1, _b("alloc-%u: %p[%u] (shared=%u)"), core, __data, size, shared); \
+ __data; \
+})
+#endif
+/* ...release allocated memory */
+static inline void xf_mem_free(void *p, u32 size, u32 core, u32 shared)
+{
+#if XF_CFG_CORES_NUM > 1
+ if (shared)
+ {
+ /* ...if memory is shared, core is dropped */
+ xf_mm_free(&xf_dsp_shmem_pool, p, size);
+ return;
+ }
+#endif
+
+ /* ...select proper pool basing on core specification */
+ xf_mm_free(&XF_CORE_DATA(core)->local_pool, p, size);
+}
+#ifdef XAF_ENABLE_NON_HIKEY
+/* ...redefine macro to add bugchecks */
+#define xf_mem_free(p, size, core, shared) \
+({ \
+ void *__data = (p); \
+ /* ...size must be properly aligned */ \
+ BUG(!XF_MM_ALIGNED(size), _x("Bad size: %u"), size); \
+ TRACE(1, _b("free-%u: %p[%u] (shared=%u)"), core, __data, size, shared); \
+ (xf_mem_free)(__data, size, core, shared); \
+})
+#endif
+/* ...allocate AP-DSP shared memory */
+static inline int xf_shmem_alloc(u32 core, xf_message_t *m)
+{
+ xf_mm_pool_t *pool = &XF_CORE_DATA(core)->shared_pool;
+
+ /* ...length is always cache-line aligned */
+ if ((m->buffer = xf_mm_alloc(pool, XF_ALIGNED(m->length))) != NULL)
+ {
+ /* ...register allocation address */
+ xf_shmem_alloc_addref(core, m);
+
+ return 0;
+ }
+ else
+ {
+ return -ENOMEM;
+ }
+}
+
+/* ...free AP-DSP shared memory */
+static inline void xf_shmem_free(u32 core, xf_message_t *m)
+{
+ xf_mm_pool_t *pool = &XF_CORE_DATA(core)->shared_pool;
+
+ /* ...length is always cache-line aligned */
+ xf_mm_free(pool, m->buffer, XF_ALIGNED(m->length));
+
+ /* ...unregister allocation address */
+ xf_shmem_alloc_rmref(core, m);
+}
+
+/*******************************************************************************
+ * Scratch memory management
+ ******************************************************************************/
+
+static inline void * xf_scratch_mem_init(u32 core)
+{
+ /* ...allocate scratch memory from local DSP memory */
+ return xf_mem_alloc(XF_CFG_CODEC_SCRATCHMEM_SIZE, XF_CFG_CODEC_SCRATCHMEM_ALIGN, core, 0);
+}
+
+/*******************************************************************************
+ * Helpers - hmm; they are platform-independent - tbd
+ ******************************************************************************/
+
+/* ...allocate local buffer */
+static inline int xf_mm_alloc_buffer(u32 size, u32 align, u32 core, xf_mm_buffer_t *b)
+{
+ /* ...allocate memory from proper local pool */
+ if ((size = XF_MM(size)) != 0)
+ XF_CHK_ERR(b->addr = xf_mem_alloc(size, align, core, 0), -ENOMEM);
+ else
+ b->addr = NULL;
+
+ /* ...save address */
+ b->size = size;
+
+ return 0;
+}
+
+/* ...free local buffer */
+static inline void xf_mm_free_buffer(xf_mm_buffer_t *b, u32 core)
+{
+ if (b->addr)
+ {
+ xf_mem_free(b->addr, b->size, core, 0);
+ }
+}
diff --git a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-runtime.h b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-runtime.h
new file mode 100644
index 0000000..ab328cc
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-runtime.h
@@ -0,0 +1,81 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-runtime.h
+ *
+ * Platform-specific runtime data definitions
+ *
+ *******************************************************************************/
+
+#ifndef __XF_H
+#error "xf-runtime.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+/* ...platform HAL layer */
+#include "xf-hal.h"
+
+/*******************************************************************************
+ * Mutex (opaque) data definition
+ ******************************************************************************/
+
+typedef volatile u32 xf_mutex_t[XF_CFG_CORES_NUM > 1 ? 1 : 0];
+
+/*******************************************************************************
+ * Local/remote/ISR IPC (opaque) data
+ ******************************************************************************/
+
+typedef struct xf_ipc_handle
+{
+ /* ...variable we are waiting on */
+ u32 wait;
+
+} xf_ipc_handle_t;
+
+/*******************************************************************************
+ * IPC events
+ ******************************************************************************/
+
+/* ...core resumption flag */
+#define XF_IPC_EVENT_CORE_ASSERT (1 << 0)
+
+/* ...core waiting flag */
+#define XF_IPC_EVENT_CORE_WAIT (1 << 1)
+
+/* ...shared memory assertion flag */
+#define XF_IPC_EVENT_SHMEM_ASSERT (1 << 2)
+
+/* ...shared memory waiting flag */
+#define XF_IPC_EVENT_SHMEM_WAIT (1 << 3)
+
+/* ...disabled interrupts status */
+#define XF_IPC_EVENT_ISR_OFF (1 << 4)
+
+/*******************************************************************************
+ * Shared memory interface (opaque) data
+ ******************************************************************************/
+
+typedef void * xf_shmem_handle_t;
diff --git a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-shmem.h b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-shmem.h
new file mode 100644
index 0000000..813bfb4
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-shmem.h
@@ -0,0 +1,173 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-shmem.h
+ *
+ * Definitions for Xtensa SHMEM configuration
+ *
+ *******************************************************************************/
+
+#ifndef __XF_H
+#error "xf-shmem.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Memory structures
+ ******************************************************************************/
+
+/* ...data managed by host CPU (remote) - in case of shunt it is a IPC layer */
+struct xf_proxy_host_data
+{
+ /* ...command queue */
+ xf_proxy_message_t command[XF_PROXY_MESSAGE_QUEUE_LENGTH];
+
+ /* ...writing index into command queue */
+ u32 cmd_write_idx;
+
+ /* ...reading index for response queue */
+ u32 rsp_read_idx;
+#ifdef XAF_ENABLE_NON_HIKEY
+} __attribute__((__packed__, __aligned__(XF_PROXY_ALIGNMENT)));
+#else
+}/* __attribute__((__packed__, __aligned__(XF_PROXY_ALIGNMENT)))*/;
+#endif
+
+/* ...data managed by DSP (local) */
+struct xf_proxy_dsp_data
+{
+ /* ...response queue */
+ xf_proxy_message_t response[XF_PROXY_MESSAGE_QUEUE_LENGTH];
+
+ /* ...writing index into response queue */
+ u32 rsp_write_idx;
+
+ /* ...reading index for command queue */
+ u32 cmd_read_idx;
+#ifdef XAF_ENABLE_NON_HIKEY
+} __attribute__((__packed__, __aligned__(XF_PROXY_ALIGNMENT)));
+#else
+}/* __attribute__((__packed__, __aligned__(XF_PROXY_ALIGNMENT)))*/;
+#endif
+/* ...shared memory data */
+typedef struct xf_shmem_data
+{
+ /* ...outgoing data (maintained by host CPU (remote side)) */
+#ifdef XAF_ENABLE_NON_HIKEY
+ struct xf_proxy_host_data remote __xf_shmem__;
+
+ /* ...ingoing data (maintained by DSP (local side)) */
+ struct xf_proxy_dsp_data local __xf_shmem__;
+
+ /* ...shared memory pool (page-aligned; why? we map memory to user-space) */
+ u8 buffer[XF_CFG_REMOTE_IPC_POOL_SIZE] __attribute__((__aligned__(4096)));
+#else
+ /* ...outgoing data (maintained by host CPU (remote side)) */
+ struct xf_proxy_host_data remote/* __xf_shmem__*/;
+
+ /* ...ingoing data (maintained by DSP (local side)) */
+ struct xf_proxy_dsp_data local/* __xf_shmem__*/;
+
+ /* ...shared memory pool (page-aligned; why? we map memory to user-space) */
+ uint8_t* buffer;
+#endif
+
+} xf_shmem_data_t;
+
+/*******************************************************************************
+ * Shared memory accessors
+ ******************************************************************************/
+
+/* ...shared memory pointer for a core */
+#define XF_SHMEM_DATA(core) \
+ ((xf_shmem_data_t *)XF_CORE_DATA(core)->shmem)
+
+/* ...atomic reading */
+#define XF_PROXY_READ_ATOMIC(var) \
+ ({ XF_PROXY_INVALIDATE(&(var), sizeof(var)); (var); })
+
+/* ...atomic writing */
+#define XF_PROXY_WRITE_ATOMIC(var, value) \
+ ({(var) = (value); XF_PROXY_FLUSH(&(var), sizeof(var)); (value); })
+
+/* ...accessors */
+#define XF_PROXY_READ(core, field) \
+ __XF_PROXY_READ_##field(XF_SHMEM_DATA(core))
+
+#define XF_PROXY_WRITE(core, field, v) \
+ __XF_PROXY_WRITE_##field(XF_SHMEM_DATA(core), (v))
+
+/* ...individual fields accessors */
+#define __XF_PROXY_READ_cmd_write_idx(proxy) \
+ XF_PROXY_READ_ATOMIC(proxy->remote.cmd_write_idx)
+
+#define __XF_PROXY_READ_cmd_read_idx(proxy) \
+ proxy->local.cmd_read_idx
+
+#define __XF_PROXY_READ_rsp_write_idx(proxy) \
+ proxy->local.rsp_write_idx
+
+#define __XF_PROXY_READ_rsp_read_idx(proxy) \
+ XF_PROXY_READ_ATOMIC(proxy->remote.rsp_read_idx)
+
+/* ...individual fields accessors */
+#define __XF_PROXY_WRITE_cmd_write_idx(proxy, v) \
+ XF_PROXY_WRITE_ATOMIC(proxy->remote.cmd_write_idx, v)
+
+#define __XF_PROXY_WRITE_cmd_read_idx(proxy, v) \
+ XF_PROXY_WRITE_ATOMIC(proxy->local.cmd_read_idx, v)
+
+#define __XF_PROXY_WRITE_rsp_read_idx(proxy, v) \
+ XF_PROXY_WRITE_ATOMIC(proxy->remote.rsp_read_idx, v)
+
+#define __XF_PROXY_WRITE_rsp_write_idx(proxy, v) \
+ XF_PROXY_WRITE_ATOMIC(proxy->local.rsp_write_idx, v)
+
+/* ...command buffer accessor */
+#define XF_PROXY_COMMAND(core, idx) \
+ (&XF_SHMEM_DATA((core))->remote.command[(idx)])
+
+/* ...response buffer accessor */
+#define XF_PROXY_RESPONSE(core, idx) \
+ (&XF_SHMEM_DATA((core))->local.response[(idx)])
+
+/*******************************************************************************
+ * Platform-specific SHMEM enable status
+ ******************************************************************************/
+
+static inline int xf_shmem_enabled(u32 core)
+{
+ return (core == 0);
+}
+
+/*******************************************************************************
+ * API functions
+ ******************************************************************************/
+
+/* ...process shared memory interface on given DSP core */
+extern void xf_shmem_process_queues(u32 core);
+
+/* ...completion callback for message originating from remote proxy */
+extern void xf_msg_proxy_complete(xf_message_t *m);
+
+/* ...initialize shared memory interface (DSP side) */
+extern int xf_shmem_init(u32 core);
diff --git a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-sys.h b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-sys.h
new file mode 100644
index 0000000..b82c10e
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-sys.h
@@ -0,0 +1,75 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-sys.h
+ *
+ * Definitions for Xtensa SHMEM configuration
+ *
+ *******************************************************************************/
+
+#ifndef __XF_H
+#error "xf-sys.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Standard system includes
+ ******************************************************************************/
+
+/* ...from directory ./board-BOARDNAME */
+#include "xf-board.h"
+
+/*******************************************************************************
+ * Global abstractions
+ ******************************************************************************/
+
+/* ...prevent instructions reordering */
+#define barrier() \
+ __asm__ __volatile__("": : : "memory")
+
+/* ...memory barrier */
+#define XF_PROXY_BARRIER() \
+ __asm__ __volatile__("memw": : : "memory")
+
+/* ...memory invalidation */
+#define XF_PROXY_INVALIDATE(buf, length) \
+ ({ if ((length)) { xthal_dcache_region_invalidate((buf), (length)); barrier(); } buf; })
+
+/* ...memory flushing */
+#define XF_PROXY_FLUSH(buf, length) \
+ ({ if ((length)) { barrier(); xthal_dcache_region_writeback((buf), (length)); XF_PROXY_BARRIER(); } buf; })
+
+/*******************************************************************************
+ * Core-specific data accessor
+ ******************************************************************************/
+
+/* ...per-core execution data */
+extern xf_core_data_t xf_core_data[XF_CFG_CORES_NUM];
+
+/* ...local memory accessor */
+#define XF_CORE_DATA(core) (&xf_core_data[core])
+
+/*******************************************************************************
+ * Inter-processor communication and shared memory interface definition
+ ******************************************************************************/
+
+#include "xf-ipc.h"
diff --git a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-types.h b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-types.h
new file mode 100644
index 0000000..5f58825
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-types.h
@@ -0,0 +1,55 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-types.h
+ *
+ * Platform-specific typedefs
+ *
+ *******************************************************************************/
+
+#ifndef __XF_H
+#error "xf-types.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <assert.h>
+#include <errno.h>
+#include <xtensa/config/core.h>
+
+/*******************************************************************************
+ * Primitive types
+ ******************************************************************************/
+
+typedef unsigned int u32;
+typedef signed int s32;
+typedef unsigned short u16;
+typedef signed short s16;
+typedef unsigned char u8;
+typedef signed char s8;
diff --git a/hifi/xaf/hifi-dpf/include/xa_profiler.h b/hifi/xaf/hifi-dpf/include/xa_profiler.h
new file mode 100644
index 0000000..675ff15
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/xa_profiler.h
@@ -0,0 +1,156 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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 __XA_PROFILER_H__
+#define __XA_PROFILER_H__
+
+#if !defined(PROFILE) && __XCC__
+#define PROFILE 1
+#endif
+
+#if !defined(PREFETCH_CTL) && __XCC__
+#define PREFETCH_CTL 1
+#endif
+
+#ifdef PROFILE
+#include <xtensa/hal.h>
+#include <sys/times.h>
+
+#include "xa_type_def.h"
+#include "xa_timer.h"
+
+TRACE_TAG(MCPS,1);
+
+typedef struct XA_PROFILER {
+#if 1
+ unsigned long cstart;
+ unsigned long cstop;
+ unsigned long cycles;
+ unsigned long g_output_bytes;
+ unsigned long Peak;
+ unsigned long Sum;
+
+ unsigned long sample_rate;
+ unsigned long channels;
+ unsigned long pcm_width;
+#else
+ struct tms start;
+ struct tms stop;
+ double Peak;
+ double Sum;
+ long long cycles;
+#endif
+ int Peak_frame;
+ int frame_count;
+ long long output_bytes;
+ long long total_cycles;
+ long long total_samples;
+ char *id;
+} xa_profiler;
+
+extern xa_profiler prof;
+
+static inline void xa_compute_mcps(xa_profiler *p_prof, WORD32 samples_decoded, UWORD32 samp_freq, long long gen_strm_pos)
+{
+ double Ave=0.0, Curr;
+
+ if (samples_decoded <= 0)
+ return;
+
+ p_prof->total_samples += samples_decoded;
+ p_prof->frame_count++;
+
+ clock_t cycles = p_prof->cycles;
+ p_prof->total_cycles = 0;
+ Curr = ((double) cycles / samples_decoded * samp_freq / 1000000);
+
+ if (p_prof->frame_count > 1) {
+ p_prof->Sum += Curr;
+ Ave = p_prof->Sum / (p_prof->frame_count-1);
+
+ if (p_prof->Peak < Curr) {
+ p_prof->Peak = Curr;
+ p_prof->Peak_frame = (p_prof->frame_count);
+ }
+ }
+
+ unsigned long long total_msec =
+ (unsigned long long)((double)p_prof->total_samples / samp_freq * 1000.0);
+ int msec = (int)(total_msec % 1000);
+ unsigned long long total_seconds = total_msec / 1000;
+ int seconds = (int)(total_seconds % 60);
+ int minutes = (int)(total_seconds / 60);
+
+#if 1
+ TRACE(MCPS, _b("[%d] %d:%d.%d MCPS: %d Average: %d samples: %d\n"),
+ p_prof->frame_count, (uint32_t)minutes, (uint32_t)seconds, (uint32_t)msec,
+ (uint32_t)Curr, (uint32_t)Ave, samples_decoded);
+#else
+ TRACE(MCPS, _b("[%d|%lld] %d:%02d.%03d MCPS: %.2f Average: %.2f Peak: %.2f @ [%d] %s\n"),
+ p_prof->frame_count, gen_strm_pos, minutes, seconds, msec,
+ Curr, Ave, p_prof->Peak, p_prof->Peak_frame, p_prof->id);
+#endif
+
+ /* reset counters */
+ p_prof->g_output_bytes = 0;
+ p_prof->cycles = 0;
+}
+
+#define INIT_XA_PROFILER(x, a) do { memset(&x, 0, sizeof(xa_profiler)); \
+ x.sample_rate = 48000;\
+ x.channels = 2;\
+ x.pcm_width = 16;\
+ x.id = a; } while(0)
+
+#define START_TIME_XA_PROFILER(x) do { set_ccount(0); \
+ x.cstart=read_ccount(); } while(0)
+#define STOP_TIME_XA_PROFILER(x) do { x.cstop =read_ccount(); \
+ x.cycles += (x.cstop - x.cstart); } while(0)
+#define COMPUTE_MHZ_XA_PROFILER(x, a, b, c) do { xa_compute_mcps(&x, a, b, c); } while(0)
+#define SUMMARY_XA_PROFILER(x) do { fprintf(stdout,"\n%5s Peak MCPS = %f\n", x.id, x.Peak); \
+ fprintf(stdout,"%5s Peak frame = %d\n", x.id, x.Peak_frame); \
+ fprintf(stdout,"%5s Average MCPS = %f\n", x.id, (x.frame_count < 2) ? 0 : (x.Sum/(x.frame_count-1))); } while(0)
+
+#else
+
+typedef struct XA_PROFILER {
+ int place_holder;
+} xa_profiler;
+
+#define INIT_XA_PROFILER(x, a) do {} while(0)
+#define START_TIME_XA_PROFILER(x) do {} while(0)
+#define STOP_TIME_XA_PROFILER(x) do {} while(0)
+#define COMPUTE_MHZ_XA_PROFILER(x, a, b) do {} while(0)
+#define SUMMARY_XA_PROFILER(x) do {} while(0)
+#endif
+
+#ifdef PREFETCH_CTL
+#define PREFETCH_AGGRESSIVE(x) do { x = xthal_set_cache_prefetch ((XTHAL_DCACHE_PREFETCH_HIGH | XTHAL_ICACHE_PREFETCH_HIGH)); \
+ } while(0)
+#define PREFETCH_RESTORE(x) do { xthal_set_cache_prefetch (x); } while(0)
+#else
+#define PREFETCH_AGGRESSIVE(x) do {} while(0)
+#define PREFETCH_RESTORE(x) do {} while(0)
+#endif
+
+#endif /* __XA_PROFILER_H__ */
+
diff --git a/hifi/xaf/hifi-dpf/include/xa_timer.h b/hifi/xaf/hifi-dpf/include/xa_timer.h
new file mode 100644
index 0000000..d45cb4b
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/xa_timer.h
@@ -0,0 +1,111 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+
+******************************************************************************/
+#include <xtensa/xtruntime.h>
+#include <xtensa/config/specreg.h>
+
+extern const unsigned char Xthal_have_ccount;
+extern const unsigned char Xthal_num_ccompare;
+extern void xthal_set_ccompare(int n, unsigned value);
+extern unsigned xthal_get_ccompare(int n);
+
+/*--------------------------------------------*/
+#include <xtensa/config/core.h>
+#define TIMER_INTERVAL 0x1000
+
+#define TIMER_INT_MASK (1 << XCHAL_TIMER0_INTERRUPT)
+#define TIMER2_INT_MASK (1 << XCHAL_TIMER1_INTERRUPT)
+#define TWO_TIMERS_INT_MASK ( TIMER_INT_MASK + TIMER2_INT_MASK )
+#define _XTSTR(x) # x
+#define XTSTR(x) _XTSTR(x)
+
+static __inline__ int read_ccount()
+{
+ unsigned int ccount;
+ __asm__ __volatile__ (
+ "rsr %0, "XTSTR(CCOUNT)
+ : "=a" (ccount)
+ );
+ return ccount;
+}
+
+static __inline__ int read_ccompare0()
+{
+ unsigned int ccompare0;
+ __asm__ __volatile__ (
+ "rsr %0, "XTSTR(CCOMPARE_0)
+ : "=a" (ccompare0)
+ );
+ return ccompare0;
+}
+
+static __inline__ int read_ccompare1()
+{
+ unsigned int ccompare1;
+ __asm__ __volatile__ (
+ "rsr %0, "XTSTR(CCOMPARE_1)
+ : "=a" (ccompare1)
+ );
+ return ccompare1;
+}
+
+static __inline__ unsigned int read_intenable()
+{
+ unsigned int intenable;
+ __asm__ __volatile__ (
+ "rsr %0, "XTSTR(INTENABLE)
+ : "=a" (intenable)
+ );
+ return intenable;
+}
+
+static __inline__ void set_ccompare1(int val)
+{
+ __asm__ __volatile__ (
+ "wsr %0, "XTSTR(CCOMPARE_1)"\n\t"
+ "isync\n\t"
+ :
+ : "a" (val)
+ );
+}
+
+static __inline__ void set_ccompare0(int val)
+{
+ __asm__ __volatile__ (
+ "wsr %0, "XTSTR(CCOMPARE_0)"\n\t"
+ "isync\n\t"
+ :
+ : "a" (val)
+ );
+}
+
+/*---------------------------------------------------*/
+
+static __inline__ void set_ccount(int val)
+{
+ __asm__ __volatile__ (
+ "wsr %0, ccount\n"
+ "isync\n"
+ :
+ : "a" (val)
+ );
+}
+
diff --git a/hifi/xaf/hifi-dpf/include/xf-component.h b/hifi/xaf/hifi-dpf/include/xf-component.h
new file mode 100644
index 0000000..f97f2e4
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/xf-component.h
@@ -0,0 +1,91 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-component.h
+ *
+ * Xtensa processing framework component definition
+ *
+ *******************************************************************************/
+
+#ifndef __XF_H
+#error "xf-component.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Types definitions
+ ******************************************************************************/
+
+/* ...component literal identifier */
+typedef const char * const xf_id_t;
+
+/* ...component descriptor (base structure) */
+typedef struct xf_component
+{
+ /* ...scheduler node */
+ xf_task_t task;
+
+ /* ...component id */
+ u32 id;
+
+ /* ...message-processing function */
+ int (*entry)(struct xf_component *, xf_message_t *);
+
+ /* ...component destructor function */
+ int (*exit)(struct xf_component *, xf_message_t *);
+#ifndef XAF_ENABLE_NON_HIKEY
+ /* ...output port accessor */
+ xf_output_port_t * (*port)(struct xf_component *, u32);
+#endif
+
+} xf_component_t;
+
+/*******************************************************************************
+ * Helpers
+ ******************************************************************************/
+
+/* ...return core-id of the component */
+static inline u32 xf_component_core(xf_component_t *component)
+{
+ return XF_PORT_CORE(component->id);
+}
+
+/* ...schedule component execution */
+#define xf_component_schedule(c, dts) \
+({ \
+ xf_sched_t *__sched = &XF_CORE_DATA(xf_component_core((c)))->sched; \
+ xf_sched_put(__sched, &(c)->task, xf_sched_timestamp(__sched) + (dts)); \
+})
+
+/* ...cancel component execution */
+#define xf_component_cancel(c) \
+({ \
+ xf_sched_t *__sched = &XF_CORE_DATA(xf_component_core((c)))->sched; \
+ xf_sched_cancel(__sched, &(c)->task); \
+})
+
+/*******************************************************************************
+ * API functions
+ ******************************************************************************/
+
+/* ...component factory */
+extern xf_component_t * xf_component_factory(u32 core, xf_id_t id, u32 length);
diff --git a/hifi/xaf/hifi-dpf/include/xf-core.h b/hifi/xaf/hifi-dpf/include/xf-core.h
new file mode 100644
index 0000000..4daea6f
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/xf-core.h
@@ -0,0 +1,150 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-core.h
+ *
+ * DSP processing framework core definitions
+ *
+ *******************************************************************************/
+
+#ifndef __XF_H
+#error "xf-core.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Shared core data
+ ******************************************************************************/
+
+/* ...core data with read-only access from remote cores */
+typedef struct xf_core_ro_data
+{
+ /* ...platform-specific multi-core mutex data (want to have an array? - tbd) */
+ xf_mutex_t lock;
+
+ /* ...opaque platform-specific IPC-data handle */
+ xf_ipc_handle_t ipc;
+
+ /* ...shared memory message pool data - here? - tbd */
+ xf_msg_pool_t pool;
+
+ /* ...anything else? - tbd */
+
+} xf_core_ro_data_t;
+
+/* ...core data with read-write access from remote cores */
+typedef struct xf_core_rw_data
+{
+ /* ...message queue containing local commands/responses */
+ xf_msg_queue_t local;
+
+ /* ...message queue containing responses to remote proxy (if enabled) */
+ xf_msg_queue_t remote;
+
+ /* ...pointer to shared memory data? anything else? - tbd */
+
+} xf_core_rw_data_t;
+
+/* ...proper cache-line aligned core data */
+XF_ALIGNED_TYPEDEF(xf_core_ro_data_t, __xf_core_ro_data_t);
+XF_ALIGNED_TYPEDEF(xf_core_rw_data_t, __xf_core_rw_data_t);
+
+/*******************************************************************************
+ * Global data definition - hmm... - tbd
+ ******************************************************************************/
+
+/* ...per-core shared memory with read-only remote access */
+extern __xf_core_ro_data_t xf_core_ro_data[XF_CFG_CORES_NUM];
+
+/* ...per-core shared memory with read-write remote access */
+extern __xf_core_rw_data_t xf_core_rw_data[XF_CFG_CORES_NUM];
+
+/* ...shared read-only memory access */
+#define XF_CORE_RO_DATA(core) ((xf_core_ro_data_t *)(&xf_core_ro_data[(core)]))
+
+/* ...shared read-write memory access */
+#define XF_CORE_RW_DATA(core) ((xf_core_rw_data_t *)(&xf_core_rw_data[(core)]))
+
+/*******************************************************************************
+ * Local core data (not accessible from remote cores)
+ ******************************************************************************/
+
+/* ...component map entry */
+typedef union xf_cmap_link
+{
+ /* ...poiner to active client */
+ xf_component_t *c;
+
+ /* ...index to a client in the list (values 0..XF_CFG_MAX_CLIENTS) */
+ u32 next;
+
+} xf_cmap_link_t;
+
+/* ...per-core local data */
+typedef struct xf_core_data
+{
+ /* ...scheduler queue (sorted by execution timestamp) */
+ xf_sched_t sched;
+
+ /* ...command/response queue for communication within local core (including ISRs) */
+ xf_msg_queue_t queue;
+
+ /* ...pending response queue (submitted from ISR context) */
+ xf_msg_queue_t response;
+
+ /* ...per-core component mapping */
+ xf_cmap_link_t cmap[XF_CFG_MAX_CLIENTS];
+
+ /* ...index of first free client */
+ u32 free;
+
+ /* ...local DSP memory pool */
+ xf_mm_pool_t local_pool;
+
+ /* ...shared AP-DSP memory pool (if enabled) */
+ xf_mm_pool_t shared_pool;
+
+ /* ...opaque system-specific shared memory data handle */
+ xf_shmem_handle_t shmem;
+
+ /* ...scratch memory pointer */
+ void *scratch;
+
+ /* ...tracer data */
+ xf_trace_data_t trace;
+
+ /* ...any debugging information? for memory allocation etc... ? */
+
+} xf_core_data_t;
+
+/*******************************************************************************
+ * API functions
+ ******************************************************************************/
+
+/* ...initialize per-core framework data */
+extern int xf_core_init(u32 core);
+
+/* ...global data initialization function */
+extern int xf_global_init(void);
+
+/* ...process core events */
+extern void xf_core_service(u32 core);
diff --git a/hifi/xaf/hifi-dpf/include/xf-debug.h b/hifi/xaf/hifi-dpf/include/xf-debug.h
new file mode 100644
index 0000000..c416cc0
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/xf-debug.h
@@ -0,0 +1,216 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-debug.h
+ *
+ * Debugging interface for Xtensa Audio DSP codec server
+ *
+ *******************************************************************************/
+
+#ifndef __XF_H
+#error "xf-debug.h mustn't be included directly"
+#endif
+
+#include "dsp_debug.h"
+
+/*******************************************************************************
+ * Auxiliary macros (put into "xf-types.h"?)
+ ******************************************************************************/
+
+#ifndef offset_of
+#define offset_of(type, member) \
+ ((int)&(((const type *)(0))->member))
+#endif
+
+#ifndef container_of
+#define container_of(ptr, type, member) \
+ ((type *)((void *)(ptr) - offset_of(type, member)))
+#endif
+
+/* ...next power-of-two calculation */
+#define xf_next_power_of_two(v) __xf_power_of_two_1((v) - 1)
+#define __xf_power_of_two_1(v) __xf_power_of_two_2((v) | ((v) >> 1))
+#define __xf_power_of_two_2(v) __xf_power_of_two_3((v) | ((v) >> 2))
+#define __xf_power_of_two_3(v) __xf_power_of_two_4((v) | ((v) >> 4))
+#define __xf_power_of_two_4(v) __xf_power_of_two_5((v) | ((v) >> 8))
+#define __xf_power_of_two_5(v) __xf_power_of_two_6((v) | ((v) >> 16))
+#define __xf_power_of_two_6(v) ((v) + 1)
+
+/* ...check if non-zero value is a power-of-two */
+#define xf_is_power_of_two(v) (((v) & ((v) - 1)) == 0)
+
+/*******************************************************************************
+ * Bug check for constant conditions (file scope)
+ ******************************************************************************/
+
+#define __C_BUG(n) __C_BUG2(n)
+#define __C_BUG2(n) __c_bug_##n
+#define C_BUG(expr) typedef char __C_BUG(__LINE__)[(expr) ? -1 : 1]
+
+/*******************************************************************************
+ * Compilation-time types control
+ ******************************************************************************/
+
+#if XF_DEBUG
+#define __C_TYPE_CONTROL(d, type) ((void) ((d) != (type*) 0))
+#else
+#define __C_TYPE_CONTROL(d, type) ((void) 0)
+#endif
+
+/*******************************************************************************
+ * Unused variable
+ ******************************************************************************/
+
+#define C_UNUSED(v) (void)(0 ? (v) = (v), 1 : 0)
+
+/*******************************************************************************
+ * Auxiliary macros
+ ******************************************************************************/
+
+/* ...define a stub for unused declarator */
+#define __xf_stub(tag, line) __xf_stub2(tag, line)
+#define __xf_stub2(tag, line) typedef int __xf_##tag##_##line
+
+/* ...convert anything into string */
+#define __xf_string(x) __xf_string2(x)
+#define __xf_string2(x) #x
+
+/*******************************************************************************
+ * Tracing facility
+ ******************************************************************************/
+
+#if XF_TRACE
+
+/* ...tracing to communication processor */
+extern int xf_trace(const char *format, ...) __attribute__((format (printf, 1, 2)));
+
+/* ...tracing facility initialization */
+extern void xf_trace_init(const char *banner);
+
+/* ...initialize tracing facility */
+//#define TRACE_INIT(banner) (xf_trace_init(banner))
+#define TRACE_INIT(banner) ({ dsp_debug_init(); DSP_TRACE("\n"banner); })
+
+/* ...trace tag definition */
+#define TRACE_TAG(tag, on) enum { __xf_trace_##tag = on }
+
+/* ...check if the trace tag is enabled */
+#define TRACE_CFG(tag) (__xf_trace_##tag)
+
+/* ...tagged tracing primitive */
+#define TRACE(tag, fmt, ...) (void)(__xf_trace_##tag ? __xf_trace(tag, __xf_format##fmt, ## __VA_ARGS__), 1 : 0)
+
+/*******************************************************************************
+ * Tagged tracing formats
+ ******************************************************************************/
+
+/* ...tracing primitive */
+#define __xf_trace(tag, fmt, ...) \
+ ({ __attribute__((unused)) const char *__xf_tag = #tag; DSP_TRACE(fmt, ## __VA_ARGS__); })
+
+/* ...just a format string */
+#define __xf_format_n(fmt) fmt
+
+/* ...module tag and trace tag shown */
+#define __xf_format_b(fmt) "[%s.%s] " fmt, __xf_string(MODULE_TAG), __xf_tag
+
+/* ...module tag, trace tag, file name and line shown */
+#define __xf_format_x(fmt) "[%s.%s] - %s@%d - " fmt, __xf_string(MODULE_TAG), __xf_tag, __FILE__, __LINE__
+
+/*******************************************************************************
+ * Globally defined tags
+ ******************************************************************************/
+
+/* ...unconditionally OFF */
+TRACE_TAG(0, 0);
+
+/* ...unconditionally ON */
+TRACE_TAG(1, 1);
+
+/* ...error output - on by default */
+TRACE_TAG(ERROR, 1);
+
+#else
+
+#define TRACE_INIT(banner) (void)0
+#define TRACE_TAG(tag, on) __xf_stub(trace_##tag, __LINE__)
+#define TRACE_CFG(tag) 0
+#define TRACE(tag, fmt, ...) (void)0
+#define __xf_trace(tag, fmt, ...) (void)0
+
+#endif /* XF_TRACE */
+
+/*******************************************************************************
+ * Bugchecks
+ ******************************************************************************/
+
+#if XF_DEBUG
+
+/* ...run-time bugcheck */
+#define BUG(cond, fmt, ...) \
+do \
+{ \
+ if (cond) \
+ { \
+ /* ...output message */ \
+ __xf_trace(BUG, __xf_format##fmt, ## __VA_ARGS__); \
+ \
+ /* ...and die (tbd) */ \
+ __xf_abort(); \
+ } \
+} \
+while (0)
+
+#else
+#define BUG(cond, fmt, ...) (void)0
+#endif /* XF_DEBUG */
+
+/*******************************************************************************
+ * Run-time error processing
+ ******************************************************************************/
+
+/* ...check the API call succeeds */
+#define XF_CHK_API(cond) \
+({ \
+ int __ret; \
+ \
+ if ((__ret = (int)(cond)) < 0) \
+ { \
+ TRACE(ERROR, _x("API error: %d"), __ret); \
+ return __ret; \
+ } \
+ __ret; \
+})
+
+/* ...check the condition is true */
+#define XF_CHK_ERR(cond, error) \
+({ \
+ int __ret; \
+ \
+ if (!(__ret = (int)(cond))) \
+ { \
+ TRACE(ERROR, _x("check failed: %d"), __ret); \
+ return (error); \
+ } \
+ __ret; \
+})
diff --git a/hifi/xaf/hifi-dpf/include/xf-io.h b/hifi/xaf/hifi-dpf/include/xf-io.h
new file mode 100644
index 0000000..17019a7
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/xf-io.h
@@ -0,0 +1,298 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-io.h
+ *
+ * Input/output data ports
+ *
+ *******************************************************************************/
+
+#ifndef __XF_H
+#error "xf-io.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Types definitions
+ ******************************************************************************/
+
+/* ...input port with interim buffer */
+typedef struct xf_input_port
+{
+ /* ...message queue */
+ xf_msg_queue_t queue;
+
+ /* ...internal contiguous buffer to store incoming data */
+ void *buffer;
+
+ /* ...size of internal buffer */
+ u32 length;
+
+ /* ...current writing position in the buffer */
+ u32 filled;
+
+ /* ...interim pointer to input message buffer */
+ void *access;
+
+ /* ...remaining length of current input message */
+ u32 remaining;
+
+ /* ...execution flags */
+ u32 flags;
+
+} xf_input_port_t;
+
+/*******************************************************************************
+ * Input port flags
+ ******************************************************************************/
+
+/* ...data enabled */
+#define XF_INPUT_FLAG_CREATED (1 << 0)
+
+/* ...data enabled */
+#define XF_INPUT_FLAG_ENABLED (1 << 1)
+
+/* ...end-of-stream condition */
+#define XF_INPUT_FLAG_EOS (1 << 2)
+
+/* ...stream completed */
+#define XF_INPUT_FLAG_DONE (1 << 3)
+
+/* ...stream purging sequence */
+#define XF_INPUT_FLAG_PURGING (1 << 4)
+
+/* ...base input port flags mask */
+#define __XF_INPUT_FLAGS(flags) ((flags) & ((1 << 5) - 1))
+
+/* ...custom input port flag */
+#define __XF_INPUT_FLAG(f) ((f) << 5)
+
+/*******************************************************************************
+ * Helpers
+ ******************************************************************************/
+
+/* ...test if input port is created */
+static inline int xf_input_port_created(xf_input_port_t *port)
+{
+ return (port->flags & XF_INPUT_FLAG_CREATED);
+}
+
+/* ...check if input port is ready (has pending message) */
+static inline int xf_input_port_ready(xf_input_port_t *port)
+{
+ return (xf_msg_queue_head(&port->queue) != NULL);
+}
+
+/* ...test if input port entered end-of-stream condition */
+static inline int xf_input_port_done(xf_input_port_t *port)
+{
+ return (port->flags & XF_INPUT_FLAG_DONE);
+}
+
+/* ...check if port is in bypass mode */
+static inline int xf_input_port_bypass(xf_input_port_t *port)
+{
+ return port->buffer == NULL;
+}
+
+/* ...bypass port only: check if there is a data available */
+static inline void * xf_input_port_data(xf_input_port_t *port)
+{
+ return port->access;
+}
+
+/* ...bypass port only: get remaining length of current message */
+static inline u32 xf_input_port_length(xf_input_port_t *port)
+{
+ return port->remaining;
+}
+
+/* ...non-bypass port only: get current fill level */
+static inline u32 xf_input_port_level(xf_input_port_t *port)
+{
+ return port->filled;
+}
+
+/*******************************************************************************
+ * Output port data
+ ******************************************************************************/
+
+typedef struct xf_output_port
+{
+ /* ...pending message queue */
+ xf_msg_queue_t queue;
+
+ /* ...message pool */
+ xf_msg_pool_t pool;
+
+ /* ...saved port unrouting message */
+ xf_message_t *unroute;
+
+ /* ...length of output buffer */
+ u32 length;
+
+ /* ...output port flags */
+ u32 flags;
+
+} xf_output_port_t;
+
+/*******************************************************************************
+ * Output port flags
+ ******************************************************************************/
+
+/* ...port is created */
+#define XF_OUTPUT_FLAG_CREATED (1 << 0)
+
+/* ...port is routed */
+#define XF_OUTPUT_FLAG_ROUTED (1 << 1)
+
+/* ...data enabled */
+#define XF_OUTPUT_FLAG_ENABLED (1 << 2)
+
+/* ...stream completed */
+#define XF_OUTPUT_FLAG_DONE (1 << 3)
+
+/* ...flushing sequence is on-going */
+#define XF_OUTPUT_FLAG_FLUSHING (1 << 4)
+
+/* ...port is idle - no outstanding messages */
+#define XF_OUTPUT_FLAG_IDLE (1 << 5)
+
+/* ...port is being unrouted */
+#define XF_OUTPUT_FLAG_UNROUTING (1 << 6)
+
+/* ...base output port flags accessor */
+#define __XF_OUTPUT_FLAGS(flags) ((flags) & ((1 << 7) - 1))
+
+/* ...custom output port flag */
+#define __XF_OUTPUT_FLAG(f) ((f) << 7)
+
+/*******************************************************************************
+ * Helpers
+ ******************************************************************************/
+
+/* ...test if input port is created */
+static inline int xf_output_port_created(xf_output_port_t *port)
+{
+ return (port->flags & XF_OUTPUT_FLAG_CREATED);
+}
+
+/* ...check if port is routed */
+static inline int xf_output_port_routed(xf_output_port_t *port)
+{
+ return ((port->flags & XF_OUTPUT_FLAG_ROUTED) != 0);
+}
+
+/* ...check if port unrouting sequence is ongoing */
+static inline int xf_output_port_unrouting(xf_output_port_t *port)
+{
+ return ((port->flags & XF_OUTPUT_FLAG_UNROUTING) != 0);
+}
+
+/* ...check if port is idle (owns all data buffers) */
+static inline int xf_output_port_idle(xf_output_port_t *port)
+{
+ return ((port->flags & XF_OUTPUT_FLAG_IDLE) != 0);
+}
+
+/* ...check if port is ready (has output buffers - better use flags - tbd) */
+static inline int xf_output_port_ready(xf_output_port_t *port)
+{
+ return (xf_msg_queue_head(&port->queue) != NULL && !xf_output_port_unrouting(port));
+}
+
+/* ...output port flow-control message accessor */
+static inline xf_message_t * xf_output_port_control_msg(xf_output_port_t *port)
+{
+ return xf_msg_pool_item(&port->pool, 0);
+}
+
+/*******************************************************************************
+ * Input port API
+ ******************************************************************************/
+
+/* ...initialize input port structure */
+extern int xf_input_port_init(xf_input_port_t *port, u32 size, u32 align, u32 core);
+
+/* ...put message into input port queue */
+extern int xf_input_port_put(xf_input_port_t *port, xf_message_t *m);
+
+/* ...fill-in required amount of data into input port buffer */
+extern int xf_input_port_fill(xf_input_port_t *port);
+
+/* ...pad input buffer with given value */
+extern void xf_input_port_pad(xf_input_port_t *port, u8 pad);
+
+/* ...consume bytes from input buffer */
+extern void xf_input_port_consume(xf_input_port_t *port, u32 n);
+
+/* ...purge input port queue */
+extern void xf_input_port_purge(xf_input_port_t *port);
+
+/* ...save flow-control message for propagated input port purging sequence */
+extern void xf_input_port_control_save(xf_input_port_t *port, xf_message_t *m);
+
+/* ...complete input port purging sequence */
+extern void xf_input_port_purge_done(xf_input_port_t *port);
+
+/* ...destroy input port data */
+extern void xf_input_port_destroy(xf_input_port_t *port, u32 core);
+
+/*******************************************************************************
+ * Output port API
+ ******************************************************************************/
+
+/* ...initialize output port structure */
+extern int xf_output_port_init(xf_output_port_t *port, u32 size);
+
+/* ...put next message to the output port */
+extern int xf_output_port_put(xf_output_port_t *port, xf_message_t *m);
+
+/* ...get data buffer of output message */
+extern void * xf_output_port_data(xf_output_port_t *port);
+
+/* ...route output port */
+extern int xf_output_port_route(xf_output_port_t *port, u32 id, u32 n, u32 length, u32 align);
+
+/* ...unroute output port */
+extern void xf_output_port_unroute(xf_output_port_t *port);
+
+/* ...start output port unrouting sequence */
+extern void xf_output_port_unroute_start(xf_output_port_t *port, xf_message_t *m);
+
+/* ...complete port unrouting sequence */
+extern void xf_output_port_unroute_done(xf_output_port_t *port);
+
+/* ...produce output message marking amount of bytes produced */
+extern int xf_output_port_produce(xf_output_port_t *port, u32 n);
+
+/* ...purge output port */
+extern void xf_output_port_purge(xf_output_port_t *port);
+
+/* ...flush output port and return non-zero result if sequence is over */
+extern int xf_output_port_flush(xf_output_port_t *port, u32 opcode);
+
+/* ...complete flushing sequence */
+extern void xf_output_port_flush_done(xf_output_port_t *port);
+
+/* ...destroy output port data */
+extern void xf_output_port_destroy(xf_output_port_t *port, u32 core);
diff --git a/hifi/xaf/hifi-dpf/include/xf-mm.h b/hifi/xaf/hifi-dpf/include/xf-mm.h
new file mode 100644
index 0000000..712ea14
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/xf-mm.h
@@ -0,0 +1,142 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-mm.h
+ *
+ * Generic dynamic memory manager (based on rb-tree index)
+ *
+ *******************************************************************************/
+
+#ifndef __XF_H
+#error "xf-mem.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+/* ...red-black trees library */
+#include "lib/rbtree.h"
+
+/*******************************************************************************
+ * Cache-line aligned types
+ ******************************************************************************/
+
+/* ...proper cache-line alignment */
+#define XF_ALIGNED(size) \
+ (((size) + XF_PROXY_ALIGNMENT - 1) & ~(XF_PROXY_ALIGNMENT - 1))
+
+/* ...cache-line aligned type identifier */
+#define XF_ALIGNED_TYPE(type) \
+ __xf_aligned_##type
+
+/* ...definition of cache-line aligned type */
+#define XF_ALIGNED_TYPEDEF(type, name) \
+typedef union \
+{ \
+ /* ...item of original type */ \
+ type __obj; \
+ \
+ /* ...padding to cache-line */ \
+ u8 __pad[XF_ALIGNED(sizeof(type))]; \
+ \
+} XF_ALIGNED_TYPE(type), name __xf_shmem__
+
+/* ...accessor to original type */
+#define XF_ALIGNED_OBJ(p) \
+ (&(p)->__obj)
+
+#define XF_IS_ALIGNED(p) \
+ (((u32)(p) & (XF_PROXY_ALIGNMENT - 1)) == 0)
+
+/*******************************************************************************
+ * Memory pool description
+ ******************************************************************************/
+
+/* ...memory allocator data */
+typedef struct xf_mm_pool
+{
+ /* ...free blocks map sorted by block length */
+ rb_tree_t l_map;
+
+ /* ...free blocks map sorted by address of the block */
+ rb_tree_t a_map;
+
+ /* ...address of memory pool (32-bytes aligned at least); need that? - tbd */
+ void *addr;
+
+ /* ...length of the pool (multiple of descriptor size); need that? - tbd */
+ u32 size;
+
+} xf_mm_pool_t;
+
+/* ...descriptor of free memory block */
+typedef struct xf_mm_block
+{
+ /* ...rb-tree node in a block-length map */
+ rb_node_t l_node;
+
+ /* ...rb-tree node in a block-address map */
+ rb_node_t a_node;
+
+} xf_mm_block_t;
+
+/* ...properly aligned allocation unit */
+typedef u8 xf_mm_item[xf_next_power_of_two(sizeof(xf_mm_block_t))];
+
+/* ...macro to assure proper alignment of dynamically allocated data */
+#define XF_MM(size) (((size) + sizeof(xf_mm_item) - 1) & ~(sizeof(xf_mm_item) - 1))
+
+/* ...check if memory is properly aligned */
+#define XF_MM_ALIGNED(size) (!((size) & (sizeof(xf_mm_item) - 1)))
+
+/* ...alignement definition */
+#define __xf_mm__ __attribute__((__aligned__(sizeof(xf_mm_item))))
+
+/*******************************************************************************
+ * Dynamically allocated buffer
+ ******************************************************************************/
+
+/* ...memory allocation metadata */
+typedef struct xf_mm_buffer
+{
+ /* ...allocation address */
+ void *addr;
+
+ /* ...length */
+ u32 size;
+
+} __xf_mm__ xf_mm_buffer_t;
+
+/*******************************************************************************
+ * API functions
+ ******************************************************************************/
+
+/* ...pool initialization */
+extern int xf_mm_init(xf_mm_pool_t *pool, void *addr, u32 size);
+
+/* ...block allocation */
+extern void * xf_mm_alloc(xf_mm_pool_t *pool, u32 size);
+
+/* ...block deallocation */
+extern void xf_mm_free(xf_mm_pool_t *pool, void *addr, u32 size);
diff --git a/hifi/xaf/hifi-dpf/include/xf-msg.h b/hifi/xaf/hifi-dpf/include/xf-msg.h
new file mode 100644
index 0000000..3448425
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/xf-msg.h
@@ -0,0 +1,252 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-msg.h
+ *
+ * Internal messages, and message queues.
+ *
+ *******************************************************************************/
+
+#ifndef __XF_H
+#error "xf-msg.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Types definitions
+ ******************************************************************************/
+
+/* ...forward declaration */
+typedef struct xf_message xf_message_t;
+
+/* ...audio command/response message (internal to DSP processing framework) */
+struct xf_message
+{
+ /* ...pointer to next item in the list */
+ xf_message_t *next;
+
+ /* ...shmem session_id */
+ u32 id;
+
+ /* ...operation code */
+ u32 opcode;
+
+ /* ...length of attached message buffer */
+ u32 length;
+
+ /* ...message buffer (translated virtual address) */
+ void *buffer;
+#ifndef XAF_ENABLE_NON_HIKEY
+ uint64_t v_buffer;
+#endif
+};
+
+/* ...cache-line aligned message buffer */
+XF_ALIGNED_TYPEDEF(xf_message_t, __xf_message_t);
+
+/* ...message pool definition */
+typedef struct xf_msg_pool
+{
+ /* ...array of aligned messages */
+ __xf_message_t *p;
+
+ /* ...pointer to first free item in the pool */
+ __xf_message_t *head;
+
+ /* ...total size of the pool */
+ u32 n;
+
+} xf_msg_pool_t;
+
+/* ...message accessor */
+static inline xf_message_t * xf_msg_pool_item(xf_msg_pool_t *pool, u32 i)
+{
+ return (xf_message_t *) &pool->p[i];
+}
+
+/*******************************************************************************
+ * Message queue data
+ ******************************************************************************/
+
+/* ...message queue (single-linked FIFO list) */
+typedef struct xf_msg_queue
+{
+ /* ...head of the queue */
+ xf_message_t *head;
+
+ /* ...tail pointer */
+ xf_message_t *tail;
+
+} xf_msg_queue_t;
+
+/*******************************************************************************
+ * Message queue API
+ ******************************************************************************/
+
+/* ...initialize message queue */
+static inline void xf_msg_queue_init(xf_msg_queue_t *queue)
+{
+ queue->head = queue->tail = NULL;
+}
+
+/* ...push message in FIFO queue */
+static inline int xf_msg_enqueue(xf_msg_queue_t *queue, xf_message_t *m)
+{
+ int empty = (queue->head == NULL);
+
+ /* ...set list terminating pointer */
+ m->next = NULL;
+
+ if (empty)
+ queue->head = m;
+ else
+ queue->tail->next = m;
+
+ /* ...advance tail pointer */
+ queue->tail = m;
+
+ /* ...return emptiness status */
+ return empty;
+}
+
+#define xf_msg_enqueue(queue, m) \
+({ \
+ BUG((m)->next != NULL, _x("message is active: %p"), (m)); \
+ (xf_msg_enqueue)((queue), (m)); \
+})
+
+/* ...retrieve (pop) next message from FIFO queue */
+static inline xf_message_t * xf_msg_dequeue(xf_msg_queue_t *queue)
+{
+ xf_message_t *m = queue->head;
+
+ /* ...check if there is anything in the queue and dequeue it */
+ if (m != NULL)
+ {
+ /* ...advance head to the next entry in the queue */
+ if ((queue->head = m->next) == NULL)
+ queue->tail = NULL;
+
+ /* ...debug - wipe out next pointer */
+ m->next = NULL;
+ }
+
+ return m;
+}
+
+/* ...test if message queue is empty */
+static inline int xf_msg_queue_empty(xf_msg_queue_t *queue)
+{
+ return (queue->head == NULL);
+}
+
+/* ...get message queue head pointer */
+static inline xf_message_t * xf_msg_queue_head(xf_msg_queue_t *queue)
+{
+ return queue->head;
+}
+
+/* ...check if message belongs to a pool */
+static inline int xf_msg_from_pool(xf_msg_pool_t *pool, xf_message_t *m)
+{
+ return (u32)((__xf_message_t*)m - pool->p) < pool->n;
+}
+
+/*******************************************************************************
+ * Global message pool API
+ ******************************************************************************/
+
+/* ...submit message execution on local DSP core */
+extern void xf_msg_schedule(xf_message_t *m, u32 ts);
+
+/* ...schedule message execution from ISR context */
+extern void xf_msg_schedule_isr(xf_message_t *m);
+
+/* ...submit message for execution on some DSP */
+extern void xf_msg_submit(xf_message_t *m);
+
+/* ...cancel local (scheduled on current core) message execution */
+extern void xf_msg_cancel(xf_message_t *m);
+
+/* ...complete message processing */
+extern void xf_msg_complete(xf_message_t *m);
+
+/* ...complete message from ISR context */
+extern void xf_msg_complete_isr(xf_message_t *m);
+
+/* ...allocate message pool on specific core */
+extern int xf_msg_pool_init(xf_msg_pool_t *pool, u32 n, u32 core);
+
+/* ...allocate message from a pool (no concurrent access from other cores) */
+extern xf_message_t * xf_msg_pool_get(xf_msg_pool_t *pool);
+
+/* ...return message back to the pool (no concurrent access from other cores) */
+extern void xf_msg_pool_put(xf_msg_pool_t *pool, xf_message_t *m);
+
+/* ...destroy message pool */
+extern void xf_msg_pool_destroy(xf_msg_pool_t *pool, u32 core);
+
+/* ...indicate whether pool of free messages is empty */
+extern int xf_message_pool_empty(void);
+
+/* ...initialize global pool of messages */
+extern void xf_message_pool_init(void);
+
+/*******************************************************************************
+ * Auxiliary helpers
+ ******************************************************************************/
+
+/* ...send response message to caller */
+static inline void xf_response(xf_message_t *m)
+{
+ xf_msg_complete(m);
+}
+
+/* ...send response message with output buffer */
+static inline void xf_response_data(xf_message_t *m, u32 length)
+{
+ /* ...adjust message output buffer */
+ m->length = length;
+
+ /* ...return message to originator */
+ xf_msg_complete(m);
+}
+
+/* ...send generic "ok" message (no data buffer) */
+static inline void xf_response_ok(xf_message_t *m)
+{
+ /* ...adjust message output buffer */
+ m->length = 0;
+
+ /* ...return message to originator */
+ xf_msg_complete(m);
+}
+
+/* ...send error-response message */
+static inline void xf_response_err(xf_message_t *m)
+{
+ /* ...set generic error message */
+ m->opcode = XF_UNREGISTER, m->length = 0;
+
+ /* ...return message to originator */
+ xf_msg_complete(m);
+}
diff --git a/hifi/xaf/hifi-dpf/include/xf-opcode.h b/hifi/xaf/hifi-dpf/include/xf-opcode.h
new file mode 100644
index 0000000..6fa0846
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/xf-opcode.h
@@ -0,0 +1,290 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-opcode.h
+ *
+ * Xtensa audio processing framework. Message API
+ *
+ ******************************************************************************/
+
+#ifndef __XF_H
+#error "xf-opcode.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Message routing composition - move somewhere else - tbd
+ ******************************************************************************/
+
+/* ...adjust IPC client of message going from user-space */
+#define XF_MSG_AP_FROM_USER(id, client) \
+ (((id) & ~(0xF << 2)) | (client))
+
+/* ...wipe out IPC client from message going to user-space */
+#define XF_MSG_AP_TO_USER(id) \
+ ((id) & ~(0xF << 18))
+
+/* ...port specification (12 bits) */
+#define __XF_PORT_SPEC(core, id, port) ((core) | ((id) << 2) | ((port) << 8))
+#define __XF_PORT_SPEC2(id, port) ((id) | ((port) << 8))
+#define XF_PORT_CORE(spec) ((spec) & 0x3)
+#define XF_PORT_CLIENT(spec) (((spec) >> 2) & 0x3F)
+#define XF_PORT_ID(spec) (((spec) >> 8) & 0xF)
+
+/* ...message id contains source and destination ports specification */
+#define __XF_MSG_ID(src, dst) (((src) & 0xFFFF) | (((dst) & 0xFFFF) << 16))
+#define XF_MSG_SRC(id) (((id) >> 0) & 0xFFFF)
+#define XF_MSG_SRC_CORE(id) (((id) >> 0) & 0x3)
+#define XF_MSG_SRC_CLIENT(id) (((id) >> 2) & 0x3F)
+#define XF_MSG_SRC_ID(id) (((id) >> 0) & 0xFF)
+#define XF_MSG_SRC_PORT(id) (((id) >> 8) & 0xF)
+#define XF_MSG_SRC_PROXY(id) (((id) >> 15) & 0x1)
+#define XF_MSG_DST(id) (((id) >> 16) & 0xFFFF)
+#define XF_MSG_DST_CORE(id) (((id) >> 16) & 0x3)
+#define XF_MSG_DST_CLIENT(id) (((id) >> 18) & 0x3F)
+#define XF_MSG_DST_ID(id) (((id) >> 16) & 0xFF)
+#define XF_MSG_DST_PORT(id) (((id) >> 24) & 0xF)
+#define XF_MSG_DST_PROXY(id) (((id) >> 31) & 0x1)
+
+/* ...special treatment of AP-proxy destination field */
+#define XF_AP_IPC_CLIENT(id) (((id) >> 18) & 0xF)
+#define XF_AP_CLIENT(id) (((id) >> 22) & 0x1FF)
+#define __XF_AP_PROXY(core) ((core) | 0x8000)
+#define __XF_DSP_PROXY(core) ((core) | 0x8000)
+#define __XF_AP_CLIENT(core, client) ((core) | ((client) << 6) | 0x8000)
+
+/* ...check if DSP message is shared between cores */
+#define XF_MSG_SHARED(id) \
+ ({ u32 __id = (id); (XF_CFG_CORES_NUM > 1 ? (__id ^ (__id >> 16)) & 0x3 : 0); })
+
+/*******************************************************************************
+ * Opcode composition
+ ******************************************************************************/
+
+/* ...opcode composition with command/response data tags */
+#define __XF_OPCODE(c, r, op) (((c) << 31) | ((r) << 30) | ((op) & 0x3F))
+
+/* ...accessors */
+#define XF_OPCODE_CDATA(opcode) ((opcode) & (1 << 31))
+#define XF_OPCODE_RDATA(opcode) ((opcode) & (1 << 30))
+#define XF_OPCODE_TYPE(opcode) ((opcode) & (0x3F))
+
+/*******************************************************************************
+ * Opcode types
+ ******************************************************************************/
+
+/* ...unregister client */
+#define XF_UNREGISTER __XF_OPCODE(0, 0, 0)
+
+/* ...register client at proxy */
+#define XF_REGISTER __XF_OPCODE(1, 0, 1)
+
+/* ...port routing command */
+#define XF_ROUTE __XF_OPCODE(1, 0, 2)
+
+/* ...port unrouting command */
+#define XF_UNROUTE __XF_OPCODE(1, 0, 3)
+
+/* ...shared buffer allocation */
+#define XF_ALLOC __XF_OPCODE(0, 0, 4)
+
+/* ...shared buffer freeing */
+#define XF_FREE __XF_OPCODE(0, 0, 5)
+
+/* ...set component parameters */
+#define XF_SET_PARAM __XF_OPCODE(1, 0, 6)
+
+/* ...get component parameters */
+#define XF_GET_PARAM __XF_OPCODE(1, 1, 7)
+
+/* ...input buffer reception */
+#define XF_EMPTY_THIS_BUFFER __XF_OPCODE(1, 0, 8)
+
+/* ...output buffer reception */
+#define XF_FILL_THIS_BUFFER __XF_OPCODE(0, 1, 9)
+
+/* ...flush specific port */
+#define XF_FLUSH __XF_OPCODE(0, 0, 10)
+
+/* ...start component operation */
+#define XF_START __XF_OPCODE(0, 0, 11)
+
+/* ...stop component operation */
+#define XF_STOP __XF_OPCODE(0, 0, 12)
+
+/* ...pause component operation */
+#define XF_PAUSE __XF_OPCODE(0, 0, 13)
+
+/* ...resume component operation */
+#define XF_RESUME __XF_OPCODE(0, 0, 14)
+
+/* ...extended parameter setting function */
+#define XF_SET_PARAM_EXT __XF_OPCODE(1, 1, 15)
+
+/* ...extended parameter retrieval function */
+#define XF_GET_PARAM_EXT __XF_OPCODE(1, 1, 16)
+
+/* ...total amount of supported decoder commands */
+#define __XF_OP_NUM 17
+
+/*******************************************************************************
+ * XF_START message definition
+ ******************************************************************************/
+
+typedef struct xf_start_msg
+{
+ /* ...effective sample rate */
+ u32 sample_rate;
+
+ /* ...number of channels */
+ u32 channels;
+
+ /* ...sample width */
+ u32 pcm_width;
+
+ /* ...minimal size of intput buffer */
+ u32 input_length;
+
+ /* ...size of output buffer */
+ u32 output_length;
+
+} __attribute__((__packed__)) xf_start_msg_t;
+
+/*******************************************************************************
+ * XF_GET_PARAM message
+ ******************************************************************************/
+
+/* ...message body (command/response) */
+typedef union xf_get_param_msg
+{
+ /* ...command structure */
+ struct
+ {
+ /* ...array of parameters requested */
+ u32 id[0];
+
+ } __attribute__((__packed__)) c;
+
+ /* ...response structure */
+ struct
+ {
+ /* ...array of parameters values */
+ u32 value[0];
+
+ } __attribute__((__packed__)) r;
+
+} xf_get_param_msg_t;
+
+/* ...length of the XF_GET_PARAM command/response */
+#define XF_GET_PARAM_CMD_LEN(params) (sizeof(u32) * (params))
+#define XF_GET_PARAM_RSP_LEN(params) (sizeof(u32) * (params))
+
+/*******************************************************************************
+ * XF_SET_PARAM message
+ ******************************************************************************/
+
+/* ...component initialization parameter */
+typedef struct xf_set_param_item
+{
+ /* ...index of parameter passed to SET_CONFIG_PARAM call */
+ u32 id;
+
+ /* ...value of parameter */
+ u32 value;
+
+} __attribute__ ((__packed__)) xf_set_param_item_t;
+
+/* ...message body (no response message? - tbd) */
+typedef struct xf_set_param_msg
+{
+ /* ...command message */
+ xf_set_param_item_t item[0];
+
+} __attribute__ ((__packed__)) xf_set_param_msg_t;
+
+/* ...length of the command message */
+#define XF_SET_PARAM_CMD_LEN(params) (sizeof(xf_set_param_item_t) * (params))
+
+/*******************************************************************************
+ * XF_SET_PARAM_EXT/XF_GET_PARAM_EXT message
+ ******************************************************************************/
+
+/* ...extended parameter descriptor */
+typedef struct xf_ext_param_desc
+{
+ /* ...index of parameter passed to SET/GET_CONFIG_PARAM call (16-bits only) */
+ u16 id;
+
+ /* ...length of embedded input/output parameter data (in bytes) */
+ u16 length;
+
+} __attribute__ ((__packed__, __aligned__(4))) xf_ext_param_desc_t;
+
+/* ...message body (no response message? - tbd) */
+typedef struct xf_ext_param_msg
+{
+ /* ...extended parameter descriptor */
+ xf_ext_param_desc_t desc;
+
+ /* ...parameter data (in the format expected by codec; 4 bytes aligned) */
+ u8 data[0];
+
+} __attribute__ ((__packed__, __aligned__(4))) xf_ext_param_msg_t;
+
+/*******************************************************************************
+ * XF_ROUTE definition
+ ******************************************************************************/
+
+/* ...port routing command */
+typedef struct xf_route_port_msg
+{
+ /* ...source port specification */
+ u32 src;
+
+ /* ...destination port specification */
+ u32 dst;
+
+ /* ...number of buffers to allocate */
+ u32 alloc_number;
+
+ /* ...length of buffer to allocate */
+ u32 alloc_size;
+
+ /* ...alignment restriction for a buffer */
+ u32 alloc_align;
+
+} __attribute__((__packed__)) xf_route_port_msg_t;
+
+/*******************************************************************************
+ * XF_UNROUTE definition
+ ******************************************************************************/
+
+/* ...port unrouting command */
+typedef struct xf_unroute_port_msg
+{
+ /* ...source port specification */
+ u32 src;
+
+ /* ...destination port specification */
+ u32 dst;
+
+} __attribute__((__packed__)) xf_unroute_port_msg_t;
diff --git a/hifi/xaf/hifi-dpf/include/xf-plugin.h b/hifi/xaf/hifi-dpf/include/xf-plugin.h
new file mode 100644
index 0000000..5805e9f
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/xf-plugin.h
@@ -0,0 +1,48 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-plugin.h
+ *
+ * Xtensa audio processing framework - plugin infrastructure.
+ *
+ ******************************************************************************/
+
+#ifdef __XF_H
+#error "xf-plugin.h cannot be used together with xf.h"
+#endif
+
+#define __XF_H
+
+/*******************************************************************************
+ * Plugin debugging interface
+ ******************************************************************************/
+
+/* ...platform-specific HAL */
+#include "xf-hal.h"
+#ifdef XAF_ENABLE_NON_HIKEY
+//#define XF_TRACE 1
+#define XF_DEBUG 1
+#endif
+
+/* ...debugging facilities */
+#include "xf-debug.h"
diff --git a/hifi/xaf/hifi-dpf/include/xf-proxy.h b/hifi/xaf/hifi-dpf/include/xf-proxy.h
new file mode 100644
index 0000000..298b782
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/xf-proxy.h
@@ -0,0 +1,101 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-proxy.h
+ *
+ * Proxy commmand/response messages
+ *
+ *******************************************************************************/
+
+#ifndef __XF_H
+#error "xf-proxy.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Types definitions
+ ******************************************************************************/
+#ifdef XAF_ENABLE_NON_HIKEY
+/* ...command/response message */
+typedef struct xf_proxy_message
+{
+ /* ...session ID */
+ u32 session_id;
+
+ /* ...proxy API command/reponse code */
+ u32 opcode;
+
+ /* ...length of attached buffer */
+ u32 length;
+
+ /* ...physical address of message buffer */
+ u32 address;
+
+} __attribute__((__packed__)) xf_proxy_message_t;
+#else
+/* ...command/response message */
+typedef struct xf_proxy_message
+{
+ /* ...session ID */
+ uint32_t session_id;
+
+ /* ...proxy API command/reponse code */
+ uint32_t opcode;
+
+ /* ...length of attached buffer */
+ uint32_t length;
+
+ /* ...physical address of message buffer */
+ uint64_t address;
+ uint64_t v_address;
+
+}/* __attribute__((__packed__)) */xf_proxy_message_t;
+#endif
+/*******************************************************************************
+ * Ring buffer support
+ ******************************************************************************/
+
+/* ...total length of shared memory queue (for commands and responses) */
+#define XF_PROXY_MESSAGE_QUEUE_LENGTH (1 << 8)
+
+/* ...index mask */
+#define XF_PROXY_MESSAGE_QUEUE_MASK 0xFF
+
+/* ...ring-buffer index */
+#define __XF_QUEUE_IDX(idx, counter) \
+ (((idx) & XF_PROXY_MESSAGE_QUEUE_MASK) | ((counter) << 16))
+
+/* ...retrieve ring-buffer index */
+#define XF_QUEUE_IDX(idx) \
+ ((idx) & XF_PROXY_MESSAGE_QUEUE_MASK)
+
+/* ...increment ring-buffer index */
+#define XF_QUEUE_ADVANCE_IDX(idx) \
+ (((idx) + 0x10001) & (0xFFFF0000 | XF_PROXY_MESSAGE_QUEUE_MASK))
+
+/* ...test if ring buffer is empty */
+#define XF_QUEUE_EMPTY(read, write) \
+ ((read) == (write))
+
+/* ...test if ring buffer is full */
+#define XF_QUEUE_FULL(read, write) \
+ ((write) == (read) + (XF_PROXY_MESSAGE_QUEUE_LENGTH << 16))
diff --git a/hifi/xaf/hifi-dpf/include/xf-sched.h b/hifi/xaf/hifi-dpf/include/xf-sched.h
new file mode 100644
index 0000000..3c04436
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/xf-sched.h
@@ -0,0 +1,98 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-sched.h
+ *
+ * Non-preemptive earliest-deadline-first scheduler
+ *
+ ******************************************************************************/
+
+#ifndef __XF_SCHED_H
+#define __XF_SCHED_H
+
+/*******************************************************************************
+ * Types definitions
+ ******************************************************************************/
+
+/* ...scheduler data */
+typedef rb_tree_t xf_sched_t;
+
+/* ...scheduling item */
+typedef rb_node_t xf_task_t;
+
+/*******************************************************************************
+ * Helpers
+ ******************************************************************************/
+
+/* ...retrieve timestamp from task handle */
+static inline u32 xf_task_timestamp(xf_task_t *t)
+{
+ /* ...wipe out last bit of "color" */
+ return (((rb_node_t *)t)->color & ~1);
+}
+
+/* ...set task decoding timestamp */
+static inline u32 xf_task_timestamp_set(xf_task_t *t, u32 ts)
+{
+ /* ...technically, wiping out last bit of timestamp is not needed */
+ return (((rb_node_t *)t)->color = ts);
+}
+
+/* ...compare two timestamps with respect to wrap-around */
+static inline int xf_timestamp_before(u32 t0, u32 t1)
+{
+ /* ...distance between active items is never high */
+ return ((s32)(t0 - t1) < 0);
+}
+
+/* ...current scheduler timestamp */
+static inline u32 xf_sched_timestamp(xf_sched_t *sched)
+{
+ /* ...don't quite care about last bit */
+ return ((rb_tree_t *)sched)->root.color;
+}
+
+/* ...set scheduler timestamp */
+static inline u32 xf_sched_timestamp_set(xf_sched_t *sched, u32 ts)
+{
+ /* ...wipe out last bit (black color is 0) */
+ return (((rb_tree_t *)sched)->root.color = ts & ~0x1);
+}
+
+/*******************************************************************************
+ * Entry points
+ ******************************************************************************/
+
+/* ...place message into scheduler queue */
+extern void xf_sched_put(xf_sched_t *sched, xf_task_t *t, u32 ts);
+
+/* ...get first item from the scheduler */
+extern xf_task_t * xf_sched_get(xf_sched_t *sched);
+
+/* ...cancel task execution */
+extern void xf_sched_cancel(xf_sched_t *sched, xf_task_t *t);
+
+/* ...initialize scheduler */
+extern void xf_sched_init(xf_sched_t *sched);
+
+#endif /* __XF_SCHED_H */
diff --git a/hifi/xaf/hifi-dpf/include/xf-timebase.h b/hifi/xaf/hifi-dpf/include/xf-timebase.h
new file mode 100644
index 0000000..7b27d58
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/xf-timebase.h
@@ -0,0 +1,132 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-timebase.h
+ *
+ * Common timebase for deadline-driven scheduler
+ *
+ *******************************************************************************/
+
+#ifndef __XF_H
+#error "xf-timebase.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Timebase for deadline-driven scheduler
+ ******************************************************************************/
+#ifdef XAF_ENABLE_NON_HIKEY
+/* ...set internal scheduler frequency as a LCM of all supported sample rates;
+ * it is in general not a problem to have large number here, however it should
+ * be noted that maximal-size audio-buffer that we handle, when expressed in
+ * ticks of this virtual frequency, must not exceed 2**31 (for otherwise
+ * scheduler timestamp comparison function will misbehave).
+ */
+#define XF_TIMEBASE_FREQ (4 * 3 * 56448000U)
+/* ...add paranoic check considering maximal audio-buffer duration as 0.1 sec */
+C_BUG((u32)(XF_TIMEBASE_FREQ / 10) >= (1 << 31));
+#else
+/* ...set internal scheduler frequency as a LCM of all supported sample rates */
+#define XF_TIMEBASE_FREQ 56448000U
+#endif
+/* ...supported sampling rates */
+C_BUG(XF_TIMEBASE_FREQ % 4000);
+C_BUG(XF_TIMEBASE_FREQ % 8000);
+C_BUG(XF_TIMEBASE_FREQ % 11025);
+C_BUG(XF_TIMEBASE_FREQ % 12000);
+C_BUG(XF_TIMEBASE_FREQ % 16000);
+C_BUG(XF_TIMEBASE_FREQ % 22050);
+C_BUG(XF_TIMEBASE_FREQ % 24000);
+C_BUG(XF_TIMEBASE_FREQ % 32000);
+C_BUG(XF_TIMEBASE_FREQ % 44100);
+C_BUG(XF_TIMEBASE_FREQ % 48000);
+C_BUG(XF_TIMEBASE_FREQ % 64000);
+C_BUG(XF_TIMEBASE_FREQ % 88200);
+C_BUG(XF_TIMEBASE_FREQ % 96000);
+C_BUG(XF_TIMEBASE_FREQ % 128000);
+C_BUG(XF_TIMEBASE_FREQ % 176400);
+C_BUG(XF_TIMEBASE_FREQ % 192000);
+
+/* ...calculate upsampling factor for given sample rate */
+static inline u32 xf_timebase_factor(u32 sample_rate)
+{
+ /* ...probably we can tolerate single division */
+ switch(sample_rate)
+ {
+ case 4000:
+ return XF_TIMEBASE_FREQ / 4000;
+ case 8000:
+ return XF_TIMEBASE_FREQ / 8000;
+ case 11025:
+ return XF_TIMEBASE_FREQ / 11025;
+ case 12000:
+ return XF_TIMEBASE_FREQ / 11025;
+ case 16000:
+ return XF_TIMEBASE_FREQ / 16000;
+ case 22050:
+ return XF_TIMEBASE_FREQ / 22050;
+ case 24000:
+ return XF_TIMEBASE_FREQ / 24000;
+ case 32000:
+ return XF_TIMEBASE_FREQ / 32000;
+ case 44100:
+ return XF_TIMEBASE_FREQ / 44100;
+ case 48000:
+ return XF_TIMEBASE_FREQ / 48000;
+ case 64000:
+ return XF_TIMEBASE_FREQ / 64000;
+ case 88200:
+ return XF_TIMEBASE_FREQ / 88200;
+ case 96000:
+ return XF_TIMEBASE_FREQ / 96000;
+ case 128000:
+ return XF_TIMEBASE_FREQ / 128000;
+ case 176400:
+ return XF_TIMEBASE_FREQ / 176400;
+ case 192000:
+ return XF_TIMEBASE_FREQ / 192000;
+ default:
+ return 0;
+ }
+}
+
+/* ...core timebase */
+static inline u32 xf_core_timebase(u32 core)
+{
+ xf_core_data_t *cd = XF_CORE_DATA(core);
+
+ /* ...get local scheduler timebase */
+ return xf_sched_timestamp(&cd->sched);
+}
+
+/* ...compare timestamps */
+static inline int xf_time_after(u32 a, u32 b)
+{
+ return ((s32)(a - b) > 0);
+}
+
+/* ...compare timstamps */
+static inline int xf_time_before(u32 a, u32 b)
+{
+ return ((s32)(a - b) < 0);
+}
+
diff --git a/hifi/xaf/hifi-dpf/include/xf-trace.h b/hifi/xaf/hifi-dpf/include/xf-trace.h
new file mode 100644
index 0000000..97bb290
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/xf-trace.h
@@ -0,0 +1,82 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-debug.h
+ *
+ * Debugging interface for Xtensa Audio DSP codec server
+ *
+ *******************************************************************************/
+
+#ifndef __XF_H
+#error "xf-debug.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Types definitions
+ ******************************************************************************/
+
+#if XF_TRACE
+
+/* ...trace data definition */
+typedef struct xf_trace_data
+{
+ /* ...current write position in tracing buffer */
+ char *p;
+
+ /* ...threshold position for buffer submission */
+ char *end;
+
+#if XF_TRACE_REMOTE
+ /* ...beginning of non-commited internal tracing buffer */
+ char *start;
+
+ /* ...message queue */
+ xf_msg_queue_t queue;
+#endif
+
+} xf_trace_data_t;
+
+#else
+
+/* ...stub for disabled tracing */
+typedef u32 xf_trace_data_t[0];
+
+#endif /* XF_TRACE */
+
+/*******************************************************************************
+ * Internal API functions
+ ******************************************************************************/
+
+#if XF_TRACE_REMOTE
+/* ...submit buffer for tracing */
+extern void xf_trace_submit(u32 core, xf_message_t *m);
+
+/* ...flush current buffer */
+extern void xf_trace_flush(u32 core, xf_message_t *m);
+
+#else
+
+#define xf_trace_submit(core, m) (void)0
+#define xf_trace_flush(core, m) (void)0
+
+#endif /* XF_TRACE_REMOTE */
diff --git a/hifi/xaf/hifi-dpf/include/xf.h b/hifi/xaf/hifi-dpf/include/xf.h
new file mode 100644
index 0000000..f124d8c
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/xf.h
@@ -0,0 +1,112 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf.h
+ *
+ * Xtensa audio processing framework. Main header
+ *
+ ******************************************************************************/
+
+#ifdef __XF_H
+#error "xf.h included more than once"
+#endif
+
+#define __XF_H
+
+/*******************************************************************************
+ * Global configuration parameters (changing is to be done carefully)
+ ******************************************************************************/
+
+/* ...allocate 6 bits for client number per core */
+#define XF_CFG_MAX_CLIENTS (1 << 6)
+
+/* ...allocate 2 bits for core id */
+#define XF_CFG_MAX_CORES (1 << 2)
+
+/* ...allocate 4 bits for maximal number of input/output ports per component */
+#define XF_CFG_MAX_PORTS (1 << 4)
+
+/* ...allocate 6 bits for opcode type */
+#define XF_CFG_MAX_CODES (1 << 6)
+
+/*******************************************************************************
+ * Common runtime framework
+ ******************************************************************************/
+#ifndef XAF_ENABLE_NON_HIKEY
+#include "cpu_c.h"
+
+#include "dsp_driver_ipc.h"
+
+#include "dsp_debug.h"
+
+#include "dsp_memory_config.h"
+
+#include "dsp_driver_mailbox.h"
+
+#include "dsp_pcm_gain.h"
+
+#endif
+/* ...target configuration */
+#include "xf-config.h"
+
+/* ...platform run-time */
+#include "xf-runtime.h"
+
+/* ...debugging facility */
+#include "xf-debug.h"
+
+/* ...generic memory allocator */
+#include "xf-mm.h"
+
+/* ...standard opcodes */
+#include "xf-opcode.h"
+
+/* ...proxy definitions (shared messages - tbd) */
+#include "xf-proxy.h"
+
+/* ...message API */
+#include "xf-msg.h"
+
+/* ...tracer data */
+#include "xf-trace.h"
+
+/* ...I/O ports */
+#include "xf-io.h"
+
+/* ...scheduler definition */
+#include "xf-sched.h"
+
+/* ...component definition */
+#include "xf-component.h"
+
+/* ...core data */
+#include "xf-core.h"
+
+/* ...system abstractions */
+#include "xf-sys.h"
+
+/* ...memory management */
+#include "xf-mem.h"
+
+/* ...common timebase */
+#include "xf-timebase.h"