blob: 33634cf83d42d98fafc4fd0fe9a08b03d1306692 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* Qualcomm TrustZone communicator driver
2 *
3 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 and
7 * only version 2 as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15#ifndef __TZCOMI_H_
16#define __TZCOMI_H_
17
18#include <linux/types.h>
19
20enum tz_sched_cmd_id {
21 TZ_SCHED_CMD_ID_INVALID = 0,
22 TZ_SCHED_CMD_ID_INIT_SB_OUT, /**< Initialize the shared buffer */
23 TZ_SCHED_CMD_ID_INIT_SB_LOG, /**< Initialize the logging shared buf */
24 TZ_SCHED_CMD_ID_UNKNOWN = 0x7FFFFFFE,
25 TZ_SCHED_CMD_ID_MAX = 0x7FFFFFFF
26};
27
28enum tz_sched_cmd_type {
29 TZ_SCHED_CMD_INVALID = 0,
30 TZ_SCHED_CMD_NEW, /** New TZ Scheduler Command */
31 TZ_SCHED_CMD_PENDING, /** Pending cmd...sched will restore stack */
32 TZ_SCHED_CMD_COMPLETE, /** TZ sched command is complete */
33 TZ_SCHED_CMD_MAX = 0x7FFFFFFF
34};
35
36enum tz_sched_cmd_status {
37 TZ_SCHED_STATUS_INCOMPLETE = 0,
38 TZ_SCHED_STATUS_COMPLETE,
39 TZ_SCHED_STATUS_MAX = 0x7FFFFFFF
40};
41
42/** Command structure for initializing shared buffers (SB_OUT
43 and SB_LOG)
44*/
45__packed struct tz_pr_init_sb_req_s {
46 /** First 4 bytes should always be command id
47 * from enum tz_sched_cmd_id */
48 uint32_t pr_cmd;
49 /** Pointer to the physical location of sb_out buffer */
50 uint32_t sb_ptr;
51 /** length of shared buffer */
52 uint32_t sb_len;
53};
54
55
56__packed struct tz_pr_init_sb_rsp_s {
57 /** First 4 bytes should always be command id
58 * from enum tz_sched_cmd_id */
59 uint32_t pr_cmd;
60 /** Return code, 0 for success, Approp error code otherwise */
61 int32_t ret;
62};
63
64
65/**
66 * struct tzcom_command - tzcom command buffer
67 * @cmd_type: value from enum tz_sched_cmd_type
68 * @sb_in_cmd_addr: points to physical location of command
69 * buffer
70 * @sb_in_cmd_len: length of command buffer
71 */
72__packed struct tzcom_command {
73 uint32_t cmd_type;
74 uint8_t *sb_in_cmd_addr;
75 uint32_t sb_in_cmd_len;
76};
77
78/**
79 * struct tzcom_response - tzcom response buffer
80 * @cmd_status: value from enum tz_sched_cmd_status
81 * @sb_in_rsp_addr: points to physical location of response
82 * buffer
83 * @sb_in_rsp_len: length of command response
84 */
85__packed struct tzcom_response {
86 uint32_t cmd_status;
87 uint8_t *sb_in_rsp_addr;
88 uint32_t sb_in_rsp_len;
89};
90
91/**
92 * struct tzcom_callback - tzcom callback buffer
93 * @cmd_id: command to run in registered service
94 * @sb_out_rsp_addr: points to physical location of response
95 * buffer
96 * @sb_in_cmd_len: length of command response
97 *
98 * A callback buffer would be laid out in sb_out as follows:
99 *
100 * --------------------- <--- struct tzcom_callback
101 * | callback header |
102 * --------------------- <--- tzcom_callback.sb_out_cb_data_off
103 * | callback data |
104 * ---------------------
105 */
106__packed struct tzcom_callback {
107 uint32_t cmd_id;
108 uint32_t sb_out_cb_data_len;
109 uint32_t sb_out_cb_data_off;
110};
111
112#endif /* __TZCOMI_H_ */