HAP example
Overview
The hap_example illustrates the usage of the remote APIs API and the following HAP APIs:
Refer to the Feature Matrix for example support and to know the DSP architecture on the target.
Project structure
Makefile
Root makefile that invokes variant-specific min files to either build the application processor source code or the Hexagon DSP source code.
android.min
,UbuntuARM.min
,hexagon.min
Contains the make.d directives used to build the application processor and Hexagon DSP source code.
inc/hap_example.idl
IDL interface that defines the hap_example API.
This IDL file is compiled by the QAIC IDL compiler into the following files:
hap_example.h
: C/C++ header filehap_example_stub.c
: Stub source that needs to be built for the HLOS (LA/LE)-
hap_example_skel.c
: Skel source that needs to be built for the Hexagon DSP -
src_app/
: Source files for the HLOS executable that offloads the task to DSP -
hap_example_main.c
: Contains main() function of the hap_example that runs on application processor -
hap_example.c
: Invokes call to DSP functions that demonstrate the HAP APIs -
src_dsp/
: Source files for the Hexagon-side implementation of the hap_example that is compiled into a shared object. Demonstrates usage of the HAP APIs. -
hap_example_imp.c
: Contains function to open and close handle to a cdsp domain -
hap_example_compute_res_imp.c
: Compute resource manager framework APIs to request and release compute resources on CDSP -
hap_example_farf_runtime.c
: FARF API to control compile-time and run-time logging -
hap_example_mem_imp.c
: HAP_mem APIs to control mapping of buffers to user PD heap memory -
hap_example_perf_imp.c
: HAP_perf APIs to measure the execution time without RPC overhead -
hap_example_power_imp.c
: HAP_power APIs to vote for DSP core, bus clock frequencies and voltage corners -
hap_example_sysmon_cachelock_imp.c
: Cache locking manager to lock a section of CDSP L2 cache and release it -
hap_example_vtcm_mgr_imp.c
: VTCM Manager to request or release VTCM memory on CDSP
Using the walkthrough script
The walkthrough script hap_example_walkthrough.py
automates the steps of signing the device, building, pushing and running the hap_example
. You can run the walkthrough script with the dry-run (-DR) option to display all the commands that the script would execute without actually running them.
Review the generic setup and walkthrough_scripts instructions to learn more about setting up your device and using the walkthrough script.
Arguments to the executable
-
The parameter to
hap_example
executable must be an integer ranging from 0 to 6 which selects the HAP APIs to be demonstrated:- 0 - HAP_compute_res.h
- 1 - HAP_farf.h
- 2 - HAP_mem.h
- 3 - HAP_perf.h
- 4 - HAP_power.h
- 5 - sysmon_cachelock.h
- 6 - HAP_vtcm_mgr.h
-
Analyze the output
The command window or shell should contain messages returned by the application processor when using the
printf
command.For example when we run the example on lahaina target :
adb shell /vendor/bin/hap_example 1
demonstrates FARF run-time logging and the following output is printed in the shell:
-----Retrieving VTCM information of CDSP using FastRPC Capability API----- Result of capability query for VTCM_PAGE on CDSP is 262144 bytes Result of capability query for VTCM_COUNT on CDSP is 1 -----------------------HAP API Example-------------------------------- Demonstrating FARF run-time logging hap_example function PASSED Please look at the mini-dm logs or the adb logcat logs for DSP output hap_example PASSED
while the FARF logs redirected to the adb logcat are :
HAP_utils.c:303:0x1620ea:13: Logging mask set to 31 mod_table.c:541:0x12f0d3:13: open_mod_table_open_dynamic: Module libhap_example_skel.so opened with handle 0xa52093d0 HAP_utils.c:303:0x12f0d3:13: Logging mask set to 0 HAP_utils.c:329:0x12f0d3:13: Logging enabled for file hap_example_farf_runtime.c hap_example_farf_runtime.c:67:0x12f0d3:13: Low FARF message : Run-time logging disabled hap_example_farf_runtime.c:68:0x12f0d3:13: Medium FARF message : Run-time logging disabled hap_example_farf_runtime.c:69:0x12f0d3:13: High FARF message : Run-time logging disabled hap_example_farf_runtime.c:70:0x12f0d3:13: Error FARF message : Run-time logging disabled hap_example_farf_runtime.c:71:0x12f0d3:13: Fatal FARF message : Run-time logging disabled HAP_utils.c:303:0x12f0d3:13: Logging mask set to 31 HAP_utils.c:329:0x12f0d3:13: Logging enabled for file hap_example_farf_runtime.c hap_example_farf_runtime.c:44:0x12f0d3:13: Low FARF message : Run-time logging enabled hap_example_farf_runtime.c:45:0x12f0d3:13: Medium FARF message : Run-time logging enabled hap_example_farf_runtime.c:46:0x12f0d3:13: High FARF message : Run-time logging enabled hap_example_farf_runtime.c:47:0x12f0d3:13: Error FARF message : Run-time logging enabled hap_example_farf_runtime.c:48:0x12f0d3:13: Fatal FARF message : Run-time logging enabled hap_example_farf_runtime.c:50:0x12f0d3:13: Runtime Low FARF message - Run-time logging enabled hap_example_farf_runtime.c:51:0x12f0d3:13: Runtime Medium FARF message - Run-time logging enabled hap_example_farf_runtime.c:52:0x12f0d3:13: Runtime High FARF message - Run-time logging enabled hap_example_farf_runtime.c:53:0x12f0d3:13: Runtime Error FARF message - Run-time logging enabled hap_example_farf_runtime.c:54:0x12f0d3:13: Runtime Fatal FARF message - Run-time logging enabled