Expand description
Userland library for Nintendo Switch homebrew (and other potential purposes), written in pure Rust and some assembly bits
§Features
This library covers a lot of different modules, wrappers, etc. so some of them (essentially those which can be opt-in) are separated as optional features:
-
services: Enables custom client-IPC service implementations, AKA thenx::servicemodule -
smc: Enables secure-monitor support, AKA thenx::smcmodule -
gpu: Enables graphics support, AKA thenx::gpumodule (also enablesservices) -
console: Enables console support, AKA thenx::consolemodule (also enablescanvasand thefont8x8dependency) -
vty: Enables virtual tty support, AKA, thenx::console::vtymodule (also enablesconsoleas well as the dependenciesembedded-termandembedded-graphics-core) -
fs: Enables support for this library’s FS implementation, aka thenx::fsmodule (also enablesservices) -
input: Enables input support, AKA thenx::inputmodule (also enablesservices) -
la: Enables library applet support, AKA thenx::lamodule (also enablesservices) -
rand: Enables pseudo-RNG support, AKA thenx::randmodule (also enablesservices) -
socket: Enables std-like network support, AKA thenx::socketmodule (also enablesservices) -
applet: Enables applet service support, AKA thenx::appletmodule (also enablesservices) -
mii: Enables mii support, AKA thenx::miimodule (also enablesservices)
Note that most of these features/modules are just simplified and easy-to-use wrappers around IPC/raw system features, so not using them doesn’t fully block those features (for instance, you could use services using IPC commands more directly without the services feature).
§Contributing
You can always contribute to these libraries, report bugs, etc. at their repository
§Examples
Library examples are located at this other repository
Modules§
- applet
- AppletAE/AppletOE Support
- arm
- ARM support and utils
- console
- Console Services
- diag
- Diagnostics (logging and aborting) support
- elf
- ELF (aarch64) support and utils
- exception
- Exception handling support (stubbed for now).
- fs
- FileSystem support
- gpu
- Graphics and GPU support and utils
- hbl
- HBL (homebrew loader) ABI support and utils
- input
- Input utils and wrappers
- ipc
- Contains the machinery for Horizon OS’s IPC interface
- la
- Library applet support and utils
- macros
- Library macros
- mem
- Memory (heap) support and utils
- mii
- Mii Support
- rand
- Pseudo-RNG support
- rc
- Generic library result definitions
- result
- Common result support
- rrt0
- Initial code/entrypoint support and utils
- service
- Base service/named port support and wrappers
- smc
- Secure monitor support and wrappers
- socket
- Implementation of the Rust libstd TCP/UDP APIs, and re-exports of the raw bsd sockets API.
- svc
- This module wraps svc calls provided by
asm.rs. There is generally no function-level Safety docs, but the core requirement is that all raw pointers provided must be validated by the caller. - sync
- Synchronization support and utils
- thread
- Threading support and wrappers
- util
- Common library utilities
- version
- System version utils
- vmem
- Virtual memory support
- wait
- Sync/waiting utilities and wrappers
Macros§
- acquire
- align_
up - Aligns a value up based on the provided alignment which should be a power of two.
- alloc_
set_ default_ heap_ size - Defines the default heap size of the current project
- api_
mark_ request_ command_ parameters_ types_ as_ copy - bit
- Gets a value corresponding to the given bit
- bit_
group - Constructs a
define_bit_settype value from various flags - client_
mark_ request_ command_ parameters_ types_ as_ copy - cur_
fn_ name - Gets the current function name
- define_
bit_ set - Defines a type meant to serve as a bitflag set with enum-like API
- diag_
assert - diag_
log - diag_
log_ assert - diag_
result_ code_ log_ assert - diag_
result_ log_ assert - ipc_
client_ define_ client_ default - Simplifies the creation of a (client-side IPC) type implementing an IPC interface, without implementing the trait or IPC serialization
- ipc_
client_ send_ control_ command - Identical to
ipc_client_send_request_commandbut for a “Control” command - ipc_
client_ send_ request_ command - Sends an IPC “Request” command
- ipc_
sf_ define_ control_ interface_ trait - Identical to
ipc_sf_define_interface_traitbut for “Control” IPC interfaces (inner trait functionality differs) - ipc_
sf_ define_ default_ client_ for_ interface - Simplifies the creation of a (client-side IPC) type implementing an IPC interface (and implementing the trait)
- ipc_
sf_ define_ interface_ trait - Defines a trait meant to be used for IPC interfaces
- is_
aligned - Checks if the provided value is aligned to the provided alignment
- read_
bits - Reads bits from a given value
- result_
define - Creates a result definition
- result_
define_ group - Creates a group of result definitions (all under the same module)
- result_
define_ subgroup - Creates a group of result definitions (all under the same module and submodule)
- result_
return_ if - Returns a given result if the given condition is true
- result_
return_ unless - Returns a given result unless the given condition is true
- result_
try - Wraps and returns a given result if it’s not successful
- rrt0_
define_ default_ module_ name - Defines the (runtime) module name of the current project as the package name
- rrt0_
define_ module_ name - Defines the (runtime) module name of the current project
- rrt0_
initialize_ heap - Defines a default heap initialization function for NROs (homebrew loaded apps)
- server_
mark_ request_ command_ parameters_ types_ as_ copy - session_
type - write_
bits - Writes bits into a given value