libnx
Data Structures | Enumerations | Functions
sm.h File Reference

Service manager (sm) IPC wrapper. More...

#include "../types.h"
#include "../kernel/svc.h"
#include "../kernel/ipc.h"

Go to the source code of this file.

Data Structures

struct  Service
 Service object structure. More...
 

Enumerations

enum  ServiceType {
  ServiceType_Uninitialized,
  ServiceType_Normal,
  ServiceType_Domain,
  ServiceType_DomainSubservice,
  ServiceType_Override
}
 Service type. More...
 

Functions

static bool serviceIsOverride (Service *s)
 Returns whether a service is overriden in the homebrew environment. More...
 
static bool serviceIsActive (Service *s)
 Returns whether a service has been initialized. 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 Result serviceCloseObjectById (Service *s, u32 object_id)
 Closes a domain object by ID. More...
 
static Result serviceIpcDispatch (Service *s)
 Dispatches an IPC request to a service. More...
 
static void serviceCreate (Service *s, Handle h)
 Creates a service object from an IPC session handle. More...
 
static void serviceCreateDomainSubservice (Service *s, Service *parent, u32 object_id)
 Creates a domain subservice object from a parent service. More...
 
static Result serviceConvertToDomain (Service *s)
 Converts a regular service to a domain. More...
 
static void serviceClose (Service *s)
 Closes a service. More...
 
Result smInitialize (void)
 Initializes SM. More...
 
void smExit (void)
 Uninitializes SM. More...
 
Result smGetService (Service *service_out, const char *name)
 Requests a service from SM. More...
 
Result smGetServiceOriginal (Handle *handle_out, u64 name)
 Requests a service from SM, as an IPC session handle directly. More...
 
Handle smGetServiceOverride (u64 name)
 Retrieves an overriden service in the homebrew environment. More...
 
Result smRegisterService (Handle *handle_out, const char *name, bool is_light, int max_sessions)
 Creates and registers a new service within SM. More...
 
Result smUnregisterService (const char *name)
 Unregisters a previously registered service in SM. More...
 
bool smHasInitialized (void)
 Check whether SM is initialized. More...
 
u64 smEncodeName (const char *name)
 Encodes a service name as a 64-bit integer. More...
 
void smAddOverrideHandle (u64 name, Handle handle)
 Overrides a service with a custom IPC service handle. More...
 

Detailed Description

Service manager (sm) IPC wrapper.

Author
plutoo
yellows8

Enumeration Type Documentation

Service type.

Enumerator
ServiceType_Uninitialized 

Uninitialized service.

ServiceType_Normal 

Normal service.

ServiceType_Domain 

Domain.

ServiceType_DomainSubservice 

Domain subservice;.

ServiceType_Override 

Service overriden in the homebrew environment.

Function Documentation

static void serviceClose ( Service s)
inlinestatic

Closes a service.

Parameters
[in]sService object.
static Result serviceCloseObjectById ( Service s,
u32  object_id 
)
inlinestatic

Closes a domain object by ID.

Parameters
[in]sService object, necessarily a domain or domain subservice.
object_idID of the object to close.
Returns
Result code.
static Result serviceConvertToDomain ( Service s)
inlinestatic

Converts a regular service to a domain.

Parameters
[in]sService object.
Returns
Result code.
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.
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.
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.
static Result serviceIpcDispatch ( Service s)
inlinestatic

Dispatches an IPC request to a service.

Parameters
[in]sService object.
Returns
Result code.
static bool serviceIsActive ( Service s)
inlinestatic

Returns whether a service has been initialized.

Parameters
[in]sService object.
Returns
true if initialized.
static bool serviceIsDomain ( Service s)
inlinestatic

Returns whether a service is a domain.

Parameters
[in]sService object.
Returns
true if a domain.
static bool serviceIsDomainSubservice ( Service s)
inlinestatic

Returns whether a service is a domain subservice.

Parameters
[in]sService object.
Returns
true if a domain subservice.
static bool serviceIsOverride ( Service s)
inlinestatic

Returns whether a service is overriden in the homebrew environment.

Parameters
[in]sService object.
Returns
true if overriden.
void smAddOverrideHandle ( u64  name,
Handle  handle 
)

Overrides a service with a custom IPC service handle.

Parameters
[in]nameName of the service (as 64-bit integer).
[in]handleIPC session handle.
u64 smEncodeName ( const char *  name)

Encodes a service name as a 64-bit integer.

Parameters
[in]nameName of the service.
Returns
Encoded name.
void smExit ( void  )

Uninitializes SM.

Returns
Result code.
Note
This function is already handled in the default application exit code (after main() returns).
Result smGetService ( Service service_out,
const char *  name 
)

Requests a service from SM.

Parameters
[out]service_outService structure which will be filled in.
[in]nameName of the service to request.
Returns
Result code.
Result smGetServiceOriginal ( Handle handle_out,
u64  name 
)

Requests a service from SM, as an IPC session handle directly.

Parameters
[out]handle_outVariable containing IPC session handle.
[in]nameName of the service to request.
Returns
Result code.
Handle smGetServiceOverride ( u64  name)

Retrieves an overriden service in the homebrew environment.

Parameters
[in]nameName of the service to request (as 64-bit integer).
Returns
IPC session handle.
bool smHasInitialized ( void  )

Check whether SM is initialized.

Returns
true if initialized.
Result smInitialize ( void  )

Initializes SM.

Returns
Result code.
Note
This function is already called in the default application startup code (before main() is called).
Result smRegisterService ( Handle handle_out,
const char *  name,
bool  is_light,
int  max_sessions 
)

Creates and registers a new service within SM.

Parameters
[out]handle_outVariable containing IPC port handle.
[in]nameName of the service.
[in]is_light"Is light"
[in]max_sessionsMaximum number of concurrent sessions that the service will accept.
Returns
Result code.
Result smUnregisterService ( const char *  name)

Unregisters a previously registered service in SM.

Parameters
[in]nameName of the service.
Returns
Result code.