## mach_subsystem_create

Function - Register information about an RPC subsystem.

### SYNOPSIS

    kern_return_t   mach_subsystem_create
                    (task_t                             target_task,
                     user_subsystem_t                   user_subsys,
                     mach_msg_type_number_t          user_subsysCnt,
                     subsystem_t                        subsystem_t);

### PARAMETERS

target_task
  The task for which the subsystem is registered; normally the calling task, but not necessarily.

user_subsys
  The MIG-generated data structure describing the exported routines and their input/output characteristics (e.g. arguments and return values).

user_subsysCnt
  The size of the user_subsys data structure argument, in bytes.

subsys
  The port returned that names the registered subsystem.

### DESCRIPTION

The mach_subsystem_create function is used by a server to register information about an RPC subsystem with the kernel. MIG automatically generates, in the server source file, a user_subsystem_t data structure that is appropriate for registering the subsystem. This data structure includes a per-routine array that specifies:

- The address of the server function that performs the work.
- The address of the MIG-generated server-side marshalling stub, to be used with mach_msg.
- The argument signature (i.e. NDR-style argument format) of the routine.

Upon successful completion, mach_subsystem_create returns, via the subsys parameter, a port naming the registered subsystem.

Each port on which the server is to receive short-circuited RPC's (or a mach_rpc call) must be associated with a registered subsystem, by calling mach_port_allocate_subsystem.

### RETURN VALUES

KERN_INVALD_ADDRESS
  One or more of the addresses in the range specified by the subsystem address and size are not valid addresses in the caller, or some of the internal pointers in the subsystem do not point to places within the address range (all of the data of the subsystem is required to be contiguous, even the parts that are pointed to by other parts).

KERN_INVALID_ARGUMENT
  The port name specified by target_task is not a send right naming a task, or the subsystem size is too small to be valid.

KERN_INVALID_TASK
  The target task is dead.

KERN_RESOURCE_SHORTAGE
  The kernel cannot allocate the subsystem due to insufficient available memory.

### RELATED INFORMATION

Functions: mach_port_allocate_subsystem, thread_activation_create.