Skip to content

Commit

Permalink
Merge pull request #28 from RusPiRo/development
Browse files Browse the repository at this point in the history
Prepare Release and crates.io publishing
  • Loading branch information
2ndTaleStudio authored Dec 29, 2021
2 parents c6837e7 + 4a02cb6 commit a34f8f5
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 106 deletions.
34 changes: 0 additions & 34 deletions .cargo/aarch64-ruspiro.json

This file was deleted.

16 changes: 9 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
toolchain: nightly-2021-12-24
override: true
components: rust-src, llvm-tools-preview
target: aarch64-unknown-none
Expand All @@ -44,7 +44,7 @@ jobs:
cat Cargo.toml
- name: Compile
run: cargo make pi3 --profile pipeline
run: cargo make -t build --profile pipeline

publish_dry:
name: Run Cargo Publish Dry-Run
Expand All @@ -62,7 +62,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
toolchain: nightly-2021-12-24
override: true
components: rust-src, llvm-tools-preview
target: aarch64-unknown-none
Expand All @@ -73,7 +73,7 @@ jobs:
version: 'latest'

- name: Publish-Dry-Run
run: cargo make publish_dry --profile pipeline
run: cargo make -t publish_dry --profile pipeline

prepare_release:
needs: [build, publish_dry]
Expand Down Expand Up @@ -152,7 +152,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
toolchain: nightly-2021-12-24
override: true
components: rust-src, llvm-tools-preview
target: aarch64-unknown-none
Expand All @@ -174,5 +174,7 @@ jobs:
# and the README.md
sed -i -e 's/||VERSION||/'$CRATE_VERSION'/g' README.md
- name: Publish-Dry-Run
run: cargo make publish --env CRATES_TOKEN=${{ secrets.CRATES_TOKEN }} --profile pipeline
- name: Publish
env:
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
run: cargo make -t publish --profile pipeline
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# Changelog

## :dog: v0.5.3
## :cat: v0.5.4

- ### :wrench: Maintenance

- update to compile with latest nightly and Rust edition 2021
- minor clean ups in CI config and `Makefile`

- ### :bulb: Features

- place the default panic handler implementation behind a feature flag. This feature is enabled by default.

## :cat: v0.5.3

This release aims to fix the build issue on doc.rs while the crate is uploaded to crates.io

