NV services: Difference between revisions

No edit summary
No edit summary
 
(47 intermediate revisions by 5 users not shown)
Line 1: Line 1:
The Switch uses a customized NVIDIA driver.
= nvdrv, nvdrv:a, nvdrv:s, nvdrv:t =
= nvdrv, nvdrv:a, nvdrv:s, nvdrv:t =
This is "nns::nvdrv::INvDrvServices".
This is "nns::nvdrv::INvDrvServices".
Main NVIDIA driver service.


Each service is used by:
Each service is used by:
* "nvdrv": Applications.
* "nvdrv": Applications.
** [[#Permissions|Permission]] mask is [3.0.0+] 0xA82B ([1.0.0-2.3.0] 0x2B).
** [[#NvDrvPermission|Permission]] mask is [11.0.0+] 0xA83B ([1.0.0-2.3.0] 0x2B, [3.0.0+] 0xA82B).
* "nvdrv:a": Applets.
* "nvdrv:a": Applets.
** [[#Permissions|Permission]] mask is [3.0.0+] 0x10A9 ([1.0.0-2.3.0] 0xA9).
** [[#NvDrvPermission|Permission]] mask is [3.0.0+] 0x10A9 ([1.0.0-2.3.0] 0xA9).
* "nvdrv:s": Sysmodules.
* "nvdrv:s": Sysmodules.
** [[#Permissions|Permission]] mask is [3.0.0+] 0x439E ([1.0.0-2.3.0] 0x39E).
** [[#NvDrvPermission|Permission]] mask is [3.0.0+] 0x439E ([1.0.0-2.3.0] 0x39E).
* "nvdrv:t": Factory.
* "nvdrv:t": Factory.
** [[#Permissions|Permission]] mask is 0xFFFFFFFF.
** [[#NvDrvPermission|Permission]] mask is 0xFFFFFFFF.


{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 50: Line 46:


== Open ==
== Open ==
Takes a type-0x5 input buffer for the device-path. Returns the output 32bit '''fd''' and the u32 '''error_code'''.
Takes a type-0x5 input buffer '''Path'''. Returns two output u32s '''FdOut''' and '''Err'''.


== Ioctl ==
== Ioctl ==
Takes a 32bit '''fd''', an u32 '''ioctl_cmd''', a type-0x21 input buffer, and a type-0x22 output buffer. Returns an output u32 ('''error_code''').
Takes two input u32s '''Fd''' and '''Iocode''', a type-0x21 input buffer and a type-0x22 output buffer. Returns an output u32 '''Err'''.


The addr/size for send/recv buffers are only set when the associated direction bit is set in the ioctl cmd (addr/size = 0 otherwise).
The addr/size for send/recv buffers are only set when the associated direction bit is set in the ioctl cmd (addr/size = 0 otherwise).


== Close ==
== Close ==
Takes a 32bit '''fd'''. Returns an output u32 ('''error_code''').
Takes an input u32 '''Fd'''. Returns an output u32 '''Err'''.


== Initialize ==
== Initialize ==
Takes two copy-handles ('''current_process''' and '''transfer_memory''') and an input u32 ('''transfer_memory_size'''). Returns an output u32 ('''error_code''').
Takes an input Process handle, an input TransferMemory handle and an input u32 '''Size'''. Returns an output u32 '''Err'''.


Webkit applet creates the transfer-memory with perm = 0 and size 0x300000.
Webkit applet creates the TransferMemory with perm == 0 and size == 0x300000.


== QueryEvent ==
== QueryEvent ==
Takes two input u32s ('''fd''' and '''event_id'''), with the second word immediately after the first one. Returns an output u32 ('''error_code''') and a copy-handle ('''event_handle''').
Takes two input u32s '''Fd''' and '''EvtId'''. Returns an output u32 '''Err''' and an output Event handle.


QueryEvent is only supported on (and implemented differently on):
QueryEvent is only supported on (and implemented differently on):
* /dev/nvhost-gpu
* /dev/nvhost-gpu
** 1: SmException_BptIntReport
** EvtId=1: SmException_BptIntReport
** 2: SmException_BptPauseReport
** EvtId=2: SmException_BptPauseReport
** 3: ErrorNotifierEvent
** EvtId=3: ErrorNotifierEvent
* /dev/nvhost-ctrl: Used to get events for SyncPts.
* /dev/nvhost-ctrl: Used to get events for syncpts.
** If bit31-28 is 1, then lower 16-bits contain event_slot, bit27-16 contain syncpt_number.  
** EvtId=(event_slot | ((syncpt_id & 0xFFF) << 16) | (is_valid << 28)): New format used by [[#NVHOST_IOCTL_CTRL_SYNCPT_WAIT_EVENT|NVHOST_IOCTL_CTRL_SYNCPT_WAIT_EVENT]]/[[#NVHOST_IOCTL_CTRL_SYNCPT_WAIT_EVENT_EX|NVHOST_IOCTL_CTRL_SYNCPT_WAIT_EVENT_EX]].
** If bit31-28 is 0, then lower 4-bits contain event_slot, bit31-4 contains syncpt_number.
** EvtId=(event_slot | (syncpt_id << 4)): Old format used by [[#NVHOST_IOCTL_CTRL_SYNCPT_WAITEX|NVHOST_IOCTL_CTRL_SYNCPT_WAITEX]].
* /dev/nvhost-ctrl-gpu
* /dev/nvhost-ctrl-gpu
** 1: Returns error_event_handle.
** EvtId=1: Returns error_event_handle.
** 2: Returns unknown event.
** EvtId=2: Returns unknown event.
* /dev/nvhost-dbg-gpu
* /dev/nvhost-dbg-gpu
** Ignores event_id.
** Ignores EvtId.


== MapSharedMem ==
== MapSharedMem ==
Takes a copy-handle ('''transfer_memory''') and two input u32s ('''fd''' and '''nvmap_handle'''). Returns an output u32 ('''error_code''').
Takes an input TransferMemory handle and two input u32s '''Fd''' and '''HMem'''. Returns an output u32 '''Err'''.
 
'''HMem''' is a [[#/dev/nvmap|/dev/nvmap]] memory handle.


== GetStatus ==
== GetStatus ==
Takes no input. Returns 0x10-bytes and an output u32 ('''error_code''').
Takes no input. Returns an output [[#NvDrvStatus]] and an output u32 '''Err'''.


== SetAruidWithoutCheck ==
== SetAruidWithoutCheck ==
Takes an input u64 which must [[IPC_Marshalling|match]] the user-process PID ([[Applet_Manager_services#AppletResourceUserId|AppletResourceUserId]]). Returns an output u32 ('''error_code''').
Takes an input u64 '''Aruid'''. Returns an output u32 '''Err'''.
 
'''Aruid''' must [[IPC_Marshalling|match]] the current [[Applet_Manager_services#AppletResourceUserId|AppletResourceUserId]].


== SetAruid ==
== SetAruid ==
Takes a PID-descriptor and an u64 which must [[IPC_Marshalling|match]] the user-process PID ([[Applet_Manager_services#AppletResourceUserId|AppletResourceUserId]]). Returns an output u32 ('''error_code''').
Takes a PID-descriptor and an input [[Applet_Manager_services#AppletResourceUserId|AppletResourceUserId]]. Returns an output u32 '''Err'''.


== DumpStatus ==
== DumpStatus ==
No input or output.
No input/output.


== InitializeDevtools ==
== InitializeDevtools ==
Takes a copy-handle ('''transfer_memory''') and an input u32 ('''transfer_memory_size'''). Returns an output u32 ('''error_code''').
Takes an input TransferMemory handle and an input u32 '''Size'''. Returns an output u32 '''Err'''.


== Ioctl2 ==
== Ioctl2 ==
Takes a type-0x21 buffer, a type-0x22 buffer, a type-0x21 buffer, and two input u32s. Returns an output u32 ('''error_code''').
Takes two input u32s '''Fd''' and '''Iocode''', two type-0x21 input buffers and a type-0x22 output buffer. Returns an output u32 '''Err'''.


== Ioctl3 ==
== Ioctl3 ==
Takes a type-0x21 buffer, a type-0x22 buffer, another type-0x22 buffer, and two input u32s. Returns an output u32 (error_code).
Takes two input u32s '''Fd''' and '''Iocode''', a type-0x21 input buffer and two type-0x22 output buffers. Returns an output u32 '''Err'''.
Cmdhdr_word1 is 0x100B instead of 0xC0B.


== SetGraphicsFirmwareMemoryMarginEnabled ==
== SetGraphicsFirmwareMemoryMarginEnabled ==
Line 112: Line 111:
This sets a boolean value based on the input u64 and the value of the "nv!nv_graphics_firmware_memory_margin" system configuration, but only for "nvdrv" (the other services default to false).
This sets a boolean value based on the input u64 and the value of the "nv!nv_graphics_firmware_memory_margin" system configuration, but only for "nvdrv" (the other services default to false).


Official user-processes starting with 3.0.0 now use this at the end of nvdrv service init with value 0x1.
[3.0.0+] Official user-processes now use this at the end of nvdrv service init with value 0x1.
 
= nvmemp =
This is "nv::MemoryProfiler::IMemoryProfiler".


= Permissions =
/dev/nvhost-ctrl sends the ioctl NVHOST_IOCTL_CTRL_GET_CONFIG to check the config "nv!NV_MEMORY_PROFILER". If config_str returns "1", the application attempts to use nvmemp.
Each nvdrv service is initialized with a bitfield that controls access to nodes and other operations.


{| class="wikitable" border="1"
{| class="wikitable" border="1"
!  Bits
!  Name
!  Description
|-
|-
| 0
! Cmd || Name
| NvDrvPermission_Gpu
| Can access [[#Channels|/dev/nvhost-gpu]], [[#/dev/nvhost-ctrl-gpu|/dev/nvhost-ctrl-gpu]] and [[#/dev/nvhost-as-gpu|/dev/nvhost-as-gpu]].
|-
|-
| 1
| 0 || [[#Open_2|Open]]
| NvDrvPermission_GpuDebug
| Can access [[#/dev/nvhost-dbg-gpu|/dev/nvhost-dbg-gpu]] and [[#/dev/nvhost-prof-gpu|/dev/nvhost-prof-gpu]].
|-
|-
| 2
| 1 || [[#GetPid|GetPid]]
| NvDrvPermission_GpuSchedule
|}
| Can access [[#/dev/nvsched-ctrl|/dev/nvsched-ctrl]].
 
== Open ==
Takes an input TransferMemory handle and an input u32 '''Size'''. No output.
 
== GetPid ==
No input. Returns an output u32 '''Pid'''.
 
= nvdrvdbg =
This is "nns::nvdrv::INvDrvDebugFSServices".
 
{| class="wikitable" border="1"
|-
|-
| 3
! Cmd || Name
| NvDrvPermission_VIC
| Can access [[#Channels|/dev/nvhost-vic]].
|-
|-
| 4
| 0 || [[#DebugFSOpen]]
| NvDrvPermission_VideoEncoder
|-
| Can access [[#Channels|/dev/nvhost-msenc]].
| 1 || [[#DebugFSClose]]
|-
|-
| 5
| 2 || [[#GetDebugFSKeys]]
| NvDrvPermission_VideoDecoder
| Can access [[#Channels|/dev/nvhost-nvdec]].
|-
|-
| 6
| 3 || [[#GetDebugFSValue]]
| NvDrvPermission_TSEC
| Can access [[#Channels|/dev/nvhost-tsec]].
|-
|-
| 7
| 4 || [[#SetDebugFSValue]]
| NvDrvPermission_JPEG
|}
| Can access [[#Channels|/dev/nvhost-nvjpg]].
 
== DebugFSOpen ==
Takes an input Process handle. Returns an output u32 '''Handle'''.
 
== DebugFSClose ==
Takes an input u32 '''Handle'''. No output.
 
== GetDebugFSKeys ==
Takes an input u32 '''Handle''' and a type-0x6 output buffer '''OutValueBuf'''. Returns an output u32 '''Err'''.
 
== GetDebugFSValue ==
Takes an input u32 '''Handle''', a type-0x5 input buffer '''InKeyBuf''' and a type-0x6 output buffer '''OutValueBuf'''. Returns an output u32 '''Err'''.
 
== SetDebugFSValue ==
Takes an input u32 '''Handle''' and two type-0x5 input buffers '''InKeyBuf''' and '''InValueBuf'''. Returns an output u32 '''Err'''.
 
= nvgem:c =
This is "nv::gemcontrol::INvGemControl".
 
{| class="wikitable" border="1"
|-
|-
| 8
! Cmd || Name
| NvDrvPermission_Display
| Can access [[#Channels|/dev/nvhost-display]], [[#/dev/nvcec-ctrl|/dev/nvcec-ctrl]], [[#/dev/nvhdcp_up-ctrl|/dev/nvhdcp_up-ctrl]], [[#/dev/nvdisp-ctrl|/dev/nvdisp-ctrl]], [[#/dev/nvdisp-disp0, /dev/nvdisp-disp1|/dev/nvdisp-disp0]], [[#/dev/nvdisp-disp0, /dev/nvdisp-disp1|/dev/nvdisp-disp1]], [[#/dev/nvdcutil-disp0, /dev/nvdcutil-disp1|/dev/nvdcutil-disp0]] and [[#/dev/nvdcutil-disp0, /dev/nvdcutil-disp1|/dev/nvdcutil-disp1]].
|-
|-
| 9
| 0 || [[#Initialize_2|Initialize]]
| NvDrvPermission_ImportMemory
| Can duplicate [[#/dev/nvmap|nvmap]] handles from other processes with [[#NVMAP_IOC_FROM_ID|NVMAP_IOC_FROM_ID]].
|-
|-
| 10
| 1 || [[#GetEventHandle|GetEventHandle]]
| NvDrvPermission_NoCheckedAruid
| Can use [[#SetAruidWithoutCheck|SetAruidWithoutCheck]].
|-
|-
| 11
| 2 || [[#ControlNotification|ControlNotification]]
|
|-
| Can use [[#SetGraphicsFirmwareMemoryMarginEnabled|SetGraphicsFirmwareMemoryMarginEnabled]].
| 3 || [[#SetNotificationPerm|SetNotificationPerm]]
|-
|-
| 12
| 4 || [[#SetCoreDumpPerm|SetCoreDumpPerm]]
|
| Can duplicate exported [[#/dev/nvmap|nvmap]] handles from other processes with [[#NVMAP_IOC_FROM_ID|NVMAP_IOC_FROM_ID]].
|-
|-
| 13
| 5 || [1.0.0-4.1.0] [[#GetAruid|GetAruid]]
|
|  
|-
|-
| 14
| 6 || [[#Reset|Reset]]
|
| Can use [[#NVMAP_IOC_EXPORT_FOR_ARUID|NVMAP_IOC_EXPORT_FOR_ARUID]] and [[#NVMAP_IOC_REMOVE_EXPORT_FOR_ARUID|NVMAP_IOC_REMOVE_EXPORT_FOR_ARUID]].
|-
|-
| 15
| 7 || [3.0.0+] [[#GetAruid2|GetAruid2]]
|
|  
|}
|}


Nodes [[#/dev/nvmap|/dev/nvmap]], [[#/dev/nvhost-ctrl|/dev/nvhost-ctrl]] and [[#/dev/nverpt-ctrl|/dev/nverpt-ctrl]] are always accessible.
== Initialize ==
No input. Returns an output u32 '''Err'''.
 
== GetEventHandle ==
No input. Returns an output Event handle and an output u32 '''Err'''.
 
== ControlNotification ==
Takes an input bool '''Enable'''. Returns an output u32 '''Err'''.
 
== SetNotificationPerm ==
Takes an input u64 '''Aruid''' and an input bool '''Enable'''. Returns an output u32 '''Err'''.
 
== SetCoreDumpPerm ==
Takes an input u64 '''Aruid''' and an input bool '''Enable'''. Returns an output u32 '''Err'''.
 
== GetAruid ==
No input. Returns an output u64 '''Aruid''' and an output u32 '''Err'''.
 
== Reset ==
No input. Returns an output u32 '''Err'''.


= Ioctls =
== GetAruid2 ==
The ioctl number is generated with the following primitive (see Linux kernel):
Unofficial name.


#define _IOC(inout, group, num, len) \
No input. Returns an output u64 '''Aruid''', an output bool '''IsCoreDumpEnabled''' and an output u32 '''Err'''.
    (inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num))


The following table contains known ioctls.
= nvgem:cd =
This is "nv::gemcoredump::INvGemCoreDump".


== /dev/nvhost-ctrl ==
{| class="wikitable" border="1"
{| class="wikitable" border="1"
! Value || Direction || Size || Description
|-
|-
| 0xC0080014 || Inout || 8 || [[#NVHOST_IOCTL_CTRL_SYNCPT_READ]]
! Cmd || Name
|-
|-
| 0x40040015 || In || 4 || [[#NVHOST_IOCTL_CTRL_SYNCPT_INCR]]
| 0 || [[#Initialize_3|Initialize]]
|-
| 0xC00C0016 || Inout || 12 || [[#NVHOST_IOCTL_CTRL_SYNCPT_WAIT]]
|-
| 0x40080017 || In || 8 || [[#NVHOST_IOCTL_CTRL_MODULE_MUTEX]]
|-
| 0xC0180018 || Inout || 24 || [[#NVHOST_IOCTL_CTRL_MODULE_REGRDWR]]
|-
| 0xC0100019 || Inout || 16 || [[#NVHOST_IOCTL_CTRL_SYNCPT_WAITEX]]
|-
| 0xC008001A || Inout || 8 || [[#NVHOST_IOCTL_CTRL_SYNCPT_READ_MAX]]
|-
| 0xC183001B || Inout || 387 || [[#NVHOST_IOCTL_CTRL_GET_CONFIG]]
|-
| 0xC004001C || Inout || 4 || [[#NVHOST_IOCTL_CTRL_SYNCPT_CLEAR_EVENT_WAIT]]
|-
| 0xC010001D || Inout || 16 || [[#NVHOST_IOCTL_CTRL_SYNCPT_EVENT_WAIT]]
|-
| 0xC010001E || Inout || 16 || [[#NVHOST_IOCTL_CTRL_SYNCPT_EVENT_WAIT_ASYNC]]
|-
|-
| 0xC004001F || Inout || 4 || [[#NVHOST_IOCTL_CTRL_SYNCPT_REGISTER_EVENT]]
| 1 || [[#GetAruid_2|GetAruid]]
|-
|-
| 0xC0040020 || Inout || 4 || [[#NVHOST_IOCTL_CTRL_SYNCPT_UNREGISTER_EVENT]]
| 2 || [1.0.0-8.1.0] [[#ReadNextBlock|ReadNextBlock]]
|-
|-
| 0x40080021 || In || 8 || [[#NVHOST_IOCTL_CTRL_SYNCPT_FREE_EVENTS]]
| 3 || [8.0.0+] [[#GetNextBlockSize|GetNextBlockSize]]
|-
|-
| 0xC0040022 || Inout || 4 || [[#NVHOST_IOCTL_CTRL_GET_MAX_EVENT_FIFO_CHANNEL]]
| 4 || [8.0.0+] [[#ReadNextBlock2|ReadNextBlock2]]
|}
|}


=== NVHOST_IOCTL_CTRL_SYNCPT_READ ===
== Initialize ==
Identical to Linux driver.
No input. Returns an output u32 '''Err'''.
 
== GetAruid ==
No input. Returns an output u64 '''Aruid''' and an output u32 '''Err'''.


  struct {
== ReadNextBlock ==
    __in  u32 id;
Takes a type-0x6 output buffer. Returns an output u32 '''Err'''.
    __out u32 value;
  };


=== NVHOST_IOCTL_CTRL_SYNCPT_INCR ===
== GetNextBlockSize ==
Identical to Linux driver.
Unofficial name.


  struct {
No input. Returns an output u64 '''Size''' and an output u32 '''Err'''.
    __in u32 id;
  };


=== NVHOST_IOCTL_CTRL_SYNCPT_WAIT ===
== ReadNextBlock2 ==
Identical to Linux driver.
Unofficial name.
 
Takes a type-0x6 output buffer and two input u64s '''Size''' and '''Offset'''. Returns an output u64 '''OutSize''' and an output u32 '''Err'''.


  struct {
= nvdbg:d =
    __in u32 id;
This is "nns::nvdrv::INvDrvDebugSvcServices". This was added with [10.0.0+].
    __in u32 thresh;
    __in s32 timeout;
  };


=== NVHOST_IOCTL_CTRL_MODULE_MUTEX ===
This service has no commands.
Identical to Linux driver.


  struct {
= Ioctls =
    __in u32 id;
The ioctl number is generated with the following primitive (see Linux kernel):
    __in u32 lock;        // (0==unlock; 1==lock)
  };


=== NVHOST_IOCTL_CTRL_MODULE_REGRDWR ===
#define _IOC(inout, group, num, len) \
Identical to Linux driver. Uses 32-bit version and doesn't work.
    (inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num))


  struct {
The following table contains all known ioctls.
    __in u32 id;
    __in u32 num_offsets;
    __in u32 block_size;
    __in u32 offsets;
    __in u32 values;
    __in u32 write;
  };


=== NVHOST_IOCTL_CTRL_SYNCPT_WAITEX ===
== /dev/nvhost-ctrl ==
Identical to Linux driver.
{| class="wikitable" border="1"
! Value || Direction || Size || Description
|-
| 0xC0080014 || Inout || 8 || [[#NVHOST_IOCTL_CTRL_SYNCPT_READ]]
|-
| 0x40040015 || In || 4 || [[#NVHOST_IOCTL_CTRL_SYNCPT_INCR]]
|-
| 0xC00C0016 || Inout || 12 || [[#NVHOST_IOCTL_CTRL_SYNCPT_WAIT]]
|-
| 0x40080017 || In || 8 || [[#NVHOST_IOCTL_CTRL_MODULE_MUTEX]]
|-
| 0xC0180018 || Inout || 24 || [[#NVHOST_IOCTL_CTRL_MODULE_REGRDWR]]
|-
| 0xC0100019 || Inout || 16 || [[#NVHOST_IOCTL_CTRL_SYNCPT_WAITEX]]
|-
| 0xC008001A || Inout || 8 || [[#NVHOST_IOCTL_CTRL_SYNCPT_READ_MAX]]
|-
| 0xC183001B || Inout || 387 || [[#NVHOST_IOCTL_CTRL_GET_CONFIG]]
|-
| 0xC004001C || Inout || 4 || [[#NVHOST_IOCTL_CTRL_SYNCPT_CLEAR_EVENT_WAIT]]
|-
| 0xC010001D || Inout || 16 || [[#NVHOST_IOCTL_CTRL_SYNCPT_WAIT_EVENT]]
|-
| 0xC010001E || Inout || 16 || [[#NVHOST_IOCTL_CTRL_SYNCPT_WAIT_EVENT_EX]]
|-
| 0xC004001F || Inout || 4 || [[#NVHOST_IOCTL_CTRL_SYNCPT_ALLOC_EVENT]]
|-
| 0xC0040020 || Inout || 4 || [[#NVHOST_IOCTL_CTRL_SYNCPT_FREE_EVENT]]
|-
| 0x40080021 || In || 8 || [[#NVHOST_IOCTL_CTRL_SYNCPT_FREE_EVENT_BATCH]]
|-
| 0xC0040022 || Inout || 4 || [[#NVHOST_IOCTL_CTRL_SYNCPT_GET_SHIFT]]
|}


  struct {
=== NVHOST_IOCTL_CTRL_SYNCPT_READ ===
    __in  u32 id;
    __in  u32 thresh;
    __in  s32 timeout;
    __out u32 value;
  };
 
=== NVHOST_IOCTL_CTRL_SYNCPT_READ_MAX ===
Identical to Linux driver.
Identical to Linux driver.


Line 294: Line 309:
   };
   };


=== NVHOST_IOCTL_CTRL_GET_CONFIG ===
=== NVHOST_IOCTL_CTRL_SYNCPT_INCR ===
Returns configured settings. Not available in production mode.
Identical to Linux driver.


   struct {
   struct {
     __in char domain_str[0x41];      // "nv"
     __in u32 id;
    __in char param_str[0x41];
    __out char config_str[0x101];
   };
   };


=== NVHOST_IOCTL_CTRL_SYNCPT_CLEAR_EVENT_WAIT ===
=== NVHOST_IOCTL_CTRL_SYNCPT_WAIT ===
Clears the wait signal of an event. Exclusive to the Switch.
Identical to Linux driver.


   struct {
   struct {
     __in u32 event_slot;         // ranges from 0x00 to 0x3F
     __in u32 id;
    __in u32 thresh;
    __in s32 timeout;
   };
   };


=== NVHOST_IOCTL_CTRL_SYNCPT_EVENT_WAIT ===
=== NVHOST_IOCTL_CTRL_MODULE_MUTEX ===
Waits on an event. If waiting fails, returns error code 0x05 (Timeout) and sets '''value''' to (('''syncpt_id''' << 0x10) | 0x10000000).
Identical to Linux driver.
 
Depending on '''threshold''', an '''event_slot''' may be returned for using with other event ioctls.


   struct {
   struct {
     __in   u32 syncpt_id;
     __in u32 id;
     __in   u32 threshold;
     __in u32 lock;       // 0=unlock, 1=lock
    __in    s32 timeout;
    __inout u32 value;          // in=event_slot (ignored); out=syncpt_value or event_slot
   };
   };


=== NVHOST_IOCTL_CTRL_SYNCPT_EVENT_WAIT_ASYNC ===
=== NVHOST_IOCTL_CTRL_MODULE_REGRDWR ===
Waits on an event (async version). If waiting fails, returns error code 0x0B (BadValue).
Identical to Linux driver. Uses 32-bit version and doesn't work.
 
Depending on '''threshold''', an '''event_slot''' may be returned for using with other event ioctls.


   struct {
   struct {
     __in   u32 syncpt_id;
     __in u32 id;
     __in   u32 threshold;
     __in u32 num_offsets;
     __in   u32 timeout;
     __in u32 block_size;
     __inout u32 value;           // in=event_slot (ignored); out=syncpt_value or event_slot
     __in u32 offsets;
    __in u32 values;
    __in u32 write;
   };
   };


=== NVHOST_IOCTL_CTRL_SYNCPT_REGISTER_EVENT ===
=== NVHOST_IOCTL_CTRL_SYNCPT_WAITEX ===
Registers an event. Exclusive to the Switch.  
Identical to Linux driver.


   struct {
   struct {
     __in u32 event_slot;         // ranges from 0x00 to 0x3F
     __in u32 id;
    __in  u32 thresh;
    __in  s32 timeout;
    __out u32 value;
   };
   };


=== NVHOST_IOCTL_CTRL_SYNCPT_UNREGISTER_EVENT ===
=== NVHOST_IOCTL_CTRL_SYNCPT_READ_MAX ===
Unregisters an event. Exclusive to the Switch.  
Identical to Linux driver.


   struct {
   struct {
     __in u32 event_slot;         // ranges from 0x00 to 0x3F
     __in u32 id;
    __out u32 value;
   };
   };


=== NVHOST_IOCTL_CTRL_SYNCPT_FREE_EVENTS ===
=== NVHOST_IOCTL_CTRL_GET_CONFIG ===
Frees events. Exclusive to the Switch.  
Returns configured settings. Not available in production mode.


   struct {
   struct {
     __in u64 events;             // 64-bit bitfield where each bit represents one event
     __in char name[0x41];       // "nv"
    __in char key[0x41];
    __out char value[0x101];
   };
   };


=== NVHOST_IOCTL_CTRL_GET_MAX_EVENT_FIFO_CHANNEL ===
=== NVHOST_IOCTL_CTRL_SYNCPT_CLEAR_EVENT_WAIT ===
If event FIFO is enabled, returns the maximum channel number. Exclusive to the Switch.
Clears the wait signal of a syncpt event.


   struct {
   struct {
     __out u32 max_channel;      // 0x00 (FIFO disabled) or 0x60 (FIFO enabled)
     __in u32 event_slot;      // 0x00 to 0x3F
   };
   };


== /dev/nvmap ==
=== NVHOST_IOCTL_CTRL_SYNCPT_WAIT_EVENT ===
{| class="wikitable" border="1"
Waits on a syncpt using events. If waiting fails, returns error code 0x05 (Timeout) and sets '''value''' to ('''event_slot''' | (('''syncpt_id''' & 0xFFF) << 16) | ('''is_valid''' << 28)).
! Value || Direction || Size || Description
 
|-
  struct {
| 0xC0080101 || Inout || 8 || [[#NVMAP_IOC_CREATE]]
    __in  u32 id;
|-
    __in  u32 thresh;
    __in  s32 timeout;
    __out u32 value;
  };
 
=== NVHOST_IOCTL_CTRL_SYNCPT_WAIT_EVENT_EX ===
Waits on a syncpt using a specific event. If waiting fails, returns error code 0x05 (Timeout) and sets '''value''' to ('''event_slot''' | ('''syncpt_id''' << 4)).
 
  struct {
    __in    u32 id;
    __in    u32 thresh;
    __in    s32 timeout;
    __inout u32 value;          // in=event_slot; out=syncpt_value
  };
 
=== NVHOST_IOCTL_CTRL_SYNCPT_ALLOC_EVENT ===
Allocates a new syncpt event.
 
  struct {
    __in u32 event_slot;        // 0x00 to 0x3F
  };
 
=== NVHOST_IOCTL_CTRL_SYNCPT_FREE_EVENT ===
Frees an existing syncpt event.
 
  struct {
    __in u32 event_slot;        // 0x00 to 0x3F
  };
 
=== NVHOST_IOCTL_CTRL_SYNCPT_FREE_EVENT_BATCH ===
Frees multiple syncpt events.
 
  struct {
    __in u64 event_slot_mask;    // 64-bit bitfield where each bit represents one event
  };
 
=== NVHOST_IOCTL_CTRL_SYNCPT_GET_SHIFT ===
Returns the syncpt shift value.
 
  struct {
    __out u32 syncpt_shift;      // 0x00 (FIFO disabled) or 0x60 (FIFO enabled)
  };
 
== /dev/nvmap ==
{| class="wikitable" border="1"
! Value || Direction || Size || Description
|-
| 0xC0080101 || Inout || 8 || [[#NVMAP_IOC_CREATE]]
|-
| 0x00000102 || - || 0 || [[#NVMAP_IOC_CLAIM]]
| 0x00000102 || - || 0 || [[#NVMAP_IOC_CLAIM]]
|-
|-
Line 433: Line 498:
     __in u32 heapmask;
     __in u32 heapmask;
     __in u32 flags;    // (0=read-only, 1=read-write)
     __in u32 flags;    // (0=read-only, 1=read-write)
     __in u32 align;
     __inout u32 align;
     __in u8  kind;
     __in u8  kind;
     u8      pad[7];
     u8      pad[7];
     __inout u64 addr;
     __in u64 addr;
   };
   };


Line 445: Line 510:
     __in  u32 handle;
     __in  u32 handle;
     u32      pad;
     u32      pad;
     __out u64 address;
     __out u64 address; // 0 if the handle wasn't yet freed
     __out u32 size;
     __out u32 size;
     __out u32 flags;    // 1=NOT_FREED_YET
     __out u32 flags;    // 1=WAS_UNCACHED (if flags bit 1 was set when NVMAP_IOC_ALLOC was called)
   };
   };


Line 528: Line 593:
! Value || Direction || Size || Description
! Value || Direction || Size || Description
|-
|-
| 0x80040212 || Out || 4 || NVDISP_CTRL_NUM_OUTPUTS
| 0x80040212 || Out || 4 || [[#NVDISP_CTRL_NUM_OUTPUTS]]
|-
|-
| 0xC0140213 || Inout || 20 || NVDISP_CTRL_GET_DISPLAY_PROPERTIES
| 0xC0140213 || Inout || 20 || NVDISP_CTRL_GET_DISPLAY_PROPERTIES
|-
|-
| 0xC1100214 || Inout || 272 || NVDISP_CTRL_QUERY_EDID
| 0xC2100214</br>([1.0.0-11.0.1] 0xC1100214) || Inout || 528</br>([1.0.0-11.0.1] 272) || NVDISP_CTRL_QUERY_EDID
|-
|-
| 0xC0080216</br>([1.0.0-3.0.0] 0xC0040216) || Inout || 8</br>([1.0.0-3.0.0] 4) || NVDISP_CTRL_GET_EXT_HPD_IN_OUT_EVENTS</br>([1.0.0-3.0.0] NVDISP_CTRL_GET_EXT_HPD_IN_EVENT)
| 0xC0080216</br>([1.0.0-3.0.0] 0xC0040216) || Inout || 8</br>([1.0.0-3.0.0] 4) || NVDISP_CTRL_GET_EXT_HPD_IN_OUT_EVENTS</br>([1.0.0-3.0.0] NVDISP_CTRL_GET_EXT_HPD_IN_EVENT)
Line 544: Line 609:
| 0xC0040220 || Inout || 4 || NVDISP_CTRL_SUSPEND
| 0xC0040220 || Inout || 4 || NVDISP_CTRL_SUSPEND
|-
|-
| 0x80010224 || Out || 1 || [11.0.0+]
| 0x80010224 || Out || 1 || [11.0.0+] NVDISP_CTRL_IS_DISPLAY_OLED
|}
|}
=== NVDISP_CTRL_NUM_OUTPUTS ===
  struct {
    __out u32 num_outputs;
  };


== /dev/nvdisp-disp0, /dev/nvdisp-disp1 ==
== /dev/nvdisp-disp0, /dev/nvdisp-disp1 ==
Line 557: Line 628:
| 0xC4C80203 || In || 1224 || NVDISP_FLIP
| 0xC4C80203 || In || 1224 || NVDISP_FLIP
|-
|-
| 0x80380204 || Out || 56 || NVDISP_GET_MODE
| 0x80380204 || Out || 56 || [[#NVDISP_GET_MODE]]
|-
|-
| 0x40380205 || Out || 56 || NVDISP_SET_MODE
| 0x40380205 || In || 56 || [[#NVDISP_SET_MODE]]
|-
|-
| 0x430C0206 || In || 780 || NVDISP_SET_LUT
| 0x430C0206 || In || 780 || NVDISP_SET_LUT
Line 569: Line 640:
| 0x80040209 || Out || 4 || NVDISP_GET_HEAD_STATUS
| 0x80040209 || Out || 4 || NVDISP_GET_HEAD_STATUS
|-
|-
| 0xC038020A || Inout || 56 || NVDISP_VALIDATE_MODE
| 0xC038020A || Inout || 56 || [[#NVDISP_VALIDATE_MODE]]
|-
|-
| 0x4018020B || In || 24 || NVDISP_SET_CSC
| 0x4018020B || In || 24 || NVDISP_SET_CSC
Line 581: Line 652:
| 0xC004020F || Inout || 4 || NVDISP_DPMS
| 0xC004020F || Inout || 4 || NVDISP_DPMS
|-
|-
| 0x80600210 || Out || 96 || NVDISP_GET_AVI_INFOFRAME
| 0x80600210 || Out || 96 || [[#NVDISP_GET_AVI_INFOFRAME]]
|-
|-
| 0x40600211 || In || 96 || NVDISP_SET_AVI_INFOFRAME
| 0x40600211 || In || 96 || [[#NVDISP_SET_AVI_INFOFRAME]]
|-
|-
| 0xEBFC0215 || Inout || 11260 || NVDISP_GET_MODE_DB
| 0xEBFC0215 || Inout || 11260 || [[#NVDISP_GET_MODE_DB]]
|-
|-
| 0xC003021A || Inout || 3 || NVDISP_PANEL_GET_VENDOR_ID
| 0xC003021A || Inout || 3 || [[#NVDISP_PANEL_GET_VENDOR_ID]]
|-
|-
| 0x803C021B || Out || 60 || NVDISP_GET_MODE2
| 0x803C021B || Out || 60 || [[#NVDISP_GET_MODE2]]
|-
|-
| 0x403C021C || In || 60 || NVDISP_SET_MODE2
| 0x403C021C || In || 60 || [[#NVDISP_SET_MODE2]]
|-
|-
| 0xC03C021D || Inout || 60 || NVDISP_VALIDATE_MODE2
| 0xC03C021D || Inout || 60 || [[#NVDISP_VALIDATE_MODE2]]
|-
|-
| 0xEF20021E || Inout || 12064 || NVDISP_GET_MODE_DB2
| 0xEF20021E || Inout || 12064 || [[#NVDISP_GET_MODE_DB2]]
|-
|-
| 0xC004021F || Inout || 4 || NVDISP_GET_WINMASK
| 0xC004021F || Inout || 4 || NVDISP_GET_WINMASK
|-
|-
| 0x80080221 || Out || 8 || [10.0.0+] NVDISP_GET_BACKLIGHT_RANGE
| 0x80080221 || Out || 8 || [10.0.0+] [[#NVDISP_GET_BACKLIGHT_RANGE]]
|-
|-
| 0x40040222 || In || 4 || [10.0.0+] NVDISP_SET_BACKLIGHT
| 0x40040222 || In || 4 || [10.0.0+] [[#NVDISP_SET_BACKLIGHT_RANGE_MAX]]
|-
|-
| 0x40040223 || In || 4 || [11.0.0+] NVDISP_SEND_PANEL_MSG
| 0x40040223 || In || 4 || [11.0.0+] [[#NVDISP_SET_BACKLIGHT_RANGE_MIN]]
|-
|-
| 0x401C0225 || In || 28 || [11.0.0+] NVDISP_SEND_PANEL_MSG_EX
| 0x401C0225 || In || 28 || [11.0.0+] [[#NVDISP_SEND_PANEL_MSG]]
|-
|-
| 0xC01C0226 || Inout || 28 || [11.0.0+] NVDISP_GET_PANEL_DATA
| 0xC01C0226 || Inout || 28 || [11.0.0+] [[#NVDISP_GET_PANEL_DATA]]
|}
|}


== /dev/nvcec-ctrl ==
=== NVDISP_GET_MODE ===
{| class="wikitable" border="1"
Almost identical to Linux driver.
! Value || Direction || Size || Description
 
|-
  struct {
| 0x40010301 || In || 1 || NVCEC_CTRL_ENABLE
    __out u32 hActive;
|-
    __out u32 vActive;
| 0x804C0302 || Out || 76 || NVCEC_CTRL_GET_PADDR
    __out u32 hSyncWidth;
|-
    __out u32 vSyncWidth;
| 0x40040303 || In || 4 || NVCEC_CTRL_SET_LADDR
    __out u32 hFrontPorch;
|-
    __out u32 vFrontPorch;
| 0xC04C0304 || Inout || 76 || NVCEC_CTRL_WRITE
    __out u32 hBackPorch;
|-
    __out u32 vBackPorch;
| 0xC04C0305 || Inout || 76 || NVCEC_CTRL_READ
    __out u32 hRefToSync;
|-
    __out u32 vRefToSync;
| 0x804C0306 || Out || 76 || NVCEC_CTRL_GET_CONNECTION_STATUS
    __out u32 pclkKHz;
|-
    __out u32 bitsPerPixel;      // Always 0
| 0x804C0307 || Out || 76 || NVCEC_CTRL_GET_WRITE_STATUS
    __out u32 vmode;            // Always 0
|}
    __out u32 sync;
  };
 
=== NVDISP_SET_MODE ===
Almost identical to Linux driver.


== /dev/nvhdcp_up-ctrl ==
  struct {
{| class="wikitable" border="1"
    __in u32 hActive;
! Value || Direction || Size || Description
    __in u32 vActive;
|-
    __in u32 hSyncWidth;
| 0xC4880401 || Inout || 1160 || NVHDCP_READ_STATUS
    __in u32 vSyncWidth;
|-
    __in u32 hFrontPorch;
| 0xC4880402 || Inout || 1160 || NVHDCP_READ_M
    __in u32 vFrontPorch;
|-
    __in u32 hBackPorch;
| 0x40010403 || In || 1 || NVHDCP_ENABLE
    __in u32 vBackPorch;
|-
    __in u32 hRefToSync;
| 0xC0080404 || Inout || 8 || NVHDCP_CTRL_STATE_TRANSIT_EVENT_DATA
    __in u32 vRefToSync;
|-
    __in u32 pclkKHz;
| 0xC0010405 || Inout || 1 || NVHDCP_CTRL_STATE_CB
    __in u32 bitsPerPixel;
|}
    __in u32 vmode;
    __in u32 sync;
  };
 
=== NVDISP_VALIDATE_MODE ===
Almost identical to Linux driver.
 
  struct {
    __inout u32 hActive;
    __inout u32 vActive;
    __inout u32 hSyncWidth;
    __inout u32 vSyncWidth;
    __inout u32 hFrontPorch;
    __inout u32 vFrontPorch;
    __inout u32 hBackPorch;
    __inout u32 vBackPorch;
    __inout u32 hRefToSync;
    __inout u32 vRefToSync;
    __inout u32 pclkKHz;
    __inout u32 bitsPerPixel;
    __inout u32 vmode;
    __inout u32 sync;
  };
 
=== NVDISP_GET_AVI_INFOFRAME ===
Unpacked standard AVI infoframe struct (HDMI v1.4b/2.0)
 
  struct {
    __out u32 csum;
    __out u32 scan;
    __out u32 bar_valid;
    __out u32 act_fmt_valid;
    __out u32 rgb_ycc;
    __out u32 act_format;
    __out u32 aspect_ratio;
    __out u32 colorimetry;
    __out u32 scaling;
    __out u32 rgb_quant;
    __out u32 ext_colorimetry;
    __out u32 it_content;
    __out u32 video_format;
    __out u32 pix_rep;
    __out u32 it_content_type;
    __out u32 ycc_quant;
    __out u32 top_bar_end_line_lsb;
    __out u32 top_bar_end_line_msb;
    __out u32 bot_bar_start_line_lsb;
    __out u32 bot_bar_start_line_msb;
    __out u32 left_bar_end_pixel_lsb;
    __out u32 left_bar_end_pixel_msb;
    __out u32 right_bar_start_pixel_lsb;
    __out u32 right_bar_start_pixel_msb;
  };
 
=== NVDISP_SET_AVI_INFOFRAME ===
Unpacked standard AVI infoframe struct (HDMI v1.4b/2.0)


== /dev/nvdcutil-disp0, /dev/nvdcutil-disp1 ==
  struct {
{| class="wikitable" border="1"
    __in u32 csum;
! Value || Direction || Size || Description
    __in u32 scan;
|-
    __in u32 bar_valid;
| 0x40010501 || In || 1 || NVDCUTIL_ENABLE_CRC
    __in u32 act_fmt_valid;
|-
    __in u32 rgb_ycc;
| 0x40010502 || In || 1 || NVDCUTIL_VIRTUAL_EDID_ENABLE
    __in u32 act_format;
|-
    __in u32 aspect_ratio;
| 0x42040503 || In || 1056 || NVDCUTIL_VIRTUAL_EDID_SET_DATA
    __in u32 colorimetry;
|-
    __in u32 scaling;
| 0x803C0504 || Out || 60 || NVDCUTIL_GET_MODE
    __in u32 rgb_quant;
|-
    __in u32 ext_colorimetry;
| 0x40010505 || In || 1 || NVDCUTIL_BEGIN_TELEMETRY_TEST
    __in u32 it_content;
|-
    __in u32 video_format;
| 0x400C0506 || In || 12 || NVDCUTIL_DSI_PACKET_TEST_SHORT_WRITE
    __in u32 pix_rep;
|-
    __in u32 it_content_type;
| 0x40F80507 || In || 248 || NVDCUTIL_DSI_PACKET_TEST_LONG_WRITE
    __in u32 ycc_quant;
|-
    __in u32 top_bar_end_line_lsb;
| 0xC0F40508 || Inout || 244 || NVDCUTIL_DSI_PACKET_TEST_READ
    __in u32 top_bar_end_line_msb;
|-
    __in u32 bot_bar_start_line_lsb;
| 0x40010509 || In || 1 || [10.0.0+] NVDCUTIL_DP_ELECTRIC_TEST_EN
    __in u32 bot_bar_start_line_msb;
|-
    __in u32 left_bar_end_pixel_lsb;
| 0xC020050A || Inout || 32 || [10.0.0+] NVDCUTIL_DP_ELECTRIC_TEST_SETTINGS
    __in u32 left_bar_end_pixel_msb;
|-
    __in u32 right_bar_start_pixel_lsb;
| 0x8070050B || Out || 112 || [11.0.0+] NVDCUTIL_DP_CONF_READ
    __in u32 right_bar_start_pixel_msb;
|}
  };
 
=== NVDISP_GET_MODE_DB ===
Almost identical to Linux driver.
 
  struct mode {
    u32 hActive;
    u32 vActive;
    u32 hSyncWidth;
    u32 vSyncWidth;
    u32 hFrontPorch;
    u32 vFrontPorch;
    u32 hBackPorch;
    u32 vBackPorch;
    u32 hRefToSync;
    u32 vRefToSync;
    u32 pclkKHz;
    u32 bitsPerPixel;
    u32 vmode;
    u32 sync;
  };
  struct {
    __out struct mode modes[201];
    __out u32 num_modes;
  };


== /dev/nvsched-ctrl ==
=== NVDISP_PANEL_GET_VENDOR_ID ===
This is a customized scheduler device.


The way this device is exposed and configured is exclusive to the Switch, since other sources don't have an actual interface for the scheduler.
Returns display panel's informations.


{| class="wikitable" border="1"
  struct {
! Value || Direction || Size || Description
    __out u8 vendor; //0x10 - JDI, 0x20 - InnoLux, 0x30 - AUO, 0x40 - Sharp, 0x50 - Samsung
|-
    __out u8 model;
| 0x00000601 || - || 0 || [[#NVSCHED_CTRL_ENABLE]]
    __out u8 board; //0xF - 6.2", 0x10 - 5.5", 0x20 - 7.0". JDI panels have nonstandard values
|-
  };
| 0x00000602 || - || 0 || [[#NVSCHED_CTRL_DISABLE]]
 
|-
=== NVDISP_GET_MODE2 ===
| 0x40180603 || In || 24 || [[#NVSCHED_CTRL_ADD_APPLICATION]]
 
|-
  struct {
| 0x40180604 || In || 24 || [[#NVSCHED_CTRL_UPDATE_APPLICATION]]
    __out u32 unk0;              //Always 0
|-
    __out u32 hActive;
| 0x40080605 || In || 8 || [[#NVSCHED_CTRL_REMOVE_APPLICATION]]
    __out u32 vActive;
|-
    __out u32 hSyncWidth;
| 0x80080606 || Out || 8 || [[#NVSCHED_CTRL_GET_ID]]
    __out u32 vSyncWidth;
|-
    __out u32 hFrontPorch;
| 0x80080607 || Out || 8 || [[#NVSCHED_CTRL_ADD_RUNLIST]]
    __out u32 vFrontPorch;
|-
    __out u32 hBackPorch;
| 0x40180608 || In || 24 || [[#NVSCHED_CTRL_UPDATE_RUNLIST]]
    __out u32 vBackPorch;
|-
    __out u32 pclkKHz;
| 0x40100609 || In || 16 || [[#NVSCHED_CTRL_LINK_RUNLIST]]
    __out u32 bitsPerPixel;      // Always 0
|-
    __out u32 vmode;            // Always 0
| 0x4010060A || In || 16 || [[#NVSCHED_CTRL_UNLINK_RUNLIST]]
    __out u32 sync;
|-
    __out u32 unk1;
| 0x4008060B || In || 8 || [[#NVSCHED_CTRL_REMOVE_RUNLIST]]
    __out u32 reserved;
|-
  };
| 0x8001060C || Out || 1 || [[#NVSCHED_CTRL_HAS_OVERRUN_EVENT]]
 
|-
=== NVDISP_SET_MODE2 ===
| 0x8020060D</br>([1.0.0-3.0.0] 0x8010060D) || Out || 32</br>([1.0.0-3.0.0] 16) || [[#NVSCHED_CTRL_GET_NEXT_OVERRUN_EVENT]]
 
|-
  struct {
| 0x400C060E || In || 12 || [[#NVSCHED_CTRL_PUT_CONDUCTOR_FLIP_FENCE]]
    __in u32 unk0;
|-
    __in u32 hActive;
| 0x4008060F || In || 8 || [[#NVSCHED_CTRL_DETACH_APPLICATION]]
    __in u32 vActive;
|-
    __in u32 hSyncWidth;
| 0x40100610 || In || 16 || NVSCHED_CTRL_SET_APPLICATION_MAX_DEBT
    __in u32 vSyncWidth;
|-
    __in u32 hFrontPorch;
| 0x40100611 || In || 16 || NVSCHED_CTRL_SET_RUNLIST_MAX_DEBT
    __in u32 vFrontPorch;
|-
    __in u32 hBackPorch;
| 0x40010612 || In || 1 || NVSCHED_CTRL_OVERRUN_EVENTS_ENABLE
    __in u32 vBackPorch;
|}
    __in u32 pclkKHz;
    __in u32 bitsPerPixel;
    __in u32 vmode;
    __in u32 sync;
    __in u32 unk1;
    __in u32 reserved;
  };
 
=== NVDISP_VALIDATE_MODE2 ===
 
  struct {
    __inout u32 unk0;
    __inout u32 hActive;
    __inout u32 vActive;
    __inout u32 hSyncWidth;
    __inout u32 vSyncWidth;
    __inout u32 hFrontPorch;
    __inout u32 vFrontPorch;
    __inout u32 hBackPorch;
    __inout u32 vBackPorch;
    __inout u32 pclkKHz;
    __inout u32 bitsPerPixel;
    __inout u32 vmode;
    __inout u32 sync;
    __inout u32 unk1;
    __inout u32 reserved;
  };
 
=== NVDISP_GET_MODE_DB2 ===


=== NVSCHED_CTRL_ENABLE ===
  struct mode2 {
Enables the scheduler.
    u32 unk0;
    u32 hActive;
    u32 vActive;
    u32 hSyncWidth;
    u32 vSyncWidth;
    u32 hFrontPorch;
    u32 vFrontPorch;
    u32 hBackPorch;
    u32 vBackPorch;
    u32 pclkKHz;
    u32 bitsPerPixel;
    u32 vmode;
    u32 sync;
    u32 unk1;
    u32 reserved;
  };
  struct {
    __out struct mode2 modes[201];
    __out u32 num_modes;
  };


=== NVSCHED_CTRL_DISABLE ===
=== NVDISP_GET_BACKLIGHT_RANGE ===
Disables the scheduler.
Returns the minimum and maximum values for the intensity of the display's backlight.
 
=== NVSCHED_CTRL_ADD_APPLICATION ===
Adds a new application to the scheduler.


   struct {
   struct {
     __in u64 application_id;
     __out u32 min;
     __in u64 priority;
     __out u32 max;
    __in u64 timeslice;
   };
   };


=== NVSCHED_CTRL_UPDATE_APPLICATION ===
=== NVDISP_SET_BACKLIGHT_RANGE_MAX ===
Updates the application parameters in the scheduler.
Sets the maximum value for the intensity of the display's backlight.


   struct {
   struct {
     __in u64 application_id;
     __in u32 max;
    __in u64 priority;
    __in u64 timeslice;
   };
   };


=== NVSCHED_CTRL_REMOVE_APPLICATION ===
=== NVDISP_SET_BACKLIGHT_RANGE_MIN ===
Removes the application from the scheduler.
Sets the minimum value for the intensity of the display's backlight.


   struct {
   struct {
     __in u64 application_id;
     __in u32 min;
   };
   };


=== NVSCHED_CTRL_GET_ID ===
=== NVDISP_SEND_PANEL_MSG ===
Returns the ID of the last scheduled object.
Sends raw data to the display panel over DPAUX.


   struct {
   struct {
     __out u64 id;
     __in u32 cmd;         // DPAUX AUXCTL command (1=unk, 2=I2CWR, 4=MOTWR, 7=AUXWR)
    __in u32 addr;        // DPAUX AUXADDR
    __in u32 size;        // message size
    __in u32 msg[4];      // raw AUXDATA message
   };
   };


=== NVSCHED_CTRL_ADD_RUNLIST ===
=== NVDISP_GET_PANEL_DATA ===
Creates a new runlist and returns it's ID.
Receives raw data from the display panel over DPAUX.


   struct {
   struct {
     __out u64 runlist_id;
    __in u32 cmd;          // DPAUX AUXCTL command (3=I2CRD, 5=MOTRD, 6=AUXRD)
    __in u32 addr;        // DPAUX AUXADDR
    __in u32 size;        // message size
     __out u32 msg[4];     // raw AUXDATA message
   };
   };


=== NVSCHED_CTRL_UPDATE_RUNLIST ===
== /dev/nvcec-ctrl ==
Updates the runlist parameters in the scheduler.
{| class="wikitable" border="1"
 
! Value || Direction || Size || Description
  struct {
|-
    __in u64 runlist_id;
| 0x40010301 || In || 1 || NVCEC_CTRL_ENABLE
    __in u64 priority;
|-
    __in u64 timeslice;
| 0x804C0302 || Out || 76 || NVCEC_CTRL_GET_PADDR
  };
|-
| 0x40040303 || In || 4 || NVCEC_CTRL_SET_LADDR
|-
| 0xC04C0304 || Inout || 76 || NVCEC_CTRL_WRITE
|-
| 0xC04C0305 || Inout || 76 || NVCEC_CTRL_READ
|-
| 0x804C0306 || Out || 76 || NVCEC_CTRL_GET_CONNECTION_STATUS
|-
| 0x804C0307 || Out || 76 || NVCEC_CTRL_GET_WRITE_STATUS
|}


=== NVSCHED_CTRL_LINK_RUNLIST ===
== /dev/nvhdcp_up-ctrl ==
Links a runlist to a given application in the scheduler.
{| class="wikitable" border="1"
 
! Value || Direction || Size || Description
  struct {
|-
    __in u64 runlist_id;
| 0xC4880401 || Inout || 1160 || NVHDCP_READ_STATUS
    __in u64 application_id;
|-
  };
| 0xC4880402 || Inout || 1160 || NVHDCP_READ_M
|-
| 0x40010403 || In || 1 || NVHDCP_ENABLE
|-
| 0xC0080404 || Inout || 8 || NVHDCP_CTRL_STATE_TRANSIT_EVENT_DATA
|-
| 0xC0010405 || Inout || 1 || NVHDCP_CTRL_STATE_CB
|}


=== NVSCHED_CTRL_UNLINK_RUNLIST ===
== /dev/nvdcutil-disp0, /dev/nvdcutil-disp1 ==
Unlinks a runlist from a given application in the scheduler.
{| class="wikitable" border="1"
 
! Value || Direction || Size || Description
  struct {
|-
    __in u64 runlist_id;
| 0x40010501 || In || 1 || NVDCUTIL_ENABLE_CRC
    __in u64 application_id;
|-
  };
| 0x40010502 || In || 1 || [[#NVDCUTIL_VIRTUAL_EDID_ENABLE]]
 
|-
=== NVSCHED_CTRL_REMOVE_RUNLIST ===
| 0x42040503 || In || 516 || [[#NVDCUTIL_VIRTUAL_EDID_SET_DATA]]
Removes the runlist from the scheduler.
|-
 
| 0x803C0504 || Out || 60 || NVDCUTIL_GET_MODE
  struct {
|-
    __in u64 runlist_id;
| 0x40010505 || In || 1 || NVDCUTIL_BEGIN_TELEMETRY_TEST
  };
|-
| 0x400C0506 || In || 12 || NVDCUTIL_DSI_PACKET_TEST_SHORT_WRITE
|-
| 0x40F80507 || In || 248 || NVDCUTIL_DSI_PACKET_TEST_LONG_WRITE
|-
| 0xC0F40508 || Inout || 244 || NVDCUTIL_DSI_PACKET_TEST_READ
|-
| 0x40010509 || In || 1 || [10.0.0+] NVDCUTIL_DP_ELECTRIC_TEST_EN
|-
| 0xC020050A || Inout || 32 || [10.0.0+] NVDCUTIL_DP_ELECTRIC_TEST_SETTINGS
|-
| 0x8070050B || Out || 112 || [11.0.0+] NVDCUTIL_DP_CONF_READ
|}


=== NVSCHED_CTRL_HAS_OVERRUN_EVENT ===
=== NVDCUTIL_VIRTUAL_EDID_ENABLE ===
Returns a boolean to tell if the scheduler has an overrun event or not.


   struct {
   struct {
     __out u8 has_overrun;
     __in u8 enable;
   };
   };


=== NVSCHED_CTRL_GET_NEXT_OVERRUN_EVENT ===
=== NVDCUTIL_VIRTUAL_EDID_SET_DATA ===
Returns the overrun event's data from the scheduler.


   struct {
   struct {
     __out u64 runlist_id;
     __in u8 edid[512];
     __out u64 debt;
     __in u32 edid_size;
    __out u64 unk0;          // 3.0.0+ only
    __out u64 unk1;          // 3.0.0+ only
   };
   };


=== NVSCHED_CTRL_PUT_CONDUCTOR_FLIP_FENCE ===
== /dev/nvsched-ctrl ==
Installs a fence swap event?
This is a customized scheduler device.


  struct {
The way this device is exposed and configured is exclusive to the Switch, since other sources don't have an actual interface for the scheduler.
    __in u32 fence_id;
    __in u32 fence_thresh;
    __in u32 swap_interval;
  };
 
=== NVSCHED_CTRL_DETACH_APPLICATION ===
Places the given application in detached state.
 
  struct {
    __in u64 application_id;
  };
 
== /dev/nverpt-ctrl ==
Added in firmware version 3.0.0.


{| class="wikitable" border="1"
{| class="wikitable" border="1"
! Value || Direction || Size || Description
! Value || Direction || Size || Description
|-
|-
| 0xC1280701 || Inout || 296 || [[#NVERPT_TELEMETRY_SUBMIT_DATA]]
| 0x00000601 || - || 0 || [[#NVSCHED_CTRL_ENABLE]]
|-
| 0x00000602 || - || 0 || [[#NVSCHED_CTRL_DISABLE]]
|-
| 0x40180603 || In || 24 || [[#NVSCHED_CTRL_ADD_APPLICATION]]
|-
| 0x40180604 || In || 24 || [[#NVSCHED_CTRL_UPDATE_APPLICATION]]
|-
| 0x40080605 || In || 8 || [[#NVSCHED_CTRL_REMOVE_APPLICATION]]
|-
|-
| 0xCF580702 || Inout || 3928 || [[#NVERPT_TELEMETRY_SUBMIT_DISPLAY_DATA]]
| 0x80080606 || Out || 8 || [[#NVSCHED_CTRL_GET_ID]]
|}
|-
 
| 0x80080607 || Out || 8 || [[#NVSCHED_CTRL_ADD_RUNLIST]]
=== NVERPT_TELEMETRY_SUBMIT_DATA ===
|-
Sends test data for creating a new [[Error_Report_services|Error Report]].
| 0x40180608 || In || 24 || [[#NVSCHED_CTRL_UPDATE_RUNLIST]]
 
|-
  struct {
| 0x40100609 || In || 16 || [[#NVSCHED_CTRL_LINK_RUNLIST]]
    __in u64 TestU64;
|-
    __in u32 TestU32;
| 0x4010060A || In || 16 || [[#NVSCHED_CTRL_UNLINK_RUNLIST]]
    __in u8  padding0[4];
|-
    __in s64 TestI64;
| 0x4008060B || In || 8 || [[#NVSCHED_CTRL_REMOVE_RUNLIST]]
    __in s32 TestI32;
|-
    __in u8  TestString[32];
| 0x8001060C || Out || 1 || [[#NVSCHED_CTRL_HAS_OVERRUN_EVENT]]
    __in u8  TestU8Array[8];
|-
    __in u32 TestU8Array_size;
| 0x8020060D</br>([1.0.0-3.0.0] 0x8010060D) || Out || 32</br>([1.0.0-3.0.0] 16) || [[#NVSCHED_CTRL_GET_NEXT_OVERRUN_EVENT]]
    __in u32 TestU32Array[8];
|-
    __in u32 TestU32Array_size;
| 0x400C060E || In || 12 || [[#NVSCHED_CTRL_PUT_CONDUCTOR_FLIP_FENCE]]
    __in u64 TestU64Array[8];
|-
    __in u32 TestU64Array_size;
| 0x4008060F || In || 8 || [[#NVSCHED_CTRL_DETACH_APPLICATION]]
    __in s32 TestI32Array[8];
|-
    __in u32 TestI32Array_size;
| 0x40100610 || In || 16 || NVSCHED_CTRL_SET_APPLICATION_MAX_DEBT
    __in s64 TestI64Array[8];
|-
    __in u32 TestI64Array_size;
| 0x40100611 || In || 16 || NVSCHED_CTRL_SET_RUNLIST_MAX_DEBT
    __in u16 TestU16;
|-
    __in u8  TestU8;
| 0x40010612 || In || 1 || NVSCHED_CTRL_OVERRUN_EVENTS_ENABLE
    __in s16 TestI16;
|}
    __in s8  TestI8;
 
    __in u8  padding1[5];
=== NVSCHED_CTRL_ENABLE ===
  };
Enables the scheduler.
 
=== NVSCHED_CTRL_DISABLE ===
Disables the scheduler.


=== NVERPT_TELEMETRY_SUBMIT_DISPLAY_DATA ===
=== NVSCHED_CTRL_ADD_APPLICATION ===
Sends display data for creating a new [[Error_Report_services|Error Report]].
Adds a new application to the scheduler.


   struct {
   struct {
     __in u32 CodecType;
     __in u64 application_id;
     __in u32 DecodeBuffers;
     __in u64 priority;
     __in u32 FrameWidth;
     __in u64 timeslice;
    __in u32 FrameHeight;
    __in u8  ColorPrimaries;
    __in u8  TransferCharacteristics;
    __in u8  MatrixCoefficients;
    __in u8  padding;
    __in u32 DisplayWidth;
    __in u32 DisplayHeight;
    __in u32 DARWidth;
    __in u32 DARHeight;
    __in u32 ColorFormat;
    __in u32 ColorSpace[8];
    __in u32 ColorSpace_size;
    __in u32 SurfaceLayout[8];
    __in u32 SurfaceLayout_size;
    __in u8  ErrorString[64];      // must be "Error detected = 0x1000000"
    __in u32 VideoDecState;
    __in u8  VideoLog[3712];
    __in u32 VideoLog_size;
   };
   };


== /dev/nvhost-as-gpu ==
=== NVSCHED_CTRL_UPDATE_APPLICATION ===
Each fd opened to this device creates an address space. An address space is then later bound with a channel.
Updates the application parameters in the scheduler.


Once a nvgpu channel has been bound to an address space it cannot be unbound. There is no support for allowing an nvgpu channel to change from one address space to another (or from one to none).
  struct {
                                                                                                                             
    __in u64 application_id;
{| class="wikitable" border="1"
    __in u64 priority;
! Value || Direction || Size || Description
    __in u64 timeslice;
|-
  };
| 0x40044101 || In || 4 || [[#NVGPU_AS_IOCTL_BIND_CHANNEL]]
|-
| 0xC0184102 || Inout || 24 || [[#NVGPU_AS_IOCTL_ALLOC_SPACE]]
|-
| 0xC0104103 || Inout || 16 || [[#NVGPU_AS_IOCTL_FREE_SPACE]]
|-
| 0xC0184104 || Inout || 24 || [[#NVGPU_AS_IOCTL_MAP_BUFFER]]
|-
| 0xC0084105 || Inout || 8 || [[#NVGPU_AS_IOCTL_UNMAP_BUFFER]]
|-
| 0xC0284106 || Inout || 40 || [[#NVGPU_AS_IOCTL_MAP_BUFFER_EX]]
|-
| 0x40104107 || In || 16 || [[#NVGPU_AS_IOCTL_ALLOC_AS]]
|-
| 0xC0404108 || Inout || 64 || [[#NVGPU_AS_IOCTL_GET_VA_REGIONS]]
|-
| 0x40284109 || In || 40 || [[#NVGPU_AS_IOCTL_ALLOC_AS_EX]]
|-
| 0xC038410A || Inout || 56 || [[#NVGPU_AS_IOCTL_MODIFY]]
|-
| 0xC0??4114 || Inout || Variable || [[#NVGPU_AS_IOCTL_REMAP]]
|}


=== NVGPU_AS_IOCTL_BIND_CHANNEL ===
=== NVSCHED_CTRL_REMOVE_APPLICATION ===
Identical to Linux driver.
Removes the application from the scheduler.


   struct {
   struct {
     __in u32 channel_fd;
     __in u64 application_id;
   };
   };


=== NVGPU_AS_IOCTL_ALLOC_SPACE ===
=== NVSCHED_CTRL_GET_ID ===
Reserves pages in the device address space.
Returns the ID of the last scheduled object.


   struct {
   struct {
     __in u32 pages;
     __out u64 id;
    __in u32 page_size;
    __in u32 flags;
    u32      padding;
    union {
      __out u64 offset;
      __in  u64 align;
    };
   };
   };


=== NVGPU_AS_IOCTL_FREE_SPACE ===
=== NVSCHED_CTRL_ADD_RUNLIST ===
Frees pages from the device address space.
Creates a new runlist and returns it's ID.


   struct {
   struct {
     __in u64 offset;
     __out u64 runlist_id;
    __in u32 pages;
    __in u32 page_size;
   };
   };


=== NVGPU_AS_IOCTL_MAP_BUFFER ===
=== NVSCHED_CTRL_UPDATE_RUNLIST ===
Maps a memory region in the device address space. Identical to Linux driver pretty much.
Updates the runlist parameters in the scheduler.
 
On success, the mapped memory region is granted the [[SVC#MemoryAttribute|DeviceShared]] attribute.


   struct {
   struct {
     __in   u32 flags;        // bit0: fixed_offset, bit2: cacheable
     __in u64 runlist_id;
    u32        reserved;
     __in u64 priority;
     __in   u32 dmabuf_fd;    // nvmap handle
     __in u64 timeslice;
    __inout u32 page_size;   // 0 means don't care
     union {
      __out u64 offset;
      __in u64 align;
    };
   };
   };


=== NVGPU_AS_IOCTL_MAP_BUFFER_EX ===
=== NVSCHED_CTRL_LINK_RUNLIST ===
Maps a memory region in the device address space with extra params.
Links a runlist to a given application in the scheduler.


Unaligned size will cause a [[#Panic]].
  struct {
    __in u64 runlist_id;
    __in u64 application_id;
  };


On success, the mapped memory region is granted the [[SVC#MemoryAttribute|DeviceShared]] attribute.
=== NVSCHED_CTRL_UNLINK_RUNLIST ===
Unlinks a runlist from a given application in the scheduler.


   struct {
   struct {
     __in     u32 flags;          // bit0: fixed_offset, bit2: cacheable
     __in u64 runlist_id;
    __in      u32 kind;          // -1 is default
     __in u64 application_id;
    __in      u32 dmabuf_fd;      // nvmap handle
    __inout  u32 page_size;      // 0 means don't care
    __in      u64 buffer_offset;
     __in     u64 mapping_size;
    __inout  u64 offset;
   };
   };


=== NVGPU_AS_IOCTL_UNMAP_BUFFER ===
=== NVSCHED_CTRL_REMOVE_RUNLIST ===
Unmaps a memory region from the device address space.
Removes the runlist from the scheduler.


struct {
  struct {
     __in u64 offset;
     __in u64 runlist_id;
   };
   };


=== NVGPU_AS_IOCTL_ALLOC_AS ===
=== NVSCHED_CTRL_HAS_OVERRUN_EVENT ===
Nintendo's custom implementation for allocating an address space.
Returns a boolean to tell if the scheduler has an overrun event or not.


   struct {
   struct {
     __in u32 big_page_size;   // depends on GPU's available_big_page_sizes; 0=default
     __out u8 has_overrun;
    __in s32 as_fd;          // ignored; passes 0
    __in u64 reserved;        // ignored; passes 0
   };
   };


=== NVGPU_AS_IOCTL_GET_VA_REGIONS ===
=== NVSCHED_CTRL_GET_NEXT_OVERRUN_EVENT ===
Nintendo's custom implementation to get rid of pointer in struct.
Returns the overrun event's data from the scheduler.


  struct va_region {
    u64 offset;
    u32 page_size;
    u32 reserved;
    u64 pages;
  };
 
   struct {
   struct {
     u64           buf_addr;   // (contained output user ptr on linux, ignored)
     __out u64 runlist_id;
     __inout u32  buf_size;   // forced to 2*sizeof(struct va_region)
     __out u64 debt;
     u32           reserved;
     __out u64 unk0;           // 3.0.0+ only
     __out struct  va_region regions[2];
     __out u64 unk1;           // 3.0.0+ only
   };
   };


=== NVGPU_AS_IOCTL_ALLOC_AS_EX ===
=== NVSCHED_CTRL_PUT_CONDUCTOR_FLIP_FENCE ===
Nintendo's custom implementation for allocating an address space with extra params.
Installs a fence swap event?


   struct {
   struct {
     __in u32 big_page_size;   // depends on GPU's available_big_page_sizes; 0=default
     __in u32 fence_id;
    __in s32 as_fd;          // ignored; passes 0
     __in u32 fence_value;
     __in u32 flags;           // passes 0
     __in u32 swap_interval;
     __in u32 reserved;        // ignored; passes 0
    __in u64 va_range_start;
    __in u64 va_range_end;
    __in u64 va_range_split;
   };
   };


=== NVGPU_AS_IOCTL_MODIFY ===
=== NVSCHED_CTRL_DETACH_APPLICATION ===
Modifies a memory region in the device address space.
Places the given application in detached state.


    struct {
  struct {
     __in     u32 flags;          // bit0: fixed_offset, bit2: cacheable
     __in u64 application_id;
    __in      u32 kind;          // -1 is default
    __in      u32 dmabuf_fd;      // nvmap handle
    __inout  u32 page_size;      // 0 means don't care
    __in      u64 buffer_offset;
    __in      u64 mapping_size;
    __inout  u64 offset;
    __in      u64 unk0;
    __in      u32 unk1;
    u32          reserved;
   };
   };


=== NVGPU_AS_IOCTL_REMAP ===
== /dev/nverpt-ctrl ==
Nintendo's custom implementation of address space remapping.
Added in firmware version 3.0.0.


  struct remap_op {
{| class="wikitable" border="1"
    __in u16 flags;                  // 0 or 4
! Value || Direction || Size || Description
    __in u16 kind;         
|-
    __in u32 mem_handle;
| 0xC1280701 || Inout || 296 || [[#NVERPT_TELEMETRY_SUBMIT_DATA]]
    __in u32 mem_offset_in_pages;
|-
    __in u32 virt_offset_in_pages;    // (alloc_space_offset >> 0x10)
| 0xCF580702 || Inout || 3928 || [[#NVERPT_TELEMETRY_SUBMIT_DISPLAY_DATA]]
    __in u32 num_pages;              // alloc_space_pages
|}
  };
struct {
    __in struct remap_op entries[];
};


== /dev/nvhost-dbg-gpu ==
=== NVERPT_TELEMETRY_SUBMIT_DATA ===
Returns [[#Errors|NotSupported]] on Open unless nn::settings::detail::GetDebugModeFlag is set.
Sends test data for creating a new [[Error_Report_services|Error Report]].


{| class="wikitable" border="1"
  struct {
! Value || Direction || Size || Description
    __in u64 TestU64;
|-
    __in u32 TestU32;
| 0x40084401 || In || 8 || NVGPU_DBG_GPU_IOCTL_BIND_CHANNEL
    __in u8  padding0[4];
|-
    __in s64 TestI64;
| 0xC0??4402 || Inout || Variable || NVGPU_DBG_GPU_IOCTL_REG_OPS
    __in s32 TestI32;
|-
    __in u8  TestString[32];
| 0x40084403 || In || 8 || NVGPU_DBG_GPU_IOCTL_EVENTS_CTRL
    __in u8  TestU8Array[8];
|-
    __in u32 TestU8Array_size;
| 0x40044404 || In || 4 || NVGPU_DBG_GPU_IOCTL_POWERGATE
    __in u32 TestU32Array[8];
|-
    __in u32 TestU32Array_size;
| 0x40044405 || In || 4 || NVGPU_DBG_GPU_IOCTL_SMPC_CTXSW_MODE
    __in u64 TestU64Array[8];
|-
    __in u32 TestU64Array_size;
| 0x40044406 || In || 4 || NVGPU_DBG_GPU_IOCTL_SUSPEND_RESUME_ALL_SMS
    __in s32 TestI32Array[8];
|-
    __in u32 TestI32Array_size;
| 0xC0184407 || Inout || 24 || NVGPU_DBG_GPU_IOCTL_PERFBUF_MAP
    __in s64 TestI64Array[8];
|-
    __in u32 TestI64Array_size;
| 0x40084408 || In || 8 || NVGPU_DBG_GPU_IOCTL_PERFBUF_UNMAP
    __in u16 TestU16;
|-
    __in u8  TestU8;
| 0x40084409 || In || 8 || NVGPU_DBG_GPU_IOCTL_PC_SAMPLING
    __in s16 TestI16;
|-
    __in s8  TestI8;
| 0x4008440A || In || 8 || NVGPU_DBG_GPU_IOCTL_TIMEOUT
    __in u8  padding1[5];
|-
  };
| 0x8008440B || Out || 8 || NVGPU_DBG_GPU_IOCTL_GET_TIMEOUT
 
|-
=== NVERPT_TELEMETRY_SUBMIT_DISPLAY_DATA ===
| 0x8004440C || Out || 4 || NVGPU_DBG_GPU_IOCTL_GET_GR_CONTEXT_SIZE
Sends display data for creating a new [[Error_Report_services|Error Report]].
|-
 
| 0x0000440D || None || 0 || [[#NVGPU_DBG_GPU_IOCTL_GET_GR_CONTEXT]]
  struct {
|-
    __in u32 CodecType;
| 0xC018440E || Inout || 24 || NVGPU_DBG_GPU_IOCTL_ACCESS_FB_MEMORY
    __in u32 DecodeBuffers;
|-
    __in u32 FrameWidth;
| 0xC018440F || Inout || 24 || NVGPU_DBG_GPU_IOCTL_GET_GPU_VA_RANGE_NUM_PDES
    __in u32 FrameHeight;
|-
    __in u8  ColorPrimaries;
| 0xC0104410 || Inout || 16 || [[#NVGPU_DBG_GPU_IOCTL_GET_GPU_VA_RANGE_PDES]]
    __in u8  TransferCharacteristics;
|-
    __in u8  MatrixCoefficients;
| 0xC0184411 || Inout || 24 || NVGPU_DBG_GPU_IOCTL_GET_GPU_VA_RANGE_NUM_PTES
    __in u8  padding;
|-
    __in u32 DisplayWidth;
| 0xC0104412 || Inout || 16 || [[#NVGPU_DBG_GPU_IOCTL_GET_GPU_VA_RANGE_PTES]]
    __in u32 DisplayHeight;
    __in u32 DARWidth;
    __in u32 DARHeight;
    __in u32 ColorFormat;
    __in u32 ColorSpace[8];
    __in u32 ColorSpace_size;
    __in u32 SurfaceLayout[8];
    __in u32 SurfaceLayout_size;
    __in u8  ErrorString[64];      // must be "Error detected = 0x1000000"
    __in u32 VideoDecState;
    __in u8  VideoLog[3712];
    __in u32 VideoLog_size;
  };
 
== /dev/nvhost-as-gpu ==
Each fd opened to this device creates an address space. An address space is then later bound with a channel.
 
Once a nvgpu channel has been bound to an address space it cannot be unbound. There is no support for allowing an nvgpu channel to change from one address space to another (or from one to none).
                                                                                                                             
{| class="wikitable" border="1"
! Value || Direction || Size || Description
|-
|-
| 0xC0684413 || Inout || 104 || NVGPU_DBG_GPU_IOCTL_GET_COMPTAG_INFO
| 0x40044101 || In || 4 || [[#NVGPU_AS_IOCTL_BIND_CHANNEL]]
|-
|-
| 0xC0184414 || Inout || 24 || [[#NVGPU_DBG_GPU_IOCTL_READ_COMPTAGS]]
| 0xC0184102 || Inout || 24 || [[#NVGPU_AS_IOCTL_ALLOC_SPACE]]
|-
|-
| 0xC0184415 || Inout || 24 || [[#NVGPU_DBG_GPU_IOCTL_WRITE_COMPTAGS]]
| 0xC0104103 || Inout || 16 || [[#NVGPU_AS_IOCTL_FREE_SPACE]]
|-
|-
| 0xC0104416 || Inout || 16 || NVGPU_DBG_GPU_IOCTL_RESERVE_COMPTAGS
| 0xC0184104 || Inout || 24 || [[#NVGPU_AS_IOCTL_MAP_BUFFER]]
|-
|-
| 0xC0104417 || Inout || 16 || NVGPU_DBG_GPU_IOCTL_FREE_RESERVED_COMPTAGS
| 0xC0084105 || Inout || 8 || [[#NVGPU_AS_IOCTL_UNMAP_BUFFER]]
|-
|-
| 0xC0104418 || Inout || 16 || NVGPU_DBG_GPU_IOCTL_RESERVE_PA
| 0xC0284106 || Inout || 40 || [[#NVGPU_AS_IOCTL_MAP_BUFFER_EX]]
|-
| 0x40104107 || In || 16 || [[#NVGPU_AS_IOCTL_ALLOC_AS]]
|-
|-
| 0xC0104419 || Inout || 16 || NVGPU_DBG_GPU_IOCTL_FREE_RESERVED_PA
| 0xC0404108 || Inout || 64 || [[#NVGPU_AS_IOCTL_GET_VA_REGIONS]]
|-
|-
| 0xC018441A || Inout || 24 || NVGPU_DBG_GPU_IOCTL_LAZY_ALLOC_RESERVED_PA
| 0x40284109 || In || 40 || [[#NVGPU_AS_IOCTL_ALLOC_AS_EX]]
|-
|-
| 0xC020441B || Inout || 32 || [11.0.0+]
| 0xC038410A || Inout || 56 || [[#NVGPU_AS_IOCTL_MAP_BUFFER_EX2]]
|-
|-
| 0xC020441E || Inout || 32 || [11.0.0+]
| 0xC0??4114 || Inout || Variable || [[#NVGPU_AS_IOCTL_REMAP]]
|}
|}


=== NVGPU_DBG_GPU_IOCTL_GET_GR_CONTEXT ===
=== NVGPU_AS_IOCTL_BIND_CHANNEL ===
Uses [[#Ioctl3|Ioctl3]].
Identical to Linux driver.


=== NVGPU_DBG_GPU_IOCTL_GET_GPU_VA_RANGE_PDES ===
  struct {
Uses [[#Ioctl3|Ioctl3]].
    __in u32 channel_fd;
  };


=== NVGPU_DBG_GPU_IOCTL_GET_GPU_VA_RANGE_PTES ===
=== NVGPU_AS_IOCTL_ALLOC_SPACE ===
Uses [[#Ioctl3|Ioctl3]].
Reserves pages in the device address space.


=== NVGPU_DBG_GPU_IOCTL_READ_COMPTAGS ===
  struct {
Uses [[#Ioctl3|Ioctl3]].
    __in u32 pages;
 
    __in u32 page_size;
=== NVGPU_DBG_GPU_IOCTL_WRITE_COMPTAGS ===
    __in u32 flags;
Uses [[#Ioctl2|Ioctl2]].
    u32      padding;
    union {
      __out u64 offset;
      __in  u64 align;
    };
  };
 
=== NVGPU_AS_IOCTL_FREE_SPACE ===
Frees pages from the device address space.
 
  struct {
    __in u64 offset;
    __in u32 pages;
    __in u32 page_size;
  };
 
=== NVGPU_AS_IOCTL_MAP_BUFFER ===
Maps a memory region in the device address space.


== /dev/nvhost-prof-gpu ==
Unaligned size will cause a [[#Panic]].
Returns [[#Errors|NotSupported]] on Open unless nn::settings::detail::GetDebugModeFlag is set.


This device is identical to [[#/dev/nvhost-dbg-gpu|/dev/nvhost-dbg-gpu]].
On success, the mapped memory region is granted the [[SVC#MemoryAttribute|DeviceShared]] attribute.


== /dev/nvhost-ctrl-gpu ==
  struct {
This device is for global (context independent) operations on the gpu. 
    __in    u32 flags;        // bit0: fixed_offset, bit2: cacheable
                                                                                                                                             
    u32        reserved0;
{| class="wikitable" border="1"
    __in    u32 mem_id;      // nvmap handle
! Value || Direction || Size || Description
    u32        reserved1;
|-
    union {
| 0x80044701 || Out || 4 || [[#NVGPU_GPU_IOCTL_ZCULL_GET_CTX_SIZE]]
      __out u64 offset;
|-
      __in  u64 align;
| 0x80284702 || Out || 40 || [[#NVGPU_GPU_IOCTL_ZCULL_GET_INFO]]
    };
|-
  };
| 0x402C4703 || In || 44 || [[#NVGPU_GPU_IOCTL_ZBC_SET_TABLE]]
 
|-
=== NVGPU_AS_IOCTL_MAP_BUFFER_EX ===
| 0xC0344704 || Inout || 52 || [[#NVGPU_GPU_IOCTL_ZBC_QUERY_TABLE]]
Maps a memory region in the device address space with extra params.
|-
 
| 0xC0B04705 || Inout || 176 || [[#NVGPU_GPU_IOCTL_GET_CHARACTERISTICS]]
Unaligned size will cause a [[#Panic]].
|-
 
| 0xC0184706 || Inout || 24 || [[#NVGPU_GPU_IOCTL_GET_TPC_MASKS]]
On success, the mapped memory region is granted the [[SVC#MemoryAttribute|DeviceShared]] attribute.
|-
 
| 0x40084707 || In || 8 || [[#NVGPU_GPU_IOCTL_FLUSH_L2]]
  struct {
|-
    __in      u32 flags;          // bit0: fixed_offset, bit2: cacheable
| 0x4008470D || In || 8 || [[#NVGPU_GPU_IOCTL_INVAL_ICACHE]]
    __inout  u32 kind;          // -1 is default
|-
    __in      u32 mem_id;        // nvmap handle
| 0x4008470E || In || 8 || [[#NVGPU_GPU_IOCTL_SET_MMU_DEBUG_MODE]]
    u32          reserved;
|-
    __in      u64 buffer_offset;
| 0x4010470F || In || 16 || [[#NVGPU_GPU_IOCTL_SET_SM_DEBUG_MODE]]
    __in      u64 mapping_size;
|-
    union {
| 0xC0304710</br>([1.0.0-6.1.0] 0xC0084710) || Inout || 48</br>([1.0.0-6.1.0] 8) || [[#NVGPU_GPU_IOCTL_WAIT_FOR_PAUSE]]
      __out  u64 offset;
|-
      __in    u64 align;
| 0x80084711 || Out || 8 || [[#NVGPU_GPU_IOCTL_GET_TPC_EXCEPTION_EN_STATUS]]
    };
|-
  };
| 0x80084712 || Out || 8 || [[#NVGPU_GPU_IOCTL_NUM_VSMS]]
 
|-
=== NVGPU_AS_IOCTL_UNMAP_BUFFER ===
| 0xC0044713 || Inout || 4 || [[#NVGPU_GPU_IOCTL_VSMS_MAPPING]]
Unmaps a memory region from the device address space.
|-
 
| 0x80084714 || Out || 8 || [[#NVGPU_GPU_IOCTL_ZBC_GET_ACTIVE_SLOT_MASK]]
struct {
|-
    __in u64 offset;
| 0x80044715 || Out || 4 || [[#NVGPU_GPU_IOCTL_PMU_GET_GPU_LOAD]]
  };
|-
 
| 0x40084716 || In || 8 || [[#NVGPU_GPU_IOCTL_SET_CG_CONTROLS]]
=== NVGPU_AS_IOCTL_ALLOC_AS ===
|-
Nintendo's custom implementation for allocating an address space.
| 0xC0084717 || Inout || 8 || [[#NVGPU_GPU_IOCTL_GET_CG_CONTROLS]]
|-
| 0x40084718 || In || 8 || [[#NVGPU_GPU_IOCTL_SET_PG_CONTROLS]]
|-
| 0xC0084719 || Inout || 8 || [[#NVGPU_GPU_IOCTL_GET_PG_CONTROLS]]
|-
| 0x8018471A || Out || 24 || [[#NVGPU_GPU_IOCTL_PMU_GET_ELPG_RESIDENCY_GATING]]
|-
| 0xC008471B || Inout || 8 || [[#NVGPU_GPU_IOCTL_GET_ERROR_CHANNEL_USER_DATA]]
|-
| 0xC010471C || Inout || 16 || [[#NVGPU_GPU_IOCTL_GET_GPU_TIME]]
|-
| 0xC108471D || Inout || 264 || [[#NVGPU_GPU_IOCTL_GET_CPU_TIME_CORRELATION_INFO]]
|}


=== NVGPU_GPU_IOCTL_ZCULL_GET_CTX_SIZE ===
  struct {
Returns the GPU's ZCULL context size. Identical to Linux driver.
    __in u32 big_page_size;  // depends on GPU's available_big_page_sizes; 0=default
 
    __in s32 as_fd;          // ignored; passes 0
struct {
     __in u64 reserved;        // ignored; passes 0
     __out u32 size;
   };
   };


=== NVGPU_GPU_IOCTL_ZCULL_GET_INFO ===
=== NVGPU_AS_IOCTL_GET_VA_REGIONS ===
Returns GPU's ZCULL information. Identical to Linux driver.
Nintendo's custom implementation to get rid of pointer in struct.
 
Uses [[#Ioctl3|Ioctl3]].


struct {
  struct va_region {
     __out u32 width_align_pixels;
     u64 offset;
     __out u32 height_align_pixels;
     u32 page_size;
     __out u32 pixel_squares_by_aliquots;
     u32 reserved;
     __out u32 aliquot_total;
     u64 pages;
    __out u32 region_byte_multiplier;
  };
    __out u32 region_header_size;
 
     __out u32 subregion_header_size;
  struct {
     __out u32 subregion_width_align_pixels;
     u64          buf_addr;   // (contained output user ptr on linux, ignored)
     __out u32 subregion_height_align_pixels;
     __inout u32   buf_size;   // forced to 2*sizeof(struct va_region)
     __out u32 subregion_count;
     u32           reserved;
     __out struct  va_region regions[2];
   };
   };


=== NVGPU_GPU_IOCTL_ZBC_SET_TABLE ===
=== NVGPU_AS_IOCTL_ALLOC_AS_EX ===
Sets the active ZBC table. Identical to Linux driver.
Nintendo's custom implementation for allocating an address space with extra params.


struct {
  struct {
     __in u32 color_ds[4];
     __in u32 big_page_size;   // depends on GPU's available_big_page_sizes; 0=default
     __in u32 color_l2[4];
    __in s32 as_fd;          // ignored; passes 0
     __in u32 depth;
     __in u32 flags;           // passes 0
     __in u32 format;
     __in u32 reserved;        // ignored; passes 0
     __in u32 type;         // 1=color, 2=depth
     __in u64 va_range_start;
    __in u64 va_range_end;
     __in u64 va_range_split;
   };
   };


=== NVGPU_GPU_IOCTL_ZBC_QUERY_TABLE ===
=== NVGPU_AS_IOCTL_MAP_BUFFER_EX2 ===
Queries the active ZBC table. Identical to Linux driver.
Maps a memory region in the device address space with extra params.


struct {
Unaligned size will cause a [[#Panic]].
    __out u32 color_ds[4];
    __out u32 color_l2[4];
    __out u32 depth;
    __out u32 ref_cnt;
    __out u32 format;
    __out u32 type;
    __inout u32 index_size;
  };


=== NVGPU_GPU_IOCTL_GET_CHARACTERISTICS ===
On success, the mapped memory region is granted the [[SVC#MemoryAttribute|DeviceShared]] attribute.
Returns the GPU characteristics. Modified to return inline data instead of using a pointer.
 
  struct {
    __in      u32 flags;          // bit0: fixed_offset, bit2: cacheable
    __inout  u32 kind;          // -1 is default
    __in      u32 mem_id;        // nvmap handle
    u32          reserved0;
    __in      u64 buffer_offset;
    __in      u64 mapping_size;
    union {
      __out  u64 offset;
      __in    u64 align;
    };
    __in      u64 vma_addr;
    __in      u32 pages;
    u32          reserved1;
  };


[3.0.0+] Uses either [[#Ioctl|Ioctl]] or [[#Ioctl3|Ioctl3]].
=== NVGPU_AS_IOCTL_REMAP ===
Nintendo's custom implementation of address space remapping for sparse pages.


   struct gpu_characteristics {
   struct remap_op {
     u32 arch;                       // 0x120 (NVGPU_GPU_ARCH_GM200)
     __in u16 flags;                     // bit2: cacheable
     u32 impl;                       // 0xB (NVGPU_GPU_IMPL_GM20B) or 0xE (NVGPU_GPU_IMPL_GM20B_B)
     __in u16 kind;          
     u32 rev;                       // 0xA1 (Revision A1)
     __in u32 mem_handle;
     u32 num_gpc;                   // 0x1
     __in u32 mem_offset_in_pages;
     u64 l2_cache_size;              // 0x40000
     __in u32 virt_offset_in_pages;       // (alloc_space_offset >> 0x10)
    u64 on_board_video_memory_size; // 0x0 (not used)
     __in u32 num_pages;                 // alloc_space_pages
     u32 num_tpc_per_gpc;           // 0x2
  };
    u32 bus_type;                   // 0x20 (NVGPU_GPU_BUS_TYPE_AXI)
    u32 big_page_size;              // 0x20000
struct {
     u32 compression_page_size;     // 0x20000
     __in struct remap_op entries[];
    u32 pde_coverage_bit_count;     // 0x1B
};
    u32 available_big_page_sizes;  // 0x30000
 
    u32 gpc_mask;                  // 0x1
== /dev/nvhost-dbg-gpu ==
    u32 sm_arch_sm_version;        // 0x503 (Maxwell Generation 5.0.3)
Returns [[#Errors|NotSupported]] on Open unless nn::settings::detail::GetDebugModeFlag is set.
    u32 sm_arch_spa_version;        // 0x503 (Maxwell Generation 5.0.3)
 
    u32 sm_arch_warp_count;        // 0x80
{| class="wikitable" border="1"
    u32 gpu_va_bit_count;          // 0x28
! Value || Direction || Size || Description
    u32 reserved;                  // NULL
|-
    u64 flags;                      // 0x55 (HAS_SYNCPOINTS | SUPPORT_SPARSE_ALLOCS | SUPPORT_CYCLE_STATS | SUPPORT_CYCLE_STATS_SNAPSHOT)
| 0x40084401 || In || 8 || NVGPU_DBG_GPU_IOCTL_BIND_CHANNEL
    u32 twod_class;                // 0x902D (FERMI_TWOD_A)
|-
    u32 threed_class;              // 0xB197 (MAXWELL_B)
| 0xC0??4402 || Inout || Variable || NVGPU_DBG_GPU_IOCTL_REG_OPS
    u32 compute_class;              // 0xB1C0 (MAXWELL_COMPUTE_B)
|-
    u32 gpfifo_class;              // 0xB06F (MAXWELL_CHANNEL_GPFIFO_A)
| 0x40084403 || In || 8 || NVGPU_DBG_GPU_IOCTL_EVENTS_CTRL
    u32 inline_to_memory_class;    // 0xA140 (KEPLER_INLINE_TO_MEMORY_B)
|-
    u32 dma_copy_class;            // 0xB0B5 (MAXWELL_DMA_COPY_A)
| 0x40044404 || In || 4 || NVGPU_DBG_GPU_IOCTL_POWERGATE
    u32 max_fbps_count;            // 0x1
|-
    u32 fbp_en_mask;                // 0x0 (disabled)
| 0x40044405 || In || 4 || NVGPU_DBG_GPU_IOCTL_SMPC_CTXSW_MODE
    u32 max_ltc_per_fbp;            // 0x2
|-
    u32 max_lts_per_ltc;            // 0x1
| 0x40044406 || In || 4 || NVGPU_DBG_GPU_IOCTL_SUSPEND_RESUME_ALL_SMS
    u32 max_tex_per_tpc;            // 0x0 (not supported)
|-
    u32 max_gpc_count;              // 0x1
| 0xC0184407 || Inout || 24 || NVGPU_DBG_GPU_IOCTL_PERFBUF_MAP
    u32 rop_l2_en_mask_0;          // 0x21D70 (fuse_status_opt_rop_l2_fbp_r)
|-
    u32 rop_l2_en_mask_1;          // 0x0
| 0x40084408 || In || 8 || NVGPU_DBG_GPU_IOCTL_PERFBUF_UNMAP
    u64 chipname;                  // 0x6230326D67 ("gm20b")
|-
    u64 gr_compbit_store_base_hw;  // 0x0 (not supported)
| 0x40084409 || In || 8 || NVGPU_DBG_GPU_IOCTL_PC_SAMPLING
  };
|-
| 0x4008440A || In || 8 || NVGPU_DBG_GPU_IOCTL_TIMEOUT
  struct {
|-
    __inout u64 gpu_characteristics_buf_size;  // must not be NULL, but gets overwritten with 0xA0=max_size
| 0x8008440B || Out || 8 || NVGPU_DBG_GPU_IOCTL_GET_TIMEOUT
    __in    u64 gpu_characteristics_buf_addr;  // ignored, but must not be NULL
|-
    __out struct gpu_characteristics gc;
| 0x8004440C || Out || 4 || NVGPU_DBG_GPU_IOCTL_GET_GR_CONTEXT_SIZE
  };
|-
 
| 0x0000440D || None || 0 || [[#NVGPU_DBG_GPU_IOCTL_GET_GR_CONTEXT]]
=== NVGPU_GPU_IOCTL_GET_TPC_MASKS ===
|-
Returns the TPC mask value for each GPC. Modified to return inline data instead of using a pointer.
| 0xC018440E || Inout || 24 || NVGPU_DBG_GPU_IOCTL_ACCESS_FB_MEMORY
 
|-
[3.0.0+] Uses either [[#Ioctl|Ioctl]] or [[#Ioctl3|Ioctl3]].
| 0xC018440F || Inout || 24 || NVGPU_DBG_GPU_IOCTL_GET_GPU_VA_RANGE_NUM_PDES
 
|-
  struct {
| 0xC0104410 || Inout || 16 || [[#NVGPU_DBG_GPU_IOCTL_GET_GPU_VA_RANGE_PDES]]
    __in u32 mask_buf_size;      // ignored, but must not be NULL
|-
    __in u32 reserved[3];
| 0xC0184411 || Inout || 24 || NVGPU_DBG_GPU_IOCTL_GET_GPU_VA_RANGE_NUM_PTES
    __out u64 mask_buf;          // receives one 32-bit TPC mask per GPC (GPC 0 and GPC 1)
|-
  };
| 0xC0104412 || Inout || 16 || [[#NVGPU_DBG_GPU_IOCTL_GET_GPU_VA_RANGE_PTES]]
 
|-
=== NVGPU_GPU_IOCTL_FLUSH_L2 ===
| 0xC0684413 || Inout || 104 || NVGPU_DBG_GPU_IOCTL_GET_COMPTAG_INFO
Flushes the GPU L2 cache.
|-
| 0xC0184414 || Inout || 24 || [[#NVGPU_DBG_GPU_IOCTL_READ_COMPTAGS]]
|-
| 0xC0184415 || Inout || 24 || [[#NVGPU_DBG_GPU_IOCTL_WRITE_COMPTAGS]]
|-
| 0xC0104416 || Inout || 16 || NVGPU_DBG_GPU_IOCTL_RESERVE_COMPTAGS
|-
| 0xC0104417 || Inout || 16 || NVGPU_DBG_GPU_IOCTL_FREE_RESERVED_COMPTAGS
|-
| 0xC0104418 || Inout || 16 || NVGPU_DBG_GPU_IOCTL_RESERVE_PA
|-
| 0xC0104419 || Inout || 16 || NVGPU_DBG_GPU_IOCTL_FREE_RESERVED_PA
|-
| 0xC018441A || Inout || 24 || NVGPU_DBG_GPU_IOCTL_LAZY_ALLOC_RESERVED_PA
|-
| 0xC020441B || Inout || 32 || [11.0.0+] NVGPU_DBG_GPU_IOCTL_LAZY_ALLOC_RESERVED_PA_EX
|-
| 0xC084441C || Inout || 132 || [11.0.0+] NVGPU_DBG_GPU_IOCTL_GET_SETTINGS
|-
| 0xC018441D || Inout || 24 || [11.0.0+] NVGPU_DBG_GPU_IOCTL_GET_SERIAL_NUMBER
|-
| 0xC020441E || Inout || 32 || [11.0.0+] NVGPU_DBG_GPU_IOCTL_GET_GPU_VA_RANGE_PAGES
|}


  struct {
=== NVGPU_DBG_GPU_IOCTL_GET_GR_CONTEXT ===
    __in u32 flush;          // l2_flush | l2_invalidate << 1 | fb_flush << 2
Uses [[#Ioctl3|Ioctl3]].
    __in u32 reserved;
  };


=== NVGPU_GPU_IOCTL_INVAL_ICACHE ===
=== NVGPU_DBG_GPU_IOCTL_GET_GPU_VA_RANGE_PDES ===
Invalidates the GPU instruction cache. Identical to Linux driver.
Uses [[#Ioctl3|Ioctl3]].


  struct {
=== NVGPU_DBG_GPU_IOCTL_GET_GPU_VA_RANGE_PTES ===
    __in s32 channel_fd;
Uses [[#Ioctl3|Ioctl3]].
    __in u32 reserved;
  };


=== NVGPU_GPU_IOCTL_SET_MMU_DEBUG_MODE ===
=== NVGPU_DBG_GPU_IOCTL_READ_COMPTAGS ===
Sets the GPU MMU debug mode. Identical to Linux driver.
Uses [[#Ioctl3|Ioctl3]].


  struct {
=== NVGPU_DBG_GPU_IOCTL_WRITE_COMPTAGS ===
    __in u32 state;
Uses [[#Ioctl2|Ioctl2]].
    __in u32 reserved;
  };


=== NVGPU_GPU_IOCTL_SET_SM_DEBUG_MODE ===
== /dev/nvhost-prof-gpu ==
Sets the GPU SM debug mode. Identical to Linux driver.
Returns [[#Errors|NotSupported]] on Open unless nn::settings::detail::GetDebugModeFlag is set.


  struct {
This device is identical to [[#/dev/nvhost-dbg-gpu|/dev/nvhost-dbg-gpu]].
    __in s32 channel_fd;
    __in u32 enable;
    __in u64 sms;
  };


=== NVGPU_GPU_IOCTL_WAIT_FOR_PAUSE ===
== /dev/nvhost-ctrl-gpu ==
Waits until all valid warps on the GPU SM are paused and returns their current state.
This device is for global (context independent) operations on the gpu.
 
                                                                                                                                             
  struct {
{| class="wikitable" border="1"
    __in u64 pwarpstate;
! Value || Direction || Size || Description
  };
|-
 
| 0x80044701 || Out || 4 || [[#NVGPU_GPU_IOCTL_ZCULL_GET_CTX_SIZE]]
[6.1.0+] This command was modified to return inline data instead of using a pointer.
|-
 
| 0x80284702 || Out || 40 || [[#NVGPU_GPU_IOCTL_ZCULL_GET_INFO]]
  struct {
|-
    __out u64 sm0_valid_warps;
| 0x402C4703 || In || 44 || [[#NVGPU_GPU_IOCTL_ZBC_SET_TABLE]]
    __out u64 sm0_trapped_warps;
|-
    __out u64 sm0_paused_warps;
| 0xC0344704 || Inout || 52 || [[#NVGPU_GPU_IOCTL_ZBC_QUERY_TABLE]]
    __out u64 sm1_valid_warps;
|-
    __out u64 sm1_trapped_warps;
| 0xC0B04705 || Inout || 176 || [[#NVGPU_GPU_IOCTL_GET_CHARACTERISTICS]]
    __out u64 sm1_paused_warps;
|-
  };
| 0xC0184706 || Inout || 24 || [[#NVGPU_GPU_IOCTL_GET_TPC_MASKS]]
 
|-
=== NVGPU_GPU_IOCTL_GET_TPC_EXCEPTION_EN_STATUS ===
| 0x40084707 || In || 8 || [[#NVGPU_GPU_IOCTL_FLUSH_L2]]
Returns a mask value describing all active TPC exceptions. Identical to Linux driver.
|-
 
| 0x4008470D || In || 8 || [[#NVGPU_GPU_IOCTL_INVAL_ICACHE]]
  struct {
|-
    __out u64 tpc_exception_en_sm_mask;
| 0x4008470E || In || 8 || [[#NVGPU_GPU_IOCTL_SET_MMU_DEBUG_MODE]]
  };
|-
 
| 0x4010470F || In || 16 || [[#NVGPU_GPU_IOCTL_SET_SM_DEBUG_MODE]]
=== NVGPU_GPU_IOCTL_NUM_VSMS ===
|-
Returns the number of GPU SM units present. Identical to Linux driver.
| 0xC0304710</br>([1.0.0-6.1.0] 0xC0084710) || Inout || 48</br>([1.0.0-6.1.0] 8) || [[#NVGPU_GPU_IOCTL_WAIT_FOR_PAUSE]]
 
|-
  struct {
| 0x80084711 || Out || 8 || [[#NVGPU_GPU_IOCTL_GET_TPC_EXCEPTION_EN_STATUS]]
    __out u32 num_vsms;
|-
    __out u32 reserved;
| 0x80084712 || Out || 8 || [[#NVGPU_GPU_IOCTL_NUM_VSMS]]
  };
|-
| 0xC0044713 || Inout || 4 || [[#NVGPU_GPU_IOCTL_VSMS_MAPPING]]
|-
| 0x80084714 || Out || 8 || [[#NVGPU_GPU_IOCTL_ZBC_GET_ACTIVE_SLOT_MASK]]
|-
| 0x80044715 || Out || 4 || [[#NVGPU_GPU_IOCTL_PMU_GET_GPU_LOAD]]
|-
| 0x40084716 || In || 8 || [[#NVGPU_GPU_IOCTL_SET_CG_CONTROLS]]
|-
| 0xC0084717 || Inout || 8 || [[#NVGPU_GPU_IOCTL_GET_CG_CONTROLS]]
|-
| 0x40084718 || In || 8 || [[#NVGPU_GPU_IOCTL_SET_PG_CONTROLS]]
|-
| 0xC0084719 || Inout || 8 || [[#NVGPU_GPU_IOCTL_GET_PG_CONTROLS]]
|-
| 0x8018471A || Out || 24 || [[#NVGPU_GPU_IOCTL_PMU_GET_ELPG_RESIDENCY_GATING]]
|-
| 0xC008471B || Inout || 8 || [[#NVGPU_GPU_IOCTL_GET_ERROR_CHANNEL_USER_DATA]]
|-
| 0xC010471C || Inout || 16 || [[#NVGPU_GPU_IOCTL_GET_GPU_TIME]]
|-
| 0xC108471D || Inout || 264 || [[#NVGPU_GPU_IOCTL_GET_CPU_TIME_CORRELATION_INFO]]
|}


=== NVGPU_GPU_IOCTL_VSMS_MAPPING ===
=== NVGPU_GPU_IOCTL_ZCULL_GET_CTX_SIZE ===
Returns mapping information on each GPU SM unit. Modified to return inline data instead of using a pointer.
Returns the GPU's ZCULL context size. Identical to Linux driver.


  struct {
struct {
     __out u8 sm0_gpc_index;
     __out u32 size;
    __out u8 sm0_tpc_index;
    __out u8 sm1_gpc_index;
    __out u8 sm1_tpc_index;
   };
   };


=== NVGPU_GPU_IOCTL_ZBC_GET_ACTIVE_SLOT_MASK ===
=== NVGPU_GPU_IOCTL_ZCULL_GET_INFO ===
Returns the mask value for a ZBC slot.
Returns GPU's ZCULL information. Identical to Linux driver.


  struct {
struct {
     __out u32 slot;       // always 0x07
     __out u32 width_align_pixels;
     __out u32 mask;
     __out u32 height_align_pixels;
    __out u32 pixel_squares_by_aliquots;
    __out u32 aliquot_total;
    __out u32 region_byte_multiplier;
    __out u32 region_header_size;
    __out u32 subregion_header_size;
    __out u32 subregion_width_align_pixels;
    __out u32 subregion_height_align_pixels;
    __out u32 subregion_count;
   };
   };


=== NVGPU_GPU_IOCTL_PMU_GET_GPU_LOAD ===
=== NVGPU_GPU_IOCTL_ZBC_SET_TABLE ===
Returns the GPU load value from the PMU.
Sets the active ZBC table. Identical to Linux driver.


  struct {
struct {
     __out u32 pmu_gpu_load;
     __in u32 color_ds[4];
    __in u32 color_l2[4];
    __in u32 depth;
    __in u32 format;
    __in u32 type;        // 1=color, 2=depth
   };
   };


=== NVGPU_GPU_IOCTL_SET_CG_CONTROLS ===
=== NVGPU_GPU_IOCTL_ZBC_QUERY_TABLE ===
Sets the clock gate control value.
Queries the active ZBC table. Identical to Linux driver.


  struct {
struct {
     __in u32 cg_mask;
     __out u32 color_ds[4];
     __in u32 cg_value;
     __out u32 color_l2[4];
    __out u32 depth;
    __out u32 ref_cnt;
    __out u32 format;
    __out u32 type;
    __inout u32 index_size;
   };
   };


=== NVGPU_GPU_IOCTL_GET_CG_CONTROLS ===
=== NVGPU_GPU_IOCTL_GET_CHARACTERISTICS ===
Returns the clock gate control value.
Returns the GPU characteristics. Modified to return inline data instead of using a pointer.


  struct {
[3.0.0+] Uses either [[#Ioctl|Ioctl]] or [[#Ioctl3|Ioctl3]].
    __in u32 cg_mask;
    __out u32 cg_value;
  };
 
=== NVGPU_GPU_IOCTL_SET_PG_CONTROLS ===
Sets the power gate control value.
 
  struct {
    __in u32 pg_mask;
    __in u32 pg_value;
  };
 
=== NVGPU_GPU_IOCTL_GET_PG_CONTROLS ===
Returns the power gate control value.
 
  struct {
    __in u32 pg_mask;
    __out u32 pg_value;
  };
 
=== NVGPU_GPU_IOCTL_PMU_GET_ELPG_RESIDENCY_GATING ===
Returns the GPU PMU ELPG residency gating values.


  struct gpu_characteristics {
    u32 arch;                      // 0x120 (NVGPU_GPU_ARCH_GM200)
    u32 impl;                      // 0xB (NVGPU_GPU_IMPL_GM20B) or 0xE (NVGPU_GPU_IMPL_GM20B_B)
    u32 rev;                        // 0xA1 (Revision A1)
    u32 num_gpc;                    // 0x1
    u64 l2_cache_size;              // 0x40000
    u64 on_board_video_memory_size; // 0x0 (not used)
    u32 num_tpc_per_gpc;            // 0x2
    u32 bus_type;                  // 0x20 (NVGPU_GPU_BUS_TYPE_AXI)
    u32 big_page_size;              // 0x20000
    u32 compression_page_size;      // 0x20000
    u32 pde_coverage_bit_count;    // 0x1B
    u32 available_big_page_sizes;  // 0x30000
    u32 gpc_mask;                  // 0x1
    u32 sm_arch_sm_version;        // 0x503 (Maxwell Generation 5.0.3)
    u32 sm_arch_spa_version;        // 0x503 (Maxwell Generation 5.0.3)
    u32 sm_arch_warp_count;        // 0x80
    u32 gpu_va_bit_count;          // 0x28
    u32 reserved;                  // NULL
    u64 flags;                      // 0x55 (HAS_SYNCPOINTS | SUPPORT_SPARSE_ALLOCS | SUPPORT_CYCLE_STATS | SUPPORT_CYCLE_STATS_SNAPSHOT)
    u32 twod_class;                // 0x902D (FERMI_TWOD_A)
    u32 threed_class;              // 0xB197 (MAXWELL_B)
    u32 compute_class;              // 0xB1C0 (MAXWELL_COMPUTE_B)
    u32 gpfifo_class;              // 0xB06F (MAXWELL_CHANNEL_GPFIFO_A)
    u32 inline_to_memory_class;    // 0xA140 (KEPLER_INLINE_TO_MEMORY_B)
    u32 dma_copy_class;            // 0xB0B5 (MAXWELL_DMA_COPY_A)
    u32 max_fbps_count;            // 0x1
    u32 fbp_en_mask;                // 0x0 (disabled)
    u32 max_ltc_per_fbp;            // 0x2
    u32 max_lts_per_ltc;            // 0x1
    u32 max_tex_per_tpc;            // 0x0 (not supported)
    u32 max_gpc_count;              // 0x1
    u32 rop_l2_en_mask_0;          // 0x21D70 (fuse_status_opt_rop_l2_fbp_r)
    u32 rop_l2_en_mask_1;          // 0x0
    u64 chipname;                  // 0x6230326D67 ("gm20b")
    u64 gr_compbit_store_base_hw;  // 0x0 (not supported)
  };
   struct {
   struct {
     __out u64 pg_ingating_time_us;
     __inout u64 gpu_characteristics_buf_size;   // must not be NULL, but gets overwritten with 0xA0=max_size
     __out u64 pg_ungating_time_us;
     __in    u64 gpu_characteristics_buf_addr;   // ignored, but must not be NULL
     __out u64 pg_gating_cnt;
     __out struct gpu_characteristics gc;
   };
   };


=== NVGPU_GPU_IOCTL_GET_ERROR_CHANNEL_USER_DATA ===
=== NVGPU_GPU_IOCTL_GET_TPC_MASKS ===
Returns user specific data from the error channel, if one exists.
Returns the TPC mask value for each GPC. Modified to return inline data instead of using a pointer.
 
[3.0.0+] Uses either [[#Ioctl|Ioctl]] or [[#Ioctl3|Ioctl3]].


   struct {
   struct {
     __out u64 data;
    __in u32 mask_buf_size;      // ignored, but must not be NULL
    __in u32 reserved[3];
     __out u64 mask_buf;           // receives one 32-bit TPC mask per GPC (GPC 0 and GPC 1)
   };
   };


=== NVGPU_GPU_IOCTL_GET_GPU_TIME ===
=== NVGPU_GPU_IOCTL_FLUSH_L2 ===
Returns the timestamp from the GPU's nanosecond timer (PTIMER). Identical to Linux driver.
Flushes the GPU L2 cache.


   struct {
   struct {
     __out u64 gpu_timestamp;     // raw GPU counter (PTIMER) value
     __in u32 flush;         // l2_flush | l2_invalidate << 1 | fb_flush << 2
     __out u64 reserved;
     __in u32 reserved;
   };
   };


=== NVGPU_GPU_IOCTL_GET_CPU_TIME_CORRELATION_INFO ===
=== NVGPU_GPU_IOCTL_INVAL_ICACHE ===
Returns CPU/GPU timestamp pairs for correlation analysis. Identical to Linux driver.
Invalidates the GPU instruction cache. Identical to Linux driver.


struct time_correlation_sample {
  struct {
  u64 cpu_timestamp;                                  // from CPU's CNTPCT_EL0 register
    __in s32 channel_fd;
  u64 gpu_timestamp;                                 // from GPU's PTIMER registers
     __in u32 reserved;
};
  };
struct {
  __out struct time_correlation_sample samples[16];  // timestamp pairs
  __in u32     count;                                // number of pairs to read
  __in u32     source_id;                             // cpu clock source id (must be 1)
};


== Channels ==
=== NVGPU_GPU_IOCTL_SET_MMU_DEBUG_MODE ===
Channels are a concept for  NVIDIA hardware blocks that share a common interface.
Sets the GPU MMU debug mode. Identical to Linux driver.


{| class="wikitable" border="1"
  struct {
! Path || Name
    __in u32 state;
|-
    __in u32 reserved;
| /dev/nvhost-gpu || GPU
  };
|-
| /dev/nvhost-msenc || Video Encoder
|-
| /dev/nvhost-nvdec || Video Decoder
|-
| /dev/nvhost-nvjpg || JPEG Decoder
|-
| /dev/nvhost-vic || Video Image Compositor
|-
| /dev/nvhost-display || Display
|}


== Channel Ioctls ==
=== NVGPU_GPU_IOCTL_SET_SM_DEBUG_MODE ===
{| class="wikitable" border="1"
Sets the GPU SM debug mode. Identical to Linux driver.
! Value || Size || Description
 
|-
  struct {
| 0xC0??0001 || Variable || [[#NVHOST_IOCTL_CHANNEL_SUBMIT]]
    __in s32 channel_fd;
|-
    __in u32 enable;
| 0xC0080002 || 8 || [[#NVHOST_IOCTL_CHANNEL_GET_SYNCPOINT]]
    __in u64 sms;
|-
  };
| 0xC0080003 || 8 || [[#NVHOST_IOCTL_CHANNEL_GET_WAITBASE]]
 
|-
=== NVGPU_GPU_IOCTL_WAIT_FOR_PAUSE ===
| 0xC0080004 || 8 || [[#NVHOST_IOCTL_CHANNEL_GET_MODMUTEX]]
Waits until all valid warps on the GPU SM are paused and returns their current state.
|-
 
| 0x40040007 || 4 || [[#NVHOST_IOCTL_CHANNEL_SET_SUBMIT_TIMEOUT]]
  struct {
|-
    __in u64 pwarpstate;
| 0x40080008 || 8 || [[#NVHOST_IOCTL_CHANNEL_SET_CLK_RATE]]
  };
|-
 
| 0xC0??0009 || Variable || [[#NVHOST_IOCTL_CHANNEL_MAP_CMD_BUFFER]]
[6.1.0+] This command was modified to return inline data instead of using a pointer.
|-
 
| 0xC0??000A || Variable || [[#NVHOST_IOCTL_CHANNEL_UNMAP_CMD_BUFFER]]
  struct {
|-
    __out u64 sm0_valid_warps;
| 0x00000013 || 0 || [[#NVHOST_IOCTL_CHANNEL_SET_TIMEOUT_EX]]
    __out u64 sm0_trapped_warps;
|-
    __out u64 sm0_paused_warps;
| 0xC0080023</br>([1.0.0-7.0.1] 0xC0080014) || 8 || [[#NVHOST_IOCTL_CHANNEL_GET_CLK_RATE]]
    __out u64 sm1_valid_warps;
|-
    __out u64 sm1_trapped_warps;
| 0xC0??0024 || Variable || [[#NVHOST_IOCTL_CHANNEL_SUBMIT_EX]]
    __out u64 sm1_paused_warps;
|-
  };
| 0xC0??0025 || Variable || [[#NVHOST_IOCTL_CHANNEL_MAP_CMD_BUFFER_EX]]
 
|-
=== NVGPU_GPU_IOCTL_GET_TPC_EXCEPTION_EN_STATUS ===
| 0xC0??0026 || Variable || [[#NVHOST_IOCTL_CHANNEL_UNMAP_CMD_BUFFER_EX]]
Returns a mask value describing all active TPC exceptions. Identical to Linux driver.
|- style="border-top: double"
 
| 0x40044801 || 4 || [[#NVGPU_IOCTL_CHANNEL_SET_NVMAP_FD]]
  struct {
|-
    __out u64 tpc_exception_en_sm_mask;
| 0x40044803 || 4 || [[#NVGPU_IOCTL_CHANNEL_SET_TIMEOUT]]
  };
|-
 
| 0x40084805 || 8 || [[#NVGPU_IOCTL_CHANNEL_ALLOC_GPFIFO]]
=== NVGPU_GPU_IOCTL_NUM_VSMS ===
|-
Returns the number of GPU SM units present. Identical to Linux driver.
| 0x40184806 || 24 || [[#NVGPU_IOCTL_CHANNEL_WAIT]]
 
|-
  struct {
| 0xC0044807 || 4 || [[#NVGPU_IOCTL_CHANNEL_CYCLE_STATS]]
    __out u32 num_vsms;
|-
    __out u32 reserved;
| 0xC0??4808 || Variable || [[#NVGPU_IOCTL_CHANNEL_SUBMIT_GPFIFO]]
  };
|-
 
| 0xC0104809 || 16 || [[#NVGPU_IOCTL_CHANNEL_ALLOC_OBJ_CTX]]
=== NVGPU_GPU_IOCTL_VSMS_MAPPING ===
|-
Returns mapping information on each GPU SM unit. Modified to return inline data instead of using a pointer.
| 0x4008480A || 8 || [[#NVHOST_IOCTL_CHANNEL_FREE_OBJ_CTX]]
 
|-
  struct {
| 0xC010480B || 16 || [[#NVGPU_IOCTL_CHANNEL_ZCULL_BIND]]
    __out u8 sm0_gpc_index;
|-
    __out u8 sm0_tpc_index;
| 0xC018480C || 24 || [[#NVGPU_IOCTL_CHANNEL_SET_ERROR_NOTIFIER]]
    __out u8 sm1_gpc_index;
|-
    __out u8 sm1_tpc_index;
| 0x4004480D || 4 || [[#NVGPU_IOCTL_CHANNEL_SET_PRIORITY]]
  };
|-
 
| 0x0000480E || 0 || [[#NVGPU_IOCTL_CHANNEL_ENABLE]]
=== NVGPU_GPU_IOCTL_ZBC_GET_ACTIVE_SLOT_MASK ===
|-
Returns the mask value for a ZBC slot.
| 0x0000480F || 0 || [[#NVGPU_IOCTL_CHANNEL_DISABLE]]
 
|-
  struct {
| 0x00004810 || 0 || [[#NVGPU_IOCTL_CHANNEL_PREEMPT]]
    __out u32 slot;      // always 0x07
|-
    __out u32 mask;
| 0x00004811 || 0 || [[#NVGPU_IOCTL_CHANNEL_FORCE_RESET]]
  };
|-
 
| 0x40084812 || 8 || [[#NVGPU_IOCTL_CHANNEL_EVENT_ID_CONTROL]]
=== NVGPU_GPU_IOCTL_PMU_GET_GPU_LOAD ===
|-
Returns the GPU load value from the PMU.
| 0xC0104813 || 16 || [[#NVGPU_IOCTL_CHANNEL_CYCLE_STATS_SNAPSHOT]]
|-
| 0x80804816 || 128 || [[#NVGPU_IOCTL_CHANNEL_GET_ERROR_INFO]]
|-
| 0xC0104817 || 16 || [[#NVGPU_IOCTL_CHANNEL_GET_ERROR_NOTIFICATION]]
|-
| 0x40204818 || 32 || [[#NVGPU_IOCTL_CHANNEL_ALLOC_GPFIFO_EX]]
|-
| 0xC0??4819 || Variable || [[#NVGPU_IOCTL_CHANNEL_SUBMIT_GPFIFO_RETRY]]
|-
| 0xC020481A || 32 || [[#NVGPU_IOCTL_CHANNEL_ALLOC_GPFIFO_EX2]]
|-
| 0xC018481B || 24 || [[#NVGPU_IOCTL_CHANNEL_SUBMIT_GPFIFO2]]
|-
| 0xC018481C || 24 || [[#NVGPU_IOCTL_CHANNEL_SUBMIT_GPFIFO2_RETRY]]
|-
| 0xC004481D || 4 || [[#NVGPU_IOCTL_CHANNEL_SET_TIMESLICE]]
|- style="border-top: double"
| 0x40084714 || 8 || [[#NVGPU_IOCTL_CHANNEL_SET_USER_DATA]]
|-
| 0x80084715 || 8 || [[#NVGPU_IOCTL_CHANNEL_GET_USER_DATA]]
|}


=== NVHOST_IOCTL_CHANNEL_SUBMIT ===
  struct {
Submits data to the channel.
    __out u32 pmu_gpu_load;
  };


   struct cmdbuf {
=== NVGPU_GPU_IOCTL_SET_CG_CONTROLS ===
     u32 mem;
Sets the clock gate control value.
    u32 offset;
 
     u32 words;
   struct {
     __in u32 cg_mask;
     __in u32 cg_value;
   };
   };
 
 
   struct reloc {
=== NVGPU_GPU_IOCTL_GET_CG_CONTROLS ===
     u32 cmdbuf_mem;
Returns the clock gate control value.
    u32 cmdbuf_offset;
 
    u32 target;
   struct {
     u32 target_offset;
     __in u32 cg_mask;
     __out u32 cg_value;
   };
   };
 
 
   struct reloc_shift {
=== NVGPU_GPU_IOCTL_SET_PG_CONTROLS ===
     u32 shift;
Sets the power gate control value.
 
   struct {
     __in u32 pg_mask;
    __in u32 pg_value;
   };
   };
 
 
  struct syncpt_incr {
=== NVGPU_GPU_IOCTL_GET_PG_CONTROLS ===
    u32 syncpt_id;
Returns the power gate control value.
    u32 syncpt_incrs;
 
  };
 
  struct fence {
    u32 id;
    u32 thresh;
  };
 
   struct {
   struct {
     __in   u32 num_cmdbufs;
     __in u32 pg_mask;
     __in    u32 num_relocs;
     __out u32 pg_value;
    __in    u32 num_syncpt_incrs;
    __in    u32 num_fences;
    __in    struct cmdbuf cmdbufs[];              // depends on num_cmdbufs
    __in    struct reloc relocs[];                // depends on num_relocs
    __in    struct reloc_shift reloc_shifts[];    // depends on num_relocs
    __in    struct syncpt_incr syncpt_incrs[];    // depends on num_syncpt_incrs
    __out  struct fence fences[];                 // depends on num_fences
   };
   };


=== NVHOST_IOCTL_CHANNEL_GET_SYNCPOINT ===
=== NVGPU_GPU_IOCTL_PMU_GET_ELPG_RESIDENCY_GATING ===
Returns the current syncpoint value for a given module. Identical to Linux driver.
Returns the GPU PMU ELPG residency gating values.


   struct {
   struct {
     __in    u32 module_id;
     __out u64 pg_ingating_time_us;
     __out   u32 syncpt_value;
    __out u64 pg_ungating_time_us;
     __out u64 pg_gating_cnt;
   };
   };


=== NVHOST_IOCTL_CHANNEL_GET_WAITBASE ===
=== NVGPU_GPU_IOCTL_GET_ERROR_CHANNEL_USER_DATA ===
Returns the current waitbase value for a given module. Always returns 0.
Returns user specific data from the error channel, if one exists.


   struct {
   struct {
    __in    u32 module_id;
     __out u64 data;
     __out   u32 waitbase_value;
   };
   };


=== NVHOST_IOCTL_CHANNEL_GET_MODMUTEX ===
=== NVGPU_GPU_IOCTL_GET_GPU_TIME ===
Stubbed. Does a debug print and returns 0.
Returns the timestamp from the GPU's nanosecond timer (PTIMER). Identical to Linux driver.
 
=== NVHOST_IOCTL_CHANNEL_SET_SUBMIT_TIMEOUT ===
Sets the submit timeout value for the channel. Identical to Linux driver.


   struct {
   struct {
     __in    u32 timeout;
     __out u64 gpu_timestamp;      // raw GPU counter (PTIMER) value
    __out u64 reserved;
   };
   };


=== NVHOST_IOCTL_CHANNEL_SET_CLK_RATE ===
=== NVGPU_GPU_IOCTL_GET_CPU_TIME_CORRELATION_INFO ===
Sets the clock rate value for a given module. Identical to Linux driver.
Returns CPU/GPU timestamp pairs for correlation analysis. Identical to Linux driver.


  struct {
struct time_correlation_sample {
    __in   u32 clk_rate;
   u64 cpu_timestamp;                                 // from CPU's CNTPCT_EL0 register
    __in    u32 module_id;
  u64 gpu_timestamp;                                 // from GPU's PTIMER registers
  };
};
 
=== NVHOST_IOCTL_CHANNEL_MAP_CMD_BUFFER ===
Uses '''nvmap_pin''' internally to pin a given number of nvmap handles to an appropriate device physical address.
 
  struct handle {
    u32 handle_id_in;                // nvmap handle to map
    u32 phys_addr_out;               // returned device physical address mapped to the handle
  };
   
   
  struct {
struct {
    __in   u32 num_handles;         // number of nvmap handles to map
   __out struct time_correlation_sample samples[16];   // timestamp pairs
    __in   u32 reserved;            // ignored
  __in u32    count;                                 // number of pairs to read
     __in    u8  is_compr;             // memory to map is compressed
  __in u32     source_id;                             // cpu clock source id (must be 1)
     __in    u8  padding[3];           // ignored
  };
    __inout struct handle handles[]; // depends on num_handles
  };


=== NVHOST_IOCTL_CHANNEL_UNMAP_CMD_BUFFER ===
= Channels =
Uses '''nvmap_unpin''' internally to unpin a given number of nvmap handles from their device physical address.
Channels are a concept for NVIDIA hardware blocks that share a common interface.


  struct handle {
{| class="wikitable" border="1"
    u32 handle_id_in;                // nvmap handle to unmap
! Path || Name
    u32 reserved;                    // ignored
|-
  };
| /dev/nvhost-gpu || GPU
|-
  struct {
| /dev/nvhost-msenc || Video Encoder
    __in    u32 num_handles;          // number of nvmap handles to unmap
|-
    __in    u32 reserved;            // ignored
| /dev/nvhost-nvdec || Video Decoder
    __in    u8  is_compr;            // memory to unmap is compressed
|-
    __in    u8  padding[3];          // ignored
| /dev/nvhost-nvjpg || JPEG Decoder
    __inout struct handle handles[];  // depends on num_handles
|-
  };
| /dev/nvhost-vic || Video Image Compositor
|-
| /dev/nvhost-display || Display
|-
| /dev/nvhost-tsec || TSEC
|}


=== NVHOST_IOCTL_CHANNEL_SET_TIMEOUT_EX ===
== Ioctls ==
Sets the global timeout value for the channel. Identical to Linux driver.
{| class="wikitable" border="1"
 
! Value || Size || Description
  struct {
|-
    __in    u32 timeout;
| 0xC0??0001 || Variable || [[#NVHOST_IOCTL_CHANNEL_SUBMIT]]
    __in    u32 flags;
|-
  };
| 0xC0080002 || 8 || [[#NVHOST_IOCTL_CHANNEL_GET_SYNCPOINT]]
 
|-
=== NVHOST_IOCTL_CHANNEL_GET_CLK_RATE ===
| 0xC0080003 || 8 || [[#NVHOST_IOCTL_CHANNEL_GET_WAITBASE]]
Returns the clock rate value for a given module. Identical to Linux driver.
|-
 
| 0xC0080004 || 8 || [[#NVHOST_IOCTL_CHANNEL_GET_MODMUTEX]]
  struct {
|-
    __out  u32 clk_rate;
| 0x40040007 || 4 || [[#NVHOST_IOCTL_CHANNEL_SET_SUBMIT_TIMEOUT]]
    __in    u32 module_id;
|-
  };
| 0x40080008 || 8 || [[#NVHOST_IOCTL_CHANNEL_SET_CLK_RATE]]
 
|-
=== NVHOST_IOCTL_CHANNEL_SUBMIT_EX ===
| 0xC0??0009 || Variable || [[#NVHOST_IOCTL_CHANNEL_MAP_CMD_BUFFER]]
Same as [[#NVHOST_IOCTL_CHANNEL_SUBMIT|NVHOST_IOCTL_CHANNEL_SUBMIT]].
|-
 
| 0xC0??000A || Variable || [[#NVHOST_IOCTL_CHANNEL_UNMAP_CMD_BUFFER]]
=== NVHOST_IOCTL_CHANNEL_MAP_CMD_BUFFER_EX ===
|-
Same as [[#NVHOST_IOCTL_CHANNEL_MAP_CMD_BUFFER|NVHOST_IOCTL_CHANNEL_MAP_CMD_BUFFER]], but calls '''nvmap_unpin''' internally in case of error.
| 0x00000013 || 0 || [[#NVHOST_IOCTL_CHANNEL_SET_TIMEOUT_EX]]
 
|-
=== NVHOST_IOCTL_CHANNEL_UNMAP_CMD_BUFFER_EX ===
| 0xC0080023</br>([1.0.0-7.0.1] 0xC0080014) || 8 || [[#NVHOST_IOCTL_CHANNEL_GET_CLK_RATE]]
Same as [[#NVHOST_IOCTL_CHANNEL_UNMAP_CMD_BUFFER|NVHOST_IOCTL_CHANNEL_UNMAP_CMD_BUFFER]].
|-
 
| 0xC0??0024 || Variable || [[#NVHOST_IOCTL_CHANNEL_SUBMIT_EX]]
=== NVGPU_IOCTL_CHANNEL_SET_NVMAP_FD ===
|-
Binds a nvmap object to this channel. Identical to Linux driver.
| 0xC0??0025 || Variable || [[#NVHOST_IOCTL_CHANNEL_MAP_CMD_BUFFER_EX]]
 
|-
  struct {
| 0xC0??0026 || Variable || [[#NVHOST_IOCTL_CHANNEL_UNMAP_CMD_BUFFER_EX]]
    __in u32 nvmap_fd;
|- style="border-top: double"
  };
| 0x40044801 || 4 || [[#NVGPU_IOCTL_CHANNEL_SET_NVMAP_FD]]
 
|-
=== NVGPU_IOCTL_CHANNEL_SET_TIMEOUT ===
| 0x40044803 || 4 || [[#NVGPU_IOCTL_CHANNEL_SET_TIMEOUT]]
Sets the timeout value for the GPU channel. Identical to Linux driver.
|-
 
| 0x40084805 || 8 || [[#NVGPU_IOCTL_CHANNEL_ALLOC_GPFIFO]]
  struct {
|-
    __in u32 timeout;
| 0x40184806 || 24 || [[#NVGPU_IOCTL_CHANNEL_WAIT]]
  };
|-
 
| 0xC0044807 || 4 || [[#NVGPU_IOCTL_CHANNEL_CYCLE_STATS]]
=== NVGPU_IOCTL_CHANNEL_ALLOC_GPFIFO ===
|-
Allocates gpfifo entries. Identical to Linux driver.
| 0xC0??4808 || Variable || [[#NVGPU_IOCTL_CHANNEL_SUBMIT_GPFIFO]]
 
|-
  struct {
| 0xC0104809 || 16 || [[#NVGPU_IOCTL_CHANNEL_ALLOC_OBJ_CTX]]
    __in u32 num_entries;
|-
    __in u32 flags;
| 0x4008480A || 8 || [[#NVHOST_IOCTL_CHANNEL_FREE_OBJ_CTX]]
  };
|-
 
| 0xC010480B || 16 || [[#NVGPU_IOCTL_CHANNEL_ZCULL_BIND]]
=== NVGPU_IOCTL_CHANNEL_WAIT ===
|-
Waits on channel. Identical to Linux driver.
| 0xC018480C || 24 || [[#NVGPU_IOCTL_CHANNEL_SET_ERROR_NOTIFIER]]
 
|-
  struct {
| 0x4004480D || 4 || [[#NVGPU_IOCTL_CHANNEL_SET_PRIORITY]]
    __in u32 type;            // wait type (0=notifier, 1=semaphore)
|-
    __in u32 timeout;        // wait timeout value
| 0x0000480E || 0 || [[#NVGPU_IOCTL_CHANNEL_ENABLE]]
    __in u32 dmabuf_fd;      // nvmap handle
|-
    __in u32 offset;          // nvmap memory offset
| 0x0000480F || 0 || [[#NVGPU_IOCTL_CHANNEL_DISABLE]]
    __in u32 payload;        // payload data (semaphore only)
|-
    __in u32 padding;        // ignored
| 0x00004810 || 0 || [[#NVGPU_IOCTL_CHANNEL_PREEMPT]]
  };
|-
 
| 0x00004811 || 0 || [[#NVGPU_IOCTL_CHANNEL_FORCE_RESET]]
=== NVGPU_IOCTL_CHANNEL_CYCLE_STATS ===
|-
Maps memory for the cycle stats buffer. Identical to Linux driver.
| 0x40084812 || 8 || [[#NVGPU_IOCTL_CHANNEL_EVENT_ID_CONTROL]]
 
|-
  struct {
| 0xC0104813 || 16 || [[#NVGPU_IOCTL_CHANNEL_CYCLE_STATS_SNAPSHOT]]
    __in u32 dmabuf_fd;  // nvmap handle
|-
  };
| 0x80804816 || 128 || [[#NVGPU_IOCTL_CHANNEL_GET_ERROR_INFO]]
|-
| 0xC0104817 || 16 || [[#NVGPU_IOCTL_CHANNEL_GET_ERROR_NOTIFICATION]]
|-
| 0x40204818 || 32 || [[#NVGPU_IOCTL_CHANNEL_ALLOC_GPFIFO_EX]]
|-
| 0xC0??4819 || Variable || [[#NVGPU_IOCTL_CHANNEL_SUBMIT_GPFIFO_RETRY]]
|-
| 0xC020481A || 32 || [[#NVGPU_IOCTL_CHANNEL_ALLOC_GPFIFO_EX2]]
|-
| 0xC018481B || 24 || [[#NVGPU_IOCTL_CHANNEL_SUBMIT_GPFIFO2]]
|-
| 0xC018481C || 24 || [[#NVGPU_IOCTL_CHANNEL_SUBMIT_GPFIFO2_RETRY]]
|-
| 0xC004481D || 4 || [[#NVGPU_IOCTL_CHANNEL_SET_TIMESLICE]]
|- style="border-top: double"
| 0x40084714 || 8 || [[#NVGPU_IOCTL_CHANNEL_SET_USER_DATA]]
|-
| 0x80084715 || 8 || [[#NVGPU_IOCTL_CHANNEL_GET_USER_DATA]]
|}


=== NVGPU_IOCTL_CHANNEL_SUBMIT_GPFIFO ===
=== NVHOST_IOCTL_CHANNEL_SUBMIT ===
Submits a gpfifo object. Modified to take inline entry objects instead of a pointer.
Submits data to the channel.


   struct fence {
   struct cmdbuf {
     u32 id;
     u32 mem;
     u32 thresh;
     u32 offset;
    u32 words;
   };
   };
    
    
   struct gpfifo_entry {
   struct reloc {
     u64 entry;                               // gpu_iova | (unk_2bits << 40) | (size << 42) | (unk_flag << 63)
     u32 cmdbuf_mem;
    u32 cmdbuf_offset;
    u32 target;
    u32 target_offset;
  };
 
  struct reloc_shift {
    u32 shift;
  };
 
  struct syncpt_incr {
    u32 syncpt_id;
    u32 syncpt_incrs;
    u32 reserved[3];
   };
   };
    
    
   struct {
   struct {
     __in    u64 gpfifo;                     // (ignored) pointer to gpfifo fence structs
     __in    u32 num_cmdbufs;
     __in    u32 num_entries;                 // number of fence objects being submitted
    __in    u32 num_relocs;
     __in    u32 flags;
    __in    u32 num_syncpt_incrs;
     __inout struct fence fence_out;         // returned new fence object for others to wait on
     __in    u32 num_fences;
     __in    struct gpfifo_entry entries[];  // depends on num_entries
    __in    struct cmdbuf cmdbufs[];              // depends on num_cmdbufs
     __in    struct reloc relocs[];                 // depends on num_relocs
     __in    struct reloc_shift reloc_shifts[];     // depends on num_relocs
     __in    struct syncpt_incr syncpt_incrs[];     // depends on num_syncpt_incrs
    __out   u32 fence_thresholds[];                // depends on num_fences
   };
   };


=== NVGPU_IOCTL_CHANNEL_ALLOC_OBJ_CTX ===
=== NVHOST_IOCTL_CHANNEL_GET_SYNCPOINT ===
Allocates a graphics context object. Modified to ignore object's ID.
Returns the current syncpoint value for a given module. Identical to Linux driver.
 
You can only have one object context allocated at a time. You must have bound an address space before using this.


   struct {
   struct {
     __in u32 class_num;   // 0x902D=2d, 0xB197=3d, 0xB1C0=compute, 0xA140=kepler, 0xB0B5=DMA, 0xB06F=channel_gpfifo
     __in    u32 module_id;
    __in  u32 flags;       // bit0: LOCKBOOST_ZERO
     __out   u32 syncpt_value;
     __out u64 obj_id;       // (ignored) used for FREE_OBJ_CTX ioctl, which is not supported
   };
   };


=== NVHOST_IOCTL_CHANNEL_FREE_OBJ_CTX ===
=== NVHOST_IOCTL_CHANNEL_GET_WAITBASE ===
Frees a graphics context object. Not supported.
Returns the current waitbase value for a given module. Always returns 0.


   struct {
   struct {
     __in u64 obj_id;       // ignored
     __in   u32 module_id;
    __out  u32 waitbase_value;
   };
   };


=== NVGPU_IOCTL_CHANNEL_ZCULL_BIND ===
=== NVHOST_IOCTL_CHANNEL_GET_MODMUTEX ===
Binds a ZCULL context to the channel. Identical to Linux driver.
Stubbed. Does a debug print and returns 0.
 
=== NVHOST_IOCTL_CHANNEL_SET_SUBMIT_TIMEOUT ===
Sets the submit timeout value for the channel. Identical to Linux driver.


struct {
  struct {
     __in u64 gpu_va;
     __in   u32 timeout;
    __in u32 mode;        // 0=global, 1=no_ctxsw, 2=separate_buffer, 3=part_of_regular_buf
    __in u32 reserved;
   };
   };


=== NVGPU_IOCTL_CHANNEL_SET_ERROR_NOTIFIER ===
=== NVHOST_IOCTL_CHANNEL_SET_CLK_RATE ===
Initializes the error notifier for this channel. Unlike for the Linux kernel, the Switch driver cannot write to an arbitrary userspace buffer. Thus new ioctls have been introduced to fetch the error information rather than using a shared memory buffer.
Sets the clock rate value for a given module. Identical to Linux driver.


   struct {
   struct {
     __in u64 offset;  // ignored
     __in   u32 clk_rate;
    __in u64 size;    // ignored
     __in   u32 module_id;
    __in u32 mem;     // must be non-zero to initialize, zero to de-initialize
     __in u32 reserved; // ignored
   };
   };


=== NVGPU_IOCTL_CHANNEL_SET_PRIORITY ===
=== NVHOST_IOCTL_CHANNEL_MAP_CMD_BUFFER ===
Changes channel's priority. Identical to Linux driver.
Uses '''nvmap_pin''' internally to pin a given number of nvmap handles to an appropriate device physical address.


  struct handle {
    u32 handle_id_in;                // nvmap handle to map
    u32 phys_addr_out;                // returned device physical address mapped to the handle
  };
   struct {
   struct {
     __in u32 priority;    // 0x32 is low, 0x64 is medium and 0x96 is high
     __in   u32 num_handles;         // number of nvmap handles to map
    __in   u32 reserved;            // ignored
    __in    u8  is_compr;            // memory to map is compressed
    __in    u8  padding[3];          // ignored
    __inout struct handle handles[];  // depends on num_handles
   };
   };


=== NVGPU_IOCTL_CHANNEL_ENABLE ===
=== NVHOST_IOCTL_CHANNEL_UNMAP_CMD_BUFFER ===
Enables the current channel. Identical to Linux driver.
Uses '''nvmap_unpin''' internally to unpin a given number of nvmap handles from their device physical address.


=== NVGPU_IOCTL_CHANNEL_DISABLE ===
  struct handle {
Disables the current channel. Identical to Linux driver.
    u32 handle_id_in;                // nvmap handle to unmap
    u32 reserved;                    // ignored
  };
  struct {
    __in    u32 num_handles;          // number of nvmap handles to unmap
    __in    u32 reserved;            // ignored
    __in    u8  is_compr;            // memory to unmap is compressed
    __in    u8  padding[3];          // ignored
    __inout struct handle handles[];  // depends on num_handles
  };


=== NVGPU_IOCTL_CHANNEL_PREEMPT ===
=== NVHOST_IOCTL_CHANNEL_SET_TIMEOUT_EX ===
Clears the FIFO pipe for this channel. Identical to Linux driver.
Sets the global timeout value for the channel. Identical to Linux driver.


=== NVGPU_IOCTL_CHANNEL_FORCE_RESET ===
  struct {
Forces the channel to reset. Identical to Linux driver.
    __in    u32 timeout;
    __in    u32 flags;
  };


=== NVGPU_IOCTL_CHANNEL_EVENT_ID_CONTROL ===
=== NVHOST_IOCTL_CHANNEL_GET_CLK_RATE ===
Controls event notifications.
Returns the clock rate value for a given module. Identical to Linux driver.


   struct {
   struct {
     __in u32 cmd;   // 0=disable, 1=enable, 2=clear
     __out  u32 clk_rate;
     __in u32 id;     // same id's as for [[#QueryEvent]]
     __in   u32 module_id;
   };
   };


=== NVGPU_IOCTL_CHANNEL_CYCLE_STATS_SNAPSHOT ===
=== NVHOST_IOCTL_CHANNEL_SUBMIT_EX ===
Controls the cycle stats snapshot buffer. Identical to Linux driver.
Same as [[#NVHOST_IOCTL_CHANNEL_SUBMIT|NVHOST_IOCTL_CHANNEL_SUBMIT]].
 
=== NVHOST_IOCTL_CHANNEL_MAP_CMD_BUFFER_EX ===
Same as [[#NVHOST_IOCTL_CHANNEL_MAP_CMD_BUFFER|NVHOST_IOCTL_CHANNEL_MAP_CMD_BUFFER]], but calls '''nvmap_unpin''' internally in case of error.
 
=== NVHOST_IOCTL_CHANNEL_UNMAP_CMD_BUFFER_EX ===
Same as [[#NVHOST_IOCTL_CHANNEL_UNMAP_CMD_BUFFER|NVHOST_IOCTL_CHANNEL_UNMAP_CMD_BUFFER]].
 
=== NVGPU_IOCTL_CHANNEL_SET_NVMAP_FD ===
Binds a nvmap object to this channel. Identical to Linux driver.


   struct {
   struct {
     __in   u32 cmd;         // command to handle (0=flush, 1=attach, 2=detach)
     __in u32 nvmap_fd;
    __in    u32 dmabuf_fd;  // nvmap handle
    __inout u32 extra;      // extra payload data/result
    __in    u32 padding;    // ignored
   };
   };


=== NVGPU_IOCTL_CHANNEL_GET_ERROR_INFO ===
=== NVGPU_IOCTL_CHANNEL_SET_TIMEOUT ===
Returns information on the current error notification caught by the error notifier. Exclusive to the Switch.
Sets the timeout value for the GPU channel. Identical to Linux driver.


   struct {
   struct {
     __out u32 error_info[32];   // first word is an error code (0=no_error, 1=gr_error, 2=gr_error, 3=invalid, 4=invalid)
     __in u32 timeout;
   };
   };


=== NVGPU_IOCTL_CHANNEL_GET_ERROR_NOTIFICATION ===
=== NVGPU_IOCTL_CHANNEL_ALLOC_GPFIFO ===
Returns the current error notification caught by the error notifier. Exclusive to the Switch.
Allocates gpfifo entries. Identical to Linux driver.


   struct {
   struct {
     __out u64 timestamp;   // fetched straight from armGetSystemTick
     __in u32 num_entries;
     __out u32 info32;      // error code
     __in u32 flags;           // bit0: vpr_enabled
    __out u16 info16;      // additional error info
    __out u16 status;       // always 0xFFFF
   };
   };


=== NVGPU_IOCTL_CHANNEL_ALLOC_GPFIFO_EX ===
=== NVGPU_IOCTL_CHANNEL_WAIT ===
Allocates gpfifo entries with additional parameters. Exclusive to the Switch.
Waits on channel. Identical to Linux driver.


struct fence {
  struct {
     u32 id;
     __in u32 type;           // wait type (0=notifier, 1=semaphore)
     u32 thresh;
     __in u32 timeout;         // wait timeout value
};
    __in u32 dmabuf_fd;       // nvmap handle
    __in u32 offset;         // nvmap memory offset
struct {
    __in u32 payload;         // payload data (semaphore only)
  __in   u32 num_entries;
    __in u32 padding;         // ignored
  __in   u32 num_jobs;
  };
  __in   u32 flags;
  __out  struct fence fence_out;          // returned new fence object for others to wait on
  __in   u32 reserved[3];                 // ignored
};


=== NVGPU_IOCTL_CHANNEL_SUBMIT_GPFIFO_RETRY ===
=== NVGPU_IOCTL_CHANNEL_CYCLE_STATS ===
Same as [[#NVGPU_IOCTL_CHANNEL_SUBMIT_GPFIFO|NVGPU_IOCTL_CHANNEL_SUBMIT_GPFIFO]].
Maps memory for the cycle stats buffer. Identical to Linux driver.


=== NVGPU_IOCTL_CHANNEL_ALLOC_GPFIFO_EX2 ===
  struct {
Same as [[#NVGPU_IOCTL_CHANNEL_ALLOC_GPFIFO_EX|NVGPU_IOCTL_CHANNEL_ALLOC_GPFIFO_EX]].
    __in u32 dmabuf_fd;  // nvmap handle
  };


=== NVGPU_IOCTL_CHANNEL_SUBMIT_GPFIFO2 ===
=== NVGPU_IOCTL_CHANNEL_SUBMIT_GPFIFO ===
Same as [[#NVGPU_IOCTL_CHANNEL_SUBMIT_GPFIFO|NVGPU_IOCTL_CHANNEL_SUBMIT_GPFIFO]], but uses [[#Ioctl2|Ioctl2]].
Submits a gpfifo object. Modified to take inline entry objects instead of a pointer.
 
=== NVGPU_IOCTL_CHANNEL_SUBMIT_GPFIFO2_RETRY ===
Same as [[#NVGPU_IOCTL_CHANNEL_SUBMIT_GPFIFO_RETRY|NVGPU_IOCTL_CHANNEL_SUBMIT_GPFIFO_RETRY]], but uses [[#Ioctl2|Ioctl2]].
 
=== NVGPU_IOCTL_CHANNEL_SET_TIMESLICE ===
Changes channel's timeslice. Identical to Linux driver.


  struct fence {
    u32 id;
    u32 value;
  };
 
  struct gpfifo_entry {
    u32 entry0;                              // gpu_iova_lo
    u32 entry1;                              // gpu_iova_hi | (allow_flush << 8) | (is_push_buf << 9) | (size << 10) | (sync << 31)
  };
 
   struct {
   struct {
     __in u32 timeslice;
     __in   u64 gpfifo;                      // (ignored) pointer to gpfifo fence structs
    __in    u32 num_entries;                // number of fence objects being submitted
    union {
      __out u32 detailed_error;
      __in  u32 flags;                      // bit0: fence_wait, bit1: fence_get, bit2: hw_format, bit3: sync_fence, bit4: suppress_wfi, bit5: skip_buffer_refcounting
    };
    __inout struct fence fence_out;          // returned new fence object for others to wait on
    __in    struct gpfifo_entry entries[];   // depends on num_entries
   };
   };


=== NVGPU_IOCTL_CHANNEL_SET_USER_DATA ===
=== NVGPU_IOCTL_CHANNEL_ALLOC_OBJ_CTX ===
Sets user specific data.
Allocates a graphics context object. Modified to ignore object's ID.
 
You can only have one object context allocated at a time. You must have bound an address space before using this.


   struct {
   struct {
     __in u64 data;
     __in u32 class_num;    // 0x902D=2d, 0xB197=3d, 0xB1C0=compute, 0xA140=kepler, 0xB0B5=DMA, 0xB06F=channel_gpfifo
    __in  u32 flags;        // bit0: LOCKBOOST_ZERO
    __out u64 obj_id;       // (ignored) used for FREE_OBJ_CTX ioctl, which is not supported
   };
   };


=== NVGPU_IOCTL_CHANNEL_GET_USER_DATA ===
=== NVHOST_IOCTL_CHANNEL_FREE_OBJ_CTX ===
Returns user specific data.
Frees a graphics context object. Not supported.


   struct {
   struct {
     __out u64 data;
     __in u64 obj_id;       // ignored
   };
   };


= nvmemp =
=== NVGPU_IOCTL_CHANNEL_ZCULL_BIND ===
This is "nv::MemoryProfiler::IMemoryProfiler".
Binds a ZCULL context to the channel. Identical to Linux driver.
 
struct {
    __in u64 gpu_va;
    __in u32 mode;        // 0=global, 1=no_ctxsw, 2=separate_buffer, 3=part_of_regular_buf
    __in u32 reserved;
  };


/dev/nvhost-ctrl sends the ioctl NVHOST_IOCTL_CTRL_GET_CONFIG to check the config "nv!NV_MEMORY_PROFILER". If config_str returns "1", the application attempts to use nvmemp.
=== NVGPU_IOCTL_CHANNEL_SET_ERROR_NOTIFIER ===
Initializes the error notifier for this channel. Unlike for the Linux kernel, the Switch driver cannot write to an arbitrary userspace buffer. Thus new ioctls have been introduced to fetch the error information rather than using a shared memory buffer.


{| class="wikitable" border="1"
  struct {
|-
    __in u64 offset;  // ignored
! Cmd || Name
    __in u64 size;    // ignored
|-
    __in u32 mem;      // must be non-zero to initialize, zero to de-initialize
| 0 || Open
    __in u32 reserved; // ignored
|-
  };
| 1 || GetPid
|}


= nvdrvdbg =
=== NVGPU_IOCTL_CHANNEL_SET_PRIORITY ===
This is "nns::nvdrv::INvDrvDebugFSServices".
Changes channel's priority. Identical to Linux driver.


{| class="wikitable" border="1"
  struct {
|-
    __in u32 priority;    // 0x32 is low, 0x64 is medium and 0x96 is high
! Cmd || Name
  };
|-
| 0 || [[#OpenDebugFS]]
|-
| 1 || [[#CloseDebugFS]]
|-
| 2 || [[#GetDebugFSKeys]]
|-
| 3 || GetDebugFSValue
|-
| 4 || SetDebugFSValue
|}


== OpenDebugFS ==
=== NVGPU_IOCTL_CHANNEL_ENABLE ===
Takes a process handle. Returns a u32 '''fd'''.
Enables the current channel. Identical to Linux driver.


== CloseDebugFS ==
=== NVGPU_IOCTL_CHANNEL_DISABLE ===
Takes a u32 '''fd''' and closes it.
Disables the current channel. Identical to Linux driver.


== GetDebugFSKeys ==
=== NVGPU_IOCTL_CHANNEL_PREEMPT ===
Takes a u32 '''fd''' and reads debug contents into a type-6 buffer.
Clears the FIFO pipe for this channel. Identical to Linux driver.


= nvgem:c =
=== NVGPU_IOCTL_CHANNEL_FORCE_RESET ===
This is "nv::gemcontrol::INvGemControl".
Forces the channel to reset. Identical to Linux driver.


{| class="wikitable" border="1"
=== NVGPU_IOCTL_CHANNEL_EVENT_ID_CONTROL ===
|-
Controls event notifications.
! Cmd || Name
|-
| 0 || Initialize
|-
| 1 || GetEventHandle
|-
| 2 || ControlNotification
|-
| 3 || SetNotificationPerm
|-
| 4 || SetCoreDumpPerm
|-
| 5 || [1.0.0-4.1.0] GetAruid
|-
| 6 || Reset
|-
| 7 || [3.0.0+]
|}


= nvgem:cd =
  struct {
This is "nv::gemcoredump::INvGemCoreDump".
    __in u32 cmd;    // 0=disable, 1=enable, 2=clear
    __in u32 id;    // same id's as for [[#QueryEvent]]
  };


{| class="wikitable" border="1"
=== NVGPU_IOCTL_CHANNEL_CYCLE_STATS_SNAPSHOT ===
|-
Controls the cycle stats snapshot buffer. Identical to Linux driver.
! Cmd || Name
 
|-
  struct {
| 0 || Initialize
    __in    u32 cmd;        // command to handle (0=flush, 1=attach, 2=detach)
|-
    __in    u32 dmabuf_fd;  // nvmap handle
| 1 || GetAruid
    __inout u32 extra;      // extra payload data/result
|-
    __in    u32 padding;    // ignored
| 2 || [1.0.0-8.1.0] ReadNextBlock
  };
|-
 
| 3 || [8.0.0+]
=== NVGPU_IOCTL_CHANNEL_GET_ERROR_INFO ===
|-
Returns information on the current error notification caught by the error notifier. Exclusive to the Switch.
| 4 || [8.0.0+]
 
  struct {
    __out u32 type;    // Error type (0=no_error, 1=mmu_error, 2=gr_error, 3=pbdma_error, 4=timeout)
    __out u32 info[31]; // Infor depends on the error type
  };
 
==== GR Error Code Format ====
When <code>type == 2</code> (GR Error), the returned data is formatted as follows:
  struct {
    __out u32 type;      // 2=gr_error
    __out u32 intr_value; // Interrupt bits
    __out u32 addr;      // Register address (in bytes)
    __out u32 data_hi;    // Data high 32 bits
    __out u32 data_lo;    // Data low 32 bits
    __out u32 class_num;  // GPU class number (e.g., 0xb197 for MAXWELL_B)
  };
 
{| class="wikitable"
|+ GR Error Interrupt Bits
|-
! Bit(s)
! Description
|-
| 0
| GR_INTR_NOTIFY
|-
| 1
| GR_INTR_SEMAPHORE
|-
| 2
| unknown
|-
| 3
| unknown
|-
| 4
| GR_INTR_ILLEGAL_METHOD
|-
| 5
| GR_INTR_ILLEGAL_CLASS
|-
| 6
| GR_INTR_ILLEGAL_NOTIFY
|-
| 7
| unknown
|-
| 8
| GR_INTR_FIRMWARE_METHOD
|-
| 9–18
| unknown
|-
| 19
| GR_INTR_FECS_ERROR
|-
| 20
| GR_INTR_CLASS_ERROR
|-
| 21
| GR_INTR_EXCEPTION
|-
| 22–31
| unknown
|}
 
=== NVGPU_IOCTL_CHANNEL_GET_ERROR_NOTIFICATION ===
Returns the current error notification caught by the error notifier. Exclusive to the Switch.
 
  struct {
    __out u64 timestamp;    // fetched straight from armGetSystemTick
    __out u32 info32;      // error code
    __out u16 info16;      // additional error info
    __out u16 status;      // always 0xFFFF
  };
 
=== NVGPU_IOCTL_CHANNEL_ALLOC_GPFIFO_EX ===
Allocates gpfifo entries with additional parameters. Exclusive to the Switch.
 
struct fence {
    u32 id;
    u32 value;
};
struct {
  __in    u32 num_entries;
  __in    u32 num_jobs;
  __in    u32 flags;                      // bit0: vpr_enabled
  __out  struct fence fence_out;          // returned new fence object for others to wait on
  __in    u32 reserved[3];                // ignored
};
 
=== NVGPU_IOCTL_CHANNEL_SUBMIT_GPFIFO_RETRY ===
Same as [[#NVGPU_IOCTL_CHANNEL_SUBMIT_GPFIFO|NVGPU_IOCTL_CHANNEL_SUBMIT_GPFIFO]].
 
=== NVGPU_IOCTL_CHANNEL_ALLOC_GPFIFO_EX2 ===
Same as [[#NVGPU_IOCTL_CHANNEL_ALLOC_GPFIFO_EX|NVGPU_IOCTL_CHANNEL_ALLOC_GPFIFO_EX]].
 
=== NVGPU_IOCTL_CHANNEL_SUBMIT_GPFIFO2 ===
Same as [[#NVGPU_IOCTL_CHANNEL_SUBMIT_GPFIFO|NVGPU_IOCTL_CHANNEL_SUBMIT_GPFIFO]], but uses [[#Ioctl2|Ioctl2]].
 
=== NVGPU_IOCTL_CHANNEL_SUBMIT_GPFIFO2_RETRY ===
Same as [[#NVGPU_IOCTL_CHANNEL_SUBMIT_GPFIFO_RETRY|NVGPU_IOCTL_CHANNEL_SUBMIT_GPFIFO_RETRY]], but uses [[#Ioctl2|Ioctl2]].
 
=== NVGPU_IOCTL_CHANNEL_SET_TIMESLICE ===
Changes channel's timeslice. Identical to Linux driver.
 
  struct {
    __in u32 timeslice;
  };
 
=== NVGPU_IOCTL_CHANNEL_SET_USER_DATA ===
Sets user specific data.
 
  struct {
    __in u64 data;
  };
 
=== NVGPU_IOCTL_CHANNEL_GET_USER_DATA ===
Returns user specific data.
 
  struct {
    __out u64 data;
  };
 
= NvDrvPermission =
This is "nns::nvdrv::NvDrvPermission".
 
{| class="wikitable" border="1"
!  Bits
! Name
!  Description
|-
| 0
| Gpu
| Can access [[#Channels|/dev/nvhost-gpu]], [[#/dev/nvhost-ctrl-gpu|/dev/nvhost-ctrl-gpu]] and [[#/dev/nvhost-as-gpu|/dev/nvhost-as-gpu]].
|-
| 1
| GpuDebug
| Can access [[#/dev/nvhost-dbg-gpu|/dev/nvhost-dbg-gpu]] and [[#/dev/nvhost-prof-gpu|/dev/nvhost-prof-gpu]].
|-
| 2
| GpuSchedule
| Can access [[#/dev/nvsched-ctrl|/dev/nvsched-ctrl]].
|-
| 3
| VIC
| Can access [[#Channels|/dev/nvhost-vic]].
|-
| 4
| VideoEncoder
| Can access [[#Channels|/dev/nvhost-msenc]].
|-
| 5
| VideoDecoder
| Can access [[#Channels|/dev/nvhost-nvdec]].
|-
| 6
| TSEC
| Can access [[#Channels|/dev/nvhost-tsec]].
|-
| 7
| JPEG
| Can access [[#Channels|/dev/nvhost-nvjpg]].
|-
| 8
| Display
| Can access [[#Channels|/dev/nvhost-display]], [[#/dev/nvcec-ctrl|/dev/nvcec-ctrl]], [[#/dev/nvhdcp_up-ctrl|/dev/nvhdcp_up-ctrl]], [[#/dev/nvdisp-ctrl|/dev/nvdisp-ctrl]], [[#/dev/nvdisp-disp0, /dev/nvdisp-disp1|/dev/nvdisp-disp0]], [[#/dev/nvdisp-disp0, /dev/nvdisp-disp1|/dev/nvdisp-disp1]], [[#/dev/nvdcutil-disp0, /dev/nvdcutil-disp1|/dev/nvdcutil-disp0]] and [[#/dev/nvdcutil-disp0, /dev/nvdcutil-disp1|/dev/nvdcutil-disp1]].
|-
| 9
| ImportMemory
| Can duplicate [[#/dev/nvmap|nvmap]] handles from other processes with [[#NVMAP_IOC_FROM_ID|NVMAP_IOC_FROM_ID]].
|-
| 10
| NoCheckedAruid
| Can use [[#SetAruidWithoutCheck|SetAruidWithoutCheck]].
|-
| 11
|
| Can use [[#SetGraphicsFirmwareMemoryMarginEnabled|SetGraphicsFirmwareMemoryMarginEnabled]].
|-
| 12
|
| Can duplicate exported [[#/dev/nvmap|nvmap]] handles from other processes with [[#NVMAP_IOC_FROM_ID|NVMAP_IOC_FROM_ID]].
|-
| 13
|
| Can use the GPU virtual address range 0xC0000 to 0x580000 instead of 0x0 to 0xC0000.
|-
| 14
|
| Can use [[#NVMAP_IOC_EXPORT_FOR_ARUID|NVMAP_IOC_EXPORT_FOR_ARUID]] and [[#NVMAP_IOC_REMOVE_EXPORT_FOR_ARUID|NVMAP_IOC_REMOVE_EXPORT_FOR_ARUID]].
|-
| 15
|
| Can use the virtual address ranges 0x0 to 0x100000000 (GPU) and 0x0 to 0xE0000000 (non-GPU) instead of 0x100000000 to 0x11FA50000 (GPU) and 0xE0000000 to 0xFFFE0000 (non-GPU).
|}
 
= NvError =
This is "nns::nvdrv::NvError".
 
{| class="wikitable" border="1"
|-
! Value || Name
|-
| 0x0 || Success
|-
| 0x1 || NotImplemented
|-
| 0x2 || NotSupported
|-
| 0x3 || NotInitialized
|-
| 0x4 || BadParameter
|-
| 0x5 || Timeout
|-
| 0x6 || InsufficientMemory
|-
| 0x7 || ReadOnlyAttribute
|-
| 0x8 || InvalidState
|-
| 0x9 || InvalidAddress
|-
| 0xA || InvalidSize
|-
| 0xB || BadValue
|-
| 0xD || AlreadyAllocated
|-
| 0xE || Busy
|-
| 0xF || ResourceError
|-
| 0x10 || CountMismatch
|-
| 0x11 || OverFlow
|-
| 0x1000 || InsufficientTransferMemory
|-
| 0x10000 || InsufficientVideoMemory
|-
| 0x10001 || BadSurfaceColorScheme
|-
| 0x10002 || InvalidSurface
|-
| 0x10003 || SurfaceNotSupported
|-
| 0x20000 || DispInitFailed
|-
| 0x20001 || DispAlreadyAttached
|-
| 0x20002 || DispTooManyDisplays
|-
| 0x20003 || DispNoDisplaysAttached
|-
| 0x20004 || DispModeNotSupported
|-
| 0x20005 || DispNotFound
|-
| 0x20006 || DispAttachDissallowed
|-
| 0x20007 || DispTypeNotSupported
|-
| 0x20008 || DispAuthenticationFailed
|-
| 0x20009 || DispNotAttached
|-
| 0x2000A || DispSamePwrState
|-
| 0x2000B || DispEdidFailure
|-
| 0x2000C || DispDsiReadAckError
|-
| 0x2000D || DispDsiReadInvalidResp
|-
| 0x30000 || FileWriteFailed
|-
| 0x30001 || FileReadFailed
|-
| 0x30002 || EndOfFile
|-
| 0x30003 || FileOperationFailed
|-
| 0x30004 || DirOperationFailed
|-
| 0x30005 || EndOfDirList
|-
| 0x30006 || ConfigVarNotFound
|-
| 0x30007 || InvalidConfigVar
|-
| 0x30008 || LibraryNotFound
|-
| 0x30009 || SymbolNotFound
|-
| 0x3000A || MemoryMapFailed
|-
| 0x3000F || IoctlFailed                       
|-
| 0x30010 || AccessDenied
|-
| 0x30011 || DeviceNotFound
|-
| 0x30012 || KernelDriverNotFound
|-
| 0x30013 || FileNotFound
|-
| 0x30014 || PathAlreadyExists
|-
| 0xA000E || ModuleNotPresent
|}
|}


= nvdbg:d =
= NvDrvStatus =
This is "nns::nvdrv::INvDrvDebugSvcServices". This was added with [10.0.0+].
This is "nns::nvdrv::NvDrvStatus".
 
This service has no commands.
 
= Errors =
Most nvidia driver commands return an error code apart from the normal return code.


{| class="wikitable" border="1"
{| class="wikitable" border="1"
|-
|-
! Value || Name
! Offset
! Size
! Description
|-
|-
| 0x0 || NvError_Success
| 0x0
| 0x4
| FreeSize
|-
|-
| 0x1 || NvError_NotImplemented
| 0x4
| 0x4
| AllocatableSize
|-
|-
| 0x2 || NvError_NotSupported
| 0x8
| 0x4
| MinimumFreeSize
|-
|-
| 0x3 || NvError_NotInitialized
| 0xC
| 0x4
| MinimumAllocatableSize
|-
|-
| 0x4 || NvError_BadParameter
| 0x10
|-
| 0x10
| 0x5 || NvError_Timeout
| Reserved
|-
|}
| 0x6 || NvError_InsufficientMemory
 
|-
= Notes =
| 0x7 || NvError_ReadOnlyAttribute
In some cases, a panic may occur. NV forces a crash by doing:
|-
(void *)0 = 0xCAFE;
| 0x8 || NvError_InvalidState
End result is that the system hangs with a white-screen.
|-
 
| 0x9 || NvError_InvalidAddress
When the gpfifo data in the gpu_va buffers specified by the submitted gpfifo entries is invalid(?), eventually the user-process will be force-terminated after using the submit-gpfifo ioctl. It's unknown how exactly this is done.
|-
| 0xA || NvError_InvalidSize
|-
| 0xB || NvError_BadValue
|-
| 0xD || NvError_AlreadyAllocated
|-
| 0xE || NvError_Busy
|-
| 0xF || NvError_ResourceError
|-
| 0x10 || NvError_CountMismatch
|-
| 0x11 || NvError_OverFlow
|-
| 0x1000 || NvError_InsufficientTransferMemory
|-
| 0x10000 || NvError_InsufficientVideoMemory
|-
| 0x10001 || NvError_BadSurfaceColorScheme
|-
| 0x10002 || NvError_InvalidSurface
|-
| 0x10003 || NvError_SurfaceNotSupported
|-
| 0x20000 || NvError_DispInitFailed
|-
| 0x20001 || NvError_DispAlreadyAttached
|-
| 0x20002 || NvError_DispTooManyDisplays
|-
| 0x20003 || NvError_DispNoDisplaysAttached
|-
| 0x20004 || NvError_DispModeNotSupported
|-
| 0x20005 || NvError_DispNotFound
|-
| 0x20006 || NvError_DispAttachDissallowed
|-
| 0x20007 || NvError_DispTypeNotSupported
|-
| 0x20008 || NvError_DispAuthenticationFailed
|-
| 0x20009 || NvError_DispNotAttached
|-
| 0x2000A || NvError_DispSamePwrState
|-
| 0x2000B || NvError_DispEdidFailure
|-
| 0x2000C || NvError_DispDsiReadAckError
|-
| 0x2000D || NvError_DispDsiReadInvalidResp
|-
| 0x30000 || NvError_FileWriteFailed
|-
| 0x30001 || NvError_FileReadFailed
|-
| 0x30002 || NvError_EndOfFile
|-
| 0x30003 || NvError_FileOperationFailed
|-
| 0x30004 || NvError_DirOperationFailed
|-
| 0x30005 || NvError_EndOfDirList
|-
| 0x30006 || NvError_ConfigVarNotFound
|-
| 0x30007 || NvError_InvalidConfigVar
|-
| 0x30008 || NvError_LibraryNotFound
|-
| 0x30009 || NvError_SymbolNotFound
|-
| 0x3000A || NvError_MemoryMapFailed
|-
| 0x3000F || NvError_IoctlFailed                       
|-
| 0x30010 || NvError_AccessDenied
|-
| 0x30011 || NvError_DeviceNotFound
|-
| 0x30012 || NvError_KernelDriverNotFound
|-
| 0x30013 || NvError_FileNotFound
|-
| 0x30014 || NvError_PathAlreadyExists
|-
| 0xA000E || NvError_ModuleNotPresent
|}


= Panic =
GPU rendering (GPFIFO) is only used by applets/Applications. All sysmodules doing any gfx-display uses software rendering. During system-boot, GPU GPFIFO is not used until the applets are launched.
In some cases, a panic may occur. NV forces a crash by doing:
(void *)0 = 0xCAFE;
End result is that the system hangs with a white-screen.
 
== Gpfifo Panic ==
When the gpfifo data in the gpu_va buffers specified by the submitted gpfifo entries is invalid(?), eventually the user-process will be force-terminated after using the submit-gpfifo ioctl. It's unknown how exactly this is done.


[[Category:Services]]
[[Category:Services]]