qseecom_proxy.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved.
  4. */
  5. #include <linux/module.h>
  6. #include <linux/printk.h>
  7. #include <linux/device.h>
  8. #include <linux/platform_device.h>
  9. #include <linux/qseecom_kernel.h>
  10. #include <linux/of_platform.h>
  11. #include <linux/mod_devicetable.h>
  12. static struct qseecom_drv_ops qseecom_fun_ops = {0};
  13. int provide_qseecom_kernel_fun_ops(const struct qseecom_drv_ops *ops)
  14. {
  15. if (!ops) {
  16. pr_err("ops is NULL\n");
  17. return -1;
  18. }
  19. qseecom_fun_ops = *ops;
  20. pr_debug("QSEECOM proxy Ready to be served\n");
  21. return 0;
  22. }
  23. EXPORT_SYMBOL(provide_qseecom_kernel_fun_ops);
  24. int qseecom_start_app(struct qseecom_handle **handle,
  25. char *app_name, uint32_t size)
  26. {
  27. int32_t ret = -1;
  28. /* start the application */
  29. if (qseecom_fun_ops.qseecom_start_app) {
  30. ret = qseecom_fun_ops.qseecom_start_app(handle, app_name, size);
  31. if (ret != 0)
  32. pr_err("%s: Start app -%s failed\n", __func__, app_name);
  33. } else {
  34. pr_err_ratelimited("Qseecom driver is not up yet\n");
  35. ret = -EAGAIN;
  36. }
  37. return ret;
  38. }
  39. EXPORT_SYMBOL(qseecom_start_app);
  40. int qseecom_shutdown_app(struct qseecom_handle **handle)
  41. {
  42. int32_t ret = -1;
  43. /* shutdown the application */
  44. if (qseecom_fun_ops.qseecom_shutdown_app) {
  45. ret = qseecom_fun_ops.qseecom_shutdown_app(handle);
  46. if (ret != 0)
  47. pr_err("%s: qseecom shutdown app failed with ret = %d\n", __func__, ret);
  48. } else {
  49. pr_err_ratelimited("Qseecom driver is not up yet\n");
  50. ret = -EAGAIN;
  51. }
  52. return ret;
  53. }
  54. EXPORT_SYMBOL(qseecom_shutdown_app);
  55. int qseecom_send_command(struct qseecom_handle *handle, void *send_buf,
  56. uint32_t sbuf_len, void *resp_buf, uint32_t rbuf_len)
  57. {
  58. int32_t ret = -1;
  59. /* send command to application*/
  60. if (qseecom_fun_ops.qseecom_send_command) {
  61. ret = qseecom_fun_ops.qseecom_send_command(handle, send_buf, sbuf_len,
  62. resp_buf, rbuf_len);
  63. if (ret != 0)
  64. pr_err("%s: qseecom send command failed with ret = %d\n", __func__, ret);
  65. } else {
  66. pr_err_ratelimited("Qseecom driver is not up yet\n");
  67. ret = -EAGAIN;
  68. }
  69. return ret;
  70. }
  71. EXPORT_SYMBOL(qseecom_send_command);
  72. MODULE_LICENSE("GPL");
  73. MODULE_DESCRIPTION("Qseecom proxy driver");