diff options
Diffstat (limited to 'bsd-core/drm_fops.c')
-rw-r--r-- | bsd-core/drm_fops.c | 61 |
1 files changed, 40 insertions, 21 deletions
diff --git a/bsd-core/drm_fops.c b/bsd-core/drm_fops.c index 53af39cd..ed85a8de 100644 --- a/bsd-core/drm_fops.c +++ b/bsd-core/drm_fops.c @@ -30,14 +30,9 @@ * Gareth Hughes <gareth@valinux.com> */ -#define __NO_VERSION__ #include "drmP.h" - -#include <sys/signalvar.h> -#include <sys/poll.h> - -drm_file_t *DRM(find_file_by_proc)(drm_device_t *dev, DRM_OS_STRUCTPROC *p) +drm_file_t *DRM(find_file_by_proc)(drm_device_t *dev, DRM_STRUCTPROC *p) { #if __FreeBSD_version >= 500021 uid_t uid = p->td_proc->p_ucred->cr_svuid; @@ -56,7 +51,7 @@ drm_file_t *DRM(find_file_by_proc)(drm_device_t *dev, DRM_OS_STRUCTPROC *p) /* DRM(open) is called whenever a process opens /dev/drm. */ -int DRM(open_helper)(dev_t kdev, int flags, int fmt, DRM_OS_STRUCTPROC *p, +int DRM(open_helper)(dev_t kdev, int flags, int fmt, DRM_STRUCTPROC *p, drm_device_t *dev) { int m = minor(kdev); @@ -66,9 +61,9 @@ int DRM(open_helper)(dev_t kdev, int flags, int fmt, DRM_OS_STRUCTPROC *p, return EBUSY; /* No exclusive opens */ dev->flags = flags; if (!DRM(cpu_valid)()) - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); - DRM_DEBUG("pid = %d, minor = %d\n", DRM_OS_CURRENTPID, m); + DRM_DEBUG("pid = %d, minor = %d\n", DRM_CURRENTPID, m); /* FIXME: linux mallocs and bzeros here */ priv = (drm_file_t *) DRM(find_file_by_proc)(dev, p); @@ -89,15 +84,14 @@ int DRM(open_helper)(dev_t kdev, int flags, int fmt, DRM_OS_STRUCTPROC *p, priv->minor = m; priv->devXX = dev; priv->ioctl_count = 0; - priv->authenticated = !DRM_OS_CHECKSUSER; - lockmgr(&dev->dev_lock, LK_EXCLUSIVE, 0, p); + priv->authenticated = !DRM_SUSER(p); + DRM_LOCK; TAILQ_INSERT_TAIL(&dev->files, priv, link); - lockmgr(&dev->dev_lock, LK_RELEASE, 0, p); + DRM_UNLOCK; } - +#ifdef __FreeBSD__ kdev->si_drv1 = dev; - - +#endif return 0; } @@ -108,7 +102,7 @@ int DRM(open_helper)(dev_t kdev, int flags, int fmt, DRM_OS_STRUCTPROC *p, ssize_t DRM(read)(dev_t kdev, struct uio *uio, int ioflag) { - DRM_OS_DEVICE; + DRM_DEVICE; int left; int avail; int send; @@ -156,6 +150,9 @@ int DRM(write_string)(drm_device_t *dev, const char *s) int left = (dev->buf_rp + DRM_BSZ - dev->buf_wp) % DRM_BSZ; int send = strlen(s); int count; +#ifdef __NetBSD__ + struct proc *p; +#endif /* __NetBSD__ */ DRM_DEBUG("%d left, %d to send (%p, %p)\n", left, send, dev->buf_rp, dev->buf_wp); @@ -186,19 +183,33 @@ int DRM(write_string)(drm_device_t *dev, const char *s) } DRM_DEBUG("dev->buf_sigio=%p\n", dev->buf_sigio); +#ifdef __FreeBSD__ if (dev->buf_sigio) { DRM_DEBUG("dev->buf_sigio->sio_pgid=%d\n", dev->buf_sigio->sio_pgid); +#if __FreeBSD_version >= 500000 + pgsigio(&dev->buf_sigio, SIGIO, 0); +#else pgsigio(dev->buf_sigio, SIGIO, 0); +#endif /* __FreeBSD_version */ } +#endif /* __FreeBSD__ */ +#ifdef __NetBSD__ + if (dev->buf_pgid) { + DRM_DEBUG("dev->buf_pgid=%d\n", dev->buf_pgid); + if(dev->buf_pgid > 0) + gsignal(dev->buf_pgid, SIGIO); + else if(dev->buf_pgid && (p = pfind(-dev->buf_pgid)) != NULL) + psignal(p, SIGIO); +#endif /* __NetBSD__ */ DRM_DEBUG("waking\n"); wakeup(&dev->buf_rp); return 0; } -int DRM(poll)(dev_t kdev, int events, DRM_OS_STRUCTPROC *p) +int DRM(poll)(dev_t kdev, int events, DRM_STRUCTPROC *p) { - drm_device_t *dev = kdev->si_drv1; + DRM_DEVICE; int s; int revents = 0; @@ -217,7 +228,15 @@ int DRM(poll)(dev_t kdev, int events, DRM_OS_STRUCTPROC *p) int DRM(write)(dev_t kdev, struct uio *uio, int ioflag) { - DRM_DEBUG("pid = %d, device = %p, open_count = %d\n", - curproc->p_pid, ((drm_device_t *)kdev->si_drv1)->device, ((drm_device_t *)kdev->si_drv1)->open_count); - return 0; +#if DRM_DEBUG_CODE + DRM_DEVICE; +#endif +#ifdef __FreeBSD__ + DRM_DEBUG("pid = %d, device = %p, open_count = %d\n", + curproc->p_pid, dev->device, dev->open_count); +#elif defined(__NetBSD__) + DRM_DEBUG("pid = %d, device = %p, open_count = %d\n", + curproc->p_pid, &dev->device, dev->open_count); +#endif + return 0; } |