Difference between revisions of "Manu services"

From Nintendo Switch Brew
Jump to navigation Jump to search
Line 95: Line 95:
  
 
Writes raw data to the device.
 
Writes raw data to the device.
 +
 +
== Cmd7 ==
 +
Takes a type-0x9 input buffer containing a path string. No output.
 +
 +
== Cmd8 ==
 +
Takes a type-0x9 input buffer containing a path string. No output.
 +
 +
= Protocol =
 +
 +
== CommandId ==
 +
{| class="wikitable" border="1"
 +
|-
 +
! Value || Name
 +
|-
 +
|}
 +
 +
== Command ==
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset || Size || Description
 +
|-
 +
| 0x0 || 0x8 || Magicnum (0xDEADCAFEDEADCAFE)
 +
|-
 +
| 0x8 || 0x4 || [[#CommandId|CommandId]]
 +
|-
 +
| 0xC || 0x4 || Padding
 +
|-
 +
| 0x10 || 0x8 || Payload size
 +
|}
 +
 +
The payload data with the above size follows.
 +
 +
After [[#WriteFile|WriteFile]] sends the file-data, it reads an additional [[#Response|Response]].
 +
 +
== Response ==
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset || Size || Description
 +
|-
 +
| 0x0 || 0x8 || Ignored by manu.
 +
|-
 +
| 0x8 || 0x4 || Status, non-zero indicates error.
 +
|-
 +
| 0xC || 0x4 || Padding
 +
|-
 +
| 0x10 || 0x8 || Output value if any. May be returned by the service commands.
 +
|}
 +
 +
[[#ReadFile|ReadFile]] additionally returns the requested file-data, followed by another [[#Response|Response]].
 +
 +
== CommandServerStatus ==
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset || Size || Description
 +
|-
 +
| 0x0 || 0x4 || Status, non-zero indicates error.
 +
|}
 +
 +
== CommandServerResponse ==
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset || Size || Description
 +
|-
 +
| 0x0 || 0x4 || Status, non-zero indicates error.
 +
|-
 +
| 0x4 || 0x4 || Padding
 +
|-
 +
| 0x8 || 0x4 || Result from handling the [[#CommandId|CommandId]].
 +
|}
 +
 +
= Notes =
 +
There's a total of 3 threads: 2 for the IPC handler threads (which send commands to the remote device and gets the response). And there's the separate nn::manu::CommandServer::RunThread, which receives commands from the remote device and sends replies. This latter thread runs regardless of any service commands being used.
  
 
[[Category:Services]]
 
[[Category:Services]]

Revision as of 16:49, 23 August 2024

Manu ("Manufacturing") services are provided by the 010000000000B14A sysmodule, which is installed at the factory but not on normal retail systems.

manu

This is "nn::manu::IManu".

Cmd Name
0 InitializeUsbTransferPipeFile
1 IsFileExist
2 ReadFile
3 WriteFile
4 InitializeUsbTransferPipeRaw
5 ReadRaw
6 WriteRaw
7 [7.0.0+]
8 [14.0.0+]

All commands are wrappers for usb:ds requests with USB configured as:

VID:           0x057E (Nintendo Co., Ltd)
PID:           0x3000
bcdDevice:     0x0100 (1.00)
Manufacturer:  "Nintendo"
Product:       "NintendoSdkDebugger"
SerialNumber:  "SerialNumber"

[7.0.0+] USB is now configured as:

VID:           0x057E (Nintendo Co., Ltd)
PID:           0x3003
bcdDevice:     0x0100 (1.00)
Manufacturer:  "Nintendo"
Product:       "NintendoSdkManufacturing"
SerialNumber:  "SerialNumber"

InitializeUsbTransferPipeFile

Unofficial name.

Takes an input u32. No output.

Configures a transfer pipe over usb:ds for file access mode.

IsFileExist

Unofficial name.

Takes a type-0x9 input buffer containing a path string. Returns an output u64.

Checks whether the specified file exists.

This is "FsFile::Exists" in SystemInitializer.

ReadFile

Unofficial name.

Takes a type-0x6 output buffer, a type-0x9 input buffer containing a path string and three u64s OutSize, Offset and InSize. No output.

Reads data from the specified file.

WriteFile

Unofficial name.

Takes a type-0x5 output input, a type-0x9 input buffer containing a path string and three u64s OutSize, Offset and InSize. No output.

Writes data to the specified file.

SystemInitializer also uses this as "FsFile::Create" with all input u64s set to 0.

InitializeUsbTransferPipeRaw

Unofficial name.

Takes an input u32. No output.

Configures a transfer pipe over usb:ds for raw access mode.

ReadRaw

Unofficial name.

Takes a type-0x6 output buffer and two u64s Offset and Size. No output.

Reads raw data from the device.

WriteRaw

Unofficial name.

Takes a type-0x5 input buffer and two u64s Offset and Size. No output.

Writes raw data to the device.

Cmd7

Takes a type-0x9 input buffer containing a path string. No output.

Cmd8

Takes a type-0x9 input buffer containing a path string. No output.

Protocol

CommandId

Value Name

Command

Offset Size Description
0x0 0x8 Magicnum (0xDEADCAFEDEADCAFE)
0x8 0x4 CommandId
0xC 0x4 Padding
0x10 0x8 Payload size

The payload data with the above size follows.

After WriteFile sends the file-data, it reads an additional Response.

Response

Offset Size Description
0x0 0x8 Ignored by manu.
0x8 0x4 Status, non-zero indicates error.
0xC 0x4 Padding
0x10 0x8 Output value if any. May be returned by the service commands.

ReadFile additionally returns the requested file-data, followed by another Response.

CommandServerStatus

Offset Size Description
0x0 0x4 Status, non-zero indicates error.

CommandServerResponse

Offset Size Description
0x0 0x4 Status, non-zero indicates error.
0x4 0x4 Padding
0x8 0x4 Result from handling the CommandId.

Notes

There's a total of 3 threads: 2 for the IPC handler threads (which send commands to the remote device and gets the response). And there's the separate nn::manu::CommandServer::RunThread, which receives commands from the remote device and sends replies. This latter thread runs regardless of any service commands being used.