@ -5,8 +5,24 @@ A Rust wrapper library for smealum's [ctrulib](https://github.com/smealum/ctruli
@@ -5,8 +5,24 @@ A Rust wrapper library for smealum's [ctrulib](https://github.com/smealum/ctruli
## Structure
This repository is organized as follows:
* `ctru-rs`: Safe, idiomatic wrapper around `ctru-sys`.
* `ctru-sys`: Low-level, unsafe bindings to ctrulib
* `ctru-rs`: Safe, idiomatic wrapper around `ctru-sys`
* `ctru-sys`: Low-level, unsafe bindings to ctrulib.
This crate's version changes according to the version of `libctru`
used to generate the bindings, with the following convention:
* `libctru` version `X.Y.Z-W`
* `ctru-sys` version `XY.Z.P+X.Y.Z-W`
where `P` is usually 0 but may be incremented for fixes in e.g.
binding generation, `libc` dependency bump, etc.
It may be possible to build this crate against a different version of `libctru`,
but you may encounter linker errors or ABI issues. A build-time Cargo warning
(displayed when built with `-vv`) will be issued if the build script detects
a mismatch or is unable to check the installed `libctru` version.
## License
@ -37,3 +53,4 @@ applies to every file in the tree, unless otherwise noted.
@@ -37,3 +53,4 @@ applies to every file in the tree, unless otherwise noted.
Rust is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses.
See [LICENSE-APACHE](https://github.com/rust-lang/rust/blob/master/LICENSE-APACHE), [LICENSE-MIT](https://github.com/rust-lang/rust/blob/master/LICENSE-MIT), and [COPYRIGHT](https://github.com/rust-lang/rust/blob/master/COPYRIGHT) for details.
@ -2267,7 +2267,7 @@ pub type StopPointType = ::libc::c_uint;
@@ -2267,7 +2267,7 @@ pub type StopPointType = ::libc::c_uint;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pubstructStopPointExceptionEvent{
#[doc = "Stop point type, see [`StopPointType`]"]
#[doc = "Stop point type, see [`StopPointType`]"]
#[doc = ""]
pubtype_: StopPointType,
#[doc = "FAR for Watchpoints, otherwise 0."]
@ -2283,12 +2283,12 @@ impl Default for StopPointExceptionEvent {
@@ -2283,12 +2283,12 @@ impl Default for StopPointExceptionEvent {
}
}
}
#[doc = "Event relating to [`svcBreak`]"]
#[doc = "Event relating to [`svcBreak`]"]
#[doc = ""]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pubstructUserBreakExceptionEvent{
#[doc = "User break type, see [`UserBreakType`]"]
#[doc = "User break type, see [`UserBreakType`]"]
#[doc = ""]
pubtype_: UserBreakType,
#[doc = "For LOAD_RO and UNLOAD_RO."]
@ -2307,12 +2307,12 @@ impl Default for UserBreakExceptionEvent {
@@ -2307,12 +2307,12 @@ impl Default for UserBreakExceptionEvent {
}
}
}
#[doc = "Event relating to [`svcBreakDebugProcess`]"]
#[doc = "Event relating to [`svcBreakDebugProcess`]"]
#[doc = ""]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pubstructDebuggerBreakExceptionEvent{
#[doc = "IDs of the attached process's threads that were running on each core at the time of the [`svcBreakDebugProcess`] call, or -1 (only the first 2 values are meaningful on O3DS)."]
#[doc = "IDs of the attached process's threads that were running on each core at the time of the [`svcBreakDebugProcess`] call, or -1 (only the first 2 values are meaningful on O3DS)."]
@ -2484,13 +2484,13 @@ pub type DebugEventType = ::libc::c_uint;
@@ -2484,13 +2484,13 @@ pub type DebugEventType = ::libc::c_uint;
#[repr(C)]
#[derive(Copy, Clone)]
pubstructDebugEventInfo{
#[doc = "Type of event. See [`DebugEventType`]"]
#[doc = "Type of event. See [`DebugEventType`]"]
#[doc = ""]
pubtype_: DebugEventType,
#[doc = "ID of the thread."]
#[doc = ""]
pubthread_id: u32_,
#[doc = "Flags. Bit0 means that [`svcContinueDebugEvent`] needs to be called for this event (except for EXIT PROCESS events, where this flag is disregarded)."]
#[doc = "Flags. Bit0 means that [`svcContinueDebugEvent`] needs to be called for this event (except for EXIT PROCESS events, where this flag is disregarded)."]
#[doc = ""]
pubflags: u32_,
#[doc = "Always 0."]
@ -2547,27 +2547,27 @@ impl Default for DebugEventInfo {
@@ -2547,27 +2547,27 @@ impl Default for DebugEventInfo {
}
}
}
#[doc = "Inhibit user-defined CPU exception handlers (including watchpoints and breakpoints, regardless of any [`svcKernelSetState`] call)."]
#[doc = "Inhibit user-defined CPU exception handlers (including watchpoints and breakpoints, regardless of any [`svcKernelSetState`] call)."]
#[doc = "Exits the current thread.\n\n This will trigger a state change and hence release all [`svcWaitSynchronization`] operations.\n It means that you can join a thread by calling ``` svcWaitSynchronization(threadHandle,yourtimeout); ```"]
#[doc = "Exits the current thread.\n\n This will trigger a state change and hence release all [`svcWaitSynchronization`] operations.\n It means that you can join a thread by calling ``` svcWaitSynchronization(threadHandle,yourtimeout);"]
#[doc = "Throws (and logs) a system error with the given Result code.\n @param[in] failure Result code to throw.\n\n This calls [`ERRF_Throw`] with error type [`ERRF_ERRTYPE_GENERIC`] and fills in the required data.\n\n This function \\em does fill in the address where this function was called from."]
#[doc = "Throws (and logs) a system error with the given Result code.\n @param[in] failure Result code to throw.\n\n This calls [`ERRF_Throw`] with error type [`ERRF_ERRTYPE_GENERIC`] and fills in the required data.\n\n This function *does* fill in the address where this function was called from."]
#[doc = ""]
pubfnERRF_ThrowResult(failure: Result)-> Result;
}
extern"C"{
#[must_use]
#[doc = "Logs a system error with the given Result code.\n @param[in] failure Result code to log.\n\n Similar to [`ERRF_Throw`] except that it does not display anything on the screen,\n nor does it force the system to reboot.\n\n This function \\em does fill in the address where this function was called from."]
#[doc = "Logs a system error with the given Result code.\n @param[in] failure Result code to log.\n\n Similar to [`ERRF_Throw`] except that it does not display anything on the screen,\n nor does it force the system to reboot.\n\n This function *does* fill in the address where this function was called from."]
#[doc = ""]
pubfnERRF_LogResult(failure: Result)-> Result;
}
extern"C"{
#[must_use]
#[doc = "Throws a system error with the given Result code and message.\n @param[in] failure Result code to throw.\n @param[in] message The message to display.\n\n This calls [`ERRF_Throw`] with error type [`ERRF_ERRTYPE_FAILURE`] and fills in the required data.\n\n This function does \\em not fill in the address where this function was called from because it\n would not be displayed."]
#[doc = "Throws a system error with the given Result code and message.\n @param[in] failure Result code to throw.\n @param[in] message The message to display.\n\n This calls [`ERRF_Throw`] with error type [`ERRF_ERRTYPE_FAILURE`] and fills in the required data.\n\n This function does *not* fill in the address where this function was called from because it\n would not be displayed."]
#[doc = "Function used to implement user-mode synchronization primitives.\n @param addr Pointer to a signed 32-bit value whose address will be used to identify waiting threads.\n @param type Type of action to be performed by the arbiter\n @param value Number of threads to signal if using [`ARBITRATION_SIGNAL`] or the value used for comparison.\n\n This will perform an arbitration based on #type. The comparisons are done between #value and the value at the address #addr.\n\n ``` s32 val=0;\n // Does *nothing* since val >= 0\n syncArbitrateAddress(&val,ARBITRATION_WAIT_IF_LESS_THAN,0);\n``` @note Usage of this function entails an implicit Data Memory Barrier (dmb)."]
#[doc = "Function used to implement user-mode synchronization primitives.\n @param addr Pointer to a signed 32-bit value whose address will be used to identify waiting threads.\n @param type Type of action to be performed by the arbiter\n @param value Number of threads to signal if using [`ARBITRATION_SIGNAL`] or the value used for comparison.\n\n This will perform an arbitration based on #type. The comparisons are done between #value and the value at the address #addr.\n\n ``` s32 val=0;\n // Does *nothing* since val >= 0\n syncArbitrateAddress(&val,ARBITRATION_WAIT_IF_LESS_THAN,0);\n*@note* Usage of this function entails an implicit Data Memory Barrier (dmb)."]
#[doc = "Function used to implement user-mode synchronization primitives (with timeout).\n @param addr Pointer to a signed 32-bit value whose address will be used to identify waiting threads.\n @param type Type of action to be performed by the arbiter (must use [`ARBITRATION_WAIT_IF_LESS_THAN_TIMEOUT`] or [`ARBITRATION_DECREMENT_AND_WAIT_IF_LESS_THAN_TIMEOUT)\n`] @param value Number of threads to signal if using [`ARBITRATION_SIGNAL`] or the value used for comparison.\n\n This will perform an arbitration based on #type. The comparisons are done between #value and the value at the address #addr.\n\n ``` s32 val=0;\n // Thread will wait for a signal or wake up after 10000000 nanoseconds because val < 1.\n syncArbitrateAddressWithTimeout(&val,ARBITRATION_WAIT_IF_LESS_THAN_TIMEOUT,1,10000000LL);\n``` @note Usage of this function entails an implicit Data Memory Barrier (dmb)."]
#[doc = "Function used to implement user-mode synchronization primitives (with timeout).\n @param addr Pointer to a signed 32-bit value whose address will be used to identify waiting threads.\n @param type Type of action to be performed by the arbiter (must use [`ARBITRATION_WAIT_IF_LESS_THAN_TIMEOUT`] or [`ARBITRATION_DECREMENT_AND_WAIT_IF_LESS_THAN_TIMEOUT)\n`] @param value Number of threads to signal if using [`ARBITRATION_SIGNAL`] or the value used for comparison.\n\n This will perform an arbitration based on #type. The comparisons are done between #value and the value at the address #addr.\n\n ``` s32 val=0;\n // Thread will wait for a signal or wake up after 10000000 nanoseconds because val < 1.\n syncArbitrateAddressWithTimeout(&val,ARBITRATION_WAIT_IF_LESS_THAN_TIMEOUT,1,10000000LL);\n*@note* Usage of this function entails an implicit Data Memory Barrier (dmb)."]
#[doc = "Updates the configuration of both screens.\n @note This function is equivalent to: ``` gfxScreenSwapBuffers(GFX_TOP,true); gfxScreenSwapBuffers(GFX_BOTTOM,true); ```"]
#[doc = "Updates the configuration of both screens.\n @note This function is equivalent to: ``` gfxScreenSwapBuffers(GFX_TOP,true); gfxScreenSwapBuffers(GFX_BOTTOM,true);"]
#[doc = ""]
pubfngfxSwapBuffers();
}
extern"C"{
#[doc = "Same as [`gfxSwapBuffers`] (formerly different)."]
#[doc = "Same as [`gfxSwapBuffers`] (formerly different)."]
#[doc = ""]
pubfngfxSwapBuffersGpu();
}
@ -5428,7 +5428,7 @@ impl Default for ConsoleFont {
@@ -5428,7 +5428,7 @@ impl Default for ConsoleFont {
}
}
}
#[doc = "Console structure used to store the state of a console render context.\n\n Default values from consoleGetDefault();\n ``` PrintConsole defaultConsole =\n {\n\t//Font:\n\t{\n\t\t(u8*)default_font_bin, //font gfx\n\t\t0, //first ascii character in the set\n\t\t128, //number of characters in the font set\n\t},\n\t0,0, //cursorX cursorY\n\t0,0, //prevcursorX prevcursorY\n\t40, //console width\n\t30, //console height\n\t0, //window x\n\t0, //window y\n\t32, //window width\n\t24, //window height\n\t3, //tab size\n\t0, //font character offset\n\t0, //print callback\n\tfalse //console initialized\n };\n ```"]
#[doc = "Console structure used to store the state of a console render context.\n\n Default values from consoleGetDefault();\n ``` PrintConsole defaultConsole =\n {\n\t//Font:\n\t{\n\t\t(u8*)default_font_bin, //font gfx\n\t\t0, //first ascii character in the set\n\t\t128, //number of characters in the font set\n\t},\n\t0,0, //cursorX cursorY\n\t0,0, //prevcursorX prevcursorY\n\t40, //console width\n\t30, //console height\n\t0, //window x\n\t0, //window y\n\t32, //window width\n\t24, //window height\n\t3, //tab size\n\t0, //font character offset\n\t0, //print callback\n\tfalse //console initialized\n };\n"]
#[doc = "Convert a UTF-8 sequence into a UTF-32 codepoint\n\n @param[out] out Output codepoint\n @param[in] in Input sequence\n\n @returns number of input code units consumed\n @returns -1 for error"]
#[doc = "Convert a UTF-8 sequence into a UTF-32 codepoint\n\n@param[out] out Output codepoint\n@param[in] in Input sequence\n\n @returns number of input code units consumed\n @returns -1 for error"]
#[doc = "Convert a UTF-16 sequence into a UTF-32 codepoint\n\n @param[out] out Output codepoint\n @param[in] in Input sequence\n\n @returns number of input code units consumed\n @returns -1 for error"]
#[doc = "Convert a UTF-16 sequence into a UTF-32 codepoint\n\n@param[out] out Output codepoint\n@param[in] in Input sequence\n\n @returns number of input code units consumed\n @returns -1 for error"]
#[doc = "Convert a UTF-32 codepoint into a UTF-8 sequence\n\n @param[out] out Output sequence\n @param[in] in Input codepoint\n\n @returns number of output code units produced\n @returns -1 for error\n\n@note \\a out must be able to store 4 code units"]
#[doc = "Convert a UTF-32 codepoint into a UTF-8 sequence\n\n@param[out] out Output sequence\n@param[in] in Input codepoint\n\n@returns number of output code units produced\n @returns -1 for error\n\n @note *out* must be able to store 4 code units"]
#[doc = ""]
pubfnencode_utf8(out: *mutu8,in_: u32)-> isize;
}
extern"C"{
#[doc = "Convert a UTF-32 codepoint into a UTF-16 sequence\n\n @param[out] out Output sequence\n @param[in] in Input codepoint\n\n @returns number of output code units produced\n @returns -1 for error\n\n@note \\a out must be able to store 2 code units"]
#[doc = "Convert a UTF-32 codepoint into a UTF-16 sequence\n\n@param[out] out Output sequence\n@param[in] in Input codepoint\n\n@returns number of output code units produced\n @returns -1 for error\n\n @note *out* must be able to store 2 code units"]
#[doc = ""]
pubfnencode_utf16(out: *mutu16,in_: u32)-> isize;
}
extern"C"{
#[doc = "Convert a UTF-8 sequence into a UTF-16 sequence\n\nFills the output buffer up to \\a len code units.\n Returns the number of code units that the input would produce;\nif it returns greater than \\a len, the output has been\n truncated.\n\n @param[out] out Output sequence\n @param[in] in Input sequence (null-terminated)\n @param[in] len Output length\n\n @returns number of output code units produced\n @returns -1 for error\n\n@note \\a out is not null-terminated"]
#[doc = "Convert a UTF-8 sequence into a UTF-16 sequence\n\n Fills the output buffer up to *len* code units.\n Returns the number of code units that the input would produce;\n if it returns greater than *len,* the output has been\n truncated.\n\n @param[out] out Output sequence\n@param[in] in Input sequence (null-terminated)\n@param[in] len Output length\n\n @returns number of output code units produced\n@returns -1 for error\n\n @note *out* is not null-terminated"]
#[doc = "Convert a UTF-8 sequence into a UTF-32 sequence\n\nFills the output buffer up to \\a len code units.\n Returns the number of code units that the input would produce;\nif it returns greater than \\a len, the output has been\n truncated.\n\n @param[out] out Output sequence\n @param[in] in Input sequence (null-terminated)\n @param[in] len Output length\n\n @returns number of output code units produced\n @returns -1 for error\n\n@note \\a out is not null-terminated"]
#[doc = "Convert a UTF-8 sequence into a UTF-32 sequence\n\n Fills the output buffer up to *len* code units.\n Returns the number of code units that the input would produce;\n if it returns greater than *len,* the output has been\n truncated.\n\n @param[out] out Output sequence\n@param[in] in Input sequence (null-terminated)\n@param[in] len Output length\n\n @returns number of output code units produced\n@returns -1 for error\n\n @note *out* is not null-terminated"]
#[doc = "Convert a UTF-16 sequence into a UTF-8 sequence\n\nFills the output buffer up to \\a len code units.\n Returns the number of code units that the input would produce;\nif it returns greater than \\a len, the output has been\n truncated.\n\n @param[out] out Output sequence\n @param[in] in Input sequence (null-terminated)\n @param[in] len Output length\n\n @returns number of output code units produced\n @returns -1 for error\n\n@note \\a out is not null-terminated"]
#[doc = "Convert a UTF-16 sequence into a UTF-8 sequence\n\n Fills the output buffer up to *len* code units.\n Returns the number of code units that the input would produce;\n if it returns greater than *len,* the output has been\n truncated.\n\n @param[out] out Output sequence\n@param[in] in Input sequence (null-terminated)\n@param[in] len Output length\n\n @returns number of output code units produced\n@returns -1 for error\n\n @note *out* is not null-terminated"]
#[doc = "Convert a UTF-16 sequence into a UTF-32 sequence\n\nFills the output buffer up to \\a len code units.\n Returns the number of code units that the input would produce;\nif it returns greater than \\a len, the output has been\n truncated.\n\n @param[out] out Output sequence\n @param[in] in Input sequence (null-terminated)\n @param[in] len Output length\n\n @returns number of output code units produced\n @returns -1 for error\n\n@note \\a out is not null-terminated"]
#[doc = "Convert a UTF-16 sequence into a UTF-32 sequence\n\n Fills the output buffer up to *len* code units.\n Returns the number of code units that the input would produce;\n if it returns greater than *len,* the output has been\n truncated.\n\n @param[out] out Output sequence\n@param[in] in Input sequence (null-terminated)\n@param[in] len Output length\n\n @returns number of output code units produced\n@returns -1 for error\n\n @note *out* is not null-terminated"]
#[doc = "Convert a UTF-32 sequence into a UTF-8 sequence\n\nFills the output buffer up to \\a len code units.\n Returns the number of code units that the input would produce;\nif it returns greater than \\a len, the output has been\n truncated.\n\n @param[out] out Output sequence\n @param[in] in Input sequence (null-terminated)\n @param[in] len Output length\n\n @returns number of output code units produced\n @returns -1 for error\n\n@note \\a out is not null-terminated"]
#[doc = "Convert a UTF-32 sequence into a UTF-8 sequence\n\n Fills the output buffer up to *len* code units.\n Returns the number of code units that the input would produce;\n if it returns greater than *len,* the output has been\n truncated.\n\n @param[out] out Output sequence\n@param[in] in Input sequence (null-terminated)\n@param[in] len Output length\n\n @returns number of output code units produced\n@returns -1 for error\n\n @note *out* is not null-terminated"]
#[doc = "Convert a UTF-32 sequence into a UTF-16 sequence\n\n @param[out] out Output sequence\n @param[in] in Input sequence (null-terminated)\n @param[in] len Output length\n\n @returns number of output code units produced\n @returns -1 for error\n\n@note \\a out is not null-terminated"]
#[doc = "Convert a UTF-32 sequence into a UTF-16 sequence\n\n@param[out] out Output sequence\n@param[in] in Input sequence (null-terminated)\n@param[in] len Output length\n\n@returns number of output code units produced\n @returns -1 for error\n\n @note *out* is not null-terminated"]
#[doc = "Returns true if there is an incoming HOME button press rejected by the policy set by [`aptSetHomeAllowed`] (use this to show a \"no HOME allowed\" icon)."]
#[doc = "Returns true if there is an incoming HOME button press rejected by the policy set by [`aptSetHomeAllowed`] (use this to show a \"no HOME allowed\" icon)."]
#[doc = "Coefficients of the YUV->RGB conversion formula.\n\n A set of coefficients configuring the RGB to YUV conversion. Coefficients 0-4 are unsigned 2.8\n fixed pointer numbers representing entries on the conversion matrix, while coefficient 5-7 are\n signed 11.5 fixed point numbers added as offsets to the RGB result.\n\n The overall conversion process formula is:\n ``` R = trunc((rgb_Y * Y + r_V * V) + 0.75 + r_offset)\n G = trunc((rgb_Y * Y - g_U * U - g_V * V) + 0.75 + g_offset)\n B = trunc((rgb_Y * Y + b_U * U ) + 0.75 + b_offset)\n ```"]
#[doc = "Coefficients of the YUV->RGB conversion formula.\n\n A set of coefficients configuring the RGB to YUV conversion. Coefficients 0-4 are unsigned 2.8\n fixed pointer numbers representing entries on the conversion matrix, while coefficient 5-7 are\n signed 11.5 fixed point numbers added as offsets to the RGB result.\n\n The overall conversion process formula is:\n ``` R = trunc((rgb_Y * Y + r_V * V) + 0.75 + r_offset)\n G = trunc((rgb_Y * Y - g_U * U - g_V * V) + 0.75 + g_offset)\n B = trunc((rgb_Y * Y + b_U * U ) + 0.75 + b_offset)\n"]
#[doc = ""]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
@ -9558,10 +9558,10 @@ pub type Y2RU_StandardCoefficient = ::libc::c_uint;
@@ -9558,10 +9558,10 @@ pub type Y2RU_StandardCoefficient = ::libc::c_uint;
#[doc = "Gets an handle to the end of conversion event.\n @param end_event Pointer to the event handle to be set to the end of conversion event. It isn't necessary to create or close this handle.\n\n To enable this event you have to use ``` ``` The event will be triggered when the corresponding interrupt is fired.\n\n @note It is recommended to use a timeout when waiting on this event, as it sometimes (but rarely) isn't triggered."]
#[doc = "Gets an handle to the end of conversion event.\n @param end_event Pointer to the event handle to be set to the end of conversion event. It isn't necessary to create or close this handle.\n\n To enable this event you have to use ``` *The* event will be triggered when the corresponding interrupt is fired.\n\n @note It is recommended to use a timeout when waiting on this event, as it sometimes (but rarely) isn't triggered."]
#[doc = "Index of the initially selected Mii. If\n[`MiiSelectorConf.show_guest_page`] is\nset, this is the index of a Guest Mii,\notherwise that of a user Mii."]
#[doc = "Index of the initially selected Mii. If\n[`MiiSelectorConf.show_guest_page`] is\nset, this is the index of a Guest Mii,\notherwise that of a user Mii."]
#[doc = ""]
pubinitial_index: u32_,
#[doc = "Each byte set to a nonzero value\nenables its corresponding Guest\nMii to be enabled for selection."]