Skip to content

Commit

Permalink
[rust] redesign the intermediate function signature generated by syte…
Browse files Browse the repository at this point in the history
…rkit::entry

Signed-off-by: RenXiao <u202112004@hust.edu.cn>
Tested-by: DongQing <placebo27@hust.edu.cn>
  • Loading branch information
wyywwi authored and luojia65 committed Sep 26, 2024
1 parent 00589b1 commit 2f654b5
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 17 deletions.
2 changes: 1 addition & 1 deletion board/100ask-d1-h-rs/src/bin/hello-world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ use panic_halt as _;
use syterkit::{entry, println, Clocks, Peripherals};

#[entry]
fn main(p: Peripherals, c: Clocks) {
fn main(_p: Peripherals, _c: Clocks) {
println!("Hello World!");
}
2 changes: 1 addition & 1 deletion board/100ask-d1-h-rs/src/bin/init-dram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use panic_halt as _;
use syterkit::{entry, mctl, println, Clocks, Peripherals};

#[entry]
fn main(p: Peripherals, c: Clocks) {
fn main(_p: Peripherals, _c: Clocks) {
println!("DDR Init");
let ram_size = mctl::init();
println!("{}M 🐏", ram_size);
Expand Down
2 changes: 1 addition & 1 deletion board/100ask-d1-h-rs/src/bin/led-lightup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use panic_halt as _;
use syterkit::{entry, Clocks, Peripherals};

#[entry]
fn main(p: Peripherals, c: Clocks) {
fn main(p: Peripherals, _c: Clocks) {
// light up led
let mut pb5 = p.gpio.pb5.into_output();
pb5.set_high().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion board/100ask-d1-h-rs/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use panic_halt as _;
use syterkit::{clock_dump, entry, println, show_banner, Clocks, Peripherals};

#[entry]
fn main(p: Peripherals, c: Clocks) {
fn main(p: Peripherals, _c: Clocks) {
// Display the bootloader banner.
show_banner();

Expand Down
21 changes: 8 additions & 13 deletions rust/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,18 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream {
quote!(
#[export_name = "main"]
pub fn main() {
let (p, c) = ::syterkit::allwinner_rt::__rom_init_params();
let (__p, __uart0, __tx, __rx) = ::syterkit::Peripherals::configure_uart0(p);
unsafe { __syterkit_macros__main(__p, c, __uart0, __tx, __rx) }
let (allwinner_rt_p, c) = ::syterkit::allwinner_rt::__rom_init_params();
let (p, uart0, tx, rx) = ::syterkit::Peripherals::configure_uart0(allwinner_rt_p);
let mut serial = ::syterkit::allwinner_hal::uart::Serial::new(uart0, (tx, rx), ::syterkit::allwinner_hal::uart::Config::default(), &c, &p.ccu);
unsafe {
*::syterkit::CONSOLE.lock() = Some(::syterkit::SyterKitConsole { inner: serial })
};
unsafe { __syterkit_macros__main(p, c) }
}
#[allow(non_snake_case)]
#[inline]
#(#attrs)*
#unsafety fn __syterkit_macros__main(
#args,
__uart0: ::syterkit::allwinner_rt::soc::d1::UART0,
__tx: ::syterkit::allwinner_hal::gpio::Function<'static, 'B', 8, 6>,
__rx: ::syterkit::allwinner_hal::gpio::Function<'static, 'B', 9, 6>
) #ret {
let mut __serial = ::syterkit::allwinner_hal::uart::Serial::new(__uart0, (__tx, __rx), ::syterkit::allwinner_hal::uart::Config::default(), &c, &p.ccu);
unsafe {
*::syterkit::CONSOLE.lock() = Some(::syterkit::SyterKitConsole { inner: __serial })
};
#unsafety fn __syterkit_macros__main(#args) #ret {
#(#stmts)*
}
)
Expand Down

0 comments on commit 2f654b5

Please sign in to comment.