FreeBSD/sys/dev/drm2/drm_agpsupport.c
/**
 * Allocate AGP memory.
 *
 * \param inode device inode.
 * \param file_priv file private pointer.
 * \param cmd command.
 * \param arg pointer to a drm_agp_buffer structure.
 * \return zero on success or a negative number on failure.
 *
 * Verifies the AGP device is present and has been acquired, allocates the
 * memory via agp_allocate_memory() and creates a drm_agp_mem entry for it.
 */
Allocate AGP memory.
\param inode device inode.
\param file_priv file private pointer.
\param cmd command.
\param arg pointer to a drm_agp_buffer structure.
\return zero on success or a negative number on failure.

Verifies the AGP device is present and has been acquired, allocates the
memory via agp_allocate_memory() and creates a drm_agp_mem entry for it.
Allocate AGP memory . \ param inode device inode . \ param file_priv file private pointer . \ param cmd command . \ param arg pointer to a drm_agp_buffer structure . \ return zero on success or a negative number on failure . Verifies the AGP device is present and has been acquired allocates the memory via agp_allocate_memory () and creates a drm_agp_mem entry for it .
int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request)
{
	struct drm_agp_mem *entry;
	DRM_AGP_MEM *memory;
	unsigned long pages;
	u32 type;
	struct agp_memory_info info;
	if (!dev->agp || !dev->agp->acquired)
		return -EINVAL;
	if (!(entry = malloc(sizeof(*entry), DRM_MEM_AGPLISTS, M_NOWAIT)))
		return -ENOMEM;
	memset(entry, 0, sizeof(*entry));
	pages = (request->size + PAGE_SIZE - 1) / PAGE_SIZE;
	type = (u32) request->type;
	if (!(memory = agp_alloc_memory(dev->agp->bridge, type, pages << PAGE_SHIFT))) {
		free(entry, DRM_MEM_AGPLISTS);
		return -ENOMEM;
	}
	entry->handle = (unsigned long)memory;
	entry->memory = memory;
	entry->bound = 0;
	entry->pages = pages;
	list_add(&entry->head, &dev->agp->memory);
	agp_memory_info(dev->agp->bridge, entry->memory, &info);
	request->handle = entry->handle;
	request->physical = info.ami_physical;
	return 0;
}
int drm_agp_alloc ( struct drm_device * dev , struct drm_agp_buffer * request ) { struct drm_agp_mem * entry ; DRM_AGP_MEM * memory ; unsigned long pages ; u32 type ; struct agp_memory_info info ; if ( ! dev -> agp || ! dev -> agp -> acquired ) return - EINVAL ; if ( ! ( entry = malloc ( sizeof ( * entry ) , DRM_MEM_AGPLISTS , M_NOWAIT ) ) ) return - ENOMEM ; memset ( entry , 0 , sizeof ( * entry ) ) ; pages = ( request -> size + PAGE_SIZE - 1 ) / PAGE_SIZE ; type = ( u32 ) request -> type ; if ( ! ( memory = agp_alloc_memory ( dev -> agp -> bridge , type , pages << PAGE_SHIFT ) ) ) { free ( entry , DRM_MEM_AGPLISTS ) ; return - ENOMEM ; } entry -> handle = ( unsigned long ) memory ; entry -> memory = memory ; entry -> bound = 0 ; entry -> pages = pages ; list_add ( & entry -> head , & dev -> agp -> memory ) ; agp_memory_info ( dev -> agp -> bridge , entry -> memory , & info ) ; request -> handle = entry -> handle ; request -> physical = info . ami_physical ; return 0 ; }
Allocate AGP memory.
Allocate AGP memory .