-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rust: Add initial crates for rust support
This commit adds three rust crates: `bitbox02-sys`, `bitbox02` and `bitbox02-new`. bitbox02-sys contains the generated unsafe rust functions that maps to c-functions in the firmware. CMake will pass the sysroot and the include paths to cargo when building. bitbox02 contains the safe wrappers around the unsafe functions above. bitbox02-rust contains new workflows/api endpoints that are implemented in rust. Functions from `bitbox02-rust` that have been declared "extern" can be called from C. During compile time a header called "bitbox02_rust.h" is generated with the correct declarations. The only crate that actually is built by CMake is `bitbox02-rust`. Due to dependency declarations in the Cargo.toml files cargo knows where to find and how to build the other crates. Unit tests can be run with `make -C build rust-test`
- Loading branch information
Showing
26 changed files
with
1,725 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Enums | ||
|
||
arm-none-eabi-gcc compiles with -fshort-enums by defualt. This means that if all variants of an | ||
enum fits in a small type (such as `uint8_t`), then the enum will be backed by such a small type. | ||
|
||
|
||
With `-fno-short-enums` (the default on other platforms) all enums will be `int32_t` sized as long | ||
as they fit, otherwise `int64_t`. `repr(C)` in rust also follows this and can therefore not be | ||
used. Instead all enums that are exported must have an explicit size using `repr(u8)` for example. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[build] | ||
target = "thumbv7em-none-eabi" |
Oops, something went wrong.