blob: 5d553bbeff3ae532bc40016194ba4981d2f28bc0 [file] [log] [blame]
Carl van Schaik4e39ee12018-09-07 22:26:50 +10001/*
2 * Copyright (c) 2018 Cog Systems Pty Ltd
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * Header file for communication with resource manager.
9 *
10 */
11
12/*
13 * Core API
14 */
15#define ERROR_REPLY 0x8000ffff
16
17/*
18 * Boot manager API
19 */
20#define BOOT_MGR_PROTOCOL_ID 'B'
21
22/* start_client: Unmap the client (ML VM) memory and start Linux */
23#define BOOT_MGR_START_CLIENT 0x00420001
24/* msg_payload: struct boot_mgr_start_params */
25
26struct boot_mgr_start_params {
27 uint64_t entry_addr; /* Physical load address / entry point of Linux */
28 uint64_t dtb_addr; /* Physical address of DTB */
29 bool is_64bit; /* True to reset VM to AArch64 mode, false for AArch32 */
30};
31
32/* start_client_reply: Response to BOOT_MGR_START_CLIENT */
33#define BOOT_MGR_START_CLIENT_REPLY 0x80420001
34/* msg_payload: bool success */
35
36/* start_self: Reset the caller and start the loaded HLOS image */
37#define BOOT_MGR_START_SELF 0x00420002
38/* msg_payload: struct boot_mgr_start_params */
39
40/*
41 * start_self_reply: Response to BOOT_MGR_START_CLIENT; sent only on
42 * failure as the caller will be reset if this call succeeds
43 */
44#define BOOT_MGR_START_SELF_REPLY 0x80420002
45/* msg_payload: bool success */
46
47
48/*
49 * Secure Camera Server API (for HLOS)
50 */
51#define RES_MGR_SECURECAM_SERVER_PROTOCOL_ID 'q'
52
53/*
54 * get_handle: Given a buffer sg list, return an SC handle.
55 *
56 * This is sent by the HLOS to the resource manager to obtain the SC handle
57 * to be used to refer to a specific camera buffer.
58 *
59 * The message payload is a list of IPA ranges in the HLOS VM's stage 2
60 * address space. These ranges must have previously been passed to a TZ secure
61 * camera map call that has been intercepted by the hypervisor and forwarded
62 * to both TZ and the resource manager.
63 *
64 * Payload: struct res_mgr_sglist securecam.sglist
65 * Note: The payload ends with a variable-length array.
66 */
67#define RES_MGR_SECURECAM_GET_HANDLE 0x00710001
68
69struct res_mgr_region {
70 uint64_t address_ipa;
71 uint64_t size;
72};
73
74struct res_mgr_sglist {
75 uint32_t region_count;
76 struct res_mgr_region regions[];
77};
78
79/*
80 * get_handle_reply: Response to a get_handle request.
81 *
82 * This is sent by the resource manager to the HLOS to return the SC handle to
83 * be used to refer to the specified buffer.
84 *
85 * If the specified sglist did not match a secure camera buffer known to the
86 * resource manager, the value 0xffffffff is returned. This value is never
87 * a valid SC handle.
88 *
89 * Payload: uint32_t securecam.handle
90 */
91#define RES_MGR_SECURECAM_GET_HANDLE_REPLY 0x80710001
92
93/*
94 * destroy_handles: Destroy all SC handles and unmap their buffers.
95 *
96 * This is sent by the HLOS to the resource manager to ask it to unmap all
97 * secure camera buffers from the ML VM and return the memory to the HLOS.
98 *
99 * Under normal operation, this message will be received by the resource
100 * manager after the ML VM has indicated that its application is complete by
101 * sending a DONE message. If this is not the case, the resource manager will
102 * wait until both this message and the DONE message have been received before
103 * destroying the buffers.
104 *
105 * Payload: void
106 */
107#define RES_MGR_SECURECAM_DESTROY_HANDLES 0x00710002
108
109/*
110 * destroy_handles_reply: Indicate that all SC handles have been destroyed.
111 *
112 * This is sent by the resource manager to the HLOS to inform it that all
113 * secure camera buffers have been unmapped from the ML VM and returned to the
114 * HLOS.
115 *
116 * Payload: void
117 */
118#define RES_MGR_SECURECAM_DESTROY_HANDLES_REPLY 0x80710002
119
120
121/*
122 * Secure Camera Client API (for ML VM)
123 */
124#define RES_MGR_SECURECAM_CLIENT_PROTOCOL_ID 'Q'
125
126/*
127 * notify_start: Tell the client that the first camera buffer has been mapped.
128 *
129 * This is sent by the resource manager to the ML VM after the first instance
130 * of a TZ map call for a secure camera buffer being intercepted.
131 *
132 * Payload: void
133 */
134#define RES_MGR_SECURECAM_NOTIFY_START 0x80510001
135
136/*
137 * ack_start: Acknowledge a notify_start message
138 *
139 * This is sent by the ML VM to the resource manager to acknowledge receipt
140 * of a notify_start message.
141 *
142 * Payload: void
143 */
144#define RES_MGR_SECURECAM_ACK_START 0x00510001
145
146/*
147 * done: Indicate that the secure camera application has terminated.
148 *
149 * This is sent by the ML VM when access to the secure camera buffers is no
150 * longer required. The resource manager will delay unmapping the buffers
151 * until this message is received.
152 *
153 * Payload: void
154 */
155#define RES_MGR_SECURECAM_DONE 0x00510002
156
157/*
158 * lookup_handle: Request physical addresses for a secure camera handle.
159 *
160 * This is sent by the ML VM when userspace code attempts to register a secure
161 * camera buffer handle.
162 *
163 * Payload: uint32_t securecam.handle
164 */
165#define RES_MGR_LOOKUP_HANDLE 0x00510003
166
167/*
168 * lookup_handle_reply: Response to lookup_handle.
169 *
170 * When the resource manager receives a lookup_handle message containing a
171 * handle that is valid and has already been mapped into the ML VM stage 2,
172 * this message is returned containing the list of IPA ranges that have been
173 * assigned to the buffer in the ML VM's address space.
174 *
175 * If the handle is unknown, or corresponds to a buffer that is not currently
176 * mapped into the ML VM stage 2, the region_count field of the result will be
177 * set to 0.
178 *
179 * Payload: struct res_mgr_sglist securecam.sglist
180 * Note: The payload ends with a variable-length array.
181 */
182#define RES_MGR_LOOKUP_HANDLE_REPLY 0x80510003
183
184/*
185 * notify_start: Tell the client that the camera buffers will be unmapped.
186 *
187 * This is sent by the resource manager to the ML VM after the first instance
188 * of a TZ unprotect call for a secure camera buffer being intercepted.
189 *
190 * Payload: void
191 */
192#define RES_MGR_SECURECAM_NOTIFY_STOP 0x80510004
193
194/*
195 * ack_start: Acknowledge a notify_stop message
196 *
197 * This is sent by the ML VM to the resource manager to acknowledge receipt
198 * of a notify_stop message.
199 *
200 * Payload: void
201 */
202#define RES_MGR_SECURECAM_ACK_STOP 0x00510004
203
204/*
205 * Top-level message structure
206 */
207struct res_mgr_msg {
208 uint32_t msg_id;
209 union {
210 bool success;
211 struct {
212 struct boot_mgr_start_params start_params;
213 } boot_mgr;
214 struct {
215 uint32_t handle;
216 struct res_mgr_sglist sglist;
217 } securecam;
218 };
219};