summaryrefslogtreecommitdiff
path: root/linux-core/xgi_misc.c
AgeCommit message (Expand)Author
2007-10-10Fix command list submission on big-endian.Ian Romanick
2007-10-03First round of byte-ordering fixes for PowerPC.Ian Romanick
2007-08-14Eliminate unused / useless ioctls.Ian Romanick
2007-08-14Clean up remaining C++ style comments.Ian Romanick
2007-08-14Clean up xgi_(en|dis)able_(mmio|ge) and move to xgi_misc.c.Ian Romanick
2007-07-31Refactor register dumping code.Ian Romanick
2007-07-30Use DRM_READ/DRM_WRITE macros instead of directly accessing MMIO space.Ian Romanick
2007-07-27Convert to new ioctl interface between core DRM and device-specific module.Ian Romanick
2007-07-24Fix license formatting.Ian Romanick
2007-07-19Initial pass at converting driver to DRM infrastructure.Ian Romanick
2007-07-16Eliminate several useless ioctls and associated cruft.Ian Romanick
2007-07-09Convert occurances of U32 to other types.Ian Romanick
2007-07-09Eliminiate fields in xgi_info that are duplicates of fields in pci_dev.Ian Romanick
2007-07-09Correct types that are shared with user mode.Ian Romanick
2007-07-05Remove XGI_IOCTL_CPUID and associated cruft.Ian Romanick
2007-07-05Major clean up of xgi_ge_irq_handlerIan Romanick
2007-07-05Convert weird rtdsc usage to get_cycles.Ian Romanick
2007-06-29Convert a few more U32 variables to more appropriate, generic types.Ian Romanick
2007-06-29Convert xgi_mem_location enum values to less generic names.Ian Romanick
2007-06-29Convert open coded list iterators to either list_for_each_entry or list_for_e...Ian Romanick
2007-06-29Replace U(8|16) with u(8|16).Ian Romanick
2007-06-29Replace BOOL with bool.Ian Romanick
2007-06-29Eliminate structure typedefsIan Romanick
2007-06-26Clean up warnings about unused variables and functions.Ian Romanick
2007-06-26Clean up mixed declarations and code.Ian Romanick
2007-06-26dos2unix and LindentIan Romanick
2007-06-26Initial XP10 code drop from XGI.Ian Romanick
class="hl com"> * OTHER DEALINGS IN THE SOFTWARE. * * Authors: * Rickard E. (Rik) Faith <faith@valinux.com> * Gareth Hughes <gareth@valinux.com> */ #include "drmP.h" static int DRM(hash_magic)(drm_magic_t magic) { return magic & (DRM_HASH_SIZE-1); } static drm_file_t *DRM(find_file)(drm_device_t *dev, drm_magic_t magic) { drm_file_t *retval = NULL; drm_magic_entry_t *pt; int hash = DRM(hash_magic)(magic); DRM_LOCK; for (pt = dev->magiclist[hash].head; pt; pt = pt->next) { if (pt->magic == magic) { retval = pt->priv; break; } } DRM_UNLOCK; return retval; } int DRM(add_magic)(drm_device_t *dev, drm_file_t *priv, drm_magic_t magic) { int hash; drm_magic_entry_t *entry; DRM_DEBUG("%d\n", magic); hash = DRM(hash_magic)(magic); entry = (drm_magic_entry_t*) DRM(alloc)(sizeof(*entry), DRM_MEM_MAGIC); if (!entry) return DRM_ERR(ENOMEM); memset(entry, 0, sizeof(*entry)); entry->magic = magic; entry->priv = priv; entry->next = NULL; DRM_LOCK; if (dev->magiclist[hash].tail) { dev->magiclist[hash].tail->next = entry; dev->magiclist[hash].tail = entry; } else { dev->magiclist[hash].head = entry; dev->magiclist[hash].tail = entry; } DRM_UNLOCK; return 0; } int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic) { drm_magic_entry_t *prev = NULL; drm_magic_entry_t *pt; int hash; DRM_DEBUG("%d\n", magic); hash = DRM(hash_magic)(magic); DRM_LOCK; for (pt = dev->magiclist[hash].head; pt; prev = pt, pt = pt->next) { if (pt->magic == magic) { if (dev->magiclist[hash].head == pt) { dev->magiclist[hash].head = pt->next; } if (dev->magiclist[hash].tail == pt) { dev->magiclist[hash].tail = prev; } if (prev) { prev->next = pt->next; } DRM_UNLOCK; return 0; } } DRM_UNLOCK; DRM(free)(pt, sizeof(*pt), DRM_MEM_MAGIC); return DRM_ERR(EINVAL); } int DRM(getmagic)(DRM_IOCTL_ARGS) { static drm_magic_t sequence = 0; drm_auth_t auth; DRM_DEVICE; DRM_PRIV; /* Find unique magic */ if (priv->magic) { auth.magic = priv->magic; } else { do { int old = sequence; auth.magic = old+1; if (!atomic_cmpset_int(&sequence, old, auth.magic)) continue; } while (DRM(find_file)(dev, auth.magic)); priv->magic = auth.magic; DRM(add_magic)(dev, priv, auth.magic); } DRM_DEBUG("%u\n", auth.magic); DRM_COPY_TO_USER_IOCTL((drm_auth_t *)data, auth, sizeof(auth)); return 0; } int DRM(authmagic)(DRM_IOCTL_ARGS) { drm_auth_t auth; drm_file_t *file; DRM_DEVICE; DRM_COPY_FROM_USER_IOCTL(auth, (drm_auth_t *)data, sizeof(auth)); DRM_DEBUG("%u\n", auth.magic); if ((file = DRM(find_file)(dev, auth.magic))) { file->authenticated = 1; DRM(remove_magic)(dev, auth.magic); return 0; } return DRM_ERR(EINVAL); }