Commit 0e5780b2 authored by David Airlie's avatar David Airlie

Merge bkbits.net:/repos/l/linux/linux-2.5

into bkbits.net:/repos/d/drm/drm-2.6
parents eb5a1b89 a13c13a2
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
# Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher. # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
# #
config DRM config DRM
bool "Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)" tristate "Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)"
depends on AGP || AGP=n
help help
Kernel-level support for the Direct Rendering Infrastructure (DRI) Kernel-level support for the Direct Rendering Infrastructure (DRI)
introduced in XFree86 4.0. If you say Y here, you need to select introduced in XFree86 4.0. If you say Y here, you need to select
......
...@@ -2,6 +2,11 @@ ...@@ -2,6 +2,11 @@
# Makefile for the drm device driver. This driver provides support for the # Makefile for the drm device driver. This driver provides support for the
# Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher. # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
drm-objs := drm_auth.o drm_bufs.o drm_context.o drm_dma.o drm_drawable.o \
drm_drv.o drm_fops.o drm_init.o drm_ioctl.o drm_irq.o \
drm_lock.o drm_memory.o drm_proc.o drm_stub.o drm_vm.o \
drm_agpsupport.o drm_scatter.o ati_pcigart.o
gamma-objs := gamma_drv.o gamma_dma.o gamma-objs := gamma_drv.o gamma_dma.o
tdfx-objs := tdfx_drv.o tdfx-objs := tdfx_drv.o
r128-objs := r128_drv.o r128_cce.o r128_state.o r128_irq.o r128-objs := r128_drv.o r128_cce.o r128_state.o r128_irq.o
...@@ -13,6 +18,7 @@ radeon-objs := radeon_drv.o radeon_cp.o radeon_state.o radeon_mem.o radeon_irq.o ...@@ -13,6 +18,7 @@ radeon-objs := radeon_drv.o radeon_cp.o radeon_state.o radeon_mem.o radeon_irq.o
ffb-objs := ffb_drv.o ffb_context.o ffb-objs := ffb_drv.o ffb_context.o
sis-objs := sis_drv.o sis_ds.o sis_mm.o sis-objs := sis_drv.o sis_ds.o sis_mm.o
obj-$(CONFIG_DRM) += drm.o
obj-$(CONFIG_DRM_GAMMA) += gamma.o obj-$(CONFIG_DRM_GAMMA) += gamma.o
obj-$(CONFIG_DRM_TDFX) += tdfx.o obj-$(CONFIG_DRM_TDFX) += tdfx.o
obj-$(CONFIG_DRM_R128) += r128.o obj-$(CONFIG_DRM_R128) += r128.o
......
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
# define ATI_MAX_PCIGART_PAGES 8192 /**< 32 MB aperture, 4K pages */ # define ATI_MAX_PCIGART_PAGES 8192 /**< 32 MB aperture, 4K pages */
# define ATI_PCIGART_PAGE_SIZE 4096 /**< PCI GART page size */ # define ATI_PCIGART_PAGE_SIZE 4096 /**< PCI GART page size */
static unsigned long DRM(ati_alloc_pcigart_table)( void ) unsigned long drm_ati_alloc_pcigart_table( void )
{ {
unsigned long address; unsigned long address;
struct page *page; struct page *page;
...@@ -75,7 +75,7 @@ static unsigned long DRM(ati_alloc_pcigart_table)( void ) ...@@ -75,7 +75,7 @@ static unsigned long DRM(ati_alloc_pcigart_table)( void )
return address; return address;
} }
static void DRM(ati_free_pcigart_table)( unsigned long address ) static void drm_ati_free_pcigart_table( unsigned long address )
{ {
struct page *page; struct page *page;
int i; int i;
...@@ -91,7 +91,44 @@ static void DRM(ati_free_pcigart_table)( unsigned long address ) ...@@ -91,7 +91,44 @@ static void DRM(ati_free_pcigart_table)( unsigned long address )
free_pages( address, ATI_PCIGART_TABLE_ORDER ); free_pages( address, ATI_PCIGART_TABLE_ORDER );
} }
int DRM(ati_pcigart_init)( drm_device_t *dev, int drm_ati_pcigart_cleanup( drm_device_t *dev,
unsigned long addr,
dma_addr_t bus_addr)
{
drm_sg_mem_t *entry = dev->sg;
unsigned long pages;
int i;
/* we need to support large memory configurations */
if ( !entry ) {
DRM_ERROR( "no scatter/gather memory!\n" );
return 0;
}
if ( bus_addr ) {
pci_unmap_single(dev->pdev, bus_addr,
ATI_PCIGART_TABLE_PAGES * PAGE_SIZE,
PCI_DMA_TODEVICE);
pages = ( entry->pages <= ATI_MAX_PCIGART_PAGES )
? entry->pages : ATI_MAX_PCIGART_PAGES;
for ( i = 0 ; i < pages ; i++ ) {
if ( !entry->busaddr[i] ) break;
pci_unmap_single(dev->pdev, entry->busaddr[i],
PAGE_SIZE, PCI_DMA_TODEVICE);
}
}
if ( addr ) {
drm_ati_free_pcigart_table( addr );
}
return 1;
}
EXPORT_SYMBOL(drm_ati_pcigart_cleanup);
int drm_ati_pcigart_init( drm_device_t *dev,
unsigned long *addr, unsigned long *addr,
dma_addr_t *bus_addr) dma_addr_t *bus_addr)
{ {
...@@ -106,7 +143,7 @@ int DRM(ati_pcigart_init)( drm_device_t *dev, ...@@ -106,7 +143,7 @@ int DRM(ati_pcigart_init)( drm_device_t *dev,
goto done; goto done;
} }
address = DRM(ati_alloc_pcigart_table)(); address = drm_ati_alloc_pcigart_table();
if ( !address ) { if ( !address ) {
DRM_ERROR( "cannot allocate PCI GART page!\n" ); DRM_ERROR( "cannot allocate PCI GART page!\n" );
goto done; goto done;
...@@ -122,7 +159,7 @@ int DRM(ati_pcigart_init)( drm_device_t *dev, ...@@ -122,7 +159,7 @@ int DRM(ati_pcigart_init)( drm_device_t *dev,
PCI_DMA_TODEVICE); PCI_DMA_TODEVICE);
if (bus_address == 0) { if (bus_address == 0) {
DRM_ERROR( "unable to map PCIGART pages!\n" ); DRM_ERROR( "unable to map PCIGART pages!\n" );
DRM(ati_free_pcigart_table)( address ); drm_ati_free_pcigart_table( address );
address = 0; address = 0;
goto done; goto done;
} }
...@@ -142,7 +179,7 @@ int DRM(ati_pcigart_init)( drm_device_t *dev, ...@@ -142,7 +179,7 @@ int DRM(ati_pcigart_init)( drm_device_t *dev,
PCI_DMA_TODEVICE); PCI_DMA_TODEVICE);
if (entry->busaddr[i] == 0) { if (entry->busaddr[i] == 0) {
DRM_ERROR( "unable to map PCIGART pages!\n" ); DRM_ERROR( "unable to map PCIGART pages!\n" );
DRM(ati_pcigart_cleanup)( dev, address, bus_address ); drm_ati_pcigart_cleanup( dev, address, bus_address );
address = 0; address = 0;
bus_address = 0; bus_address = 0;
goto done; goto done;
...@@ -168,39 +205,4 @@ int DRM(ati_pcigart_init)( drm_device_t *dev, ...@@ -168,39 +205,4 @@ int DRM(ati_pcigart_init)( drm_device_t *dev,
*bus_addr = bus_address; *bus_addr = bus_address;
return ret; return ret;
} }
EXPORT_SYMBOL(drm_ati_pcigart_init);
int DRM(ati_pcigart_cleanup)( drm_device_t *dev,
unsigned long addr,
dma_addr_t bus_addr)
{
drm_sg_mem_t *entry = dev->sg;
unsigned long pages;
int i;
/* we need to support large memory configurations */
if ( !entry ) {
DRM_ERROR( "no scatter/gather memory!\n" );
return 0;
}
if ( bus_addr ) {
pci_unmap_single(dev->pdev, bus_addr,
ATI_PCIGART_TABLE_PAGES * PAGE_SIZE,
PCI_DMA_TODEVICE);
pages = ( entry->pages <= ATI_MAX_PCIGART_PAGES )
? entry->pages : ATI_MAX_PCIGART_PAGES;
for ( i = 0 ; i < pages ; i++ ) {
if ( !entry->busaddr[i] ) break;
pci_unmap_single(dev->pdev, entry->busaddr[i],
PAGE_SIZE, PCI_DMA_TODEVICE);
}
}
if ( addr ) {
DRM(ati_free_pcigart_table)( addr );
}
return 1;
}
This diff is collapsed.
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
* The key is the modulus of the hash table size, #DRM_HASH_SIZE, which must be * The key is the modulus of the hash table size, #DRM_HASH_SIZE, which must be
* a power of 2. * a power of 2.
*/ */
static int DRM(hash_magic)(drm_magic_t magic) static int drm_hash_magic(drm_magic_t magic)
{ {
return magic & (DRM_HASH_SIZE-1); return magic & (DRM_HASH_SIZE-1);
} }
...@@ -59,11 +59,11 @@ static int DRM(hash_magic)(drm_magic_t magic) ...@@ -59,11 +59,11 @@ static int DRM(hash_magic)(drm_magic_t magic)
* the one with matching magic number, while holding the drm_device::struct_sem * the one with matching magic number, while holding the drm_device::struct_sem
* lock. * lock.
*/ */
static drm_file_t *DRM(find_file)(drm_device_t *dev, drm_magic_t magic) static drm_file_t *drm_find_file(drm_device_t *dev, drm_magic_t magic)
{ {
drm_file_t *retval = NULL; drm_file_t *retval = NULL;
drm_magic_entry_t *pt; drm_magic_entry_t *pt;
int hash = DRM(hash_magic)(magic); int hash = drm_hash_magic(magic);
down(&dev->struct_sem); down(&dev->struct_sem);
for (pt = dev->magiclist[hash].head; pt; pt = pt->next) { for (pt = dev->magiclist[hash].head; pt; pt = pt->next) {
...@@ -87,15 +87,15 @@ static drm_file_t *DRM(find_file)(drm_device_t *dev, drm_magic_t magic) ...@@ -87,15 +87,15 @@ static drm_file_t *DRM(find_file)(drm_device_t *dev, drm_magic_t magic)
* associated the magic number hash key in drm_device::magiclist, while holding * associated the magic number hash key in drm_device::magiclist, while holding
* the drm_device::struct_sem lock. * the drm_device::struct_sem lock.
*/ */
int DRM(add_magic)(drm_device_t *dev, drm_file_t *priv, drm_magic_t magic) int drm_add_magic(drm_device_t *dev, drm_file_t *priv, drm_magic_t magic)
{ {
int hash; int hash;
drm_magic_entry_t *entry; drm_magic_entry_t *entry;
DRM_DEBUG("%d\n", magic); DRM_DEBUG("%d\n", magic);
hash = DRM(hash_magic)(magic); hash = drm_hash_magic(magic);
entry = DRM(alloc)(sizeof(*entry), DRM_MEM_MAGIC); entry = drm_alloc(sizeof(*entry), DRM_MEM_MAGIC);
if (!entry) return -ENOMEM; if (!entry) return -ENOMEM;
memset(entry, 0, sizeof(*entry)); memset(entry, 0, sizeof(*entry));
entry->magic = magic; entry->magic = magic;
...@@ -124,7 +124,7 @@ int DRM(add_magic)(drm_device_t *dev, drm_file_t *priv, drm_magic_t magic) ...@@ -124,7 +124,7 @@ int DRM(add_magic)(drm_device_t *dev, drm_file_t *priv, drm_magic_t magic)
* Searches and unlinks the entry in drm_device::magiclist with the magic * Searches and unlinks the entry in drm_device::magiclist with the magic
* number hash key, while holding the drm_device::struct_sem lock. * number hash key, while holding the drm_device::struct_sem lock.
*/ */
int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic) int drm_remove_magic(drm_device_t *dev, drm_magic_t magic)
{ {
drm_magic_entry_t *prev = NULL; drm_magic_entry_t *prev = NULL;
drm_magic_entry_t *pt; drm_magic_entry_t *pt;
...@@ -132,7 +132,7 @@ int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic) ...@@ -132,7 +132,7 @@ int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic)
DRM_DEBUG("%d\n", magic); DRM_DEBUG("%d\n", magic);
hash = DRM(hash_magic)(magic); hash = drm_hash_magic(magic);
down(&dev->struct_sem); down(&dev->struct_sem);
for (pt = dev->magiclist[hash].head; pt; prev = pt, pt = pt->next) { for (pt = dev->magiclist[hash].head; pt; prev = pt, pt = pt->next) {
...@@ -152,7 +152,7 @@ int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic) ...@@ -152,7 +152,7 @@ int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic)
} }
up(&dev->struct_sem); up(&dev->struct_sem);
DRM(free)(pt, sizeof(*pt), DRM_MEM_MAGIC); drm_free(pt, sizeof(*pt), DRM_MEM_MAGIC);
return -EINVAL; return -EINVAL;
} }
...@@ -170,7 +170,7 @@ int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic) ...@@ -170,7 +170,7 @@ int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic)
* searches an unique non-zero magic number and add it associating it with \p * searches an unique non-zero magic number and add it associating it with \p
* filp. * filp.
*/ */
int DRM(getmagic)(struct inode *inode, struct file *filp, int drm_getmagic(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
static drm_magic_t sequence = 0; static drm_magic_t sequence = 0;
...@@ -188,9 +188,9 @@ int DRM(getmagic)(struct inode *inode, struct file *filp, ...@@ -188,9 +188,9 @@ int DRM(getmagic)(struct inode *inode, struct file *filp,
if (!sequence) ++sequence; /* reserve 0 */ if (!sequence) ++sequence; /* reserve 0 */
auth.magic = sequence++; auth.magic = sequence++;
spin_unlock(&lock); spin_unlock(&lock);
} while (DRM(find_file)(dev, auth.magic)); } while (drm_find_file(dev, auth.magic));
priv->magic = auth.magic; priv->magic = auth.magic;
DRM(add_magic)(dev, priv, auth.magic); drm_add_magic(dev, priv, auth.magic);
} }
DRM_DEBUG("%u\n", auth.magic); DRM_DEBUG("%u\n", auth.magic);
...@@ -210,7 +210,7 @@ int DRM(getmagic)(struct inode *inode, struct file *filp, ...@@ -210,7 +210,7 @@ int DRM(getmagic)(struct inode *inode, struct file *filp,
* *
* Checks if \p filp is associated with the magic number passed in \arg. * Checks if \p filp is associated with the magic number passed in \arg.
*/ */
int DRM(authmagic)(struct inode *inode, struct file *filp, int drm_authmagic(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -221,9 +221,9 @@ int DRM(authmagic)(struct inode *inode, struct file *filp, ...@@ -221,9 +221,9 @@ int DRM(authmagic)(struct inode *inode, struct file *filp,
if (copy_from_user(&auth, (drm_auth_t __user *)arg, sizeof(auth))) if (copy_from_user(&auth, (drm_auth_t __user *)arg, sizeof(auth)))
return -EFAULT; return -EFAULT;
DRM_DEBUG("%u\n", auth.magic); DRM_DEBUG("%u\n", auth.magic);
if ((file = DRM(find_file)(dev, auth.magic))) { if ((file = drm_find_file(dev, auth.magic))) {
file->authenticated = 1; file->authenticated = 1;
DRM(remove_magic)(dev, auth.magic); drm_remove_magic(dev, auth.magic);
return 0; return 0;
} }
return -EINVAL; return -EINVAL;
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
* in drm_device::context_sareas, while holding the drm_device::struct_sem * in drm_device::context_sareas, while holding the drm_device::struct_sem
* lock. * lock.
*/ */
void DRM(ctxbitmap_free)( drm_device_t *dev, int ctx_handle ) void drm_ctxbitmap_free( drm_device_t *dev, int ctx_handle )
{ {
if ( ctx_handle < 0 ) goto failed; if ( ctx_handle < 0 ) goto failed;
if ( !dev->ctx_bitmap ) goto failed; if ( !dev->ctx_bitmap ) goto failed;
...@@ -84,7 +84,7 @@ void DRM(ctxbitmap_free)( drm_device_t *dev, int ctx_handle ) ...@@ -84,7 +84,7 @@ void DRM(ctxbitmap_free)( drm_device_t *dev, int ctx_handle )
* drm_device::context_sareas to accommodate the new entry while holding the * drm_device::context_sareas to accommodate the new entry while holding the
* drm_device::struct_sem lock. * drm_device::struct_sem lock.
*/ */
int DRM(ctxbitmap_next)( drm_device_t *dev ) int drm_ctxbitmap_next( drm_device_t *dev )
{ {
int bit; int bit;
...@@ -100,7 +100,7 @@ int DRM(ctxbitmap_next)( drm_device_t *dev ) ...@@ -100,7 +100,7 @@ int DRM(ctxbitmap_next)( drm_device_t *dev )
if(dev->context_sareas) { if(dev->context_sareas) {
drm_map_t **ctx_sareas; drm_map_t **ctx_sareas;
ctx_sareas = DRM(realloc)(dev->context_sareas, ctx_sareas = drm_realloc(dev->context_sareas,
(dev->max_context - 1) * (dev->max_context - 1) *
sizeof(*dev->context_sareas), sizeof(*dev->context_sareas),
dev->max_context * dev->max_context *
...@@ -115,7 +115,7 @@ int DRM(ctxbitmap_next)( drm_device_t *dev ) ...@@ -115,7 +115,7 @@ int DRM(ctxbitmap_next)( drm_device_t *dev )
dev->context_sareas[bit] = NULL; dev->context_sareas[bit] = NULL;
} else { } else {
/* max_context == 1 at this point */ /* max_context == 1 at this point */
dev->context_sareas = DRM(alloc)( dev->context_sareas = drm_alloc(
dev->max_context * dev->max_context *
sizeof(*dev->context_sareas), sizeof(*dev->context_sareas),
DRM_MEM_MAPS); DRM_MEM_MAPS);
...@@ -142,13 +142,13 @@ int DRM(ctxbitmap_next)( drm_device_t *dev ) ...@@ -142,13 +142,13 @@ int DRM(ctxbitmap_next)( drm_device_t *dev )
* Allocates and initialize drm_device::ctx_bitmap and drm_device::context_sareas, while holding * Allocates and initialize drm_device::ctx_bitmap and drm_device::context_sareas, while holding
* the drm_device::struct_sem lock. * the drm_device::struct_sem lock.
*/ */
int DRM(ctxbitmap_init)( drm_device_t *dev ) int drm_ctxbitmap_init( drm_device_t *dev )
{ {
int i; int i;
int temp; int temp;
down(&dev->struct_sem); down(&dev->struct_sem);
dev->ctx_bitmap = (unsigned long *) DRM(alloc)( PAGE_SIZE, dev->ctx_bitmap = (unsigned long *) drm_alloc( PAGE_SIZE,
DRM_MEM_CTXBITMAP ); DRM_MEM_CTXBITMAP );
if ( dev->ctx_bitmap == NULL ) { if ( dev->ctx_bitmap == NULL ) {
up(&dev->struct_sem); up(&dev->struct_sem);
...@@ -160,7 +160,7 @@ int DRM(ctxbitmap_init)( drm_device_t *dev ) ...@@ -160,7 +160,7 @@ int DRM(ctxbitmap_init)( drm_device_t *dev )
up(&dev->struct_sem); up(&dev->struct_sem);
for ( i = 0 ; i < DRM_RESERVED_CONTEXTS ; i++ ) { for ( i = 0 ; i < DRM_RESERVED_CONTEXTS ; i++ ) {
temp = DRM(ctxbitmap_next)( dev ); temp = drm_ctxbitmap_next( dev );
DRM_DEBUG( "drm_ctxbitmap_init : %d\n", temp ); DRM_DEBUG( "drm_ctxbitmap_init : %d\n", temp );
} }
...@@ -175,14 +175,14 @@ int DRM(ctxbitmap_init)( drm_device_t *dev ) ...@@ -175,14 +175,14 @@ int DRM(ctxbitmap_init)( drm_device_t *dev )
* Frees drm_device::ctx_bitmap and drm_device::context_sareas, while holding * Frees drm_device::ctx_bitmap and drm_device::context_sareas, while holding
* the drm_device::struct_sem lock. * the drm_device::struct_sem lock.
*/ */
void DRM(ctxbitmap_cleanup)( drm_device_t *dev ) void drm_ctxbitmap_cleanup( drm_device_t *dev )
{ {
down(&dev->struct_sem); down(&dev->struct_sem);
if( dev->context_sareas ) DRM(free)( dev->context_sareas, if( dev->context_sareas ) drm_free( dev->context_sareas,
sizeof(*dev->context_sareas) * sizeof(*dev->context_sareas) *
dev->max_context, dev->max_context,
DRM_MEM_MAPS ); DRM_MEM_MAPS );
DRM(free)( (void *)dev->ctx_bitmap, PAGE_SIZE, DRM_MEM_CTXBITMAP ); drm_free( (void *)dev->ctx_bitmap, PAGE_SIZE, DRM_MEM_CTXBITMAP );
up(&dev->struct_sem); up(&dev->struct_sem);
} }
...@@ -204,7 +204,7 @@ void DRM(ctxbitmap_cleanup)( drm_device_t *dev ) ...@@ -204,7 +204,7 @@ void DRM(ctxbitmap_cleanup)( drm_device_t *dev )
* Gets the map from drm_device::context_sareas with the handle specified and * Gets the map from drm_device::context_sareas with the handle specified and
* returns its handle. * returns its handle.
*/ */
int DRM(getsareactx)(struct inode *inode, struct file *filp, int drm_getsareactx(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -243,7 +243,7 @@ int DRM(getsareactx)(struct inode *inode, struct file *filp, ...@@ -243,7 +243,7 @@ int DRM(getsareactx)(struct inode *inode, struct file *filp,
* Searches the mapping specified in \p arg and update the entry in * Searches the mapping specified in \p arg and update the entry in
* drm_device::context_sareas with it. * drm_device::context_sareas with it.
*/ */
int DRM(setsareactx)(struct inode *inode, struct file *filp, int drm_setsareactx(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -297,7 +297,7 @@ int DRM(setsareactx)(struct inode *inode, struct file *filp, ...@@ -297,7 +297,7 @@ int DRM(setsareactx)(struct inode *inode, struct file *filp,
* *
* Attempt to set drm_device::context_flag. * Attempt to set drm_device::context_flag.
*/ */
int DRM(context_switch)( drm_device_t *dev, int old, int new ) int drm_context_switch( drm_device_t *dev, int old, int new )
{ {
if ( test_and_set_bit( 0, &dev->context_flag ) ) { if ( test_and_set_bit( 0, &dev->context_flag ) ) {
DRM_ERROR( "Reentering -- FIXME\n" ); DRM_ERROR( "Reentering -- FIXME\n" );
...@@ -326,7 +326,7 @@ int DRM(context_switch)( drm_device_t *dev, int old, int new ) ...@@ -326,7 +326,7 @@ int DRM(context_switch)( drm_device_t *dev, int old, int new )
* hardware lock is held, clears the drm_device::context_flag and wakes up * hardware lock is held, clears the drm_device::context_flag and wakes up
* drm_device::context_wait. * drm_device::context_wait.
*/ */
int DRM(context_switch_complete)( drm_device_t *dev, int new ) int drm_context_switch_complete( drm_device_t *dev, int new )
{ {
dev->last_context = new; /* PRE/POST: This is the _only_ writer. */ dev->last_context = new; /* PRE/POST: This is the _only_ writer. */
dev->last_switch = jiffies; dev->last_switch = jiffies;
...@@ -353,7 +353,7 @@ int DRM(context_switch_complete)( drm_device_t *dev, int new ) ...@@ -353,7 +353,7 @@ int DRM(context_switch_complete)( drm_device_t *dev, int new )
* \param arg user argument pointing to a drm_ctx_res structure. * \param arg user argument pointing to a drm_ctx_res structure.
* \return zero on success or a negative number on failure. * \return zero on success or a negative number on failure.
*/ */
int DRM(resctx)( struct inode *inode, struct file *filp, int drm_resctx( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg ) unsigned int cmd, unsigned long arg )
{ {
drm_ctx_res_t res; drm_ctx_res_t res;
...@@ -391,7 +391,7 @@ int DRM(resctx)( struct inode *inode, struct file *filp, ...@@ -391,7 +391,7 @@ int DRM(resctx)( struct inode *inode, struct file *filp,
* *
* Get a new handle for the context and copy to userspace. * Get a new handle for the context and copy to userspace.
*/ */
int DRM(addctx)( struct inode *inode, struct file *filp, int drm_addctx( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg ) unsigned int cmd, unsigned long arg )
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -403,10 +403,10 @@ int DRM(addctx)( struct inode *inode, struct file *filp, ...@@ -403,10 +403,10 @@ int DRM(addctx)( struct inode *inode, struct file *filp,
if ( copy_from_user( &ctx, argp, sizeof(ctx) ) ) if ( copy_from_user( &ctx, argp, sizeof(ctx) ) )
return -EFAULT; return -EFAULT;
ctx.handle = DRM(ctxbitmap_next)( dev ); ctx.handle = drm_ctxbitmap_next( dev );
if ( ctx.handle == DRM_KERNEL_CONTEXT ) { if ( ctx.handle == DRM_KERNEL_CONTEXT ) {
/* Skip kernel's context and get a new one. */ /* Skip kernel's context and get a new one. */
ctx.handle = DRM(ctxbitmap_next)( dev ); ctx.handle = drm_ctxbitmap_next( dev );
} }
DRM_DEBUG( "%d\n", ctx.handle ); DRM_DEBUG( "%d\n", ctx.handle );
if ( ctx.handle == -1 ) { if ( ctx.handle == -1 ) {
...@@ -417,11 +417,11 @@ int DRM(addctx)( struct inode *inode, struct file *filp, ...@@ -417,11 +417,11 @@ int DRM(addctx)( struct inode *inode, struct file *filp,
if ( ctx.handle != DRM_KERNEL_CONTEXT ) if ( ctx.handle != DRM_KERNEL_CONTEXT )
{ {
if (dev->fn_tbl.context_ctor) if (dev->driver->context_ctor)
dev->fn_tbl.context_ctor(dev, ctx.handle); dev->driver->context_ctor(dev, ctx.handle);
} }
ctx_entry = DRM(alloc)( sizeof(*ctx_entry), DRM_MEM_CTXLIST ); ctx_entry = drm_alloc( sizeof(*ctx_entry), DRM_MEM_CTXLIST );
if ( !ctx_entry ) { if ( !ctx_entry ) {
DRM_DEBUG("out of memory\n"); DRM_DEBUG("out of memory\n");
return -ENOMEM; return -ENOMEM;
...@@ -441,7 +441,7 @@ int DRM(addctx)( struct inode *inode, struct file *filp, ...@@ -441,7 +441,7 @@ int DRM(addctx)( struct inode *inode, struct file *filp,
return 0; return 0;
} }
int DRM(modctx)( struct inode *inode, struct file *filp, int drm_modctx( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg ) unsigned int cmd, unsigned long arg )
{ {
/* This does nothing */ /* This does nothing */
...@@ -457,7 +457,7 @@ int DRM(modctx)( struct inode *inode, struct file *filp, ...@@ -457,7 +457,7 @@ int DRM(modctx)( struct inode *inode, struct file *filp,
* \param arg user argument pointing to a drm_ctx structure. * \param arg user argument pointing to a drm_ctx structure.
* \return zero on success or a negative number on failure. * \return zero on success or a negative number on failure.
*/ */
int DRM(getctx)( struct inode *inode, struct file *filp, int drm_getctx( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg ) unsigned int cmd, unsigned long arg )
{ {
drm_ctx_t __user *argp = (void __user *)arg; drm_ctx_t __user *argp = (void __user *)arg;
...@@ -485,7 +485,7 @@ int DRM(getctx)( struct inode *inode, struct file *filp, ...@@ -485,7 +485,7 @@ int DRM(getctx)( struct inode *inode, struct file *filp,
* *
* Calls context_switch(). * Calls context_switch().
*/ */
int DRM(switchctx)( struct inode *inode, struct file *filp, int drm_switchctx( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg ) unsigned int cmd, unsigned long arg )
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -496,7 +496,7 @@ int DRM(switchctx)( struct inode *inode, struct file *filp, ...@@ -496,7 +496,7 @@ int DRM(switchctx)( struct inode *inode, struct file *filp,
return -EFAULT; return -EFAULT;
DRM_DEBUG( "%d\n", ctx.handle ); DRM_DEBUG( "%d\n", ctx.handle );
return DRM(context_switch)( dev, dev->last_context, ctx.handle ); return drm_context_switch( dev, dev->last_context, ctx.handle );
} }
/** /**
...@@ -510,7 +510,7 @@ int DRM(switchctx)( struct inode *inode, struct file *filp, ...@@ -510,7 +510,7 @@ int DRM(switchctx)( struct inode *inode, struct file *filp,
* *
* Calls context_switch_complete(). * Calls context_switch_complete().
*/ */
int DRM(newctx)( struct inode *inode, struct file *filp, int drm_newctx( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg ) unsigned int cmd, unsigned long arg )
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -521,7 +521,7 @@ int DRM(newctx)( struct inode *inode, struct file *filp, ...@@ -521,7 +521,7 @@ int DRM(newctx)( struct inode *inode, struct file *filp,
return -EFAULT; return -EFAULT;
DRM_DEBUG( "%d\n", ctx.handle ); DRM_DEBUG( "%d\n", ctx.handle );
DRM(context_switch_complete)( dev, ctx.handle ); drm_context_switch_complete( dev, ctx.handle );
return 0; return 0;
} }
...@@ -537,7 +537,7 @@ int DRM(newctx)( struct inode *inode, struct file *filp, ...@@ -537,7 +537,7 @@ int DRM(newctx)( struct inode *inode, struct file *filp,
* *
* If not the special kernel context, calls ctxbitmap_free() to free the specified context. * If not the special kernel context, calls ctxbitmap_free() to free the specified context.
*/ */
int DRM(rmctx)( struct inode *inode, struct file *filp, int drm_rmctx( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg ) unsigned int cmd, unsigned long arg )
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -552,9 +552,9 @@ int DRM(rmctx)( struct inode *inode, struct file *filp, ...@@ -552,9 +552,9 @@ int DRM(rmctx)( struct inode *inode, struct file *filp,
priv->remove_auth_on_close = 1; priv->remove_auth_on_close = 1;
} }
if ( ctx.handle != DRM_KERNEL_CONTEXT ) { if ( ctx.handle != DRM_KERNEL_CONTEXT ) {
if (dev->fn_tbl.context_dtor) if (dev->driver->context_dtor)
dev->fn_tbl.context_dtor(dev, ctx.handle); dev->driver->context_dtor(dev, ctx.handle);
DRM(ctxbitmap_free)( dev, ctx.handle ); drm_ctxbitmap_free( dev, ctx.handle );
} }
down( &dev->ctxlist_sem ); down( &dev->ctxlist_sem );
...@@ -564,7 +564,7 @@ int DRM(rmctx)( struct inode *inode, struct file *filp, ...@@ -564,7 +564,7 @@ int DRM(rmctx)( struct inode *inode, struct file *filp,
list_for_each_entry_safe( pos, n, &dev->ctxlist->head, head ) { list_for_each_entry_safe( pos, n, &dev->ctxlist->head, head ) {
if ( pos->handle == ctx.handle ) { if ( pos->handle == ctx.handle ) {
list_del( &pos->head ); list_del( &pos->head );
DRM(free)( pos, sizeof(*pos), DRM_MEM_CTXLIST ); drm_free( pos, sizeof(*pos), DRM_MEM_CTXLIST );
--dev->ctx_count; --dev->ctx_count;
} }
} }
......
...@@ -20,21 +20,15 @@ ...@@ -20,21 +20,15 @@
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
#define DRIVER_AUTHOR "Gareth Hughes, Leif Delgass, José Fonseca, Jon Smirl"
#include "drm_auth.h" #define DRIVER_NAME "drm"
#include "drm_agpsupport.h" #define DRIVER_DESC "DRM shared core routines"
#include "drm_bufs.h" #define DRIVER_DATE "20040925"
#include "drm_context.h"
#include "drm_dma.h" #define DRM_IF_MAJOR 1
#include "drm_irq.h" #define DRM_IF_MINOR 2
#include "drm_drawable.h"
#include "drm_drv.h" #define DRIVER_MAJOR 1
#include "drm_fops.h" #define DRIVER_MINOR 0
#include "drm_init.h" #define DRIVER_PATCHLEVEL 0
#include "drm_ioctl.h"
#include "drm_lock.h"
#include "drm_memory.h"
#include "drm_proc.h"
#include "drm_vm.h"
#include "drm_stub.h"
#include "drm_scatter.h"
...@@ -43,11 +43,11 @@ ...@@ -43,11 +43,11 @@
* *
* Allocate and initialize a drm_device_dma structure. * Allocate and initialize a drm_device_dma structure.
*/ */
int DRM(dma_setup)( drm_device_t *dev ) int drm_dma_setup( drm_device_t *dev )
{ {
int i; int i;
dev->dma = DRM(alloc)( sizeof(*dev->dma), DRM_MEM_DRIVER ); dev->dma = drm_alloc( sizeof(*dev->dma), DRM_MEM_DRIVER );
if ( !dev->dma ) if ( !dev->dma )
return -ENOMEM; return -ENOMEM;
...@@ -67,7 +67,7 @@ int DRM(dma_setup)( drm_device_t *dev ) ...@@ -67,7 +67,7 @@ int DRM(dma_setup)( drm_device_t *dev )
* Free all pages associated with DMA buffers, the buffers and pages lists, and * Free all pages associated with DMA buffers, the buffers and pages lists, and
* finally the the drm_device::dma structure itself. * finally the the drm_device::dma structure itself.
*/ */
void DRM(dma_takedown)(drm_device_t *dev) void drm_dma_takedown(drm_device_t *dev)
{ {
drm_device_dma_t *dma = dev->dma; drm_device_dma_t *dma = dev->dma;
int i, j; int i, j;
...@@ -84,12 +84,12 @@ void DRM(dma_takedown)(drm_device_t *dev) ...@@ -84,12 +84,12 @@ void DRM(dma_takedown)(drm_device_t *dev)
dma->bufs[i].seg_count); dma->bufs[i].seg_count);
for (j = 0; j < dma->bufs[i].seg_count; j++) { for (j = 0; j < dma->bufs[i].seg_count; j++) {
if (dma->bufs[i].seglist[j]) { if (dma->bufs[i].seglist[j]) {
DRM(free_pages)(dma->bufs[i].seglist[j], drm_free_pages(dma->bufs[i].seglist[j],
dma->bufs[i].page_order, dma->bufs[i].page_order,
DRM_MEM_DMA); DRM_MEM_DMA);
} }
} }
DRM(free)(dma->bufs[i].seglist, drm_free(dma->bufs[i].seglist,
dma->bufs[i].seg_count dma->bufs[i].seg_count
* sizeof(*dma->bufs[0].seglist), * sizeof(*dma->bufs[0].seglist),
DRM_MEM_SEGS); DRM_MEM_SEGS);
...@@ -97,12 +97,12 @@ void DRM(dma_takedown)(drm_device_t *dev) ...@@ -97,12 +97,12 @@ void DRM(dma_takedown)(drm_device_t *dev)
if (dma->bufs[i].buf_count) { if (dma->bufs[i].buf_count) {
for (j = 0; j < dma->bufs[i].buf_count; j++) { for (j = 0; j < dma->bufs[i].buf_count; j++) {
if (dma->bufs[i].buflist[j].dev_private) { if (dma->bufs[i].buflist[j].dev_private) {
DRM(free)(dma->bufs[i].buflist[j].dev_private, drm_free(dma->bufs[i].buflist[j].dev_private,
dma->bufs[i].buflist[j].dev_priv_size, dma->bufs[i].buflist[j].dev_priv_size,
DRM_MEM_BUFS); DRM_MEM_BUFS);
} }
} }
DRM(free)(dma->bufs[i].buflist, drm_free(dma->bufs[i].buflist,
dma->bufs[i].buf_count * dma->bufs[i].buf_count *
sizeof(*dma->bufs[0].buflist), sizeof(*dma->bufs[0].buflist),
DRM_MEM_BUFS); DRM_MEM_BUFS);
...@@ -110,17 +110,17 @@ void DRM(dma_takedown)(drm_device_t *dev) ...@@ -110,17 +110,17 @@ void DRM(dma_takedown)(drm_device_t *dev)
} }
if (dma->buflist) { if (dma->buflist) {
DRM(free)(dma->buflist, drm_free(dma->buflist,
dma->buf_count * sizeof(*dma->buflist), dma->buf_count * sizeof(*dma->buflist),
DRM_MEM_BUFS); DRM_MEM_BUFS);
} }
if (dma->pagelist) { if (dma->pagelist) {
DRM(free)(dma->pagelist, drm_free(dma->pagelist,
dma->page_count * sizeof(*dma->pagelist), dma->page_count * sizeof(*dma->pagelist),
DRM_MEM_PAGES); DRM_MEM_PAGES);
} }
DRM(free)(dev->dma, sizeof(*dev->dma), DRM_MEM_DRIVER); drm_free(dev->dma, sizeof(*dev->dma), DRM_MEM_DRIVER);
dev->dma = NULL; dev->dma = NULL;
} }
...@@ -133,7 +133,7 @@ void DRM(dma_takedown)(drm_device_t *dev) ...@@ -133,7 +133,7 @@ void DRM(dma_takedown)(drm_device_t *dev)
* *
* Resets the fields of \p buf. * Resets the fields of \p buf.
*/ */
void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf) void drm_free_buffer(drm_device_t *dev, drm_buf_t *buf)
{ {
if (!buf) return; if (!buf) return;
...@@ -154,7 +154,7 @@ void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf) ...@@ -154,7 +154,7 @@ void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf)
* *
* Frees each buffer associated with \p filp not already on the hardware. * Frees each buffer associated with \p filp not already on the hardware.
*/ */
void DRM(core_reclaim_buffers)( struct file *filp ) void drm_core_reclaim_buffers( struct file *filp )
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
drm_device_t *dev = priv->dev; drm_device_t *dev = priv->dev;
...@@ -166,7 +166,7 @@ void DRM(core_reclaim_buffers)( struct file *filp ) ...@@ -166,7 +166,7 @@ void DRM(core_reclaim_buffers)( struct file *filp )
if (dma->buflist[i]->filp == filp) { if (dma->buflist[i]->filp == filp) {
switch (dma->buflist[i]->list) { switch (dma->buflist[i]->list) {
case DRM_LIST_NONE: case DRM_LIST_NONE:
DRM(free_buffer)(dev, dma->buflist[i]); drm_free_buffer(dev, dma->buflist[i]);
break; break;
case DRM_LIST_WAIT: case DRM_LIST_WAIT:
dma->buflist[i]->list = DRM_LIST_RECLAIM; dma->buflist[i]->list = DRM_LIST_RECLAIM;
...@@ -178,4 +178,5 @@ void DRM(core_reclaim_buffers)( struct file *filp ) ...@@ -178,4 +178,5 @@ void DRM(core_reclaim_buffers)( struct file *filp )
} }
} }
} }
EXPORT_SYMBOL(drm_core_reclaim_buffers);
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#include "drmP.h" #include "drmP.h"
/** No-op. */ /** No-op. */
int DRM(adddraw)(struct inode *inode, struct file *filp, int drm_adddraw(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
drm_draw_t draw; drm_draw_t draw;
...@@ -49,7 +49,7 @@ int DRM(adddraw)(struct inode *inode, struct file *filp, ...@@ -49,7 +49,7 @@ int DRM(adddraw)(struct inode *inode, struct file *filp,
} }
/** No-op. */ /** No-op. */
int DRM(rmdraw)(struct inode *inode, struct file *filp, int drm_rmdraw(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
return 0; /* NOOP */ return 0; /* NOOP */
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -35,88 +35,12 @@ ...@@ -35,88 +35,12 @@
#include "drmP.h" #include "drmP.h"
/** Debug flags. Set by parse_option(). */
#if 0
int DRM(flags) = DRM_FLAG_DEBUG;
#else
int DRM(flags) = 0;
#endif
/**
* Parse a single option.
*
* \param s option string.
*
* \sa See parse_options() for details.
*/
static void DRM(parse_option)(char *s)
{
char *c, *r;
DRM_DEBUG("\"%s\"\n", s);
if (!s || !*s) return;
for (c = s; *c && *c != ':'; c++); /* find : or \0 */
if (*c) r = c + 1; else r = NULL; /* remember remainder */
*c = '\0'; /* terminate */
if (!strcmp(s, "debug")) {
DRM(flags) |= DRM_FLAG_DEBUG;
DRM_INFO("Debug messages ON\n");
return;
}
DRM_ERROR("\"%s\" is not a valid option\n", s);
return;
}
/**
* Parse the insmod "drm_opts=" options, or the command-line
* options passed to the kernel via LILO.
*
* \param s contains option_list without the 'drm_opts=' part.
*
* The grammar of the format is as
* follows:
*
* \code
* drm ::= 'drm_opts=' option_list
* option_list ::= option [ ';' option_list ]
* option ::= 'device:' major
* | 'debug'
* | 'noctx'
* major ::= INTEGER
* \endcode
*
* - device=major,minor specifies the device number used for /dev/drm
* - if major == 0 then the misc device is used
* - if major == 0 and minor == 0 then dynamic misc allocation is used
* - debug=on specifies that debugging messages will be printk'd
* - debug=trace specifies that each function call will be logged via printk
* - debug=off turns off all debugging options
*
* \todo Actually only the \e presence of the 'debug' option is currently
* checked.
*/
void DRM(parse_options)(char *s)
{
char *h, *t, *n;
DRM_DEBUG("\"%s\"\n", s ?: "");
if (!s || !*s) return;
for (h = t = n = s; h && *h; h = n) {
for (; *t && *t != ';'; t++); /* find ; or \0 */
if (*t) n = t + 1; else n = NULL; /* remember next */
*t = '\0'; /* terminate */
DRM(parse_option)(h); /* parse */
}
}
/** /**
* Check whether DRI will run on this CPU. * Check whether DRI will run on this CPU.
* *
* \return non-zero if the DRI will run on this CPU, or zero otherwise. * \return non-zero if the DRI will run on this CPU, or zero otherwise.
*/ */
int DRM(cpu_valid)(void) int drm_cpu_valid(void)
{ {
#if defined(__i386__) #if defined(__i386__)
if (boot_cpu_data.x86 == 3) return 0; /* No cmpxchg on a 386 */ if (boot_cpu_data.x86 == 3) return 0; /* No cmpxchg on a 386 */
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
*/ */
#include "drmP.h" #include "drmP.h"
#include "drm_core.h"
#include "linux/pci.h" #include "linux/pci.h"
...@@ -48,7 +49,7 @@ ...@@ -48,7 +49,7 @@
* *
* Copies the bus id from drm_device::unique into user space. * Copies the bus id from drm_device::unique into user space.
*/ */
int DRM(getunique)(struct inode *inode, struct file *filp, int drm_getunique(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -82,7 +83,7 @@ int DRM(getunique)(struct inode *inode, struct file *filp, ...@@ -82,7 +83,7 @@ int DRM(getunique)(struct inode *inode, struct file *filp,
* in interface version 1.1 and will return EBUSY when setversion has requested * in interface version 1.1 and will return EBUSY when setversion has requested
* version 1.1 or greater. * version 1.1 or greater.
*/ */
int DRM(setunique)(struct inode *inode, struct file *filp, int drm_setunique(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -98,19 +99,19 @@ int DRM(setunique)(struct inode *inode, struct file *filp, ...@@ -98,19 +99,19 @@ int DRM(setunique)(struct inode *inode, struct file *filp,
if (!u.unique_len || u.unique_len > 1024) return -EINVAL; if (!u.unique_len || u.unique_len > 1024) return -EINVAL;
dev->unique_len = u.unique_len; dev->unique_len = u.unique_len;
dev->unique = DRM(alloc)(u.unique_len + 1, DRM_MEM_DRIVER); dev->unique = drm_alloc(u.unique_len + 1, DRM_MEM_DRIVER);
if(!dev->unique) return -ENOMEM; if(!dev->unique) return -ENOMEM;
if (copy_from_user(dev->unique, u.unique, dev->unique_len)) if (copy_from_user(dev->unique, u.unique, dev->unique_len))
return -EFAULT; return -EFAULT;
dev->unique[dev->unique_len] = '\0'; dev->unique[dev->unique_len] = '\0';
dev->devname = DRM(alloc)(strlen(dev->name) + strlen(dev->unique) + 2, dev->devname = drm_alloc(strlen(dev->driver->pci_driver.name) + strlen(dev->unique) + 2,
DRM_MEM_DRIVER); DRM_MEM_DRIVER);
if (!dev->devname) if (!dev->devname)
return -ENOMEM; return -ENOMEM;
sprintf(dev->devname, "%s@%s", dev->name, dev->unique); sprintf(dev->devname, "%s@%s", dev->driver->pci_driver.name, dev->unique);
/* Return error if the busid submitted doesn't match the device's actual /* Return error if the busid submitted doesn't match the device's actual
* busid. * busid.
...@@ -131,25 +132,25 @@ int DRM(setunique)(struct inode *inode, struct file *filp, ...@@ -131,25 +132,25 @@ int DRM(setunique)(struct inode *inode, struct file *filp,
} }
static int static int
DRM(set_busid)(drm_device_t *dev) drm_set_busid(drm_device_t *dev)
{ {
if (dev->unique != NULL) if (dev->unique != NULL)
return EBUSY; return EBUSY;
dev->unique_len = 20; dev->unique_len = 20;
dev->unique = DRM(alloc)(dev->unique_len + 1, DRM_MEM_DRIVER); dev->unique = drm_alloc(dev->unique_len + 1, DRM_MEM_DRIVER);
if (dev->unique == NULL) if (dev->unique == NULL)
return ENOMEM; return ENOMEM;
snprintf(dev->unique, dev->unique_len, "pci:%04x:%02x:%02x.%d", snprintf(dev->unique, dev->unique_len, "pci:%04x:%02x:%02x.%d",
dev->pci_domain, dev->pci_bus, dev->pci_slot, dev->pci_func); dev->pci_domain, dev->pci_bus, dev->pci_slot, dev->pci_func);
dev->devname = DRM(alloc)(strlen(dev->name) + dev->unique_len + 2, dev->devname = drm_alloc(strlen(dev->driver->pci_driver.name) + dev->unique_len + 2,
DRM_MEM_DRIVER); DRM_MEM_DRIVER);
if (dev->devname == NULL) if (dev->devname == NULL)
return ENOMEM; return ENOMEM;
sprintf(dev->devname, "%s@%s", dev->name, dev->unique); sprintf(dev->devname, "%s@%s", dev->driver->pci_driver.name, dev->unique);
return 0; return 0;
} }
...@@ -168,7 +169,7 @@ DRM(set_busid)(drm_device_t *dev) ...@@ -168,7 +169,7 @@ DRM(set_busid)(drm_device_t *dev)
* Searches for the mapping with the specified offset and copies its information * Searches for the mapping with the specified offset and copies its information
* into userspace * into userspace
*/ */
int DRM(getmap)( struct inode *inode, struct file *filp, int drm_getmap( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg ) unsigned int cmd, unsigned long arg )
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -228,7 +229,7 @@ int DRM(getmap)( struct inode *inode, struct file *filp, ...@@ -228,7 +229,7 @@ int DRM(getmap)( struct inode *inode, struct file *filp,
* Searches for the client with the specified index and copies its information * Searches for the client with the specified index and copies its information
* into userspace * into userspace
*/ */
int DRM(getclient)( struct inode *inode, struct file *filp, int drm_getclient( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg ) unsigned int cmd, unsigned long arg )
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -272,7 +273,7 @@ int DRM(getclient)( struct inode *inode, struct file *filp, ...@@ -272,7 +273,7 @@ int DRM(getclient)( struct inode *inode, struct file *filp,
* *
* \return zero on success or a negative number on failure. * \return zero on success or a negative number on failure.
*/ */
int DRM(getstats)( struct inode *inode, struct file *filp, int drm_getstats( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg ) unsigned int cmd, unsigned long arg )
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -303,10 +304,7 @@ int DRM(getstats)( struct inode *inode, struct file *filp, ...@@ -303,10 +304,7 @@ int DRM(getstats)( struct inode *inode, struct file *filp,
return 0; return 0;
} }
#define DRM_IF_MAJOR 1 int drm_setversion(DRM_IOCTL_ARGS)
#define DRM_IF_MINOR 2
int DRM(setversion)(DRM_IOCTL_ARGS)
{ {
DRM_DEVICE; DRM_DEVICE;
drm_set_version_t sv; drm_set_version_t sv;
...@@ -333,7 +331,7 @@ int DRM(setversion)(DRM_IOCTL_ARGS) ...@@ -333,7 +331,7 @@ int DRM(setversion)(DRM_IOCTL_ARGS)
/* /*
* Version 1.1 includes tying of DRM to specific device * Version 1.1 includes tying of DRM to specific device
*/ */
DRM(set_busid)(dev); drm_set_busid(dev);
} }
} }
...@@ -342,8 +340,16 @@ int DRM(setversion)(DRM_IOCTL_ARGS) ...@@ -342,8 +340,16 @@ int DRM(setversion)(DRM_IOCTL_ARGS)
sv.drm_dd_minor < 0 || sv.drm_dd_minor > DRIVER_MINOR) sv.drm_dd_minor < 0 || sv.drm_dd_minor > DRIVER_MINOR)
return EINVAL; return EINVAL;
if (dev->fn_tbl.set_version) if (dev->driver->set_version)
dev->fn_tbl.set_version(dev, &sv); dev->driver->set_version(dev, &sv);
} }
return 0; return 0;
} }
/** No-op ioctl. */
int drm_noop(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg)
{
DRM_DEBUG("\n");
return 0;
}
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
* This IOCTL is deprecated, and will now return EINVAL for any busid not equal * This IOCTL is deprecated, and will now return EINVAL for any busid not equal
* to that of the device that this DRM instance attached to. * to that of the device that this DRM instance attached to.
*/ */
int DRM(irq_by_busid)(struct inode *inode, struct file *filp, int drm_irq_by_busid(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -86,10 +86,10 @@ int DRM(irq_by_busid)(struct inode *inode, struct file *filp, ...@@ -86,10 +86,10 @@ int DRM(irq_by_busid)(struct inode *inode, struct file *filp,
* \param irq IRQ number. * \param irq IRQ number.
* *
* Initializes the IRQ related data, and setups drm_device::vbl_queue. Installs the handler, calling the driver * Initializes the IRQ related data, and setups drm_device::vbl_queue. Installs the handler, calling the driver
* \c DRM(driver_irq_preinstall)() and \c DRM(driver_irq_postinstall)() functions * \c drm_driver_irq_preinstall() and \c drm_driver_irq_postinstall() functions
* before and after the installation. * before and after the installation.
*/ */
int DRM(irq_install)( drm_device_t *dev ) int drm_irq_install( drm_device_t *dev )
{ {
int ret; int ret;
unsigned long sh_flags=0; unsigned long sh_flags=0;
...@@ -128,13 +128,13 @@ int DRM(irq_install)( drm_device_t *dev ) ...@@ -128,13 +128,13 @@ int DRM(irq_install)( drm_device_t *dev )
} }
/* Before installing handler */ /* Before installing handler */
dev->fn_tbl.irq_preinstall(dev); dev->driver->irq_preinstall(dev);
/* Install handler */ /* Install handler */
if (drm_core_check_feature(dev, DRIVER_IRQ_SHARED)) if (drm_core_check_feature(dev, DRIVER_IRQ_SHARED))
sh_flags = SA_SHIRQ; sh_flags = SA_SHIRQ;
ret = request_irq( dev->irq, dev->fn_tbl.irq_handler, ret = request_irq( dev->irq, dev->driver->irq_handler,
sh_flags, dev->devname, dev ); sh_flags, dev->devname, dev );
if ( ret < 0 ) { if ( ret < 0 ) {
down( &dev->struct_sem ); down( &dev->struct_sem );
...@@ -144,7 +144,7 @@ int DRM(irq_install)( drm_device_t *dev ) ...@@ -144,7 +144,7 @@ int DRM(irq_install)( drm_device_t *dev )
} }
/* After installing handler */ /* After installing handler */
dev->fn_tbl.irq_postinstall(dev); dev->driver->irq_postinstall(dev);
return 0; return 0;
} }
...@@ -154,9 +154,9 @@ int DRM(irq_install)( drm_device_t *dev ) ...@@ -154,9 +154,9 @@ int DRM(irq_install)( drm_device_t *dev )
* *
* \param dev DRM device. * \param dev DRM device.
* *
* Calls the driver's \c DRM(driver_irq_uninstall)() function, and stops the irq. * Calls the driver's \c drm_driver_irq_uninstall() function, and stops the irq.
*/ */
int DRM(irq_uninstall)( drm_device_t *dev ) int drm_irq_uninstall( drm_device_t *dev )
{ {
int irq_enabled; int irq_enabled;
...@@ -173,12 +173,13 @@ int DRM(irq_uninstall)( drm_device_t *dev ) ...@@ -173,12 +173,13 @@ int DRM(irq_uninstall)( drm_device_t *dev )
DRM_DEBUG( "%s: irq=%d\n", __FUNCTION__, dev->irq ); DRM_DEBUG( "%s: irq=%d\n", __FUNCTION__, dev->irq );
dev->fn_tbl.irq_uninstall(dev); dev->driver->irq_uninstall(dev);
free_irq( dev->irq, dev ); free_irq( dev->irq, dev );
return 0; return 0;
} }
EXPORT_SYMBOL(drm_irq_uninstall);
/** /**
* IRQ control ioctl. * IRQ control ioctl.
...@@ -191,7 +192,7 @@ int DRM(irq_uninstall)( drm_device_t *dev ) ...@@ -191,7 +192,7 @@ int DRM(irq_uninstall)( drm_device_t *dev )
* *
* Calls irq_install() or irq_uninstall() according to \p arg. * Calls irq_install() or irq_uninstall() according to \p arg.
*/ */
int DRM(control)( struct inode *inode, struct file *filp, int drm_control( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg ) unsigned int cmd, unsigned long arg )
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -210,11 +211,11 @@ int DRM(control)( struct inode *inode, struct file *filp, ...@@ -210,11 +211,11 @@ int DRM(control)( struct inode *inode, struct file *filp,
if (dev->if_version < DRM_IF_VERSION(1, 2) && if (dev->if_version < DRM_IF_VERSION(1, 2) &&
ctl.irq != dev->irq) ctl.irq != dev->irq)
return -EINVAL; return -EINVAL;
return DRM(irq_install)( dev ); return drm_irq_install( dev );
case DRM_UNINST_HANDLER: case DRM_UNINST_HANDLER:
if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ)) if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
return 0; return 0;
return DRM(irq_uninstall)( dev ); return drm_irq_uninstall( dev );
default: default:
return -EINVAL; return -EINVAL;
} }
...@@ -239,7 +240,7 @@ int DRM(control)( struct inode *inode, struct file *filp, ...@@ -239,7 +240,7 @@ int DRM(control)( struct inode *inode, struct file *filp,
* *
* If a signal is not requested, then calls vblank_wait(). * If a signal is not requested, then calls vblank_wait().
*/ */
int DRM(wait_vblank)( DRM_IOCTL_ARGS ) int drm_wait_vblank( DRM_IOCTL_ARGS )
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
drm_device_t *dev = priv->dev; drm_device_t *dev = priv->dev;
...@@ -300,7 +301,7 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS ) ...@@ -300,7 +301,7 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS )
spin_unlock_irqrestore( &dev->vbl_lock, irqflags ); spin_unlock_irqrestore( &dev->vbl_lock, irqflags );
if ( !( vbl_sig = DRM_MALLOC( sizeof( drm_vbl_sig_t ) ) ) ) { if ( !( vbl_sig = drm_alloc( sizeof( drm_vbl_sig_t ), DRM_MEM_DRIVER ) ) ) {
return -ENOMEM; return -ENOMEM;
} }
...@@ -316,8 +317,8 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS ) ...@@ -316,8 +317,8 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS )
spin_unlock_irqrestore( &dev->vbl_lock, irqflags ); spin_unlock_irqrestore( &dev->vbl_lock, irqflags );
} else { } else {
if (dev->fn_tbl.vblank_wait) if (dev->driver->vblank_wait)
ret = dev->fn_tbl.vblank_wait( dev, &vblwait.request.sequence ); ret = dev->driver->vblank_wait( dev, &vblwait.request.sequence );
do_gettimeofday( &now ); do_gettimeofday( &now );
vblwait.reply.tval_sec = now.tv_sec; vblwait.reply.tval_sec = now.tv_sec;
...@@ -339,7 +340,7 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS ) ...@@ -339,7 +340,7 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS )
* *
* If a signal is not requested, then calls vblank_wait(). * If a signal is not requested, then calls vblank_wait().
*/ */
void DRM(vbl_send_signals)( drm_device_t *dev ) void drm_vbl_send_signals( drm_device_t *dev )
{ {
struct list_head *list, *tmp; struct list_head *list, *tmp;
drm_vbl_sig_t *vbl_sig; drm_vbl_sig_t *vbl_sig;
...@@ -356,7 +357,7 @@ void DRM(vbl_send_signals)( drm_device_t *dev ) ...@@ -356,7 +357,7 @@ void DRM(vbl_send_signals)( drm_device_t *dev )
list_del( list ); list_del( list );
DRM_FREE( vbl_sig, sizeof(*vbl_sig) ); drm_free( vbl_sig, sizeof(*vbl_sig), DRM_MEM_DRIVER );
dev->vbl_pending--; dev->vbl_pending--;
} }
...@@ -364,5 +365,6 @@ void DRM(vbl_send_signals)( drm_device_t *dev ) ...@@ -364,5 +365,6 @@ void DRM(vbl_send_signals)( drm_device_t *dev )
spin_unlock_irqrestore( &dev->vbl_lock, flags ); spin_unlock_irqrestore( &dev->vbl_lock, flags );
} }
EXPORT_SYMBOL(drm_vbl_send_signals);
...@@ -35,11 +35,146 @@ ...@@ -35,11 +35,146 @@
#include "drmP.h" #include "drmP.h"
/** No-op ioctl. */ /**
int DRM(noop)(struct inode *inode, struct file *filp, unsigned int cmd, * Lock ioctl.
unsigned long arg) *
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg user argument, pointing to a drm_lock structure.
* \return zero on success or negative number on failure.
*
* Add the current task to the lock wait queue, and attempt to take to lock.
*/
int drm_lock( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg )
{ {
DRM_DEBUG("\n"); drm_file_t *priv = filp->private_data;
drm_device_t *dev = priv->dev;
DECLARE_WAITQUEUE( entry, current );
drm_lock_t lock;
int ret = 0;
++priv->lock_count;
if ( copy_from_user( &lock, (drm_lock_t __user *)arg, sizeof(lock) ) )
return -EFAULT;
if ( lock.context == DRM_KERNEL_CONTEXT ) {
DRM_ERROR( "Process %d using kernel context %d\n",
current->pid, lock.context );
return -EINVAL;
}
DRM_DEBUG( "%d (pid %d) requests lock (0x%08x), flags = 0x%08x\n",
lock.context, current->pid,
dev->lock.hw_lock->lock, lock.flags );
if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE))
if ( lock.context < 0 )
return -EINVAL;
add_wait_queue( &dev->lock.lock_queue, &entry );
for (;;) {
__set_current_state(TASK_INTERRUPTIBLE);
if ( !dev->lock.hw_lock ) {
/* Device has been unregistered */
ret = -EINTR;
break;
}
if ( drm_lock_take( &dev->lock.hw_lock->lock,
lock.context ) ) {
dev->lock.filp = filp;
dev->lock.lock_time = jiffies;
atomic_inc( &dev->counts[_DRM_STAT_LOCKS] );
break; /* Got lock */
}
/* Contention */
schedule();
if ( signal_pending( current ) ) {
ret = -ERESTARTSYS;
break;
}
}
__set_current_state(TASK_RUNNING);
remove_wait_queue( &dev->lock.lock_queue, &entry );
sigemptyset( &dev->sigmask );
sigaddset( &dev->sigmask, SIGSTOP );
sigaddset( &dev->sigmask, SIGTSTP );
sigaddset( &dev->sigmask, SIGTTIN );
sigaddset( &dev->sigmask, SIGTTOU );
dev->sigdata.context = lock.context;
dev->sigdata.lock = dev->lock.hw_lock;
block_all_signals( drm_notifier,
&dev->sigdata, &dev->sigmask );
if (dev->driver->dma_ready && (lock.flags & _DRM_LOCK_READY))
dev->driver->dma_ready(dev);
if ( dev->driver->dma_quiescent && (lock.flags & _DRM_LOCK_QUIESCENT ))
return dev->driver->dma_quiescent(dev);
/* dev->driver->kernel_context_switch isn't used by any of the x86
* drivers but is used by the Sparc driver.
*/
if (dev->driver->kernel_context_switch &&
dev->last_context != lock.context) {
dev->driver->kernel_context_switch(dev, dev->last_context,
lock.context);
}
DRM_DEBUG( "%d %s\n", lock.context, ret ? "interrupted" : "has lock" );
return ret;
}
/**
* Unlock ioctl.
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg user argument, pointing to a drm_lock structure.
* \return zero on success or negative number on failure.
*
* Transfer and free the lock.
*/
int drm_unlock( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg )
{
drm_file_t *priv = filp->private_data;
drm_device_t *dev = priv->dev;
drm_lock_t lock;
if ( copy_from_user( &lock, (drm_lock_t __user *)arg, sizeof(lock) ) )
return -EFAULT;
if ( lock.context == DRM_KERNEL_CONTEXT ) {
DRM_ERROR( "Process %d using kernel context %d\n",
current->pid, lock.context );
return -EINVAL;
}
atomic_inc( &dev->counts[_DRM_STAT_UNLOCKS] );
/* kernel_context_switch isn't used by any of the x86 drm
* modules but is required by the Sparc driver.
*/
if (dev->driver->kernel_context_switch_unlock)
dev->driver->kernel_context_switch_unlock(dev, &lock);
else {
drm_lock_transfer( dev, &dev->lock.hw_lock->lock,
DRM_KERNEL_CONTEXT );
if ( drm_lock_free( dev, &dev->lock.hw_lock->lock,
DRM_KERNEL_CONTEXT ) ) {
DRM_ERROR( "\n" );
}
}
unblock_all_signals();
return 0; return 0;
} }
...@@ -52,7 +187,7 @@ int DRM(noop)(struct inode *inode, struct file *filp, unsigned int cmd, ...@@ -52,7 +187,7 @@ int DRM(noop)(struct inode *inode, struct file *filp, unsigned int cmd,
* *
* Attempt to mark the lock as held by the given context, via the \p cmpxchg instruction. * Attempt to mark the lock as held by the given context, via the \p cmpxchg instruction.
*/ */
int DRM(lock_take)(__volatile__ unsigned int *lock, unsigned int context) int drm_lock_take(__volatile__ unsigned int *lock, unsigned int context)
{ {
unsigned int old, new, prev; unsigned int old, new, prev;
...@@ -90,7 +225,7 @@ int DRM(lock_take)(__volatile__ unsigned int *lock, unsigned int context) ...@@ -90,7 +225,7 @@ int DRM(lock_take)(__volatile__ unsigned int *lock, unsigned int context)
* Resets the lock file pointer. * Resets the lock file pointer.
* Marks the lock as held by the given context, via the \p cmpxchg instruction. * Marks the lock as held by the given context, via the \p cmpxchg instruction.
*/ */
int DRM(lock_transfer)(drm_device_t *dev, int drm_lock_transfer(drm_device_t *dev,
__volatile__ unsigned int *lock, unsigned int context) __volatile__ unsigned int *lock, unsigned int context)
{ {
unsigned int old, new, prev; unsigned int old, new, prev;
...@@ -115,7 +250,7 @@ int DRM(lock_transfer)(drm_device_t *dev, ...@@ -115,7 +250,7 @@ int DRM(lock_transfer)(drm_device_t *dev,
* Marks the lock as not held, via the \p cmpxchg instruction. Wakes any task * Marks the lock as not held, via the \p cmpxchg instruction. Wakes any task
* waiting on the lock queue. * waiting on the lock queue.
*/ */
int DRM(lock_free)(drm_device_t *dev, int drm_lock_free(drm_device_t *dev,
__volatile__ unsigned int *lock, unsigned int context) __volatile__ unsigned int *lock, unsigned int context)
{ {
unsigned int old, new, prev; unsigned int old, new, prev;
...@@ -147,7 +282,7 @@ int DRM(lock_free)(drm_device_t *dev, ...@@ -147,7 +282,7 @@ int DRM(lock_free)(drm_device_t *dev,
* \return one if the signal should be delivered normally, or zero if the * \return one if the signal should be delivered normally, or zero if the
* signal should be blocked. * signal should be blocked.
*/ */
int DRM(notifier)(void *priv) int drm_notifier(void *priv)
{ {
drm_sigdata_t *s = (drm_sigdata_t *)priv; drm_sigdata_t *s = (drm_sigdata_t *)priv;
unsigned int old, new, prev; unsigned int old, new, prev;
......
/** /**
* \file drm_fops.h * \file drm_memory.h
* File operations for DRM * Memory management wrappers for DRM
* *
* \author Rickard E. (Rik) Faith <faith@valinux.com> * \author Rickard E. (Rik) Faith <faith@valinux.com>
* \author Daryll Strauss <daryll@valinux.com>
* \author Gareth Hughes <gareth@valinux.com> * \author Gareth Hughes <gareth@valinux.com>
*/ */
/* /*
* Created: Mon Jan 4 08:58:31 1999 by faith@valinux.com * Created: Thu Feb 4 14:00:34 1999 by faith@valinux.com
* *
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
...@@ -34,123 +33,149 @@ ...@@ -34,123 +33,149 @@
* OTHER DEALINGS IN THE SOFTWARE. * OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include <linux/config.h>
#include <linux/highmem.h>
#include "drmP.h" #include "drmP.h"
#include <linux/poll.h>
#ifdef DEBUG_MEMORY
#include "drm_memory_debug.h"
#else
/** No-op. */
void drm_mem_init(void)
{
}
/** /**
* Called whenever a process opens /dev/drm. * Called when "/proc/dri/%dev%/mem" is read.
* *
* \param inode device inode. * \param buf output buffer.
* \param filp file pointer. * \param start start of output data.
* \param dev device. * \param offset requested start offset.
* \return zero on success or a negative number on failure. * \param len requested number of bytes.
* \param eof whether there is no more data to return.
* \param data private data.
* \return number of written bytes.
* *
* Creates and initializes a drm_file structure for the file private data in \p * No-op.
* filp and add it into the double linked list in \p dev.
*/ */
int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev) int drm_mem_info(char *buf, char **start, off_t offset,
int len, int *eof, void *data)
{ {
int minor = iminor(inode); return 0;
drm_file_t *priv; }
int ret;
/** Wrapper around kmalloc() */
if (filp->f_flags & O_EXCL) return -EBUSY; /* No exclusive opens */ void *drm_calloc(size_t nmemb, size_t size, int area)
if (!DRM(cpu_valid)()) return -EINVAL; {
void *addr;
DRM_DEBUG("pid = %d, minor = %d\n", current->pid, minor);
addr = kmalloc(size * nmemb, GFP_KERNEL);
priv = DRM(alloc)(sizeof(*priv), DRM_MEM_FILES); if (addr != NULL)
if(!priv) return -ENOMEM; memset((void *)addr, 0, size * nmemb);
memset(priv, 0, sizeof(*priv)); return addr;
filp->private_data = priv; }
priv->uid = current->euid; EXPORT_SYMBOL(drm_calloc);
priv->pid = current->pid;
priv->minor = minor; /** Wrapper around kmalloc() and kfree() */
priv->dev = dev; void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area)
priv->ioctl_count = 0; {
priv->authenticated = capable(CAP_SYS_ADMIN); void *pt;
priv->lock_count = 0;
if (dev->fn_tbl.open_helper) {
ret=dev->fn_tbl.open_helper(dev, priv);
if (ret < 0)
goto out_free;
}
down(&dev->struct_sem); if (!(pt = kmalloc(size, GFP_KERNEL))) return NULL;
if (!dev->file_last) { if (oldpt && oldsize) {
priv->next = NULL; memcpy(pt, oldpt, oldsize);
priv->prev = NULL; kfree(oldpt);
dev->file_first = priv;
dev->file_last = priv;
} else {
priv->next = NULL;
priv->prev = dev->file_last;
dev->file_last->next = priv;
dev->file_last = priv;
} }
up(&dev->struct_sem); return pt;
}
#ifdef __alpha__ /**
/* * Allocate pages.
* Default the hose *
* \param order size order.
* \param area memory area. (Not used.)
* \return page address on success, or zero on failure.
*
* Allocate and reserve free pages.
*/ */
if (!dev->hose) { unsigned long drm_alloc_pages(int order, int area)
struct pci_dev *pci_dev; {
pci_dev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, NULL); unsigned long address;
if (pci_dev) { unsigned long bytes = PAGE_SIZE << order;
dev->hose = pci_dev->sysdata; unsigned long addr;
pci_dev_put(pci_dev); unsigned int sz;
}
if (!dev->hose) {
struct pci_bus *b = pci_bus_b(pci_root_buses.next);
if (b) dev->hose = b->sysdata;
}
}
#endif
address = __get_free_pages(GFP_KERNEL, order);
if (!address)
return 0; return 0;
out_free:
DRM(free)(priv, sizeof(*priv), DRM_MEM_FILES); /* Zero */
filp->private_data=NULL; memset((void *)address, 0, bytes);
return ret;
/* Reserve */
for (addr = address, sz = bytes;
sz > 0;
addr += PAGE_SIZE, sz -= PAGE_SIZE) {
SetPageReserved(virt_to_page(addr));
}
return address;
} }
/** No-op. */ /**
int DRM(flush)(struct file *filp) * Free pages.
*
* \param address address of the pages to free.
* \param order size order.
* \param area memory area. (Not used.)
*
* Unreserve and free pages allocated by alloc_pages().
*/
void drm_free_pages(unsigned long address, int order, int area)
{ {
drm_file_t *priv = filp->private_data; unsigned long bytes = PAGE_SIZE << order;
drm_device_t *dev = priv->dev; unsigned long addr;
unsigned int sz;
if (!address)
return;
/* Unreserve */
for (addr = address, sz = bytes;
sz > 0;
addr += PAGE_SIZE, sz -= PAGE_SIZE) {
ClearPageReserved(virt_to_page(addr));
}
DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n", free_pages(address, order);
current->pid, (long)old_encode_dev(dev->device), dev->open_count);
return 0;
} }
/** No-op. */
int DRM(fasync)(int fd, struct file *filp, int on)
{
drm_file_t *priv = filp->private_data;
drm_device_t *dev = priv->dev;
int retcode;
DRM_DEBUG("fd = %d, device = 0x%lx\n", fd, (long)old_encode_dev(dev->device)); #if __OS_HAS_AGP
retcode = fasync_helper(fd, filp, on, &dev->buf_async); /** Wrapper around agp_allocate_memory() */
if (retcode < 0) return retcode; DRM_AGP_MEM *drm_alloc_agp(int pages, u32 type)
return 0; {
return drm_agp_allocate_memory(pages, type);
} }
/** No-op. */ /** Wrapper around agp_free_memory() */
unsigned int DRM(poll)(struct file *filp, struct poll_table_struct *wait) int drm_free_agp(DRM_AGP_MEM *handle, int pages)
{ {
return 0; return drm_agp_free_memory(handle) ? 0 : -EINVAL;
} }
/** Wrapper around agp_bind_memory() */
int drm_bind_agp(DRM_AGP_MEM *handle, unsigned int start)
{
return drm_agp_bind_memory(handle, start);
}
/** No-op. */ /** Wrapper around agp_unbind_memory() */
ssize_t DRM(read)(struct file *filp, char __user *buf, size_t count, loff_t *off) int drm_unbind_agp(DRM_AGP_MEM *handle)
{ {
return 0; return drm_agp_unbind_memory(handle);
} }
#endif /* agp */
#endif /* debug_memory */
This diff is collapsed.
...@@ -167,7 +167,7 @@ void *DRM(alloc)(size_t size, int area) ...@@ -167,7 +167,7 @@ void *DRM(alloc)(size_t size, int area)
return pt; return pt;
} }
void *DRM(calloc)(size_t size, size_t nmemb, int area) void *DRM(calloc)(size_t nmemb, size_t size, int area)
{ {
void *addr; void *addr;
......
...@@ -100,11 +100,6 @@ static __inline__ int mtrr_del (int reg, unsigned long base, ...@@ -100,11 +100,6 @@ static __inline__ int mtrr_del (int reg, unsigned long base,
__put_user(val, uaddr) __put_user(val, uaddr)
/** 'malloc' without the overhead of DRM(alloc)() */
#define DRM_MALLOC(x) kmalloc(x, GFP_KERNEL)
/** 'free' without the overhead of DRM(free)() */
#define DRM_FREE(x,size) kfree(x)
#define DRM_GET_PRIV_WITH_RETURN(_priv, _filp) _priv = _filp->private_data #define DRM_GET_PRIV_WITH_RETURN(_priv, _filp) _priv = _filp->private_data
/** /**
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#define DEBUG_SCATTER 0 #define DEBUG_SCATTER 0
void DRM(sg_cleanup)( drm_sg_mem_t *entry ) void drm_sg_cleanup( drm_sg_mem_t *entry )
{ {
struct page *page; struct page *page;
int i; int i;
...@@ -50,18 +50,18 @@ void DRM(sg_cleanup)( drm_sg_mem_t *entry ) ...@@ -50,18 +50,18 @@ void DRM(sg_cleanup)( drm_sg_mem_t *entry )
vfree( entry->virtual ); vfree( entry->virtual );
DRM(free)( entry->busaddr, drm_free( entry->busaddr,
entry->pages * sizeof(*entry->busaddr), entry->pages * sizeof(*entry->busaddr),
DRM_MEM_PAGES ); DRM_MEM_PAGES );
DRM(free)( entry->pagelist, drm_free( entry->pagelist,
entry->pages * sizeof(*entry->pagelist), entry->pages * sizeof(*entry->pagelist),
DRM_MEM_PAGES ); DRM_MEM_PAGES );
DRM(free)( entry, drm_free( entry,
sizeof(*entry), sizeof(*entry),
DRM_MEM_SGLISTS ); DRM_MEM_SGLISTS );
} }
int DRM(sg_alloc)( struct inode *inode, struct file *filp, int drm_sg_alloc( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg ) unsigned int cmd, unsigned long arg )
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -82,7 +82,7 @@ int DRM(sg_alloc)( struct inode *inode, struct file *filp, ...@@ -82,7 +82,7 @@ int DRM(sg_alloc)( struct inode *inode, struct file *filp,
if ( copy_from_user( &request, argp, sizeof(request) ) ) if ( copy_from_user( &request, argp, sizeof(request) ) )
return -EFAULT; return -EFAULT;
entry = DRM(alloc)( sizeof(*entry), DRM_MEM_SGLISTS ); entry = drm_alloc( sizeof(*entry), DRM_MEM_SGLISTS );
if ( !entry ) if ( !entry )
return -ENOMEM; return -ENOMEM;
...@@ -92,22 +92,22 @@ int DRM(sg_alloc)( struct inode *inode, struct file *filp, ...@@ -92,22 +92,22 @@ int DRM(sg_alloc)( struct inode *inode, struct file *filp,
DRM_DEBUG( "sg size=%ld pages=%ld\n", request.size, pages ); DRM_DEBUG( "sg size=%ld pages=%ld\n", request.size, pages );
entry->pages = pages; entry->pages = pages;
entry->pagelist = DRM(alloc)( pages * sizeof(*entry->pagelist), entry->pagelist = drm_alloc( pages * sizeof(*entry->pagelist),
DRM_MEM_PAGES ); DRM_MEM_PAGES );
if ( !entry->pagelist ) { if ( !entry->pagelist ) {
DRM(free)( entry, sizeof(*entry), DRM_MEM_SGLISTS ); drm_free( entry, sizeof(*entry), DRM_MEM_SGLISTS );
return -ENOMEM; return -ENOMEM;
} }
memset(entry->pagelist, 0, pages * sizeof(*entry->pagelist)); memset(entry->pagelist, 0, pages * sizeof(*entry->pagelist));
entry->busaddr = DRM(alloc)( pages * sizeof(*entry->busaddr), entry->busaddr = drm_alloc( pages * sizeof(*entry->busaddr),
DRM_MEM_PAGES ); DRM_MEM_PAGES );
if ( !entry->busaddr ) { if ( !entry->busaddr ) {
DRM(free)( entry->pagelist, drm_free( entry->pagelist,
entry->pages * sizeof(*entry->pagelist), entry->pages * sizeof(*entry->pagelist),
DRM_MEM_PAGES ); DRM_MEM_PAGES );
DRM(free)( entry, drm_free( entry,
sizeof(*entry), sizeof(*entry),
DRM_MEM_SGLISTS ); DRM_MEM_SGLISTS );
return -ENOMEM; return -ENOMEM;
...@@ -116,13 +116,13 @@ int DRM(sg_alloc)( struct inode *inode, struct file *filp, ...@@ -116,13 +116,13 @@ int DRM(sg_alloc)( struct inode *inode, struct file *filp,
entry->virtual = vmalloc_32( pages << PAGE_SHIFT ); entry->virtual = vmalloc_32( pages << PAGE_SHIFT );
if ( !entry->virtual ) { if ( !entry->virtual ) {
DRM(free)( entry->busaddr, drm_free( entry->busaddr,
entry->pages * sizeof(*entry->busaddr), entry->pages * sizeof(*entry->busaddr),
DRM_MEM_PAGES ); DRM_MEM_PAGES );
DRM(free)( entry->pagelist, drm_free( entry->pagelist,
entry->pages * sizeof(*entry->pagelist), entry->pages * sizeof(*entry->pagelist),
DRM_MEM_PAGES ); DRM_MEM_PAGES );
DRM(free)( entry, drm_free( entry,
sizeof(*entry), sizeof(*entry),
DRM_MEM_SGLISTS ); DRM_MEM_SGLISTS );
return -ENOMEM; return -ENOMEM;
...@@ -148,7 +148,7 @@ int DRM(sg_alloc)( struct inode *inode, struct file *filp, ...@@ -148,7 +148,7 @@ int DRM(sg_alloc)( struct inode *inode, struct file *filp,
request.handle = entry->handle; request.handle = entry->handle;
if ( copy_to_user( argp, &request, sizeof(request) ) ) { if ( copy_to_user( argp, &request, sizeof(request) ) ) {
DRM(sg_cleanup)( entry ); drm_sg_cleanup( entry );
return -EFAULT; return -EFAULT;
} }
...@@ -197,11 +197,11 @@ int DRM(sg_alloc)( struct inode *inode, struct file *filp, ...@@ -197,11 +197,11 @@ int DRM(sg_alloc)( struct inode *inode, struct file *filp,
return 0; return 0;
failed: failed:
DRM(sg_cleanup)( entry ); drm_sg_cleanup( entry );
return -ENOMEM; return -ENOMEM;
} }
int DRM(sg_free)( struct inode *inode, struct file *filp, int drm_sg_free( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg ) unsigned int cmd, unsigned long arg )
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -225,7 +225,7 @@ int DRM(sg_free)( struct inode *inode, struct file *filp, ...@@ -225,7 +225,7 @@ int DRM(sg_free)( struct inode *inode, struct file *filp,
DRM_DEBUG( "sg free virtual = %p\n", entry->virtual ); DRM_DEBUG( "sg free virtual = %p\n", entry->virtual );
DRM(sg_cleanup)( entry ); drm_sg_cleanup( entry );
return 0; return 0;
} }
...@@ -210,9 +210,7 @@ unsigned long ffb_get_unmapped_area(struct file *filp, ...@@ -210,9 +210,7 @@ unsigned long ffb_get_unmapped_area(struct file *filp,
return addr; return addr;
} }
#include "drm_core.h" /* This functions must be here since it references drm_numdevs)
/* This functions must be here since it references DRM(numdevs)
* which drm_drv.h declares. * which drm_drv.h declares.
*/ */
static int ffb_presetup(drm_device_t *dev) static int ffb_presetup(drm_device_t *dev)
...@@ -227,13 +225,13 @@ static int ffb_presetup(drm_device_t *dev) ...@@ -227,13 +225,13 @@ static int ffb_presetup(drm_device_t *dev)
return -ENODEV; return -ENODEV;
/* Find our instance number by finding our device in dev structure */ /* Find our instance number by finding our device in dev structure */
for (i = 0; i < DRM(numdevs); i++) { for (i = 0; i < drm_numdevs; i++) {
temp_dev = &(DRM(device)[i]); temp_dev = &(drm_device[i]);
if(temp_dev == dev) if(temp_dev == dev)
break; break;
} }
if (i == DRM(numdevs)) if (i == drm_numdevs)
return -ENODEV; return -ENODEV;
ffb_priv = kmalloc(sizeof(ffb_dev_priv_t), GFP_KERNEL); ffb_priv = kmalloc(sizeof(ffb_dev_priv_t), GFP_KERNEL);
...@@ -311,12 +309,12 @@ void ffb_driver_register_fns(drm_device_t *dev) ...@@ -311,12 +309,12 @@ void ffb_driver_register_fns(drm_device_t *dev)
{ {
ffb_set_context_ioctls(); ffb_set_context_ioctls();
DRM(fops).get_unmapped_area = ffb_get_unmapped_area; DRM(fops).get_unmapped_area = ffb_get_unmapped_area;
dev->fn_tbl.release = ffb_driver_release; dev->driver.release = ffb_driver_release;
dev->fn_tbl.presetup = ffb_presetup; dev->driver.presetup = ffb_presetup;
dev->fn_tbl.pretakedown = ffb_driver_pretakedown; dev->driver.pretakedown = ffb_driver_pretakedown;
dev->fn_tbl.postcleanup = ffb_driver_postcleanup; dev->driver.postcleanup = ffb_driver_postcleanup;
dev->fn_tbl.kernel_context_switch = ffb_context_switch; dev->driver.kernel_context_switch = ffb_context_switch;
dev->fn_tbl.kernel_context_switch_unlock = ffb_driver_kernel_context_switch_unlock; dev->driver.kernel_context_switch_unlock = ffb_driver_kernel_context_switch_unlock;
dev->fn_tbl.get_map_ofs = ffb_driver_get_map_ofs; dev->driver.get_map_ofs = ffb_driver_get_map_ofs;
dev->fn_tbl.get_reg_ofs = ffb_driver_get_reg_ofs; dev->driver.get_reg_ofs = ffb_driver_get_reg_ofs;
} }
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment