/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.hidl.memory@1.0;

interface IMemory {

    /**
     * Notify that you are about to use all of this memory.
     */
    update();

    /**
     * Notify that you are about to use the specific range.
     *
     * start + length must be < size
     *
     * @param start Offset from start of buffer about to be updated.
     * @param length Number of bytes to be updated.
     */
    updateRange(uint64_t start, uint64_t length);

    /**
     * Notify that you are about to start reading all of this memory.
     */
    read();

    /**
     * Notify that you are about to read the specific range.
     *
     * @param start Offset from start of buffer about to be read.
     * @param length Number of bytes to be read.
     */
    readRange(uint64_t start, uint64_t length);

    /**
     * Notify that you are done reading and/or writing this memory.
     *
     * Must commit all previous update's and updateAll's.
     */
    commit();

    /**
     * Must return the same value everytime it is called. Must be callable
     * at any point in or outside of the update/commit process.
     *
     * @return ptr Actual pointer to underlying memory.
     */
    getPointer() generates (pointer ptr);

    /**
     * @return size Size in bytes of underlying memory.
     */
    getSize() generates (uint64_t size);

};