From fa6b1d129e7bf8acf41e66c9c665ae9f9c1d5b0d Mon Sep 17 00:00:00 2001 From: Jon Smirl Date: Mon, 27 Sep 2004 19:51:38 +0000 Subject: First check in for DRM that splits core from personality modules --- linux-core/drm_bufs.c | 157 +++++++++++++++++++++++++------------------------- 1 file changed, 79 insertions(+), 78 deletions(-) (limited to 'linux-core/drm_bufs.c') diff --git a/linux-core/drm_bufs.c b/linux-core/drm_bufs.c index 5058a1d3..88ca09ce 100644 --- a/linux-core/drm_bufs.c +++ b/linux-core/drm_bufs.c @@ -45,7 +45,7 @@ * * \todo Can be made faster. */ -int DRM(order)( unsigned long size ) +int drm_order( unsigned long size ) { int order; unsigned long tmp; @@ -58,14 +58,14 @@ int DRM(order)( unsigned long size ) return order; } +EXPORT_SYMBOL(drm_order); -static int permanent_maps = 0; /** * Adjusts the memory offset to its absolute value according to the mapping * type. Adds the map to the map list drm_device::maplist. Adds MTRR's where * applicable and if supported by the kernel. */ -int DRM(initmap)( drm_device_t *dev, unsigned int offset, unsigned int size, int type, int flags ) +int drm_initmap( drm_device_t *dev, unsigned int offset, unsigned int size, int type, int flags ) { drm_map_t *map; drm_map_list_t *list; @@ -78,12 +78,12 @@ int DRM(initmap)( drm_device_t *dev, unsigned int offset, unsigned int size, int if ( offset + size < offset || offset < virt_to_phys(high_memory) ) return -EINVAL; #endif - if ( !(list = DRM(alloc)( sizeof(*list), DRM_MEM_MAPS ))) + if ( !(list = drm_alloc( sizeof(*list), DRM_MEM_MAPS ))) return -ENOMEM; memset(list, 0, sizeof(*list)); - if ( !(map = DRM(alloc)( sizeof(*map), DRM_MEM_MAPS ))) { - DRM(free)(list, sizeof(*list), DRM_MEM_MAPS); + if ( !(map = drm_alloc( sizeof(*map), DRM_MEM_MAPS ))) { + drm_free(list, sizeof(*list), DRM_MEM_MAPS); return -ENOMEM; } @@ -99,7 +99,7 @@ int DRM(initmap)( drm_device_t *dev, unsigned int offset, unsigned int size, int DRM_DEBUG( "initmap offset = 0x%08lx, size = 0x%08lx, type = %d\n", map->offset, map->size, map->type ); - + #ifdef __alpha__ map->offset += dev->hose->mem_space->start; #endif @@ -112,17 +112,18 @@ int DRM(initmap)( drm_device_t *dev, unsigned int offset, unsigned int size, int } if (map->type == _DRM_REGISTERS) - map->handle = DRM(ioremap)( map->offset, map->size, dev ); + map->handle = drm_ioremap( map->offset, map->size, dev ); down(&dev->struct_sem); list_add(&list->head, &dev->maplist->head); up(&dev->struct_sem); - permanent_maps = 1; + dev->fn_tbl->permanent_maps = 1; DRM_DEBUG("finished\n"); return 0; } +EXPORT_SYMBOL(drm_initmap); /** * Ioctl to specify a range of memory that is available for mapping by a non-root process. @@ -137,7 +138,7 @@ int DRM(initmap)( drm_device_t *dev, unsigned int offset, unsigned int size, int * type. Adds the map to the map list drm_device::maplist. Adds MTRR's where * applicable and if supported by the kernel. */ -int DRM(addmap)( struct inode *inode, struct file *filp, +int drm_addmap( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ) { drm_file_t *priv = filp->private_data; @@ -148,12 +149,12 @@ int DRM(addmap)( struct inode *inode, struct file *filp, if ( !(filp->f_mode & 3) ) return -EACCES; /* Require read/write */ - map = DRM(alloc)( sizeof(*map), DRM_MEM_MAPS ); + map = drm_alloc( sizeof(*map), DRM_MEM_MAPS ); if ( !map ) return -ENOMEM; if ( copy_from_user( map, argp, sizeof(*map) ) ) { - DRM(free)( map, sizeof(*map), DRM_MEM_MAPS ); + drm_free( map, sizeof(*map), DRM_MEM_MAPS ); return -EFAULT; } @@ -162,13 +163,13 @@ int DRM(addmap)( struct inode *inode, struct file *filp, * when processes fork. */ if ( (map->flags & _DRM_REMOVABLE) && map->type != _DRM_SHM ) { - DRM(free)( map, sizeof(*map), DRM_MEM_MAPS ); + drm_free( map, sizeof(*map), DRM_MEM_MAPS ); return -EINVAL; } DRM_DEBUG( "offset = 0x%08lx, size = 0x%08lx, type = %d\n", map->offset, map->size, map->type ); if ( (map->offset & (~PAGE_MASK)) || (map->size & (~PAGE_MASK)) ) { - DRM(free)( map, sizeof(*map), DRM_MEM_MAPS ); + drm_free( map, sizeof(*map), DRM_MEM_MAPS ); return -EINVAL; } map->mtrr = -1; @@ -181,7 +182,7 @@ int DRM(addmap)( struct inode *inode, struct file *filp, struct list_head *_list; /* If permanent maps are implemented, maps must match */ - if (permanent_maps) { + if (dev->fn_tbl->permanent_maps) { DRM_DEBUG( "Looking for: offset = 0x%08lx, size = 0x%08lx, type = %d\n", map->offset, map->size, map->type ); list_for_each( _list, &dev->maplist->head ) { @@ -191,7 +192,7 @@ int DRM(addmap)( struct inode *inode, struct file *filp, if ( _entry->map && map->type == _entry->map->type && map->offset == _entry->map->offset ) { _entry->map->size = map->size; - DRM(free)( map, sizeof(*map), DRM_MEM_MAPS ); + drm_free( map, sizeof(*map), DRM_MEM_MAPS ); map = _entry->map; DRM_DEBUG( "Found existing: offset = 0x%08lx, size = 0x%08lx, type = %d\n", map->offset, map->size, map->type ); @@ -204,7 +205,7 @@ int DRM(addmap)( struct inode *inode, struct file *filp, #if !defined(__sparc__) && !defined(__alpha__) && !defined(__ia64__) if ( map->offset + map->size < map->offset || map->offset < virt_to_phys(high_memory) ) { - DRM(free)( map, sizeof(*map), DRM_MEM_MAPS ); + drm_free( map, sizeof(*map), DRM_MEM_MAPS ); return -EINVAL; } #endif @@ -219,16 +220,16 @@ int DRM(addmap)( struct inode *inode, struct file *filp, } } if (map->type == _DRM_REGISTERS) - map->handle = DRM(ioremap)( map->offset, map->size, + map->handle = drm_ioremap( map->offset, map->size, dev ); break; } case _DRM_SHM: map->handle = vmalloc_32(map->size); DRM_DEBUG( "%lu %d %p\n", - map->size, DRM(order)( map->size ), map->handle ); + map->size, drm_order( map->size ), map->handle ); if ( !map->handle ) { - DRM(free)( map, sizeof(*map), DRM_MEM_MAPS ); + drm_free( map, sizeof(*map), DRM_MEM_MAPS ); return -ENOMEM; } map->offset = (unsigned long)map->handle; @@ -236,7 +237,7 @@ int DRM(addmap)( struct inode *inode, struct file *filp, /* Prevent a 2nd X Server from creating a 2nd lock */ if (dev->lock.hw_lock != NULL) { vfree( map->handle ); - DRM(free)( map, sizeof(*map), DRM_MEM_MAPS ); + drm_free( map, sizeof(*map), DRM_MEM_MAPS ); return -EBUSY; } dev->sigdata.lock = @@ -254,20 +255,20 @@ int DRM(addmap)( struct inode *inode, struct file *filp, break; case _DRM_SCATTER_GATHER: if (!dev->sg) { - DRM(free)(map, sizeof(*map), DRM_MEM_MAPS); + drm_free(map, sizeof(*map), DRM_MEM_MAPS); return -EINVAL; } map->offset += dev->sg->handle; break; default: - DRM(free)( map, sizeof(*map), DRM_MEM_MAPS ); + drm_free( map, sizeof(*map), DRM_MEM_MAPS ); return -EINVAL; } - list = DRM(alloc)(sizeof(*list), DRM_MEM_MAPS); + list = drm_alloc(sizeof(*list), DRM_MEM_MAPS); if(!list) { - DRM(free)(map, sizeof(*map), DRM_MEM_MAPS); + drm_free(map, sizeof(*map), DRM_MEM_MAPS); return -EINVAL; } memset(list, 0, sizeof(*list)); @@ -305,7 +306,7 @@ found_it: * * \sa addmap(). */ -int DRM(rmmap)(struct inode *inode, struct file *filp, +int drm_rmmap(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { drm_file_t *priv = filp->private_data; @@ -347,7 +348,7 @@ int DRM(rmmap)(struct inode *inode, struct file *filp, return 0; } list_del(list); - DRM(free)(list, sizeof(*list), DRM_MEM_MAPS); + drm_free(list, sizeof(*list), DRM_MEM_MAPS); for (pt = dev->vmalist, prev = NULL; pt; prev = pt, pt = pt->next) { if (pt->vma->vm_private_data == map) found_maps++; @@ -365,7 +366,7 @@ int DRM(rmmap)(struct inode *inode, struct file *filp, case _DRM_SCATTER_GATHER: break; } - DRM(free)(map, sizeof(*map), DRM_MEM_MAPS); + drm_free(map, sizeof(*map), DRM_MEM_MAPS); } up(&dev->struct_sem); return 0; @@ -379,19 +380,19 @@ int DRM(rmmap)(struct inode *inode, struct file *filp, * * Frees any pages and buffers associated with the given entry. */ -static void DRM(cleanup_buf_error)(drm_device_t *dev, drm_buf_entry_t *entry) +static void drm_cleanup_buf_error(drm_device_t *dev, drm_buf_entry_t *entry) { int i; if (entry->seg_count) { for (i = 0; i < entry->seg_count; i++) { if (entry->seglist[i]) { - DRM(free_pages)(entry->seglist[i], + drm_free_pages(entry->seglist[i], entry->page_order, DRM_MEM_DMA); } } - DRM(free)(entry->seglist, + drm_free(entry->seglist, entry->seg_count * sizeof(*entry->seglist), DRM_MEM_SEGS); @@ -402,12 +403,12 @@ static void DRM(cleanup_buf_error)(drm_device_t *dev, drm_buf_entry_t *entry) if (entry->buf_count) { for (i = 0; i < entry->buf_count; i++) { if (entry->buflist[i].dev_private) { - DRM(free)(entry->buflist[i].dev_private, + drm_free(entry->buflist[i].dev_private, entry->buflist[i].dev_priv_size, DRM_MEM_BUFS); } } - DRM(free)(entry->buflist, + drm_free(entry->buflist, entry->buf_count * sizeof(*entry->buflist), DRM_MEM_BUFS); @@ -430,7 +431,7 @@ static void DRM(cleanup_buf_error)(drm_device_t *dev, drm_buf_entry_t *entry) * reallocates the buffer list of the same size order to accommodate the new * buffers. */ -int DRM(addbufs_agp)( struct inode *inode, struct file *filp, +int drm_addbufs_agp( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ) { drm_file_t *priv = filp->private_data; @@ -459,7 +460,7 @@ int DRM(addbufs_agp)( struct inode *inode, struct file *filp, return -EFAULT; count = request.count; - order = DRM(order)( request.size ); + order = drm_order( request.size ); size = 1 << order; alignment = (request.flags & _DRM_PAGE_ALIGN) @@ -503,7 +504,7 @@ int DRM(addbufs_agp)( struct inode *inode, struct file *filp, return -EINVAL; } - entry->buflist = DRM(alloc)( count * sizeof(*entry->buflist), + entry->buflist = drm_alloc( count * sizeof(*entry->buflist), DRM_MEM_BUFS ); if ( !entry->buflist ) { up( &dev->struct_sem ); @@ -533,13 +534,13 @@ int DRM(addbufs_agp)( struct inode *inode, struct file *filp, init_waitqueue_head( &buf->dma_wait ); buf->filp = NULL; - buf->dev_priv_size = dev->dev_priv_size; - buf->dev_private = DRM(alloc)( buf->dev_priv_size, + buf->dev_priv_size = dev->fn_tbl->dev_priv_size; + buf->dev_private = drm_alloc( buf->dev_priv_size, DRM_MEM_BUFS ); if(!buf->dev_private) { /* Set count correctly so we free the proper amount. */ entry->buf_count = count; - DRM(cleanup_buf_error)(dev,entry); + drm_cleanup_buf_error(dev,entry); up( &dev->struct_sem ); atomic_dec( &dev->buf_alloc ); return -ENOMEM; @@ -556,14 +557,14 @@ int DRM(addbufs_agp)( struct inode *inode, struct file *filp, DRM_DEBUG( "byte_count: %d\n", byte_count ); - temp_buflist = DRM(realloc)( dma->buflist, + temp_buflist = drm_realloc( dma->buflist, dma->buf_count * sizeof(*dma->buflist), (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist), DRM_MEM_BUFS ); if(!temp_buflist) { /* Free the entry because it isn't valid */ - DRM(cleanup_buf_error)(dev,entry); + drm_cleanup_buf_error(dev,entry); up( &dev->struct_sem ); atomic_dec( &dev->buf_alloc ); return -ENOMEM; @@ -595,7 +596,7 @@ int DRM(addbufs_agp)( struct inode *inode, struct file *filp, } #endif /* __OS_HAS_AGP */ -int DRM(addbufs_pci)( struct inode *inode, struct file *filp, +int drm_addbufs_pci( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ) { drm_file_t *priv = filp->private_data; @@ -627,7 +628,7 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp, return -EFAULT; count = request.count; - order = DRM(order)( request.size ); + order = drm_order( request.size ); size = 1 << order; DRM_DEBUG( "count=%d, size=%d (%d), order=%d, queue_count=%d\n", @@ -664,7 +665,7 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp, return -EINVAL; } - entry->buflist = DRM(alloc)( count * sizeof(*entry->buflist), + entry->buflist = drm_alloc( count * sizeof(*entry->buflist), DRM_MEM_BUFS ); if ( !entry->buflist ) { up( &dev->struct_sem ); @@ -673,10 +674,10 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp, } memset( entry->buflist, 0, count * sizeof(*entry->buflist) ); - entry->seglist = DRM(alloc)( count * sizeof(*entry->seglist), + entry->seglist = drm_alloc( count * sizeof(*entry->seglist), DRM_MEM_SEGS ); if ( !entry->seglist ) { - DRM(free)( entry->buflist, + drm_free( entry->buflist, count * sizeof(*entry->buflist), DRM_MEM_BUFS ); up( &dev->struct_sem ); @@ -688,14 +689,14 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp, /* Keep the original pagelist until we know all the allocations * have succeeded */ - temp_pagelist = DRM(alloc)( (dma->page_count + (count << page_order)) + temp_pagelist = drm_alloc( (dma->page_count + (count << page_order)) * sizeof(*dma->pagelist), DRM_MEM_PAGES ); if (!temp_pagelist) { - DRM(free)( entry->buflist, + drm_free( entry->buflist, count * sizeof(*entry->buflist), DRM_MEM_BUFS ); - DRM(free)( entry->seglist, + drm_free( entry->seglist, count * sizeof(*entry->seglist), DRM_MEM_SEGS ); up( &dev->struct_sem ); @@ -714,13 +715,13 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp, page_count = 0; while ( entry->buf_count < count ) { - page = DRM(alloc_pages)( page_order, DRM_MEM_DMA ); + page = drm_alloc_pages( page_order, DRM_MEM_DMA ); if ( !page ) { /* Set count correctly so we free the proper amount. */ entry->buf_count = count; entry->seg_count = count; - DRM(cleanup_buf_error)(dev,entry); - DRM(free)( temp_pagelist, + drm_cleanup_buf_error(dev,entry); + drm_free( temp_pagelist, (dma->page_count + (count << page_order)) * sizeof(*dma->pagelist), DRM_MEM_PAGES ); @@ -753,15 +754,15 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp, init_waitqueue_head( &buf->dma_wait ); buf->filp = NULL; - buf->dev_priv_size = dev->dev_priv_size; - buf->dev_private = DRM(alloc)( dev->dev_priv_size, + buf->dev_priv_size = dev->fn_tbl->dev_priv_size; + buf->dev_private = drm_alloc( dev->fn_tbl->dev_priv_size, DRM_MEM_BUFS ); if(!buf->dev_private) { /* Set count correctly so we free the proper amount. */ entry->buf_count = count; entry->seg_count = count; - DRM(cleanup_buf_error)(dev,entry); - DRM(free)( temp_pagelist, + drm_cleanup_buf_error(dev,entry); + drm_free( temp_pagelist, (dma->page_count + (count << page_order)) * sizeof(*dma->pagelist), DRM_MEM_PAGES ); @@ -777,15 +778,15 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp, byte_count += PAGE_SIZE << page_order; } - temp_buflist = DRM(realloc)( dma->buflist, + temp_buflist = drm_realloc( dma->buflist, dma->buf_count * sizeof(*dma->buflist), (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist), DRM_MEM_BUFS ); if (!temp_buflist) { /* Free the entry because it isn't valid */ - DRM(cleanup_buf_error)(dev,entry); - DRM(free)( temp_pagelist, + drm_cleanup_buf_error(dev,entry); + drm_free( temp_pagelist, (dma->page_count + (count << page_order)) * sizeof(*dma->pagelist), DRM_MEM_PAGES ); @@ -803,7 +804,7 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp, * with the new one. */ if (dma->page_count) { - DRM(free)(dma->pagelist, + drm_free(dma->pagelist, dma->page_count * sizeof(*dma->pagelist), DRM_MEM_PAGES); } @@ -827,7 +828,7 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp, } -int DRM(addbufs_sg)( struct inode *inode, struct file *filp, +int drm_addbufs_sg( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ) { drm_file_t *priv = filp->private_data; @@ -857,7 +858,7 @@ int DRM(addbufs_sg)( struct inode *inode, struct file *filp, return -EFAULT; count = request.count; - order = DRM(order)( request.size ); + order = drm_order( request.size ); size = 1 << order; alignment = (request.flags & _DRM_PAGE_ALIGN) @@ -901,7 +902,7 @@ int DRM(addbufs_sg)( struct inode *inode, struct file *filp, return -EINVAL; } - entry->buflist = DRM(alloc)( count * sizeof(*entry->buflist), + entry->buflist = drm_alloc( count * sizeof(*entry->buflist), DRM_MEM_BUFS ); if ( !entry->buflist ) { up( &dev->struct_sem ); @@ -931,13 +932,13 @@ int DRM(addbufs_sg)( struct inode *inode, struct file *filp, init_waitqueue_head( &buf->dma_wait ); buf->filp = NULL; - buf->dev_priv_size = dev->dev_priv_size; - buf->dev_private = DRM(alloc)( dev->dev_priv_size, + buf->dev_priv_size = dev->fn_tbl->dev_priv_size; + buf->dev_private = drm_alloc( dev->fn_tbl->dev_priv_size, DRM_MEM_BUFS ); if(!buf->dev_private) { /* Set count correctly so we free the proper amount. */ entry->buf_count = count; - DRM(cleanup_buf_error)(dev,entry); + drm_cleanup_buf_error(dev,entry); up( &dev->struct_sem ); atomic_dec( &dev->buf_alloc ); return -ENOMEM; @@ -955,14 +956,14 @@ int DRM(addbufs_sg)( struct inode *inode, struct file *filp, DRM_DEBUG( "byte_count: %d\n", byte_count ); - temp_buflist = DRM(realloc)( dma->buflist, + temp_buflist = drm_realloc( dma->buflist, dma->buf_count * sizeof(*dma->buflist), (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist), DRM_MEM_BUFS ); if(!temp_buflist) { /* Free the entry because it isn't valid */ - DRM(cleanup_buf_error)(dev,entry); + drm_cleanup_buf_error(dev,entry); up( &dev->struct_sem ); atomic_dec( &dev->buf_alloc ); return -ENOMEM; @@ -1007,7 +1008,7 @@ int DRM(addbufs_sg)( struct inode *inode, struct file *filp, * addbufs_sg() or addbufs_pci() for AGP, scatter-gather or consistent * PCI memory respectively. */ -int DRM(addbufs)( struct inode *inode, struct file *filp, +int drm_addbufs( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ) { drm_buf_desc_t request; @@ -1023,13 +1024,13 @@ int DRM(addbufs)( struct inode *inode, struct file *filp, #if __OS_HAS_AGP if ( request.flags & _DRM_AGP_BUFFER ) - return DRM(addbufs_agp)( inode, filp, cmd, arg ); + return drm_addbufs_agp( inode, filp, cmd, arg ); else #endif if ( request.flags & _DRM_SG_BUFFER ) - return DRM(addbufs_sg)( inode, filp, cmd, arg ); + return drm_addbufs_sg( inode, filp, cmd, arg ); else - return DRM(addbufs_pci)( inode, filp, cmd, arg ); + return drm_addbufs_pci( inode, filp, cmd, arg ); } @@ -1050,7 +1051,7 @@ int DRM(addbufs)( struct inode *inode, struct file *filp, * lock, preventing of allocating more buffers after this call. Information * about each requested buffer is then copied into user space. */ -int DRM(infobufs)( struct inode *inode, struct file *filp, +int drm_infobufs( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ) { drm_file_t *priv = filp->private_data; @@ -1135,7 +1136,7 @@ int DRM(infobufs)( struct inode *inode, struct file *filp, * * \note This ioctl is deprecated and mostly never used. */ -int DRM(markbufs)( struct inode *inode, struct file *filp, +int drm_markbufs( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ) { drm_file_t *priv = filp->private_data; @@ -1157,7 +1158,7 @@ int DRM(markbufs)( struct inode *inode, struct file *filp, DRM_DEBUG( "%d, %d, %d\n", request.size, request.low_mark, request.high_mark ); - order = DRM(order)( request.size ); + order = drm_order( request.size ); if ( order < DRM_MIN_ORDER || order > DRM_MAX_ORDER ) return -EINVAL; entry = &dma->bufs[order]; @@ -1184,7 +1185,7 @@ int DRM(markbufs)( struct inode *inode, struct file *filp, * Calls free_buffer() for each used buffer. * This function is primarily used for debugging. */ -int DRM(freebufs)( struct inode *inode, struct file *filp, +int drm_freebufs( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ) { drm_file_t *priv = filp->private_data; @@ -1222,7 +1223,7 @@ int DRM(freebufs)( struct inode *inode, struct file *filp, current->pid ); return -EINVAL; } - DRM(free_buffer)( dev, buf ); + drm_free_buffer( dev, buf ); } return 0; @@ -1241,7 +1242,7 @@ int DRM(freebufs)( struct inode *inode, struct file *filp, * about each buffer into user space. The PCI buffers are already mapped on the * addbufs_pci() call. */ -int DRM(mapbufs)( struct inode *inode, struct file *filp, +int drm_mapbufs( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ) { drm_file_t *priv = filp->private_data; -- cgit v1.2.3