$ show OP-TEE/optee_os
OP-TEE (Open Portable Trusted Execution Environment) is a secure operating system that provides a Trusted Execution Environment (TEE) for ARM and RISC-V platforms. It runs in the secure world of a system-on-chip, isolated from the normal world (e.g., Linux). The OS includes a microkernel, cryptographic libraries (LibTomCrypt, Mbed TLS), hardware abstraction layers for crypto accelerators (CAAM, SE050, Hisilicon, etc.), device drivers (UART, GPIO, I2C, clocks, reset controllers, firewalls), and a framework for trusted applications (TAs) and pseudo TAs. It communicates with the normal world via SMC (Secure Monitor Call) or FF-A (Firmware Framework for Arm A-profile). The architecture is a monolithic kernel with modular driver registration using device tree and initcall macros. Key entry points include boot code (platform-specific main.c), SMC handlers (sm.c, thread_optee_smc.c), and system call handlers (arch_scall.c). Data flows involve secure storage (encrypted file system), cryptographic operations (symmetric/asymmetric ciphers, hashing, key derivation), and remote procedure calls (RPC) for I2C, RPMB, and other services. External dependencies include libfdt (device tree), qcbor (CBOR encoding), and softfloat (IEEE 754 floating-point emulation). The project supports a wide range of hardware platforms (NXP i.MX, STMicroelectronics STM32MP, Qualcomm, Xilinx Versal, Microchip SAMA5, etc.) and is actively maintained with frequent releases.
The LLM identified 3 files worth highlighting for reuse:
A standalone implementation of IEEE 754 floating-point arithmetic (SoftFloat Release 3a) for ARM platforms without hardware FPU. It provides complete single, double, and quadruple precision operations, including rounding and exception handling. This library is fully self-contained, can be extracted and used in any bare-metal or RTOS project requiring software floating-point support, and demonstrates careful implementation of a complex numerical standard.
A generic handle-to-pointer database used throughout OP-TEE for managing objects (e.g., cryptographic keys, sessions). It provides allocation, lookup, and deallocation of handles with a simple API (handle_get, handle_put, handle_lookup). The implementation is minimal, thread-safe (uses spinlocks), and can be extracted as a reusable resource management component for any kernel or library that needs integer-based object references.
A generic SCMI (System Control and Management Interface) message dispatcher that routes incoming SCMI messages to protocol-specific handlers (clock, reset, performance, voltage domains). It handles channel identification, message validation, and response formatting. The design is modular and protocol-agnostic; it can be extracted and reused in other firmware projects that need to implement SCMI server functionality, with minimal adaptation to the underlying transport layer.