tee.rst 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. .. SPDX-License-Identifier: GPL-2.0
  2. ===============================================
  3. TEE (Trusted Execution Environment) driver API
  4. ===============================================
  5. Kernel provides a TEE bus infrastructure where a Trusted Application is
  6. represented as a device identified via Universally Unique Identifier (UUID) and
  7. client drivers register a table of supported device UUIDs.
  8. TEE bus infrastructure registers following APIs:
  9. match():
  10. iterates over the client driver UUID table to find a corresponding
  11. match for device UUID. If a match is found, then this particular device is
  12. probed via corresponding probe API registered by the client driver. This
  13. process happens whenever a device or a client driver is registered with TEE
  14. bus.
  15. uevent():
  16. notifies user-space (udev) whenever a new device is registered on
  17. TEE bus for auto-loading of modularized client drivers.
  18. TEE bus device enumeration is specific to underlying TEE implementation, so it
  19. is left open for TEE drivers to provide corresponding implementation.
  20. Then TEE client driver can talk to a matched Trusted Application using APIs
  21. listed in include/linux/tee_drv.h.
  22. TEE client driver example
  23. -------------------------
  24. Suppose a TEE client driver needs to communicate with a Trusted Application
  25. having UUID: ``ac6a4085-0e82-4c33-bf98-8eb8e118b6c2``, so driver registration
  26. snippet would look like::
  27. static const struct tee_client_device_id client_id_table[] = {
  28. {UUID_INIT(0xac6a4085, 0x0e82, 0x4c33,
  29. 0xbf, 0x98, 0x8e, 0xb8, 0xe1, 0x18, 0xb6, 0xc2)},
  30. {}
  31. };
  32. MODULE_DEVICE_TABLE(tee, client_id_table);
  33. static struct tee_client_driver client_driver = {
  34. .id_table = client_id_table,
  35. .driver = {
  36. .name = DRIVER_NAME,
  37. .bus = &tee_bus_type,
  38. .probe = client_probe,
  39. .remove = client_remove,
  40. },
  41. };
  42. static int __init client_init(void)
  43. {
  44. return driver_register(&client_driver.driver);
  45. }
  46. static void __exit client_exit(void)
  47. {
  48. driver_unregister(&client_driver.driver);
  49. }
  50. module_init(client_init);
  51. module_exit(client_exit);