• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright (C) 2017 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15namespace chre.fbs;
16
17/// Represents a message sent to/from a nanoapp from/to a client on the host
18table NanoappMessage {
19  app_id:ulong = 0;
20  message_type:uint = 0;
21
22  /// Identifies the host-side endpoint on the host that sent or should receive
23  /// this message. The default value is a special value defined in the HAL and
24  /// elsewhere that indicates that the endpoint is unspecified.
25  host_endpoint:ushort = 0xfffe;
26
27  /// Vector containing arbitrary application-specific message data
28  message:[ubyte] (required);
29}
30
31table HubInfoRequest {}
32table HubInfoResponse {
33  /// The name of the hub. Nominally a UTF-8 string, but note that we're not
34  /// using the built-in "string" data type from FlatBuffers here, because the
35  /// generated C++ uses std::string which is not well-supported in CHRE. This
36  /// applies for vendor and toolchain as well.
37  name:[byte];
38  vendor:[byte];
39  toolchain:[byte];
40
41  /// Legacy platform version reported in the HAL; semantics not strictly
42  /// defined
43  platform_version:uint;
44
45  /// Toolchain version reported in the HAL; semantics not strictly defined
46  toolchain_version:uint;
47
48  peak_mips:float;
49  stopped_power:float;
50  sleep_power:float;
51  peak_power:float;
52
53  /// Maximum size message that can be sent to a nanoapp
54  max_msg_len:uint;
55
56  /// @see chreGetPlatformId()
57  platform_id:ulong;
58
59  /// @see chreGetVersion()
60  chre_platform_version:uint;
61
62  // TODO: list of connected sensors
63}
64
65table NanoappListRequest {}
66
67table NanoappListEntry {
68  app_id:ulong;
69  version:uint;
70  enabled:bool = true;
71
72  /// Whether the nanoapp is a pre-loaded "system" nanoapp, i.e. one that should
73  /// not show up in the list of nanoapps in the context hub HAL. System
74  /// nanoapps are typically used to leverage CHRE for some device functionality
75  /// and do not interact via the context hub HAL.
76  is_system:bool = false;
77
78  // TODO: memory usage
79}
80
81table NanoappListResponse {
82  nanoapps:[NanoappListEntry] (required);
83}
84
85table LoadNanoappRequest {
86  transaction_id:uint;
87
88  app_id:ulong;
89  app_version:uint;
90  target_api_version:uint;
91
92  app_binary:[ubyte] (required);
93}
94
95table LoadNanoappResponse {
96  transaction_id:uint;
97  success:bool;
98
99  // TODO: detailed error code?
100}
101
102/// A union that joins together all possible messages. Note that in FlatBuffers,
103/// unions have an implicit type
104union ChreMessage {
105  NanoappMessage,
106
107  HubInfoRequest,
108  HubInfoResponse,
109
110  NanoappListRequest,
111  NanoappListResponse,
112
113  LoadNanoappRequest,
114  LoadNanoappResponse,
115
116  // TODO: extend with system-specific messages, e.g. load app command, etc.
117}
118
119struct HostAddress {
120  client_id:ushort;
121}
122
123/// The top-level container that encapsulates all possible messages. Note that
124/// per FlatBuffers requirements, we can't use a union as the top-level structure
125/// (root type), so we must wrap it in a table.
126table MessageContainer {
127  message:ChreMessage (required);
128
129  /// The originating or destination client ID on the host side, used to direct
130  /// responses only to the client that sent the request. Although initially
131  /// populated by the requesting client, this is enforced to be the correct
132  /// value by the entity guarding access to CHRE.
133  /// This is wrapped in a struct to ensure that it is always included when
134  /// encoding the message, so it can be mutated by the host daemon.
135  host_addr:HostAddress (required);
136}
137
138root_type MessageContainer;
139