1// Copyright 2018 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
15syntax = "proto2";
16
17package android.vts;
18option java_package = "com.android.vts.proto";
19option java_outer_classname = "VtsResourceControllerMessage";
20
21import "test/vts/proto/ComponentSpecificationMessage.proto";
22
23// Possible operations on Fast Message Queue.
24enum FmqOp {
25    // Unknown operation.
26    FMQ_UNKNOWN = 0;
27    // Create a new FMQ object.
28    FMQ_CREATE = 1;
29    // Read from a FMQ (no blocking).
30    FMQ_READ = 2;
31    // Read from a FMQ (with short-form blocking).
32    FMQ_READ_BLOCKING = 3;
33    // Read from a FMQ (with long-form blocking).
34    // TODO: support this from host side in the future
35    FMQ_READ_BLOCKING_LONG = 4;
36    // Write to a FMQ (no blocking).
37    FMQ_WRITE = 5;
38    // Write to a FMQ (with short-form blocking).
39    FMQ_WRITE_BLOCKING = 6;
40    // Write to a FMQ (with long-form blocking).
41    // TODO: support this from host side in the future
42    FMQ_WRITE_BLOCKING_LONG = 7;
43    // Get space available to write in FMQ.
44    FMQ_AVAILABLE_WRITE = 8;
45    // Get number of items available to read.
46    FMQ_AVAILABLE_READ = 9;
47    // Get size of item in FMQ.
48    FMQ_GET_QUANTUM_SIZE = 10;
49    // Get number of items that fit in FMQ.
50    FMQ_GET_QUANTUM_COUNT = 11;
51    // Check if FMQ is valid.
52    FMQ_IS_VALID = 12;
53    // Get address of queue descriptor.
54    // This is an operation that is used in the target-side
55    // drivers to pass queue descriptor address to identify
56    // the FMQ. It is not for communication between host and
57    // target.
58    FMQ_GET_DESC_ADDR = 13;
59}
60
61// Possible operations on hidl_memory.
62enum HidlMemoryOp {
63    // Unknown operation.
64    MEM_PROTO_UNKNOWN = 0;
65    // Allcate a new memory region.
66    MEM_PROTO_ALLOCATE = 1;
67    // Signal starting to read memory.
68    MEM_PROTO_START_READ = 2;
69    // Signal starting to read a particular region of memory.
70    MEM_PROTO_START_READ_RANGE = 3;
71    // Perform actual read operation.
72    MEM_PROTO_READ_BYTES = 4;
73    // Signal starting to write to memory.
74    MEM_PROTO_START_UPDATE = 5;
75    // Signal starting to write to a particular region of memory.
76    MEM_PROTO_START_UPDATE_RANGE = 6;
77    // Perform actual write operation.
78    MEM_PROTO_UPDATE_BYTES = 7;
79    // Commit to a read/write operation.
80    MEM_PROTO_COMMIT = 8;
81    // Get the size of memory region.
82    MEM_PROTO_GET_SIZE = 9;
83}
84
85// Possible operations on hidl_handle.
86enum HidlHandleOp {
87    // Unknown operation.
88    HANDLE_PROTO_UNKNOWN = 0;
89    // Create a handle object for a single file.
90    HANDLE_PROTO_CREATE_FILE = 1;
91    // Read from a handle object with one file.
92    HANDLE_PROTO_READ_FILE = 2;
93    // Write to a handle object with one file.
94    HANDLE_PROTO_WRITE_FILE = 3;
95    // Delete a handle object.
96    HANDLE_PROTO_DELETE = 4;
97}
98
99// The arguments for a FMQ operation.
100message FmqRequestMessage {
101    // operation to be performed
102    optional FmqOp operation = 1;
103
104    // string to represent type of data in the queue
105    // TODO: support user-defined types
106    optional bytes data_type = 2;
107    // queue flavor
108    optional bool sync = 3;
109
110    // queue id
111    optional int32 queue_id = 4 [default = -1];
112
113    // queue size
114    optional uint64 queue_size = 5;
115    // whether to enable blocking
116    optional bool blocking = 6;
117    // whether to reset read/write pointers
118    optional bool reset_pointers = 7;
119
120    // data to be written
121    repeated VariableSpecificationMessage write_data = 8;
122    // length of data to be read
123    optional uint64 read_data_size = 9;
124    // wait time when blocking
125    optional int64 time_out_nanos = 10;
126
127    // store address of queue descriptor
128    // This is a field that is used by internal drivers
129    // to identify a FMQ.
130    // It is not used for communication between host and target.
131    optional uint64 queue_desc_addr = 11;
132}
133
134// The response for a FMQ operation,
135// including scalar values and data read back from the queue.
136message FmqResponseMessage {
137    // data read from the queue
138    repeated VariableSpecificationMessage read_data = 1;
139
140    // three possible return types from FMQ
141    // basic util function return values
142    optional uint64 sizet_return_val = 2;
143    // function that returns a queue id
144    optional int32 queue_id = 3;
145    // signal if the operation succeeds on target side
146    optional bool success = 4;
147}
148
149// The arguments for a hidl_memory operation.
150message HidlMemoryRequestMessage {
151    // operation to be performed
152    optional HidlMemoryOp operation = 1;
153    // id to identify memory region
154    optional int32 mem_id = 2 [default = -1];
155    // requested memory size
156    optional uint64 mem_size = 3;
157    // offset from the start of memory region
158    optional uint64 start = 4;
159    // length of memory to be modified
160    optional uint64 length = 5;
161    // data to be written into memory
162    optional bytes write_data = 6;
163}
164
165// The response for a hidl_memory operation.
166message HidlMemoryResponseMessage {
167    // indicate if the memory region is found
168    optional bool success = 1;
169    // new id assigned to the new memory region
170    optional int32 new_mem_id = 2;
171    // result returned by GetSize() method on the memory region
172    optional uint64 mem_size = 3;
173    // data read from memory
174    optional bytes read_data = 4;
175}
176
177// The arguments for a hidl_handle operation.
178message HidlHandleRequestMessage {
179    // operation to be performed
180    optional HidlHandleOp operation = 1;
181    // identifies the handle object
182    optional int32 handle_id = 2 [default = -1];
183    // to specify what files to open, and additional integers
184    // in a handle object
185    optional HandleDataValueMessage handle_info = 3;
186    // number of bytes to read from the file
187    // read() function in C I/O takes in a size_t,
188    // so use unsigned integer here.
189    optional uint64 read_data_size = 4;
190    // data to be written into file
191    optional bytes write_data = 5;
192}
193
194// The response for a hidl_handle operation.
195message HidlHandleResponseMessage {
196    // indicate if the operation succeeds
197    optional bool success = 1;
198    // new id assigned to the new handle object
199    optional int32 new_handle_id = 2;
200    // data read from the file
201    optional bytes read_data = 3;
202    // number of bytes written into the file if the request is a write operation
203    // write() function in C I/O returns a ssize_t,
204    // so use signed integer here.
205    optional int64 write_data_size = 4;
206}
207