blob: eb764bc467bc6160584972de66292eaaca984fb7 [file] [log] [blame]
Tri Vo19b62a52021-02-16 11:51:26 -08001/*
2 * Copyright 2021 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include <stdint.h>
20
21/*
22 * This interface is shared between Android and Trusty. There is a copy in each
23 * repository. They must be kept in sync.
24 */
25
26#define CONFIRMATIONUI_PORT "com.android.trusty.confirmationui"
27
28/**
29 * enum confirmationui_cmd - command identifiers for ConfirmationUI interface
30 * @CONFIRMATIONUI_RESP_BIT: response bit set as part of response
31 * @CONFIRMATIONUI_REQ_SHIFT: number of bits used by response bit
32 * @CONFIRMATIONUI_CMD_INIT: command to initialize session
33 * @CONFIRMATIONUI_CMD_MSG: command to send ConfirmationUI messages
34 */
35enum confirmationui_cmd : uint32_t {
36 CONFIRMATIONUI_RESP_BIT = 1,
37 CONFIRMATIONUI_REQ_SHIFT = 1,
38
39 CONFIRMATIONUI_CMD_INIT = (1 << CONFIRMATIONUI_REQ_SHIFT),
40 CONFIRMATIONUI_CMD_MSG = (2 << CONFIRMATIONUI_REQ_SHIFT),
41};
42
43/**
44 * struct confirmationui_hdr - header for ConfirmationUI messages
45 * @cmd: command identifier
46 *
47 * Note that no messages return a status code. Any error on the server side
48 * results in the connection being closed. So, operations can be assumed to be
49 * successful if they return a response.
50 */
51struct confirmationui_hdr {
52 uint32_t cmd;
53};
54
55/**
56 * struct confirmationui_init_req - arguments for request to initialize a
57 * session
58 * @shm_len: length of memory region being shared
59 *
60 * A handle to a memory region must be sent along with this message. This memory
61 * is send to ConfirmationUI messages.
62 */
63struct confirmationui_init_req {
64 uint32_t shm_len;
65};
66
67/**
68 * struct confirmationui_msg_args - arguments for sending a message
69 * @msg_len: length of message being sent
70 *
71 * Contents of the message are located in the shared memory region that is
72 * established using %CONFIRMATIONUI_CMD_INIT.
73 *
74 * ConfirmationUI messages can travel both ways.
75 */
76struct confirmationui_msg_args {
77 uint32_t msg_len;
78};
79
80#define CONFIRMATIONUI_MAX_MSG_SIZE 0x2000