DSP ABI Calling

Calling Conventions

Xtensa supports two different application binary interfaces (ABI), Windowed register ABI and Call0 ABI, which also include the calling conventions.

A windowed function call and return can only be within the same 1GB aligned region. That is to say, all of the functions must reside in exactly one of the following 4 regions of the 4GB memory space. However, a Call0 function call and return can be within the whole 4GB region. The address range of SRAM is from 0x2000_0000 to 0x2008_0000, and the address range of PSRAM starts from 0x6000_0000 (end address depends on the type of PSRAM). The ranges of SRAM and PSRAM are not in the same 1GB region, so it is impossible to call a function residing in SRAM from a function residing in PSRAM with a windowed register ABI.

Switching between Call0 and Windowed Register ABI

Each configuration is either compatible with Call0 ABI or windowed register ABI.

  • HIFI5_PROD_1123_asic_UPG: compatible with Call0 ABI

  • HIFI5_PROD_1123_asic_wUPG: compatible with windowed register ABI

If Xplorer is used to manage the project, you just need to change the configuration to choose the ABI you use. Be careful, the pre-built libs should be compiled according to the ABI you choose. Here is the configuration chosen for a Call0 ABI:

../../rst_dsp/dsp_abi/figures/dspcfg_chosen_for_call0_abi.png

Here is the configuration chosen for a Windowed register ABI:

../../rst_dsp/dsp_abi/figures/dspcfg_chosen_for_windowed_register_abi.png

Note

  • If your project uses some libs provided by yourself, please re-compile the project according to the ABI you choose.

  • If use CMD line (auto_build.sh) to build the project, the configuration file for the automatic compilation script is project/auto_build /dsp_batch.xml (HIFI5_PROD_1123_asic_wUPG or HIFI5_PROD_1123_asic_UPG).

Placing Libs According to Calling Conventions

Using Environment Variable to Avoid Changing Search Path

It will be tedious to change the location of lib search path when switching between two ABIs. You can create two folders named HIFI5_PROD_1123_asic_UPG and HIFI5_PROD_1123_asic_wUPG under the path you used to store libs, and place libs compiled with different ABIs into these two folders.

For example, if we used to place libs in lib/audio/prebuilts:

  1. Create two folders under the path /lib/audio/prebuilts/HIFI5_PROD_1123_asic_UPG and /lib/audio/prebuilts/HIFI5_PROD_1123_asic_wUPG.

  2. Change the Library Search Paths to ${workspace_loc}/.../lib/audio/prebuilts/$(TARGET_CONFIG). Environment variable $(TARGET_CONFIG) changes as configuration changes, which assures the right place to find prebuilt libs.

    ../../rst_dsp/dsp_abi/figures/dspcfg_library_search_path.png

Libs Provided by Realtek

libaudio_base.a and librpc_hal.a

Two libs of different flavors are stored under dsp/lib/audio/prebuilts/$(TARGET_CONFIG).

  • libaudio_base.a is a RPC framework to synchronize data and signal between MCU and DSP.

  • librpc_hal.a is a hardware layer to adapt to different RPC platform.

libxa_nnlib.a and libhifi5_dsp.a

  • libxa_nnlib.a can be found under dsp/lib/xa_nnlib/v1.7.0/bin/$(TARGET_CONFIG)/Release. It is the HiFi 5 Neural Network Library.

  • libhifi5_dsp.a can be found under dsp/lib/lib_hifi5/project/hifi5_library/bin/$(TARGET_CONFIG)/Release. It is the NatureDSP Signal for HiFi 5 DSP.