mirror of
https://github.com/switchbrew/libnx.git
synced 2025-07-15 23:42:13 +02:00
Moved ioctl defines into a dedicated header, with some additional defines. Load the output error field for nv cmds.
This commit is contained in:
parent
caa06c4d6c
commit
38cc12f02c
@ -35,6 +35,7 @@ extern "C" {
|
|||||||
#include <switch/gfx/gfx.h>
|
#include <switch/gfx/gfx.h>
|
||||||
#include <switch/gfx/parcel.h>
|
#include <switch/gfx/parcel.h>
|
||||||
#include <switch/gfx/gfxproducer.h>
|
#include <switch/gfx/gfxproducer.h>
|
||||||
|
#include <switch/gfx/ioctl.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
40
nx/include/switch/gfx/ioctl.h
Normal file
40
nx/include/switch/gfx/ioctl.h
Normal 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)
|
||||||
|
|
@ -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 {
|
typedef enum {
|
||||||
NVSERVTYPE_Default = -1,
|
NVSERVTYPE_Default = -1,
|
||||||
NVSERVTYPE_Application = 0,
|
NVSERVTYPE_Application = 0,
|
||||||
|
@ -176,9 +176,11 @@ Result nvOpen(u32 *fd, const char *devicepath) {
|
|||||||
u64 magic;
|
u64 magic;
|
||||||
u64 result;
|
u64 result;
|
||||||
u32 fd;
|
u32 fd;
|
||||||
|
u32 error;
|
||||||
} *resp = r.Raw;
|
} *resp = r.Raw;
|
||||||
|
|
||||||
rc = resp->result;
|
rc = resp->result;
|
||||||
|
if (R_SUCCEEDED(rc)) rc = resp->error;
|
||||||
if (R_SUCCEEDED(rc)) *fd = resp->fd;
|
if (R_SUCCEEDED(rc)) *fd = resp->fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,9 +233,11 @@ Result nvIoctl(u32 fd, u32 request, void* argp) {
|
|||||||
struct {
|
struct {
|
||||||
u64 magic;
|
u64 magic;
|
||||||
u64 result;
|
u64 result;
|
||||||
|
u32 error;
|
||||||
} *resp = r.Raw;
|
} *resp = r.Raw;
|
||||||
|
|
||||||
rc = resp->result;
|
rc = resp->result;
|
||||||
|
if (R_SUCCEEDED(rc)) rc = resp->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
@ -263,9 +267,11 @@ Result nvClose(u32 fd) {
|
|||||||
struct {
|
struct {
|
||||||
u64 magic;
|
u64 magic;
|
||||||
u64 result;
|
u64 result;
|
||||||
|
u32 error;
|
||||||
} *resp = r.Raw;
|
} *resp = r.Raw;
|
||||||
|
|
||||||
rc = resp->result;
|
rc = resp->result;
|
||||||
|
if (R_SUCCEEDED(rc)) rc = resp->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
Loading…
Reference in New Issue
Block a user