1*4d7e907cSAndroid Build Coastguard Worker/* 2*4d7e907cSAndroid Build Coastguard Worker * Copyright (C) 2018 The Android Open Source Project 3*4d7e907cSAndroid Build Coastguard Worker * 4*4d7e907cSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*4d7e907cSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*4d7e907cSAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*4d7e907cSAndroid Build Coastguard Worker * 8*4d7e907cSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*4d7e907cSAndroid Build Coastguard Worker * 10*4d7e907cSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*4d7e907cSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*4d7e907cSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*4d7e907cSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*4d7e907cSAndroid Build Coastguard Worker * limitations under the License. 15*4d7e907cSAndroid Build Coastguard Worker */ 16*4d7e907cSAndroid Build Coastguard Worker 17*4d7e907cSAndroid Build Coastguard Workerpackage [email protected]; 18*4d7e907cSAndroid Build Coastguard Worker 19*4d7e907cSAndroid Build Coastguard Workerimport IConnection; 20*4d7e907cSAndroid Build Coastguard Worker/** 21*4d7e907cSAndroid Build Coastguard Worker * IAccessor creates IConnection which is used from IClientManager in order to 22*4d7e907cSAndroid Build Coastguard Worker * use functionality of the specified buffer pool. 23*4d7e907cSAndroid Build Coastguard Worker */ 24*4d7e907cSAndroid Build Coastguard Workerinterface IAccessor { 25*4d7e907cSAndroid Build Coastguard Worker 26*4d7e907cSAndroid Build Coastguard Worker /** 27*4d7e907cSAndroid Build Coastguard Worker * Registers a new client and creates IConnection to the buffer pool for 28*4d7e907cSAndroid Build Coastguard Worker * the client. IConnection and FMQ are used by IClientManager in order to 29*4d7e907cSAndroid Build Coastguard Worker * communicate with the buffer pool. Via FMQ IClientManager sends 30*4d7e907cSAndroid Build Coastguard Worker * BufferStatusMesage(s) to the buffer pool. 31*4d7e907cSAndroid Build Coastguard Worker * 32*4d7e907cSAndroid Build Coastguard Worker * FMQ is used to send buffer ownership status changes to a buffer pool 33*4d7e907cSAndroid Build Coastguard Worker * from a buffer pool client. A buffer pool synchronizes FMQ messages when 34*4d7e907cSAndroid Build Coastguard Worker * there is a hidl request from the clients. Every client has its own 35*4d7e907cSAndroid Build Coastguard Worker * connection and FMQ to communicate with the buffer pool. So sending an 36*4d7e907cSAndroid Build Coastguard Worker * FMQ message on behalf of other clients is not possible. 37*4d7e907cSAndroid Build Coastguard Worker * 38*4d7e907cSAndroid Build Coastguard Worker * FMQ messages are sent when a buffer is acquired or released. Also, FMQ 39*4d7e907cSAndroid Build Coastguard Worker * messages are sent when a buffer is transferred from a client to another 40*4d7e907cSAndroid Build Coastguard Worker * client. FMQ has its own ID from a buffer pool. A client is specified 41*4d7e907cSAndroid Build Coastguard Worker * with the ID. 42*4d7e907cSAndroid Build Coastguard Worker * 43*4d7e907cSAndroid Build Coastguard Worker * To transfer a buffer, a sender must send an FMQ message. The message 44*4d7e907cSAndroid Build Coastguard Worker * must include a receiver's ID and a transaction ID. A receiver must send 45*4d7e907cSAndroid Build Coastguard Worker * the transaction ID to fetch a buffer from a buffer pool. Since the 46*4d7e907cSAndroid Build Coastguard Worker * sender already registered the receiver via an FMQ message, The buffer 47*4d7e907cSAndroid Build Coastguard Worker * pool must verify the receiver with the transaction ID. In order to 48*4d7e907cSAndroid Build Coastguard Worker * prevent faking a receiver, a connection to a buffer pool from client is 49*4d7e907cSAndroid Build Coastguard Worker * made and kept private. Also part of transaction ID is a sender ID in 50*4d7e907cSAndroid Build Coastguard Worker * order to prevent fake transactions from other clients. This must be 51*4d7e907cSAndroid Build Coastguard Worker * verified with an FMQ message from a buffer pool. 52*4d7e907cSAndroid Build Coastguard Worker * 53*4d7e907cSAndroid Build Coastguard Worker * @return status The status of the call. 54*4d7e907cSAndroid Build Coastguard Worker * OK - A connection is made successfully. 55*4d7e907cSAndroid Build Coastguard Worker * NO_MEMORY - Memory allocation failure occurred. 56*4d7e907cSAndroid Build Coastguard Worker * ALREADY_EXISTS - A connection was already made. 57*4d7e907cSAndroid Build Coastguard Worker * CRITICAL_ERROR - Other errors. 58*4d7e907cSAndroid Build Coastguard Worker * @return connection The IConnection have interfaces 59*4d7e907cSAndroid Build Coastguard Worker * to get shared buffers from the buffer pool. 60*4d7e907cSAndroid Build Coastguard Worker * @return connectionId Id of IConnection. The Id identifies 61*4d7e907cSAndroid Build Coastguard Worker * sender and receiver in FMQ messages during buffer transfer. 62*4d7e907cSAndroid Build Coastguard Worker * @return mqDesc FMQ descriptor. The descriptor can be used to 63*4d7e907cSAndroid Build Coastguard Worker * send/receive FMQ messages. 64*4d7e907cSAndroid Build Coastguard Worker */ 65*4d7e907cSAndroid Build Coastguard Worker connect() 66*4d7e907cSAndroid Build Coastguard Worker generates (ResultStatus status, IConnection connection, 67*4d7e907cSAndroid Build Coastguard Worker int64_t connectionId, fmq_sync<BufferStatusMessage> mqDesc); 68*4d7e907cSAndroid Build Coastguard Worker}; 69