Alan Coopersmith wrote:
> Garrett D'Amore wrote:
>
>> 1) The macros themselves that make use of _IOCPARM_MASK (_IOR, _IOW,
>> _IORW) are "private" to ON. That is, external code shouldn't be
>> directly using them.
>>
>
> Are they? I've been working to get our DRI/DRM (graphics direct
> rendering, not media rights/restrictions) changes upstream - currently
> the drm.h header exports the ioctl defintions as:
>
> #define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
>
> #define _IOC_NRBITS 8
> #define _IOC_TYPEBITS 8
> #define _IOC_SIZEBITS 14
> #define _IOC_DIRBITS 2
>
> #define _IOC_NRMASK ((1 << _IOC_NRBITS)-1)
> #define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1)
> #define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1)
> #define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1)
>
> #define _IOC_NRSHIFT 0
> #define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS)
> #define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS)
> #define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS)
>
> #define _IOC_NONE 0U
> #define _IOC_WRITE 1U
> #define _IOC_READ 2U
>
> #define _IOC(dir, type, nr, size) \
> (((dir) << _IOC_DIRSHIFT) | \
> ((type) << _IOC_TYPESHIFT) | \
> ((nr) << _IOC_NRSHIFT) | \
> ((size) << _IOC_SIZESHIFT))
>
> (For the full ugly header, see
> http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/common/io/drm/drm.h
> .)
>
> For the upstream integration, I was going to simplify, use the system
> provided definitions instead of making our own, and merge with
> the existing BSD code:
>
> #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) ||
> defined(__NetBSD__)
> || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__sun)
> #include <sys/ioccom.h>
> #define DRM_IOCTL_NR(n) ((n) & 0xff)
> #define DRM_IOC_VOID IOC_VOID
> #define DRM_IOC_READ IOC_OUT
> #define DRM_IOC_WRITE IOC_IN
> #define DRM_IOC_READWRITE IOC_INOUT
> #define DRM_IOC(dir, group, nr, size) _IOC(dir, group, nr, size)
> #endif
>
> #if defined(__sun) && !defined(_IOC)
> #define _IOC(dir, group, nr, size) \
> (dir == DRM_IOC_READWRITE ? _IOWRN(group, nr, size) : \
> (dir == DRM_IOC_WRITE ? _IOWN(group, nr, size) : \
> /* dir == DRM_IOC_READ */ _IORN(group, nr, size) ))
> #endif
>
> This is the interface between the DRM kernel modules in ON and the
> user space consumers in the X consolidation, but since ON doesn't
> deliver the drm.h header for some reason, X has a second copy that
> we use instead. (Unfortunately, the people who originally
> integrated this to ON & X aren't around any more to ask why.)
>
> If <sys/ioccom.h> added a _IOC like BSD, we'd not need any Solaris
> specific code, but I haven't gotten around to filing that RFE yet,
> and am not even sure what bug category to file against.
>
> What should we be doing here?
>
IMO, we should probably document these macros for real (with the fixed
definitions). For now, they are not documented on Solaris. Perhaps
"Sun Private" is appropriate for now.
-- Garrett
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code