DSP ABI Calling Convention
Calling Convention
Xtensa supports two different Application Binary Interfaces (ABI): Window ABI (Window register ABI) and Call0 ABI, both of which include calling conventions.
Window ABI: Function calls and returns must be located within the same 1GB aligned region. When a function call occurs, register rotation is used to switch CPU registers, saving time that would otherwise be spent saving and restoring CPU register state.
Call0 ABI: Function calls and returns can be executed throughout the entire 4GB region. When a function call occurs, CPU register state is saved on the stack.
The SRAM address range is 0x2000_0000 ~ 0x2008_0000; the PSRAM start address is 0x6000_0000, and the end address depends on the PSRAM type. Since SRAM and PSRAM are not in the same 1GB region, Window ABI cannot call functions across SRAM and PSRAM.
Switching Between Call0 ABI and Window ABI
Different Configurations correspond to different ABI types. If using Xplorer to manage the project, you only need to switch the Configuration to select the desired ABI.
HIFI5_PROD_1123_asic_UPG: Corresponds to Call0 ABI
HIFI5_PROD_1123_asic_wUPG: Corresponds to Window ABI
The following is an example of Call0 ABI configuration:
The following is an example of Window ABI configuration:
Note
If your project uses custom libraries, ensure that the corresponding library files are recompiled according to the selected ABI.
If using CMD command line (
auto_build.sh) to build the project, the automatic build script’s Configuration configuration file isproject/auto_build/dsp_batch.xml(HIFI5_PROD_1123_asic_wUPG or HIFI5_PROD_1123_asic_UPG).
Configuring Library Paths for Different ABIs
When switching between ABIs, modifying the library search path each time can be tedious. You can use the $(TARGET_CONFIG) environment variable to set the search path:
Create two folders, HIFI5_PROD_1123_asic_UPG and HIFI5_PROD_1123_asic_wUPG, under the library path, and place the libraries compiled with different ABIs in their corresponding directories.
For example, if you originally placed libraries under the lib/audio/prebuilts path:
Create two new folders under this path:
/lib/audio/prebuilts/HIFI5_PROD_1123_asic_UPGand/lib/audio/prebuilts/HIFI5_PROD_1123_asic_wUPG.Set Library Search Paths to
${workspace_loc}/.../lib/audio/prebuilts/$(TARGET_CONFIG). The environment variable $(TARGET_CONFIG) will automatically switch with ABI changes, ensuring the correct precompiled library is loaded.