1/* 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 17package android.hardware.neuralnetworks@1.3; 18 19import ErrorStatus; 20 21/** 22 * This interface represents a device memory buffer. 23 */ 24interface IBuffer { 25 /** 26 * Retrieves the content of this buffer to a shared memory region. 27 * 28 * The IBuffer object must have been initialized before the call to IBuffer::copyTo. 29 * For more information on the state of the IBuffer object, refer to IDevice::allocate. 30 * 31 * @param dst The destination shared memory region. 32 * @return status Error status of the call, must be: 33 * - NONE if successful 34 * - DEVICE_UNAVAILABLE if driver is offline or busy 35 * - GENERAL_FAILURE if the IBuffer object is uninitialized, or there is an unspecified 36 * error 37 * - INVALID_ARGUMENT if provided memory is invalid 38 */ 39 copyTo(memory dst) generates (ErrorStatus status); 40 41 /** 42 * Sets the content of this buffer from a shared memory region. 43 * 44 * @param src The source shared memory region. 45 * @param dimensions Updated dimensional information. If the dimensions of the IBuffer object 46 * are not fully specified, then the dimensions must be fully specified here. If the 47 * dimensions of the IBuffer object are fully specified, then the dimensions may be empty 48 * here. If dimensions.size() > 0, then all dimensions must be specified here, and any 49 * dimension that was specified in the IBuffer object must have the same value here. 50 * @return status Error status of the call, must be: 51 * - NONE if successful 52 * - DEVICE_UNAVAILABLE if driver is offline or busy 53 * - GENERAL_FAILURE if there is an unspecified error 54 * - INVALID_ARGUMENT if provided memory is invalid, or if the dimensions is invalid 55 */ 56 copyFrom(memory src, vec<uint32_t> dimensions) generates (ErrorStatus status); 57}; 58