libnx  v4.6.0
Data Structures | Macros | Enumerations | Functions
service.h File Reference

Service wrapper object. More...

#include <assert.h>
#include "hipc.h"
#include "cmif.h"

Go to the source code of this file.

Data Structures

struct  Service
 Service object structure. More...
 
struct  SfBufferAttrs
 
struct  SfBuffer
 
struct  SfOutHandleAttrs
 
struct  SfDispatchParams
 

Macros

#define serviceAssumeDomain(_s)
 Hints the compiler that a service will always contain a domain object. More...
 
#define serviceMacroDetectIsSameType(a, b)   __builtin_types_compatible_p(typeof(a), typeof(b))
 
#define serviceMacroDetectIsPointerOrArray(p)   (__builtin_classify_type(p) == 5)
 
#define serviceMacroDecay(p)   (&*__builtin_choose_expr(serviceMacroDetectIsPointerOrArray(p), p, NULL))
 
#define serviceMacroDetectIsPointer(p)   serviceMacroDetectIsSameType(p, serviceMacroDecay(p))
 
#define serviceDispatch(_s, _rid, ...)    serviceDispatchImpl((_s),(_rid),NULL,0,NULL,0,(SfDispatchParams){ __VA_ARGS__ })
 
#define serviceDispatchIn(_s, _rid, _in, ...)
 
#define serviceDispatchOut(_s, _rid, _out, ...)
 
#define serviceDispatchInOut(_s, _rid, _in, _out, ...)
 

Enumerations

enum  {
  SfBufferAttr_In = (1U<<( 0 )) ,
  SfBufferAttr_Out = (1U<<( 1 )) ,
  SfBufferAttr_HipcMapAlias = (1U<<( 2 )) ,
  SfBufferAttr_HipcPointer = (1U<<( 3 )) ,
  SfBufferAttr_FixedSize = (1U<<( 4 )) ,
  SfBufferAttr_HipcAutoSelect = (1U<<( 5 )) ,
  SfBufferAttr_HipcMapTransferAllowsNonSecure = (1U<<( 6 )) ,
  SfBufferAttr_HipcMapTransferAllowsNonDevice = (1U<<( 7 ))
}
 
enum  SfOutHandleAttr {
  SfOutHandleAttr_None = 0 ,
  SfOutHandleAttr_HipcCopy = 1 ,
  SfOutHandleAttr_HipcMove = 2
}
 

Functions

static bool serviceIsActive (Service *s)
 Returns whether a service has been initialized. More...
 
static bool serviceIsOverride (Service *s)
 Returns whether a service is overriden in the homebrew environment. More...
 
static bool serviceIsDomain (Service *s)
 Returns whether a service is a domain. More...
 
static bool serviceIsDomainSubservice (Service *s)
 Returns whether a service is a domain subservice. More...
 
static u32 serviceGetObjectId (Service *s)
 For a domain/domain subservice, return the associated object ID. More...
 
static void serviceCreate (Service *s, Handle h)
 Creates a service object from an IPC session handle. More...
 
static void serviceCreateNonDomainSubservice (Service *s, Service *parent, Handle h)
 Creates a non-domain subservice object from a parent service. More...
 
static void serviceCreateDomainSubservice (Service *s, Service *parent, u32 object_id)
 Creates a domain subservice object from a parent service. More...
 
static void serviceClose (Service *s)
 Closes a service. More...
 
static Result serviceClone (Service *s, Service *out_s)
 Clones a service. More...
 
static Result serviceCloneEx (Service *s, u32 tag, Service *out_s)
 Clones a service with a session manager tag. More...
 
static Result serviceConvertToDomain (Service *s)
 Converts a regular service to a domain. More...
 
static void _serviceRequestFormatProcessBuffer (CmifRequestFormat *fmt, u32 attr)
 
static void _serviceRequestProcessBuffer (CmifRequest *req, const SfBuffer *buf, u32 attr)
 
static void * serviceMakeRequest (Service *s, u32 request_id, u32 context, u32 data_size, bool send_pid, const SfBufferAttrs buffer_attrs, const SfBuffer *buffers, u32 num_objects, const Service *const *objects, u32 num_handles, const Handle *handles)
 
static void _serviceResponseGetHandle (CmifResponse *res, SfOutHandleAttr type, Handle *out)
 
static Result serviceParseResponse (Service *s, u32 out_size, void **out_data, u32 num_out_objects, Service *out_objects, const SfOutHandleAttrs out_handle_attrs, Handle *out_handles)
 
static Result serviceDispatchImpl (Service *s, u32 request_id, const void *in_data, u32 in_data_size, void *out_data, u32 out_data_size, SfDispatchParams disp)
 

Detailed Description

Service wrapper object.

Author
fincs
SciresM

Macro Definition Documentation

◆ serviceAssumeDomain

#define serviceAssumeDomain (   _s)
Value:
do { \
if (!(_s)->object_id) \
__builtin_unreachable(); \
} while(0)

Hints the compiler that a service will always contain a domain object.

Parameters
[in]_sService object.

◆ serviceDispatchIn

#define serviceDispatchIn (   _s,
  _rid,
  _in,
  ... 
)
Value:
({ static_assert(!(serviceMacroDetectIsPointer(_in))); \
serviceDispatchImpl((_s),(_rid),&(_in),sizeof(_in),NULL,0,(SfDispatchParams){ __VA_ARGS__ }); })
Definition: service.h:65

◆ serviceDispatchInOut

#define serviceDispatchInOut (   _s,
  _rid,
  _in,
  _out,
  ... 
)
Value:
({ static_assert(!(serviceMacroDetectIsPointer(_in))); \
static_assert(!(serviceMacroDetectIsPointer(_out))); \
serviceDispatchImpl((_s),(_rid),&(_in),sizeof(_in),&(_out),sizeof(_out),(SfDispatchParams){ __VA_ARGS__ }); })

◆ serviceDispatchOut

#define serviceDispatchOut (   _s,
  _rid,
  _out,
  ... 
)
Value:
({ static_assert(!(serviceMacroDetectIsPointer(_out))); \
serviceDispatchImpl((_s),(_rid),NULL,0,&(_out),sizeof(_out),(SfDispatchParams){ __VA_ARGS__ }); })

Function Documentation

◆ serviceClone()

static Result serviceClone ( Service s,
Service out_s 
)
inlinestatic

Clones a service.

Parameters
[in]sService object.
[out]out_sOutput service object.

◆ serviceCloneEx()

static Result serviceCloneEx ( Service s,
u32  tag,
Service out_s 
)
inlinestatic

Clones a service with a session manager tag.

Parameters
[in]sService object.
[in]tagSession manager tag (unused in current official server code)
[out]out_sOutput service object.

◆ serviceClose()

static void serviceClose ( Service s)
inlinestatic

Closes a service.

Parameters
[in]sService object.

◆ serviceConvertToDomain()

static Result serviceConvertToDomain ( Service s)
inlinestatic

Converts a regular service to a domain.

Parameters
[in]sService object.
Returns
Result code.

◆ serviceCreate()

static void serviceCreate ( Service s,
Handle  h 
)
inlinestatic

Creates a service object from an IPC session handle.

Parameters
[out]sService object.
[in]hIPC session handle.

◆ serviceCreateDomainSubservice()

static void serviceCreateDomainSubservice ( Service s,
Service parent,
u32  object_id 
)
inlinestatic

Creates a domain subservice object from a parent service.

Parameters
[out]sService object.
[in]parentParent service, necessarily a domain or domain subservice.
[in]object_idObject ID for this subservice.

◆ serviceCreateNonDomainSubservice()

static void serviceCreateNonDomainSubservice ( Service s,
Service parent,
Handle  h 
)
inlinestatic

Creates a non-domain subservice object from a parent service.

Parameters
[out]sService object.
[in]parentParent service.
[in]hIPC session handle for this subservice.

◆ serviceGetObjectId()

static u32 serviceGetObjectId ( Service s)
inlinestatic

For a domain/domain subservice, return the associated object ID.

Parameters
[in]sService object, necessarily a domain or domain subservice.
Returns
The object ID.

◆ serviceIsActive()

static bool serviceIsActive ( Service s)
inlinestatic

Returns whether a service has been initialized.

Parameters
[in]sService object.
Returns
true if initialized.

◆ serviceIsDomain()

static bool serviceIsDomain ( Service s)
inlinestatic

Returns whether a service is a domain.

Parameters
[in]sService object.
Returns
true if a domain.

◆ serviceIsDomainSubservice()

static bool serviceIsDomainSubservice ( Service s)
inlinestatic

Returns whether a service is a domain subservice.

Parameters
[in]sService object.
Returns
true if a domain subservice.

◆ serviceIsOverride()

static bool serviceIsOverride ( Service s)
inlinestatic

Returns whether a service is overriden in the homebrew environment.

Parameters
[in]sService object.
Returns
true if overriden.