/*
*/
/*
* drm_bufs.h -- Generic buffer template -*- linux-c -*-
* Created: Thu Nov 23 03:10:50 2000 by gareth@valinux.com
*/
/*
* Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors:
* Rickard E. (Rik) Faith <faith@valinux.com>
* Gareth Hughes <gareth@valinux.com>
*
*/
#include "drmP.h"
#ifdef __x86
#include <gfx_private.h>
#endif
#include "drm_io32.h"
/*
* Compute order. Can be made faster.
*/
int
{
int order = 0;
while (tmp >>= 1)
order ++;
++order;
return (order);
}
static inline drm_local_map_t *
{
return (map);
}
return (NULL);
}
{
#ifdef __x86
#endif
int retval;
/*
* Only allow shared memory to be removable since we only keep
* enough book keeping information about shared memory to allow
* for removal when processes fork.
*/
return (EINVAL);
return (EINVAL);
return (EINVAL);
/*
* Check if this is just another version of a kernel-allocated
* map, and just hand that back if so.
*/
goto done;
}
/*
* Allocate a new map structure, fill it in, and do any
* type-specific initialization necessary.
*/
if (!map)
return (ENOMEM);
case _DRM_REGISTERS:
case _DRM_FRAME_BUFFER:
if (retval)
return (retval);
break;
case _DRM_SHM:
/*
* ddi_umem_alloc() grants page-aligned memory. We needn't
* handle alignment issue here.
*/
DRM_ERROR("drm_addmap: ddi_umem_alloc failed");
return (ENOMEM);
}
/*
* record only low 32-bit of this handle, since 32-bit
* user app is incapable of passing in 64bit offset when
* doing mmap.
*/
/* Prevent a 2nd X Server from creating a 2nd lock */
return (EBUSY);
}
}
break;
case _DRM_SCATTER_GATHER:
return (EINVAL);
}
break;
case _DRM_CONSISTENT:
return (ENOTSUP);
#ifdef __x86
case _DRM_AGP:
if (kva == 0) {
"drm_addmap: failed to map AGP aperture");
return (ENOMEM);
}
break;
#endif
default:
return (EINVAL);
}
done:
/* Jumped to, with lock held, when a kernel map is found. */
return (0);
}
/*ARGSUSED*/
int
{
int err;
#ifdef _MULTI_DATAMODEL
} else
#endif
if (err != 0)
return (err);
#ifdef _MULTI_DATAMODEL
DRM_COPYTO_WITH_RETURN((void *)data,
} else
#endif
DRM_COPYTO_WITH_RETURN((void *)data,
return (0);
}
void
{
case _DRM_REGISTERS:
break;
/* FALLTHROUGH */
case _DRM_FRAME_BUFFER:
break;
case _DRM_SHM:
break;
#ifdef __x86
case _DRM_AGP:
/*
* we mapped AGP aperture into kernel space in drm_addmap,
* here, unmap them and release kernel virtual address space
*/
break;
case _DRM_SCATTER_GATHER:
break;
#endif /* sparc */
case _DRM_CONSISTENT:
break;
default:
break;
}
}
/*
* Remove a map private from list and deallocate resources if the
* mapping isn't in use.
*/
/*ARGSUSED*/
int
{
#ifdef _MULTI_DATAMODEL
(void *)data, sizeof (drm_map_32_t));
} else
#endif
DRM_LOCK();
break;
}
/* No match found. */
DRM_UNLOCK();
return (EINVAL);
}
DRM_UNLOCK();
return (0);
}
/*ARGSUSED*/
static void
{
int i;
"drm_cleanup_buf_error: not implemented");
}
}
}
}
}
}
}
/*ARGSUSED*/
int
{
DRM_DEBUG("drm_markbufs");
return (EINVAL);
}
/*ARGSUSED*/
int
{
DRM_DEBUG("drm_infobufs");
return (EINVAL);
}
static int
{
unsigned long offset;
unsigned long agp_offset;
int count;
int order;
int size;
int alignment;
int page_order;
int byte_count;
int i;
if (!dma)
return (EINVAL);
byte_count = 0;
/* No more than one allocation per order */
return (ENOMEM);
}
return (ENOMEM);
}
offset = 0;
/* Set count correctly so we free the proper amount. */
return (ENOMEM);
}
}
if (temp_buflist == NULL) {
/* Free the entry because it isn't valid */
DRM_ERROR(" temp_buflist is NULL");
return (ENOMEM);
}
}
return (0);
}
static int
{
unsigned long offset;
unsigned long agp_offset;
int count;
int order;
int size;
int alignment;
int page_order;
int byte_count;
int i;
byte_count = 0;
return (ENOMEM);
offset = 0;
/* Set count correctly so we free the proper amount. */
return (ENOMEM);
}
}
if (!temp_buflist) {
return (ENOMEM);
}
}
return (0);
}
int
{
return (EINVAL);
}
return (EINVAL);
}
/* No more allocations after first buffer-using ioctl. */
return (EBUSY);
}
/* No more than one allocation per order */
return (ENOMEM);
}
return (ret);
}
int
{
return (EINVAL);
}
return (EINVAL);
}
/* No more allocations after first buffer-using ioctl. */
return (EBUSY);
}
/* No more than one allocation per order */
return (ENOMEM);
}
return (ret);
}
/*ARGSUSED*/
int
{
#ifdef _MULTI_DATAMODEL
} else
#endif
#ifdef _MULTI_DATAMODEL
DRM_COPYTO_WITH_RETURN((void *)data,
} else
#endif
DRM_COPYTO_WITH_RETURN((void *)data,
return (err);
}
/*ARGSUSED*/
int
{
int i;
int idx;
int retcode = 0;
#ifdef _MULTI_DATAMODEL
} else
#endif
break;
}
DRM_ERROR("drm_freebufs: Index %d (of %d max)\n",
break;
}
"drm_freebufs: process %d not owning the buffer.\n",
break;
}
}
return (retcode);
}
#ifdef _LP64
#else
#if defined(_SYSCALL32_IMPL) || defined(_ILP32)
#else
#error "No define for _LP64, _SYSCALL32_IMPL or _ILP32"
#endif
#endif
/*ARGSUSED*/
int
{
const int zero = 0;
unsigned long vaddr;
unsigned long address;
int ret_tmp;
int i;
#ifdef _MULTI_DATAMODEL
} else
#endif
goto done;
return (EINVAL);
} else {
foff = 0;
}
DRM_ERROR("drm_mapbufs: request.virtual is NULL");
return (EINVAL);
}
#ifdef _MULTI_DATAMODEL
return (EFAULT);
}
return (EFAULT);
}
return (EFAULT);
}
if (ret_tmp)
return (EFAULT);
}
goto done;
}
#endif
return (EFAULT);
}
return (EFAULT);
}
sizeof (zero))) {
return (EFAULT);
}
if (ret_tmp) {
return (EFAULT);
}
}
done:
#ifdef _MULTI_DATAMODEL
DRM_COPYTO_WITH_RETURN((void *)data,
} else {
#endif
DRM_COPYTO_WITH_RETURN((void *)data,
#ifdef _MULTI_DATAMODEL
}
#endif
return (0);
}