#include <sys/cdefs.h>
#include <dev/drm2/drmP.h>
#define vunmap(handle)
#if __OS_HAS_AGP
static void *agp_remap(unsigned long offset, unsigned long size,
struct drm_device * dev)
{
return NULL;
}
void drm_free_agp(DRM_AGP_MEM * handle, int pages)
{
device_t agpdev;
agpdev = agp_find_device();
if (!agpdev || !handle)
return;
agp_free_memory(agpdev, handle);
}
EXPORT_SYMBOL(drm_free_agp);
int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start)
{
device_t agpdev;
agpdev = agp_find_device();
if (!agpdev || !handle)
return -EINVAL;
return -agp_bind_memory(agpdev, handle, start * PAGE_SIZE);
}
int drm_unbind_agp(DRM_AGP_MEM * handle)
{
device_t agpdev;
agpdev = agp_find_device();
if (!agpdev || !handle)
return -EINVAL;
return -agp_unbind_memory(agpdev, handle);
}
EXPORT_SYMBOL(drm_unbind_agp);
#else
static inline void *agp_remap(unsigned long offset, unsigned long size,
struct drm_device * dev)
{
return NULL;
}
#endif
void drm_core_ioremap(struct drm_local_map *map, struct drm_device *dev)
{
if (drm_core_has_AGP(dev) &&
dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP)
map->handle = agp_remap(map->offset, map->size, dev);
else
map->handle = pmap_mapdev(map->offset, map->size);
}
EXPORT_SYMBOL(drm_core_ioremap);
void drm_core_ioremap_wc(struct drm_local_map *map, struct drm_device *dev)
{
if (drm_core_has_AGP(dev) &&
dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP)
map->handle = agp_remap(map->offset, map->size, dev);
else
map->handle = pmap_mapdev_attr(map->offset, map->size,
VM_MEMATTR_WRITE_COMBINING);
}
EXPORT_SYMBOL(drm_core_ioremap_wc);
void drm_core_ioremapfree(struct drm_local_map *map, struct drm_device *dev)
{
if (!map->handle || !map->size)
return;
if (drm_core_has_AGP(dev) &&
dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP)
vunmap(map->handle);
else
pmap_unmapdev(map->handle, map->size);
}
EXPORT_SYMBOL(drm_core_ioremapfree);