Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 1 | .. _libraries: |
| 2 | |
| 3 | ######### |
| 4 | Libraries |
| 5 | ######### |
| 6 | |
Etienne Carriere | 7b78018 | 2023-11-10 10:25:02 +0100 | [diff] [blame] | 7 | .. _libutils: |
| 8 | |
| 9 | libutils |
| 10 | ******** |
| 11 | |
| 12 | OP-TEE core and OP-TEE development kit for Trusted Application provide a |
| 13 | standard C library that is named **libutils**. It implements many |
| 14 | standard functions like ``snprintf()``, ``strncmp()``, ``memcpy()``, |
| 15 | ``malloc()``. ``qsort()``, and many more but not all standard C library |
| 16 | functions. |
| 17 | |
| 18 | Note however that Trusted Applications implemented in C should use GP TEE |
| 19 | Internal Core API functions rather than their standard C library function |
| 20 | equivalent (e.g. ``TEE_MemMove()`` instead of ``memcpy()`` and |
| 21 | ``memmove()``, or ``TEE_Malloc()`` instead of ``malloc()`` and friends). |
| 22 | This makes those TAs implementation more portable to other GP |
| 23 | TEE compliant environments. |
| 24 | |
Etienne Carriere | c75d19d | 2023-11-10 14:29:28 +0100 | [diff] [blame^] | 25 | When ``CFG_ULIBS_SHARED`` is enabled, **libutils** is assigned UUID |
| 26 | **71855bba-6055-4293-a63f-b0963a737360**. |
| 27 | |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 28 | .. _libutee: |
| 29 | |
| 30 | libutee |
| 31 | ******* |
| 32 | The :ref:`tee_internal_core_api` describes services that are provided to Trusted |
| 33 | Applications. **libutee** is a library that implements this API. |
| 34 | |
Etienne Carriere | c75d19d | 2023-11-10 14:29:28 +0100 | [diff] [blame^] | 35 | libutee is designed as a userland library specifically dedicated to OP-TEE |
| 36 | Trusted Applications and aims at being executed in the non-privileged secure |
| 37 | userspace. |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 38 | |
| 39 | Some services for this API are fully statically implemented inside the libutee |
| 40 | library while some services for the API are implemented inside the OP-TEE core |
| 41 | (privileged level) and libutee calls such services through system calls. |
| 42 | |
Etienne Carriere | c75d19d | 2023-11-10 14:29:28 +0100 | [diff] [blame^] | 43 | When ``CFG_ULIBS_SHARED`` is enabled, **libutee** is assigned UUID |
| 44 | **4b3d937e-d57e-418b-8673-1c04f2420226**. |
| 45 | |
| 46 | .. _statci_or_shared_lib: |
| 47 | |
| 48 | Static vs Shared libraries |
| 49 | ************************** |
| 50 | |
| 51 | OP-TEE core supports only static libraries that are linked at build time to |
| 52 | produce the monolithic OP-TEE core image. |
| 53 | |
| 54 | OP-TEE Trusted Applications can support both static and shared libraries. In |
| 55 | the latter case, each shared library is identified by a UUID and OP-TEE OS |
| 56 | is in charge of dynamically loading the required shared libraries in the |
| 57 | address space of the Trusted Application when this one uses a resource of |
| 58 | the related library. |
| 59 | |
| 60 | In order to support shared library, OP-TEE OS shall be built with |
| 61 | ``CFG_ULIBS_SHARED=y``. Shared library binary images are generated as |
| 62 | **.elf** and **.ta** files, like Trusted Applications are, and shall be |
| 63 | installed the same way as Trusted Applications are, see ref:`ta_locations`. |
| 64 | |