blob: 668e32c72723bf4a92b060664468ca854c9e1feb [file] [log] [blame]
Shashank Mittal162244e2011-08-08 19:01:25 -07001/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
2
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are
5 * met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above
9 * copyright notice, this list of conditions and the following
10 * disclaimer in the documentation and/or other materials provided
11 * with the distribution.
12 * * Neither the name of Code Aurora Forum, Inc. nor the names of its
13 * contributors may be used to endorse or promote products derived
14 * from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef __SCM_H__
30#define __SCM_H__
31
32/* 8 Byte SSD magic number (LE) */
33#define SSD_HEADER_MAGIC_0 0x73737A74
34#define SSD_HEADER_MAGIC_1 0x676D6964
35#define SSD_HEADER_MAGIC_SIZE 8
36#define SSD_HEADER_XML_SIZE 2048
37
38typedef unsigned int uint32;
39
Ajay Dudanib01e5062011-12-03 23:23:42 -080040typedef struct {
41 uint32 len;
42 uint32 buf_offset;
43 uint32 resp_hdr_offset;
44 uint32 id;
Shashank Mittal162244e2011-08-08 19:01:25 -070045} scm_command;
46
Ajay Dudanib01e5062011-12-03 23:23:42 -080047typedef struct {
48 uint32 len;
49 uint32 buf_offset;
50 uint32 is_complete;
Shashank Mittal162244e2011-08-08 19:01:25 -070051} scm_response;
52
Ajay Dudanib01e5062011-12-03 23:23:42 -080053typedef struct {
54 scm_command common_req;
55 uint32 *img_ptr;
56 uint32 *img_len_ptr;
Shashank Mittal162244e2011-08-08 19:01:25 -070057} decrypt_img_req;
58
59#define SYSCALL_CREATE_CMD_ID(s, f) \
60 ((uint32)(((s & 0x3ff) << 10) | (f & 0x3ff)))
61
62#define SCM_SVC_SSD 7
63#define SSD_DECRYPT_IMG_ID SYSCALL_CREATE_CMD_ID(SCM_SVC_SSD, 0x01)
64
Ajay Dudanib01e5062011-12-03 23:23:42 -080065void setup_decrypt_cmd(decrypt_img_req * dec_cmd,
66 uint32 ** img_ptr, uint32 * img_len_ptr);
Shashank Mittal162244e2011-08-08 19:01:25 -070067static uint32 smc(uint32 cmd_addr);
Ajay Dudanib01e5062011-12-03 23:23:42 -080068int decrypt_img_scm(uint32 ** img_ptr, uint32 * img_len_ptr);
Shashank Mittal162244e2011-08-08 19:01:25 -070069
Deepa Dinamani193874e2012-02-07 14:00:04 -080070#define SCM_SVC_FUSE 0x08
71#define SCM_BLOW_SW_FUSE_ID 0x01
72#define SCM_IS_SW_FUSE_BLOWN_ID 0x02
Shashank Mittal162244e2011-08-08 19:01:25 -070073
Deepa Dinamani193874e2012-02-07 14:00:04 -080074#define HLOS_IMG_TAMPER_FUSE 0
75
76
77#define SCM_SVC_CE_CHN_SWITCH_ID 0x04
78#define SCM_CE_CHN_SWITCH_ID 0x02
79
80enum ap_ce_channel_type {
81AP_CE_REGISTER_USE = 0,
82AP_CE_ADM_USE = 1
83};
84
85/* Apps CE resource. */
86#define TZ_RESOURCE_CE_AP 2
87
88uint8_t switch_ce_chn_cmd(enum ap_ce_channel_type channel);
89
90
Shashank Mittal162244e2011-08-08 19:01:25 -070091void set_tamper_fuse_cmd();
92
93/**
94 * struct scm_command - one SCM command buffer
95 * @len: total available memory for command and response
96 * @buf_offset: start of command buffer
97 * @resp_hdr_offset: start of response buffer
98 * @id: command to be executed
99 * @buf: buffer returned from scm_get_command_buffer()
100 *
101 * An SCM command is layed out in memory as follows:
102 *
103 * ------------------- <--- struct scm_command
104 * | command header |
105 * ------------------- <--- scm_get_command_buffer()
106 * | command buffer |
107 * ------------------- <--- struct scm_response and
108 * | response header | scm_command_to_response()
109 * ------------------- <--- scm_get_response_buffer()
110 * | response buffer |
111 * -------------------
112 *
113 * There can be arbitrary padding between the headers and buffers so
114 * you should always use the appropriate scm_get_*_buffer() routines
115 * to access the buffers in a safe manner.
116 */
117struct scm_command {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800118 uint32_t len;
119 uint32_t buf_offset;
120 uint32_t resp_hdr_offset;
121 uint32_t id;
122 uint32_t buf[0];
Shashank Mittal162244e2011-08-08 19:01:25 -0700123};
124
125/**
126 * struct scm_response - one SCM response buffer
127 * @len: total available memory for response
128 * @buf_offset: start of response data relative to start of scm_response
129 * @is_complete: indicates if the command has finished processing
130 */
131struct scm_response {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800132 uint32_t len;
133 uint32_t buf_offset;
134 uint32_t is_complete;
Shashank Mittal162244e2011-08-08 19:01:25 -0700135};
136
Deepa Dinamani193874e2012-02-07 14:00:04 -0800137
138
Shashank Mittal162244e2011-08-08 19:01:25 -0700139#endif