From 6cfc6c7f5c5e5d2a9b27574209b0204985cf7b7b Mon Sep 17 00:00:00 2001 From: mekosko Date: Fri, 23 Aug 2024 21:51:45 +0500 Subject: [PATCH 01/13] Make support for u-boot --- riscv-rt/Cargo.toml | 1 + riscv-rt/macros/Cargo.toml | 1 + riscv-rt/macros/src/lib.rs | 46 ++++++++++++++++++++++++++++++++++++++ riscv-rt/src/asm.rs | 5 +++-- 4 files changed, 51 insertions(+), 2 deletions(-) diff --git a/riscv-rt/Cargo.toml b/riscv-rt/Cargo.toml index 2910e355..440a41bb 100644 --- a/riscv-rt/Cargo.toml +++ b/riscv-rt/Cargo.toml @@ -23,3 +23,4 @@ panic-halt = "0.2.0" s-mode = ["riscv-rt-macros/s-mode"] single-hart = [] v-trap = ["riscv-rt-macros/v-trap"] +u-boot = ["riscv-rt-macros/u-boot"] diff --git a/riscv-rt/macros/Cargo.toml b/riscv-rt/macros/Cargo.toml index 19f6690d..b7dba6fb 100644 --- a/riscv-rt/macros/Cargo.toml +++ b/riscv-rt/macros/Cargo.toml @@ -23,3 +23,4 @@ syn = { version = "2.0", features = ["extra-traits", "full"] } [features] s-mode = [] v-trap = [] +u-boot = [] diff --git a/riscv-rt/macros/src/lib.rs b/riscv-rt/macros/src/lib.rs index c34e3a25..25d571f4 100644 --- a/riscv-rt/macros/src/lib.rs +++ b/riscv-rt/macros/src/lib.rs @@ -53,6 +53,7 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream { let f = parse_macro_input!(input as ItemFn); // check the function arguments + #[cfg(not(feature = "u-boot"))] if f.sig.inputs.len() > 3 { return parse::Error::new( f.sig.inputs.last().unwrap().span(), @@ -61,6 +62,17 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream { .to_compile_error() .into(); } + #[cfg(feature = "u-boot")] + if f.sig.inputs.len() != 2 { + return parse::Error::new( + f.sig.inputs.last().unwrap().span(), + "`#[entry]` function must have exactly two arguments", + ) + .to_compile_error() + .into(); + } + + #[cfg(not(feature = "u-boot"))] for arg in &f.sig.inputs { match arg { FnArg::Receiver(_) => { @@ -77,6 +89,40 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream { } } } + #[cfg(feature = "u-boot")] + { + // We have checked that there are two arguments above. + let (a1, a2) = (&f.sig.inputs[0], &f.sig.inputs[1]); + + match a1 { + FnArg::Receiver(_) => { + return parse::Error::new(a1.span(), "invalid argument") + .to_compile_error() + .into(); + } + FnArg::Typed(t) => { + if !is_simple_type(&t.ty, "c_int") { + return parse::Error::new(t.ty.span(), "argument type must be c_int") + .to_compile_error() + .into(); + } + } + } + match a2 { + FnArg::Receiver(_) => { + return parse::Error::new(a2.span(), "invalid argument") + .to_compile_error() + .into(); + } + FnArg::Typed(t) => { + if !is_simple_type(&t.ty, "usize") { + return parse::Error::new(t.ty.span(), "argument type must be usize") + .to_compile_error() + .into(); + } + } + } + } // check the function signature let valid_signature = f.sig.constness.is_none() diff --git a/riscv-rt/src/asm.rs b/riscv-rt/src/asm.rs index 7883c446..46fb112a 100644 --- a/riscv-rt/src/asm.rs +++ b/riscv-rt/src/asm.rs @@ -125,6 +125,7 @@ cfg_global_asm!( ); // STORE A0..A2 IN THE STACK, AS THEY WILL BE NEEDED LATER BY main +#[cfg(not(feature = "u-boot"))] cfg_global_asm!( #[cfg(riscv32)] "addi sp, sp, -4 * 3 @@ -213,12 +214,12 @@ riscv_rt_macros::loop_global_asm!(" fmv.w.x f{}, x0", 32); // SET UP INTERRUPTS, RESTORE a0..a2, AND JUMP TO MAIN RUST FUNCTION cfg_global_asm!( "call _setup_interrupts", - #[cfg(riscv32)] + #[cfg(all(riscv32, not(feature = "u-boot")))] "lw a0, 4 * 0(sp) lw a1, 4 * 1(sp) lw a2, 4 * 2(sp) addi sp, sp, 4 * 3", - #[cfg(riscv64)] + #[cfg(all(riscv64, not(feature = "u-boot")))] "ld a0, 8 * 0(sp) ld a1, 8 * 1(sp) ld a2, 8 * 2(sp) From 6f71bda55e77e4aded0e4cb564b953bad777db52 Mon Sep 17 00:00:00 2001 From: mekosko Date: Fri, 23 Aug 2024 23:04:49 +0500 Subject: [PATCH 02/13] Accept 2 or less arguments --- riscv-rt/macros/src/lib.rs | 42 ++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/riscv-rt/macros/src/lib.rs b/riscv-rt/macros/src/lib.rs index 25d571f4..76cc96ef 100644 --- a/riscv-rt/macros/src/lib.rs +++ b/riscv-rt/macros/src/lib.rs @@ -52,21 +52,16 @@ use proc_macro::TokenStream; pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream { let f = parse_macro_input!(input as ItemFn); - // check the function arguments #[cfg(not(feature = "u-boot"))] - if f.sig.inputs.len() > 3 { - return parse::Error::new( - f.sig.inputs.last().unwrap().span(), - "`#[entry]` function has too many arguments", - ) - .to_compile_error() - .into(); - } + let arguments_limit = 3; #[cfg(feature = "u-boot")] - if f.sig.inputs.len() != 2 { + let arguments_limit = 2; + + // check the function arguments + if f.sig.inputs.len() > arguments_limit { return parse::Error::new( f.sig.inputs.last().unwrap().span(), - "`#[entry]` function must have exactly two arguments", + "`#[entry]` function has too many arguments", ) .to_compile_error() .into(); @@ -90,10 +85,7 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream { } } #[cfg(feature = "u-boot")] - { - // We have checked that there are two arguments above. - let (a1, a2) = (&f.sig.inputs[0], &f.sig.inputs[1]); - + if let Some(a1) = f.sig.inputs.get(0) { match a1 { FnArg::Receiver(_) => { return parse::Error::new(a1.span(), "invalid argument") @@ -108,18 +100,20 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream { } } } - match a2 { - FnArg::Receiver(_) => { - return parse::Error::new(a2.span(), "invalid argument") - .to_compile_error() - .into(); - } - FnArg::Typed(t) => { - if !is_simple_type(&t.ty, "usize") { - return parse::Error::new(t.ty.span(), "argument type must be usize") + if let Some(a2) = f.sig.inputs.get(1) { + match a2 { + FnArg::Receiver(_) => { + return parse::Error::new(a2.span(), "invalid argument") .to_compile_error() .into(); } + FnArg::Typed(t) => { + if !is_simple_type(&t.ty, "usize") { + return parse::Error::new(t.ty.span(), "argument type must be usize") + .to_compile_error() + .into(); + } + } } } } From 95a4f49eb1eda662e87e3f6a0bffda95a1ea3a5c Mon Sep 17 00:00:00 2001 From: mekosko Date: Sat, 24 Aug 2024 00:05:19 +0500 Subject: [PATCH 03/13] Reduce code complexity --- riscv-rt/macros/src/lib.rs | 78 ++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 45 deletions(-) diff --git a/riscv-rt/macros/src/lib.rs b/riscv-rt/macros/src/lib.rs index 76cc96ef..d10961db 100644 --- a/riscv-rt/macros/src/lib.rs +++ b/riscv-rt/macros/src/lib.rs @@ -12,7 +12,7 @@ use proc_macro2::Span; use syn::{ parse::{self, Parse}, spanned::Spanned, - FnArg, ItemFn, LitInt, LitStr, PathArguments, ReturnType, Type, Visibility, + FnArg, ItemFn, LitInt, LitStr, PatType, PathArguments, ReturnType, Type, Visibility, }; use proc_macro::TokenStream; @@ -67,54 +67,42 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream { .into(); } - #[cfg(not(feature = "u-boot"))] - for arg in &f.sig.inputs { - match arg { - FnArg::Receiver(_) => { - return parse::Error::new(arg.span(), "invalid argument") - .to_compile_error() - .into(); - } - FnArg::Typed(t) => { - if !is_simple_type(&t.ty, "usize") { - return parse::Error::new(t.ty.span(), "argument type must be usize") - .to_compile_error() - .into(); - } - } + fn check_simple_type(argument: &PatType, ty: &str) -> Option { + let inv_type_message = format!("argument type must be {}", ty); + + if !is_simple_type(&argument.ty, ty) { + let error = parse::Error::new(argument.ty.span(), inv_type_message); + + Some(error.to_compile_error().into()) + } else { + None + } + } + fn check_argument_type(argument: &FnArg, ty: &str) -> Option { + let argument_error = parse::Error::new(argument.span(), "invalid argument"); + let argument_error = argument_error.to_compile_error().into(); + + match argument { + FnArg::Typed(argument) => check_simple_type(argument, ty), + FnArg::Receiver(_) => Some(argument_error), } } + #[cfg(not(feature = "u-boot"))] + for argument in f.sig.inputs.iter() { + if let Some(message) = check_argument_type(argument, "usize") { + return message; + }; + } #[cfg(feature = "u-boot")] - if let Some(a1) = f.sig.inputs.get(0) { - match a1 { - FnArg::Receiver(_) => { - return parse::Error::new(a1.span(), "invalid argument") - .to_compile_error() - .into(); - } - FnArg::Typed(t) => { - if !is_simple_type(&t.ty, "c_int") { - return parse::Error::new(t.ty.span(), "argument type must be c_int") - .to_compile_error() - .into(); - } - } + if let Some(argument) = f.sig.inputs.get(0) { + if let Some(message) = check_argument_type(argument, "c_int") { + return message; } - if let Some(a2) = f.sig.inputs.get(1) { - match a2 { - FnArg::Receiver(_) => { - return parse::Error::new(a2.span(), "invalid argument") - .to_compile_error() - .into(); - } - FnArg::Typed(t) => { - if !is_simple_type(&t.ty, "usize") { - return parse::Error::new(t.ty.span(), "argument type must be usize") - .to_compile_error() - .into(); - } - } - } + } + #[cfg(feature = "u-boot")] + if let Some(argument) = f.sig.inputs.get(1) { + if let Some(message) = check_argument_type(argument, "usize") { + return message; } } From e3110d69a74269f6a79f721e8cab14ebeab174e5 Mon Sep 17 00:00:00 2001 From: mekosko Date: Sat, 24 Aug 2024 00:29:18 +0500 Subject: [PATCH 04/13] Update CHANGELOG.md --- riscv-rt/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/riscv-rt/CHANGELOG.md b/riscv-rt/CHANGELOG.md index 59b407c1..d224e5cd 100644 --- a/riscv-rt/CHANGELOG.md +++ b/riscv-rt/CHANGELOG.md @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Add `v-trap` feature to enable interrupt handling in vectored mode. - Add `interrupt` proc macro to help defining interrupt handlers. If `v-trap` feature is enabled, this macro also generates its corresponding trap. +- Add `u-boot` feature, so that you can start your elf binary with u-boot and +work with passed arguments. ### Changed From 0fe5fae17fcf8979c3755a704ea15a9e4d467b1e Mon Sep 17 00:00:00 2001 From: mekosko Date: Sat, 24 Aug 2024 12:44:53 +0500 Subject: [PATCH 05/13] Explicitly specify features in CI --- .github/workflows/riscv-rt.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/riscv-rt.yaml b/.github/workflows/riscv-rt.yaml index 34702a74..6bcf6fe1 100644 --- a/.github/workflows/riscv-rt.yaml +++ b/.github/workflows/riscv-rt.yaml @@ -42,7 +42,7 @@ jobs: - name : Build (v-trap) run: RUSTFLAGS="-C link-arg=-Triscv-rt/examples/device.x" cargo build --package riscv-rt --target ${{ matrix.target }} --example ${{ matrix.example }} --features=v-trap - name: Build (all features) - run: RUSTFLAGS="-C link-arg=-Triscv-rt/examples/device.x" cargo build --package riscv-rt --target ${{ matrix.target }} --example ${{ matrix.example }} --all-features + run: RUSTFLAGS="-C link-arg=-Triscv-rt/examples/device.x" cargo build --package riscv-rt --target ${{ matrix.target }} --example ${{ matrix.example }} --features=s-mode,signle-hart,v-trap # Job to check that all the builds succeeded build-check: From cf770ffcc0dc888c0c3f23f96adae780e9f23dcd Mon Sep 17 00:00:00 2001 From: mekosko Date: Sat, 24 Aug 2024 15:03:09 +0500 Subject: [PATCH 06/13] Require single-hart when booting through u-boot --- riscv-rt/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/riscv-rt/Cargo.toml b/riscv-rt/Cargo.toml index 440a41bb..eb2e212f 100644 --- a/riscv-rt/Cargo.toml +++ b/riscv-rt/Cargo.toml @@ -23,4 +23,4 @@ panic-halt = "0.2.0" s-mode = ["riscv-rt-macros/s-mode"] single-hart = [] v-trap = ["riscv-rt-macros/v-trap"] -u-boot = ["riscv-rt-macros/u-boot"] +u-boot = ["riscv-rt-macros/u-boot", "single-hart"] From d35152c43625a6125a85bbce27ba3fb99e1ee630 Mon Sep 17 00:00:00 2001 From: mekosko Date: Sun, 25 Aug 2024 10:48:45 +0000 Subject: [PATCH 07/13] Make u-boot feature docs --- riscv-rt/src/lib.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/riscv-rt/src/lib.rs b/riscv-rt/src/lib.rs index 0ffb3441..f8907b61 100644 --- a/riscv-rt/src/lib.rs +++ b/riscv-rt/src/lib.rs @@ -452,6 +452,20 @@ //! ``` //! //! This will generate a function named `_start_MachineTimer_trap` that calls the interrupt handler `MachineTimer`. +//! +//! ## `u-boot` +//! +//! The u-boot support feature (`u-boot`) can be activated via [Cargo features](https://doc.rust-lang.org/cargo/reference/features.html). +//! +//! For example: +//! ``` text +//! [dependencies] +//! riscv-rt = { features = ["u-boot"] } +//! ``` +//! When the u-boot feature is enabled, some assembly code is disabled to leave stack untouched. This is required +//! because when booting from elf, u-boot passes arguments as argc and argv through stack. Because the only way +//! to get boot-hart is through fdt, this feature also implies `single-hart` so other harts initialization +//! is up to you. // NOTE: Adapted from cortex-m/src/lib.rs #![no_std] From 35702532ff7a8fa5ec8c67786620995898c5686c Mon Sep 17 00:00:00 2001 From: mekosko Date: Sun, 25 Aug 2024 11:24:55 +0000 Subject: [PATCH 08/13] Resolve typo --- .github/workflows/riscv-rt.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/riscv-rt.yaml b/.github/workflows/riscv-rt.yaml index 6bcf6fe1..3ccfb139 100644 --- a/.github/workflows/riscv-rt.yaml +++ b/.github/workflows/riscv-rt.yaml @@ -42,7 +42,7 @@ jobs: - name : Build (v-trap) run: RUSTFLAGS="-C link-arg=-Triscv-rt/examples/device.x" cargo build --package riscv-rt --target ${{ matrix.target }} --example ${{ matrix.example }} --features=v-trap - name: Build (all features) - run: RUSTFLAGS="-C link-arg=-Triscv-rt/examples/device.x" cargo build --package riscv-rt --target ${{ matrix.target }} --example ${{ matrix.example }} --features=s-mode,signle-hart,v-trap + run: RUSTFLAGS="-C link-arg=-Triscv-rt/examples/device.x" cargo build --package riscv-rt --target ${{ matrix.target }} --example ${{ matrix.example }} --features=s-mode,single-hart,v-trap # Job to check that all the builds succeeded build-check: From 2669a1905561c0bf68655b747a2520ca3c09fda2 Mon Sep 17 00:00:00 2001 From: mekosko Date: Tue, 27 Aug 2024 00:48:28 +0500 Subject: [PATCH 09/13] Wipe stack related changes --- riscv-rt/src/asm.rs | 5 ++--- riscv-rt/src/lib.rs | 13 ++++++------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/riscv-rt/src/asm.rs b/riscv-rt/src/asm.rs index 46fb112a..7883c446 100644 --- a/riscv-rt/src/asm.rs +++ b/riscv-rt/src/asm.rs @@ -125,7 +125,6 @@ cfg_global_asm!( ); // STORE A0..A2 IN THE STACK, AS THEY WILL BE NEEDED LATER BY main -#[cfg(not(feature = "u-boot"))] cfg_global_asm!( #[cfg(riscv32)] "addi sp, sp, -4 * 3 @@ -214,12 +213,12 @@ riscv_rt_macros::loop_global_asm!(" fmv.w.x f{}, x0", 32); // SET UP INTERRUPTS, RESTORE a0..a2, AND JUMP TO MAIN RUST FUNCTION cfg_global_asm!( "call _setup_interrupts", - #[cfg(all(riscv32, not(feature = "u-boot")))] + #[cfg(riscv32)] "lw a0, 4 * 0(sp) lw a1, 4 * 1(sp) lw a2, 4 * 2(sp) addi sp, sp, 4 * 3", - #[cfg(all(riscv64, not(feature = "u-boot")))] + #[cfg(riscv64)] "ld a0, 8 * 0(sp) ld a1, 8 * 1(sp) ld a2, 8 * 2(sp) diff --git a/riscv-rt/src/lib.rs b/riscv-rt/src/lib.rs index f8907b61..c4572dc4 100644 --- a/riscv-rt/src/lib.rs +++ b/riscv-rt/src/lib.rs @@ -452,20 +452,19 @@ //! ``` //! //! This will generate a function named `_start_MachineTimer_trap` that calls the interrupt handler `MachineTimer`. -//! +//! //! ## `u-boot` -//! +//! //! The u-boot support feature (`u-boot`) can be activated via [Cargo features](https://doc.rust-lang.org/cargo/reference/features.html). -//! +//! //! For example: //! ``` text //! [dependencies] //! riscv-rt = { features = ["u-boot"] } //! ``` -//! When the u-boot feature is enabled, some assembly code is disabled to leave stack untouched. This is required -//! because when booting from elf, u-boot passes arguments as argc and argv through stack. Because the only way -//! to get boot-hart is through fdt, this feature also implies `single-hart` so other harts initialization -//! is up to you. +//! When the u-boot feature is enabled, acceptable signature for `#[entry]` macros is changed. This is required +//! because when booting from elf, u-boot passes `argc` and `argv`. This feature also implies `single-hart`. +//! The only way to get boot-hart is through fdt, so other harts initialization is up to you. // NOTE: Adapted from cortex-m/src/lib.rs #![no_std] From 778950b6a369d7f6a40f3e0bf623b9bb13f7a965 Mon Sep 17 00:00:00 2001 From: mekosko Date: Tue, 27 Aug 2024 01:56:52 +0500 Subject: [PATCH 10/13] Make types check more flexible --- riscv-rt/macros/src/lib.rs | 44 ++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/riscv-rt/macros/src/lib.rs b/riscv-rt/macros/src/lib.rs index d10961db..a9c6afa7 100644 --- a/riscv-rt/macros/src/lib.rs +++ b/riscv-rt/macros/src/lib.rs @@ -11,8 +11,9 @@ extern crate syn; use proc_macro2::Span; use syn::{ parse::{self, Parse}, + punctuated::Punctuated, spanned::Spanned, - FnArg, ItemFn, LitInt, LitStr, PatType, PathArguments, ReturnType, Type, Visibility, + FnArg, ItemFn, LitInt, LitStr, PatType, ReturnType, Type, Visibility, }; use proc_macro::TokenStream; @@ -67,10 +68,10 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream { .into(); } - fn check_simple_type(argument: &PatType, ty: &str) -> Option { + fn check_correct_type(argument: &PatType, ty: &str) -> Option { let inv_type_message = format!("argument type must be {}", ty); - if !is_simple_type(&argument.ty, ty) { + if !is_correct_type(&argument.ty, ty) { let error = parse::Error::new(argument.ty.span(), inv_type_message); Some(error.to_compile_error().into()) @@ -83,7 +84,7 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream { let argument_error = argument_error.to_compile_error().into(); match argument { - FnArg::Typed(argument) => check_simple_type(argument, ty), + FnArg::Typed(argument) => check_correct_type(argument, ty), FnArg::Receiver(_) => Some(argument_error), } } @@ -101,7 +102,7 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream { } #[cfg(feature = "u-boot")] if let Some(argument) = f.sig.inputs.get(1) { - if let Some(message) = check_argument_type(argument, "usize") { + if let Some(message) = check_argument_type(argument, "*const *const c_char") { return message; } } @@ -151,17 +152,32 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream { .into() } -#[allow(unused)] -fn is_simple_type(ty: &Type, name: &str) -> bool { - if let Type::Path(p) = ty { - if p.qself.is_none() && p.path.leading_colon.is_none() && p.path.segments.len() == 1 { - let segment = p.path.segments.first().unwrap(); - if segment.ident == name && segment.arguments == PathArguments::None { - return true; - } +fn strip_type_path(ty: &Type) -> Option { + match ty { + Type::Ptr(ty) => { + let mut ty = ty.clone(); + ty.elem = Box::new(strip_type_path(&ty.elem)?); + Some(Type::Ptr(ty)) } + Type::Path(ty) => { + let mut ty = ty.clone(); + let last_segment = ty.path.segments.last().unwrap().clone(); + ty.path.segments = Punctuated::new(); + ty.path.segments.push_value(last_segment); + Some(Type::Path(ty)) + } + _ => None, + } +} + +#[allow(unused)] +fn is_correct_type(ty: &Type, name: &str) -> bool { + let correct: Type = syn::parse_str(name).unwrap(); + if let Some(ty) = strip_type_path(ty) { + ty == correct + } else { + false } - false } /// Attribute to mark which function will be called at the beginning of the reset handler. From c2adf559a7f7b39f8f6b608537b61a4ab6c0770d Mon Sep 17 00:00:00 2001 From: mekosko Date: Tue, 27 Aug 2024 02:22:33 +0500 Subject: [PATCH 11/13] Make empty example with u-boot --- .github/workflows/riscv-rt.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/riscv-rt.yaml b/.github/workflows/riscv-rt.yaml index 3ccfb139..be49bbce 100644 --- a/.github/workflows/riscv-rt.yaml +++ b/.github/workflows/riscv-rt.yaml @@ -41,8 +41,10 @@ jobs: run: RUSTFLAGS="-C link-arg=-Triscv-rt/examples/device.x" cargo build --package riscv-rt --target ${{ matrix.target }} --example ${{ matrix.example }} --features=single-hart - name : Build (v-trap) run: RUSTFLAGS="-C link-arg=-Triscv-rt/examples/device.x" cargo build --package riscv-rt --target ${{ matrix.target }} --example ${{ matrix.example }} --features=v-trap - - name: Build (all features) + - name : Build (all features except u-boot) run: RUSTFLAGS="-C link-arg=-Triscv-rt/examples/device.x" cargo build --package riscv-rt --target ${{ matrix.target }} --example ${{ matrix.example }} --features=s-mode,single-hart,v-trap + - name : Build (u-boot) + run: RUSTFLAGS="-C link-arg=-Triscv-rt/examples/device.x" cargo build --package riscv-rt --target ${{ matrix.target }} --example empty --features=u-boot # Job to check that all the builds succeeded build-check: From d9f2ee1d6482e7ea825f69758405e957ec4f5a12 Mon Sep 17 00:00:00 2001 From: mekosko Date: Tue, 27 Aug 2024 22:40:35 +0500 Subject: [PATCH 12/13] Resolve lints issue --- riscv/src/interrupt.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/riscv/src/interrupt.rs b/riscv/src/interrupt.rs index 0bd03b7e..b6fcae4a 100644 --- a/riscv/src/interrupt.rs +++ b/riscv/src/interrupt.rs @@ -142,6 +142,7 @@ pub mod supervisor { } /// Execute closure `f` with interrupts enabled in the current hart (supervisor mode). + /// /// This method is assumed to be called within an interrupt handler, and allows /// nested interrupts to occur. After the closure `f` is executed, the [`sstatus`] /// and [`sepc`] registers are properly restored to their previous values. From 86a3ebf0d38e278029e9a95f129e24b3019f5689 Mon Sep 17 00:00:00 2001 From: mekosko Date: Tue, 27 Aug 2024 22:49:26 +0500 Subject: [PATCH 13/13] Resolve lints issue --- riscv-rt/macros/src/lib.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/riscv-rt/macros/src/lib.rs b/riscv-rt/macros/src/lib.rs index a9c6afa7..df7d5a01 100644 --- a/riscv-rt/macros/src/lib.rs +++ b/riscv-rt/macros/src/lib.rs @@ -549,15 +549,21 @@ _continue_interrupt_trap: } #[proc_macro_attribute] -/// Attribute to declare an interrupt handler. The function must have the signature `[unsafe] fn() [-> !]`. -/// If the `v-trap` feature is enabled, this macro generates the interrupt trap handler in assembly for RISCV-32 targets. +/// Attribute to declare an interrupt handler. +/// +/// The function must have the signature `[unsafe] fn() [-> !]`. +/// If the `v-trap` feature is enabled, this macro generates the +/// interrupt trap handler in assembly for RISCV-32 targets. pub fn interrupt_riscv32(args: TokenStream, input: TokenStream) -> TokenStream { interrupt(args, input, RiscvArch::Rv32) } #[proc_macro_attribute] -/// Attribute to declare an interrupt handler. The function must have the signature `[unsafe] fn() [-> !]`. -/// If the `v-trap` feature is enabled, this macro generates the interrupt trap handler in assembly for RISCV-32 targets. +/// Attribute to declare an interrupt handler. +/// +/// The function must have the signature `[unsafe] fn() [-> !]`. +/// If the `v-trap` feature is enabled, this macro generates the +/// interrupt trap handler in assembly for RISCV-64 targets. pub fn interrupt_riscv64(args: TokenStream, input: TokenStream) -> TokenStream { interrupt(args, input, RiscvArch::Rv64) }