diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2022-02-16 07:40:03 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2022-02-16 07:40:03 +0000 |
commit | b2bb602e7be31f80b8d2a74cd283ff5cb70ea7c9 (patch) | |
tree | f0abcbb9970bde49ee3b2c7531b022fac4315cfa | |
parent | 15940eb7032ee053c104a6433f3aa47372502caa (diff) | |
parent | 92fd6ed17beaad46ede504577b65f45dd015190a (diff) | |
download | hikey-b2bb602e7be31f80b8d2a74cd283ff5cb70ea7c9.tar.gz |
Merge changes I22cfd132,If6784590 am: 92fd6ed17b
Original change: https://android-review.googlesource.com/c/device/linaro/hikey/+/1987334
Change-Id: I1057fa53829e3cbf9187cb07ac37fede6aad04b8
195 files changed, 30948 insertions, 121 deletions
diff --git a/audio/Android.mk b/audio/Android.mk index 84e2e56e..eb0732d7 100644 --- a/audio/Android.mk +++ b/audio/Android.mk @@ -38,4 +38,15 @@ LOCAL_C_INCLUDES += \ system/media/audio_utils/include \ system/media/audio_effects/include +ifeq ($(TARGET_ENABLE_DSP_DEVICE), true) +LOCAL_CFLAGS += -DENABLE_XAF_DSP_DEVICE +LOCAL_C_INCLUDES += \ + $(LOCAL_PATH)/../hifi/xaf/host-apf/include \ + $(LOCAL_PATH)/../hifi/xaf/host-apf/include/os/android \ + $(LOCAL_PATH)/../hifi/xaf/host-apf/include/sys/fio\ + $(LOCAL_PATH)/../hifi/xaf/host-apf/include/audio \ + $(LOCAL_PATH)/../hifi/xaf/host-apf/utest/include + +LOCAL_STATIC_LIBRARIES := libxtensa_proxy +endif include $(BUILD_SHARED_LIBRARY) diff --git a/audio/audio_hw.c b/audio/audio_hw.c index 3fdf3f97..02ce2508 100644 --- a/audio/audio_hw.c +++ b/audio/audio_hw.c @@ -42,6 +42,7 @@ #include <audio_effects/effect_aec.h> #include <sys/ioctl.h> +#include <linux/audio_hifi.h> #define CARD_OUT 0 #define PORT_CODEC 0 diff --git a/bt-wifi-firmware-util/NOTICE b/bt-wifi-firmware-util/NOTICE new file mode 100644 index 00000000..e5bdc11d --- /dev/null +++ b/bt-wifi-firmware-util/NOTICE @@ -0,0 +1,72 @@ +TEXAS INSTRUMENTS TEXT FILE LICENSE + + +Copyright (c) 2008 - 2013 Texas Instruments Incorporated + +All rights reserved not granted herein. + +Limited License. + +If you download and use any version of this software from www.github.com, you +acknowledge and agree that the terms and conditions of this license control and any +previous licenses under which this software may have been provided on www.github.com +are superseded and replaced by the terms and conditions of this license. + +Texas Instruments Incorporated grants a world-wide, royalty-free, non-exclusive +license under copyrights and patents it now or hereafter owns or controls to make, +have made, use, import, offer to sell and sell ("Utilize") this software subject +to the terms herein. With respect to the foregoing patent license, such license +is granted solely to the extent that any such patent is necessary to Utilize the +software alone. The patent license shall not apply to any combinations which +include this software, other than combinations with devices manufactured by or +for TI ("TI Devices"). No hardware patent is licensed hereunder. + +Redistributions must preserve existing copyright notices and reproduce this license +(including the above copyright notice and the disclaimer and (if applicable) source +code license limitations below) in the documentation and/or other materials provided +with the distribution + +Redistribution and use in binary form, without modification, are permitted provided +that the following conditions are met: + +* No reverse engineering, decompilation, or disassembly of this software is permitted + with respect to any software provided in binary form. + +* any redistribution and use are licensed by TI for use only with TI Devices. + +* Nothing shall obligate TI to provide you with source code for the software + licensed and provided to you in object code. + +If software source code is provided to you, modification and redistribution of the +source code are permitted provided that the following conditions are met: + +* any redistribution and use of the source code, including any resulting + derivative works, are licensed by TI for use only with TI Devices. + +* any redistribution and use of any object code compiled from the source + code and any resulting derivative works, are licensed by TI for use only + with TI Devices. + +Neither the name of Texas Instruments Incorporated nor the names of its suppliers +may be used to endorse or promote products derived from this software without specific +prior written permission. + +DISCLAIMER. + +THIS SOFTWARE IS PROVIDED BY TI AND TI'S LICENSORS "AS IS" AND ANY EXPRESS +OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN +NO EVENT SHALL TI AND TI'S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +BY UTILIZING THIS SOFTWARE TO ENABLE ANT CODE EMBEDDED ON TI DEVICES, YOU +AGREE THAT NOTHING IN THIS LICENSE GIVES RISE TO ANY WARRANTY OR OTHER +OBLIGATIONS BY TI OR ITS LICENSORS WITH RESPECT TO THE ANT CODE EMBEDDED +ON TI DEVICES AND ENABLED BY THE SOFTWARE UNDER THIS LICENSE. FURTHER, YOU +AGREE THAT NOTHING IN THIS LICENSE GIVES RISE TO ANY RIGHT TO REVERSE ENGINEER, +DECOMPILE OR DISASSEMBLE THE ANT CODE EMBEDDED ON THE TI DEVICES. diff --git a/bt-wifi-firmware-util/TIInit_11.8.32-pcm-960.bts b/bt-wifi-firmware-util/TIInit_11.8.32-pcm-960.bts Binary files differnew file mode 100644 index 00000000..ff56d1c5 --- /dev/null +++ b/bt-wifi-firmware-util/TIInit_11.8.32-pcm-960.bts diff --git a/bt-wifi-firmware-util/TIInit_11.8.32.bts b/bt-wifi-firmware-util/TIInit_11.8.32.bts Binary files differnew file mode 100755 index 00000000..824ca0f2 --- /dev/null +++ b/bt-wifi-firmware-util/TIInit_11.8.32.bts diff --git a/bt-wifi-firmware-util/wl18xx-conf-wl1837mod.bin b/bt-wifi-firmware-util/wl18xx-conf-wl1837mod.bin Binary files differnew file mode 100644 index 00000000..5dd913cc --- /dev/null +++ b/bt-wifi-firmware-util/wl18xx-conf-wl1837mod.bin diff --git a/bt-wifi-firmware-util/wl18xx-conf.bin b/bt-wifi-firmware-util/wl18xx-conf.bin Binary files differnew file mode 100644 index 00000000..2bd0f4df --- /dev/null +++ b/bt-wifi-firmware-util/wl18xx-conf.bin diff --git a/bt-wifi-firmware-util/wl18xx-fw-4.bin b/bt-wifi-firmware-util/wl18xx-fw-4.bin Binary files differnew file mode 100755 index 00000000..71c160ac --- /dev/null +++ b/bt-wifi-firmware-util/wl18xx-fw-4.bin diff --git a/build/tasks/dtimage.mk b/build/tasks/dtimage.mk index e125d170..4d6a74d4 100644 --- a/build/tasks/dtimage.mk +++ b/build/tasks/dtimage.mk @@ -1,7 +1,7 @@ ifneq ($(filter hikey%, $(TARGET_DEVICE)),) ifneq ($(TARGET_NO_DTIMAGE), true) -MKDTIMG := $(LINARO_VENDOR_PATH)/hikey960/$(EXPECTED_LINARO_VENDOR_VERSION)/bootloader/mkdtimg +MKDTIMG := device/linaro/hikey/installer/hikey960/mkdtimg DTB := $(PRODUCT_OUT)/hi3660-hikey960.dtb $(PRODUCT_OUT)/dt.img: $(DTB) diff --git a/device-common.mk b/device-common.mk index 90695957..6d047521 100644 --- a/device-common.mk +++ b/device-common.mk @@ -17,31 +17,6 @@ # Enable updating of APEXes $(call inherit-product, $(SRC_TARGET_DIR)/product/updatable_apex.mk) -# Check vendor package version -# If you need to make changes to the vendor partition, -# please modify the source git project here: -# https://staging-git.codelinaro.org/linaro/linaro-aosp/aosp-linaro-vendor-package -include $(LOCAL_PATH)/vendor-package-ver.mk -ifneq (,$(wildcard $(LINARO_VENDOR_PATH)/hikey960/$(EXPECTED_LINARO_VENDOR_VERSION)/version.mk)) - # Unfortunately inherit-product doesn't export build variables from the - # called make file to the caller, so we have to include it directly here. - include $(LINARO_VENDOR_PATH)/hikey960/$(EXPECTED_LINARO_VENDOR_VERSION)/version.mk - ifneq ($(TARGET_LINARO_VENDOR_VERSION), $(EXPECTED_LINARO_VENDOR_VERSION)) - $(warning TARGET_LINARO_VENDOR_VERSION ($(TARGET_LINARO_VENDOR_VERSION)) does not match exiting the build ($(EXPECTED_LINARO_VENDOR_VERSION)).) - $(warning Please download new binaries here:) - $(warning $(VND_PKG_URL) ) - $(warning And extract in the ANDROID_TOP_DIR) - # Would be good to error out here, but that causes other issues - endif -else - $(warning Missing Linaro Vendor Package!) - $(warning Please download new binaries here:) - $(warning $(VND_PKG_URL) ) - $(warning And extract in the ANDROID_TOP_DIR) - # Would be good to error out here, but that causes other issues -endif - -$(warning, EXPECTED_LINARO_VENDOR_VERSION=$(EXPECTED_LINARO_VENDOR_VERSION)) ifneq (,$(filter $(TARGET_PRODUCT),hikey960_tv hikey_tv)) # Setup TV Build diff --git a/fetch-vendor-package.sh b/fetch-vendor-package.sh deleted file mode 100755 index cbadbdeb..00000000 --- a/fetch-vendor-package.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash -# fetch, check & extract the current vendor package -set -e - -DIR_PARENT=$(cd $(dirname $0); pwd) -if [ -z "${ANDROID_BUILD_TOP}" ]; then - ANDROID_BUILD_TOP=$(cd ${DIR_PARENT}/../../../; pwd) -fi - -. "${ANDROID_BUILD_TOP}/device/linaro/hikey/vendor-package-ver.sh" - -PKG_FILE=extract-linaro_devices-${EXPECTED_LINARO_VENDOR_VERSION} - -pushd ${ANDROID_BUILD_TOP} - -if [ ! -e "${PKG_FILE}.tgz" ]; then - curl -L ${VND_PKG_URL} -o ${PKG_FILE}.tgz -fi - -# generate expected sha512sum, check & cleanup -echo "${EXPECTED_LINARO_VENDOR_SHA} ${PKG_FILE}.tgz" > ${PKG_FILE}.tgz.sha -sha512sum -c ${PKG_FILE}.tgz.sha -rm ${PKG_FILE}.tgz.sha - -tar -xf ${PKG_FILE}.tgz -./${PKG_FILE}.sh -popd diff --git a/hifi/Android.mk b/hifi/Android.mk new file mode 100644 index 00000000..f3377fec --- /dev/null +++ b/hifi/Android.mk @@ -0,0 +1,17 @@ +# +# Copyright 2017 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +include $(all-subdir-makefiles) diff --git a/hifi/debug-hifi/Android.mk b/hifi/debug-hifi/Android.mk new file mode 100644 index 00000000..eefcaa58 --- /dev/null +++ b/hifi/debug-hifi/Android.mk @@ -0,0 +1,23 @@ +# Copyright (C) 2017 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License + +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) +LOCAL_MODULE := debug-hifi +LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 +LOCAL_LICENSE_CONDITIONS := notice +LOCAL_SHARED_LIBRARIES := liblog libcutils +LOCAL_SRC_FILES := debug-hifi.c +include $(BUILD_EXECUTABLE) diff --git a/hifi/debug-hifi/debug-hifi.c b/hifi/debug-hifi/debug-hifi.c new file mode 100644 index 00000000..75bda4cf --- /dev/null +++ b/hifi/debug-hifi/debug-hifi.c @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "debug-hifi" +#include <errno.h> +#include <fcntl.h> +#include <unistd.h> +#include <poll.h> +#include <pthread.h> +#include <sys/ioctl.h> +#include <sys/prctl.h> +#include <stdio.h> +#include <cutils/log.h> +#include <cutils/uevent.h> +#include <stdlib.h> +#include <linux/audio_hifi.h> + +int main(int argc, char *argv[]) +{ + char *buffer; + int hifi_dsp_fd; + int ret = -1; + int i = 0; + unsigned int memsize = DRV_DSP_UART_TO_MEM_SIZE; + unsigned int clear = 0; + struct misc_io_dump_buf_param dump_buf; + + ALOGI("Enter hifi-dsp Audio Framework - sample application\n"); + if (argc > 1) + memsize = strtoul(argv[1], NULL, 0); + if (argc > 2) + clear = 1; + hifi_dsp_fd = open(HIFI_DSP_MISC_DRIVER, O_RDWR, 0); + if (hifi_dsp_fd < 0) { + ALOGE("Error %d opening hifi dsp device", errno); + return ret; + } + buffer = malloc(memsize); + if (!buffer) { + ALOGE("Error allocating buffer"); + goto out0; + } + dump_buf.user_buf = (uint64_t)buffer; + dump_buf.buf_size = memsize; + dump_buf.clear = clear; + ret = ioctl(hifi_dsp_fd, HIFI_MISC_IOCTL_DISPLAY_MSG, &dump_buf); + if (ret < 0) { /* This IOCTL returns buffer size */ + ALOGE("Error %d accessing message buffer", errno); + } else { + printf("%s\n", ret > 0 ? buffer : "Buffer is empty"); + } + free(buffer); +out0: + close(hifi_dsp_fd); + ALOGI("Exit hifi-dsp Audio Framework - sample application\n"); + return ret; +} diff --git a/hifi/firmware/hifi-hikey960.img b/hifi/firmware/hifi-hikey960.img Binary files differnew file mode 100644 index 00000000..b8c25169 --- /dev/null +++ b/hifi/firmware/hifi-hikey960.img diff --git a/hifi/xaf/Android.mk b/hifi/xaf/Android.mk new file mode 100644 index 00000000..f3377fec --- /dev/null +++ b/hifi/xaf/Android.mk @@ -0,0 +1,17 @@ +# +# Copyright 2017 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +include $(all-subdir-makefiles) diff --git a/hifi/xaf/README b/hifi/xaf/README new file mode 100755 index 00000000..9c835768 --- /dev/null +++ b/hifi/xaf/README @@ -0,0 +1,39 @@ + +. +|--- README +| - This file +| +|--- release.txt +| - Release notes +| +|--- config +| | +| |--- hifi3_hikey960_linux.tgz +| | - HiKey960 HiFi3 LX6 config with SW upgraded to RG.5 tools for Linux +| | +| |-- hifi3_hikey960_win32.tgz +| - HiKey960 HiFi3 LX6 config with SW upgraded to RG.5 tools for Windows +| +|--- docs +| | +| |--- HiFi-AF-Hosted-ProgrammersGuide.pdf +| | - Xtensa Audio Framework (Hosted) Programmers Guide, v0.6 +| | +| |--- HiFi-Audio-Codec-API-Definition.pdf +| | - HiFi Audio Codec API Definition, v1.0 +| | +| |--- HiFi-Speech-Codec-API-Definition.pdf +| | - HiFi Speech Codec API Definition, v1.0 +| | +| |-- HiKey960-HiFi3-Android-SDK-Guide.pdf +| - HiKey960-HiFi3-Android-SDK Guide, v0.7 +| +|--- xaf-dsp-v0.7_Alpha.tgz +| - XAF DSP Firmware Source Code(hifi-dpf) +| +|-- xaf-host-v0.7_Alpha.tgz +| - XAF Host application Source Code(host-apf) +| +|-- Get xtensa tools and guide to install xtensa tools,HiKey960 HiFi3 LX6 config +| -https://www.tensilicatools.com/platform/huawei-kirin-960/ +| diff --git a/hifi/xaf/config/hifi3_hikey960_linux.tgz b/hifi/xaf/config/hifi3_hikey960_linux.tgz Binary files differnew file mode 100755 index 00000000..81152190 --- /dev/null +++ b/hifi/xaf/config/hifi3_hikey960_linux.tgz diff --git a/hifi/xaf/config/hifi3_hikey960_win32.tgz b/hifi/xaf/config/hifi3_hikey960_win32.tgz Binary files differnew file mode 100755 index 00000000..32871752 --- /dev/null +++ b/hifi/xaf/config/hifi3_hikey960_win32.tgz diff --git a/hifi/xaf/docs/HiFi-AF-Hosted-ProgrammersGuide.pdf b/hifi/xaf/docs/HiFi-AF-Hosted-ProgrammersGuide.pdf Binary files differnew file mode 100755 index 00000000..3499a875 --- /dev/null +++ b/hifi/xaf/docs/HiFi-AF-Hosted-ProgrammersGuide.pdf diff --git a/hifi/xaf/docs/HiFi-Audio-Codec-API-Definition.pdf b/hifi/xaf/docs/HiFi-Audio-Codec-API-Definition.pdf Binary files differnew file mode 100755 index 00000000..179d13b3 --- /dev/null +++ b/hifi/xaf/docs/HiFi-Audio-Codec-API-Definition.pdf diff --git a/hifi/xaf/docs/HiFi-Speech-Codec-API-Definition.pdf b/hifi/xaf/docs/HiFi-Speech-Codec-API-Definition.pdf Binary files differnew file mode 100755 index 00000000..2b6a68ac --- /dev/null +++ b/hifi/xaf/docs/HiFi-Speech-Codec-API-Definition.pdf diff --git a/hifi/xaf/docs/HiKey960-HiFi3-Android-SDK-Guide.pdf b/hifi/xaf/docs/HiKey960-HiFi3-Android-SDK-Guide.pdf Binary files differnew file mode 100755 index 00000000..ea3c07a4 --- /dev/null +++ b/hifi/xaf/docs/HiKey960-HiFi3-Android-SDK-Guide.pdf diff --git a/hifi/xaf/docs/Hosted_XAF_Arch_v0.7.pdf b/hifi/xaf/docs/Hosted_XAF_Arch_v0.7.pdf Binary files differnew file mode 100755 index 00000000..f5b372f4 --- /dev/null +++ b/hifi/xaf/docs/Hosted_XAF_Arch_v0.7.pdf diff --git a/hifi/xaf/hifi-dpf/app/xa-factory.c b/hifi/xaf/hifi-dpf/app/xa-factory.c new file mode 100644 index 00000000..b9e7d193 --- /dev/null +++ b/hifi/xaf/hifi-dpf/app/xa-factory.c @@ -0,0 +1,163 @@ +/******************************************************************************* +* 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-factory.c + * + * DSP processing framework core - component factory + * + ******************************************************************************/ + +#define MODULE_TAG FACTORY + +/******************************************************************************* + * Includes + ******************************************************************************/ + +#include "xf.h" +#include "audio/xa_type_def.h" + +/******************************************************************************* + * Tracing tags + ******************************************************************************/ + +/* ...general initialization sequence */ +TRACE_TAG(INIT, 1); + +/******************************************************************************* + * Local types definitions + ******************************************************************************/ + +/* ...component descriptor */ +typedef struct xf_component_id +{ + /* ...class id (string identifier) */ + const char *id; + + /* ...class constructor */ + xf_component_t * (*factory)(u32 core, xa_codec_func_t process); + + /* ...component API function */ + xa_codec_func_t *process; + +} xf_component_id_t; + +/******************************************************************************* + * External functions + ******************************************************************************/ + +/* ...components API functions */ +extern XA_ERRORCODE xa_pcm_codec(xa_codec_handle_t, WORD32, WORD32, pVOID); +extern XA_ERRORCODE xa_mp3_decoder(xa_codec_handle_t, WORD32, WORD32, pVOID); +extern XA_ERRORCODE xa_aac_decoder(xa_codec_handle_t, WORD32, WORD32, pVOID); +extern XA_ERRORCODE xa_aac_encoder(xa_codec_handle_t, WORD32, WORD32, pVOID); +extern XA_ERRORCODE xa_vorbis_decoder(xa_codec_handle_t, WORD32, WORD32, pVOID); +extern XA_ERRORCODE xa_ac3_decoder(xa_codec_handle_t, WORD32, WORD32, pVOID); +extern XA_ERRORCODE xa_ddplus71_decoder(xa_codec_handle_t, WORD32, WORD32, pVOID); +extern XA_ERRORCODE xa_mixer(xa_codec_handle_t, WORD32, WORD32, pVOID); +extern XA_ERRORCODE xa_renderer(xa_codec_handle_t, WORD32, WORD32, pVOID); +extern XA_ERRORCODE xa_capturer(xa_codec_handle_t, WORD32, WORD32, pVOID); +extern XA_ERRORCODE xa_src_pp_fx(xa_codec_handle_t, WORD32, WORD32, pVOID); +extern XA_ERRORCODE xa_dts_hd_decoder(xa_codec_handle_t, WORD32, WORD32, pVOID); +extern XA_ERRORCODE xa_dap_fx(xa_codec_handle_t, WORD32, WORD32, pVOID); + +/* ...component class factories */ +extern xf_component_t * xa_audio_codec_factory(u32 core, xa_codec_func_t process); +extern xf_component_t * xa_audio_fx_factory(u32 core, xa_codec_func_t process); +extern xf_component_t * xa_mixer_factory(u32 core, xa_codec_func_t process); +extern xf_component_t * xa_renderer_factory(u32 core,xa_codec_func_t process); + +/******************************************************************************* + * Local constants definitions + ******************************************************************************/ + +/* ...component class id */ +static const xf_component_id_t xf_component_id[] = +{ +#if XA_PCM + { "audio-decoder/pcm", xa_audio_codec_factory, xa_pcm_codec }, +#endif +#if XA_MP3_DECODER + { "audio-decoder/mp3", xa_audio_codec_factory, xa_mp3_decoder }, +#endif +#if XA_AAC_DECODER + { "audio-decoder/aac", xa_audio_codec_factory, xa_aac_decoder }, +#endif +#if XA_AC3_DECODER + { "audio-decoder/ac3", xa_audio_codec_factory, xa_ac3_decoder }, +#endif +#if XA_DDP71_DECODER + { "audio-decoder/ddplus71", xa_audio_codec_factory, xa_ddplus71_decoder }, +#endif +#if XA_DTS_HD_DECODER + { "audio-decoder/dts-hd", xa_audio_codec_factory, xa_dts_hd_decoder }, +#endif +#if XA_VORBIS_DECODER + { "audio-decoder/vorbis", xa_audio_codec_factory, xa_vorbis_decoder }, +#endif +#if XA_AAC_ENCODER + { "audio-encoder/aac", xa_audio_codec_factory, xa_aac_encoder }, +#endif +#if XA_SRC_PP_FX + { "audio-fx/src-pp", xa_audio_codec_factory, xa_src_pp_fx }, +#endif +#if XA_DAP_FX + { "audio-fx/dap", xa_audio_codec_factory, xa_dap_fx }, +#endif +#if XA_MIXER + { "mixer", xa_mixer_factory, xa_mixer }, +#endif +#if XA_RENDERER + { "renderer", xa_renderer_factory, xa_renderer }, +#endif +#if XA_CAPTURER + { "capturer", xa_capturer_factory, xa_capturer }, +#endif +}; + +/* ...number of items in the map */ +#define XF_COMPONENT_ID_MAX (sizeof(xf_component_id) / sizeof(xf_component_id[0])) + +/******************************************************************************* + * Enry points + ******************************************************************************/ + +xf_component_t * xf_component_factory(u32 core, xf_id_t id, u32 length) +{ + u32 i; + + /* ...find component-id in static map */ + for (i = 0; i < XF_COMPONENT_ID_MAX; i++) + { + /* ...symbolic search - not too good; would prefer GUIDs in some form */ + if (!strncmp(id, xf_component_id[i].id, length)) + { + /* ...pass control to specific class factory */ + return xf_component_id[i].factory(core, xf_component_id[i].process); + } + } + + /* ...component string id is not recognized */ + TRACE(ERROR, _b("Unknown component type: %s"), id); + + return NULL; +} diff --git a/hifi/xaf/hifi-dpf/audio/xa-class-audio-codec.c b/hifi/xaf/hifi-dpf/audio/xa-class-audio-codec.c new file mode 100644 index 00000000..ce233f07 --- /dev/null +++ b/hifi/xaf/hifi-dpf/audio/xa-class-audio-codec.c @@ -0,0 +1,785 @@ +/******************************************************************************* +* 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-class-audio-codec.c + * + * Generic audio codec task implementation + * + ******************************************************************************/ + +#define MODULE_TAG CODEC + +/******************************************************************************* + * Includes + ******************************************************************************/ + +#include "xf.h" +#include "xa-class-base.h" +#include "audio/xa-audio-decoder-api.h" + +/******************************************************************************* + * Tracing configuration + ******************************************************************************/ + +TRACE_TAG(INIT, 1); +TRACE_TAG(WARNING, 1); +TRACE_TAG(INFO, 1); +TRACE_TAG(INPUT, 1); +TRACE_TAG(OUTPUT, 1); +TRACE_TAG(DECODE, 1); + +/******************************************************************************* + * Internal functions definitions + ******************************************************************************/ + +typedef struct XAAudioCodec +{ + /*************************************************************************** + * Control data + **************************************************************************/ + + /* ...generic audio codec data */ + XACodecBase base; + + /* ...input port data */ + xf_input_port_t input; + + /* ...output port data */ + xf_output_port_t output; + + /* ...input port index */ + WORD32 in_idx; + + /* ...output port index */ + WORD32 out_idx; + + /*************************************************************************** + * Run-time configuration parameters + **************************************************************************/ + + /* ...sample size in bytes */ + u32 sample_size; + + /* ...audio sample duration */ + u32 factor; + + /* ...total number of produced audio frames since last reset */ + u32 produced; + +} XAAudioCodec; + +/******************************************************************************* + * Auxiliary codec execution flags + ******************************************************************************/ + +/* ...input port setup condition */ +#define XA_CODEC_FLAG_INPUT_SETUP __XA_BASE_FLAG(1 << 0) + +/* ...output port setup condition */ +#define XA_CODEC_FLAG_OUTPUT_SETUP __XA_BASE_FLAG(1 << 1) + +/******************************************************************************* + * Data processing scheduling + ******************************************************************************/ + +/* ...prepare codec for steady operation (tbd - don't absolutely like it) */ +static inline XA_ERRORCODE xa_codec_prepare_runtime(XAAudioCodec *codec) +{ + XACodecBase *base = (XACodecBase *)codec; + xf_message_t *m = xf_msg_queue_head(&codec->output.queue); + xf_start_msg_t *msg = m->buffer; + u32 frame_size; + u32 factor; + + /* ...fill-in buffer parameters */ + XA_API(base, XA_API_CMD_GET_CONFIG_PARAM, XA_CODEC_CONFIG_PARAM_SAMPLE_RATE, &msg->sample_rate); + XA_API(base, XA_API_CMD_GET_CONFIG_PARAM, XA_CODEC_CONFIG_PARAM_CHANNELS, &msg->channels); + XA_API(base, XA_API_CMD_GET_CONFIG_PARAM, XA_CODEC_CONFIG_PARAM_PCM_WIDTH, &msg->pcm_width); + XA_API(base, XA_API_CMD_GET_MEM_INFO_SIZE, codec->in_idx, &msg->input_length); + XA_API(base, XA_API_CMD_GET_MEM_INFO_SIZE, codec->out_idx, &msg->output_length); + + TRACE(INIT, _b("codec[%p]::runtime init: f=%u, c=%u, w=%u, i=%u, o=%u"), codec, msg->sample_rate, msg->channels, msg->pcm_width, msg->input_length, msg->output_length); + + /* ...reallocate input port buffer as needed - tbd */ + BUG(msg->input_length > codec->input.length, _x("Input buffer reallocation required: %u to %u"), codec->input.length, msg->input_length); + + /* ...save sample size in bytes */ + codec->sample_size = msg->channels * (msg->pcm_width == 16 ? 2 : 4); + + /* ...calculate frame duration; get number of samples in the frame (don't like division here - tbd) */ + frame_size = msg->output_length / codec->sample_size; + + /* ...it must be a multiple */ + XF_CHK_ERR(frame_size * codec->sample_size == msg->output_length, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...retrieve upsampling factor for given sample rate */ + XF_CHK_ERR(factor = xf_timebase_factor(msg->sample_rate), XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...set frame duration factor (converts number of bytes into timebase units) */ + codec->factor = factor / codec->sample_size; + + TRACE(INIT, _b("ts-factor: %u (%u)"), codec->factor, factor); + + BUG(codec->factor * codec->sample_size != factor, _x("Freq mismatch: %u vs %u"), codec->factor * codec->sample_size, factor); + + /* ...pass response to caller (push out of output port) */ + xf_output_port_produce(&codec->output, sizeof(*msg)); + + /* ...codec runtime initialization is completed */ + TRACE(INIT, _b("codec[%p] runtime initialized: i=%u, o=%u"), codec, msg->input_length, msg->output_length); + + return XA_NO_ERROR; +} + +/******************************************************************************* + * Commands processing + ******************************************************************************/ + +/* ...EMPTY-THIS-BUFFER command processing */ +static XA_ERRORCODE xa_codec_empty_this_buffer(XACodecBase *base, xf_message_t *m) +{ + XAAudioCodec *codec = (XAAudioCodec *) base; + + /* ...make sure the port is valid */ + XF_CHK_ERR(XF_MSG_DST_PORT(m->id) == 0, XA_API_FATAL_INVALID_CMD); + + /* ...command is allowed only in post-init state */ + XF_CHK_ERR(base->state & XA_BASE_FLAG_POSTINIT, XA_API_FATAL_INVALID_CMD); + + /* ...put message into input queue */ + if (xf_input_port_put(&codec->input, m)) + { + /* ...restart stream if it is in completed state */ + if (base->state & XA_BASE_FLAG_COMPLETED) + { + /* ...reset execution stage */ + base->state = XA_BASE_FLAG_POSTINIT | XA_BASE_FLAG_EXECUTION; + + /* ...reset execution runtime */ + XA_API(base, XA_API_CMD_EXECUTE, XA_CMD_TYPE_DO_RUNTIME_INIT, NULL); + + /* ...reset produced samples counter */ + codec->produced = 0; + } + + /* ...codec must be in one of these states */ + XF_CHK_ERR(base->state & (XA_BASE_FLAG_RUNTIME_INIT | XA_BASE_FLAG_EXECUTION), XA_API_FATAL_INVALID_CMD); + + /* ...schedule data processing if output is ready */ + if (xf_output_port_ready(&codec->output)) + { + xa_base_schedule(base, 0); + } + } + + TRACE(INPUT, _b("Received buffer [%p]:%u"), m->buffer, m->length); + + return XA_NO_ERROR; +} + +/* ...FILL-THIS-BUFFER command processing */ +static XA_ERRORCODE xa_codec_fill_this_buffer(XACodecBase *base, xf_message_t *m) +{ + XAAudioCodec *codec = (XAAudioCodec *) base; + + /* ...make sure the port is valid */ + XF_CHK_ERR(XF_MSG_DST_PORT(m->id) == 1, XA_API_FATAL_INVALID_CMD); + + /* ...command is allowed only in postinit state */ + XF_CHK_ERR(base->state & XA_BASE_FLAG_POSTINIT, XA_API_FATAL_INVALID_CMD); + + /* ...special handling of zero-length buffer */ + if (base->state & XA_BASE_FLAG_RUNTIME_INIT) + { + /* ...message must be zero-length */ + BUG(m->length != 0, _x("Invalid message length: %u"), m->length); + } + else if (m == xf_output_port_control_msg(&codec->output)) + { + /* ...end-of-stream processing indication received; check the state */ + BUG((base->state & XA_BASE_FLAG_COMPLETED) == 0, _x("invalid state: %x"), base->state); + + /* ... mark flushing sequence is done */ + xf_output_port_flush_done(&codec->output); + + /* ...complete pending zero-length input buffer */ + xf_input_port_purge(&codec->input); + + TRACE(INFO, _b("codec[%p] playback completed"), codec); + + /* ...playback is over */ + return XA_NO_ERROR; + } + else if ((base->state & XA_BASE_FLAG_COMPLETED) && !xf_output_port_routed(&codec->output)) + { + /* ...return message arrived from application immediately */ + xf_response_ok(m); + + return XA_NO_ERROR; + } + else + { + TRACE(OUTPUT, _b("Received output buffer [%p]:%u"), m->buffer, m->length); + + /* ...adjust message length (may be shorter than original) */ + m->length = codec->output.length; + } + + /* ...place message into output port */ + if (xf_output_port_put(&codec->output, m) && xf_input_port_ready(&codec->input)) + { + /* ...schedule data processing instantly */ + if (base->state & (XA_BASE_FLAG_RUNTIME_INIT | XA_BASE_FLAG_EXECUTION)) + { + xa_base_schedule(base, 0); + } + } + + return XA_NO_ERROR; +} + +/* ...output port routing */ +static XA_ERRORCODE xa_codec_port_route(XACodecBase *base, xf_message_t *m) +{ + XAAudioCodec *codec = (XAAudioCodec *) base; + xf_route_port_msg_t *cmd = m->buffer; + xf_output_port_t *port = &codec->output; + u32 src = XF_MSG_DST(m->id); + u32 dst = cmd->dst; + + /* ...command is allowed only in "postinit" state */ + XF_CHK_ERR(base->state & XA_BASE_FLAG_POSTINIT, XA_API_FATAL_INVALID_CMD); + + /* ...make sure output port is addressed */ + XF_CHK_ERR(XF_MSG_DST_PORT(m->id) == 1, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...make sure port is not routed yet */ + XF_CHK_ERR(!xf_output_port_routed(port), XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...route output port - allocate queue */ + XF_CHK_ERR(xf_output_port_route(port, __XF_MSG_ID(dst, src), cmd->alloc_number, cmd->alloc_size, cmd->alloc_align) == 0, XA_API_FATAL_MEM_ALLOC); + + /* ...schedule processing instantly */ + xa_base_schedule(base, 0); + + /* ...pass success result to caller */ + xf_response_ok(m); + + return XA_NO_ERROR; +} + +/* ...port unroute command */ +static XA_ERRORCODE xa_codec_port_unroute(XACodecBase *base, xf_message_t *m) +{ + XAAudioCodec *codec = (XAAudioCodec *) base; + + /* ...command is allowed only in "postinit" state */ + XF_CHK_ERR(base->state & XA_BASE_FLAG_POSTINIT, XA_API_FATAL_INVALID_CMD); + + /* ...make sure output port is addressed */ + XF_CHK_ERR(XF_MSG_DST_PORT(m->id) == 1, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...cancel any pending processing */ + xa_base_cancel(base); + + /* ...clear output-port-setup condition */ + base->state &= ~XA_CODEC_FLAG_OUTPUT_SETUP; + + /* ...pass flush command down the graph */ + if (xf_output_port_flush(&codec->output, XF_FLUSH)) + { + TRACE(INFO, _b("port is idle; instantly unroute")); + + /* ...flushing sequence is not needed; command may be satisfied instantly */ + xf_output_port_unroute(&codec->output); + + /* ...pass response to the proxy */ + xf_response_ok(m); + } + else + { + TRACE(INFO, _b("port is busy; propagate unroute command")); + + /* ...flushing sequence is started; save flow-control message */ + xf_output_port_unroute_start(&codec->output, m); + } + + return XA_NO_ERROR; +} + +/* ...FLUSH command processing */ +static XA_ERRORCODE xa_codec_flush(XACodecBase *base, xf_message_t *m) +{ + XAAudioCodec *codec = (XAAudioCodec *) base; + + /* ...command is allowed only in "postinit" state */ + XF_CHK_ERR(base->state & XA_BASE_FLAG_POSTINIT, XA_API_FATAL_INVALID_CMD); + + /* ...ensure input parameter length is zero */ + XF_CHK_ERR(m->length == 0, XA_API_FATAL_INVALID_CMD_TYPE); + + TRACE(1, _b("flush command received")); + + /* ...flush command must be addressed to input port */ + if (XF_MSG_DST_PORT(m->id) == 0) + { + /* ...cancel data processing message if needed */ + xa_base_cancel(base); + + /* ...input port flushing; purge content of input buffer */ + xf_input_port_purge(&codec->input); + + /* ...clear input-ready condition */ + base->state &= ~XA_CODEC_FLAG_INPUT_SETUP; + + /* ...reset execution runtime */ + XA_API(base, XA_API_CMD_EXECUTE, XA_CMD_TYPE_DO_RUNTIME_INIT, NULL); + + /* ...reset produced samples counter */ + codec->produced = 0; + + /* ...propagate flushing command to output port */ + if (xf_output_port_flush(&codec->output, XF_FLUSH)) + { + /* ...flushing sequence is not needed; satisfy command instantly */ + xf_response(m); + } + else + { + /* ...flushing sequence is started; save flow-control message at input port */ + xf_input_port_control_save(&codec->input, m); + } + } + else if (xf_output_port_unrouting(&codec->output)) + { + /* ...flushing during port unrouting; complete unroute sequence */ + xf_output_port_unroute_done(&codec->output); + + TRACE(INFO, _b("port is unrouted")); + } + else + { + /* ...output port flush command/response; check if the port is routed */ + if (!xf_output_port_routed(&codec->output)) + { + /* ...complete all queued messages */ + xf_output_port_flush(&codec->output, XF_FLUSH); + + /* ...and pass response to flushing command */ + xf_response(m); + } + else + { + /* ...response to flushing command received */ + BUG(m != xf_output_port_control_msg(&codec->output), _x("invalid message: %p"), m); + + /* ...mark flushing sequence is completed */ + xf_output_port_flush_done(&codec->output); + + /* ...complete original flow-control command */ + xf_input_port_purge_done(&codec->input); + } + + /* ...clear output-setup condition */ + base->state &= ~XA_CODEC_FLAG_OUTPUT_SETUP; + } + + return XA_NO_ERROR; +} + +/******************************************************************************* + * Generic codec API + ******************************************************************************/ + +/* ...memory buffer handling */ +static XA_ERRORCODE xa_codec_memtab(XACodecBase *base, WORD32 idx, WORD32 type, WORD32 size, WORD32 align, u32 core) +{ + XAAudioCodec *codec = (XAAudioCodec *) base; + + if (type == XA_MEMTYPE_INPUT) + { + /* ...input port specification; allocate internal buffer */ + XF_CHK_ERR(xf_input_port_init(&codec->input, size, align, core) == 0, XA_API_FATAL_MEM_ALLOC); + + /* ...save input port index */ + codec->in_idx = idx; + + /* ...set input buffer pointer as needed */ + (size ? XA_API(base, XA_API_CMD_SET_MEM_PTR, idx, codec->input.buffer) : 0); + + (size ? TRACE(1, _x("set input ptr: %p"), codec->input.buffer) : 0); + } + else + { + /* ...output buffer specification */ + XF_CHK_ERR(type == XA_MEMTYPE_OUTPUT, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...initialize output port queue (no allocation here yet) */ + XF_CHK_ERR(xf_output_port_init(&codec->output, size) == 0, XA_API_FATAL_MEM_ALLOC); + + /* ...save output port index */ + codec->out_idx = idx; + } + + return XA_NO_ERROR; +} + +/* ...prepare input/output buffers */ +static XA_ERRORCODE xa_codec_preprocess(XACodecBase *base) +{ + XAAudioCodec *codec = (XAAudioCodec *) base; + + /* ...prepare output buffer if needed */ + if (!(base->state & XA_CODEC_FLAG_OUTPUT_SETUP)) + { + void *output; + + /* ...get output buffer from port, if possible */ + if (base->state & XA_BASE_FLAG_RUNTIME_INIT) + { + /* ...run-time is not initialized yet; use scratch buffer */ + output = base->scratch; + } + else if ((output = xf_output_port_data(&codec->output)) == NULL) + { + /* ...no output buffer available */ + return XA_CODEC_EXEC_NO_DATA; + } + + /* ...set the output buffer pointer */ + XA_API(base, XA_API_CMD_SET_MEM_PTR, codec->out_idx, output); + + TRACE(1, _x("set output ptr: %p"), output); + + /* ...mark output port is setup */ + base->state ^= XA_CODEC_FLAG_OUTPUT_SETUP; + } + + /* ...prepare input data if needed */ + if (!(base->state & XA_CODEC_FLAG_INPUT_SETUP)) + { + void *input; + u32 filled; + + /* ...fill input buffer */ + if (xf_input_port_bypass(&codec->input)) + { + /* ...use input buffer directly; check if there is data available */ + if ((input = xf_input_port_data(&codec->input)) != NULL) + { + /* ...set input data buffer pointer */ + XA_API(base, XA_API_CMD_SET_MEM_PTR, codec->in_idx, input); + + /* ...retrieve number of input bytes */ + filled = xf_input_port_length(&codec->input); + } + else if (!xf_input_port_done(&codec->input)) + { + /* ...return non-fatal indication to prevent further processing */ + return XA_CODEC_EXEC_NO_DATA; + } + else + { + /* ...mark we have no data in current buffer */ + filled = 0; + } + } + else + { + /* ...port is in non-bypass mode; try to fill internal buffer */ + if (xf_input_port_done(&codec->input) || xf_input_port_fill(&codec->input)) + { + /* ...retrieve number of bytes in input buffer (not really - tbd) */ + filled = xf_input_port_level(&codec->input); + } + else + { + /* ...return non-fatal indication to prevent further processing */ + return XA_CODEC_EXEC_NO_DATA; + } + } + + /* ...check if input stream is over */ + if (xf_input_port_done(&codec->input)) + { + /* ...pass input-over command to the codec to indicate the final buffer */ + XA_API(base, XA_API_CMD_INPUT_OVER, codec->in_idx, NULL); + + TRACE(INFO, _b("codec[%p]: signal input-over (filled: %u)"), codec, filled); + } + + TRACE(INPUT, _b("input-buffer fill-level: %u bytes"), filled); + + /* ...specify number of bytes available in the input buffer */ + XA_API(base, XA_API_CMD_SET_INPUT_BYTES, codec->in_idx, &filled); + + /* ...mark input port is setup */ + base->state ^= XA_CODEC_FLAG_INPUT_SETUP; + } + + return XA_NO_ERROR; +} + +/* ...post-processing operation; input/output ports maintenance */ +static XA_ERRORCODE xa_codec_postprocess(XACodecBase *base, int done) +{ + XAAudioCodec *codec = (XAAudioCodec *) base; + WORD32 consumed = 0; + WORD32 produced = 0; + + /* ...get number of consumed / produced bytes */ + XA_API(base, XA_API_CMD_GET_CURIDX_INPUT_BUF, codec->in_idx, &consumed); + + /* ...get number of produced bytes only if runtime is initialized (sample size is known) */ + (codec->sample_size ? XA_API(base, XA_API_CMD_GET_OUTPUT_BYTES, codec->out_idx, &produced) : 0); + + TRACE(DECODE, _b("codec[%p]::postprocess(c=%u, p=%u, d=%u)"), codec, consumed, produced, done); + + /* ...input buffer maintenance; check if we consumed anything */ + if (consumed) + { + /* ...consume specified number of bytes from input port */ + xf_input_port_consume(&codec->input, consumed); + + /* ...clear input-setup flag */ + base->state ^= XA_CODEC_FLAG_INPUT_SETUP; + } + + /* ...output buffer maintenance; check if we have produced anything */ + if (produced) + { + /* ...increment total number of produced samples (really don't like division here - tbd) */ + codec->produced += produced / codec->sample_size; + + /* ...immediately complete output buffer (don't wait until it gets filled) */ + xf_output_port_produce(&codec->output, produced); + + /* ...clear output port setup flag */ + base->state ^= XA_CODEC_FLAG_OUTPUT_SETUP; + } + + /* ...process execution stage transition */ + if (done) + { + if (base->state & XA_BASE_FLAG_RUNTIME_INIT) + { + /* ...stream is completed while codec is in runtime initialization stage */ + BUG(1, _x("breakpoint")); + } + else if (base->state & XA_BASE_FLAG_EXECUTION) + { + /* ...runtime initialization done */ + XA_CHK(xa_codec_prepare_runtime(codec)); + + /* ...clear output port setup flag as we were using scratch buffer; + * technically, no need to repeat setup of input buffer, but some codecs require + * it as well + */ + base->state &= ~(XA_CODEC_FLAG_INPUT_SETUP | XA_CODEC_FLAG_OUTPUT_SETUP); + } + else + { + /* ...output stream is over; propagate condition to sink port */ + if (xf_output_port_flush(&codec->output, XF_FILL_THIS_BUFFER)) + { + /* ...flushing sequence is not needed; complete pending zero-length input */ + xf_input_port_purge(&codec->input); + + /* ...no propagation to output port */ + TRACE(INFO, _b("codec[%p] playback completed"), codec); + } + else + { + /* ...flushing sequence is started; wait until flow-control message returns */ + TRACE(INFO, _b("propagate end-of-stream condition")); + } + } + + /* ...return early to prevent task rescheduling */ + return XA_NO_ERROR; + } + + /* ...reschedule processing if needed */ + if (xf_input_port_ready(&codec->input) && xf_output_port_ready(&codec->output)) + { + /* ...schedule data processing with respect to its urgency */ + xa_base_schedule(base, produced * codec->factor); + } + + return XA_NO_ERROR; +} + +/* ...configuration parameter retrieval */ +static XA_ERRORCODE xa_codec_getparam(XACodecBase *base, WORD32 id, pVOID value) +{ + XAAudioCodec *codec = (XAAudioCodec *) base; + + if (id == XA_CODEC_CONFIG_PARAM_PRODUCED) + { + /* ...retrieve number of produced samples since last reset */ + *(u32 *)value = codec->produced; + + return XA_NO_ERROR; + } + else + { + /* ...pass command to underlying codec plugin */ + return XA_API(base, XA_API_CMD_GET_CONFIG_PARAM, id, value); + } +} + +/******************************************************************************* + * Component entry point + ******************************************************************************/ + +/* ...command hooks */ +static XA_ERRORCODE (* const xa_codec_cmd[])(XACodecBase *, xf_message_t *) = +{ + [XF_OPCODE_TYPE(XF_SET_PARAM)] = xa_base_set_param, + [XF_OPCODE_TYPE(XF_GET_PARAM)] = xa_base_get_param, + [XF_OPCODE_TYPE(XF_ROUTE)] = xa_codec_port_route, + [XF_OPCODE_TYPE(XF_UNROUTE)] = xa_codec_port_unroute, + [XF_OPCODE_TYPE(XF_EMPTY_THIS_BUFFER)] = xa_codec_empty_this_buffer, + [XF_OPCODE_TYPE(XF_FILL_THIS_BUFFER)] = xa_codec_fill_this_buffer, + [XF_OPCODE_TYPE(XF_FLUSH)] = xa_codec_flush, + [XF_OPCODE_TYPE(XF_SET_PARAM_EXT)] = xa_base_set_param_ext, + [XF_OPCODE_TYPE(XF_GET_PARAM_EXT)] = xa_base_get_param_ext, +}; + +/* ...total number of commands supported */ +#define XA_CODEC_CMD_NUM (sizeof(xa_codec_cmd) / sizeof(xa_codec_cmd[0])) + +/* ...command processor for termination state (only for routed port case) */ +static int xa_audio_codec_terminate(xf_component_t *component, xf_message_t *m) +{ + XAAudioCodec *codec = (XAAudioCodec *) component; + u32 opcode = m->opcode; + + /* ...check if we received output port control message */ + if (m == xf_output_port_control_msg(&codec->output)) + { + /* ...output port flushing complete; mark port is idle and terminate */ + xf_output_port_flush_done(&codec->output); + return -1; + } + else if (opcode == XF_FILL_THIS_BUFFER) + { + /* ...output buffer returned by the sink component; ignore and keep waiting */ + TRACE(OUTPUT, _b("collect output buffer")); + return 0; + } + else if (opcode == XF_UNREGISTER) + { + /* ...ignore subsequent unregister command/response - tbd */ + return 0; + } + else + { + /* ...everything else is responded with generic failure */ + xf_response_err(m); + return 0; + } +} + +/* ...audio codec destructor */ +static int xa_audio_codec_destroy(xf_component_t *component, xf_message_t *m) +{ + XAAudioCodec *codec = (XAAudioCodec *) component; + u32 core = xf_component_core(component); + + /* ...destroy input port */ + xf_input_port_destroy(&codec->input, core); + + /* ...destroy output port */ + xf_output_port_destroy(&codec->output, core); + + /* ...deallocate all resources */ + xa_base_destroy(&codec->base, XF_MM(sizeof(*codec)), core); + + TRACE(INIT, _b("audio-codec[%p@%u] destroyed"), codec, core); + + /* ...indicate the client has been destroyed */ + return 0; +} + +/* ...audio codec destructor - first stage (ports unrouting) */ +static int xa_audio_codec_cleanup(xf_component_t *component, xf_message_t *m) +{ + XAAudioCodec *codec = (XAAudioCodec *) component; + + /* ...complete message with error response */ + xf_response_err(m); + + /* ...cancel internal scheduling message if needed */ + xa_base_cancel(&codec->base); + + /* ...purge input port (returns OK? pretty strange at this point - tbd) */ + xf_input_port_purge(&codec->input); + + /* ...propagate unregister command to connected component */ + if (xf_output_port_flush(&codec->output, XF_FLUSH)) + { + /* ...flushing sequence is not needed; destroy audio codec */ + return xa_audio_codec_destroy(component, NULL); + } + else + { + /* ...wait until output port is cleaned; adjust component hooks */ + component->entry = xa_audio_codec_terminate; + component->exit = xa_audio_codec_destroy; + + TRACE(INIT, _b("codec[%p] cleanup sequence started"), codec); + + /* ...indicate that second stage is required */ + return 1; + } +} + +/******************************************************************************* + * Audio codec component factory + ******************************************************************************/ + +xf_component_t * xa_audio_codec_factory(u32 core, xa_codec_func_t process) +{ + XAAudioCodec *codec; + + /* ...allocate local memory for codec structure */ + XF_CHK_ERR(codec = (XAAudioCodec *) xa_base_factory(core, XF_MM(sizeof(*codec)), process), NULL); + + /* ...set base codec API methods */ + codec->base.memtab = xa_codec_memtab; + codec->base.preprocess = xa_codec_preprocess; + codec->base.postprocess = xa_codec_postprocess; + codec->base.getparam = xa_codec_getparam; + + /* ...set message commands processing table */ + codec->base.command = xa_codec_cmd; + codec->base.command_num = XA_CODEC_CMD_NUM; + + /* ...set component destructor hook */ + codec->base.component.exit = xa_audio_codec_cleanup; + + TRACE(INIT, _b("Codec[%p] initialized"), codec); + + return (xf_component_t *) codec; +} diff --git a/hifi/xaf/hifi-dpf/audio/xa-class-base.c b/hifi/xaf/hifi-dpf/audio/xa-class-base.c new file mode 100644 index 00000000..ef1110e6 --- /dev/null +++ b/hifi/xaf/hifi-dpf/audio/xa-class-base.c @@ -0,0 +1,537 @@ +/******************************************************************************* +* 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-class-base.c + * + * Generic audio codec task implementation + * + ******************************************************************************/ + +#define MODULE_TAG BASE + +/******************************************************************************* + * Includes + ******************************************************************************/ + +#include "xf.h" +#include "xa-class-base.h" + +/******************************************************************************* + * Tracing configuration + ******************************************************************************/ + +TRACE_TAG(INIT, 1); +TRACE_TAG(WARNING, 1); +TRACE_TAG(SETUP, 1); +TRACE_TAG(EXEC, 1); + +/******************************************************************************* + * Internal functions definitions + ******************************************************************************/ + +/* ...codec pre-initialization */ +static XA_ERRORCODE xa_base_preinit(XACodecBase *base, u32 core) +{ + WORD32 n; + + /* ...codec must be empty */ + XF_CHK_ERR(base->state == 0, XA_API_FATAL_INVALID_CMD); + + /* ...get API structure size */ + XA_API(base, XA_API_CMD_GET_API_SIZE, 0, &n); + + /* ...allocate memory for codec API structure (4-bytes aligned) */ + XMALLOC(&base->api, n, 4, core); + + /* ...set default config parameters */ + XA_API(base, XA_API_CMD_INIT, XA_CMD_TYPE_INIT_API_PRE_CONFIG_PARAMS, NULL); + + /* ...get memory info tables size */ + if (XA_API(base, XA_API_CMD_GET_MEMTABS_SIZE, 0, &n), n != 0) + { + /* ...allocate memory for tables (4-bytes aligned) */ + XMALLOC(&base->mem_tabs, n, 4, core); + + /* ...set pointer for process memory tables */ + XA_API(base, XA_API_CMD_SET_MEMTABS_PTR, 0, base->mem_tabs.addr); + } + + TRACE(INIT, _b("Codec[%p] pre-initialization completed"), base); + + return XA_NO_ERROR; +} + +/* ...post-initialization setup */ +static XA_ERRORCODE xa_base_postinit(XACodecBase *base, u32 core) +{ + WORD32 n, i; + + /* ...issue post-config command and determine the buffer requirements */ + XA_API(base, XA_API_CMD_INIT, XA_CMD_TYPE_INIT_API_POST_CONFIG_PARAMS, NULL); + + /* ...get number of memory tables required */ + XA_API(base, XA_API_CMD_GET_N_MEMTABS, 0, &n); + + /* ...set scratch buffer in advance (as codec not necessarily exposes it) */ + base->scratch = XF_CORE_DATA(core)->scratch; + + /* ...allocate memory buffers */ + for (i = 0; i < n; i++) + { + WORD32 size, align, type; + + TRACE(1, _b("i = %u (of %u)"), (u32)i, (u32)n); + + /* ...get memory type */ + XA_API(base, XA_API_CMD_GET_MEM_INFO_TYPE, i, &type); + + /* ...get memory size of i-th buffer */ + XA_API(base, XA_API_CMD_GET_MEM_INFO_SIZE, i, &size); + + /* ...get alignment */ + XA_API(base, XA_API_CMD_GET_MEM_INFO_ALIGNMENT, i, &align); + + /* ...process individual buffer */ + switch (type) + { + case XA_MEMTYPE_SCRATCH: + /* ...scratch memory is shared among all codecs; check its validity */ + XF_CHK_ERR(size <= XF_CFG_CODEC_SCRATCHMEM_SIZE, XA_API_FATAL_MEM_ALLOC); + + /* ...make sure alignment is valid */ + XF_CHK_ERR((XF_CFG_CODEC_SCRATCHMEM_ALIGN & (align - 1)) == 0, XA_API_FATAL_MEM_ALIGN); + + /* ...set the scratch memory pointer */ + XA_API(base, XA_API_CMD_SET_MEM_PTR, i, base->scratch); + + TRACE(INIT, _b("Mem tab %d: sz=%d al=%d ty=%d Scratch memory (%p)"), i, size, align, type, base->scratch); + + break; + + case XA_MEMTYPE_PERSIST: + /* ...allocate persistent memory */ + XMALLOC(&base->persist, size, align, core); + + /* ...and set the pointer instantly */ + XA_API(base, XA_API_CMD_SET_MEM_PTR, i, base->persist.addr); + + TRACE(INIT, _b("Mem tab %d: sz=%d al=%d ty=%d Persistent memory (%p)"), i, size, align, type, base->persist.addr); + + break; + + case XA_MEMTYPE_INPUT: + case XA_MEMTYPE_OUTPUT: + /* ...input/output buffer specification; pass to codec function */ + CODEC_API(base, memtab, i, type, size, align, core); + + break; + + default: + /* ...unrecognized memory type */ + TRACE(ERROR, _x("Invalid memory type: [%d]=(%u, %u, %u)"), i, type, size, align); + return XA_API_FATAL_INVALID_CMD_TYPE; + } + } + + TRACE(INIT, _b("Codec[%p] post-initialization completed (api:%p[%u])"), base, base->api.addr, base->api.size); + + return XA_NO_ERROR; +} + +/******************************************************************************* + * Commands processing + ******************************************************************************/ + +/* ...SET-PARAM processing (enabled in all states) */ +XA_ERRORCODE xa_base_set_param(XACodecBase *base, xf_message_t *m) +{ + xf_set_param_msg_t *cmd = m->buffer; + xf_set_param_item_t *param = &cmd->item[0]; + WORD32 n, i; + + /* ...calculate total amount of parameters */ + n = m->length / sizeof(*param); + + /* ...check the message length is valid */ + XF_CHK_ERR(m->length == XF_SET_PARAM_CMD_LEN(n), XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...apply all parameters; pass to codec-specific function */ + for (i = 0; i < n; i++) + { + TRACE(SETUP, _b("set-param[%p]: [%u]=%u"), base, param[i].id, param[i].value); + + if (base->setparam) + { + CODEC_API(base, setparam, param[i].id, ¶m[i].value); + } + else + { + XA_API(base, XA_API_CMD_SET_CONFIG_PARAM, param[i].id, ¶m[i].value); + } + } + + /* ...check if we need to do post-initialization */ + if ((base->state & XA_BASE_FLAG_POSTINIT) == 0) + { + /* ...do post-initialization step */ + XA_CHK(xa_base_postinit(base, XF_MSG_DST_CORE(m->id))); + + /* ...mark the codec static configuration is set */ + base->state ^= XA_BASE_FLAG_POSTINIT | XA_BASE_FLAG_RUNTIME_INIT; + } + + /* ...complete message processing; output buffer is empty */ + xf_response_ok(m); + + return XA_NO_ERROR; +} + +/* ...GET-PARAM message processing (enabled in all states) */ +XA_ERRORCODE xa_base_get_param(XACodecBase *base, xf_message_t *m) +{ + xf_get_param_msg_t *cmd = m->buffer; + u32 *id = &cmd->c.id[0]; + u32 *value = &cmd->r.value[0]; + u32 n, i; + + /* ...calculate amount of parameters */ + n = m->length / sizeof(*id); + + /* ...check input parameter length */ + XF_CHK_ERR(XF_GET_PARAM_CMD_LEN(n) == m->length, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...retrieve the collection of codec parameters */ + for (i = 0; i < n; i++) + { + /* ...place the result into same location */ + if (base->getparam) + { + CODEC_API(base, getparam, id[i], &value[i]); + } + else + { + XA_API(base, XA_API_CMD_GET_CONFIG_PARAM, id[i], &value[i]); + } + } + + /* ...complete message specifying output buffer size */ + xf_response_data(m, XF_GET_PARAM_RSP_LEN(n)); + + return XA_NO_ERROR; +} + +/* ...SET-PARAM-EXT processing (enabled in all states) */ +XA_ERRORCODE xa_base_set_param_ext(XACodecBase *base, xf_message_t *m) +{ + xf_ext_param_msg_t *cmd = m->buffer; + u16 length = m->length; + u16 remaining = (length + 3) & ~3; + u16 i; + + for (i = 0; TRACE_CFG(SETUP) && i < remaining; i += 16) + { + TRACE(SETUP, _b("[%03x]: %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X"), + i, + ((u8 *)m->buffer)[i + 0], ((u8 *)m->buffer)[i + 1], + ((u8 *)m->buffer)[i + 2], ((u8 *)m->buffer)[i + 3], + ((u8 *)m->buffer)[i + 4], ((u8 *)m->buffer)[i + 5], + ((u8 *)m->buffer)[i + 6], ((u8 *)m->buffer)[i + 7], + ((u8 *)m->buffer)[i + 8], ((u8 *)m->buffer)[i + 9], + ((u8 *)m->buffer)[i + 10], ((u8 *)m->buffer)[i + 11], + ((u8 *)m->buffer)[i + 12], ((u8 *)m->buffer)[i + 13], + ((u8 *)m->buffer)[i + 14], ((u8 *)m->buffer)[i + 15]); + } + + /* ...process all parameters encapsulated in buffer */ + while (remaining >= sizeof(*cmd)) + { + u16 id = cmd->desc.id; + u16 dlen = cmd->desc.length; + u16 dsize = (dlen + 3) & ~3; + u16 pad = dlen & 3; + + /* ...cut-off descriptor header */ + remaining -= sizeof(*cmd); + + TRACE(SETUP, _b("remaining:%u, desc_size:%u"), (u32)remaining, (u32)dsize); + + /* ...make sure length is sufficient */ + XF_CHK_ERR(remaining >= dsize, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...pad remaining bytes with zeroes */ + (pad ? memset(cmd->data + dlen, 0, 4 - pad) : 0); + + TRACE(SETUP, _b("set-ext-param[%p]: [%u]:%u - [%02X:%02X:%02X:%02X:...]"), base, id, dsize, cmd->data[0], cmd->data[1], cmd->data[2], cmd->data[3]); + + /* ...apply parameter */ + XA_API(base, XA_API_CMD_SET_CONFIG_PARAM, id, cmd->data); + + /* ...move to next item (keep 4-bytes alignment for descriptor) */ + cmd = (xf_ext_param_msg_t *)(&cmd->data[0] + dsize), remaining -= dsize; + } + + /* ...check the message is fully processed */ + XF_CHK_ERR(remaining == 0, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...complete message processing; output buffer is empty */ + //xf_response_ok(m); + + /* ...unfortunately, it looks like a bug of the library that updates the memory + * and leaves it in a dirty state causing subsequent cache inconsistency - tbd + */ + xf_response_data(m, length); + + return XA_NO_ERROR; +} + +/* ...GET-PARAM-EXT message processing (enabled in all states) */ +XA_ERRORCODE xa_base_get_param_ext(XACodecBase *base, xf_message_t *m) +{ + xf_ext_param_msg_t *cmd = m->buffer; + u32 length = m->length; + u32 remaining = (length + 3) & ~3; + int i; + + for (i = 0; TRACE_CFG(SETUP) && i < remaining; i += 16) + { + TRACE(SETUP, _b("[%03x]: %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X"), + i, + ((u8 *)m->buffer)[i + 0], ((u8 *)m->buffer)[i + 1], + ((u8 *)m->buffer)[i + 2], ((u8 *)m->buffer)[i + 3], + ((u8 *)m->buffer)[i + 4], ((u8 *)m->buffer)[i + 5], + ((u8 *)m->buffer)[i + 6], ((u8 *)m->buffer)[i + 7], + ((u8 *)m->buffer)[i + 8], ((u8 *)m->buffer)[i + 9], + ((u8 *)m->buffer)[i + 10], ((u8 *)m->buffer)[i + 11], + ((u8 *)m->buffer)[i + 12], ((u8 *)m->buffer)[i + 13], + ((u8 *)m->buffer)[i + 14], ((u8 *)m->buffer)[i + 15]); + } + + /* ...process all parameters encapsulated in buffer */ + while (remaining >= sizeof(*cmd)) + { + u16 id = cmd->desc.id; + u16 len = cmd->desc.length; + u16 size = (len + 3) & ~3; + u8 pad = len & 3; + + /* ...cut-off command header */ + remaining -= sizeof(*cmd); + + /* ...make sure data buffer has sufficient length */ + XF_CHK_ERR(remaining >= size, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...retrieve parameter from buffer (care about alignment? - tbd) */ + XA_API(base, XA_API_CMD_GET_CONFIG_PARAM, id, cmd->data); + + /* ...pad remaininig bytes with zeroes */ + (pad ? memset(cmd->data + len, 0, 4 - pad) : 0); + + TRACE(SETUP, _b("get-ext-param[%p]: [%u]:%u - [%02X:%02X:%02X:%02X:...]"), base, id, size, cmd->data[0], cmd->data[1], cmd->data[2], cmd->data[3]); + + /* ...move to next item (alignment issues? - tbd) */ + cmd = (xf_ext_param_msg_t *)(&cmd->data[0] + size), remaining -= size; + } + + /* ...check the message is fully processed */ + XF_CHK_ERR(remaining == 0, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...complete message processing; output buffer has the same length */ + xf_response_data(m, length); + + return XA_NO_ERROR; +} + +/******************************************************************************* + * Command/data processing functions + ******************************************************************************/ + +/* ...generic codec data processing */ +static XA_ERRORCODE xa_base_process(XACodecBase *base) +{ + XA_ERRORCODE error; + WORD32 done; + + /* ...clear internal scheduling flag */ + base->state &= ~XA_BASE_FLAG_SCHEDULE; + + /* ...codec-specific preprocessing (buffer maintenance) */ + if ((error = CODEC_API(base, preprocess)) != XA_NO_ERROR) + { + /* ...return non-fatal codec error */ + return error; + } + + /* ...execution step */ + if (base->state & XA_BASE_FLAG_RUNTIME_INIT) + { + /* ...kick initialization process */ + XA_API(base, XA_API_CMD_INIT, XA_CMD_TYPE_INIT_PROCESS, NULL); + + /* ...check if initialization is completed */ + XA_API(base, XA_API_CMD_INIT, XA_CMD_TYPE_INIT_DONE_QUERY, &done); + + TRACE(EXEC, _b("Initialization result: %d"), done); + + /* ...switch to execution state if required */ + (done ? base->state ^= XA_BASE_FLAG_RUNTIME_INIT | XA_BASE_FLAG_EXECUTION : 0); + } + else if (base->state & XA_BASE_FLAG_EXECUTION) + { + TRACE(1, _b("do exec")); + + /* ...execute decoding process */ + XA_API(base, XA_API_CMD_EXECUTE, XA_CMD_TYPE_DO_EXECUTE, NULL); + + /* ...check for end-of-stream condition */ + XA_API(base, XA_API_CMD_EXECUTE, XA_CMD_TYPE_DONE_QUERY, &done); + + TRACE(EXEC, _b("Execution result: %d"), done); + + /* ...mark the output path is done to release all queued buffers */ + (done ? base->state ^= XA_BASE_FLAG_EXECUTION | XA_BASE_FLAG_COMPLETED : 0); + } + + /* ...codec-specific buffer post-processing */ + return CODEC_API(base, postprocess, done); +} + +/* ...message-processing function (component entry point) */ +static int xa_base_command(xf_component_t *component, xf_message_t *m) +{ + XACodecBase *base = (XACodecBase *) component; + u32 cmd; + + /* ...invoke data-processing function if message is null */ + if (m == NULL) + { + XF_CHK_ERR(!XA_ERROR_SEVERITY(xa_base_process(base)), -EPIPE); + return 0; + } + + /* ...process the command */ + TRACE(EXEC, _b("[%p]:state[%X]:(%X, %d, %p)"), base, base->state, m->opcode, m->length, m->buffer); + + /* ...bail out if this is forced termination command (I do have a map; maybe I'd better have a hook? - tbd) */ + if ((cmd = XF_OPCODE_TYPE(m->opcode)) == XF_OPCODE_TYPE(XF_UNREGISTER)) + { + TRACE(INIT, _b("force component[%p] termination"), base); + return -1; + } + + /* ...check opcode is valid */ + XF_CHK_ERR(cmd < base->command_num, -EINVAL); + + /* ...and has a hook */ + XF_CHK_ERR(base->command[cmd] != NULL, -EINVAL); + + /* ...pass control to specific command */ + XF_CHK_ERR(!XA_ERROR_SEVERITY(base->command[cmd](base, m)), -EPIPE); + + /* ...execution completed successfully */ + return 0; +} + +/******************************************************************************* + * Base codec API + ******************************************************************************/ + +/* ...data processing scheduling */ +void xa_base_schedule(XACodecBase *base, u32 dts) +{ + if ((base->state & XA_BASE_FLAG_SCHEDULE) == 0) + { + /* ...schedule component task execution */ + xf_component_schedule(&base->component, dts); + + /* ...and put scheduling flag */ + base->state ^= XA_BASE_FLAG_SCHEDULE; + } + else + { + TRACE(EXEC, _b("codec[%p] processing pending"), base); + } +} + +/* ...cancel data processing */ +void xa_base_cancel(XACodecBase *base) +{ + if (base->state & XA_BASE_FLAG_SCHEDULE) + { + /* ...cancel scheduled codec task */ + xf_component_cancel(&base->component); + + /* ...and clear scheduling flag */ + base->state ^= XA_BASE_FLAG_SCHEDULE; + + TRACE(EXEC, _b("codec[%p] processing cancelled"), base); + } +} + +/* ...base codec destructor */ +void xa_base_destroy(XACodecBase *base, u32 size, u32 core) +{ + /* ...deallocate all resources */ + xf_mm_free_buffer(&base->persist, core); + xf_mm_free_buffer(&base->mem_tabs, core); + xf_mm_free_buffer(&base->api, core); + + /* ...destroy codec structure (and task) itself */ + xf_mem_free(base, size, core, 0); + + TRACE(INIT, _b("codec[%p]:%u destroyed"), base, core); +} + +/* ...generic codec initialization routine */ +XACodecBase * xa_base_factory(u32 core, u32 size, xa_codec_func_t process) +{ + XACodecBase *base; + + /* ...make sure the size is valid */ + XF_CHK_ERR(size >= sizeof(XACodecBase), NULL); + + /* ...allocate local memory for codec structure */ + XF_CHK_ERR(base = xf_mem_alloc(size, 0, core, 0), NULL); + + /* ...reset codec memory */ + memset(base, 0, size); + + /* ...set low-level codec API function */ + base->process = process; + + /* ...set message processing function */ + base->component.entry = xa_base_command; + + /* ...do basic initialization */ + if (xa_base_preinit(base, core) != XA_NO_ERROR) + { + /* ...initialization failed for some reason; do cleanup */ + xa_base_destroy(base, size, core); + + return NULL; + } + + /* ...initialization completed successfully */ + TRACE(INIT, _b("Codec[%p]:%u initialized"), base, core); + + return base; +} diff --git a/hifi/xaf/hifi-dpf/audio/xa-class-base.h b/hifi/xaf/hifi-dpf/audio/xa-class-base.h new file mode 100644 index 00000000..252044d4 --- /dev/null +++ b/hifi/xaf/hifi-dpf/audio/xa-class-base.h @@ -0,0 +1,263 @@ +/******************************************************************************* +* 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-class-base.h + * + * Generic Xtensa Audio codecs interfaces + * + ******************************************************************************/ + +#ifndef __XA_CLASS_BASE_H +#define __XA_CLASS_BASE_H + +/******************************************************************************* + * Includes + ******************************************************************************/ + +/* ...audio-specific API */ +#include "audio/xa_type_def.h" +#include "audio/xa_error_standards.h" +#include "audio/xa_apicmd_standards.h" +#include "audio/xa_memory_standards.h" + +/******************************************************************************* + * Generic codec structure + ******************************************************************************/ + +typedef struct XACodecBase XACodecBase; + +/* ...memory buffer initialization */ +typedef XA_ERRORCODE (*xa_codec_memtab_f)(XACodecBase *codec, WORD32 i, WORD32 type, WORD32 size, WORD32 align, u32 core); + +/* ...preprocessing operation */ +typedef XA_ERRORCODE (*xa_codec_preprocess_f)(XACodecBase *); + +/* ...postprocessing operation */ +typedef XA_ERRORCODE (*xa_codec_postprocess_f)(XACodecBase *, int); + +/* ...parameter setting function */ +typedef XA_ERRORCODE (*xa_codec_setparam_f)(XACodecBase *, WORD32, pVOID p); + +/* ...parameter retrival function */ +typedef XA_ERRORCODE (*xa_codec_getparam_f)(XACodecBase *, WORD32, pVOID p); + +/******************************************************************************* + * Codec instance structure + ******************************************************************************/ + +struct XACodecBase +{ + /*************************************************************************** + * Control data + **************************************************************************/ + + /* ...generic component handle */ + xf_component_t component; + + /* ...codec API entry point (function) */ + xa_codec_func_t *process; + + /* ...codec API handle, passed to *process */ + xf_mm_buffer_t api; + + /* ...memory table buffer */ + xf_mm_buffer_t mem_tabs; + + /* ...persistent memory buffer */ + xf_mm_buffer_t persist; + + /* ...scratch memory pointer */ + void *scratch; + + /* ...codec control state */ + u32 state; + + /*************************************************************************** + * Codec-specific methods + **************************************************************************/ + + /* ...memory buffer initialization */ + xa_codec_memtab_f memtab; + + /* ...preprocessing function */ + xa_codec_preprocess_f preprocess; + + /* ...postprocessing function */ + xa_codec_postprocess_f postprocess; + + /* ...configuration parameter setting function */ + xa_codec_setparam_f setparam; + + /* ...configuration parameter retrieval function */ + xa_codec_getparam_f getparam; + + /* ...command-processing table */ + XA_ERRORCODE (* const * command)(XACodecBase *, xf_message_t *); + + /* ...command-processing table size */ + u32 command_num; +}; + +/******************************************************************************* + * Base codec execution flags + ******************************************************************************/ + +/* ...codec static initialization completed */ +#define XA_BASE_FLAG_POSTINIT (1 << 0) + +/* ...codec runtime initialization sequence */ +#define XA_BASE_FLAG_RUNTIME_INIT (1 << 1) + +/* ...codec steady execution state */ +#define XA_BASE_FLAG_EXECUTION (1 << 2) + +/* ...execution stage completed */ +#define XA_BASE_FLAG_COMPLETED (1 << 3) + +/* ...data processing scheduling flag */ +#define XA_BASE_FLAG_SCHEDULE (1 << 4) + +/* ...base codec flags accessor */ +#define __XA_BASE_FLAGS(flags) ((flags) & ((1 << 5) - 1)) + +/* ...custom execution flag */ +#define __XA_BASE_FLAG(f) ((f) << 5) + +/******************************************************************************* + * Local macros definitions + ******************************************************************************/ + +/* ...audio-framework API function execution */ +#define XA_CHK(cond) \ +({ \ + XA_ERRORCODE __e = (cond); \ + if (__e != XA_NO_ERROR) \ + { \ + if (XA_ERROR_SEVERITY(__e)) \ + { \ + TRACE(ERROR, _x("error: %X"), __e); \ + return __e; \ + } \ + TRACE(WARNING, _x("warning: %X"), __e); \ + } \ + __e; \ +}) + +/* ...low-level codec API function execution */ +#define XA_API(codec, cmd, idx, pv) \ +({ \ + XA_ERRORCODE __e; \ + __e = (codec)->process((xa_codec_handle_t)(codec)->api.addr, (cmd), (idx), (pv)); \ + if (__e != XA_NO_ERROR) \ + { \ + if (XA_ERROR_SEVERITY(__e)) \ + { \ + TRACE(ERROR, _x("[%p]:(%d, %d, %p): %X"), (codec), (cmd), (idx), (pv), __e); \ + return __e; \ + } \ + TRACE(WARNING, _x("%X"), __e); \ + } \ + __e; \ +}) + +#define XA_API_NORET(codec, cmd, idx, pv) \ +({ \ + XA_ERRORCODE __e; \ + __e = (codec)->process((xa_codec_handle_t)(codec)->api.addr, (cmd), (idx), (pv)); \ + if (__e != XA_NO_ERROR) \ + { \ + if (XA_ERROR_SEVERITY(__e)) \ + { \ + TRACE(ERROR, _x("[%p]:(%d, %d, %p): %X"), (codec), (cmd), (idx), (pv), __e); \ + } \ + TRACE(WARNING, _x("%X"), __e); \ + } \ + __e; \ +}) + +/* ...codec hook invocation */ +#define CODEC_API(codec, func, ...) \ +({ \ + XA_ERRORCODE __e = (codec)->func((codec), ##__VA_ARGS__); \ + \ + if (__e != XA_NO_ERROR) \ + { \ + if (XA_ERROR_SEVERITY(__e)) \ + { \ + /* ...actual error is reported by the codec */ \ + TRACE(ERROR, _x("[%p]: " #func ": %X"), (codec), __e); \ + return __e; \ + } \ + \ + TRACE(WARNING, _x("warning: %X"), __e); \ + } \ + __e; \ +}) + +/* ...allocate local memory on specific core */ +#define XMALLOC(p, size, align, core) \ +do \ +{ \ + if (xf_mm_alloc_buffer((size), (align), (core), (p)) != 0) \ + { \ + TRACE(ERROR, _x("Failed to allocate %d bytes of memory"), (size)); \ + return XA_API_FATAL_MEM_ALLOC; \ + } \ + \ + if (((u32)((p)->addr) & ((align) - 1)) != 0) \ + { \ + TRACE(ERROR, _x("Invalid %d-algnment: %p"), (align), (p)->addr); \ + return XA_API_FATAL_MEM_ALIGN; \ + } \ +} \ +while (0) + +/******************************************************************************* + * Public API + ******************************************************************************/ + +/* ...SET-PARAM processing */ +extern XA_ERRORCODE xa_base_set_param(XACodecBase *base, xf_message_t *m); + +/* ...GET-PARAM-EXT message processing */ +extern XA_ERRORCODE xa_base_set_param_ext(XACodecBase *base, xf_message_t *m); + +/* ...GET-PARAM message processing */ +extern XA_ERRORCODE xa_base_get_param(XACodecBase *base, xf_message_t *m); + +/* ...GET-PARAM-EXT message processing */ +extern XA_ERRORCODE xa_base_get_param_ext(XACodecBase *base, xf_message_t *m); + +/* ...data processing scheduling */ +extern void xa_base_schedule(XACodecBase *base, u32 dts); + +/* ...cancel internal scheduling message */ +extern void xa_base_cancel(XACodecBase *base); + +/* ...base codec factory */ +extern XACodecBase * xa_base_factory(u32 core, u32 size, xa_codec_func_t process); + +/* ...base codec destructor */ +extern void xa_base_destroy(XACodecBase *base, u32 size, u32 core); + +#endif /* __XA_CLASS_BASE_H */ diff --git a/hifi/xaf/hifi-dpf/audio/xa-class-mixer.c b/hifi/xaf/hifi-dpf/audio/xa-class-mixer.c new file mode 100644 index 00000000..47b47406 --- /dev/null +++ b/hifi/xaf/hifi-dpf/audio/xa-class-mixer.c @@ -0,0 +1,870 @@ +/******************************************************************************* +* 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-class-mixer.c + * + * Generic mixer component class + * + ******************************************************************************/ + +#define MODULE_TAG MIXER + +/******************************************************************************* + * Includes + ******************************************************************************/ + +#include "xf.h" +#include "xa-class-base.h" +#include "audio/xa-mixer-api.h" + +/******************************************************************************* + * Tracing tags + ******************************************************************************/ + +TRACE_TAG(INIT, 1); +TRACE_TAG(WARNING, 1); +TRACE_TAG(INFO, 1); +TRACE_TAG(INPUT, 1); +TRACE_TAG(OUTPUT, 1); + +/******************************************************************************* + * Data structures + ******************************************************************************/ + +/* ...mixed source - input data */ +typedef struct XATrack +{ + /* ...input port data */ + xf_input_port_t input; + + /* ...current presentation timestamp (in samples; local to a mixer state) */ + u32 pts; + + /* ...total amount of decoded frames since last synchronization point */ + u32 decoded; + + /* ...total amount of rendered frames (consumed) since last synchronization point */ + u32 rendered; + +} XATrack; + +/******************************************************************************* + * Helpers + ******************************************************************************/ + +static inline u32 xa_track_test_flags(XATrack *track, u32 flags) +{ + return (track->input.flags & flags); +} + +static inline u32 xa_track_set_flags(XATrack *track, u32 flags) +{ + return (track->input.flags |= flags); +} + +static inline u32 xa_track_clear_flags(XATrack *track, u32 flags) +{ + return (track->input.flags &= ~flags); +} + +static inline u32 xa_track_toggle_flags(XATrack *track, u32 flags) +{ + return (track->input.flags ^= flags); +} + +/******************************************************************************* + * Mixer data definitions + ******************************************************************************/ + +/* ...mixer data */ +typedef struct XAMixer +{ + /*************************************************************************** + * Control data + **************************************************************************/ + + /* ...generic audio codec data */ + XACodecBase base; + + /* ...input tracks */ + XATrack track[XA_MIXER_MAX_TRACK_NUMBER]; + + /* ...output port */ + xf_output_port_t output; + + /*************************************************************************** + * Run-time configuration parameters + **************************************************************************/ + + /* ...audio frame size in samples */ + u32 frame_size; + + /* ...audio frame duration */ + u32 frame_duration; + + /* ...presentation timestamp (in samples; local mixer scope) */ + u32 pts; + +} XAMixer; + +/******************************************************************************* + * Mixer flags + ******************************************************************************/ + +/* ...output port setup completed */ +#define XA_MIXER_FLAG_OUTPUT_SETUP __XA_BASE_FLAG(1 << 0) + +/******************************************************************************* + * Track state flags + ******************************************************************************/ + +/* ...track is idle (will autostart as soon as input data received) */ +#define XA_TRACK_FLAG_IDLE __XF_INPUT_FLAG(1 << 0) + +/* ...track is rendered */ +#define XA_TRACK_FLAG_ACTIVE __XF_INPUT_FLAG(1 << 1) + +/* ...track is paused */ +#define XA_TRACK_FLAG_PAUSED __XF_INPUT_FLAG(1 << 2) + +/* ...track input port is setup */ +#define XA_TRACK_FLAG_INPUT_SETUP __XF_INPUT_FLAG(1 << 3) + +/* ...track has received data */ +#define XA_TRACK_FLAG_RECVD_DATA __XF_INPUT_FLAG(1 << 4) + +/******************************************************************************* + * Helper functions + ******************************************************************************/ +/* ...Count the tracks that have received data or are active*/ +static inline UWORD32 xa_mixer_check_active(XAMixer *mixer) +{ + XATrack *track; + UWORD32 i; + UWORD32 cnt = 0; + + for (track = &mixer->track[i = 0]; i < XA_MIXER_MAX_TRACK_NUMBER; i++, track++) + { + if (xa_track_test_flags(track, XA_TRACK_FLAG_RECVD_DATA | XA_TRACK_FLAG_ACTIVE)) + cnt++; + } + return cnt; +} + +/* ...prepare mixer for steady operation */ +static inline XA_ERRORCODE xa_mixer_prepare_runtime(XAMixer *mixer) +{ + XACodecBase *base = (XACodecBase *) mixer; + xf_message_t *m = xf_msg_dequeue(&mixer->output.queue); + xf_start_msg_t *msg = m->buffer; + u32 frame_size; + u32 factor; + + /* ...query mixer parameters */ + XA_API(base, XA_API_CMD_GET_CONFIG_PARAM, XA_MIXER_CONFIG_PARAM_SAMPLE_RATE, &msg->sample_rate); + XA_API(base, XA_API_CMD_GET_CONFIG_PARAM, XA_MIXER_CONFIG_PARAM_CHANNELS, &msg->channels); + XA_API(base, XA_API_CMD_GET_CONFIG_PARAM, XA_MIXER_CONFIG_PARAM_PCM_WIDTH, &msg->pcm_width); + XA_API(base, XA_API_CMD_GET_MEM_INFO_SIZE, 0, &msg->input_length); + XA_API(base, XA_API_CMD_GET_MEM_INFO_SIZE, XA_MIXER_MAX_TRACK_NUMBER, &msg->output_length); + XA_API(base, XA_API_CMD_GET_CONFIG_PARAM, XA_MIXER_CONFIG_PARAM_FRAME_SIZE, &frame_size); + + /* ...calculate mixer frame duration; get upsample factor */ + XF_CHK_ERR(factor = xf_timebase_factor(msg->sample_rate), XA_MIXER_CONFIG_FATAL_RANGE); + + /* ...set mixer frame duration */ + mixer->frame_duration = frame_size * factor; + + /* ...pass response to caller */ + xf_response_data(m, sizeof(*msg)); + + return XA_NO_ERROR; +} + +/******************************************************************************* + * Commands handlers + ******************************************************************************/ + +/* ...EMPTY-THIS-BUFFER command processing */ +static XA_ERRORCODE xa_mixer_empty_this_buffer(XACodecBase *base, xf_message_t *m) +{ + XAMixer *mixer = (XAMixer *) base; + u32 i = XF_MSG_DST_PORT(m->id); + XATrack *track = &mixer->track[i]; + + /* ...make sure the port is valid */ + XF_CHK_ERR(i < XA_MIXER_MAX_TRACK_NUMBER, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...command is allowed only in "postinit" state */ + XF_CHK_ERR(base->state & XA_BASE_FLAG_POSTINIT, XA_API_FATAL_INVALID_CMD); + + TRACE(INPUT, _b("track-%u: received buffer [%p]:%u"), i, m->buffer, m->length); + + /* ...update received data for the track */ + if (m->length) + xa_track_set_flags(track, XA_TRACK_FLAG_RECVD_DATA); + else + xa_track_clear_flags(track, XA_TRACK_FLAG_RECVD_DATA); + + /* ...place received message into track input port */ + if (xf_input_port_put(&track->input, m)) + { + /* ...process track autostart if needed */ + if (xa_track_test_flags(track, XA_TRACK_FLAG_IDLE)) + { + /* ...put track into active state */ + xa_track_toggle_flags(track, XA_TRACK_FLAG_IDLE | XA_TRACK_FLAG_ACTIVE); + + /* ...save track presentation timestamp */ + track->pts = mixer->pts; + + TRACE(INFO, _b("track-%u started (pts=%x)"), i, track->pts); + } + + /* ...schedule data processing if there is output port available */ + if (xf_output_port_ready(&mixer->output)) + { + /* ...force data processing */ + xa_base_schedule(base, 0); + } + } + + return XA_NO_ERROR; +} + +/* ...FILL-THIS-BUFFER command processing */ +static XA_ERRORCODE xa_mixer_fill_this_buffer(XACodecBase *base, xf_message_t *m) +{ + XAMixer *mixer = (XAMixer *) base; + u32 i = XF_MSG_DST_PORT(m->id); + + /* ...make sure the port is valid */ + XF_CHK_ERR(i == XA_MIXER_MAX_TRACK_NUMBER, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...command is allowed only in "postinit" state */ + XF_CHK_ERR(base->state & XA_BASE_FLAG_POSTINIT, XA_API_FATAL_INVALID_CMD); + + /* ...process runtime initialization explicitly */ + if (base->state & XA_BASE_FLAG_RUNTIME_INIT) + { + /* ...message must be zero-length */ + XF_CHK_ERR(m->length == 0, XA_MIXER_EXEC_FATAL_STATE); + } + else if (m->length != 0) /* ...EOS response */ + { + /* ...message must have exactly expected size (there is no ordered abortion) */ + XF_CHK_ERR(m->length == mixer->output.length, XA_MIXER_EXEC_FATAL_STATE); + } + + TRACE(OUTPUT, _b("received output buffer [%p]:%u"), m->buffer, m->length); + + /* ...put message into output port */ + if (xf_output_port_put(&mixer->output, m)) + { + /* ...force data processing */ + xa_base_schedule(base, 0); + } + + return XA_NO_ERROR; +} + +/* ...output port routing */ +static XA_ERRORCODE xa_mixer_port_route(XACodecBase *base, xf_message_t *m) +{ + XAMixer *mixer = (XAMixer *) base; + xf_route_port_msg_t *cmd = m->buffer; + xf_output_port_t *port = &mixer->output; + u32 src = XF_MSG_DST(m->id); + u32 dst = cmd->dst; + + /* ...command is allowed only in "postinit" state */ + XF_CHK_ERR(base->state & XA_BASE_FLAG_POSTINIT, XA_API_FATAL_INVALID_CMD); + + /* ...make sure output port is addressed */ + XF_CHK_ERR(XF_MSG_DST_PORT(m->id) == XA_MIXER_MAX_TRACK_NUMBER, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...make sure port is not routed yet */ + XF_CHK_ERR(!xf_output_port_routed(port), XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...route output port - allocate queue */ + XF_CHK_ERR(xf_output_port_route(port, __XF_MSG_ID(dst, src), cmd->alloc_number, cmd->alloc_size, cmd->alloc_align) == 0, XA_API_FATAL_MEM_ALLOC); + + /* ...schedule processing instantly - tbd - check if we have anything pending on input */ + xa_base_schedule(base, 0); + + /* ...pass success result to caller */ + xf_response_ok(m); + + return XA_NO_ERROR; +} + +/* ...port unroute command */ +static XA_ERRORCODE xa_mixer_port_unroute(XACodecBase *base, xf_message_t *m) +{ + XAMixer *mixer = (XAMixer *) base; + xf_output_port_t *port = &mixer->output; + + /* ...command is allowed only in "postinit" state */ + XF_CHK_ERR(base->state & XA_BASE_FLAG_POSTINIT, XA_API_FATAL_INVALID_CMD); + + /* ...make sure output port is addressed */ + XF_CHK_ERR(XF_MSG_DST_PORT(m->id) == XA_MIXER_MAX_TRACK_NUMBER, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...cancel any pending processing */ + xa_base_cancel(base); + + /* ...clear output-port-setup condition */ + base->state &= ~XA_MIXER_FLAG_OUTPUT_SETUP; + + /* ...pass flush command down the graph */ + if (xf_output_port_flush(port, XF_FLUSH)) + { + TRACE(INFO, _b("port is idle; instantly unroute")); + + /* ...flushing sequence is not needed; command may be satisfied instantly */ + xf_output_port_unroute(port); + + /* ...pass response to the proxy */ + xf_response_ok(m); + } + else + { + TRACE(INFO, _b("port is busy; propagate unroute command")); + + /* ...flushing sequence is started; save flow-control message */ + xf_output_port_unroute_start(port, m); + } + + return XA_NO_ERROR; +} + +/* ...PAUSE message processing */ +static XA_ERRORCODE xa_mixer_pause(XACodecBase *base, xf_message_t *m) +{ + XAMixer *mixer = (XAMixer *) base; + u32 i = XF_MSG_DST_PORT(m->id); + XATrack *track = &mixer->track[i]; + + /* ...make sure the buffer is empty */ + XF_CHK_ERR(m->length == 0, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...check destination port is valid */ + XF_CHK_ERR(i < XA_MIXER_MAX_TRACK_NUMBER, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...check for actual track flags */ + if (xa_track_test_flags(track, XA_TRACK_FLAG_ACTIVE)) + { + /* ...switch to paused state */ + xa_track_toggle_flags(track, XA_TRACK_FLAG_ACTIVE | XA_TRACK_FLAG_PAUSED); + + /* ...other tracks may be waiting for this one, so force data processing */ + if (xf_output_port_ready(&mixer->output)) + { + xa_base_schedule(base, 0); + } + + TRACE(INFO, _b("mixer[%p]::track[%u] paused"), mixer, i); + } + else + { + /* ...track is in idle state and pausing here means suspending */ + TRACE(INFO, _b("mixer[%p]::track[%u] is not active"), mixer, i); + } + + /* ...complete message immediately */ + xf_response(m); + + return XA_NO_ERROR; +} + +/* ...RESUME command processing */ +static XA_ERRORCODE xa_mixer_resume(XACodecBase *base, xf_message_t *m) +{ + XAMixer *mixer = (XAMixer *) base; + u32 i = XF_MSG_DST_PORT(m->id); + XATrack *track = &mixer->track[i]; + + /* ...make sure the buffer is empty */ + XF_CHK_ERR(m->length == 0, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...check destination port is valid */ + XF_CHK_ERR(i < XA_MIXER_MAX_TRACK_NUMBER, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...check for actual track state */ + if (xa_track_test_flags(track, XA_TRACK_FLAG_PAUSED)) + { + /* ...switch track to active state */ + xa_track_toggle_flags(track, XA_TRACK_FLAG_ACTIVE | XA_TRACK_FLAG_PAUSED); + + /* ...reset track presentation timestamp - tbd */ + track->pts = mixer->pts; + + /* ...force data processing if there is an output buffer */ + if (xf_output_port_ready(&mixer->output)) + { + xa_base_schedule(base, 0); + } + + TRACE(INFO, _b("mixer[%p]::track[%u] resumed"), mixer, i); + } + else + { + /* ...track is in idle state; do nothing */ + TRACE(INFO, _b("mixer[%p]::track[%u] is not paused"), mixer, i); + } + + /* ...complete message */ + xf_response(m); + + return XA_NO_ERROR; +} + +/* ...FLUSH command processing */ +static XA_ERRORCODE xa_mixer_flush(XACodecBase *base, xf_message_t *m) +{ + XAMixer *mixer = (XAMixer *) base; + u32 i = XF_MSG_DST_PORT(m->id); + XATrack *track = &mixer->track[i]; + + /* ...make sure the buffer is empty */ + XF_CHK_ERR(m->length == 0, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...check destination port index */ + if (i == XA_MIXER_MAX_TRACK_NUMBER) + { + /* ...flushing response received; that is a port unrouting sequence */ + XF_CHK_ERR(xf_output_port_unrouting(&mixer->output), XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...complete unroute sequence */ + xf_output_port_unroute_done(&mixer->output); + + TRACE(INFO, _b("port is unrouted")); + + return XA_NO_ERROR; + } + + /* ...check destination port index is valid */ + XF_CHK_ERR(i < XA_MIXER_MAX_TRACK_NUMBER, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...input port flushing; check the track state is valid */ + if (xa_track_test_flags(track, XA_TRACK_FLAG_ACTIVE | XA_TRACK_FLAG_PAUSED)) + { + /* ...purge input port */ + xf_input_port_purge(&track->input); + + /* ...force clearing of ACTIVE and INPUT_SETUP condition */ + xa_track_clear_flags(track, XA_TRACK_FLAG_ACTIVE | XA_TRACK_FLAG_PAUSED | XA_TRACK_FLAG_INPUT_SETUP); + + /* ...and enter into idle state */ + xa_track_set_flags(track, XA_TRACK_FLAG_IDLE); + + /* ...other tracks may be waiting for this track, so force data processing */ + if (xf_output_port_ready(&mixer->output)) + { + xa_base_schedule(base, 0); + } + + TRACE(INFO, _b("mixer[%p]::track[%u] flushed"), mixer, i); + } + + /* ...complete message instantly (no propagation to output port) */ + xf_response(m); + + return XA_NO_ERROR; +} + +/******************************************************************************* + * Codec API implementation + ******************************************************************************/ + +/* ...buffers handling */ +static XA_ERRORCODE xa_mixer_memtab(XACodecBase *base, WORD32 idx, WORD32 type, WORD32 size, WORD32 align, u32 core) +{ + XAMixer *mixer = (XAMixer *)base; + + if (type == XA_MEMTYPE_INPUT) + { + XATrack *track = &mixer->track[idx]; + + /* ...input buffer allocation; check track number is valid */ + XF_CHK_ERR(idx < XA_MIXER_MAX_TRACK_NUMBER, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...create input port for a track */ + XF_CHK_ERR(xf_input_port_init(&track->input, size, align, core) == 0, XA_API_FATAL_MEM_ALLOC); + + /* ...set input port buffer */ + XA_API(base, XA_API_CMD_SET_MEM_PTR, idx, track->input.buffer); + + /* ...put track into idle state (will start as soon as we receive data) */ + xa_track_set_flags(track, XA_TRACK_FLAG_IDLE); + + TRACE(INIT, _b("mixer[%p]::track[%u] input port created - size=%u"), mixer, idx, size); + } + else + { + /* ...output buffer allocation */ + XF_CHK_ERR(type == XA_MEMTYPE_OUTPUT, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...check port number is what we expect */ + XF_CHK_ERR(idx == XA_MIXER_MAX_TRACK_NUMBER, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...set mixer frame-size (in samples - for timestamp tracking) */ + XA_API(base, XA_API_CMD_GET_CONFIG_PARAM, XA_MIXER_CONFIG_PARAM_FRAME_SIZE, &mixer->frame_size); + + /* ...create output port for a track */ + XF_CHK_ERR(xf_output_port_init(&mixer->output, size) == 0, XA_API_FATAL_MEM_ALLOC); + + TRACE(INIT, _b("mixer[%p] output port created; size=%u"), mixer, size); + } + + return XA_NO_ERROR; +} + +/* ...preprocessing function */ +static XA_ERRORCODE xa_mixer_preprocess(XACodecBase *base) +{ + XAMixer *mixer = (XAMixer *) base; + XATrack *track; + u8 i; + XA_ERRORCODE e = XA_MIXER_EXEC_NONFATAL_NO_DATA; + + /* ...prepare output buffer */ + if (!(base->state & XA_MIXER_FLAG_OUTPUT_SETUP)) + { + void *output; + + /* ...set output buffer pointer */ + if (base->state & XA_BASE_FLAG_RUNTIME_INIT) + { + /* ...no actual data processing during initialization */ + return XA_NO_ERROR; + } + else if ((output = xf_output_port_data(&mixer->output)) == NULL) + { + /* ...no output buffer available */ + return e; + } + + /* ...set output buffer pointer */ + XA_API(base, XA_API_CMD_SET_MEM_PTR, XA_MIXER_MAX_TRACK_NUMBER, output); + + /* ...mark output port is setup */ + base->state ^= XA_MIXER_FLAG_OUTPUT_SETUP; + } + + /* ...check EOS */ + if (!xa_mixer_check_active(mixer)) + { + /* ...push EOS to output port */ + xf_output_port_produce(&mixer->output, 0); + TRACE(INFO, _b("mixer[%p]::EOS generated"), mixer); + } + + /* ...setup input buffer pointers and length */ + for (track = &mixer->track[i = 0]; i < XA_MIXER_MAX_TRACK_NUMBER; i++, track++) + { + /* ...skip tracks that are not played */ + if (!xa_track_test_flags(track, XA_TRACK_FLAG_ACTIVE)) continue; + + /* ...set temporary mixing request */ + e = XA_NO_ERROR; + + /* ...skip the tracks that has been setup already */ + if (xa_track_test_flags(track, XA_TRACK_FLAG_INPUT_SETUP)) continue; + + /* ...found active track that hasn't been setup yet */ + TRACE(INPUT, _b("track-%u: ts=%x vs mts=%x"), i, track->pts, mixer->pts); + + /* ...if track presentation timestamp is in the future, do nothing yet really */ + if (!xf_time_after(track->pts, mixer->pts)) + { + u32 filled; + + /* ...take actual data from input port (mixer is always using internal buffer) */ + if (!xf_input_port_fill(&track->input)) + { + /* ...failed to prefill input buffer - no sufficient data yet */ + return XA_MIXER_EXEC_NONFATAL_NO_DATA; + } + else + { + /* ...retrieve number of bytes available */ + filled = xf_input_port_level(&track->input); + } + + /* ...set total number of bytes we have in buffer */ + XA_API(base, XA_API_CMD_SET_INPUT_BYTES, i, &filled); + + /* ...actual data is to be played */ + TRACE(INPUT, _b("track-%u: filled %u bytes"), i, filled); + } + + /* ...mark the track input is setup (emit silence or actual data) */ + xa_track_set_flags(track, XA_TRACK_FLAG_INPUT_SETUP); + } + + /* ...do mixing operation only when all active tracks are setup */ + return e; +} + +/* ...postprocessing function */ +static XA_ERRORCODE xa_mixer_postprocess(XACodecBase *base, int done) +{ + XAMixer *mixer = (XAMixer *) base; + XATrack *track; + u32 produced; + u32 consumed; + u8 i; + + /* ...process execution stage transitions */ + if (done) + { + if (base->state & XA_BASE_FLAG_RUNTIME_INIT) + { + /* ...failed to initialize runtime (can't be? - tbd)*/ + BUG(1, _x("breakpoint")); + } + else if (base->state & XA_BASE_FLAG_EXECUTION) + { + /* ...enter into execution state; initialize runtime */ + return XA_CHK(xa_mixer_prepare_runtime(mixer)); + } + else + { + /* ...mixer operation is over (can't be? - tbd) */ + BUG(1, _x("breakpoint")); + } + } + + /* ...input ports maintenance; process all tracks */ + for (track = &mixer->track[i = 0]; i < XA_MIXER_MAX_TRACK_NUMBER; i++, track++) + { + /* ...skip the tracks that are not runing */ + if (!xa_track_test_flags(track, XA_TRACK_FLAG_ACTIVE)) continue; + + /* ...clear input setup flag */ + xa_track_clear_flags(track, XA_TRACK_FLAG_INPUT_SETUP); + + /* ...advance track presentation timestamp */ + track->pts += mixer->frame_size; + + /* ...get total amount of consumed bytes */ + XA_API(base, XA_API_CMD_GET_CURIDX_INPUT_BUF, i, &consumed); + + TRACE(INPUT, _b("track-%u::postprocess(c=%u, ts=%x)"), i, consumed, track->pts); + + /* ...consume that amount from input port (may be zero) */ + xf_input_port_consume(&track->input, consumed); + + /* ...check if input port is done */ + if (xf_input_port_done(&track->input)) + { + /* ...input stream is over; return zero-length input back to caller */ + xf_input_port_purge(&track->input); + + /* ...switch to idle state */ + xa_track_toggle_flags(track, XA_TRACK_FLAG_ACTIVE | XA_TRACK_FLAG_IDLE); + + TRACE(INFO, _b("mixer[%p]::track[%u] completed"), mixer, i); + } + } + + /* ...check if we have produced anything */ + XA_API(base, XA_API_CMD_GET_OUTPUT_BYTES, XA_MIXER_MAX_TRACK_NUMBER, &produced); + + TRACE(OUTPUT, _b("mixer[%p]::postprocess(p=%u, ts=%x, done=%u)"), mixer, produced, mixer->pts, done); + + /* ...output port maintenance */ + if (produced) + { + /* ...make sure we have produced exactly single frame */ + BUG(produced != mixer->output.length, _x("Invalid length: %u != %u"), produced, mixer->output.length); + + /* ...steady mixing process; advance mixer presentation timestamp */ + mixer->pts += mixer->frame_size; + + /* ...push data from output port */ + xf_output_port_produce(&mixer->output, produced); + + /* ...clear output-setup condition */ + base->state &= ~XA_MIXER_FLAG_OUTPUT_SETUP; + } + + /* ...reschedule data processing if there is a pending output message */ + if (xf_output_port_ready(&mixer->output)) + { + /* ...schedule execution with respect to urgency */ + xa_base_schedule(base, (produced ? mixer->frame_duration : 0)); + } + + return XA_NO_ERROR; +} + +/******************************************************************************* + * Command-processing function + ******************************************************************************/ + +/* ...command hooks */ +static XA_ERRORCODE (* const xa_mixer_cmd[])(XACodecBase *, xf_message_t *) = +{ + /* ...set-parameter - actually, same as in generic case */ + [XF_OPCODE_TYPE(XF_SET_PARAM)] = xa_base_set_param, + [XF_OPCODE_TYPE(XF_GET_PARAM)] = xa_base_get_param, + + /* ...output port routing/unrouting */ + [XF_OPCODE_TYPE(XF_ROUTE)] = xa_mixer_port_route, + [XF_OPCODE_TYPE(XF_UNROUTE)] = xa_mixer_port_unroute, + + /* ...input/output buffers processing */ + [XF_OPCODE_TYPE(XF_EMPTY_THIS_BUFFER)] = xa_mixer_empty_this_buffer, + [XF_OPCODE_TYPE(XF_FILL_THIS_BUFFER)] = xa_mixer_fill_this_buffer, + [XF_OPCODE_TYPE(XF_FLUSH)] = xa_mixer_flush, + + /* ...track control */ + [XF_OPCODE_TYPE(XF_PAUSE)] = xa_mixer_pause, + [XF_OPCODE_TYPE(XF_RESUME)] = xa_mixer_resume, +}; + +/* ...total number of commands supported */ +#define XA_MIXER_CMD_NUM (sizeof(xa_mixer_cmd) / sizeof(xa_mixer_cmd[0])) + +/******************************************************************************* + * Entry points + ******************************************************************************/ + +/* ...mixer termination-state command processor */ +static int xa_mixer_terminate(xf_component_t *component, xf_message_t *m) +{ + XAMixer *mixer = (XAMixer *) component; + u32 opcode = m->opcode; + + if (m == xf_output_port_control_msg(&mixer->output)) + { + /* ...output port flushing complete; mark port is idle and terminate */ + xf_output_port_flush_done(&mixer->output); + return -1; + } + else if (opcode == XF_FILL_THIS_BUFFER && xf_output_port_routed(&mixer->output)) + { + /* ...output buffer returned by the sink component; ignore and keep waiting */ + TRACE(OUTPUT, _b("collect output buffer")); + return 0; + } + else if (opcode == XF_UNREGISTER) + { + /* ...ignore subsequent unregister command/response */ + return 0; + } + else + { + /* ...everything else is responded with generic failure */ + xf_response_err(m); + return 0; + } +} + +/* ...mixer class destructor */ +static int xa_mixer_destroy(xf_component_t *component, xf_message_t *m) +{ + XAMixer *mixer = (XAMixer *) component; + u32 core = xf_component_core(component); + u32 i; + + /* ...destroy all inputs */ + for (i = 0; i < XA_MIXER_MAX_TRACK_NUMBER; i++) + { + xf_input_port_destroy(&mixer->track[i].input, core); + } + + /* ...destroy output port */ + xf_output_port_destroy(&mixer->output, core); + + /* ...destroy base object */ + xa_base_destroy(&mixer->base, XF_MM(sizeof(*mixer)), core); + + TRACE(INIT, _b("mixer[%p] destroyed"), mixer); + + return 0; +} + +/* ...mixer class first-stage destructor */ +static int xa_mixer_cleanup(xf_component_t *component, xf_message_t *m) +{ + XAMixer *mixer = (XAMixer *) component; + u32 i; + + /* ...complete message with error result code */ + xf_response_err(m); + + /* ...cancel internal scheduling message if needed */ + xa_base_cancel(&mixer->base); + + /* ...purge all input ports (specify "unregister"? - don't know yet - tbd) */ + for (i = 0; i < XA_MIXER_MAX_TRACK_NUMBER; i++) + { + xf_input_port_purge(&mixer->track[i].input); + } + + /* ...flush output port */ + if (xf_output_port_flush(&mixer->output, XF_FLUSH)) + { + /* ...flushing sequence is not needed; destroy mixer */ + return xa_mixer_destroy(component, NULL); + } + else + { + /* ...wait until output port is cleaned; adjust component hooks */ + component->entry = xa_mixer_terminate; + component->exit = xa_mixer_destroy; + + TRACE(INIT, _b("mixer[%p] cleanup sequence started"), mixer); + + /* ...indicate that second stage is required */ + return 1; + } +} + +/* ...mixer class factory */ +xf_component_t * xa_mixer_factory(u32 core, xa_codec_func_t process) +{ + XAMixer *mixer; + + /* ...construct generic audio component */ + XF_CHK_ERR(mixer = (XAMixer *)xa_base_factory(core, XF_MM(sizeof(*mixer)), process), NULL); + + /* ...set generic codec API */ + mixer->base.memtab = xa_mixer_memtab; + mixer->base.preprocess = xa_mixer_preprocess; + mixer->base.postprocess = xa_mixer_postprocess; + + /* ...set message-processing table */ + mixer->base.command = xa_mixer_cmd; + mixer->base.command_num = XA_MIXER_CMD_NUM; + + /* ...set component destructor hook */ + mixer->base.component.exit = xa_mixer_cleanup; + + TRACE(INIT, _b("Mixer[%p] created"), mixer); + + /* ...return handle to component */ + return (xf_component_t *) mixer; +} diff --git a/hifi/xaf/hifi-dpf/build_hikey/Makefile b/hifi/xaf/hifi-dpf/build_hikey/Makefile new file mode 100644 index 00000000..e1980a0d --- /dev/null +++ b/hifi/xaf/hifi-dpf/build_hikey/Makefile @@ -0,0 +1,135 @@ +# +# 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. +# + + +.PHONY: all install clean HIKEY960 + +NOSTRIP = 1 +XF_TRACE = 1 + +ROOTDIR = .. +CODEC_NAME = hikey + +PLUGINO2OBJS = +PLUGINLIBS = +PLUGININCLUDES = + +XA_MP3_DECODER ?= 0 +XA_VORBIS_DECODER ?= 1 +XA_MIXER ?= 1 +XA_PCM ?= 1 + + +vpath %.c $(ROOTDIR)/ipc/xt-shmem/hikey +vpath %.c $(ROOTDIR)/ipc/xt-shmem +vpath %.c $(ROOTDIR)/core/util +vpath %.c $(ROOTDIR)/core/util/gdbstub +vpath %.c $(ROOTDIR)/core +vpath %.c $(ROOTDIR)/app +vpath %.c $(ROOTDIR)/audio + +vpath %.S $(ROOTDIR)/ipc/xt-shmem/hikey +vpath %.S $(ROOTDIR)/core/util/gdbstub + +vpath %.c $(ROOTDIR)/plugins/cadence/mixer + +LIBXAFASMOBJS = \ + reset.o \ + int_vector.o \ + arch_hifi330.o \ + gdbstub-entry.o + +LIBXAFO2OBJS = \ + cpu_c.o \ + dsp_debug.o \ + dsp_comm.o \ + mutex.o \ + rbtree.o \ + xf-core.o \ + xf-io.o \ + xf-mem.o \ + xf-msg.o \ + xf-sched.o \ + xa-factory.o \ + xf-shmem.o \ + tinyvprintf.o \ + xf-isr.o \ + gdbstub.o \ + xa-class-base.o \ + xa-class-audio-codec.o \ + xa-class-mixer.o \ + xf-main.o + +ifeq ($(XF_TRACE),1) + CFLAGS += -DXF_TRACE=1 + CFLAGS += -DXAF_PROFILE_DSP=1 +endif + +ifeq ($(XA_MP3_DECODER),1) + vpath %.c $(ROOTDIR)/plugins/cadence/mp3_dec + CFLAGS += -DXA_MP3_DECODER=1 + PLUGINO2OBJS += xa-mp3-decoder.o + PLUGINLIBS += $(ROOTDIR)/plugins/cadence/mp3_dec/lib/hifi2/xa_mp3_dec.a + PLUGININCLUDES += -I$(ROOTDIR)/plugins/cadence/mp3_dec +endif + +ifeq ($(XA_PCM),1) + vpath %.c $(ROOTDIR)/plugins/cadence/pcm_proc + CFLAGS += -DXA_PCM=1 + PLUGINO2OBJS += xa-pcm.o + PLUGINLIBS += + PLUGININCLUDES += -I$(ROOTDIR)/plugins/cadence/pcm_proc +endif + +ifeq ($(XA_VORBIS_DECODER),1) + vpath %.c $(ROOTDIR)/plugins/cadence/vorbis_dec + CFLAGS += -DXA_VORBIS_DECODER=1 + PLUGINO2OBJS += xa-vorbis-decoder.o + PLUGINLIBS += $(ROOTDIR)/plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a + PLUGININCLUDES += -I$(ROOTDIR)/plugins/cadence/vorbis_dec +endif + +ifeq ($(XA_MIXER),1) + vpath %.c $(ROOTDIR)/plugins/cadence/mixer + CFLAGS += -DXA_MIXER=1 + PLUGINO2OBJS += xa-mixer.o + PLUGINLIBS += + PLUGININCLUDES += -I$(ROOTDIR)/plugins/cadence/mixer +endif + +LIBO2OBJS = $(LIBXAFO2OBJS) $(LIBMP3DECO2OBJS) $(LIBMIXERO2OBJS) $(PLUGINO2OBJS) +LIBASMOBJS = $(LIBXAFASMOBJS) + +INCLUDES += \ + -I$(ROOTDIR)/include \ + -I$(ROOTDIR)/include/audio \ + -I$(ROOTDIR)/include/sys/xt-shmem \ + -I$(ROOTDIR)/include/sys/xt-shmem/board-hikey \ + -I$(ROOTDIR)/plugins/cadence/mp3_dec + +INCLUDES += $(PLUGININCLUDES) + +LDFLAGS += -nostdlib -lhal -lhandlers-board -lc -lgcc +LDFLAGS += -mlsp="./hifi_hikey_lsp" + +HIKEY960: $(CODEC_NAME) + +include $(ROOTDIR)/build_hikey/common.mk diff --git a/hifi/xaf/hifi-dpf/build_hikey/common.mk b/hifi/xaf/hifi-dpf/build_hikey/common.mk new file mode 100644 index 00000000..ef4429ea --- /dev/null +++ b/hifi/xaf/hifi-dpf/build_hikey/common.mk @@ -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. +# + +QUIET = +MAPFILE = map_$(CODEC_NAME).txt +LDSCRIPT = ldscript_$(CODEC_NAME).txt +SYMFILE = symbols_$(CODEC_NAME).txt +ELFTOBIN = $(ROOTDIR)/build_hikey/tools/elftobin.sh + +ifeq ($(CPU), gcc) + S = / + AR = ar + OBJCOPY = objcopy + CC = gcc + CXX = g++ + CFLAGS += -fno-exceptions -DCSTUB=1 + CFLAGS += -ffloat-store + CFLAGS += -DHIFI3_CSTUB + RM = rm -f + RM_R = rm -rf + MKPATH = mkdir -p + CP = cp -f + INCLUDES += \ + -I$(ROOTDIR)/test/include +else + AR = xt-ar $(XTCORE) + OBJCOPY = xt-objcopy $(XTCORE) + CC = xt-xcc $(XTCORE) + CXX = xt-xc++ $(XTCORE) + ISS = xt-run $(XTCORE) + CONFIGDIR := $(shell $(ISS) --show-config=config) + include $(CONFIGDIR)/misc/hostenv.mk + #CFLAGS += -Wall + #CFLAGS += -Werror + #CFLAGS += -mno-mul16 -mno-mul32 -mno-div32 -fsigned-char -fno-exceptions -mlongcalls -INLINE:requested -mcoproc -fno-zero-initialized-in-bss + CFLAGS += -mlongcalls -mtext-section-literals + ASMFLAGS += -mlongcalls +endif + +OBJDIR = objs$(S)$(CODEC_NAME) +LIBDIR = $(ROOTDIR)$(S)lib + +OBJ_LIBO2OBJS = $(addprefix $(OBJDIR)/,$(LIBO2OBJS)) +OBJ_LIBOSOBJS = $(addprefix $(OBJDIR)/,$(LIBOSOBJS)) +OBJ_LIBO2CPPOBJS = $(addprefix $(OBJDIR)/,$(LIBO2CPPOBJS)) +OBJ_LIBOSCPPOBJS = $(addprefix $(OBJDIR)/,$(LIBOSCPPOBJS)) +OBJ_LIBASMOBJS = $(addprefix $(OBJDIR)/,$(LIBASMOBJS)) + +TEMPOBJ = temp.o + +ifeq ($(CPU), gcc) + LIBOBJ = $(OBJDIR)/xgcc_$(CODEC_NAME).o + LIB = xgcc_$(CODEC_NAME).img +else + LIBOBJ = $(OBJDIR)/xa_$(CODEC_NAME).o + LIB = xa_$(CODEC_NAME).img +endif + +CFLAGS += \ + $(EXTRA_CFLAGS) $(EXTRA_CFLAGS2) + + +ifeq ($(DEBUG),1) + NOSTRIP = 1 + OPT_O2 = -O0 -g + OPT_OS = -O0 -g + CFLAGS += -DDEBUG +else +ifeq ($(CPU), gcc) + OPT_O2 = -O2 -g + OPT_OS = -O2 -g +else + #OPT_O2 = -O3 -LNO:simd + OPT_O2 = -g -O2 + OPT_OS = -Os +endif +endif + +OPT_ASM = -g -Wa,--gdwarf-2 + + +all: $(OBJDIR) $(LIB) +$(CODEC_NAME): $(OBJDIR) $(LIB) + +install: $(LIB) + @echo "Installing $(LIB)" + $(QUIET) -$(MKPATH) "$(LIBDIR)" + $(QUIET) $(CP) $(LIB) "$(LIBDIR)" + +$(OBJDIR): + $(QUIET) -$(MKPATH) $@ + +ifeq ($(NOSTRIP), 1) +$(LIBOBJ): $(OBJ_LIBO2OBJS) $(OBJ_LIBOSOBJS) $(OBJ_LIBO2CPPOBJS) $(OBJ_LIBOSCPPOBJS) $(OBJ_LIBASMOBJS) $(PLUGINLIBS) + @echo "Linking Objects" + $(QUIET) $(CXX) -c $(OPT_O2) $(CFLAGS) -o $@ $^ \ + -Wl,-Map,$(MAPFILE) --no-standard-libraries \ + $(LDFLAGS) $(EXTRA_LDFLAGS) +else +$(LIBOBJ): $(OBJ_LIBO2OBJS) $(OBJ_LIBOSOBJS) $(OBJ_LIBO2CPPOBJS) $(OBJ_LIBOSCPPOBJS) $(OBJ_LIBASMOBJS) $(PLUGINLIBS) + @echo "Linking Objects" + $(QUIET) $(CXX) -c $(OPT_O2) $(CFLAGS) -o $@ $^ \ + -Wl,-Map,$(MAPFILE) --no-standard-libraries \ + -Wl,--retain-symbols-file,$(SYMFILE) \ + $(IPA_FLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) + $(QUIET) $(OBJCOPY) --keep-global-symbols=$(SYMFILE) $@ $(TEMPOBJ) + $(QUIET) $(OBJCOPY) --strip-unneeded $(TEMPOBJ) $@ + $(QUIET) -$(RM) $(TEMPOBJ) +endif + + +$(OBJ_LIBO2OBJS): $(OBJDIR)/%.o: %.c + @echo "Compiling $<" + $(QUIET) $(CC) -o $@ $(OPT_O2) $(CFLAGS) $(INCLUDES) -c $< + +$(OBJ_LIBOSOBJS): $(OBJDIR)/%.o: %.c + @echo "Compiling $<" + $(QUIET) $(CC) -o $@ $(OPT_OS) $(CFLAGS) $(INCLUDES) -c $< + +$(OBJ_LIBO2CPPOBJS): $(OBJDIR)/%.o: %.cpp + @echo "Compiling $<" + $(QUIET) $(CXX) -o $@ $(OPT_O2) $(CFLAGS) $(INCLUDES) -c $< + +$(OBJ_LIBOSCPPOBJS): $(OBJDIR)/%.o: %.cpp + @echo "Compiling $<" + $(QUIET) $(CXX) -o $@ $(OPT_OS) $(CFLAGS) $(INCLUDES) -c $< + +$(OBJ_LIBASMOBJS): $(OBJDIR)/%.o: %.S + @echo "Compiling $<" + $(QUIET) $(CC) -o $@ $(OPT_ASM) $(ASMFLAGS) $(INCLUDES) -c $< + +$(LIB): %.img: $(OBJDIR)/%.o + @echo "Creating Library $@" + $(ELFTOBIN) $< $@ + +clean: + -$(RM) $(LIB) $(MAPFILE) + -$(RM_R) $(OBJDIR) $(LIBDIR) diff --git a/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/ldscripts/elf32xtensa.x b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/ldscripts/elf32xtensa.x new file mode 100644 index 00000000..67507ed3 --- /dev/null +++ b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/ldscripts/elf32xtensa.x @@ -0,0 +1,827 @@ +/* This linker script generated from xt-genldscripts.tpp for LSP hifi_hikey_lsp */ +/* Linker Script for default link */ +MEMORY +{ + sram0_seg : org = 0xC0000000, len = 0x408000 + old_vlpd_seg : org = 0xC0408000, len = 0x10000 + efr_fr_hr_vlpd_seg : org = 0xC0418000, len = 0x10000 + amr_vlpd_seg : org = 0xC0428000, len = 0x10000 + amrwb_vlpd_seg : org = 0xC0438000, len = 0x10000 + evrc_evrcb_vlpt_seg : org = 0xC0448000, len = 0x48000 + efr_fr_hr_vlpt_seg : org = 0xC0490000, len = 0x30000 + amr_vlpt_seg : org = 0xC04C0000, len = 0x20000 + amrwb_vlpt_seg : org = 0xC04E0000, len = 0x30000 + vlpt_seg : org = 0xC0510000, len = 0x48000 + vlpd_seg : org = 0xC0558000, len = 0x20000 + ulpp_seg : org = 0xC0578000, len = 0x40000 + dtsv3_seg : org = 0xC05B8000, len = 0x20000 + dtsv4_seg : org = 0xC05D8000, len = 0x28000 + dram0_0_seg : org = 0xE8058000, len = 0x28000 + iram0_0_seg : org = 0xE8080000, len = 0x300 + iram0_1_seg : org = 0xE8080300, len = 0x100 + iram0_2_seg : org = 0xE8080400, len = 0x178 + iram0_3_seg : org = 0xE8080578, len = 0x8 + iram0_4_seg : org = 0xE8080580, len = 0x38 + iram0_5_seg : org = 0xE80805B8, len = 0x8 + iram0_6_seg : org = 0xE80805C0, len = 0x38 + iram0_7_seg : org = 0xE80805F8, len = 0x8 + iram0_8_seg : org = 0xE8080600, len = 0x38 + iram0_9_seg : org = 0xE8080638, len = 0x8 + iram0_10_seg : org = 0xE8080640, len = 0x38 + iram0_11_seg : org = 0xE8080678, len = 0x48 + iram0_12_seg : org = 0xE80806C0, len = 0x38 + iram0_13_seg : org = 0xE80806F8, len = 0x8 + iram0_14_seg : org = 0xE8080700, len = 0x38 + iram0_15_seg : org = 0xE8080738, len = 0x8 + iram0_16_seg : org = 0xE8080740, len = 0x38 + iram0_17_seg : org = 0xE8080778, len = 0x48 + iram0_18_seg : org = 0xE80807C0, len = 0x40 + iram0_19_seg : org = 0xE8080800, len = 0xB800 +} + +PHDRS +{ + sram0_phdr PT_LOAD; + sram0_bss_phdr PT_LOAD; + old_vlpd_phdr PT_LOAD; + old_vlpd_bss_phdr PT_LOAD; + efr_fr_hr_vlpd_phdr PT_LOAD; + efr_fr_hr_vlpd_bss_phdr PT_LOAD; + amr_vlpd_phdr PT_LOAD; + amr_vlpd_bss_phdr PT_LOAD; + amrwb_vlpd_phdr PT_LOAD; + amrwb_vlpd_bss_phdr PT_LOAD; + evrc_evrcb_vlpt_phdr PT_LOAD; + efr_fr_hr_vlpt_phdr PT_LOAD; + amr_vlpt_phdr PT_LOAD; + amrwb_vlpt_phdr PT_LOAD; + vlpt_phdr PT_LOAD; + vlpd_phdr PT_LOAD; + ulpp_phdr PT_LOAD; + ulpp_bss_phdr PT_LOAD; + dtsv3_phdr PT_LOAD; + dtsv3_bss_phdr PT_LOAD; + dtsv4_phdr PT_LOAD; + dtsv4_bss_phdr PT_LOAD; + dram0_0_phdr PT_LOAD; + dram0_0_bss_phdr PT_LOAD; + iram0_0_phdr PT_LOAD; + iram0_1_phdr PT_LOAD; + iram0_2_phdr PT_LOAD; + iram0_3_phdr PT_LOAD; + iram0_4_phdr PT_LOAD; + iram0_5_phdr PT_LOAD; + iram0_6_phdr PT_LOAD; + iram0_7_phdr PT_LOAD; + iram0_8_phdr PT_LOAD; + iram0_9_phdr PT_LOAD; + iram0_10_phdr PT_LOAD; + iram0_11_phdr PT_LOAD; + iram0_12_phdr PT_LOAD; + iram0_13_phdr PT_LOAD; + iram0_14_phdr PT_LOAD; + iram0_15_phdr PT_LOAD; + iram0_16_phdr PT_LOAD; + iram0_17_phdr PT_LOAD; + iram0_18_phdr PT_LOAD; + iram0_19_phdr PT_LOAD; +} + + +/* Default entry point: */ +ENTRY(_ResetVector) + +/* Memory boundary addresses: */ +_memmap_mem_iram0_start = 0xe8080000; +_memmap_mem_iram0_end = 0xe808c000; +_memmap_mem_dram0_start = 0xe8058000; +_memmap_mem_dram0_end = 0xe8080000; +_memmap_mem_sram_start = 0xc0000000; +_memmap_mem_sram_end = 0xc0600000; + +/* Memory segment boundary addresses: */ +_memmap_seg_sram0_start = 0xc0000000; +_memmap_seg_sram0_max = 0xc0408000; +_memmap_seg_old_vlpd_start = 0xc0408000; +_memmap_seg_old_vlpd_max = 0xc0418000; +_memmap_seg_efr_fr_hr_vlpd_start = 0xc0418000; +_memmap_seg_efr_fr_hr_vlpd_max = 0xc0428000; +_memmap_seg_amr_vlpd_start = 0xc0428000; +_memmap_seg_amr_vlpd_max = 0xc0438000; +_memmap_seg_amrwb_vlpd_start = 0xc0438000; +_memmap_seg_amrwb_vlpd_max = 0xc0448000; +_memmap_seg_evrc_evrcb_vlpt_start = 0xc0448000; +_memmap_seg_evrc_evrcb_vlpt_max = 0xc0490000; +_memmap_seg_efr_fr_hr_vlpt_start = 0xc0490000; +_memmap_seg_efr_fr_hr_vlpt_max = 0xc04c0000; +_memmap_seg_amr_vlpt_start = 0xc04c0000; +_memmap_seg_amr_vlpt_max = 0xc04e0000; +_memmap_seg_amrwb_vlpt_start = 0xc04e0000; +_memmap_seg_amrwb_vlpt_max = 0xc0510000; +_memmap_seg_vlpt_start = 0xc0510000; +_memmap_seg_vlpt_max = 0xc0558000; +_memmap_seg_vlpd_start = 0xc0558000; +_memmap_seg_vlpd_max = 0xc0578000; +_memmap_seg_ulpp_start = 0xc0578000; +_memmap_seg_ulpp_max = 0xc05b8000; +_memmap_seg_dtsv3_start = 0xc05b8000; +_memmap_seg_dtsv3_max = 0xc05d8000; +_memmap_seg_dtsv4_start = 0xc05d8000; +_memmap_seg_dtsv4_max = 0xc0600000; +_memmap_seg_dram0_0_start = 0xe8058000; +_memmap_seg_dram0_0_max = 0xe8080000; +_memmap_seg_iram0_0_start = 0xe8080000; +_memmap_seg_iram0_0_max = 0xe8080300; +_memmap_seg_iram0_1_start = 0xe8080300; +_memmap_seg_iram0_1_max = 0xe8080400; +_memmap_seg_iram0_2_start = 0xe8080400; +_memmap_seg_iram0_2_max = 0xe8080578; +_memmap_seg_iram0_3_start = 0xe8080578; +_memmap_seg_iram0_3_max = 0xe8080580; +_memmap_seg_iram0_4_start = 0xe8080580; +_memmap_seg_iram0_4_max = 0xe80805b8; +_memmap_seg_iram0_5_start = 0xe80805b8; +_memmap_seg_iram0_5_max = 0xe80805c0; +_memmap_seg_iram0_6_start = 0xe80805c0; +_memmap_seg_iram0_6_max = 0xe80805f8; +_memmap_seg_iram0_7_start = 0xe80805f8; +_memmap_seg_iram0_7_max = 0xe8080600; +_memmap_seg_iram0_8_start = 0xe8080600; +_memmap_seg_iram0_8_max = 0xe8080638; +_memmap_seg_iram0_9_start = 0xe8080638; +_memmap_seg_iram0_9_max = 0xe8080640; +_memmap_seg_iram0_10_start = 0xe8080640; +_memmap_seg_iram0_10_max = 0xe8080678; +_memmap_seg_iram0_11_start = 0xe8080678; +_memmap_seg_iram0_11_max = 0xe80806c0; +_memmap_seg_iram0_12_start = 0xe80806c0; +_memmap_seg_iram0_12_max = 0xe80806f8; +_memmap_seg_iram0_13_start = 0xe80806f8; +_memmap_seg_iram0_13_max = 0xe8080700; +_memmap_seg_iram0_14_start = 0xe8080700; +_memmap_seg_iram0_14_max = 0xe8080738; +_memmap_seg_iram0_15_start = 0xe8080738; +_memmap_seg_iram0_15_max = 0xe8080740; +_memmap_seg_iram0_16_start = 0xe8080740; +_memmap_seg_iram0_16_max = 0xe8080778; +_memmap_seg_iram0_17_start = 0xe8080778; +_memmap_seg_iram0_17_max = 0xe80807c0; +_memmap_seg_iram0_18_start = 0xe80807c0; +_memmap_seg_iram0_18_max = 0xe8080800; +_memmap_seg_iram0_19_start = 0xe8080800; +_memmap_seg_iram0_19_max = 0xe808c000; + +_rom_store_table = 0; +PROVIDE(_memmap_vecbase_reset = 0xe8080400); +PROVIDE(_memmap_reset_vector = 0xe8080000); +/* Various memory-map dependent cache attribute settings: */ +_memmap_cacheattr_wb_base = 0x44000000; +_memmap_cacheattr_wt_base = 0x11000000; +_memmap_cacheattr_bp_base = 0x22000000; +_memmap_cacheattr_unused_mask = 0x00FFFFFF; +_memmap_cacheattr_wb_trapnull = 0x4422222F; +_memmap_cacheattr_wba_trapnull = 0x4422222F; +_memmap_cacheattr_wbna_trapnull = 0x5522222F; +_memmap_cacheattr_wt_trapnull = 0x1122222F; +_memmap_cacheattr_bp_trapnull = 0x2222222F; +_memmap_cacheattr_wb_strict = 0x44FFFFFF; +_memmap_cacheattr_wt_strict = 0x11FFFFFF; +_memmap_cacheattr_bp_strict = 0x22FFFFFF; +_memmap_cacheattr_wb_allvalid = 0x44222222; +_memmap_cacheattr_wt_allvalid = 0x11222222; +_memmap_cacheattr_bp_allvalid = 0x22222222; +PROVIDE(_memmap_cacheattr_reset = _memmap_cacheattr_wb_trapnull); + +SECTIONS +{ + + .vlpd.rodata : ALIGN(4) + { + _vlpd_rodata_start = ABSOLUTE(.); + *(.vlpd.rodata) + _vlpd_rodata_end = ABSOLUTE(.); + } >old_vlpd_seg :old_vlpd_phdr + + .vlpd.data : ALIGN(4) + { + _vlpd_data_start = ABSOLUTE(.); + *(.vlpd.data) + _vlpd_data_end = ABSOLUTE(.); + } >old_vlpd_seg :old_vlpd_phdr + + .vlpd.bss (NOLOAD) : ALIGN(8) + { + . = ALIGN (8); + _vlpd_bss_start = ABSOLUTE(.); + *(.vlpd.bss) + . = ALIGN (8); + _vlpd_bss_end = ABSOLUTE(.); + _memmap_seg_old_vlpd_end = ALIGN(0x8); + } >old_vlpd_seg :old_vlpd_bss_phdr + + .efr_fr_hr_vlpd.rodata : ALIGN(4) + { + _efr_fr_hr_vlpd_rodata_start = ABSOLUTE(.); + *(.efr_fr_hr_vlpd.rodata) + _efr_fr_hr_vlpd_rodata_end = ABSOLUTE(.); + } >efr_fr_hr_vlpd_seg :efr_fr_hr_vlpd_phdr + + .efr_fr_hr_vlpd.data : ALIGN(4) + { + _efr_fr_hr_vlpd_data_start = ABSOLUTE(.); + *(.efr_fr_hr_vlpd.data) + _efr_fr_hr_vlpd_data_end = ABSOLUTE(.); + } >efr_fr_hr_vlpd_seg :efr_fr_hr_vlpd_phdr + + .efr_fr_hr_vlpd.bss (NOLOAD) : ALIGN(8) + { + . = ALIGN (8); + _efr_fr_hr_vlpd_bss_start = ABSOLUTE(.); + *(.efr_fr_hr_vlpd.bss) + . = ALIGN (8); + _efr_fr_hr_vlpd_bss_end = ABSOLUTE(.); + _memmap_seg_efr_fr_hr_vlpd_end = ALIGN(0x8); + } >efr_fr_hr_vlpd_seg :efr_fr_hr_vlpd_bss_phdr + + .amr_vlpd.rodata : ALIGN(4) + { + _amr_vlpd_rodata_start = ABSOLUTE(.); + *(.amr_vlpd.rodata) + _amr_vlpd_rodata_end = ABSOLUTE(.); + } >amr_vlpd_seg :amr_vlpd_phdr + + .amr_vlpd.data : ALIGN(4) + { + _amr_vlpd_data_start = ABSOLUTE(.); + *(.amr_vlpd.data) + _amr_vlpd_data_end = ABSOLUTE(.); + } >amr_vlpd_seg :amr_vlpd_phdr + + .amr_vlpd.bss (NOLOAD) : ALIGN(8) + { + . = ALIGN (8); + _amr_vlpd_bss_start = ABSOLUTE(.); + *(.amr_vlpd.bss) + . = ALIGN (8); + _amr_vlpd_bss_end = ABSOLUTE(.); + _memmap_seg_amr_vlpd_end = ALIGN(0x8); + } >amr_vlpd_seg :amr_vlpd_bss_phdr + + .amrwb_vlpd.rodata : ALIGN(4) + { + _amrwb_vlpd_rodata_start = ABSOLUTE(.); + *(.amrwb_vlpd.rodata) + _amrwb_vlpd_rodata_end = ABSOLUTE(.); + } >amrwb_vlpd_seg :amrwb_vlpd_phdr + + .amrwb_vlpd.data : ALIGN(4) + { + _amrwb_vlpd_data_start = ABSOLUTE(.); + *(.amrwb_vlpd.data) + _amrwb_vlpd_data_end = ABSOLUTE(.); + } >amrwb_vlpd_seg :amrwb_vlpd_phdr + + .amrwb_vlpd.bss (NOLOAD) : ALIGN(8) + { + . = ALIGN (8); + _amrwb_vlpd_bss_start = ABSOLUTE(.); + *(.amrwb_vlpd.bss) + . = ALIGN (8); + _amrwb_vlpd_bss_end = ABSOLUTE(.); + _memmap_seg_amrwb_vlpd_end = ALIGN(0x8); + } >amrwb_vlpd_seg :amrwb_vlpd_bss_phdr + + .evrc_evrcb_vlpt.text : ALIGN(4) + { + _evrc_evrcb_vlpt_text_start = ABSOLUTE(.); + *(.evrc_evrcb_vlpt.literal .evrc_evrcb_vlpt.text) + _evrc_evrcb_vlpt_text_end = ABSOLUTE(.); + _memmap_seg_evrc_evrcb_vlpt_end = ALIGN(0x8); + } >evrc_evrcb_vlpt_seg :evrc_evrcb_vlpt_phdr + + .efr_fr_hr_vlpt.text : ALIGN(4) + { + _efr_fr_hr_vlpt_text_start = ABSOLUTE(.); + *(.efr_fr_hr_vlpt.literal .efr_fr_hr_vlpt.text) + _efr_fr_hr_vlpt_text_end = ABSOLUTE(.); + _memmap_seg_efr_fr_hr_vlpt_end = ALIGN(0x8); + } >efr_fr_hr_vlpt_seg :efr_fr_hr_vlpt_phdr + + .amr_vlpt.text : ALIGN(4) + { + _amr_vlpt_text_start = ABSOLUTE(.); + *(.amr_vlpt.literal .amr_vlpt.text) + _amr_vlpt_text_end = ABSOLUTE(.); + _memmap_seg_amr_vlpt_end = ALIGN(0x8); + } >amr_vlpt_seg :amr_vlpt_phdr + + .amrwb_vlpt.text : ALIGN(4) + { + _amrwb_vlpt_text_start = ABSOLUTE(.); + *(.amrwb_vlpt.literal .amrwb_vlpt.text) + _amrwb_vlpt_text_end = ABSOLUTE(.); + _memmap_seg_amrwb_vlpt_end = ALIGN(0x8); + } >amrwb_vlpt_seg :amrwb_vlpt_phdr + + .vlpt.text : ALIGN(4) + { + _vlpt_text_start = ABSOLUTE(.); + *(.vlpt.literal .vlpt.text) + _vlpt_text_end = ABSOLUTE(.); + _memmap_seg_vlpt_end = ALIGN(0x8); + } >vlpt_seg :vlpt_phdr + + .low_power_dyn_alloc : ALIGN(4) + { + _low_power_dyn_alloc_start = ABSOLUTE(.); + *(.low_power_dyn_alloc) + _low_power_dyn_alloc_end = ABSOLUTE(.); + _memmap_seg_vlpd_end = ALIGN(0x8); + } >vlpd_seg :vlpd_phdr + + .ulpp.rodata : ALIGN(4) + { + _ulpp_rodata_start = ABSOLUTE(.); + *(.ulpp.rodata) + _ulpp_rodata_end = ABSOLUTE(.); + } >ulpp_seg :ulpp_phdr + + .ulpp.data : ALIGN(4) + { + _ulpp_data_start = ABSOLUTE(.); + *(.ulpp.data) + _ulpp_data_end = ABSOLUTE(.); + } >ulpp_seg :ulpp_phdr + + .ulpp.text : ALIGN(4) + { + _ulpp_text_start = ABSOLUTE(.); + *(.ulpp.literal .ulpp.text) + _ulpp_text_end = ABSOLUTE(.); + } >ulpp_seg :ulpp_phdr + + .ulpp.bss (NOLOAD) : ALIGN(8) + { + . = ALIGN (8); + _ulpp_bss_start = ABSOLUTE(.); + *(.ulpp.bss) + . = ALIGN (8); + _ulpp_bss_end = ABSOLUTE(.); + _memmap_seg_ulpp_end = ALIGN(0x8); + } >ulpp_seg :ulpp_bss_phdr + + .dtsv3.rodata : ALIGN(4) + { + _dtsv3_rodata_start = ABSOLUTE(.); + *(.dtsv3.rodata) + _dtsv3_rodata_end = ABSOLUTE(.); + } >dtsv3_seg :dtsv3_phdr + + .dtsv3.data : ALIGN(4) + { + _dtsv3_data_start = ABSOLUTE(.); + *(.dtsv3.data) + _dtsv3_data_end = ABSOLUTE(.); + } >dtsv3_seg :dtsv3_phdr + + .dtsv3.text : ALIGN(4) + { + _dtsv3_text_start = ABSOLUTE(.); + *(.dtsv3.literal .dtsv3.text) + _dtsv3_text_end = ABSOLUTE(.); + } >dtsv3_seg :dtsv3_phdr + + .dtsv3.bss (NOLOAD) : ALIGN(8) + { + . = ALIGN (8); + _dtsv3_bss_start = ABSOLUTE(.); + *(.dtsv3.bss) + . = ALIGN (8); + _dtsv3_bss_end = ABSOLUTE(.); + _memmap_seg_dtsv3_end = ALIGN(0x8); + } >dtsv3_seg :dtsv3_bss_phdr + + .dtsv4.rodata : ALIGN(4) + { + _dtsv4_rodata_start = ABSOLUTE(.); + *(.dtsv4.rodata) + _dtsv4_rodata_end = ABSOLUTE(.); + } >dtsv4_seg :dtsv4_phdr + + .dtsv4.data : ALIGN(4) + { + _dtsv4_data_start = ABSOLUTE(.); + *(.dtsv4.data) + _dtsv4_data_end = ABSOLUTE(.); + } >dtsv4_seg :dtsv4_phdr + + .dtsv4.text : ALIGN(4) + { + _dtsv4_text_start = ABSOLUTE(.); + *(.dtsv4.literal .dtsv4.text) + _dtsv4_text_end = ABSOLUTE(.); + } >dtsv4_seg :dtsv4_phdr + + .dtsv4.bss (NOLOAD) : ALIGN(8) + { + . = ALIGN (8); + _dtsv4_bss_start = ABSOLUTE(.); + *(.dtsv4.bss) + . = ALIGN (8); + _dtsv4_bss_end = ABSOLUTE(.); + _memmap_seg_dtsv4_end = ALIGN(0x8); + } >dtsv4_seg :dtsv4_bss_phdr + + .dram0.rodata : ALIGN(4) + { + _dram0_rodata_start = ABSOLUTE(.); + *(.dram0.rodata) + *(.dram.rodata) + _dram0_rodata_end = ABSOLUTE(.); + } >dram0_0_seg :dram0_0_phdr + + .dram0.literal : ALIGN(4) + { + _dram0_literal_start = ABSOLUTE(.); + *(.dram0.literal) + *(.dram.literal) + _dram0_literal_end = ABSOLUTE(.); + } >dram0_0_seg :dram0_0_phdr + + .dram0.data : ALIGN(4) + { + _dram0_data_start = ABSOLUTE(.); + *(.dram0.data) + *(.dram.data) + _dram0_data_end = ABSOLUTE(.); + } >dram0_0_seg :dram0_0_phdr + + .dram0.bss (NOLOAD) : ALIGN(8) + { + . = ALIGN (8); + _dram0_bss_start = ABSOLUTE(.); + *(.dram0.bss) + *(.om.debug.bss) + *(.os.stack.bss) + . = ALIGN (8); + _dram0_bss_end = ABSOLUTE(.); + _end = ALIGN(0x8); + PROVIDE(end = ALIGN(0x8)); + _stack_sentry = ALIGN(0x8); + _memmap_seg_dram0_0_end = ALIGN(0x8); + } >dram0_0_seg :dram0_0_bss_phdr + __stack = 0xe8080000; + _heap_sentry = 0xe8080000; + + .ResetVector.text : ALIGN(4) + { + _ResetVector_text_start = ABSOLUTE(.); + KEEP (*(.ResetVector.text)) + _ResetVector_text_end = ABSOLUTE(.); + _memmap_seg_iram0_0_end = ALIGN(0x8); + } >iram0_0_seg :iram0_0_phdr + + .Reset.literal : ALIGN(4) + { + _Reset_literal_start = ABSOLUTE(.); + *(.Reset.literal) + _Reset_literal_end = ABSOLUTE(.); + _memmap_seg_iram0_1_end = ALIGN(0x8); + } >iram0_1_seg :iram0_1_phdr + + .WindowVectors.text : ALIGN(4) + { + _WindowVectors_text_start = ABSOLUTE(.); + KEEP (*(.WindowVectors.text)) + _WindowVectors_text_end = ABSOLUTE(.); + _memmap_seg_iram0_2_end = ALIGN(0x8); + } >iram0_2_seg :iram0_2_phdr + + .Level2InterruptVector.literal : ALIGN(4) + { + _Level2InterruptVector_literal_start = ABSOLUTE(.); + *(.Level2InterruptVector.literal) + _Level2InterruptVector_literal_end = ABSOLUTE(.); + _memmap_seg_iram0_3_end = ALIGN(0x8); + } >iram0_3_seg :iram0_3_phdr + + .Level2InterruptVector.text : ALIGN(4) + { + _Level2InterruptVector_text_start = ABSOLUTE(.); + KEEP (*(.Level2InterruptVector.text)) + _Level2InterruptVector_text_end = ABSOLUTE(.); + _memmap_seg_iram0_4_end = ALIGN(0x8); + } >iram0_4_seg :iram0_4_phdr + + .Level3InterruptVector.literal : ALIGN(4) + { + _Level3InterruptVector_literal_start = ABSOLUTE(.); + *(.Level3InterruptVector.literal) + _Level3InterruptVector_literal_end = ABSOLUTE(.); + _memmap_seg_iram0_5_end = ALIGN(0x8); + } >iram0_5_seg :iram0_5_phdr + + .Level3InterruptVector.text : ALIGN(4) + { + _Level3InterruptVector_text_start = ABSOLUTE(.); + KEEP (*(.Level3InterruptVector.text)) + _Level3InterruptVector_text_end = ABSOLUTE(.); + _memmap_seg_iram0_6_end = ALIGN(0x8); + } >iram0_6_seg :iram0_6_phdr + + .Level4InterruptVector.literal : ALIGN(4) + { + _Level4InterruptVector_literal_start = ABSOLUTE(.); + *(.Level4InterruptVector.literal) + _Level4InterruptVector_literal_end = ABSOLUTE(.); + _memmap_seg_iram0_7_end = ALIGN(0x8); + } >iram0_7_seg :iram0_7_phdr + + .Level4InterruptVector.text : ALIGN(4) + { + _Level4InterruptVector_text_start = ABSOLUTE(.); + KEEP (*(.Level4InterruptVector.text)) + _Level4InterruptVector_text_end = ABSOLUTE(.); + _memmap_seg_iram0_8_end = ALIGN(0x8); + } >iram0_8_seg :iram0_8_phdr + + .DebugExceptionVector.literal : ALIGN(4) + { + _DebugExceptionVector_literal_start = ABSOLUTE(.); + *(.DebugExceptionVector.literal) + _DebugExceptionVector_literal_end = ABSOLUTE(.); + _memmap_seg_iram0_9_end = ALIGN(0x8); + } >iram0_9_seg :iram0_9_phdr + + .DebugExceptionVector.text : ALIGN(4) + { + _DebugExceptionVector_text_start = ABSOLUTE(.); + KEEP (*(.DebugExceptionVector.text)) + _DebugExceptionVector_text_end = ABSOLUTE(.); + _memmap_seg_iram0_10_end = ALIGN(0x8); + } >iram0_10_seg :iram0_10_phdr + + .NMIExceptionVector.literal : ALIGN(4) + { + _NMIExceptionVector_literal_start = ABSOLUTE(.); + *(.NMIExceptionVector.literal) + _NMIExceptionVector_literal_end = ABSOLUTE(.); + _memmap_seg_iram0_11_end = ALIGN(0x8); + } >iram0_11_seg :iram0_11_phdr + + .NMIExceptionVector.text : ALIGN(4) + { + _NMIExceptionVector_text_start = ABSOLUTE(.); + KEEP (*(.NMIExceptionVector.text)) + _NMIExceptionVector_text_end = ABSOLUTE(.); + _memmap_seg_iram0_12_end = ALIGN(0x8); + } >iram0_12_seg :iram0_12_phdr + + .KernelExceptionVector.literal : ALIGN(4) + { + _KernelExceptionVector_literal_start = ABSOLUTE(.); + *(.KernelExceptionVector.literal) + _KernelExceptionVector_literal_end = ABSOLUTE(.); + _memmap_seg_iram0_13_end = ALIGN(0x8); + } >iram0_13_seg :iram0_13_phdr + + .KernelExceptionVector.text : ALIGN(4) + { + _KernelExceptionVector_text_start = ABSOLUTE(.); + KEEP (*(.KernelExceptionVector.text)) + _KernelExceptionVector_text_end = ABSOLUTE(.); + _memmap_seg_iram0_14_end = ALIGN(0x8); + } >iram0_14_seg :iram0_14_phdr + + .UserExceptionVector.literal : ALIGN(4) + { + _UserExceptionVector_literal_start = ABSOLUTE(.); + *(.UserExceptionVector.literal) + _UserExceptionVector_literal_end = ABSOLUTE(.); + _memmap_seg_iram0_15_end = ALIGN(0x8); + } >iram0_15_seg :iram0_15_phdr + + .UserExceptionVector.text : ALIGN(4) + { + _UserExceptionVector_text_start = ABSOLUTE(.); + KEEP (*(.UserExceptionVector.text)) + _UserExceptionVector_text_end = ABSOLUTE(.); + _memmap_seg_iram0_16_end = ALIGN(0x8); + } >iram0_16_seg :iram0_16_phdr + + .DoubleExceptionVector.literal : ALIGN(4) + { + _DoubleExceptionVector_literal_start = ABSOLUTE(.); + *(.DoubleExceptionVector.literal) + _DoubleExceptionVector_literal_end = ABSOLUTE(.); + _memmap_seg_iram0_17_end = ALIGN(0x8); + } >iram0_17_seg :iram0_17_phdr + + .DoubleExceptionVector.text : ALIGN(4) + { + _DoubleExceptionVector_text_start = ABSOLUTE(.); + KEEP (*(.DoubleExceptionVector.text)) + _DoubleExceptionVector_text_end = ABSOLUTE(.); + _memmap_seg_iram0_18_end = ALIGN(0x8); + } >iram0_18_seg :iram0_18_phdr + + .Reset.text : ALIGN(4) + { + _Reset_text_start = ABSOLUTE(.); + *(.Reset.text) + _Reset_text_end = ABSOLUTE(.); + } >iram0_19_seg :iram0_19_phdr + + .iram0.text : ALIGN(4) + { + _iram0_text_start = ABSOLUTE(.); + *(.iram0.literal .iram.literal .iram.text.literal .iram0.text .iram.text) + _iram0_text_end = ABSOLUTE(.); + _memmap_seg_iram0_19_end = ALIGN(0x8); + } >iram0_19_seg :iram0_19_phdr + + .sram.shareaddr : ALIGN(4) + { + _sram_shareaddr_start = ABSOLUTE(.); + *(.sram.shareaddr) + _sram_shareaddr_end = ABSOLUTE(.); + } >sram0_seg :sram0_phdr + + .sram.rodata : ALIGN(4) + { + _sram_rodata_start = ABSOLUTE(.); + *(.sram.rodata) + _sram_rodata_end = ABSOLUTE(.); + } >sram0_seg :sram0_phdr + + .rodata : ALIGN(4) + { + _rodata_start = ABSOLUTE(.); + *(.rodata) + *(.rodata.*) + *(.gnu.linkonce.r.*) + *(.rodata1) + __XT_EXCEPTION_TABLE__ = ABSOLUTE(.); + KEEP (*(.xt_except_table)) + KEEP (*(.gcc_except_table)) + *(.gnu.linkonce.e.*) + *(.gnu.version_r) + KEEP (*(.eh_frame)) + /* C++ constructor and destructor tables, properly ordered: */ + KEEP (*crtbegin.o(.ctors)) + KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + KEEP (*crtbegin.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + /* C++ exception handlers table: */ + __XT_EXCEPTION_DESCS__ = ABSOLUTE(.); + *(.xt_except_desc) + *(.gnu.linkonce.h.*) + __XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.); + *(.xt_except_desc_end) + *(.dynamic) + *(.gnu.version_d) + . = ALIGN(4); /* this table MUST be 4-byte aligned */ + _bss_table_start = ABSOLUTE(.); + LONG(_vlpd_bss_start) + LONG(_vlpd_bss_end) + LONG(_efr_fr_hr_vlpd_bss_start) + LONG(_efr_fr_hr_vlpd_bss_end) + LONG(_amr_vlpd_bss_start) + LONG(_amr_vlpd_bss_end) + LONG(_amrwb_vlpd_bss_start) + LONG(_amrwb_vlpd_bss_end) + LONG(_ulpp_bss_start) + LONG(_ulpp_bss_end) + LONG(_dtsv3_bss_start) + LONG(_dtsv3_bss_end) + LONG(_dtsv4_bss_start) + LONG(_dtsv4_bss_end) + LONG(_dram0_bss_start) + LONG(_dram0_bss_end) + LONG(_bss_start) + LONG(_bss_end) + _bss_table_end = ABSOLUTE(.); + _rodata_end = ABSOLUTE(.); + } >sram0_seg :sram0_phdr + + .sram.text : ALIGN(4) + { + _sram_text_start = ABSOLUTE(.); + *(.sram.literal .sram.text) + _sram_text_end = ABSOLUTE(.); + } >sram0_seg :sram0_phdr + + .text : ALIGN(4) + { + _stext = .; + _text_start = ABSOLUTE(.); + *(.entry.text) + *(.init.literal) + KEEP(*(.init)) + *(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*) + *(.fini.literal) + KEEP(*(.fini)) + *(.gnu.version) + _text_end = ABSOLUTE(.); + _etext = .; + } >sram0_seg :sram0_phdr + + .sram.data : ALIGN(4) + { + _sram_data_start = ABSOLUTE(.); + *(.sram.data) + _sram_data_end = ABSOLUTE(.); + } >sram0_seg :sram0_phdr + + .data : ALIGN(4) + { + _data_start = ABSOLUTE(.); + *(.data) + *(.data.*) + *(.gnu.linkonce.d.*) + KEEP(*(.gnu.linkonce.d.*personality*)) + *(.data1) + *(.sdata) + *(.sdata.*) + *(.gnu.linkonce.s.*) + *(.sdata2) + *(.sdata2.*) + *(.gnu.linkonce.s2.*) + KEEP(*(.jcr)) + _data_end = ABSOLUTE(.); + } >sram0_seg :sram0_phdr + + .sram.uninit : ALIGN(4) + { + _sram_uninit_start = ABSOLUTE(.); + *(.sram.uninit) + _sram_uninit_end = ABSOLUTE(.); + } >sram0_seg :sram0_phdr + + .bss (NOLOAD) : ALIGN(8) + { + . = ALIGN (8); + _bss_start = ABSOLUTE(.); + *(.dynsbss) + *(.sbss) + *(.sbss.*) + *(.gnu.linkonce.sb.*) + *(.scommon) + *(.sbss2) + *(.sbss2.*) + *(.gnu.linkonce.sb2.*) + *(.dynbss) + *(.bss) + *(.bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + *(.sram.pool.bss) + *(.sram.bss) + . = ALIGN (8); + _bss_end = ABSOLUTE(.); + _memmap_seg_sram0_end = ALIGN(0x8); + } >sram0_seg :sram0_bss_phdr + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_info 0 : { *(.debug_info) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + .xt.insn 0 : + { + KEEP (*(.xt.insn)) + KEEP (*(.gnu.linkonce.x.*)) + } + .xt.prop 0 : + { + KEEP (*(.xt.prop)) + KEEP (*(.xt.prop.*)) + KEEP (*(.gnu.linkonce.prop.*)) + } + .xt.lit 0 : + { + KEEP (*(.xt.lit)) + KEEP (*(.xt.lit.*)) + KEEP (*(.gnu.linkonce.p.*)) + } + .debug.xt.callgraph 0 : + { + KEEP (*(.debug.xt.callgraph .debug.xt.callgraph.* .gnu.linkonce.xt.callgraph.*)) + } +} + diff --git a/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/ldscripts/elf32xtensa.xbn b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/ldscripts/elf32xtensa.xbn new file mode 100644 index 00000000..e226d641 --- /dev/null +++ b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/ldscripts/elf32xtensa.xbn @@ -0,0 +1,827 @@ +/* This linker script generated from xt-genldscripts.tpp for LSP hifi_hikey_lsp */ +/* Linker Script for ld -N */ +MEMORY +{ + sram0_seg : org = 0xC0000000, len = 0x408000 + old_vlpd_seg : org = 0xC0408000, len = 0x10000 + efr_fr_hr_vlpd_seg : org = 0xC0418000, len = 0x10000 + amr_vlpd_seg : org = 0xC0428000, len = 0x10000 + amrwb_vlpd_seg : org = 0xC0438000, len = 0x10000 + evrc_evrcb_vlpt_seg : org = 0xC0448000, len = 0x48000 + efr_fr_hr_vlpt_seg : org = 0xC0490000, len = 0x30000 + amr_vlpt_seg : org = 0xC04C0000, len = 0x20000 + amrwb_vlpt_seg : org = 0xC04E0000, len = 0x30000 + vlpt_seg : org = 0xC0510000, len = 0x48000 + vlpd_seg : org = 0xC0558000, len = 0x20000 + ulpp_seg : org = 0xC0578000, len = 0x40000 + dtsv3_seg : org = 0xC05B8000, len = 0x20000 + dtsv4_seg : org = 0xC05D8000, len = 0x28000 + dram0_0_seg : org = 0xE8058000, len = 0x28000 + iram0_0_seg : org = 0xE8080000, len = 0x300 + iram0_1_seg : org = 0xE8080300, len = 0x100 + iram0_2_seg : org = 0xE8080400, len = 0x178 + iram0_3_seg : org = 0xE8080578, len = 0x8 + iram0_4_seg : org = 0xE8080580, len = 0x38 + iram0_5_seg : org = 0xE80805B8, len = 0x8 + iram0_6_seg : org = 0xE80805C0, len = 0x38 + iram0_7_seg : org = 0xE80805F8, len = 0x8 + iram0_8_seg : org = 0xE8080600, len = 0x38 + iram0_9_seg : org = 0xE8080638, len = 0x8 + iram0_10_seg : org = 0xE8080640, len = 0x38 + iram0_11_seg : org = 0xE8080678, len = 0x48 + iram0_12_seg : org = 0xE80806C0, len = 0x38 + iram0_13_seg : org = 0xE80806F8, len = 0x8 + iram0_14_seg : org = 0xE8080700, len = 0x38 + iram0_15_seg : org = 0xE8080738, len = 0x8 + iram0_16_seg : org = 0xE8080740, len = 0x38 + iram0_17_seg : org = 0xE8080778, len = 0x48 + iram0_18_seg : org = 0xE80807C0, len = 0x40 + iram0_19_seg : org = 0xE8080800, len = 0xB800 +} + +PHDRS +{ + sram0_phdr PT_LOAD; + sram0_bss_phdr PT_LOAD; + old_vlpd_phdr PT_LOAD; + old_vlpd_bss_phdr PT_LOAD; + efr_fr_hr_vlpd_phdr PT_LOAD; + efr_fr_hr_vlpd_bss_phdr PT_LOAD; + amr_vlpd_phdr PT_LOAD; + amr_vlpd_bss_phdr PT_LOAD; + amrwb_vlpd_phdr PT_LOAD; + amrwb_vlpd_bss_phdr PT_LOAD; + evrc_evrcb_vlpt_phdr PT_LOAD; + efr_fr_hr_vlpt_phdr PT_LOAD; + amr_vlpt_phdr PT_LOAD; + amrwb_vlpt_phdr PT_LOAD; + vlpt_phdr PT_LOAD; + vlpd_phdr PT_LOAD; + ulpp_phdr PT_LOAD; + ulpp_bss_phdr PT_LOAD; + dtsv3_phdr PT_LOAD; + dtsv3_bss_phdr PT_LOAD; + dtsv4_phdr PT_LOAD; + dtsv4_bss_phdr PT_LOAD; + dram0_0_phdr PT_LOAD; + dram0_0_bss_phdr PT_LOAD; + iram0_0_phdr PT_LOAD; + iram0_1_phdr PT_LOAD; + iram0_2_phdr PT_LOAD; + iram0_3_phdr PT_LOAD; + iram0_4_phdr PT_LOAD; + iram0_5_phdr PT_LOAD; + iram0_6_phdr PT_LOAD; + iram0_7_phdr PT_LOAD; + iram0_8_phdr PT_LOAD; + iram0_9_phdr PT_LOAD; + iram0_10_phdr PT_LOAD; + iram0_11_phdr PT_LOAD; + iram0_12_phdr PT_LOAD; + iram0_13_phdr PT_LOAD; + iram0_14_phdr PT_LOAD; + iram0_15_phdr PT_LOAD; + iram0_16_phdr PT_LOAD; + iram0_17_phdr PT_LOAD; + iram0_18_phdr PT_LOAD; + iram0_19_phdr PT_LOAD; +} + + +/* Default entry point: */ +ENTRY(_ResetVector) + +/* Memory boundary addresses: */ +_memmap_mem_iram0_start = 0xe8080000; +_memmap_mem_iram0_end = 0xe808c000; +_memmap_mem_dram0_start = 0xe8058000; +_memmap_mem_dram0_end = 0xe8080000; +_memmap_mem_sram_start = 0xc0000000; +_memmap_mem_sram_end = 0xc0600000; + +/* Memory segment boundary addresses: */ +_memmap_seg_sram0_start = 0xc0000000; +_memmap_seg_sram0_max = 0xc0408000; +_memmap_seg_old_vlpd_start = 0xc0408000; +_memmap_seg_old_vlpd_max = 0xc0418000; +_memmap_seg_efr_fr_hr_vlpd_start = 0xc0418000; +_memmap_seg_efr_fr_hr_vlpd_max = 0xc0428000; +_memmap_seg_amr_vlpd_start = 0xc0428000; +_memmap_seg_amr_vlpd_max = 0xc0438000; +_memmap_seg_amrwb_vlpd_start = 0xc0438000; +_memmap_seg_amrwb_vlpd_max = 0xc0448000; +_memmap_seg_evrc_evrcb_vlpt_start = 0xc0448000; +_memmap_seg_evrc_evrcb_vlpt_max = 0xc0490000; +_memmap_seg_efr_fr_hr_vlpt_start = 0xc0490000; +_memmap_seg_efr_fr_hr_vlpt_max = 0xc04c0000; +_memmap_seg_amr_vlpt_start = 0xc04c0000; +_memmap_seg_amr_vlpt_max = 0xc04e0000; +_memmap_seg_amrwb_vlpt_start = 0xc04e0000; +_memmap_seg_amrwb_vlpt_max = 0xc0510000; +_memmap_seg_vlpt_start = 0xc0510000; +_memmap_seg_vlpt_max = 0xc0558000; +_memmap_seg_vlpd_start = 0xc0558000; +_memmap_seg_vlpd_max = 0xc0578000; +_memmap_seg_ulpp_start = 0xc0578000; +_memmap_seg_ulpp_max = 0xc05b8000; +_memmap_seg_dtsv3_start = 0xc05b8000; +_memmap_seg_dtsv3_max = 0xc05d8000; +_memmap_seg_dtsv4_start = 0xc05d8000; +_memmap_seg_dtsv4_max = 0xc0600000; +_memmap_seg_dram0_0_start = 0xe8058000; +_memmap_seg_dram0_0_max = 0xe8080000; +_memmap_seg_iram0_0_start = 0xe8080000; +_memmap_seg_iram0_0_max = 0xe8080300; +_memmap_seg_iram0_1_start = 0xe8080300; +_memmap_seg_iram0_1_max = 0xe8080400; +_memmap_seg_iram0_2_start = 0xe8080400; +_memmap_seg_iram0_2_max = 0xe8080578; +_memmap_seg_iram0_3_start = 0xe8080578; +_memmap_seg_iram0_3_max = 0xe8080580; +_memmap_seg_iram0_4_start = 0xe8080580; +_memmap_seg_iram0_4_max = 0xe80805b8; +_memmap_seg_iram0_5_start = 0xe80805b8; +_memmap_seg_iram0_5_max = 0xe80805c0; +_memmap_seg_iram0_6_start = 0xe80805c0; +_memmap_seg_iram0_6_max = 0xe80805f8; +_memmap_seg_iram0_7_start = 0xe80805f8; +_memmap_seg_iram0_7_max = 0xe8080600; +_memmap_seg_iram0_8_start = 0xe8080600; +_memmap_seg_iram0_8_max = 0xe8080638; +_memmap_seg_iram0_9_start = 0xe8080638; +_memmap_seg_iram0_9_max = 0xe8080640; +_memmap_seg_iram0_10_start = 0xe8080640; +_memmap_seg_iram0_10_max = 0xe8080678; +_memmap_seg_iram0_11_start = 0xe8080678; +_memmap_seg_iram0_11_max = 0xe80806c0; +_memmap_seg_iram0_12_start = 0xe80806c0; +_memmap_seg_iram0_12_max = 0xe80806f8; +_memmap_seg_iram0_13_start = 0xe80806f8; +_memmap_seg_iram0_13_max = 0xe8080700; +_memmap_seg_iram0_14_start = 0xe8080700; +_memmap_seg_iram0_14_max = 0xe8080738; +_memmap_seg_iram0_15_start = 0xe8080738; +_memmap_seg_iram0_15_max = 0xe8080740; +_memmap_seg_iram0_16_start = 0xe8080740; +_memmap_seg_iram0_16_max = 0xe8080778; +_memmap_seg_iram0_17_start = 0xe8080778; +_memmap_seg_iram0_17_max = 0xe80807c0; +_memmap_seg_iram0_18_start = 0xe80807c0; +_memmap_seg_iram0_18_max = 0xe8080800; +_memmap_seg_iram0_19_start = 0xe8080800; +_memmap_seg_iram0_19_max = 0xe808c000; + +_rom_store_table = 0; +PROVIDE(_memmap_vecbase_reset = 0xe8080400); +PROVIDE(_memmap_reset_vector = 0xe8080000); +/* Various memory-map dependent cache attribute settings: */ +_memmap_cacheattr_wb_base = 0x44000000; +_memmap_cacheattr_wt_base = 0x11000000; +_memmap_cacheattr_bp_base = 0x22000000; +_memmap_cacheattr_unused_mask = 0x00FFFFFF; +_memmap_cacheattr_wb_trapnull = 0x4422222F; +_memmap_cacheattr_wba_trapnull = 0x4422222F; +_memmap_cacheattr_wbna_trapnull = 0x5522222F; +_memmap_cacheattr_wt_trapnull = 0x1122222F; +_memmap_cacheattr_bp_trapnull = 0x2222222F; +_memmap_cacheattr_wb_strict = 0x44FFFFFF; +_memmap_cacheattr_wt_strict = 0x11FFFFFF; +_memmap_cacheattr_bp_strict = 0x22FFFFFF; +_memmap_cacheattr_wb_allvalid = 0x44222222; +_memmap_cacheattr_wt_allvalid = 0x11222222; +_memmap_cacheattr_bp_allvalid = 0x22222222; +PROVIDE(_memmap_cacheattr_reset = _memmap_cacheattr_wb_trapnull); + +SECTIONS +{ + + .vlpd.rodata : ALIGN(4) + { + _vlpd_rodata_start = ABSOLUTE(.); + *(.vlpd.rodata) + _vlpd_rodata_end = ABSOLUTE(.); + } >old_vlpd_seg :old_vlpd_phdr + + .vlpd.data : ALIGN(4) + { + _vlpd_data_start = ABSOLUTE(.); + *(.vlpd.data) + _vlpd_data_end = ABSOLUTE(.); + } >old_vlpd_seg :old_vlpd_phdr + + .vlpd.bss (NOLOAD) : ALIGN(8) + { + . = ALIGN (8); + _vlpd_bss_start = ABSOLUTE(.); + *(.vlpd.bss) + . = ALIGN (8); + _vlpd_bss_end = ABSOLUTE(.); + _memmap_seg_old_vlpd_end = ALIGN(0x8); + } >old_vlpd_seg :old_vlpd_bss_phdr + + .efr_fr_hr_vlpd.rodata : ALIGN(4) + { + _efr_fr_hr_vlpd_rodata_start = ABSOLUTE(.); + *(.efr_fr_hr_vlpd.rodata) + _efr_fr_hr_vlpd_rodata_end = ABSOLUTE(.); + } >efr_fr_hr_vlpd_seg :efr_fr_hr_vlpd_phdr + + .efr_fr_hr_vlpd.data : ALIGN(4) + { + _efr_fr_hr_vlpd_data_start = ABSOLUTE(.); + *(.efr_fr_hr_vlpd.data) + _efr_fr_hr_vlpd_data_end = ABSOLUTE(.); + } >efr_fr_hr_vlpd_seg :efr_fr_hr_vlpd_phdr + + .efr_fr_hr_vlpd.bss (NOLOAD) : ALIGN(8) + { + . = ALIGN (8); + _efr_fr_hr_vlpd_bss_start = ABSOLUTE(.); + *(.efr_fr_hr_vlpd.bss) + . = ALIGN (8); + _efr_fr_hr_vlpd_bss_end = ABSOLUTE(.); + _memmap_seg_efr_fr_hr_vlpd_end = ALIGN(0x8); + } >efr_fr_hr_vlpd_seg :efr_fr_hr_vlpd_bss_phdr + + .amr_vlpd.rodata : ALIGN(4) + { + _amr_vlpd_rodata_start = ABSOLUTE(.); + *(.amr_vlpd.rodata) + _amr_vlpd_rodata_end = ABSOLUTE(.); + } >amr_vlpd_seg :amr_vlpd_phdr + + .amr_vlpd.data : ALIGN(4) + { + _amr_vlpd_data_start = ABSOLUTE(.); + *(.amr_vlpd.data) + _amr_vlpd_data_end = ABSOLUTE(.); + } >amr_vlpd_seg :amr_vlpd_phdr + + .amr_vlpd.bss (NOLOAD) : ALIGN(8) + { + . = ALIGN (8); + _amr_vlpd_bss_start = ABSOLUTE(.); + *(.amr_vlpd.bss) + . = ALIGN (8); + _amr_vlpd_bss_end = ABSOLUTE(.); + _memmap_seg_amr_vlpd_end = ALIGN(0x8); + } >amr_vlpd_seg :amr_vlpd_bss_phdr + + .amrwb_vlpd.rodata : ALIGN(4) + { + _amrwb_vlpd_rodata_start = ABSOLUTE(.); + *(.amrwb_vlpd.rodata) + _amrwb_vlpd_rodata_end = ABSOLUTE(.); + } >amrwb_vlpd_seg :amrwb_vlpd_phdr + + .amrwb_vlpd.data : ALIGN(4) + { + _amrwb_vlpd_data_start = ABSOLUTE(.); + *(.amrwb_vlpd.data) + _amrwb_vlpd_data_end = ABSOLUTE(.); + } >amrwb_vlpd_seg :amrwb_vlpd_phdr + + .amrwb_vlpd.bss (NOLOAD) : ALIGN(8) + { + . = ALIGN (8); + _amrwb_vlpd_bss_start = ABSOLUTE(.); + *(.amrwb_vlpd.bss) + . = ALIGN (8); + _amrwb_vlpd_bss_end = ABSOLUTE(.); + _memmap_seg_amrwb_vlpd_end = ALIGN(0x8); + } >amrwb_vlpd_seg :amrwb_vlpd_bss_phdr + + .evrc_evrcb_vlpt.text : ALIGN(4) + { + _evrc_evrcb_vlpt_text_start = ABSOLUTE(.); + *(.evrc_evrcb_vlpt.literal .evrc_evrcb_vlpt.text) + _evrc_evrcb_vlpt_text_end = ABSOLUTE(.); + _memmap_seg_evrc_evrcb_vlpt_end = ALIGN(0x8); + } >evrc_evrcb_vlpt_seg :evrc_evrcb_vlpt_phdr + + .efr_fr_hr_vlpt.text : ALIGN(4) + { + _efr_fr_hr_vlpt_text_start = ABSOLUTE(.); + *(.efr_fr_hr_vlpt.literal .efr_fr_hr_vlpt.text) + _efr_fr_hr_vlpt_text_end = ABSOLUTE(.); + _memmap_seg_efr_fr_hr_vlpt_end = ALIGN(0x8); + } >efr_fr_hr_vlpt_seg :efr_fr_hr_vlpt_phdr + + .amr_vlpt.text : ALIGN(4) + { + _amr_vlpt_text_start = ABSOLUTE(.); + *(.amr_vlpt.literal .amr_vlpt.text) + _amr_vlpt_text_end = ABSOLUTE(.); + _memmap_seg_amr_vlpt_end = ALIGN(0x8); + } >amr_vlpt_seg :amr_vlpt_phdr + + .amrwb_vlpt.text : ALIGN(4) + { + _amrwb_vlpt_text_start = ABSOLUTE(.); + *(.amrwb_vlpt.literal .amrwb_vlpt.text) + _amrwb_vlpt_text_end = ABSOLUTE(.); + _memmap_seg_amrwb_vlpt_end = ALIGN(0x8); + } >amrwb_vlpt_seg :amrwb_vlpt_phdr + + .vlpt.text : ALIGN(4) + { + _vlpt_text_start = ABSOLUTE(.); + *(.vlpt.literal .vlpt.text) + _vlpt_text_end = ABSOLUTE(.); + _memmap_seg_vlpt_end = ALIGN(0x8); + } >vlpt_seg :vlpt_phdr + + .low_power_dyn_alloc : ALIGN(4) + { + _low_power_dyn_alloc_start = ABSOLUTE(.); + *(.low_power_dyn_alloc) + _low_power_dyn_alloc_end = ABSOLUTE(.); + _memmap_seg_vlpd_end = ALIGN(0x8); + } >vlpd_seg :vlpd_phdr + + .ulpp.rodata : ALIGN(4) + { + _ulpp_rodata_start = ABSOLUTE(.); + *(.ulpp.rodata) + _ulpp_rodata_end = ABSOLUTE(.); + } >ulpp_seg :ulpp_phdr + + .ulpp.data : ALIGN(4) + { + _ulpp_data_start = ABSOLUTE(.); + *(.ulpp.data) + _ulpp_data_end = ABSOLUTE(.); + } >ulpp_seg :ulpp_phdr + + .ulpp.text : ALIGN(4) + { + _ulpp_text_start = ABSOLUTE(.); + *(.ulpp.literal .ulpp.text) + _ulpp_text_end = ABSOLUTE(.); + } >ulpp_seg :ulpp_phdr + + .ulpp.bss (NOLOAD) : ALIGN(8) + { + . = ALIGN (8); + _ulpp_bss_start = ABSOLUTE(.); + *(.ulpp.bss) + . = ALIGN (8); + _ulpp_bss_end = ABSOLUTE(.); + _memmap_seg_ulpp_end = ALIGN(0x8); + } >ulpp_seg :ulpp_bss_phdr + + .dtsv3.rodata : ALIGN(4) + { + _dtsv3_rodata_start = ABSOLUTE(.); + *(.dtsv3.rodata) + _dtsv3_rodata_end = ABSOLUTE(.); + } >dtsv3_seg :dtsv3_phdr + + .dtsv3.data : ALIGN(4) + { + _dtsv3_data_start = ABSOLUTE(.); + *(.dtsv3.data) + _dtsv3_data_end = ABSOLUTE(.); + } >dtsv3_seg :dtsv3_phdr + + .dtsv3.text : ALIGN(4) + { + _dtsv3_text_start = ABSOLUTE(.); + *(.dtsv3.literal .dtsv3.text) + _dtsv3_text_end = ABSOLUTE(.); + } >dtsv3_seg :dtsv3_phdr + + .dtsv3.bss (NOLOAD) : ALIGN(8) + { + . = ALIGN (8); + _dtsv3_bss_start = ABSOLUTE(.); + *(.dtsv3.bss) + . = ALIGN (8); + _dtsv3_bss_end = ABSOLUTE(.); + _memmap_seg_dtsv3_end = ALIGN(0x8); + } >dtsv3_seg :dtsv3_bss_phdr + + .dtsv4.rodata : ALIGN(4) + { + _dtsv4_rodata_start = ABSOLUTE(.); + *(.dtsv4.rodata) + _dtsv4_rodata_end = ABSOLUTE(.); + } >dtsv4_seg :dtsv4_phdr + + .dtsv4.data : ALIGN(4) + { + _dtsv4_data_start = ABSOLUTE(.); + *(.dtsv4.data) + _dtsv4_data_end = ABSOLUTE(.); + } >dtsv4_seg :dtsv4_phdr + + .dtsv4.text : ALIGN(4) + { + _dtsv4_text_start = ABSOLUTE(.); + *(.dtsv4.literal .dtsv4.text) + _dtsv4_text_end = ABSOLUTE(.); + } >dtsv4_seg :dtsv4_phdr + + .dtsv4.bss (NOLOAD) : ALIGN(8) + { + . = ALIGN (8); + _dtsv4_bss_start = ABSOLUTE(.); + *(.dtsv4.bss) + . = ALIGN (8); + _dtsv4_bss_end = ABSOLUTE(.); + _memmap_seg_dtsv4_end = ALIGN(0x8); + } >dtsv4_seg :dtsv4_bss_phdr + + .dram0.rodata : ALIGN(4) + { + _dram0_rodata_start = ABSOLUTE(.); + *(.dram0.rodata) + *(.dram.rodata) + _dram0_rodata_end = ABSOLUTE(.); + } >dram0_0_seg :dram0_0_phdr + + .dram0.literal : ALIGN(4) + { + _dram0_literal_start = ABSOLUTE(.); + *(.dram0.literal) + *(.dram.literal) + _dram0_literal_end = ABSOLUTE(.); + } >dram0_0_seg :dram0_0_phdr + + .dram0.data : ALIGN(4) + { + _dram0_data_start = ABSOLUTE(.); + *(.dram0.data) + *(.dram.data) + _dram0_data_end = ABSOLUTE(.); + } >dram0_0_seg :dram0_0_phdr + + .dram0.bss (NOLOAD) : ALIGN(8) + { + . = ALIGN (8); + _dram0_bss_start = ABSOLUTE(.); + *(.dram0.bss) + *(.om.debug.bss) + *(.os.stack.bss) + . = ALIGN (8); + _dram0_bss_end = ABSOLUTE(.); + _end = ALIGN(0x8); + PROVIDE(end = ALIGN(0x8)); + _stack_sentry = ALIGN(0x8); + _memmap_seg_dram0_0_end = ALIGN(0x8); + } >dram0_0_seg :dram0_0_bss_phdr + __stack = 0xe8080000; + _heap_sentry = 0xe8080000; + + .ResetVector.text : ALIGN(4) + { + _ResetVector_text_start = ABSOLUTE(.); + KEEP (*(.ResetVector.text)) + _ResetVector_text_end = ABSOLUTE(.); + _memmap_seg_iram0_0_end = ALIGN(0x8); + } >iram0_0_seg :iram0_0_phdr + + .Reset.literal : ALIGN(4) + { + _Reset_literal_start = ABSOLUTE(.); + *(.Reset.literal) + _Reset_literal_end = ABSOLUTE(.); + _memmap_seg_iram0_1_end = ALIGN(0x8); + } >iram0_1_seg :iram0_1_phdr + + .WindowVectors.text : ALIGN(4) + { + _WindowVectors_text_start = ABSOLUTE(.); + KEEP (*(.WindowVectors.text)) + _WindowVectors_text_end = ABSOLUTE(.); + _memmap_seg_iram0_2_end = ALIGN(0x8); + } >iram0_2_seg :iram0_2_phdr + + .Level2InterruptVector.literal : ALIGN(4) + { + _Level2InterruptVector_literal_start = ABSOLUTE(.); + *(.Level2InterruptVector.literal) + _Level2InterruptVector_literal_end = ABSOLUTE(.); + _memmap_seg_iram0_3_end = ALIGN(0x8); + } >iram0_3_seg :iram0_3_phdr + + .Level2InterruptVector.text : ALIGN(4) + { + _Level2InterruptVector_text_start = ABSOLUTE(.); + KEEP (*(.Level2InterruptVector.text)) + _Level2InterruptVector_text_end = ABSOLUTE(.); + _memmap_seg_iram0_4_end = ALIGN(0x8); + } >iram0_4_seg :iram0_4_phdr + + .Level3InterruptVector.literal : ALIGN(4) + { + _Level3InterruptVector_literal_start = ABSOLUTE(.); + *(.Level3InterruptVector.literal) + _Level3InterruptVector_literal_end = ABSOLUTE(.); + _memmap_seg_iram0_5_end = ALIGN(0x8); + } >iram0_5_seg :iram0_5_phdr + + .Level3InterruptVector.text : ALIGN(4) + { + _Level3InterruptVector_text_start = ABSOLUTE(.); + KEEP (*(.Level3InterruptVector.text)) + _Level3InterruptVector_text_end = ABSOLUTE(.); + _memmap_seg_iram0_6_end = ALIGN(0x8); + } >iram0_6_seg :iram0_6_phdr + + .Level4InterruptVector.literal : ALIGN(4) + { + _Level4InterruptVector_literal_start = ABSOLUTE(.); + *(.Level4InterruptVector.literal) + _Level4InterruptVector_literal_end = ABSOLUTE(.); + _memmap_seg_iram0_7_end = ALIGN(0x8); + } >iram0_7_seg :iram0_7_phdr + + .Level4InterruptVector.text : ALIGN(4) + { + _Level4InterruptVector_text_start = ABSOLUTE(.); + KEEP (*(.Level4InterruptVector.text)) + _Level4InterruptVector_text_end = ABSOLUTE(.); + _memmap_seg_iram0_8_end = ALIGN(0x8); + } >iram0_8_seg :iram0_8_phdr + + .DebugExceptionVector.literal : ALIGN(4) + { + _DebugExceptionVector_literal_start = ABSOLUTE(.); + *(.DebugExceptionVector.literal) + _DebugExceptionVector_literal_end = ABSOLUTE(.); + _memmap_seg_iram0_9_end = ALIGN(0x8); + } >iram0_9_seg :iram0_9_phdr + + .DebugExceptionVector.text : ALIGN(4) + { + _DebugExceptionVector_text_start = ABSOLUTE(.); + KEEP (*(.DebugExceptionVector.text)) + _DebugExceptionVector_text_end = ABSOLUTE(.); + _memmap_seg_iram0_10_end = ALIGN(0x8); + } >iram0_10_seg :iram0_10_phdr + + .NMIExceptionVector.literal : ALIGN(4) + { + _NMIExceptionVector_literal_start = ABSOLUTE(.); + *(.NMIExceptionVector.literal) + _NMIExceptionVector_literal_end = ABSOLUTE(.); + _memmap_seg_iram0_11_end = ALIGN(0x8); + } >iram0_11_seg :iram0_11_phdr + + .NMIExceptionVector.text : ALIGN(4) + { + _NMIExceptionVector_text_start = ABSOLUTE(.); + KEEP (*(.NMIExceptionVector.text)) + _NMIExceptionVector_text_end = ABSOLUTE(.); + _memmap_seg_iram0_12_end = ALIGN(0x8); + } >iram0_12_seg :iram0_12_phdr + + .KernelExceptionVector.literal : ALIGN(4) + { + _KernelExceptionVector_literal_start = ABSOLUTE(.); + *(.KernelExceptionVector.literal) + _KernelExceptionVector_literal_end = ABSOLUTE(.); + _memmap_seg_iram0_13_end = ALIGN(0x8); + } >iram0_13_seg :iram0_13_phdr + + .KernelExceptionVector.text : ALIGN(4) + { + _KernelExceptionVector_text_start = ABSOLUTE(.); + KEEP (*(.KernelExceptionVector.text)) + _KernelExceptionVector_text_end = ABSOLUTE(.); + _memmap_seg_iram0_14_end = ALIGN(0x8); + } >iram0_14_seg :iram0_14_phdr + + .UserExceptionVector.literal : ALIGN(4) + { + _UserExceptionVector_literal_start = ABSOLUTE(.); + *(.UserExceptionVector.literal) + _UserExceptionVector_literal_end = ABSOLUTE(.); + _memmap_seg_iram0_15_end = ALIGN(0x8); + } >iram0_15_seg :iram0_15_phdr + + .UserExceptionVector.text : ALIGN(4) + { + _UserExceptionVector_text_start = ABSOLUTE(.); + KEEP (*(.UserExceptionVector.text)) + _UserExceptionVector_text_end = ABSOLUTE(.); + _memmap_seg_iram0_16_end = ALIGN(0x8); + } >iram0_16_seg :iram0_16_phdr + + .DoubleExceptionVector.literal : ALIGN(4) + { + _DoubleExceptionVector_literal_start = ABSOLUTE(.); + *(.DoubleExceptionVector.literal) + _DoubleExceptionVector_literal_end = ABSOLUTE(.); + _memmap_seg_iram0_17_end = ALIGN(0x8); + } >iram0_17_seg :iram0_17_phdr + + .DoubleExceptionVector.text : ALIGN(4) + { + _DoubleExceptionVector_text_start = ABSOLUTE(.); + KEEP (*(.DoubleExceptionVector.text)) + _DoubleExceptionVector_text_end = ABSOLUTE(.); + _memmap_seg_iram0_18_end = ALIGN(0x8); + } >iram0_18_seg :iram0_18_phdr + + .Reset.text : ALIGN(4) + { + _Reset_text_start = ABSOLUTE(.); + *(.Reset.text) + _Reset_text_end = ABSOLUTE(.); + } >iram0_19_seg :iram0_19_phdr + + .iram0.text : ALIGN(4) + { + _iram0_text_start = ABSOLUTE(.); + *(.iram0.literal .iram.literal .iram.text.literal .iram0.text .iram.text) + _iram0_text_end = ABSOLUTE(.); + _memmap_seg_iram0_19_end = ALIGN(0x8); + } >iram0_19_seg :iram0_19_phdr + + .sram.shareaddr : ALIGN(4) + { + _sram_shareaddr_start = ABSOLUTE(.); + *(.sram.shareaddr) + _sram_shareaddr_end = ABSOLUTE(.); + } >sram0_seg :sram0_phdr + + .sram.rodata : ALIGN(4) + { + _sram_rodata_start = ABSOLUTE(.); + *(.sram.rodata) + _sram_rodata_end = ABSOLUTE(.); + } >sram0_seg :sram0_phdr + + .rodata : ALIGN(4) + { + _rodata_start = ABSOLUTE(.); + *(.rodata) + *(.rodata.*) + *(.gnu.linkonce.r.*) + *(.rodata1) + __XT_EXCEPTION_TABLE__ = ABSOLUTE(.); + KEEP (*(.xt_except_table)) + KEEP (*(.gcc_except_table)) + *(.gnu.linkonce.e.*) + *(.gnu.version_r) + KEEP (*(.eh_frame)) + /* C++ constructor and destructor tables, properly ordered: */ + KEEP (*crtbegin.o(.ctors)) + KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + KEEP (*crtbegin.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + /* C++ exception handlers table: */ + __XT_EXCEPTION_DESCS__ = ABSOLUTE(.); + *(.xt_except_desc) + *(.gnu.linkonce.h.*) + __XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.); + *(.xt_except_desc_end) + *(.dynamic) + *(.gnu.version_d) + . = ALIGN(4); /* this table MUST be 4-byte aligned */ + _bss_table_start = ABSOLUTE(.); + LONG(_vlpd_bss_start) + LONG(_vlpd_bss_end) + LONG(_efr_fr_hr_vlpd_bss_start) + LONG(_efr_fr_hr_vlpd_bss_end) + LONG(_amr_vlpd_bss_start) + LONG(_amr_vlpd_bss_end) + LONG(_amrwb_vlpd_bss_start) + LONG(_amrwb_vlpd_bss_end) + LONG(_ulpp_bss_start) + LONG(_ulpp_bss_end) + LONG(_dtsv3_bss_start) + LONG(_dtsv3_bss_end) + LONG(_dtsv4_bss_start) + LONG(_dtsv4_bss_end) + LONG(_dram0_bss_start) + LONG(_dram0_bss_end) + LONG(_bss_start) + LONG(_bss_end) + _bss_table_end = ABSOLUTE(.); + _rodata_end = ABSOLUTE(.); + } >sram0_seg :sram0_phdr + + .sram.text : ALIGN(4) + { + _sram_text_start = ABSOLUTE(.); + *(.sram.literal .sram.text) + _sram_text_end = ABSOLUTE(.); + } >sram0_seg :sram0_phdr + + .text : ALIGN(4) + { + _stext = .; + _text_start = ABSOLUTE(.); + *(.entry.text) + *(.init.literal) + KEEP(*(.init)) + *(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*) + *(.fini.literal) + KEEP(*(.fini)) + *(.gnu.version) + _text_end = ABSOLUTE(.); + _etext = .; + } >sram0_seg :sram0_phdr + + .sram.data : ALIGN(4) + { + _sram_data_start = ABSOLUTE(.); + *(.sram.data) + _sram_data_end = ABSOLUTE(.); + } >sram0_seg :sram0_phdr + + .data : ALIGN(4) + { + _data_start = ABSOLUTE(.); + *(.data) + *(.data.*) + *(.gnu.linkonce.d.*) + KEEP(*(.gnu.linkonce.d.*personality*)) + *(.data1) + *(.sdata) + *(.sdata.*) + *(.gnu.linkonce.s.*) + *(.sdata2) + *(.sdata2.*) + *(.gnu.linkonce.s2.*) + KEEP(*(.jcr)) + _data_end = ABSOLUTE(.); + } >sram0_seg :sram0_phdr + + .sram.uninit : ALIGN(4) + { + _sram_uninit_start = ABSOLUTE(.); + *(.sram.uninit) + _sram_uninit_end = ABSOLUTE(.); + } >sram0_seg :sram0_phdr + + .bss (NOLOAD) : ALIGN(8) + { + . = ALIGN (8); + _bss_start = ABSOLUTE(.); + *(.dynsbss) + *(.sbss) + *(.sbss.*) + *(.gnu.linkonce.sb.*) + *(.scommon) + *(.sbss2) + *(.sbss2.*) + *(.gnu.linkonce.sb2.*) + *(.dynbss) + *(.bss) + *(.bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + *(.sram.pool.bss) + *(.sram.bss) + . = ALIGN (8); + _bss_end = ABSOLUTE(.); + _memmap_seg_sram0_end = ALIGN(0x8); + } >sram0_seg :sram0_bss_phdr + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_info 0 : { *(.debug_info) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + .xt.insn 0 : + { + KEEP (*(.xt.insn)) + KEEP (*(.gnu.linkonce.x.*)) + } + .xt.prop 0 : + { + KEEP (*(.xt.prop)) + KEEP (*(.xt.prop.*)) + KEEP (*(.gnu.linkonce.prop.*)) + } + .xt.lit 0 : + { + KEEP (*(.xt.lit)) + KEEP (*(.xt.lit.*)) + KEEP (*(.gnu.linkonce.p.*)) + } + .debug.xt.callgraph 0 : + { + KEEP (*(.debug.xt.callgraph .debug.xt.callgraph.* .gnu.linkonce.xt.callgraph.*)) + } +} + diff --git a/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/ldscripts/elf32xtensa.xn b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/ldscripts/elf32xtensa.xn new file mode 100644 index 00000000..17c05e16 --- /dev/null +++ b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/ldscripts/elf32xtensa.xn @@ -0,0 +1,827 @@ +/* This linker script generated from xt-genldscripts.tpp for LSP hifi_hikey_lsp */ +/* Linker Script for ld -n */ +MEMORY +{ + sram0_seg : org = 0xC0000000, len = 0x408000 + old_vlpd_seg : org = 0xC0408000, len = 0x10000 + efr_fr_hr_vlpd_seg : org = 0xC0418000, len = 0x10000 + amr_vlpd_seg : org = 0xC0428000, len = 0x10000 + amrwb_vlpd_seg : org = 0xC0438000, len = 0x10000 + evrc_evrcb_vlpt_seg : org = 0xC0448000, len = 0x48000 + efr_fr_hr_vlpt_seg : org = 0xC0490000, len = 0x30000 + amr_vlpt_seg : org = 0xC04C0000, len = 0x20000 + amrwb_vlpt_seg : org = 0xC04E0000, len = 0x30000 + vlpt_seg : org = 0xC0510000, len = 0x48000 + vlpd_seg : org = 0xC0558000, len = 0x20000 + ulpp_seg : org = 0xC0578000, len = 0x40000 + dtsv3_seg : org = 0xC05B8000, len = 0x20000 + dtsv4_seg : org = 0xC05D8000, len = 0x28000 + dram0_0_seg : org = 0xE8058000, len = 0x28000 + iram0_0_seg : org = 0xE8080000, len = 0x300 + iram0_1_seg : org = 0xE8080300, len = 0x100 + iram0_2_seg : org = 0xE8080400, len = 0x178 + iram0_3_seg : org = 0xE8080578, len = 0x8 + iram0_4_seg : org = 0xE8080580, len = 0x38 + iram0_5_seg : org = 0xE80805B8, len = 0x8 + iram0_6_seg : org = 0xE80805C0, len = 0x38 + iram0_7_seg : org = 0xE80805F8, len = 0x8 + iram0_8_seg : org = 0xE8080600, len = 0x38 + iram0_9_seg : org = 0xE8080638, len = 0x8 + iram0_10_seg : org = 0xE8080640, len = 0x38 + iram0_11_seg : org = 0xE8080678, len = 0x48 + iram0_12_seg : org = 0xE80806C0, len = 0x38 + iram0_13_seg : org = 0xE80806F8, len = 0x8 + iram0_14_seg : org = 0xE8080700, len = 0x38 + iram0_15_seg : org = 0xE8080738, len = 0x8 + iram0_16_seg : org = 0xE8080740, len = 0x38 + iram0_17_seg : org = 0xE8080778, len = 0x48 + iram0_18_seg : org = 0xE80807C0, len = 0x40 + iram0_19_seg : org = 0xE8080800, len = 0xB800 +} + +PHDRS +{ + sram0_phdr PT_LOAD; + sram0_bss_phdr PT_LOAD; + old_vlpd_phdr PT_LOAD; + old_vlpd_bss_phdr PT_LOAD; + efr_fr_hr_vlpd_phdr PT_LOAD; + efr_fr_hr_vlpd_bss_phdr PT_LOAD; + amr_vlpd_phdr PT_LOAD; + amr_vlpd_bss_phdr PT_LOAD; + amrwb_vlpd_phdr PT_LOAD; + amrwb_vlpd_bss_phdr PT_LOAD; + evrc_evrcb_vlpt_phdr PT_LOAD; + efr_fr_hr_vlpt_phdr PT_LOAD; + amr_vlpt_phdr PT_LOAD; + amrwb_vlpt_phdr PT_LOAD; + vlpt_phdr PT_LOAD; + vlpd_phdr PT_LOAD; + ulpp_phdr PT_LOAD; + ulpp_bss_phdr PT_LOAD; + dtsv3_phdr PT_LOAD; + dtsv3_bss_phdr PT_LOAD; + dtsv4_phdr PT_LOAD; + dtsv4_bss_phdr PT_LOAD; + dram0_0_phdr PT_LOAD; + dram0_0_bss_phdr PT_LOAD; + iram0_0_phdr PT_LOAD; + iram0_1_phdr PT_LOAD; + iram0_2_phdr PT_LOAD; + iram0_3_phdr PT_LOAD; + iram0_4_phdr PT_LOAD; + iram0_5_phdr PT_LOAD; + iram0_6_phdr PT_LOAD; + iram0_7_phdr PT_LOAD; + iram0_8_phdr PT_LOAD; + iram0_9_phdr PT_LOAD; + iram0_10_phdr PT_LOAD; + iram0_11_phdr PT_LOAD; + iram0_12_phdr PT_LOAD; + iram0_13_phdr PT_LOAD; + iram0_14_phdr PT_LOAD; + iram0_15_phdr PT_LOAD; + iram0_16_phdr PT_LOAD; + iram0_17_phdr PT_LOAD; + iram0_18_phdr PT_LOAD; + iram0_19_phdr PT_LOAD; +} + + +/* Default entry point: */ +ENTRY(_ResetVector) + +/* Memory boundary addresses: */ +_memmap_mem_iram0_start = 0xe8080000; +_memmap_mem_iram0_end = 0xe808c000; +_memmap_mem_dram0_start = 0xe8058000; +_memmap_mem_dram0_end = 0xe8080000; +_memmap_mem_sram_start = 0xc0000000; +_memmap_mem_sram_end = 0xc0600000; + +/* Memory segment boundary addresses: */ +_memmap_seg_sram0_start = 0xc0000000; +_memmap_seg_sram0_max = 0xc0408000; +_memmap_seg_old_vlpd_start = 0xc0408000; +_memmap_seg_old_vlpd_max = 0xc0418000; +_memmap_seg_efr_fr_hr_vlpd_start = 0xc0418000; +_memmap_seg_efr_fr_hr_vlpd_max = 0xc0428000; +_memmap_seg_amr_vlpd_start = 0xc0428000; +_memmap_seg_amr_vlpd_max = 0xc0438000; +_memmap_seg_amrwb_vlpd_start = 0xc0438000; +_memmap_seg_amrwb_vlpd_max = 0xc0448000; +_memmap_seg_evrc_evrcb_vlpt_start = 0xc0448000; +_memmap_seg_evrc_evrcb_vlpt_max = 0xc0490000; +_memmap_seg_efr_fr_hr_vlpt_start = 0xc0490000; +_memmap_seg_efr_fr_hr_vlpt_max = 0xc04c0000; +_memmap_seg_amr_vlpt_start = 0xc04c0000; +_memmap_seg_amr_vlpt_max = 0xc04e0000; +_memmap_seg_amrwb_vlpt_start = 0xc04e0000; +_memmap_seg_amrwb_vlpt_max = 0xc0510000; +_memmap_seg_vlpt_start = 0xc0510000; +_memmap_seg_vlpt_max = 0xc0558000; +_memmap_seg_vlpd_start = 0xc0558000; +_memmap_seg_vlpd_max = 0xc0578000; +_memmap_seg_ulpp_start = 0xc0578000; +_memmap_seg_ulpp_max = 0xc05b8000; +_memmap_seg_dtsv3_start = 0xc05b8000; +_memmap_seg_dtsv3_max = 0xc05d8000; +_memmap_seg_dtsv4_start = 0xc05d8000; +_memmap_seg_dtsv4_max = 0xc0600000; +_memmap_seg_dram0_0_start = 0xe8058000; +_memmap_seg_dram0_0_max = 0xe8080000; +_memmap_seg_iram0_0_start = 0xe8080000; +_memmap_seg_iram0_0_max = 0xe8080300; +_memmap_seg_iram0_1_start = 0xe8080300; +_memmap_seg_iram0_1_max = 0xe8080400; +_memmap_seg_iram0_2_start = 0xe8080400; +_memmap_seg_iram0_2_max = 0xe8080578; +_memmap_seg_iram0_3_start = 0xe8080578; +_memmap_seg_iram0_3_max = 0xe8080580; +_memmap_seg_iram0_4_start = 0xe8080580; +_memmap_seg_iram0_4_max = 0xe80805b8; +_memmap_seg_iram0_5_start = 0xe80805b8; +_memmap_seg_iram0_5_max = 0xe80805c0; +_memmap_seg_iram0_6_start = 0xe80805c0; +_memmap_seg_iram0_6_max = 0xe80805f8; +_memmap_seg_iram0_7_start = 0xe80805f8; +_memmap_seg_iram0_7_max = 0xe8080600; +_memmap_seg_iram0_8_start = 0xe8080600; +_memmap_seg_iram0_8_max = 0xe8080638; +_memmap_seg_iram0_9_start = 0xe8080638; +_memmap_seg_iram0_9_max = 0xe8080640; +_memmap_seg_iram0_10_start = 0xe8080640; +_memmap_seg_iram0_10_max = 0xe8080678; +_memmap_seg_iram0_11_start = 0xe8080678; +_memmap_seg_iram0_11_max = 0xe80806c0; +_memmap_seg_iram0_12_start = 0xe80806c0; +_memmap_seg_iram0_12_max = 0xe80806f8; +_memmap_seg_iram0_13_start = 0xe80806f8; +_memmap_seg_iram0_13_max = 0xe8080700; +_memmap_seg_iram0_14_start = 0xe8080700; +_memmap_seg_iram0_14_max = 0xe8080738; +_memmap_seg_iram0_15_start = 0xe8080738; +_memmap_seg_iram0_15_max = 0xe8080740; +_memmap_seg_iram0_16_start = 0xe8080740; +_memmap_seg_iram0_16_max = 0xe8080778; +_memmap_seg_iram0_17_start = 0xe8080778; +_memmap_seg_iram0_17_max = 0xe80807c0; +_memmap_seg_iram0_18_start = 0xe80807c0; +_memmap_seg_iram0_18_max = 0xe8080800; +_memmap_seg_iram0_19_start = 0xe8080800; +_memmap_seg_iram0_19_max = 0xe808c000; + +_rom_store_table = 0; +PROVIDE(_memmap_vecbase_reset = 0xe8080400); +PROVIDE(_memmap_reset_vector = 0xe8080000); +/* Various memory-map dependent cache attribute settings: */ +_memmap_cacheattr_wb_base = 0x44000000; +_memmap_cacheattr_wt_base = 0x11000000; +_memmap_cacheattr_bp_base = 0x22000000; +_memmap_cacheattr_unused_mask = 0x00FFFFFF; +_memmap_cacheattr_wb_trapnull = 0x4422222F; +_memmap_cacheattr_wba_trapnull = 0x4422222F; +_memmap_cacheattr_wbna_trapnull = 0x5522222F; +_memmap_cacheattr_wt_trapnull = 0x1122222F; +_memmap_cacheattr_bp_trapnull = 0x2222222F; +_memmap_cacheattr_wb_strict = 0x44FFFFFF; +_memmap_cacheattr_wt_strict = 0x11FFFFFF; +_memmap_cacheattr_bp_strict = 0x22FFFFFF; +_memmap_cacheattr_wb_allvalid = 0x44222222; +_memmap_cacheattr_wt_allvalid = 0x11222222; +_memmap_cacheattr_bp_allvalid = 0x22222222; +PROVIDE(_memmap_cacheattr_reset = _memmap_cacheattr_wb_trapnull); + +SECTIONS +{ + + .vlpd.rodata : ALIGN(4) + { + _vlpd_rodata_start = ABSOLUTE(.); + *(.vlpd.rodata) + _vlpd_rodata_end = ABSOLUTE(.); + } >old_vlpd_seg :old_vlpd_phdr + + .vlpd.data : ALIGN(4) + { + _vlpd_data_start = ABSOLUTE(.); + *(.vlpd.data) + _vlpd_data_end = ABSOLUTE(.); + } >old_vlpd_seg :old_vlpd_phdr + + .vlpd.bss (NOLOAD) : ALIGN(8) + { + . = ALIGN (8); + _vlpd_bss_start = ABSOLUTE(.); + *(.vlpd.bss) + . = ALIGN (8); + _vlpd_bss_end = ABSOLUTE(.); + _memmap_seg_old_vlpd_end = ALIGN(0x8); + } >old_vlpd_seg :old_vlpd_bss_phdr + + .efr_fr_hr_vlpd.rodata : ALIGN(4) + { + _efr_fr_hr_vlpd_rodata_start = ABSOLUTE(.); + *(.efr_fr_hr_vlpd.rodata) + _efr_fr_hr_vlpd_rodata_end = ABSOLUTE(.); + } >efr_fr_hr_vlpd_seg :efr_fr_hr_vlpd_phdr + + .efr_fr_hr_vlpd.data : ALIGN(4) + { + _efr_fr_hr_vlpd_data_start = ABSOLUTE(.); + *(.efr_fr_hr_vlpd.data) + _efr_fr_hr_vlpd_data_end = ABSOLUTE(.); + } >efr_fr_hr_vlpd_seg :efr_fr_hr_vlpd_phdr + + .efr_fr_hr_vlpd.bss (NOLOAD) : ALIGN(8) + { + . = ALIGN (8); + _efr_fr_hr_vlpd_bss_start = ABSOLUTE(.); + *(.efr_fr_hr_vlpd.bss) + . = ALIGN (8); + _efr_fr_hr_vlpd_bss_end = ABSOLUTE(.); + _memmap_seg_efr_fr_hr_vlpd_end = ALIGN(0x8); + } >efr_fr_hr_vlpd_seg :efr_fr_hr_vlpd_bss_phdr + + .amr_vlpd.rodata : ALIGN(4) + { + _amr_vlpd_rodata_start = ABSOLUTE(.); + *(.amr_vlpd.rodata) + _amr_vlpd_rodata_end = ABSOLUTE(.); + } >amr_vlpd_seg :amr_vlpd_phdr + + .amr_vlpd.data : ALIGN(4) + { + _amr_vlpd_data_start = ABSOLUTE(.); + *(.amr_vlpd.data) + _amr_vlpd_data_end = ABSOLUTE(.); + } >amr_vlpd_seg :amr_vlpd_phdr + + .amr_vlpd.bss (NOLOAD) : ALIGN(8) + { + . = ALIGN (8); + _amr_vlpd_bss_start = ABSOLUTE(.); + *(.amr_vlpd.bss) + . = ALIGN (8); + _amr_vlpd_bss_end = ABSOLUTE(.); + _memmap_seg_amr_vlpd_end = ALIGN(0x8); + } >amr_vlpd_seg :amr_vlpd_bss_phdr + + .amrwb_vlpd.rodata : ALIGN(4) + { + _amrwb_vlpd_rodata_start = ABSOLUTE(.); + *(.amrwb_vlpd.rodata) + _amrwb_vlpd_rodata_end = ABSOLUTE(.); + } >amrwb_vlpd_seg :amrwb_vlpd_phdr + + .amrwb_vlpd.data : ALIGN(4) + { + _amrwb_vlpd_data_start = ABSOLUTE(.); + *(.amrwb_vlpd.data) + _amrwb_vlpd_data_end = ABSOLUTE(.); + } >amrwb_vlpd_seg :amrwb_vlpd_phdr + + .amrwb_vlpd.bss (NOLOAD) : ALIGN(8) + { + . = ALIGN (8); + _amrwb_vlpd_bss_start = ABSOLUTE(.); + *(.amrwb_vlpd.bss) + . = ALIGN (8); + _amrwb_vlpd_bss_end = ABSOLUTE(.); + _memmap_seg_amrwb_vlpd_end = ALIGN(0x8); + } >amrwb_vlpd_seg :amrwb_vlpd_bss_phdr + + .evrc_evrcb_vlpt.text : ALIGN(4) + { + _evrc_evrcb_vlpt_text_start = ABSOLUTE(.); + *(.evrc_evrcb_vlpt.literal .evrc_evrcb_vlpt.text) + _evrc_evrcb_vlpt_text_end = ABSOLUTE(.); + _memmap_seg_evrc_evrcb_vlpt_end = ALIGN(0x8); + } >evrc_evrcb_vlpt_seg :evrc_evrcb_vlpt_phdr + + .efr_fr_hr_vlpt.text : ALIGN(4) + { + _efr_fr_hr_vlpt_text_start = ABSOLUTE(.); + *(.efr_fr_hr_vlpt.literal .efr_fr_hr_vlpt.text) + _efr_fr_hr_vlpt_text_end = ABSOLUTE(.); + _memmap_seg_efr_fr_hr_vlpt_end = ALIGN(0x8); + } >efr_fr_hr_vlpt_seg :efr_fr_hr_vlpt_phdr + + .amr_vlpt.text : ALIGN(4) + { + _amr_vlpt_text_start = ABSOLUTE(.); + *(.amr_vlpt.literal .amr_vlpt.text) + _amr_vlpt_text_end = ABSOLUTE(.); + _memmap_seg_amr_vlpt_end = ALIGN(0x8); + } >amr_vlpt_seg :amr_vlpt_phdr + + .amrwb_vlpt.text : ALIGN(4) + { + _amrwb_vlpt_text_start = ABSOLUTE(.); + *(.amrwb_vlpt.literal .amrwb_vlpt.text) + _amrwb_vlpt_text_end = ABSOLUTE(.); + _memmap_seg_amrwb_vlpt_end = ALIGN(0x8); + } >amrwb_vlpt_seg :amrwb_vlpt_phdr + + .vlpt.text : ALIGN(4) + { + _vlpt_text_start = ABSOLUTE(.); + *(.vlpt.literal .vlpt.text) + _vlpt_text_end = ABSOLUTE(.); + _memmap_seg_vlpt_end = ALIGN(0x8); + } >vlpt_seg :vlpt_phdr + + .low_power_dyn_alloc : ALIGN(4) + { + _low_power_dyn_alloc_start = ABSOLUTE(.); + *(.low_power_dyn_alloc) + _low_power_dyn_alloc_end = ABSOLUTE(.); + _memmap_seg_vlpd_end = ALIGN(0x8); + } >vlpd_seg :vlpd_phdr + + .ulpp.rodata : ALIGN(4) + { + _ulpp_rodata_start = ABSOLUTE(.); + *(.ulpp.rodata) + _ulpp_rodata_end = ABSOLUTE(.); + } >ulpp_seg :ulpp_phdr + + .ulpp.data : ALIGN(4) + { + _ulpp_data_start = ABSOLUTE(.); + *(.ulpp.data) + _ulpp_data_end = ABSOLUTE(.); + } >ulpp_seg :ulpp_phdr + + .ulpp.text : ALIGN(4) + { + _ulpp_text_start = ABSOLUTE(.); + *(.ulpp.literal .ulpp.text) + _ulpp_text_end = ABSOLUTE(.); + } >ulpp_seg :ulpp_phdr + + .ulpp.bss (NOLOAD) : ALIGN(8) + { + . = ALIGN (8); + _ulpp_bss_start = ABSOLUTE(.); + *(.ulpp.bss) + . = ALIGN (8); + _ulpp_bss_end = ABSOLUTE(.); + _memmap_seg_ulpp_end = ALIGN(0x8); + } >ulpp_seg :ulpp_bss_phdr + + .dtsv3.rodata : ALIGN(4) + { + _dtsv3_rodata_start = ABSOLUTE(.); + *(.dtsv3.rodata) + _dtsv3_rodata_end = ABSOLUTE(.); + } >dtsv3_seg :dtsv3_phdr + + .dtsv3.data : ALIGN(4) + { + _dtsv3_data_start = ABSOLUTE(.); + *(.dtsv3.data) + _dtsv3_data_end = ABSOLUTE(.); + } >dtsv3_seg :dtsv3_phdr + + .dtsv3.text : ALIGN(4) + { + _dtsv3_text_start = ABSOLUTE(.); + *(.dtsv3.literal .dtsv3.text) + _dtsv3_text_end = ABSOLUTE(.); + } >dtsv3_seg :dtsv3_phdr + + .dtsv3.bss (NOLOAD) : ALIGN(8) + { + . = ALIGN (8); + _dtsv3_bss_start = ABSOLUTE(.); + *(.dtsv3.bss) + . = ALIGN (8); + _dtsv3_bss_end = ABSOLUTE(.); + _memmap_seg_dtsv3_end = ALIGN(0x8); + } >dtsv3_seg :dtsv3_bss_phdr + + .dtsv4.rodata : ALIGN(4) + { + _dtsv4_rodata_start = ABSOLUTE(.); + *(.dtsv4.rodata) + _dtsv4_rodata_end = ABSOLUTE(.); + } >dtsv4_seg :dtsv4_phdr + + .dtsv4.data : ALIGN(4) + { + _dtsv4_data_start = ABSOLUTE(.); + *(.dtsv4.data) + _dtsv4_data_end = ABSOLUTE(.); + } >dtsv4_seg :dtsv4_phdr + + .dtsv4.text : ALIGN(4) + { + _dtsv4_text_start = ABSOLUTE(.); + *(.dtsv4.literal .dtsv4.text) + _dtsv4_text_end = ABSOLUTE(.); + } >dtsv4_seg :dtsv4_phdr + + .dtsv4.bss (NOLOAD) : ALIGN(8) + { + . = ALIGN (8); + _dtsv4_bss_start = ABSOLUTE(.); + *(.dtsv4.bss) + . = ALIGN (8); + _dtsv4_bss_end = ABSOLUTE(.); + _memmap_seg_dtsv4_end = ALIGN(0x8); + } >dtsv4_seg :dtsv4_bss_phdr + + .dram0.rodata : ALIGN(4) + { + _dram0_rodata_start = ABSOLUTE(.); + *(.dram0.rodata) + *(.dram.rodata) + _dram0_rodata_end = ABSOLUTE(.); + } >dram0_0_seg :dram0_0_phdr + + .dram0.literal : ALIGN(4) + { + _dram0_literal_start = ABSOLUTE(.); + *(.dram0.literal) + *(.dram.literal) + _dram0_literal_end = ABSOLUTE(.); + } >dram0_0_seg :dram0_0_phdr + + .dram0.data : ALIGN(4) + { + _dram0_data_start = ABSOLUTE(.); + *(.dram0.data) + *(.dram.data) + _dram0_data_end = ABSOLUTE(.); + } >dram0_0_seg :dram0_0_phdr + + .dram0.bss (NOLOAD) : ALIGN(8) + { + . = ALIGN (8); + _dram0_bss_start = ABSOLUTE(.); + *(.dram0.bss) + *(.om.debug.bss) + *(.os.stack.bss) + . = ALIGN (8); + _dram0_bss_end = ABSOLUTE(.); + _end = ALIGN(0x8); + PROVIDE(end = ALIGN(0x8)); + _stack_sentry = ALIGN(0x8); + _memmap_seg_dram0_0_end = ALIGN(0x8); + } >dram0_0_seg :dram0_0_bss_phdr + __stack = 0xe8080000; + _heap_sentry = 0xe8080000; + + .ResetVector.text : ALIGN(4) + { + _ResetVector_text_start = ABSOLUTE(.); + KEEP (*(.ResetVector.text)) + _ResetVector_text_end = ABSOLUTE(.); + _memmap_seg_iram0_0_end = ALIGN(0x8); + } >iram0_0_seg :iram0_0_phdr + + .Reset.literal : ALIGN(4) + { + _Reset_literal_start = ABSOLUTE(.); + *(.Reset.literal) + _Reset_literal_end = ABSOLUTE(.); + _memmap_seg_iram0_1_end = ALIGN(0x8); + } >iram0_1_seg :iram0_1_phdr + + .WindowVectors.text : ALIGN(4) + { + _WindowVectors_text_start = ABSOLUTE(.); + KEEP (*(.WindowVectors.text)) + _WindowVectors_text_end = ABSOLUTE(.); + _memmap_seg_iram0_2_end = ALIGN(0x8); + } >iram0_2_seg :iram0_2_phdr + + .Level2InterruptVector.literal : ALIGN(4) + { + _Level2InterruptVector_literal_start = ABSOLUTE(.); + *(.Level2InterruptVector.literal) + _Level2InterruptVector_literal_end = ABSOLUTE(.); + _memmap_seg_iram0_3_end = ALIGN(0x8); + } >iram0_3_seg :iram0_3_phdr + + .Level2InterruptVector.text : ALIGN(4) + { + _Level2InterruptVector_text_start = ABSOLUTE(.); + KEEP (*(.Level2InterruptVector.text)) + _Level2InterruptVector_text_end = ABSOLUTE(.); + _memmap_seg_iram0_4_end = ALIGN(0x8); + } >iram0_4_seg :iram0_4_phdr + + .Level3InterruptVector.literal : ALIGN(4) + { + _Level3InterruptVector_literal_start = ABSOLUTE(.); + *(.Level3InterruptVector.literal) + _Level3InterruptVector_literal_end = ABSOLUTE(.); + _memmap_seg_iram0_5_end = ALIGN(0x8); + } >iram0_5_seg :iram0_5_phdr + + .Level3InterruptVector.text : ALIGN(4) + { + _Level3InterruptVector_text_start = ABSOLUTE(.); + KEEP (*(.Level3InterruptVector.text)) + _Level3InterruptVector_text_end = ABSOLUTE(.); + _memmap_seg_iram0_6_end = ALIGN(0x8); + } >iram0_6_seg :iram0_6_phdr + + .Level4InterruptVector.literal : ALIGN(4) + { + _Level4InterruptVector_literal_start = ABSOLUTE(.); + *(.Level4InterruptVector.literal) + _Level4InterruptVector_literal_end = ABSOLUTE(.); + _memmap_seg_iram0_7_end = ALIGN(0x8); + } >iram0_7_seg :iram0_7_phdr + + .Level4InterruptVector.text : ALIGN(4) + { + _Level4InterruptVector_text_start = ABSOLUTE(.); + KEEP (*(.Level4InterruptVector.text)) + _Level4InterruptVector_text_end = ABSOLUTE(.); + _memmap_seg_iram0_8_end = ALIGN(0x8); + } >iram0_8_seg :iram0_8_phdr + + .DebugExceptionVector.literal : ALIGN(4) + { + _DebugExceptionVector_literal_start = ABSOLUTE(.); + *(.DebugExceptionVector.literal) + _DebugExceptionVector_literal_end = ABSOLUTE(.); + _memmap_seg_iram0_9_end = ALIGN(0x8); + } >iram0_9_seg :iram0_9_phdr + + .DebugExceptionVector.text : ALIGN(4) + { + _DebugExceptionVector_text_start = ABSOLUTE(.); + KEEP (*(.DebugExceptionVector.text)) + _DebugExceptionVector_text_end = ABSOLUTE(.); + _memmap_seg_iram0_10_end = ALIGN(0x8); + } >iram0_10_seg :iram0_10_phdr + + .NMIExceptionVector.literal : ALIGN(4) + { + _NMIExceptionVector_literal_start = ABSOLUTE(.); + *(.NMIExceptionVector.literal) + _NMIExceptionVector_literal_end = ABSOLUTE(.); + _memmap_seg_iram0_11_end = ALIGN(0x8); + } >iram0_11_seg :iram0_11_phdr + + .NMIExceptionVector.text : ALIGN(4) + { + _NMIExceptionVector_text_start = ABSOLUTE(.); + KEEP (*(.NMIExceptionVector.text)) + _NMIExceptionVector_text_end = ABSOLUTE(.); + _memmap_seg_iram0_12_end = ALIGN(0x8); + } >iram0_12_seg :iram0_12_phdr + + .KernelExceptionVector.literal : ALIGN(4) + { + _KernelExceptionVector_literal_start = ABSOLUTE(.); + *(.KernelExceptionVector.literal) + _KernelExceptionVector_literal_end = ABSOLUTE(.); + _memmap_seg_iram0_13_end = ALIGN(0x8); + } >iram0_13_seg :iram0_13_phdr + + .KernelExceptionVector.text : ALIGN(4) + { + _KernelExceptionVector_text_start = ABSOLUTE(.); + KEEP (*(.KernelExceptionVector.text)) + _KernelExceptionVector_text_end = ABSOLUTE(.); + _memmap_seg_iram0_14_end = ALIGN(0x8); + } >iram0_14_seg :iram0_14_phdr + + .UserExceptionVector.literal : ALIGN(4) + { + _UserExceptionVector_literal_start = ABSOLUTE(.); + *(.UserExceptionVector.literal) + _UserExceptionVector_literal_end = ABSOLUTE(.); + _memmap_seg_iram0_15_end = ALIGN(0x8); + } >iram0_15_seg :iram0_15_phdr + + .UserExceptionVector.text : ALIGN(4) + { + _UserExceptionVector_text_start = ABSOLUTE(.); + KEEP (*(.UserExceptionVector.text)) + _UserExceptionVector_text_end = ABSOLUTE(.); + _memmap_seg_iram0_16_end = ALIGN(0x8); + } >iram0_16_seg :iram0_16_phdr + + .DoubleExceptionVector.literal : ALIGN(4) + { + _DoubleExceptionVector_literal_start = ABSOLUTE(.); + *(.DoubleExceptionVector.literal) + _DoubleExceptionVector_literal_end = ABSOLUTE(.); + _memmap_seg_iram0_17_end = ALIGN(0x8); + } >iram0_17_seg :iram0_17_phdr + + .DoubleExceptionVector.text : ALIGN(4) + { + _DoubleExceptionVector_text_start = ABSOLUTE(.); + KEEP (*(.DoubleExceptionVector.text)) + _DoubleExceptionVector_text_end = ABSOLUTE(.); + _memmap_seg_iram0_18_end = ALIGN(0x8); + } >iram0_18_seg :iram0_18_phdr + + .Reset.text : ALIGN(4) + { + _Reset_text_start = ABSOLUTE(.); + *(.Reset.text) + _Reset_text_end = ABSOLUTE(.); + } >iram0_19_seg :iram0_19_phdr + + .iram0.text : ALIGN(4) + { + _iram0_text_start = ABSOLUTE(.); + *(.iram0.literal .iram.literal .iram.text.literal .iram0.text .iram.text) + _iram0_text_end = ABSOLUTE(.); + _memmap_seg_iram0_19_end = ALIGN(0x8); + } >iram0_19_seg :iram0_19_phdr + + .sram.shareaddr : ALIGN(4) + { + _sram_shareaddr_start = ABSOLUTE(.); + *(.sram.shareaddr) + _sram_shareaddr_end = ABSOLUTE(.); + } >sram0_seg :sram0_phdr + + .sram.rodata : ALIGN(4) + { + _sram_rodata_start = ABSOLUTE(.); + *(.sram.rodata) + _sram_rodata_end = ABSOLUTE(.); + } >sram0_seg :sram0_phdr + + .rodata : ALIGN(4) + { + _rodata_start = ABSOLUTE(.); + *(.rodata) + *(.rodata.*) + *(.gnu.linkonce.r.*) + *(.rodata1) + __XT_EXCEPTION_TABLE__ = ABSOLUTE(.); + KEEP (*(.xt_except_table)) + KEEP (*(.gcc_except_table)) + *(.gnu.linkonce.e.*) + *(.gnu.version_r) + KEEP (*(.eh_frame)) + /* C++ constructor and destructor tables, properly ordered: */ + KEEP (*crtbegin.o(.ctors)) + KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + KEEP (*crtbegin.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + /* C++ exception handlers table: */ + __XT_EXCEPTION_DESCS__ = ABSOLUTE(.); + *(.xt_except_desc) + *(.gnu.linkonce.h.*) + __XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.); + *(.xt_except_desc_end) + *(.dynamic) + *(.gnu.version_d) + . = ALIGN(4); /* this table MUST be 4-byte aligned */ + _bss_table_start = ABSOLUTE(.); + LONG(_vlpd_bss_start) + LONG(_vlpd_bss_end) + LONG(_efr_fr_hr_vlpd_bss_start) + LONG(_efr_fr_hr_vlpd_bss_end) + LONG(_amr_vlpd_bss_start) + LONG(_amr_vlpd_bss_end) + LONG(_amrwb_vlpd_bss_start) + LONG(_amrwb_vlpd_bss_end) + LONG(_ulpp_bss_start) + LONG(_ulpp_bss_end) + LONG(_dtsv3_bss_start) + LONG(_dtsv3_bss_end) + LONG(_dtsv4_bss_start) + LONG(_dtsv4_bss_end) + LONG(_dram0_bss_start) + LONG(_dram0_bss_end) + LONG(_bss_start) + LONG(_bss_end) + _bss_table_end = ABSOLUTE(.); + _rodata_end = ABSOLUTE(.); + } >sram0_seg :sram0_phdr + + .sram.text : ALIGN(4) + { + _sram_text_start = ABSOLUTE(.); + *(.sram.literal .sram.text) + _sram_text_end = ABSOLUTE(.); + } >sram0_seg :sram0_phdr + + .text : ALIGN(4) + { + _stext = .; + _text_start = ABSOLUTE(.); + *(.entry.text) + *(.init.literal) + KEEP(*(.init)) + *(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*) + *(.fini.literal) + KEEP(*(.fini)) + *(.gnu.version) + _text_end = ABSOLUTE(.); + _etext = .; + } >sram0_seg :sram0_phdr + + .sram.data : ALIGN(4) + { + _sram_data_start = ABSOLUTE(.); + *(.sram.data) + _sram_data_end = ABSOLUTE(.); + } >sram0_seg :sram0_phdr + + .data : ALIGN(4) + { + _data_start = ABSOLUTE(.); + *(.data) + *(.data.*) + *(.gnu.linkonce.d.*) + KEEP(*(.gnu.linkonce.d.*personality*)) + *(.data1) + *(.sdata) + *(.sdata.*) + *(.gnu.linkonce.s.*) + *(.sdata2) + *(.sdata2.*) + *(.gnu.linkonce.s2.*) + KEEP(*(.jcr)) + _data_end = ABSOLUTE(.); + } >sram0_seg :sram0_phdr + + .sram.uninit : ALIGN(4) + { + _sram_uninit_start = ABSOLUTE(.); + *(.sram.uninit) + _sram_uninit_end = ABSOLUTE(.); + } >sram0_seg :sram0_phdr + + .bss (NOLOAD) : ALIGN(8) + { + . = ALIGN (8); + _bss_start = ABSOLUTE(.); + *(.dynsbss) + *(.sbss) + *(.sbss.*) + *(.gnu.linkonce.sb.*) + *(.scommon) + *(.sbss2) + *(.sbss2.*) + *(.gnu.linkonce.sb2.*) + *(.dynbss) + *(.bss) + *(.bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + *(.sram.pool.bss) + *(.sram.bss) + . = ALIGN (8); + _bss_end = ABSOLUTE(.); + _memmap_seg_sram0_end = ALIGN(0x8); + } >sram0_seg :sram0_bss_phdr + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_info 0 : { *(.debug_info) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + .xt.insn 0 : + { + KEEP (*(.xt.insn)) + KEEP (*(.gnu.linkonce.x.*)) + } + .xt.prop 0 : + { + KEEP (*(.xt.prop)) + KEEP (*(.xt.prop.*)) + KEEP (*(.gnu.linkonce.prop.*)) + } + .xt.lit 0 : + { + KEEP (*(.xt.lit)) + KEEP (*(.xt.lit.*)) + KEEP (*(.gnu.linkonce.p.*)) + } + .debug.xt.callgraph 0 : + { + KEEP (*(.debug.xt.callgraph .debug.xt.callgraph.* .gnu.linkonce.xt.callgraph.*)) + } +} + diff --git a/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/ldscripts/elf32xtensa.xr b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/ldscripts/elf32xtensa.xr new file mode 100644 index 00000000..3e9f189a --- /dev/null +++ b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/ldscripts/elf32xtensa.xr @@ -0,0 +1,42 @@ +/* This linker script generated from xt-genldscripts.tpp for LSP hifi_hikey_lsp */ +/* Linker Script for ld -r or ld -i */ + +/* Default entry point: */ +ENTRY(_ResetVector) + +SECTIONS +{ + + .text 0 : + { + *(.literal .text) + } + + .bss 0 : + { + *(.dynsbss) + *(.sbss) + *(.scommon) + *(.dynbss) + *(.bss) + *(COMMON) + } + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_info 0 : { *(.debug_info) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } +} + diff --git a/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/ldscripts/elf32xtensa.xu b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/ldscripts/elf32xtensa.xu new file mode 100644 index 00000000..d8e1986d --- /dev/null +++ b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/ldscripts/elf32xtensa.xu @@ -0,0 +1,42 @@ +/* This linker script generated from xt-genldscripts.tpp for LSP hifi_hikey_lsp */ +/* Linker Script for ld -Ur */ + +/* Default entry point: */ +ENTRY(_ResetVector) + +SECTIONS +{ + + .text 0 : + { + *(.literal .text) + } + + .bss 0 : + { + *(.dynsbss) + *(.sbss) + *(.scommon) + *(.dynbss) + *(.bss) + *(COMMON) + } + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_info 0 : { *(.debug_info) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } +} + diff --git a/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/memmap.xmm b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/memmap.xmm new file mode 100644 index 00000000..c7a94bc8 --- /dev/null +++ b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/memmap.xmm @@ -0,0 +1,49 @@ + + +BEGIN iram0 +0xe8080000: instRam : iram0 : 0xc000 : executable, writable ; + iram0_0 : F : 0xe8080000 - 0xe80802ff : .ResetVector.text; + iram0_1 : C : 0xe8080300 - 0xe80803ff : .Reset.literal; + iram0_2 : F : 0xe8080400 - 0xe8080577 : .WindowVectors.text; + iram0_3 : C : 0xe8080578 - 0xe808057f : .Level2InterruptVector.literal; + iram0_4 : F : 0xe8080580 - 0xe80805b7 : .Level2InterruptVector.text; + iram0_5 : C : 0xe80805b8 - 0xe80805bf : .Level3InterruptVector.literal; + iram0_6 : F : 0xe80805c0 - 0xe80805f7 : .Level3InterruptVector.text; + iram0_7 : C : 0xe80805f8 - 0xe80805ff : .Level4InterruptVector.literal; + iram0_8 : F : 0xe8080600 - 0xe8080637 : .Level4InterruptVector.text; + iram0_9 : C : 0xe8080638 - 0xe808063f : .DebugExceptionVector.literal; + iram0_10 : F : 0xe8080640 - 0xe8080677 : .DebugExceptionVector.text; + iram0_11 : C : 0xe8080678 - 0xe80806bf : .NMIExceptionVector.literal; + iram0_12 : F : 0xe80806c0 - 0xe80806f7 : .NMIExceptionVector.text; + iram0_13 : C : 0xe80806f8 - 0xe80806ff : .KernelExceptionVector.literal; + iram0_14 : F : 0xe8080700 - 0xe8080737 : .KernelExceptionVector.text; + iram0_15 : C : 0xe8080738 - 0xe808073f : .UserExceptionVector.literal; + iram0_16 : F : 0xe8080740 - 0xe8080777 : .UserExceptionVector.text; + iram0_17 : C : 0xe8080778 - 0xe80807bf : .DoubleExceptionVector.literal; + iram0_18 : F : 0xe80807c0 - 0xe80807ff : .DoubleExceptionVector.text; + iram0_19 : C : 0xe8080800 - 0xe808bfff : .iram0.literal .Reset.text .iram0.text; +END iram0 + +BEGIN dram0 +0xe8058000: dataRam : dram0 : 0x28000 : writable ; + dram0_0 : C : 0xe8058000 - 0xe807ffff : STACK : HEAP : .dram0.rodata .dram0.literal .dram0.data .dram0.bss .om.debug.bss .os.stack.bss; +END dram0 + +BEGIN sram +0xc0000000: sysram : sram : 0x600000 : executable, writable ; + sram0 : C : 0xc0000000 - 0xC0407FFF : .sram.shareaddr .sram.rodata .rodata .sram.literal .literal .sram.text .text .sram.data .data .sram.uninit .sram.pool.bss .sram.bss .bss; + old_vlpd : C : 0xC0408000 - 0xC0417FFF : .vlpd.rodata .vlpd.data .vlpd.bss; + efr_fr_hr_vlpd : C : 0xC0418000 - 0xC0427FFF : .efr_fr_hr_vlpd.rodata .efr_fr_hr_vlpd.data .efr_fr_hr_vlpd.bss; + amr_vlpd : C : 0xC0428000 - 0xC0437FFF : .amr_vlpd.rodata .amr_vlpd.data .amr_vlpd.bss; + amrwb_vlpd : C : 0xC0438000 - 0xC0447FFF : .amrwb_vlpd.rodata .amrwb_vlpd.data .amrwb_vlpd.bss; + evrc_evrcb_vlpt : C : 0xC0448000 - 0xC048FFFF : .evrc_evrcb_vlpt.literal .evrc_evrcb_vlpt.text; + efr_fr_hr_vlpt : C : 0xC0490000 - 0xC04BFFFF : .efr_fr_hr_vlpt.literal .efr_fr_hr_vlpt.text; + amr_vlpt : C : 0xC04C0000 - 0xC04DFFFF : .amr_vlpt.literal .amr_vlpt.text; + amrwb_vlpt : C : 0xC04E0000 -0xC050FFFF : .amrwb_vlpt.literal .amrwb_vlpt.text; + vlpt : C : 0xC0510000 - 0xC0557FFF : .vlpt.literal .vlpt.text; + vlpd : C : 0xC0558000 - 0xC0577FFF : .low_power_dyn_alloc; + ulpp : C : 0xc0578000 - 0xc05b7fff : .ulpp.rodata .ulpp.data .ulpp.literal .ulpp.text .ulpp.bss; + dtsv3 : C : 0xc05b8000 - 0xc05d7fff : .dtsv3.rodata .dtsv3.data .dtsv3.literal .dtsv3.text .dtsv3.bss; + dtsv4 : C : 0xc05d8000 - 0xc05fffff : .dtsv4.rodata .dtsv4.data .dtsv4.literal .dtsv4.text .dtsv4.bss; +END sram + diff --git a/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/min-rt.parm b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/min-rt.parm new file mode 100644 index 00000000..25083eeb --- /dev/null +++ b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/min-rt.parm @@ -0,0 +1,15 @@ +// Memory map file to generate linker scripts for programs without board I/O. + +// $Id: //depot/rel/Cottonwood/Xtensa/SWConfig/ldscripts/min-rt.parm#1 $ + +// Customer ID=9470; Build=0x42f97; Copyright (c) 2004-2007 by Tensilica Inc. ALL RIGHTS RESERVED. +// These coded instructions, statements, and computer programs are the +// copyrighted works and confidential proprietary information of Tensilica Inc. +// They may not be modified, copied, reproduced, distributed, or disclosed to +// third parties in any manner, medium, or form, in whole or in part, without +// the prior written consent of Tensilica Inc. + +// Show more details if configuration targets the XT2000 board: +INCLUDE_XT2000_MEMORIES = try +RESERVE_SEGMENT_AREA = ".i_ocram.text 0x7800 + 0 start : .d_ocram.data 0x5000 + 0 start" + diff --git a/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/specs b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/specs new file mode 100644 index 00000000..2988e02a --- /dev/null +++ b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/specs @@ -0,0 +1,22 @@ +# Customer ID=9470; Build=0x42f97; Copyright (c) 2001-2010 by Tensilica Inc. ALL RIGHTS RESERVED. +# These coded instructions, statements, and computer programs are the +# copyrighted works and confidential proprietary information of Tensilica Inc. +# They may not be modified, copied, reproduced, distributed, or disclosed to +# third parties in any manner, medium, or form, in whole or in part, without +# the prior written consent of Tensilica Inc. + + +# The %O suffix on the start and end files indicates that the system's +# standard suffix for object files (e.g., ".o") should be appended. +# The %s suffix tells the compiler driver to search for the file in the +# list of known locations for startfiles. + +*startfile: +crt1-boards%O%s crti%O%s crtbegin%O%s _sharedvectors%O%s _vectors%O%s + +*endfile: +crtend%O%s crtn%O%s + +*lib: +-lc -lgloss -lminrt -lc -lhandler-reset -lhandlers-board -lminrt -lhal -lc + diff --git a/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/tag b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/tag new file mode 100644 index 00000000..7be80f2a --- /dev/null +++ b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/tag @@ -0,0 +1,3 @@ +#This file is generated by Xplorer, do not edit. +#Mon Aug 26 15:41:31 CST 2013 +standardlsp=min-rt diff --git a/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/user.parm b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/user.parm new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/user.parm diff --git a/hifi/xaf/hifi-dpf/build_hikey/map_hikey.txt b/hifi/xaf/hifi-dpf/build_hikey/map_hikey.txt new file mode 100644 index 00000000..58a3efce --- /dev/null +++ b/hifi/xaf/hifi-dpf/build_hikey/map_hikey.txt @@ -0,0 +1,2167 @@ +Archive member included because of file (symbol) + +../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a(xa_vorbis_dec.o) + objs/hikey/xa-vorbis-decoder.o (xa_vorbis_dec) +/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(windowspill_asm.o) + objs/hikey/arch_hifi330.o (xthal_window_spill_nw) +/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_invalidate.o) + objs/hikey/xf-shmem.o (xthal_dcache_region_invalidate) +/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_writeback.o) + objs/hikey/xf-shmem.o (xthal_dcache_region_writeback) +/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--hw_configid0.o) + /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_invalidate.o) (xthals_hw_configid0) +/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--hw_configid1.o) + /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_invalidate.o) (xthals_hw_configid1) +/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--release_major.o) + /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_invalidate.o) (xthals_release_major) +/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--release_minor.o) + /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_invalidate.o) (xthals_release_minor) +/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--get_intenable.o) + objs/hikey/cpu_c.o (xthal_get_intenable) +/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--set_intenable.o) + objs/hikey/cpu_c.o (xthal_set_intenable) +/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--restore_extra_nw.o) + objs/hikey/arch_hifi330.o (xthal_restore_extra_nw) +/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--save_extra_nw.o) + objs/hikey/arch_hifi330.o (xthal_save_extra_nw) +/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-on.o) + objs/hikey/xf-main.o (_xtos_ints_on) +/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-off.o) + objs/hikey/mutex.o (_xtos_ints_off) +/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(interrupt-table.o) + /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-on.o) (_xtos_intstruct) +/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memchr.o) + ../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a(xa_vorbis_dec.o) (memchr) +/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcmp.o) + ../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a(xa_vorbis_dec.o) (memcmp) +/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcpy.o) + objs/hikey/xf-io.o (memcpy) +/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memset.o) + objs/hikey/xf-io.o (memset) +/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-qsort.o) + ../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a(xa_vorbis_dec.o) (qsort) +/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-strncmp.o) + objs/hikey/xa-factory.o (strncmp) +/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divsi3.o) + ../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a(xa_vorbis_dec.o) (__divsi3) +/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_modsi3.o) + ../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a(xa_vorbis_dec.o) (__modsi3) +/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_addsubdf3.o) + objs/hikey/xf-core.o (__adddf3) +/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_muldf3.o) + objs/hikey/dsp_debug.o (__muldf3) +/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_cmpdf2.o) + objs/hikey/dsp_debug.o (__ltdf2) +/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfsi.o) + objs/hikey/xf-core.o (__fixunsdfsi) +/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfdi.o) + objs/hikey/dsp_debug.o (__fixunsdfdi) +/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatsidf.o) + objs/hikey/xf-core.o (__floatunsidf) +/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatdidf.o) + objs/hikey/dsp_debug.o (__floatundidf) +/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divdi3.o) + ../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a(xa_vorbis_dec.o) (__divdi3) +/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_udivdi3.o) + objs/hikey/dsp_debug.o (__udivdi3) +/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_umoddi3.o) + objs/hikey/dsp_debug.o (__umoddi3) +/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memcpy.o) + ../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a(xa_vorbis_dec.o) (__vec_memcpy) +/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memset.o) + ../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a(xa_vorbis_dec.o) (__vec_memset) +/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_div_df.o) + objs/hikey/xf-core.o (__divdf3) +/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_df.o) + /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_div_df.o) (__propagateFloat64NaN) +/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_div.o) + /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_div_df.o) (__estimateDiv64To32) + +Memory Configuration + +Name Origin Length Attributes +sram0_seg 0xc0000000 0x00408000 +old_vlpd_seg 0xc0408000 0x00010000 +efr_fr_hr_vlpd_seg 0xc0418000 0x00010000 +amr_vlpd_seg 0xc0428000 0x00010000 +amrwb_vlpd_seg 0xc0438000 0x00010000 +evrc_evrcb_vlpt_seg 0xc0448000 0x00048000 +efr_fr_hr_vlpt_seg 0xc0490000 0x00030000 +amr_vlpt_seg 0xc04c0000 0x00020000 +amrwb_vlpt_seg 0xc04e0000 0x00030000 +vlpt_seg 0xc0510000 0x00048000 +vlpd_seg 0xc0558000 0x00020000 +ulpp_seg 0xc0578000 0x00040000 +dtsv3_seg 0xc05b8000 0x00020000 +dtsv4_seg 0xc05d8000 0x00028000 +dram0_0_seg 0xe8058000 0x00028000 +iram0_0_seg 0xe8080000 0x00000300 +iram0_1_seg 0xe8080300 0x00000100 +iram0_2_seg 0xe8080400 0x00000178 +iram0_3_seg 0xe8080578 0x00000008 +iram0_4_seg 0xe8080580 0x00000038 +iram0_5_seg 0xe80805b8 0x00000008 +iram0_6_seg 0xe80805c0 0x00000038 +iram0_7_seg 0xe80805f8 0x00000008 +iram0_8_seg 0xe8080600 0x00000038 +iram0_9_seg 0xe8080638 0x00000008 +iram0_10_seg 0xe8080640 0x00000038 +iram0_11_seg 0xe8080678 0x00000048 +iram0_12_seg 0xe80806c0 0x00000038 +iram0_13_seg 0xe80806f8 0x00000008 +iram0_14_seg 0xe8080700 0x00000038 +iram0_15_seg 0xe8080738 0x00000008 +iram0_16_seg 0xe8080740 0x00000038 +iram0_17_seg 0xe8080778 0x00000048 +iram0_18_seg 0xe80807c0 0x00000040 +iram0_19_seg 0xe8080800 0x0000b800 +*default* 0x00000000 0xffffffff + +Linker script and memory map + +LOAD objs/hikey/cpu_c.o +LOAD objs/hikey/dsp_debug.o +LOAD objs/hikey/dsp_comm.o +LOAD objs/hikey/mutex.o +LOAD objs/hikey/rbtree.o +LOAD objs/hikey/xf-core.o +LOAD objs/hikey/xf-io.o +LOAD objs/hikey/xf-mem.o +LOAD objs/hikey/xf-msg.o +LOAD objs/hikey/xf-sched.o +LOAD objs/hikey/xa-factory.o +LOAD objs/hikey/xf-shmem.o +LOAD objs/hikey/tinyvprintf.o +LOAD objs/hikey/xf-isr.o +LOAD objs/hikey/gdbstub.o +LOAD objs/hikey/xa-class-base.o +LOAD objs/hikey/xa-class-audio-codec.o +LOAD objs/hikey/xa-class-mixer.o +LOAD objs/hikey/xf-main.o +LOAD objs/hikey/xa-pcm.o +LOAD objs/hikey/xa-vorbis-decoder.o +LOAD objs/hikey/xa-mixer.o +LOAD objs/hikey/reset.o +LOAD objs/hikey/int_vector.o +LOAD objs/hikey/arch_hifi330.o +LOAD objs/hikey/gdbstub-entry.o +LOAD ../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a +LOAD /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a +LOAD /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a +LOAD /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a +LOAD /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a + 0xe8080000 _memmap_mem_iram0_start = 0xe8080000 + 0xe808c000 _memmap_mem_iram0_end = 0xe808c000 + 0xe8058000 _memmap_mem_dram0_start = 0xe8058000 + 0xe8080000 _memmap_mem_dram0_end = 0xe8080000 + 0xc0000000 _memmap_mem_sram_start = 0xc0000000 + 0xc0600000 _memmap_mem_sram_end = 0xc0600000 + 0xc0000000 _memmap_seg_sram0_start = 0xc0000000 + 0xc0408000 _memmap_seg_sram0_max = 0xc0408000 + 0xc0408000 _memmap_seg_old_vlpd_start = 0xc0408000 + 0xc0418000 _memmap_seg_old_vlpd_max = 0xc0418000 + 0xc0418000 _memmap_seg_efr_fr_hr_vlpd_start = 0xc0418000 + 0xc0428000 _memmap_seg_efr_fr_hr_vlpd_max = 0xc0428000 + 0xc0428000 _memmap_seg_amr_vlpd_start = 0xc0428000 + 0xc0438000 _memmap_seg_amr_vlpd_max = 0xc0438000 + 0xc0438000 _memmap_seg_amrwb_vlpd_start = 0xc0438000 + 0xc0448000 _memmap_seg_amrwb_vlpd_max = 0xc0448000 + 0xc0448000 _memmap_seg_evrc_evrcb_vlpt_start = 0xc0448000 + 0xc0490000 _memmap_seg_evrc_evrcb_vlpt_max = 0xc0490000 + 0xc0490000 _memmap_seg_efr_fr_hr_vlpt_start = 0xc0490000 + 0xc04c0000 _memmap_seg_efr_fr_hr_vlpt_max = 0xc04c0000 + 0xc04c0000 _memmap_seg_amr_vlpt_start = 0xc04c0000 + 0xc04e0000 _memmap_seg_amr_vlpt_max = 0xc04e0000 + 0xc04e0000 _memmap_seg_amrwb_vlpt_start = 0xc04e0000 + 0xc0510000 _memmap_seg_amrwb_vlpt_max = 0xc0510000 + 0xc0510000 _memmap_seg_vlpt_start = 0xc0510000 + 0xc0558000 _memmap_seg_vlpt_max = 0xc0558000 + 0xc0558000 _memmap_seg_vlpd_start = 0xc0558000 + 0xc0578000 _memmap_seg_vlpd_max = 0xc0578000 + 0xc0578000 _memmap_seg_ulpp_start = 0xc0578000 + 0xc05b8000 _memmap_seg_ulpp_max = 0xc05b8000 + 0xc05b8000 _memmap_seg_dtsv3_start = 0xc05b8000 + 0xc05d8000 _memmap_seg_dtsv3_max = 0xc05d8000 + 0xc05d8000 _memmap_seg_dtsv4_start = 0xc05d8000 + 0xc0600000 _memmap_seg_dtsv4_max = 0xc0600000 + 0xe8058000 _memmap_seg_dram0_0_start = 0xe8058000 + 0xe8080000 _memmap_seg_dram0_0_max = 0xe8080000 + 0xe8080000 _memmap_seg_iram0_0_start = 0xe8080000 + 0xe8080300 _memmap_seg_iram0_0_max = 0xe8080300 + 0xe8080300 _memmap_seg_iram0_1_start = 0xe8080300 + 0xe8080400 _memmap_seg_iram0_1_max = 0xe8080400 + 0xe8080400 _memmap_seg_iram0_2_start = 0xe8080400 + 0xe8080578 _memmap_seg_iram0_2_max = 0xe8080578 + 0xe8080578 _memmap_seg_iram0_3_start = 0xe8080578 + 0xe8080580 _memmap_seg_iram0_3_max = 0xe8080580 + 0xe8080580 _memmap_seg_iram0_4_start = 0xe8080580 + 0xe80805b8 _memmap_seg_iram0_4_max = 0xe80805b8 + 0xe80805b8 _memmap_seg_iram0_5_start = 0xe80805b8 + 0xe80805c0 _memmap_seg_iram0_5_max = 0xe80805c0 + 0xe80805c0 _memmap_seg_iram0_6_start = 0xe80805c0 + 0xe80805f8 _memmap_seg_iram0_6_max = 0xe80805f8 + 0xe80805f8 _memmap_seg_iram0_7_start = 0xe80805f8 + 0xe8080600 _memmap_seg_iram0_7_max = 0xe8080600 + 0xe8080600 _memmap_seg_iram0_8_start = 0xe8080600 + 0xe8080638 _memmap_seg_iram0_8_max = 0xe8080638 + 0xe8080638 _memmap_seg_iram0_9_start = 0xe8080638 + 0xe8080640 _memmap_seg_iram0_9_max = 0xe8080640 + 0xe8080640 _memmap_seg_iram0_10_start = 0xe8080640 + 0xe8080678 _memmap_seg_iram0_10_max = 0xe8080678 + 0xe8080678 _memmap_seg_iram0_11_start = 0xe8080678 + 0xe80806c0 _memmap_seg_iram0_11_max = 0xe80806c0 + 0xe80806c0 _memmap_seg_iram0_12_start = 0xe80806c0 + 0xe80806f8 _memmap_seg_iram0_12_max = 0xe80806f8 + 0xe80806f8 _memmap_seg_iram0_13_start = 0xe80806f8 + 0xe8080700 _memmap_seg_iram0_13_max = 0xe8080700 + 0xe8080700 _memmap_seg_iram0_14_start = 0xe8080700 + 0xe8080738 _memmap_seg_iram0_14_max = 0xe8080738 + 0xe8080738 _memmap_seg_iram0_15_start = 0xe8080738 + 0xe8080740 _memmap_seg_iram0_15_max = 0xe8080740 + 0xe8080740 _memmap_seg_iram0_16_start = 0xe8080740 + 0xe8080778 _memmap_seg_iram0_16_max = 0xe8080778 + 0xe8080778 _memmap_seg_iram0_17_start = 0xe8080778 + 0xe80807c0 _memmap_seg_iram0_17_max = 0xe80807c0 + 0xe80807c0 _memmap_seg_iram0_18_start = 0xe80807c0 + 0xe8080800 _memmap_seg_iram0_18_max = 0xe8080800 + 0xe8080800 _memmap_seg_iram0_19_start = 0xe8080800 + 0xe808c000 _memmap_seg_iram0_19_max = 0xe808c000 + 0x00000000 _rom_store_table = 0x0 + 0xe8080400 PROVIDE (_memmap_vecbase_reset, 0xe8080400) + 0xe8080000 PROVIDE (_memmap_reset_vector, 0xe8080000) + 0x44000000 _memmap_cacheattr_wb_base = 0x44000000 + 0x11000000 _memmap_cacheattr_wt_base = 0x11000000 + 0x22000000 _memmap_cacheattr_bp_base = 0x22000000 + 0x00ffffff _memmap_cacheattr_unused_mask = 0xffffff + 0x4422222f _memmap_cacheattr_wb_trapnull = 0x4422222f + 0x4422222f _memmap_cacheattr_wba_trapnull = 0x4422222f + 0x5522222f _memmap_cacheattr_wbna_trapnull = 0x5522222f + 0x1122222f _memmap_cacheattr_wt_trapnull = 0x1122222f + 0x2222222f _memmap_cacheattr_bp_trapnull = 0x2222222f + 0x44ffffff _memmap_cacheattr_wb_strict = 0x44ffffff + 0x11ffffff _memmap_cacheattr_wt_strict = 0x11ffffff + 0x22ffffff _memmap_cacheattr_bp_strict = 0x22ffffff + 0x44222222 _memmap_cacheattr_wb_allvalid = 0x44222222 + 0x11222222 _memmap_cacheattr_wt_allvalid = 0x11222222 + 0x22222222 _memmap_cacheattr_bp_allvalid = 0x22222222 + 0x4422222f PROVIDE (_memmap_cacheattr_reset, _memmap_cacheattr_wb_trapnull) + +.vlpd.rodata 0xc0408000 0x0 + 0xc0408000 _vlpd_rodata_start = ABSOLUTE (.) + *(.vlpd.rodata) + 0xc0408000 _vlpd_rodata_end = ABSOLUTE (.) + +.vlpd.data 0xc0408000 0x0 + 0xc0408000 _vlpd_data_start = ABSOLUTE (.) + *(.vlpd.data) + 0xc0408000 _vlpd_data_end = ABSOLUTE (.) + +.vlpd.bss 0xc0408000 0x0 + 0xc0408000 . = ALIGN (0x8) + 0xc0408000 _vlpd_bss_start = ABSOLUTE (.) + *(.vlpd.bss) + 0xc0408000 . = ALIGN (0x8) + 0xc0408000 _vlpd_bss_end = ABSOLUTE (.) + 0xc0408000 _memmap_seg_old_vlpd_end = ALIGN (0x8) + +.efr_fr_hr_vlpd.rodata + 0xc0418000 0x0 + 0xc0418000 _efr_fr_hr_vlpd_rodata_start = ABSOLUTE (.) + *(.efr_fr_hr_vlpd.rodata) + 0xc0418000 _efr_fr_hr_vlpd_rodata_end = ABSOLUTE (.) + +.efr_fr_hr_vlpd.data + 0xc0418000 0x0 + 0xc0418000 _efr_fr_hr_vlpd_data_start = ABSOLUTE (.) + *(.efr_fr_hr_vlpd.data) + 0xc0418000 _efr_fr_hr_vlpd_data_end = ABSOLUTE (.) + +.efr_fr_hr_vlpd.bss + 0xc0418000 0x0 + 0xc0418000 . = ALIGN (0x8) + 0xc0418000 _efr_fr_hr_vlpd_bss_start = ABSOLUTE (.) + *(.efr_fr_hr_vlpd.bss) + 0xc0418000 . = ALIGN (0x8) + 0xc0418000 _efr_fr_hr_vlpd_bss_end = ABSOLUTE (.) + 0xc0418000 _memmap_seg_efr_fr_hr_vlpd_end = ALIGN (0x8) + +.amr_vlpd.rodata + 0xc0428000 0x0 + 0xc0428000 _amr_vlpd_rodata_start = ABSOLUTE (.) + *(.amr_vlpd.rodata) + 0xc0428000 _amr_vlpd_rodata_end = ABSOLUTE (.) + +.amr_vlpd.data 0xc0428000 0x0 + 0xc0428000 _amr_vlpd_data_start = ABSOLUTE (.) + *(.amr_vlpd.data) + 0xc0428000 _amr_vlpd_data_end = ABSOLUTE (.) + +.amr_vlpd.bss 0xc0428000 0x0 + 0xc0428000 . = ALIGN (0x8) + 0xc0428000 _amr_vlpd_bss_start = ABSOLUTE (.) + *(.amr_vlpd.bss) + 0xc0428000 . = ALIGN (0x8) + 0xc0428000 _amr_vlpd_bss_end = ABSOLUTE (.) + 0xc0428000 _memmap_seg_amr_vlpd_end = ALIGN (0x8) + +.amrwb_vlpd.rodata + 0xc0438000 0x0 + 0xc0438000 _amrwb_vlpd_rodata_start = ABSOLUTE (.) + *(.amrwb_vlpd.rodata) + 0xc0438000 _amrwb_vlpd_rodata_end = ABSOLUTE (.) + +.amrwb_vlpd.data + 0xc0438000 0x0 + 0xc0438000 _amrwb_vlpd_data_start = ABSOLUTE (.) + *(.amrwb_vlpd.data) + 0xc0438000 _amrwb_vlpd_data_end = ABSOLUTE (.) + +.amrwb_vlpd.bss + 0xc0438000 0x0 + 0xc0438000 . = ALIGN (0x8) + 0xc0438000 _amrwb_vlpd_bss_start = ABSOLUTE (.) + *(.amrwb_vlpd.bss) + 0xc0438000 . = ALIGN (0x8) + 0xc0438000 _amrwb_vlpd_bss_end = ABSOLUTE (.) + 0xc0438000 _memmap_seg_amrwb_vlpd_end = ALIGN (0x8) + +.evrc_evrcb_vlpt.text + 0xc0448000 0x0 + 0xc0448000 _evrc_evrcb_vlpt_text_start = ABSOLUTE (.) + *(.evrc_evrcb_vlpt.literal .evrc_evrcb_vlpt.text) + 0xc0448000 _evrc_evrcb_vlpt_text_end = ABSOLUTE (.) + 0xc0448000 _memmap_seg_evrc_evrcb_vlpt_end = ALIGN (0x8) + +.efr_fr_hr_vlpt.text + 0xc0490000 0x0 + 0xc0490000 _efr_fr_hr_vlpt_text_start = ABSOLUTE (.) + *(.efr_fr_hr_vlpt.literal .efr_fr_hr_vlpt.text) + 0xc0490000 _efr_fr_hr_vlpt_text_end = ABSOLUTE (.) + 0xc0490000 _memmap_seg_efr_fr_hr_vlpt_end = ALIGN (0x8) + +.amr_vlpt.text 0xc04c0000 0x0 + 0xc04c0000 _amr_vlpt_text_start = ABSOLUTE (.) + *(.amr_vlpt.literal .amr_vlpt.text) + 0xc04c0000 _amr_vlpt_text_end = ABSOLUTE (.) + 0xc04c0000 _memmap_seg_amr_vlpt_end = ALIGN (0x8) + +.amrwb_vlpt.text + 0xc04e0000 0x0 + 0xc04e0000 _amrwb_vlpt_text_start = ABSOLUTE (.) + *(.amrwb_vlpt.literal .amrwb_vlpt.text) + 0xc04e0000 _amrwb_vlpt_text_end = ABSOLUTE (.) + 0xc04e0000 _memmap_seg_amrwb_vlpt_end = ALIGN (0x8) + +.vlpt.text 0xc0510000 0x0 + 0xc0510000 _vlpt_text_start = ABSOLUTE (.) + *(.vlpt.literal .vlpt.text) + 0xc0510000 _vlpt_text_end = ABSOLUTE (.) + 0xc0510000 _memmap_seg_vlpt_end = ALIGN (0x8) + +.low_power_dyn_alloc + 0xc0558000 0x0 + 0xc0558000 _low_power_dyn_alloc_start = ABSOLUTE (.) + *(.low_power_dyn_alloc) + 0xc0558000 _low_power_dyn_alloc_end = ABSOLUTE (.) + 0xc0558000 _memmap_seg_vlpd_end = ALIGN (0x8) + +.ulpp.rodata 0xc0578000 0x0 + 0xc0578000 _ulpp_rodata_start = ABSOLUTE (.) + *(.ulpp.rodata) + 0xc0578000 _ulpp_rodata_end = ABSOLUTE (.) + +.ulpp.data 0xc0578000 0x0 + 0xc0578000 _ulpp_data_start = ABSOLUTE (.) + *(.ulpp.data) + 0xc0578000 _ulpp_data_end = ABSOLUTE (.) + +.ulpp.text 0xc0578000 0x0 + 0xc0578000 _ulpp_text_start = ABSOLUTE (.) + *(.ulpp.literal .ulpp.text) + 0xc0578000 _ulpp_text_end = ABSOLUTE (.) + +.ulpp.bss 0xc0578000 0x0 + 0xc0578000 . = ALIGN (0x8) + 0xc0578000 _ulpp_bss_start = ABSOLUTE (.) + *(.ulpp.bss) + 0xc0578000 . = ALIGN (0x8) + 0xc0578000 _ulpp_bss_end = ABSOLUTE (.) + 0xc0578000 _memmap_seg_ulpp_end = ALIGN (0x8) + +.dtsv3.rodata 0xc05b8000 0x0 + 0xc05b8000 _dtsv3_rodata_start = ABSOLUTE (.) + *(.dtsv3.rodata) + 0xc05b8000 _dtsv3_rodata_end = ABSOLUTE (.) + +.dtsv3.data 0xc05b8000 0x0 + 0xc05b8000 _dtsv3_data_start = ABSOLUTE (.) + *(.dtsv3.data) + 0xc05b8000 _dtsv3_data_end = ABSOLUTE (.) + +.dtsv3.text 0xc05b8000 0x0 + 0xc05b8000 _dtsv3_text_start = ABSOLUTE (.) + *(.dtsv3.literal .dtsv3.text) + 0xc05b8000 _dtsv3_text_end = ABSOLUTE (.) + +.dtsv3.bss 0xc05b8000 0x0 + 0xc05b8000 . = ALIGN (0x8) + 0xc05b8000 _dtsv3_bss_start = ABSOLUTE (.) + *(.dtsv3.bss) + 0xc05b8000 . = ALIGN (0x8) + 0xc05b8000 _dtsv3_bss_end = ABSOLUTE (.) + 0xc05b8000 _memmap_seg_dtsv3_end = ALIGN (0x8) + +.dtsv4.rodata 0xc05d8000 0x0 + 0xc05d8000 _dtsv4_rodata_start = ABSOLUTE (.) + *(.dtsv4.rodata) + 0xc05d8000 _dtsv4_rodata_end = ABSOLUTE (.) + +.dtsv4.data 0xc05d8000 0x0 + 0xc05d8000 _dtsv4_data_start = ABSOLUTE (.) + *(.dtsv4.data) + 0xc05d8000 _dtsv4_data_end = ABSOLUTE (.) + +.dtsv4.text 0xc05d8000 0x0 + 0xc05d8000 _dtsv4_text_start = ABSOLUTE (.) + *(.dtsv4.literal .dtsv4.text) + 0xc05d8000 _dtsv4_text_end = ABSOLUTE (.) + +.dtsv4.bss 0xc05d8000 0x0 + 0xc05d8000 . = ALIGN (0x8) + 0xc05d8000 _dtsv4_bss_start = ABSOLUTE (.) + *(.dtsv4.bss) + 0xc05d8000 . = ALIGN (0x8) + 0xc05d8000 _dtsv4_bss_end = ABSOLUTE (.) + 0xc05d8000 _memmap_seg_dtsv4_end = ALIGN (0x8) + +.dram0.rodata 0xe8058000 0x0 + 0xe8058000 _dram0_rodata_start = ABSOLUTE (.) + *(.dram0.rodata) + *(.dram.rodata) + 0xe8058000 _dram0_rodata_end = ABSOLUTE (.) + +.dram0.literal 0xe8058000 0x0 + 0xe8058000 _dram0_literal_start = ABSOLUTE (.) + *(.dram0.literal) + *(.dram.literal) + 0xe8058000 _dram0_literal_end = ABSOLUTE (.) + +.dram0.data 0xe8058000 0x51 + 0xe8058000 _dram0_data_start = ABSOLUTE (.) + *(.dram0.data) + .dram0.data 0xe8058000 0x50 objs/hikey/int_vector.o + 0xe8058030 g_awVosCoprocOwnerSa + 0xe8058038 g_strVosPanicMessage + .dram0.data 0xe8058050 0x1 objs/hikey/arch_hifi330.o + *(.dram.data) + 0xe8058051 _dram0_data_end = ABSOLUTE (.) + +.dram0.bss 0xe8058058 0x0 + 0xe8058058 . = ALIGN (0x8) + 0xe8058058 _dram0_bss_start = ABSOLUTE (.) + *(.dram0.bss) + *(.om.debug.bss) + *(.os.stack.bss) + 0xe8058058 . = ALIGN (0x8) + 0xe8058058 _dram0_bss_end = ABSOLUTE (.) + 0xe8058058 _end = ALIGN (0x8) + 0xe8058058 PROVIDE (end, ALIGN (0x8)) + 0xe8058058 _stack_sentry = ALIGN (0x8) + 0xe8058058 _memmap_seg_dram0_0_end = ALIGN (0x8) + 0xe8080000 __stack = 0xe8080000 + 0xe8080000 _heap_sentry = 0xe8080000 + +.ResetVector.text + 0xe8080000 0x3 + 0xe8080000 _ResetVector_text_start = ABSOLUTE (.) + *(.ResetVector.text) + .ResetVector.text + 0xe8080000 0x3 objs/hikey/reset.o + 0xe8080000 _ResetVector + 0xe8080003 _ResetVector_text_end = ABSOLUTE (.) + 0xe8080008 _memmap_seg_iram0_0_end = ALIGN (0x8) + +.Reset.literal 0xe8080300 0x40 + 0xe8080300 _Reset_literal_start = ABSOLUTE (.) + *(.Reset.literal) + .Reset.literal + 0xe8080300 0x40 objs/hikey/reset.o + 0xe8080340 _Reset_literal_end = ABSOLUTE (.) + 0xe8080340 _memmap_seg_iram0_1_end = ALIGN (0x8) + +.WindowVectors.text + 0xe8080400 0x16a + 0xe8080400 _WindowVectors_text_start = ABSOLUTE (.) + *(.WindowVectors.text) + .WindowVectors.text + 0xe8080400 0x16a objs/hikey/int_vector.o + 0xe8080400 _WindowOverflow4 + 0xe8080440 _WindowUnderflow4 + 0xe8080450 OS_AllocaException + 0xe8080480 _WindowOverflow8 + 0xe80804c0 _WindowUnderflow8 + 0xe8080500 _WindowOverflow12 + 0xe8080540 _WindowUnderflow12 + 0xe808056a _WindowVectors_text_end = ABSOLUTE (.) + 0xe8080570 _memmap_seg_iram0_2_end = ALIGN (0x8) + +.Level2InterruptVector.literal + 0xe8080578 0x0 + 0xe8080578 _Level2InterruptVector_literal_start = ABSOLUTE (.) + *(.Level2InterruptVector.literal) + .Level2InterruptVector.literal + 0xe8080578 0x0 objs/hikey/int_vector.o + 0x4 (size before relaxing) + 0xe8080578 _Level2InterruptVector_literal_end = ABSOLUTE (.) + 0xe8080578 _memmap_seg_iram0_3_end = ALIGN (0x8) + +.Level2InterruptVector.text + 0xe8080580 0x6 + 0xe8080580 _Level2InterruptVector_text_start = ABSOLUTE (.) + *(.Level2InterruptVector.text) + .Level2InterruptVector.text + 0xe8080580 0x6 objs/hikey/int_vector.o + 0x9 (size before relaxing) + 0xe8080580 OS_Level2Vector + 0xe8080586 _Level2InterruptVector_text_end = ABSOLUTE (.) + 0xe8080588 _memmap_seg_iram0_4_end = ALIGN (0x8) + +.Level3InterruptVector.literal + 0xe80805b8 0x0 + 0xe80805b8 _Level3InterruptVector_literal_start = ABSOLUTE (.) + *(.Level3InterruptVector.literal) + .Level3InterruptVector.literal + 0xe80805b8 0x0 objs/hikey/int_vector.o + 0x4 (size before relaxing) + 0xe80805b8 _Level3InterruptVector_literal_end = ABSOLUTE (.) + 0xe80805b8 _memmap_seg_iram0_5_end = ALIGN (0x8) + +.Level3InterruptVector.text + 0xe80805c0 0x6 + 0xe80805c0 _Level3InterruptVector_text_start = ABSOLUTE (.) + *(.Level3InterruptVector.text) + .Level3InterruptVector.text + 0xe80805c0 0x6 objs/hikey/int_vector.o + 0x9 (size before relaxing) + 0xe80805c0 OS_Level3Vector + 0xe80805c6 _Level3InterruptVector_text_end = ABSOLUTE (.) + 0xe80805c8 _memmap_seg_iram0_6_end = ALIGN (0x8) + +.Level4InterruptVector.literal + 0xe80805f8 0x0 + 0xe80805f8 _Level4InterruptVector_literal_start = ABSOLUTE (.) + *(.Level4InterruptVector.literal) + 0xe80805f8 _Level4InterruptVector_literal_end = ABSOLUTE (.) + 0xe80805f8 _memmap_seg_iram0_7_end = ALIGN (0x8) + +.Level4InterruptVector.text + 0xe8080600 0x0 + 0xe8080600 _Level4InterruptVector_text_start = ABSOLUTE (.) + *(.Level4InterruptVector.text) + 0xe8080600 _Level4InterruptVector_text_end = ABSOLUTE (.) + 0xe8080600 _memmap_seg_iram0_8_end = ALIGN (0x8) + +.DebugExceptionVector.literal + 0xe8080638 0x0 + 0xe8080638 _DebugExceptionVector_literal_start = ABSOLUTE (.) + *(.DebugExceptionVector.literal) + .DebugExceptionVector.literal + 0xe8080638 0x0 objs/hikey/int_vector.o + 0x4 (size before relaxing) + 0xe8080638 _DebugExceptionVector_literal_end = ABSOLUTE (.) + 0xe8080638 _memmap_seg_iram0_9_end = ALIGN (0x8) + +.DebugExceptionVector.text + 0xe8080640 0x16 + 0xe8080640 _DebugExceptionVector_text_start = ABSOLUTE (.) + *(.DebugExceptionVector.text) + .DebugExceptionVector.text + 0xe8080640 0x9 objs/hikey/int_vector.o + 0xc (size before relaxing) + 0xe8080640 OS_DebugExceptionVector + *fill* 0xe8080649 0x3 + .DebugExceptionVector.text + 0xe808064c 0xa objs/hikey/gdbstub-entry.o + 0xe808064c DebugExceptionVector + 0xe8080656 _DebugExceptionVector_text_end = ABSOLUTE (.) + 0xe8080658 _memmap_seg_iram0_10_end = ALIGN (0x8) + +.NMIExceptionVector.literal + 0xe8080678 0x8 + 0xe8080678 _NMIExceptionVector_literal_start = ABSOLUTE (.) + *(.NMIExceptionVector.literal) + .NMIExceptionVector.literal + 0xe8080678 0x8 objs/hikey/int_vector.o + 0xe8080680 _NMIExceptionVector_literal_end = ABSOLUTE (.) + 0xe8080680 _memmap_seg_iram0_11_end = ALIGN (0x8) + +.NMIExceptionVector.text + 0xe80806c0 0x1b + 0xe80806c0 _NMIExceptionVector_text_start = ABSOLUTE (.) + *(.NMIExceptionVector.text) + .NMIExceptionVector.text + 0xe80806c0 0x1b objs/hikey/int_vector.o + 0xe80806c0 OS_NMIExceptionVector + 0xe80806db _NMIExceptionVector_text_end = ABSOLUTE (.) + 0xe80806e0 _memmap_seg_iram0_12_end = ALIGN (0x8) + +.KernelExceptionVector.literal + 0xe80806f8 0x0 + 0xe80806f8 _KernelExceptionVector_literal_start = ABSOLUTE (.) + *(.KernelExceptionVector.literal) + .KernelExceptionVector.literal + 0xe80806f8 0x0 objs/hikey/int_vector.o + 0x4 (size before relaxing) + 0xe80806f8 _KernelExceptionVector_literal_end = ABSOLUTE (.) + 0xe80806f8 _memmap_seg_iram0_13_end = ALIGN (0x8) + +.KernelExceptionVector.text + 0xe8080700 0x6 + 0xe8080700 _KernelExceptionVector_text_start = ABSOLUTE (.) + *(.KernelExceptionVector.text) + .KernelExceptionVector.text + 0xe8080700 0x6 objs/hikey/int_vector.o + 0x9 (size before relaxing) + 0xe8080700 OS_KernelExceptionVector + 0xe8080706 _KernelExceptionVector_text_end = ABSOLUTE (.) + 0xe8080708 _memmap_seg_iram0_14_end = ALIGN (0x8) + +.UserExceptionVector.literal + 0xe8080738 0x0 + 0xe8080738 _UserExceptionVector_literal_start = ABSOLUTE (.) + *(.UserExceptionVector.literal) + .UserExceptionVector.literal + 0xe8080738 0x0 objs/hikey/int_vector.o + 0x4 (size before relaxing) + 0xe8080738 _UserExceptionVector_literal_end = ABSOLUTE (.) + 0xe8080738 _memmap_seg_iram0_15_end = ALIGN (0x8) + +.UserExceptionVector.text + 0xe8080740 0x6 + 0xe8080740 _UserExceptionVector_text_start = ABSOLUTE (.) + *(.UserExceptionVector.text) + .UserExceptionVector.text + 0xe8080740 0x6 objs/hikey/int_vector.o + 0x9 (size before relaxing) + 0xe8080740 OS_UserExceptionVector + 0xe8080746 _UserExceptionVector_text_end = ABSOLUTE (.) + 0xe8080748 _memmap_seg_iram0_16_end = ALIGN (0x8) + +.DoubleExceptionVector.literal + 0xe8080778 0x0 + 0xe8080778 _DoubleExceptionVector_literal_start = ABSOLUTE (.) + *(.DoubleExceptionVector.literal) + .DoubleExceptionVector.literal + 0xe8080778 0x0 objs/hikey/int_vector.o + 0x4 (size before relaxing) + 0xe8080778 _DoubleExceptionVector_literal_end = ABSOLUTE (.) + 0xe8080778 _memmap_seg_iram0_17_end = ALIGN (0x8) + +.DoubleExceptionVector.text + 0xe80807c0 0x6 + 0xe80807c0 _DoubleExceptionVector_text_start = ABSOLUTE (.) + *(.DoubleExceptionVector.text) + .DoubleExceptionVector.text + 0xe80807c0 0x6 objs/hikey/int_vector.o + 0x9 (size before relaxing) + 0xe80807c0 OS_DoubleExceptionVector + 0xe80807c6 _DoubleExceptionVector_text_end = ABSOLUTE (.) + 0xe80807c8 _memmap_seg_iram0_18_end = ALIGN (0x8) + +.Reset.text 0xe8080800 0x23d + 0xe8080800 _Reset_text_start = ABSOLUTE (.) + *(.Reset.text) + .Reset.text 0xe8080800 0x23d objs/hikey/reset.o + 0xe8080800 _Reset + 0xe8080a3d _Reset_text_end = ABSOLUTE (.) + +.iram0.text 0xe8080a40 0x600 + 0xe8080a40 _iram0_text_start = ABSOLUTE (.) + *(.iram0.literal .iram.literal .iram.text.literal .iram0.text .iram.text) + .iram0.literal + 0xe8080a40 0x44 objs/hikey/int_vector.o + 0x88 (size before relaxing) + .iram0.literal + 0xe8080a84 0x2c objs/hikey/arch_hifi330.o + 0x58 (size before relaxing) + .iram0.text 0xe8080ab0 0x3b4 objs/hikey/int_vector.o + 0x3c0 (size before relaxing) + 0xe8080ab0 OS_Panic + 0xe8080ad0 OS_UserExc + 0xe8080b68 OS_UserExit + 0xe8080dc4 OS_Medint2Exit + 0xe8080e50 OS_Medint3Exit + .iram0.text 0xe8080e64 0x1dc objs/hikey/arch_hifi330.o + 0xe8080e64 VOSStartHighRdy + 0xe8080e7c VOSCtxSw + 0xe8080eac VOSIntCtxSw + 0xe8080ecc OSCPUSaveSR + 0xe8080ed8 OSCPURestoreSR + 0xe8080ee4 OS_TaskSwitch + 0xe8080f24 OS_ContextSave + 0xe8080f90 OS_ContextRestore + 0xe8080fd8 OS_IntEnter + 0xe8081008 OS_IntExit + 0xe8081020 OS_GetTaskCoprocState + 0xe8081040 _iram0_text_end = ABSOLUTE (.) + 0xe8081040 _memmap_seg_iram0_19_end = ALIGN (0x8) + +.sram.shareaddr + 0xc0000000 0x0 + 0xc0000000 _sram_shareaddr_start = ABSOLUTE (.) + *(.sram.shareaddr) + 0xc0000000 _sram_shareaddr_end = ABSOLUTE (.) + +.sram.rodata 0xc0000000 0x0 + 0xc0000000 _sram_rodata_start = ABSOLUTE (.) + *(.sram.rodata) + 0xc0000000 _sram_rodata_end = ABSOLUTE (.) + +.rodata 0xc0000000 0x75a0 + 0xc0000000 _rodata_start = ABSOLUTE (.) + *(.rodata) + .rodata 0xc0000000 0x84 objs/hikey/dsp_debug.o + *fill* 0xc0000084 0xc + .rodata 0xc0000090 0x10f objs/hikey/xf-core.o + *fill* 0xc000019f 0x1 + .rodata 0xc00001a0 0x197 objs/hikey/xf-io.o + *fill* 0xc0000337 0x9 + .rodata 0xc0000340 0x1b objs/hikey/xf-mem.o + *fill* 0xc000035b 0x5 + .rodata 0xc0000360 0x30 objs/hikey/xf-msg.o + .rodata 0xc0000390 0x1d objs/hikey/xf-sched.o + *fill* 0xc00003ad 0x3 + .rodata 0xc00003b0 0x45 objs/hikey/xa-factory.o + *fill* 0xc00003f5 0xb + .rodata 0xc0000400 0x4e objs/hikey/xf-shmem.o + *fill* 0xc000044e 0x2 + .rodata 0xc0000450 0x1ec objs/hikey/tinyvprintf.o + *fill* 0xc000063c 0x4 + .rodata 0xc0000640 0x120 objs/hikey/gdbstub.o + 0xc0000640 rx + 0xc0000644 tx + .rodata 0xc0000760 0x140 objs/hikey/xa-class-base.o + .rodata 0xc00008a0 0x1e7 objs/hikey/xa-class-audio-codec.o + *fill* 0xc0000a87 0x9 + .rodata 0xc0000a90 0x1d1 objs/hikey/xa-class-mixer.o + *fill* 0xc0000c61 0xf + .rodata 0xc0000c70 0x15 objs/hikey/xf-main.o + *fill* 0xc0000c85 0xb + .rodata 0xc0000c90 0x2ed objs/hikey/xa-pcm.o + *fill* 0xc0000f7d 0x3 + .rodata 0xc0000f80 0xc objs/hikey/xa-vorbis-decoder.o + *fill* 0xc0000f8c 0x4 + .rodata 0xc0000f90 0x269 objs/hikey/xa-mixer.o + *fill* 0xc00011f9 0x7 + .rodata 0xc0001200 0x4a54 ../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a(xa_vorbis_dec.o) + *(.rodata.*) + .rodata.str1.4 + 0xc0005c54 0x7 objs/hikey/dsp_debug.o + *fill* 0xc0005c5b 0x1 + .rodata.str1.4 + 0xc0005c5c 0x2e1 objs/hikey/xf-core.o + *fill* 0xc0005f3d 0x3 + .rodata.str1.4 + 0xc0005f40 0x2fb objs/hikey/xf-io.o + 0x363 (size before relaxing) + *fill* 0xc000623b 0x1 + .rodata.str1.4 + 0xc000623c 0x50 objs/hikey/xf-mem.o + 0x8c (size before relaxing) + .rodata.str1.4 + 0xc000628c 0x15 objs/hikey/xf-msg.o + 0x49 (size before relaxing) + *fill* 0xc00062a1 0x3 + .rodata.str1.4 + 0xc00062a4 0x56 objs/hikey/xf-sched.o + *fill* 0xc00062fa 0x2 + .rodata.str1.4 + 0xc00062fc 0x68 objs/hikey/xa-factory.o + 0x70 (size before relaxing) + .rodata.str1.4 + 0xc0006364 0xa8 objs/hikey/xf-shmem.o + 0xe4 (size before relaxing) + .rodata.str1.4 + 0xc000640c 0x11 objs/hikey/tinyvprintf.o + *fill* 0xc000641d 0x3 + .rodata.str1.4 + 0xc0006420 0x3f objs/hikey/gdbstub.o + *fill* 0xc000645f 0x1 + .rodata.str1.4 + 0xc0006460 0x6b6 objs/hikey/xa-class-base.o + 0x6f2 (size before relaxing) + *fill* 0xc0006b16 0x2 + .rodata.str1.4 + 0xc0006b18 0x41b objs/hikey/xa-class-audio-codec.o + 0x517 (size before relaxing) + *fill* 0xc0006f33 0x1 + .rodata.str1.4 + 0xc0006f34 0x3cf objs/hikey/xa-class-mixer.o + 0x58b (size before relaxing) + *fill* 0xc0007303 0x1 + .rodata.str1.4 + 0xc0007304 0x4c objs/hikey/xf-main.o + 0x8c (size before relaxing) + .rodata.str1.4 + 0xc0007350 0x86 objs/hikey/xa-pcm.o + 0xc2 (size before relaxing) + *fill* 0xc00073d6 0x2 + .rodata.str1.4 + 0xc00073d8 0x129 objs/hikey/xa-mixer.o + 0x169 (size before relaxing) + *fill* 0xc0007501 0x3 + .rodata.str1.4 + 0xc0007504 0x8 ../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a(xa_vorbis_dec.o) + 0x7 (size before relaxing) + *(.gnu.linkonce.r.*) + *(.rodata1) + 0xc000750c __XT_EXCEPTION_TABLE__ = ABSOLUTE (.) + *(.xt_except_table) + *(.gcc_except_table) + *(.gnu.linkonce.e.*) + *(.gnu.version_r) + *(.eh_frame) + .eh_frame 0xc000750c 0x24 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divdi3.o) + .eh_frame 0xc0007530 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_udivdi3.o) + 0x24 (size before relaxing) + .eh_frame 0xc0007544 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_umoddi3.o) + 0x24 (size before relaxing) + *crtbegin.o(.ctors) + *(EXCLUDE_FILE(*crtend.o) .ctors) + *(SORT(.ctors.*)) + *(.ctors) + *crtbegin.o(.dtors) + *(EXCLUDE_FILE(*crtend.o) .dtors) + *(SORT(.dtors.*)) + *(.dtors) + 0xc0007558 __XT_EXCEPTION_DESCS__ = ABSOLUTE (.) + *(.xt_except_desc) + *(.gnu.linkonce.h.*) + 0xc0007558 __XT_EXCEPTION_DESCS_END__ = ABSOLUTE (.) + *(.xt_except_desc_end) + *(.dynamic) + *(.gnu.version_d) + 0xc0007558 . = ALIGN (0x4) + 0xc0007558 _bss_table_start = ABSOLUTE (.) + 0xc0007558 0x4 LONG 0xc0408000 _vlpd_bss_start + 0xc000755c 0x4 LONG 0xc0408000 _vlpd_bss_end + 0xc0007560 0x4 LONG 0xc0418000 _efr_fr_hr_vlpd_bss_start + 0xc0007564 0x4 LONG 0xc0418000 _efr_fr_hr_vlpd_bss_end + 0xc0007568 0x4 LONG 0xc0428000 _amr_vlpd_bss_start + 0xc000756c 0x4 LONG 0xc0428000 _amr_vlpd_bss_end + 0xc0007570 0x4 LONG 0xc0438000 _amrwb_vlpd_bss_start + 0xc0007574 0x4 LONG 0xc0438000 _amrwb_vlpd_bss_end + 0xc0007578 0x4 LONG 0xc0578000 _ulpp_bss_start + 0xc000757c 0x4 LONG 0xc0578000 _ulpp_bss_end + 0xc0007580 0x4 LONG 0xc05b8000 _dtsv3_bss_start + 0xc0007584 0x4 LONG 0xc05b8000 _dtsv3_bss_end + 0xc0007588 0x4 LONG 0xc05d8000 _dtsv4_bss_start + 0xc000758c 0x4 LONG 0xc05d8000 _dtsv4_bss_end + 0xc0007590 0x4 LONG 0xe8058058 _dram0_bss_start + 0xc0007594 0x4 LONG 0xe8058058 _dram0_bss_end + 0xc0007598 0x4 LONG 0xc001a300 _bss_start + 0xc000759c 0x4 LONG 0xc011b628 _bss_end + 0xc00075a0 _bss_table_end = ABSOLUTE (.) + 0xc00075a0 _rodata_end = ABSOLUTE (.) + +.sram.text 0xc00075a0 0x0 + 0xc00075a0 _sram_text_start = ABSOLUTE (.) + *(.sram.literal .sram.text) + 0xc00075a0 _sram_text_end = ABSOLUTE (.) + +.text 0xc00075a0 0x12b4c + 0xc00075a0 _stext = . + 0xc00075a0 _text_start = ABSOLUTE (.) + *(.entry.text) + *(.init.literal) + *(.init) + *(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*) + .text 0xc00075a0 0xc3 objs/hikey/cpu_c.o + 0xd9 (size before relaxing) + 0xc00075a4 OS_EnterIntHook + 0xc00075bc OS_ExitIntHook + 0xc00075d8 OS_UserexecHandler + 0xc00075f8 OS_InterruptHandler + 0xc0007610 OS_NmiHook + 0xc000762c VOS_ConnectInterrupt + 0xc000763c VOS_EnableInterrupt + 0xc0007658 VOS_DisableInterrupt + *fill* 0xc0007663 0x5 + .text 0xc0007668 0x59a objs/hikey/dsp_debug.o + 0x5da (size before relaxing) + 0xc0007690 __xprintf + 0xc0007b60 dsp_debug_init + 0xc0007bd8 print_log + *fill* 0xc0007c02 0x6 + .text 0xc0007c08 0x40 objs/hikey/mutex.o + .text 0xc0007c48 0x535 objs/hikey/rbtree.o + 0x53d (size before relaxing) + 0xc0007c80 rb_first + 0xc0007ca0 rb_last + 0xc0007cc0 rb_next + 0xc0007d00 rb_prev + 0xc0007d40 rb_init + 0xc0007d54 rb_insert + 0xc0007e84 rb_delete + 0xc0008138 rb_replace + *fill* 0xc000817d 0x3 + .text 0xc0008180 0x899 objs/hikey/xf-core.o + 0xaa4 (size before relaxing) + 0xc0008538 xf_msg_submit + 0xc00085b4 xf_msg_complete + 0xc0008614 xf_core_init + 0xc000874c xf_core_service + 0xc0008a00 xf_global_init + *fill* 0xc0008a19 0x7 + .text 0xc0008a20 0x79b objs/hikey/xf-io.o + 0x88b (size before relaxing) + 0xc0008a78 xf_input_port_init + 0xc0008b0c xf_input_port_put + 0xc0008bf4 xf_input_port_fill + 0xc0008c9c xf_input_port_pad + 0xc0008cc8 xf_input_port_consume + 0xc0008d38 xf_input_port_purge + 0xc0008da0 xf_input_port_control_save + 0xc0008de8 xf_input_port_purge_done + 0xc0008e34 xf_input_port_destroy + 0xc0008e84 xf_output_port_init + 0xc0008ec4 xf_output_port_route + 0xc0008fe0 xf_output_port_unroute_start + 0xc0008ff4 xf_output_port_unroute_done + 0xc0009020 xf_output_port_unroute + 0xc0009088 xf_output_port_put + 0xc00090ac xf_output_port_data + 0xc00090c0 xf_output_port_produce + 0xc00090f0 xf_output_port_flush + 0xc0009158 xf_output_port_flush_done + 0xc000918c xf_output_port_destroy + *fill* 0xc00091bb 0x5 + .text 0xc00091c0 0x2e0 objs/hikey/xf-mem.o + 0x338 (size before relaxing) + 0xc000924c xf_mm_alloc + 0xc00092ec xf_mm_free + 0xc000940c xf_mm_init + .text 0xc00094a0 0x153 objs/hikey/xf-msg.o + 0x173 (size before relaxing) + 0xc00094f0 xf_msg_pool_init + 0xc000957c xf_msg_pool_destroy + 0xc00095b0 xf_msg_pool_get + 0xc00095e8 xf_msg_pool_put + *fill* 0xc00095f3 0x5 + .text 0xc00095f8 0x127 objs/hikey/xf-sched.o + 0x14a (size before relaxing) + 0xc0009640 xf_sched_put + 0xc00096b0 xf_sched_get + 0xc00096f8 xf_sched_cancel + 0xc0009714 xf_sched_init + *fill* 0xc000971f 0x1 + .text 0xc0009720 0x91 objs/hikey/xa-factory.o + 0xa1 (size before relaxing) + 0xc000976c xf_component_factory + *fill* 0xc00097b1 0x7 + .text 0xc00097b8 0x532 objs/hikey/xf-shmem.o + 0x61a (size before relaxing) + 0xc0009a68 xf_shmem_process_queues + 0xc0009bd4 xf_msg_proxy_complete + 0xc0009c4c xf_shmem_init + *fill* 0xc0009cea 0x6 + .text 0xc0009cf0 0x380 objs/hikey/tinyvprintf.o + 0xc0009d0c tiny_vsprintf + 0xc000a04c tiny_sprintf + .text 0xc000a070 0x108 objs/hikey/xf-isr.o + 0x120 (size before relaxing) + 0xc000a0b4 xf_msg_schedule_isr + 0xc000a11c xf_msg_complete_isr + .text 0xc000a178 0xe34 objs/hikey/gdbstub.o + 0x100c (size before relaxing) + 0xc000a18c init_debug_comm + 0xc000a1d4 poll_debug_ring + 0xc000a36c getpacket + 0xc000aa64 handle_exception + 0xc000af5c init_gdbstub + *fill* 0xc000afac 0x4 + .text 0xc000afb0 0x1622 objs/hikey/xa-class-base.o + 0x1cea (size before relaxing) + 0xc000b0c4 xa_base_set_param + 0xc000b82c xa_base_get_param + 0xc000b968 xa_base_set_param_ext + 0xc000bb80 xa_base_get_param_ext + 0xc000c17c xa_base_schedule + 0xc000c1d4 xa_base_cancel + 0xc000c22c xa_base_destroy + 0xc000c2a8 xa_base_factory + *fill* 0xc000c5d2 0x6 + .text 0xc000c5d8 0x14e3 objs/hikey/xa-class-audio-codec.o + 0x1afb (size before relaxing) + 0xc000da44 xa_audio_codec_factory + *fill* 0xc000dabb 0x5 + .text 0xc000dac0 0x144a objs/hikey/xa-class-mixer.o + 0x1aaa (size before relaxing) + 0xc000ee98 xa_mixer_factory + *fill* 0xc000ef0a 0x6 + .text 0xc000ef10 0x185 objs/hikey/xf-main.o + 0x205 (size before relaxing) + 0xc000ef6c xf_ipc_init + 0xc000efe8 main + *fill* 0xc000f095 0x3 + .text 0xc000f098 0xf0f objs/hikey/xa-pcm.o + 0x13e7 (size before relaxing) + 0xc000ff3c xa_pcm_codec + *fill* 0xc000ffa7 0x1 + .text 0xc000ffa8 0x46 objs/hikey/xa-vorbis-decoder.o + 0x4e (size before relaxing) + 0xc000ffb0 xa_vorbis_decoder + *fill* 0xc000ffee 0x2 + .text 0xc000fff0 0xc77 objs/hikey/xa-mixer.o + 0x10cf (size before relaxing) + 0xc0010bfc xa_mixer + *fill* 0xc0010c67 0x1 + .literal 0xc0010c68 0x10 objs/hikey/gdbstub-entry.o + 0x2c (size before relaxing) + .literal 0xc0010c78 0x4 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(windowspill_asm.o) + .literal 0xc0010c7c 0x4 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-on.o) + .literal 0xc0010c80 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-off.o) + 0x4 (size before relaxing) + .literal 0xc0010c80 0x8 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memchr.o) + .literal 0xc0010c88 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-strncmp.o) + 0x8 (size before relaxing) + .literal 0xc0010c88 0x8 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_addsubdf3.o) + 0xc (size before relaxing) + .literal 0xc0010c90 0x4 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_muldf3.o) + 0x10 (size before relaxing) + .literal 0xc0010c94 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_cmpdf2.o) + 0x18 (size before relaxing) + .literal 0xc0010c94 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfsi.o) + 0x4 (size before relaxing) + .literal 0xc0010c94 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfdi.o) + 0x4 (size before relaxing) + .literal 0xc0010c94 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memcpy.o) + 0x8 (size before relaxing) + .literal 0xc0010c94 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memset.o) + 0x4 (size before relaxing) + .literal 0xc0010c94 0x8 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_div_df.o) + 0x2c (size before relaxing) + .literal 0xc0010c9c 0xc /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_df.o) + 0x1c (size before relaxing) + .literal 0xc0010ca8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_div.o) + 0xc (size before relaxing) + .text 0xc0010ca8 0x138 objs/hikey/gdbstub-entry.o + 0xc0010ca8 DebugExceptionEntry + 0xc0010dc8 init_debug_entry + 0xc0010dd8 breakpoint + *fill* 0xc0010de0 0x0 + .text 0xc0010de0 0x7321 ../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a(xa_vorbis_dec.o) + 0x7339 (size before relaxing) + 0xc0013ef8 xa_vorbis_dec + *fill* 0xc0018101 0x3 + .text 0xc0018104 0x137 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(windowspill_asm.o) + 0xc0018104 xthal_window_spill_nw + 0xc0018104 xthal_spill_registers_into_stack_nw + 0xc0018218 xthal_window_spill + *fill* 0xc001823b 0x1 + .text 0xc001823c 0x22 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-on.o) + 0xc001823c _xtos_ints_on + *fill* 0xc001825e 0x2 + .text 0xc0018260 0x25 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-off.o) + 0xc0018260 _xtos_ints_off + *fill* 0xc0018285 0x3 + .text 0xc0018288 0x7c /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memchr.o) + 0xc0018288 memchr + *fill* 0xc0018304 0x4 + .text 0xc0018308 0x84 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-strncmp.o) + 0xc0018308 strncmp + .text 0xc001838c 0x2fa /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_addsubdf3.o) + 0xc00183ac __adddf3 + 0xc0018500 __subdf3 + *fill* 0xc0018686 0x2 + .text 0xc0018688 0x1ff /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_muldf3.o) + 0xc0018768 __muldf3 + *fill* 0xc0018887 0x1 + .text 0xc0018888 0x176 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_cmpdf2.o) + 0xc0018888 __eqdf2 + 0xc0018888 __nedf2 + 0xc00188bc __gtdf2 + 0xc00188e4 __ledf2 + 0xc0018948 __gedf2 + 0xc0018970 __ltdf2 + 0xc00189d4 __unorddf2 + *fill* 0xc00189fe 0x2 + .text 0xc0018a00 0x5d /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfsi.o) + 0xc0018a00 __fixunsdfsi + *fill* 0xc0018a5d 0x3 + .text 0xc0018a60 0x75 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfdi.o) + 0xc0018a60 __fixunsdfdi + *fill* 0xc0018ad5 0x3 + .text 0xc0018ad8 0xa3 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memcpy.o) + 0xc0018ad8 __vec_memcpy + *fill* 0xc0018b7b 0x5 + .text 0xc0018b80 0x71 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memset.o) + 0xc0018b80 __vec_memset + *fill* 0xc0018bf1 0x7 + .text 0xc0018bf8 0x318 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_div_df.o) + 0xc0018bf8 __divdf3 + .text 0xc0018f10 0x29a /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_df.o) + 0xc0018f10 __propagateFloat64NaN + 0xc00190c0 __roundAndPackFloat64 + *fill* 0xc00191aa 0x6 + .text 0xc00191b0 0x6d /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_div.o) + 0xc00191b0 __estimateDiv64To32 + *fill* 0xc001921d 0x3 + .literal 0xc0019220 0x0 objs/hikey/cpu_c.o + *fill* 0xc0019220 0x0 + .literal 0xc0019220 0x0 objs/hikey/dsp_debug.o + *fill* 0xc0019220 0x0 + *fill* 0xc0019220 0x0 + .literal 0xc0019220 0x0 objs/hikey/dsp_comm.o + *fill* 0xc0019220 0x0 + .text 0xc0019220 0xda objs/hikey/dsp_comm.o + 0xc0019220 dsp_memcpy + 0xc00192a0 dsp_memset + 0xc00192d4 division + *fill* 0xc00192fa 0x2 + .literal 0xc00192fc 0x0 objs/hikey/mutex.o + *fill* 0xc00192fc 0x0 + .literal 0xc00192fc 0x0 objs/hikey/rbtree.o + *fill* 0xc00192fc 0x0 + .literal 0xc00192fc 0x0 objs/hikey/xf-core.o + .literal 0xc00192fc 0x0 objs/hikey/xf-io.o + *fill* 0xc00192fc 0x0 + *fill* 0xc00192fc 0x0 + .literal 0xc00192fc 0x0 objs/hikey/xf-mem.o + *fill* 0xc00192fc 0x0 + .literal 0xc00192fc 0x0 objs/hikey/xf-msg.o + *fill* 0xc00192fc 0x0 + .literal 0xc00192fc 0x0 objs/hikey/xf-sched.o + *fill* 0xc00192fc 0x0 + *fill* 0xc00192fc 0x0 + .literal 0xc00192fc 0x0 objs/hikey/xa-factory.o + *fill* 0xc00192fc 0x0 + *fill* 0xc00192fc 0x0 + .literal 0xc00192fc 0x0 objs/hikey/xf-shmem.o + *fill* 0xc00192fc 0x0 + *fill* 0xc00192fc 0x0 + .literal 0xc00192fc 0x0 objs/hikey/tinyvprintf.o + *fill* 0xc00192fc 0x0 + .literal 0xc00192fc 0x0 objs/hikey/xf-isr.o + .literal 0xc00192fc 0x0 objs/hikey/gdbstub.o + .literal 0xc00192fc 0x0 objs/hikey/xa-class-base.o + *fill* 0xc00192fc 0x0 + *fill* 0xc00192fc 0x0 + .literal 0xc00192fc 0x0 objs/hikey/xa-class-audio-codec.o + *fill* 0xc00192fc 0x0 + *fill* 0xc00192fc 0x0 + .literal 0xc00192fc 0x0 objs/hikey/xa-class-mixer.o + *fill* 0xc00192fc 0x0 + *fill* 0xc00192fc 0x0 + .literal 0xc00192fc 0x0 objs/hikey/xf-main.o + *fill* 0xc00192fc 0x0 + *fill* 0xc00192fc 0x0 + .literal 0xc00192fc 0x0 objs/hikey/xa-pcm.o + *fill* 0xc00192fc 0x0 + .literal 0xc00192fc 0x0 objs/hikey/xa-vorbis-decoder.o + *fill* 0xc00192fc 0x0 + .literal 0xc00192fc 0x0 objs/hikey/xa-mixer.o + .text 0xc00192fc 0x0 objs/hikey/reset.o + .text 0xc00192fc 0x0 objs/hikey/int_vector.o + .text 0xc00192fc 0x0 objs/hikey/arch_hifi330.o + *fill* 0xc00192fc 0x0 + *fill* 0xc00192fc 0x0 + *fill* 0xc00192fc 0x0 + *fill* 0xc00192fc 0x4 + .text 0xc0019300 0x1c /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_invalidate.o) + 0xc0019300 xthal_dcache_region_invalidate + *fill* 0xc001931c 0x4 + .text 0xc0019320 0x1c /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_writeback.o) + 0xc0019320 xthal_dcache_region_writeback + .text 0xc001933c 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--hw_configid0.o) + .text 0xc001933c 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--hw_configid1.o) + .text 0xc001933c 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--release_major.o) + .text 0xc001933c 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--release_minor.o) + .text 0xc001933c 0x8 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--get_intenable.o) + 0xc001933c xthal_get_intenable + .text 0xc0019344 0x8 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--set_intenable.o) + 0xc0019344 xthal_set_intenable + .text 0xc001934c 0x2a /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--restore_extra_nw.o) + 0xc001934c xthal_restore_extra_nw + *fill* 0xc0019376 0x2 + .text 0xc0019378 0x2a /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--save_extra_nw.o) + 0xc0019378 xthal_save_extra_nw + *fill* 0xc00193a2 0x0 + *fill* 0xc00193a2 0x0 + *fill* 0xc00193a2 0x2 + .text 0xc00193a4 0x8 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(interrupt-table.o) + 0xc00193a4 _xtos_unhandled_interrupt + *fill* 0xc00193ac 0x4 + .text 0xc00193b0 0x45 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcmp.o) + 0xc00193b0 memcmp + *fill* 0xc00193f5 0x3 + .text 0xc00193f8 0x138 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcpy.o) + 0xc001943c memcpy + .text 0xc0019530 0x78 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memset.o) + 0xc001955c memset + .literal 0xc00195a8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-qsort.o) + .text 0xc00195a8 0x338 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-qsort.o) + 0xc001962c qsort + .text 0xc00198e0 0x8 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divsi3.o) + 0xc00198e0 __divsi3 + .text 0xc00198e8 0x8 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_modsi3.o) + 0xc00198e8 __modsi3 + *fill* 0xc00198f0 0x0 + *fill* 0xc00198f0 0x0 + *fill* 0xc00198f0 0x0 + *fill* 0xc00198f0 0x0 + *fill* 0xc00198f0 0x0 + .text 0xc00198f0 0x3e /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatsidf.o) + 0xc00198f0 __floatunsidf + 0xc00198fc __floatsidf + *fill* 0xc001992e 0x2 + .text 0xc0019930 0x84 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatdidf.o) + 0xc0019930 __floatundidf + 0xc0019940 __floatdidf + *fill* 0xc00199b4 0x4 + .text 0xc00199b8 0x271 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divdi3.o) + 0xc00199b8 __divdi3 + *fill* 0xc0019c29 0x7 + .text 0xc0019c30 0x24c /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_udivdi3.o) + 0xc0019c30 __udivdi3 + *fill* 0xc0019e7c 0x4 + .text 0xc0019e80 0x26c /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_umoddi3.o) + 0xc0019e80 __umoddi3 + *fill* 0xc001a0ec 0x0 + *fill* 0xc001a0ec 0x0 + *fill* 0xc001a0ec 0x0 + *fill* 0xc001a0ec 0x0 + *fill* 0xc001a0ec 0x0 + *(.fini.literal) + *(.fini) + *(.gnu.version) + 0xc001a0ec _text_end = ABSOLUTE (.) + 0xc001a0ec _etext = . + +.sram.data 0xc001a0ec 0x0 + 0xc001a0ec _sram_data_start = ABSOLUTE (.) + *(.sram.data) + 0xc001a0ec _sram_data_end = ABSOLUTE (.) + +.data 0xc001a0f0 0x208 + 0xc001a0f0 _data_start = ABSOLUTE (.) + *(.data) + .data 0xc001a0f0 0x0 objs/hikey/cpu_c.o + .data 0xc001a0f0 0x0 objs/hikey/dsp_debug.o + .data 0xc001a0f0 0x0 objs/hikey/dsp_comm.o + .data 0xc001a0f0 0x0 objs/hikey/mutex.o + .data 0xc001a0f0 0x0 objs/hikey/rbtree.o + .data 0xc001a0f0 0x0 objs/hikey/xf-core.o + .data 0xc001a0f0 0x0 objs/hikey/xf-io.o + .data 0xc001a0f0 0x0 objs/hikey/xf-mem.o + .data 0xc001a0f0 0x0 objs/hikey/xf-msg.o + .data 0xc001a0f0 0x0 objs/hikey/xf-sched.o + .data 0xc001a0f0 0x0 objs/hikey/xa-factory.o + .data 0xc001a0f0 0x0 objs/hikey/xf-shmem.o + .data 0xc001a0f0 0x0 objs/hikey/tinyvprintf.o + .data 0xc001a0f0 0x0 objs/hikey/xf-isr.o + .data 0xc001a0f0 0x0 objs/hikey/gdbstub.o + .data 0xc001a0f0 0x0 objs/hikey/xa-class-base.o + .data 0xc001a0f0 0x0 objs/hikey/xa-class-audio-codec.o + .data 0xc001a0f0 0x0 objs/hikey/xa-class-mixer.o + .data 0xc001a0f0 0x0 objs/hikey/xf-main.o + .data 0xc001a0f0 0x0 objs/hikey/xa-pcm.o + .data 0xc001a0f0 0x0 objs/hikey/xa-vorbis-decoder.o + .data 0xc001a0f0 0x0 objs/hikey/xa-mixer.o + .data 0xc001a0f0 0x0 objs/hikey/reset.o + .data 0xc001a0f0 0x0 objs/hikey/int_vector.o + .data 0xc001a0f0 0x0 objs/hikey/arch_hifi330.o + .data 0xc001a0f0 0x0 objs/hikey/gdbstub-entry.o + .data 0xc001a0f0 0x0 ../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a(xa_vorbis_dec.o) + .data 0xc001a0f0 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(windowspill_asm.o) + .data 0xc001a0f0 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_invalidate.o) + .data 0xc001a0f0 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_writeback.o) + .data 0xc001a0f0 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--hw_configid0.o) + .data 0xc001a0f0 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--hw_configid1.o) + .data 0xc001a0f0 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--release_major.o) + .data 0xc001a0f0 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--release_minor.o) + .data 0xc001a0f0 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--get_intenable.o) + .data 0xc001a0f0 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--set_intenable.o) + .data 0xc001a0f0 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--restore_extra_nw.o) + .data 0xc001a0f0 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--save_extra_nw.o) + .data 0xc001a0f0 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-on.o) + .data 0xc001a0f0 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-off.o) + .data 0xc001a0f0 0x208 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(interrupt-table.o) + 0xc001a0f0 _xtos_enabled + 0xc001a0f0 _xtos_intstruct + 0xc001a0f4 _xtos_vpri_enabled + 0xc001a0f8 _xtos_interrupt_table + 0xc001a1f8 _xtos_interrupt_mask_table + .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memchr.o) + .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcmp.o) + .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcpy.o) + .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memset.o) + .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-qsort.o) + .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-strncmp.o) + .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divsi3.o) + .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_modsi3.o) + .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_addsubdf3.o) + .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_muldf3.o) + .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_cmpdf2.o) + .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfsi.o) + .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfdi.o) + .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatsidf.o) + .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatdidf.o) + .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divdi3.o) + .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_udivdi3.o) + .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_umoddi3.o) + .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memcpy.o) + .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memset.o) + .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_div_df.o) + .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_df.o) + .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_div.o) + *(.data.*) + *(.gnu.linkonce.d.*) + *(.gnu.linkonce.d.*personality*) + *(.data1) + *(.sdata) + *(.sdata.*) + *(.gnu.linkonce.s.*) + *(.sdata2) + *(.sdata2.*) + *(.gnu.linkonce.s2.*) + *(.jcr) + 0xc001a2f8 _data_end = ABSOLUTE (.) + +.sram.uninit 0xc001a2f8 0x0 + 0xc001a2f8 _sram_uninit_start = ABSOLUTE (.) + *(.sram.uninit) + 0xc001a2f8 _sram_uninit_end = ABSOLUTE (.) + +.bss 0xc001a300 0x101328 + 0xc001a300 . = ALIGN (0x8) + 0xc001a300 _bss_start = ABSOLUTE (.) + *(.dynsbss) + *(.sbss) + *(.sbss.*) + *(.gnu.linkonce.sb.*) + *(.scommon) + *(.sbss2) + *(.sbss2.*) + *(.gnu.linkonce.sb2.*) + *(.dynbss) + *(.bss) + .bss 0xc001a300 0xb0 objs/hikey/cpu_c.o + 0xc001a300 g_ucVosIntNesting + 0xc001a301 g_ucVosPrioCur + 0xc001a302 g_ucVosPrioHighRdy + 0xc001a304 g_bVosRunning + 0xc001a308 g_pstVosTCBHighRdy + 0xc001a30c g_pstVosTCBCur + 0xc001a310 g_pfVosHookFuncTable + 0xc001a330 g_pfVosIntrFuncTable + .bss 0xc001a3b0 0x4 objs/hikey/dsp_debug.o + .bss 0xc001a3b4 0x0 objs/hikey/dsp_comm.o + .bss 0xc001a3b4 0x0 objs/hikey/mutex.o + .bss 0xc001a3b4 0x0 objs/hikey/rbtree.o + .bss 0xc001a3b4 0x0 objs/hikey/xf-core.o + .bss 0xc001a3b4 0x0 objs/hikey/xf-io.o + .bss 0xc001a3b4 0x0 objs/hikey/xf-mem.o + .bss 0xc001a3b4 0x0 objs/hikey/xf-msg.o + .bss 0xc001a3b4 0x0 objs/hikey/xf-sched.o + .bss 0xc001a3b4 0x0 objs/hikey/xa-factory.o + .bss 0xc001a3b4 0x0 objs/hikey/xf-shmem.o + .bss 0xc001a3b4 0x0 objs/hikey/tinyvprintf.o + .bss 0xc001a3b4 0x0 objs/hikey/xf-isr.o + *fill* 0xc001a3b4 0xc + .bss 0xc001a3c0 0xb70 objs/hikey/gdbstub.o + 0xc001a3c0 mem_err + 0xc001a530 sregs + 0xc001aa30 aregs + 0xc001ab30 stack + .bss 0xc001af30 0x0 objs/hikey/xa-class-base.o + .bss 0xc001af30 0x0 objs/hikey/xa-class-audio-codec.o + .bss 0xc001af30 0x0 objs/hikey/xa-class-mixer.o + *fill* 0xc001af30 0x50 + .bss 0xc001af80 0x1006a8 objs/hikey/xf-main.o + 0xc001af80 xf_dsp_local_buffer + 0xc011b2c0 waitstate + 0xc011b2c8 prof + 0xc011b318 xf_ap_shmem_pool + 0xc011b340 xf_core_data + 0xc011b500 xf_core_rw_data + 0xc011b580 xf_core_ro_data + 0xc011b600 xf_dsp_local_pool + .bss 0xc011b628 0x0 objs/hikey/xa-pcm.o + .bss 0xc011b628 0x0 objs/hikey/xa-vorbis-decoder.o + .bss 0xc011b628 0x0 objs/hikey/xa-mixer.o + .bss 0xc011b628 0x0 objs/hikey/reset.o + .bss 0xc011b628 0x0 objs/hikey/int_vector.o + .bss 0xc011b628 0x0 objs/hikey/arch_hifi330.o + .bss 0xc011b628 0x0 objs/hikey/gdbstub-entry.o + .bss 0xc011b628 0x0 ../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a(xa_vorbis_dec.o) + .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(windowspill_asm.o) + .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_invalidate.o) + .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_writeback.o) + .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--hw_configid0.o) + .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--hw_configid1.o) + .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--release_major.o) + .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--release_minor.o) + .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--get_intenable.o) + .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--set_intenable.o) + .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--restore_extra_nw.o) + .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--save_extra_nw.o) + .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-on.o) + .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-off.o) + .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(interrupt-table.o) + .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memchr.o) + .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcmp.o) + .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcpy.o) + .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memset.o) + .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-qsort.o) + .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-strncmp.o) + .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divsi3.o) + .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_modsi3.o) + .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_addsubdf3.o) + .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_muldf3.o) + .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_cmpdf2.o) + .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfsi.o) + .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfdi.o) + .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatsidf.o) + .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatdidf.o) + .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divdi3.o) + .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_udivdi3.o) + .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_umoddi3.o) + .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memcpy.o) + .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memset.o) + .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_div_df.o) + .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_df.o) + .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_div.o) + *(.bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + *(.sram.pool.bss) + *(.sram.bss) + 0xc011b628 . = ALIGN (0x8) + 0xc011b628 _bss_end = ABSOLUTE (.) + 0xc011b628 _memmap_seg_sram0_end = ALIGN (0x8) + +.debug + *(.debug) + +.line + *(.line) + +.debug_srcinfo + *(.debug_srcinfo) + +.debug_sfnames + *(.debug_sfnames) + +.debug_aranges 0x00000000 0x7b0 + *(.debug_aranges) + .debug_aranges + 0x00000000 0x20 objs/hikey/cpu_c.o + .debug_aranges + 0x00000020 0x20 objs/hikey/dsp_debug.o + .debug_aranges + 0x00000040 0x20 objs/hikey/dsp_comm.o + .debug_aranges + 0x00000060 0x20 objs/hikey/mutex.o + .debug_aranges + 0x00000080 0x20 objs/hikey/rbtree.o + .debug_aranges + 0x000000a0 0x20 objs/hikey/xf-core.o + .debug_aranges + 0x000000c0 0x20 objs/hikey/xf-io.o + .debug_aranges + 0x000000e0 0x20 objs/hikey/xf-mem.o + .debug_aranges + 0x00000100 0x20 objs/hikey/xf-msg.o + .debug_aranges + 0x00000120 0x20 objs/hikey/xf-sched.o + .debug_aranges + 0x00000140 0x20 objs/hikey/xa-factory.o + .debug_aranges + 0x00000160 0x20 objs/hikey/xf-shmem.o + .debug_aranges + 0x00000180 0x20 objs/hikey/tinyvprintf.o + .debug_aranges + 0x000001a0 0x20 objs/hikey/xf-isr.o + .debug_aranges + 0x000001c0 0x20 objs/hikey/gdbstub.o + .debug_aranges + 0x000001e0 0x20 objs/hikey/xa-class-base.o + .debug_aranges + 0x00000200 0x20 objs/hikey/xa-class-audio-codec.o + .debug_aranges + 0x00000220 0x20 objs/hikey/xa-class-mixer.o + .debug_aranges + 0x00000240 0x20 objs/hikey/xf-main.o + .debug_aranges + 0x00000260 0x20 objs/hikey/xa-pcm.o + .debug_aranges + 0x00000280 0x20 objs/hikey/xa-vorbis-decoder.o + .debug_aranges + 0x000002a0 0x20 objs/hikey/xa-mixer.o + .debug_aranges + 0x000002c0 0x28 objs/hikey/reset.o + .debug_aranges + 0x000002e8 0x60 objs/hikey/int_vector.o + .debug_aranges + 0x00000348 0x20 objs/hikey/arch_hifi330.o + .debug_aranges + 0x00000368 0x28 objs/hikey/gdbstub-entry.o + .debug_aranges + 0x00000390 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(windowspill_asm.o) + .debug_aranges + 0x000003b0 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_invalidate.o) + .debug_aranges + 0x000003d0 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_writeback.o) + .debug_aranges + 0x000003f0 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--get_intenable.o) + .debug_aranges + 0x00000410 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--set_intenable.o) + .debug_aranges + 0x00000430 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--restore_extra_nw.o) + .debug_aranges + 0x00000450 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--save_extra_nw.o) + .debug_aranges + 0x00000470 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-on.o) + .debug_aranges + 0x00000490 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-off.o) + .debug_aranges + 0x000004b0 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(interrupt-table.o) + .debug_aranges + 0x000004d0 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memchr.o) + .debug_aranges + 0x000004f0 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcmp.o) + .debug_aranges + 0x00000510 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcpy.o) + .debug_aranges + 0x00000530 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memset.o) + .debug_aranges + 0x00000550 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-qsort.o) + .debug_aranges + 0x00000570 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-strncmp.o) + .debug_aranges + 0x00000590 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divsi3.o) + .debug_aranges + 0x000005b0 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_modsi3.o) + .debug_aranges + 0x000005d0 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_addsubdf3.o) + .debug_aranges + 0x000005f0 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_muldf3.o) + .debug_aranges + 0x00000610 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_cmpdf2.o) + .debug_aranges + 0x00000630 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfsi.o) + .debug_aranges + 0x00000650 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfdi.o) + .debug_aranges + 0x00000670 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatsidf.o) + .debug_aranges + 0x00000690 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatdidf.o) + .debug_aranges + 0x000006b0 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divdi3.o) + .debug_aranges + 0x000006d0 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_udivdi3.o) + .debug_aranges + 0x000006f0 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_umoddi3.o) + .debug_aranges + 0x00000710 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memcpy.o) + .debug_aranges + 0x00000730 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memset.o) + .debug_aranges + 0x00000750 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_div_df.o) + .debug_aranges + 0x00000770 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_df.o) + .debug_aranges + 0x00000790 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_div.o) + +.debug_pubnames + 0x00000000 0xb7d + *(.debug_pubnames) + .debug_pubnames + 0x00000000 0x16f objs/hikey/cpu_c.o + .debug_pubnames + 0x0000016f 0x41 objs/hikey/dsp_debug.o + .debug_pubnames + 0x000001b0 0x3d objs/hikey/dsp_comm.o + .debug_pubnames + 0x000001ed 0x7a objs/hikey/rbtree.o + .debug_pubnames + 0x00000267 0x70 objs/hikey/xf-core.o + .debug_pubnames + 0x000002d7 0x21d objs/hikey/xf-io.o + .debug_pubnames + 0x000004f4 0x40 objs/hikey/xf-mem.o + .debug_pubnames + 0x00000534 0x67 objs/hikey/xf-msg.o + .debug_pubnames + 0x0000059b 0x5a objs/hikey/xf-sched.o + .debug_pubnames + 0x000005f5 0x2b objs/hikey/xa-factory.o + .debug_pubnames + 0x00000620 0x5a objs/hikey/xf-shmem.o + .debug_pubnames + 0x0000067a 0x35 objs/hikey/tinyvprintf.o + .debug_pubnames + 0x000006af 0x42 objs/hikey/xf-isr.o + .debug_pubnames + 0x000006f1 0xa6 objs/hikey/gdbstub.o + .debug_pubnames + 0x00000797 0xc2 objs/hikey/xa-class-base.o + .debug_pubnames + 0x00000859 0x2d objs/hikey/xa-class-audio-codec.o + .debug_pubnames + 0x00000886 0x27 objs/hikey/xa-class-mixer.o + .debug_pubnames + 0x000008ad 0xbe objs/hikey/xf-main.o + .debug_pubnames + 0x0000096b 0x23 objs/hikey/xa-pcm.o + .debug_pubnames + 0x0000098e 0x28 objs/hikey/xa-vorbis-decoder.o + .debug_pubnames + 0x000009b6 0x1f objs/hikey/xa-mixer.o + .debug_pubnames + 0x000009d5 0x1d /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memchr.o) + .debug_pubnames + 0x000009f2 0x1d /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcmp.o) + .debug_pubnames + 0x00000a0f 0x1c /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-qsort.o) + .debug_pubnames + 0x00000a2b 0x1e /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-strncmp.o) + .debug_pubnames + 0x00000a49 0x1f /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divdi3.o) + .debug_pubnames + 0x00000a68 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_udivdi3.o) + .debug_pubnames + 0x00000a88 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_umoddi3.o) + .debug_pubnames + 0x00000aa8 0x23 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memcpy.o) + .debug_pubnames + 0x00000acb 0x23 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memset.o) + .debug_pubnames + 0x00000aee 0x1f /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_div_df.o) + .debug_pubnames + 0x00000b0d 0x46 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_df.o) + .debug_pubnames + 0x00000b53 0x2a /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_div.o) + +.debug_info 0x00000000 0x18e3c + *(.debug_info) + .debug_info 0x00000000 0x516 objs/hikey/cpu_c.o + .debug_info 0x00000516 0x3c2 objs/hikey/dsp_debug.o + .debug_info 0x000008d8 0x208 objs/hikey/dsp_comm.o + .debug_info 0x00000ae0 0xbd5 objs/hikey/mutex.o + .debug_info 0x000016b5 0xf10 objs/hikey/rbtree.o + .debug_info 0x000025c5 0x16ac objs/hikey/xf-core.o + .debug_info 0x00003c71 0x1826 objs/hikey/xf-io.o + .debug_info 0x00005497 0xef6 objs/hikey/xf-mem.o + .debug_info 0x0000638d 0xdc1 objs/hikey/xf-msg.o + .debug_info 0x0000714e 0xdf5 objs/hikey/xf-sched.o + .debug_info 0x00007f43 0xdfd objs/hikey/xa-factory.o + .debug_info 0x00008d40 0x1353 objs/hikey/xf-shmem.o + .debug_info 0x0000a093 0x2d0 objs/hikey/tinyvprintf.o + .debug_info 0x0000a363 0xc73 objs/hikey/xf-isr.o + .debug_info 0x0000afd6 0xa47 objs/hikey/gdbstub.o + .debug_info 0x0000ba1d 0x1c9b objs/hikey/xa-class-base.o + .debug_info 0x0000d6b8 0x1fe2 objs/hikey/xa-class-audio-codec.o + .debug_info 0x0000f69a 0x21c9 objs/hikey/xa-class-mixer.o + .debug_info 0x00011863 0x1203 objs/hikey/xf-main.o + .debug_info 0x00012a66 0x1841 objs/hikey/xa-pcm.o + .debug_info 0x000142a7 0x1f6 objs/hikey/xa-vorbis-decoder.o + .debug_info 0x0001449d 0x12e9 objs/hikey/xa-mixer.o + .debug_info 0x00015786 0x95 objs/hikey/reset.o + .debug_info 0x0001581b 0x9a objs/hikey/int_vector.o + .debug_info 0x000158b5 0xa0 objs/hikey/arch_hifi330.o + .debug_info 0x00015955 0x9c objs/hikey/gdbstub-entry.o + .debug_info 0x000159f1 0xdf /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(windowspill_asm.o) + .debug_info 0x00015ad0 0xd9 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_invalidate.o) + .debug_info 0x00015ba9 0xd9 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_writeback.o) + .debug_info 0x00015c82 0xd7 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--get_intenable.o) + .debug_info 0x00015d59 0xd7 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--set_intenable.o) + .debug_info 0x00015e30 0xd9 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--restore_extra_nw.o) + .debug_info 0x00015f09 0xd9 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--save_extra_nw.o) + .debug_info 0x00015fe2 0xd9 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-on.o) + .debug_info 0x000160bb 0xda /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-off.o) + .debug_info 0x00016195 0xe1 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(interrupt-table.o) + .debug_info 0x00016276 0x22e /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memchr.o) + .debug_info 0x000164a4 0x20a /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcmp.o) + .debug_info 0x000166ae 0x11c /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcpy.o) + .debug_info 0x000167ca 0x11c /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memset.o) + .debug_info 0x000168e6 0x399 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-qsort.o) + .debug_info 0x00016c7f 0x204 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-strncmp.o) + .debug_info 0x00016e83 0xf7 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divsi3.o) + .debug_info 0x00016f7a 0xf7 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_modsi3.o) + .debug_info 0x00017071 0xf6 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_addsubdf3.o) + .debug_info 0x00017167 0xf6 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_muldf3.o) + .debug_info 0x0001725d 0xf6 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_cmpdf2.o) + .debug_info 0x00017353 0xf6 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfsi.o) + .debug_info 0x00017449 0xf6 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfdi.o) + .debug_info 0x0001753f 0xf6 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatsidf.o) + .debug_info 0x00017635 0xf6 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatdidf.o) + .debug_info 0x0001772b 0x2b1 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divdi3.o) + .debug_info 0x000179dc 0x26e /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_udivdi3.o) + .debug_info 0x00017c4a 0x278 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_umoddi3.o) + .debug_info 0x00017ec2 0x2c3 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memcpy.o) + .debug_info 0x00018185 0x28b /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memset.o) + .debug_info 0x00018410 0x3a7 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_div_df.o) + .debug_info 0x000187b7 0x3ae /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_df.o) + .debug_info 0x00018b65 0x2d7 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_div.o) + +.debug_abbrev 0x00000000 0x2ee0 + *(.debug_abbrev) + .debug_abbrev 0x00000000 0xcd objs/hikey/cpu_c.o + .debug_abbrev 0x000000cd 0x156 objs/hikey/dsp_debug.o + .debug_abbrev 0x00000223 0xa2 objs/hikey/dsp_comm.o + .debug_abbrev 0x000002c5 0x140 objs/hikey/mutex.o + .debug_abbrev 0x00000405 0x201 objs/hikey/rbtree.o + .debug_abbrev 0x00000606 0x28c objs/hikey/xf-core.o + .debug_abbrev 0x00000892 0x255 objs/hikey/xf-io.o + .debug_abbrev 0x00000ae7 0x1ff objs/hikey/xf-mem.o + .debug_abbrev 0x00000ce6 0x1d3 objs/hikey/xf-msg.o + .debug_abbrev 0x00000eb9 0x1b2 objs/hikey/xf-sched.o + .debug_abbrev 0x0000106b 0x17d objs/hikey/xa-factory.o + .debug_abbrev 0x000011e8 0x1f8 objs/hikey/xf-shmem.o + .debug_abbrev 0x000013e0 0xf6 objs/hikey/tinyvprintf.o + .debug_abbrev 0x000014d6 0x184 objs/hikey/xf-isr.o + .debug_abbrev 0x0000165a 0x282 objs/hikey/gdbstub.o + .debug_abbrev 0x000018dc 0x269 objs/hikey/xa-class-base.o + .debug_abbrev 0x00001b45 0x20b objs/hikey/xa-class-audio-codec.o + .debug_abbrev 0x00001d50 0x20b objs/hikey/xa-class-mixer.o + .debug_abbrev 0x00001f5b 0x1b3 objs/hikey/xf-main.o + .debug_abbrev 0x0000210e 0x1aa objs/hikey/xa-pcm.o + .debug_abbrev 0x000022b8 0xa4 objs/hikey/xa-vorbis-decoder.o + .debug_abbrev 0x0000235c 0x1cc objs/hikey/xa-mixer.o + .debug_abbrev 0x00002528 0x12 objs/hikey/reset.o + .debug_abbrev 0x0000253a 0x12 objs/hikey/int_vector.o + .debug_abbrev 0x0000254c 0x14 objs/hikey/arch_hifi330.o + .debug_abbrev 0x00002560 0x12 objs/hikey/gdbstub-entry.o + .debug_abbrev 0x00002572 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(windowspill_asm.o) + .debug_abbrev 0x00002586 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_invalidate.o) + .debug_abbrev 0x0000259a 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_writeback.o) + .debug_abbrev 0x000025ae 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--get_intenable.o) + .debug_abbrev 0x000025c2 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--set_intenable.o) + .debug_abbrev 0x000025d6 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--restore_extra_nw.o) + .debug_abbrev 0x000025ea 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--save_extra_nw.o) + .debug_abbrev 0x000025fe 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-on.o) + .debug_abbrev 0x00002612 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-off.o) + .debug_abbrev 0x00002626 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(interrupt-table.o) + .debug_abbrev 0x0000263a 0x8e /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memchr.o) + .debug_abbrev 0x000026c8 0x85 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcmp.o) + .debug_abbrev 0x0000274d 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcpy.o) + .debug_abbrev 0x00002761 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memset.o) + .debug_abbrev 0x00002775 0xcf /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-qsort.o) + .debug_abbrev 0x00002844 0x80 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-strncmp.o) + .debug_abbrev 0x000028c4 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divsi3.o) + .debug_abbrev 0x000028d8 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_modsi3.o) + .debug_abbrev 0x000028ec 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_addsubdf3.o) + .debug_abbrev 0x00002900 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_muldf3.o) + .debug_abbrev 0x00002914 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_cmpdf2.o) + .debug_abbrev 0x00002928 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfsi.o) + .debug_abbrev 0x0000293c 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfdi.o) + .debug_abbrev 0x00002950 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatsidf.o) + .debug_abbrev 0x00002964 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatdidf.o) + .debug_abbrev 0x00002978 0xbd /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divdi3.o) + .debug_abbrev 0x00002a35 0xa1 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_udivdi3.o) + .debug_abbrev 0x00002ad6 0xae /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_umoddi3.o) + .debug_abbrev 0x00002b84 0xa3 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memcpy.o) + .debug_abbrev 0x00002c27 0x82 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memset.o) + .debug_abbrev 0x00002ca9 0xbb /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_div_df.o) + .debug_abbrev 0x00002d64 0xd0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_df.o) + .debug_abbrev 0x00002e34 0xac /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_div.o) + +.debug_line 0x00000000 0xd0d8 + *(.debug_line) + .debug_line 0x00000000 0x14b objs/hikey/cpu_c.o + .debug_line 0x0000014b 0x433 objs/hikey/dsp_debug.o + .debug_line 0x0000057e 0x105 objs/hikey/dsp_comm.o + .debug_line 0x00000683 0x1fc objs/hikey/mutex.o + .debug_line 0x0000087f 0x8f3 objs/hikey/rbtree.o + .debug_line 0x00001172 0x8a9 objs/hikey/xf-core.o + .debug_line 0x00001a1b 0xb08 objs/hikey/xf-io.o + .debug_line 0x00002523 0x4c3 objs/hikey/xf-mem.o + .debug_line 0x000029e6 0x2cf objs/hikey/xf-msg.o + .debug_line 0x00002cb5 0x32f objs/hikey/xf-sched.o + .debug_line 0x00002fe4 0x233 objs/hikey/xa-factory.o + .debug_line 0x00003217 0x70b objs/hikey/xf-shmem.o + .debug_line 0x00003922 0x268 objs/hikey/tinyvprintf.o + .debug_line 0x00003b8a 0x33e objs/hikey/xf-isr.o + .debug_line 0x00003ec8 0x9d7 objs/hikey/gdbstub.o + .debug_line 0x0000489f 0x92f objs/hikey/xa-class-base.o + .debug_line 0x000051ce 0xb85 objs/hikey/xa-class-audio-codec.o + .debug_line 0x00005d53 0xcd5 objs/hikey/xa-class-mixer.o + .debug_line 0x00006a28 0x2e7 objs/hikey/xf-main.o + .debug_line 0x00006d0f 0xbd0 objs/hikey/xa-pcm.o + .debug_line 0x000078df 0x145 objs/hikey/xa-vorbis-decoder.o + .debug_line 0x00007a24 0x94f objs/hikey/xa-mixer.o + .debug_line 0x00008373 0x36b objs/hikey/reset.o + .debug_line 0x000086de 0x7f7 objs/hikey/int_vector.o + .debug_line 0x00008ed5 0x463 objs/hikey/arch_hifi330.o + .debug_line 0x00009338 0x293 objs/hikey/gdbstub-entry.o + .debug_line 0x000095cb 0x337 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(windowspill_asm.o) + .debug_line 0x00009902 0x91 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_invalidate.o) + .debug_line 0x00009993 0x91 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_writeback.o) + .debug_line 0x00009a24 0x8e /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--get_intenable.o) + .debug_line 0x00009ab2 0x8f /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--set_intenable.o) + .debug_line 0x00009b41 0x8a /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--restore_extra_nw.o) + .debug_line 0x00009bcb 0x8a /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--save_extra_nw.o) + .debug_line 0x00009c55 0xc5 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-on.o) + .debug_line 0x00009d1a 0xcc /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-off.o) + .debug_line 0x00009de6 0x98 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(interrupt-table.o) + .debug_line 0x00009e7e 0x10f /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memchr.o) + .debug_line 0x00009f8d 0xf6 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcmp.o) + .debug_line 0x0000a083 0x363 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcpy.o) + .debug_line 0x0000a3e6 0x19a /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memset.o) + .debug_line 0x0000a580 0x25a /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-qsort.o) + .debug_line 0x0000a7da 0x110 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-strncmp.o) + .debug_line 0x0000a8ea 0xa9 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divsi3.o) + .debug_line 0x0000a993 0xa8 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_modsi3.o) + .debug_line 0x0000aa3b 0x6d1 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_addsubdf3.o) + .debug_line 0x0000b10c 0x4c4 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_muldf3.o) + .debug_line 0x0000b5d0 0x3bf /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_cmpdf2.o) + .debug_line 0x0000b98f 0x167 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfsi.o) + .debug_line 0x0000baf6 0x191 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfdi.o) + .debug_line 0x0000bc87 0x119 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatsidf.o) + .debug_line 0x0000bda0 0x1af /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatdidf.o) + .debug_line 0x0000bf4f 0x1e3 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divdi3.o) + .debug_line 0x0000c132 0x1c4 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_udivdi3.o) + .debug_line 0x0000c2f6 0x220 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_umoddi3.o) + .debug_line 0x0000c516 0x13d /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memcpy.o) + .debug_line 0x0000c653 0x137 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memset.o) + .debug_line 0x0000c78a 0x46e /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_div_df.o) + .debug_line 0x0000cbf8 0x36e /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_df.o) + .debug_line 0x0000cf66 0x172 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_div.o) + +.debug_frame + *(.debug_frame) + +.debug_str + *(.debug_str) + +.debug_loc + *(.debug_loc) + +.debug_macinfo + *(.debug_macinfo) + +.debug_weaknames + *(.debug_weaknames) + +.debug_funcnames + *(.debug_funcnames) + +.debug_typenames + *(.debug_typenames) + +.debug_varnames + *(.debug_varnames) + +.xt.insn + *(.xt.insn) + *(.gnu.linkonce.x.*) + +.xt.prop 0x00000000 0xe8ec + *(.xt.prop) + .xt.prop 0x00000000 0x15c objs/hikey/cpu_c.o + 0x1ec (size before relaxing) + .xt.prop 0x0000015c 0x570 objs/hikey/dsp_debug.o + 0x594 (size before relaxing) + .xt.prop 0x000006cc 0x84 objs/hikey/dsp_comm.o + .xt.prop 0x00000750 0x3c objs/hikey/mutex.o + 0x48 (size before relaxing) + .xt.prop 0x0000078c 0x6e4 objs/hikey/rbtree.o + 0x6f0 (size before relaxing) + .xt.prop 0x00000e70 0x624 objs/hikey/xf-core.o + 0x6e4 (size before relaxing) + .xt.prop 0x00001494 0x7b0 objs/hikey/xf-io.o + 0x894 (size before relaxing) + .xt.prop 0x00001c44 0x354 objs/hikey/xf-mem.o + 0x390 (size before relaxing) + .xt.prop 0x00001f98 0x12c objs/hikey/xf-msg.o + 0x15c (size before relaxing) + .xt.prop 0x000020c4 0x150 objs/hikey/xf-sched.o + 0x18c (size before relaxing) + .xt.prop 0x00002214 0x9c objs/hikey/xa-factory.o + 0xb4 (size before relaxing) + .xt.prop 0x000022b0 0x36c objs/hikey/xf-shmem.o + 0x3a8 (size before relaxing) + .xt.prop 0x0000261c 0x498 objs/hikey/tinyvprintf.o + 0x4a4 (size before relaxing) + .xt.prop 0x00002ab4 0xe4 objs/hikey/xf-isr.o + 0x108 (size before relaxing) + .xt.prop 0x00002b98 0x9c0 objs/hikey/gdbstub.o + 0xa8c (size before relaxing) + .xt.prop 0x00003558 0xa80 objs/hikey/xa-class-base.o + 0xb28 (size before relaxing) + .xt.prop 0x00003fd8 0xbb8 objs/hikey/xa-class-audio-codec.o + 0xc84 (size before relaxing) + .xt.prop 0x00004b90 0xcf0 objs/hikey/xa-class-mixer.o + 0xdd4 (size before relaxing) + .xt.prop 0x00005880 0xe4 objs/hikey/xf-main.o + 0x18c (size before relaxing) + .xt.prop 0x00005964 0xdec objs/hikey/xa-pcm.o + 0xef4 (size before relaxing) + .xt.prop 0x00006750 0x48 objs/hikey/xa-vorbis-decoder.o + 0x60 (size before relaxing) + .xt.prop 0x00006798 0xaa4 objs/hikey/xa-mixer.o + 0xb7c (size before relaxing) + .xt.prop 0x0000723c 0x6c objs/hikey/reset.o + .xt.prop 0x000072a8 0x300 objs/hikey/int_vector.o + 0x390 (size before relaxing) + .xt.prop 0x000075a8 0x150 objs/hikey/arch_hifi330.o + 0x15c (size before relaxing) + .xt.prop 0x000076f8 0xf0 objs/hikey/gdbstub-entry.o + .xt.prop 0x000077e8 0x5154 ../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a(xa_vorbis_dec.o) + 0x51d8 (size before relaxing) + .xt.prop 0x0000c93c 0xf0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(windowspill_asm.o) + .xt.prop 0x0000ca2c 0x24 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_invalidate.o) + .xt.prop 0x0000ca50 0x24 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_writeback.o) + .xt.prop 0x0000ca74 0x18 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--get_intenable.o) + .xt.prop 0x0000ca8c 0x18 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--set_intenable.o) + .xt.prop 0x0000caa4 0x18 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--restore_extra_nw.o) + .xt.prop 0x0000cabc 0x18 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--save_extra_nw.o) + .xt.prop 0x0000cad4 0x24 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-on.o) + .xt.prop 0x0000caf8 0x18 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-off.o) + 0x24 (size before relaxing) + .xt.prop 0x0000cb10 0x24 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(interrupt-table.o) + .xt.prop 0x0000cb34 0x90 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memchr.o) + .xt.prop 0x0000cbc4 0x3c /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcmp.o) + .xt.prop 0x0000cc00 0x144 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcpy.o) + .xt.prop 0x0000cd44 0xc0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memset.o) + .xt.prop 0x0000ce04 0x3e4 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-qsort.o) + 0x3f0 (size before relaxing) + .xt.prop 0x0000d1e8 0x9c /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-strncmp.o) + 0xa8 (size before relaxing) + .xt.prop 0x0000d284 0x18 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divsi3.o) + .xt.prop 0x0000d29c 0x18 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_modsi3.o) + .xt.prop 0x0000d2b4 0x444 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_addsubdf3.o) + .xt.prop 0x0000d6f8 0x264 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_muldf3.o) + .xt.prop 0x0000d95c 0x27c /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_cmpdf2.o) + 0x288 (size before relaxing) + .xt.prop 0x0000dbd8 0x90 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfsi.o) + 0x9c (size before relaxing) + .xt.prop 0x0000dc68 0xc0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfdi.o) + 0xcc (size before relaxing) + .xt.prop 0x0000dd28 0x54 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatsidf.o) + .xt.prop 0x0000dd7c 0x9c /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatdidf.o) + .xt.prop 0x0000de18 0x150 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divdi3.o) + .xt.prop 0x0000df68 0x120 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_udivdi3.o) + .xt.prop 0x0000e088 0x120 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_umoddi3.o) + .xt.prop 0x0000e1a8 0xa8 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memcpy.o) + 0xb4 (size before relaxing) + .xt.prop 0x0000e250 0x78 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memset.o) + 0x84 (size before relaxing) + .xt.prop 0x0000e2c8 0x1ec /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_div_df.o) + .xt.prop 0x0000e4b4 0x3a8 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_df.o) + .xt.prop 0x0000e85c 0x90 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_div.o) + 0x9c (size before relaxing) + *(.xt.prop.*) + *(.gnu.linkonce.prop.*) + +.xt.lit 0x00000000 0x518 + *(.xt.lit) + .xt.lit 0x00000000 0x18 objs/hikey/cpu_c.o + 0x40 (size before relaxing) + .xt.lit 0x00000018 0x20 objs/hikey/dsp_debug.o + .xt.lit 0x00000038 0x8 objs/hikey/mutex.o + .xt.lit 0x00000040 0x8 objs/hikey/rbtree.o + .xt.lit 0x00000048 0x60 objs/hikey/xf-core.o + 0x68 (size before relaxing) + .xt.lit 0x000000a8 0x70 objs/hikey/xf-io.o + 0x98 (size before relaxing) + .xt.lit 0x00000118 0x18 objs/hikey/xf-mem.o + 0x28 (size before relaxing) + .xt.lit 0x00000130 0x20 objs/hikey/xf-msg.o + .xt.lit 0x00000150 0x18 objs/hikey/xf-sched.o + 0x28 (size before relaxing) + .xt.lit 0x00000168 0x10 objs/hikey/xa-factory.o + .xt.lit 0x00000178 0x20 objs/hikey/xf-shmem.o + 0x30 (size before relaxing) + .xt.lit 0x00000198 0x8 objs/hikey/tinyvprintf.o + .xt.lit 0x000001a0 0x18 objs/hikey/xf-isr.o + .xt.lit 0x000001b8 0x60 objs/hikey/gdbstub.o + 0x70 (size before relaxing) + .xt.lit 0x00000218 0x58 objs/hikey/xa-class-base.o + .xt.lit 0x00000270 0x70 objs/hikey/xa-class-audio-codec.o + 0x78 (size before relaxing) + .xt.lit 0x000002e0 0x78 objs/hikey/xa-class-mixer.o + 0x80 (size before relaxing) + .xt.lit 0x00000358 0x18 objs/hikey/xf-main.o + .xt.lit 0x00000370 0xa8 objs/hikey/xa-pcm.o + .xt.lit 0x00000418 0x8 objs/hikey/xa-vorbis-decoder.o + .xt.lit 0x00000420 0x80 objs/hikey/xa-mixer.o + .xt.lit 0x000004a0 0x8 objs/hikey/reset.o + .xt.lit 0x000004a8 0x10 objs/hikey/int_vector.o + 0x40 (size before relaxing) + .xt.lit 0x000004b8 0x8 objs/hikey/arch_hifi330.o + .xt.lit 0x000004c0 0x8 objs/hikey/gdbstub-entry.o + .xt.lit 0x000004c8 0x18 ../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a(xa_vorbis_dec.o) + 0x78 (size before relaxing) + .xt.lit 0x000004e0 0x8 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(windowspill_asm.o) + .xt.lit 0x000004e8 0x8 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-on.o) + .xt.lit 0x000004f0 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-off.o) + 0x8 (size before relaxing) + .xt.lit 0x000004f0 0x8 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memchr.o) + .xt.lit 0x000004f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-strncmp.o) + 0x8 (size before relaxing) + .xt.lit 0x000004f8 0x8 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_addsubdf3.o) + .xt.lit 0x00000500 0x8 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_muldf3.o) + .xt.lit 0x00000508 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_cmpdf2.o) + 0x8 (size before relaxing) + .xt.lit 0x00000508 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfsi.o) + 0x8 (size before relaxing) + .xt.lit 0x00000508 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfdi.o) + 0x8 (size before relaxing) + .xt.lit 0x00000508 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memcpy.o) + 0x8 (size before relaxing) + .xt.lit 0x00000508 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memset.o) + 0x8 (size before relaxing) + .xt.lit 0x00000508 0x8 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_div_df.o) + .xt.lit 0x00000510 0x8 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_df.o) + .xt.lit 0x00000518 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_div.o) + 0x8 (size before relaxing) + *(.xt.lit.*) + *(.gnu.linkonce.p.*) + +.comment 0x00000000 0x1351 + .comment 0x00000000 0x59 objs/hikey/cpu_c.o + 0x5a (size before relaxing) + .comment 0x00000059 0x5d objs/hikey/dsp_debug.o + 0x5e (size before relaxing) + .comment 0x000000b6 0x5c objs/hikey/dsp_comm.o + 0x5d (size before relaxing) + .comment 0x00000112 0x50 objs/hikey/mutex.o + 0x51 (size before relaxing) + .comment 0x00000162 0x51 objs/hikey/rbtree.o + 0x52 (size before relaxing) + .comment 0x000001b3 0x4d objs/hikey/xf-core.o + 0x4e (size before relaxing) + .comment 0x00000200 0x4b objs/hikey/xf-io.o + 0x4c (size before relaxing) + .comment 0x0000024b 0x4c objs/hikey/xf-mem.o + 0x4d (size before relaxing) + .comment 0x00000297 0x4c objs/hikey/xf-msg.o + 0x4d (size before relaxing) + .comment 0x000002e3 0x4e objs/hikey/xf-sched.o + 0x4f (size before relaxing) + .comment 0x00000331 0x4f objs/hikey/xa-factory.o + 0x50 (size before relaxing) + .comment 0x00000380 0x4e objs/hikey/xf-shmem.o + 0x4f (size before relaxing) + .comment 0x000003ce 0x56 objs/hikey/tinyvprintf.o + 0x57 (size before relaxing) + .comment 0x00000424 0x4c objs/hikey/xf-isr.o + 0x4d (size before relaxing) + .comment 0x00000470 0x5a objs/hikey/gdbstub.o + 0x5b (size before relaxing) + .comment 0x000004ca 0x54 objs/hikey/xa-class-base.o + 0x55 (size before relaxing) + .comment 0x0000051e 0x5b objs/hikey/xa-class-audio-codec.o + 0x5c (size before relaxing) + .comment 0x00000579 0x55 objs/hikey/xa-class-mixer.o + 0x56 (size before relaxing) + .comment 0x000005ce 0x55 objs/hikey/xf-main.o + 0x56 (size before relaxing) + .comment 0x00000623 0x60 objs/hikey/xa-pcm.o + 0x61 (size before relaxing) + .comment 0x00000683 0x6d objs/hikey/xa-vorbis-decoder.o + 0x6e (size before relaxing) + .comment 0x000006f0 0x5f objs/hikey/xa-mixer.o + 0x60 (size before relaxing) + .comment 0x0000074f 0x573 ../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a(xa_vorbis_dec.o) + 0x584 (size before relaxing) + .comment 0x00000cc2 0xa1 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memchr.o) + 0xa2 (size before relaxing) + .comment 0x00000d63 0xa1 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcmp.o) + 0xa2 (size before relaxing) + .comment 0x00000e04 0xa0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-qsort.o) + 0xa1 (size before relaxing) + .comment 0x00000ea4 0xa2 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-strncmp.o) + 0xa3 (size before relaxing) + .comment 0x00000f46 0xa1 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divdi3.o) + 0xa2 (size before relaxing) + .comment 0x00000000 0xa2 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_udivdi3.o) + .comment 0x00000000 0xa2 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_umoddi3.o) + .comment 0x00000fe7 0xa5 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memcpy.o) + 0xa6 (size before relaxing) + .comment 0x0000108c 0xa5 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memset.o) + 0xa6 (size before relaxing) + .comment 0x00001131 0xb5 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_div_df.o) + 0xb6 (size before relaxing) + .comment 0x000011e6 0xb5 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_df.o) + 0xb6 (size before relaxing) + .comment 0x0000129b 0xb6 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_div.o) + 0xb7 (size before relaxing) + +.xtensa.info 0x00000000 0x1d8 + .xtensa.info 0x00000000 0x1d8 objs/hikey/cpu_c.o + .xtensa.info 0x00000000 0x0 objs/hikey/dsp_debug.o + .xtensa.info 0x00000000 0x0 objs/hikey/dsp_comm.o + .xtensa.info 0x00000000 0x0 objs/hikey/mutex.o + .xtensa.info 0x00000000 0x0 objs/hikey/rbtree.o + .xtensa.info 0x00000000 0x0 objs/hikey/xf-core.o + .xtensa.info 0x00000000 0x0 objs/hikey/xf-io.o + .xtensa.info 0x00000000 0x0 objs/hikey/xf-mem.o + .xtensa.info 0x00000000 0x0 objs/hikey/xf-msg.o + .xtensa.info 0x00000000 0x0 objs/hikey/xf-sched.o + .xtensa.info 0x00000000 0x0 objs/hikey/xa-factory.o + .xtensa.info 0x00000000 0x0 objs/hikey/xf-shmem.o + .xtensa.info 0x00000000 0x0 objs/hikey/tinyvprintf.o + .xtensa.info 0x00000000 0x0 objs/hikey/xf-isr.o + .xtensa.info 0x00000000 0x0 objs/hikey/gdbstub.o + .xtensa.info 0x00000000 0x0 objs/hikey/xa-class-base.o + .xtensa.info 0x00000000 0x0 objs/hikey/xa-class-audio-codec.o + .xtensa.info 0x00000000 0x0 objs/hikey/xa-class-mixer.o + .xtensa.info 0x00000000 0x0 objs/hikey/xf-main.o + .xtensa.info 0x00000000 0x0 objs/hikey/xa-pcm.o + .xtensa.info 0x00000000 0x0 objs/hikey/xa-vorbis-decoder.o + .xtensa.info 0x00000000 0x0 objs/hikey/xa-mixer.o + .xtensa.info 0x00000000 0x0 objs/hikey/reset.o + .xtensa.info 0x00000000 0x0 objs/hikey/int_vector.o + .xtensa.info 0x00000000 0x0 objs/hikey/arch_hifi330.o + .xtensa.info 0x00000000 0x0 objs/hikey/gdbstub-entry.o + .xtensa.info 0x00000000 0x0 ../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a(xa_vorbis_dec.o) + .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(windowspill_asm.o) + .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_invalidate.o) + .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_writeback.o) + .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--hw_configid0.o) + .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--hw_configid1.o) + .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--release_major.o) + .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--release_minor.o) + .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--get_intenable.o) + .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--set_intenable.o) + .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--restore_extra_nw.o) + .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--save_extra_nw.o) + .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-on.o) + .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-off.o) + .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(interrupt-table.o) + .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memchr.o) + .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcmp.o) + .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcpy.o) + .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memset.o) + .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-qsort.o) + .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-strncmp.o) + .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divsi3.o) + .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_modsi3.o) + .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_addsubdf3.o) + .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_muldf3.o) + .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_cmpdf2.o) + .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfsi.o) + .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfdi.o) + .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatsidf.o) + .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatdidf.o) + .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divdi3.o) + .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_udivdi3.o) + .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_umoddi3.o) + .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memcpy.o) + .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memset.o) + .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_div_df.o) + .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_df.o) + .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_div.o) + +.debug.xt.callgraph + *(.debug.xt.callgraph .debug.xt.callgraph.* .gnu.linkonce.xt.callgraph.*) +OUTPUT(objs/hikey/xa_hikey.o elf32-xtensa-le) + +.debug_ranges 0x00000000 0x98 + .debug_ranges 0x00000000 0x20 objs/hikey/reset.o + .debug_ranges 0x00000020 0x58 objs/hikey/int_vector.o + .debug_ranges 0x00000078 0x20 objs/hikey/gdbstub-entry.o diff --git a/hifi/xaf/hifi-dpf/build_hikey/tools/elftobin.sh b/hifi/xaf/hifi-dpf/build_hikey/tools/elftobin.sh new file mode 100755 index 00000000..cebe6bf4 --- /dev/null +++ b/hifi/xaf/hifi-dpf/build_hikey/tools/elftobin.sh @@ -0,0 +1,94 @@ +#!/bin/bash + +if [ $# != 2 ] +then +echo "elftobin.sh <input_elf_file> <output_img_file>" +exit +fi + +if [ $XTENSA_CORE == "" ] +then +echo "XTENSA_CORE is not set" +exit +fi + +if [ $XTENSA_SYSTEM == "" ] +then +echo "XTENSA_SYSTEM is not set" +exit +fi + +export INPUT_ELF_FILE=$1 +export OUTPUT_BIN_FILE=__hikey_temp.bin +export OUTPUT_IMG_FILE=$2 +export OP_DIR=./ + +xt-objdump -h $INPUT_ELF_FILE > __elfdump +less __elfdump | sed -n '/ALLOC/{g;1!p;};h' > __header +less __header | awk '{print $2 " " $3 " " $4}' > __proc + +sections=`less __proc | cut -f1 -d' ' | tr '\n' ',' | sed 's/\,$//g'` +SECTION_NUM=`awk 'END {print NR}' __proc` +echo "Total number of sections are $SECTION_NUM" +#sections=(".dram0.data" ".ResetVector.text" ".Reset.literal" ".WindowVectors.text" ".Level2InterruptVector.literal" ".Level2InterruptVector.text" ".Level3InterruptVector.literal" ".Level3InterruptVector.text" ".DebugExceptionVector.literal" ".DebugExceptionVector.text" ".NMIExceptionVector.literal" ".NMIExceptionVector.text" ".KernelExceptionVector.literal" ".KernelExceptionVector.text" ".UserExceptionVector.literal" ".UserExceptionVector.text" ".DoubleExceptionVector.literal" ".DoubleExceptionVector.text" ".Reset.text" ".iram0.text" ".rodata" ".text" ".data" ".bss") +#dst_addr=("0xe8058000" "0xe8080000" "0xe8080300" "0xe8080400" "0xe8080578" "0xe8080580" "0xe80805b8" "0xe80805c0" "0xe8080638" "0xe8080640" "0xe8080678" "0xe80806c0" "0xe80806f8" "0xe8080700" "0xe8080738" "0xe8080740" "0xe8080778" "0xe80807c0" "0xe8080800" "0xe8080a44" "0xc0000000" "0xc0000cc8" "0xc00025c0" "0xc0002a20") + +ID_Sec=("0x01010000" "0x01000001" "0x01000002" "0x01000003" "0x01000004" "0x01000005" "0x01000006" "0x01000007" "0x01000008" "0x01000009" "0x0100000A" "0x0100000B" "0x0100000C" "0x0100000D" "0x0100000E" "0x0100000F" "0x01000010" "0x01000011" "0x01000012" "0x01000013" "0x00000014" "0x00000015" "0x00010016" "0x00020017") + +head -c "4" /dev/zero > __zero.bin + +i=0 +for j in `seq 1 $SECTION_NUM` +do + VAR=`less __proc | awk 'FNR == "'"$j"'" {print $1}'` + VARBIN=`echo "$VAR" | sed 's/^./__/' | sed "s/\..*//" | sed 's/$/.bin/' ` + #echo "section: $VAR $VARBIN" + xt-objcopy $INPUT_ELF_FILE -O binary --only-section $VAR $VARBIN + + size_sec[${i}]=$(cat $VARBIN | wc -c) + #echo "size : ${size_sec[${i}]}" + mod0=`expr ${size_sec[${i}]} % 4` + nbytes=`expr 4 - $mod0` + if [ "$nbytes" -ne "4" ] ; then + tail -c $nbytes __zero.bin >> $VARBIN + size_sec[$i]=`expr ${size_sec[${i}]} + $nbytes` + fi + cat $VARBIN >> $OUTPUT_BIN_FILE + i=`expr $i + 1`; +done +cd $OP_DIR + +tmp1=$(cat $OUTPUT_BIN_FILE | wc -c) +total_sections=$SECTION_NUM +main_header_size=32 +section_header_size=16 +size_total_img=`expr $main_header_size + $tmp1 + $total_sections \* $section_header_size` +current_date_time=`date "+%Y/%m/%d %H:%M:%S"` +echo "HIF:$current_date_time" > $OUTPUT_IMG_FILE + +printf "0: %.8x" $size_total_img | sed -e 's/0\: \(..\)\(..\)\(..\)\(..\)/0\: \4\3\2\1/' | xxd -r -g0 >> $OUTPUT_IMG_FILE +printf "0: %.8x" $total_sections | sed -e 's/0\: \(..\)\(..\)\(..\)\(..\)/0\: \4\3\2\1/' | xxd -r -g0 >> $OUTPUT_IMG_FILE + +cnt1=`expr $main_header_size + $total_sections \* $section_header_size` +i=0 +for j in `seq 1 $SECTION_NUM` +do + DST_ADDR=`less __proc | awk 'FNR == "'"$j"'" {print $3}'` + printf "0: %.8x" ${ID_Sec[${i}]} | sed -e 's/0\: \(..\)\(..\)\(..\)\(..\)/0\: \4\3\2\1/' | xxd -r -g0 >> $OUTPUT_IMG_FILE + printf "0: %.8x" $cnt1 | sed -e 's/0\: \(..\)\(..\)\(..\)\(..\)/0\: \4\3\2\1/' | xxd -r -g0 >> $OUTPUT_IMG_FILE + printf "0: %.8x" 0x$DST_ADDR | sed -e 's/0\: \(..\)\(..\)\(..\)\(..\)/0\: \4\3\2\1/' | xxd -r -g0 >> $OUTPUT_IMG_FILE + printf "0: %.8x" ${size_sec[${i}]} | sed -e 's/0\: \(..\)\(..\)\(..\)\(..\)/0\: \4\3\2\1/' | xxd -r -g0 >> $OUTPUT_IMG_FILE + cnt_prev=$cnt1 + cnt1=`expr ${size_sec[${i}]} + $cnt_prev` + i=`expr $i + 1` +done + +cat $OUTPUT_BIN_FILE >> $OUTPUT_IMG_FILE +rm $OUTPUT_BIN_FILE +rm __*.bin +rm __proc +rm __elfdump +rm __header + +echo "elftobin successful!" + diff --git a/hifi/xaf/hifi-dpf/build_hikey/xa_hikey.img b/hifi/xaf/hifi-dpf/build_hikey/xa_hikey.img Binary files differnew file mode 100644 index 00000000..4c166528 --- /dev/null +++ b/hifi/xaf/hifi-dpf/build_hikey/xa_hikey.img diff --git a/hifi/xaf/hifi-dpf/core/util/gdbstub/gdbstub-entry.S b/hifi/xaf/hifi-dpf/core/util/gdbstub/gdbstub-entry.S new file mode 100644 index 00000000..50a33a93 --- /dev/null +++ b/hifi/xaf/hifi-dpf/core/util/gdbstub/gdbstub-entry.S @@ -0,0 +1,198 @@ +/******************************************************************************* +* 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-defs.h" + +.macro SAVE_ reg, loc + rsr a1, \reg + s32i a1, a3, \loc * 4 +.endm +.macro SAVE reg + SAVE_ \reg, \reg +.endm + +.macro LOAD_ reg, loc + l32i a1, a3, \loc * 4 + wsr a1, \reg +.endm +.macro LOAD reg + LOAD_ \reg, \reg +.endm + + .section ".DebugExceptionVector.text", "ax" + .global DebugExceptionVector + +DebugExceptionVector: + j 1f + .align 4 + .literal_position +1: + xsr a2, DEBUG_EXCSAVE + jx a2 + + .text + .global DebugExceptionEntry + .align 4 + +DebugExceptionEntry: + j 1f + .align 4 + .literal_position +1: + movi a2, aregs + s32i a0, a2, 0 + s32i a1, a2, 4 + rsr a1, DEBUG_EXCSAVE + s32i a1, a2, 8 + s32i a3, a2, 12 + + movi a3, sregs + SAVE LBEG + SAVE LEND + SAVE LCOUNT + SAVE SAR + SAVE WINDOWBASE + SAVE WINDOWSTART + + rsr a1, DEBUG_PC + movi a2, initial_breakpoint + bne a1, a2, 1f + addi a1, a1, 3 +1: + s32i a1, a3, DEBUG_PC * 4 + + SAVE EXCSAVE_1 + SAVE_ DEBUG_PS, PS + SAVE EXCCAUSE + SAVE DEBUGCAUSE + SAVE EXCVADDR + + movi a1, XCHAL_NUM_AREGS / 4 - 1 + movi a2, aregs +1: + s32i a4, a2, 16 + s32i a5, a2, 20 + s32i a6, a2, 24 + s32i a7, a2, 28 + + addi a6, a2, 16 + addi a5, a1, -1 + rotw 1 + bnez a1, 1b + + movi a1, 1 + wsr a1, windowstart + movi a0, 0 + wsr a0, windowbase + rsync + + movi a0, 0 + movi a1, stack + STACK_SIZE - 20 + rsr a2, ps + addi a2, a2, -PS_EXCM_MASK + wsr a2, ps + rsync + + movi a4, handle_exception + callx4 a4 + +DebugExceptionExit: + movi a2, DebugExceptionEntry + wsr a2, DEBUG_EXCSAVE + + rsr a2, ps + addi a2, a2, PS_EXCM_MASK + wsr a2, ps + rsync + + movi a3, sregs + LOAD LBEG + LOAD LEND + LOAD LCOUNT + /* TODO: handle unlikely return-to-lend case */ + LOAD SAR + LOAD WINDOWBASE + rsync + movi a3, sregs + LOAD WINDOWSTART + LOAD DEBUG_PC + LOAD EXCSAVE_1 + LOAD_ DEBUG_PS, PS + LOAD EXCCAUSE + LOAD EXCVADDR + + movi a6, aregs + movi a5, XCHAL_NUM_AREGS / 4 - 2 +1: + l32i a0, a6, 0 + l32i a1, a6, 4 + l32i a2, a6, 8 + l32i a3, a6, 12 + + beqz a5, 2f + addi a10, a6, 16 + addi a9, a5, -1 + rotw 1 + j 1b +2: + l32i a4, a6, 16 + l32i a5, a6, 20 + l32i a7, a6, 28 + l32i a6, a6, 24 + rotw 2 + + rfi XCHAL_DEBUGLEVEL + + +#ifdef LIBC_LEVEL1_HANDLER + .global fault_handler + .align 4 +fault_handler: + rsr a2, epc1 + addi a2, a2, 3 + wsr a2, epc1 + rsync + movi a2, mem_err + s32i a2, a2, 0 + + l32i a2, a1, 16 + l32i a3, a1, 20 + addi a1, a1, 256 + rfe +#endif + + + .global init_debug_entry + .align 4 +init_debug_entry: + entry a1, 16 + movi a2, DebugExceptionEntry + wsr a2, DEBUG_EXCSAVE + isync + retw + + .global breakpoint + .align 4 +breakpoint: + entry a1, 16 +initial_breakpoint: + _break 0, 0 + retw diff --git a/hifi/xaf/hifi-dpf/core/util/gdbstub/gdbstub.c b/hifi/xaf/hifi-dpf/core/util/gdbstub/gdbstub.c new file mode 100644 index 00000000..e125b94c --- /dev/null +++ b/hifi/xaf/hifi-dpf/core/util/gdbstub/gdbstub.c @@ -0,0 +1,756 @@ +/******************************************************************************* +* 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. + +******************************************************************************/ + +/**************************************************************************** + + THIS SOFTWARE IS NOT COPYRIGHTED + + HP offers the following for use in the public domain. HP makes no + warranty with regard to the software or it's performance and the + user accepts the software "AS IS" with all faults. + + HP DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, WITH REGARD + TO THIS SOFTWARE INCLUDING BUT NOT LIMITED TO THE WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + +****************************************************************************/ + +/**************************************************************************** + * Header: remcom.c,v 1.34 91/03/09 12:29:49 glenne Exp $ + * + * Module name: remcom.c $ + * Revision: 1.34 $ + * Date: 91/03/09 12:29:49 $ + * Contributor: Lake Stevens Instrument Division$ + * + * Description: low level support for gdb debugger. $ + * + * Considerations: only works on target hardware $ + * + * Written by: Glenn Engel $ + * ModuleState: Experimental $ + * + * NOTES: See Below $ + * + * Modified for SPARC by Stu Grossman, Cygnus Support. + * + * This code has been extensively tested on the Fujitsu SPARClite demo board. + * + * To enable debugger support, two things need to happen. One, a + * call to set_debug_traps() is necessary in order to allow any breakpoints + * or error conditions to be properly intercepted and reported to gdb. + * Two, a breakpoint needs to be generated to begin communication. This + * is most easily accomplished by a call to breakpoint(). Breakpoint() + * simulates a breakpoint by executing a trap #1. + * + ************* + * + * The following gdb commands are supported: + * + * command function Return value + * + * g return the value of the CPU registers hex data or ENN + * G set the value of the CPU registers OK or ENN + * + * mAA..AA,LLLL Read LLLL bytes at address AA..AA hex data or ENN + * MAA..AA,LLLL: Write LLLL bytes at address AA.AA OK or ENN + * + * c Resume at current address SNN ( signal NN) + * cAA..AA Continue at address AA..AA SNN + * + * s Step one instruction SNN + * sAA..AA Step one instruction from AA..AA SNN + * + * k kill + * + * ? What was the last sigval ? SNN (signal NN) + * + * All commands and responses are sent with a packet which includes a + * checksum. A packet consists of + * + * $<packet info>#<checksum>. + * + * where + * <packet info> :: <characters representing the command or response> + * <checksum> :: < two hex digits computed as modulo 256 sum of <packetinfo>> + * + * When a packet is received, it is first acknowledged with either '+' or '-'. + * '+' indicates a successful transfer. '-' indicates a failed transfer. + * + * Example: + * + * Host: Reply: + * $m0,10#2a +$00010203040506070809101112131415#42 + * + ****************************************************************************/ +#ifdef XAF_ENABLE_NON_HIKEY +#include "xf.h" +#else +#include <string.h> +#include <signal.h> +#include <stdint.h> +#include <xtensa/xtruntime.h> +#endif +#include "xtensa-defs.h" + +/******************************************************************************* + * Ring-buffer definition + ******************************************************************************/ + +#define RING_SIZE 256 + +struct ring { + unsigned char head; + unsigned char fill1[63]; + unsigned char tail; + unsigned char fill2[63]; + unsigned char data[RING_SIZE]; +}; + +#define GDB_INVALIDATE(p) \ + xthal_dcache_region_invalidate((void *)(p), sizeof(*p)) + +#define GDB_FLUSH(p) \ + xthal_dcache_region_writeback((void *)(p), sizeof(*p)) + +static inline unsigned int ring_next_head(const volatile struct ring *ring) +{ + return (ring->head + 1) & (RING_SIZE - 1); +} + +static inline unsigned int ring_next_tail(const volatile struct ring *ring) +{ + return (ring->tail + 1) & (RING_SIZE - 1); +} + +static inline int ring_have_space(const volatile struct ring *ring) +{ + /* ...invalidate tail pointer of tx-ring (updated by host) */ + GDB_INVALIDATE(&ring->tail); + + return ring_next_head(ring) != ring->tail; +} + +static inline int ring_have_data(const volatile struct ring *ring) +{ + /* ...invalidate head pointer of rx-ring (updated by host) */ + GDB_INVALIDATE(&ring->head); + + return ring->head != ring->tail; +} +#ifdef XAF_ENABLE_NON_HIKEY +#define DEBUG_RX_BASE XF_CFG_GDB_RING_RX +#define DEBUG_TX_BASE XF_CFG_GDB_RING_TX +#else +//#define DEBUG_RX_BASE (0x72000000) +//#define DEBUG_TX_BASE (0x72000800) +#define DEBUG_RX_BASE (0x6FFFF000) +#define DEBUG_TX_BASE (0x6FFFF800) +#endif + +volatile struct ring * const rx = (void *)DEBUG_RX_BASE; +volatile struct ring * const tx = (void *)DEBUG_TX_BASE; + +void init_debug_comm(void) +{ + rx->head = rx->tail = 0; + tx->head = tx->tail = 0; + GDB_FLUSH(&rx->head); + GDB_FLUSH(&rx->tail); + GDB_FLUSH(&tx->head); + GDB_FLUSH(&tx->tail); +} + +/* ...functions defined in asm code */ +extern void breakpoint(void); +extern void init_debug_entry(void); + +void poll_debug_ring(void) +{ + if (ring_have_data(rx)) { + breakpoint(); + } +} + +static void putDebugChar(char c) +{ + while (!ring_have_space(tx)) + ; + + tx->data[tx->head] = c; + + /* ...flush data buffer to main memory */ + GDB_FLUSH(&tx->data[tx->head]); + + tx->head = ring_next_head(tx); + + /* ...flush head pointer to main memory */ + GDB_FLUSH(&tx->head); +} + +static int getDebugChar(void) +{ + int v; + while (!ring_have_data(rx)) + ; + + /* ...inavlidate data buffer */ + GDB_INVALIDATE(&rx->data[rx->tail]); + + v = rx->data[rx->tail]; + rx->tail = ring_next_tail(rx); + + /* ...update tail index */ + GDB_FLUSH(&rx->tail); + + return v; +} + +/************************************************************************/ +/* BUFMAX defines the maximum number of characters in inbound/outbound buffers*/ +/* at least NUMREGBYTES*2 are needed for register packets */ +#define BUFMAX 256 + +#ifdef USE_GDBSTUB +#define bulk_data __attribute__((section (".ddr0.data"))) +#else +#define bulk_data +#endif +uint32_t stack[STACK_SIZE / sizeof(uint32_t)] bulk_data; +static uint8_t sregs_read[32] bulk_data; +static uint8_t sregs_mod[32] bulk_data; +static uint8_t sregs_late[32] bulk_data; +uint32_t sregs[256] bulk_data; +uint32_t aregs[XCHAL_NUM_AREGS] bulk_data; +static uint8_t remcomInBuffer[BUFMAX] bulk_data; +static uint8_t remcomOutBuffer[BUFMAX] bulk_data; + +static const char hexchars[]="0123456789abcdef"; + +/* Convert ch from a hex digit to an int */ + +static int hex(unsigned char ch) +{ + if (ch >= 'a' && ch <= 'f') + return ch-'a'+10; + if (ch >= '0' && ch <= '9') + return ch-'0'; + if (ch >= 'A' && ch <= 'F') + return ch-'A'+10; + return -1; +} + +/* scan for the sequence $<data>#<checksum> */ + +unsigned char *getpacket(void) +{ + unsigned char *buffer = &remcomInBuffer[0]; + unsigned char checksum; + unsigned char xmitcsum; + int count; + char ch; + + while (1) { + /* wait around for the start character, ignore all other characters */ + while ((ch = getDebugChar ()) != '$') + ; + +retry: + checksum = 0; + xmitcsum = -1; + count = 0; + + /* now, read until a # or end of buffer is found */ + while (count < BUFMAX - 1) { + ch = getDebugChar (); + if (ch == '$') + goto retry; + if (ch == '#') + break; + checksum = checksum + ch; + buffer[count] = ch; + count = count + 1; + } + buffer[count] = 0; + + if (ch == '#') { + ch = getDebugChar (); + xmitcsum = hex (ch) << 4; + ch = getDebugChar (); + xmitcsum += hex (ch); + + if (checksum != xmitcsum) { + putDebugChar ('-'); /* failed checksum */ + } else { + putDebugChar ('+'); /* successful transfer */ + + /* if a sequence char is present, reply the sequence ID */ + if (buffer[2] == ':') { + putDebugChar (buffer[0]); + putDebugChar (buffer[1]); + + return &buffer[3]; + } + + return &buffer[0]; + } + } + } +} + +/* send the packet in buffer. */ + +static void putpacket(uint8_t *buffer) +{ + unsigned char checksum; + int count; + unsigned char ch; + + /* $<packet info>#<checksum>. */ + do { + putDebugChar('$'); + checksum = 0; + count = 0; + + while ((ch = buffer[count]) != 0) { + putDebugChar(ch); + checksum += ch; + count += 1; + } + + putDebugChar('#'); + putDebugChar(hexchars[checksum >> 4]); + putDebugChar(hexchars[checksum & 0xf]); + + } while (getDebugChar() != '+'); +} + +/* Indicate to caller of mem2hex or hex2mem that there has been an + error. */ +volatile int mem_err = 0; + +/* Convert the memory pointed to by mem into hex, placing result in buf. + * Return a pointer to the last char put in buf (null), in case of mem fault, + * return 0. + */ + +static uint8_t * mem2hex(const void *mem_, uint8_t *buf, int count) +{ + const unsigned char *mem = mem_; + unsigned char ch; + + mem_err = 0; + while (count-- > 0) { +#ifdef __XTENSA__ + unsigned long v; + unsigned long addr = (unsigned long)mem; + asm volatile ("_l32i %0, %1, 0\n" + : "=r"(v) + : "r"(addr & ~3) + : "memory"); + ch = v >> (addr & 3) * 8; +#endif + mem++; + if (mem_err) + return NULL; + *buf++ = hexchars[ch >> 4]; + *buf++ = hexchars[ch & 0xf]; + } + + *buf = 0; + + return buf; +} + +/* convert the hex array pointed to by buf into binary to be placed in mem + * return a pointer to the character AFTER the last byte written */ + +static uint8_t * hex2mem(const uint8_t *buf, void *mem_, int count) +{ + uint8_t *mem = mem_; + int i; + uint8_t ch; + + if ((unsigned long)mem >= 0xece80000) + return NULL; + + mem_err = 0; + for (i=0; i<count; i++) { + ch = hex(*buf++) << 4; + ch |= hex(*buf++); +#ifdef __XTENSA__ + unsigned long tmp; + unsigned long addr = (unsigned long)mem; + asm volatile ("_l32i %0, %1, 0\n" + "and %0, %0, %2\n" + "or %0, %0, %3\n" + "_s32i %0, %1, 0\n" + "dhwb %1, 0\n" + "ihi %1, 0\n" + : "=r"(tmp) + : "r"(addr & ~3), "r"(0xffffffff ^ (0xff << (addr & 3) * 8)), "r"(ch << (addr & 3) * 8) + : "memory"); +#endif + mem++; + if (mem_err) + return NULL; + } + + return mem; +} + +/* + * While we find nice hex chars, build an int. + * Return number of chars processed. + */ + +static int hexToInt(uint8_t **ptr, int *intValue) +{ + int numChars = 0; + int hexValue; + + *intValue = 0; + + while (**ptr) { + hexValue = hex(**ptr); + if (hexValue < 0) + break; + + *intValue = (*intValue << 4) | hexValue; + numChars ++; + + (*ptr)++; + } + + return (numChars); +} + +static inline int test_bit(const uint8_t *p, int bit) +{ + return (p[bit / 8] >> (bit & 0x7)) & 1; +} +static inline int set_bit(uint8_t *p, int bit) +{ + return (p[bit / 8] |= 1u << (bit & 0x7)); +} + +static inline void mark_read(int sr) +{ + set_bit(sregs_read, sr); +} +static inline int is_read(int sr) +{ + return test_bit(sregs_read, sr); +} +static inline void mark_mod(int sr) +{ + set_bit(sregs_mod, sr); +} +static inline int is_mod(int sr) +{ + return test_bit(sregs_mod, sr); +} +static inline void mark_late(int sr) +{ + set_bit(sregs_late, sr); +} +static inline int is_late(int sr) +{ + return test_bit(sregs_late, sr); +} + +static void read_sr(int sr) +{ + if (!is_read(sr)) { +#ifdef __XTENSA__ + uint32_t val; + asm volatile ("movi a3, 1f + 1\n" + "s8i %1, a3, 0\n" + "dhwb a3, 0\n" + "ihi a3, 0\n" + "isync\n" + "1:\n" + "rsr %0, lbeg\n" + : "=r"(val) + : "r"(sr) + : "a3", "memory"); + sregs[sr] = val; +#endif + mark_read(sr); + } +} + +static void write_sr(int sr) +{ +#ifdef __XTENSA__ + asm volatile ("movi a3, 1f + 1\n" + "s8i %1, a3, 0\n" + "dhwb a3, 0\n" + "ihi a3, 0\n" + "isync\n" + "1:\n" + "wsr %0, lbeg\n" + : + : "r"(sregs[sr]), "r"(sr) + : "a3", "memory"); +#endif +} + +static void restore_sr(void) +{ + int i; + for (i = 0; i < 256; ++i) + if (is_mod(i) && !is_late(i)) + write_sr(i); +} + +extern void *_xtos_exc_handler_table[]; +void fault_handler(void); +#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a))) + +void handle_exception(void) +{ + int sigval = 0; + int addr; + int length; + uint8_t *ptr; + unsigned i; + const unsigned windowbase = 4 * sregs[WINDOWBASE]; + uint8_t stop_status[4] = "Sxx"; +#ifdef LIBC_LEVEL1_HANDLER + static const int cause[] = { + EXCCAUSE_LOAD_STORE_ERROR, + EXCCAUSE_LOAD_STORE_DATA_ERROR, + EXCCAUSE_LOAD_STORE_ADDR_ERROR, + EXCCAUSE_DTLB_MISS, + EXCCAUSE_DTLB_MULTIHIT, + EXCCAUSE_LOAD_PROHIBITED, + EXCCAUSE_STORE_PROHIBITED, + }; + _xtos_handler handler[sizeof(cause) / sizeof(cause[0])]; + + for (i = 0; i < ARRAY_SIZE(cause); ++i) { + handler[i] = _xtos_exc_handler_table[cause[i]]; + _xtos_exc_handler_table[cause[i]] = fault_handler; + } +#endif + memcpy(sregs_read, sregs_late, sizeof(sregs_read)); + memset(sregs_mod, 0, sizeof(sregs_mod)); + + sigval = 5; + stop_status[1] = hexchars[sigval >> 4]; + stop_status[2] = hexchars[sigval & 0xf]; + + if (sregs[DEBUGCAUSE] & DEBUGCAUSE_ICOUNT_MASK) { + sregs[ICOUNTLEVEL] = 0; + mark_mod(ICOUNTLEVEL); + } + putpacket(stop_status); + + while (1) { + remcomOutBuffer[0] = 0; + + ptr = getpacket(); + switch (*ptr++) { + case '?': + memcpy(remcomOutBuffer, stop_status, sizeof(stop_status)); + break; + + case 'c': /* cAA..AA Continue at address AA..AA(optional) */ + /* try to read optional parameter, pc unchanged if no parm */ + + if (hexToInt(&ptr, &addr)) + sregs[DEBUG_PC] = addr; + goto out; + + case 'm': /* mAA..AA,LLLL Read LLLL bytes at address AA..AA */ + /* Try to read %x,%x. */ + + if (hexToInt(&ptr, &addr) && *ptr++ == ',' && + hexToInt(&ptr, &length)) { + if (mem2hex((void *)addr, remcomOutBuffer, length)) + break; + + strcpy((char *)remcomOutBuffer, "E03"); + } else { + strcpy((char *)remcomOutBuffer, "E01"); + } + break; + + case 'M': /* MAA..AA,LLLL: Write LLLL bytes at address AA.AA return OK */ + /* Try to read '%x,%x:'. */ + + if (hexToInt(&ptr, &addr) && *ptr++ == ',' && + hexToInt(&ptr, &length) && *ptr++ == ':') { + if (hex2mem(ptr, (void *)addr, length)) + strcpy((char *)remcomOutBuffer, "OK"); + else + strcpy((char *)remcomOutBuffer, "E03"); + } else { + strcpy((char *)remcomOutBuffer, "E02"); + } + break; + + case 'p': /* pAA..AA read register number AA..AA */ + if (hexToInt(&ptr, &addr)) { + if (addr < 0x10) { /* read address register in the current window */ + mem2hex(aregs + addr, remcomOutBuffer, 4); + } else if (addr == 0x20) { /* read PC */ + mem2hex(sregs + DEBUG_PC, remcomOutBuffer, 4); + } else if (addr >= 0x100 && addr < 0x100 + XCHAL_NUM_AREGS) { /* read address register by absolute index */ + mem2hex(aregs + ((addr - windowbase) & 0xff), remcomOutBuffer, 4); + } else if (addr >= 0x200 && addr < 0x300) { /* read special register */ + addr &= 0xff; + read_sr(addr); + mem2hex(sregs + addr, remcomOutBuffer, 4); + } else if (addr >= 0x300 && addr < 0x400) { /* TODO read user register */ + strcpy((char *)remcomOutBuffer, "deadbabe"); + } else { /* unexpected register number */ + strcpy((char *)remcomOutBuffer, "E00"); + } + } + break; + + case 'P': /* PAA..AA=VV..VV Set register number AA..AA to a value VV..VV */ + if (hexToInt(&ptr, &addr) && *(ptr++) == '=') { + int ok = 1; + + if (addr < 0x10) { + hex2mem(ptr, aregs + addr, 4); + } else if (addr == 0x20) { + hex2mem(ptr, sregs + DEBUG_PC, 4); + } else if (addr >= 0x100 && addr < 0x100 + XCHAL_NUM_AREGS) { + hex2mem(ptr, aregs + ((addr - windowbase) & 0xff), 4); + } else if (addr >= 0x200 && addr < 0x300) { + addr &= 0xff; + hex2mem(ptr, sregs + addr, 4); + mark_read(addr); + mark_mod(addr); + } else { + ok = 0; + strcpy((char *)remcomOutBuffer, "E00"); + } + if (ok) + strcpy((char *)remcomOutBuffer, "OK"); + } + break; + + case 'q': /* generic query */ + if (strncmp((char *)ptr, "Supported", 9) == 0) + strcpy((char *)remcomOutBuffer, "PacketSize=100"); /* must match BUFMAX */ + break; + + case 's': /* s[AA..AA] Single step */ + if (hexToInt(&ptr, &addr)) + sregs[DEBUG_PC] = addr; + sregs[ICOUNT] = 0xfffffffe; + mark_mod(ICOUNT); + sregs[ICOUNTLEVEL] = XCHAL_DEBUGLEVEL; + mark_mod(ICOUNTLEVEL); + goto out; + + case 'Z': /* insert HW breakpoint*/ + switch (*ptr++) { + case '1': + read_sr(IBREAKENABLE); + if (*ptr++ == ',' && hexToInt(&ptr, &addr) && + *ptr++ == ',' && hexToInt(&ptr, &length) && + *ptr == 0) { + for (i = 0; i < XCHAL_NUM_IBREAK; ++i) { + if (!(sregs[IBREAKENABLE] & (1 << i)) || + sregs[IBREAKA + i] == addr) { + sregs[IBREAKA + i] = addr; + mark_mod(IBREAKA + i); + sregs[IBREAKENABLE] |= (1 << i); + mark_mod(IBREAKENABLE); + break; + } + } + if (i == XCHAL_NUM_IBREAK) + strcpy((char *)remcomOutBuffer, "E02"); + else + strcpy((char *)remcomOutBuffer, "OK"); + } else { + strcpy((char *)remcomOutBuffer, "E01"); + } + break; + } + break; + + case 'z': /* remove HW breakpoint */ + switch (*ptr++) { + case '1': + read_sr(IBREAKENABLE); + if (*ptr++ == ',' && hexToInt(&ptr, &addr) && + *ptr++ == ',' && hexToInt(&ptr, &length)) { + for (i = 0; i < XCHAL_NUM_IBREAK; ++i) { + read_sr(IBREAKA + i); + if (sregs[IBREAKENABLE] & (1 << i) && + sregs[IBREAKA + i] == addr) { + sregs[IBREAKENABLE] &= ~(1 << i); + mark_mod(IBREAKENABLE); + break; + } + } + if (i == XCHAL_NUM_IBREAK) + strcpy((char *)remcomOutBuffer, "E02"); + else + strcpy((char *)remcomOutBuffer, "OK"); + } else { + strcpy((char *)remcomOutBuffer, "E01"); + } + break; + } + break; + } + + /* reply to the request */ + putpacket(remcomOutBuffer); + } +out: +#ifdef LIBC_LEVEL1_HANDLER + for (i = 0; i < ARRAY_SIZE(cause); ++i) { + _xtos_exc_handler_table[cause[i]] = handler[i]; + } +#endif + restore_sr(); +} + +void init_gdbstub(void) +{ + mark_late(LBEG); + mark_late(LEND); + mark_late(LCOUNT); + mark_late(SAR); + mark_late(WINDOWBASE); + mark_late(WINDOWSTART); + mark_late(DEBUG_PC); + mark_late(EXCSAVE_1); + mark_late(PS); + mark_late(EXCCAUSE); + mark_late(DEBUGCAUSE); + mark_late(EXCVADDR); +#ifdef __XTENSA__ + init_debug_comm(); + init_debug_entry(); +#endif +} diff --git a/hifi/xaf/hifi-dpf/core/util/gdbstub/xtensa-defs.h b/hifi/xaf/hifi-dpf/core/util/gdbstub/xtensa-defs.h new file mode 100644 index 00000000..6ba485ff --- /dev/null +++ b/hifi/xaf/hifi-dpf/core/util/gdbstub/xtensa-defs.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 XTENSA_DEFS_H +#define XTENSA_DEFS_H + +#include <xtensa/specreg.h> +#include <xtensa/config/core-isa.h> +#include <xtensa/corebits.h> + +#define _AREG0 256 + +#define STACK_SIZE 1024 +#define DEBUG_PC (EPC + XCHAL_DEBUGLEVEL) +#define DEBUG_EXCSAVE (EXCSAVE + XCHAL_DEBUGLEVEL) +#define DEBUG_PS (EPS + XCHAL_DEBUGLEVEL) + +#endif /* XTENSA_DEFS_H */ diff --git a/hifi/xaf/hifi-dpf/core/util/mutex.c b/hifi/xaf/hifi-dpf/core/util/mutex.c new file mode 100644 index 00000000..d62a6a17 --- /dev/null +++ b/hifi/xaf/hifi-dpf/core/util/mutex.c @@ -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. + +******************************************************************************/ + +/******************************************************************************* + * mutex.c + * + * 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. + ******************************************************************************/ + +#include "xf.h" + +/******************************************************************************* + * Local constants definitions + ******************************************************************************/ + +/* ...communication variables */ +#define __M_A (1 << 0) +#define __M_W (1 << 1) +#define __M_S (1 << 2) + +/* ...process states (updated atomically) */ +#define M_PASSIVE (0) +#define M_ENTRY (__M_A) +#define M_INSIDE (__M_W) +#define M_TRANSIENT (__M_S | __M_W) +#define M_EXIT (__M_S) + +/* ...total number of cores */ +#define M_N XF_CFG_CORES_NUM + +/* ...do not compile the code if there is just a single core */ +#if M_N > 1 +/******************************************************************************* + * Entry points + ******************************************************************************/ + +void mutex_lock(u32 i) +{ + u32 j; + + /* ...p1: i-th core goes into "entry" state (aws = true,false,false) */ + MUTEX_SHARED_WRITE(i, M_ENTRY); + + /* ...p2: wait all processes have sj=false (waiting room door is open) */ + for (j = 0; j < M_N; j++) + { + /* ...wait until sj = false */ + while (MUTEX_SHARED_READ(j) & __M_S) (void) 0; + } + + /* ...p3: i-th core enters "inside" state (aws = false,true,false) */ + MUTEX_SHARED_WRITE(i, M_INSIDE); + +p4: + /* ...p4: wait in "inside" state */ + for (j = 0; j < M_N; j++) + { + /* ...p5: check if any of the cores appears is in "entry" state (aj=true) */ + if (MUTEX_SHARED_READ(j) & __M_A) + { + /* ...p5: found core in "entry" state (j < n); wait until it enters waiting room */ + goto p7; + } + } + + /* ...p6: j == n; enter into "transient" state (ai=false, wi=true, si=true) */ + MUTEX_SHARED_WRITE(i, M_TRANSIENT); + + /* ...p6.1: check for any core appearing in "entry" room */ + for (j = 0; j < M_N; j++) + { + if (MUTEX_SHARED_READ(j) & __M_A) + { + /* ...p6.2: found core in "entry" state (j < n) */ + MUTEX_SHARED_WRITE(i, M_INSIDE); + + /* ...back of to the "inside" state */ + goto p7; + } + } + + /* ...p6.3: no cores in "entry" room (j == n); go to "exit" state (ai=false, wi=false, si=true) */ + MUTEX_SHARED_WRITE(i, M_EXIT); + + /* ...p6.4: allow all cores to leave "transient" state (i.e. switch to "exit") */ + for (j = 0; j < M_N; j++) + { + while (MUTEX_SHARED_READ(j) & __M_W) (void) 0; + } + + goto p9; + +p7: + /* ...j < n condition is met; find any cores in "inside" state (wj = true, sj = false) */ + for (j = 0; j < M_N; j++) + { + /* ...check if the core is in "exit" state */ + if (MUTEX_SHARED_READ(j) == M_EXIT) + { + /* ...p8.1: different core is a leader; go to "exit" state (ai=false, wi=false, si=true) */ + MUTEX_SHARED_WRITE(i, M_EXIT); + + goto p9; + } + } + + /* ...wait in "inside" state while all transients settle */ + goto p4; + +p9: + /* ...p9: i-th core is in "exit" state; enter critical section in accordance with numbering */ + for (j = 0; j < i; j++) + { + /* ...wait until core with lower number in "inside"/"transient"/"exit" states leaves */ + while (MUTEX_SHARED_READ(j) & (__M_W | __M_S)) (void) 0; + } + + /* ...critical section entered */ +} + +/******************************************************************************* + * mutex_unlock + * + * Release multi-core mutex + ******************************************************************************/ + +void mutex_unlock(u32 i) +{ + /* ...enter into "passive" state (ai=false, wi=false, si=false) */ + MUTEX_SHARED_WRITE(i, M_PASSIVE); +} + +#endif /* M_N > 1 */ diff --git a/hifi/xaf/hifi-dpf/core/util/rbtree.c b/hifi/xaf/hifi-dpf/core/util/rbtree.c new file mode 100644 index 00000000..740e0255 --- /dev/null +++ b/hifi/xaf/hifi-dpf/core/util/rbtree.c @@ -0,0 +1,842 @@ +/******************************************************************************* +* 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.c + * + * Red-black tree library + ******************************************************************************/ + +#include "xf.h" + +/******************************************************************************* + * Macros definitions + ******************************************************************************/ + +/* ...node color */ +#define RB_RED (1) +#define RB_BLK (0) + +/* ...pointer to parent node */ +#define RB_PARENT(tree, node) ((node)->parent) + +/* ...pointer to left child node */ +#define RB_LEFT(tree, node) ((node)->left) + +/* ...pointer to right child node */ +#define RB_RIGHT(tree, node) ((node)->right) + +/* ...pointer to right child node */ +#define RB_COLOR(tree, node) ((node)->color & 1) + +/* ...check if node is black */ +#define RB_IS_BLACK(tree, node) (!((node)->color & RB_RED)) + +/* ...root node index of the tree - can be simplified? */ +#define RB_ROOT(tree) RB_LEFT((tree), &(tree)->root) + +/* ...empty node */ +#define RB_NULL(tree) (&(tree)->root) + +/******************************************************************************* + * Helpers + ******************************************************************************/ + +#define RB_SET_P(t, n, p) \ + ({ (n)->parent = (p); }) + +#define RB_SET_L(t, n, l) \ + ({ (n)->left = (l); }) + +#define RB_SET_R(t, n, r) \ + ({ (n)->right = (r); }) + +#define RB_SET_C(t, n, c) \ + RB_SET_C_##c((t), (n)) + +#define RB_SET_C_RB_BLK(t, n) \ + ({ (n)->color &= ~1; }) + +#define RB_SET_C_RB_RED(t, n) \ + ({ (n)->color |= 1; }) + +#define RB_SET_P_C(t, n, p, c) \ + ({ (n)->parent = (p); RB_SET_C_##c(t, n); }) + +#define RB_SET_P_L(t, n, p, l) \ + ({ (n)->parent = (p); (n)->left = (l); }) + +#define RB_SET_P_L_C(t, n, p, l, c) \ + ({ (n)->parent = (p); (n)->left = (l); RB_SET_C_##c(t, n); }) + +#define RB_SET_P_R(t, n, p, r) \ + ({ (n)->parent = (p); (n)->right = (r); }) + +#define RB_SET_P_R_C(t, n, p, r, c) \ + ({ (n)->parent = (p); (n)->right = (r); RB_SET_C_##c(t, n); }) + +#define RB_SET_P_L_R(t, n, p, l, r) \ + ({ (n)->parent = (p); (n)->left = (l); (n)->right = (r); }) + +#define RB_SET_P_L_R_C(t, n, p, l, r, c)\ + ({ (n)->parent = (p); (n)->left = (l); (n)->right = (r); RB_SET_C_##c(t, n); }) + +#define RB_SET_ROOT(t, n) \ + RB_SET_L((t), &(t)->root, (n)) + +/******************************************************************************* + * RB-tree functions + ******************************************************************************/ + +/******************************************************************************* + * rb_first, rb_last + * + * Return pointer to first/last item in the tree + ******************************************************************************/ + +rb_idx_t rb_first(rb_tree_t *tree) +{ + rb_idx_t p_idx, t_idx; + + if ((p_idx = RB_ROOT(tree)) != RB_NULL(tree)) + { + /* ...find left-most item in non-empty tree */ + while ((t_idx = RB_LEFT(tree, p_idx)) != RB_NULL(tree)) + p_idx = t_idx; + } + + return p_idx; +} + +rb_idx_t rb_last(rb_tree_t *tree) +{ + rb_idx_t p_idx, t_idx; + + if ((p_idx = RB_ROOT(tree)) != RB_NULL(tree)) + { + /* ...find right-most item in non-empty tree */ + while ((t_idx = RB_RIGHT(tree, p_idx)) != RB_NULL(tree)) + p_idx = t_idx; + } + + return p_idx; +} + +/******************************************************************************* + * rb_next, rb_prev + * + * Return next / previous in-order item in the tree + ******************************************************************************/ + +rb_idx_t rb_next(rb_tree_t *tree, rb_idx_t n_idx) +{ + rb_idx_t p_idx, c_idx, t_idx; + + /* ...if we have any right children, process them */ + if ((c_idx = RB_RIGHT(tree, n_idx)) != RB_NULL(tree)) + { + /* ...descent to the left-most node starting from right child */ + while ((t_idx = RB_LEFT(tree, c_idx)) != RB_NULL(tree)) + c_idx = t_idx; + return c_idx; + } + + /* ...no right children; ascend to our parent while we are right child */ + while ((p_idx = RB_PARENT(tree, n_idx)) != RB_NULL(tree)) + { + /* ...as soon as "n" is a left child, return "p" */ + if (n_idx == RB_RIGHT(tree, p_idx)) + n_idx = p_idx; + else + return p_idx; + } + + /* ...we were right-most child */ + return p_idx; +} + +rb_idx_t rb_prev(rb_tree_t *tree, rb_idx_t n_idx) +{ + rb_idx_t p_idx, c_idx, t_idx; + + /* ...if we have any left children, process them */ + if ((c_idx = RB_LEFT(tree, n_idx)) != RB_NULL(tree)) + { + /* ...descent to the right-most node starting from left child */ + while ((t_idx = RB_RIGHT(tree, c_idx)) != RB_NULL(tree)) + c_idx = t_idx; + return c_idx; + } + + /* ...no left children; ascend to our parent while we are left child */ + while ((p_idx = RB_PARENT(tree, n_idx)) != RB_NULL(tree)) + { + /* ...as soon as "n" is a right child, return "p" */ + if (n_idx == RB_LEFT(tree, p_idx)) + n_idx = p_idx; + else + return p_idx; + } + + /* ...we were left-most child */ + return p_idx; +} + +/******************************************************************************* + * rb_init + * + * Initialize rb-tree structure + ******************************************************************************/ + +void rb_init(rb_tree_t *tree) +{ + /* ...initialize sentinel node of the empty tree */ + RB_SET_P_L_R_C(tree, &tree->root, RB_NULL(tree), RB_NULL(tree), RB_NULL(tree), RB_BLK); +} + +/******************************************************************************* + * rb_insert + * + * Insert new item into RB-tree. Returns non-zero node index on success + ******************************************************************************/ + +/* ...internal tree balancing function */ +static void __rb_insert_balance(rb_tree_t *tree, rb_idx_t n_idx, rb_idx_t p_idx) +{ + rb_idx_t u_idx, g_idx, t_idx, cl_idx, cr_idx; + +rebalance: + + /*************************************************************************** + * Trivial case #1 - N (red) is a root + **************************************************************************/ + + if (p_idx == RB_NULL(tree)) + { + RB_SET_C(tree, n_idx, RB_BLK); + goto root; + } + + /*************************************************************************** + * Trivial case #2 - P is black + **************************************************************************/ + + if (RB_IS_BLACK(tree, p_idx)) + goto done; + + /*************************************************************************** + * Complex cases - P is red, N is red + **************************************************************************/ + + /* ...grandparent must exist and be black */ + g_idx = RB_PARENT(tree, p_idx); + if (p_idx == RB_LEFT(tree, g_idx)) + { + /* ...we are left grandchild; get uncle (if it exists) */ + u_idx = RB_RIGHT(tree, g_idx); + + /* ...if U is read, we have conditions of case #3 */ + if (!RB_IS_BLACK(tree, u_idx)) + goto case3; + + /* ...we will need grand-grand-parent later */ + t_idx = RB_PARENT(tree, g_idx); + + /* ...U is black/null; if we are LL grandchild, we have case #5 */ + if (n_idx == RB_LEFT(tree, p_idx)) + goto case5_ll; + + /* ...N is RL grandchild of G; case #4 */ + goto case4_rl; + } + else + { + /* ...we are right grandchild; get uncle (if it exists) */ + u_idx = RB_LEFT(tree, g_idx); + + /* ...if U is read, we have conditions of case #3 */ + if (!RB_IS_BLACK(tree, u_idx)) + goto case3; + + /* ...we will need grand-grand-parent later */ + t_idx = RB_PARENT(tree, g_idx); + + /* ...U is black/null; if we are RR grandchild, we have case #5 */ + if (n_idx == RB_RIGHT(tree, p_idx)) + goto case5_rr; + + /* ...N is LR grandchild of G; case #4 */ + goto case4_lr; + } + +case4_rl: + + /*************************************************************************** + * Case #4 - P is red, U is black, N is red RL grandchild of G. We will do + * two tree rotations - first the one described in case #4, second is the + * one described in case #5 (as have conditions for case #5(LL) with P and + * N changing roles + **************************************************************************/ + + cl_idx = RB_LEFT(tree, n_idx), cr_idx = RB_RIGHT(tree, n_idx); + RB_SET_P_L_R_C(tree, n_idx, t_idx, p_idx, g_idx, RB_BLK); + RB_SET_P_R(tree, p_idx, n_idx, cl_idx); + RB_SET_P(tree, cl_idx, p_idx); + RB_SET_P_L_C(tree, g_idx, n_idx, cr_idx, RB_RED); + RB_SET_P(tree, cr_idx, g_idx); + + /* ...new root of subtree is N; adjust T pointer */ + goto case5_xx; + +case4_lr: + + /*************************************************************************** + * Case #4 - P is red, U is black, N is red LR grandchild of G. We will do + * two tree rotations - first the one described in case #4, second is the + * one described in case #5 (as have conditions for case #5(RR) with P and + * N changing roles + **************************************************************************/ + + cl_idx = RB_LEFT(tree, n_idx), cr_idx = RB_RIGHT(tree, n_idx); + RB_SET_P_L_R_C(tree, n_idx, t_idx, g_idx, p_idx, RB_BLK); + RB_SET_P_L(tree, p_idx, n_idx, cr_idx); + RB_SET_P(tree, cr_idx, p_idx); + RB_SET_P_R_C(tree, g_idx, n_idx, cl_idx, RB_RED); + RB_SET_P(tree, cl_idx, g_idx); + + /* ...new root of the subtree is N; adjust T pointer */ + goto case5_xx; + +case5_ll: + + /*************************************************************************** + * Case #5: N is LL grandchild of P; N and P red, G and U black + **************************************************************************/ + + cr_idx = RB_RIGHT(tree, p_idx); + RB_SET_P_L_C(tree, g_idx, p_idx, cr_idx, RB_RED); + RB_SET_P(tree, cr_idx, g_idx); + RB_SET_P_R_C(tree, p_idx, t_idx, g_idx, RB_BLK); + + /* ...new root of the subtree is P; relabel and adjust T pointer */ + n_idx = p_idx; + goto case5_xx; + +case5_rr: + + /*************************************************************************** + * Case #5: N is RR grandchild of P; N and P red, G and U black + **************************************************************************/ + + cl_idx = RB_LEFT(tree, p_idx); + RB_SET_P_R_C(tree, g_idx, p_idx, cl_idx, RB_RED); + RB_SET_P(tree, cl_idx, g_idx); + RB_SET_P_L_C(tree, p_idx, t_idx, g_idx, RB_BLK); + + /* ...new root of the subtree is P; relabel and adjust T pointer */ + n_idx = p_idx; + goto case5_xx; + +case5_xx: + + /* ...N is a (black) root of subtree; check if it is a root of tree as well */ + if (t_idx == RB_NULL(tree)) + goto root; + else if (g_idx == RB_LEFT(tree, t_idx)) + RB_SET_L(tree, t_idx, n_idx); + else + RB_SET_R(tree, t_idx, n_idx); + + goto done; + +case3: + + /*************************************************************************** + * Case #3 - P and U are red, G is black + **************************************************************************/ + + RB_SET_C(tree, p_idx, RB_BLK); + RB_SET_C(tree, u_idx, RB_BLK); + RB_SET_C(tree, g_idx, RB_RED); + + /* ...rebalance the tree for a G */ + n_idx = g_idx, p_idx = RB_PARENT(tree, g_idx); + goto rebalance; + +root: + /* ...adjust root pointer of the tree */ + RB_SET_ROOT(tree, n_idx); + +done: + /* ...tree is balanced */ + return; +} + +/* ...high-level API function */ +void rb_insert(rb_tree_t *tree, rb_idx_t n_idx, rb_idx_t p_idx) +{ + if (p_idx == RB_NULL(tree)) + { + /* ...set black root node */ + RB_SET_P_L_R_C(tree, n_idx, p_idx, p_idx, p_idx, RB_BLK); + + /* ...tree consists of the only root node; is balanced */ + RB_SET_ROOT(tree, n_idx); + } + else + { + /* ...create new node - set parent pointer and paint red */ + RB_SET_P_L_R_C(tree, n_idx, p_idx, RB_NULL(tree), RB_NULL(tree), RB_RED); + + /* ...and rebalance the tree */ + __rb_insert_balance(tree, n_idx, p_idx); + } +} + +/******************************************************************************* + * rb_delete + * + * Remove item from RB-key (by key). Returns zero on success + ******************************************************************************/ + +/* ...internal tree balancing function */ +static void __rb_delete_rebalance(rb_tree_t *tree, rb_idx_t p_idx) +{ + rb_idx_t n_idx, s_idx, sl_idx, sr_idx, g_idx, c_idx, cl_idx, cr_idx; + + /* ...initialize rebalancing procedure with null-child of P */ + n_idx = RB_NULL(tree); + +rebalance: + + /* ...save grand-parent pointer (may be null) */ + g_idx = RB_PARENT(tree, p_idx); + + /*************************************************************************** + * Check for complex cases + **************************************************************************/ + + if (n_idx == RB_LEFT(tree, p_idx)) + { + /* ...N is left child; get sibling (must exist) and its children */ + s_idx = RB_RIGHT(tree, p_idx); + sl_idx = RB_LEFT(tree, s_idx); + sr_idx = RB_RIGHT(tree, s_idx); + + /* ...if S is black, test for conditions 3,4,5,6; otherwise - case 2 */ + if (RB_IS_BLACK(tree, s_idx)) + goto test3_l; + else + goto case2_l; + } + else + { + /* ...N is right child; get sibling (must exist) and its children */ + s_idx = RB_LEFT(tree, p_idx); + sl_idx = RB_LEFT(tree, s_idx); + sr_idx = RB_RIGHT(tree, s_idx); + + /* ...if S is black, test for conditions 3,4,5,6; otherwise - case 2 */ + if (RB_IS_BLACK(tree, s_idx)) + goto test3_r; + else + goto case2_r; + } + +case2_l: + + /*************************************************************************** + * Case #2: N is a left child of P; S is red + **************************************************************************/ + + c_idx = sl_idx; + RB_SET_P_L_C(tree, s_idx, g_idx, p_idx, RB_BLK); + RB_SET_P_R_C(tree, p_idx, s_idx, c_idx, RB_RED); + RB_SET_P(tree, c_idx, p_idx); + + /* ...S is new root of subtree, Sl(C) is new sibling of N; update G */ + goto case2_x; + +case2_r: + + /*************************************************************************** + * Case #2: N is a right child of P; S is red + **************************************************************************/ + + c_idx = sr_idx; + RB_SET_P_R_C(tree, s_idx, g_idx, p_idx, RB_BLK); + RB_SET_P_L_C(tree, p_idx, s_idx, c_idx, RB_RED); + RB_SET_P(tree, c_idx, p_idx); + + /* ...S is new root of subtree, Sr(C) is new sibling of N; update G */ + goto case2_x; + +case2_x: + + /* ...check if S is becoming new (black) root of the tree */ + if (g_idx == RB_NULL(tree)) + RB_SET_ROOT(tree, s_idx); + else if (p_idx == RB_LEFT(tree, g_idx)) + RB_SET_L(tree, g_idx, s_idx); + else + RB_SET_R(tree, g_idx, s_idx); + + /* ...relabel new N's grandparent (now S) as G and new sibling (now C) as S */ + g_idx = s_idx, s_idx = c_idx; + sl_idx = RB_LEFT(tree, s_idx); + sr_idx = RB_RIGHT(tree, s_idx); + + /* ...N is still one of P's children; select proper side */ + if (n_idx == RB_LEFT(tree, p_idx)) + goto test3_l; + else + goto test3_r; + +test3_l: + + /*************************************************************************** + * Test for cases 3,4,5,6; P is any, S is black. N is left child of P + **************************************************************************/ + + if (!RB_IS_BLACK(tree, sr_idx)) + /* ...Sr is red, Sl of any color; conditions for case #6 are met */ + goto case6_l; + else if (!RB_IS_BLACK(tree, sl_idx)) + /* ...Sr is black and Sl is red; conditions for case #5 are met */ + goto case5_l; + else if (RB_IS_BLACK(tree, p_idx)) + /* ...Sl and Sr are of the same (black) color and P is black */ + goto case3; + else + /* ...Sl and Sr are of the same (black) color and P is red */ + goto case4; + +test3_r: + + /*************************************************************************** + * Test for cases 3,4,5,6; P is any, S is black. N is right child of P + **************************************************************************/ + + if (!RB_IS_BLACK(tree, sl_idx)) + /* ...Sl is red, Sr of any color; conditions for case #6 are met */ + goto case6_r; + else if (!RB_IS_BLACK(tree, sr_idx)) + /* ...Sl is black and Sr is red; conditions for case #5 are met */ + goto case5_r; + else if (RB_IS_BLACK(tree, p_idx)) + /* ...Sl and Sr are of the same (black) color and P is black */ + goto case3; + else + /* ...Sl and Sr are of the same (black) color and P is red */ + goto case4; + +case3: + + /*************************************************************************** + * Case #3: N, P, S, Sl and Sr are black + **************************************************************************/ + + RB_SET_C(tree, s_idx, RB_RED); + + /* ...and rebalance the tree for parent */ + n_idx = p_idx, p_idx = RB_PARENT(tree, p_idx); + + if (p_idx == RB_NULL(tree)) + goto done; + else + goto rebalance; + +case4: + + /*************************************************************************** + * Case #4: N and S are black, P is red, Sl and Sr are all black + **************************************************************************/ + + RB_SET_C(tree, s_idx, RB_RED); + RB_SET_C(tree, p_idx, RB_BLK); + + goto done; + +case5_l: + /*************************************************************************** + * Case #5: S is black, Sl is red, Sr is black; N is left child of P. We + * have two subsequent transformations (case #5 and case #6) combined + **************************************************************************/ + + cl_idx = RB_LEFT(tree, sl_idx); + cr_idx = RB_RIGHT(tree, sl_idx); + + if (RB_IS_BLACK(tree, p_idx)) + RB_SET_P_L_R_C(tree, sl_idx, g_idx, p_idx, s_idx, RB_BLK); + else + RB_SET_P_L_R_C(tree, sl_idx, g_idx, p_idx, s_idx, RB_RED); + + RB_SET_P_R_C(tree, p_idx, sl_idx, cl_idx, RB_BLK); + RB_SET_P(tree, cl_idx, p_idx); + RB_SET_P_L(tree, s_idx, sl_idx, cr_idx); + RB_SET_P(tree, cr_idx, s_idx); + + /* ...relabel new root as S (for common processing in case #6) */ + s_idx = sl_idx; + goto case6_x; + +case5_r: + /*************************************************************************** + * Case #5: S is black, Sr is red, Sl is black; N is right child of P. We + * have two subsequent transformations (case #5 and case #6) combined + **************************************************************************/ + + cl_idx = RB_LEFT(tree, sr_idx); + cr_idx = RB_RIGHT(tree, sr_idx); + + if (RB_IS_BLACK(tree, p_idx)) + RB_SET_P_L_R_C(tree, sr_idx, g_idx, s_idx, p_idx, RB_BLK); + else + RB_SET_P_L_R_C(tree, sr_idx, g_idx, s_idx, p_idx, RB_RED); + + RB_SET_P_L_C(tree, p_idx, sr_idx, cr_idx, RB_BLK); + RB_SET_P(tree, cr_idx, p_idx); + RB_SET_P_R(tree, s_idx, sr_idx, cl_idx); + RB_SET_P(tree, cl_idx, s_idx); + + /* ...relabel new root as S (for common processing in case #6) */ + s_idx = sr_idx; + goto case6_x; + +case6_l: + + /*************************************************************************** + * Case #6: S is black, N is the left child of P, Sr is red + **************************************************************************/ + + if (RB_IS_BLACK(tree, p_idx)) + RB_SET_P_L(tree, s_idx, g_idx, p_idx); + else + RB_SET_P_L_C(tree, s_idx, g_idx, p_idx, RB_RED); + + RB_SET_P_R_C(tree, p_idx, s_idx, sl_idx, RB_BLK); + RB_SET_P(tree, sl_idx, p_idx); + RB_SET_C(tree, sr_idx, RB_BLK); + + /* ...S is a new root of subtree; update G */ + goto case6_x; + +case6_r: + + /*************************************************************************** + * Case #6: S is black, N is the right child of P, Sl is red + **************************************************************************/ + + if (RB_IS_BLACK(tree, p_idx)) + RB_SET_P_R(tree, s_idx, g_idx, p_idx); + else + RB_SET_P_R_C(tree, s_idx, g_idx, p_idx, RB_RED); + + RB_SET_P_L_C(tree, p_idx, s_idx, sr_idx, RB_BLK); + RB_SET_P(tree, sr_idx, p_idx); + RB_SET_C(tree, sl_idx, RB_BLK); + + /* ...S is a new root of subtree; update G */ + goto case6_x; + +case6_x: + + /* ...S is a new root of subtree; update G's pointer */ + if (g_idx == RB_NULL(tree)) + RB_SET_ROOT(tree, s_idx); + else if (p_idx == RB_LEFT(tree, g_idx)) + RB_SET_L(tree, g_idx, s_idx); + else + RB_SET_R(tree, g_idx, s_idx); + + /* ...tree is balanced; pass through */ + +done: + + return; +} + +/* ...high-level API function */ +rb_idx_t rb_delete(rb_tree_t *tree, rb_idx_t n_idx) +{ + rb_idx_t p_idx, t_idx, m_idx, c_idx, l_idx, r_idx, k_idx; + u32 color; + + /* ...save parent of element N that we are going to remove */ + p_idx = RB_PARENT(tree, n_idx); + + /* ...get in-order predecessor/successor of n_idx, if possible */ + if ((m_idx = RB_LEFT(tree, n_idx)) != RB_NULL(tree)) + { + while ((t_idx = RB_RIGHT(tree, m_idx)) != RB_NULL(tree)) + m_idx = t_idx; + + /* ...set the child of in-order predecessor (may be null) */ + c_idx = RB_LEFT(tree, m_idx); + } + else if ((m_idx = RB_RIGHT(tree, n_idx)) != RB_NULL(tree)) + { + while ((t_idx = RB_LEFT(tree, m_idx)) != RB_NULL(tree)) + m_idx = t_idx; + + /* ...set the child of in-order successor (may be null) */ + c_idx = RB_RIGHT(tree, m_idx); + } + else if (p_idx == RB_NULL(tree)) + { + /* ...tree consists of the only root node N that we are removing */ + RB_SET_ROOT(tree, m_idx); + + /* ..return tree null pointer */ + return m_idx; + } + else + { + /* ...N is a (non-root) leaf node; M and C are null */ + c_idx = m_idx; + + /* ...save the color of the node we are going to delete */ + color = RB_COLOR(tree, n_idx); + + /* ...set new parent of C */ + t_idx = p_idx; + + /* ...pointer that we return as in-order predecessor/successor */ + k_idx = p_idx; + + /* ...adjust only parent of the N */ + goto adjust_parent; + } + + /* ...node that replaces our component is M */ + k_idx = m_idx; + + /*************************************************************************** + * Replace node N with M + **************************************************************************/ + + /* ...save original color of M (the node that we are deleting) */ + color = RB_COLOR(tree, m_idx); + + /* ...put M in place of N; get N's children */ + l_idx = RB_LEFT(tree, n_idx); + r_idx = RB_RIGHT(tree, n_idx); + + /* ...see if M is a child of N */ + if ((t_idx = RB_PARENT(tree, m_idx)) != n_idx) + { + /* ...C becomes left or right child of M's original parent T */ + if (c_idx == RB_LEFT(tree, m_idx)) + RB_SET_R(tree, t_idx, c_idx); + else + RB_SET_L(tree, t_idx, c_idx); + + /* ...adjust C parent pointer (okay if it's null) */ + RB_SET_P(tree, c_idx, t_idx); + + /* ...set all pointers of node M (it replaces N) */ + RB_SET_P_L_R(tree, m_idx, p_idx, l_idx, r_idx); + RB_SET_P(tree, l_idx, m_idx); + RB_SET_P(tree, r_idx, m_idx); + } + else + { + /* ...M is a left or right child of N; it gets to N's place, and C remains intact */ + if (m_idx == l_idx) + { + RB_SET_P_R(tree, m_idx, p_idx, r_idx); + RB_SET_P(tree, r_idx, m_idx); + } + else + { + RB_SET_P_L(tree, m_idx, p_idx, l_idx); + RB_SET_P(tree, l_idx, m_idx); + } + + /* ...parent of C is still M (we label it as T) */ + t_idx = m_idx; + } + + /* ...paint M in the same color as N which it replaced */ + if (RB_IS_BLACK(tree, n_idx)) + RB_SET_C(tree, m_idx, RB_BLK); + else + RB_SET_C(tree, m_idx, RB_RED); + +adjust_parent: + + /* ...adjust N's parent node to point to M */ + if (p_idx == RB_NULL(tree)) + RB_SET_ROOT(tree, m_idx); + else if (n_idx == RB_LEFT(tree, p_idx)) + RB_SET_L(tree, p_idx, m_idx); + else + RB_SET_R(tree, p_idx, m_idx); + + /* ...check for a color of deleted item (M or N in case it is a leaf) */ + if (color == RB_BLK) + { + if (c_idx == RB_NULL(tree)) + /* ...rebalance the tree for a T node (it is never a null)*/ + __rb_delete_rebalance(tree, t_idx); + else + /* ...C node exists and is necessarily red; repaint it black */ + RB_SET_C(tree, c_idx, RB_BLK); + } + + /* ....return the node K which replaced deleted node N */ + return k_idx; +} + +/******************************************************************************* + * rb_replace + * + * Replace the node with the same-key node - adjust tree pointers + ******************************************************************************/ + +void rb_replace(rb_tree_t *tree, rb_idx_t n_idx, rb_idx_t t_idx) +{ + rb_idx_t p_idx, l_idx, r_idx; + + /* ...get node pointers */ + p_idx = RB_PARENT(tree, n_idx), l_idx = RB_LEFT(tree, n_idx), r_idx = RB_RIGHT(tree, n_idx); + + /* ...set new node pointers */ + RB_SET_P_L_R(tree, t_idx, p_idx, l_idx, r_idx); + + /* ...set node color */ + if (RB_IS_BLACK(tree, n_idx)) + RB_SET_C(tree, t_idx, RB_BLK); + else + RB_SET_C(tree, t_idx, RB_RED); + + /* ...update parent node */ + if (p_idx == RB_NULL(tree)) + RB_SET_ROOT(tree, t_idx); + else if (n_idx == RB_LEFT(tree, p_idx)) + RB_SET_L(tree, p_idx, t_idx); + else + RB_SET_R(tree, p_idx, t_idx); + + /* ...update children's parent node (okay if null) */ + RB_SET_P(tree, l_idx, t_idx), RB_SET_P(tree, r_idx, t_idx); +} diff --git a/hifi/xaf/hifi-dpf/core/util/tinyvprintf.c b/hifi/xaf/hifi-dpf/core/util/tinyvprintf.c new file mode 100644 index 00000000..25d7e03e --- /dev/null +++ b/hifi/xaf/hifi-dpf/core/util/tinyvprintf.c @@ -0,0 +1,198 @@ +/******************************************************************************* +* 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 <string.h> +#include "lib/tinyput.h" + + +/* + * Simple formatted output routine. + * Designed primarily for small size (and secondarily for efficiency). + * Only a common subset of printf formats and options are handled: + * + * %[-+ ][0][width]i decimal signed integer + * %[-+ ][0][width]d decimal signed integer + * %[-][0][width]u decimal unsigned integer + * %[-][0][width]x hex unsigned integer + * %[-][0][width]p hex unsigned integer with 0x prefix ("pointer") + * %[-][width]c single character + * %[-][width]s string + * + * These modifiers are ignored (legally on 32-bit Xtensa): + * # (alternate format) + * h (short) expands to int on 32-bit Xtensa + * l (long) same as int on 32-bit Xtensa + * j (intmax_t or uintmax_t) same as int on 32-bit Xtensa + * z (size_t or ssize_t) same as int on 32-bit Xtensa + * t (ptrdiff_t) same as int on 32-bit Xtensa + * + * Does NOT support: + * width.prec (precision modifier) + * %X (capitalized hex; handles this as lowercase hex) + * %o (octal) + * %[L][feEgG] (floating point formats) + * %a %A (hex floating point formats, C99) + * %C (multibyte character) + * %S (multibyte character string) + * %n (returning count of character written) + * ll (long long) + * q j z t (other size modifiers, eg. see glibc) + */ +int tiny_vsprintf(char *out, const char *fmt, va_list ap) +{ + int total = 0; + char c, space = ' ', buf[11]; /* largest 32-bit integer output (octal) */ + + while ((c = *(char*)fmt++) != 0) { + if (c != '%') { + *out++ = c; + total++; + } else { + int width = 0, len = 1, rightjust = 1; + unsigned n; + char *s = buf, *t, pad = ' ', sign = 0; + while (1) { + c = *(char*)fmt++; + switch (c) { + case 'c': buf[0] = va_arg(ap, int); goto donefmt; + case 's': s = va_arg(ap, char*); + if (s == 0) + len = 0; + else { + for (t = s; *t; t++) ; + len = t - s; + } + goto donefmt; + + case '#': /* ignore (not supported) */ + case 'h': /* ignore (short; passed as int) */ + case 'l': /* ignore (long; same as int) */ + case 'j': /* ignore (intmax_t or uintmax_t; same as int) */ + case 'z': /* ignore (size_t or ssize_t; same as int) */ + case 't': /* ignore (ptrdiff_t; same as int) */ + break; + + case ' ': sign = ' '; break; + case '+': sign = '+'; break; + case '-': rightjust = 0; break; + + case 'i': /*FALLTHROUGH*/ + case 'd': n = va_arg(ap, int); + if ((int)n < 0) { + sign = '-'; + n = -(int)n; + } + if (sign) { + if (rightjust && pad == ' ') + *s++ = sign; + else { + *out++ = sign; + width--; + total++; + } + } + goto do_decimal; + case 'u': n = va_arg(ap, int); + do_decimal: + { + /* (avoids division or multiplication) */ + int digit, i, seen = 0; + for (digit = 0; n >= 1000000000; digit++) + n -= 1000000000; + for (i = 9;;) { + if (!seen && digit != 0) + seen = i; + if (seen) + *s++ = '0' + digit; + for (digit = 0; n >= 100000000; digit++) + n -= 100000000; + if (--i == 0) { + *s++ = '0' + digit; + len = s - buf; + s = buf; + goto donefmt; + } + n = ((n << 1) + (n << 3)); + } + } + /*NOTREACHED*/ + +#if 0 + case 'o': n = va_arg(ap, unsigned); + s = buf + 11; + do { + *--s = '0' + (n & 7); + n = (unsigned)n >> 3; + } while (n); + len = buf + 11 - s; + goto donefmt; +#endif + + case 'p': *out++ = '0', *out++ = 'x'; + total += 2; + /*FALLTHROUGH*/ + case 'X': /*FALLTHROUGH*/ + case 'x': n = va_arg(ap, unsigned); + s = buf + 8; + do { + *--s = "0123456789abcdef"[n & 0xF]; + n = (unsigned)n >> 4; + } while (n); + len = buf + 8 - s; + goto donefmt; + + case 0: goto done; + case '0': if (width == 0) pad = '0'; /*FALLTHROUGH*/ + default: if (c >= '0' && c <= '9') + width = ((width<<1) + (width<<3)) + (c - '0'); + else { + buf[0] = c; /* handles case of '%' */ + goto donefmt; + } + } + } + /*NOTREACHED*/ + donefmt: + if (len < width) { + total += width; + if (rightjust) + do { *out++ = pad; } while (len < --width); + } else + total += len; + for(n = len; n > 0; n--) *out++ = *s++; + for (; len < width; len++) *out++ = space; + } + } +done: + return total; +} + +int tiny_sprintf(char *out, const char *fmt, ...) +{ + int n = 0; + va_list ap; + va_start(ap, fmt); + n = tiny_vsprintf(out, fmt, ap); + va_end(ap); + return n; +} diff --git a/hifi/xaf/hifi-dpf/core/xf-core.c b/hifi/xaf/hifi-dpf/core/xf-core.c new file mode 100644 index 00000000..95bca129 --- /dev/null +++ b/hifi/xaf/hifi-dpf/core/xf-core.c @@ -0,0 +1,709 @@ +/******************************************************************************* +* 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.c + * + * DSP processing framework core + * + ******************************************************************************/ + +#define MODULE_TAG CORE + +/******************************************************************************* + * Includes + ******************************************************************************/ + +#include "xf.h" + +/******************************************************************************* + * Tracing tags + ******************************************************************************/ + +/* ...general initialization sequence */ +TRACE_TAG(INIT, 1); + +/* ...message dispatching */ +TRACE_TAG(DISP, 1); + +/* ...client registration procedures */ +TRACE_TAG(REG, 1); + +/* ...ports routing/unrouting */ +TRACE_TAG(ROUTE, 1); + +#ifdef XAF_PROFILE_DSP +/* ... MCPS/profile info */ +#include "xa_profiler.h" +#endif +/******************************************************************************* + * Internal helpers + ******************************************************************************/ + +/* ...translate client-id into component handle */ +static inline xf_component_t * xf_client_lookup(xf_core_data_t *cd, u32 client) +{ + xf_cmap_link_t *link = &cd->cmap[client]; + + /* ...if link pointer is less than XF_CFG_MAX_CLIENTS, it is a free descriptor */ + return (link->next > XF_CFG_MAX_CLIENTS ? link->c : NULL); +} + +/* ...allocate client-id */ +static inline u32 xf_client_alloc(xf_core_data_t *cd) +{ + u32 client = cd->free; + + /* ...advance list head to next free id */ + (client < XF_CFG_MAX_CLIENTS ? cd->free = cd->cmap[client].next : 0); + + return client; +} + +/* ...recycle client-id */ +static inline void xf_client_free(xf_core_data_t *cd, u32 client) +{ + /* ...put client into the head of the free id list */ + cd->cmap[client].next = cd->free, cd->free = client; +} + +/******************************************************************************* + * Process commands to a proxy + ******************************************************************************/ + +/* ...register new client */ +static int xf_proxy_register(u32 core, xf_message_t *m) +{ + xf_core_data_t *cd = XF_CORE_DATA(core); + u32 src = XF_MSG_SRC(m->id); + u32 client; + xf_component_t *component; + + /* ...allocate new client-id */ + XF_CHK_ERR((client = xf_client_alloc(cd)) != XF_CFG_MAX_CLIENTS, -EBUSY); + + /* ...create component via class factory */ + if ((component = xf_component_factory(core, m->buffer, m->length)) == NULL) + { + TRACE(ERROR, _x("Component creation failed")); + + /* ...recycle client-id */ + xf_client_free(cd, client); + + /* ...return generic out-of-memory code always (tbd) */ + return -ENOMEM; + } + + /* ...register component in a map */ + cd->cmap[client].c = component; + + /* ...set component "default" port specification ("destination") */ + component->id = __XF_PORT_SPEC(core, client, 0); + + /* ...adjust session-id to include newly created component-id */ + m->id = __XF_MSG_ID(src, component->id); + + /* ...do system-specific registration of component within IPC layer */ + xf_ipc_component_addref(m->id); + + TRACE(REG, _b("registered client: %u:%u (%s)"), core, client, (xf_id_t)m->buffer); + + /* ...and return success to remote proxy (zero-length output) */ + xf_response_ok(m); + + return 0; +} + +/* ...shared buffer allocation request */ +static int xf_proxy_alloc(u32 core, xf_message_t *m) +{ + /* ...command is valid only if shared memory interface for core is specified */ + XF_CHK_ERR(xf_shmem_enabled(core), -EPERM); + + /* ...allocate shared memory buffer (system-specific function; may fail) */ + xf_shmem_alloc(core, m); + + /* ...pass result to remote proxy (on success buffer is non-null) */ + xf_response(m); + + return 0; +} + +/* ...shared buffer freeing request */ +static int xf_proxy_free(u32 core, xf_message_t *m) +{ + /* ...command is valid only if shared memory interface for core is specified */ + XF_CHK_ERR(xf_shmem_enabled(core), -EPERM); + + /* ...pass buffer freeing request to system-specific function */ + xf_shmem_free(core, m); + + /* ...return success to remote proxy (function never fails) */ + xf_response(m); + + return 0; +} + +#if 0 +/* ...port routing command processing */ +static int xf_proxy_route(u32 core, xf_message_t *m) +{ + xf_route_port_msg_t *cmd = m->buffer; + u32 src = cmd->src; + u32 dst = cmd->dst; + xf_component_t *component; + xf_output_port_t *port; + + /* ...source component must reside on the local core */ + XF_CHK_ERR(XF_MSG_SRC_CORE(src) == core, -EINVAL); + + /* ...make sure the "src" component is valid ("dst" may reside on other core) */ + if ((component = xf_client_lookup(XF_CORE_DATA(core), XF_PORT_CLIENT(src))) == NULL) + { + TRACE(ERROR, _x("Source port lookup failed: %x"), src); + return -ENOENT; + } + else if (!component->port || !(port = component->port(component, XF_PORT_ID(src)))) + { + TRACE(ERROR, _b("Source port doesn't exist: %x"), src); + return -ENOENT; + } + else if (xf_output_port_routed(port)) + { + TRACE(ERROR, _b("Source port is already routed: %x"), src); + return -EBUSY; + } + + /* ...route output port with source port set as destination */ + XF_CHK_API(xf_output_port_route(port, __XF_MSG_ID(dst, src), cmd->alloc_number, cmd->alloc_size, cmd->alloc_align)); + + TRACE(ROUTE, _b("Ports routed: %03x -> %03x"), src, dst); + + /* ...invoke component data-processing function directly (ignore errors? - tbd) */ + component->entry(component, NULL); + + /* ...return success result code (no output attached) */ + xf_response_ok(m); + + return 0; +} + +/* ...disconnect ports */ +static int xf_proxy_unroute(u32 core, xf_message_t *m) +{ + xf_unroute_port_msg_t *cmd = m->buffer; + u32 src = cmd->src; + xf_component_t *component; + xf_output_port_t *port; + + /* ...source component must reside on the local core */ + XF_CHK_ERR(XF_MSG_SRC_CORE(src) == core, -EINVAL); + + /* ...lookup source (output) port */ + if ((component = xf_client_lookup(XF_CORE_DATA(core), XF_PORT_CLIENT(src))) == NULL) + { + TRACE(ERROR, _b("Source port lookup failed: %x"), src); + return -ENOENT; + } + else if (!component->port || !(port = component->port(component, XF_PORT_ID(src)))) + { + TRACE(ERROR, _b("Source port doesn't exist: %x"), src); + return -ENOENT; + } + else if (!xf_output_port_routed(port)) + { + /* ...port is not routed; satisfy immediately */ + goto done; + } + else if (!xf_output_port_idle(port)) + { + TRACE(ERROR, _b("Source port is not idle: %x"), src); + return -EBUSY; + } + + /* ...unroute port (call must succeed) */ + xf_output_port_unroute(port); + + /* ...we cannot satisfy the command now, and need to propagate it to a sink - tbd */ + //return 0; + +done: + /* ...pass success result code to caller */ + xf_response_ok(m); + + return 0; +} +#endif + +/* ...fill-this-buffer command processing */ +static int xf_proxy_output(u32 core, xf_message_t *m) +{ + /* ...determine destination "client" */ + switch (XF_MSG_SRC_CLIENT(m->id)) + { +#if XF_TRACE_REMOTE + case 0: + /* ...destination is a tracer facility; submit buffer to tracer */ + xf_trace_submit(core, m); + return 0; +#endif + + default: + /* ...unrecognized destination; return general failure response */ + return XF_CHK_ERR(0, -EINVAL); + } +} + +/* ...flush command processing */ +static int xf_proxy_flush(u32 core, xf_message_t *m) +{ + /* ...determine destination "client" */ + switch (XF_MSG_SRC_CLIENT(m->id)) + { +#if XF_TRACE_REMOTE + case 0: + /* ...destination is a tracer facility; flush current buffer */ + xf_trace_flush(core, m); + return 0; +#endif + + default: + /* ...unrecognized destination; return general failure response */ + return XF_CHK_ERR(0, -EINVAL); + } +} + +/* ...proxy command processing table */ +static int (* const xf_proxy_cmd[])(u32, xf_message_t *) = +{ + [XF_OPCODE_TYPE(XF_REGISTER)] = xf_proxy_register, + [XF_OPCODE_TYPE(XF_ALLOC)] = xf_proxy_alloc, + [XF_OPCODE_TYPE(XF_FREE)] = xf_proxy_free, +#if 0 + [XF_OPCODE_TYPE(XF_ROUTE)] = xf_proxy_route, + [XF_OPCODE_TYPE(XF_UNROUTE)] = xf_proxy_unroute, +#endif + [XF_OPCODE_TYPE(XF_FILL_THIS_BUFFER)] = xf_proxy_output, + [XF_OPCODE_TYPE(XF_FLUSH)] = xf_proxy_flush, +}; + +/* ...total number of commands supported */ +#define XF_PROXY_CMD_NUM (sizeof(xf_proxy_cmd) / sizeof(xf_proxy_cmd[0])) + +/* ...process commands to a proxy */ +static void xf_proxy_command(u32 core, xf_message_t *m) +{ + u32 opcode = m->opcode; + int res; + + /* ...dispatch command to proper hook */ + if (XF_OPCODE_TYPE(opcode) < XF_PROXY_CMD_NUM) + { + if ((res = xf_proxy_cmd[XF_OPCODE_TYPE(opcode)](core, m)) >= 0) + { + /* ...command processed successfully; do nothing */ + return; + } + } + else + { + TRACE(ERROR, _x("invalid opcode: %x"), opcode); + } + + /* ...command processing failed; return generic failure response */ + xf_response_err(m); +} + +/******************************************************************************* + * Message completion helper + ******************************************************************************/ + +/* ...put message into local IPC command queue on remote core (src != dst) */ +static inline void xf_msg_local_ipc_put(u32 src, u32 dst, xf_message_t *m) +{ + xf_core_rw_data_t *rw = XF_CORE_RW_DATA(dst); + int first; + + /* ...flush message payload if needed */ + if (XF_LOCAL_IPC_NON_COHERENT) + { + /* ...it may be a command with output payload only - tbd */ + XF_PROXY_FLUSH(m->buffer, m->length); + } + + /* ...acquire mutex to target rw-data (running on source core) */ + xf_mutex_lock(src); + + /* ...assure memory coherency as needed */ + if (XF_LOCAL_IPC_NON_COHERENT) + { + /* ...invalidate local queue data */ + XF_PROXY_INVALIDATE(&rw->local, sizeof(rw->local)); + + /* ...place message into queue */ + first = xf_msg_enqueue(&rw->local, m); + + /* ...flush both queue and message data */ + XF_PROXY_FLUSH(&rw->local, sizeof(rw->local)), XF_PROXY_FLUSH(m, sizeof(*m)); + } + else + { + /* ...just enqueue the message */ + first = xf_msg_enqueue(&rw->local, m); + } + + /* ...release global rw-memory access lock */ + xf_mutex_unlock(src); + + /* ...signal IPI interrupt on destination core as needed */ + (first ? xf_ipi_assert(dst), 1 : 0); +} + +/* ...dequeue message from core-specific dispatch queue */ +static inline xf_message_t * xf_msg_local_ipc_get(u32 core) +{ + xf_core_rw_data_t *rw = XF_CORE_RW_DATA(core); + xf_message_t *m; + + /* ...retrieve message from queue in atomic fashion */ + xf_mutex_lock(core); + + /* ...process memory coherency as required */ + if (XF_LOCAL_IPC_NON_COHERENT) + { + /* ...inavlidate local rw-data */ + XF_PROXY_INVALIDATE(&rw->local, sizeof(rw->local)); + + /* ...get message from the queue */ + if ((m = xf_msg_dequeue(&rw->local)) != NULL) + { + /* ...flush rw-queue data */ + XF_PROXY_FLUSH(&rw->local, sizeof(rw->local)); + } + } + else + { + /* ...just dequeue message from the queue */ + m = xf_msg_dequeue(&rw->local); + } + + /* ...release rw-memory access lock */ + xf_mutex_unlock(core); + + /* ...invalidate message header and data as needed */ + if (XF_LOCAL_IPC_NON_COHERENT && m != NULL) + { + /* ...invalidate message header */ + XF_PROXY_INVALIDATE(m, sizeof(*m)); + + /* ...and data if needed (it may not be always needed - tbd) */ + (m->length ? XF_PROXY_INVALIDATE(m->buffer, m->length) : 0); + } + + /* ...return message */ + return m; +} + +/* ...retrieve message from local queue (protected from ISR) */ +static inline int xf_msg_local_put(u32 core, xf_message_t *m) +{ + xf_core_data_t *cd = XF_CORE_DATA(core); + int first; + u32 status; + + /* ...use interrupt masking protocol to protect message queue */ + status = xf_isr_disable(core); + first = xf_msg_enqueue(&cd->queue, m); + xf_isr_restore(core, status); + + return first; +} + +/* ...retrieve message from local queue (protected from ISR) */ +static inline xf_message_t * xf_msg_local_get(u32 core) +{ + xf_core_data_t *cd = XF_CORE_DATA(core); + xf_message_t *m; + u32 status; + + /* ...use interrupt masking protocol to protect message queue */ + status = xf_isr_disable(core); + m = xf_msg_dequeue(&cd->queue); + xf_isr_restore(core, status); + + return m; +} + +/* ...retrieve message from local queue (protected from ISR) */ +static inline xf_message_t * xf_msg_local_response_get(u32 core) +{ + xf_core_data_t *cd = XF_CORE_DATA(core); + xf_message_t *m; + u32 status; + + /* ...use interrupt masking protocol to protect message queue */ + status = xf_isr_disable(core); + m = xf_msg_dequeue(&cd->response); + xf_isr_restore(core, status); + + return m; +} + +/* ...call component data processing function */ +static inline void xf_core_process(xf_component_t *component) +{ + u32 id = component->id; + + /* ...client look-up successfull */ + TRACE(DISP, _b("core[%u]::client[%u]::process"), XF_PORT_CORE(id), XF_PORT_CLIENT(id)); + + /* ...call data-processing interface */ + if (component->entry(component, NULL) < 0) + { + TRACE(ERROR, _b("execution error (ignored)")); + } +} + +/* ...dispatch message queue execution */ +static inline void xf_core_dispatch(xf_core_data_t *cd, u32 core, xf_message_t *m) +{ + u32 client; + xf_component_t *component; + + /* ...do client-id/component lookup */ + if (XF_MSG_DST_PROXY(m->id)) + { + TRACE(DISP, _b("core[%u]::proxy-cmd(id=%x, opcode=%x)"), core, m->id, m->opcode); + + /* ...process message addressed to proxy */ + xf_proxy_command(core, m); + + /* ...do not like this return statement... - tbd */ + return; + } + + /* ...message goes to local component */ + client = XF_MSG_DST_CLIENT(m->id); + + /* ...check if client is alive */ + if ((component = xf_client_lookup(cd, client)) != NULL) + { + /* ...client look-up successfull */ + TRACE(DISP, _b("core[%u]::client[%u]::cmd(id=%x, opcode=%x)"), core, client, m->id, m->opcode); + + /* ...pass message to component entry point */ + if (component->entry(component, m) < 0) + { + /* ...call component destructor */ + if (component->exit(component, m) == 0) + { + /* ...component cleanup completed; recycle component-id */ + xf_client_free(cd, client); + + /* ...do system-specific deregistration of component within IPC layer */ + xf_ipc_component_rmref(__XF_PORT_SPEC(core, client, 0)); + } + } + } + else + { + TRACE(DISP, _b("Discard message id=%x - client %u:%u not registered"), m->id, core, client); + + /* ...complete message with general failure response */ + xf_response_err(m); + } +} + +/******************************************************************************* + * Entry points + ******************************************************************************/ + +/* ...submit message for instant execution on some core */ +void xf_msg_submit(xf_message_t *m) +{ + u32 src = XF_MSG_SRC_CORE(m->id); + u32 dst = XF_MSG_DST_CORE(m->id); + + /* ...check if message shall go through local IPC layer */ + if (src ^ dst) + { + /* ...put message into local IPC queue */ + xf_msg_local_ipc_put(src, dst, m); + } + else + { + /* ...message is addressed to same core */ + xf_msg_local_put(src, m); + } +} + +/* ...complete message and pass response to a caller */ +void xf_msg_complete(xf_message_t *m) +{ + u32 src = XF_MSG_SRC(m->id); + u32 dst = XF_MSG_DST(m->id); + + /* ...swap src/dst specifiers */ + m->id = __XF_MSG_ID(dst, src); + + /* ...check if message goes to remote IPC layer */ + if (XF_MSG_DST_PROXY(m->id)) + { + /* ...return message to proxy */ + xf_msg_proxy_complete(m); + } + else + { + /* ...destination is within DSP cluster; check if that is a data buffer */ + switch (m->opcode) + { + case XF_EMPTY_THIS_BUFFER: + /* ...emptied buffer goes back to the output port */ + m->opcode = XF_FILL_THIS_BUFFER; + break; + + case XF_FILL_THIS_BUFFER: + /* ...filled buffer is passed to the input port */ + m->opcode = XF_EMPTY_THIS_BUFFER; + break; + } + + /* ...submit message for execution */ + xf_msg_submit(m); + } +} + +/* ...initialize per-core framework data */ +int xf_core_init(u32 core) +{ + xf_core_data_t *cd = XF_CORE_DATA(core); + xf_cmap_link_t *link; + u32 i; + + /* ...create list of free client descriptors */ + for (link = &cd->cmap[i = 0]; i < XF_CFG_MAX_CLIENTS; i++, link++) + { + link->next = i + 1; + } + + /* ...set head of free clients list */ + cd->free = 0; + + /* ...initialize local queue scheduler */ + xf_sched_init(&cd->sched); + + /* ...initialize IPI subsystem */ + XF_CHK_API(xf_ipi_init(core)); + + /* ...initialize shared read-write memory */ + XF_CHK_API(xf_shmem_enabled(core) ? xf_shmem_init(core) : 0); + + /* ...initialize scratch memory */ + XF_CHK_ERR(cd->scratch = xf_scratch_mem_init(core), -ENOMEM); + + /* ...okay... it's all good */ + TRACE(INIT, _b("core-%u initialized"), core); + + return 0; +} + +/* ...core executive loop function */ +void xf_core_service(u32 core) +{ + xf_core_data_t *cd = &xf_core_data[core]; + u32 status; + xf_message_t *m; + xf_task_t *t; + +#ifdef XAF_PROFILE_DSP + START_TIME_XA_PROFILER(prof); +#endif + do + { + /* ...clear local status change */ + status = 0; + + /* ...if core is servicing shared memory with AP, do it first - actually, they all need to support it */ + if (xf_shmem_enabled(core)) + { + /* ...process all commands */ + xf_shmem_process_queues(core); + } + + /* ...check if we have a backlog message placed into interim queue */ + while ((m = xf_msg_local_ipc_get(core)) || (m = xf_msg_local_get(core))) + { + /* ...dispatch message execution */ + xf_core_dispatch(cd, core, m); + + /* ...set local status change */ + status = 1; + } + + /* ...check if we have pending responses (submitted from ISR) we need to process */ + while ((m = xf_msg_local_response_get(core)) != NULL) + { + /* ...call completion handler on current stack */ + xf_msg_complete(m); + + /* ...set local status change */ + status = 1; + + } + + /* ...if scheduler queue is empty, break the loop and pause the core */ + if ((t = xf_sched_get(&cd->sched)) != NULL) + { + /* ...data-processing execution (ignore internal errors) */ + xf_core_process((xf_component_t *)t); + + /* ...set local status change */ + status = 1; + } + } + while (status); + +#ifdef XAF_PROFILE_DSP + STOP_TIME_XA_PROFILER(prof); + + if(prof.g_output_bytes) + { + unsigned long output_samples = prof.g_output_bytes; + output_samples >>= (prof.channels == 2 ? 1 : 0); + output_samples >>= (prof.pcm_width == 24 ? 2 : 1); + + COMPUTE_MHZ_XA_PROFILER(prof, output_samples, prof.sample_rate, 0); + + prof.g_output_bytes = prof.cycles = 0; /* reset counters */ + } +#endif + +} + +/* ...global data initialization function */ +int xf_global_init(void) +{ + /* ...what global data we have to initialize? - tbd */ + TRACE(INIT, _b("Global data initialized")); + + return 0; +} diff --git a/hifi/xaf/hifi-dpf/core/xf-io.c b/hifi/xaf/hifi-dpf/core/xf-io.c new file mode 100644 index 00000000..09f8e3e6 --- /dev/null +++ b/hifi/xaf/hifi-dpf/core/xf-io.c @@ -0,0 +1,644 @@ +/******************************************************************************* +* 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.c + * + * Generic input/output ports handling + * + ******************************************************************************/ + +#define MODULE_TAG IO + +/******************************************************************************* + * Includes + ******************************************************************************/ + +#include "xf.h" + +/******************************************************************************* + * Tracing configuration + ******************************************************************************/ + +TRACE_TAG(INIT, 1); +TRACE_TAG(INPUT, 1); +TRACE_TAG(OUTPUT, 1); +TRACE_TAG(ROUTE, 1); + +/******************************************************************************* + * Input port API + ******************************************************************************/ + +/* ...initialize input port structure */ +int xf_input_port_init(xf_input_port_t *port, u32 size, u32 align, u32 core) +{ + /* ...allocate local internal buffer of particular size and alignment */ + if (size) + { + /* ...internal buffer is used */ + XF_CHK_ERR(port->buffer = xf_mem_alloc(size, align, core, 0), -ENOMEM); + } + else + { + /* ...no internal buffering is used */ + port->buffer = NULL; + } + + /* ...initialize message queue */ + xf_msg_queue_init(&port->queue); + + /* ...set buffer size */ + port->length = size; + + /* ...enable input by default */ + port->flags = XF_INPUT_FLAG_ENABLED | XF_INPUT_FLAG_CREATED; + + /* ...mark buffer is empty */ + port->filled = 0, port->access = NULL; + + TRACE(INIT, _b("input-port[%p] created - %p@%u[%u]"), port, port->buffer, align, size); + + return 0; +} + +/* ...put message into input port queue; return non-zero if queue was empty */ +int xf_input_port_put(xf_input_port_t *port, xf_message_t *m) +{ + /* ...check if input is enabled */ + if ((port->flags & XF_INPUT_FLAG_ENABLED) == 0) + { + /* ...input disabled; this is an error condition, likely */ + TRACE(INPUT, _b("input-port[%p] disabled"), port); + + /* ...release the message instantly */ + xf_response_ok(m); + + /* ...buffer has not been accepted - no actions to take */ + return 0; + } + else if (m->length == 0) + { + /* ...it is forbidden to pass more than one zero-length message */ + BUG(port->flags & XF_INPUT_FLAG_EOS, _x("invalid state: %x"), port->flags); + + /* ...received a message with zero-length; mark end-of-stream condition */ + port->flags ^= XF_INPUT_FLAG_ENABLED | XF_INPUT_FLAG_EOS; + + /* ...still enqueue that zero-length message; it will be processed afterwards */ + TRACE(INPUT, _b("input-port[%p]: zero-length buffer received"), port); + } + else + { + TRACE(INPUT, _b("input-port[%p]: buffer received - %u bytes"), port, m->length); + } + + /* ...enqueue message and set access pointer as needed */ + if (xf_msg_enqueue(&port->queue, m)) + { + /* ...first message put - set access pointer and length */ + port->access = m->buffer, port->remaining = m->length; + + /* ...if first message is empty, mark port is done */ + (!port->access ? port->flags ^= XF_INPUT_FLAG_EOS | XF_INPUT_FLAG_DONE : 0); + + /* ...return non-zero to indicate the first buffer is placed into port */ + return 1; + } + else + { + /* ...subsequent message placed into buffer */ + return 0; + } +} + +/* ...internal helper - input message completion */ +static inline int xf_input_port_complete(xf_input_port_t *port) +{ + /* ...dequeue message from queue */ + xf_message_t *m = xf_msg_dequeue(&port->queue); + + /* ...message cannot be NULL */ + BUG(m == NULL, _x("invalid port state")); + + /* ...complete current message (EMPTY-THIS-BUFFER always; no length adjustment) */ + xf_response(m); + + /* ...set up next head */ + if ((m = xf_msg_queue_head(&port->queue)) != NULL) + { + /* ...set new access pointers */ + port->access = m->buffer, port->remaining = m->length; + + /* ...return indication that there is an input message */ + return 1; + } + else + { + /* ...no more messages; reset access pointer */ + port->access = NULL; + + /* ...return indication that input port has no data available */ + return 0; + } +} + +/* ...fill-in required amount of data into input port buffer */ +int xf_input_port_fill(xf_input_port_t *port) +{ + u32 filled = port->filled; + u32 remaining = port->remaining; + u32 copied = 0; + s32 n; + + /* ...function shall not be called if no internal buffering is used */ + BUG(xf_input_port_bypass(port), _x("Invalid transaction")); + + /* ...if there is no message pending, bail out */ + if (!xf_msg_queue_head(&port->queue)) + { + TRACE(INPUT, _b("No message ready")); + return 0; + } + + /* ...calculate total amount of bytes we need to copy */ + n = (s32)(port->length - filled); + + /* ...get at most "n" bytes from input message(s) buffer(s) */ + while (n > 0) + { + u32 k; + + /* ...determine the size of the chunk to copy */ + ((k = remaining) > n ? k = n : 0); + + /* ...process zero-length input message separately */ + if (k == 0) + { + /* ...end-of-stream condition must be set */ + BUG((port->flags & XF_INPUT_FLAG_EOS) == 0, _x("port[%p]: invalid state: %x"), port, port->flags); + + /* ...mark stream is completed */ + port->flags ^= XF_INPUT_FLAG_EOS | XF_INPUT_FLAG_DONE; + + /* ...reset total amount of bytes to fill */ + n = 0; + + /* ...do not release message yet */ + TRACE(INPUT, _b("input-port[%p] done"), port); + + /* ...and break the loop */ + break; + } + + /* ...buffer must be set */ + BUG(!port->access, _x("invalid port state")); + + /* ...get required amount from input buffer */ + memcpy(port->buffer + filled, port->access, k), port->access += k; + + /* ...advance buffer positions */ + filled += k, copied += k, n -= k; + + /* ...check if input buffer is processed completely */ + if ((remaining -= k) == 0) + { + if (!xf_input_port_complete(port)) + { + /* ...no more input messages; break the loop */ + break; + } + else + { + /* ...update remaining counter */ + remaining = port->remaining; + } + } + } + + /* ...update buffer positions */ + port->filled = filled, port->remaining = remaining; + + /* ...return indicator whether input buffer is prefilled */ + return (n == 0); +} + +/* ...pad input buffer with given pattern */ +void xf_input_port_pad(xf_input_port_t *port, u8 pad) +{ + u32 filled = port->filled; + s32 k; + + /* ...do padding if port buffer is not filled */ + if ((k = port->length - filled) > 0) + { + memset(port->buffer + filled, pad, k); + + /* ...indicate port is filled */ + port->filled = port->length; + } +} + +/* ...consume input buffer data */ +void xf_input_port_consume(xf_input_port_t *port, u32 n) +{ + /* ...check whether input port is in bypass mode */ + if (xf_input_port_bypass(port)) + { + /* ...port is in bypass mode; advance access pointer */ + if ((port->remaining -= n) == 0) + { + /* ...complete message and try to rearm input port */ + xf_input_port_complete(port); + + /* ...check if end-of-stream flag is set */ + if (xf_msg_queue_head(&port->queue) && !port->access) + { + BUG((port->flags & XF_INPUT_FLAG_EOS) == 0, _x("port[%p]: invalid state: %x"), port, port->flags); + + /* ...mark stream is completed */ + port->flags ^= XF_INPUT_FLAG_EOS | XF_INPUT_FLAG_DONE; + + TRACE(INPUT, _b("input-port[%p] done"), port); + } + } + else + { + /* ...advance message buffer pointer */ + port->access += n; + } + } + else if (port->filled > n) + { + u32 k = port->filled - n; + + /* ...move tail of buffer to the head (safe to use memcpy) */ + memcpy(port->buffer, port->buffer + n, k); + + /* ...adjust filled position */ + port->filled = k; + } + else + { + /* ...entire buffer is consumed; reset fill level */ + port->filled = 0; + } +} + +/* ...purge input port queue */ +void xf_input_port_purge(xf_input_port_t *port) +{ + xf_message_t *m; + + /* ...bail out early if port is not created */ + if (!xf_input_port_created(port)) return; + + /* ...free all queued messages with generic "ok" response */ + while ((m = xf_msg_dequeue(&port->queue)) != NULL) + { + xf_response_ok(m); + } + + /* ...reset internal buffer position */ + port->filled = 0, port->access = NULL; + + /* ...reset port flags */ + port->flags = (port->flags & ~__XF_INPUT_FLAGS(~0)) | XF_INPUT_FLAG_ENABLED | XF_INPUT_FLAG_CREATED; + + TRACE(INPUT, _b("input-port[%p] purged"), port); +} + +/* ...save flow-control message for propagated input port purging sequence */ +void xf_input_port_control_save(xf_input_port_t *port, xf_message_t *m) +{ + /* ...make sure purging sequence is not active */ + BUG(port->flags & XF_INPUT_FLAG_PURGING, _x("invalid state: %x"), port->flags); + + /* ...place message into internal queue */ + xf_msg_enqueue(&port->queue, m); + + /* ...set port purging flag */ + port->flags ^= XF_INPUT_FLAG_PURGING; + + TRACE(INPUT, _b("port[%p] start purge sequence"), port); +} + +/* ...mark flushing sequence is completed */ +void xf_input_port_purge_done(xf_input_port_t *port) +{ + /* ...make sure flushing sequence is ongoing */ + BUG((port->flags & XF_INPUT_FLAG_PURGING) == 0, _x("invalid state: %x"), port->flags); + + /* ...complete saved flow-control message */ + xf_response_ok(xf_msg_dequeue(&port->queue)); + + /* ...clear port purging flag */ + port->flags ^= XF_INPUT_FLAG_PURGING; + + TRACE(INPUT, _b("port[%p] purge sequence completed"), port); +} + +/* ...destroy input port data */ +void xf_input_port_destroy(xf_input_port_t *port, u32 core) +{ + /* ...bail out earlier if port is not created */ + if (!xf_input_port_created(port)) return; + + /* ...deallocate input buffer if needed */ + (port->buffer ? xf_mem_free(port->buffer, port->length, core, 0), port->buffer = NULL : 0); + + /* ...reset input port flags */ + port->flags = 0; + + TRACE(INIT, _b("input-port[%p] destroyed"), port); +} + +/******************************************************************************* + * Output port API + ******************************************************************************/ + +/* ...initialize output port (structure must be zero-initialized) */ +int xf_output_port_init(xf_output_port_t *port, u32 size) +{ + /* ...initialize message queue */ + xf_msg_queue_init(&port->queue); + + /* ...set output buffer length */ + port->length = size; + + /* ...mark port is created */ + port->flags = XF_OUTPUT_FLAG_CREATED; + + TRACE(INIT, _b("output-port[%p] initialized"), port); + + return 0; +} + +/* ...route output port */ +int xf_output_port_route(xf_output_port_t *port, u32 id, u32 n, u32 length, u32 align) +{ + u32 core = XF_MSG_DST_CORE(id); + u32 shared = XF_MSG_SHARED(id); + xf_message_t *m; + u32 i; + + /* ...allocate message pool for a port; extra message for control */ + XF_CHK_API(xf_msg_pool_init(&port->pool, n + 1, core)); + + /* ...allocate required amount of buffers */ + for (i = 1; i <= n; i++) + { + /* ...get message from pool (directly; bypass that "get" interface) */ + m = xf_msg_pool_item(&port->pool, i); + + /* ...wipe out message link pointer (debugging) */ + m->next = NULL; + + /* ...set message parameters */ + m->id = id; + m->opcode = XF_FILL_THIS_BUFFER; + m->length = length; + m->buffer = xf_mem_alloc(length, align, core, shared); + + /* ...if allocation failed, do a cleanup */ + if (!m->buffer) goto error; + + /* ...place message into output port */ + xf_msg_enqueue(&port->queue, m); + } + + /* ...setup flow-control message */ + m = xf_output_port_control_msg(port); + m->id = id; + m->length = 0; + m->buffer = NULL; + + /* ...wipe out message link pointer (debugging) */ + m->next = NULL; + + /* ...save port length */ + port->length = length; + + /* ...mark port is routed */ + port->flags |= XF_OUTPUT_FLAG_ROUTED | XF_OUTPUT_FLAG_IDLE; + + TRACE(ROUTE, _b("output-port[%p] routed: %x -> %x"), port, XF_MSG_DST(id), XF_MSG_SRC(id)); + + return 0; + +error: + /* ...allocation failed; do a cleanup */ + while (--i) + { + m = xf_msg_pool_item(&port->pool, i); + + /* ...free item */ + xf_mem_free(m->buffer, length, core, shared); + } + + /* ...destroy pool data */ + xf_msg_pool_destroy(&port->pool, core); + + return -ENOMEM; +} + +/* ...start output port unrouting sequence */ +void xf_output_port_unroute_start(xf_output_port_t *port, xf_message_t *m) +{ + /* ...port must be routed */ + BUG(!xf_output_port_routed(port), _x("invalid state: %x"), port->flags); + + /* ...save message in the queue */ + port->unroute = m; + + /* ...put port unrouting flag */ + port->flags |= XF_OUTPUT_FLAG_UNROUTING; +} + +/* ...complete port unrouting sequence */ +void xf_output_port_unroute_done(xf_output_port_t *port) +{ + xf_message_t *m; + + /* ...make sure we have an outstanding port unrouting sequence */ + BUG(!xf_output_port_unrouting(port), _x("invalid state: %x"), port->flags); + + /* ...retrieve enqueued control-flow message */ + m = port->unroute, port->unroute = NULL; + + /* ...destroy port buffers */ + xf_output_port_unroute(port); + + /* ...and pass response to the caller */ + xf_response_ok(m); +} + +/* ...unroute output port and destroy all memory buffers allocated */ +void xf_output_port_unroute(xf_output_port_t *port) +{ + xf_message_t *m = xf_output_port_control_msg(port); + u32 core = XF_MSG_DST_CORE(m->id); + u32 shared = XF_MSG_SHARED(m->id); + u32 n = port->pool.n - 1; + u32 i; + + /* ...free all messages (we are running on "dst" core) */ + for (i = 1; i <= n; i++) + { + /* ...directly obtain message item */ + m = xf_msg_pool_item(&port->pool, i); + + /* ...free message buffer (must exist) */ + xf_mem_free(m->buffer, port->length, core, shared); + } + + /* ...destroy pool data */ + xf_msg_pool_destroy(&port->pool, core); + + /* ...reset all flags */ + port->flags = XF_OUTPUT_FLAG_CREATED; + + /* ...reset message queue (it is empty again) */ + xf_msg_queue_init(&port->queue); + + TRACE(ROUTE, _b("output-port[%p] unrouted"), port); +} + +/* ...put next message to the port */ +int xf_output_port_put(xf_output_port_t *port, xf_message_t *m) +{ + /* ...in case of port unrouting sequence the flag returned will always be 0 */ + return xf_msg_enqueue(&port->queue, m); +} + +/* ...retrieve next message from the port */ +void * xf_output_port_data(xf_output_port_t *port) +{ + xf_message_t *m = xf_msg_queue_head(&port->queue); + + /* ...bail out if there is nothing enqueued */ + if (m == NULL) return NULL; + + /* ...it is not permitted to access port data when port is being unrouted */ + BUG(xf_output_port_unrouting(port), _x("invalid transaction")); + + /* ...make sure message length is valid */ + BUG(m->length < port->length, _x("Insufficient buffer length: %u < %u"), m->length, port->length); + + /* ...return access buffer pointer */ + return m->buffer; +} + +/* ...produce output message marking amount of bytes produced */ +int xf_output_port_produce(xf_output_port_t *port, u32 n) +{ + xf_message_t *m = xf_msg_dequeue(&port->queue); + + /* ...message cannot be NULL */ + BUG(m == NULL, _x("Invalid transaction")); + + /* ...it is not permitted to invoke this when port is being unrouted (or flushed - tbd) */ + BUG(xf_output_port_unrouting(port), _x("invalid transaction")); + + /* ...complete message with specified amount of bytes produced */ + xf_response_data(m, n); + + /* ...clear port idle flag (technically, not needed for unrouted port) */ + port->flags &= ~XF_OUTPUT_FLAG_IDLE; + + /* ...return indication of pending message availability */ + return (xf_msg_queue_head(&port->queue) != NULL); +} + +/* ...flush output port */ +int xf_output_port_flush(xf_output_port_t *port, u32 opcode) +{ + xf_message_t *m; + + /* ...if port is routed, we shall pass flush command to sink port */ + if (xf_output_port_routed(port)) + { + /* ...if port is idle, satisfy immediately */ + if (port->flags & XF_OUTPUT_FLAG_IDLE) return 1; + + /* ...start flushing sequence if not already started */ + if ((port->flags & XF_OUTPUT_FLAG_FLUSHING) == 0) + { + /* ...put flushing flag */ + port->flags ^= XF_OUTPUT_FLAG_FLUSHING; + + /* ...get control message from associated pool */ + m = xf_output_port_control_msg(port); + + /* ...set flow-control operation */ + m->opcode = opcode; + + /* ...message is a command, but source and destination are swapped */ + xf_response(m); + } + + /* ...zero-result indicates the flushing is in progress */ + return 0; + } + else + { + /* ...for non-routed port just complete all queued messages */ + while ((m = xf_msg_dequeue(&port->queue)) != NULL) + { + /* ...pass generic zero-length "okay" response - tbd */ + xf_response_ok(m); + } + + /* ...non-zero result indicates the flushing is done */ + return 1; + } +} + +/* ...mark flushing sequence is completed */ +void xf_output_port_flush_done(xf_output_port_t *port) +{ + /* ...make sure flushing sequence is ongoing */ + BUG((port->flags & XF_OUTPUT_FLAG_FLUSHING) == 0, _x("invalid state: %x"), port->flags); + + /* ...clear flushing flag and set idle flag */ + port->flags ^= XF_OUTPUT_FLAG_IDLE | XF_OUTPUT_FLAG_FLUSHING; + + TRACE(OUTPUT, _b("port[%p] flush sequence completed"), port); +} + +/* ...destroy output port */ +void xf_output_port_destroy(xf_output_port_t *port, u32 core) +{ + /* ...check if port is routed */ + if (xf_output_port_routed(port)) + { + /* ...port must be in idle state */ + BUG(!xf_output_port_idle(port), _x("destroying non-idle port[%p]"), port); + + /* ...unroute port */ + xf_output_port_unroute(port); + } + + /* ...reset port flags */ + port->flags = 0; + + TRACE(INIT, _b("output-port[%p] destroyed"), port); +} diff --git a/hifi/xaf/hifi-dpf/core/xf-isr.c b/hifi/xaf/hifi-dpf/core/xf-isr.c new file mode 100644 index 00000000..4e2add1e --- /dev/null +++ b/hifi/xaf/hifi-dpf/core/xf-isr.c @@ -0,0 +1,68 @@ +/******************************************************************************* +* 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-isr.c + * + * DSP processing framework - code running from interrupt context + * + ******************************************************************************/ + +#define MODULE_TAG ISR + +/******************************************************************************* + * Includes + ******************************************************************************/ + +#include "xf.h" + +/******************************************************************************* + * API functions definitions + ******************************************************************************/ + +/* ...submit command message from interrupt context on local core */ +void xf_msg_schedule_isr(xf_message_t *m) +{ + u32 core = XF_MSG_DST_CORE(m->id); + xf_core_data_t *cd = XF_CORE_DATA(core); + + /* ...interrupt masking protocol is used for protecting local message queue */ + if (xf_msg_enqueue(&cd->queue, m)) + { + /* ...resume local scheduler if that is the first message */ + xf_ipi_resume(core); + } +} + +/* ...complete message from interrupt handler */ +void xf_msg_complete_isr(xf_message_t *m) +{ + u32 core = XF_MSG_DST_CORE(m->id); + xf_core_data_t *cd = XF_CORE_DATA(core); + + /* ...place message into response queue */ + if (xf_msg_enqueue(&cd->response, m)) + { + /* ...notify local scheduler if that is the first message */ + xf_ipi_resume(core); + } +} diff --git a/hifi/xaf/hifi-dpf/core/xf-mem.c b/hifi/xaf/hifi-dpf/core/xf-mem.c new file mode 100644 index 00000000..ce5d8a6a --- /dev/null +++ b/hifi/xaf/hifi-dpf/core/xf-mem.c @@ -0,0 +1,361 @@ +/******************************************************************************* +* 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.c + * + * Dynamic memory allocator implementation (based on rb-tree index) + * + ******************************************************************************/ + +#define MODULE_TAG MM + +/******************************************************************************* + * Includes + ******************************************************************************/ + +#include "xf.h" + +/******************************************************************************* + * Tracing configuration + ******************************************************************************/ + +TRACE_TAG(INIT, 1); + +/******************************************************************************* + * Internal helpers + ******************************************************************************/ + +/* ...initialize block */ +static inline xf_mm_block_t * xf_mm_block_init(void *addr, u32 size) +{ + xf_mm_block_t *b = (xf_mm_block_t *)addr; + + /* ...use 31 available bits of node color to keep aligned size */ + return b->l_node.color = size, b; +} + +/* ...check if the length of the block is less than given */ +static inline int xf_mm_block_length_less(xf_mm_block_t *b, u32 size) +{ + /* ...we don't really care about LSB of color */ + return (b->l_node.color < size); +} + +/* ...return exact block length */ +static inline u32 xf_mm_block_length(xf_mm_block_t *b) +{ + /* ...wipe out least-significant bit from node color */ + return (b->l_node.color & ~1); +} + +/* ...increase block length */ +static inline u32 xf_mm_block_length_add(xf_mm_block_t *b, u32 size) +{ + /* ...return exact block length after increase */ + return ((b->l_node.color += size) & ~1); +} + +/* ...decrease block length */ +static inline u32 xf_mm_block_length_sub(xf_mm_block_t *b, u32 size) +{ + /* ...return exact block length after decrease */ + return ((b->l_node.color -= size) & ~1); +} + +/******************************************************************************* + * Internal functions + ******************************************************************************/ + +/* ...find best-match node given requested size */ +static inline xf_mm_block_t * xf_mm_find_by_size(xf_mm_pool_t *pool, u32 size) +{ + rb_tree_t *tree = &pool->l_map; + rb_idx_t p_idx, t_idx; + + /* ...find first block having length greater than requested */ + for (p_idx = rb_root(tree); p_idx != rb_null(tree); p_idx = rb_right(tree, p_idx)) + { + xf_mm_block_t *b = container_of(p_idx, xf_mm_block_t, l_node); + + /* ...break upon finding first matching candidate */ + if (!xf_mm_block_length_less(b, size)) + break; + } + + /* ...bail out if haven't found a block with sufficient size */ + if (p_idx == rb_null(tree)) + return NULL; + + /* ...try to find better match in left subtree */ + for (t_idx = rb_left(tree, p_idx); t_idx != rb_null(tree); ) + { + xf_mm_block_t *b = container_of(t_idx, xf_mm_block_t, l_node); + + /* ...check the size of the block */ + if (!xf_mm_block_length_less(b, size)) + { + /* ...update best match */ + p_idx = t_idx; + + /* ...and check if we have anything better in left sbtree */ + t_idx = rb_left(tree, t_idx); + } + else + { + /* ...move towards higher block sizes in that subtree */ + t_idx = rb_right(tree, t_idx); + } + } + + /* ...p_idx is our best choice */ + return container_of(p_idx, xf_mm_block_t, l_node); +} + +/* ...find the neighbours of the block basing on its address */ +static void xf_mm_find_by_addr(xf_mm_pool_t *pool, void *addr, xf_mm_block_t **n) +{ + rb_tree_t *tree = &pool->a_map; + rb_idx_t p_idx, l_idx, r_idx; + + /* ...it is not possible to have exact match in this map */ + for (p_idx = rb_root(tree), l_idx = r_idx = NULL; p_idx != rb_null(tree); ) + { + /* ...only "is less than" comparison is valid (as "a_node" pointer is biased) */ + if ((u32)p_idx < (u32)addr) + { + /* ...update lower neighbour */ + l_idx = p_idx; + + /* ...and move towards higher addresses */ + p_idx = rb_right(tree, p_idx); + } + else + { + /* ...update higher neighbour */ + r_idx = p_idx; + + /* ...and move towards lower addresses */ + p_idx = rb_left(tree, p_idx); + } + } + + /* ...translate nodes into blocks */ + n[0] = (l_idx ? container_of(l_idx, xf_mm_block_t, a_node) : NULL); + n[1] = (r_idx ? container_of(r_idx, xf_mm_block_t, a_node) : NULL); +} + +/* ...insert the block into L-map */ +static void xf_mm_insert_size(xf_mm_pool_t *pool, xf_mm_block_t *b, u32 size) +{ + rb_tree_t *tree = &pool->l_map; + rb_idx_t p_idx, t_idx; + + /* ...find the parent node for the next block */ + for (p_idx = rb_root(tree); p_idx != rb_null(tree); p_idx = t_idx) + { + /* ...check for the size */ + if (xf_mm_block_length_less(container_of(p_idx, xf_mm_block_t, l_node), size)) + { + /* ...move towards higher addresses */ + if ((t_idx = rb_right(tree, p_idx)) == rb_null(tree)) + { + /* ...node becomes a right child of parent p */ + rb_set_right(tree, p_idx, &b->l_node); + break; + } + } + else + { + /* ...move towards lower addresses (ok if exact size match is found) */ + if ((t_idx = rb_left(tree, p_idx)) == rb_null(tree)) + { + /* ...node becomes a left child of parent p */ + rb_set_left(tree, p_idx, &b->l_node); + break; + } + } + } + + /* ...insert node into tree */ + rb_insert(tree, &b->l_node, p_idx); +} + +/* ...insert the block into A-map */ +static void xf_mm_insert_addr(xf_mm_pool_t *pool, xf_mm_block_t *b) +{ + rb_tree_t *tree = &pool->a_map; + rb_idx_t p_idx, t_idx; + + /* ...find the parent node for the next block */ + for (p_idx = rb_root(tree); p_idx != rb_null(tree); p_idx = t_idx) + { + /* ...check for the address (only "is less than" comparison is valid) */ + if ((u32)p_idx < (u32)b) + { + /* ...move towards higher addresses */ + if ((t_idx = rb_right(tree, p_idx)) == rb_null(tree)) + { + /* ...node becomes a right child of parent p */ + rb_set_right(tree, p_idx, &b->a_node); + break; + } + } + else + { + /* ...move towards lower addresses (by design there cannot be exact match) */ + if ((t_idx = rb_left(tree, p_idx)) == rb_null(tree)) + { + /* ...node becomes a left child of parent p */ + rb_set_left(tree, p_idx, &b->a_node); + break; + } + } + } + + /* ...insert node into tree */ + rb_insert(tree, &b->a_node, p_idx); +} + +/******************************************************************************* + * Entry points + ******************************************************************************/ + +/* ...block allocation */ +void * xf_mm_alloc(xf_mm_pool_t *pool, u32 size) +{ + xf_mm_block_t *b; + + /* ...find best-fit free block */ + XF_CHK_ERR(b = xf_mm_find_by_size(pool, size), NULL); + + /* ...remove the block from the L-map */ + rb_delete(&pool->l_map, &b->l_node); + + /* ...check if the size is exactly the same as requested */ + if ((size = xf_mm_block_length_sub(b, size)) == 0) + { + /* ...the block needs to be removed from the A-map as well */ + rb_delete(&pool->a_map, &b->a_node); + + /* ...entire block goes to user */ + return (void *) b; + } + else + { + /* ...insert the block into L-map */ + xf_mm_insert_size(pool, b, size); + + /* ...A-map remains intact; tail of the block goes to user */ + return (void *) b + size; + } +} + +/* ...block deallocation */ +void xf_mm_free(xf_mm_pool_t *pool, void *addr, u32 size) +{ + xf_mm_block_t *b = xf_mm_block_init(addr, size); + xf_mm_block_t *n[2]; + + /* ...find block neighbours in A-map */ + xf_mm_find_by_addr(pool, addr, n); + + /* ...check if we can merge block to left neighbour */ + if (n[0]) + { + if ((void *)n[0] + xf_mm_block_length(n[0]) == addr) + { + /* ...merge free block with left neighbour; delete it from L-map */ + rb_delete(&pool->l_map, &n[0]->l_node); + + /* ...adjust block length (block remains in A-map) */ + addr = (void *)(b = n[0]), size = xf_mm_block_length_add(b, size); + } + else + { + /* ...mark there is no left-merge */ + n[0] = NULL; + } + } + + /* ...check if we can merge block to right neighbour */ + if (n[1]) + { + if ((void *)n[1] == addr + size) + { + /* ...merge free block with right neighbour; delete it from L-map */ + rb_delete(&pool->l_map, &n[1]->l_node); + + /* ...adjust block length */ + size = xf_mm_block_length_add(b, xf_mm_block_length(n[1])); + + /* ...check if left merge took place as well */ + if (n[0]) + { + /* ...left neighbour covers now all three blocks; drop record from A-map */ + rb_delete(&pool->a_map, &n[1]->a_node); + } + else + { + /* ...fixup tree pointers (equivalent to remove/reinsert the same key) */ + rb_replace(&pool->a_map, &n[1]->a_node, &b->a_node); + } + } + else + { + n[1] = NULL; + } + } + + /* ...if any merge has occured, A-map is updated */ + if (n[0] == NULL && n[1] == NULL) + { + /* ...add new block into A-map */ + xf_mm_insert_addr(pool, b); + } + + /* ...add (new or adjusted) block into L-map */ + xf_mm_insert_size(pool, b, size); +} + +/* ...initialize memory allocator */ +int xf_mm_init(xf_mm_pool_t *pool, void *addr, u32 size) +{ + /* ...check pool alignment validity */ + XF_CHK_ERR(((u32)addr & (sizeof(xf_mm_block_t) - 1)) == 0, -EINVAL); + + /* ...check pool size validity */ + XF_CHK_ERR(((size) & (sizeof(xf_mm_block_t) - 1)) == 0, -EINVAL); + + /* ...set pool parameters (need that stuff at all? - tbd) */ + pool->addr = addr, pool->size = size; + + /* ...initialize rb-trees */ + rb_init(&pool->l_map), rb_init(&pool->a_map); + + /* ..."free" the entire block */ + xf_mm_free(pool, addr, size); + + TRACE(INIT, _b("memory allocator initialized: [%p..%p)"), addr, addr + size); + + return 0; +} diff --git a/hifi/xaf/hifi-dpf/core/xf-msg.c b/hifi/xaf/hifi-dpf/core/xf-msg.c new file mode 100644 index 00000000..4253e1e3 --- /dev/null +++ b/hifi/xaf/hifi-dpf/core/xf-msg.c @@ -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. + +******************************************************************************/ + +/******************************************************************************* + * xf-msg.c + * + * Message/message pool handling + * + ******************************************************************************/ + +#define MODULE_TAG MSG + +/******************************************************************************* + * Includes + ******************************************************************************/ + +#include "xf.h" + +/******************************************************************************* + * Entry points + ******************************************************************************/ + +/* ...allocate message pool */ +int xf_msg_pool_init(xf_msg_pool_t *pool, u32 n, u32 core) +{ + u32 i; + + /* ...allocate shared memory from global pool */ + XF_CHK_ERR(pool->p = xf_mem_alloc(XF_MM(sizeof(*pool->p) * n), XF_PROXY_ALIGNMENT, core, 1), -ENOMEM); + + /* ...place all messages into single-liked list */ + for (pool->head = &pool->p[i = 0]; i < n - 1; i++) + { + /* ...set message pointer to next message in the pool */ + xf_msg_pool_item(pool, i)->next = xf_msg_pool_item(pool, i + 1); + } + + /* ...set tail of the list */ + xf_msg_pool_item(pool, i)->next = NULL; + + /* ...save pool size */ + pool->n = n; + + return 0; +} + +/* ...destroy memory pool */ +void xf_msg_pool_destroy(xf_msg_pool_t *pool, u32 core) +{ + /* ...release pool memory (from shared local-IPC memory) */ + xf_mem_free(pool->p, XF_MM(sizeof(*pool->p) * pool->n), core, 1); +} + +/* ...allocate message from a pool (no concurrent access from other cores) */ +xf_message_t * xf_msg_pool_get(xf_msg_pool_t *pool) +{ + __xf_message_t *_m; + + /* ...pop message from the head of the pool */ + XF_CHK_ERR(_m = pool->head, NULL); + + /* ...advance list head */ + pool->head = (__xf_message_t *)(((xf_message_t *) _m)->next); + + /* ...debug - wipe out message "next" pointer */ + ((xf_message_t *) _m)->next = NULL; + + /* ...return properly aligned message pointer */ + return (xf_message_t *) _m; +} + +/* ...return message back to the pool (no concurrent access from other cores) */ +void xf_msg_pool_put(xf_msg_pool_t *pool, xf_message_t *m) +{ + __xf_message_t *_m = (__xf_message_t *) m; + + /* ...make sure the message is properly aligned object */ + BUG(!XF_IS_ALIGNED(_m), _x("Corrupted message pointer: %p"), _m); + + /* ...make sure it is returned to the same pool (need a length for that - tbd) */ + BUG(!xf_msg_from_pool(pool, m) < 0, _x("Bad pool/message: %p/%p"), pool->p, _m); + + /* ...place message into the head */ + m->next = (xf_message_t *) pool->head; + + /* ...advance pool head */ + pool->head = _m; +} diff --git a/hifi/xaf/hifi-dpf/core/xf-sched.c b/hifi/xaf/hifi-dpf/core/xf-sched.c new file mode 100644 index 00000000..cc1b4e8d --- /dev/null +++ b/hifi/xaf/hifi-dpf/core/xf-sched.c @@ -0,0 +1,153 @@ +/******************************************************************************* +* 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.c + * + * Non-preemptive earliest-deadline-first scheduler + * + ******************************************************************************/ + +#define MODULE_TAG SCHED + +/******************************************************************************* + * Includes + ******************************************************************************/ + +#include "xf.h" + +/******************************************************************************* + * Tracing configuration + ******************************************************************************/ + +TRACE_TAG(DEBUG, 1); + +/******************************************************************************* + * Global functions definitions + ******************************************************************************/ + +/* ...place task into scheduler queue */ +void xf_sched_put(xf_sched_t *sched, xf_task_t *t, u32 ts) +{ + rb_tree_t *tree = (rb_tree_t *)sched; + rb_node_t *node = (rb_node_t *)t; + rb_idx_t p_idx, t_idx; + u32 _ts; + + /* ...set scheduling timestamp */ + xf_task_timestamp_set(t, ts); + + /* ...find a place in the tree where the message should be inserted */ + for (p_idx = rb_root(tree); p_idx != rb_null(tree); p_idx = t_idx) + { + /* ...get timestamp of the p_idx */ + _ts = xf_task_timestamp((xf_task_t *)p_idx); + + /* ...ordering respects FIFO order of messages with same timestamp */ + if (xf_timestamp_before(ts, _ts)) + { + if ((t_idx = rb_left(tree, p_idx)) == rb_null(tree)) + { + /* ...p_idx is a direct successor of the message */ + rb_set_left(tree, p_idx, node); + + /* ...adjust head of the tree if needed */ + if (p_idx == rb_cache(tree)) goto insert_head; + else goto insert; + } + } + else + { + if ((t_idx = rb_right(tree, p_idx)) == rb_null(tree)) + { + /* ...p_idx is a direct predeccessor of the message */ + rb_set_right(tree, p_idx, node); + + goto insert; + } + } + } + +insert_head: + /* ...adjust scheduler head element */ + rb_set_cache(tree, node); + +insert: + /* ...insert item and rebalance the tree */ + rb_insert(tree, node, p_idx); + + /* ...head cannot be NULL */ + BUG(rb_cache(tree) == rb_null(tree), _x("Invalid scheduler state")); + + TRACE(DEBUG, _b("in: %x:[%p] (ts:%x)"), ts, node, xf_sched_timestamp(sched)); +} + +/* ...get first item from the scheduler */ +xf_task_t * xf_sched_get(xf_sched_t *sched) +{ + rb_tree_t *tree = (rb_tree_t *)sched; + rb_idx_t n_idx, t_idx; + u32 ts; + + /* ...head of the tree is cached; replace it with its parent (direct successor) */ + if ((n_idx = rb_cache(tree)) == rb_null(tree)) + { + /* ...tree is empty; bail out */ + return NULL; + } + else + { + /* ...delete current node and rebalance the tree */ + t_idx = rb_delete(tree, n_idx), rb_set_cache(tree, t_idx); + + /* ...get task timestamp */ + ts = xf_task_timestamp((xf_task_t *)n_idx); + + /* ...advance scheduler timestamp */ + xf_sched_timestamp_set(sched, ts); + + TRACE(DEBUG, _b("out: %x:[%p]"), ts, n_idx); + + /* ...return task */ + return (xf_task_t *)n_idx; + } +} + +/* ...cancel specified task execution (must be scheduled!) */ +void xf_sched_cancel(xf_sched_t *sched, xf_task_t *t) +{ + rb_tree_t *tree = (rb_tree_t *)sched; + rb_idx_t n_idx = t; + rb_idx_t t_idx; + + /* ...delete message from tree */ + t_idx = rb_delete(tree, n_idx); + + /* ...adjust head if that was the first message */ + (n_idx == rb_cache(tree) ? rb_set_cache(tree, t_idx), 1 : 0); +} + +/* ...initialize scheduler data */ +void xf_sched_init(xf_sched_t *sched) +{ + rb_init((rb_tree_t *)sched); +} diff --git a/hifi/xaf/hifi-dpf/core/xf-shmem.c b/hifi/xaf/hifi-dpf/core/xf-shmem.c new file mode 100644 index 00000000..15d3b1d9 --- /dev/null +++ b/hifi/xaf/hifi-dpf/core/xf-shmem.c @@ -0,0 +1,350 @@ +/******************************************************************************* +* 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.c + * + * DSP shared memory interface implementation + * + ******************************************************************************/ + +#define MODULE_TAG SHMEM + +/******************************************************************************* + * Includes + ******************************************************************************/ + +#include "xf.h" + +/******************************************************************************* + * Tracing tags + ******************************************************************************/ + +/* ...general initialization sequence */ +TRACE_TAG(INIT, 1); + +/* ...interface status change */ +TRACE_TAG(EXEC, 0); + +/* ...command reception */ +TRACE_TAG(CMD, 1); + +/* ...response generation */ +TRACE_TAG(RSP, 1); + +#ifdef XAF_PROFILE_DSP +#include "xa_profiler.h" +#endif +/******************************************************************************* + * Local constants definitions + ******************************************************************************/ + +/* ...local interface status change flag */ +#define XF_PROXY_STATUS_LOCAL (1 << 0) + +/* ...remote status change notification flag */ +#define XF_PROXY_STATUS_REMOTE (1 << 1) + +/******************************************************************************* + * Internal helpers + ******************************************************************************/ + +/* ...put message into proxy queue */ +static inline void xf_msg_proxy_put(xf_message_t *m) +{ + u32 dst = XF_MSG_DST_CORE(m->id); + u32 src = XF_MSG_SRC_CORE(m->id); + xf_core_rw_data_t *rw = XF_CORE_RW_DATA(dst); + int first; + + /* ...get an access to shared rw-memory (we are running on "source" core) */ + xf_mutex_lock(src); + + /* ...assure memory coherency if needed */ + if (XF_REMOTE_IPC_NON_COHERENT) + { + /* ...invalidate rw-shared memory region */ + XF_PROXY_INVALIDATE(rw, sizeof(*rw)); + + /* ...put message into shared queue */ + first = xf_msg_enqueue(&rw->remote, m); + + /* ...flush both message and shared queue data */ + XF_PROXY_FLUSH(rw, sizeof(*rw)), XF_PROXY_FLUSH(m, sizeof(*m)); + } + else + { + /* ...no memory coherency concerns; just place a message in the queue */ + first = xf_msg_enqueue(&rw->remote, m); + } + + /* ...release rw-memory region lock */ + xf_mutex_unlock(src); + + /* ...assert IPI interrupt on target ("destination") core if needed */ + if (first && (dst ^ src)) + { + xf_ipi_assert(dst); + } +} + +/* ...retrieve message from proxy queue */ +static inline xf_message_t * xf_msg_proxy_get(u32 core) +{ + xf_core_rw_data_t *rw = XF_CORE_RW_DATA(core); + xf_message_t *m; + + /* ...retrieve message from queue in atomic fashion */ + xf_mutex_lock(core); + + /* ...assure memory coherency if needed */ + if (XF_REMOTE_IPC_NON_COHERENT) + { + /* ...invalidate rw-memory */ + XF_PROXY_INVALIDATE(rw, sizeof(*rw)); + + /* ...dequeue message from response queue */ + m = xf_msg_dequeue(&rw->remote); + + /* ...flush rw memory */ + XF_PROXY_FLUSH(rw, sizeof(*rw)); + + /* ...invalidate message data if found */ + (m ? XF_PROXY_INVALIDATE(m, sizeof(*m)) : 0); + } + else + { + /* ...just dequeue message from response queue */ + m = xf_msg_dequeue(&rw->remote); + } + + /* ...release the rw-lock */ + xf_mutex_unlock(core); + + return m; +} + +/******************************************************************************* + * Internal functions definitions + ******************************************************************************/ + +/* ...retrieve all incoming commands from shared memory ring-buffer */ +static u32 xf_shmem_process_input(u32 core) +{ + xf_message_t *m; + u32 read_idx; + u32 write_idx; + u32 status = 0; + + /* ...get current value of write pointer */ + read_idx = XF_PROXY_READ(core, cmd_read_idx); + write_idx = XF_PROXY_READ(core, cmd_write_idx); + + TRACE(EXEC, _b("Command queue: write = %x / read = %x"), write_idx, read_idx); + + /* ...process all committed commands */ + while (!XF_QUEUE_EMPTY(read_idx, write_idx)) + { + xf_proxy_message_t *command; + + /* ...allocate message; the call should not fail */ + if ((m = xf_msg_pool_get(&XF_CORE_RO_DATA(core)->pool)) == NULL) + break; + + /* ...if queue was full, set global proxy update flag */ + if (XF_QUEUE_FULL(read_idx, write_idx)) + status |= XF_PROXY_STATUS_REMOTE | XF_PROXY_STATUS_LOCAL; + else + status |= XF_PROXY_STATUS_LOCAL; + + /* ...get oldest not processed command */ + command = XF_PROXY_COMMAND(core, XF_QUEUE_IDX(read_idx)); + + /* ...synchronize memory contents */ + XF_PROXY_INVALIDATE(command, sizeof(*command)); + + /* ...fill message parameters */ + m->id = command->session_id; + m->opcode = command->opcode; + m->length = command->length; + m->buffer = xf_ipc_a2b(core, command->address); + TRACE(CMD, _b("C[%x]:(%x,%u,%p)"), m->id, m->opcode, m->length, m->buffer); + + /* ...invalidate message buffer contents as required - not here - tbd */ + (XF_OPCODE_CDATA(m->opcode) ? XF_PROXY_INVALIDATE(m->buffer, m->length) : 0); + + /* ...advance local reading index copy */ + read_idx = XF_QUEUE_ADVANCE_IDX(read_idx); + + /* ...update shadow copy of reading index */ + XF_PROXY_WRITE(core, cmd_read_idx, read_idx); + + /* ...and schedule message execution on proper core */ + xf_msg_submit(m); + } + + return status; +} + +/* ...send out all pending outgoing responses to the shared memory ring-buffer */ +static u32 xf_shmem_process_output(u32 core) +{ + xf_message_t *m; + u32 read_idx; + u32 write_idx; + u32 status = 0; + + /* ...get current value of peer read pointer */ + write_idx = XF_PROXY_READ(core, rsp_write_idx); + read_idx = XF_PROXY_READ(core, rsp_read_idx); + + TRACE(EXEC, _b("Response queue: write = %08X / read = %08X"), write_idx, read_idx); + + /* ...while we have response messages and there's space to write out one */ + while (!XF_QUEUE_FULL(read_idx, write_idx)) + { + xf_proxy_message_t *response; + + /* ...remove message from internal queue */ + if ((m = xf_msg_proxy_get(core)) == NULL) + break; + + /* ...notify remote interface each time we send it a message (only if it was empty?) */ + status = XF_PROXY_STATUS_REMOTE | XF_PROXY_STATUS_LOCAL; + +#if 0 + /* ...need to decide on best strategy - tbd */ + if (XF_QUEUE_EMPTY(read_idx, write_idx)) + status |= XF_PROXY_STATUS_REMOTE | XF_PROXY_STATUS_LOCAL; + else + status |= XF_PROXY_STATUS_LOCAL; +#endif + + /* ...flush message buffer contents to main memory as required - too late - different core - tbd */ + (XF_OPCODE_RDATA(m->opcode) ? XF_PROXY_FLUSH(m->buffer, m->length) : 0); + + /* ...find place in a queue for next response */ + response = XF_PROXY_RESPONSE(core, XF_QUEUE_IDX(write_idx)); + + /* ...put the response message fields */ + response->session_id = m->id; + response->opcode = m->opcode; + response->length = m->length; + response->address = xf_ipc_b2a(core, m->buffer); + /* ...flush the content of the caches to main memory */ + XF_PROXY_FLUSH(response, sizeof(*response)); + +#ifdef XAF_PROFILE_DSP + if((m->opcode == XF_FILL_THIS_BUFFER)) + { + if((m->length != 0) && (m->length != 20)) + { + prof.g_output_bytes += (unsigned long)m->length; + } + else if (m->length == 20) + { + /* Profiler re-initialization */ + INIT_XA_PROFILER(prof,"DSP core"); + + /* update stream params on re-init */ + xf_start_msg_t *sm = (xf_start_msg_t *)m->buffer; + prof.sample_rate = sm->sample_rate; + prof.channels = sm->channels; + prof.pcm_width = sm->pcm_width; + } + } +#endif + TRACE(RSP, _b("R[%x]:(%x,%u,%p)"), m->id, m->opcode, m->length, m->buffer); + + /* ...return message back to the pool */ + xf_msg_pool_put(&XF_CORE_RO_DATA(core)->pool, m); + + /* ...advance local writing index copy */ + write_idx = XF_QUEUE_ADVANCE_IDX(write_idx); + + /* ...update shared copy of queue write pointer */ + XF_PROXY_WRITE(core, rsp_write_idx, write_idx); + } + + /* ...return interface status change flags */ + return status; +} + +/******************************************************************************* + * Entry points + ******************************************************************************/ + +/* ...process local/remote shared memory interface status change */ +void xf_shmem_process_queues(u32 core) +{ + u32 status; + + do + { + /* ...acknowledge/clear any pending incoming interrupt */ + XF_PROXY_SYNC_PEER(core); + + /* ...send out pending response messages (frees message buffers, so do it first) */ + status = xf_shmem_process_output(core); + + /* ...receive and forward incoming command messages (allocates message buffers) */ + status |= xf_shmem_process_input(core); + + /* ...assert remote mailbox interrupt if global update bit is set */ + if (status & XF_PROXY_STATUS_REMOTE) + { + XF_PROXY_NOTIFY_PEER(core); + } + } + while (status); +} + +/* ...completion callback for message originating from remote proxy */ +void xf_msg_proxy_complete(xf_message_t *m) +{ + /* ...place message into proxy response queue */ + xf_msg_proxy_put(m); +} + +/* ...initialize shared memory interface (DSP side) */ +int xf_shmem_init(u32 core) +{ + xf_core_rw_data_t *rw = XF_CORE_RW_DATA(core); + xf_core_ro_data_t *ro = XF_CORE_RO_DATA(core); + + /* ...initialize local/remote message queues */ + xf_msg_queue_init(&rw->local); + xf_msg_queue_init(&rw->remote); + + /* ...initialize global message list */ + XF_CHK_API(xf_msg_pool_init(&ro->pool, XF_CFG_MESSAGE_POOL_SIZE, core)); + + /* ...flush memory content as needed */ + (XF_REMOTE_IPC_NON_COHERENT ? XF_PROXY_FLUSH(rw, sizeof(*rw)) : 0); + + /* ...system-specific initialization of IPC layer */ + XF_CHK_API(xf_ipc_init(core)); + + TRACE(INIT, _b("SHMEM-%u subsystem initialized"), core); + + return 0; +} 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 00000000..797bf231 --- /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 00000000..0de1745d --- /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 00000000..eb1b78e1 --- /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 00000000..1b67b52f --- /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 00000000..27ec455f --- /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 00000000..e83cdd34 --- /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 00000000..2aef0f6e --- /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 00000000..7f02cdf3 --- /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 00000000..dadd0885 --- /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 00000000..74b12220 --- /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 00000000..0cc0da93 --- /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 00000000..37646777 --- /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 00000000..0ca2d373 --- /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 00000000..2228f32a --- /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 00000000..5fdcca9a --- /dev/null +++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_driver_mailbox.h @@ -0,0 +1,171 @@ +/******************************************************************************* +* 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; + + /* ...physical address of message buffer */ + uint64_t address; + uint64_t v_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 00000000..fd5a93d3 --- /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 00000000..24f94ec1 --- /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 00000000..5a77a97d --- /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 00000000..e42ab1b9 --- /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 00000000..4775e807 --- /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 00000000..82cf3c11 --- /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 00000000..3ce5bd66 --- /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 00000000..dc277871 --- /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 00000000..ab328ccf --- /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 00000000..813bfb48 --- /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 00000000..b82c10eb --- /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 00000000..5f58825f --- /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 00000000..675ff15c --- /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 00000000..d45cb4b8 --- /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 00000000..f97f2e48 --- /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 00000000..4daea6f2 --- /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 00000000..c416cc01 --- /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 00000000..17019a73 --- /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 00000000..712ea14a --- /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 00000000..3448425b --- /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 00000000..6fa08465 --- /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 00000000..5805e9ff --- /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 00000000..0260749c --- /dev/null +++ b/hifi/xaf/hifi-dpf/include/xf-proxy.h @@ -0,0 +1,102 @@ +/******************************************************************************* +* 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 */ + 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; +#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 00000000..3c04436c --- /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 00000000..7b27d580 --- /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 00000000..97bb2905 --- /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 00000000..f124d8ca --- /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" diff --git a/hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/arch_hifi330.S b/hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/arch_hifi330.S new file mode 100644 index 00000000..6d1eb7e7 --- /dev/null +++ b/hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/arch_hifi330.S @@ -0,0 +1,468 @@ +/******************************************************************************* +* 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. + +******************************************************************************/ +/****************************************************************************** + arch_hifi330.S +******************************************************************************/ + +#include <xtensa/coreasm.h> +#include <xtensa/simcall.h> +#include <xtensa/corebits.h> +#include <xtensa/config/system.h> +#include <xtensa/config/core.h> +#include "arch_hifi330.h" + + .global OSStartHighRdy + .global OSTaskSwHook + .global g_pstVosTCBHighRdy + .global g_bVosRunning + +// .data + .section .dram0.data, "aw" + .type OSIntCtxSw_Occur,@object +OSIntCtxSw_Occur: + .byte 0 + + .begin literal_prefix .iram0 + .section .iram0.text, "ax" + .align 4 + .globl VOSStartHighRdy + .type VOSStartHighRdy,@function + .align 4 +/***************************************************************************** + VOSStartHighRdy +*****************************************************************************/ +VOSStartHighRdy: + ENTRY(16) + + /*OSIntCtxSw_Occur*/ + movi a2, OSIntCtxSw_Occur + movi a3, 0 + s8i a3, a2, 0 + + movi a2, g_bVosRunning + movi a3, 1 + s8i a3, a2, 0 + +#if 0 + /*OS_TaskSwHook */ + movi a2, OS_TaskSwHook + callx4 a2 +#endif + call0 OS_TaskSwitch + .end literal_prefix + + .begin literal_prefix .iram0 + .section .iram0.text, "ax" + .globl VOSCtxSw + .type VOSCtxSw,@function + .align 4 +/***************************************************************************** + OSCtxSw +*****************************************************************************/ +VOSCtxSw: + entry sp, XT_SOL_FRMSZ + rsr a2, PS + s32i a0, sp, XT_SOL_PC + s32i a2, sp, XT_SOL_PS + movi a2, g_pstVosTCBCur + movi a3, 0 + l32i a2, a2, 0 + s32i a3, sp, XT_SOL_EXIT + s32i sp, a2, OSTCBStkPtr /* g_pstVosTCBCur->OSTCBStkPtr = SP; */ + + call4 xthal_window_spill +#if 0 + /*OS_TaskSwHook */ + movi a2, OS_TaskSwHook + callx4 a2 +#endif + + /* CPENABLE, co-processor state. */ + movi a3, g_pstVosTCBCur + l32i a3, a3, 0 + l32i a2, a3, OSTCBStkBottom + movi a3, 0 + + wsr a3, CPENABLE /* disable all co-processors */ + s8i a3, a2, XT_CPENABLE /* cp_state->cpenable = 0; */ + + + call0 OS_TaskSwitch + .end literal_prefix + + .begin literal_prefix .iram0 + .section .iram0.text, "ax" + .globl VOSIntCtxSw + .type VOSIntCtxSw,@function + .align 4 +/***************************************************************************** + OSIntCtxSw +*****************************************************************************/ +VOSIntCtxSw: + ENTRY(16) +#if 0 + /*OS_TaskSwHook */ + movi a2, OS_TaskSwHook + callx4 a2 +#endif + + /*CPENABLE task co-processor, CPENABLE. */ + movi a3, g_pstVosTCBCur + l32i a3, a3, 0 + l32i a2, a3, OSTCBStkBottom + rsr a3, CPENABLE + s8i a3, a2, XT_CPENABLE + movi a3, 0 + wsr a3, CPENABLE + + movi a2, OSIntCtxSw_Occur + movi a3, 1 + s8i a3, a2, 0 + + + RET(16) + + .end literal_prefix + + .begin literal_prefix .iram0 + .section .iram0.text, "ax" + .global OSCPUSaveSR + .type OSCPUSaveSR,@function + .align 4 +/***************************************************************************** + OSCPUSaveSR +*****************************************************************************/ +OSCPUSaveSR: + entry a1,32 + rsil a2,15 + esync + retw + .end literal_prefix + + .begin literal_prefix .iram0 + .section .iram0.text, "ax" + .global OSCPURestoreSR + .type OSCPURestoreSR,@function + .align 4 +/***************************************************************************** + OSCPURestoreSR +*****************************************************************************/ +OSCPURestoreSR: + entry a1,32 + wsr.ps a2 + esync + retw + .end literal_prefix + + .begin literal_prefix .iram0 + .section .iram0.text, "ax" + .global OS_TaskSwitch + .type OS_TaskSwitch,@function + .align 4 +/***************************************************************************** + OS_TaskSwitch +*****************************************************************************/ +OS_TaskSwitch: + + /*1) + g_ucVosPrioCur = g_ucVosPrioHighRdy; + g_pstVosTCBCur = g_pstVosTCBHighRdy; + SP = g_pstVosTCBHighRdy->OSTCBStkPtr; + */ + movi a2, g_ucVosPrioHighRdy + movi a3, g_ucVosPrioCur + l8ui a2, a2, 0 + movi a4, g_pstVosTCBHighRdy + s8i a2, a3, 0 + movi a2, g_pstVosTCBCur + l32i a3, a4, 0 + l32i sp, a3, OSTCBStkPtr + s32i a3, a2, 0 + + + l32i a2, sp, XT_STK_EXIT + bnez a2, .L_in_int + + + l32i a3, sp, XT_SOL_PS + l32i a0, sp, XT_SOL_PC + + rsync + + wsr a3, PS + retw + +.L_in_int: + /* co-processor CPENABLE*/ + movi a3, g_pstVosTCBCur + l32i a3, a3, 0 + l32i a2, a3, OSTCBStkBottom + l8ui a3, a2, XT_CPENABLE + wsr a3, CPENABLE + + + call0 OS_ContextRestore + rsync + + l32i a0, sp, XT_STK_EXIT + ret + .end literal_prefix + + .begin literal_prefix .iram0 + .section .iram0.text, "ax" + .globl OS_ContextSave + .type OS_ContextSave,@function + .align 4 +/***************************************************************************** + OS_ContextSave +*****************************************************************************/ +OS_ContextSave: + + /*1): + A2 + A3 + A4 + A5 + A6 + A7 + A8 + A9 + A10 + A11 + SAR,LBENG,LEND,LCOUNT*/ + s32i a2, sp, XT_STK_A2 + s32i a3, sp, XT_STK_A3 + s32i a4, sp, XT_STK_A4 + s32i a5, sp, XT_STK_A5 + s32i a6, sp, XT_STK_A6 + s32i a7, sp, XT_STK_A7 + s32i a8, sp, XT_STK_A8 + s32i a9, sp, XT_STK_A9 + s32i a10, sp, XT_STK_A10 + s32i a11, sp, XT_STK_A11 + s32i a14, sp, XT_STK_A14 + s32i a15, sp, XT_STK_A15 + + + rsr a3, SAR + s32i a3, sp, XT_STK_SAR + + rsr a3, LBEG + s32i a3, sp, XT_STK_LBEG + rsr a3, LEND + s32i a3, sp, XT_STK_LEND + rsr a3, LCOUNT + s32i a3, sp, XT_STK_LCOUNT + + /*2)*/ + mov a9, a0 + s32i a12, sp, XT_STK_TMP+0 + s32i a13, sp, XT_STK_TMP+4 + s32i a9, sp, XT_STK_TMP+8 + l32i a12, sp, XT_STK_A12 + l32i a13, sp, XT_STK_A13 + l32i a9, sp, XT_STK_A9 + addi sp, sp, XT_STK_FRMSZ + call0 xthal_window_spill_nw + addi sp, sp, -XT_STK_FRMSZ + l32i a12, sp, XT_STK_TMP+0 + l32i a13, sp, XT_STK_TMP+4 + l32i a9, sp, XT_STK_TMP+8 + + addi a2, sp, XT_STK_EXTRA + call0 xthal_save_extra_nw + + mov a0, a9 + ret + .end literal_prefix + + .begin literal_prefix .iram0 + .section .iram0.text, "ax" + .global OS_ContextRestore + .type OS_ContextRestore,@function + .align 4 +/***************************************************************************** + OS_ContextRestore +*****************************************************************************/ +OS_ContextRestore: + /* + 1) xthal_restore_extra_nw*/ + mov a13, a0 + addi a2, sp, XT_STK_EXTRA + call0 xthal_restore_extra_nw + mov a0, a13 + + /*2): + LBEG + LEND + LCOUNT + A2 + SAR + A3 + A4 + A5 + A6 + A7 + A8 + A9 + A10 + A11 + A12 + A13 + A14 + A15*/ + l32i a2, sp, XT_STK_LBEG + l32i a3, sp, XT_STK_LEND + wsr a2, LBEG + l32i a2, sp, XT_STK_LCOUNT + wsr a3, LEND + wsr a2, LCOUNT + + l32i a3, sp, XT_STK_SAR + l32i a2, sp, XT_STK_A2 + wsr a3, SAR + l32i a3, sp, XT_STK_A3 + l32i a4, sp, XT_STK_A4 + l32i a5, sp, XT_STK_A5 + l32i a6, sp, XT_STK_A6 + l32i a7, sp, XT_STK_A7 + l32i a8, sp, XT_STK_A8 + l32i a9, sp, XT_STK_A9 + l32i a10, sp, XT_STK_A10 + l32i a11, sp, XT_STK_A11 + + l32i a12, sp, XT_STK_A12 + l32i a13, sp, XT_STK_A13 + l32i a14, sp, XT_STK_A14 + l32i a15, sp, XT_STK_A15 + + ret + + .end literal_prefix + + .begin literal_prefix .iram0 + .section .iram0.text, "ax" + .globl OS_IntEnter + .type OS_IntEnter,@function + .align 4 +OS_IntEnter: + + /* Save a12-13 in the stack frame as required by _xt_context_save. */ + s32i a12, sp, XT_STK_A12 + s32i a13, sp, XT_STK_A13 + + /* Save return address in a safe place (free a0). */ + mov a12, a0 + + /* Save the rest of the interrupted context (preserves A12-13). */ + call0 OS_ContextSave + + /* + Save interrupted task's SP in TCB only if not nesting. + Manage nesting directly rather than call the generic OSIntEnter() + (in windowed ABI we can't call a C function here anyway because PS.EXCM is still set). + */ + movi a2, g_bVosRunning + movi a3, g_ucVosIntNesting + l8ui a2, a2, 0 /* if (g_bVosRunning == OS_TRUE) { */ + beqz a2, 2f + l8ui a2, a3, 0 /* if (g_ucVosIntNesting == 0) { */ + bnez a2, 1f + movi a4, g_pstVosTCBCur + l32i a4, a4, 0 + s32i sp, a4, OSTCBStkPtr /* g_pstVosTCBCur->OSTCBStkPtr = SP; */ +1: /* } */ + addi a2, a2, 1 /* if (g_ucVosIntNesting < 255u) { */ + bgeui a2, 256, 2f /* g_ucVosIntNesting++; */ + s8i a2, a3, 0 /* } */ +2: /* } */ + + /* Retrieve the return address and return to interrupt handler. */ + mov a0, a12 + ret + .end literal_prefix + + .begin literal_prefix .iram0 + .section .iram0.text, "ax" + .globl OS_IntExit + .type OS_IntExit,@function + .align 4 +OS_IntExit: +#if 0 + /* Call VOSIntExit() to deal with nesting and call the scheduler. */ + movi a2, VOSIntExit + + rsil a0, XCHAL_EXCM_LEVEL /* enter critical section */ + callx4 a2 /* VOSIntExit() */ +#endif + /* Context-switch deferred from OSIntCtxSw(). Still in critical section. */ + movi a2, OSIntCtxSw_Occur + l8ui a3, a2, 0 + beqz a3, 1f /* if (OSIntCtxSw_Occur) { */ + movi a3, 0 /* OSIntCtxSw_Occur = false; */ + s8i a3, a2, 0 + call0 OS_TaskSwitch /* tail-call dispatcher; */ + /* Never returns here. */ /* } */ +1: + + /* + We come here only if there was no context switch, that is if this + is a nested interrupt or the interrupted task was not preempted. + We are still on the same stack so there's no need to load the SP. + */ + + /* Restore full context from interrupt stack frame and return to exit dispatcher. */ + call0 OS_ContextRestore + + /* + Must return via the exit dispatcher corresponding to the entrypoint from which + this was called. Interruptee's A0, A1, PS, PC are restored and the interrupt + stack frame is deallocated in the exit dispatcher. + */ + l32i a0, sp, XT_STK_EXIT + ret + .end literal_prefix + + .begin literal_prefix .iram0 + .section .iram0.text, "ax" + .globl OS_GetTaskCoprocState + .type OS_GetTaskCoprocState,@function + .align 4 +OS_GetTaskCoprocState: + + movi a2, g_bVosRunning + movi a3, g_ucVosIntNesting + l8ui a2, a2, 0 + l8ui a3, a3, 0 + beqz a2, 1f + bnez a3, 1f + movi a15, g_pstVosTCBCur + l32i a15, a15, 0 + beqz a15, 2f + l32i a15, a15, OSTCBStkBottom + ret + +1: movi a15, 0 +2: ret + .end literal_prefix + + diff --git a/hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/cpu_c.c b/hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/cpu_c.c new file mode 100644 index 00000000..12ce8b71 --- /dev/null +++ b/hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/cpu_c.c @@ -0,0 +1,152 @@ +/******************************************************************************* +* 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 "cpu_c.h" +#include <xtensa/config/specreg.h> +#include <xtensa/config/core.h> +#include <xtensa/simcall.h> +#include "arch_hifi330.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif +#endif + +/*lint -e838 -e835 -e750 -e529 -e533 -e40*/ + +//#define DSP_TRACES_TO_MEM_SIZE (0x800) + +void *g_pfVosHookFuncTable[OS_HOOK_TYPE_BUTT]; + +void *g_pfVosIntrFuncTable[OS_INTR_CONNECT_BUTT]; + +//unsigned int g_uwSoftIntInfo = 0; + +/* Interrupt nesting level */ +unsigned char g_ucVosIntNesting; + +/* Priority of current task */ +unsigned char g_ucVosPrioCur; + +/* Priority of highest priority task */ +unsigned char g_ucVosPrioHighRdy; + +/* Flag indicating that kernel is running */ +unsigned short g_bVosRunning; + +/* Pointer to highest priority TCB R-to-R */ +unsigned int *g_pstVosTCBHighRdy; + +/* Pointer to currently running TCB*/ +unsigned int *g_pstVosTCBCur; + +#define _XTSTR(x) #x +#define XTSTR(x) _XTSTR(x) + +void OS_EnterIntHook(unsigned int uhwIntrNo) +{ + INTR_HOOK_FUN_TYPE pfIntrHook = (INTR_HOOK_FUN_TYPE)g_pfVosHookFuncTable[OS_HOOK_TYPE_ENTER_INTR];/*lint !e611*/ + + if (0 != pfIntrHook) + { + pfIntrHook(uhwIntrNo); + } +} + +void OS_ExitIntHook(unsigned int uhwIntrNo) +{ + INTR_HOOK_FUN_TYPE pfIntrHook = (INTR_HOOK_FUN_TYPE)g_pfVosHookFuncTable[OS_HOOK_TYPE_EXIT_INTR];/*lint !e611*/ + + if (0 != pfIntrHook) + { + pfIntrHook(uhwIntrNo); + } +} + +void OS_UserexecHandler(unsigned int uwExecCauseNo, unsigned int psAddr) +{ + VOS_EXCEPTION_HOOK_FUNC pfIntrHook = (VOS_EXCEPTION_HOOK_FUNC)g_pfVosHookFuncTable[OS_HOOK_TYPE_EXCEPTION];/*lint !e611*/ + + if (0 != pfIntrHook) + { + pfIntrHook(uwExecCauseNo); + } + else + { + extern void OS_Panic(void); + OS_Panic(); + } +} + +void OS_InterruptHandler(unsigned int uhwIntrNo) +{ + HOOK_FUN_TYPE pfIntrHook = (HOOK_FUN_TYPE)g_pfVosIntrFuncTable[uhwIntrNo]; + + if (0 != pfIntrHook) + //pfIntrHook(); + pfIntrHook(0); +} + +void OS_NmiHook(unsigned int uwExecCauseNo, unsigned int psAddr) +{ + HOOK_FUN_TYPE pfNmiHook = (HOOK_FUN_TYPE)g_pfVosHookFuncTable[OS_HOOK_TYPE_NMI];/*lint !e611*/ + + if (0 != pfNmiHook) + { + //pfNmiHook(); + pfNmiHook(0); + } + + //wait for hifi reset + UCOM_SET_WFI_NMI(5); +} + +void VOS_ConnectInterrupt(unsigned int uwIntrNo, HOOK_FUN_TYPE pfnInterruptHook) +{ + g_pfVosIntrFuncTable[uwIntrNo] = (void *)pfnInterruptHook;/*lint !e611*/ +} + +void VOS_EnableInterrupt(unsigned int uwIntNo) +{ + unsigned int uwBitEnable; + + uwBitEnable = xthal_get_intenable(); + xthal_set_intenable(uwBitEnable | (((unsigned int)1) << uwIntNo )); + +} +void VOS_DisableInterrupt(unsigned int uwIntNo) +{ + unsigned int uwBitEnable; + + uwBitEnable = xthal_get_intenable(); + xthal_set_intenable(uwBitEnable | (((unsigned int)0) << uwIntNo )); + +} + +#ifdef __cplusplus + #if __cplusplus + } + #endif +#endif + diff --git a/hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/dsp_comm.c b/hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/dsp_comm.c new file mode 100644 index 00000000..290ca9dd --- /dev/null +++ b/hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/dsp_comm.c @@ -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. + +******************************************************************************/ + +#include "dsp_comm.h" + +void dsp_memcpy(void *d, void *s, unsigned int size) +{ + unsigned char *dest = (unsigned char*)d; + unsigned char *src = (unsigned char*)s; + + if (s == d) { + return; + } else if (src > dest) { + for (; dest < ((unsigned char*)d + size); dest++) { + *dest = *src; + src++; + } + } else { + src = src + (size - 1); + for (dest = dest + (size - 1); dest >= (unsigned char*)d; dest--) { + *dest = *src; + src--; + } + } +} + + +void dsp_memset(void *d, unsigned char ucData, unsigned int size) +{ + unsigned int i; + unsigned char *dest = (unsigned char*)d; + + for(i = 0; i < size; i++) + *dest++ = ucData; +} +int division(int a, int b) +{ + const int bits_in_word_m1 = (int)(sizeof(int) * 8) - 1; + int s_a = a >> bits_in_word_m1; /* s_a = a < 0 ? -1 : 0 */ + int s_b = b >> bits_in_word_m1; /* s_b = b < 0 ? -1 : 0 */ + a = (a ^ s_a) - s_a; /* negate if s_a == -1 */ + b = (b ^ s_b) - s_b; /* negate if s_b == -1 */ + s_a ^= s_b; /* sign of quotient */ + /* + * On CPUs without unsigned hardware division support, + * this calls __udivsi3 (notice the cast to su_int). + * On CPUs with unsigned hardware division support, + * this uses the unsigned division instruction. + */ + return ((int)a/(int)b ^ s_a) - s_a; /* negate if s_a == -1 */ + +} + + + + diff --git a/hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/dsp_debug.c b/hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/dsp_debug.c new file mode 100644 index 00000000..a74308e4 --- /dev/null +++ b/hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/dsp_debug.c @@ -0,0 +1,468 @@ +/******************************************************************************* +* 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 <stdarg.h> +#include <stdlib.h> +#include "dsp_debug.h" +#include "dsp_memory_config.h" +#include "dsp_driver_mailbox.h" +#include "dsp_comm.h" +#include "dsp_pcm_gain.h" +extern int g_pcm_gain; +extern int MsgFlag; +extern int InpBuf[HOLD_BUF_SIZE]; // assumes 32 bit samples. +extern int OutBuf[HOLD_BUF_SIZE]; // assumes 32 bit samples. + +static int hex2asc(int n) +{ + n &= 15; + if(n > 9){ + return ('a' - 10) + n; + } else { + return '0' + n; + } +} + +static void xputs(const char *s, void (*xputc)(unsigned n, void *cookie), void *cookie) +{ + while (*s) { + xputc(*s++, cookie); + } +} + +void __xprintf(const char *fmt, va_list ap,void (*xputc)(unsigned n, void *cookie), void *cookie) +{ + char scratch[32]; + for(;;){ + switch(*fmt){ + case 0: + va_end(ap); + return; + case '%': + switch(fmt[1]) { + case 'c': { + unsigned n = va_arg(ap, unsigned); + xputc(n, cookie); + fmt += 2; + continue; + } + case 'h': { + unsigned n = va_arg(ap, unsigned); + xputc(hex2asc(n >> 12), cookie); + xputc(hex2asc(n >> 8), cookie); + xputc(hex2asc(n >> 4), cookie); + xputc(hex2asc(n >> 0), cookie); + fmt += 2; + continue; + } + case 'b': { + unsigned n = va_arg(ap, unsigned); + xputc(hex2asc(n >> 4), cookie); + xputc(hex2asc(n >> 0), cookie); + fmt += 2; + continue; + } + case 'p': + case 'X': + case 'x': { + unsigned n = va_arg(ap, unsigned); + char *p = scratch + 15; + *p = 0; + do { + *--p = hex2asc(n); + n = n >> 4; + } while(n != 0); + while(p > (scratch + 7)) *--p = '0'; + xputs(p, xputc, cookie); + fmt += 2; + continue; + } + case 'd': { + int n = va_arg(ap, int); + char *p = scratch + 15; + *p = 0; + if(n < 0) { + xputc('-', cookie); + n = -n; + } + do { + *--p = (n % 10) + '0'; + n /= 10; + } while(n != 0); + xputs(p, xputc, cookie); + fmt += 2; + continue; + } + + case 'f': { + double fnum = va_arg(ap, double); + unsigned long long ipart, fpart; + int i=4; + char *p = scratch + 31; + *p = '\0'; + + if(fnum < 0.0) + { + xputc('-', cookie); + fnum = -fnum; + } + ipart = (unsigned long long)fnum; + fpart = ((fnum-ipart)*10000); //10^i = 10000 + + while(i>0) + { + *--p = (fpart % 10) + '0'; + fpart /= 10; + i--; + } + *--p = '.'; + while(ipart > 0) + { + *--p = (ipart % 10) + '0'; + ipart /= 10; + } + + xputs(p, xputc, cookie); + fmt += 2; + continue; + } + + case 'u': { + unsigned n = va_arg(ap, unsigned); + char *p = scratch + 15; + *p = 0; + do { + *--p = (n % 10) + '0'; + n /= 10; + } while(n != 0); + xputs(p, xputc, cookie); + fmt += 2; + continue; + } + case 's': { + char *s = (char *)va_arg(ap, char*); + if(s == 0) s = "(null)"; + xputs(s, xputc, cookie); + fmt += 2; + continue; + } + case 'l': { + if (fmt[2] == 'x') { + unsigned long long n = va_arg(ap, unsigned long long); + char *p = scratch + 23; + *p = 0; + do { + *--p = hex2asc((int)n); + n = n >> 4; + } while(n != 0); + while(p > (scratch + 7)) *--p = '0'; + xputs(p, xputc, cookie); + fmt += 3; + continue; + } + } + } + xputc(*fmt++, cookie); + break; + case '\n': + xputc('\r', cookie); + default: + xputc(*fmt++, cookie); + } + } +} + +static char* log_to_mem_head = 0; +void dsp_debug_init() +{ + log_to_mem_head = (char *)(*((unsigned int *)DRV_DSP_UART_TO_MEM_CUR_ADDR) + DRV_DSP_UART_TO_MEM); + +} + +static void log_write_to_mem(const char c_data) +{ + *log_to_mem_head = c_data; + + log_to_mem_head++; + if ((unsigned int)log_to_mem_head >= (DRV_DSP_UART_TO_MEM + DRV_DSP_UART_TO_MEM_SIZE - 1)) + log_to_mem_head = (char *)DRV_DSP_UART_TO_MEM + DRV_DSP_UART_TO_MEM_RESERVE_SIZE; + + *((unsigned int *)DRV_DSP_UART_TO_MEM_CUR_ADDR) = (unsigned int)log_to_mem_head - DRV_DSP_UART_TO_MEM; +} + + +static void print_char(const char c_data) +{ + if (c_data == '\n') + log_write_to_mem('\r'); + log_write_to_mem(c_data); +} + +typedef void (*xputc_type)(unsigned n, void *cookie); + +void print_log(const char *fmt, ...) +{ + va_list args; +va_start(args, fmt); + __xprintf(fmt, args, (xputc_type)print_char, 0); + va_end(args); +} +#ifdef HIKEY_XAF_IPC_COMMENT_OUT +#define ISSPACE(c) (c == ' ' || c == 0x09 || c == 0x0A || c == 0x0D || c == 0) + +char* dsp_om_trim_zero(char* str) +{ + char *str_begin = 0; + char *str_end = 0; + + if (!str) + return 0; + + str_begin = str; + str_end = str + strlen(str); + + while (str_begin < str_end) { + if (ISSPACE(*str_begin)) { + *str_begin = 0; + str_begin++; + } else { + break; + } + } + while (str_begin < str_end) { + if (ISSPACE(*str_end)) { + *str_end = 0; + str_end--; + } else { + break; + } + } + + return str_begin; +} + +char * dsp_om_split_str(char* str, char** split_str) +{ + char *str_begin = 0; + char *str_end = 0; + + if ((!str) || (!split_str)) { + DSP_LOGE("input param is null\n"); + return str; + } + + str_end = str + strlen(str); + str_begin = dsp_om_trim_zero(str); + + if (str_begin == str_end) { + DSP_LOGE("input str all space\n"); + return 0; + } + + *split_str = dsp_om_trim_zero(strchr(str_begin, ' ')); + + return str_begin; +} + +#ifdef GJB_CHANGE +void send_msg_data_to_ap() +{ + + struct hikey_msg_with_content hikey_msg; + DSP_LOGE("%s\n", __func__); + hikey_msg.msg_info.msg_id=HIKEY_AUDIO_DSP_AP_OM_CMD; + hikey_msg.msg_info.msg_len=HIKEY_AP_DSP_MSG_MAX_LEN; + strncpy(hikey_msg.msg_info.msg_content,"pcm_gain",HIKEY_AP_DSP_MSG_MAX_LEN); + dsp_mailbox_write(&hikey_msg); + DSP_LOGE("Exit %s\n", __func__); +} + +void send_pcm_data_to_ap() +{ + struct hikey_ap_dsp_msg_body msg_info; + DSP_LOGE("Enter %s\n", __func__); + msg_info.msg_id = ID_XAF_DSP_TO_AP; + msg_info.msg_len = sizeof(msg_info); + msg_info.xf_dsp_msg.id= 0; + msg_info.xf_dsp_msg.opcode = 0xc; + msg_info.xf_dsp_msg.length = 0x400; + msg_info.xf_dsp_msg.address = 0x8B432000; + dsp_mailbox_write(&msg_info); + DSP_LOGE("Exit %s\n", __func__); +} +#else +void send_msg_data_to_ap() +{ + xf_proxy_message_t hikey_msg; + DSP_LOGE("%s\n", __func__); + hikey_msg.id=HIKEY_AUDIO_DSP_AP_OM_CMD; + hikey_msg.length=HIKEY_AP_DSP_MSG_MAX_LEN; + strncpy(hikey_msg.address,"pcm_gain",HIKEY_AP_DSP_MSG_MAX_LEN); + dsp_mailbox_write(&hikey_msg); + DSP_LOGE("Exit %s\n", __func__); +} + +void send_pcm_data_to_ap() +{ + xf_proxy_message_t msg_info; + DSP_LOGE("Enter %s\n", __func__); + msg_info.id = ID_XAF_DSP_TO_AP; + msg_info.opcode = 0xc; + msg_info.length = 0x400; + msg_info.address = 0x8B432000; + dsp_mailbox_write(&msg_info); + DSP_LOGE("Exit %s\n", __func__); +} +#endif +static void dsp_om_read_mem(char *str) +{ + unsigned int addr = 0; + unsigned int val = 0; + if (!str) { + DSP_LOGE("str is null\n"); + return; + } + + addr = strtoul(str, 0, 16); + DSP_LOGD("str:%s addr:0x%x\n", str, addr); + + val = *(unsigned int*)addr; + send_pcm_data_to_ap(); +//send_msg_data_to_ap(); + dsp_ipc_send_irq_to_ap(); + DSP_LOGI("read addr:0x%x value:0x%x\n", addr, val); + return; +} + +static void dsp_om_write_mem(char *str) +{ + char* str_addr = 0; + char* str_val = 0; + unsigned int addr = 0; + unsigned int val = 0; + if (!str) { + DSP_LOGE("str is null\n"); + return; + } + + str_addr = dsp_om_split_str(str, &str_val); + + if(!str_addr || !str_val) { + DSP_LOGE("str:%s str_addr:%s strValue:%s\n", str, str_addr ? str_addr : "null", str_val ? str_val : "null"); + return; + } + addr = strtoul(str_addr, 0, 16); + val= strtoul(str_val, 0, 16); + DSP_LOGI("str_addr:%s addr:%x str_val:%s val:%x\n", str_addr ? str_addr : "null", addr, str_val ? str_val : "null", val); + + *(unsigned int *)addr = val; + + return; + +} + +static void dsp_om_pcm_gain(char *str) +{ + char* str_addr = 0; + char* str_val = 0; + unsigned int addr = 0; + unsigned int val = 0; + if (!str) { + DSP_LOGE("str is null\n"); + return; + } + str_addr = dsp_om_split_str(str, &str_val); + if(!str_addr || !str_val) { + DSP_LOGE("str:%s str_addr:%s strValue:%s\n", str, str_addr ? str_addr : "null", str_val ? str_val : "null"); + return; + } + addr = strtoul(str_addr, 0, 16); + val= strtoul(str_val, 0, 16); + DSP_LOGI("str_addr:%s addr:%x str_val:%s val:%x\n", str_addr ? str_addr : "null", addr, str_val ? str_val : "null", val); + if(ReadData((char*)InpBuf, val) ){ + processAudio(OutBuf, InpBuf, (val/4)); + if(WriteData((char*)OutBuf, val)) { + MsgFlag = MSG_PROC; // indicate that the msg is processed. + DSP_LOGI("PCM gain processed\n"); + send_msg_data_to_ap(); + dsp_ipc_send_irq_to_ap(); // Indicate data is ready to pickup... Maybe you need to send a msg to AP. + } + else { + DSP_LOGI("PCM gain Write error\n"); + MsgFlag = MSG_INCOMP; + dsp_ipc_send_irq_to_ap();// Report error.. + } + } + else { + DSP_LOGI("PCM gain Read error\n"); + MsgFlag = MSG_INCOMP; + dsp_ipc_send_irq_to_ap(); + } + return; +} +typedef void (*om_proc_func)(char *str); + +struct om_proc_info { + char *om_proc_name; + om_proc_func func; +}; + +struct om_proc_info om_proc_table[] = { + {"read_mem", dsp_om_read_mem}, + {"write_mem", dsp_om_write_mem}, + {"pcm_gain", dsp_om_pcm_gain}, +}; + +om_proc_func dsp_om_get_func_by_name(char *name) +{ + unsigned int i = 0; + unsigned int func_num = sizeof(om_proc_table) / sizeof(om_proc_table[0]); + + if (!name) { + DSP_LOGE("name is null\n"); + return 0; + } + + for (i = 0; i < func_num; i++) + if (!strncmp((char *)om_proc_table[i].om_proc_name, name, strlen((char *)om_proc_table[i].om_proc_name))) + return om_proc_table[i].func; + + return 0; +} + +void dsp_om_func_proc(char *om_str, unsigned int str_len) +{ + char * cmd_name = 0; + char * str_param = 0; + om_proc_func proc_func = 0; + + cmd_name = dsp_om_split_str((char *)om_str, &str_param); + + DSP_LOGI("cmd_name:%s\n", cmd_name); + proc_func = dsp_om_get_func_by_name(cmd_name); + if (proc_func) + proc_func(str_param); + else + DSP_LOGE("do not find func\n"); +} +#endif + diff --git a/hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/int_vector.S b/hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/int_vector.S new file mode 100644 index 00000000..d579a55e --- /dev/null +++ b/hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/int_vector.S @@ -0,0 +1,830 @@ +/******************************************************************************* +* 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. + +******************************************************************************/ +/****************************************************************************** + int_vector.S +******************************************************************************/ +#include <xtensa/coreasm.h> +#include <xtensa/corebits.h> +#include <xtensa/config/system.h> +#include <xtensa/simcall.h> +#include "arch_hifi330.h" + +// .data + .section .dram0.data, "aw" +/* CP */ + .type g_awVosCoprocSaOffset,@object + .align 16 /* minimize crossing cache boundaries */ +g_awVosCoprocSaOffset: + .word XT_CP0_SA, XT_CP1_SA, XT_CP2_SA, XT_CP3_SA + .word XT_CP4_SA, XT_CP5_SA, XT_CP6_SA, XT_CP7_SA + +/* CP n's CPENABLE bit. */ + .type g_bVosCoprocMask,@object + .align 16,,8 /* try to keep it all in one cache line */ +g_bVosCoprocMask: + .byte 0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80 + +/* Owner of CP (0 = unowned). */ + .global g_awVosCoprocOwnerSa + .type g_awVosCoprocOwnerSa,@object + .align 16,,XCHAL_CP_MAX<<2 /* minimize crossing cache boundaries */ +g_awVosCoprocOwnerSa: + .space XCHAL_CP_MAX << 2,0 + + .global g_strVosPanicMessage + .align 4 +g_strVosPanicMessage: + .string "\npanic at addr 0x%08x.\n" + + + .begin literal_prefix .iram0 + .section .iram0.text, "ax" + .global OS_Panic + .type OS_Panic,@function + .align 4 +/***************************************************************************** + OS_Panic +*****************************************************************************/ +OS_Panic: + +#ifdef ZOS_SIM + /*panic at addr*/ + addi a4, a0, -3 /* point to call0 */ + movi a3, g_strVosPanicMessage + movi a2, SYS_log_msg + simcall + movi a2, SYS_gdb_abort + simcall +#else + /*low & med*/ + rsil a2, XCHAL_EXCM_LEVEL /* disable all low & med ints */ +1: j 1b /* loop infinitely */ +#endif + + .end literal_prefix + + .begin literal_prefix .DebugExceptionVector + .section .DebugExceptionVector.text, "ax" + .global OS_DebugExceptionVector + .align 4 +/***************************************************************************** +_DebugExceptionVector +*****************************************************************************/ +OS_DebugExceptionVector: +#ifdef ZOS_SIM + wsr a2, EXCSAVE+XCHAL_DEBUGLEVEL + movi a2, SYS_gdb_enter_sktloop + simcall +#else + wsr a0, EXCSAVE+XCHAL_DEBUGLEVEL + call0 OS_Panic + rfi XCHAL_DEBUGLEVEL +#endif + + .end literal_prefix + + + .begin literal_prefix .DoubleExceptionVector + .section .DoubleExceptionVector.text, "ax" + .global OS_DoubleExceptionVector + .align 4 +/***************************************************************************** + OS_DoubleExceptionVector +*****************************************************************************/ +OS_DoubleExceptionVector: + call0 OS_Panic /* does not return */ + rfde /* make a0 point here not later */ + + .end literal_prefix + + + .begin literal_prefix .KernelExceptionVector + .section .KernelExceptionVector.text, "ax" + .global OS_KernelExceptionVector + .align 4 +/***************************************************************************** + _KernelExceptionVector +*****************************************************************************/ +OS_KernelExceptionVector: + call0 OS_Panic /* does not return */ + rfe /* make a0 point here not later */ + + .end literal_prefix + + + .begin literal_prefix .UserExceptionVector + .section .UserExceptionVector.text, "ax" + .global OS_UserExceptionVector + .type OS_UserExceptionVector,@function + .align 4 +/***************************************************************************** + _UserExceptionVector +*****************************************************************************/ +OS_UserExceptionVector: + wsr a0, EXCSAVE_1 /* preserve a0 */ + call0 OS_UserExc /* user exception handler */ + /* never returns here - call0 is used as a jump (see note at top) */ + + .end literal_prefix + + .begin literal_prefix .iram0 + .section .iram0.text, "ax" + + .align 4 +OS_CoProcessorExc: + s32i a5, sp, XT_STK_A5 /* save a5 */ + addi a5, a0, -EXCCAUSE_CP0_DISABLED /* a0 = CP index */ + bgei a5, XCHAL_CP_MAX, .L_xt_user_exc_not_coproc + call0 OS_CoProcessorException /* in window vectors section */ + /* never returns here - call0 is used as a jump (see note at top) */ + .end literal_prefix + + .begin literal_prefix .iram0 + .section .iram0.text, "ax" + .align 4 +OS_AllocExc: + call0 OS_AllocaException /* in window vectors section */ + /* never returns here - call0 is used as a jump (see note at top) */ + .end literal_prefix + + .begin literal_prefix .iram0 + .section .iram0.text, "ax" + .align 4 +OS_SyscallExc: + call0 OS_SyscallException + /* never returns here - call0 is used as a jump (see note at top) */ + + .end literal_prefix + + .begin literal_prefix .iram0 + .section .iram0.text, "ax" + .global OS_UserExc + .type OS_UserExc,@function + .align 4 +OS_UserExc: + rsr a0, EXCCAUSE + beqi a0, EXCCAUSE_ALLOCA, OS_AllocExc + beqi a0, EXCCAUSE_SYSCALL, OS_SyscallExc + + mov a0, sp /* sp == a1 */ + addi sp, sp, -XT_STK_FRMSZ /* allocate interrupt stack frame */ + s32i a0, sp, XT_STK_A1 /* save pre-interrupt SP */ + rsr a0, PS /* save interruptee's PS */ + s32i a0, sp, XT_STK_PS + rsr a0, EPC_1 /* save interruptee's PC */ + s32i a0, sp, XT_STK_PC + rsr a0, EXCSAVE_1 /* save interruptee's a0 */ + s32i a0, sp, XT_STK_A0 + movi a0, OS_UserExit /* save exit point for dispatch */ + s32i a0, sp, XT_STK_EXIT + + rsr a0, EXCCAUSE + bgeui a0, EXCCAUSE_CP0_DISABLED, OS_CoProcessorExc + +.L_xt_user_exc_not_coproc: + + + call0 XT_RTOS_INT_ENTER + + + movi a0, PS_INTLEVEL(XCHAL_EXCM_LEVEL) | PS_UM | PS_WOE + wsr a0, PS + rsync + + rsr a2, EXCCAUSE + beqi a2, EXCCAUSE_LEVEL1INTERRUPT, .L_xt_user_int + mov a6,a2 + mov a7,a1 + /*User exception*/ + call4 OS_UserexecHandler + j .L_xt_user_done + +.L_xt_user_int: + /* level 1 int */ + rsr a2, INTENABLE + rsr a3, INTERRUPT + movi a4, XCHAL_INTLEVEL1_MASK + and a2, a2, a3 + and a2, a2, a4 + beqz a2, .L_int_done1 + + neg a3,a2 + and a3,a3,a2 + wsr a3,INTCLEAR + + find_ls_one a2, a3 + mov a6,a2 + call4 OS_EnterIntHook + + mov a6,a2 + call4 OS_InterruptHandler + + mov a6,a2 + call4 OS_ExitIntHook + j .L_xt_user_int + +.L_int_done1: + + +.L_xt_user_done: + call0 XT_RTOS_INT_EXIT + + .end literal_prefix + + .begin literal_prefix .iram0 + .section .iram0.text, "ax" + .global OS_UserExit + .type OS_UserExit,@function + .align 4 +OS_UserExit: + l32i a0, sp, XT_STK_PS /* retrieve interruptee's PS */ + wsr a0, PS + l32i a0, sp, XT_STK_PC /* retrieve interruptee's PC */ + wsr a0, EPC_1 + l32i a0, sp, XT_STK_A0 /* retrieve interruptee's A0 */ + l32i sp, sp, XT_STK_A1 /* remove interrupt stack frame */ + rsync /* ensure PS and EPC written */ + rfe /* PS.EXCM is cleared */ + + .end literal_prefix + + .begin literal_prefix .iram0 + .section .iram0.text, "ax" + .type OS_SyscallException,@function + .align 4 +/***************************************************************************** + OS_SyscallException +*****************************************************************************/ +OS_SyscallException: + addi sp, sp, -XT_STK_FRMSZ /* allocate interrupt stack frame */ + s32i a12, sp, XT_STK_A12 /* _xt_context_save requires A12- */ + s32i a13, sp, XT_STK_A13 /* A13 to have already been saved */ + call0 OS_ContextSave + + + /* + 2)update PC*/ + rsr a2, EPC_1 + addi a3, a2, 3 + + rsr a0, LEND + bne a3, a0, 1f + rsr a0, LCOUNT + beqz a0, 1f + addi a0, a0, -1 + rsr a3, LBEG + wsr a0, LCOUNT + +1: wsr a3, EPC_1 + + /* Restore context,exception */ + call0 OS_ContextRestore + addi sp, sp, XT_STK_FRMSZ + + movi a0, -1 + movnez a2, a0, a2 /* return -1 if not syscall 0 */ + rsr a0, EXCSAVE_1 + rfe + + + + .end literal_prefix + + .begin literal_prefix .iram0 + .section .iram0.text, "ax" + .type OS_CoProcessorException,@function + .align 4 +/***************************************************************************** + OS_CoProcessorException +*****************************************************************************/ +OS_CoProcessorException: /* a5 = CP index */ + + s32i a2, sp, XT_STK_A2 + s32i a3, sp, XT_STK_A3 + s32i a4, sp, XT_STK_A4 + s32i a15, sp, XT_STK_A15 + + + /* co-processor old owner new owner. */ + call0 XT_RTOS_CP_STATE /* a15 = new owner's save area */ + beqz a15, .L_xt_coproc_invalid /* not in a thread (invalid) */ + + mov a0, a5 /* a0 = CP index */ + movi a3, g_awVosCoprocOwnerSa + addx4 a3, a0, a3 /* a3 = &g_awVosCoprocOwnerSa[CP] */ + l32i a2, a3, 0 /* a2 = old owner's save area */ + + /* Enable the co-processor's bit in CPENABLE. */ + movi a4, g_bVosCoprocMask + rsr a5, CPENABLE /* a5 = CPENABLE */ + add a4, a4, a0 + l8ui a4, a4, 0 /* a4 = bitmask from CP index */ + or a5, a5, a4 /* a5 = CPENABLE + CP */ + wsr a5, CPENABLE + + + beq a15, a2, .L_xt_coproc_done /* new owner == old, we're done */ + + s32i a15, a3, 0 /* g_awVosCoprocOwnerSa[CP] = new */ + + l8ui a5, a15, XT_CPSTORED /* a5 = new owner's old CPSTORED */ + neg a3, a4 + addi a3, a3, -1 /* a3 = ~a4 (bitmask for CP) */ + and a3, a5, a3 /* clr CP in new owner's CPSTORED */ + s8i a3, a15, XT_CPSTORED /* update new owner's CPSTORED */ + + /* Adjust new owner's save area pointers to area for CP n. */ + movi a3, g_awVosCoprocSaOffset + and a5, a5, a4 /* a5 = new owner's CP is stored */ + addx4 a3, a0, a3 /* a3 = &OS_CoprocSaOffset[CP] */ + l32i a3, a3, 0 /* a3 = XT_CP[CP]_SA */ + add a15, a15, a3 /* a15 = new owner's area for CP */ + moveqz a15, a5, a5 /* a15 = 0 if state not stored */ + + rsync /* ensure wsr.CPENABLE is complete */ + beqz a2, .L_xt_coproc_new /* no old owner to save */ + + /* If old owner still needs CP, clear CP in CPENABLE and set in CPSTORED. */ + l8ui a5, a2, XT_CPENABLE /* a5 = old owner's CPENABLE */ + and a4, a5, a4 /* a4 = CP in old owner CPENABLE */ + beqz a4, .L_xt_coproc_new /* discard old owner's CP state */ + + sub a5, a5, a4 /* clr CP in old owner's CPENABLE */ + s8i a5, a2, XT_CPENABLE /* update old owner's CPENABLE */ + l8ui a5, a2, XT_CPSTORED /* a5 = old owner's CPSTORED */ + or a5, a5, a4 /* set CP in old owner's CPSTORED */ + s8i a5, a2, XT_CPSTORED /* update old owner's CPSTORED */ + + /* Save co-processor state of old owner. */ +.Ln_xt_coproc_old: + add a2, a2, a3 /* a2 = old owner's area for CP */ + mov a3, a0 /* a3 = CP index */ + /* + The config-specific HAL macro invoked below destroys a2-5, preserves a0-1. + It is theoretically possible for Xtensa processor designers to write TIE + that causes more address registers to be affected, but it is generally + unlikely. If that ever happens, more registers needs to be saved/restored + around this macro invocation, and the value in a15 needs to be recomputed. + */ + xchal_cpi_store_funcbody + + /* Restore co-processor state of new owner. */ +.L_xt_coproc_new: + beqz a15, .L_xt_coproc_done /* no valid state to restore */ + mov a2, a15 /* a2 = new owner's area for CP */ + mov a3, a0 /* a3 = CP index */ + + xchal_cpi_load_funcbody + + +.L_xt_coproc_done: + l32i a15, sp, XT_STK_A15 + l32i a5, sp, XT_STK_A5 + l32i a4, sp, XT_STK_A4 + l32i a3, sp, XT_STK_A3 + l32i a2, sp, XT_STK_A2 + call0 OS_UserExit + +.L_xt_coproc_invalid: + call0 OS_Panic /* not in a thread (invalid) */ + .end literal_prefix + + .begin literal_prefix .Level2InterruptVector + .section .Level2InterruptVector.text, "ax" + .global OS_Level2Vector + .type OS_Level2Vector,@function + .align 4 +/***************************************************************************** + _Level2Vector +*****************************************************************************/ +OS_Level2Vector: + wsr a0, EXCSAVE_2 /* preserve a0 */ + call0 OS_Medint2 /* load interrupt handler */ + + .end literal_prefix + + .begin literal_prefix .iram0 + .section .iram0.text, "ax" + .extern OS_InterruptHandler + .type OS_Medint2,@function + .align 4 +OS_Medint2: + +#movi a1, 0xdeadbeef + movi a1, 0xe8075000 + movi a2, 0xe8075e30 /*HIFI_RESERVE1_LOCATION*/ + s32i a1, a2, 0 + + mov a0, sp /* sp == a1 */ + addi sp, sp, -XT_STK_FRMSZ /* allocate interrupt stack frame */ + s32i a0, sp, XT_STK_A1 /* save pre-interrupt SP */ + rsr a0, EPS_2 /* save interruptee's PS */ + s32i a0, sp, XT_STK_PS + rsr a0, EPC_2 /* save interruptee's PC */ + s32i a0, sp, XT_STK_PC + rsr a0, EXCSAVE_2 /* save interruptee's a0 */ + s32i a0, sp, XT_STK_A0 + movi a0, OS_Medint2Exit /* save exit point for dispatch */ + s32i a0, sp, XT_STK_EXIT + + call0 XT_RTOS_INT_ENTER + + movi a0, PS_INTLEVEL(2) | PS_UM | PS_WOE + wsr a0, PS + rsync + + +.L_ProcAllInt2: + rsr a2, INTENABLE + rsr a3, INTERRUPT + movi a4, XCHAL_INTLEVEL2_MASK + and a2, a2, a3 + and a2, a2, a4 + beqz a2, .L_int_done2 + + neg a3,a2 + and a3,a3,a2 + wsr a3,INTCLEAR + + find_ls_one a2, a3 + mov a6,a2 + call4 OS_EnterIntHook + + mov a6,a2 + call4 OS_InterruptHandler + + mov a6,a2 + call4 OS_ExitIntHook + j .L_ProcAllInt2 + +.L_int_done2: + call0 XT_RTOS_INT_EXIT + + .end literal_prefix + + .begin literal_prefix .iram0 + .section .iram0.text, "ax" + .global OS_Medint2Exit + .type OS_Medint2Exit,@function + .align 4 +OS_Medint2Exit: + /* Restore only level-specific regs (the rest were already restored) */ + l32i a0, sp, XT_STK_PS /* retrieve interruptee's PS */ + wsr a0, EPS_2 + l32i a0, sp, XT_STK_PC /* retrieve interruptee's PC */ + wsr a0, EPC_2 + l32i a0, sp, XT_STK_A0 /* retrieve interruptee's A0 */ + l32i sp, sp, XT_STK_A1 /* remove interrupt stack frame */ + rsync /* ensure EPS and EPC written */ + rfi 2 + .end literal_prefix + + + .begin literal_prefix .Level3InterruptVector + .section .Level3InterruptVector.text, "ax" + .global OS_Level3Vector + .type OS_Level3Vector,@function + .align 4 +/***************************************************************************** + _Level3Vector +*****************************************************************************/ +OS_Level3Vector: + wsr a0, EXCSAVE_3 /* preserve a0 */ + call0 OS_MedInt3 /* load interrupt handler */ + + .end literal_prefix + + .begin literal_prefix .iram0 + .section .iram0.text, "ax" + .extern OS_InterruptHandler + .type OS_MedInt3,@function + .align 4 +OS_MedInt3: + + mov a0, sp /* sp == a1 */ + addi sp, sp, -XT_STK_FRMSZ /* allocate interrupt stack frame */ + s32i a0, sp, XT_STK_A1 /* save pre-interrupt SP */ + rsr a0, EPS_3 /* save interruptee's PS */ + s32i a0, sp, XT_STK_PS + rsr a0, EPC_3 /* save interruptee's PC */ + s32i a0, sp, XT_STK_PC + rsr a0, EXCSAVE_3 /* save interruptee's a0 */ + s32i a0, sp, XT_STK_A0 + movi a0, OS_Medint3Exit /* save exit point for dispatch */ + s32i a0, sp, XT_STK_EXIT + + call0 XT_RTOS_INT_ENTER + + movi a0, PS_INTLEVEL(3) | PS_UM | PS_WOE + wsr a0, PS + rsync + + +.L_ProcAllInt3: + rsr a2, INTENABLE + rsr a3, INTERRUPT + movi a4, XCHAL_INTLEVEL3_MASK + and a2, a2, a3 + and a2, a2, a4 + beqz a2, .L_int_done3 + + neg a3,a2 + and a3,a3,a2 + wsr a3,INTCLEAR + + find_ls_one a2, a3 + mov a6,a2 + call4 OS_EnterIntHook + + mov a6,a2 + call4 OS_InterruptHandler + + mov a6,a2 + call4 OS_ExitIntHook + j .L_ProcAllInt3 + +.L_int_done3: + + call0 XT_RTOS_INT_EXIT + + .end literal_prefix + + .begin literal_prefix .iram0 + .section .iram0.text, "ax" + .global OS_Medint3Exit + .type OS_Medint3Exit,@function + .align 4 +OS_Medint3Exit: + /* Restore only level-specific regs (the rest were already restored) */ + l32i a0, sp, XT_STK_PS /* retrieve interruptee's PS */ + wsr a0, EPS_3 + l32i a0, sp, XT_STK_PC /* retrieve interruptee's PC */ + wsr a0, EPC_3 + l32i a0, sp, XT_STK_A0 /* retrieve interruptee's A0 */ + l32i sp, sp, XT_STK_A1 /* remove interrupt stack frame */ + rsync /* ensure EPS and EPC written */ + rfi 3 + .end literal_prefix + + + .begin literal_prefix .NMIExceptionVector + .section .NMIExceptionVector.text, "ax" + .global OS_NMIExceptionVector + .align 8 +/***************************************************************************** + OS_NMIExceptionVector +*****************************************************************************/ +OS_NMIExceptionVector: + /*wsr a3, 213 + wsr a4, 214*/ + + /*movi a3, 0x0 + movi a4, 0xf711a510 + s32i a3, a4, 0*/ + + /*rsr a3, 213 + rsr a4, 214*/ + + movi a0, PS_INTLEVEL(3) | PS_UM | PS_WOE + wsr a0, PS + rsync + rsr a2, EXCCAUSE + mov a6,a2 + mov a7,a1 + call4 OS_NmiHook + + rfi XCHAL_NMILEVEL + + .end literal_prefix + + .section .WindowVectors.text, "ax" + +/* +-------------------------------------------------------------------------------- +Window Overflow Exception for Call4. + +Invoked if a call[i] referenced a register (a4-a15) +that contains data from ancestor call[j]; +call[j] had done a call4 to call[j+1]. +On entry here: + window rotated to call[j] start point; + a0-a3 are registers to be saved; + a4-a15 must be preserved; + a5 is call[j+1]'s stack pointer. +-------------------------------------------------------------------------------- +*/ + + .org 0x0 + .global _WindowOverflow4 +_WindowOverflow4: + + s32e a0, a5, -16 /* save a0 to call[j+1]'s stack frame */ + s32e a1, a5, -12 /* save a1 to call[j+1]'s stack frame */ + s32e a2, a5, -8 /* save a2 to call[j+1]'s stack frame */ + s32e a3, a5, -4 /* save a3 to call[j+1]'s stack frame */ + rfwo /* rotates back to call[i] position */ + +/* +-------------------------------------------------------------------------------- +Window Underflow Exception for Call4 + +Invoked by RETW returning from call[i+1] to call[i] +where call[i]'s registers must be reloaded (not live in ARs); +where call[i] had done a call4 to call[i+1]. +On entry here: + window rotated to call[i] start point; + a0-a3 are undefined, must be reloaded with call[i].reg[0..3]; + a4-a15 must be preserved (they are call[i+1].reg[0..11]); + a5 is call[i+1]'s stack pointer. +-------------------------------------------------------------------------------- +*/ + + .org 0x40 + .global _WindowUnderflow4 +_WindowUnderflow4: + + l32e a0, a5, -16 /* restore a0 from call[i+1]'s stack frame */ + l32e a1, a5, -12 /* restore a1 from call[i+1]'s stack frame */ + l32e a2, a5, -8 /* restore a2 from call[i+1]'s stack frame */ + l32e a3, a5, -4 /* restore a3 from call[i+1]'s stack frame */ + rfwu + + .global OS_AllocaException + .align 4 +/***************************************************************************** + OS_AllocaException +*****************************************************************************/ +OS_AllocaException: + + rsr a0, WINDOWBASE /* grab WINDOWBASE before rotw changes it */ + rotw -1 /* WINDOWBASE goes to a4, new a0-a3 are scratch */ + rsr a2, PS + extui a3, a2, XCHAL_PS_OWB_SHIFT, XCHAL_PS_OWB_BITS + xor a3, a3, a4 /* bits changed from old to current windowbase */ + rsr a4, EXCSAVE_1 /* restore original a0 (now in a4) */ + slli a3, a3, XCHAL_PS_OWB_SHIFT + xor a2, a2, a3 /* flip changed bits in old window base */ + wsr a2, PS /* update PS.OWB to new window base */ + rsync + + _bbci.l a4, 31, _WindowUnderflow4 + rotw -1 /* original a0 goes to a8 */ + _bbci.l a8, 30, _WindowUnderflow8 + rotw -1 + j _WindowUnderflow12 + + + +/* +-------------------------------------------------------------------------------- +Window Overflow Exception for Call8 + +Invoked if a call[i] referenced a register (a4-a15) +that contains data from ancestor call[j]; +call[j] had done a call8 to call[j+1]. +On entry here: + window rotated to call[j] start point; + a0-a7 are registers to be saved; + a8-a15 must be preserved; + a9 is call[j+1]'s stack pointer. +-------------------------------------------------------------------------------- +*/ + + .org 0x80 + .global _WindowOverflow8 +_WindowOverflow8: + + s32e a0, a9, -16 /* save a0 to call[j+1]'s stack frame */ + l32e a0, a1, -12 /* a0 <- call[j-1]'s sp + (used to find end of call[j]'s frame) */ + s32e a1, a9, -12 /* save a1 to call[j+1]'s stack frame */ + s32e a2, a9, -8 /* save a2 to call[j+1]'s stack frame */ + s32e a3, a9, -4 /* save a3 to call[j+1]'s stack frame */ + s32e a4, a0, -32 /* save a4 to call[j]'s stack frame */ + s32e a5, a0, -28 /* save a5 to call[j]'s stack frame */ + s32e a6, a0, -24 /* save a6 to call[j]'s stack frame */ + s32e a7, a0, -20 /* save a7 to call[j]'s stack frame */ + rfwo /* rotates back to call[i] position */ + +/* +-------------------------------------------------------------------------------- +Window Underflow Exception for Call8 + +Invoked by RETW returning from call[i+1] to call[i] +where call[i]'s registers must be reloaded (not live in ARs); +where call[i] had done a call8 to call[i+1]. +On entry here: + window rotated to call[i] start point; + a0-a7 are undefined, must be reloaded with call[i].reg[0..7]; + a8-a15 must be preserved (they are call[i+1].reg[0..7]); + a9 is call[i+1]'s stack pointer. +-------------------------------------------------------------------------------- +*/ + + .org 0xC0 + .global _WindowUnderflow8 +_WindowUnderflow8: + + l32e a0, a9, -16 /* restore a0 from call[i+1]'s stack frame */ + l32e a1, a9, -12 /* restore a1 from call[i+1]'s stack frame */ + l32e a2, a9, -8 /* restore a2 from call[i+1]'s stack frame */ + l32e a7, a1, -12 /* a7 <- call[i-1]'s sp + (used to find end of call[i]'s frame) */ + l32e a3, a9, -4 /* restore a3 from call[i+1]'s stack frame */ + l32e a4, a7, -32 /* restore a4 from call[i]'s stack frame */ + l32e a5, a7, -28 /* restore a5 from call[i]'s stack frame */ + l32e a6, a7, -24 /* restore a6 from call[i]'s stack frame */ + l32e a7, a7, -20 /* restore a7 from call[i]'s stack frame */ + rfwu + +/* +-------------------------------------------------------------------------------- +Window Overflow Exception for Call12 + +Invoked if a call[i] referenced a register (a4-a15) +that contains data from ancestor call[j]; +call[j] had done a call12 to call[j+1]. +On entry here: + window rotated to call[j] start point; + a0-a11 are registers to be saved; + a12-a15 must be preserved; + a13 is call[j+1]'s stack pointer. +-------------------------------------------------------------------------------- +*/ + + .org 0x100 + .global _WindowOverflow12 +_WindowOverflow12: + + s32e a0, a13, -16 /* save a0 to call[j+1]'s stack frame */ + l32e a0, a1, -12 /* a0 <- call[j-1]'s sp + (used to find end of call[j]'s frame) */ + s32e a1, a13, -12 /* save a1 to call[j+1]'s stack frame */ + s32e a2, a13, -8 /* save a2 to call[j+1]'s stack frame */ + s32e a3, a13, -4 /* save a3 to call[j+1]'s stack frame */ + s32e a4, a0, -48 /* save a4 to end of call[j]'s stack frame */ + s32e a5, a0, -44 /* save a5 to end of call[j]'s stack frame */ + s32e a6, a0, -40 /* save a6 to end of call[j]'s stack frame */ + s32e a7, a0, -36 /* save a7 to end of call[j]'s stack frame */ + s32e a8, a0, -32 /* save a8 to end of call[j]'s stack frame */ + s32e a9, a0, -28 /* save a9 to end of call[j]'s stack frame */ + s32e a10, a0, -24 /* save a10 to end of call[j]'s stack frame */ + s32e a11, a0, -20 /* save a11 to end of call[j]'s stack frame */ + rfwo /* rotates back to call[i] position */ + +/* +-------------------------------------------------------------------------------- +Window Underflow Exception for Call12 + +Invoked by RETW returning from call[i+1] to call[i] +where call[i]'s registers must be reloaded (not live in ARs); +where call[i] had done a call12 to call[i+1]. +On entry here: + window rotated to call[i] start point; + a0-a11 are undefined, must be reloaded with call[i].reg[0..11]; + a12-a15 must be preserved (they are call[i+1].reg[0..3]); + a13 is call[i+1]'s stack pointer. +-------------------------------------------------------------------------------- +*/ + + .org 0x140 + .global _WindowUnderflow12 +_WindowUnderflow12: + + l32e a0, a13, -16 /* restore a0 from call[i+1]'s stack frame */ + l32e a1, a13, -12 /* restore a1 from call[i+1]'s stack frame */ + l32e a2, a13, -8 /* restore a2 from call[i+1]'s stack frame */ + l32e a11, a1, -12 /* a11 <- call[i-1]'s sp + (used to find end of call[i]'s frame) */ + l32e a3, a13, -4 /* restore a3 from call[i+1]'s stack frame */ + l32e a4, a11, -48 /* restore a4 from end of call[i]'s stack frame */ + l32e a5, a11, -44 /* restore a5 from end of call[i]'s stack frame */ + l32e a6, a11, -40 /* restore a6 from end of call[i]'s stack frame */ + l32e a7, a11, -36 /* restore a7 from end of call[i]'s stack frame */ + l32e a8, a11, -32 /* restore a8 from end of call[i]'s stack frame */ + l32e a9, a11, -28 /* restore a9 from end of call[i]'s stack frame */ + l32e a10, a11, -24 /* restore a10 from end of call[i]'s stack frame */ + l32e a11, a11, -20 /* restore a11 from end of call[i]'s stack frame */ + rfwu + + + diff --git a/hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/reset.S b/hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/reset.S new file mode 100644 index 00000000..b2cb2688 --- /dev/null +++ b/hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/reset.S @@ -0,0 +1,460 @@ +/******************************************************************************* +* 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. + +******************************************************************************/ +/****************************************************************************** + reset.S + reset vector for BALONGV7R1 architechure,Any problem pls refer + to the Xtensa Microprocessor Programmer's Guide. +******************************************************************************/ + +#include <xtensa/coreasm.h> +#include <xtensa/simcall.h> +#include "reset.h" + + .begin literal_prefix .ResetVector + .section .ResetVector.text, "ax" + .global _ResetVector + .align 4 + +_ResetVector: + j _Reset + + .end literal_prefix + + /***************************************************************************** + Reset + *****************************************************************************/ + .begin literal_prefix .Reset + .section .Reset.text, "ax" + .global _Reset + .align 4 + +_Reset: + /* clear all of interrupts*/ + movi a0, 0 + wsr a0, INTENABLE + + wsr a0, IBREAKA_0 + wsr a0, IBREAKA_1 + wsr a0, DBREAKA_0 + wsr a0, DBREAKA_1 + wsr a0, DBREAKC_0 + wsr a0, DBREAKC_1 + wsr a0, IBREAKENABLE + + /* ICOUNT,ICOUNTLEVEL,ICOUNTexception clear ICOUNT and ICOUNTLEVEL*/ + wsr a0, ICOUNT + wsr a0, ICOUNTLEVEL + isync + + /*debug disable XCHAL_DEBUGLEVEL*/ + rsil a1, XCHAL_DEBUGLEVEL - 1 + +// write windowbase and windowstart, then do rsync. +// reload a0 with 0, because registers may have moved after +// writing windowbase/windowstart. + wsr a0, CCOUNT + /* init register windows*/ + wsr a0, WINDOWBASE + rsync + movi a1, 1 + wsr a1, WINDOWSTART + + ssai 0 + + /*Level-1 init EXCSAVE_1 level-1 interrupt*/ + wsr a0, EXCSAVE_1 + wsr a0, EPC_1 + wsr a0, EXCCAUSE + + /*Level-2 init EXCSAVE_1 level-2 interrupt*/ + wsr a0, EPC_2 + wsr a0, EPS_2 + wsr a0, EXCSAVE_2 + + /*Level-3 init EXCSAVE_1 level-3 interrupt*/ + wsr a0, EPC_3 + wsr a0, EPS_3 + wsr a0, EXCSAVE_3 + + /*Level-4 init EXCSAVE_1 level-4 interrupt*/ + wsr a0, EPC_4 + wsr a0, EPS_4 + wsr a0, EXCSAVE_4 + + /*Level-5(DEBUG) init EXCSAVE_1 level-5 interrupt*/ + wsr a0, EPC_5 + wsr a0, EPS_5 + wsr a0, EXCSAVE_5 + + /*NMI init EXCSAVE_1 level-6(NMI) interrupt */ + wsr a0, EPC_6 + wsr a0, EPS_6 + wsr a0, EXCSAVE_6 + + + /*0/1/2 init timer 0&1 */ + wsr a0, CCOMPARE_0 + wsr a0, CCOMPARE_1 + //wsr a0, CCOMPARE_2 //hifi3 CCOMPARE_0 CCOMPARE_1 + + /* clear all of */ + movi a2, XCHAL_INTTYPE_MASK_EXTERN_EDGE | XCHAL_INTTYPE_MASK_SOFTWARE + wsr a2, INTCLEAR + + wsr a0, BR + + /* disable coprocessor */ + /*wsr a0, CPENABLE*/ + + movi a2, XCHAL_DEBUGLEVEL - 1 + wsr a2, PS + rsync + + + /*icache init icache */ +#if (XCHAL_ICACHE_SIZE != 0) + #if (XCHAL_ICACHE_SIZE == 8192) //212GP and 330HiFi + movi a2, 64 + #elif (XCHAL_ICACHE_SIZE == 16384) //232L and 570T + movi a2, 128 + #elif (XCHAL_ICACHE_SIZE == 32768) //BALONGV7R1 + movi a2, 256 + #elif (XCHAL_ICACHE_SIZE == 65536) //CHICAGO HIFI + movi a2, 256 + #endif + + /*icache unlock icache */ + #if (XCHAL_ICACHE_LINESIZE == 128) + movi a3, 0 + loop a2, .L0 + iiu a3, 0 + iiu a3, XCHAL_ICACHE_LINESIZE + addi a3, a3, XCHAL_ICACHE_LINESIZE*2 + + iiu a3, 0 + iiu a3, XCHAL_ICACHE_LINESIZE + addi a3, a3, XCHAL_ICACHE_LINESIZE*2 +.L0: + + #else + movi a3, 0 + loop a2, .L0 + iiu a3, 0 + iiu a3, XCHAL_ICACHE_LINESIZE + iiu a3, XCHAL_ICACHE_LINESIZE*2 + iiu a3, XCHAL_ICACHE_LINESIZE*3 + addi a3, a3, XCHAL_ICACHE_LINESIZE*4 +.L0: + #endif + + + #if (XCHAL_ICACHE_SIZE == 8192) //212GP and 330HiFi + movi a2, 64 + #elif (XCHAL_ICACHE_SIZE == 16384) //232L and 570T + movi a2, 128 + #elif (XCHAL_ICACHE_SIZE == 32768) //BALONGV7R1 + movi a2, 256 + #elif (XCHAL_ICACHE_SIZE == 65536) //CHICAGO HIFI + movi a2, 256 + #endif + + /*icache disable icache */ + movi a3, 0 + loop a2, .L1 + iii a3, 0 + iii a3, XCHAL_ICACHE_LINESIZE + iii a3, XCHAL_ICACHE_LINESIZE*2 + iii a3, XCHAL_ICACHE_LINESIZE*3 + addi a3, a3, XCHAL_ICACHE_LINESIZE*4 +.L1: + isync +#endif + + + + + /*dcache init dcache */ +#if (XCHAL_DCACHE_SIZE != 0) + #if (XCHAL_DCACHE_SIZE == 8192) //212GP and 330HiFi + movi a2, 64 + #elif (XCHAL_DCACHE_SIZE == 16384) //232L and 570T + movi a2, 128 + #elif (XCHAL_DCACHE_SIZE == 32768) //BALONGV7R1 + movi a2, 256 + #elif (XCHAL_DCACHE_SIZE == 65536) //CHICAGO HIFI + movi a2, 256 + #endif + + /*dcache unlock dcache */ + #if (XCHAL_DCACHE_LINESIZE == 128) + movi a3, 0 + loop a2, .L2 + diu a3, 0 + diu a3, XCHAL_DCACHE_LINESIZE + addi a3, a3, XCHAL_DCACHE_LINESIZE*2 + + diu a3, 0 + diu a3, XCHAL_DCACHE_LINESIZE + addi a3, a3, XCHAL_DCACHE_LINESIZE*2 +.L2: + + #else + movi a3, 0 + loop a2, .L2 + diu a3, 0 + diu a3, XCHAL_DCACHE_LINESIZE + diu a3, XCHAL_DCACHE_LINESIZE*2 + diu a3, XCHAL_DCACHE_LINESIZE*3 + addi a3, a3, XCHAL_DCACHE_LINESIZE*4 +.L2: + #endif + #if (XCHAL_DCACHE_SIZE == 8192) //212GP and 330HiFi + movi a2, 64 + #elif (XCHAL_DCACHE_SIZE == 16384) //232L and 570T + movi a2, 128 + #elif (XCHAL_DCACHE_SIZE == 32768) //BALONGV7R1 + movi a2, 256 + #elif (XCHAL_DCACHE_SIZE == 65536) //CHICAGO HIFI + movi a2, 256 + #endif + + + /*dcache disable dcache */ + movi a3, 0 + loop a2, .L3 + dii a3, 0 + dii a3, XCHAL_DCACHE_LINESIZE + dii a3, XCHAL_DCACHE_LINESIZE*2 + dii a3, XCHAL_DCACHE_LINESIZE*3 + addi a3, a3, XCHAL_DCACHE_LINESIZE*4 +.L3: + dsync +#endif + + /* + 0x00000000-0x1fffffff : caches off(bypass) + 0x20000000-0x3fffffff : caches off(bypass) + 0x40000000-0x5fffffff : caches off(bypass) + 0x60000000-0x7fffffff : caches off(bypass) + 0x80000000-0x9fffffff : caches off(bypass) + 0xa0000000-0xbfffffff : caches off(bypass) + 0xc0000000-0xdfffffff : caches on,0x00000000-0x1fffffff + 0xe0000000-0xffffffff : caches off(bypass),:0xe0000000~0xefffffff 0x20000000~0x2fffffff + */ + /* config the memory access right */ + movi a3, 0x00000000 /*0x00000000-0x1fffffff*/ + set_access_mode PIF_BYPASS /*can not access*/ + + movi a3, 0x20000000 /*0x20000000-0x3fffffff*/ + set_access_mode PIF_BYPASS + + movi a3, 0x40000000 /*0x40000000-0x5fffffff*/ +#if (XCHAL_DCACHE_LINESIZE == 128) + set_access_mode PIF_BYPASS +#else + set_access_mode PIF_BYPASS +#endif + + movi a3, 0x60000000 /*0x60000000-0x7fffffff*/ + set_access_mode PIF_BYPASS + + movi a3, 0x80000000 /*0x80000000-0x9fffffff*/ + #if (XCHAL_DCACHE_LINESIZE == 128) + set_access_mode PIF_BYPASS + #else + set_access_mode PIF_BYPASS + #endif + + movi a3, 0xa0000000 /*0xa0000000-0xbfffffff*/ + set_access_mode PIF_BYPASS + + movi a3, 0xc0000000 /*0xc0000000-0xdfffffff*/ + set_access_mode PIF_CACHED_WBA /*PIF_CACHED*/ + + movi a3, 0xe0000000 /*0xe0000000-0xffffffff*/ + set_access_mode PIF_BYPASS + + /* 0x40000000 0xe0000000, 0x50000000 0xf0000000,*/ + /*movi a2, 0x40000000 //vpn + movi a3, 0xe0000000 //ppn + movi a5, 0xE0000000 // tlb mask, upper 3 bits + and a4, a3, a5 // upper 3 bits of PPN area + and a7, a2, a5 // upper 3 bits of VPN area + + ritlb1 a5, a7 // get current PPN+AM of segment for I + rdtlb1 a6, a7 // get current PPN+AM of segment for D + extui a5, a5, 0, 4 // keep only AM for I + extui a6, a6, 0, 4 // keep only AM for D + add a2, a4, a5 // combine new PPN with orig AM for I + add a3, a4, a6 // combine new PPN with orig AM for D + witlb a2, a7 // write new tlb mapping for I + wdtlb a3, a7 // write new tlb mapping for D + */ + isync + dsync + + /* + prepare the environment of run C code + */ + movi sp, __stack + + movi a2, PS_WOE_MASK | PS_PROGSTACK_MASK + wsr a2, PS + rsync + + movi a8, _bss_start + movi a10, _bss_end + sub a11, a10, a8 + srli a11, a11, 2 + + movi a9, 0 + loopnez a11, zerodone + s32i a9, a8, 0 + addi a8, a8, 4 +zerodone: + + movi a8, _ulpp_bss_start + movi a10, _ulpp_bss_end + sub a11, a10, a8 + srli a11, a11, 2 + + movi a9, 0 + loopnez a11, zerodone1 + s32i a9, a8, 0 + addi a8, a8, 4 +zerodone1: + +#ifdef HIFI_DTS_V3 + movi a8, _dtsv3_bss_start + movi a10, _dtsv3_bss_end + sub a11, a10, a8 + srli a11, a11, 2 + + movi a9, 0 + loopnez a11, zerodone2 + s32i a9, a8, 0 + addi a8, a8, 4 +zerodone2: +#endif + +#ifdef HIFI_DTS_V4 + movi a8, _dtsv4_bss_start + movi a10, _dtsv4_bss_end + sub a11, a10, a8 + srli a11, a11, 2 + + movi a9, 0 + loopnez a11, zerodone3 + s32i a9, a8, 0 + addi a8, a8, 4 +zerodone3: +#endif + +#ifdef HIFI_VLP + movi a8, _efr_fr_hr_vlpd_bss_start + movi a10, _efr_fr_hr_vlpd_bss_end + sub a11, a10, a8 + srli a11, a11, 2 + + movi a9, 0 + loopnez a11, zerodone4 + s32i a9, a8, 0 + addi a8, a8, 4 +zerodone4: + + movi a8, _amr_vlpd_bss_start + movi a10, _amr_vlpd_bss_end + sub a11, a10, a8 + srli a11, a11, 2 + + movi a9, 0 + loopnez a11, zerodone5 + s32i a9, a8, 0 + addi a8, a8, 4 +zerodone5: + + movi a8, _vlpd_bss_start + movi a10, _vlpd_bss_end + sub a11, a10, a8 + srli a11, a11, 2 + + movi a9, 0 + loopnez a11, zerodone6 + s32i a9, a8, 0 + addi a8, a8, 4 +zerodone6: + + movi a8, _amrwb_vlpd_bss_start + movi a10, _amrwb_vlpd_bss_end + sub a11, a10, a8 + srli a11, a11, 2 + + movi a9, 0 + loopnez a11, zerodone7 + s32i a9, a8, 0 + addi a8, a8, 4 +zerodone7: +#endif + +callmain: + +// Do NOT modify a1 here, it is the stack pointer. +// Use another register instead (a3?) +// Not sure why the NOPs are present. +#movi a1, 0xdeadbeef + movi a1, 0xe8073000 + movi a2, 0xe8075e10 /*HIFI_RESERVE1_LOCATION*/ + s32i a1, a2, 0 + + movi a0, 0 + movi a6, 0 /* clear argc*/ + movi a7, 0 /* clear argv*/ + movi a8, 0 /* clear envp*/ + movi a4, main + nop + nop + callx4 a4 + +reset_exit: + movi a2, SYS_exit +// Where does it go from here ? execution will fall through into +// whatever happens to follow. Either halt here or jump to some +// specific code. + + .end literal_prefix + +#ifdef VOS_VENUS_TEST_STUB + .text + .global sim_call + .type sim_call,@function + .align 4 +sim_call: + entry sp, 64 + addi a4, a3,-3 + movi a3, g_auwVosTestMessageBuf + movi a2, SYS_log_msg + simcall + retw + +#endif + + diff --git a/hifi/xaf/hifi-dpf/ipc/xt-shmem/xf-main.c b/hifi/xaf/hifi-dpf/ipc/xt-shmem/xf-main.c new file mode 100644 index 00000000..dd52bd27 --- /dev/null +++ b/hifi/xaf/hifi-dpf/ipc/xt-shmem/xf-main.c @@ -0,0 +1,189 @@ +/******************************************************************************* +* 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-main.c + * + * DSP processing framework main file + * + ******************************************************************************/ + +#define MODULE_TAG MAIN + +/******************************************************************************* + * Includes + ******************************************************************************/ + +#include "xf.h" +#ifndef XAF_ENABLE_NON_HIKEY +volatile int waitstate; +#endif + +#ifdef XAF_PROFILE_DSP +/* ... MCPS/profile info */ +#include "xa_profiler.h" +#endif + +/******************************************************************************* + * Global data definition + ******************************************************************************/ +/* ...per-core execution data */ +xf_core_data_t xf_core_data[XF_CFG_CORES_NUM]; + +/* ...AP-DSP shared memory pool */ +xf_mm_pool_t xf_ap_shmem_pool; + +/* ...per-core local memory pool */ +xf_mm_pool_t xf_dsp_local_pool[XF_CFG_CORES_NUM]; + +#if XF_CFG_CORES_NUM > 1 +/* ...DSP cluster shared memory pool */ +xf_mm_pool_t xf_dsp_shmem_pool; +#endif + +/* ...per-core shared memory with read-only access */ +__xf_core_ro_data_t xf_core_ro_data[XF_CFG_CORES_NUM]; + +/* ...per-core shared memory with read-write access */ +__xf_core_rw_data_t xf_core_rw_data[XF_CFG_CORES_NUM]; + +/******************************************************************************* + * Memory buffers - take them from linker file somehow - tbd + ******************************************************************************/ + +/* ...unallocated memory region - AP-DSP shared memory buffer - export from linker somehow */ +//u8 xf_ap_shmem_buffer[XF_CFG_REMOTE_IPC_POOL_SIZE] __xf_shmem__; + +#if XF_CFG_CORES_NUM > 1 +/* ...unallocated DSP shared memory buffer */ +u8 xf_dsp_shmem_buffer[XF_CFG_LOCAL_IPC_POOL_SIZE] __xf_shmem__; +#endif + +/* ...unallocated per-core local memory (in 32-byte chunks) */ +#ifdef XAF_ENABLE_NON_HIKEY +u8 xf_dsp_local_buffer[XF_CFG_CORES_NUM][XF_CFG_LOCAL_POOL_SIZE] __xf_mm__; +#else +u8 xf_dsp_local_buffer[XF_CFG_CORES_NUM][XF_CFG_LOCAL_POOL_SIZE]; +//u8 g_tmp[2]; +#endif + +#ifdef XAF_PROFILE_DSP +xa_profiler prof; +#endif + +/******************************************************************************* + * Timer interrupt - tbd + ******************************************************************************/ + +/******************************************************************************* + * IPC layer initialization + ******************************************************************************/ + +/* ...system-specific IPC layer initialization */ +int xf_ipc_init(u32 core) +{ + xf_core_data_t *cd = XF_CORE_DATA(core); + xf_shmem_data_t *shmem = (xf_shmem_data_t *)XF_CFG_SHMEM_ADDRESS(core); + + /* ...initialize pointer to shared memory */ + cd->shmem = (xf_shmem_handle_t *)shmem; + shmem->buffer = (uint8_t *) HIFI_MUSIC_DATA_LOCATION; + /* ...global memory pool initialization */ +#ifdef XAF_ENABLE_NON_HIKEY + XF_CHK_API(xf_mm_init(&cd->shared_pool, shmem->buffer, XF_CFG_REMOTE_IPC_POOL_SIZE)); +#else + XF_CHK_API(xf_mm_init(&cd->shared_pool, (void *) HIFI_MUSIC_DATA_LOCATION, XF_CFG_REMOTE_IPC_POOL_SIZE)); +#endif + return 0; +} + +/******************************************************************************* + * Core executive loop + ******************************************************************************/ + +static void xf_core_loop(u32 core) +{ + /* ...initialize internal core structures */ + xf_core_init(core); + +#ifdef XAF_PROFILE_DSP +/* Profiler initialization */ + INIT_XA_PROFILER(prof,"DSP core"); +#endif + + for(;;) + { + /* ...wait in a low-power mode until event is triggered */ + xf_ipi_wait(core); + + /* ...service core event */ + xf_core_service(core); + } +} + +/******************************************************************************* + * Global entry point + ******************************************************************************/ + +int main(void) +{ +#if XF_CFG_CORES_NUM > 1 + u32 i; +#endif + + /* ...reset ro/rw core data - tbd */ + memset(xf_core_rw_data, 0, sizeof(xf_core_rw_data)); + memset(xf_core_ro_data, 0, sizeof(xf_core_ro_data)); + + TRACE_INIT("Xtensa Audio DSP Codec Server"); +#ifdef XAF_ENABLE_NON_HIKEY + /* ...initialize board */ + xf_board_init(); + + /* ...global framework data initialization */ + xf_global_init(); +#endif + +#if XF_CFG_CORES_NUM > 1 + /* ...DSP shared memory pool initialization */ + XF_CHK_API(xf_mm_init(&xf_dsp_shmem_pool, xf_dsp_shmem_buffer, XF_CFG_LOCAL_IPC_POOL_SIZE)); +#endif + + /* ...initialize per-core memory loop */ + XF_CHK_API(xf_mm_init(&xf_core_data[0].local_pool, xf_dsp_local_buffer[0], XF_CFG_LOCAL_POOL_SIZE)); + +#if XF_CFG_CORES_NUM > 1 + /* ...bring up all cores */ + for (i = 1; i < XF_CFG_CORES_NUM; i++) + { + /* ...wake-up secondary core somehow and make it execute xf_core_loop */ + xf_core_secondary_startup(i, xf_core_loop, i); + + } +#endif + + /* ...enter execution loop on main core #0 */ + xf_core_loop(0); + + /* ...not reachable */ + return 0; +} diff --git a/hifi/xaf/hifi-dpf/plugins/cadence/mixer/xa-mixer.c b/hifi/xaf/hifi-dpf/plugins/cadence/mixer/xa-mixer.c new file mode 100644 index 00000000..2191239b --- /dev/null +++ b/hifi/xaf/hifi-dpf/plugins/cadence/mixer/xa-mixer.c @@ -0,0 +1,669 @@ +/******************************************************************************* +* 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.c + * + * Sample mixer plugin + * + ******************************************************************************/ + +#define MODULE_TAG MIXER + +/******************************************************************************* + * Includes + ******************************************************************************/ + +#include "xf-plugin.h" +#include "audio/xa-mixer-api.h" + +/******************************************************************************* + * Tracing configuration + ******************************************************************************/ + +TRACE_TAG(INIT, 1); +TRACE_TAG(PROCESS, 1); + +/******************************************************************************* + * Internal functions definitions + ******************************************************************************/ + +/* ...API structure */ +typedef struct XAPcmMixer +{ + /* ...mixer state */ + u32 state; + + /* ...number of samples in a frame */ + u32 frame_size; + + /* ...number of channels (channel mask?) */ + u32 channels; + + /* ...PCM sample width */ + u32 pcm_width; + + /* ...sampling rate */ + u32 sample_rate; + + /* ...number of bytes in input/output buffer */ + u32 buffer_size; + + /* ...main volume and individual track volumes*/ + u32 volume[XA_MIXER_MAX_TRACK_NUMBER + 1]; + + /* ...input buffers */ + void *input[XA_MIXER_MAX_TRACK_NUMBER]; + + /* ...number of samples in individual buffers */ + u32 input_length[XA_MIXER_MAX_TRACK_NUMBER]; + + /* ...output buffer */ + void *output; + + /* ...number of produced bytes - do I need that? have buffer-size already - tbd */ + u32 produced; + + /* ...scratch buffer pointer */ + void *scratch; + +} XAPcmMixer; + +/******************************************************************************* + * Mixer state flags + ******************************************************************************/ + +#define XA_MIXER_FLAG_PREINIT_DONE (1 << 0) +#define XA_MIXER_FLAG_POSTINIT_DONE (1 << 1) +#define XA_MIXER_FLAG_RUNNING (1 << 2) +#define XA_MIXER_FLAG_OUTPUT (1 << 3) +#define XA_MIXER_FLAG_COMPLETE (1 << 4) + +/******************************************************************************* + * DSP functions + ******************************************************************************/ + +#define DSP_SATURATE_S16(s32) \ + (s16)((s32) > 0x7fff ? 0x7fff : ((s32) < -0x8000 ? -0x8000 : (s32))) + +/* ...mixer preinitialization (default parameters) */ +static inline void xa_mixer_preinit(XAPcmMixer *d) +{ + u32 i; + + /* ...pre-configuration initialization; reset internal data */ + memset(d, 0, sizeof(*d)); + + /* ...set default parameters */ + d->pcm_width = 16, d->channels = 2, d->frame_size = 512; + + /* ...set default volumes (last index is a main volume)*/ + for (i = 0; i <= XA_MIXER_MAX_TRACK_NUMBER; i++) + { + d->volume[i] = ((1 << 12) << 16) | (1 << 12); + } +} + +/* ...do mixing of stereo PCM-16 streams */ +static XA_ERRORCODE xa_mixer_do_execute_stereo_16bit(XAPcmMixer *d) +{ + s16 *output = d->output; + s16 *b[XA_MIXER_MAX_TRACK_NUMBER]; + u16 v_l[XA_MIXER_MAX_TRACK_NUMBER]; + u16 v_r[XA_MIXER_MAX_TRACK_NUMBER]; + u16 w_l, w_r; + u32 t32; + u32 i, j; + + /* ...retrieve main volume - assume up to 24dB amplifying (4 bits) */ + t32 = d->volume[XA_MIXER_MAX_TRACK_NUMBER]; + w_l = (u16)(t32 & 0xFFFF), w_r = (u16)(t32 >> 16); + + /* ...prepare individual tracks */ + for (j = 0; j < XA_MIXER_MAX_TRACK_NUMBER; j++) + { + u32 n = d->input_length[j]; + + /* ...check if we have input buffer available */ + if (n == 0) + { + /* ...output silence (multiply garbage in the scratch buffer by 0) */ + b[j] = d->scratch; + v_l[j] = v_r[j] = 0; + } + else + { + s32 k = (s32)(d->buffer_size - n); + + /* ...put input buffer */ + XF_CHK_ERR(b[j] = d->input[j], XA_MIXER_EXEC_FATAL_INPUT); + + /* ...if length is not sufficient, pad buffer remainder */ + (k > 0 ? memset((void *)b[j] + n, 0x00, k) : 0); + + /* ...set individual track volume/balance */ + t32 = d->volume[j]; + v_l[j] = (u16)(t32 & 0xFFFF), v_r[j] = (u16)(t32 >> 16); + } + + TRACE(PROCESS, _b("b[%u] = %p%s"), j, b[j], (n == 0 ? " - scratch" : "")); + } + + /* ...process all tracks */ + for (i = 0; i < d->frame_size; i++) + { + s32 l32 = 0, r32 = 0; + + /* ...fill-in every channel in our map (unrolls loop here) */ + for (j = 0; j < XA_MIXER_MAX_TRACK_NUMBER; j++) + { + /* ...left channel processing (no saturation here yet) */ + l32 += *b[j]++ * v_l[j]; + + /* ...right channel processing */ + r32 += *b[j]++ * v_r[j]; + } + + /* ...normalize (truncate towards -inf) and multiply by main volume */ + l32 = ((l32 >> 12) * w_l) >> 12; + r32 = ((r32 >> 12) * w_r) >> 12; + + /* ...saturate and store in buffer */ + *output++ = DSP_SATURATE_S16(l32); + *output++ = DSP_SATURATE_S16(r32); + } + + /* ...save total number of produced bytes */ + d->produced = (u32)((void *)output - d->output); + + /* ...put flag saying we have output buffer */ + d->state |= XA_MIXER_FLAG_OUTPUT; + + TRACE(PROCESS, _b("produced: %u bytes (%u samples)"), d->produced, d->frame_size); + + /* ...reset input buffer length? */ + //memset(d->input_length, 0, sizeof(d->input_length)); + + /* ...return success result code */ + return XA_NO_ERROR; +} + +/* ...runtime reset */ +static XA_ERRORCODE xa_mixer_do_runtime_init(XAPcmMixer *d) +{ + /* ...no special processing is needed here */ + return XA_NO_ERROR; +} + +/******************************************************************************* + * Commands processing + ******************************************************************************/ + +/* ...codec API size query */ +static XA_ERRORCODE xa_mixer_get_api_size(XAPcmMixer *d, WORD32 i_idx, pVOID pv_value) +{ + /* ...check parameters are valid */ + XF_CHK_ERR(pv_value, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...retrieve API structure size */ + *(WORD32 *)pv_value = sizeof(*d); + + return XA_NO_ERROR; +} + +/* ...standard codec initialization routine */ +static XA_ERRORCODE xa_mixer_init(XAPcmMixer *d, WORD32 i_idx, pVOID pv_value) +{ + /* ...validity check - mixer must be valid */ + XF_CHK_ERR(d, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...process particular initialization type */ + switch (i_idx) + { + case XA_CMD_TYPE_INIT_API_PRE_CONFIG_PARAMS: + { + /* ...pre-configuration initialization; reset internal data */ + xa_mixer_preinit(d); + + /* ...and mark mixer has been created */ + d->state = XA_MIXER_FLAG_PREINIT_DONE; + + return XA_NO_ERROR; + } + + case XA_CMD_TYPE_INIT_API_POST_CONFIG_PARAMS: + { + /* ...post-configuration initialization (all parameters are set) */ + XF_CHK_ERR(d->state & XA_MIXER_FLAG_PREINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...calculate input/output buffer size in bytes */ + d->buffer_size = d->channels * d->frame_size * (d->pcm_width == 16 ? sizeof(s16) : sizeof(s32)); + + /* ...mark post-initialization is complete */ + d->state |= XA_MIXER_FLAG_POSTINIT_DONE; + + return XA_NO_ERROR; + } + + case XA_CMD_TYPE_INIT_PROCESS: + { + /* ...kick run-time initialization process; make sure mixer is setup */ + XF_CHK_ERR(d->state & XA_MIXER_FLAG_POSTINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...enter into execution stage */ + d->state |= XA_MIXER_FLAG_RUNNING; + + return XA_NO_ERROR; + } + + case XA_CMD_TYPE_INIT_DONE_QUERY: + { + /* ...check if initialization is done; make sure pointer is valid */ + XF_CHK_ERR(pv_value, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...put current status */ + *(WORD32 *)pv_value = (d->state & XA_MIXER_FLAG_RUNNING ? 1 : 0); + + return XA_NO_ERROR; + } + + default: + /* ...unrecognized command type */ + TRACE(ERROR, _x("Unrecognized command type: %X"), i_idx); + return XA_API_FATAL_INVALID_CMD_TYPE; + } +} + +/* ...set mixer configuration parameter */ +static XA_ERRORCODE xa_mixer_set_config_param(XAPcmMixer *d, WORD32 i_idx, pVOID pv_value) +{ + u32 i_value; + + /* ...validity check - mixer pointer must be valid */ + XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...pre-initialization must be completed, mixer must be idle */ + XF_CHK_ERR(d->state & XA_MIXER_FLAG_PREINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...get parameter value */ + i_value = (u32) *(WORD32 *)pv_value; + + /* ...process individual configuration parameter */ + switch (i_idx) + { + case XA_MIXER_CONFIG_PARAM_PCM_WIDTH: + /* ...check value is permitted (16 bits only) */ + XF_CHK_ERR(i_value == 16, XA_MIXER_CONFIG_NONFATAL_RANGE); + d->pcm_width = (u32)i_value; + return XA_NO_ERROR; + + case XA_MIXER_CONFIG_PARAM_CHANNELS: + /* ...allow stereo only */ + XF_CHK_ERR(i_value == 2, XA_MIXER_CONFIG_NONFATAL_RANGE); + d->channels = (u32)i_value; + return XA_NO_ERROR; + + case XA_MIXER_CONFIG_PARAM_SAMPLE_RATE: + /* ...set mixer sample rate */ + d->sample_rate = (u32)i_value; + return XA_NO_ERROR; + + default: + TRACE(ERROR, _x("Invalid parameter: %X"), i_idx); + return XA_API_FATAL_INVALID_CMD_TYPE; + } +} + +/* ...retrieve configuration parameter */ +static XA_ERRORCODE xa_mixer_get_config_param(XAPcmMixer *d, WORD32 i_idx, pVOID pv_value) +{ + /* ...validity check - mixer must be initialized */ + XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...make sure pre-initialization is completed */ + XF_CHK_ERR(d->state & XA_MIXER_FLAG_PREINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...process individual configuration parameter */ + switch (i_idx) + { + case XA_MIXER_CONFIG_PARAM_INPUT_TRACKS: + /* ...return maximal number of input tracks supported */ + *(WORD32 *)pv_value = XA_MIXER_MAX_TRACK_NUMBER; + return XA_NO_ERROR; + + case XA_MIXER_CONFIG_PARAM_SAMPLE_RATE: + /* ...return mixer sample rate */ + *(WORD32 *)pv_value = d->sample_rate; + return XA_NO_ERROR; + + case XA_MIXER_CONFIG_PARAM_PCM_WIDTH: + /* ...return current PCM width */ + *(WORD32 *)pv_value = d->pcm_width; + return XA_NO_ERROR; + + case XA_MIXER_CONFIG_PARAM_CHANNELS: + /* ...return current channel number */ + *(WORD32 *)pv_value = d->channels; + return XA_NO_ERROR; + + case XA_MIXER_CONFIG_PARAM_FRAME_SIZE: + /* ...return current in/out frame length (in samples) */ + *(WORD32 *)pv_value = d->frame_size; + return XA_NO_ERROR; + + case XA_MIXER_CONFIG_PARAM_BUFFER_SIZE: + /* ...return current in/out frame length (in bytes) */ + *(WORD32 *)pv_value = d->buffer_size; + return XA_NO_ERROR; + + default: + TRACE(ERROR, _x("Invalid parameter: %X"), i_idx); + return XA_API_FATAL_INVALID_CMD_TYPE; + } +} + +/* ...execution command */ +static XA_ERRORCODE xa_mixer_execute(XAPcmMixer *d, WORD32 i_idx, pVOID pv_value) +{ + /* ...validity check - mixer must be valid */ + XF_CHK_ERR(d, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...mixer must be in running state */ + XF_CHK_ERR(d->state & XA_MIXER_FLAG_RUNNING, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...process individual command type */ + switch (i_idx) + { + case XA_CMD_TYPE_DO_EXECUTE: + /* ...perform mixing of the channels */ + return xa_mixer_do_execute_stereo_16bit(d); + + case XA_CMD_TYPE_DONE_QUERY: + /* ...check if processing is complete */ + XF_CHK_ERR(pv_value, XA_API_FATAL_INVALID_CMD_TYPE); + *(WORD32 *)pv_value = (d->state & XA_MIXER_FLAG_COMPLETE ? 1 : 0); + return XA_NO_ERROR; + + case XA_CMD_TYPE_DO_RUNTIME_INIT: + /* ...reset mixer operation */ + return xa_mixer_do_runtime_init(d); + + default: + /* ...unrecognized command */ + TRACE(ERROR, _x("Invalid index: %X"), i_idx); + return XA_API_FATAL_INVALID_CMD_TYPE; + } +} + +/* ...set number of input bytes */ +static XA_ERRORCODE xa_mixer_set_input_bytes(XAPcmMixer *d, WORD32 i_idx, pVOID pv_value) +{ + u32 size; + + /* ...validity check - check parameters */ + XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...track index must be valid */ + XF_CHK_ERR(i_idx >= 0 && i_idx < XA_MIXER_MAX_TRACK_NUMBER, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...mixer must be initialized */ + XF_CHK_ERR(d->state & XA_MIXER_FLAG_POSTINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...input buffer must exist */ + XF_CHK_ERR(d->input[i_idx], XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...input frame length should not be zero (in bytes) */ + XF_CHK_ERR((size = (u32)*(WORD32 *)pv_value) > 0, XA_MIXER_EXEC_NONFATAL_INPUT); + + /* ...all is correct; set input buffer length in bytes */ + d->input_length[i_idx] = size; + + return XA_NO_ERROR; +} + +/* ...get number of output bytes */ +static XA_ERRORCODE xa_mixer_get_output_bytes(XAPcmMixer *d, WORD32 i_idx, pVOID pv_value) +{ + /* ...validity check - check parameters */ + XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...track index must be zero */ + XF_CHK_ERR(i_idx == XA_MIXER_MAX_TRACK_NUMBER, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...mixer must be running */ + XF_CHK_ERR(d->state & XA_MIXER_FLAG_RUNNING, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...output buffer must exist */ + XF_CHK_ERR(d->output, XA_MIXER_EXEC_NONFATAL_OUTPUT); + + /* ...return number of produced bytes */ + *(WORD32 *)pv_value = (d->state & XA_MIXER_FLAG_OUTPUT ? d->buffer_size : 0); + + return XA_NO_ERROR; +} + +/* ...get number of consumed bytes */ +static XA_ERRORCODE xa_mixer_get_curidx_input_buf(XAPcmMixer *d, WORD32 i_idx, pVOID pv_value) +{ + /* ...validity check - check parameters */ + XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...track index must be valid */ + XF_CHK_ERR(i_idx >= 0 && i_idx < XA_MIXER_MAX_TRACK_NUMBER, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...mixer must be running */ + XF_CHK_ERR(d->state & XA_MIXER_FLAG_RUNNING, XA_MIXER_EXEC_FATAL_STATE); + + /* ...input buffer must exist */ + XF_CHK_ERR(d->input[i_idx], XA_MIXER_EXEC_FATAL_INPUT); + + /* ...return number of bytes consumed (always consume fixed-length chunk) */ + *(WORD32 *)pv_value = d->input_length[i_idx], d->input_length[i_idx] = 0; + + return XA_NO_ERROR; +} + +/******************************************************************************* + * Memory information API + ******************************************************************************/ + +/* ..get total amount of data for memory tables */ +static XA_ERRORCODE xa_mixer_get_memtabs_size(XAPcmMixer *d, WORD32 i_idx, pVOID pv_value) +{ + /* ...basic validity checks */ + XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...check mixer is pre-initialized */ + XF_CHK_ERR(d->state & XA_MIXER_FLAG_PREINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...we have all our tables inside API structure - good? tbd */ + *(WORD32 *)pv_value = 0; + + return XA_NO_ERROR; +} + +/* ..set memory tables pointer */ +static XA_ERRORCODE xa_mixer_set_memtabs_ptr(XAPcmMixer *d, WORD32 i_idx, pVOID pv_value) +{ + /* ...basic validity checks */ + XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...check mixer is pre-initialized */ + XF_CHK_ERR(d->state & XA_MIXER_FLAG_PREINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...do not do anything; just return success - tbd */ + return XA_NO_ERROR; +} + +/* ...return total amount of memory buffers */ +static XA_ERRORCODE xa_mixer_get_n_memtabs(XAPcmMixer *d, WORD32 i_idx, pVOID pv_value) +{ + /* ...basic validity checks */ + XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...we have N input buffers, 1 output buffer and 1 scratch buffer */ + *(WORD32 *)pv_value = XA_MIXER_MAX_TRACK_NUMBER + 1 + 1; + + return XA_NO_ERROR; +} + +/* ...return memory buffer data */ +static XA_ERRORCODE xa_mixer_get_mem_info_size(XAPcmMixer *d, WORD32 i_idx, pVOID pv_value) +{ + /* ...basic validity check */ + XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...return frame buffer minimal size only after post-initialization is done */ + XF_CHK_ERR(d->state & XA_MIXER_FLAG_POSTINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...all buffers are of the same length */ + *(WORD32 *)pv_value = (WORD32) d->buffer_size; + + return XA_NO_ERROR; +} + +/* ...return memory alignment data */ +static XA_ERRORCODE xa_mixer_get_mem_info_alignment(XAPcmMixer *d, WORD32 i_idx, pVOID pv_value) +{ + /* ...basic validity check */ + XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...return frame buffer minimal size only after post-initialization is done */ + XF_CHK_ERR(d->state & XA_MIXER_FLAG_POSTINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...all buffers are 4-bytes aligned */ + *(WORD32 *)pv_value = 4; + + return XA_NO_ERROR; +} + +/* ...return memory type data */ +static XA_ERRORCODE xa_mixer_get_mem_info_type(XAPcmMixer *d, WORD32 i_idx, pVOID pv_value) +{ + /* ...basic validity check */ + XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...return frame buffer minimal size only after post-initialization is done */ + XF_CHK_ERR(d->state & XA_MIXER_FLAG_POSTINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE); + + switch (i_idx) + { + case 0 ... XA_MIXER_MAX_TRACK_NUMBER - 1: + /* ...input buffers */ + *(WORD32 *)pv_value = XA_MEMTYPE_INPUT; + return XA_NO_ERROR; + + case XA_MIXER_MAX_TRACK_NUMBER: + /* ...output buffer */ + *(WORD32 *)pv_value = XA_MEMTYPE_OUTPUT; + return XA_NO_ERROR; + + case XA_MIXER_MAX_TRACK_NUMBER + 1: + /* ...scratch buffer */ + *(WORD32 *)pv_value = XA_MEMTYPE_SCRATCH; + return XA_NO_ERROR; + + default: + /* ...invalid index */ + return XF_CHK_ERR(0, XA_API_FATAL_INVALID_CMD_TYPE); + } +} + +/* ...set memory pointer */ +static XA_ERRORCODE xa_mixer_set_mem_ptr(XAPcmMixer *d, WORD32 i_idx, pVOID pv_value) +{ + /* ...basic validity check */ + XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...codec must be initialized */ + XF_CHK_ERR(d->state & XA_MIXER_FLAG_POSTINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...select memory buffer */ + switch (i_idx) + { + case 0 ... XA_MIXER_MAX_TRACK_NUMBER - 1: + /* ...input buffers */ + d->input[i_idx] = pv_value; + return XA_NO_ERROR; + + case XA_MIXER_MAX_TRACK_NUMBER: + /* ...output buffer */ + d->output = pv_value; + return XA_NO_ERROR; + + case XA_MIXER_MAX_TRACK_NUMBER + 1: + /* ...scratch buffer */ + d->scratch = pv_value; + return XA_NO_ERROR; + + default: + /* ...invalid index */ + return XF_CHK_ERR(0, XA_API_FATAL_INVALID_CMD_TYPE); + } +} + +/******************************************************************************* + * API command hooks + ******************************************************************************/ + +static XA_ERRORCODE (* const xa_mixer_api[])(XAPcmMixer *, WORD32, pVOID) = +{ + [XA_API_CMD_GET_API_SIZE] = xa_mixer_get_api_size, + + [XA_API_CMD_INIT] = xa_mixer_init, + [XA_API_CMD_SET_CONFIG_PARAM] = xa_mixer_set_config_param, + [XA_API_CMD_GET_CONFIG_PARAM] = xa_mixer_get_config_param, + + [XA_API_CMD_EXECUTE] = xa_mixer_execute, + [XA_API_CMD_SET_INPUT_BYTES] = xa_mixer_set_input_bytes, + [XA_API_CMD_GET_OUTPUT_BYTES] = xa_mixer_get_output_bytes, + [XA_API_CMD_GET_CURIDX_INPUT_BUF] = xa_mixer_get_curidx_input_buf, + + [XA_API_CMD_GET_MEMTABS_SIZE] = xa_mixer_get_memtabs_size, + [XA_API_CMD_SET_MEMTABS_PTR] = xa_mixer_set_memtabs_ptr, + [XA_API_CMD_GET_N_MEMTABS] = xa_mixer_get_n_memtabs, + [XA_API_CMD_GET_MEM_INFO_SIZE] = xa_mixer_get_mem_info_size, + [XA_API_CMD_GET_MEM_INFO_ALIGNMENT] = xa_mixer_get_mem_info_alignment, + [XA_API_CMD_GET_MEM_INFO_TYPE] = xa_mixer_get_mem_info_type, + [XA_API_CMD_SET_MEM_PTR] = xa_mixer_set_mem_ptr, +}; + +/* ...total numer of commands supported */ +#define XA_MIXER_API_COMMANDS_NUM (sizeof(xa_mixer_api) / sizeof(xa_mixer_api[0])) + +/******************************************************************************* + * API entry point + ******************************************************************************/ + +XA_ERRORCODE xa_mixer(xa_codec_handle_t p_xa_module_obj, WORD32 i_cmd, WORD32 i_idx, pVOID pv_value) +{ + XAPcmMixer *d = (XAPcmMixer *) p_xa_module_obj; + + /* ...check if command index is valid */ + XF_CHK_ERR(i_cmd < XA_MIXER_API_COMMANDS_NUM, XA_API_FATAL_INVALID_CMD); + + /* ...see if command is defined */ + XF_CHK_ERR(xa_mixer_api[i_cmd], XA_API_FATAL_INVALID_CMD); + + /* ...execute requested command */ + return xa_mixer_api[i_cmd](d, i_idx, pv_value); +} diff --git a/hifi/xaf/hifi-dpf/plugins/cadence/pcm_proc/xa-pcm-api.h b/hifi/xaf/hifi-dpf/plugins/cadence/pcm_proc/xa-pcm-api.h new file mode 100644 index 00000000..cb14dad0 --- /dev/null +++ b/hifi/xaf/hifi-dpf/plugins/cadence/pcm_proc/xa-pcm-api.h @@ -0,0 +1,145 @@ +/******************************************************************************* +* 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-pcm-api.h + * + * Generic PCM format converter API + * + ******************************************************************************/ + +#ifndef __XA_PCM_API_H__ +#define __XA_PCM_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 + ******************************************************************************/ + +/* ...codec-specific configuration parameters */ +enum xa_config_param_pcm { + XA_PCM_CONFIG_PARAM_SAMPLE_RATE = 0, + XA_PCM_CONFIG_PARAM_IN_PCM_WIDTH = 1, + XA_PCM_CONFIG_PARAM_IN_CHANNELS = 2, + XA_PCM_CONFIG_PARAM_OUT_PCM_WIDTH = 3, + XA_PCM_CONFIG_PARAM_OUT_CHANNELS = 4, + XA_PCM_CONFIG_PARAM_CHANROUTING = 5, + XA_PCM_CONFIG_PARAM_NUM = 6, +}; + +/* ...component identifier (informative) */ +#define XA_CODEC_PCM 16 + +/******************************************************************************* + * Class 0: API Errors + ******************************************************************************/ + +#define XA_PCM_API_NONFATAL(e) \ + XA_ERROR_CODE(xa_severity_nonfatal, xa_class_api, XA_CODEC_PCM, (e)) + +#define XA_PCM_API_FATAL(e) \ + XA_ERROR_CODE(xa_severity_fatal, xa_class_api, XA_CODEC_PCM, (e)) + +enum xa_error_nonfatal_api_pcm { + XA_PCM_API_NONFATAL_MAX = XA_PCM_API_NONFATAL(0) +}; + +enum xa_error_fatal_api_pcm { + XA_PCM_API_FATAL_MAX = XA_PCM_API_FATAL(0) +}; + +/******************************************************************************* + * Class 1: Configuration Errors + ******************************************************************************/ + +#define XA_PCM_CONFIG_NONFATAL(e) \ + XA_ERROR_CODE(xa_severity_nonfatal, xa_class_config, XA_CODEC_PCM, (e)) + +#define XA_PCM_CONFIG_FATAL(e) \ + XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_PCM, (e)) + +enum xa_error_nonfatal_config_pcm { + XA_PCM_CONFIG_NONFATAL_RANGE = XA_PCM_CONFIG_NONFATAL(0), + XA_PCM_CONFIG_NONFATAL_STATE = XA_PCM_CONFIG_NONFATAL(1), + XA_PCM_CONFIG_NONFATAL_MAX = XA_PCM_CONFIG_NONFATAL(2) +}; + +enum xa_error_fatal_config_pcm { + XA_PCM_CONFIG_FATAL_RANGE = XA_PCM_CONFIG_FATAL(0), + XA_PCM_CONFIG_FATAL_MAX = XA_PCM_CONFIG_FATAL(1) +}; + +/******************************************************************************* + * Class 2: Execution Class Errors + ******************************************************************************/ + +#define XA_PCM_EXEC_NONFATAL(e) \ + XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_PCM, (e)) + +#define XA_PCM_EXEC_FATAL(e) \ + XA_ERROR_CODE(xa_severity_fatal, xa_class_execute, XA_CODEC_PCM, (e)) + +enum xa_error_nonfatal_execute_pcm { + XA_PCM_EXEC_NONFATAL_STATE = XA_PCM_EXEC_NONFATAL(0), + XA_PCM_EXEC_NONFATAL_NO_DATA = XA_PCM_EXEC_NONFATAL(1), + XA_PCM_EXEC_NONFATAL_INPUT = XA_PCM_EXEC_NONFATAL(2), + XA_PCM_EXEC_NONFATAL_OUTPUT = XA_PCM_EXEC_NONFATAL(3), + XA_PCM_EXEC_NONFATAL_MAX = XA_PCM_EXEC_NONFATAL(4) +}; + +enum xa_error_fatal_execute_pcm { + XA_PCM_EXEC_FATAL_STATE = XA_PCM_EXEC_FATAL(0), + XA_PCM_EXEC_FATAL_INPUT = XA_PCM_EXEC_FATAL(1), + XA_PCM_EXEC_FATAL_OUTPUT = XA_PCM_EXEC_FATAL(2), + XA_PCM_EXEC_FATAL_MAX = XA_PCM_EXEC_FATAL(3) +}; + +/******************************************************************************* + * API function definition + ******************************************************************************/ + +#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_pcm_codec; +#if defined(__cplusplus) +} +#endif /* __cplusplus */ + +#endif /* __XA_PCM_API_H__ */ + diff --git a/hifi/xaf/hifi-dpf/plugins/cadence/pcm_proc/xa-pcm.c b/hifi/xaf/hifi-dpf/plugins/cadence/pcm_proc/xa-pcm.c new file mode 100644 index 00000000..cca97ef9 --- /dev/null +++ b/hifi/xaf/hifi-dpf/plugins/cadence/pcm_proc/xa-pcm.c @@ -0,0 +1,841 @@ +/******************************************************************************* +* 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-pcm.c + * + * PCM format converter plugin + * + ******************************************************************************/ + +#define MODULE_TAG PCM + +/******************************************************************************* + * Includes + ******************************************************************************/ + +#include "xf-plugin.h" +#include "xa-audio-decoder-api.h" +#include "xa-pcm-api.h" + +#include <fcntl.h> + +/******************************************************************************* + * Tracing configuration + ******************************************************************************/ + +TRACE_TAG(INIT, 1); +TRACE_TAG(PROCESS, 0); + +/******************************************************************************* + * Local typedefs + ******************************************************************************/ + +/* ...API structure */ +typedef struct XAPcmCodec +{ + /* ...codec state */ + u32 state; + + /* ...sampling rate of input/output signal (informative only) */ + u32 sample_rate; + + /* ...number of input/output channels */ + u8 in_channels, out_channels; + + /* ...PCM sample width of input/output streams */ + u8 in_pcm_width, out_pcm_width; + + /* ...input/output stride size */ + u8 in_stride, out_stride; + + /* ...channel routing map between input and output */ + u32 chan_routing; + + /* ...data processing hook */ + XA_ERRORCODE (*process)(struct XAPcmCodec *); + + /* ...number of samples in input/output buffers */ + u32 insize, outsize; + + /* ...input/output memory indices */ + u32 input_idx, output_idx; + + /* ...input/output buffers passed from/to caller */ + void *input, *output; + + /* ...number of input bytes consumed/produced */ + u32 consumed, produced; + + /* ...debug - file handles */ + int f_input, f_output; + +} XAPcmCodec; + +/******************************************************************************* + * Local execution flags + ******************************************************************************/ + +#define XA_PCM_FLAG_PREINIT_DONE (1 << 0) +#define XA_PCM_FLAG_POSTINIT_DONE (1 << 1) +#define XA_PCM_FLAG_RUNNING (1 << 2) +#define XA_PCM_FLAG_EOS (1 << 3) +#define XA_PCM_FLAG_COMPLETE (1 << 4) + +/******************************************************************************* + * Local constants definitions + ******************************************************************************/ + +/* ...process at most 1024 samples per call */ +#define XA_PCM_MAX_SAMPLES 1024 + +/******************************************************************************* + * Internal processing functions + ******************************************************************************/ + +/* ...identity translation of PCM16/24 */ +static XA_ERRORCODE xa_pcm_do_execute_copy(XAPcmCodec *d) +{ + u32 n = d->insize; + u8 k = d->in_channels; + u32 length = n * k * (d->in_pcm_width == 16 ? 2 : 4); + s16 *input = d->input, *output = d->output; + + TRACE(PROCESS, _b("Copy PCM%d %p to %p (%u samples)"), d->in_pcm_width, input, output, n); + + /* ...check if we have all data setup */ + XF_CHK_ERR(input && n && output, XA_PCM_EXEC_FATAL_STATE); + + /* ...copy the samples without any processing */ + memcpy(output, input, length); + + /* ...set number of consumed/produced bytes */ + d->consumed = length; + d->produced = length; + + /* ...reset input buffer length */ + d->insize = 0; + + /* ...copy input to output */ + return XA_NO_ERROR; +} + +/* ...data processing for PCM16, channel mapping case */ +static XA_ERRORCODE xa_pcm_do_execute_pcm16_chmap(XAPcmCodec *d) +{ + u32 n = d->insize, i; + u8 k = d->in_channels, j; + u32 chmap = d->chan_routing, map; + s16 *input = d->input, *output = d->output; + u32 length = n * k * (d->in_pcm_width == 16 ? 2 : 4); + + TRACE(PROCESS, _b("Map PCM16 %p to %p (%u samples, map: %X)"), input, output, n, chmap); + + /* ...check if we have all data setup */ + XF_CHK_ERR(input && n && output, XA_PCM_EXEC_FATAL_STATE); + +#if 0 + /* ...convert individual samples (that function could be CPU-optimized - tbd) */ + for (i = 0; i < n; i++, input += k) + { + /* ...process individual channels in a sample */ + for (j = 0, map = chmap; j < k; j++, map >>= 4) + { + u8 m = map & 0xF; + + /* ...fill output channel (zero unused channel) */ + *output++ = (m < 8 ? input[m] : 0); + } + } + + /* ...set number of consumed/produced bytes */ + d->consumed = (u32)((u8 *)input - (u8 *)d->input); + d->produced = (u32)((u8 *)output - (u8 *)d->output); +#else + memcpy(output, input, length); + /* ...set number of consumed/produced bytes */ + d->consumed = length; + d->produced = length; +#endif + /* ...reset input buffer length */ + d->insize = 0; + + /* ...copy input to output */ + return XA_NO_ERROR; +} + +/* ...data processing for PCM24/PCM32, channel mapping case */ +static XA_ERRORCODE xa_pcm_do_execute_pcm24_chmap(XAPcmCodec *d) +{ + u32 n = d->insize, i; + u8 k = d->in_channels, j; + u32 chmap = d->chan_routing, map; + s32 *input = d->input, *output = d->output; + + TRACE(PROCESS, _b("Map PCM24 %p to %p (%u samples, map: %X)"), input, output, n, chmap); + + /* ...check if we have all data setup */ + XF_CHK_ERR(input && n && output, XA_PCM_EXEC_FATAL_STATE); + + /* ...convert individual samples (that function could be CPU-optimized - tbd) */ + for (i = 0; i < n; i++, input += k) + { + /* ...process individual channels in a sample */ + for (j = 0, map = chmap; j < k; j++, map >>= 4) + { + u8 m = map & 0xF; + + /* ...fill output channel (zero unused channel) */ + *output++ = (m < 8 ? input[m] : 0); + } + } + + /* ...set number of consumed/produced bytes */ + d->consumed = (u32)((u8 *)input - (u8 *)d->input); + d->produced = (u32)((u8 *)output - (u8 *)d->output); + + /* ...reset input buffer length */ + d->insize = 0; + + /* ...copy input to output */ + return XA_NO_ERROR; +} + +/* ...convert multichannel 24-bit PCM to 16-bit PCM with channel mapping */ +static XA_ERRORCODE xa_pcm_do_execute_pcm24_to_pcm16(XAPcmCodec *d) +{ + u32 n = d->insize, i; + u8 k = d->in_channels, j; + u32 chmap = d->chan_routing, map; + s32 *input = d->input; + s16 *output = d->output; + + TRACE(PROCESS, _b("Convert PCM24 %p to PCM16 %p (%u samples, map: %X)"), input, output, n, chmap); + + /* ...check if we have all data setup */ + XF_CHK_ERR(input && n && output, XA_PCM_EXEC_FATAL_STATE); + + /* ...convert individual samples (that function could be CPU-optimized - tbd) */ + for (i = 0; i < n; i++, input += k) + { + /* ...process individual channels in a sample */ + for (j = 0, map = chmap; j < k; j++, map >>= 4) + { + u8 m = map & 0xF; + + /* ...convert and zero out unused channels */ + *output++ = (m < 8 ? input[m] >> 16 : 0); + } + } + + /* ...set number of consumed/produced bytes */ + d->consumed = (u32)((u8 *)input - (u8 *)d->input); + d->produced = (u32)((u8 *)output - (u8 *)d->output); + + /* ...dump output data */ + //BUG(write(d->f_input, d->input, d->consumed) != d->consumed, _x("%m")); + //BUG(write(d->f_output, d->output, d->produced) != d->produced, _x("%m")); + + /* ...reset input buffer length (tbd - need that?) */ + d->insize = 0; + + /* ...copy input to output */ + return XA_NO_ERROR; +} + +/* ...convert multichannel 16-bit PCM to 24-bit PCM with channel mapping */ +static XA_ERRORCODE xa_pcm_do_execute_pcm16_to_pcm24(XAPcmCodec *d) +{ + u32 n = d->insize, i; + u8 k = d->in_channels, j; + u32 chmap = d->chan_routing, map; + s16 *input = d->input; + s32 *output = d->output; + + TRACE(PROCESS, _b("Convert PCM16 %p to PCM24 %p (%u samples, map: %X)"), input, output, n, chmap); + + /* ...check if we have all data setup */ + XF_CHK_ERR(input && n && output, XA_PCM_EXEC_FATAL_STATE); + + /* ...convert individual samples (that function could be CPU-optimized - tbd) */ + for (i = 0; i < n; i++, input += k) + { + /* ...process individual channels in a sample */ + for (j = 0, map = chmap; j < k; j++, map >>= 4) + { + u8 m = map & 0xF; + + /* ...convert and zero out unused channels */ + *output++ = (m < 8 ? input[m] << 16 : 0); + } + } + + /* ...set number of consumed/produced bytes */ + d->consumed = (u32)((u8 *)input - (u8 *)d->input); + d->produced = (u32)((u8 *)output - (u8 *)d->output); + + /* ...reset input buffer length (tbd - need that?) */ + d->insize = 0; + + /* ...copy input to output */ + return XA_NO_ERROR; +} + +/* ...determine if we need to do a channel routing */ +static inline int xa_pcm_is_identity_mapping(u32 chmap, u8 k) +{ + u8 j; + + for (j = 0; j < k; j++, chmap >>= 4) + if ((chmap & 0xF) != j) + return 0; + + return 1; +} + +/* ...runtime initialization */ +static inline XA_ERRORCODE xa_pcm_do_runtime_init(XAPcmCodec *d) +{ + u8 in_width = d->in_pcm_width, out_width = d->out_pcm_width; + u8 in_ch = d->in_channels, out_ch = d->out_channels; + u32 chmap = d->chan_routing; + + /* ...check for supported processing schemes */ + if (in_width == out_width) + { + /* ...check if we need to do a channel mapping */ + if (in_ch != out_ch || !xa_pcm_is_identity_mapping(chmap, in_ch)) + { + /* ...mapping is needed */ + d->process = (in_width == 16 ? xa_pcm_do_execute_pcm16_chmap : xa_pcm_do_execute_pcm24_chmap); + } + else + { + /* ...setup identity translation */ + d->process = xa_pcm_do_execute_copy; + } + } + else + { + /* ...samples converion is required */ + d->process = (in_width == 16 ? xa_pcm_do_execute_pcm16_to_pcm24 : xa_pcm_do_execute_pcm24_to_pcm16); + } + + /* ...mark the runtime initialization is completed */ + d->state = XA_PCM_FLAG_PREINIT_DONE | XA_PCM_FLAG_POSTINIT_DONE | XA_PCM_FLAG_RUNNING; + + TRACE(INIT, _b("PCM format converter initialized: PCM%u -> PCM%u, ich=%u, och=%u, map=%X"), in_width, out_width, in_ch, out_ch, chmap); + + return XA_NO_ERROR; +} + +/******************************************************************************* + * Commands processing + ******************************************************************************/ + +/* ...standard codec initialization routine */ +static XA_ERRORCODE xa_pcm_get_api_size(XAPcmCodec *d, WORD32 i_idx, pVOID pv_value) +{ + /* ...return API structure size */ + *(WORD32 *)pv_value = sizeof(*d); + + return XA_NO_ERROR; +} + +/* ...standard codec initialization routine */ +static XA_ERRORCODE xa_pcm_init(XAPcmCodec *d, WORD32 i_idx, pVOID pv_value) +{ + /* ...validity check */ + XF_CHK_ERR(d, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...process particular initialization type */ + switch (i_idx) + { + case XA_CMD_TYPE_INIT_API_PRE_CONFIG_PARAMS: + { + /* ...pre-configuration initialization; reset internal data */ + memset(d, 0, sizeof(*d)); + + /* ...set default parameters */ + d->in_pcm_width = d->out_pcm_width = 16; + d->in_channels = d->out_channels = 2; + d->chan_routing = (0 << 0) | (1 << 1); + d->sample_rate = 48000; + + /* ...open debug files */ + //BUG((d->f_input = open("pcm-in.dat", O_WRONLY | O_CREAT, 0664)) < 0, _x("%m")); + //BUG((d->f_output = open("pcm-out.dat", O_WRONLY | O_CREAT, 0664)) < 0, _x("%m")); + + /* ...mark pre-initialization is done */ + d->state = XA_PCM_FLAG_PREINIT_DONE; + + return XA_NO_ERROR; + } + + case XA_CMD_TYPE_INIT_API_POST_CONFIG_PARAMS: + { + /* ...post-configuration initialization (all parameters are set) */ + XF_CHK_ERR(d->state & XA_PCM_FLAG_PREINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...calculate input sample stride size */ + d->in_stride = d->in_channels * (d->in_pcm_width == 16 ? 2 : 4); + d->out_stride = d->out_channels * (d->out_pcm_width == 16 ? 2 : 4); + + /* ...mark post-initialization is complete */ + d->state |= XA_PCM_FLAG_POSTINIT_DONE; + + return XA_NO_ERROR; + } + + case XA_CMD_TYPE_INIT_PROCESS: + { + /* ...run-time initialization process; make sure post-init is complete */ + XF_CHK_ERR(d->state & XA_PCM_FLAG_POSTINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...initialize runtime for specified transformation function */ + return xa_pcm_do_runtime_init(d); + } + + case XA_CMD_TYPE_INIT_DONE_QUERY: + { + /* ...check for runtime initialization completion; maske usre post-init is complete */ + XF_CHK_ERR(d->state & XA_PCM_FLAG_POSTINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...put current status */ + *(WORD32 *)pv_value = (d->state & XA_PCM_FLAG_RUNNING ? 1 : 0); + + return XA_NO_ERROR; + } + + default: + /* ...unrecognized command */ + return XF_CHK_ERR(0, XA_API_FATAL_INVALID_CMD_TYPE); + } +} + +/* ...set configuration parameter */ +static XA_ERRORCODE xa_pcm_set_config_param(XAPcmCodec *d, WORD32 i_idx, pVOID pv_value) +{ + WORD32 i_value; + + /* ...validity check */ + XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...configuration is allowed only in PRE-CONFIG state */ + XF_CHK_ERR(d->state == XA_PCM_FLAG_PREINIT_DONE, XA_PCM_CONFIG_NONFATAL_STATE); + + /* ...get integer parameter value */ + i_value = *(WORD32 *)pv_value; + + /* ...process individual configuration parameter */ + switch (i_idx) + { + case XA_CODEC_CONFIG_PARAM_SAMPLE_RATE: + case XA_PCM_CONFIG_PARAM_SAMPLE_RATE: + /* ...accept any sampling rate */ + d->sample_rate = (u32)i_value; + return XA_NO_ERROR; + + case XA_PCM_CONFIG_PARAM_IN_PCM_WIDTH: + /* ...return input sample bit-width */ + XF_CHK_ERR(i_value == 16 || i_value == 24, XA_PCM_CONFIG_NONFATAL_RANGE); + d->in_pcm_width = (u8)i_value; + return XA_NO_ERROR; + + case XA_PCM_CONFIG_PARAM_IN_CHANNELS: + /* ...support at most 8-channels stream */ + XF_CHK_ERR(i_value > 0 && i_value <= 8, XA_PCM_CONFIG_NONFATAL_RANGE); + d->in_channels = (u8)i_value; + return XA_NO_ERROR; + + case XA_CODEC_CONFIG_PARAM_PCM_WIDTH: + case XA_PCM_CONFIG_PARAM_OUT_PCM_WIDTH: + /* ...we only support PCM16 and PCM24 */ + XF_CHK_ERR(i_value == 16 || i_value == 24, XA_PCM_CONFIG_NONFATAL_RANGE); + d->out_pcm_width = (u8)i_value; + return XA_NO_ERROR; + + case XA_CODEC_CONFIG_PARAM_CHANNELS: + case XA_PCM_CONFIG_PARAM_OUT_CHANNELS: + /* ...support at most 8-channels stream */ + XF_CHK_ERR(i_value > 0 && i_value <= 8, XA_API_FATAL_INVALID_CMD_TYPE); + d->out_channels = (u8)i_value; + return XA_NO_ERROR; + + case XA_PCM_CONFIG_PARAM_CHANROUTING: + /* ...accept any channel routing mask */ + d->chan_routing = (u32)i_value; + return XA_NO_ERROR; + + default: + /* ...unrecognized parameter */ + return XF_CHK_ERR(0, XA_API_FATAL_INVALID_CMD_TYPE); + } +} + +/* ...retrieve configuration parameter */ +static XA_ERRORCODE xa_pcm_get_config_param(XAPcmCodec *d, WORD32 i_idx, pVOID pv_value) +{ + /* ...validity check */ + XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...make sure pre-configuration is completed */ + XF_CHK_ERR(d->state & XA_PCM_FLAG_PREINIT_DONE, XA_PCM_CONFIG_NONFATAL_STATE); + + /* ...process individual parameter */ + switch (i_idx) + { + case XA_CODEC_CONFIG_PARAM_SAMPLE_RATE: + case XA_PCM_CONFIG_PARAM_SAMPLE_RATE: + /* ...return output sampling frequency */ + *(WORD32 *)pv_value = d->sample_rate; + return XA_NO_ERROR; + + case XA_PCM_CONFIG_PARAM_IN_PCM_WIDTH: + /* ...return input sample bit-width */ + *(WORD32 *)pv_value = d->in_pcm_width; + return XA_NO_ERROR; + + case XA_PCM_CONFIG_PARAM_IN_CHANNELS: + /* ...return number of input channels */ + *(WORD32 *)pv_value = d->in_channels; + return XA_NO_ERROR; + + case XA_CODEC_CONFIG_PARAM_PCM_WIDTH: + case XA_PCM_CONFIG_PARAM_OUT_PCM_WIDTH: + /* ...return output sample bit-width */ + *(WORD32 *)pv_value = d->out_pcm_width; + return XA_NO_ERROR; + + case XA_CODEC_CONFIG_PARAM_CHANNELS: + case XA_PCM_CONFIG_PARAM_OUT_CHANNELS: + /* ...return number of output channels */ + *(WORD32 *)pv_value = d->out_channels; + return XA_NO_ERROR; + + case XA_PCM_CONFIG_PARAM_CHANROUTING: + /* ...return current channel routing mask */ + *(WORD32 *)pv_value = d->chan_routing; + return XA_NO_ERROR; + + default: + /* ...unrecognized parameter */ + return XF_CHK_ERR(0, XA_API_FATAL_INVALID_CMD_TYPE); + } +} + +/* ...execution command */ +static XA_ERRORCODE xa_pcm_execute(XAPcmCodec *d, WORD32 i_idx, pVOID pv_value) +{ + /* ...basic validity check */ + XF_CHK_ERR(d, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...codec must be in running state */ + XF_CHK_ERR(d->state & XA_PCM_FLAG_RUNNING, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...process individual command type */ + switch (i_idx) + { + case XA_CMD_TYPE_DO_EXECUTE: + /* ...do data processing (tbd - result code is bad) */ + if (d->insize != 0) + { + XF_CHK_ERR(!XA_ERROR_SEVERITY(d->process(d)), XA_PCM_EXEC_FATAL_STATE); + } + + /* ...process end-of-stream condition */ + (d->state & XA_PCM_FLAG_EOS ? d->state ^= XA_PCM_FLAG_EOS | XA_PCM_FLAG_COMPLETE : 0); + + return XA_NO_ERROR; + + case XA_CMD_TYPE_DONE_QUERY: + /* ...check if processing is complete */ + XF_CHK_ERR(pv_value, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...return completion status */ + *(WORD32 *)pv_value = (d->state & XA_PCM_FLAG_COMPLETE ? 1 : 0); + + return XA_NO_ERROR; + + case XA_CMD_TYPE_DO_RUNTIME_INIT: + /* ...reset codec operation */ + return xa_pcm_do_runtime_init(d); + + default: + /* ...unrecognized command */ + return XF_CHK_ERR(0, XA_API_FATAL_INVALID_CMD_TYPE); + } +} + +/* ...set number of input bytes */ +static XA_ERRORCODE xa_pcm_set_input_bytes(XAPcmCodec *d, WORD32 i_idx, pVOID pv_value) +{ + u32 in_stride = d->in_stride; + u32 insize; + + /* ...validity check */ + XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...track index must be valid */ + XF_CHK_ERR(i_idx == 0, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...component must be initialized */ + XF_CHK_ERR(d->state & XA_PCM_FLAG_POSTINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...input buffer must exist */ + XF_CHK_ERR(d->input, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...convert bytes into samples (don't like division, but still...) */ + insize = *(WORD32 *)pv_value / in_stride; + + /* ...make sure we have integral amount of samples */ + XF_CHK_ERR(*(WORD32 *)pv_value == insize * in_stride, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...limit input buffer size to maximal value*/ + d->insize = (insize > XA_PCM_MAX_SAMPLES ? XA_PCM_MAX_SAMPLES : insize); + + return XA_NO_ERROR; +} + +/* ...get number of output bytes produced */ +static XA_ERRORCODE xa_pcm_get_output_bytes(XAPcmCodec *d, WORD32 i_idx, pVOID pv_value) +{ + /* ...validity check */ + XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...buffer index must be valid */ + XF_CHK_ERR(i_idx == 1, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...component must be initialized */ + XF_CHK_ERR(d->state & XA_PCM_FLAG_POSTINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...output buffer must exist */ + XF_CHK_ERR(d->output, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...return number of produced bytes (and reset instantly? - tbd) */ + *(WORD32 *)pv_value = d->produced; + + return XA_NO_ERROR; +} + +/* ...get number of consumed bytes */ +static XA_ERRORCODE xa_pcm_get_curidx_input_buf(XAPcmCodec *d, WORD32 i_idx, pVOID pv_value) +{ + /* ...validity check */ + XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...index must be valid */ + XF_CHK_ERR(i_idx == 0, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...input buffer must exist */ + XF_CHK_ERR(d->input, XA_PCM_EXEC_NONFATAL_INPUT); + + /* ...return number of bytes consumed */ + *(WORD32 *)pv_value = d->consumed; + + return XA_NO_ERROR; +} + +/* ...end-of-stream processing */ +static XA_ERRORCODE xa_pcm_input_over(XAPcmCodec *d, WORD32 i_idx, pVOID pv_value) +{ + /* ...validity check */ + XF_CHK_ERR(d, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...put end-of-stream flag */ + d->state |= XA_PCM_FLAG_EOS; + + TRACE(PROCESS, _b("Input-over-condition signalled")); + + return XA_NO_ERROR; +} + +/* ..get total amount of data for memory tables */ +static XA_ERRORCODE xa_pcm_get_memtabs_size(XAPcmCodec *d, WORD32 i_idx, pVOID pv_value) +{ + /* ...basic validity checks */ + XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...check mixer is pre-initialized */ + XF_CHK_ERR(d->state & XA_PCM_FLAG_PREINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...we have all our tables inside API structure */ + *(WORD32 *)pv_value = 0; + + return XA_NO_ERROR; +} + +/* ...return total amount of memory buffers */ +static XA_ERRORCODE xa_pcm_get_n_memtabs(XAPcmCodec *d, WORD32 i_idx, pVOID pv_value) +{ + /* ...basic validity checks */ + XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...we have 1 input buffer and 1 output buffer */ + *(WORD32 *)pv_value = 1 + 1; + + return XA_NO_ERROR; +} + +/* ...return memory type data */ +static XA_ERRORCODE xa_pcm_get_mem_info_type(XAPcmCodec *d, WORD32 i_idx, pVOID pv_value) +{ + /* ...basic validity check */ + XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...codec must be in post-init state */ + XF_CHK_ERR(d->state & XA_PCM_FLAG_POSTINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...check buffer type */ + switch (i_idx) + { + case 0: + *(WORD32 *)pv_value = XA_MEMTYPE_INPUT; + return XA_NO_ERROR; + + case 1: + *(WORD32 *)pv_value = XA_MEMTYPE_OUTPUT; + return XA_NO_ERROR; + + default: + return XF_CHK_ERR(0, XA_API_FATAL_INVALID_CMD_TYPE); + } +} + +/* ...return memory buffer size */ +static XA_ERRORCODE xa_pcm_get_mem_info_size(XAPcmCodec *d, WORD32 i_idx, pVOID pv_value) +{ + /* ...basic validity check */ + XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...codec must be in post-init state */ + XF_CHK_ERR(d->state & XA_PCM_FLAG_POSTINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...determine particular buffer */ + switch (i_idx) + { + case 0: + /* ...input buffer size can be any */ + *(WORD32 *)pv_value = 0; + return XA_NO_ERROR; + + case 1: + /* ...output buffer size is dependent on stride */ + *(WORD32 *)pv_value = XA_PCM_MAX_SAMPLES * d->out_stride; + return XA_NO_ERROR; + + default: + /* ...invalid buffer index */ + return XF_CHK_ERR(0, XA_API_FATAL_INVALID_CMD_TYPE); + } +} + +/* ...return memory alignment data */ +static XA_ERRORCODE xa_pcm_get_mem_info_alignment(XAPcmCodec *d, WORD32 i_idx, pVOID pv_value) +{ + /* ...basic validity check */ + XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...codec must be in post-initialization state */ + XF_CHK_ERR(d->state & XA_PCM_FLAG_POSTINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...all buffers are 4-bytes aligned */ + *(WORD32 *)pv_value = 4; + + return XA_NO_ERROR; +} + +/* ...set memory pointer */ +static XA_ERRORCODE xa_pcm_set_mem_ptr(XAPcmCodec *d, WORD32 i_idx, pVOID pv_value) +{ + /* ...basic validity check */ + XF_CHK_ERR(d, XA_API_FATAL_INVALID_CMD_TYPE); + XF_CHK_ERR(pv_value, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...codec must be in post-initialized state */ + XF_CHK_ERR(d->state & XA_PCM_FLAG_POSTINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE); + + /* ...select memory buffer */ + switch (i_idx) + { + case 0: + /* ...input buffer */ + d->input = pv_value; + return XA_NO_ERROR; + + case 1: + /* ...output buffer */ + d->output = pv_value; + return XA_NO_ERROR; + + default: + /* ...invalid index */ + return XF_CHK_ERR(0, XA_API_FATAL_INVALID_CMD_TYPE); + } +} + +/******************************************************************************* + * API command hooks + ******************************************************************************/ + +static XA_ERRORCODE (* const xa_pcm_api[])(XAPcmCodec *, WORD32, pVOID) = +{ + [XA_API_CMD_GET_API_SIZE] = xa_pcm_get_api_size, + + [XA_API_CMD_INIT] = xa_pcm_init, + [XA_API_CMD_SET_CONFIG_PARAM] = xa_pcm_set_config_param, + [XA_API_CMD_GET_CONFIG_PARAM] = xa_pcm_get_config_param, + + [XA_API_CMD_EXECUTE] = xa_pcm_execute, + [XA_API_CMD_SET_INPUT_BYTES] = xa_pcm_set_input_bytes, + [XA_API_CMD_GET_OUTPUT_BYTES] = xa_pcm_get_output_bytes, + [XA_API_CMD_GET_CURIDX_INPUT_BUF] = xa_pcm_get_curidx_input_buf, + [XA_API_CMD_INPUT_OVER] = xa_pcm_input_over, + + [XA_API_CMD_GET_MEMTABS_SIZE] = xa_pcm_get_memtabs_size, + [XA_API_CMD_GET_N_MEMTABS] = xa_pcm_get_n_memtabs, + [XA_API_CMD_GET_MEM_INFO_TYPE] = xa_pcm_get_mem_info_type, + [XA_API_CMD_GET_MEM_INFO_SIZE] = xa_pcm_get_mem_info_size, + [XA_API_CMD_GET_MEM_INFO_ALIGNMENT] = xa_pcm_get_mem_info_alignment, + [XA_API_CMD_SET_MEM_PTR] = xa_pcm_set_mem_ptr, +}; + +/* ...total numer of commands supported */ +#define XA_PCM_API_COMMANDS_NUM (sizeof(xa_pcm_api) / sizeof(xa_pcm_api[0])) + +/******************************************************************************* + * API entry point + ******************************************************************************/ + +XA_ERRORCODE xa_pcm_codec(xa_codec_handle_t p_xa_module_obj, WORD32 i_cmd, WORD32 i_idx, pVOID pv_value) +{ + XAPcmCodec *d = (XAPcmCodec *) p_xa_module_obj; + + /* ...check if command index is valid */ + XF_CHK_ERR(i_cmd < XA_PCM_API_COMMANDS_NUM, XA_API_FATAL_INVALID_CMD); + + /* ...see if command is defined */ + XF_CHK_ERR(xa_pcm_api[i_cmd], XA_API_FATAL_INVALID_CMD); + + /* ...execute requested command */ + return xa_pcm_api[i_cmd](d, i_idx, pv_value); +} diff --git a/hifi/xaf/hifi-dpf/plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a b/hifi/xaf/hifi-dpf/plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a Binary files differnew file mode 100644 index 00000000..cb284459 --- /dev/null +++ b/hifi/xaf/hifi-dpf/plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a diff --git a/hifi/xaf/hifi-dpf/plugins/cadence/vorbis_dec/xa-vorbis-decoder.c b/hifi/xaf/hifi-dpf/plugins/cadence/vorbis_dec/xa-vorbis-decoder.c new file mode 100644 index 00000000..43220ef3 --- /dev/null +++ b/hifi/xaf/hifi-dpf/plugins/cadence/vorbis_dec/xa-vorbis-decoder.c @@ -0,0 +1,84 @@ +/******************************************************************************* +* 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-vorbis-decoder.c + * + * VORBIS decoder plugin - thin wrapper around VORBISDEC library + * + ******************************************************************************/ + +#define MODULE_TAG VORBISDEC + +/******************************************************************************* + * Includes + ******************************************************************************/ + +#include "xf-plugin.h" +#include "audio/xa-audio-decoder-api.h" +#include "xa_vorbis_dec_api.h" + +/******************************************************************************* + * Override GET-CONFIG-PARAM function + ******************************************************************************/ + +static inline XA_ERRORCODE xa_vorbis_get_config_param(xa_codec_handle_t handle, WORD32 i_idx, pVOID pv_value) +{ + /* ...translate "standard" parameter index into internal value */ + switch (i_idx) + { + case XA_CODEC_CONFIG_PARAM_CHANNELS: + /* ...return number of output channels */ + i_idx = XA_VORBISDEC_CONFIG_PARAM_NUM_CHANNELS; + break; + + case XA_CODEC_CONFIG_PARAM_SAMPLE_RATE: + /* ...return output sampling frequency */ + i_idx = XA_VORBISDEC_CONFIG_PARAM_SAMP_FREQ; + break; + + case XA_CODEC_CONFIG_PARAM_PCM_WIDTH: + /* ...return sample bit-width */ + i_idx = XA_VORBISDEC_CONFIG_PARAM_PCM_WDSZ; + break; + } + + /* ...pass to library */ + return xa_vorbis_dec(handle, XA_API_CMD_GET_CONFIG_PARAM, i_idx, pv_value); +} + +/******************************************************************************* + * API entry point + ******************************************************************************/ + +XA_ERRORCODE xa_vorbis_decoder(xa_codec_handle_t p_xa_module_obj, WORD32 i_cmd, WORD32 i_idx, pVOID pv_value) +{ + /* ...process common audio-decoder commands */ + if (i_cmd == XA_API_CMD_GET_CONFIG_PARAM) + { + return xa_vorbis_get_config_param(p_xa_module_obj, i_idx, pv_value); + } + else + { + return xa_vorbis_dec(p_xa_module_obj, i_cmd, i_idx, pv_value); + } +} diff --git a/hifi/xaf/hifi-dpf/plugins/cadence/vorbis_dec/xa_vorbis_dec_api.h b/hifi/xaf/hifi-dpf/plugins/cadence/vorbis_dec/xa_vorbis_dec_api.h new file mode 100644 index 00000000..f99660f8 --- /dev/null +++ b/hifi/xaf/hifi-dpf/plugins/cadence/vorbis_dec/xa_vorbis_dec_api.h @@ -0,0 +1,121 @@ +/******************************************************************************* +* 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_VORBIS_DEC_API_H__ +#define __XA_VORBIS_DEC_API_H__ + +#include <xa_memory_standards.h> + +/* vorbis_dec-specific configuration parameters */ +enum xa_config_param_vorbis_dec +{ + XA_VORBISDEC_CONFIG_PARAM_SAMP_FREQ = 0, + XA_VORBISDEC_CONFIG_PARAM_NUM_CHANNELS = 1, + XA_VORBISDEC_CONFIG_PARAM_PCM_WDSZ = 2, + XA_VORBISDEC_CONFIG_PARAM_COMMENT_MEM_PTR = 3, + XA_VORBISDEC_CONFIG_PARAM_COMMENT_MEM_SIZE = 4, + XA_VORBISDEC_CONFIG_PARAM_GET_CUR_BITRATE = 5, + XA_VORBISDEC_CONFIG_PARAM_RAW_VORBIS_FILE_MODE = 6, + XA_VORBISDEC_CONFIG_PARAM_RAW_VORBIS_LAST_PKT_GRANULE_POS = 7, + XA_VORBISDEC_CONFIG_PARAM_OGG_MAX_PAGE_SIZE = 8, + XA_VORBISDEC_CONFIG_PARAM_RUNTIME_MEM = 9 +}; + +/* commands */ +#include <xa_apicmd_standards.h> + +/* vorbis_dec-specific command types */ +/* (none) */ + +/* error codes */ +#include <xa_error_standards.h> +#define XA_CODEC_VORBIS_DEC 7 + +/* vorbis_dec-specific error codes */ + +/*****************************************************************************/ +/* Class 1: Configuration Errors */ +/*****************************************************************************/ +/* Nonfatal Errors */ +enum xa_error_nonfatal_config_vorbis_dec +{ + XA_VORBISDEC_CONFIG_NONFATAL_GROUPED_STREAM = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_config, XA_CODEC_VORBIS_DEC, 0), + XA_VORBISDEC_CONFIG_NONFATAL_BAD_PARAM = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_config, XA_CODEC_VORBIS_DEC, 1) +}; + +/* Fatal Errors */ +enum xa_error_fatal_config_vorbis_dec +{ + XA_VORBISDEC_CONFIG_FATAL_BADHDR = XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_VORBIS_DEC, 0), + XA_VORBISDEC_CONFIG_FATAL_NOTVORBIS = XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_VORBIS_DEC, 1), + XA_VORBISDEC_CONFIG_FATAL_BADINFO = XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_VORBIS_DEC, 2), + XA_VORBISDEC_CONFIG_FATAL_BADVERSION = XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_VORBIS_DEC, 3), + XA_VORBISDEC_CONFIG_FATAL_BADBOOKS = XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_VORBIS_DEC, 4), + XA_VORBISDEC_CONFIG_FATAL_CODEBOOK_DECODE = XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_VORBIS_DEC, 5), + XA_VORBISDEC_CONFIG_FATAL_INVALID_PARAM = XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_VORBIS_DEC, 6) +}; + +/*****************************************************************************/ +/* Class 2: Execution Errors */ +/*****************************************************************************/ +/* Nonfatal Errors */ +enum xa_error_nonfatal_execute_vorbis_dec +{ + XA_VORBISDEC_EXECUTE_NONFATAL_OV_HOLE = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 0), + XA_VORBISDEC_EXECUTE_NONFATAL_OV_NOTAUDIO = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 1), + XA_VORBISDEC_EXECUTE_NONFATAL_OV_BADPACKET = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 2), + XA_VORBISDEC_EXECUTE_NONFATAL_OV_RUNTIME_DECODE_FLUSH_IN_PROGRESS = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 3), + XA_VORBISDEC_EXECUTE_NONFATAL_OV_INVALID_STRM_POS = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 4), + XA_VORBISDEC_EXECUTE_NONFATAL_OV_INSUFFICIENT_DATA = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 5), + XA_VORBISDEC_EXECUTE_NONFATAL_OV_UNEXPECTED_IDENT_PKT_RECEIVED = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 6), + XA_VORBISDEC_EXECUTE_NONFATAL_OV_UNEXPECTED_HEADER_PKT_RECEIVED = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 7) +}; +/* Fatal Errors */ +enum xa_error_fatal_execute_vorbis_dec +{ + XA_VORBISDEC_EXECUTE_FATAL_PERSIST_ALLOC = XA_ERROR_CODE(xa_severity_fatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 0), + XA_VORBISDEC_EXECUTE_FATAL_SCRATCH_ALLOC = XA_ERROR_CODE(xa_severity_fatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 1), + XA_VORBISDEC_EXECUTE_FATAL_CORRUPT_STREAM = XA_ERROR_CODE(xa_severity_fatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 2), + XA_VORBISDEC_EXECUTE_FATAL_INSUFFICIENT_INP_BUF_SIZE = XA_ERROR_CODE(xa_severity_fatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 3) +}; + +#include "xa_type_def.h" + +#ifdef __cplusplus + extern "C" { +#endif /* __cplusplus */ + + xa_codec_func_t xa_vorbis_dec; + +#ifdef __cplusplus + } +#endif /* __cplusplus */ + +#endif /* __XA_VORBIS_DEC_API_H__ */ diff --git a/hifi/xaf/host-apf/Android.bp b/hifi/xaf/host-apf/Android.bp new file mode 100644 index 00000000..58875388 --- /dev/null +++ b/hifi/xaf/host-apf/Android.bp @@ -0,0 +1,41 @@ +// Copyright (C) 2020 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package { + // See: http://go/android-license-faq + // A large-scale-change added 'default_applicable_licenses' to import + // all of the 'license_kinds' from "device_linaro_hikey_license" + // to get the below license kinds: + // SPDX-license-identifier-MIT + default_applicable_licenses: ["device_linaro_hikey_license"], +} + +cc_prebuilt_binary { + name: "dhifimesg", + srcs: ["tools/dhifimesg"], + shared_libs: [ + "libutils", + "liblog", + "libbinder", + "libc++", + "libdl", + "libc", + "libm", + ], + compile_multilib: "64", + vendor: true, + strip: { + none: true, + }, +} diff --git a/hifi/xaf/host-apf/Android.mk b/hifi/xaf/host-apf/Android.mk new file mode 100644 index 00000000..270c9aab --- /dev/null +++ b/hifi/xaf/host-apf/Android.mk @@ -0,0 +1,76 @@ +LOCAL_PATH := $(call my-dir) +################################################################################ +# libxtensa_proxy library building +################################################################################ + +include $(CLEAR_VARS) +LOCAL_VENDOR_MODULE := true +common_C_INCLUDES := \ + $(LOCAL_PATH)/include \ + $(LOCAL_PATH)/include/audio \ + $(LOCAL_PATH)/include/os/android \ + $(LOCAL_PATH)/include/sys/fio \ + $(LOCAL_PATH)/playback \ + $(LOCAL_PATH)/playback/tinyalsa \ + $(LOCAL_PATH)/utest/include + +LOCAL_SRC_FILES := \ + proxy/xf-proxy.c \ + proxy/xaf-api.c \ + proxy/xf-trace.c \ + proxy/xf-fio.c \ + playback/xa_playback.c \ + playback/tinyalsa/pcm.c \ + utest/xaf-utils-test.c \ + utest/xaf-mem-test.c + +C_FLAGS := -DXF_TRACE=0 -Wall -Werror -Wno-everything + +LOCAL_SHARED_LIBRARIES := liblog +LOCAL_C_INCLUDES := $(common_C_INCLUDES) +LOCAL_C_INCLUDES += external/expat/lib +LOCAL_CFLAGS := $(C_FLAGS) +LOCAL_MODULE := libxtensa_proxy +LOCAL_LICENSE_KINDS := SPDX-license-identifier-MIT +LOCAL_LICENSE_CONDITIONS := notice +LOCAL_MODULE_TAGS := optional + +include $(BUILD_STATIC_LIBRARY) + +################################################################################ +# xaf-dec-test: fileinput->ogg/pcm decoder->speaker output +################################################################################ +include $(CLEAR_VARS) +LOCAL_VENDOR_MODULE := true +LOCAL_MODULE := xaf-dec-test +LOCAL_LICENSE_KINDS := SPDX-license-identifier-MIT +LOCAL_LICENSE_CONDITIONS := notice + +LOCAL_SRC_FILES := \ + utest/xaf-dec-test.c + +LOCAL_C_INCLUDES := $(common_C_INCLUDES) +LOCAL_CFLAGS := $(C_FLAGS) +LOCAL_STATIC_LIBRARIES := libxtensa_proxy +LOCAL_SHARED_LIBRARIES := liblog libcutils +LOCAL_MODULE_TAGS := optional +include $(BUILD_EXECUTABLE) + +################################################################################ +# xaf-dec-mix-test: fileinput->ogg orpcm decoder->Mixer->speaker output +################################################################################ +include $(CLEAR_VARS) +LOCAL_VENDOR_MODULE := true +LOCAL_MODULE := xaf-dec-mix-test +LOCAL_LICENSE_KINDS := SPDX-license-identifier-MIT +LOCAL_LICENSE_CONDITIONS := notice + +LOCAL_SRC_FILES := \ + utest/xaf-dec-mix-test.c + +LOCAL_C_INCLUDES := $(common_C_INCLUDES) +LOCAL_CFLAGS := $(C_FLAGS) +LOCAL_STATIC_LIBRARIES := libxtensa_proxy +LOCAL_SHARED_LIBRARIES := liblog libcutils +LOCAL_MODULE_TAGS := optional +include $(BUILD_EXECUTABLE) diff --git a/hifi/xaf/host-apf/include/audio/xa-audio-decoder-api.h b/hifi/xaf/host-apf/include/audio/xa-audio-decoder-api.h new file mode 100644 index 00000000..f82544c8 --- /dev/null +++ b/hifi/xaf/host-apf/include/audio/xa-audio-decoder-api.h @@ -0,0 +1,46 @@ +/******************************************************************************* +* 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_ADEC_API_H__ +#define __XA_ADEC_API_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) +}; + +#endif diff --git a/hifi/xaf/host-apf/include/audio/xa-mixer-api.h b/hifi/xaf/host-apf/include/audio/xa-mixer-api.h new file mode 100644 index 00000000..c9695b40 --- /dev/null +++ b/hifi/xaf/host-apf/include/audio/xa-mixer-api.h @@ -0,0 +1,154 @@ +/******************************************************************************* +* 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_MIXER_API_H__ +#define __XA_MIXER_API_H__ + +/******************************************************************************* + * Includes + ******************************************************************************/ + +/* ...generic commands */ +#include "xa_apicmd_standards.h" + +/* ...generic error codes */ +#include "xa_error_standards.h" + +/* ...common types */ +#include "xa_type_def.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/host-apf/include/audio/xa-pcm-api.h b/hifi/xaf/host-apf/include/audio/xa-pcm-api.h new file mode 100644 index 00000000..94fb1362 --- /dev/null +++ b/hifi/xaf/host-apf/include/audio/xa-pcm-api.h @@ -0,0 +1,138 @@ +/******************************************************************************* +* 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_PCM_API_H__ +#define __XA_PCM_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 + ******************************************************************************/ + +/* ...codec-specific configuration parameters */ +enum xa_config_param_pcm { + XA_PCM_CONFIG_PARAM_SAMPLE_RATE = 0, + XA_PCM_CONFIG_PARAM_IN_PCM_WIDTH = 1, + XA_PCM_CONFIG_PARAM_IN_CHANNELS = 2, + XA_PCM_CONFIG_PARAM_OUT_PCM_WIDTH = 3, + XA_PCM_CONFIG_PARAM_OUT_CHANNELS = 4, + XA_PCM_CONFIG_PARAM_CHANROUTING = 5, + XA_PCM_CONFIG_PARAM_NUM = 6, +}; + +/* ...component identifier (informative) */ +#define XA_CODEC_PCM 16 + +/******************************************************************************* + * Class 0: API Errors + ******************************************************************************/ + +#define XA_PCM_API_NONFATAL(e) \ + XA_ERROR_CODE(xa_severity_nonfatal, xa_class_api, XA_CODEC_PCM, (e)) + +#define XA_PCM_API_FATAL(e) \ + XA_ERROR_CODE(xa_severity_fatal, xa_class_api, XA_CODEC_PCM, (e)) + +enum xa_error_nonfatal_api_pcm { + XA_PCM_API_NONFATAL_MAX = XA_PCM_API_NONFATAL(0) +}; + +enum xa_error_fatal_api_pcm { + XA_PCM_API_FATAL_MAX = XA_PCM_API_FATAL(0) +}; + +/******************************************************************************* + * Class 1: Configuration Errors + ******************************************************************************/ + +#define XA_PCM_CONFIG_NONFATAL(e) \ + XA_ERROR_CODE(xa_severity_nonfatal, xa_class_config, XA_CODEC_PCM, (e)) + +#define XA_PCM_CONFIG_FATAL(e) \ + XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_PCM, (e)) + +enum xa_error_nonfatal_config_pcm { + XA_PCM_CONFIG_NONFATAL_RANGE = XA_PCM_CONFIG_NONFATAL(0), + XA_PCM_CONFIG_NONFATAL_STATE = XA_PCM_CONFIG_NONFATAL(1), + XA_PCM_CONFIG_NONFATAL_MAX = XA_PCM_CONFIG_NONFATAL(2) +}; + +enum xa_error_fatal_config_pcm { + XA_PCM_CONFIG_FATAL_RANGE = XA_PCM_CONFIG_FATAL(0), + XA_PCM_CONFIG_FATAL_MAX = XA_PCM_CONFIG_FATAL(1) +}; + +/******************************************************************************* + * Class 2: Execution Class Errors + ******************************************************************************/ + +#define XA_PCM_EXEC_NONFATAL(e) \ + XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_PCM, (e)) + +#define XA_PCM_EXEC_FATAL(e) \ + XA_ERROR_CODE(xa_severity_fatal, xa_class_execute, XA_CODEC_PCM, (e)) + +enum xa_error_nonfatal_execute_pcm { + XA_PCM_EXEC_NONFATAL_STATE = XA_PCM_EXEC_NONFATAL(0), + XA_PCM_EXEC_NONFATAL_NO_DATA = XA_PCM_EXEC_NONFATAL(1), + XA_PCM_EXEC_NONFATAL_INPUT = XA_PCM_EXEC_NONFATAL(2), + XA_PCM_EXEC_NONFATAL_OUTPUT = XA_PCM_EXEC_NONFATAL(3), + XA_PCM_EXEC_NONFATAL_MAX = XA_PCM_EXEC_NONFATAL(4) +}; + +enum xa_error_fatal_execute_pcm { + XA_PCM_EXEC_FATAL_STATE = XA_PCM_EXEC_FATAL(0), + XA_PCM_EXEC_FATAL_INPUT = XA_PCM_EXEC_FATAL(1), + XA_PCM_EXEC_FATAL_OUTPUT = XA_PCM_EXEC_FATAL(2), + XA_PCM_EXEC_FATAL_MAX = XA_PCM_EXEC_FATAL(3) +}; + +/******************************************************************************* + * API function definition + ******************************************************************************/ + +#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_pcm_codec; +#if defined(__cplusplus) +} +#endif /* __cplusplus */ + +#endif /* __XA_PCM_API_H__ */ + diff --git a/hifi/xaf/host-apf/include/audio/xa_apicmd_standards.h b/hifi/xaf/host-apf/include/audio/xa_apicmd_standards.h new file mode 100644 index 00000000..eb1b78e1 --- /dev/null +++ b/hifi/xaf/host-apf/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/host-apf/include/audio/xa_error_standards.h b/hifi/xaf/host-apf/include/audio/xa_error_standards.h new file mode 100644 index 00000000..1b67b52f --- /dev/null +++ b/hifi/xaf/host-apf/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/host-apf/include/audio/xa_memory_standards.h b/hifi/xaf/host-apf/include/audio/xa_memory_standards.h new file mode 100644 index 00000000..27ec455f --- /dev/null +++ b/hifi/xaf/host-apf/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/host-apf/include/audio/xa_type_def.h b/hifi/xaf/host-apf/include/audio/xa_type_def.h new file mode 100644 index 00000000..e83cdd34 --- /dev/null +++ b/hifi/xaf/host-apf/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/host-apf/include/audio/xa_vorbis_dec_api.h b/hifi/xaf/host-apf/include/audio/xa_vorbis_dec_api.h new file mode 100644 index 00000000..f99660f8 --- /dev/null +++ b/hifi/xaf/host-apf/include/audio/xa_vorbis_dec_api.h @@ -0,0 +1,121 @@ +/******************************************************************************* +* 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_VORBIS_DEC_API_H__ +#define __XA_VORBIS_DEC_API_H__ + +#include <xa_memory_standards.h> + +/* vorbis_dec-specific configuration parameters */ +enum xa_config_param_vorbis_dec +{ + XA_VORBISDEC_CONFIG_PARAM_SAMP_FREQ = 0, + XA_VORBISDEC_CONFIG_PARAM_NUM_CHANNELS = 1, + XA_VORBISDEC_CONFIG_PARAM_PCM_WDSZ = 2, + XA_VORBISDEC_CONFIG_PARAM_COMMENT_MEM_PTR = 3, + XA_VORBISDEC_CONFIG_PARAM_COMMENT_MEM_SIZE = 4, + XA_VORBISDEC_CONFIG_PARAM_GET_CUR_BITRATE = 5, + XA_VORBISDEC_CONFIG_PARAM_RAW_VORBIS_FILE_MODE = 6, + XA_VORBISDEC_CONFIG_PARAM_RAW_VORBIS_LAST_PKT_GRANULE_POS = 7, + XA_VORBISDEC_CONFIG_PARAM_OGG_MAX_PAGE_SIZE = 8, + XA_VORBISDEC_CONFIG_PARAM_RUNTIME_MEM = 9 +}; + +/* commands */ +#include <xa_apicmd_standards.h> + +/* vorbis_dec-specific command types */ +/* (none) */ + +/* error codes */ +#include <xa_error_standards.h> +#define XA_CODEC_VORBIS_DEC 7 + +/* vorbis_dec-specific error codes */ + +/*****************************************************************************/ +/* Class 1: Configuration Errors */ +/*****************************************************************************/ +/* Nonfatal Errors */ +enum xa_error_nonfatal_config_vorbis_dec +{ + XA_VORBISDEC_CONFIG_NONFATAL_GROUPED_STREAM = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_config, XA_CODEC_VORBIS_DEC, 0), + XA_VORBISDEC_CONFIG_NONFATAL_BAD_PARAM = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_config, XA_CODEC_VORBIS_DEC, 1) +}; + +/* Fatal Errors */ +enum xa_error_fatal_config_vorbis_dec +{ + XA_VORBISDEC_CONFIG_FATAL_BADHDR = XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_VORBIS_DEC, 0), + XA_VORBISDEC_CONFIG_FATAL_NOTVORBIS = XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_VORBIS_DEC, 1), + XA_VORBISDEC_CONFIG_FATAL_BADINFO = XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_VORBIS_DEC, 2), + XA_VORBISDEC_CONFIG_FATAL_BADVERSION = XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_VORBIS_DEC, 3), + XA_VORBISDEC_CONFIG_FATAL_BADBOOKS = XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_VORBIS_DEC, 4), + XA_VORBISDEC_CONFIG_FATAL_CODEBOOK_DECODE = XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_VORBIS_DEC, 5), + XA_VORBISDEC_CONFIG_FATAL_INVALID_PARAM = XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_VORBIS_DEC, 6) +}; + +/*****************************************************************************/ +/* Class 2: Execution Errors */ +/*****************************************************************************/ +/* Nonfatal Errors */ +enum xa_error_nonfatal_execute_vorbis_dec +{ + XA_VORBISDEC_EXECUTE_NONFATAL_OV_HOLE = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 0), + XA_VORBISDEC_EXECUTE_NONFATAL_OV_NOTAUDIO = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 1), + XA_VORBISDEC_EXECUTE_NONFATAL_OV_BADPACKET = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 2), + XA_VORBISDEC_EXECUTE_NONFATAL_OV_RUNTIME_DECODE_FLUSH_IN_PROGRESS = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 3), + XA_VORBISDEC_EXECUTE_NONFATAL_OV_INVALID_STRM_POS = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 4), + XA_VORBISDEC_EXECUTE_NONFATAL_OV_INSUFFICIENT_DATA = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 5), + XA_VORBISDEC_EXECUTE_NONFATAL_OV_UNEXPECTED_IDENT_PKT_RECEIVED = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 6), + XA_VORBISDEC_EXECUTE_NONFATAL_OV_UNEXPECTED_HEADER_PKT_RECEIVED = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 7) +}; +/* Fatal Errors */ +enum xa_error_fatal_execute_vorbis_dec +{ + XA_VORBISDEC_EXECUTE_FATAL_PERSIST_ALLOC = XA_ERROR_CODE(xa_severity_fatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 0), + XA_VORBISDEC_EXECUTE_FATAL_SCRATCH_ALLOC = XA_ERROR_CODE(xa_severity_fatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 1), + XA_VORBISDEC_EXECUTE_FATAL_CORRUPT_STREAM = XA_ERROR_CODE(xa_severity_fatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 2), + XA_VORBISDEC_EXECUTE_FATAL_INSUFFICIENT_INP_BUF_SIZE = XA_ERROR_CODE(xa_severity_fatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 3) +}; + +#include "xa_type_def.h" + +#ifdef __cplusplus + extern "C" { +#endif /* __cplusplus */ + + xa_codec_func_t xa_vorbis_dec; + +#ifdef __cplusplus + } +#endif /* __cplusplus */ + +#endif /* __XA_VORBIS_DEC_API_H__ */ diff --git a/hifi/xaf/host-apf/include/os/android/xf-osal.h b/hifi/xaf/host-apf/include/os/android/xf-osal.h new file mode 100644 index 00000000..6286405e --- /dev/null +++ b/hifi/xaf/host-apf/include/os/android/xf-osal.h @@ -0,0 +1,215 @@ +/******************************************************************************* +* 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 __XF_H +#error "xf-osal.h mustn't be included directly" +#endif + +/******************************************************************************* + * Includes + ******************************************************************************/ + +#include <pthread.h> +#include <fcntl.h> +#include <limits.h> +#include <sys/mman.h> +#include <sys/ioctl.h> +#include <sys/time.h> +#include <log/log.h> + +/******************************************************************************* + * Tracing primitive + ******************************************************************************/ + +#define __xf_puts(str) \ + ALOG(LOG_INFO, "PROXY", "%s", (str)) + +/******************************************************************************* + * Lock operation + ******************************************************************************/ + +/* ...lock definition */ +typedef pthread_mutex_t xf_lock_t; + +/* ...lock initialization */ +static inline void __xf_lock_init(xf_lock_t *lock) +{ + pthread_mutex_init(lock, NULL); +} + +/* ...lock acquisition */ +static inline void __xf_lock(xf_lock_t *lock) +{ + pthread_mutex_lock(lock); +} + +/* ...lock release */ +static inline void __xf_unlock(xf_lock_t *lock) +{ + pthread_mutex_unlock(lock); +} + +/******************************************************************************* + * Waiting object + ******************************************************************************/ + +/* ...waiting object handle */ +typedef struct __xf_wait +{ + /* ...conditional variable */ + pthread_cond_t wait; + + /* ...waiting mutex */ + pthread_mutex_t mutex; + +} xf_wait_t; + +/* ...initialize waiting object */ +static inline void __xf_wait_init(xf_wait_t *w) +{ + pthread_cond_init(&w->wait, NULL); + pthread_mutex_init(&w->mutex, NULL); +} + +/* ...prepare to waiting */ +static inline void __xf_wait_prepare(xf_wait_t *w) +{ + pthread_mutex_lock(&w->mutex); +} + +#define __xf_wait_prepare(w) \ +({ \ + TRACE(1, _x("prepare-wait")); \ + (__xf_wait_prepare)(w); \ +}) + +/* ...wait until event is signalled */ +static inline int __xf_wait(xf_wait_t *w, u32 timeout) +{ + struct timespec ts; + struct timeval tv; + int r; + + /* ...wait with or without timeout (communication mutex is taken) */ + if (!timeout) + { + r = -pthread_cond_wait(&w->wait, &w->mutex); + } + else + { + /* ...get current time */ + gettimeofday(&tv, NULL); + + /* ...set absolute timeout */ + ts.tv_sec = tv.tv_sec + timeout / 1000; + ts.tv_nsec = tv.tv_usec * 1000 + (timeout % 1000) * 1000000; + (ts.tv_nsec >= 1000000000 ? ts.tv_sec++, ts.tv_nsec -= 1000000000 : 0); + + /* ...wait conditionally with absolute timeout*/ + r = -pthread_cond_timedwait(&w->wait, &w->mutex, &ts); + } + + /* ...leave with communication mutex taken */ + return r; +} + +#define __xf_wait(w, timeout) \ +({ \ + int __r; \ + TRACE(1, _x("wait")); \ + __r = (__xf_wait)(w, timeout); \ + TRACE(1, _x("resume")); \ + __r; \ +}) + +/* ...wake up waiting handle */ +static inline void __xf_wakeup(xf_wait_t *w) +{ + /* ...take communication mutex before signaling */ + pthread_mutex_lock(&w->mutex); + + /* ...signalling will resume waiting thread */ + pthread_cond_signal(&w->wait); + + /* ...assure that waiting task will not resume until we say this - is that really needed? - tbd */ + pthread_mutex_unlock(&w->mutex); +} + +#define __xf_wakeup(w) \ +({ \ + TRACE(1, _x("wakeup")); \ + (__xf_wakeup)(w); \ +}) + +/* ...complete waiting operation */ +static inline void __xf_wait_complete(xf_wait_t *w) +{ + pthread_mutex_unlock(&w->mutex); +} + +#define __xf_wait_complete(w) \ +({ \ + TRACE(1, _x("wait-complete")); \ + (__xf_wait_complete)(w); \ +}) + +/******************************************************************************* + * Thread support + ******************************************************************************/ + +/* ...thread handle definition */ +typedef pthread_t xf_thread_t; + +/* ...thread creation */ +static inline int __xf_thread_create(xf_thread_t *thread, void * (*f)(void *), void *arg) +{ + pthread_attr_t attr; + int r; + + /* ...initialize thread attributes - joinable with minimal stack */ + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); + pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN); + + /* ...create proxy asynchronous thread managing SHMEM */ + r = -pthread_create(thread, &attr, f, arg); + + /* ...destroy thread attributes */ + pthread_attr_destroy(&attr); + + return r; +} + +/* ...terminate thread operation */ +static inline int __xf_thread_destroy(xf_thread_t *thread) +{ + void *r; + + /* ...tell the thread to terminate */ + pthread_kill(*thread,SIGUSR1); + + /* ...wait until thread terminates */ + pthread_join(*thread, &r); + + /* ...return final status */ + return (int)(intptr_t)r; +} diff --git a/hifi/xaf/host-apf/include/os/xos/xf-osal.h b/hifi/xaf/host-apf/include/os/xos/xf-osal.h new file mode 100644 index 00000000..c3468000 --- /dev/null +++ b/hifi/xaf/host-apf/include/os/xos/xf-osal.h @@ -0,0 +1,206 @@ +/******************************************************************************* +* 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 __XF_H +#error "xf-osal.h mustn't be included directly" +#endif + +/******************************************************************************* + * Includes + ******************************************************************************/ +#include "xos.h" + +/******************************************************************************* + * Tracing primitive + ******************************************************************************/ + +#define __xf_puts(str) \ + puts((str)) + +/******************************************************************************* + * Lock operation + ******************************************************************************/ + +/* ...lock definition */ +typedef XosMutex xf_lock_t; + +/* ...lock initialization */ +static inline void __xf_lock_init(xf_lock_t *lock) +{ + xos_mutex_create(lock, XOS_MUTEX_WAIT_PRIORITY, 0); +} + +/* ...lock acquisition */ +static inline void __xf_lock(xf_lock_t *lock) +{ + xos_mutex_lock(lock); +} + +/* ...lock release */ +static inline void __xf_unlock(xf_lock_t *lock) +{ + xos_mutex_unlock(lock); +} + +/******************************************************************************* + * Waiting object + ******************************************************************************/ + +#if 0 +/* ...waiting object handle */ +typedef struct __xf_wait +{ + /* ...conditional variable */ + pthread_cond_t wait; + + /* ...waiting mutex */ + pthread_mutex_t mutex; + +} xf_wait_t; + +/* ...initialize waiting object */ +static inline void __xf_wait_init(xf_wait_t *w) +{ + pthread_cond_init(&w->wait, NULL); + pthread_mutex_init(&w->mutex, NULL); +} + +/* ...prepare to waiting */ +static inline void __xf_wait_prepare(xf_wait_t *w) +{ + pthread_mutex_lock(&w->mutex); +} + +#define __xf_wait_prepare(w) \ +({ \ + TRACE(1, _x("prepare-wait")); \ + (__xf_wait_prepare)(w); \ +}) + +/* ...wait until event is signalled */ +static inline int __xf_wait(xf_wait_t *w, u32 timeout) +{ + struct timespec ts; + struct timeval tv; + int r; + + /* ...wait with or without timeout (communication mutex is taken) */ + if (!timeout) + { + r = -pthread_cond_wait(&w->wait, &w->mutex); + } + else + { + /* ...get current time */ + gettimeofday(&tv, NULL); + + /* ...set absolute timeout */ + ts.tv_sec = tv.tv_sec + timeout / 1000; + ts.tv_nsec = tv.tv_usec * 1000 + (timeout % 1000) * 1000000; + (ts.tv_nsec >= 1000000000 ? ts.tv_sec++, ts.tv_nsec -= 1000000000 : 0); + + /* ...wait conditionally with absolute timeout*/ + r = -pthread_cond_timedwait(&w->wait, &w->mutex, &ts); + } + + /* ...leave with communication mutex taken */ + return r; +} + +#define __xf_wait(w, timeout) \ +({ \ + int __r; \ + TRACE(1, _x("wait")); \ + __r = (__xf_wait)(w, timeout); \ + TRACE(1, _x("resume")); \ + __r; \ +}) + +/* ...wake up waiting handle */ +static inline void __xf_wakeup(xf_wait_t *w) +{ + /* ...take communication mutex before signaling */ + pthread_mutex_lock(&w->mutex); + + /* ...signalling will resume waiting thread */ + pthread_cond_signal(&w->wait); + + /* ...assure that waiting task will not resume until we say this - is that really needed? - tbd */ + pthread_mutex_unlock(&w->mutex); +} + +#define __xf_wakeup(w) \ +({ \ + TRACE(1, _x("wakeup")); \ + (__xf_wakeup)(w); \ +}) + +/* ...complete waiting operation */ +static inline void __xf_wait_complete(xf_wait_t *w) +{ + pthread_mutex_unlock(&w->mutex); +} + +#define __xf_wait_complete(w) \ +({ \ + TRACE(1, _x("wait-complete")); \ + (__xf_wait_complete)(w); \ +}) +#endif + +/******************************************************************************* + * Thread support + ******************************************************************************/ + +/* ...thread handle definition */ +typedef XosThread xf_thread_t; +typedef XosThreadFunc xf_entry_t; + +/* ...thread creation */ +static inline int __xf_thread_create(xf_thread_t *thread, xf_entry_t *f, + void *arg, const char *name, void * stack, + unsigned int stack_size, int priority) +{ + int r; + + /* ...create proxy asynchronous thread managing SHMEM */ + r = xos_thread_create(thread, 0, f, arg, name, stack, stack_size, priority, 0, 0); + + return r; +} + +/* ...terminate thread operation */ +static inline int __xf_thread_destroy(xf_thread_t *thread) +{ + int r; + + /* ...wait until thread terminates */ + /* v-tbd - avoid infinite wait for join */ + //xos_thread_join(thread, &r); + + /* ...delete thread, free up TCB, stack */ + r = xos_thread_delete(thread); + + /* ...return final status */ + return r; +} + diff --git a/hifi/xaf/host-apf/include/sys/fio/xf-config.h b/hifi/xaf/host-apf/include/sys/fio/xf-config.h new file mode 100644 index 00000000..2e1d4c61 --- /dev/null +++ b/hifi/xaf/host-apf/include/sys/fio/xf-config.h @@ -0,0 +1,36 @@ +/******************************************************************************* +* 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. + +******************************************************************************/ + +/* ...number of DSP cores */ +#define XF_CFG_CORES_NUM 4 + +/* ...maximal number of clients supported by proxy */ +#define XF_CFG_PROXY_MAX_CLIENTS 256 + +/* ...size of the shared memory pool (in bytes) */ +#define XF_CFG_REMOTE_IPC_POOL_SIZE (256 << 10) + +/* ...size of the component(DSP) local memory pool (in bytes) */ +#define XF_CFG_LOCAL_POOL_SIZE (1024<< 10) + +/* ...alignment for shared buffers */ +#define XF_PROXY_ALIGNMENT 64 diff --git a/hifi/xaf/host-apf/include/sys/fio/xf-hal.h b/hifi/xaf/host-apf/include/sys/fio/xf-hal.h new file mode 100644 index 00000000..15a82b03 --- /dev/null +++ b/hifi/xaf/host-apf/include/sys/fio/xf-hal.h @@ -0,0 +1,34 @@ +/******************************************************************************* +* 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 __XF_H +#error "xf-hal.h mustn't be included directly" +#endif + +/******************************************************************************* + * Includes + ******************************************************************************/ + +/* ...primitive types */ +#include "xf-types.h" + +/* ...anything else? - tbd */ diff --git a/hifi/xaf/host-apf/include/sys/fio/xf-ipc.h b/hifi/xaf/host-apf/include/sys/fio/xf-ipc.h new file mode 100644 index 00000000..2ee859a8 --- /dev/null +++ b/hifi/xaf/host-apf/include/sys/fio/xf-ipc.h @@ -0,0 +1,127 @@ +/******************************************************************************* +* 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 __XF_H +#error "xf-ipc.h mustn't be included directly" +#endif + +/******************************************************************************* + * Types definitions + ******************************************************************************/ + +/* ...proxy IPC data */ +typedef struct xf_proxy_ipc_data +{ + /* ...shared memory buffer pointer */ + void *shmem; + + /* ...file descriptor */ + int fd; + + /* ...pipe for asynchronous response delivery */ + int pipe[2]; + +} xf_proxy_ipc_data_t; + +/******************************************************************************* + * Helpers for asynchronous response delivery + ******************************************************************************/ + +#define xf_proxy_ipc_response_put(ipc, msg) \ + (write((ipc)->pipe[1], (msg), sizeof(*(msg))) == sizeof(*(msg)) ? 0 : -errno) + +#define xf_proxy_ipc_response_get(ipc, msg) \ + (read((ipc)->pipe[0], (msg), sizeof(*(msg))) == sizeof(*(msg)) ? 0 : -errno) + +/******************************************************************************* + * Shared memory translation + ******************************************************************************/ + +/* ...translate proxy shared address into local virtual address */ +static inline void * xf_ipc_a2b(xf_proxy_ipc_data_t *ipc, u32 address) +{ + if (address < XF_CFG_REMOTE_IPC_POOL_SIZE) + return (unsigned char *) ipc->shmem + address; + else if (address == XF_PROXY_NULL) + return NULL; + else + return (void *) -1; +} + +/* ...translate local virtual address into shared proxy address */ +static inline u32 xf_ipc_b2a(xf_proxy_ipc_data_t *ipc, void *b) +{ + u32 a; + + if (b == NULL) + return XF_PROXY_NULL; + if ((a = (u32)((u8 *)b - (u8 *)ipc->shmem)) < XF_CFG_REMOTE_IPC_POOL_SIZE) + return a; + else + return XF_PROXY_BADADDR; +} + +/******************************************************************************* + * Component inter-process communication + ******************************************************************************/ + +typedef struct xf_ipc_data +{ + /* ...asynchronous response delivery pipe */ + int pipe[2]; + +} xf_ipc_data_t; + +/******************************************************************************* + * Helpers for asynchronous response delivery + ******************************************************************************/ + +#define xf_ipc_response_put(ipc, msg) \ + (write((ipc)->pipe[1], (msg), sizeof(*(msg))) == sizeof(*(msg)) ? 0 : -errno) + +#define xf_ipc_response_get(ipc, msg) \ + (read((ipc)->pipe[0], (msg), sizeof(*(msg))) == sizeof(*(msg)) ? 0 : -errno) + +#define xf_ipc_data_init(ipc) \ + (pipe((ipc)->pipe) == 0 ? 0 : -errno) + +#define xf_ipc_data_destroy(ipc) \ + (close((ipc)->pipe[0]), close((ipc)->pipe[1])) + +/******************************************************************************* +* API functions + ******************************************************************************/ + +/* ...send asynchronous command */ +extern int xf_ipc_send(xf_proxy_ipc_data_t *ipc, xf_proxy_msg_t *msg, void *b); + +/* ...wait for response from remote proxy */ +extern int xf_ipc_wait(xf_proxy_ipc_data_t *ipc, u32 timeout); + +/* ...receive response from IPC layer */ +extern int xf_ipc_recv(xf_proxy_ipc_data_t *ipc, xf_proxy_msg_t *msg, void **b); + +/* ...open proxy interface on proper DSP partition */ +extern int xf_ipc_open(xf_proxy_ipc_data_t *proxy, u32 core, void *p_shmem); + +/* ...close proxy handle */ +extern void xf_ipc_close(xf_proxy_ipc_data_t *proxy, u32 core); diff --git a/hifi/xaf/host-apf/include/sys/fio/xf-runtime.h b/hifi/xaf/host-apf/include/sys/fio/xf-runtime.h new file mode 100644 index 00000000..9cad95f4 --- /dev/null +++ b/hifi/xaf/host-apf/include/sys/fio/xf-runtime.h @@ -0,0 +1,35 @@ +/******************************************************************************* +* 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 __XF_H +#error "xf-runtime.h mustn't be included directly" +#endif + +/******************************************************************************* + * Includes + ******************************************************************************/ + +/* ...platform HAL layer */ +#include "xf-hal.h" + +/* ...OS abstraction layer */ +#include "xf-osal.h" diff --git a/hifi/xaf/host-apf/include/sys/fio/xf-types.h b/hifi/xaf/host-apf/include/sys/fio/xf-types.h new file mode 100644 index 00000000..a610c8e1 --- /dev/null +++ b/hifi/xaf/host-apf/include/sys/fio/xf-types.h @@ -0,0 +1,88 @@ +/******************************************************************************* +* 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 __XF_H +#error "xf-types.h mustn't be included directly" +#endif + +/******************************************************************************* + * Standard includes + ******************************************************************************/ + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + +#include <stdarg.h> +#include <stdint.h> +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <assert.h> +#include <errno.h> + +#include <unistd.h> +#include <fcntl.h> +#include <pthread.h> +#include <signal.h> +#include <limits.h> +#include <sys/mman.h> +#include <sys/ioctl.h> +#include <sys/time.h> + +/******************************************************************************* + * Primitive types + ******************************************************************************/ + +typedef uint32_t u32; +typedef int32_t s32; +typedef uint16_t u16; +typedef int16_t s16; +typedef uint8_t u8; +typedef int8_t s8; + +/******************************************************************************* + * Macros definitions + ******************************************************************************/ + +/* ...NULL-address specification */ +#define XF_PROXY_NULL (~0U) + +/* ...invalid proxy address */ +#define XF_PROXY_BADADDR XF_CFG_REMOTE_IPC_POOL_SIZE + +/******************************************************************************* + * Auxiliary helpers + ******************************************************************************/ + +/* ...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) + diff --git a/hifi/xaf/host-apf/include/xaf-api.h b/hifi/xaf/host-apf/include/xaf-api.h new file mode 100644 index 00000000..5cebb430 --- /dev/null +++ b/hifi/xaf/host-apf/include/xaf-api.h @@ -0,0 +1,139 @@ +/******************************************************************************* +* 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. + +******************************************************************************/ + + +/* ...number of max input buffers */ +#define XAF_MAX_INBUFS 2 +#define XAF_INBUF_SIZE 8192 + +typedef enum { + XAF_DECODER = 0, + XAF_ENCODER = 1, + XAF_MIXER = 2, + XAF_PRE_PROC = 3, + XAF_POST_PROC = 4, +} xaf_comp_type; + +typedef enum { + XAF_STARTING = 0, + XAF_INIT_DONE = 1, + XAF_NEED_INPUT = 2, + XAF_OUTPUT_READY = 3, + XAF_EXEC_DONE = 4, +} xaf_comp_status; + +typedef enum { + XAF_START_FLAG = 1, + XAF_EXEC_FLAG = 2, + XAF_INPUT_OVER_FLAG = 3, + XAF_INPUT_READY_FLAG = 4, + XAF_NEED_OUTPUT_FLAG = 5, +} xaf_comp_flag; + +typedef enum { + XAF_NO_ERROR = 0, + XAF_PTR_ERROR = -1, + XAF_INVALID_VALUE = -2, + XAF_ROUTING_ERROR = -3, + /*XAF_XOS_ERROR = -4,*/ + XAF_API_ERR = -5, +} XAF_ERR_CODE; + +typedef enum { + XAF_MEM_ID_DEV = 0, + XAF_MEM_ID_COMP = 1, +} XAF_MEM_ID; + +/* structure for component memory sizes */ +typedef struct xaf_mem_size_s{ + u32 persist; + u32 scratch; + u32 input; + u32 output; +}xaf_mem_size_t; + +/* structure for host-side utility handles */ +typedef struct xaf_ap_utils_s{ + int xf_cfg_remote_ipc_pool_size; + xaf_mem_size_t mem_size; +}xaf_ap_utils_t; + +typedef struct xaf_format_s { + u32 sample_rate; + u32 channels; + u32 pcm_width; + u32 input_length; + u32 output_length; +} xaf_format_t; + +#ifndef XAF_HOSTLESS +typedef struct xaf_info_s { + void * buf; + u32 length; +} xaf_info_t; +#endif + +XAF_ERR_CODE xaf_adev_open(void **pp_adev, s32 audio_frmwk_buf_size, s32 audio_comp_buf_size, xaf_mem_malloc_fxn_t mm_malloc, xaf_mem_free_fxn_t mm_free); +XAF_ERR_CODE xaf_adev_close(void *adev_ptr, xaf_comp_flag flag); + +XAF_ERR_CODE xaf_comp_create(void* p_adev, void **p_comp, xf_id_t comp_id, u32 ninbuf, u32 noutbuf, void *pp_inbuf[], xaf_comp_type comp_type); +XAF_ERR_CODE xaf_comp_delete(void* p_comp); +XAF_ERR_CODE xaf_comp_set_config(void *p_comp, s32 num_param, s32 *p_param); +XAF_ERR_CODE xaf_comp_get_config(void *p_comp, s32 num_param, s32 *p_param); +XAF_ERR_CODE xaf_comp_process(void *p_adev, void *p_comp, void *p_buf, u32 length, xaf_comp_flag flag); +XAF_ERR_CODE xaf_connect(void *p_src, void *p_dest, s32 num_buf); + +/* Not available in this version yet. +XAF_ERR_CODE xaf_disconnect(xaf_comp_t *p_comp); +*/ + +XAF_ERR_CODE xaf_comp_get_status(void *p_adev, void *p_comp, xaf_comp_status *p_status, xaf_info_t *p_info); + +/* ...check null pointer */ +#define XAF_CHK_PTR(ptr) \ +({ \ + int __ret; \ + \ + if ((__ret = (int)(ptr)) == 0) \ + { \ + TRACE(ERROR, _x("Null pointer error: %d"), __ret); \ + return XAF_PTR_ERROR; \ + } \ + __ret; \ +}) + +/* ...check range */ +#define XAF_CHK_RANGE(val, min, max) \ +({ \ + int __ret = val; \ + \ + if ((__ret < (int)min) || (__ret > (int)max)) \ + { \ + TRACE(ERROR, _x("Invalid value: %d"), __ret); \ + return XAF_INVALID_VALUE; \ + } \ + __ret; \ +}) + + + + diff --git a/hifi/xaf/host-apf/include/xaf-structs.h b/hifi/xaf/host-apf/include/xaf-structs.h new file mode 100644 index 00000000..f632600a --- /dev/null +++ b/hifi/xaf/host-apf/include/xaf-structs.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. + +******************************************************************************/ + +/* ...size of auxiliary pool for communication with HiFi */ +#define XAF_AUX_POOL_SIZE 32 + +/* ...length of auxiliary pool messages */ +#define XAF_AUX_POOL_MSG_LENGTH 128 +#define XAF_MAX_CONFIG_PARAMS (XAF_AUX_POOL_MSG_LENGTH >> 3) + +typedef struct xaf_comp xaf_comp_t; + +struct xaf_comp { + xf_handle_t handle; + + u32 inp_routed; + u32 out_routed; + u32 inp_ports; + u32 out_ports; + u32 init_done; + u32 pending_resp; + u32 expect_out_cmd; + u32 input_over; + + xaf_comp_type comp_type; + xaf_comp_status comp_status; + u32 start_cmd_issued; + u32 exec_cmd_issued; + void *start_buf; + + xaf_format_t inp_format; + xaf_format_t out_format; + + xf_pool_t *inpool; + xf_pool_t *outpool; + u32 noutbuf; + + xaf_comp_t *next; + + u32 ninbuf; + void *p_adev; + //xaf_comp_state comp_state; + void *comp_ptr; +}; + +typedef struct xaf_adev_s { + xf_proxy_t proxy; + xaf_comp_t *comp_chain; + + u32 n_comp; + void *adev_ptr; + void *p_dspMem; + void *p_apMem; + void *p_dspLocalBuff; + void *p_apSharedMem; + + xaf_ap_utils_t *p_ap_utils; //host-side utility structure handle + void *(*pxf_mem_malloc_fxn)(s32, s32); + void (*pxf_mem_free_fxn)(void *,s32); + //xaf_adev_state adev_state; + +} xaf_adev_t; + diff --git a/hifi/xaf/host-apf/include/xf-debug.h b/hifi/xaf/host-apf/include/xf-debug.h new file mode 100644 index 00000000..83172302 --- /dev/null +++ b/hifi/xaf/host-apf/include/xf-debug.h @@ -0,0 +1,194 @@ +/******************************************************************************* +* 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 __XF_H +#error "xf-debug.h mustn't be included directly" +#endif + +/******************************************************************************* + * Auxiliary macros (put into "xf-types.h"?) + ******************************************************************************/ + +#ifndef offset_of +#define offset_of(type, member) \ + ((int)(intptr_t)&(((const type *)(0))->member)) +#endif + +#ifndef container_of +#define container_of(ptr, type, member) \ + ((type *)((void *)(ptr) - offset_of(type, member))) +#endif + +/******************************************************************************* + * 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, ...); + +/* ...tracing facility initialization */ +extern void xf_trace_init(const char *banner); + +/* ...initialize tracing facility */ +#define TRACE_INIT(banner) (xf_trace_init(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; xf_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(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 */ \ + 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) \ +({ \ + intptr_t __ret; \ + \ + if (!(__ret = (intptr_t)(cond))) \ + { \ + TRACE(ERROR, _x("check failed")); \ + return (error); \ + } \ + (int)__ret; \ +}) + diff --git a/hifi/xaf/host-apf/include/xf-opcode.h b/hifi/xaf/host-apf/include/xf-opcode.h new file mode 100644 index 00000000..f585f5c2 --- /dev/null +++ b/hifi/xaf/host-apf/include/xf-opcode.h @@ -0,0 +1,297 @@ +/******************************************************************************* +* 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 __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) + +/******************************************************************************* + * 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) */ + u8 data[0]; + +} __attribute__ ((__packed__)) xf_ext_param_msg_t; + +/* ...access macros */ + +#define xf_ext_param_first(e) \ + (&(e)->desc) + +#define xf_ext_param_next(d) \ + (xf_ext_param_desc_t *)(((xf_ext_param_msg_t *)(d))->data + (((d)->length + 3) & ~3)) + +#define xf_ext_param_length(e, d) \ + ((u32)((u8 *)(d) - (u8 *)(ext))) + +#define xf_ext_param_data(d, t) \ + ((t *)&(d)[1]) + +#define xf_ext_param_setup(d, i, t, s) \ + ((d)->id = (i), (d)->length = (s), xf_ext_param_data(d, 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/host-apf/include/xf-proto.h b/hifi/xaf/host-apf/include/xf-proto.h new file mode 100644 index 00000000..095e353a --- /dev/null +++ b/hifi/xaf/host-apf/include/xf-proto.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. + +******************************************************************************/ + +#ifndef __XF_H +#error "xf-proto.h mustn't be included directly" +#endif + +/******************************************************************************* + * Forward types declarations + ******************************************************************************/ + +/* ...component string identifier */ +typedef const char *xf_id_t; + +/* ...handle to proxy data */ +typedef struct xf_proxy xf_proxy_t; + +/* ...handle to component data */ +typedef struct xf_handle xf_handle_t; + +/* ...buffer pool */ +typedef struct xf_pool xf_pool_t; + +/* ...individual buffer from pool */ +typedef struct xf_buffer xf_buffer_t; + +/* ...buffer pool type */ +typedef u32 xf_pool_type_t; + +/* ...user-message */ +typedef struct xf_user_msg xf_user_msg_t; + +/* ...proxy-message */ +typedef struct xf_proxy_msg xf_proxy_msg_t; + +/* ...response callback */ +typedef void (*xf_response_cb)(xf_handle_t *h, xf_user_msg_t *msg); + +typedef void* xaf_mem_malloc_fxn_t(s32 size, s32 id); +typedef void xaf_mem_free_fxn_t(void* ptr, s32 id); + +/******************************************************************************* + * High-level API functions + ******************************************************************************/ + +/* ...component operations */ +extern int xf_open(xf_proxy_t *proxy, xf_handle_t *handle, xf_id_t id, u32 core, xf_response_cb cb); +extern void xf_close(xf_handle_t *handle); +extern int xf_command(xf_handle_t *handle, u32 dst, u32 opcode, void *buf, u32 length); +extern int xf_route(xf_handle_t *src, u32 s_port, xf_handle_t *dst, u32 d_port, u32 num, u32 size, u32 align); +extern int xf_unroute(xf_handle_t *src, u32 s_port); + +/* ...shared buffers operations */ +extern int xf_pool_alloc(xf_proxy_t *proxy, u32 number, u32 length, xf_pool_type_t type, xf_pool_t **pool, s32 id, + xaf_mem_malloc_fxn_t, xaf_mem_free_fxn_t); +extern void xf_pool_free(xf_pool_t *pool, s32 id, xaf_mem_free_fxn_t); +extern xf_buffer_t * xf_buffer_get(xf_pool_t *pool); +extern void xf_buffer_put(xf_buffer_t *buffer); + +/* ...proxy operations */ +extern int xf_proxy_init(xf_proxy_t *proxy, u32 core, void *p_shmem); +extern void xf_proxy_close(xf_proxy_t *proxy); + diff --git a/hifi/xaf/host-apf/include/xf-proxy.h b/hifi/xaf/host-apf/include/xf-proxy.h new file mode 100644 index 00000000..90d70793 --- /dev/null +++ b/hifi/xaf/host-apf/include/xf-proxy.h @@ -0,0 +1,297 @@ +/******************************************************************************* +* 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 __XF_H +#error "xf-proxy.h mustn't be included directly" +#endif + +/******************************************************************************* + * User-message description - move from here to API - tbd + ******************************************************************************/ + +/* ...need that at all? hope no */ +struct xf_user_msg +{ + /* ...source component specification */ + u32 id; + + /* ...message opcode */ + u32 opcode; + + /* ...buffer length */ + u32 length; + + /* ...buffer pointer */ + void *buffer; +}; + +/* ...proxy message - bad placing of that thing here - tbd */ +struct xf_proxy_msg +{ + /* ...session-id field */ + uint32_t id; + + /* ...message opcode */ + uint32_t opcode; + + /* ...buffer length */ + uint32_t length; + + /* ...buffer pointer */ + uint64_t address; + uint64_t v_address; + +} __attribute__((__packed__)); + +typedef struct xf_proxy_msg_driv +{ + /* ...session ID */ + uint32_t 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_driv_t; +/******************************************************************************* + * Buffer pools + ******************************************************************************/ + +/* ...buffer pool type */ +enum xf_pool_type +{ + XF_POOL_AUX = 0, + XF_POOL_INPUT = 1, + XF_POOL_OUTPUT = 2 +}; + +/* ...buffer link pointer */ +typedef union xf_buffer_link +{ + /* ...pointer to next free buffer in a pool (for free buffer) */ + xf_buffer_t *next; + + /* ...reference to a buffer pool (for allocated buffer) */ + xf_pool_t *pool; + +} xf_buffer_link_t; + +/* ...buffer descriptor */ +struct xf_buffer +{ + /* ...virtual address of contiguous buffer */ + void *address; + + /* ...link pointer */ + xf_buffer_link_t link; +}; + +/* ...buffer pool */ +struct xf_pool +{ + /* ...reference to proxy data */ + xf_proxy_t *proxy; + + /* ...length of individual buffer in a pool */ + u32 length; + + /* ...number of buffers in a pool */ + u32 number; + + /* ...pointer to pool memory */ + void *p; + + /* ...pointer to first free buffer in a pool */ + xf_buffer_t *free; + + /* ...individual buffers */ + xf_buffer_t buffer[0]; +}; + +/* ...accessor to buffer data */ +static inline void * xf_buffer_data(xf_buffer_t *buffer) +{ + return buffer->address; +} + +/* ...length of buffer data */ +static inline size_t xf_buffer_length(xf_buffer_t *buffer) +{ + return buffer->link.pool->length; +} + +/******************************************************************************* + * Proxy handle definition + ******************************************************************************/ + +/* ...free clients list */ +typedef union xf_proxy_cmap_link +{ + /* ...index of next free client in the list */ + u32 next; + + /* ...pointer to allocated component handle */ + xf_handle_t *handle; + +} xf_proxy_cmap_link_t; + +/* ...proxy data structure */ +struct xf_proxy +{ + /* ...platform-specific IPC data */ + xf_proxy_ipc_data_t ipc; + + /* ...auxiliary buffer pool for clients */ + xf_pool_t *aux; + + /* ...global proxy lock */ + xf_lock_t lock; + + /* ...proxy thread handle */ + xf_thread_t thread; + + /* ...proxy identifier (core of remote DSP hosting SHMEM interface) */ + u32 core; + + /* ...client association map */ + xf_proxy_cmap_link_t cmap[XF_CFG_PROXY_MAX_CLIENTS]; +}; + +/******************************************************************************* + * Auxiliary proxy helpers + ******************************************************************************/ + +/* ...get proxy identifier */ +static inline u32 xf_proxy_id(xf_proxy_t *proxy) +{ + return proxy->core; +} + +/* ...lock proxy data */ +static inline void xf_proxy_lock(xf_proxy_t *proxy) +{ + __xf_lock(&proxy->lock); +} + +/* ...unlock proxy data */ +static inline void xf_proxy_unlock(xf_proxy_t *proxy) +{ + __xf_unlock(&proxy->lock); +} + +/* ...translate proxy shared address into local virtual address */ +static inline void * xf_proxy_a2b(xf_proxy_t *proxy, u32 address) +{ + return xf_ipc_a2b(&proxy->ipc, address); +} + +/* ...translate local virtual address into shared proxy address */ +static inline u32 xf_proxy_b2a(xf_proxy_t *proxy, void *b) +{ + return xf_ipc_b2a(&proxy->ipc, b); +} + +/* ...submit asynchronous response message */ +static inline int xf_proxy_response_put(xf_proxy_t *proxy, xf_proxy_msg_t *msg) +{ + return xf_proxy_ipc_response_put(&proxy->ipc, msg); +} + +/* ...retrieve asynchronous response message */ +static inline int xf_proxy_response_get(xf_proxy_t *proxy, xf_proxy_msg_t *msg) +{ + return xf_proxy_ipc_response_get(&proxy->ipc, msg); +} + +/******************************************************************************* + * Component handle definition + ******************************************************************************/ + +struct xf_handle +{ + /* ...platform-specific IPC data */ + xf_ipc_data_t ipc; + + /* ...reference to proxy data */ + xf_proxy_t *proxy; + + /* ...component lock */ + xf_lock_t lock; + + /* ...auxiliary control buffer for control transactions */ + xf_buffer_t *aux; + + /* ...global client-id of the component */ + u32 id; + + /* ...local client number (think about merging into "id" field - tbd) */ + u32 client; + + /* ...response processing hook */ + xf_response_cb response; +}; + +/******************************************************************************* + * Auxiliary component helpers + ******************************************************************************/ + +/* ...component client-id (global scope) */ +static inline u32 xf_handle_id(xf_handle_t *handle) +{ + return handle->id; +} + +/* ...pointer to auxiliary buffer */ +static inline void * xf_handle_aux(xf_handle_t *handle) +{ + return xf_buffer_data(handle->aux); +} + +/* ...acquire component lock */ +static inline void xf_lock(xf_handle_t *handle) +{ + __xf_lock(&handle->lock); +} + +/* ...release component lock */ +static inline void xf_unlock(xf_handle_t *handle) +{ + __xf_unlock(&handle->lock); +} + +/* ...put asynchronous response into local IPC */ +static inline int xf_response_put(xf_handle_t *handle, xf_user_msg_t *msg) +{ + return xf_ipc_response_put(&handle->ipc, msg); +} + +/* ...get asynchronous response from local IPC */ +static inline int xf_response_get(xf_handle_t *handle, xf_user_msg_t *msg) +{ + return xf_ipc_response_get(&handle->ipc, msg); +} diff --git a/hifi/xaf/host-apf/include/xf.h b/hifi/xaf/host-apf/include/xf.h new file mode 100644 index 00000000..6af69ce6 --- /dev/null +++ b/hifi/xaf/host-apf/include/xf.h @@ -0,0 +1,53 @@ +/******************************************************************************* +* 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. + +******************************************************************************/ + +#ifdef __XF_H +#error "xf.h included more than once" +#endif + +#define __XF_H + +/******************************************************************************* + * Common runtime framework + ******************************************************************************/ + +/* ...target configuration */ +#include "xf-config.h" + +/* ...platform run-time */ +#include "xf-runtime.h" + +/* ...debugging facility */ +#include "xf-debug.h" + +/* ...API prototypes */ +#include "xf-proto.h" + +/* ...standard opcodes */ +#include "xf-opcode.h" + +/* ...platform-specific IPC layer */ +#include "xf-ipc.h" + +/* ...proxy definitions */ +#include "xf-proxy.h" + diff --git a/hifi/xaf/host-apf/playback/tinyalsa/asoundlib.h b/hifi/xaf/host-apf/playback/tinyalsa/asoundlib.h new file mode 100644 index 00000000..753a996b --- /dev/null +++ b/hifi/xaf/host-apf/playback/tinyalsa/asoundlib.h @@ -0,0 +1,314 @@ +/******************************************************************************* +* 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 ASOUNDLIB_H +#define ASOUNDLIB_H + +#include <sys/time.h> +#include <stddef.h> + +#if defined(__cplusplus) +extern "C" { +#endif + +/* + * PCM API + */ + +struct pcm; + +#define PCM_OUT 0x00000000 +#define PCM_IN 0x10000000 +#define PCM_MMAP 0x00000001 +#define PCM_NOIRQ 0x00000002 +#define PCM_NORESTART 0x00000004 /* PCM_NORESTART - when set, calls to + * pcm_write for a playback stream will not + * attempt to restart the stream in the case + * of an underflow, but will return -EPIPE + * instead. After the first -EPIPE error, the + * stream is considered to be stopped, and a + * second call to pcm_write will attempt to + * restart the stream. + */ +#define PCM_MONOTONIC 0x00000008 /* see pcm_get_htimestamp */ + +/* PCM runtime states */ +#define PCM_STATE_OPEN 0 +#define PCM_STATE_SETUP 1 +#define PCM_STATE_PREPARED 2 +#define PCM_STATE_RUNNING 3 +#define PCM_STATE_XRUN 4 +#define PCM_STATE_DRAINING 5 +#define PCM_STATE_PAUSED 6 +#define PCM_STATE_SUSPENDED 7 +#define PCM_STATE_DISCONNECTED 8 + +/* TLV header size*/ +#define TLV_HEADER_SIZE (2 * sizeof(unsigned int)) + +/* Bit formats */ +enum pcm_format { + PCM_FORMAT_INVALID = -1, + PCM_FORMAT_S16_LE = 0, /* 16-bit signed */ + PCM_FORMAT_S32_LE, /* 32-bit signed */ + PCM_FORMAT_S8, /* 8-bit signed */ + PCM_FORMAT_S24_LE, /* 24-bits in 4-bytes */ + PCM_FORMAT_S24_3LE, /* 24-bits in 3-bytes */ + + PCM_FORMAT_MAX, +}; + +/* Bitmask has 256 bits (32 bytes) in asound.h */ +struct pcm_mask { + unsigned int bits[32 / sizeof(unsigned int)]; +}; + +/* Configuration for a stream */ +struct pcm_config { + unsigned int channels; + unsigned int rate; + unsigned int period_size; + unsigned int period_count; + enum pcm_format format; + + /* Values to use for the ALSA start, stop and silence thresholds, and + * silence size. Setting any one of these values to 0 will cause the + * default tinyalsa values to be used instead. + * Tinyalsa defaults are as follows. + * + * start_threshold : period_count * period_size + * stop_threshold : period_count * period_size + * silence_threshold : 0 + * silence_size : 0 + */ + unsigned int start_threshold; + unsigned int stop_threshold; + unsigned int silence_threshold; + unsigned int silence_size; + + /* Minimum number of frames available before pcm_mmap_write() will actually + * write into the kernel buffer. Only used if the stream is opened in mmap mode + * (pcm_open() called with PCM_MMAP flag set). Use 0 for default. + */ + int avail_min; +}; + +/* PCM parameters */ +enum pcm_param +{ + /* mask parameters */ + PCM_PARAM_ACCESS, + PCM_PARAM_FORMAT, + PCM_PARAM_SUBFORMAT, + /* interval parameters */ + PCM_PARAM_SAMPLE_BITS, + PCM_PARAM_FRAME_BITS, + PCM_PARAM_CHANNELS, + PCM_PARAM_RATE, + PCM_PARAM_PERIOD_TIME, + PCM_PARAM_PERIOD_SIZE, + PCM_PARAM_PERIOD_BYTES, + PCM_PARAM_PERIODS, + PCM_PARAM_BUFFER_TIME, + PCM_PARAM_BUFFER_SIZE, + PCM_PARAM_BUFFER_BYTES, + PCM_PARAM_TICK_TIME, +}; + +/* Mixer control types */ +enum mixer_ctl_type { + MIXER_CTL_TYPE_BOOL, + MIXER_CTL_TYPE_INT, + MIXER_CTL_TYPE_ENUM, + MIXER_CTL_TYPE_BYTE, + MIXER_CTL_TYPE_IEC958, + MIXER_CTL_TYPE_INT64, + MIXER_CTL_TYPE_UNKNOWN, + + MIXER_CTL_TYPE_MAX, +}; + +/* Open and close a stream */ +struct pcm *pcm_open(unsigned int card, unsigned int device, + unsigned int flags, struct pcm_config *config); +int pcm_close(struct pcm *pcm); +int pcm_is_ready(struct pcm *pcm); + +/* Obtain the parameters for a PCM */ +struct pcm_params *pcm_params_get(unsigned int card, unsigned int device, + unsigned int flags); +void pcm_params_free(struct pcm_params *pcm_params); + +struct pcm_mask *pcm_params_get_mask(struct pcm_params *pcm_params, + enum pcm_param param); +unsigned int pcm_params_get_min(struct pcm_params *pcm_params, + enum pcm_param param); +void pcm_params_set_min(struct pcm_params *pcm_params, + enum pcm_param param, unsigned int val); +unsigned int pcm_params_get_max(struct pcm_params *pcm_params, + enum pcm_param param); +void pcm_params_set_max(struct pcm_params *pcm_params, + enum pcm_param param, unsigned int val); + +/* Converts the pcm parameters to a human readable string. + * The string parameter is a caller allocated buffer of size bytes, + * which is then filled up to size - 1 and null terminated, + * if size is greater than zero. + * The return value is the number of bytes copied to string + * (not including null termination) if less than size; otherwise, + * the number of bytes required for the buffer. + */ +int pcm_params_to_string(struct pcm_params *params, char *string, unsigned int size); + +/* Returns 1 if the pcm_format is present (format bit set) in + * the pcm_params structure; 0 otherwise, or upon unrecognized format. + */ +int pcm_params_format_test(struct pcm_params *params, enum pcm_format format); + +/* Set and get config */ +int pcm_get_config(struct pcm *pcm, struct pcm_config *config); +int pcm_set_config(struct pcm *pcm, struct pcm_config *config); + +/* Returns a human readable reason for the last error */ +const char *pcm_get_error(struct pcm *pcm); + +/* Returns the sample size in bits for a PCM format. + * As with ALSA formats, this is the storage size for the format, whereas the + * format represents the number of significant bits. For example, + * PCM_FORMAT_S24_LE uses 32 bits of storage. + */ +unsigned int pcm_format_to_bits(enum pcm_format format); + +/* Returns the buffer size (int frames) that should be used for pcm_write. */ +unsigned int pcm_get_buffer_size(struct pcm *pcm); +unsigned int pcm_frames_to_bytes(struct pcm *pcm, unsigned int frames); +unsigned int pcm_bytes_to_frames(struct pcm *pcm, unsigned int bytes); + +/* Returns the pcm latency in ms */ +unsigned int pcm_get_latency(struct pcm *pcm); + +/* Returns available frames in pcm buffer and corresponding time stamp. + * The clock is CLOCK_MONOTONIC if flag PCM_MONOTONIC was specified in pcm_open, + * otherwise the clock is CLOCK_REALTIME. + * For an input stream, frames available are frames ready for the + * application to read. + * For an output stream, frames available are the number of empty frames available + * for the application to write. + */ +int pcm_get_htimestamp(struct pcm *pcm, unsigned int *avail, + struct timespec *tstamp); + +/* Returns the subdevice on which the pcm has been opened */ +unsigned int pcm_get_subdevice(struct pcm *pcm); + +/* Write data to the fifo. + * Will start playback on the first write or on a write that + * occurs after a fifo underrun. + */ +int pcm_write(struct pcm *pcm, const void *data, unsigned int count); +int pcm_read(struct pcm *pcm, void *data, unsigned int count); + +/* + * mmap() support. + */ +int pcm_mmap_write(struct pcm *pcm, const void *data, unsigned int count); +int pcm_mmap_read(struct pcm *pcm, void *data, unsigned int count); +int pcm_mmap_begin(struct pcm *pcm, void **areas, unsigned int *offset, + unsigned int *frames); +int pcm_mmap_commit(struct pcm *pcm, unsigned int offset, unsigned int frames); +int pcm_mmap_avail(struct pcm *pcm); + +/* Prepare the PCM substream to be triggerable */ +int pcm_prepare(struct pcm *pcm); +/* Start and stop a PCM channel that doesn't transfer data */ +int pcm_start(struct pcm *pcm); +int pcm_stop(struct pcm *pcm); + +/* ioctl function for PCM driver */ +int pcm_ioctl(struct pcm *pcm, int request, ...); + +/* Interrupt driven API */ +int pcm_wait(struct pcm *pcm, int timeout); +int pcm_get_poll_fd(struct pcm *pcm); + +/* Change avail_min after the stream has been opened with no need to stop the stream. + * Only accepted if opened with PCM_MMAP and PCM_NOIRQ flags + */ +int pcm_set_avail_min(struct pcm *pcm, int avail_min); + +/* + * MIXER API + */ + +struct mixer; +struct mixer_ctl; + +/* Open and close a mixer */ +struct mixer *mixer_open(unsigned int card); +void mixer_close(struct mixer *mixer); + +/* Get info about a mixer */ +const char *mixer_get_name(struct mixer *mixer); + +/* Obtain mixer controls */ +unsigned int mixer_get_num_ctls(struct mixer *mixer); +struct mixer_ctl *mixer_get_ctl(struct mixer *mixer, unsigned int id); +struct mixer_ctl *mixer_get_ctl_by_name(struct mixer *mixer, const char *name); + +/* Get info about mixer controls */ +const char *mixer_ctl_get_name(struct mixer_ctl *ctl); +enum mixer_ctl_type mixer_ctl_get_type(struct mixer_ctl *ctl); +const char *mixer_ctl_get_type_string(struct mixer_ctl *ctl); +unsigned int mixer_ctl_get_num_values(struct mixer_ctl *ctl); +unsigned int mixer_ctl_get_num_enums(struct mixer_ctl *ctl); +const char *mixer_ctl_get_enum_string(struct mixer_ctl *ctl, + unsigned int enum_id); + +/* Some sound cards update their controls due to external events, + * such as HDMI EDID byte data changing when an HDMI cable is + * connected. This API allows the count of elements to be updated. + */ +void mixer_ctl_update(struct mixer_ctl *ctl); + +/* Set and get mixer controls */ +int mixer_ctl_get_percent(struct mixer_ctl *ctl, unsigned int id); +int mixer_ctl_set_percent(struct mixer_ctl *ctl, unsigned int id, int percent); + +int mixer_ctl_get_value(struct mixer_ctl *ctl, unsigned int id); +int mixer_ctl_is_access_tlv_rw(struct mixer_ctl *ctl); +int mixer_ctl_get_array(struct mixer_ctl *ctl, void *array, size_t count); +int mixer_ctl_set_value(struct mixer_ctl *ctl, unsigned int id, int value); +int mixer_ctl_set_array(struct mixer_ctl *ctl, const void *array, size_t count); +int mixer_ctl_set_enum_by_string(struct mixer_ctl *ctl, const char *string); + +/* Determe range of integer mixer controls */ +int mixer_ctl_get_range_min(struct mixer_ctl *ctl); +int mixer_ctl_get_range_max(struct mixer_ctl *ctl); + +int mixer_subscribe_events(struct mixer *mixer, int subscribe); +int mixer_wait_event(struct mixer *mixer, int timeout); + +#if defined(__cplusplus) +} /* extern "C" */ +#endif + +#endif diff --git a/hifi/xaf/host-apf/playback/tinyalsa/pcm.c b/hifi/xaf/host-apf/playback/tinyalsa/pcm.c new file mode 100644 index 00000000..e0dc7bb7 --- /dev/null +++ b/hifi/xaf/host-apf/playback/tinyalsa/pcm.c @@ -0,0 +1,1311 @@ +/******************************************************************************* +* 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 <stdio.h> +#include <stdlib.h> +#include <fcntl.h> +#include <stdarg.h> +#include <string.h> +#include <errno.h> +#include <unistd.h> +#include <poll.h> + +#include <sys/ioctl.h> +#include <sys/mman.h> +#include <sys/time.h> +#include <limits.h> + +#include <linux/ioctl.h> +#define __force +//#define __bitwise +#define __user +#include <sound/asound.h> + +#include <tinyalsa/asoundlib.h> + +#define PARAM_MAX SNDRV_PCM_HW_PARAM_LAST_INTERVAL + +/* Logs information into a string; follows snprintf() in that + * offset may be greater than size, and though no characters are copied + * into string, characters are still counted into offset. */ +#define STRLOG(string, offset, size, ...) \ + do { int temp, clipoffset = offset > size ? size : offset; \ + temp = snprintf(string + clipoffset, size - clipoffset, __VA_ARGS__); \ + if (temp > 0) offset += temp; } while (0) + +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) +#endif + +/* refer to SNDRV_PCM_ACCESS_##index in sound/asound.h. */ +static const char * const access_lookup[] = { + "MMAP_INTERLEAVED", + "MMAP_NONINTERLEAVED", + "MMAP_COMPLEX", + "RW_INTERLEAVED", + "RW_NONINTERLEAVED", +}; + +/* refer to SNDRV_PCM_FORMAT_##index in sound/asound.h. */ +static const char * const format_lookup[] = { + /*[0] =*/ "S8", + "U8", + "S16_LE", + "S16_BE", + "U16_LE", + "U16_BE", + "S24_LE", + "S24_BE", + "U24_LE", + "U24_BE", + "S32_LE", + "S32_BE", + "U32_LE", + "U32_BE", + "FLOAT_LE", + "FLOAT_BE", + "FLOAT64_LE", + "FLOAT64_BE", + "IEC958_SUBFRAME_LE", + "IEC958_SUBFRAME_BE", + "MU_LAW", + "A_LAW", + "IMA_ADPCM", + "MPEG", + /*[24] =*/ "GSM", + /* gap */ + [31] = "SPECIAL", + "S24_3LE", + "S24_3BE", + "U24_3LE", + "U24_3BE", + "S20_3LE", + "S20_3BE", + "U20_3LE", + "U20_3BE", + "S18_3LE", + "S18_3BE", + "U18_3LE", + /*[43] =*/ "U18_3BE", +#if 0 + /* recent additions, may not be present on local asound.h */ + "G723_24", + "G723_24_1B", + "G723_40", + "G723_40_1B", + "DSD_U8", + "DSD_U16_LE", +#endif +}; + +/* refer to SNDRV_PCM_SUBFORMAT_##index in sound/asound.h. */ +static const char * const subformat_lookup[] = { + "STD", +}; + +static inline int param_is_mask(int p) +{ + return (p >= SNDRV_PCM_HW_PARAM_FIRST_MASK) && + (p <= SNDRV_PCM_HW_PARAM_LAST_MASK); +} + +static inline int param_is_interval(int p) +{ + return (p >= SNDRV_PCM_HW_PARAM_FIRST_INTERVAL) && + (p <= SNDRV_PCM_HW_PARAM_LAST_INTERVAL); +} + +static inline struct snd_interval *param_to_interval(struct snd_pcm_hw_params *p, int n) +{ + return &(p->intervals[n - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL]); +} + +static inline struct snd_mask *param_to_mask(struct snd_pcm_hw_params *p, int n) +{ + return &(p->masks[n - SNDRV_PCM_HW_PARAM_FIRST_MASK]); +} + +static void param_set_mask(struct snd_pcm_hw_params *p, int n, unsigned int bit) +{ + if (bit >= SNDRV_MASK_MAX) + return; + if (param_is_mask(n)) { + struct snd_mask *m = param_to_mask(p, n); + m->bits[0] = 0; + m->bits[1] = 0; + m->bits[bit >> 5] |= (1 << (bit & 31)); + } +} + +static void param_set_min(struct snd_pcm_hw_params *p, int n, unsigned int val) +{ + if (param_is_interval(n)) { + struct snd_interval *i = param_to_interval(p, n); + i->min = val; + } +} + +static unsigned int param_get_min(struct snd_pcm_hw_params *p, int n) +{ + if (param_is_interval(n)) { + struct snd_interval *i = param_to_interval(p, n); + return i->min; + } + return 0; +} + +static void param_set_max(struct snd_pcm_hw_params *p, int n, unsigned int val) +{ + if (param_is_interval(n)) { + struct snd_interval *i = param_to_interval(p, n); + i->max = val; + } +} + +static unsigned int param_get_max(struct snd_pcm_hw_params *p, int n) +{ + if (param_is_interval(n)) { + struct snd_interval *i = param_to_interval(p, n); + return i->max; + } + return 0; +} + +static void param_set_int(struct snd_pcm_hw_params *p, int n, unsigned int val) +{ + if (param_is_interval(n)) { + struct snd_interval *i = param_to_interval(p, n); + i->min = val; + i->max = val; + i->integer = 1; + } +} + +static unsigned int param_get_int(struct snd_pcm_hw_params *p, int n) +{ + if (param_is_interval(n)) { + struct snd_interval *i = param_to_interval(p, n); + if (i->integer) + return i->max; + } + return 0; +} + +static void param_init(struct snd_pcm_hw_params *p) +{ + int n; + + memset(p, 0, sizeof(*p)); + for (n = SNDRV_PCM_HW_PARAM_FIRST_MASK; + n <= SNDRV_PCM_HW_PARAM_LAST_MASK; n++) { + struct snd_mask *m = param_to_mask(p, n); + m->bits[0] = ~0; + m->bits[1] = ~0; + } + for (n = SNDRV_PCM_HW_PARAM_FIRST_INTERVAL; + n <= SNDRV_PCM_HW_PARAM_LAST_INTERVAL; n++) { + struct snd_interval *i = param_to_interval(p, n); + i->min = 0; + i->max = ~0; + } + p->rmask = ~0U; + p->cmask = 0; + p->info = ~0U; +} + +#define PCM_ERROR_MAX 128 + +struct pcm { + int fd; + unsigned int flags; + int running:1; + int prepared:1; + int underruns; + unsigned int buffer_size; + unsigned int boundary; + char error[PCM_ERROR_MAX]; + struct pcm_config config; + struct snd_pcm_mmap_status *mmap_status; + struct snd_pcm_mmap_control *mmap_control; + struct snd_pcm_sync_ptr *sync_ptr; + void *mmap_buffer; + unsigned int noirq_frames_per_msec; + int wait_for_avail_min; + unsigned int subdevice; +}; + +unsigned int pcm_get_buffer_size(struct pcm *pcm) +{ + return pcm->buffer_size; +} + +const char* pcm_get_error(struct pcm *pcm) +{ + return pcm->error; +} + +unsigned int pcm_get_subdevice(struct pcm *pcm) +{ + return pcm->subdevice; +} + +static int oops(struct pcm *pcm, int e, const char *fmt, ...) +{ + va_list ap; + int sz; + + va_start(ap, fmt); + vsnprintf(pcm->error, PCM_ERROR_MAX, fmt, ap); + va_end(ap); + sz = strlen(pcm->error); + + if (errno) + snprintf(pcm->error + sz, PCM_ERROR_MAX - sz, + ": %s", strerror(e)); + return -1; +} + +static unsigned int pcm_format_to_alsa(enum pcm_format format) +{ + switch (format) { + case PCM_FORMAT_S32_LE: + return SNDRV_PCM_FORMAT_S32_LE; + case PCM_FORMAT_S8: + return SNDRV_PCM_FORMAT_S8; + case PCM_FORMAT_S24_3LE: + return SNDRV_PCM_FORMAT_S24_3LE; + case PCM_FORMAT_S24_LE: + return SNDRV_PCM_FORMAT_S24_LE; + default: + case PCM_FORMAT_S16_LE: + return SNDRV_PCM_FORMAT_S16_LE; + }; +} + +unsigned int pcm_format_to_bits(enum pcm_format format) +{ + switch (format) { + case PCM_FORMAT_S32_LE: + case PCM_FORMAT_S24_LE: + return 32; + case PCM_FORMAT_S24_3LE: + return 24; + default: + case PCM_FORMAT_S16_LE: + return 16; + }; +} + +unsigned int pcm_bytes_to_frames(struct pcm *pcm, unsigned int bytes) +{ + return bytes / (pcm->config.channels * + (pcm_format_to_bits(pcm->config.format) >> 3)); +} + +unsigned int pcm_frames_to_bytes(struct pcm *pcm, unsigned int frames) +{ + return frames * pcm->config.channels * + (pcm_format_to_bits(pcm->config.format) >> 3); +} + +static int pcm_sync_ptr(struct pcm *pcm, int flags) { + if (pcm->sync_ptr) { + pcm->sync_ptr->flags = flags; + if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_SYNC_PTR, pcm->sync_ptr) < 0) + return -1; + } + return 0; +} + +static int pcm_hw_mmap_status(struct pcm *pcm) { + + if (pcm->sync_ptr) + return 0; + + int page_size = sysconf(_SC_PAGE_SIZE); + pcm->mmap_status = mmap(NULL, page_size, PROT_READ, MAP_FILE | MAP_SHARED, + pcm->fd, SNDRV_PCM_MMAP_OFFSET_STATUS); + if (pcm->mmap_status == MAP_FAILED) + pcm->mmap_status = NULL; + if (!pcm->mmap_status) + goto mmap_error; + + pcm->mmap_control = mmap(NULL, page_size, PROT_READ | PROT_WRITE, + MAP_FILE | MAP_SHARED, pcm->fd, SNDRV_PCM_MMAP_OFFSET_CONTROL); + if (pcm->mmap_control == MAP_FAILED) + pcm->mmap_control = NULL; + if (!pcm->mmap_control) { + munmap(pcm->mmap_status, page_size); + pcm->mmap_status = NULL; + goto mmap_error; + } + if (pcm->flags & PCM_MMAP) + pcm->mmap_control->avail_min = pcm->config.avail_min; + else + pcm->mmap_control->avail_min = 1; + + return 0; + +mmap_error: + + pcm->sync_ptr = calloc(1, sizeof(*pcm->sync_ptr)); + if (!pcm->sync_ptr) + return -ENOMEM; + pcm->mmap_status = &pcm->sync_ptr->s.status; + pcm->mmap_control = &pcm->sync_ptr->c.control; + if (pcm->flags & PCM_MMAP) + pcm->mmap_control->avail_min = pcm->config.avail_min; + else + pcm->mmap_control->avail_min = 1; + + pcm_sync_ptr(pcm, 0); + + return 0; +} + +static void pcm_hw_munmap_status(struct pcm *pcm) { + if (pcm->sync_ptr) { + free(pcm->sync_ptr); + pcm->sync_ptr = NULL; + } else { + int page_size = sysconf(_SC_PAGE_SIZE); + if (pcm->mmap_status) + munmap(pcm->mmap_status, page_size); + if (pcm->mmap_control) + munmap(pcm->mmap_control, page_size); + } + pcm->mmap_status = NULL; + pcm->mmap_control = NULL; +} + +static int pcm_areas_copy(struct pcm *pcm, unsigned int pcm_offset, + char *buf, unsigned int src_offset, + unsigned int frames) +{ + int size_bytes = pcm_frames_to_bytes(pcm, frames); + int pcm_offset_bytes = pcm_frames_to_bytes(pcm, pcm_offset); + int src_offset_bytes = pcm_frames_to_bytes(pcm, src_offset); + + /* interleaved only atm */ + if (pcm->flags & PCM_IN) + memcpy(buf + src_offset_bytes, + (char*)pcm->mmap_buffer + pcm_offset_bytes, + size_bytes); + else + memcpy((char*)pcm->mmap_buffer + pcm_offset_bytes, + buf + src_offset_bytes, + size_bytes); + return 0; +} + +static int pcm_mmap_transfer_areas(struct pcm *pcm, char *buf, + unsigned int offset, unsigned int size) +{ + void *pcm_areas; + int commit; + unsigned int pcm_offset, frames, count = 0; + + while (size > 0) { + frames = size; + pcm_mmap_begin(pcm, &pcm_areas, &pcm_offset, &frames); + pcm_areas_copy(pcm, pcm_offset, buf, offset, frames); + commit = pcm_mmap_commit(pcm, pcm_offset, frames); + if (commit < 0) { + oops(pcm, commit, "failed to commit %d frames\n", frames); + return commit; + } + + offset += commit; + count += commit; + size -= commit; + } + return count; +} + +int pcm_get_htimestamp(struct pcm *pcm, unsigned int *avail, + struct timespec *tstamp) +{ + int frames; + int rc; + snd_pcm_uframes_t hw_ptr; + + if (!pcm_is_ready(pcm)) + return -1; + + rc = pcm_sync_ptr(pcm, SNDRV_PCM_SYNC_PTR_APPL|SNDRV_PCM_SYNC_PTR_HWSYNC); + if (rc < 0) + return -1; + + if ((pcm->mmap_status->state != PCM_STATE_RUNNING) && + (pcm->mmap_status->state != PCM_STATE_DRAINING)) + return -1; + + *tstamp = pcm->mmap_status->tstamp; + if (tstamp->tv_sec == 0 && tstamp->tv_nsec == 0) + return -1; + + hw_ptr = pcm->mmap_status->hw_ptr; + if (pcm->flags & PCM_IN) + frames = hw_ptr - pcm->mmap_control->appl_ptr; + else + frames = hw_ptr + pcm->buffer_size - pcm->mmap_control->appl_ptr; + + if (frames < 0) + frames += pcm->boundary; + else if (frames > (int)pcm->boundary) + frames -= pcm->boundary; + + *avail = (unsigned int)frames; + + return 0; +} + +int pcm_write(struct pcm *pcm, const void *data, unsigned int count) +{ + struct snd_xferi x; + + if (pcm->flags & PCM_IN) + return -EINVAL; + + x.buf = (void*)data; + x.frames = count / (pcm->config.channels * + pcm_format_to_bits(pcm->config.format) / 8); + + for (;;) { + if (!pcm->running) { + int prepare_error = pcm_prepare(pcm); + if (prepare_error) + return prepare_error; + if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_WRITEI_FRAMES, &x)) + return oops(pcm, errno, "cannot write initial data"); + pcm->running = 1; + return 0; + } + if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_WRITEI_FRAMES, &x)) { + pcm->prepared = 0; + pcm->running = 0; + if (errno == EPIPE) { + /* we failed to make our window -- try to restart if we are + * allowed to do so. Otherwise, simply allow the EPIPE error to + * propagate up to the app level */ + pcm->underruns++; + if (pcm->flags & PCM_NORESTART) + return -EPIPE; + continue; + } + return oops(pcm, errno, "cannot write stream data"); + } + return 0; + } +} + +int pcm_read(struct pcm *pcm, void *data, unsigned int count) +{ + struct snd_xferi x; + + if (!(pcm->flags & PCM_IN)) + return -EINVAL; + + x.buf = data; + x.frames = count / (pcm->config.channels * + pcm_format_to_bits(pcm->config.format) / 8); + + for (;;) { + if (!pcm->running) { + if (pcm_start(pcm) < 0) { + fprintf(stderr, "start error"); + return -errno; + } + } + if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_READI_FRAMES, &x)) { + pcm->prepared = 0; + pcm->running = 0; + if (errno == EPIPE) { + /* we failed to make our window -- try to restart */ + pcm->underruns++; + continue; + } + return oops(pcm, errno, "cannot read stream data"); + } + return 0; + } +} + +static struct pcm bad_pcm = { + .fd = -1, +}; + +struct pcm_params *pcm_params_get(unsigned int card, unsigned int device, + unsigned int flags) +{ + struct snd_pcm_hw_params *params; + char fn[256]; + int fd; + + snprintf(fn, sizeof(fn), "/dev/snd/pcmC%uD%u%c", card, device, + flags & PCM_IN ? 'c' : 'p'); + + fd = open(fn, O_RDWR); + if (fd < 0) { + fprintf(stderr, "cannot open device '%s'\n", fn); + goto err_open; + } + + params = calloc(1, sizeof(struct snd_pcm_hw_params)); + if (!params) + goto err_calloc; + + param_init(params); + if (ioctl(fd, SNDRV_PCM_IOCTL_HW_REFINE, params)) { + fprintf(stderr, "SNDRV_PCM_IOCTL_HW_REFINE error (%d)\n", errno); + goto err_hw_refine; + } + + close(fd); + + return (struct pcm_params *)params; + +err_hw_refine: + free(params); +err_calloc: + close(fd); +err_open: + return NULL; +} + +void pcm_params_free(struct pcm_params *pcm_params) +{ + struct snd_pcm_hw_params *params = (struct snd_pcm_hw_params *)pcm_params; + + if (params) + free(params); +} + +static int pcm_param_to_alsa(enum pcm_param param) +{ + switch (param) { + case PCM_PARAM_ACCESS: + return SNDRV_PCM_HW_PARAM_ACCESS; + case PCM_PARAM_FORMAT: + return SNDRV_PCM_HW_PARAM_FORMAT; + case PCM_PARAM_SUBFORMAT: + return SNDRV_PCM_HW_PARAM_SUBFORMAT; + case PCM_PARAM_SAMPLE_BITS: + return SNDRV_PCM_HW_PARAM_SAMPLE_BITS; + break; + case PCM_PARAM_FRAME_BITS: + return SNDRV_PCM_HW_PARAM_FRAME_BITS; + break; + case PCM_PARAM_CHANNELS: + return SNDRV_PCM_HW_PARAM_CHANNELS; + break; + case PCM_PARAM_RATE: + return SNDRV_PCM_HW_PARAM_RATE; + break; + case PCM_PARAM_PERIOD_TIME: + return SNDRV_PCM_HW_PARAM_PERIOD_TIME; + break; + case PCM_PARAM_PERIOD_SIZE: + return SNDRV_PCM_HW_PARAM_PERIOD_SIZE; + break; + case PCM_PARAM_PERIOD_BYTES: + return SNDRV_PCM_HW_PARAM_PERIOD_BYTES; + break; + case PCM_PARAM_PERIODS: + return SNDRV_PCM_HW_PARAM_PERIODS; + break; + case PCM_PARAM_BUFFER_TIME: + return SNDRV_PCM_HW_PARAM_BUFFER_TIME; + break; + case PCM_PARAM_BUFFER_SIZE: + return SNDRV_PCM_HW_PARAM_BUFFER_SIZE; + break; + case PCM_PARAM_BUFFER_BYTES: + return SNDRV_PCM_HW_PARAM_BUFFER_BYTES; + break; + case PCM_PARAM_TICK_TIME: + return SNDRV_PCM_HW_PARAM_TICK_TIME; + break; + + default: + return -1; + } +} + +struct pcm_mask *pcm_params_get_mask(struct pcm_params *pcm_params, + enum pcm_param param) +{ + int p; + struct snd_pcm_hw_params *params = (struct snd_pcm_hw_params *)pcm_params; + if (params == NULL) { + return NULL; + } + + p = pcm_param_to_alsa(param); + if (p < 0 || !param_is_mask(p)) { + return NULL; + } + + return (struct pcm_mask *)param_to_mask(params, p); +} + +unsigned int pcm_params_get_min(struct pcm_params *pcm_params, + enum pcm_param param) +{ + struct snd_pcm_hw_params *params = (struct snd_pcm_hw_params *)pcm_params; + int p; + + if (!params) + return 0; + + p = pcm_param_to_alsa(param); + if (p < 0) + return 0; + + return param_get_min(params, p); +} + +void pcm_params_set_min(struct pcm_params *pcm_params, + enum pcm_param param, unsigned int val) +{ + struct snd_pcm_hw_params *params = (struct snd_pcm_hw_params *)pcm_params; + int p; + + if (!params) + return; + + p = pcm_param_to_alsa(param); + if (p < 0) + return; + + param_set_min(params, p, val); +} + +unsigned int pcm_params_get_max(struct pcm_params *pcm_params, + enum pcm_param param) +{ + struct snd_pcm_hw_params *params = (struct snd_pcm_hw_params *)pcm_params; + int p; + + if (!params) + return 0; + + p = pcm_param_to_alsa(param); + if (p < 0) + return 0; + + return param_get_max(params, p); +} + +void pcm_params_set_max(struct pcm_params *pcm_params, + enum pcm_param param, unsigned int val) +{ + struct snd_pcm_hw_params *params = (struct snd_pcm_hw_params *)pcm_params; + int p; + + if (!params) + return; + + p = pcm_param_to_alsa(param); + if (p < 0) + return; + + param_set_max(params, p, val); +} + +static int pcm_mask_test(struct pcm_mask *m, unsigned int index) +{ + const unsigned int bitshift = 5; /* for 32 bit integer */ + const unsigned int bitmask = (1 << bitshift) - 1; + unsigned int element; + + element = index >> bitshift; + if (element >= ARRAY_SIZE(m->bits)) + return 0; /* for safety, but should never occur */ + return (m->bits[element] >> (index & bitmask)) & 1; +} + +static int pcm_mask_to_string(struct pcm_mask *m, char *string, unsigned int size, + char *mask_name, + const char * const *bit_array_name, size_t bit_array_size) +{ + unsigned int i; + unsigned int offset = 0; + + if (m == NULL) + return 0; + if (bit_array_size < 32) { + STRLOG(string, offset, size, "%12s:\t%#08x\n", mask_name, m->bits[0]); + } else { /* spans two or more bitfields, print with an array index */ + for (i = 0; i < (bit_array_size + 31) >> 5; ++i) { + STRLOG(string, offset, size, "%9s[%d]:\t%#08x\n", + mask_name, i, m->bits[i]); + } + } + for (i = 0; i < bit_array_size; ++i) { + if (pcm_mask_test(m, i)) { + STRLOG(string, offset, size, "%12s \t%s\n", "", bit_array_name[i]); + } + } + return offset; +} + +int pcm_params_to_string(struct pcm_params *params, char *string, unsigned int size) +{ + struct pcm_mask *m; + unsigned int min, max; + unsigned int clipoffset, offset; + + m = pcm_params_get_mask(params, PCM_PARAM_ACCESS); + offset = pcm_mask_to_string(m, string, size, + "Access", access_lookup, ARRAY_SIZE(access_lookup)); + m = pcm_params_get_mask(params, PCM_PARAM_FORMAT); + clipoffset = offset > size ? size : offset; + offset += pcm_mask_to_string(m, string + clipoffset, size - clipoffset, + "Format", format_lookup, ARRAY_SIZE(format_lookup)); + m = pcm_params_get_mask(params, PCM_PARAM_SUBFORMAT); + clipoffset = offset > size ? size : offset; + offset += pcm_mask_to_string(m, string + clipoffset, size - clipoffset, + "Subformat", subformat_lookup, ARRAY_SIZE(subformat_lookup)); + min = pcm_params_get_min(params, PCM_PARAM_RATE); + max = pcm_params_get_max(params, PCM_PARAM_RATE); + STRLOG(string, offset, size, " Rate:\tmin=%uHz\tmax=%uHz\n", min, max); + min = pcm_params_get_min(params, PCM_PARAM_CHANNELS); + max = pcm_params_get_max(params, PCM_PARAM_CHANNELS); + STRLOG(string, offset, size, " Channels:\tmin=%u\t\tmax=%u\n", min, max); + min = pcm_params_get_min(params, PCM_PARAM_SAMPLE_BITS); + max = pcm_params_get_max(params, PCM_PARAM_SAMPLE_BITS); + STRLOG(string, offset, size, " Sample bits:\tmin=%u\t\tmax=%u\n", min, max); + min = pcm_params_get_min(params, PCM_PARAM_PERIOD_SIZE); + max = pcm_params_get_max(params, PCM_PARAM_PERIOD_SIZE); + STRLOG(string, offset, size, " Period size:\tmin=%u\t\tmax=%u\n", min, max); + min = pcm_params_get_min(params, PCM_PARAM_PERIODS); + max = pcm_params_get_max(params, PCM_PARAM_PERIODS); + STRLOG(string, offset, size, "Period count:\tmin=%u\t\tmax=%u\n", min, max); + return offset; +} + +int pcm_params_format_test(struct pcm_params *params, enum pcm_format format) +{ + unsigned int alsa_format = pcm_format_to_alsa(format); + + if (alsa_format == SNDRV_PCM_FORMAT_S16_LE && format != PCM_FORMAT_S16_LE) + return 0; /* caution: format not recognized is equivalent to S16_LE */ + return pcm_mask_test(pcm_params_get_mask(params, PCM_PARAM_FORMAT), alsa_format); +} + +int pcm_close(struct pcm *pcm) +{ + if (pcm == &bad_pcm) + return 0; + + pcm_hw_munmap_status(pcm); + + if (pcm->flags & PCM_MMAP) { + pcm_stop(pcm); + munmap(pcm->mmap_buffer, pcm_frames_to_bytes(pcm, pcm->buffer_size)); + } + + if (pcm->fd >= 0) + close(pcm->fd); + pcm->prepared = 0; + pcm->running = 0; + pcm->buffer_size = 0; + pcm->fd = -1; + free(pcm); + return 0; +} + +struct pcm *pcm_open(unsigned int card, unsigned int device, + unsigned int flags, struct pcm_config *config) +{ + struct pcm *pcm; + struct snd_pcm_info info; + struct snd_pcm_hw_params params; + struct snd_pcm_sw_params sparams; + char fn[256]; + int rc; + + pcm = calloc(1, sizeof(struct pcm)); + if (!pcm || !config) + return &bad_pcm; /* TODO: could support default config here */ + + pcm->config = *config; + + snprintf(fn, sizeof(fn), "/dev/snd/pcmC%uD%u%c", card, device, + flags & PCM_IN ? 'c' : 'p'); + + pcm->flags = flags; + pcm->fd = open(fn, O_RDWR|O_NONBLOCK); + if (pcm->fd < 0) { + oops(pcm, errno, "cannot open device '%s'", fn); + return pcm; + } + + if (fcntl(pcm->fd, F_SETFL, fcntl(pcm->fd, F_GETFL) & + ~O_NONBLOCK) < 0) { + oops(pcm, errno, "failed to reset blocking mode '%s'", fn); + goto fail_close; + } + + if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_INFO, &info)) { + oops(pcm, errno, "cannot get info"); + goto fail_close; + } + pcm->subdevice = info.subdevice; + + param_init(¶ms); + param_set_mask(¶ms, SNDRV_PCM_HW_PARAM_FORMAT, + pcm_format_to_alsa(config->format)); + param_set_mask(¶ms, SNDRV_PCM_HW_PARAM_SUBFORMAT, + SNDRV_PCM_SUBFORMAT_STD); + param_set_min(¶ms, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, config->period_size); + param_set_int(¶ms, SNDRV_PCM_HW_PARAM_SAMPLE_BITS, + pcm_format_to_bits(config->format)); + param_set_int(¶ms, SNDRV_PCM_HW_PARAM_FRAME_BITS, + pcm_format_to_bits(config->format) * config->channels); + param_set_int(¶ms, SNDRV_PCM_HW_PARAM_CHANNELS, + config->channels); + param_set_int(¶ms, SNDRV_PCM_HW_PARAM_PERIODS, config->period_count); + param_set_int(¶ms, SNDRV_PCM_HW_PARAM_RATE, config->rate); + + if (flags & PCM_NOIRQ) { + if (!(flags & PCM_MMAP)) { + oops(pcm, -EINVAL, "noirq only currently supported with mmap()."); + goto fail_close; + } + + params.flags |= SNDRV_PCM_HW_PARAMS_NO_PERIOD_WAKEUP; + pcm->noirq_frames_per_msec = config->rate / 1000; + } + + if (flags & PCM_MMAP) + param_set_mask(¶ms, SNDRV_PCM_HW_PARAM_ACCESS, + SNDRV_PCM_ACCESS_MMAP_INTERLEAVED); + else + param_set_mask(¶ms, SNDRV_PCM_HW_PARAM_ACCESS, + SNDRV_PCM_ACCESS_RW_INTERLEAVED); + + if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_HW_PARAMS, ¶ms)) { + oops(pcm, errno, "cannot set hw params"); + goto fail_close; + } + + /* get our refined hw_params */ + config->period_size = param_get_int(¶ms, SNDRV_PCM_HW_PARAM_PERIOD_SIZE); + config->period_count = param_get_int(¶ms, SNDRV_PCM_HW_PARAM_PERIODS); + pcm->buffer_size = config->period_count * config->period_size; + + if (flags & PCM_MMAP) { + pcm->mmap_buffer = mmap(NULL, pcm_frames_to_bytes(pcm, pcm->buffer_size), + PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, pcm->fd, 0); + if (pcm->mmap_buffer == MAP_FAILED) { + oops(pcm, -errno, "failed to mmap buffer %d bytes\n", + pcm_frames_to_bytes(pcm, pcm->buffer_size)); + goto fail_close; + } + } + + memset(&sparams, 0, sizeof(sparams)); + sparams.tstamp_mode = SNDRV_PCM_TSTAMP_ENABLE; + sparams.period_step = 1; + + if (!config->start_threshold) { + if (pcm->flags & PCM_IN) + pcm->config.start_threshold = sparams.start_threshold = 1; + else + pcm->config.start_threshold = sparams.start_threshold = + config->period_count * config->period_size / 2; + } else + sparams.start_threshold = config->start_threshold; + + /* pick a high stop threshold - todo: does this need further tuning */ + if (!config->stop_threshold) { + if (pcm->flags & PCM_IN) + pcm->config.stop_threshold = sparams.stop_threshold = + config->period_count * config->period_size * 10; + else + pcm->config.stop_threshold = sparams.stop_threshold = + config->period_count * config->period_size; + } + else + sparams.stop_threshold = config->stop_threshold; + + if (!pcm->config.avail_min) { + if (pcm->flags & PCM_MMAP) + pcm->config.avail_min = sparams.avail_min = pcm->config.period_size; + else + pcm->config.avail_min = sparams.avail_min = 1; + } else + sparams.avail_min = config->avail_min; + + sparams.xfer_align = config->period_size / 2; /* needed for old kernels */ + sparams.silence_threshold = config->silence_threshold; + sparams.silence_size = config->silence_size; + pcm->boundary = sparams.boundary = pcm->buffer_size; + + while (pcm->boundary * 2 <= INT_MAX - pcm->buffer_size) + pcm->boundary *= 2; + + if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_SW_PARAMS, &sparams)) { + oops(pcm, errno, "cannot set sw params"); + goto fail; + } + + rc = pcm_hw_mmap_status(pcm); + if (rc < 0) { + oops(pcm, rc, "mmap status failed"); + goto fail; + } + +#ifdef SNDRV_PCM_IOCTL_TTSTAMP + if (pcm->flags & PCM_MONOTONIC) { + int arg = SNDRV_PCM_TSTAMP_TYPE_MONOTONIC; + rc = ioctl(pcm->fd, SNDRV_PCM_IOCTL_TTSTAMP, &arg); + if (rc < 0) { + oops(pcm, rc, "cannot set timestamp type"); + goto fail; + } + } +#endif + + pcm->underruns = 0; + return pcm; + +fail: + if (flags & PCM_MMAP) + munmap(pcm->mmap_buffer, pcm_frames_to_bytes(pcm, pcm->buffer_size)); +fail_close: + close(pcm->fd); + pcm->fd = -1; + return pcm; +} + +int pcm_is_ready(struct pcm *pcm) +{ + return pcm->fd >= 0; +} + +int pcm_prepare(struct pcm *pcm) +{ + if (pcm->prepared) + return 0; + + if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_PREPARE) < 0) + return oops(pcm, errno, "cannot prepare channel"); + + pcm->prepared = 1; + return 0; +} + +int pcm_start(struct pcm *pcm) +{ + int prepare_error = pcm_prepare(pcm); + if (prepare_error) + return prepare_error; + + if (pcm->flags & PCM_MMAP) + pcm_sync_ptr(pcm, 0); + + if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_START) < 0) + return oops(pcm, errno, "cannot start channel"); + + pcm->running = 1; + return 0; +} + +int pcm_stop(struct pcm *pcm) +{ + if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_DROP) < 0) + return oops(pcm, errno, "cannot stop channel"); + + pcm->prepared = 0; + pcm->running = 0; + return 0; +} + +static inline int pcm_mmap_playback_avail(struct pcm *pcm) +{ + int avail; + + avail = pcm->mmap_status->hw_ptr + pcm->buffer_size - pcm->mmap_control->appl_ptr; + + if (avail < 0) + avail += pcm->boundary; + else if (avail > (int)pcm->boundary) + avail -= pcm->boundary; + + return avail; +} + +static inline int pcm_mmap_capture_avail(struct pcm *pcm) +{ + int avail = pcm->mmap_status->hw_ptr - pcm->mmap_control->appl_ptr; + if (avail < 0) + avail += pcm->boundary; + return avail; +} + +int pcm_mmap_avail(struct pcm *pcm) +{ + pcm_sync_ptr(pcm, SNDRV_PCM_SYNC_PTR_HWSYNC); + if (pcm->flags & PCM_IN) + return pcm_mmap_capture_avail(pcm); + else + return pcm_mmap_playback_avail(pcm); +} + +static void pcm_mmap_appl_forward(struct pcm *pcm, int frames) +{ + unsigned int appl_ptr = pcm->mmap_control->appl_ptr; + appl_ptr += frames; + + /* check for boundary wrap */ + if (appl_ptr > pcm->boundary) + appl_ptr -= pcm->boundary; + pcm->mmap_control->appl_ptr = appl_ptr; +} + +int pcm_mmap_begin(struct pcm *pcm, void **areas, unsigned int *offset, + unsigned int *frames) +{ + unsigned int continuous, copy_frames, avail; + + /* return the mmap buffer */ + *areas = pcm->mmap_buffer; + + /* and the application offset in frames */ + *offset = pcm->mmap_control->appl_ptr % pcm->buffer_size; + + avail = pcm_mmap_avail(pcm); + if (avail > pcm->buffer_size) + avail = pcm->buffer_size; + continuous = pcm->buffer_size - *offset; + + /* we can only copy frames if the are availabale and continuos */ + copy_frames = *frames; + if (copy_frames > avail) + copy_frames = avail; + if (copy_frames > continuous) + copy_frames = continuous; + *frames = copy_frames; + + return 0; +} + +int pcm_mmap_commit(struct pcm *pcm, unsigned int offset __attribute__((unused)), unsigned int frames) +{ + /* update the application pointer in userspace and kernel */ + pcm_mmap_appl_forward(pcm, frames); + pcm_sync_ptr(pcm, 0); + + return frames; +} + +int pcm_avail_update(struct pcm *pcm) +{ + pcm_sync_ptr(pcm, 0); + return pcm_mmap_avail(pcm); +} + +int pcm_state(struct pcm *pcm) +{ + int err = pcm_sync_ptr(pcm, 0); + if (err < 0) + return err; + + return pcm->mmap_status->state; +} + +int pcm_set_avail_min(struct pcm *pcm, int avail_min) +{ + if ((~pcm->flags) & (PCM_MMAP | PCM_NOIRQ)) + return -ENOSYS; + + pcm->config.avail_min = avail_min; + return 0; +} + +int pcm_wait(struct pcm *pcm, int timeout) +{ + struct pollfd pfd; + int err; + + pfd.fd = pcm->fd; + pfd.events = POLLOUT | POLLERR | POLLNVAL; + + do { + /* let's wait for avail or timeout */ + err = poll(&pfd, 1, timeout); + if (err < 0) + return -errno; + + /* timeout ? */ + if (err == 0) + return 0; + + /* have we been interrupted ? */ + if (errno == -EINTR) + continue; + + /* check for any errors */ + if (pfd.revents & (POLLERR | POLLNVAL)) { + switch (pcm_state(pcm)) { + case PCM_STATE_XRUN: + return -EPIPE; + case PCM_STATE_SUSPENDED: + return -ESTRPIPE; + case PCM_STATE_DISCONNECTED: + return -ENODEV; + default: + return -EIO; + } + } + /* poll again if fd not ready for IO */ + } while (!(pfd.revents & (POLLIN | POLLOUT))); + + return 1; +} + +int pcm_get_poll_fd(struct pcm *pcm) +{ + return pcm->fd; +} + +int pcm_mmap_transfer(struct pcm *pcm, const void *buffer, unsigned int bytes) +{ + int err = 0, frames, avail; + unsigned int offset = 0, count; + + if (bytes == 0) + return 0; + + count = pcm_bytes_to_frames(pcm, bytes); + + while (count > 0) { + + /* get the available space for writing new frames */ + avail = pcm_avail_update(pcm); + if (avail < 0) { + fprintf(stderr, "cannot determine available mmap frames"); + return err; + } + + /* start the audio if we reach the threshold */ + if (!pcm->running && + (pcm->buffer_size - avail) >= pcm->config.start_threshold) { + if (pcm_start(pcm) < 0) { + fprintf(stderr, "start error: hw 0x%x app 0x%x avail 0x%x\n", + (unsigned int)pcm->mmap_status->hw_ptr, + (unsigned int)pcm->mmap_control->appl_ptr, + avail); + return -errno; + } + pcm->wait_for_avail_min = 0; + } + + /* sleep until we have space to write new frames */ + if (pcm->running) { + /* enable waiting for avail_min threshold when less frames than we have to write + * are available. */ + if (!pcm->wait_for_avail_min && (count > (unsigned int)avail)) + pcm->wait_for_avail_min = 1; + + if (pcm->wait_for_avail_min && (avail < pcm->config.avail_min)) { + int time = -1; + + /* disable waiting for avail_min threshold to allow small amounts of data to be + * written without waiting as long as there is enough room in buffer. */ + pcm->wait_for_avail_min = 0; + + if (pcm->flags & PCM_NOIRQ) + time = (pcm->config.avail_min - avail) / pcm->noirq_frames_per_msec; + + err = pcm_wait(pcm, time); + if (err < 0) { + pcm->prepared = 0; + pcm->running = 0; + oops(pcm, err, "wait error: hw 0x%x app 0x%x avail 0x%x\n", + (unsigned int)pcm->mmap_status->hw_ptr, + (unsigned int)pcm->mmap_control->appl_ptr, + avail); + pcm->mmap_control->appl_ptr = 0; + return err; + } + continue; + } + } + + frames = count; + if (frames > avail) + frames = avail; + + if (!frames) + break; + + /* copy frames from buffer */ + frames = pcm_mmap_transfer_areas(pcm, (void *)buffer, offset, frames); + if (frames < 0) { + fprintf(stderr, "write error: hw 0x%x app 0x%x avail 0x%x\n", + (unsigned int)pcm->mmap_status->hw_ptr, + (unsigned int)pcm->mmap_control->appl_ptr, + avail); + return frames; + } + + offset += frames; + count -= frames; + } + + return 0; +} + +int pcm_mmap_write(struct pcm *pcm, const void *data, unsigned int count) +{ + if ((~pcm->flags) & (PCM_OUT | PCM_MMAP)) + return -ENOSYS; + + return pcm_mmap_transfer(pcm, (void *)data, count); +} + +int pcm_mmap_read(struct pcm *pcm, void *data, unsigned int count) +{ + if ((~pcm->flags) & (PCM_IN | PCM_MMAP)) + return -ENOSYS; + + return pcm_mmap_transfer(pcm, data, count); +} + +int pcm_ioctl(struct pcm *pcm, int request, ...) +{ + va_list ap; + void * arg; + + if (!pcm_is_ready(pcm)) + return -1; + + va_start(ap, request); + arg = va_arg(ap, void *); + va_end(ap); + + return ioctl(pcm->fd, request, arg); +} diff --git a/hifi/xaf/host-apf/playback/xa_playback.c b/hifi/xaf/host-apf/playback/xa_playback.c new file mode 100644 index 00000000..2a8eefdf --- /dev/null +++ b/hifi/xaf/host-apf/playback/xa_playback.c @@ -0,0 +1,366 @@ +/******************************************************************************* +* 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. + +******************************************************************************/ + +#define MODULE_TAG PLYBK + +#include <tinyalsa/asoundlib.h> +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <string.h> +#include <signal.h> +#include <sys/ioctl.h> +#include <fcntl.h> +#include <unistd.h> +#include <errno.h> + +#include "xf.h" +#include "xa_playback.h" + +#if 0 +#define ID_RIFF 0x46464952 +#define ID_WAVE 0x45564157 +#define ID_FMT 0x20746d66 +#define ID_DATA 0x61746164 + +#define HIFI_MISC_IOCTL_PCM_GAIN _IOW('A', 0x7b, struct misc_io_pcm_buf_param) +#define HIFI_DSP_MISC_DRIVER "/dev/hifi_misc" +struct misc_io_pcm_buf_param { + uint64_t buf; + uint32_t buf_size; +}; + +struct riff_wave_header { + uint32_t riff_id; + uint32_t riff_sz; + uint32_t wave_id; +}; + +struct chunk_header { + uint32_t id; + uint32_t sz; +}; + +struct chunk_fmt { + uint16_t audio_format; + uint16_t num_channels; + uint32_t sample_rate; + uint32_t byte_rate; + uint16_t block_align; + uint16_t bits_per_sample; +}; + +static int s_close = 0; + +void play_sample(FILE *file, unsigned int card, unsigned int device, unsigned int channels, + unsigned int rate, unsigned int bits, unsigned int period_size, + unsigned int period_count); + +void stream_close(int sig) +{ + /* allow the stream to be closed gracefully */ + signal(sig, SIG_IGN); + s_close = 1; +} +#endif + +#if 0 +int main(int argc, char **argv) +{ + FILE *file; + struct riff_wave_header riff_wave_header; + struct chunk_header chunk_header; + struct chunk_fmt chunk_fmt; + unsigned int device = 0; + unsigned int card = 0; + unsigned int period_size = 1024; + unsigned int period_count = 4; + char *filename; + int more_chunks = 1; + + if (argc < 2) { + fprintf(stderr, "Usage: %s file.wav [-D card] [-d device] [-p period_size]" + " [-n n_periods] \n", argv[0]); + return 1; + } + + filename = argv[1]; + file = fopen(filename, "rb"); + if (!file) { + fprintf(stderr, "Unable to open file '%s'\n", filename); + return 1; + } + + fread(&riff_wave_header, sizeof(riff_wave_header), 1, file); + if ((riff_wave_header.riff_id != ID_RIFF) || + (riff_wave_header.wave_id != ID_WAVE)) { + fprintf(stderr, "Error: '%s' is not a riff/wave file\n", filename); + fclose(file); + return 1; + } + + do { + fread(&chunk_header, sizeof(chunk_header), 1, file); + + switch (chunk_header.id) { + case ID_FMT: + fread(&chunk_fmt, sizeof(chunk_fmt), 1, file); + /* If the format header is larger, skip the rest */ + if (chunk_header.sz > sizeof(chunk_fmt)) + fseek(file, chunk_header.sz - sizeof(chunk_fmt), SEEK_CUR); + break; + case ID_DATA: + /* Stop looking for chunks */ + more_chunks = 0; + break; + default: + /* Unknown chunk, skip bytes */ + fseek(file, chunk_header.sz, SEEK_CUR); + } + } while (more_chunks); + + /* parse command line arguments */ + argv += 2; + while (*argv) { + if (strcmp(*argv, "-d") == 0) { + argv++; + if (*argv) + device = atoi(*argv); + } + if (strcmp(*argv, "-p") == 0) { + argv++; + if (*argv) + period_size = atoi(*argv); + } + if (strcmp(*argv, "-n") == 0) { + argv++; + if (*argv) + period_count = atoi(*argv); + } + if (strcmp(*argv, "-D") == 0) { + argv++; + if (*argv) + card = atoi(*argv); + } + if (*argv) + argv++; + } + + play_sample(file, card, device, chunk_fmt.num_channels, chunk_fmt.sample_rate, + chunk_fmt.bits_per_sample, period_size, period_count); + + fclose(file); + + return 0; +} +#endif + +static int check_param(struct pcm_params *params, unsigned int param, unsigned int value, + char *param_name, char *param_unit) +{ + unsigned int min; + unsigned int max; + int is_within_bounds = 1; + + min = pcm_params_get_min(params, param); + if (value < min) { + TRACE(ERROR, _x("%s is %u%s, device only supports >= %u%s\n"), param_name, value, + param_unit, min, param_unit); + is_within_bounds = 0; + } + + max = pcm_params_get_max(params, param); + if (value > max) { + TRACE(ERROR, _x("%s is %u%s, device only supports <= %u%s\n"), param_name, value, + param_unit, max, param_unit); + is_within_bounds = 0; + } + + return is_within_bounds; +} + +static int sample_is_playable(unsigned int card, unsigned int device, unsigned int channels, + unsigned int rate, unsigned int bits, unsigned int period_size, + unsigned int period_count) +{ + struct pcm_params *params; + int can_play; + + params = pcm_params_get(card, device, PCM_OUT); + if (params == NULL) { + TRACE(ERROR, _x("Unable to open PCM device %u.\n"), device); + return 0; + } + + can_play = check_param(params, PCM_PARAM_RATE, rate, "Sample rate", "Hz"); + can_play &= check_param(params, PCM_PARAM_CHANNELS, channels, "Sample", " channels"); + can_play &= check_param(params, PCM_PARAM_SAMPLE_BITS, bits, "Bitrate", " bits"); + can_play &= check_param(params, PCM_PARAM_PERIOD_SIZE, period_size, "Period size", "Hz"); + can_play &= check_param(params, PCM_PARAM_PERIODS, period_count, "Period count", "Hz"); + + pcm_params_free(params); + + return can_play; +} + +void *xa_playback_open(unsigned int card, + unsigned int device, + unsigned int channels, + unsigned int rate, + unsigned int bits, + unsigned int period_size, + unsigned int period_count) +{ + struct pcm_config config; + struct pcm *pcm; + + memset(&config, 0, sizeof(config)); + config.channels = channels; + config.rate = rate; + config.period_size = period_size; + config.period_count = period_count; + if (bits == 32) + config.format = PCM_FORMAT_S32_LE; + else if (bits == 16) + config.format = PCM_FORMAT_S16_LE; + config.start_threshold = 0; + config.stop_threshold = 0; + config.silence_threshold = 0; + + if (!sample_is_playable(card, device, channels, rate, bits, period_size, period_count)) { + return NULL; + } + + pcm = pcm_open(card, device, PCM_OUT, &config); + if (!pcm || !pcm_is_ready(pcm)) { + TRACE(ERROR, _x("Unable to open PCM device %u (%s)\n"), + device, pcm_get_error(pcm)); + return NULL; + } + + return pcm; +} + +int xa_playback_buf(void *handle, + const void *data, + unsigned int nbytes) +{ + int err; + + if (!handle || !data) + return XA_PLAYBACK_INVALID_PARAM; + + if (nbytes > 0) { + err = pcm_write(handle, data, nbytes); + + if (err == -EINVAL) return XA_PLAYBACK_INVALID_PARAM; + if (err == -EPIPE ) return XA_PLAYBACK_UNDERRUN; + } + + return XA_PLAYBACK_OK; +} + +int xa_playback_close(void *handle) +{ + return pcm_close(handle); +} + +#if 0 +void play_sample(FILE *file, unsigned int card, unsigned int device, unsigned int channels, + unsigned int rate, unsigned int bits, unsigned int period_size, + unsigned int period_count) +{ + struct pcm_config config; + struct pcm *pcm; + char *buffer; + int size; + int num_read; + int hifi_dsp_fd; + struct misc_io_pcm_buf_param pcmbuf; + + hifi_dsp_fd = open(HIFI_DSP_MISC_DRIVER, O_RDWR, 0); + if(hifi_dsp_fd < 0){ + printf("Error opening hifi dsp device %d", errno); + } + + memset(&config, 0, sizeof(config)); + config.channels = channels; + config.rate = rate; + config.period_size = period_size; + config.period_count = period_count; + if (bits == 32) + config.format = PCM_FORMAT_S32_LE; + else if (bits == 16) + config.format = PCM_FORMAT_S16_LE; + config.start_threshold = 0; + config.stop_threshold = 0; + config.silence_threshold = 0; + + if (!sample_is_playable(card, device, channels, rate, bits, period_size, period_count)) { + return; + } + + pcm = pcm_open(card, device, PCM_OUT, &config); + if (!pcm || !pcm_is_ready(pcm)) { + fprintf(stderr, "Unable to open PCM device %u (%s)\n", + device, pcm_get_error(pcm)); + return; + } + + size = pcm_frames_to_bytes(pcm, pcm_get_buffer_size(pcm)); + buffer = malloc(size); + if (!buffer) { + fprintf(stderr, "Unable to allocate %d bytes\n", size); + free(buffer); + pcm_close(pcm); + return; + } + + printf("Playing sample: %u ch, %u hz, %u bit\n", channels, rate, bits); + + /* catch ctrl-c to shutdown cleanly */ + signal(SIGINT, stream_close); + + do { + num_read = fread(buffer, 1, size, file); + + pcmbuf.buf =(uint64_t) buffer; + pcmbuf.buf_size = num_read; + if(hifi_dsp_fd) { + // printf("ioctl send \n"); + ioctl(hifi_dsp_fd,HIFI_MISC_IOCTL_PCM_GAIN, &pcmbuf); + // printf("ioctl complete \n"); + } + + if (num_read > 0) { + if (pcm_write(pcm, buffer, num_read)) { + fprintf(stderr, "Error playing sample\n"); + break; + } + } + } while (!s_close && num_read > 0); + + free(buffer); + pcm_close(pcm); + close(hifi_dsp_fd); +} +#endif diff --git a/hifi/xaf/host-apf/playback/xa_playback.h b/hifi/xaf/host-apf/playback/xa_playback.h new file mode 100644 index 00000000..8e4b3c63 --- /dev/null +++ b/hifi/xaf/host-apf/playback/xa_playback.h @@ -0,0 +1,42 @@ +/******************************************************************************* +* 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. + +******************************************************************************/ + +enum xa_playback_error { + XA_PLAYBACK_OK = 0, + XA_PLAYBACK_INVALID_PARAM = -1, + XA_PLAYBACK_UNDERRUN = -2, +}; + +void *xa_playback_open(unsigned int card, + unsigned int device, + unsigned int channels, + unsigned int rate, + unsigned int bits, + unsigned int period_size, + unsigned int period_count); + +int xa_playback_buf(void *handle, + const void *data, + unsigned int nbytes); + +int xa_playback_close(void *handle); + diff --git a/hifi/xaf/host-apf/proxy/xaf-api.c b/hifi/xaf/host-apf/proxy/xaf-api.c new file mode 100644 index 00000000..6b5862df --- /dev/null +++ b/hifi/xaf/host-apf/proxy/xaf-api.c @@ -0,0 +1,597 @@ +/******************************************************************************* +* 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 "xf.h" +#include "xaf-api.h" +#include "xaf-structs.h" + +#ifdef XAF_HOSTLESS +#include "xos-msgq-if.h" +#endif +#define MODULE_TAG DEVAPI + +/******************************************************************************* + * Tracing configuration + ******************************************************************************/ + +TRACE_TAG(INIT, 1); +TRACE_TAG(DEBUG, 1); +TRACE_TAG(INFO, 1); + +#define XAF_4BYTE_ALIGN 4 +#define XAF_8BYTE_ALIGN 8 +#define XAF_32BYTE_ALIGN 32 + + +static void xaf_comp_response(xf_handle_t *h, xf_user_msg_t *msg) +{ + if (msg->opcode == XF_UNREGISTER) + { + /* ...component execution failed unexpectedly; die */ + BUG(1, _x("[%p] Abnormal termination"), h); + } + else + { + /* ...submit response to asynchronous delivery queue */ + xf_response_put(h, msg); + } +} + +static XAF_ERR_CODE xaf_comp_add(xaf_comp_t **pp_comp_chain, xaf_comp_t *p_comp) +{ + XAF_CHK_PTR(pp_comp_chain); + XAF_CHK_PTR(p_comp); + + p_comp->next = *pp_comp_chain; + *pp_comp_chain = p_comp; + + return XAF_NO_ERROR; +} + +static XAF_ERR_CODE xaf_comp_post_init_config(xaf_adev_t *p_adev, xaf_comp_t *p_comp, void *p_msg) +{ + xf_proxy_t *p_proxy = &p_adev->proxy; + xf_start_msg_t *smsg = p_msg; + + p_comp->out_format.sample_rate = smsg->sample_rate; + p_comp->out_format.channels = smsg->channels; + p_comp->out_format.pcm_width = smsg->pcm_width; + p_comp->out_format.input_length = smsg->input_length; + p_comp->out_format.output_length = smsg->output_length; + + TRACE(INFO, _b("Component[%x] Params: f=%d, c=%d, w=%d i=%d o=%d"), p_comp->handle.id, smsg->sample_rate, smsg->channels, smsg->pcm_width, smsg->input_length, smsg->output_length); + + if (p_comp->noutbuf) + { + XF_CHK_API(xf_pool_alloc(p_proxy, p_comp->noutbuf, smsg->output_length, XF_POOL_OUTPUT, &p_comp->outpool, XAF_MEM_ID_COMP, + p_adev->pxf_mem_malloc_fxn, p_adev->pxf_mem_free_fxn)); + } + + p_comp->init_done = 1; + p_comp->comp_status = XAF_INIT_DONE; + + return XAF_NO_ERROR; +} + +#ifdef XAF_HOSTLESS +XAF_ERR_CODE xaf_xos_start() +{ +#if defined BOARD + xos_set_clock_freq(xtbsp_clock_freq_hz()); +#else + xos_set_clock_freq(XOS_CLOCK_FREQ); +#endif + + xos_start("main", 7, 0); +#if XCHAL_NUM_TIMERS > 0 + xos_start_system_timer(0, TICK_CYCLES); +#endif + + return XAF_NO_ERROR; +} +#endif + +XAF_ERR_CODE xaf_adev_open(void** pp_adev, s32 audio_frmwk_buf_size, s32 audio_comp_buf_size, xaf_mem_malloc_fxn_t mem_malloc, xaf_mem_free_fxn_t mem_free) +{ + int size; + void * pTmp; + xaf_adev_t *p_adev; + xf_proxy_t *p_proxy; + + XAF_CHK_PTR(pp_adev); + XAF_CHK_PTR(mem_malloc); + XAF_CHK_PTR(mem_free); + + /* ...unused arg */ + (void) audio_comp_buf_size; + + //Memory allocation for adev struct pointer + size = (sizeof(xaf_adev_t) +(XAF_4BYTE_ALIGN-1)); + pTmp = mem_malloc(size, XAF_MEM_ID_DEV); + XAF_CHK_PTR(pTmp); + memset(pTmp, 0, size); + + p_adev = (xaf_adev_t *) (((unsigned long)pTmp + (XAF_4BYTE_ALIGN-1))& ~(XAF_4BYTE_ALIGN-1)); + p_adev->adev_ptr = pTmp; + *pp_adev = (void *)p_adev; + + p_proxy = &p_adev->proxy; + + // Host side Memory allocation (BSS) + p_adev->pxf_mem_malloc_fxn = mem_malloc; + p_adev->pxf_mem_free_fxn = mem_free; + + size = sizeof(xaf_ap_utils_t)+(XAF_8BYTE_ALIGN-1); + p_adev->p_ap_utils = mem_malloc(size, XAF_MEM_ID_DEV); + XAF_CHK_PTR(p_adev->p_ap_utils); + //reset memory size stats + memset(p_adev->p_ap_utils, 0, sizeof(xaf_ap_utils_t)); + + // shmmem Memory allocation + p_adev->p_ap_utils->xf_cfg_remote_ipc_pool_size = audio_frmwk_buf_size; //minimum size 256 KB, mmap multiple is 0x1000 + + //DSP localbuf allocation is done in the DSP core; nothing to be done here + + /* ...open DSP proxy - specify "DSP#0" */ + XF_CHK_API(xf_proxy_init(p_proxy, 0, (void *)&p_adev->p_ap_utils->xf_cfg_remote_ipc_pool_size)); + + /* ...create auxiliary buffers pool for control commands */ + XF_CHK_API(xf_pool_alloc(p_proxy, XAF_AUX_POOL_SIZE, XAF_AUX_POOL_MSG_LENGTH, XF_POOL_AUX, &p_proxy->aux, XAF_MEM_ID_DEV, + p_adev->pxf_mem_malloc_fxn, p_adev->pxf_mem_free_fxn)); + + return XAF_NO_ERROR; +} + +XAF_ERR_CODE xaf_adev_close(void* adev_ptr, xaf_comp_flag flag) +{ + xaf_adev_t *p_adev; + xf_proxy_t *p_proxy; + + XAF_CHK_PTR(adev_ptr); + p_adev = (xaf_adev_t *)adev_ptr; + + /* ...unused arg */ + (void) flag; + + p_proxy = &p_adev->proxy; + if(p_proxy->aux != NULL) + { + xf_pool_free(p_proxy->aux, XAF_MEM_ID_DEV, p_adev->pxf_mem_free_fxn); + } + + xf_proxy_close(p_proxy); + + p_adev->pxf_mem_free_fxn(p_adev->p_ap_utils, XAF_MEM_ID_DEV); + p_adev->p_ap_utils = NULL; + p_adev->pxf_mem_free_fxn(p_adev->adev_ptr, XAF_MEM_ID_DEV); + p_adev->adev_ptr = NULL; + + p_adev->pxf_mem_malloc_fxn = NULL; + p_adev->pxf_mem_free_fxn = NULL; + + return XAF_NO_ERROR; +} + +XAF_ERR_CODE xaf_comp_create(void *adev_ptr, void **pp_comp, xf_id_t comp_id, u32 ninbuf, u32 noutbuf, void *pp_inbuf[], xaf_comp_type comp_type) +{ + xf_handle_t *p_handle; + void * pTmp; + int size; + + xaf_adev_t *p_adev; + p_adev = (xaf_adev_t *)adev_ptr; + xaf_comp_t *p_comp; + + XAF_CHK_PTR(p_adev); + XAF_CHK_PTR(pp_comp); + XAF_CHK_PTR(comp_id); + if (ninbuf) XAF_CHK_PTR(pp_inbuf); + + XAF_CHK_RANGE(ninbuf, 0, XAF_MAX_INBUFS); + XAF_CHK_RANGE(noutbuf, 0, 1); + XAF_CHK_RANGE(comp_type, XAF_DECODER, XAF_POST_PROC); + + //Memory allocation for component struct pointer + size = (sizeof(xaf_comp_t) + (XAF_4BYTE_ALIGN-1)); + pTmp = p_adev->pxf_mem_malloc_fxn(size, XAF_MEM_ID_COMP); + XAF_CHK_PTR(pTmp); + memset(pTmp, 0, size); + p_comp = (xaf_comp_t *) (((unsigned long)pTmp + (XAF_4BYTE_ALIGN-1))& ~(XAF_4BYTE_ALIGN-1)); + + p_comp->comp_ptr = pTmp; + *pp_comp = (void*)p_comp; + + memset(p_comp, 0, sizeof(xaf_comp_t)); + p_handle = &p_comp->handle; + + /* ...create component instance (select core-0) */ + XF_CHK_API(xf_open(&p_adev->proxy, p_handle, comp_id, 0, xaf_comp_response)); + + xaf_comp_add(&p_adev->comp_chain, p_comp); + + // Temporary solution in place of component chain handling + p_comp->p_adev = p_adev; + p_adev->n_comp += 1; + p_comp->ninbuf = ninbuf; + + /* ...allocate input buffer */ + if (ninbuf) + { + xf_buffer_t *buf; + u32 i; + XF_CHK_API(xf_pool_alloc(&p_adev->proxy, ninbuf, XAF_INBUF_SIZE, XF_POOL_INPUT, &p_comp->inpool, XAF_MEM_ID_COMP, + p_adev->pxf_mem_malloc_fxn, p_adev->pxf_mem_free_fxn)); + + for (i=0; i<ninbuf; i++) + { + buf = xf_buffer_get(p_comp->inpool); + pp_inbuf[i] = xf_buffer_data(buf); + } + + } + p_comp->noutbuf = noutbuf; + + p_comp->comp_type = comp_type; + p_comp->comp_status = XAF_STARTING; + + switch (comp_type) + { + case XAF_DECODER: + case XAF_ENCODER: + case XAF_PRE_PROC: + case XAF_POST_PROC: + p_comp->inp_ports = 1; p_comp->out_ports = 1; + break; + case XAF_MIXER: + p_comp->inp_ports = 4; p_comp->out_ports = 1; + break; + } + + return XAF_NO_ERROR; +} + +XAF_ERR_CODE xaf_comp_delete(void *comp_ptr) +{ + xaf_adev_t *p_adev; + + xaf_comp_t *p_comp; + p_comp = (xaf_comp_t *)comp_ptr; + + XAF_CHK_PTR(p_comp); + + // Temporary solution in place of component chain handling + p_adev = (xaf_adev_t *)(p_comp->p_adev); + XF_CHK_ERR((p_adev->n_comp > 0), XAF_API_ERR); + p_adev->n_comp -= 1; + + + if (p_comp->inpool) xf_pool_free(p_comp->inpool, XAF_MEM_ID_COMP, p_adev->pxf_mem_free_fxn); + if (p_comp->outpool) xf_pool_free(p_comp->outpool, XAF_MEM_ID_COMP, p_adev->pxf_mem_free_fxn); + + xf_close(&p_comp->handle); + + /* ...tbd - remove from chain */ + p_adev->pxf_mem_free_fxn(p_comp->comp_ptr, XAF_MEM_ID_COMP); + p_comp->comp_ptr = NULL; + + return XAF_NO_ERROR; +} + +XAF_ERR_CODE xaf_comp_set_config(void *comp_ptr, s32 num_param, s32 *p_param) +{ + xaf_comp_t *p_comp; + xf_user_msg_t rmsg; + xf_set_param_msg_t *smsg; + xf_handle_t *p_handle; + s32 i, j; + + p_comp = (xaf_comp_t *)comp_ptr; + + XAF_CHK_PTR(p_comp); + XAF_CHK_PTR(p_param); + XAF_CHK_RANGE(num_param, 1, XAF_MAX_CONFIG_PARAMS); + + p_handle = &p_comp->handle; + XAF_CHK_PTR(p_handle); + + /* ...set persistent stream characteristics */ + smsg = xf_buffer_data(p_handle->aux); + + j = 0; + for (i=0; i<num_param; i++) + { + smsg->item[i].id = p_param[j++]; + smsg->item[i].value = p_param[j++]; + } + + /* ...pass command to the component */ + /* ...tbd - command goes port 0 always, check if okay */ + XF_CHK_API(xf_command(p_handle, 0, XF_SET_PARAM, smsg, sizeof(xf_set_param_item_t)*num_param)); + + /* ...wait until result is delivered */ + XF_CHK_API(xf_response_get(p_handle, &rmsg)); + + /* ...make sure response is expected */ + XF_CHK_ERR(rmsg.opcode == (u32) XF_SET_PARAM && rmsg.buffer == smsg, XAF_API_ERR); + + return XAF_NO_ERROR; +} + +XAF_ERR_CODE xaf_comp_get_config(void *comp_ptr, s32 num_param, s32 *p_param) +{ + xaf_comp_t *p_comp; + xf_user_msg_t rmsg; + xf_get_param_msg_t *smsg; + xf_handle_t *p_handle; + s32 i; + + p_comp = (xaf_comp_t *)comp_ptr; + + XAF_CHK_PTR(p_comp); + XAF_CHK_PTR(p_param); + XAF_CHK_RANGE(num_param, 1, XAF_MAX_CONFIG_PARAMS); + + p_handle = &p_comp->handle; + XAF_CHK_PTR(p_handle); + + /* ...set persistent stream characteristics */ + smsg = xf_buffer_data(p_handle->aux); + + for (i=0; i<num_param; i++) + { + smsg->c.id[i] = p_param[i]; + } + + /* ...pass command to the component */ + /* ...tbd - command goes port 0 always, check if okay */ + XF_CHK_API(xf_command(p_handle, 0, XF_GET_PARAM, smsg, XF_GET_PARAM_CMD_LEN(num_param))); + + /* ...wait until result is delivered */ + XF_CHK_API(xf_response_get(p_handle, &rmsg)); + + /* ...make sure response is expected */ + XF_CHK_ERR(rmsg.opcode == (u32) XF_GET_PARAM && rmsg.buffer == smsg, XAF_API_ERR); + + for (i=0; i<num_param; i++) + { + p_param[i] = smsg->r.value[i]; + } + + return XAF_NO_ERROR; +} +#ifdef XAF_HOSTLESS +XAF_ERR_CODE xaf_comp_get_status(xaf_adev_t *p_adev, xaf_comp_t *p_comp, xaf_comp_status *p_status, void *p_info) +#else +XAF_ERR_CODE xaf_comp_get_status(void *adev_ptr, void *comp_ptr, xaf_comp_status *p_status, xaf_info_t *p_info) +#endif +{ + xaf_adev_t *p_adev; + xaf_comp_t *p_comp; + xf_handle_t *p_handle; + + p_adev = (xaf_adev_t *)adev_ptr; + p_comp = (xaf_comp_t *)comp_ptr; + + XAF_CHK_PTR(p_comp); + XAF_CHK_PTR(p_status); + XAF_CHK_PTR(p_info); + if (!p_comp->init_done) XAF_CHK_PTR(p_adev); + + p_handle = &p_comp->handle; + + if (p_comp->pending_resp) + { + xf_user_msg_t rmsg; + /* ...wait until result is delivered */ + XF_CHK_API(xf_response_get(p_handle, &rmsg)); + + if (rmsg.opcode == XF_FILL_THIS_BUFFER) + { + if (rmsg.buffer == p_comp->start_buf) + { + XF_CHK_API(xaf_comp_post_init_config(p_adev, p_comp, p_comp->start_buf)); + } + else + { +#ifdef XAF_HOSTLESS + s32 *p_buf = (s32 *) p_info; + p_buf[0] = (s32) rmsg.buffer; + p_buf[1] = (s32) rmsg.length; +#else + p_info->buf = (void*) rmsg.buffer; + p_info->length = (s32) rmsg.length; +#endif + if (!p_comp->inpool && p_comp->outpool) p_comp->pending_resp--; + + if (!rmsg.length) p_comp->comp_status = XAF_EXEC_DONE; + else + { + p_comp->comp_status = XAF_OUTPUT_READY; + p_comp->expect_out_cmd++; + } + } + } + else + { + /* ...make sure response is expected */ + XF_CHK_ERR(rmsg.opcode == (u32) XF_EMPTY_THIS_BUFFER, XAF_API_ERR); +#ifdef XAF_HOSTLESS + s32 *p_buf = (s32 *) p_info; + p_buf[0] = (s32) rmsg.buffer; + p_buf[1] = (s32) rmsg.length; +#else + p_info->buf = (void*) rmsg.buffer; + p_info->length = (s32) rmsg.length; +#endif + p_comp->pending_resp--; + + if (p_comp->input_over && rmsg.buffer == NULL) p_comp->comp_status = XAF_EXEC_DONE; + else p_comp->comp_status = XAF_NEED_INPUT; + } + } + else if ((p_comp->comp_status == XAF_STARTING && p_comp->start_cmd_issued) || + (p_comp->comp_status == XAF_INIT_DONE && p_comp->exec_cmd_issued)) + { + if (p_comp->inpool) p_comp->comp_status = XAF_NEED_INPUT; + } + + *p_status = p_comp->comp_status; + + return XAF_NO_ERROR; +} + +XAF_ERR_CODE xaf_comp_process(void *adev_ptr, void *comp_ptr, void *p_buf, u32 length, xaf_comp_flag flag) +{ + xaf_adev_t *p_adev; + xaf_comp_t *p_comp; + xf_handle_t *p_handle; + + p_adev = (xaf_adev_t *)adev_ptr; + p_comp = (xaf_comp_t *)comp_ptr; + + XAF_CHK_PTR(p_comp); + if (!p_comp->init_done) XAF_CHK_PTR(p_adev); + XAF_CHK_RANGE(flag, XAF_START_FLAG, XAF_NEED_OUTPUT_FLAG); + if (flag == XAF_INPUT_READY_FLAG) XAF_CHK_RANGE(length, 0, XAF_INBUF_SIZE); + + p_handle = &p_comp->handle; + + switch (flag) + { + case XAF_START_FLAG: + if (p_comp->start_cmd_issued) + break; + else + { + p_comp->start_buf = xf_buffer_data(p_handle->aux); + XF_CHK_API(xf_command(p_handle, (p_comp->inp_ports), XF_FILL_THIS_BUFFER, p_comp->start_buf, 0)); + p_comp->start_cmd_issued = 1; + + if(p_comp->comp_type != XAF_DECODER) + { + xf_user_msg_t rmsg; + /* ...wait until result is delivered */ + XF_CHK_API(xf_response_get(p_handle, &rmsg)); + + /* ...make sure response is expected */ + XF_CHK_ERR(rmsg.opcode == XF_FILL_THIS_BUFFER && rmsg.buffer == p_comp->start_buf, XAF_API_ERR); + + XF_CHK_API(xaf_comp_post_init_config(p_adev, p_comp, p_comp->start_buf)); + } + } + break; + + case XAF_EXEC_FLAG: + if (!p_comp->init_done || p_comp->exec_cmd_issued) + break; + p_comp->exec_cmd_issued = 1; + if (p_comp->outpool) + { + u32 i; + xf_buffer_t *p_buf; + void *p_data; + + for (i=0; i<p_comp->noutbuf; i++) + { + p_buf = xf_buffer_get(p_comp->outpool); + p_data = xf_buffer_data(p_buf); + + XF_CHK_API(xf_command(&p_comp->handle, (p_comp->inp_ports), XF_FILL_THIS_BUFFER, p_data, p_comp->out_format.output_length)); + } + + if (!p_comp->inpool) p_comp->pending_resp = p_comp->noutbuf; + } + break; + + case XAF_INPUT_OVER_FLAG: + if (!p_comp->input_over) + { + XF_CHK_API(xf_command(p_handle, 0, XF_EMPTY_THIS_BUFFER, NULL, 0)); + p_comp->input_over = 1; + p_comp->pending_resp++; + } + break; + + case XAF_INPUT_READY_FLAG: + if (!p_comp->input_over) + { + XAF_CHK_PTR(p_buf); + XF_CHK_API(xf_command(p_handle, 0, XF_EMPTY_THIS_BUFFER, p_buf, length)); + p_comp->pending_resp++; + } + break; + + case XAF_NEED_OUTPUT_FLAG: + if (p_comp->expect_out_cmd) + { + XAF_CHK_PTR(p_buf); + XF_CHK_API(xf_command(p_handle, (p_comp->inp_ports), XF_FILL_THIS_BUFFER, p_buf, length)); + p_comp->expect_out_cmd--; + + if (!p_comp->inpool && p_comp->outpool) p_comp->pending_resp++; + } + break; + } + + return XAF_NO_ERROR; +} + +XAF_ERR_CODE xaf_connect(void *src_ptr, void *dest_ptr, s32 num_buf) +{ + xaf_comp_t *p_src; + xaf_comp_t *p_dest; + + p_src = (xaf_comp_t *)src_ptr; + p_dest = (xaf_comp_t *)dest_ptr; + + XAF_CHK_PTR(p_src); + XAF_CHK_PTR(p_dest); + XAF_CHK_RANGE(num_buf, 2, 4); + + if (!p_src->init_done || p_src->out_routed == p_src->out_ports || p_dest->inp_routed == p_dest->inp_ports) + return XAF_ROUTING_ERROR; + + XF_CHK_API(xf_route(&p_src->handle, (p_src->inp_ports + p_src->out_routed), &p_dest->handle, (p_dest->inp_routed), num_buf, p_src->out_format.output_length, 8)); + + p_src->out_routed++; + p_dest->inp_routed++; + + return XAF_NO_ERROR; +} + +XAF_ERR_CODE xaf_disconnect(xaf_comp_t *p_comp) +{ + XAF_CHK_PTR(p_comp); + + /* ...tbd - support for multiple output ports */ + if (!p_comp->init_done || p_comp->out_routed != p_comp->out_ports) + return XAF_ROUTING_ERROR; + + XF_CHK_API(xf_unroute(&p_comp->handle, (p_comp->inp_ports))); + + return XAF_NO_ERROR; +} + + + + + + diff --git a/hifi/xaf/host-apf/proxy/xf-fio.c b/hifi/xaf/host-apf/proxy/xf-fio.c new file mode 100644 index 00000000..5c3c3dbf --- /dev/null +++ b/hifi/xaf/host-apf/proxy/xf-fio.c @@ -0,0 +1,193 @@ +/******************************************************************************* +* 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. + +******************************************************************************/ + +#define MODULE_TAG FIO + +/******************************************************************************* + * Includes + ******************************************************************************/ + +#include "xf.h" +#include <sys/ioctl.h> +#include <sys/mman.h> + +/******************************************************************************* + * Tracing configuration + ******************************************************************************/ + +TRACE_TAG(INIT, 1); +TRACE_TAG(CMD, 1); +TRACE_TAG(RSP, 1); + +/******************************************************************************* + * Local constants - tbd + ******************************************************************************/ + +/* ...proxy setup ioctl */ +#define XF_PROXY_SETUP_IOCTL _IO('P', 0x0) + +/* ...proxy close ioctl */ +#define XF_PROXY_CLOSE_IOCTL _IO('P', 0x1) + +#define HIFI_DSP_MISC_DRIVER "/dev/hifi_misc" +#ifndef GJB_COMMENT +#define HIFI_MISC_IOCTL_XAF_IPC_MSG_SEND _IOW('A', 0x7c, xf_proxy_message_driv_t) +#define HIFI_MISC_IOCTL_XAF_IPC_MSG_RECV _IOR('A', 0x7d, xf_proxy_message_driv_t) +#define HIFI_MISC_IOCTL_XAF_IPC_VMSG_PTR _IOR('A', 0x7e, xf_proxy_message_driv_t) +#endif +//u8 remote_ipc_pool[XF_CFG_REMOTE_IPC_POOL_SIZE]; +/******************************************************************************* + * Internal IPC API implementation + ******************************************************************************/ + +/* ...pass command to remote DSP */ +int xf_ipc_send(xf_proxy_ipc_data_t *ipc, xf_proxy_msg_t *msg, void *b) +{ + /* ...unused arg */ + (void) b; + + int fd = ipc->fd; + int ret; +#ifdef GJB_COMMENT + TRACE(CMD, _b("C[%08x]:(%x,%08x,%u)"), msg->id, msg->opcode, msg->address, msg->length); + + /* ...pass message to kernel driver */ + XF_CHK_ERR(write(fd, msg, sizeof(*msg)) == sizeof(*msg), -errno); +#else + ret = ioctl(fd, HIFI_MISC_IOCTL_XAF_IPC_MSG_SEND, msg);// GJB:-Verify th return value with driver implementation. +#endif + + /* ...communication mutex is still locked! */ + return 0; +} + +/* ...wait for response availability */ +int xf_ipc_wait(xf_proxy_ipc_data_t *ipc, u32 timeout) +{ + int fd = ipc->fd; + fd_set rfds; + struct timeval tv; + + /* ...specify waiting set */ + FD_ZERO(&rfds); + FD_SET(fd, &rfds); + + /* ...set timeout value if given */ + (timeout ? tv.tv_sec = timeout / 1000, tv.tv_usec = (timeout % 1000) * 1000 : 0); + + /* ...wait until there is a data in file */ +// XF_CHK_ERR(select(fd + 1, &rfds, NULL, NULL, (timeout ? &tv : NULL)) >= 0, -errno); + select(fd+1,&rfds,NULL,NULL,(timeout? &tv: NULL)); + + /* ...check if descriptor is set */ + return (FD_ISSET(fd, &rfds) ? 0 : -ETIMEDOUT); +} + +/* ...read response from proxy */ +int xf_ipc_recv(xf_proxy_ipc_data_t *ipc, xf_proxy_msg_t *msg, void **buffer) +{ + int fd = ipc->fd; + int r; + xf_proxy_msg_t temp; +#ifdef GJB_COMMENT + /* ...get message header from file */ + if ((r = read(fd, msg, sizeof(*msg))) == sizeof(*msg)) + { + TRACE(RSP, _b("R[%08x]:(%x,%u,%08x)"), msg->id, msg->opcode, msg->length, msg->address); + + /* ...translate shared address into local pointer */ + XF_CHK_ERR((*buffer = xf_ipc_a2b(ipc, msg->address)) != (void *)-1, -EBADFD); + + /* ...return positive result indicating the message has been received */ + return sizeof(*msg); + } +#else + if ((r = ioctl(fd, HIFI_MISC_IOCTL_XAF_IPC_MSG_RECV, &temp)) == sizeof(temp)) + { + msg->id = temp.id; + msg->opcode = temp.opcode; + msg->length = temp.length; + *buffer = xf_ipc_a2b(ipc, temp.address); + /* ...translate shared address into local pointer */ + XF_CHK_ERR((*buffer = xf_ipc_a2b(ipc, temp.address)) != (void *)-1, -EBADFD); + msg->address = temp.address; + return sizeof(*msg); + } +#endif + else + { + /* ...if no response is available, return 0 result */ + return XF_CHK_API(errno == EAGAIN ? 0 : -errno); + } +} + +/******************************************************************************* + * Internal API functions implementation + ******************************************************************************/ + +/* ...open proxy interface on proper DSP partition */ +int xf_ipc_open(xf_proxy_ipc_data_t *ipc, u32 core, void *p_shmem) +{ + //XF_CHK_ERR((p_shmem != NULL), -errno); + //size_t xf_cfg_remote_ipc_pool_size = *(size_t *)p_shmem;//user configured shmem pool size: minimum 256 KB + /* ...unused arg */ + (void) p_shmem; +#ifdef GJB_COMMENT + /* ...open file handle */ + XF_CHK_ERR((ipc->fd = open("/dev/xtensa-proxy", O_RDWR)) >= 0, -errno); + + /* ...pass shread memory core for this proxy instance */ + XF_CHK_ERR(ioctl(ipc->fd, XF_PROXY_SETUP_IOCTL, core) >= 0, -errno); +#else + XF_CHK_ERR((ipc->fd = open(HIFI_DSP_MISC_DRIVER, O_RDWR,0)) >= 0, -errno); +#endif + /* ...create pipe for asynchronous response delivery */ + XF_CHK_ERR(pipe(ipc->pipe) == 0, -errno); + + /* ...map entire shared memory region (not too good - tbd) */ +// ipc->shmem = remote_ipc_pool; +// ioctl(ipc->fd, HIFI_MISC_IOCTL_XAF_IPC_VMSG_PTR, ipc->shmem); +#if 1 + //allocate 256 KB constant size + XF_CHK_ERR((ipc->shmem = mmap(NULL, XF_CFG_REMOTE_IPC_POOL_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, ipc->fd, 0)) != MAP_FAILED, -errno); +#else + XF_CHK_ERR((ipc->shmem = mmap(NULL, xf_cfg_remote_ipc_pool_size, PROT_READ | PROT_WRITE, MAP_SHARED, ipc->fd, 0)) != MAP_FAILED, -errno); +#endif + TRACE(INIT, _b("proxy-%u interface opened"), core); + return 0; +} + +/* ...close proxy handle */ +void xf_ipc_close(xf_proxy_ipc_data_t *ipc, u32 core) +{ + /* ...unmap shared memory region */ +// (void)munmap(ipc->shmem, XF_CFG_REMOTE_IPC_POOL_SIZE); + + /* ...close asynchronous response delivery pipe */ + close(ipc->pipe[0]), close(ipc->pipe[1]); + + /* ...close proxy file handle */ + close(ipc->fd); + + TRACE(INIT, _b("proxy-%u interface closed"), core); +} + diff --git a/hifi/xaf/host-apf/proxy/xf-proxy.c b/hifi/xaf/host-apf/proxy/xf-proxy.c new file mode 100644 index 00000000..0af45179 --- /dev/null +++ b/hifi/xaf/host-apf/proxy/xf-proxy.c @@ -0,0 +1,686 @@ +/******************************************************************************* +* 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. + +******************************************************************************/ + +#define MODULE_TAG PROXY + +/******************************************************************************* + * Includes + ******************************************************************************/ + +#include "xf.h" + +/******************************************************************************* + * Tracing configuration + ******************************************************************************/ + +TRACE_TAG(INIT, 1); +TRACE_TAG(CMD, 1); +TRACE_TAG(EXEC, 1); +TRACE_TAG(RSP, 1); +TRACE_TAG(REG, 1); +TRACE_TAG(MEM, 1); +TRACE_TAG(GRAPH, 1); +TRACE_TAG(BUFFER, 1); + +/******************************************************************************* + * Internal functions definitions + ******************************************************************************/ + +/* ...execute proxy command synchronously */ +static inline int xf_proxy_cmd_exec(xf_proxy_t *proxy, xf_user_msg_t *msg) +{ + xf_proxy_msg_t m; + + /* ...send command to remote proxy */ + m.id = msg->id, m.opcode = msg->opcode, m.length = msg->length; + + /* ...translate address */ + XF_CHK_ERR((m.address = xf_proxy_b2a(proxy, msg->buffer)) != XF_PROXY_BADADDR, -EINVAL); + + /* ...pass command to remote proxy */ + XF_CHK_API(xf_ipc_send(&proxy->ipc, &m, msg->buffer)); + + /* ...wait for response reception indication from proxy thread */ + XF_CHK_API(xf_proxy_response_get(proxy, &m)); + + /* ...copy parameters */ + msg->id = m.id, msg->opcode = m.opcode, msg->length = m.length; + + /* ...translate address back to virtual space */ + XF_CHK_ERR((msg->buffer = xf_proxy_a2b(proxy, m.address)) != (void *)-1, -EBADFD); + + TRACE(EXEC, _b("proxy[%p]: command done: [%08x:%p:%u]"), proxy, msg->opcode, msg->buffer, msg->length); + + return 0; +} + +#if 0 +/* ...pass command to remote DSP */ +static inline int xf_proxy_cmd(xf_proxy_t *proxy, xf_handle_t *handle, xf_user_msg_t *m) +{ + xf_proxy_msg_t msg; + + /* ...set session-id of the message */ + msg.id = __XF_MSG_ID(__XF_AP_CLIENT(proxy->core, handle->client), m->id); + msg.opcode = m->opcode; + msg.length = m->length; + + /* ...translate buffer pointer to shared address */ + XF_CHK_ERR((msg.address = xf_proxy_b2a(proxy, m->buffer)) != XF_PROXY_BADADDR, -EINVAL); + + /* ...submit command message to IPC layer */ + return XF_CHK_API(xf_ipc_send(&proxy->ipc, &msg, m->buffer)); +} +#endif /* 0 */ + +/* ...allocate local client-id number */ +static inline u32 xf_client_alloc(xf_proxy_t *proxy, xf_handle_t *handle) +{ + u32 client; + + if ((client = proxy->cmap[0].next) != 0) + { + /* ...pop client from free clients list */ + proxy->cmap[0].next = proxy->cmap[client].next; + + /* ...put client handle into association map */ + handle->client = client, proxy->cmap[client].handle = handle; + } + + return client; +} + +/* ...recycle local client-id number */ +static inline void xf_client_free(xf_proxy_t *proxy, xf_handle_t *handle) +{ + u32 client = handle->client; + + /* ...push client into head of the free clients list */ + proxy->cmap[client].next = proxy->cmap[0].next; + + /* ...adjust head of free clients */ + proxy->cmap[0].next = client; +} + +/* ...lookup client basing on its local id */ +static inline xf_handle_t * xf_client_lookup(xf_proxy_t *proxy, u32 client) +{ + /* ...client index must be in proper range */ + BUG(client >= XF_CFG_PROXY_MAX_CLIENTS, _x("Invalid client index: %u"), client); + + /* ...check if client index is small */ + if (proxy->cmap[client].next < XF_CFG_PROXY_MAX_CLIENTS) + return NULL; + else + return proxy->cmap[client].handle; +} + +/* ...create new client on remote core */ +static inline int xf_client_register(xf_proxy_t *proxy, xf_handle_t *handle, xf_id_t id, u32 core) +{ + void *b = xf_handle_aux(handle); + xf_user_msg_t msg; + + /* ...set session-id: source is local proxy, destination is remote proxy */ + msg.id = __XF_MSG_ID(__XF_AP_PROXY(proxy->core), __XF_DSP_PROXY(core)); + msg.opcode = XF_REGISTER; + msg.buffer = b; + msg.length = strlen(id) + 1; + + /* ...copy component identifier */ + strncpy(b, id, xf_buffer_length(handle->aux)); + + /* ...execute command synchronously */ + XF_CHK_API(xf_proxy_cmd_exec(proxy, &msg)); + + /* ...check operation is successfull */ + XF_CHK_ERR(msg.opcode == (u32) XF_REGISTER, -EFAULT); + + /* ...save received component global client-id */ + handle->id = XF_MSG_SRC(msg.id); + + TRACE(REG, _b("[%p]=[%s:%u:%u]"), handle, id, XF_PORT_CORE(handle->id), XF_PORT_CLIENT(handle->id)); + + return 0; +} + +/* ...unregister client from remote proxy */ +static inline int xf_client_unregister(xf_proxy_t *proxy, xf_handle_t *handle) +{ + xf_user_msg_t msg; + + /* ...make sure the client is consistent */ + BUG(proxy->cmap[handle->client].handle != handle, _x("Invalid handle: %p"), handle); + + /* ...set message parameters */ + msg.id = __XF_MSG_ID(__XF_AP_PROXY(proxy->core), handle->id); + msg.opcode = XF_UNREGISTER; + msg.buffer = NULL; + msg.length = 0; + + /* ...synchronously execute command on remote proxy */ + XF_CHK_API(xf_proxy_cmd_exec(proxy, &msg)); + + /* ...opcode must be XF_UNREGISTER - tbd */ + BUG(msg.opcode != XF_UNREGISTER, _x("Invalid opcode: %X"), msg.opcode); + + TRACE(REG, _b("%p[%u:%u] unregistered"), handle, XF_PORT_CORE(handle->id), XF_PORT_CLIENT(handle->id)); + + return 0; +} + +/* ...allocate shared buffer */ +static inline int xf_proxy_buffer_alloc(xf_proxy_t *proxy, u32 length, void **buffer) +{ + u32 core = proxy->core; + xf_user_msg_t msg; + + /* ...prepare command parameters */ + msg.id = __XF_MSG_ID(__XF_AP_PROXY(core), __XF_DSP_PROXY(core)); + msg.opcode = XF_ALLOC; + msg.length = length; + msg.buffer = NULL; + + /* ...synchronously execute command on remote proxy */ + XF_CHK_API(xf_proxy_cmd_exec(proxy, &msg)); + + /* ...check if response is valid */ + XF_CHK_ERR(msg.opcode == XF_ALLOC, -EBADFD); + + /* ...check if allocation is successful */ + XF_CHK_ERR(msg.buffer != NULL, -ENOMEM); + + /* ...save output parameter */ + *buffer = msg.buffer; + + TRACE(MEM, _b("proxy-%u: allocated [%p:%u]"), core, *buffer, length); + + return 0; +} + +/* ...free shared AP-DSP memory */ +static inline int xf_proxy_buffer_free(xf_proxy_t *proxy, void *buffer, u32 length) +{ + u32 core = proxy->core; + xf_user_msg_t msg; + + /* ...prepare command parameters */ + msg.id = __XF_MSG_ID(__XF_AP_PROXY(core), __XF_DSP_PROXY(core)); + msg.opcode = XF_FREE; + msg.length = length; + msg.buffer = buffer; + + /* ...synchronously execute command on remote proxy */ + XF_CHK_API(xf_proxy_cmd_exec(proxy, &msg)); + + /* ...check if response is valid */ + XF_CHK_ERR(msg.opcode == XF_FREE, -EBADFD); + + TRACE(MEM, _b("proxy-%u: free [%p:%u]"), core, buffer, length); + + return 0; +} + +/******************************************************************************* + * Proxy interface asynchronous receiving thread + ******************************************************************************/ + +static void * xf_proxy_thread(void *arg) +{ + xf_proxy_t *proxy = arg; + xf_handle_t *client; + int r; + + /* ...start polling thread */ + while (1) + { + xf_proxy_msg_t m; + xf_user_msg_t msg; + + /* ...wait for response from remote proxy (infinite timeout) */ + if ((r = xf_ipc_wait(&proxy->ipc, 0)) < 0) + break; + + /* ...retrieve all responses received */ + while ((r = xf_ipc_recv(&proxy->ipc, &m, &msg.buffer)) == sizeof(m)) + { + /* ...make sure we have proper core identifier of SHMEM interface */ + BUG(XF_MSG_DST_CORE(m.id) != proxy->core, _x("Invalid session-id: %X (core=%u)"), m.id, proxy->core); + + /* ...make sure translation is successful */ + BUG(msg.buffer == (void *)-1, _x("Invalid buffer address: %08x"), m.address); + + /* ...retrieve information fields */ + msg.id = XF_MSG_SRC(m.id), msg.opcode = m.opcode, msg.length = m.length; + + TRACE(RSP, _b("R[%08x]:(%08x,%u,%08x)"), m.id, m.opcode, m.length, m.address); + + /* ...lookup component basing on destination port specification */ + if (XF_AP_CLIENT(m.id) == 0) + { + /* ...put proxy response to local IPC queue */ + xf_proxy_response_put(proxy, &m); + } + else if ((client = xf_client_lookup(proxy, XF_AP_CLIENT(m.id))) != NULL) + { + /* ...client is found; invoke its response callback (must be non-blocking) */ + client->response(client, &msg); + } + else + { + /* ...client has been disconnected already; drop message */ + TRACE(RSP, _b("Client look-up failed - drop message")); + } + } + + /* ...if result code is negative; terminate thread operation */ + if (r < 0) + { + TRACE(ERROR, _x("abnormal proxy[%p] thread termination: %d"), proxy, r); + break; + } + } + + TRACE(INIT, _b("IPC proxy[%p] thread terminated: %d"), proxy, r); + + return (void *)(intptr_t)r; +} + +/******************************************************************************* + * HiFi proxy API + ******************************************************************************/ + +/* ...open HiFi proxy */ +int xf_proxy_init(xf_proxy_t *proxy, u32 core, void *p_shmem) +{ + u32 i; + int r; + + /* ...initialize proxy lock */ + __xf_lock_init(&proxy->lock); + + /* ...open proxy IPC interface */ + XF_CHK_API(xf_ipc_open(&proxy->ipc, core, p_shmem)); + + /* ...save proxy core - hmm, too much core identifiers - tbd */ + proxy->core = core; + + /* ...line-up all clients into single-linked list */ + for (i = 0; i < XF_CFG_PROXY_MAX_CLIENTS - 1; i++) + { + proxy->cmap[i].next = i + 1; + } + + /* ...tail of the list points back to head (list terminator) */ + proxy->cmap[i].next = 0; + + /* ...initialize thread attributes (joinable, with minimal stack) */ + if ((r = __xf_thread_create(&proxy->thread, xf_proxy_thread, proxy)) < 0) + { + TRACE(ERROR, _x("Failed to create polling thread: %d"), r); + xf_ipc_close(&proxy->ipc, core); + return r; + } + + TRACE(INIT, _b("proxy-%u[%p] opened"), core, proxy); + + return 0; +} + +/* ...close proxy handle */ +void xf_proxy_close(xf_proxy_t *proxy) +{ + u32 core = proxy->core; + + /* ...terminate proxy thread */ + __xf_thread_destroy(&proxy->thread); + + /* ...close proxy IPC interface */ + xf_ipc_close(&proxy->ipc, core); + + TRACE(INIT, _b("proxy-%u[%p] closed"), core, proxy); +} + +/******************************************************************************* + * HiFi component API + ******************************************************************************/ + +/* ...open component handle */ +int xf_open(xf_proxy_t *proxy, xf_handle_t *handle, xf_id_t id, u32 core, xf_response_cb response) +{ + int r; + + /* ...retrieve auxiliary control buffer from proxy - need I */ + XF_CHK_ERR(handle->aux = xf_buffer_get(proxy->aux), -EBUSY); + + /* ...initialize IPC data */ + XF_CHK_API(xf_ipc_data_init(&handle->ipc)); + + /* ...register client in interlocked fashion */ + xf_proxy_lock(proxy); + + /* ...allocate local client */ + if (xf_client_alloc(proxy, handle) == 0) + { + TRACE(ERROR, _x("client allocation failed")); + r = -EBUSY; + } + else if ((r = xf_client_register(proxy, handle, id, core)) < 0) + { + TRACE(ERROR, _x("client registering failed")); + xf_client_free(proxy, handle); + } + + xf_proxy_unlock(proxy); + + /* ...if failed, release buffer handle */ + if (r < 0) + { + /* ...operation failed; return buffer back to proxy pool */ + xf_buffer_put(handle->aux), handle->aux = NULL; + } + else + { + /* ...operation completed successfully; assign handle data */ + handle->response = response; + handle->proxy = proxy; + + TRACE(INIT, _b("component[%p]:(id=%s,core=%u) created"), handle, id, core); + } + + return XF_CHK_API(r); +} + +/* ...close component handle */ +void xf_close(xf_handle_t *handle) +{ + xf_proxy_t *proxy = handle->proxy; + + /* ...do I need to take component lock here? guess no - tbd */ + + /* ...buffers and stuff? - tbd */ + + /* ...acquire global proxy lock */ + xf_proxy_lock(proxy); + + /* ...unregister component from remote DSP proxy (ignore result code) */ + (void) xf_client_unregister(proxy, handle); + + /* ...recycle client-id afterwards */ + xf_client_free(proxy, handle); + + /* ...release global proxy lock */ + xf_proxy_unlock(proxy); + + /* ...destroy IPC data */ + xf_ipc_data_destroy(&handle->ipc); + + /* ...clear handle data */ + xf_buffer_put(handle->aux), handle->aux = NULL; + + /* ...wipe out proxy pointer */ + handle->proxy = NULL; + + TRACE(INIT, _b("component[%p] destroyed"), handle); +} + +/* ...port binding function */ +int xf_route(xf_handle_t *src, u32 src_port, xf_handle_t *dst, u32 dst_port, u32 num, u32 size, u32 align) +{ + xf_proxy_t *proxy = src->proxy; + xf_buffer_t *b; + xf_route_port_msg_t *m; + xf_user_msg_t msg; + + /* ...validity checks - proxy pointers are same */ + XF_CHK_ERR(proxy == dst->proxy, -EINVAL); + + /* ...buffer data is valid */ + XF_CHK_ERR(num && size && xf_is_power_of_two(align), -EINVAL); + + /* ...get control buffer */ + XF_CHK_ERR(b = xf_buffer_get(proxy->aux), -EBUSY); + + /* ...get message buffer */ + m = xf_buffer_data(b); + + /* ...fill-in message parameters */ + //m->src = __XF_PORT_SPEC2(src->id, src_port); + m->dst = __XF_PORT_SPEC2(dst->id, dst_port); + m->alloc_number = num; + m->alloc_size = size; + m->alloc_align = align; + + /* ...set command parameters */ + msg.id = __XF_MSG_ID(__XF_AP_PROXY(proxy->core), __XF_PORT_SPEC2(src->id, src_port)); + msg.opcode = XF_ROUTE; + msg.length = sizeof(*m); + msg.buffer = m; + + /* ...synchronously execute command on remote DSP */ + XF_CHK_API(xf_proxy_cmd_exec(proxy, &msg)); + + /* ...return buffer to proxy */ + xf_buffer_put(b); + + /* ...check result is successfull */ + XF_CHK_ERR(msg.opcode == (u32) XF_ROUTE, -ENOMEM); + + /* ...port binding completed */ + TRACE(GRAPH, _b("[%p]:%u bound to [%p]:%u"), src, src_port, dst, dst_port); + + return 0; +} + +/* ...port unbinding function */ +int xf_unroute(xf_handle_t *src, u32 src_port) +{ + xf_proxy_t *proxy = src->proxy; + xf_buffer_t *b; + xf_unroute_port_msg_t *m; + xf_user_msg_t msg; + int r; + + /* ...get control buffer */ + XF_CHK_ERR(b = xf_buffer_get(proxy->aux), -EBUSY); + + /* ...get message buffer */ + m = xf_buffer_data(b); + + /* ...fill-in message parameters */ + //m->src = __XF_PORT_SPEC2(src->id, src_port); + + /* ...set command parameters */ + msg.id = __XF_MSG_ID(__XF_AP_PROXY(proxy->core), __XF_PORT_SPEC2(src->id, src_port)); + msg.opcode = XF_UNROUTE; + msg.length = sizeof(*m); + msg.buffer = m; + + /* ...synchronously execute command on remote DSP */ + if ((r = xf_proxy_cmd_exec(proxy, &msg)) != 0) + { + TRACE(ERROR, _x("Command failed: %d"), r); + goto out; + } + else if (msg.opcode != (u32) XF_UNROUTE) + { + TRACE(ERROR, _x("Port unbinding failed")); + r = -EBADFD; + goto out; + } + + /* ...port binding completed */ + TRACE(GRAPH, _b("[%p]:%u unbound"), src, src_port); + +out: + /* ...return buffer to proxy */ + xf_buffer_put(b); + + return r; +} + +/* ...send a command message to component */ +int xf_command(xf_handle_t *handle, u32 port, u32 opcode, void *buffer, u32 length) +{ + xf_proxy_t *proxy = handle->proxy; + xf_proxy_msg_t msg; + + /* ...fill-in message parameters */ + msg.id = __XF_MSG_ID(__XF_AP_CLIENT(proxy->core, handle->client), __XF_PORT_SPEC2(handle->id, port)); + msg.opcode = opcode; + msg.length = length; + XF_CHK_ERR((msg.address = xf_proxy_b2a(proxy, buffer)) != XF_PROXY_BADADDR, -EINVAL); + + TRACE(CMD, _b("[%p]:[%08x]:(%08x,%u,%p)"), handle, msg.id, opcode, length, buffer); + + /* ...pass command to IPC layer */ + return XF_CHK_API(xf_ipc_send(&proxy->ipc, &msg, buffer)); +} + +/******************************************************************************* + * Buffer pool API + ******************************************************************************/ + +/* ...allocate buffer pool */ +int xf_pool_alloc(xf_proxy_t *proxy, u32 number, u32 length, xf_pool_type_t type, xf_pool_t **pool, s32 id, + xaf_mem_malloc_fxn_t xaf_malloc, xaf_mem_free_fxn_t xaf_free) +{ + xf_pool_t *p; + xf_buffer_t *b; + void *data; + int r; + + /* ...unused arg */ + (void) type; + + /* ...basic validity checks; number of buffers is positive */ + XF_CHK_ERR(number > 0, -EINVAL); + + /* ...get properly aligned buffer length */ + length = (length + XF_PROXY_ALIGNMENT - 1) & ~(XF_PROXY_ALIGNMENT - 1); + + /* ...allocate data structure */ + p = xaf_malloc(offset_of(xf_pool_t, buffer) + number * sizeof(xf_buffer_t), id); + XF_CHK_ERR(p, -ENOMEM); + + /* ...issue memory pool allocation request to remote DSP */ + xf_proxy_lock(proxy); + r = xf_proxy_buffer_alloc(proxy, number * length, &p->p); + xf_proxy_unlock(proxy); + + /* ...if operation is failed, do cleanup */ + if (r < 0) + { + TRACE(ERROR, _x("failed to allocate buffer: %d"), r); + xaf_free(p, id); + return r; + } + else + { + /* ...set pool parameters */ + p->number = number, p->length = length; + p->proxy = proxy; + } + + /* ...create individual buffers and link them into free list */ + for (p->free = b = &p->buffer[0], data = p->p; number > 0; number--, b++) + { + /* ...set address of the buffer (no length there) */ + b->address = data; + + /* ...file buffer into the free list */ + b->link.next = b + 1; + + /* ...advance data pointer in contiguous buffer */ + data = (unsigned char *) data + length; + } + + /* ...terminate list of buffers (not too good - tbd) */ + b[-1].link.next = NULL; + + TRACE(BUFFER, _b("[%p]: pool[%p] created: %u * %u"), proxy, p, p->number, p->length); + + /* ...return buffer pointer */ + *pool = p; + + return 0; +} + +/* ...buffer pool destruction */ +void xf_pool_free(xf_pool_t *pool, s32 id, xaf_mem_free_fxn_t xaf_free) +{ + xf_proxy_t *proxy = pool->proxy; + + /* ...check buffers are all freed - tbd */ + + /* ...use global proxy lock for pool operations protection */ + xf_proxy_lock(proxy); + + /* ...release allocated buffer on remote DSP */ + xf_proxy_buffer_free(proxy, pool->p, pool->length * pool->number); + + /* ...release global proxy lock */ + xf_proxy_unlock(proxy); + + /* ...deallocate pool structure itself */ + xaf_free(pool, id); + + TRACE(BUFFER, _b("[%p]::pool[%p] destroyed"), proxy, pool); +} + +/* ...get new buffer from a pool */ +xf_buffer_t * xf_buffer_get(xf_pool_t *pool) +{ + xf_buffer_t *b; + + /* ...use global proxy lock for pool operations protection */ + xf_proxy_lock(pool->proxy); + + /* ...take buffer from a head of the free list */ + if ((b = pool->free) != NULL) + { + /* ...advance free list head */ + pool->free = b->link.next, b->link.pool = pool; + + TRACE(BUFFER, _b("pool[%p]::get[%p]"), pool, b); + } + + xf_proxy_unlock(pool->proxy); + + return b; +} + +/* ...return buffer back to pool */ +void xf_buffer_put(xf_buffer_t *buffer) +{ + xf_pool_t *pool = buffer->link.pool; + + /* ...use global proxy lock for pool operations protection */ + xf_proxy_lock(pool->proxy); + + /* ...put buffer back to a pool */ + buffer->link.next = pool->free, pool->free = buffer; + + TRACE(BUFFER, _b("pool[%p]::put[%p]"), pool, buffer); + + xf_proxy_unlock(pool->proxy); +} diff --git a/hifi/xaf/host-apf/proxy/xf-trace.c b/hifi/xaf/host-apf/proxy/xf-trace.c new file mode 100644 index 00000000..fb902676 --- /dev/null +++ b/hifi/xaf/host-apf/proxy/xf-trace.c @@ -0,0 +1,90 @@ +/******************************************************************************* +* 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 "xf.h" +#include <sys/time.h> + +#if XF_TRACE +/******************************************************************************* + * Local data definitions + ******************************************************************************/ + +/* ...tracing lock */ +static pthread_mutex_t xf_trace_mutex; + +/******************************************************************************* + * Tracing facility + ******************************************************************************/ + +/* ...timestamp function */ +static u32 xf_timenow(void) +{ + struct timeval tv; + + /* ...get current time value */ + gettimeofday(&tv, NULL); + + /* ...wrap over every 100 seconds */ + return (u32)((tv.tv_sec % 100) * 1000000 + tv.tv_usec); +} + +/* ...tracing initialization */ +void xf_trace_init(const char *banner) +{ + /* ...initialize tracing lock */ + pthread_mutex_init(&xf_trace_mutex, NULL); + + /* ...output banner */ + xf_trace(banner); +} + +/* ...tracing primitive */ +int xf_trace(const char *format, ...) +{ + va_list args; + static char buf[256]; + char *b = buf; + + /* ...get global tracing lock */ + pthread_mutex_lock(&xf_trace_mutex); + + /* ...output timestamp */ + b += sprintf(b, "[%08u] ", xf_timenow()); + + /* ...output format string */ + va_start(args, format); + b += vsprintf(b, format, args); + va_end(args); + + /* ...put terminator */ + *b = '\0'; + + /* ...output prepared string */ + __xf_puts(buf); + + /* ...release tracing lock */ + pthread_mutex_unlock(&xf_trace_mutex); + + return 0; +} + +#endif /* XF_TRACE */ diff --git a/hifi/xaf/host-apf/tools/dhifimesg b/hifi/xaf/host-apf/tools/dhifimesg Binary files differnew file mode 100755 index 00000000..88294880 --- /dev/null +++ b/hifi/xaf/host-apf/tools/dhifimesg diff --git a/hifi/xaf/host-apf/utest/include/xaf-mem.h b/hifi/xaf/host-apf/utest/include/xaf-mem.h new file mode 100644 index 00000000..68838035 --- /dev/null +++ b/hifi/xaf/host-apf/utest/include/xaf-mem.h @@ -0,0 +1,49 @@ +/******************************************************************************* +* 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. + +******************************************************************************/ + +#define MEM_NUM_MEM_ALLOC 32 + +typedef struct { + void* heap_ptr; + int size; +}mem_obj_dev_t; + +typedef struct { + void* heap_ptr; + int size; +}mem_obj_comp_t; + +typedef struct { + mem_obj_dev_t mem_dev[MEM_NUM_MEM_ALLOC]; + mem_obj_comp_t mem_comp[MEM_NUM_MEM_ALLOC]; + int num_malloc_dev; + int num_malloc_comp; + int persi_mem_dev; + int persi_mem_comp; +}mem_obj_t; + +void* mem_malloc(int size, int id); +void mem_free(void * heap_ptr, int id); +void* mem_init(); +void mem_exit(); +int mem_get_alloc_size(mem_obj_t* mem_handle, int id); + diff --git a/hifi/xaf/host-apf/utest/include/xaf-utils-test.h b/hifi/xaf/host-apf/utest/include/xaf-utils-test.h new file mode 100644 index 00000000..e6c2ce03 --- /dev/null +++ b/hifi/xaf/host-apf/utest/include/xaf-utils-test.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. + +******************************************************************************/ + +#include <stdio.h> + +#include "xf.h" +#include "xaf-api.h" +#include "xa_type_def.h" + +#include "xaf-mem.h" + +/* exported global variables */ +extern int audio_frmwk_buf_size; +extern int audio_comp_buf_size; + +int print_mem_mcps_info(mem_obj_t* mem_handle, int num_comp); +int print_banner(char *app_name); + diff --git a/hifi/xaf/host-apf/utest/xaf-dec-mix-test.c b/hifi/xaf/host-apf/utest/xaf-dec-mix-test.c new file mode 100644 index 00000000..28ac8767 --- /dev/null +++ b/hifi/xaf/host-apf/utest/xaf-dec-mix-test.c @@ -0,0 +1,421 @@ +/******************************************************************************* +* 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. + +******************************************************************************/ + +#define MODULE_TAG UTEST + +#include "xaf-utils-test.h" + +#include "audio/xa_vorbis_dec_api.h" +#include "audio/xa-mixer-api.h" +#include "audio/xa-audio-decoder-api.h" + +#include "xa_playback.h" + +#define PRINT_USAGE do { fprintf(stderr, "\nUsage: %s <input-file1> <input-file2>\n", argv[0]); \ + fprintf(stderr, " Only .ogg and .pcm files are supported. \n"); \ + fprintf(stderr, " Playback is configured @ 48kHz, 2 ch, 16 bits pcm. \n"); \ + fprintf(stderr, " <input-file2> is optional. \n"); \ + fprintf(stderr, " pcm output is written to dec-mix-out.pcm, by default. \n\n"); \ + } while(0) + +#define MAX_INP_STRMS 2 +#define NUM_COMP_IN_GRAPH 3 + +/* ...global variables */ +int g_pthread_exit_code=0x12345678; + +/* ...playback format */ +xaf_format_t pb_format; + +/* ...playback device parameters */ +void *pb_handle = NULL; + +void thread_exit_handler(int sig) +{ + /* ...unused arg */ + (void) sig; + + pthread_exit(0); +} + +static int vorbis_setup(void *p_decoder) +{ + int param[2]; + + /* 1: Raw decode, 0: Ogg decode */ + param[0] = XA_VORBISDEC_CONFIG_PARAM_RAW_VORBIS_FILE_MODE; + param[1] = 0; + + XF_CHK_API(xaf_comp_set_config(p_decoder, 1, ¶m[0])); + + return 0; +} + +static int pcm_setup(void *p_pcm) +{ + int param[6]; + + param[0] = XA_CODEC_CONFIG_PARAM_SAMPLE_RATE; + param[1] = pb_format.sample_rate; + param[2] = XA_CODEC_CONFIG_PARAM_CHANNELS; + param[3] = pb_format.channels; + param[4] = XA_CODEC_CONFIG_PARAM_PCM_WIDTH; + param[5] = pb_format.pcm_width; + + XF_CHK_API(xaf_comp_set_config(p_pcm, 3, ¶m[0])); + + return 0; +} + +static int mixer_setup(void *p_decoder, xaf_format_t *p_format) +{ + int param[6]; + + param[0] = XA_MIXER_CONFIG_PARAM_SAMPLE_RATE; + param[1] = p_format->sample_rate; + param[2] = XA_MIXER_CONFIG_PARAM_CHANNELS; + param[3] = p_format->channels; + param[4] = XA_MIXER_CONFIG_PARAM_PCM_WIDTH; + param[5] = p_format->pcm_width; + + XF_CHK_API(xaf_comp_set_config(p_decoder, 3, ¶m[0])); + + return 0; +} + +static int consume_output(void *p_buf, int buf_length, void *p_output) +{ + XAF_CHK_PTR(p_buf); + XAF_CHK_PTR(p_output); + +#if !defined BOARD + FILE *fp = p_output; + fwrite(p_buf, 1, buf_length, fp); + + if (xa_playback_buf(pb_handle, p_buf, buf_length)) { + TRACE(ERROR, _b("Playback Failed \n")); + return -1; + } +#else +#endif + return 0; +} + +static int read_input(void *p_buf, int buf_length, int *read_length, void *p_input) +{ + XAF_CHK_PTR(p_buf); + XAF_CHK_PTR(read_length); + XAF_CHK_PTR(p_input); + +#if !defined BOARD + FILE *fp = p_input; + *read_length = fread(p_buf, 1, buf_length, fp); +#else +#endif + return 0; +} + +static int comp_process_entry(void *arg) +{ + void *p_comp; + void *p_input, *p_output; + xaf_comp_status comp_status; + xaf_info_t comp_info; + int input_over, read_length; + void * (*arg_arr)[3]; + void *pg_pthread_exit_code = (void*)&g_pthread_exit_code; + + XAF_CHK_PTR(arg); + + arg_arr = arg; + p_comp = (*arg_arr)[0]; + p_input = (*arg_arr)[1]; + p_output = (*arg_arr)[2]; + input_over = 0; + + XF_CHK_API(xaf_comp_process(NULL, p_comp, NULL, 0, XAF_EXEC_FLAG)); + + while (1) + { + XF_CHK_API(xaf_comp_get_status(NULL, p_comp, &comp_status, &comp_info)); + + if (comp_status == XAF_EXEC_DONE) break; + + if (comp_status == XAF_NEED_INPUT && !input_over) + { + void *p_buf = (void *) comp_info.buf; + int size = comp_info.length; + + XF_CHK_API(read_input(p_buf, size, &read_length, p_input)); + + if (read_length) + XF_CHK_API(xaf_comp_process(NULL, p_comp, (void *)comp_info.buf, read_length, XAF_INPUT_READY_FLAG)); + else + { + XF_CHK_API(xaf_comp_process(NULL, p_comp, NULL, 0, XAF_INPUT_OVER_FLAG)); + input_over = 1; + } + } + + if (comp_status == XAF_OUTPUT_READY) + { + void *p_buf = (void *) comp_info.buf; + int size = comp_info.length; + + XF_CHK_API(consume_output(p_buf, size, p_output)); + XF_CHK_API(xaf_comp_process(NULL, p_comp, (void *)comp_info.buf, comp_info.length, XAF_NEED_OUTPUT_FLAG)); + } + } + pthread_exit(pg_pthread_exit_code); + + return 0; +} + +int main(int argc, const char **argv) +{ + void *p_adev = NULL; + void *p_decoder[MAX_INP_STRMS]; + void *p_mixer; + mem_obj_t* mem_handle; + int num_comp = NUM_COMP_IN_GRAPH; + + xaf_comp_status dec_status; + xaf_info_t comp_info; + + void *p_input[MAX_INP_STRMS], *p_output; + + xf_id_t dec_id[MAX_INP_STRMS]; + int (*dec_setup[MAX_INP_STRMS])(void *p_comp); + + pthread_t dec_thread[MAX_INP_STRMS]; + pthread_t mixer_thread; + void *dec_thread_args[MAX_INP_STRMS][3]; + void *mixer_thread_args[3]; + + const char *ext; + FILE *fp, *ofp; + void *dec_inbuf[MAX_INP_STRMS][2]; + int buf_length = XAF_INBUF_SIZE; + int read_length; + int input_over = 0; + int i, j; + int num_strms; + + unsigned int card = 0; + unsigned int device = 0; + unsigned int period_size = 1024; + unsigned int period_count = 4; + + int pthread_error; + void *pthread_exit_code[3]; + + struct sigaction actions; + memset(&actions, 0, sizeof(actions)); + sigemptyset(&actions.sa_mask); + actions.sa_flags = 0; + actions.sa_handler = thread_exit_handler; + sigaction(SIGUSR1,&actions,NULL); + + /* ...initialize playback format */ + pb_format.sample_rate = 48000; + pb_format.channels = 2; + pb_format.pcm_width = 16; + + audio_frmwk_buf_size = 0; //unused + audio_comp_buf_size = 0; //unused + + print_banner("\'Audio decoder(PCM/Ogg-Vorbis) + Mixer\'"); + + /* ...initialize tracing facility */ + TRACE_INIT("Xtensa Audio Framework - Sample Application"); + +#if !defined BOARD + /* ...check input arguments */ + if (argc < 2 || argc > (MAX_INP_STRMS+1)) + { + TRACE(ERROR, _b("Usage: ./xaf-test <infile1> <infile2>\n")); + PRINT_USAGE; + return 0; + } + + argc--; + for (i=0; i<argc; i++) + { + ext = strrchr(argv[i+1], '.'); + if (!ext) + { + PRINT_USAGE; + return 0; + } + ext++; + if (!strcmp(ext, "pcm")) { + dec_id[i] = "audio-decoder/pcm"; + dec_setup[i] = pcm_setup; + } + else if (!strcmp(ext, "ogg")) { + dec_id[i] = "audio-decoder/vorbis"; + dec_setup[i] = vorbis_setup; + } + else { + TRACE(ERROR, _x("Unknown Decoder Extension '%s'"), ext); + PRINT_USAGE; + exit(-1); + } + /* ...open file */ + if ((fp = fopen(argv[i+1], "rb")) == NULL) + { + TRACE(ERROR, _x("Failed to open '%s': %d"), argv[i+1], errno); + exit(-1); + } + p_input[i] = fp; + } + num_strms = i; + + if ((ofp = fopen("dec-mix-out.pcm", "wb")) == NULL) + { + TRACE(ERROR, _x("Failed to open '%s': %d"), "dec-mix-out.pcm", errno); + exit(-1); + } + p_output = ofp; +#endif + + mem_handle = mem_init(); //initialize memory handler + + XF_CHK_API(xaf_adev_open(&p_adev, audio_frmwk_buf_size, audio_comp_buf_size, mem_malloc, mem_free)); + + /* ...create mixer component */ + XF_CHK_API(xaf_comp_create(p_adev, &p_mixer, "mixer", 0, 1, NULL, XAF_MIXER)); + XF_CHK_API(mixer_setup(p_mixer, &pb_format)); + + for (i=0; i<num_strms; i++) + { + /* ...create decoder component */ + XF_CHK_API(xaf_comp_create(p_adev, &p_decoder[i], dec_id[i], 2, 0, &dec_inbuf[i][0], XAF_DECODER)); + XF_CHK_API((dec_setup[i])(p_decoder[i])); + + /* ...start decoder component */ + XF_CHK_API(xaf_comp_process(p_adev, p_decoder[i], NULL, 0, XAF_START_FLAG)); + + /* ...feed input to decoder component */ + for (j=0; j<2; j++) + { + XF_CHK_API(read_input(dec_inbuf[i][j], buf_length, &read_length, p_input[i])); + + if (read_length) + XF_CHK_API(xaf_comp_process(p_adev, p_decoder[i], dec_inbuf[i][j], read_length, XAF_INPUT_READY_FLAG)); + else + break; + } + + /* ...initialization loop */ + while (1) + { + XF_CHK_API(xaf_comp_get_status(p_adev, p_decoder[i], &dec_status, &comp_info)); + + if (dec_status == XAF_INIT_DONE || dec_status == XAF_EXEC_DONE) break; + + if (dec_status == XAF_NEED_INPUT && !input_over) + { + void *p_buf = (void *) comp_info.buf; + int size = comp_info.length; + + XF_CHK_API(read_input(p_buf, size, &read_length, p_input[i])); + + if (read_length) + XF_CHK_API(xaf_comp_process(p_adev, p_decoder[i], p_buf, read_length, XAF_INPUT_READY_FLAG)); + else + break; + } + } + + if (dec_status != XAF_INIT_DONE) + { + TRACE(ERROR, _x("Failed to init")); + exit(-1); + } + + XF_CHK_API(xaf_connect(p_decoder[i], p_mixer, 4)); + } + + XF_CHK_API(xaf_comp_process(p_adev, p_mixer, NULL, 0, XAF_START_FLAG)); + XF_CHK_API(xaf_comp_get_status(p_adev, p_mixer, &dec_status, &comp_info)); + + if (dec_status != XAF_INIT_DONE) + { + TRACE(ERROR, _x("Failed to init")); + exit(-1); + } + + /* ...open playback device */ + pb_handle = xa_playback_open(card, device, pb_format.channels, pb_format.sample_rate, + pb_format.pcm_width, period_size, period_count); + if (!pb_handle) { + TRACE(ERROR, _x("Playback open error\n")); + return -1; + } + + for (i=0; i<num_strms; i++) + { + dec_thread_args[i][0] = p_decoder[i]; + dec_thread_args[i][1] = p_input[i]; + dec_thread_args[i][2] = p_output; + pthread_create(&dec_thread[i], 0, (void *(*)(void*))&comp_process_entry, dec_thread_args[i]); + } + + mixer_thread_args[0] = p_mixer; + mixer_thread_args[1] = NULL; + mixer_thread_args[2] = p_output; + pthread_create(&mixer_thread, 0, (void *(*)(void*))comp_process_entry, &mixer_thread_args[0]); + + for (i=0; i<num_strms; i++) + { + pthread_error = pthread_join(dec_thread[i], (void **) &pthread_exit_code[i]); + if(pthread_error) + { + TRACE(ERROR, _b("decode thread %d join error:%x\n"), i, pthread_error); + } + } + pthread_error = pthread_join(mixer_thread, (void **) &pthread_exit_code[i]); + if(pthread_error) + { + TRACE(ERROR, _b("mixer thread join error:%x\n"), pthread_error); + } + + for (i=0; i<num_strms; i++) + { + XF_CHK_API(xaf_comp_delete(p_decoder[i])); + if (p_input[i]) fclose(p_input[i]); + } + XF_CHK_API(xaf_comp_delete(p_mixer)); + + /* ...exec done, clean-up */ + xa_playback_close(pb_handle); + + XF_CHK_API(xaf_adev_close(p_adev, 0 /*unused*/)); + if (p_output) fclose(p_output); + + mem_exit(); + XF_CHK_API(print_mem_mcps_info(mem_handle, num_comp)); + + return 0; +} + diff --git a/hifi/xaf/host-apf/utest/xaf-dec-test.c b/hifi/xaf/host-apf/utest/xaf-dec-test.c new file mode 100644 index 00000000..b83a0f90 --- /dev/null +++ b/hifi/xaf/host-apf/utest/xaf-dec-test.c @@ -0,0 +1,344 @@ +/******************************************************************************* +* 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. + +******************************************************************************/ + +#define MODULE_TAG UTEST + +#include "xaf-utils-test.h" + +#include "audio/xa_vorbis_dec_api.h" +#include "audio/xa-audio-decoder-api.h" + +#include "xa_playback.h" + +#define PRINT_USAGE do { fprintf(stderr, "\nUsage: %s <input-file>\n", argv[0]); \ + fprintf(stderr, " Only .ogg and .pcm files are supported. \n"); \ + fprintf(stderr, " Playback is configured @ 48kHz, 2 ch, 16 bits pcm. \n"); \ + fprintf(stderr, " pcm output is written to dec-out.pcm, by default. \n\n"); \ + } while(0) + + +#define NUM_COMP_IN_GRAPH 1 + +void *p_input, *p_output; +pthread_t dec_thread; + +FILE *fp, *ofp=NULL; +xaf_info_t comp_info; +void *pb_handle = NULL; +unsigned int card = 0; +unsigned int device = 0; +unsigned int period_size = 1024; +unsigned int period_count = 4; + +/* ...playback format */ +xaf_format_t pb_format; + +int g_pthread_exit_code=0x12345678; + +void thread_exit_handler(int sig) +{ + /* ...unused arg */ + (void) sig; + + pthread_exit(0); +} + +static int vorbis_setup(void *p_decoder) +{ + int param[2]; + + /* 1: Raw decode, 0: Ogg decode */ + param[0] = XA_VORBISDEC_CONFIG_PARAM_RAW_VORBIS_FILE_MODE; + param[1] = 0; + + XF_CHK_API(xaf_comp_set_config(p_decoder, 1, ¶m[0])); + + return 0; +} + +static int pcm_setup(void *p_pcm) +{ + int param[6]; + + param[0] = XA_CODEC_CONFIG_PARAM_SAMPLE_RATE; + param[1] = pb_format.sample_rate; + param[2] = XA_CODEC_CONFIG_PARAM_CHANNELS; + param[3] = pb_format.channels; + param[4] = XA_CODEC_CONFIG_PARAM_PCM_WIDTH; + param[5] = pb_format.pcm_width; + + XF_CHK_API(xaf_comp_set_config(p_pcm, 3, ¶m[0])); + + return 0; +} + +static int consume_output(void *p_buf, int buf_length, void *p_output) +{ + XAF_CHK_PTR(p_buf); + XAF_CHK_PTR(p_output); + +#if !defined BOARD + FILE *fp = p_output; + fwrite(p_buf, 1, buf_length, fp); + + if (xa_playback_buf(pb_handle, p_buf, buf_length)) { + TRACE(ERROR, _b("Playback Failed \n")); + return -1; + } +#else +#endif + return 0; +} + +static int read_input(void *p_buf, int buf_length, int *read_length, void *p_input) +{ + XAF_CHK_PTR(p_buf); + XAF_CHK_PTR(read_length); + XAF_CHK_PTR(p_input); + +#if !defined BOARD + FILE *fp = p_input; + *read_length = fread(p_buf, 1, buf_length, fp); +#else +#endif + return 0; +} + +static int comp_process_entry(void *arg) +{ + void *p_comp; + xaf_comp_status comp_status; + int input_over, read_length; + void *pg_pthread_exit_code = (void*)&g_pthread_exit_code; + + XAF_CHK_PTR(arg); + XAF_CHK_PTR(p_input); + XAF_CHK_PTR(p_output); + + p_comp = arg; + input_over = 0; + + XF_CHK_API(xaf_comp_process(NULL, p_comp, NULL, 0, XAF_EXEC_FLAG)); + + while (1) + { + + XF_CHK_API(xaf_comp_get_status(NULL, p_comp, &comp_status, &comp_info)); + + if (comp_status == XAF_EXEC_DONE) break; + + if (comp_status == XAF_NEED_INPUT && !input_over) + { + void *p_buf = (void *)comp_info.buf; + int size = comp_info.length; + + XF_CHK_API(read_input(p_buf, size, &read_length, p_input)); + + if (read_length) + XF_CHK_API(xaf_comp_process(NULL, p_comp, (void *)comp_info.buf, read_length, XAF_INPUT_READY_FLAG)); + else + { + XF_CHK_API(xaf_comp_process(NULL, p_comp, NULL, 0, XAF_INPUT_OVER_FLAG)); + input_over = 1; + } + } + + if (comp_status == XAF_OUTPUT_READY) + { + void *p_buf = (void *)comp_info.buf; + int size = comp_info.length; + + XF_CHK_API(consume_output(p_buf, size, p_output)); + XF_CHK_API(xaf_comp_process(NULL, p_comp, (void *)comp_info.buf, comp_info.length, XAF_NEED_OUTPUT_FLAG)); + } + } + pthread_exit(pg_pthread_exit_code); + + return 0; +} + + +int main(int argc, const char **argv) +{ + void *p_adev = NULL; + void *p_decoder; + mem_obj_t* mem_handle; + int num_comp = NUM_COMP_IN_GRAPH; + + xaf_comp_status dec_status; + void *dec_inbuf[2]; + int buf_length = XAF_INBUF_SIZE; + int read_length; + int i; + + xf_id_t dec_id; + int (*dec_setup)(void *p_comp); + const char *ext; + int pthread_error; + void *pthread_exit_code; + + struct sigaction actions; + memset(&actions, 0, sizeof(actions)); + sigemptyset(&actions.sa_mask); + actions.sa_flags = 0; + actions.sa_handler = thread_exit_handler; + sigaction(SIGUSR1,&actions,NULL); + + /* ...initialize playback format */ + pb_format.sample_rate = 48000; + pb_format.channels = 2; + pb_format.pcm_width = 16; + + audio_frmwk_buf_size = 0; //unused + audio_comp_buf_size = 0; //unused + + print_banner("\'Audio decoder(PCM/Ogg-Vorbis)\'"); + + /* ...initialize tracing facility */ + TRACE_INIT("Xtensa Audio Framework - Sample Application"); + +#if !defined BOARD + /* ...check input arguments */ + if (argc != 2) + { + TRACE(ERROR, _b("Usage: ./xaf-test <input-file-.ogg/.pcm>\n")); + PRINT_USAGE; + return 0; + } + + + ext = strrchr(argv[1], '.'); + if (!ext) + { + PRINT_USAGE; + return 0; + } + ext++; + if (!strcmp(ext, "pcm")) { + dec_id = "audio-decoder/pcm"; + dec_setup = pcm_setup; + } + else if (!strcmp(ext, "ogg")) { + dec_id = "audio-decoder/vorbis"; + dec_setup = vorbis_setup; + } + else { + TRACE(ERROR, _x("Unknown Decoder Extension '%s'"), ext); + PRINT_USAGE; + exit(-1); + } + + /* ...open file */ + if ((fp = fopen(argv[1], "rb")) == NULL) + { + TRACE(ERROR, _x("Failed to open '%s': %d"), argv[1], errno); + exit(-1); + } + if ((ofp = fopen("/data/dec-out.pcm", "wb")) == NULL) + { + TRACE(ERROR, _x("Failed to open '%s': %d"), "/data/dec-out.pcm", errno); + exit(-1); + } + p_input = fp; + p_output = ofp; +#endif + + mem_handle = mem_init(); //initialize memory handler + + XF_CHK_API(xaf_adev_open(&p_adev, audio_frmwk_buf_size, audio_comp_buf_size, mem_malloc, mem_free)); + + /* ...create decoder component */ + XF_CHK_API(xaf_comp_create(p_adev, &p_decoder, dec_id, 2, 1, &dec_inbuf[0], XAF_DECODER)); + XF_CHK_API(dec_setup(p_decoder)); + + /* ...start decoder component */ + XF_CHK_API(xaf_comp_process(p_adev, p_decoder, NULL, 0, XAF_START_FLAG)); + + /* ...feed input to decoder component */ + for (i=0; i<2; i++) + { + XF_CHK_API(read_input(dec_inbuf[i], buf_length, &read_length, p_input)); + + if (read_length) + XF_CHK_API(xaf_comp_process(p_adev, p_decoder, dec_inbuf[i], read_length, XAF_INPUT_READY_FLAG)); + else + break; + } + + /* ...initialization loop */ + while (1) + { + XF_CHK_API(xaf_comp_get_status(p_adev, p_decoder, &dec_status, &comp_info)); + + if (dec_status == XAF_INIT_DONE || dec_status == XAF_EXEC_DONE) + { + pb_handle = xa_playback_open(card, device, pb_format.channels, pb_format.sample_rate, + pb_format.pcm_width, period_size, period_count); + if (!pb_handle) { + TRACE(ERROR, _x("Playback open error\n")); + return -1; + } + + break; + } + + if (dec_status == XAF_NEED_INPUT) + { + void *p_buf = (void *) comp_info.buf; + int size = comp_info.length; + + XF_CHK_API(read_input(p_buf, size, &read_length, p_input)); + + if (read_length) + XF_CHK_API(xaf_comp_process(p_adev, p_decoder, p_buf, read_length, XAF_INPUT_READY_FLAG)); + else + break; + } + } + + if (dec_status != XAF_INIT_DONE) + { + TRACE(ERROR, _x("Failed to init")); + exit(-1); + } + + pthread_create(&dec_thread, 0, (void *(*)(void *))&comp_process_entry, p_decoder); + + pthread_error = pthread_join(dec_thread, (void **) &pthread_exit_code); + if(pthread_error) + { + TRACE(ERROR, _b("decode thread join error:%x\n"), pthread_error); + } + + /* ...exec done, clean-up */ + XF_CHK_API(xaf_comp_delete(p_decoder)); + xa_playback_close(pb_handle); + XF_CHK_API(xaf_adev_close(p_adev, 0 /*unused*/)); + if (fp) fclose(fp); + if (ofp) fclose(ofp); + + mem_exit(); + XF_CHK_API(print_mem_mcps_info(mem_handle, num_comp)); + + return 0; +} + diff --git a/hifi/xaf/host-apf/utest/xaf-mem-test.c b/hifi/xaf/host-apf/utest/xaf-mem-test.c new file mode 100644 index 00000000..1343c904 --- /dev/null +++ b/hifi/xaf/host-apf/utest/xaf-mem-test.c @@ -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. + +******************************************************************************/ +#include <stdio.h> +#include <stdlib.h> + +#include "xa_type_def.h" + +/* ...debugging facility */ +#include "xaf-utils-test.h" + +mem_obj_t g_mem_obj; + +void* mem_malloc(int size, int id) +{ + int index; + void* heap_ptr = NULL; + + if(id == XAF_MEM_ID_DEV) + { + index = g_mem_obj.num_malloc_dev; + if(index >= MEM_NUM_MEM_ALLOC-1) + { + heap_ptr = NULL; + } + else + { + heap_ptr = malloc(size); + g_mem_obj.num_malloc_dev++; + g_mem_obj.mem_dev[index].heap_ptr = heap_ptr; + g_mem_obj.mem_dev[index].size = size; + g_mem_obj.persi_mem_dev += size; + } + } + else if(id == XAF_MEM_ID_COMP) + { + index = g_mem_obj.num_malloc_comp; + if(index >= MEM_NUM_MEM_ALLOC-1) + { + heap_ptr = NULL; + } + else + { + heap_ptr = malloc(size); + g_mem_obj.num_malloc_comp++; + g_mem_obj.mem_comp[index].heap_ptr = heap_ptr; + g_mem_obj.mem_comp[index].size = size; + g_mem_obj.persi_mem_comp += size; + } + } + return heap_ptr; +} + +int get_heap_ptr_index(void* p_heap, int id) +{ + int idx; + + idx = -1; + if(id == XAF_MEM_ID_DEV) + { + for(idx = 0; idx < MEM_NUM_MEM_ALLOC; idx++) + { + if(g_mem_obj.mem_dev[idx].heap_ptr == p_heap) + break; + } + } + + else if(id == XAF_MEM_ID_COMP) + { + for(idx = 0; idx < MEM_NUM_MEM_ALLOC; idx++) + { + if(g_mem_obj.mem_comp[idx].heap_ptr == p_heap) + break; + } + } + return idx; +} + +void mem_free(void * heap_ptr, int id) +{ + int index; + int size; + + index = get_heap_ptr_index(heap_ptr, id); + + if (index != -1) + { + if(id == XAF_MEM_ID_DEV) + { + size=g_mem_obj.mem_dev[index].size; + g_mem_obj.mem_dev[index].size = 0; + g_mem_obj.num_malloc_dev--; + free(heap_ptr); + g_mem_obj.mem_dev[index].heap_ptr = NULL; + } + else if(id == XAF_MEM_ID_COMP) + { + size=g_mem_obj.mem_comp[index].size; + g_mem_obj.mem_comp[index].size = 0; + g_mem_obj.num_malloc_comp--; + free(heap_ptr); + g_mem_obj.mem_comp[index].heap_ptr = NULL; + } + } + return; +} + +int mem_get_alloc_size(mem_obj_t* pmem_handle, int id) +{ + int mem_size = 0; + if(id == XAF_MEM_ID_DEV) + mem_size = pmem_handle->persi_mem_dev; + else if(id == XAF_MEM_ID_COMP) + mem_size = pmem_handle->persi_mem_comp; + return mem_size; +} + +void* mem_init() +{ + void* ptr; + ptr = &g_mem_obj; + return ptr; +} + +void mem_exit() +{ + if((g_mem_obj.num_malloc_dev != 0)||(g_mem_obj.num_malloc_comp != 0)) + { + fprintf(stdout,"Memory leaks\n"); + } + return; +} diff --git a/hifi/xaf/host-apf/utest/xaf-utils-test.c b/hifi/xaf/host-apf/utest/xaf-utils-test.c new file mode 100644 index 00000000..79c6710d --- /dev/null +++ b/hifi/xaf/host-apf/utest/xaf-utils-test.c @@ -0,0 +1,69 @@ +/******************************************************************************* +* 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 <stdio.h> +#include <string.h> + +#include "xaf-utils-test.h" + +int audio_frmwk_buf_size; +int audio_comp_buf_size; + +int print_banner(char *app_name) +{ + /* + XAF_CHK_PTR(ver_info[0], "print_verinfo"); + XAF_CHK_PTR(ver_info[1], "print_verinfo"); + XAF_CHK_PTR(ver_info[2], "print_verinfo"); + */ + + fprintf(stdout, "******************************************************************************\n"); + fprintf(stdout, "Cadence Audio Framework (Hosted) : %s \n",app_name); + fprintf(stdout, "Copyright (c) 2018 Cadence Design Systems, Inc.\n"); + /*fprintf(stdout, "Lib Name : %s\n", ver_info[0]); + fprintf(stdout, "Lib Version : %s\n", ver_info[1]); + fprintf(stdout, "API Version : %s\n", ver_info[2]);*/ + fprintf(stdout, "******************************************************************************\n"); + + return 0; +} + +int print_mem_mcps_info(mem_obj_t* mem_handle, int num_comp) +{ + int tot_dev_mem_size, tot_comp_mem_size, tot_size; + + /* ...unused arg */ + (void) num_comp; + + /* ...printing memory info*/ + + tot_dev_mem_size = mem_get_alloc_size(mem_handle, XAF_MEM_ID_DEV); + tot_comp_mem_size = mem_get_alloc_size(mem_handle, XAF_MEM_ID_COMP); + tot_size = tot_dev_mem_size + tot_comp_mem_size; + + fprintf(stdout,"Shared Memory between AP and DSP for IPC: %8d \n", XF_CFG_REMOTE_IPC_POOL_SIZE); + fprintf(stdout,"Memory allocated on AP for Device : %8d \n", tot_dev_mem_size); + fprintf(stdout,"Memory allocated on AP for Components : %8d \n", tot_comp_mem_size); + fprintf(stdout,"Memory allocated on DSP for Components : %8d \n", XF_CFG_LOCAL_POOL_SIZE); + + return 0; +} + diff --git a/hifi/xaf/release.txt b/hifi/xaf/release.txt new file mode 100755 index 00000000..cebd1e24 --- /dev/null +++ b/hifi/xaf/release.txt @@ -0,0 +1,24 @@ +====================================================================== +Xtensa Audio Framework (XAF) - Hosted solution +====================================================================== + +====================================================================== +Revision History +====================================================================== + +Version 0.7_Alpha API 1.1 : April 17, 2018 + ++ Alpha Release ++ Built with RG.5 tools + ++ Added copyrights for makefiles and assembly files. ++ Added float-print (%f) support in DSP trace logs. + +---------------------------------------------------------------------- + +Version 0.6_Alpha API 1.1 : February 15, 2018 + ++ Alpha Release ++ Built with RG.5 tools + +---------------------------------------------------------------------- @@ -1,7 +1,5 @@ -include $(LOCAL_PATH)/vendor-package-ver.mk $(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk) $(call inherit-product, device/linaro/hikey/hikey-common.mk) -$(call inherit-product, vendor/linaro/hikey960/$(EXPECTED_LINARO_VENDOR_VERSION)/hikey.mk) #setup dm-verity configs PRODUCT_SYSTEM_VERITY_PARTITION := /dev/block/platform/soc/f723d000.dwmmc0/by-name/system @@ -56,7 +54,3 @@ ifneq ($(HIKEY_MODS),) endif endif - -PRODUCT_SOONG_NAMESPACES += \ - vendor/linaro/hikey960/$(EXPECTED_LINARO_VENDOR_VERSION)/mali/utgard - diff --git a/hikey/device-hikey.mk b/hikey/device-hikey.mk index cc94c401..aa202b37 100644 --- a/hikey/device-hikey.mk +++ b/hikey/device-hikey.mk @@ -24,6 +24,15 @@ PRODUCT_COPY_FILES += $(TARGET_PREBUILT_KERNEL):kernel \ device/linaro/hikey/ueventd.common.rc:$(TARGET_COPY_OUT_VENDOR)/ueventd.rc \ device/linaro/hikey/common.kl:$(TARGET_COPY_OUT_VENDOR)/usr/keylayout/hikey.kl +# Copy BT firmware +PRODUCT_COPY_FILES += \ + device/linaro/hikey/bt-wifi-firmware-util/TIInit_11.8.32.bts:$(TARGET_COPY_OUT_VENDOR)/firmware/ti-connectivity/TIInit_11.8.32.bts + +# Copy wlan firmware +PRODUCT_COPY_FILES += \ + device/linaro/hikey/bt-wifi-firmware-util/wl18xx-fw-4.bin:$(TARGET_COPY_OUT_VENDOR)/firmware/ti-connectivity/wl18xx-fw-4.bin \ + device/linaro/hikey/bt-wifi-firmware-util/wl18xx-conf.bin:$(TARGET_COPY_OUT_VENDOR)/firmware/ti-connectivity/wl18xx-conf.bin + # Build HiKey HDMI audio HAL PRODUCT_PACKAGES += audio.primary.hikey @@ -45,7 +54,7 @@ PRODUCT_PACKAGES += sensors.hikey PRODUCT_PACKAGES += hwcomposer.drm_hikey # Include mali blobs from ARM -PRODUCT_PACKAGES += libGLES_mali +PRODUCT_PACKAGES += libGLES_mali.so END_USER_LICENCE_AGREEMENT.txt ifneq ($(TARGET_NO_RECOVERY),true) PRODUCT_COPY_FILES += \ diff --git a/hikey960.mk b/hikey960.mk index 06ac84b5..b300bfa8 100644 --- a/hikey960.mk +++ b/hikey960.mk @@ -11,14 +11,11 @@ ifndef HIKEY_USES_GKI endif endif - -include $(LOCAL_PATH)/vendor-package-ver.mk - +# # Inherit the common device configuration $(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk) $(call inherit-product, device/linaro/hikey/hikey960/device-hikey960.mk) $(call inherit-product, device/linaro/hikey/device-common.mk) -$(call inherit-product, vendor/linaro/hikey960/$(EXPECTED_LINARO_VENDOR_VERSION)/hikey960.mk) PRODUCT_PROPERTY_OVERRIDES += ro.opengles.version=196608 @@ -49,6 +46,3 @@ ifneq ($(HIKEY_USES_GKI),) $(SDCARDFS_KO) endif endif - -PRODUCT_SOONG_NAMESPACES += \ - vendor/linaro/hikey960/$(EXPECTED_LINARO_VENDOR_VERSION)/mali/bifrost diff --git a/hikey960/device-hikey960.mk b/hikey960/device-hikey960.mk index fba39a48..d34dc311 100644 --- a/hikey960/device-hikey960.mk +++ b/hikey960/device-hikey960.mk @@ -42,17 +42,35 @@ PRODUCT_BUILD_SUPER_PARTITION := true PRODUCT_USE_DYNAMIC_PARTITIONS := true PRODUCT_USE_DYNAMIC_PARTITION_SIZE :=true +# Copy BT firmware +PRODUCT_COPY_FILES += \ + device/linaro/hikey/bt-wifi-firmware-util/TIInit_11.8.32-pcm-960.bts:$(TARGET_COPY_OUT_VENDOR)/firmware/ti-connectivity/TIInit_11.8.32.bts + +# Copy wlan firmware +PRODUCT_COPY_FILES += \ + device/linaro/hikey/bt-wifi-firmware-util/wl18xx-fw-4.bin:$(TARGET_COPY_OUT_VENDOR)/firmware/ti-connectivity/wl18xx-fw-4.bin \ + device/linaro/hikey/bt-wifi-firmware-util/wl18xx-conf-wl1837mod.bin:$(TARGET_COPY_OUT_VENDOR)/firmware/ti-connectivity/wl18xx-conf.bin + +# Copy hifi firmware +PRODUCT_COPY_FILES += \ + device/linaro/hikey/hifi/firmware/hifi-hikey960.img:$(TARGET_COPY_OUT_VENDOR)/firmware/hifi/hifi.img + +PRODUCT_PACKAGES += \ + dhifimesg + + # Build HiKey960 HDMI audio HAL. Experimental only may not work. FIXME PRODUCT_PACKAGES += audio.primary.hikey960 PRODUCT_PACKAGES += gralloc.hikey960 #binary blobs from ARM -PRODUCT_PACKAGES += libGLES_mali \ - vulkan.hikey960 \ - libbccArm \ - libRSDriverArm \ - libmalicore.bc +PRODUCT_PACKAGES += libGLES_mali.so \ + vulkan.hikey960.so \ + libbccArm.so \ + libRSDriverArm.so \ + libmalicore.bc \ + END_USER_LICENCE_AGREEMENT.txt ifdef MALI_RS_DRIVER_AVAILABLE PRODUCT_COPY_FILES += \ diff --git a/installer/hikey960/fip.bin b/installer/hikey960/fip.bin Binary files differnew file mode 100644 index 00000000..dcf61e25 --- /dev/null +++ b/installer/hikey960/fip.bin diff --git a/installer/hikey960/flash-all.sh b/installer/hikey960/flash-all.sh index c894558c..70bb4328 100755 --- a/installer/hikey960/flash-all.sh +++ b/installer/hikey960/flash-all.sh @@ -5,7 +5,7 @@ ECHO_PREFIX="=== " # for cases that don't run "lunch hikey960-userdebug" if [ -z "${ANDROID_BUILD_TOP}" ]; then - ANDROID_BUILD_TOP=$(cd ${INSTALLER_DIR}/../../../../../; pwd) + ANDROID_BUILD_TOP=${INSTALLER_DIR}/../../../../../ ANDROID_PRODUCT_OUT="${ANDROID_BUILD_TOP}/out/target/product/hikey960" fi @@ -16,22 +16,6 @@ fi echo ${ECHO_PREFIX}"android out dir:${ANDROID_PRODUCT_OUT}" -. "${ANDROID_BUILD_TOP}/device/linaro/hikey/vendor-package-ver.sh" - -VENDOR_DIR=$ANDROID_BUILD_TOP/vendor/linaro/hikey960/${EXPECTED_LINARO_VENDOR_VERSION}/ - -# TODO: Pull one-time recovery/qdl path out of standard install -# Flash bootloader firmware files -if [ ! -d "${VENDOR_DIR}/" ]; then - echo "FLASH-ALL-AOSP: Missing vendor firmware package?" - echo " Make sure the vendor binaries have been downloaded from" - echo " ${VND_PKG_URL}" - echo " and extracted to $ANDROID_BUILD_TOP." - exit -fi - -pushd $VENDOR_DIR/bootloader/ - function check_partition_table_version () { fastboot erase reserved if [ $? -eq 0 ] @@ -43,21 +27,21 @@ function check_partition_table_version () { } function flashing_atf_uefi () { - fastboot flash ptable prm_ptable.img - fastboot flash xloader hisi-sec_xloader.img + fastboot flash ptable "${INSTALLER_DIR}"/prm_ptable.img + fastboot flash xloader "${INSTALLER_DIR}"/hisi-sec_xloader.img fastboot reboot-bootloader - fastboot flash fastboot l-loader.bin - fastboot flash fip fip.bin - fastboot flash nvme hisi-nvme.img - fastboot flash fw_lpm3 hisi-lpm3.img - fastboot flash trustfirmware hisi-bl31.bin + fastboot flash fastboot "${INSTALLER_DIR}"/l-loader.bin + fastboot flash fip "${INSTALLER_DIR}"/fip.bin + fastboot flash nvme "${INSTALLER_DIR}"/hisi-nvme.img + fastboot flash fw_lpm3 "${INSTALLER_DIR}"/hisi-lpm3.img + fastboot flash trustfirmware "${INSTALLER_DIR}"/hisi-bl31.bin fastboot reboot-bootloader - fastboot flash ptable prm_ptable.img - fastboot flash xloader hisi-sec_xloader.img - fastboot flash fastboot l-loader.bin - fastboot flash fip fip.bin + fastboot flash ptable "${INSTALLER_DIR}"/prm_ptable.img + fastboot flash xloader "${INSTALLER_DIR}"/hisi-sec_xloader.img + fastboot flash fastboot "${INSTALLER_DIR}"/l-loader.bin + fastboot flash fip "${INSTALLER_DIR}"/fip.bin fastboot flash boot "${ANDROID_PRODUCT_OUT}"/boot.img fastboot flash super "${ANDROID_PRODUCT_OUT}"/super.img @@ -66,9 +50,9 @@ function flashing_atf_uefi () { } function upgrading_ptable_1mb_aligned () { - fastboot flash xloader hisi-sec_xloader.img - fastboot flash ptable hisi-ptable.img - fastboot flash fastboot hisi-fastboot.img + fastboot flash xloader "${INSTALLER_DIR}"/hisi-sec_xloader.img + fastboot flash ptable "${INSTALLER_DIR}"/hisi-ptable.img + fastboot flash fastboot "${INSTALLER_DIR}"/hisi-fastboot.img fastboot reboot-bootloader } @@ -89,4 +73,3 @@ else fi fastboot reboot -popd diff --git a/installer/hikey960/hisi-bl31.bin b/installer/hikey960/hisi-bl31.bin Binary files differnew file mode 100644 index 00000000..abebea6d --- /dev/null +++ b/installer/hikey960/hisi-bl31.bin diff --git a/installer/hikey960/hisi-fastboot.img b/installer/hikey960/hisi-fastboot.img Binary files differnew file mode 100644 index 00000000..72cbf90f --- /dev/null +++ b/installer/hikey960/hisi-fastboot.img diff --git a/installer/hikey960/hisi-lpm3.img b/installer/hikey960/hisi-lpm3.img Binary files differnew file mode 100644 index 00000000..bd0243bf --- /dev/null +++ b/installer/hikey960/hisi-lpm3.img diff --git a/installer/hikey960/hisi-nvme.img b/installer/hikey960/hisi-nvme.img Binary files differnew file mode 100644 index 00000000..ca5bc7c1 --- /dev/null +++ b/installer/hikey960/hisi-nvme.img diff --git a/installer/hikey960/hisi-ptable.img b/installer/hikey960/hisi-ptable.img Binary files differnew file mode 100644 index 00000000..269aa63d --- /dev/null +++ b/installer/hikey960/hisi-ptable.img diff --git a/installer/hikey960/hisi-sec_xloader.img b/installer/hikey960/hisi-sec_xloader.img Binary files differnew file mode 100644 index 00000000..47c353b8 --- /dev/null +++ b/installer/hikey960/hisi-sec_xloader.img diff --git a/installer/hikey960/l-loader.bin b/installer/hikey960/l-loader.bin Binary files differnew file mode 100644 index 00000000..e0c37260 --- /dev/null +++ b/installer/hikey960/l-loader.bin diff --git a/installer/hikey960/legacy-flash-all.sh b/installer/hikey960/legacy-flash-all.sh new file mode 100755 index 00000000..3f8bf9b4 --- /dev/null +++ b/installer/hikey960/legacy-flash-all.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +INSTALLER_DIR="`dirname ${0}`" + +# for cases that don't run "lunch hikey960-userdebug" +if [ -z "${ANDROID_BUILD_TOP}" ]; then + ANDROID_BUILD_TOP=${INSTALLER_DIR}/../../../../../ + ANDROID_PRODUCT_OUT="${ANDROID_BUILD_TOP}/out/target/product/hikey960" +fi + +if [ ! -d "${ANDROID_PRODUCT_OUT}" ]; then + echo "error in locating out directory, check if it exist" + exit +fi + +echo "android out dir:${ANDROID_PRODUCT_OUT}" + +fastboot flash xloader "${INSTALLER_DIR}"/hisi-sec_xloader.img +fastboot flash ptable "${INSTALLER_DIR}"/hisi-ptable.img +fastboot flash fastboot "${INSTALLER_DIR}"/hisi-fastboot.img +fastboot reboot-bootloader +fastboot flash nvme "${INSTALLER_DIR}"/hisi-nvme.img +fastboot flash fw_lpm3 "${INSTALLER_DIR}"/hisi-lpm3.img +fastboot flash trustfirmware "${INSTALLER_DIR}"/hisi-bl31.bin +fastboot flash boot "${ANDROID_PRODUCT_OUT}"/boot.img +fastboot flash dts "${ANDROID_PRODUCT_OUT}"/dt.img +fastboot flash super "${ANDROID_PRODUCT_OUT}"/super.img +fastboot flash userdata "${ANDROID_PRODUCT_OUT}"/userdata.img +fastboot format:ext4:10000000 cache +fastboot reboot diff --git a/installer/hikey960/mkdtimg b/installer/hikey960/mkdtimg new file mode 100755 index 00000000..65722043 --- /dev/null +++ b/installer/hikey960/mkdtimg @@ -0,0 +1,159 @@ +#!/usr/bin/env python +# Copyright 2017, The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +from __future__ import print_function +try: + from os import fstat, stat, remove + from sys import exit + from argparse import ArgumentParser, FileType + from ctypes import sizeof, Structure, c_char, c_int + from struct import pack, calcsize + import zlib +except Exception as e: + print("some module is needed:" + str(e)) + exit(-1) + +dt_head_info_fmt = '4sII' +dt_entry_fmt = 'Q4I2Q' +dtimg_version = 1 +dtb_count = 1 + +def write32(output, value): + output.write(chr(value & 255)) ; value=value // 256 + output.write(chr(value & 255)) ; value=value // 256 + output.write(chr(value & 255)) ; value=value // 256 + output.write(chr(value & 255)) + +def compress(filename, input, output): + output.write('\037\213\010') + output.write(chr(0)) + + statval = stat(filename) + write32(output, 0) + output.write('\002') + output.write('\003') + + crcval = zlib.crc32("") + compobj = zlib.compressobj(9, zlib.DEFLATED, -zlib.MAX_WBITS, + zlib.DEF_MEM_LEVEL, 0) + while True: + data = input.read(1024) + if data == "": + break + crcval = zlib.crc32(data, crcval) + output.write(compobj.compress(data)) + output.write(compobj.flush()) + write32(output, crcval) + write32(output, statval.st_size) + +def dtb_compress(dtb_file): + try: + outputname = dtb_file + '.gz' + input = open(dtb_file, 'rb') + output = open(outputname, 'wb') + compress(dtb_file, input, output) + input.close() + output.close() + except Exception as e: + print('dtb_compress error:' + str(e)) + exit(-1) + return outputname + +class dt_head_info(Structure): + _fields_ = [('magic', c_char * 4), + ('version', c_int), + ('dt_count', c_int)] + +class dt_entry_t(Structure): + _fields_ = [('dtb_size', c_int), + ('dtb_offset', c_int)] + +def align_page_size(offset, pagesize): + return (pagesize - (offset % pagesize)) + +def write_head_info(head_info, args): + args.output.write(pack(dt_head_info_fmt, + head_info.magic, + head_info.version, + head_info.dt_count)) + +def write_dtb_entry_t(dt_entry, args): + args.output.write(pack(dt_entry_fmt, + 0, # reserved + dt_entry.dtb_size, + 0, # reserved + dt_entry.dtb_offset, + 0, # reserved + 0, # reserved + 0)) # reserved + +def write_padding(args, padding): + for i in range(0, padding): + args.output.write('\x00') + +def write_dtb(args): + dtb_file = args.dtb + out_dtb = dtb_file + if args.compress == True: + out_dtb = dtb_compress(dtb_file) + try: + dtb_offset = calcsize(dt_head_info_fmt) + \ + calcsize(dt_entry_fmt) + \ + 4 + padding = align_page_size(dtb_offset, args.pagesize) + dtb_size = stat(out_dtb).st_size + dtb_size_padding = align_page_size(dtb_size, args.pagesize) + dt_entry = dt_entry_t(dtb_size + dtb_size_padding, + dtb_offset + padding) + write_dtb_entry_t(dt_entry, args) + args.output.write(pack('I', 0)) # SUCCESS code number + write_padding(args, padding) + with open(out_dtb, 'rb') as dtb_fd: + args.output.write(dtb_fd.read(dtb_size)) + write_padding(args, dtb_size_padding) + except Exception as e: + print('write dtb error:' + str(e)) + exit(-1) + +def clean_gz_file(args): + try: + if args.compress != True: + return + remove(args.dtb + '.gz') + except Exception as e: + print('clean gz file error:' + str(e)) + exit(-1) + +def parse_cmdline(): + parser = ArgumentParser() + parser.add_argument('-c', '--compress', help='compress dtb or not', + action='store_true') + parser.add_argument('-d', '--dtb', help='path to the dtb', type=str, + required=True) + parser.add_argument('-s', '--pagesize', help='align page size', + type=int, choices=[2**i for i in range(11,15)], + default=2048) + parser.add_argument('-o', '--output', help='output file name', + type=FileType('wb'), required=True) + return parser.parse_args() + +def main(): + args = parse_cmdline() + dtimg_head_info = dt_head_info('HSDT', dtimg_version, dtb_count) + write_head_info(dtimg_head_info, args) + write_dtb(args) + clean_gz_file(args) + +if __name__ == '__main__': + main() diff --git a/installer/hikey960/prm_ptable.img b/installer/hikey960/prm_ptable.img Binary files differnew file mode 100644 index 00000000..e7b9b037 --- /dev/null +++ b/installer/hikey960/prm_ptable.img diff --git a/installer/hikey960/uefi-flash-all.sh b/installer/hikey960/uefi-flash-all.sh new file mode 100755 index 00000000..347b5b28 --- /dev/null +++ b/installer/hikey960/uefi-flash-all.sh @@ -0,0 +1,3 @@ +#!/bin/bash +INSTALLER_DIR="`dirname ${0}`" +${INSTALLER_DIR}/flash-all.sh diff --git a/kernel-headers/linux/audio_hifi.h b/kernel-headers/linux/audio_hifi.h new file mode 100644 index 00000000..2fff5d9a --- /dev/null +++ b/kernel-headers/linux/audio_hifi.h @@ -0,0 +1,42 @@ +#ifndef _AUDIO_HIFI_H +#define _AUDIO_HIFI_H + +#include <linux/types.h> + +struct misc_io_dump_buf_param { + uint64_t user_buf; + unsigned int clear; /*clear current log buf */ + unsigned int buf_size; +}; + +struct misc_io_pcm_buf_param { + uint64_t buf; + uint32_t buf_size; +}; + +#define HIFI_DSP_MISC_DRIVER "/dev/hifi_misc" + +#define HIFI_MISC_IOCTL_ASYNCMSG _IOWR('A', 0x70, struct misc_io_async_param) +#define HIFI_MISC_IOCTL_SYNCMSG _IOW('A', 0x71, struct misc_io_sync_param) +#define HIFI_MISC_IOCTL_SENDDATA_SYNC _IOW('A', 0x72, struct misc_io_senddata_sync_param) +#define HIFI_MISC_IOCTL_GET_PHYS _IOWR('A', 0x73, struct misc_io_get_phys_param) +#define HIFI_MISC_IOCTL_TEST _IOWR('A', 0x74, struct misc_io_senddata_sync_param) +#define HIFI_MISC_IOCTL_WRITE_PARAMS _IOWR('A', 0x75, struct misc_io_sync_param) +#define HIFI_MISC_IOCTL_DUMP_HIFI _IOWR('A', 0x76, struct misc_io_dump_buf_param) +#define HIFI_MISC_IOCTL_DUMP_CODEC _IOWR('A', 0x77, struct misc_io_dump_buf_param) +#define HIFI_MISC_IOCTL_WAKEUP_THREAD _IOW('A', 0x78, unsigned int) +#define HIFI_MISC_IOCTL_DISPLAY_MSG _IOWR('A', 0x79, struct misc_io_dump_buf_param) +#define HIFI_MISC_IOCTL_WAKEUP_PCM_READ_THREAD _IOW('A', 0x7a, unsigned int) +#define HIFI_MISC_IOCTL_PCM_GAIN _IOW('A', 0x7b, struct misc_io_pcm_buf_param) +#define HIFI_MISC_IOCTL_XAF_IPC_MSG_SEND _IOW('A', 0x7c, xf_proxy_msg_t) +#define HIFI_MISC_IOCTL_XAF_IPC_MSG_RECV _IOR('A', 0x7d, xf_proxy_msg_t) + +#ifdef CLT_VOICE +#define CLT_HIFI_MISC_IOCTL_SEND_VOICE _IOWR('A', 0x90, struct misc_io_async_param) +#endif + +#define HIFI_MISC_IOCTL_GET_VOICE_BSD_PARAM _IOWR('A', 0x7c, unsigned int) + +#define DRV_DSP_UART_TO_MEM_SIZE 0x7f000 + +#endif /* _AUDIO_HIFI_H */ diff --git a/mali/Android.mk b/mali/Android.mk new file mode 100644 index 00000000..40604835 --- /dev/null +++ b/mali/Android.mk @@ -0,0 +1,31 @@ +# +# Copyright (C) 2015 The Android Open-Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# WARNING: Everything listed here will be built on ALL platforms, +# including x86, the emulator, and the SDK. Modules must be uniquely +# named (liblights.panda), and must build everywhere, or limit themselves +# to only building on ARM if they include assembly. Individual makefiles +# are responsible for having their own logic, for fine-grained control. + +ifneq ($(filter hikey%, $(TARGET_DEVICE)),) + +LOCAL_PATH := $(call my-dir) + +# if some modules are built directly from this directory (not subdirectories), +# their rules should be written here. + +include $(call all-makefiles-under,$(LOCAL_PATH)) +endif diff --git a/mali/bifrost/APACHE_LICENSE.txt b/mali/bifrost/APACHE_LICENSE.txt new file mode 100644 index 00000000..d6456956 --- /dev/null +++ b/mali/bifrost/APACHE_LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/mali/bifrost/Android.mk b/mali/bifrost/Android.mk new file mode 100644 index 00000000..0df1f5fc --- /dev/null +++ b/mali/bifrost/Android.mk @@ -0,0 +1,87 @@ +ifneq ($(filter hikey960, $(TARGET_DEVICE)),) +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) +LOCAL_MODULE := END_USER_LICENCE_AGREEMENT.txt +LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 +LOCAL_LICENSE_CONDITIONS := notice +LOCAL_MODULE_CLASS := SHARED_LIBRARIES +LOCAL_STRIP_MODULE := false +LOCAL_SRC_FILES_arm := $(LOCAL_MODULE) +LOCAL_MODULE_PATH_32 := $(TARGET_OUT_VENDOR) +LOCAL_MULTILIB := 32 +include $(BUILD_PREBUILT) + +include $(CLEAR_VARS) +LOCAL_MODULE := libGLES_mali.so +LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 +LOCAL_LICENSE_CONDITIONS := notice +LOCAL_MODULE_CLASS := SHARED_LIBRARIES +LOCAL_STRIP_MODULE := false +LOCAL_SRC_FILES_arm := lib/egl/$(LOCAL_MODULE) +LOCAL_SRC_FILES_arm64 := lib64/egl/$(LOCAL_MODULE) +LOCAL_MODULE_PATH_32 := $(TARGET_OUT_VENDOR)/lib/egl/ +LOCAL_MODULE_PATH_64 := $(TARGET_OUT_VENDOR)/lib64/egl/ +LOCAL_MULTILIB := both +LOCAL_SHARED_LIBRARIES := android.hardware.graphics.common@1.0 libz libnativewindow libc++ liblog libm libc libdl +include $(BUILD_PREBUILT) + +include $(CLEAR_VARS) +LOCAL_MODULE := libbccArm.so +LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 +LOCAL_LICENSE_CONDITIONS := notice +LOCAL_MODULE_CLASS := SHARED_LIBRARIES +LOCAL_STRIP_MODULE := false +LOCAL_SRC_FILES_arm64 := lib64/$(LOCAL_MODULE) +LOCAL_MODULE_PATH_64 := $(TARGET_OUT_VENDOR)/lib64/ +LOCAL_MULTILIB := 64 +# Bypass prebuilt ELF check because libLLVM is not a module (it is copied by +# PRODUCT_COPY_FILES instead). +LOCAL_CHECK_ELF_FILES := false +include $(BUILD_PREBUILT) + +include $(CLEAR_VARS) +LOCAL_MODULE := libRSDriverArm.so +LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 +LOCAL_LICENSE_CONDITIONS := notice +LOCAL_MODULE_CLASS := SHARED_LIBRARIES +LOCAL_STRIP_MODULE := false +LOCAL_SRC_FILES_arm := lib/$(LOCAL_MODULE) +LOCAL_SRC_FILES_arm64 := lib64/$(LOCAL_MODULE) +LOCAL_MODULE_PATH_32 := $(TARGET_OUT_VENDOR)/lib/ +LOCAL_MODULE_PATH_64 := $(TARGET_OUT_VENDOR)/lib64/ +LOCAL_MULTILIB := both +LOCAL_SHARED_LIBRARIES := libRS_internal libRSCpuRef liblog libnativewindow libbcinfo libdl libc++ libc libm +include $(BUILD_PREBUILT) + +include $(CLEAR_VARS) +LOCAL_MODULE := libmalicore.bc +LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 +LOCAL_LICENSE_CONDITIONS := notice +LOCAL_MODULE_CLASS := SHARED_LIBRARIES +LOCAL_STRIP_MODULE := false +LOCAL_SRC_FILES_arm := lib/$(LOCAL_MODULE) +LOCAL_SRC_FILES_arm64 := lib64/$(LOCAL_MODULE) +LOCAL_MODULE_PATH_32 := $(TARGET_OUT_VENDOR)/lib/ +LOCAL_MODULE_PATH_64 := $(TARGET_OUT_VENDOR)/lib64/ +LOCAL_MULTILIB := both +include $(BUILD_PREBUILT) + +include $(CLEAR_VARS) +LOCAL_MODULE := vulkan.hikey960.so +LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 +LOCAL_LICENSE_CONDITIONS := notice +LOCAL_MODULE_CLASS := SHARED_LIBRARIES +LOCAL_STRIP_MODULE := false +LOCAL_SRC_FILES_arm := lib/hw/$(LOCAL_MODULE) +LOCAL_SRC_FILES_arm64 := lib64/hw/$(LOCAL_MODULE) +LOCAL_MODULE_PATH_32 := $(TARGET_OUT_VENDOR)/lib/hw +LOCAL_MODULE_PATH_64 := $(TARGET_OUT_VENDOR)/lib64/hw +LOCAL_MULTILIB := both +LOCAL_SHARED_LIBRARIES := android.hardware.graphics.common@1.0 libz libnativewindow libc++ liblog libm libc libdl +# Bypass prebuilt ELF check because the DT_SONAME "libGLES_mali.so" is +# different from LOCAL_MODULE "vulkan.hikey960.so". +LOCAL_CHECK_ELF_FILES := false +include $(BUILD_PREBUILT) + +endif diff --git a/mali/bifrost/END_USER_LICENCE_AGREEMENT.txt b/mali/bifrost/END_USER_LICENCE_AGREEMENT.txt new file mode 100644 index 00000000..34da5f85 --- /dev/null +++ b/mali/bifrost/END_USER_LICENCE_AGREEMENT.txt @@ -0,0 +1,194 @@ +LES-PRE-20769
+SP-Version: 1.0
+25 November 2015
+
+END USER LICENCE AGREEMENT FOR THE MALI USERSPACE DRIVER ("Mali DRIVER")
+
+THIS END USER LICENCE AGREEMENT ("LICENCE") IS A LEGAL AGREEMENT
+BETWEEN YOU (EITHER A SINGLE INDIVIDUAL, OR SINGLE LEGAL ENTITY) AND
+ARM LIMITED ("ARM") FOR THE USE OF THE SOFTWARE ACCOMPANYING THIS
+LICENCE. ARM IS ONLY WILLING TO LICENSE THE SOFTWARE TO YOU ON
+CONDITION THAT YOU ACCEPT ALL OF THE TERMS IN THIS LICENCE. BY
+INSTALLING OR OTHERWISE USING OR COPYING THE SOFTWARE YOU INDICATE
+THAT YOU AGREE TO BE BOUND BY ALL OF THE TERMS OF THIS LICENCE. IF YOU
+DO NOT AGREE TO THE TERMS OF THIS LICENCE, ARM IS UNWILLING TO LICENSE
+THE SOFTWARE TO YOU AND YOU MAY NOT INSTALL, USE OR COPY THE SOFTWARE,
+AND YOU SHOULD PROMPTLY RETURN THE SOFTWARE TO YOUR SUPPLIER.
+
+"Applications" means applications for use solely in conjunction with
+Mali-based products manufactured under licence from ARM.
+
+"Output" means data resulting from your use of the Software and all
+direct and indirect derivatives thereof.
+
+"Software" means any software, firmware and data accompanying this
+Licence, any printed, electronic or online documentation supplied with
+it under the terms of this Licence for the Mali Driver.
+
+1. LICENCE GRANTS TO YOU.
+
+1.1 ARM hereby grants to you, subject to the terms and conditions of
+this Licence, a non-exclusive, non-transferable, revocable, worldwide
+licence to:
+
+(i) use and copy the Software or certain components or optional
+ functionality in the Software, as applicable, solely for the
+ purposes of running, designing or developing Applications; and
+
+(ii) subject to Clause 1.2, distribute the whole of the Software;
+ and/or (b) the whole or any part of the Software together
+ with, or as incorporated into, Applications; and
+
+1.2 If you choose to redistribute the whole or any part of the
+Software pursuant to the licences granted in Clause 1.1(ii), you
+agree: (i) not to use ARM's or any of its licensors names, logos or
+trademarks to market Applications; (ii) to retain any and all
+copyright notices and other notices (whether ARM's or its licensor's)
+which are included with the Software; and (iii) include a copy of this
+Licence with such redistribution.
+
+2. RESTRICTIONS ON USE OF THE SOFTWARE.
+
+BENCHMARKING: This Licence does not prevent you from using the
+Software for benchmarking purposes. However, you shall ensure that any
+and all benchmarking data relating to the Software, and any other
+results of your use or testing of the Software which are indicative of
+its performance, efficacy, reliability or quality, shall not be used
+to disparage ARM, its products or services, or in a manner that, in
+ARM's reasonable judgment, may diminish or otherwise damage the
+reputation of ARM.
+
+COPYRIGHT AND RESERVATION OF RIGHTS: The Software is owned by ARM or
+its licensors and is protected by copyright and other intellectual
+property laws and international treaties. The Software is licensed not
+sold. You acquire no rights to the Software other than as expressly
+provided by this Licence. You shall not remove from the Software any
+copyright notice or other notice and shall ensure that any such notice
+is reproduced in any copies of the whole or any part of the Software
+made by you or other permitted users.
+
+REVERSE ENGINEERING: Except to the extent that such activity is
+permitted by applicable law you shall not reverse engineer, decompile
+or disassemble any of the Software. If the Software was provided to
+you in Europe you shall not reverse engineer, decompile or disassemble
+any of the Software for the purposes of error correction.
+
+RESTRICTED USE: You agree that you shall not use the Software or the
+Output other than pursuant to and in accordance with the exercise of
+any of the licences granted under this Licence. Without limiting the
+generality of the foregoing, you shall not use the Software or any
+Output: (a) for determining if any features, functions or processes
+provided by the Software are covered by any patents or patent
+applications owned by you or a third party; or (b) for developing
+technology, applications or products which avoid any of ARM's
+intellectual property in the Software licensed hereunder; or (c) as a
+reference for modifying existing patents or patent applications or
+creating any continuation, continuation in part, or extension of
+existing patents or patent applications.
+
+3. SUPPORT.
+
+ARM is not under an obligation to provide support, but it may do so at
+its own discretion, and if it does, it will only be in respect of the
+Software as delivered.
+
+4. NO WARRANTIES.
+
+YOU AGREE THAT THE SOFTWARE IS LICENSED "AS IS", AND THAT ARM
+EXPRESSLY DISCLAIMS ALL REPRESENTATIONS, WARRANTIES, CONDITIONS OR
+OTHER TERMS, EXPRESS OR IMPLIED OR STATUTORY, INCLUDING WITHOUT
+LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, SATISFACTORY
+QUALITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+
+YOU EXPRESSLY ASSUME ALL LIABILITIES AND RISKS, FOR USE OR OPERATION
+OF APPLICATIONS, INCLUDING WITHOUT LIMITATION, APPLICATIONS DESIGNED
+OR INTENDED FOR MISSION CRITICAL APPLICATIONS, SUCH AS PACEMAKERS,
+WEAPONRY, AIRCRAFT NAVIGATION, FACTORY CONTROL SYSTEMS, ETC. SHOULD
+THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE ENTIRE COST OF ALL
+NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+5. LIMITATION OF LIABILITY.
+
+TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL
+ARM BE LIABLE FOR ANY INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL
+DAMAGES (INCLUDING LOSS OF PROFITS) ARISING OUT OF THE USE OR
+INABILITY TO USE THE SOFTWARE WHETHER BASED ON A CLAIM UNDER CONTRACT,
+TORT OR OTHER LEGAL THEORY, EVEN IF ARM WAS ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGES.
+
+ARM does not seek to limit or exclude liability for death or personal
+injury arising from ARM's negligence or ARM's fraud and because some
+jurisdictions do not permit the exclusion or limitation of liability
+for consequential or incidental damages the above limitation relating
+to liability for consequential damages may not apply to you.
+
+NOTWITHSTANDING ANYTHING TO THE CONTRARY CONTAINED IN THIS LICENCE,
+THE MAXIMUM LIABILITY OF ARM TO YOU IN AGGREGATE FOR ALL CLAIMS MADE
+AGAINST ARM IN CONTRACT TORT OR OTHERWISE UNDER OR IN CONNECTION WITH
+THE SUBJECT MATTER OF THIS LICENCE SHALL NOT EXCEED THE GREATER OF:
+(I) THE TOTAL OF SUMS PAID BY YOU TO ARM (IF ANY) FOR THIS LICENCE;
+AND (II) $10.00 USD. THE EXISTENCE OF MORE THAN ONE CLAIM WILL NOT
+ENLARGE OR EXTEND THE LIMIT.
+
+6. U.S. GOVERNMENT END USERS.
+
+US Government Restrictions: Use, duplication, reproduction, release,
+modification, disclosure or transfer of the Software is restricted in
+accordance with the terms of this Licence.
+
+7. TERM AND TERMINATION.
+
+This Licence shall remain in force until terminated by you or by ARM.
+Without prejudice to any of its other rights if you are in breach of
+any of the terms and conditions of this Licence then ARM may terminate
+this Licence immediately upon giving written notice to you or on
+thirty (30) days written notice without cause. You may terminate this
+Licence at any time. Upon termination of this Licence by you or by ARM
+, you shall stop using the Software and destroy all copies of the
+Software in your possession, together with all documentation and
+related materials. The provisions of clauses 2, 3, 4, 5, 6, 7, and 8
+shall survive termination of this Licence.
+
+8. GENERAL.
+
+This Licence is governed by English Law. Except where ARM agrees
+otherwise in: (i) a written contract signed by you and ARM; or (ii) a
+written contract provided by ARM and accepted by you, this is the only
+agreement between you and ARM relating to the Software and it may only
+be modified by written agreement between you and ARM. Except as
+expressly agreed in writing, this Licence may not be modified by
+purchase orders, advertising or other representation by any person. If
+any clause or sentence in this Licence is held by a court of law to be
+illegal or unenforceable the remaining provisions of this Licence
+shall not be affected thereby. The failure by ARM to enforce any of
+the provisions of this Licence, unless waived in writing, shall not
+constitute a waiver of ARM's rights to enforce such provision or any
+other provision of this Licence in the future.
+
+At ARM's request, you agree to check your computers for installations
+of the Software and any other information requested by ARM relating to
+Software installation and to provide this information to ARM. You
+agree that auditors nominated by ARM may also perform such checking
+and reporting on behalf of ARM by prior appointment during your normal
+business hours on seven (7) days' notice. ARM shall bear the auditors'
+costs for that audit unless it reveals unlicensed usage in which case
+you shall promptly reimburse ARM for all reasonable costs and
+expenses, including professional fees, relating to such audit. Any
+information which is disclosed to ARM or such auditors during checking
+or audit shall be treated as your confidential information and shall
+only be used by ARM for licence management, compliance and enforcement
+purposes.
+
+The Software provided under this Agreement is subject to U.K.,
+European Union, and U.S. export control laws and regulations,
+including the U.S. Export Administration Act and its associated
+regulations (hereafter collectively referred to as "Export
+Regulations"). LICENSEE agrees to comply fully with all such Export
+Regulations and LICENSEE agrees that it shall not, either directly or
+indirectly, export in breach of the Export Regulations, any Software
+received under this Agreement, nor any direct products thereof; (i) to
+any country, company or person subject to export restrictions or
+sanctions under the Export Regulations; or (ii) for any prohibited end
+use, which at the time of export requires an export license or other
+governmental approval, without first obtaining such license or
+approval.
diff --git a/mali/bifrost/bin/bcc b/mali/bifrost/bin/bcc Binary files differnew file mode 100755 index 00000000..c828bcaf --- /dev/null +++ b/mali/bifrost/bin/bcc diff --git a/mali/bifrost/lib/egl/libGLES_mali.so b/mali/bifrost/lib/egl/libGLES_mali.so Binary files differnew file mode 100755 index 00000000..092d472f --- /dev/null +++ b/mali/bifrost/lib/egl/libGLES_mali.so diff --git a/mali/bifrost/lib/hw/vulkan.hikey960.so b/mali/bifrost/lib/hw/vulkan.hikey960.so new file mode 120000 index 00000000..57c186c5 --- /dev/null +++ b/mali/bifrost/lib/hw/vulkan.hikey960.so @@ -0,0 +1 @@ +../egl/libGLES_mali.so
\ No newline at end of file diff --git a/mali/bifrost/lib/libRSDriverArm.so b/mali/bifrost/lib/libRSDriverArm.so Binary files differnew file mode 100755 index 00000000..721e324b --- /dev/null +++ b/mali/bifrost/lib/libRSDriverArm.so diff --git a/mali/bifrost/lib/libclcore.bc b/mali/bifrost/lib/libclcore.bc Binary files differnew file mode 100644 index 00000000..ee0429ad --- /dev/null +++ b/mali/bifrost/lib/libclcore.bc diff --git a/mali/bifrost/lib/libclcore_neon.bc b/mali/bifrost/lib/libclcore_neon.bc Binary files differnew file mode 100644 index 00000000..ce3da693 --- /dev/null +++ b/mali/bifrost/lib/libclcore_neon.bc diff --git a/mali/bifrost/lib/libmalicore.bc b/mali/bifrost/lib/libmalicore.bc Binary files differnew file mode 100644 index 00000000..5901017e --- /dev/null +++ b/mali/bifrost/lib/libmalicore.bc diff --git a/mali/bifrost/lib64/egl/libGLES_mali.so b/mali/bifrost/lib64/egl/libGLES_mali.so Binary files differnew file mode 100755 index 00000000..19c41f1d --- /dev/null +++ b/mali/bifrost/lib64/egl/libGLES_mali.so diff --git a/mali/bifrost/lib64/hw/vulkan.hikey960.so b/mali/bifrost/lib64/hw/vulkan.hikey960.so new file mode 120000 index 00000000..57c186c5 --- /dev/null +++ b/mali/bifrost/lib64/hw/vulkan.hikey960.so @@ -0,0 +1 @@ +../egl/libGLES_mali.so
\ No newline at end of file diff --git a/mali/bifrost/lib64/libLLVM.so b/mali/bifrost/lib64/libLLVM.so Binary files differnew file mode 100755 index 00000000..894b1d1c --- /dev/null +++ b/mali/bifrost/lib64/libLLVM.so diff --git a/mali/bifrost/lib64/libRSDriverArm.so b/mali/bifrost/lib64/libRSDriverArm.so Binary files differnew file mode 100755 index 00000000..0a10776d --- /dev/null +++ b/mali/bifrost/lib64/libRSDriverArm.so diff --git a/mali/bifrost/lib64/libbcc.so b/mali/bifrost/lib64/libbcc.so Binary files differnew file mode 100755 index 00000000..b95b141c --- /dev/null +++ b/mali/bifrost/lib64/libbcc.so diff --git a/mali/bifrost/lib64/libbccArm.so b/mali/bifrost/lib64/libbccArm.so Binary files differnew file mode 100755 index 00000000..7fe1dfd3 --- /dev/null +++ b/mali/bifrost/lib64/libbccArm.so diff --git a/mali/bifrost/lib64/libclcore.bc b/mali/bifrost/lib64/libclcore.bc Binary files differnew file mode 100644 index 00000000..ca3d10b8 --- /dev/null +++ b/mali/bifrost/lib64/libclcore.bc diff --git a/mali/bifrost/lib64/libmalicore.bc b/mali/bifrost/lib64/libmalicore.bc Binary files differnew file mode 100644 index 00000000..f8c6d712 --- /dev/null +++ b/mali/bifrost/lib64/libmalicore.bc diff --git a/mali/utgard/Android.mk b/mali/utgard/Android.mk new file mode 100644 index 00000000..c7afa7b4 --- /dev/null +++ b/mali/utgard/Android.mk @@ -0,0 +1,30 @@ +ifneq ($(filter hikey hikey64 hikey32, $(TARGET_DEVICE)),) +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) +LOCAL_MODULE := END_USER_LICENCE_AGREEMENT.txt +LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 +LOCAL_LICENSE_CONDITIONS := notice +LOCAL_MODULE_CLASS := SHARED_LIBRARIES +LOCAL_STRIP_MODULE := false +LOCAL_SRC_FILES_arm := $(LOCAL_MODULE) +LOCAL_MODULE_PATH_32 := $(TARGET_OUT_VENDOR) +LOCAL_MULTILIB := 32 +LOCAL_SHARED_LIBRARIES := libc++ libc libdl liblog libm +include $(BUILD_PREBUILT) + +include $(CLEAR_VARS) +LOCAL_MODULE := libGLES_mali.so +LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 +LOCAL_LICENSE_CONDITIONS := notice +LOCAL_MODULE_CLASS := SHARED_LIBRARIES +LOCAL_STRIP_MODULE := false +LOCAL_SRC_FILES_arm := lib/egl/$(LOCAL_MODULE) +LOCAL_SRC_FILES_arm64 := lib64/egl/$(LOCAL_MODULE) +LOCAL_MODULE_PATH_32 := $(TARGET_OUT_VENDOR)/lib/egl/ +LOCAL_MODULE_PATH_64 := $(TARGET_OUT_VENDOR)/lib64/egl/ +LOCAL_MULTILIB := both +LOCAL_SHARED_LIBRARIES := libc++ libc libdl liblog libm +include $(BUILD_PREBUILT) + +endif diff --git a/mali/utgard/END_USER_LICENCE_AGREEMENT.txt b/mali/utgard/END_USER_LICENCE_AGREEMENT.txt new file mode 100644 index 00000000..34da5f85 --- /dev/null +++ b/mali/utgard/END_USER_LICENCE_AGREEMENT.txt @@ -0,0 +1,194 @@ +LES-PRE-20769
+SP-Version: 1.0
+25 November 2015
+
+END USER LICENCE AGREEMENT FOR THE MALI USERSPACE DRIVER ("Mali DRIVER")
+
+THIS END USER LICENCE AGREEMENT ("LICENCE") IS A LEGAL AGREEMENT
+BETWEEN YOU (EITHER A SINGLE INDIVIDUAL, OR SINGLE LEGAL ENTITY) AND
+ARM LIMITED ("ARM") FOR THE USE OF THE SOFTWARE ACCOMPANYING THIS
+LICENCE. ARM IS ONLY WILLING TO LICENSE THE SOFTWARE TO YOU ON
+CONDITION THAT YOU ACCEPT ALL OF THE TERMS IN THIS LICENCE. BY
+INSTALLING OR OTHERWISE USING OR COPYING THE SOFTWARE YOU INDICATE
+THAT YOU AGREE TO BE BOUND BY ALL OF THE TERMS OF THIS LICENCE. IF YOU
+DO NOT AGREE TO THE TERMS OF THIS LICENCE, ARM IS UNWILLING TO LICENSE
+THE SOFTWARE TO YOU AND YOU MAY NOT INSTALL, USE OR COPY THE SOFTWARE,
+AND YOU SHOULD PROMPTLY RETURN THE SOFTWARE TO YOUR SUPPLIER.
+
+"Applications" means applications for use solely in conjunction with
+Mali-based products manufactured under licence from ARM.
+
+"Output" means data resulting from your use of the Software and all
+direct and indirect derivatives thereof.
+
+"Software" means any software, firmware and data accompanying this
+Licence, any printed, electronic or online documentation supplied with
+it under the terms of this Licence for the Mali Driver.
+
+1. LICENCE GRANTS TO YOU.
+
+1.1 ARM hereby grants to you, subject to the terms and conditions of
+this Licence, a non-exclusive, non-transferable, revocable, worldwide
+licence to:
+
+(i) use and copy the Software or certain components or optional
+ functionality in the Software, as applicable, solely for the
+ purposes of running, designing or developing Applications; and
+
+(ii) subject to Clause 1.2, distribute the whole of the Software;
+ and/or (b) the whole or any part of the Software together
+ with, or as incorporated into, Applications; and
+
+1.2 If you choose to redistribute the whole or any part of the
+Software pursuant to the licences granted in Clause 1.1(ii), you
+agree: (i) not to use ARM's or any of its licensors names, logos or
+trademarks to market Applications; (ii) to retain any and all
+copyright notices and other notices (whether ARM's or its licensor's)
+which are included with the Software; and (iii) include a copy of this
+Licence with such redistribution.
+
+2. RESTRICTIONS ON USE OF THE SOFTWARE.
+
+BENCHMARKING: This Licence does not prevent you from using the
+Software for benchmarking purposes. However, you shall ensure that any
+and all benchmarking data relating to the Software, and any other
+results of your use or testing of the Software which are indicative of
+its performance, efficacy, reliability or quality, shall not be used
+to disparage ARM, its products or services, or in a manner that, in
+ARM's reasonable judgment, may diminish or otherwise damage the
+reputation of ARM.
+
+COPYRIGHT AND RESERVATION OF RIGHTS: The Software is owned by ARM or
+its licensors and is protected by copyright and other intellectual
+property laws and international treaties. The Software is licensed not
+sold. You acquire no rights to the Software other than as expressly
+provided by this Licence. You shall not remove from the Software any
+copyright notice or other notice and shall ensure that any such notice
+is reproduced in any copies of the whole or any part of the Software
+made by you or other permitted users.
+
+REVERSE ENGINEERING: Except to the extent that such activity is
+permitted by applicable law you shall not reverse engineer, decompile
+or disassemble any of the Software. If the Software was provided to
+you in Europe you shall not reverse engineer, decompile or disassemble
+any of the Software for the purposes of error correction.
+
+RESTRICTED USE: You agree that you shall not use the Software or the
+Output other than pursuant to and in accordance with the exercise of
+any of the licences granted under this Licence. Without limiting the
+generality of the foregoing, you shall not use the Software or any
+Output: (a) for determining if any features, functions or processes
+provided by the Software are covered by any patents or patent
+applications owned by you or a third party; or (b) for developing
+technology, applications or products which avoid any of ARM's
+intellectual property in the Software licensed hereunder; or (c) as a
+reference for modifying existing patents or patent applications or
+creating any continuation, continuation in part, or extension of
+existing patents or patent applications.
+
+3. SUPPORT.
+
+ARM is not under an obligation to provide support, but it may do so at
+its own discretion, and if it does, it will only be in respect of the
+Software as delivered.
+
+4. NO WARRANTIES.
+
+YOU AGREE THAT THE SOFTWARE IS LICENSED "AS IS", AND THAT ARM
+EXPRESSLY DISCLAIMS ALL REPRESENTATIONS, WARRANTIES, CONDITIONS OR
+OTHER TERMS, EXPRESS OR IMPLIED OR STATUTORY, INCLUDING WITHOUT
+LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, SATISFACTORY
+QUALITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+
+YOU EXPRESSLY ASSUME ALL LIABILITIES AND RISKS, FOR USE OR OPERATION
+OF APPLICATIONS, INCLUDING WITHOUT LIMITATION, APPLICATIONS DESIGNED
+OR INTENDED FOR MISSION CRITICAL APPLICATIONS, SUCH AS PACEMAKERS,
+WEAPONRY, AIRCRAFT NAVIGATION, FACTORY CONTROL SYSTEMS, ETC. SHOULD
+THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE ENTIRE COST OF ALL
+NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+5. LIMITATION OF LIABILITY.
+
+TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL
+ARM BE LIABLE FOR ANY INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL
+DAMAGES (INCLUDING LOSS OF PROFITS) ARISING OUT OF THE USE OR
+INABILITY TO USE THE SOFTWARE WHETHER BASED ON A CLAIM UNDER CONTRACT,
+TORT OR OTHER LEGAL THEORY, EVEN IF ARM WAS ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGES.
+
+ARM does not seek to limit or exclude liability for death or personal
+injury arising from ARM's negligence or ARM's fraud and because some
+jurisdictions do not permit the exclusion or limitation of liability
+for consequential or incidental damages the above limitation relating
+to liability for consequential damages may not apply to you.
+
+NOTWITHSTANDING ANYTHING TO THE CONTRARY CONTAINED IN THIS LICENCE,
+THE MAXIMUM LIABILITY OF ARM TO YOU IN AGGREGATE FOR ALL CLAIMS MADE
+AGAINST ARM IN CONTRACT TORT OR OTHERWISE UNDER OR IN CONNECTION WITH
+THE SUBJECT MATTER OF THIS LICENCE SHALL NOT EXCEED THE GREATER OF:
+(I) THE TOTAL OF SUMS PAID BY YOU TO ARM (IF ANY) FOR THIS LICENCE;
+AND (II) $10.00 USD. THE EXISTENCE OF MORE THAN ONE CLAIM WILL NOT
+ENLARGE OR EXTEND THE LIMIT.
+
+6. U.S. GOVERNMENT END USERS.
+
+US Government Restrictions: Use, duplication, reproduction, release,
+modification, disclosure or transfer of the Software is restricted in
+accordance with the terms of this Licence.
+
+7. TERM AND TERMINATION.
+
+This Licence shall remain in force until terminated by you or by ARM.
+Without prejudice to any of its other rights if you are in breach of
+any of the terms and conditions of this Licence then ARM may terminate
+this Licence immediately upon giving written notice to you or on
+thirty (30) days written notice without cause. You may terminate this
+Licence at any time. Upon termination of this Licence by you or by ARM
+, you shall stop using the Software and destroy all copies of the
+Software in your possession, together with all documentation and
+related materials. The provisions of clauses 2, 3, 4, 5, 6, 7, and 8
+shall survive termination of this Licence.
+
+8. GENERAL.
+
+This Licence is governed by English Law. Except where ARM agrees
+otherwise in: (i) a written contract signed by you and ARM; or (ii) a
+written contract provided by ARM and accepted by you, this is the only
+agreement between you and ARM relating to the Software and it may only
+be modified by written agreement between you and ARM. Except as
+expressly agreed in writing, this Licence may not be modified by
+purchase orders, advertising or other representation by any person. If
+any clause or sentence in this Licence is held by a court of law to be
+illegal or unenforceable the remaining provisions of this Licence
+shall not be affected thereby. The failure by ARM to enforce any of
+the provisions of this Licence, unless waived in writing, shall not
+constitute a waiver of ARM's rights to enforce such provision or any
+other provision of this Licence in the future.
+
+At ARM's request, you agree to check your computers for installations
+of the Software and any other information requested by ARM relating to
+Software installation and to provide this information to ARM. You
+agree that auditors nominated by ARM may also perform such checking
+and reporting on behalf of ARM by prior appointment during your normal
+business hours on seven (7) days' notice. ARM shall bear the auditors'
+costs for that audit unless it reveals unlicensed usage in which case
+you shall promptly reimburse ARM for all reasonable costs and
+expenses, including professional fees, relating to such audit. Any
+information which is disclosed to ARM or such auditors during checking
+or audit shall be treated as your confidential information and shall
+only be used by ARM for licence management, compliance and enforcement
+purposes.
+
+The Software provided under this Agreement is subject to U.K.,
+European Union, and U.S. export control laws and regulations,
+including the U.S. Export Administration Act and its associated
+regulations (hereafter collectively referred to as "Export
+Regulations"). LICENSEE agrees to comply fully with all such Export
+Regulations and LICENSEE agrees that it shall not, either directly or
+indirectly, export in breach of the Export Regulations, any Software
+received under this Agreement, nor any direct products thereof; (i) to
+any country, company or person subject to export restrictions or
+sanctions under the Export Regulations; or (ii) for any prohibited end
+use, which at the time of export requires an export license or other
+governmental approval, without first obtaining such license or
+approval.
diff --git a/mali/utgard/lib/egl/libGLES_mali.so b/mali/utgard/lib/egl/libGLES_mali.so Binary files differnew file mode 100755 index 00000000..f86da7e5 --- /dev/null +++ b/mali/utgard/lib/egl/libGLES_mali.so diff --git a/mali/utgard/lib64/egl/libGLES_mali.so b/mali/utgard/lib64/egl/libGLES_mali.so Binary files differnew file mode 100755 index 00000000..5c0af47c --- /dev/null +++ b/mali/utgard/lib64/egl/libGLES_mali.so diff --git a/vendor-package-ver.mk b/vendor-package-ver.mk deleted file mode 100644 index be369eb1..00000000 --- a/vendor-package-ver.mk +++ /dev/null @@ -1,4 +0,0 @@ -HELPER_SCRIPT=./device/linaro/hikey/vendor-package-ver.sh -EXPECTED_LINARO_VENDOR_VERSION := $(shell $(HELPER_SCRIPT) ver) -VND_PKG_URL := $(shell $(HELPER_SCRIPT) url) -LINARO_VENDOR_PATH := vendor/linaro/ diff --git a/vendor-package-ver.sh b/vendor-package-ver.sh deleted file mode 100755 index 12f4a6f0..00000000 --- a/vendor-package-ver.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -export EXPECTED_LINARO_VENDOR_VERSION=20220210 -export EXPECTED_LINARO_VENDOR_SHA=75efc8471f299f64716140712c0785b8e8aeaf5aa7e389a6f12f78ad4962420740da32f4535d795006e78c5f0b77a1cee8c168192a87f668103c00d87d480e6d -export VND_PKG_URL=https://releases.linaro.org/android/aosp-linaro-vendor-package/extract-linaro_devices-20220210.tgz - -if [ "$1" = "url" ]; then - echo $VND_PKG_URL -elif [ "$1" = "ver" ]; then - echo $EXPECTED_LINARO_VENDOR_VERSION -elif [ "$1" = "sha" ]; then - echo $EXPECTED_LINARO_VENDOR_SHA -fi |