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 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 |
| |} | | |} |
| | | |
Line 557: |
Line 622: |
| | 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 634: |
| | 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 587: |
Line 652: |
| | 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 |
Line 601: |
Line 666: |
| | 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+] | + | | 0x40040223 || In || 4 || [11.0.0+] [[#NVDISP_SET_BACKLIGHT_RANGE_MIN]] |
| |- | | |- |
| | 0x401C0225 || In || 28 || [11.0.0+] [[#NVDISP_SEND_PANEL_MSG]] | | | 0x401C0225 || In || 28 || [11.0.0+] [[#NVDISP_SEND_PANEL_MSG]] |
Line 609: |
Line 674: |
| | 0xC01C0226 || Inout || 28 || [11.0.0+] [[#NVDISP_GET_PANEL_DATA]] | | | 0xC01C0226 || Inout || 28 || [11.0.0+] [[#NVDISP_GET_PANEL_DATA]] |
| |} | | |} |
| + | |
| + | === NVDISP_GET_MODE === |
| + | Identical to Linux driver. |
| + | |
| + | struct { |
| + | __out u32 hActive; |
| + | __out u32 vActive; |
| + | __out u32 hSyncWidth; |
| + | __out u32 vSyncWidth; |
| + | __out u32 hFrontPorch; |
| + | __out u32 vFrontPorch; |
| + | __out u32 hBackPorch; |
| + | __out u32 vBackPorch; |
| + | __out u32 hRefToSync; |
| + | __out u32 vRefToSync; |
| + | __out u32 pclkKHz; |
| + | __out u32 bitsPerPixel; // Always 0 |
| + | __out u32 vmode; // Always 0 |
| + | }; |
| + | |
| + | === NVDISP_SET_MODE === |
| + | Identical to Linux driver. |
| + | |
| + | struct { |
| + | __in u32 hActive; |
| + | __in u32 vActive; |
| + | __in u32 hSyncWidth; |
| + | __in u32 vSyncWidth; |
| + | __in u32 hFrontPorch; |
| + | __in u32 vFrontPorch; |
| + | __in u32 hBackPorch; |
| + | __in u32 vBackPorch; |
| + | __in u32 hRefToSync; |
| + | __in u32 vRefToSync; |
| + | __in u32 pclkKHz; |
| + | __in u32 bitsPerPixel; |
| + | __in u32 vmode; |
| + | }; |
| + | |
| + | === NVDISP_VALIDATE_MODE === |
| + | 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; |
| + | }; |
| + | |
| + | === NVDISP_PANEL_GET_VENDOR_ID === |
| + | |
| + | Returns display panel's informations. |
| + | |
| + | struct { |
| + | __out u8 vendor; //0x10 - JDI, 0x20 - InnoLux, 0x30 - AUO, 0x40 - Sharp, 0x50 - Samsung |
| + | __out u8 model; |
| + | __out u8 board; //0xF - 6.2", 0x10 - 5.5", 0x20 - 7.0". JDI panels have nonstandard values |
| + | }; |
| | | |
| === NVDISP_GET_BACKLIGHT_RANGE === | | === NVDISP_GET_BACKLIGHT_RANGE === |
Line 618: |
Line 750: |
| }; | | }; |
| | | |
− | === NVDISP_SET_BACKLIGHT === | + | === NVDISP_SET_BACKLIGHT_RANGE_MAX === |
− | Sets the value for the intensity of the display's backlight. | + | Sets the maximum value for the intensity of the display's backlight. |
| + | |
| + | struct { |
| + | __in u32 max; |
| + | }; |
| + | |
| + | === NVDISP_SET_BACKLIGHT_RANGE_MIN === |
| + | Sets the minimum value for the intensity of the display's backlight. |
| | | |
| struct { | | struct { |
− | __in u32 val; | + | __in u32 min; |
| }; | | }; |
| | | |
Line 850: |
Line 989: |
| struct { | | struct { |
| __in u32 fence_id; | | __in u32 fence_id; |
− | __in u32 fence_thresh; | + | __in u32 fence_value; |
| __in u32 swap_interval; | | __in u32 swap_interval; |
| }; | | }; |
Line 952: |
Line 1,091: |
| | 0x40284109 || In || 40 || [[#NVGPU_AS_IOCTL_ALLOC_AS_EX]] | | | 0x40284109 || In || 40 || [[#NVGPU_AS_IOCTL_ALLOC_AS_EX]] |
| |- | | |- |
− | | 0xC038410A || Inout || 56 || [[#NVGPU_AS_IOCTL_MODIFY]] | + | | 0xC038410A || Inout || 56 || [[#NVGPU_AS_IOCTL_MAP_BUFFER_EX2]] |
| |- | | |- |
| | 0xC0??4114 || Inout || Variable || [[#NVGPU_AS_IOCTL_REMAP]] | | | 0xC0??4114 || Inout || Variable || [[#NVGPU_AS_IOCTL_REMAP]] |
Line 988: |
Line 1,127: |
| | | |
| === NVGPU_AS_IOCTL_MAP_BUFFER === | | === NVGPU_AS_IOCTL_MAP_BUFFER === |
− | Maps a memory region in the device address space. Identical to Linux driver pretty much. | + | Maps a memory region in the device address space. |
| + | |
| + | Unaligned size will cause a [[#Panic]]. |
| | | |
| On success, the mapped memory region is granted the [[SVC#MemoryAttribute|DeviceShared]] attribute. | | On success, the mapped memory region is granted the [[SVC#MemoryAttribute|DeviceShared]] attribute. |
Line 994: |
Line 1,135: |
| struct { | | struct { |
| __in u32 flags; // bit0: fixed_offset, bit2: cacheable | | __in u32 flags; // bit0: fixed_offset, bit2: cacheable |
− | u32 reserved; | + | u32 reserved0; |
− | __in u32 dmabuf_fd; // nvmap handle | + | __in u32 mem_id; // nvmap handle |
− | __inout u32 page_size; // 0 means don't care | + | u32 reserved1; |
| union { | | union { |
| __out u64 offset; | | __out u64 offset; |
Line 1,012: |
Line 1,153: |
| struct { | | struct { |
| __in u32 flags; // bit0: fixed_offset, bit2: cacheable | | __in u32 flags; // bit0: fixed_offset, bit2: cacheable |
− | __in u32 kind; // -1 is default | + | __inout u32 kind; // -1 is default |
− | __in u32 dmabuf_fd; // nvmap handle | + | __in u32 mem_id; // nvmap handle |
− | __inout u32 page_size; // 0 means don't care | + | u32 reserved; |
| __in u64 buffer_offset; | | __in u64 buffer_offset; |
| __in u64 mapping_size; | | __in u64 mapping_size; |
− | __inout u64 offset; | + | union { |
| + | __out u64 offset; |
| + | __in u64 align; |
| + | }; |
| }; | | }; |
| | | |
Line 1,038: |
Line 1,182: |
| === NVGPU_AS_IOCTL_GET_VA_REGIONS === | | === NVGPU_AS_IOCTL_GET_VA_REGIONS === |
| Nintendo's custom implementation to get rid of pointer in struct. | | Nintendo's custom implementation to get rid of pointer in struct. |
| + | |
| + | Uses [[#Ioctl3|Ioctl3]]. |
| | | |
| struct va_region { | | struct va_region { |
Line 1,066: |
Line 1,212: |
| }; | | }; |
| | | |
− | === NVGPU_AS_IOCTL_MODIFY === | + | === NVGPU_AS_IOCTL_MAP_BUFFER_EX2 === |
− | Modifies a memory region in the device address space.
| + | Maps a memory region in the device address space with extra params. |
| + | |
| + | Unaligned size will cause a [[#Panic]]. |
| + | |
| + | On success, the mapped memory region is granted the [[SVC#MemoryAttribute|DeviceShared]] attribute. |
| | | |
− | struct {
| + | struct { |
| __in u32 flags; // bit0: fixed_offset, bit2: cacheable | | __in u32 flags; // bit0: fixed_offset, bit2: cacheable |
− | __in u32 kind; // -1 is default | + | __inout u32 kind; // -1 is default |
− | __in u32 dmabuf_fd; // nvmap handle | + | __in u32 mem_id; // nvmap handle |
− | __inout u32 page_size; // 0 means don't care | + | u32 reserved0; |
| __in u64 buffer_offset; | | __in u64 buffer_offset; |
| __in u64 mapping_size; | | __in u64 mapping_size; |
− | __inout u64 offset; | + | union { |
− | __in u64 unk0; | + | __out u64 offset; |
− | __in u32 unk1; | + | __in u64 align; |
− | u32 reserved; | + | }; |
| + | __in u64 vma_addr; |
| + | __in u32 pages; |
| + | u32 reserved1; |
| }; | | }; |
| | | |
| === NVGPU_AS_IOCTL_REMAP === | | === NVGPU_AS_IOCTL_REMAP === |
− | Nintendo's custom implementation of address space remapping. | + | Nintendo's custom implementation of address space remapping for sparse pages. |
| | | |
| struct remap_op { | | struct remap_op { |
− | __in u16 flags; // 0 or 4 | + | __in u16 flags; // bit2: cacheable |
| __in u16 kind; | | __in u16 kind; |
| __in u32 mem_handle; | | __in u32 mem_handle; |
| __in u32 mem_offset_in_pages; | | __in u32 mem_offset_in_pages; |
− | __in u32 virt_offset_in_pages; // (alloc_space_offset >> 0x10) | + | __in u32 virt_offset_in_pages; // (alloc_space_offset >> 0x10) |
− | __in u32 num_pages; // alloc_space_pages | + | __in u32 num_pages; // alloc_space_pages |
| }; | | }; |
| | | |
Line 1,156: |
Line 1,309: |
| | 0xC018441A || Inout || 24 || NVGPU_DBG_GPU_IOCTL_LAZY_ALLOC_RESERVED_PA | | | 0xC018441A || Inout || 24 || NVGPU_DBG_GPU_IOCTL_LAZY_ALLOC_RESERVED_PA |
| |- | | |- |
− | | 0xC020441B || Inout || 32 || [11.0.0+] | + | | 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+] | + | | 0xC020441E || Inout || 32 || [11.0.0+] NVGPU_DBG_GPU_IOCTL_GET_GPU_VA_RANGE_PAGES |
| |} | | |} |
| | | |
Line 1,504: |
Line 1,661: |
| }; | | }; |
| | | |
− | == Channels ==
| + | = Channels = |
− | Channels are a concept for NVIDIA hardware blocks that share a common interface. | + | Channels are a concept for NVIDIA hardware blocks that share a common interface. |
| | | |
| {| class="wikitable" border="1" | | {| class="wikitable" border="1" |
Line 1,521: |
Line 1,678: |
| |- | | |- |
| | /dev/nvhost-display || Display | | | /dev/nvhost-display || Display |
| + | |- |
| + | | /dev/nvhost-tsec || TSEC |
| |} | | |} |
| | | |
− | == Channel Ioctls == | + | == Ioctls == |
| {| class="wikitable" border="1" | | {| class="wikitable" border="1" |
| ! Value || Size || Description | | ! Value || Size || Description |
Line 1,631: |
Line 1,790: |
| u32 syncpt_id; | | u32 syncpt_id; |
| u32 syncpt_incrs; | | u32 syncpt_incrs; |
− | };
| + | u32 reserved[3]; |
− |
| |
− | struct fence {
| |
− | u32 id; | |
− | u32 thresh;
| |
| }; | | }; |
| | | |
Line 1,647: |
Line 1,802: |
| __in struct reloc_shift reloc_shifts[]; // 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 | | __in struct syncpt_incr syncpt_incrs[]; // depends on num_syncpt_incrs |
− | __out struct fence fences[]; // depends on num_fences | + | __out u32 fence_thresholds[]; // depends on num_fences |
| }; | | }; |
| | | |
Line 1,760: |
Line 1,915: |
| struct { | | struct { |
| __in u32 num_entries; | | __in u32 num_entries; |
− | __in u32 flags; | + | __in u32 flags; // bit0: vpr_enabled |
| }; | | }; |
| | | |
Line 1,787: |
Line 1,942: |
| struct fence { | | struct fence { |
| u32 id; | | u32 id; |
− | u32 thresh; | + | u32 value; |
| }; | | }; |
| | | |
| struct gpfifo_entry { | | struct gpfifo_entry { |
− | u64 entry; // gpu_iova | (unk_2bits << 40) | (size << 42) | (unk_flag << 63) | + | u32 entry0; // gpu_iova_lo |
| + | u32 entry1; // gpu_iova_hi | (allow_flush << 8) | (is_push_buf << 9) | (size << 10) | (sync << 31) |
| }; | | }; |
| | | |
Line 1,797: |
Line 1,953: |
| __in u64 gpfifo; // (ignored) pointer to gpfifo fence structs | | __in u64 gpfifo; // (ignored) pointer to gpfifo fence structs |
| __in u32 num_entries; // number of fence objects being submitted | | __in u32 num_entries; // number of fence objects being submitted |
− | __in u32 flags; | + | 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 | | __inout struct fence fence_out; // returned new fence object for others to wait on |
| __in struct gpfifo_entry entries[]; // depends on num_entries | | __in struct gpfifo_entry entries[]; // depends on num_entries |
Line 1,880: |
Line 2,039: |
| | | |
| 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) | + | __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 |
− | | + | }; |
− | === NVGPU_IOCTL_CHANNEL_GET_ERROR_NOTIFICATION ===
| |
− | Returns the current error notification caught by the error notifier. Exclusive to the Switch.
| |
| | | |
| + | ==== GR Error Code Format ==== |
| + | When <code>type == 2</code> (GR Error), the returned data is formatted as follows: |
| struct { | | struct { |
− | __out u64 timestamp; // fetched straight from armGetSystemTick | + | __out u32 type; // 2=gr_error |
− | __out u32 info32; // error code | + | __out u32 intr_value; // Interrupt bits |
− | __out u16 info16; // additional error info | + | __out u32 addr; // Register address (in bytes) |
− | __out u16 status; // always 0xFFFF | + | __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) |
| + | }; |
| | | |
− | === NVGPU_IOCTL_CHANNEL_ALLOC_GPFIFO_EX === | + | {| class="wikitable" |
− | Allocates gpfifo entries with additional parameters. Exclusive to the Switch.
| + | |+ 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 |
| + | |} |
| | | |
− | struct fence { | + | === NVGPU_IOCTL_CHANNEL_GET_ERROR_NOTIFICATION === |
− | u32 id; | + | Returns the current error notification caught by the error notifier. Exclusive to the Switch. |
− | u32 thresh; | + | |
| + | 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; |
| }; | | }; |
| | | |
Line 1,904: |
Line 2,124: |
| __in u32 num_entries; | | __in u32 num_entries; |
| __in u32 num_jobs; | | __in u32 num_jobs; |
− | __in u32 flags; | + | __in u32 flags; // bit0: vpr_enabled |
| __out struct fence fence_out; // returned new fence object for others to wait on | | __out struct fence fence_out; // returned new fence object for others to wait on |
| __in u32 reserved[3]; // ignored | | __in u32 reserved[3]; // ignored |
Line 1,942: |
Line 2,162: |
| }; | | }; |
| | | |
− | = nvmemp = | + | = NvDrvPermission = |
− | This is "nv::MemoryProfiler::IMemoryProfiler". | + | This is "nns::nvdrv::NvDrvPermission". |
− | | |
− | /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.
| |
| | | |
| {| class="wikitable" border="1" | | {| 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]]. |
| |- | | |- |
− | ! Cmd || Name
| + | | 1 |
| + | | GpuDebug |
| + | | Can access [[#/dev/nvhost-dbg-gpu|/dev/nvhost-dbg-gpu]] and [[#/dev/nvhost-prof-gpu|/dev/nvhost-prof-gpu]]. |
| |- | | |- |
− | | 0 || Open | + | | 2 |
| + | | GpuSchedule |
| + | | Can access [[#/dev/nvsched-ctrl|/dev/nvsched-ctrl]]. |
| |- | | |- |
− | | 1 || GetPid | + | | 3 |
− | |} | + | | VIC |
− | | + | | Can access [[#Channels|/dev/nvhost-vic]]. |
− | = nvdrvdbg =
| |
− | This is "nns::nvdrv::INvDrvDebugFSServices".
| |
− | | |
− | {| class="wikitable" border="1"
| |
| |- | | |- |
− | ! Cmd || Name
| + | | 4 |
| + | | VideoEncoder |
| + | | Can access [[#Channels|/dev/nvhost-msenc]]. |
| |- | | |- |
− | | 0 || [[#OpenDebugFS]] | + | | 5 |
| + | | VideoDecoder |
| + | | Can access [[#Channels|/dev/nvhost-nvdec]]. |
| |- | | |- |
− | | 1 || [[#CloseDebugFS]] | + | | 6 |
| + | | TSEC |
| + | | Can access [[#Channels|/dev/nvhost-tsec]]. |
| |- | | |- |
− | | 2 || [[#GetDebugFSKeys]] | + | | 7 |
| + | | JPEG |
| + | | Can access [[#Channels|/dev/nvhost-nvjpg]]. |
| |- | | |- |
− | | 3 || GetDebugFSValue | + | | 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]]. |
| |- | | |- |
− | | 4 || SetDebugFSValue | + | | 9 |
− | |} | + | | ImportMemory |
− | | + | | Can duplicate [[#/dev/nvmap|nvmap]] handles from other processes with [[#NVMAP_IOC_FROM_ID|NVMAP_IOC_FROM_ID]]. |
− | == OpenDebugFS ==
| |
− | Takes a process handle. Returns a u32 '''fd'''.
| |
− | | |
− | == CloseDebugFS ==
| |
− | Takes a u32 '''fd''' and closes it.
| |
− | | |
− | == GetDebugFSKeys ==
| |
− | Takes a u32 '''fd''' and reads debug contents into a type-6 buffer.
| |
− | | |
− | = nvgem:c =
| |
− | This is "nv::gemcontrol::INvGemControl".
| |
− | | |
− | {| class="wikitable" border="1"
| |
| |- | | |- |
− | ! Cmd || Name
| + | | 10 |
| + | | NoCheckedAruid |
| + | | Can use [[#SetAruidWithoutCheck|SetAruidWithoutCheck]]. |
| |- | | |- |
− | | 0 || Initialize | + | | 11 |
| + | | |
| + | | Can use [[#SetGraphicsFirmwareMemoryMarginEnabled|SetGraphicsFirmwareMemoryMarginEnabled]]. |
| |- | | |- |
− | | 1 || GetEventHandle | + | | 12 |
| + | | |
| + | | Can duplicate exported [[#/dev/nvmap|nvmap]] handles from other processes with [[#NVMAP_IOC_FROM_ID|NVMAP_IOC_FROM_ID]]. |
| |- | | |- |
− | | 2 || ControlNotification | + | | 13 |
| + | | |
| + | | Can use the GPU virtual address range 0xC0000 to 0x580000 instead of 0x0 to 0xC0000. |
| |- | | |- |
− | | 3 || SetNotificationPerm | + | | 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]]. |
| |- | | |- |
− | | 4 || SetCoreDumpPerm | + | | 15 |
− | |- | + | | |
− | | 5 || [1.0.0-4.1.0] GetAruid | + | | 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). |
− | |-
| |
− | | 6 || Reset
| |
− | |-
| |
− | | 7 || [3.0.0+]
| |
| |} | | |} |
| | | |
− | = nvgem:cd = | + | = NvError = |
− | This is "nv::gemcoredump::INvGemCoreDump". | + | This is "nns::nvdrv::NvError". |
| | | |
| {| class="wikitable" border="1" | | {| class="wikitable" border="1" |
| |- | | |- |
− | ! Cmd || Name | + | ! Value || Name |
| |- | | |- |
− | | 0 || Initialize | + | | 0x0 || Success |
| |- | | |- |
− | | 1 || GetAruid | + | | 0x1 || NotImplemented |
| |- | | |- |
− | | 2 || [1.0.0-8.1.0] ReadNextBlock | + | | 0x2 || NotSupported |
| |- | | |- |
− | | 3 || [8.0.0+] | + | | 0x3 || NotInitialized |
| |- | | |- |
− | | 4 || [8.0.0+] | + | | 0x4 || BadParameter |
− | |}
| |
− | | |
− | = nvdbg:d =
| |
− | This is "nns::nvdrv::INvDrvDebugSvcServices". This was added with [10.0.0+].
| |
− | | |
− | This service has no commands.
| |
− | | |
− | = Errors =
| |
− | Most nvidia driver commands return an error code apart from the normal return code.
| |
− | | |
− | {| class="wikitable" border="1"
| |
| |- | | |- |
− | ! Value || Name
| + | | 0x5 || Timeout |
| |- | | |- |
− | | 0x0 || NvError_Success | + | | 0x6 || InsufficientMemory |
| |- | | |- |
− | | 0x1 || NvError_NotImplemented | + | | 0x7 || ReadOnlyAttribute |
| |- | | |- |
− | | 0x2 || NvError_NotSupported | + | | 0x8 || InvalidState |
| |- | | |- |
− | | 0x3 || NvError_NotInitialized | + | | 0x9 || InvalidAddress |
| |- | | |- |
− | | 0x4 || NvError_BadParameter | + | | 0xA || InvalidSize |
| |- | | |- |
− | | 0x5 || NvError_Timeout | + | | 0xB || BadValue |
| |- | | |- |
− | | 0x6 || NvError_InsufficientMemory | + | | 0xD || AlreadyAllocated |
| |- | | |- |
− | | 0x7 || NvError_ReadOnlyAttribute | + | | 0xE || Busy |
| |- | | |- |
− | | 0x8 || NvError_InvalidState | + | | 0xF || ResourceError |
| |- | | |- |
− | | 0x9 || NvError_InvalidAddress | + | | 0x10 || CountMismatch |
| |- | | |- |
− | | 0xA || NvError_InvalidSize | + | | 0x11 || OverFlow |
| |- | | |- |
− | | 0xB || NvError_BadValue | + | | 0x1000 || InsufficientTransferMemory |
| |- | | |- |
− | | 0xD || NvError_AlreadyAllocated | + | | 0x10000 || InsufficientVideoMemory |
| |- | | |- |
− | | 0xE || NvError_Busy | + | | 0x10001 || BadSurfaceColorScheme |
| |- | | |- |
− | | 0xF || NvError_ResourceError | + | | 0x10002 || InvalidSurface |
| |- | | |- |
− | | 0x10 || NvError_CountMismatch | + | | 0x10003 || SurfaceNotSupported |
| |- | | |- |
− | | 0x11 || NvError_OverFlow | + | | 0x20000 || DispInitFailed |
| |- | | |- |
− | | 0x1000 || NvError_InsufficientTransferMemory | + | | 0x20001 || DispAlreadyAttached |
| |- | | |- |
− | | 0x10000 || NvError_InsufficientVideoMemory | + | | 0x20002 || DispTooManyDisplays |
| |- | | |- |
− | | 0x10001 || NvError_BadSurfaceColorScheme | + | | 0x20003 || DispNoDisplaysAttached |
| |- | | |- |
− | | 0x10002 || NvError_InvalidSurface | + | | 0x20004 || DispModeNotSupported |
| |- | | |- |
− | | 0x10003 || NvError_SurfaceNotSupported | + | | 0x20005 || DispNotFound |
| |- | | |- |
− | | 0x20000 || NvError_DispInitFailed | + | | 0x20006 || DispAttachDissallowed |
| |- | | |- |
− | | 0x20001 || NvError_DispAlreadyAttached | + | | 0x20007 || DispTypeNotSupported |
| |- | | |- |
− | | 0x20002 || NvError_DispTooManyDisplays | + | | 0x20008 || DispAuthenticationFailed |
| |- | | |- |
− | | 0x20003 || NvError_DispNoDisplaysAttached | + | | 0x20009 || DispNotAttached |
| |- | | |- |
− | | 0x20004 || NvError_DispModeNotSupported | + | | 0x2000A || DispSamePwrState |
| |- | | |- |
− | | 0x20005 || NvError_DispNotFound | + | | 0x2000B || DispEdidFailure |
| |- | | |- |
− | | 0x20006 || NvError_DispAttachDissallowed | + | | 0x2000C || DispDsiReadAckError |
| |- | | |- |
− | | 0x20007 || NvError_DispTypeNotSupported | + | | 0x2000D || DispDsiReadInvalidResp |
| |- | | |- |
− | | 0x20008 || NvError_DispAuthenticationFailed | + | | 0x30000 || FileWriteFailed |
| |- | | |- |
− | | 0x20009 || NvError_DispNotAttached | + | | 0x30001 || FileReadFailed |
| |- | | |- |
− | | 0x2000A || NvError_DispSamePwrState | + | | 0x30002 || EndOfFile |
| |- | | |- |
− | | 0x2000B || NvError_DispEdidFailure | + | | 0x30003 || FileOperationFailed |
| |- | | |- |
− | | 0x2000C || NvError_DispDsiReadAckError | + | | 0x30004 || DirOperationFailed |
| |- | | |- |
− | | 0x2000D || NvError_DispDsiReadInvalidResp | + | | 0x30005 || EndOfDirList |
| |- | | |- |
− | | 0x30000 || NvError_FileWriteFailed | + | | 0x30006 || ConfigVarNotFound |
| |- | | |- |
− | | 0x30001 || NvError_FileReadFailed | + | | 0x30007 || InvalidConfigVar |
| |- | | |- |
− | | 0x30002 || NvError_EndOfFile | + | | 0x30008 || LibraryNotFound |
| |- | | |- |
− | | 0x30003 || NvError_FileOperationFailed | + | | 0x30009 || SymbolNotFound |
| |- | | |- |
− | | 0x30004 || NvError_DirOperationFailed | + | | 0x3000A || MemoryMapFailed |
| |- | | |- |
− | | 0x30005 || NvError_EndOfDirList | + | | 0x3000F || IoctlFailed |
| |- | | |- |
− | | 0x30006 || NvError_ConfigVarNotFound | + | | 0x30010 || AccessDenied |
| |- | | |- |
− | | 0x30007 || NvError_InvalidConfigVar | + | | 0x30011 || DeviceNotFound |
| |- | | |- |
− | | 0x30008 || NvError_LibraryNotFound | + | | 0x30012 || KernelDriverNotFound |
| |- | | |- |
− | | 0x30009 || NvError_SymbolNotFound | + | | 0x30013 || FileNotFound |
| |- | | |- |
− | | 0x3000A || NvError_MemoryMapFailed | + | | 0x30014 || PathAlreadyExists |
| |- | | |- |
− | | 0x3000F || NvError_IoctlFailed | + | | 0xA000E || ModuleNotPresent |
| + | |} |
| + | |
| + | = NvDrvStatus = |
| + | This is "nns::nvdrv::NvDrvStatus". |
| + | |
| + | {| class="wikitable" border="1" |
| |- | | |- |
− | | 0x30010 || NvError_AccessDenied
| + | ! Offset |
| + | ! Size |
| + | ! Description |
| |- | | |- |
− | | 0x30011 || NvError_DeviceNotFound | + | | 0x0 |
| + | | 0x4 |
| + | | FreeSize |
| |- | | |- |
− | | 0x30012 || NvError_KernelDriverNotFound | + | | 0x4 |
| + | | 0x4 |
| + | | AllocatableSize |
| |- | | |- |
− | | 0x30013 || NvError_FileNotFound | + | | 0x8 |
| + | | 0x4 |
| + | | MinimumFreeSize |
| |- | | |- |
− | | 0x30014 || NvError_PathAlreadyExists | + | | 0xC |
| + | | 0x4 |
| + | | MinimumAllocatableSize |
| |- | | |- |
− | | 0xA000E || NvError_ModuleNotPresent | + | | 0x10 |
| + | | 0x10 |
| + | | Reserved |
| |} | | |} |
| | | |
− | = Panic = | + | = Notes = |
| In some cases, a panic may occur. NV forces a crash by doing: | | In some cases, a panic may occur. NV forces a crash by doing: |
| (void *)0 = 0xCAFE; | | (void *)0 = 0xCAFE; |
| End result is that the system hangs with a white-screen. | | 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. | | 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. |
| + | |
| + | 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. |
| | | |
| [[Category:Services]] | | [[Category:Services]] |