ql_ipc_dev.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * Copyright (C) 2016 The Android Open Source Project
  3. *
  4. * Permission is hereby granted, free of charge, to any person
  5. * obtaining a copy of this software and associated documentation
  6. * files (the "Software"), to deal in the Software without
  7. * restriction, including without limitation the rights to use, copy,
  8. * modify, merge, publish, distribute, sublicense, and/or sell copies
  9. * of the Software, and to permit persons to whom the Software is
  10. * furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be
  13. * included in all copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  18. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  19. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  20. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  21. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  22. * SOFTWARE.
  23. */
  24. #ifndef TRUSTY_QL_IPC_DEV_H_
  25. #define TRUSTY_QL_IPC_DEV_H_
  26. /*
  27. * Architecture specific Trusty device struct.
  28. *
  29. * @priv_data: system dependent data, may be unused
  30. * @api_version: TIPC version
  31. */
  32. struct trusty_dev {
  33. void* priv_data;
  34. uint32_t api_version;
  35. osiMutex_t *lock;
  36. };
  37. /*
  38. * Initializes @dev with @priv, and gets the API version by calling
  39. * into Trusty. Returns negative on error.
  40. */
  41. int trusty_dev_init(struct trusty_dev* dev, void* priv);
  42. /*
  43. * Cleans up anything related to @dev. Returns negative on error.
  44. */
  45. int trusty_dev_shutdown(struct trusty_dev* dev);
  46. /*
  47. * Enter trusty on cpus that are not in an ipc call
  48. */
  49. int trusty_dev_nop(struct trusty_dev* dev);
  50. /*
  51. * Invokes creation of queueless Trusty IPC device on the secure side.
  52. * @buf will be mapped into Trusty's address space.
  53. *
  54. * @dev: trusty device, initialized with trusty_dev_init
  55. * @buf: physical address info of buffer to share with Trusty
  56. * @buf_size: size of @buf
  57. */
  58. int trusty_dev_init_ipc(struct trusty_dev* dev,
  59. struct ns_mem_page_info* buf,
  60. uint32_t buf_size);
  61. /*
  62. * Invokes execution of command on the secure side.
  63. *
  64. * @dev: trusty device, initialized with trusty_dev_init
  65. * @buf: physical address info of shared buffer containing command
  66. * @buf_size: size of command data
  67. */
  68. int trusty_dev_exec_ipc(struct trusty_dev* dev,
  69. struct ns_mem_page_info* buf,
  70. uint32_t buf_size);
  71. int trusty_dev_exec_fc_ipc(struct trusty_dev* dev,
  72. struct ns_mem_page_info* buf,
  73. uint32_t buf_size);
  74. /*
  75. * Invokes deletion of queueless Trusty IPC device on the secure side.
  76. * @buf is unmapped, and all open channels are closed.
  77. *
  78. * @dev: trusty device, initialized with trusty_dev_init
  79. * @buf: physical address info of shared buffer
  80. * @buf_size: size of @buf
  81. */
  82. int trusty_dev_shutdown_ipc(struct trusty_dev* dev,
  83. struct ns_mem_page_info* buf,
  84. uint32_t buf_size);
  85. #endif /* TRUSTY_QL_IPC_DEV_H_ */