cdn_dp.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <assert.h>
  7. #include <cdefs.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10. #include <lib/smccc.h>
  11. #include <cdn_dp.h>
  12. __asm__(
  13. ".pushsection .text.hdcp_handler, \"ax\", %progbits\n"
  14. ".global hdcp_handler\n"
  15. ".balign 4\n"
  16. "hdcp_handler:\n"
  17. ".incbin \"" HDCPFW "\"\n"
  18. ".type hdcp_handler, %function\n"
  19. ".size hdcp_handler, .- hdcp_handler\n"
  20. ".popsection\n"
  21. );
  22. static uint64_t *hdcp_key_pdata;
  23. static struct cdn_dp_hdcp_key_1x key;
  24. int hdcp_handler(struct cdn_dp_hdcp_key_1x *key);
  25. uint64_t dp_hdcp_ctrl(uint64_t type)
  26. {
  27. switch (type) {
  28. case HDCP_KEY_DATA_START_TRANSFER:
  29. memset(&key, 0x00, sizeof(key));
  30. hdcp_key_pdata = (uint64_t *)&key;
  31. return 0;
  32. case HDCP_KEY_DATA_START_DECRYPT:
  33. if (hdcp_key_pdata == (uint64_t *)(&key + 1))
  34. return hdcp_handler(&key);
  35. else
  36. return PSCI_E_INVALID_PARAMS;
  37. assert(0); /* Unreachable */
  38. default:
  39. return SMC_UNK;
  40. }
  41. }
  42. uint64_t dp_hdcp_store_key(uint64_t x1,
  43. uint64_t x2,
  44. uint64_t x3,
  45. uint64_t x4,
  46. uint64_t x5,
  47. uint64_t x6)
  48. {
  49. if (hdcp_key_pdata < (uint64_t *)&key ||
  50. hdcp_key_pdata + 6 > (uint64_t *)(&key + 1))
  51. return PSCI_E_INVALID_PARAMS;
  52. hdcp_key_pdata[0] = x1;
  53. hdcp_key_pdata[1] = x2;
  54. hdcp_key_pdata[2] = x3;
  55. hdcp_key_pdata[3] = x4;
  56. hdcp_key_pdata[4] = x5;
  57. hdcp_key_pdata[5] = x6;
  58. hdcp_key_pdata += 6;
  59. return 0;
  60. }