blob: 73a75bb7c48f46de6f69514404987d66d1169178 [file] [log] [blame]
Ziyuan Xu48890e22016-10-27 19:07:35 +08001/*
Antonio Nino Diaz3c817f42018-03-21 10:49:27 +00002 * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
Ziyuan Xu48890e22016-10-27 19:07:35 +08003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Daniel Boulby8942a1b2018-06-22 14:16:03 +01007#include <assert.h>
Antonio Nino Diaz4b32e622018-08-16 16:52:57 +01008#include <cdefs.h>
Ziyuan Xu4060cfd2017-02-10 11:54:52 +08009#include <cdn_dp.h>
Antonio Nino Diaz3c817f42018-03-21 10:49:27 +000010#include <smccc.h>
Ziyuan Xu48890e22016-10-27 19:07:35 +080011#include <stdlib.h>
Ziyuan Xu4060cfd2017-02-10 11:54:52 +080012#include <string.h>
Ziyuan Xu48890e22016-10-27 19:07:35 +080013
14__asm__(
15 ".pushsection .text.hdcp_handler, \"ax\", %progbits\n"
16 ".global hdcp_handler\n"
17 ".balign 4\n"
18 "hdcp_handler:\n"
19 ".incbin \"" __XSTRING(HDCPFW) "\"\n"
20 ".type hdcp_handler, %function\n"
21 ".size hdcp_handler, .- hdcp_handler\n"
22 ".popsection\n"
23);
24
Ziyuan Xu4060cfd2017-02-10 11:54:52 +080025static uint64_t *hdcp_key_pdata;
26static struct cdn_dp_hdcp_key_1x key;
27
28int hdcp_handler(struct cdn_dp_hdcp_key_1x *key);
29
30uint64_t dp_hdcp_ctrl(uint64_t type)
31{
32 switch (type) {
33 case HDCP_KEY_DATA_START_TRANSFER:
34 memset(&key, 0x00, sizeof(key));
35 hdcp_key_pdata = (uint64_t *)&key;
36 return 0;
37 case HDCP_KEY_DATA_START_DECRYPT:
38 if (hdcp_key_pdata == (uint64_t *)(&key + 1))
39 return hdcp_handler(&key);
40 else
41 return PSCI_E_INVALID_PARAMS;
Daniel Boulby8942a1b2018-06-22 14:16:03 +010042 assert(0); /* Unreachable */
Ziyuan Xu4060cfd2017-02-10 11:54:52 +080043 default:
44 return SMC_UNK;
45 }
46}
47
48uint64_t dp_hdcp_store_key(uint64_t x1,
49 uint64_t x2,
50 uint64_t x3,
51 uint64_t x4,
52 uint64_t x5,
53 uint64_t x6)
54{
55 if (hdcp_key_pdata < (uint64_t *)&key ||
56 hdcp_key_pdata + 6 > (uint64_t *)(&key + 1))
57 return PSCI_E_INVALID_PARAMS;
58
59 hdcp_key_pdata[0] = x1;
60 hdcp_key_pdata[1] = x2;
61 hdcp_key_pdata[2] = x3;
62 hdcp_key_pdata[3] = x4;
63 hdcp_key_pdata[4] = x5;
64 hdcp_key_pdata[5] = x6;
65 hdcp_key_pdata += 6;
66
67 return 0;
68}