blob: 2b7903c708ff604f96a876cc2a9c63e8c789d49c [file] [log] [blame]
Neeti Desai127b9e02012-03-20 16:11:23 -07001/* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
Shashank Mittal162244e2011-08-08 19:01:25 -07002
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) */
Neeti Desai127b9e02012-03-20 16:11:23 -070033#define DECRYPT_MAGIC_0 0x73737A74
34#define DECRYPT_MAGIC_1 0x676D6964
35#define ENCRYPT_MAGIC_0 0x6B647373
36#define ENCRYPT_MAGIC_1 0x676D6973
Shashank Mittal162244e2011-08-08 19:01:25 -070037#define SSD_HEADER_MAGIC_SIZE 8
38#define SSD_HEADER_XML_SIZE 2048
39
40typedef unsigned int uint32;
41
Ajay Dudanib01e5062011-12-03 23:23:42 -080042typedef struct {
43 uint32 len;
44 uint32 buf_offset;
45 uint32 resp_hdr_offset;
46 uint32 id;
Shashank Mittal162244e2011-08-08 19:01:25 -070047} scm_command;
48
Ajay Dudanib01e5062011-12-03 23:23:42 -080049typedef struct {
50 uint32 len;
51 uint32 buf_offset;
52 uint32 is_complete;
Shashank Mittal162244e2011-08-08 19:01:25 -070053} scm_response;
54
Ajay Dudanib01e5062011-12-03 23:23:42 -080055typedef struct {
Ajay Dudanib01e5062011-12-03 23:23:42 -080056 uint32 *img_ptr;
57 uint32 *img_len_ptr;
Neeti Desai127b9e02012-03-20 16:11:23 -070058} img_req;
Shashank Mittal162244e2011-08-08 19:01:25 -070059
Neeti Desai127b9e02012-03-20 16:11:23 -070060#define SCM_SVC_SSD 7
61#define SSD_DECRYPT_ID 0x01
62#define SSD_ENCRYPT_ID 0x02
Shashank Mittal162244e2011-08-08 19:01:25 -070063
Shashank Mittal162244e2011-08-08 19:01:25 -070064static uint32 smc(uint32 cmd_addr);
Neeti Desai127b9e02012-03-20 16:11:23 -070065
66int decrypt_scm(uint32_t ** img_ptr, uint32_t * img_len_ptr);
67int encrypt_scm(uint32_t ** img_ptr, uint32_t * img_len_ptr);
Shashank Mittal162244e2011-08-08 19:01:25 -070068
Deepa Dinamani193874e2012-02-07 14:00:04 -080069#define SCM_SVC_FUSE 0x08
70#define SCM_BLOW_SW_FUSE_ID 0x01
71#define SCM_IS_SW_FUSE_BLOWN_ID 0x02
Shashank Mittal162244e2011-08-08 19:01:25 -070072
Deepa Dinamani193874e2012-02-07 14:00:04 -080073#define HLOS_IMG_TAMPER_FUSE 0
74
75
76#define SCM_SVC_CE_CHN_SWITCH_ID 0x04
77#define SCM_CE_CHN_SWITCH_ID 0x02
78
79enum ap_ce_channel_type {
80AP_CE_REGISTER_USE = 0,
81AP_CE_ADM_USE = 1
82};
83
84/* Apps CE resource. */
85#define TZ_RESOURCE_CE_AP 2
86
87uint8_t switch_ce_chn_cmd(enum ap_ce_channel_type channel);
88
89
Shashank Mittal162244e2011-08-08 19:01:25 -070090void set_tamper_fuse_cmd();
91
92/**
93 * struct scm_command - one SCM command buffer
94 * @len: total available memory for command and response
95 * @buf_offset: start of command buffer
96 * @resp_hdr_offset: start of response buffer
97 * @id: command to be executed
98 * @buf: buffer returned from scm_get_command_buffer()
99 *
100 * An SCM command is layed out in memory as follows:
101 *
102 * ------------------- <--- struct scm_command
103 * | command header |
104 * ------------------- <--- scm_get_command_buffer()
105 * | command buffer |
106 * ------------------- <--- struct scm_response and
107 * | response header | scm_command_to_response()
108 * ------------------- <--- scm_get_response_buffer()
109 * | response buffer |
110 * -------------------
111 *
112 * There can be arbitrary padding between the headers and buffers so
113 * you should always use the appropriate scm_get_*_buffer() routines
114 * to access the buffers in a safe manner.
115 */
116struct scm_command {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800117 uint32_t len;
118 uint32_t buf_offset;
119 uint32_t resp_hdr_offset;
120 uint32_t id;
121 uint32_t buf[0];
Shashank Mittal162244e2011-08-08 19:01:25 -0700122};
123
124/**
125 * struct scm_response - one SCM response buffer
126 * @len: total available memory for response
127 * @buf_offset: start of response data relative to start of scm_response
128 * @is_complete: indicates if the command has finished processing
129 */
130struct scm_response {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800131 uint32_t len;
132 uint32_t buf_offset;
133 uint32_t is_complete;
Shashank Mittal162244e2011-08-08 19:01:25 -0700134};
135
Deepa Dinamani193874e2012-02-07 14:00:04 -0800136
137
Shashank Mittal162244e2011-08-08 19:01:25 -0700138#endif