Changes

1,122 bytes added ,  16:29, 5 November 2019
Line 636: Line 636:  
The Receive async [[#Cmd72|thread]] does the following:
 
The Receive async [[#Cmd72|thread]] does the following:
 
* Sets the <code>nn::fs::PriorityRaw</code> using a value loaded from state.
 
* Sets the <code>nn::fs::PriorityRaw</code> using a value loaded from state.
* Calls a func.
+
* Calls a func, and writes the returned Result into state.
 
* Signals the async Event and returns.
 
* Signals the async Event and returns.
 
** That func does:
 
** That func does:
** ...
+
** This handles installation, with messages being used via vtable funcptrs.
    
The Send async [[#Cmd77|thread]] does the following:
 
The Send async [[#Cmd77|thread]] does the following:
 
* This is identical to the Receive thread except the called func is different.
 
* This is identical to the Receive thread except the called func is different.
 
** That func does:
 
** That func does:
** ...
+
** Gets [[System_Settings|system-setting]] <code>nim.errorsimulate!error_localcommunication_result</code>, returning that as an error if set + non-zero.
 +
** Does socket setup.
 +
** Calls a func.
 +
** When any of the above fail (including the system-setting), the Result is written into state, then the Result is returned.
 +
** Lastly this returns 0.
 +
*** The above func does:
 +
*** This repeatedly receives requests, processes them, and sends the replies. This loop (and func) will only exit when an error occurs, or when request ID 0x0 is used (the latter causes the func to return 0).
 +
*** This handles the requests as required by the ID, no particular order is required by the server.
 +
*** All IDs in the below table are implemented by the server, even 0x3 for SystemUpdate.
 +
*** An error is thrown if the ID is unrecognized. An error is thrown if the value of the request size1 doesn't match the expected fixed value (except for ID 0x0).
    
Messages (requests/replies) begin with the following 0x10-byte header, then any associated data.
 
Messages (requests/replies) begin with the following 0x10-byte header, then any associated data.
Line 675: Line 684:  
! ID || Request size1 / data || Reply size1 / data || Description
 
! ID || Request size1 / data || Reply size1 / data || Description
 
|-
 
|-
| 0x0 || 0x0 || 0x0 || Tells the server to exit.
+
| 0x0 || 0x0 || 0x0 || Tells the server to exit. When handling this the handler func will immediately return 0, without sending a reply.
 
|-
 
|-
 
| 0x1 || [[NCM_services#ContentMetaKey|ContentMetaKey]] || 0x38-byte [[CNMT#Content_Records|Content Record]] || Gets the Content Record with type==Meta for the specified ContentMetaKey. The SystemUpdate client uses the ContentMetaKey from [[#Cmd69]].
 
| 0x1 || [[NCM_services#ContentMetaKey|ContentMetaKey]] || 0x38-byte [[CNMT#Content_Records|Content Record]] || Gets the Content Record with type==Meta for the specified ContentMetaKey. The SystemUpdate client uses the ContentMetaKey from [[#Cmd69]].