ipc.h File Reference

Inter Process Communication helpers. More...

`#include <3ds/types.h>`

Go to the source code of this file.

## Enumerations

enum | IPC_BufferRights { IPC_BUFFER_R = BIT(1) , IPC_BUFFER_W = BIT(2) , IPC_BUFFER_RW = IPC_BUFFER_R | IPC_BUFFER_W }
| IPC buffer access rights. More...

## Functions

static u32 | IPC_MakeHeader (u16 command_id, unsigned normal_params, unsigned translate_params)
| Creates a command header to be used for IPC. More...
static u32 | IPC_Desc_SharedHandles (unsigned number)
| Creates a header to share handles. More...
static u32 | IPC_Desc_MoveHandles (unsigned number)
| Creates the header to transfer handle ownership. More...
static u32 | IPC_Desc_CurProcessId (void)
| Returns the code to ask the kernel to fill the handle with the current process ID. More...
static CTR_DEPRECATED u32 | IPC_Desc_CurProcessHandle (void)
static u32 | IPC_Desc_StaticBuffer (size_t size, unsigned buffer_id)
| Creates a header describing a static buffer. More...
static u32 | IPC_Desc_PXIBuffer (size_t size, unsigned buffer_id, bool is_read_only)
| Creates a header describing a buffer to be sent over PXI. More...
static u32 | IPC_Desc_Buffer (size_t size, IPC_BufferRights rights)
| Creates a header describing a buffer from the main memory. More...

## Detailed Description

Inter Process Communication helpers.

## Enumeration Type Documentation

## IPC_BufferRights

enum IPC_BufferRights

IPC buffer access rights.

Enumerator
IPC_BUFFER_R | Readable.
IPC_BUFFER_W | Writable.
IPC_BUFFER_RW | Readable and Writable.

## Function Documentation

## IPC_Desc_Buffer()

static u32 IPC_Desc_Buffer | ( | size_t | size,
|  | IPC_BufferRights | rights
| ) |  |

inlinestatic

Creates a header describing a buffer from the main memory.

Parameters

  size | Size of the buffer. Max 0x0FFFFFFF.
  rights | The rights of the buffer for the destination process.

Returns
  The created buffer header.

The next value is a pointer to the buffer.

## IPC_Desc_CurProcessId()

static u32 IPC_Desc_CurProcessId | ( | void |  | ) |

inlinestatic

Returns the code to ask the kernel to fill the handle with the current process ID.

Returns
  The code to request the current process ID.

The next value is a placeholder that will be replaced by the current process ID by the kernel.

## IPC_Desc_MoveHandles()

static u32 IPC_Desc_MoveHandles | ( | unsigned | number | ) |

inlinestatic

Creates the header to transfer handle ownership.

Parameters

  number | The number of handles following this header. Max 64.

Returns
  The created handle transfer header.

The #number next values are handles that will be duplicated and closed by the other process.

Note
  Zero values will have no effect.

## IPC_Desc_PXIBuffer()

static u32 IPC_Desc_PXIBuffer | ( | size_t | size,
|  | unsigned | buffer_id,
|  | bool | is_read_only
| ) |  |

inlinestatic

Creates a header describing a buffer to be sent over PXI.

Parameters

  size | Size of the buffer. Max 0x00FFFFFF.
  buffer_id | The Id of the buffer. Max 0xF.
  is_read_only | true if the buffer is read-only. If false, the buffer is considered to have read-write access.

Returns
  The created PXI buffer header.

The next value is a phys-address of a table located in the BASE memregion.

## IPC_Desc_SharedHandles()

static u32 IPC_Desc_SharedHandles | ( | unsigned | number | ) |

inlinestatic

Creates a header to share handles.

Parameters

  number | The number of handles following this header. Max 64.

Returns
  The created shared handles header.

The #number next values are handles that will be shared between the two processes.

Note
  Zero values will have no effect.

## IPC_Desc_StaticBuffer()

static u32 IPC_Desc_StaticBuffer | ( | size_t | size,
|  | unsigned | buffer_id
| ) |  |

inlinestatic

Creates a header describing a static buffer.

Parameters

  size | Size of the buffer. Max ?0x03FFFF?.
  buffer_id | The Id of the buffer. Max 0xF.

Returns
  The created static buffer header.

The next value is a pointer to the buffer. It will be copied to TLS offset 0x180 + static_buffer_id*8.

## IPC_MakeHeader()

static u32 IPC_MakeHeader | ( | u16 | command_id,
|  | unsigned | normal_params,
|  | unsigned | translate_params
| ) |  |

inlinestatic

Creates a command header to be used for IPC.

Parameters

  command_id | ID of the command to create a header for.
  normal_params | Size of the normal parameters in words. Up to 63.
  translate_params | Size of the translate parameters in words. Up to 63.

Returns
  The created IPC header.

Normal parameters are sent directly to the process while the translate parameters might go through modifications and checks by the kernel. The translate parameters are described by headers generated with the IPC_Desc_* functions.

Note
  While #normal_params is equivalent to the number of normal parameters, #translate_params includes the size occupied by the translate parameters headers.