-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Add a project example from @willemolding's
Cannon-rs
project
- Loading branch information
Showing
9 changed files
with
211 additions
and
0 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
Binary file not shown.
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 @@ | ||
# Rust target dir | ||
target |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,12 @@ | ||
[package] | ||
name = "hello-rs-willem" | ||
edition = "2021" | ||
version = "0.0.1" | ||
authors = ["Willem Olding"] | ||
|
||
[dependencies] | ||
cannon-io = { git = "https://github.com/badboilabs/Cannon-rs" } | ||
cannon-heap = { git = "https://github.com/badboilabs/Cannon-rs" } | ||
|
||
[profile.release] | ||
panic = "abort" |
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,20 @@ | ||
# [`Cannon-rs`][cannon-rs-willem] example program | ||
|
||
This is an example Rust program for Cannon that uses Willem Olding's [program template][program-template-willem]. | ||
|
||
## Building | ||
|
||
The program can be built using Badboilabs' provided container: | ||
|
||
```sh | ||
docker run \ | ||
--rm \ | ||
--platform linux/amd64 \ | ||
-v `pwd`/:/code \ | ||
-w="/code" \ | ||
ghcr.io/badboilabs/cannon-rs/builder:main cargo build --release -Zbuild-std && \ | ||
cp target/mips-unknown-none/release/hello-rs-willem ../bin/hello-willem-rs.elf | ||
``` | ||
|
||
[cannon-rs-willem]: https://github.com/BadBoiLabs/Cannon-rs | ||
[program-template-willem]: https://github.com/BadBoiLabs/Cannon-rs/tree/main/project-template |
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,29 @@ | ||
{ | ||
"arch": "mips", | ||
"cpu": "mips32", | ||
"crt-objects-fallback": "false", | ||
"crt-static-respected": true, | ||
"data-layout": "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64", | ||
"dynamic-linking": true, | ||
"env": "gnu", | ||
"features": "-mips32r2,-fpxx,-nooddspreg,+mips32,+crt-static,+soft-float", | ||
"has-rpath": true, | ||
"has-thread-local": true, | ||
"linker-flavor": "gnu-cc", | ||
"llvm-target": "mips-unknown-linux-gnu", | ||
"max-atomic-width": 32, | ||
"os": "linux", | ||
"position-independent-executables": true, | ||
"relro-level": "full", | ||
"supported-split-debuginfo": [ | ||
"packed", | ||
"unpacked", | ||
"off" | ||
], | ||
"target-endian": "big", | ||
"target-family": [ | ||
"unix" | ||
], | ||
"target-mcount": "_mcount", | ||
"target-pointer-width": "32" | ||
} |
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,36 @@ | ||
//! `cannon-rs` program template, provided by Willem Olding in the other [`Cannon-rs`](https://github.com/BadBoiLabs/Cannon-rs/tree/main). | ||
#![no_std] | ||
#![no_main] | ||
#![feature(core_intrinsics)] | ||
#![feature(alloc_error_handler)] | ||
#![feature(asm_experimental_arch)] | ||
|
||
extern crate alloc; | ||
|
||
const HEAP_SIZE: usize = 0x400000; | ||
|
||
use cannon_heap::init_heap; | ||
use cannon_io::prelude::*; | ||
|
||
#[no_mangle] | ||
pub extern "C" fn _start() { | ||
init_heap!(HEAP_SIZE); | ||
|
||
print("hello world!\n").unwrap(); | ||
|
||
exit(0); | ||
} | ||
|
||
#[panic_handler] | ||
fn panic(info: &core::panic::PanicInfo) -> ! { | ||
let msg = alloc::format!("panic: {}", info); | ||
let _ = print(&msg); | ||
exit(2); | ||
} | ||
|
||
#[alloc_error_handler] | ||
fn alloc_error_handler(_layout: alloc::alloc::Layout) -> ! { | ||
let _ = print("alloc error!"); | ||
exit(3); | ||
} |