1235783Skib/*- 2235783Skib * Copyright (c) 2011 The FreeBSD Foundation 3235783Skib * All rights reserved. 4235783Skib * 5235783Skib * This software was developed by Konstantin Belousov under sponsorship from 6235783Skib * the FreeBSD Foundation. 7235783Skib * 8235783Skib * Redistribution and use in source and binary forms, with or without 9235783Skib * modification, are permitted provided that the following conditions 10235783Skib * are met: 11235783Skib * 1. Redistributions of source code must retain the above copyright 12235783Skib * notice, this list of conditions and the following disclaimer. 13235783Skib * 2. Redistributions in binary form must reproduce the above copyright 14235783Skib * notice, this list of conditions and the following disclaimer in the 15235783Skib * documentation and/or other materials provided with the distribution. 16235783Skib * 17235783Skib * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18235783Skib * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19235783Skib * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20235783Skib * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21235783Skib * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22235783Skib * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23235783Skib * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24235783Skib * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25235783Skib * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26235783Skib * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27235783Skib * SUCH DAMAGE. 28235783Skib * 29235783Skib * $FreeBSD: releng/10.2/sys/dev/drm2/drm_gem_names.h 271816 2014-09-18 20:32:40Z dumbbell $ 30235783Skib * 31235783Skib */ 32235783Skib 33235783Skib#ifndef DRM_GEM_NAMES_H 34235783Skib#define DRM_GEM_NAMES_H 35235783Skib 36235783Skib#include <sys/types.h> 37235783Skib#include <sys/lock.h> 38235783Skib#include <sys/mutex.h> 39235783Skib#include <sys/queue.h> 40235783Skib 41235783Skibstruct drm_gem_name { 42235783Skib uint32_t name; 43235783Skib void *ptr; 44235783Skib LIST_ENTRY(drm_gem_name) link; 45235783Skib}; 46235783Skib 47235783Skibstruct drm_gem_names { 48235783Skib struct mtx lock; 49235783Skib LIST_HEAD(drm_gem_names_head, drm_gem_name) *names_hash; 50235783Skib u_long hash_mask; 51235783Skib struct unrhdr *unr; 52235783Skib}; 53235783Skib 54235783Skibvoid drm_gem_names_init(struct drm_gem_names *names); 55235783Skibvoid drm_gem_names_fini(struct drm_gem_names *names); 56235783Skibuint32_t drm_gem_find_name(struct drm_gem_names *names, void *ptr); 57271816Sdumbbellvoid *drm_gem_find_ptr(struct drm_gem_names *names, uint32_t name); 58235783Skibvoid *drm_gem_name_ref(struct drm_gem_names *names, uint32_t name, 59235783Skib void (*ref)(void *)); 60235783Skibint drm_gem_name_create(struct drm_gem_names *names, void *obj, uint32_t *name); 61235783Skibvoid drm_gem_names_foreach(struct drm_gem_names *names, 62235783Skib int (*f)(uint32_t, void *, void *), void *arg); 63235783Skibvoid *drm_gem_names_remove(struct drm_gem_names *names, uint32_t name); 64235783Skib 65235783Skib#endif 66