Expand Down
14 changes: 7 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 9 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "ruspiro-boot"
authors = ["André Borrmann <[email protected]>"]
version = "0.5.3" # remember to update html_root_url
version = "0.5.4" # remember to update html_root_url
description = """
Bare metal boot strapper code for the Raspberry Pi 3 to conviniently start a custom kernel within the Rust environment
without the need to deal with all the initial setup like stack pointers, switch to the appropriate exeption level and getting all cores kicked off for processing of code compiled from Rust.
Expand All @@ -12,7 +12,7 @@ documentation = "https://docs.rs/ruspiro-boot/||VERSION||"
readme = "README.md"
keywords = ["RusPiRo", "aarch64", "boot", "baremetal", "multicore"]
categories = ["no-std", "embedded"]
edition = "2018"
edition = "2021"
# define a linkage name to ensure this crate is ever beeing linked once into a final binary
links = "ruspiro_boot"
# compile the assembler parts before the rust compiler runs on this crate
Expand All @@ -29,18 +29,22 @@ cc = "~1.0"

[dependencies]
log = { version = "~0.4.14", default-features = false }
ruspiro-register = "~0.5.4"
ruspiro-register = "~0.5.5"
ruspiro-cache = "~0.4.1"

[features]
default = ["panic"]
# activate this feature to get multicore support
multicore = [ ]
multicore = []
# activate this feature to provide a default panic handler
panic = []

# ensure the required features of the crate are active for the doc.rs build
[package.metadata.docs.rs]
default-target = "aarch64-unknown-linux-gnu"
features = [
"multicore"
"multicore",
"panic"
]

[patch.crates-io]
Expand Down
33 changes: 12 additions & 21 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,28 @@ AR = "aarch64-linux-gnu-ar"
CFLAGS = "-march=armv8-a -Wall -O3 -nostdlib -nostartfiles -ffreestanding -mtune=cortex-a53"
RUSTFLAGS = "-C target-cpu=cortex-a53 -C target-feature=+strict-align,+a53,+fp-armv8,+neon -C link-arg=-T./link64.ld"

[tasks.build]
command = "cargo"
args = ["build", "--release", "--features", "${FEATURES}"]

[tasks.clippy]
env = { FEATURES = "" }
env = { FEATURES = "panic, multicore" }
command = "cargo"
args = ["clippy", "--features", "${FEATURES}"]

[tasks.doc]
env = { FEATURES = "" }
env = { FEATURES = "panic, multicore" }
command = "cargo"
args = ["doc", "--features", "${FEATURES}", "--open"]

[tasks.test]
env = { FEATURES = "" }
[tasks.singlecore]
env = { FEATURES = "panic" }
command = "cargo"
args = ["test", "--features", "${FEATURES}"]

[tasks.pi3_singlecore]
env = { FEATURES = "" }
run_task = "build"
dependencies = ["clean"]
args = ["build", "--release", "--features", "${FEATURES}"]

[tasks.pi3_multicore]
env = { FEATURES = "multicore" }
run_task = "build"
dependencies = ["clean"]
[tasks.multicore]
env = { FEATURES = "multicore, panic" }
command = "cargo"
args = ["build", "--release", "--features", "${FEATURES}"]

[tasks.pi3]
dependencies = ["pi3_singlecore", "pi3_multicore"]
[tasks.build]
dependencies = ["singlecore", "multicore"]

[tasks.clean]
command = "cargo"
Expand All @@ -55,6 +46,6 @@ command = "cargo"
args = ["publish", "--dry-run", "--features", "${FEATURES}"]

[tasks.publish]
env = { FEATURES = "" }
env = { FEATURES = "panic, multicore" }
command = "cargo"
args = ["publish", "--token", "${CRATES_TOKEN}", "--allow-dirty", "--features", "${FEATURES}"]
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ both architectures and the execution is tested on a Raspberry Pi 3 B+.
Feature | Purpose
-----------------|--------------------------
`multicore` | Compiles the multi-core version of the crate, kicking off all 4 cores of the Raspberry Pi.
`panic` | Enable the default panic handler. This feature is enabled by default.

## Usage

Expand Down
8 changes: 0 additions & 8 deletions aarch64-ruspiro.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@
"target-family": "unix",
"target-mcount": "\u0001_mcount",
"target-pointer-width": "64",
"unsupported-abis": [
"stdcall",
"fastcall",
"vectorcall",
"thiscall",
"win64",
"sysv64"
],
"vendor": "unknown",
"panic-strategy": "abort",
"disable-redzone": true,
Expand Down
4 changes: 4 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[toolchain]
channel = "nightly-2021-12-24"
components = [ "rustfmt", "clippy", "rust-src", "llvm-tools-preview" ]
profile = "minimal"
6 changes: 3 additions & 3 deletions src/asm/aarch64/bootstrap.S
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
* License: Apache License 2.0 / MIT
**********************************************************************************************************************/

.global __boot // global entry point
.global __hang // helper to savely "hang" a core with nothing else to do
.global __boot // global entry point
.global __hang // helper to savely "hang" a core with nothing else to do

/***************************************************************************************************
* main entry point using specific section that is ensured to be linked against the entrypoint
Expand Down Expand Up @@ -141,7 +141,7 @@ __switch_el2_to_el1:
ret

/***************************************************************************************************
* savely hang the core
* safely hang the core
* use the WFE instruction to save power while waiting for any event
* wfe is triggered by any exception/interrupt raised, but as long as there is no event
* the core sleeps....
Expand Down
17 changes: 9 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
**********************************************************************************************************************/
#![doc(html_root_url = "https://docs.rs/ruspiro-boot/||VERSION||")]
#![no_std]
#![feature(llvm_asm, lang_items, linkage)]
#![feature(lang_items, linkage)]
// this crate does only compile with valid content if the target architecture is AARCH64!
#![cfg(target_arch = "aarch64")]

Expand Down Expand Up @@ -44,9 +44,10 @@
//!
//! # Features
//!
//! Feature | Description
//! ----------------|------------------------------------------------------------------------------
//! ``multicore`` | Enables the compilation of the multi core boot sequence. Without it only the main core 0 is running.
//! Feature | Description
//! --------------|------------------------------------------------------------------------------
//! `multicore` | Enables the compilation of the multi core boot sequence. Without it only the main core 0 is running.
//! `panic` | Enables the default panic handler. This feature is enabled by default
//!
//! ## Hint:
//! To successfully build a bare metal binary/kernel that depends on this one to perform the boot
Expand Down Expand Up @@ -140,10 +141,10 @@ fn kickoff_next_core(core: u32) {
_ => return,
};
unsafe {
ptr::write_volatile(jump_store as *mut u64, 0x80000); //__boot as *const () as u64);
// as this core may have caches enabled, flush it so the other core
// sees the correct data on memory and the write does not only hit the cache
ptr::write_volatile(jump_store as *mut u64, 0x8_0000);
// as this core may have caches enabled, flush it so the other core
// sees the correct data on memory and the write does not only hit the cache
cache::flush_dcache_range(0xe0, 0x10);
llvm_asm!("sev"); // trigger an event to wake up the sleeping cores
core::arch::asm!("sev"); // trigger an event to wake up the sleeping cores
}
}
15 changes: 3 additions & 12 deletions src/panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,15 @@
use core::panic::PanicInfo;
use log::error;

#[cfg(not(test))]
#[cfg(all(not(test), feature = "panic"))]
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
// Panicing means we have reach a situation we are unable to recover from into a valid state.
// Halt the panicing core and safely do nothing!
// The error will be printed using the log crate. It requires a global logger to be configure
// The error will be printed using the log crate. It requires a global logger to be configured
// otherwise the output is just going no-where. Refer to the ruspiro-console crate which provides
// the functionality to setup a global logger
if let Some(location) = info.location() {
error!(
"PANIC at {:?}, {}:{}",
location.file(),
location.line(),
location.column()
);
} else {
error!("PANIC somewhere!");
}
error!("PANIC: {}", info);
loop {}
}

Expand Down

0 comments on commit a34f8f5

Please sign in to comment.