Changes

1,555 bytes added ,  14:41, 20 March 2016
Add documentation on static buffers
Line 133: Line 133:  
|}
 
|}
   −
== Usage Examples for other Translation Types ==
+
== Static Buffer Translation ==
 +
 
 +
Each thread may set up up to 16 static buffer descriptors in their [[Thread Local Storage]] at offset 0x180. These contain information about buffers in the thread's memory space that may be used for information exchange for communication with other processes. In particular, a static buffer descriptor encodes the address and size of a buffer.
 +
 
 +
Using IPC requests, data can be transferred from any location in the source process to one of the static buffers set up in the target process. This is done using a translation descriptor of type 1, which is followed by a pointer to the source data. The translation descriptor has the following structure:
 +
 
 +
{| class="wikitable" border="1"
 +
|-
 +
!  Bits
 +
!  Description
 +
|-
 +
| 2-4
 +
| Translation type
 +
|-
 +
| 10-13
 +
| Static buffer index of the receiving process
 +
|-
 +
| 14-??
 +
| Size in bytes of the transferred data. Specifying an amount larger than the target static buffer will result in an error.
 +
|}
 +
 
 +
When encountering such a translation descriptor, the kernel will look up the static buffer address and size corresponding to the given index and (if the buffer can hold the requested amount of data) will copy the data to the specified location.
 +
 
 +
Note that the translation descriptor and static buffer descriptor share the same layout. However, it is unknown whether the kernel ever reads fields other than the buffer address and size when dealing with static buffer descriptors.
    +
Usage examples:
 
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
 
|-
 
|-
!  Type
   
! scope="col" width="300" |  Usual form
 
! scope="col" width="300" |  Usual form
 
!  Description
 
!  Description
 
|-
 
|-
| 1
   
| 0x00000002 <nowiki>|</nowiki> (size<<14) <nowiki>|</nowiki> (static_buffer_id<<10)
 
| 0x00000002 <nowiki>|</nowiki> (size<<14) <nowiki>|</nowiki> (static_buffer_id<<10)
 
<ptr>
 
<ptr>
 
| The corresponding value contains a ptr to a buffer of said size, that should be copied to an already set-up buffer in destination process at [[Thread Local Storage]] offset 0x180 + static_buffer_id*8. The static_buffer_id is only 4 bits, making it possible for at most up to 16 buffers in total per thread.
 
| The corresponding value contains a ptr to a buffer of said size, that should be copied to an already set-up buffer in destination process at [[Thread Local Storage]] offset 0x180 + static_buffer_id*8. The static_buffer_id is only 4 bits, making it possible for at most up to 16 buffers in total per thread.
 +
|}
 +
 +
== Usage Examples for other Translation Types ==
 +
 +
{| class="wikitable" border="1"
 +
|-
 +
!  Type
 +
! scope="col" width="300" |  Usual form
 +
!  Description
 
|-
 
|-
 
| 2
 
| 2
549

edits