blob: c5fa008308f86322a61196e3d3511c39f62700ce [file] [log] [blame]
Steven Moreland5553ac42020-11-11 02:14:45 +00001/*
2 * Copyright (C) 2020 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#pragma once
17
18namespace android {
19
20#pragma clang diagnostic push
21#pragma clang diagnostic error "-Wpadded"
22
23enum : uint32_t {
24 /**
25 * follows is RpcWireTransaction, if flags != oneway, reply w/ RPC_COMMAND_REPLY expected
26 */
27 RPC_COMMAND_TRANSACT = 0,
28 /**
29 * follows is RpcWireReply
30 */
31 RPC_COMMAND_REPLY,
32 /**
33 * follows is RpcWireAddress
34 *
35 * note - this in the protocol directly instead of as a 'special
36 * transaction' in order to keep it as lightweight as possible (we don't
37 * want to create a 'Parcel' object for every decref)
38 */
39 RPC_COMMAND_DEC_STRONG,
40};
41
42/**
43 * These commands are used when the address in an RpcWireTransaction is zero'd
44 * out (no address). This allows the transact/reply flow to be used for
45 * additional server commands, without making the protocol for
46 * transactions/replies more complicated.
47 */
48enum : uint32_t {
49 RPC_SPECIAL_TRANSACT_GET_ROOT = 0,
Steven Morelandf137de92021-04-24 01:54:26 +000050 RPC_SPECIAL_TRANSACT_GET_MAX_THREADS = 1,
Steven Morelandbdb53ab2021-05-05 17:57:41 +000051 RPC_SPECIAL_TRANSACT_GET_SESSION_ID = 2,
Steven Moreland5553ac42020-11-11 02:14:45 +000052};
53
Steven Morelandbdb53ab2021-05-05 17:57:41 +000054constexpr int32_t RPC_SESSION_ID_NEW = -1;
Steven Moreland736664b2021-05-01 04:27:25 +000055
Steven Moreland5553ac42020-11-11 02:14:45 +000056// serialization is like:
57// |RpcWireHeader|struct desginated by 'command'| (over and over again)
58
59struct RpcWireHeader {
60 uint32_t command; // RPC_COMMAND_*
61 uint32_t bodySize;
62
63 uint32_t reserved[2];
64};
65
66struct RpcWireAddress {
67 uint8_t address[32];
68};
69
70struct RpcWireTransaction {
71 RpcWireAddress address;
72 uint32_t code;
73 uint32_t flags;
74
75 uint64_t asyncNumber;
76
77 uint32_t reserved[4];
78
79 uint8_t data[0];
80};
81
82struct RpcWireReply {
83 int32_t status; // transact return
84 uint8_t data[0];
85};
86
87#pragma clang diagnostic pop
88
89} // namespace android