/*
*/
/* radeon_mem.c -- Simple GART/fb memory manager for radeon -*- linux-c -*- */
/*
* Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
*
* The Weather Channel (TM) funded Tungsten Graphics to develop the
* initial release of the Radeon 8500 driver under the XFree86 license.
* This notice must be preserved.
*
* 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:
* Keith Whitwell <keith@tungstengraphics.com>
*/
#include "drmP.h"
#include "drm.h"
#include "radeon_drm.h"
#include "radeon_drv.h"
#include "radeon_io32.h"
/*
* Very simple allocator for GART memory, working on a static range
* already mapped into each client's address space.
*/
static struct mem_block *
{
/* Maybe cut off the start of an existing block */
if (!newblock)
goto out;
p = newblock;
}
/* Maybe cut off the end of an existing block */
if (!newblock)
goto out;
}
out:
/* Our block is in the middle */
return (p);
}
static struct mem_block *
{
struct mem_block *p;
}
return (NULL);
}
static struct mem_block *
{
struct mem_block *p;
return (p);
return (NULL);
}
static void
{
/*
* Assumes a single contiguous range. Needs a special filp in
* 'heap' to stop it being subsumed.
*/
drm_free(q, sizeof (*q), DRM_MEM_BUFS);
}
drm_free(p, sizeof (*q), DRM_MEM_BUFS);
}
}
/*
* Initialize. How to check for an uninitialized heap?
*/
static int
{
if (!blocks)
return (ENOMEM);
if (!*heap) {
return (ENOMEM);
}
return (0);
}
/*
* Free all blocks associated with the releasing file.
*/
void
{
struct mem_block *p;
return;
}
/*
* Assumes a single contiguous range. Needs a special filp in
* 'heap' to stop it being subsumed.
*/
drm_free(q, sizeof (*q), DRM_MEM_DRIVER);
}
}
}
/*
* Shutdown.
*/
void
{
struct mem_block *p;
if (!*heap)
return;
struct mem_block *q = p;
p = p->next;
drm_free(q, sizeof (*q), DRM_MEM_DRIVER);
}
}
/* IOCTL HANDLERS */
static struct mem_block **
{
switch (region) {
case RADEON_MEM_REGION_GART:
case RADEON_MEM_REGION_FB:
default:
return (NULL);
}
}
/*ARGSUSED*/
int
{
if (!dev_priv) {
return (EINVAL);
}
#ifdef _MULTI_DATAMODEL
sizeof (alloc32));
} else {
#endif
#ifdef _MULTI_DATAMODEL
}
#endif
return (EFAULT);
/*
* Make things easier on ourselves: all allocations at least
* 4k aligned.
*/
if (!block)
return (ENOMEM);
sizeof (int))) {
DRM_ERROR("copy_to_user\n");
return (EFAULT);
}
return (0);
}
/*ARGSUSED*/
int
{
if (!dev_priv) {
return (EINVAL);
}
return (EFAULT);
if (!block)
return (EFAULT);
return (EPERM);
return (0);
}
/*ARGSUSED*/
int
{
if (!dev_priv) {
return (EINVAL);
}
if (!heap)
return (EFAULT);
if (*heap) {
DRM_ERROR("heap already initialized?");
return (EFAULT);
}
}