/*1* Copyright (C) 2021 Alyssa Rosenzweig <[email protected]>2* © Copyright 2019 Collabora, Ltd.3*4* Permission is hereby granted, free of charge, to any person obtaining a5* copy of this software and associated documentation files (the "Software"),6* to deal in the Software without restriction, including without limitation7* the rights to use, copy, modify, merge, publish, distribute, sublicense,8* and/or sell copies of the Software, and to permit persons to whom the9* Software is furnished to do so, subject to the following conditions:10*11* The above copyright notice and this permission notice (including the next12* paragraph) shall be included in all copies or substantial portions of the13* Software.14*15* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR16* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,17* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL18* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER19* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,20* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE21* SOFTWARE.22*/2324#ifndef __AGX_BO_H25#define __AGX_BO_H2627#include <stdbool.h>28#include <stddef.h>29#include <stdint.h>3031struct agx_device;3233enum agx_alloc_type {34AGX_ALLOC_REGULAR = 0,35AGX_ALLOC_MEMMAP = 1,36AGX_ALLOC_CMDBUF = 2,37AGX_NUM_ALLOC,38};3940struct agx_ptr {41/* If CPU mapped, CPU address. NULL if not mapped */42void *cpu;4344/* If type REGULAR, mapped GPU address */45uint64_t gpu;46};4748struct agx_bo {49enum agx_alloc_type type;5051/* Creation attributes */52unsigned flags;53size_t size;5455/* Mapping */56struct agx_ptr ptr;5758/* Index unique only up to type, process-local */59uint32_t handle;6061/* Globally unique value (system wide) for tracing. Exists for resources,62* command buffers, GPU submissions, segments, segmentent lists, encoders,63* accelerators, and channels. Corresponds to Instruments' magic table64* metal-gpu-submission-to-command-buffer-id */65uint64_t guid;6667/* Human-readable label, or NULL if none */68char *name;6970/* Owner */71struct agx_device *dev;7273/* Update atomically */74int32_t refcnt;7576/* Used while decoding, marked read-only */77bool ro;7879/* Used while decoding, mapped */80bool mapped;81};8283struct agx_bo *84agx_bo_create(struct agx_device *dev, unsigned size, unsigned flags);8586void agx_bo_reference(struct agx_bo *bo);87void agx_bo_unreference(struct agx_bo *bo);8889#endif909192