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