nx/
lib.rs

1//! Userland library for Nintendo Switch homebrew (and other potential purposes), written in pure Rust and some assembly bits
2//!
3//! # Features
4//!
5//! 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:
6//!
7//! - `services`: Enables custom client-IPC service implementations, AKA the `nx::service` module
8//!
9//! - `smc`: Enables secure-monitor support, AKA the `nx::smc` module
10//!
11//! - `gpu`: Enables graphics support, AKA the `nx::gpu` module (also enables `services`)
12//!
13//! - `console`: Enables console support, AKA the `nx::console` module (also enables `canvas` and the `font8x8` dependency)
14//!
15//! - `vty`: Enables virtual tty support, AKA, the `nx::console::vty` module (also enables `console` as well as the dependencies `embedded-term` and `embedded-graphics-core`)
16//!
17//! - `fs`: Enables support for this library's FS implementation, aka the `nx::fs` module (also enables `services`)
18//!
19//! - `input`: Enables input support, AKA the `nx::input` module (also enables `services`)
20//!
21//! - `la`: Enables library applet support, AKA the `nx::la` module (also enables `services`)
22//!
23//! - `rand`: Enables pseudo-RNG support, AKA the `nx::rand` module (also enables `services`)
24//!
25//! - `socket` : Enables std-like network support, AKA the `nx::socket` module (also enables `services`)
26//!
27//! - `applet` : Enables applet service support, AKA the `nx::applet` module (also enables `services`)
28//!
29//! - `mii` : Enables mii support, AKA the `nx::mii` module (also enables `services`)
30//!
31//! 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).
32//!
33//! # Contributing
34//!
35//! You can always contribute to these libraries, report bugs, etc. at their [repository](https://github.com/aarch64-switch-rs/nx)
36//!
37//! # Examples
38//!
39//! Library examples are located at this other [repository](https://github.com/aarch64-switch-rs/examples)
40
41#![no_std]
42// needed to implement the APIs for collection types with custom allocators, and doing raw allocations
43#![feature(allocator_api)]
44// needed to specify weak linkage on some items
45#![feature(linkage)]
46// needed for the implementation of the threads module
47#![feature(get_mut_unchecked)]
48// get rid of mangled error handling in applet::initialize
49#![feature(try_blocks)]
50// used for ergonomics reading UTF16 strings
51#![feature(str_from_utf16_endian)]
52//#![warn(missing_docs)]
53#![macro_use]
54use core::arch::global_asm;
55
56// Required assembly bits (those which essentially cannot/shouldn't be inlined)
57global_asm!(include_str!("rrt0.s"));
58global_asm!(include_str!("mod0.s"));
59//global_asm!(include_str!("exception.s"));
60
61extern crate self as nx;
62
63#[macro_use]
64extern crate alloc;
65
66#[macro_use]
67extern crate static_assertions;
68
69#[macro_use]
70pub mod macros;
71
72#[macro_use]
73pub mod result;
74
75pub mod rc;
76
77#[macro_use]
78pub mod util;
79
80pub mod mem;
81
82pub mod elf;
83
84pub mod exception;
85
86pub mod sync;
87
88pub mod thread;
89
90pub mod hbl;
91
92#[macro_use]
93pub mod rrt0;
94
95// We're going to allow this just because EVERYTHING in there is potentially unsafe in some way,
96// even if it's not necessarily memory safety.
97#[allow(clippy::missing_safety_doc)]
98pub mod svc;
99
100#[macro_use]
101pub mod ipc;
102
103#[macro_use]
104pub mod diag;
105
106#[cfg(feature = "input")]
107pub mod input;
108
109pub mod vmem;
110
111pub mod arm;
112
113pub mod wait;
114
115pub mod version;
116
117#[cfg(feature = "applet")]
118pub mod applet;
119#[cfg(feature = "services")]
120pub mod service;
121
122#[cfg(feature = "gpu")]
123pub mod gpu;
124#[cfg(feature = "smc")]
125pub mod smc;
126
127#[cfg(feature = "fs")]
128pub mod fs;
129
130#[cfg(feature = "rand")]
131pub mod rand;
132
133#[cfg(feature = "la")]
134pub mod la;
135
136#[cfg(any(feature = "console", feature = "vty"))]
137#[macro_use]
138pub mod console;
139
140#[cfg(feature = "socket")]
141pub mod socket;
142
143#[cfg(feature = "mii")]
144pub mod mii;