summaryrefslogtreecommitdiff
path: root/trusty/secure_dpu/include/trusty/secure_dpu/SecureDpu.h
blob: b939d44aa291f32abe84c895d28fe6bb7a13817f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
 * Copyright 2020, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#pragma once

#include <stdint.h>

/**
 * DOC: Secure DPU
 *
 * The Secure DPU works as the persistent channel between the non-secure and the
 * secure world. The channel is established during the boot up stage of the
 * non-secure world system. In general, the established channel allows the
 * secure world applications initiate requests or notifications to the non-secure
 * world.
 *
 * For particular devices, the secure world can only perform operations on the
 * display when in the TUI session if device-specific setup is done by the
 * non-secure world. Besides, the non-secure world could allocate framebuffer
 * for the secure world application if the memory is limited in the secure world
 * on specific devices.
 *
 * Currently, supported requests are to start / stop the secure display mode and
 * to allocate framebuffer.
 *
 * This header file needs to be synced on both the Trusty and the Android
 * codebase.
 */

#define SECURE_DPU_PORT_NAME "com.android.trusty.secure_dpu"
#define SECURE_DPU_MAX_MSG_SIZE 64

/**
 * enum secure_dpu_cmd - command identifiers for secure_fb interface
 * @SECURE_DPU_CMD_RESP_BIT:
 *      Message is a response.
 * @SECURE_DPU_CMD_REQ_SHIFT:
 *      Number of bits used by @SECURE_DPU_CMD_RESP_BIT.
 * @SECURE_DPU_CMD_START_SECURE_DISPLAY:
 *      Notify the system to start secure display mode
 * @SECURE_DPU_CMD_STOP_SECURE_DISPLAY:
 *      Notify the system to stop secure display mode
 * @SECURE_DPU_CMD_ALLOCATE_BUFFER:
 *      Request non-secure world to allocate the buffer
 */
enum secure_dpu_cmd {
    SECURE_DPU_CMD_RESP_BIT = 1,
    SECURE_DPU_CMD_REQ_SHIFT = 1,
    SECURE_DPU_CMD_START_SECURE_DISPLAY = (1 << SECURE_DPU_CMD_REQ_SHIFT),
    SECURE_DPU_CMD_STOP_SECURE_DISPLAY = (2 << SECURE_DPU_CMD_REQ_SHIFT),
    SECURE_DPU_CMD_ALLOCATE_BUFFER = (3 << SECURE_DPU_CMD_REQ_SHIFT),
};

/**
 * struct secure_dpu_allocate_buffer_req - payload for
 *                                         %SECURE_DPU_CMD_ALLOCATE_BUFFER
 *                                         request
 * @buffer_len: Requested length
 */
struct secure_dpu_allocate_buffer_req {
    uint64_t buffer_len;
};

/**
 * struct secure_dpu_allocate_buffer_resp - payload for
 *                                          %SECURE_DPU_CMD_ALLOCATE_BUFFER
 *                                          response
 * @buffer_len: Allocated length
 */
struct secure_dpu_allocate_buffer_resp {
    uint64_t buffer_len;
};

/**
 * struct secure_fb_req - common structure for secure_fb requests.
 * @cmd: Command identifier - one of &enum secure_dpu_cmd.
 */
struct secure_dpu_req {
    uint32_t cmd;
};

/**
 * struct secure_dpu_resp - common structure for secure_dpu responses.
 * @cmd:    Command identifier - %SECURE_DPU_CMD_RESP_BIT or'ed with the
 *                               command identifier of the corresponding
 *                               request.
 * @status: Status of requested operation. One of &enum secure_dpu_error.
 */
struct secure_dpu_resp {
    uint32_t cmd;
    int32_t status;
};

enum secure_dpu_error {
    SECURE_DPU_ERROR_OK = 0,
    SECURE_DPU_ERROR_FAIL = -1,
    SECURE_DPU_ERROR_UNINITIALIZED = -2,
    SECURE_DPU_ERROR_PARAMETERS = -3,
    SECURE_DPU_ERROR_NO_MEMORY = -4,
};