Moved ioctl defines into a dedicated header, with some additional defines. Load the output error field for nv cmds.

This commit is contained in:
yellows8 2017-11-12 23:27:42 -05:00
parent caa06c4d6c
commit 38cc12f02c
4 changed files with 47 additions and 34 deletions

View File

@ -35,6 +35,7 @@ extern "C" {
#include <switch/gfx/gfx.h>
#include <switch/gfx/parcel.h>
#include <switch/gfx/gfxproducer.h>
#include <switch/gfx/ioctl.h>
#ifdef __cplusplus
}

View File

@ -0,0 +1,40 @@
//The below defines are from Linux kernel ioctl.h.
#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)
/*
* Direction bits.
*/
#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))
/* used to create numbers */
#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0)
#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size))
#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size))
#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))
/* used to decode ioctl numbers.. */
#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)

View File

@ -1,37 +1,3 @@
//The below defines are from Linux kernel ioctl.h.
#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)
/*
* Direction bits.
*/
#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))
/* used to decode ioctl numbers.. */
#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)
typedef enum {
NVSERVTYPE_Default = -1,
NVSERVTYPE_Application = 0,

View File

@ -176,9 +176,11 @@ Result nvOpen(u32 *fd, const char *devicepath) {
u64 magic;
u64 result;
u32 fd;
u32 error;
} *resp = r.Raw;
rc = resp->result;
if (R_SUCCEEDED(rc)) rc = resp->error;
if (R_SUCCEEDED(rc)) *fd = resp->fd;
}
@ -231,9 +233,11 @@ Result nvIoctl(u32 fd, u32 request, void* argp) {
struct {
u64 magic;
u64 result;
u32 error;
} *resp = r.Raw;
rc = resp->result;
if (R_SUCCEEDED(rc)) rc = resp->error;
}
return rc;
@ -263,9 +267,11 @@ Result nvClose(u32 fd) {
struct {
u64 magic;
u64 result;
u32 error;
} *resp = r.Raw;
rc = resp->result;
if (R_SUCCEEDED(rc)) rc = resp->error;
}
return rc;