Difference between revisions of "TMA services"

From Nintendo Switch Brew
Jump to navigation Jump to search
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
TMA (Target Manager) acts as a debugging sysmodule for development kits. This system module is loaded in retail units, but remains unused.
+
TMA (Target Manager Agent) acts as a debugging sysmodule for development kits. This system module is loaded in retail units, but remains unused.
  
 
These services are inaccessible on retail units. However, all [[Title_list#System_Applets|System Applets]] have permission to access them (see [[NPDM#Service_Access_Control]]).
 
These services are inaccessible on retail units. However, all [[Title_list#System_Applets|System Applets]] have permission to access them (see [[NPDM#Service_Access_Control]]).
 +
 +
TMA makes a few sets of services available. One set (the "htc" family), is aimed around managing Host/Target Connections. "htc" allows orchestrating the switch<->pc connection, "htc:tenv" allows retrieving information about the target's environment from the host, and "htcs" provides an interface for managing sockets on PC from the Switch. htcs is used primarily to host services on PC ports with actual management code running on Switch. The other service ("file_io") manages HostIO, a mechanism by which the Switch can read files present on the Host PC. When a host is connected, FS will attempt to read data via file_io when @Host:/ content paths are used, or when fsp-srv->OpenHostFileSystem() is used to open an IFileSystem to the Host PC. Nintendo's implementation only supports Windows, and FS will explicitly check for the presence of a "C:/" drive to detect this.
  
 
= htc =
 
= htc =
Line 26: Line 28:
 
| 7 || [3.0.0+] GetBridgePort
 
| 7 || [3.0.0+] GetBridgePort
 
|-
 
|-
| 8 || [3.0.0+] SetUsbDetachedForDebug
+
| 8 || [3.0.0+] SetCradleAttached
 
|-
 
|-
 
| 9 || [4.0.0+] GetBridgeSubnetMask
 
| 9 || [4.0.0+] GetBridgeSubnetMask
Line 36: Line 38:
 
| 12 || [6.0.0+] GetWorkingDirectoryPathSize
 
| 12 || [6.0.0+] GetWorkingDirectoryPathSize
 
|-
 
|-
| 13 || [6.0.0+] RunOnHost
+
| 13 || [6.0.0+] RunOnHostStart
 +
|-
 +
| 14 || [9.0.0+] RunOnHostResults
 +
|-
 +
| 21 || [19.0.0+] BeginUpdateBridge
 +
|-
 +
| 22 || [19.0.0+] ContinueUpdateBridge
 +
|-
 +
| 23 || [19.0.0+] EndUpdateBridge
 +
|-
 +
| 24 || [19.0.0+] GetBridgeType
 
|}
 
|}
  
Line 46: Line 58:
 
! Cmd || Name
 
! Cmd || Name
 
|-
 
|-
| 0 ||
+
| 0 || Socket
 
|-
 
|-
| 1 ||
+
| 1 || Close
 
|-
 
|-
| 2 ||
+
| 2 || Connect
 
|-
 
|-
| 3 ||
+
| 3 || Bind
 
|-
 
|-
| 4 ||
+
| 4 || Listen
 
|-
 
|-
| 5 ||
+
| 5 || Accept
 
|-
 
|-
| 6 ||
+
| 6 || Recv
 
|-
 
|-
| 7 ||
+
| 7 || Send
 
|-
 
|-
| 8 ||
+
| 8 || Shutdown
 
|-
 
|-
| 9 ||
+
| 9 || Fcntl
 
|-
 
|-
 
| 10 || GetPeerNameAny
 
| 10 || GetPeerNameAny
Line 136: Line 148:
 
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
 
|-
 
|-
! Cmd || Name || Notes
+
! Cmd || Name
 
|-
 
|-
| 0 || OpenFile || returns an [[#IFileAccessor]]
+
| 0 || [[#OpenFile]]
 
|-
 
|-
| 1 || FileExists ||
+
| 1 || [[#FileExists]]
 
|-
 
|-
| 2 || DeleteFile ||
+
| 2 || [[#DeleteFile]]
 
|-
 
|-
| 3 || RenameFile ||
+
| 3 || [[#RenameFile]]
 
|-
 
|-
| 4 || GetIOType ||
+
| 4 || [[#GetIOType]]
 
|-
 
|-
| 5 || OpenDirectory || returns an [[#IDirectoryAccessor]]
+
| 5 || [[#OpenDirectory]]
 
|-
 
|-
| 6 || DirectoryExists ||
+
| 6 || [[#DirectoryExists]]
 
|-
 
|-
| 7 || CreateDirectory ||
+
| 7 || [[#CreateDirectory]]
 
|-
 
|-
| 8 || DeleteDirectory||
+
| 8 || [[#DeleteDirectory]]
 
|-
 
|-
| 9 || RenameDirectory ||
+
| 9 || [[#RenameDirectory]]
 
|-
 
|-
| 10 || CreateFile ||
+
| 10 || [[#CreateFile]]
 
|-
 
|-
| 11 || GetFileTimeStamp ||
+
| 11 || [[#GetFileTimeStamp]]
 
|-
 
|-
| 12 || GetCaseSensitivePath ||
+
| 12 || GetCaseSensitivePath
 
|}
 
|}
 +
 +
=== OpenFile ===
 +
Takes in an input X descriptor "Path" and a u32 "OpenMode", returns a [[#IFileAccessor]] interface.
 +
 +
=== FileExists ===
 +
Takes in an input X descriptor "Path", and returns an output bool.
 +
 +
=== DeleteFile ===
 +
Takes in an input X descriptor "Path".
 +
 +
=== RenameFile ===
 +
Takes in an input X descriptor "SrcPath" and an input X descriptor "DstPath".
 +
 +
=== GetIOType ===
 +
Takes in an input X descriptor "Path", returns an output int "EntryType".
 +
 +
=== OpenDirectory ===
 +
Takes in an input X descriptor "Path" and a u32 "OpenMode", returns a [[#IDirectoryAccessor]] interface.
 +
 +
=== DirectoryExists ===
 +
Takes in an input X descriptor "Path", and returns an output bool.
 +
 +
=== CreateDirectory ===
 +
Takes in an input X descriptor "Path".
 +
 +
=== DeleteDirectory ===
 +
Takes in an input X descriptor "Path" and an input bool "IsRecursive".
 +
 +
=== RenameDirectory ===
 +
Takes in an input X descriptor "SrcPath" and an input X descriptor "DstPath".
 +
 +
=== CreateFile ===
 +
Takes in an input X descriptor "Path" and an input s64 "Size".
 +
 +
=== GetFileTimeStamp ===
 +
Takes in an input X descriptor "Path", and returns 3 output u64s ("CreatedTime", "AccessedTime", "ModifiedTime").
  
 
== IFileAccessor ==
 
== IFileAccessor ==
Line 186: Line 234:
 
| 6 || GetPriorityForFile
 
| 6 || GetPriorityForFile
 
|}
 
|}
 +
 +
=== ReadFile ===
 +
Takes in an input s64 "Offset", an input ReadOption, and a NonSecure B descriptor "OutBuffer", and returns a s64 "BytesRead".
 +
 +
=== WriteFile ===
 +
Takes in an input s64 "Offset", an input WriteOption, and a NonSecure A descriptor "InBuffer".
 +
 +
=== GetFileSize ===
 +
Takes no input, and returns a s64 "FileSize".
 +
 +
=== SetFileSize ===
 +
Takes an s64 "FileSize".
 +
 +
=== FlushFile ===
 +
Takes no input, returns no output.
 +
 +
=== SetPriorityForFile ===
 +
Takes an input s32 "Priority".
 +
 +
=== GetPriorityForFile ===
 +
Takes no input, returns an s32 "Priority".
  
 
== IDirectoryAccessor ==
 
== IDirectoryAccessor ==
Line 194: Line 263:
 
! Cmd || Name
 
! Cmd || Name
 
|-
 
|-
| 0 || GetEntryCount
+
| 0 || [[#GetEntryCount]]
 
|-
 
|-
| 1 || ReadDirectory
+
| 1 || [[#ReadDirectory]]
 
|-
 
|-
| 2 || SetPriorityForDirectory
+
| 2 || [[#SetPriorityForDirectory]]
 
|-
 
|-
| 3 || GetPriorityForDirectory
+
| 3 || [[#GetPriorityForDirectory]]
 
|}
 
|}
 +
 +
=== GetEntryCount ===
 +
Takes no input, returns an s64 "EntryCount".
 +
 +
=== ReadDirectory ===
 +
Takes an input B descriptor "OutEntryBuffer", returns an s64 "NumEntriesRead"
 +
 +
=== SetPriorityForDirectory ===
 +
Takes an input s32 "Priority".
 +
 +
=== GetPriorityForDirectory ===
 +
Takes no input, returns an s32 "Priority".
  
  
 
[[Category:Services]]
 
[[Category:Services]]

Latest revision as of 20:03, 8 October 2024

TMA (Target Manager Agent) acts as a debugging sysmodule for development kits. This system module is loaded in retail units, but remains unused.

These services are inaccessible on retail units. However, all System Applets have permission to access them (see NPDM#Service_Access_Control).

TMA makes a few sets of services available. One set (the "htc" family), is aimed around managing Host/Target Connections. "htc" allows orchestrating the switch<->pc connection, "htc:tenv" allows retrieving information about the target's environment from the host, and "htcs" provides an interface for managing sockets on PC from the Switch. htcs is used primarily to host services on PC ports with actual management code running on Switch. The other service ("file_io") manages HostIO, a mechanism by which the Switch can read files present on the Host PC. When a host is connected, FS will attempt to read data via file_io when @Host:/ content paths are used, or when fsp-srv->OpenHostFileSystem() is used to open an IFileSystem to the Host PC. Nintendo's implementation only supports Windows, and FS will explicitly check for the presence of a "C:/" drive to detect this.

htc

This is "nn::tma::IHtcManager".

Cmd Name
0 GetEnvironmentVariable
1 GetEnvironmentVariableLength
2 BindHostConnectionEvent
3 BindHostDisconnectionEvent
4 BindHostConnectionEventForSystem
5 BindHostDisconnectionEventForSystem
6 [3.0.0+] GetBridgeIpAddress
7 [3.0.0+] GetBridgePort
8 [3.0.0+] SetCradleAttached
9 [4.0.0+] GetBridgeSubnetMask
10 [4.0.0+] GetBridgeMacAddress
11 [6.0.0+] GetWorkingDirectoryPath
12 [6.0.0+] GetWorkingDirectoryPathSize
13 [6.0.0+] RunOnHostStart
14 [9.0.0+] RunOnHostResults
21 [19.0.0+] BeginUpdateBridge
22 [19.0.0+] ContinueUpdateBridge
23 [19.0.0+] EndUpdateBridge
24 [19.0.0+] GetBridgeType

htcs

This is "nn::tma::IHtcsManager".

Cmd Name
0 Socket
1 Close
2 Connect
3 Bind
4 Listen
5 Accept
6 Recv
7 Send
8 Shutdown
9 Fcntl
10 GetPeerNameAny
11 GetDefaultHostName
12 CreateSocketOld
13 CreateSocket
100 RegisterProcessId
101 MonitorManager

ISocket

This is "nn::tma::ISocket".

Cmd Name
0 Close
1 Connect
2 Bind
3 Listen
4 Accept
5 Recv
6 Send
7 Shutdown
8 Fcntl

htc:tenv

This is "nn::htc::tenv::IServiceManager".

Cmd Name
0 GetServiceInterface

IService

This is "nn::htc::tenv::IService".

Cmd Name
0 GetVariable
1 GetVariableLength
2 WaitUntilVariableAvailable

file_io

This is "nn::tma::IFileManager".

This service is not normally present on retail units.

Cmd Name
0 #OpenFile
1 #FileExists
2 #DeleteFile
3 #RenameFile
4 #GetIOType
5 #OpenDirectory
6 #DirectoryExists
7 #CreateDirectory
8 #DeleteDirectory
9 #RenameDirectory
10 #CreateFile
11 #GetFileTimeStamp
12 GetCaseSensitivePath

OpenFile

Takes in an input X descriptor "Path" and a u32 "OpenMode", returns a #IFileAccessor interface.

FileExists

Takes in an input X descriptor "Path", and returns an output bool.

DeleteFile

Takes in an input X descriptor "Path".

RenameFile

Takes in an input X descriptor "SrcPath" and an input X descriptor "DstPath".

GetIOType

Takes in an input X descriptor "Path", returns an output int "EntryType".

OpenDirectory

Takes in an input X descriptor "Path" and a u32 "OpenMode", returns a #IDirectoryAccessor interface.

DirectoryExists

Takes in an input X descriptor "Path", and returns an output bool.

CreateDirectory

Takes in an input X descriptor "Path".

DeleteDirectory

Takes in an input X descriptor "Path" and an input bool "IsRecursive".

RenameDirectory

Takes in an input X descriptor "SrcPath" and an input X descriptor "DstPath".

CreateFile

Takes in an input X descriptor "Path" and an input s64 "Size".

GetFileTimeStamp

Takes in an input X descriptor "Path", and returns 3 output u64s ("CreatedTime", "AccessedTime", "ModifiedTime").

IFileAccessor

This is "nn::tma::IFileAccessor".

Cmd Name
0 ReadFile
1 WriteFile
2 GetFileSize
3 SetFileSize
4 FlushFile
5 SetPriorityForFile
6 GetPriorityForFile

ReadFile

Takes in an input s64 "Offset", an input ReadOption, and a NonSecure B descriptor "OutBuffer", and returns a s64 "BytesRead".

WriteFile

Takes in an input s64 "Offset", an input WriteOption, and a NonSecure A descriptor "InBuffer".

GetFileSize

Takes no input, and returns a s64 "FileSize".

SetFileSize

Takes an s64 "FileSize".

FlushFile

Takes no input, returns no output.

SetPriorityForFile

Takes an input s32 "Priority".

GetPriorityForFile

Takes no input, returns an s32 "Priority".

IDirectoryAccessor

This is "nn::tma::IDirectoryAccessor".

Cmd Name
0 #GetEntryCount
1 #ReadDirectory
2 #SetPriorityForDirectory
3 #GetPriorityForDirectory

GetEntryCount

Takes no input, returns an s64 "EntryCount".

ReadDirectory

Takes an input B descriptor "OutEntryBuffer", returns an s64 "NumEntriesRead"

SetPriorityForDirectory

Takes an input s32 "Priority".

GetPriorityForDirectory

Takes no input, returns an s32 "Priority".