Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array and string params #110

Merged
merged 2 commits into from
Mar 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,11 @@ jobs:
-smp 2 \
-nographic \
-no-reboot \
-append '${{ env.QEMU_APPEND }} rust_example.my_i32=123321 rust_example.my_str=🦀mod rust_example_2.my_i32=234432' \
-append '${{ env.QEMU_APPEND }} \
rust_example.my_i32=123321 \
rust_example.my_str=🦀mod \
rust_example_2.my_i32=234432 \
rust_example_2.my_array=1,2,3' \
| sed s:$'\r'$:: \
| tee qemu-stdout.log

Expand All @@ -191,6 +195,11 @@ jobs:
grep '] \[3] my_str: 🦀mod$' qemu-stdout.log
grep '] \[4] my_str: default str val$' qemu-stdout.log

grep '] my_array: \[0, 1]$' qemu-stdout.log
grep '] \[2] my_array: \[1, 2, 3]$' qemu-stdout.log
grep '] \[3] my_array: \[0, 1]$' qemu-stdout.log
grep '] \[4] my_array: \[1, 2, 3]$' qemu-stdout.log

grep '] \[3] Rust Example (exit)$' qemu-stdout.log
grep '] \[4] Rust Example (exit)$' qemu-stdout.log

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/qemu-init.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

busybox insmod rust_example_3.ko my_i32=345543 my_str=🦀mod
busybox insmod rust_example_4.ko my_i32=456654 my_usize=84
busybox insmod rust_example_4.ko my_i32=456654 my_usize=84 my_array=1,2,3
busybox rmmod rust_example_3.ko
busybox rmmod rust_example_4.ko

Expand Down
6 changes: 6 additions & 0 deletions drivers/char/rust_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ module! {
permissions: 0o644,
description: b"Example of usize",
},
my_array: ArrayParam<i32, 3> {
default: [0, 1],
permissions: 0,
description: b"Example of array",
},
},
}

Expand Down Expand Up @@ -79,6 +84,7 @@ impl KernelModule for RustExample {
core::str::from_utf8(my_str.read(&lock))?
);
println!(" my_usize: {}", my_usize.read(&lock));
println!(" my_array: {:?}", my_array.read());
}

// Test mutexes.
Expand Down
6 changes: 6 additions & 0 deletions drivers/char/rust_example_2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ module! {
permissions: 0o644,
description: b"Example of usize",
},
my_array: ArrayParam<i32, 3> {
default: [0, 1],
permissions: 0,
description: b"Example of array",
},
},
}

Expand All @@ -54,6 +59,7 @@ impl KernelModule for RustExample2 {
core::str::from_utf8(my_str.read(&lock))?
);
println!("[2] my_usize: {}", my_usize.read(&lock));
println!("[2] my_array: {:?}", my_array.read());
}

// Including this large variable on the stack will trigger
Expand Down
6 changes: 6 additions & 0 deletions drivers/char/rust_example_3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ module! {
permissions: 0o644,
description: b"Example of usize",
},
my_array: ArrayParam<i32, 3> {
default: [0, 1],
permissions: 0,
description: b"Example of array",
},
},
}

Expand All @@ -54,6 +59,7 @@ impl KernelModule for RustExample3 {
core::str::from_utf8(my_str.read(&lock))?
);
println!("[3] my_usize: {}", my_usize.read(&lock));
println!("[3] my_array: {:?}", my_array.read());
}

// Including this large variable on the stack will trigger
Expand Down
6 changes: 6 additions & 0 deletions drivers/char/rust_example_4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ module! {
permissions: 0o644,
description: b"Example of usize",
},
my_array: ArrayParam<i32, 3> {
default: [0, 1],
permissions: 0,
description: b"Example of array",
},
},
}

Expand All @@ -54,6 +59,7 @@ impl KernelModule for RustExample4 {
core::str::from_utf8(my_str.read(&lock))?
);
println!("[4] my_usize: {}", my_usize.read(&lock));
println!("[4] my_array: {:?}", my_array.read());
}

// Including this large variable on the stack will trigger
Expand Down
5 changes: 4 additions & 1 deletion rust/kernel/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//! do so first instead of bypassing this crate.

#![no_std]
#![feature(allocator_api, alloc_error_handler)]
#![feature(allocator_api, alloc_error_handler, const_fn, const_mut_refs)]
#![deny(clippy::complexity)]
#![deny(clippy::correctness)]
#![deny(clippy::perf)]
Expand All @@ -36,7 +36,10 @@ pub mod chrdev;
mod error;
pub mod file_operations;
pub mod miscdev;

#[doc(hidden)]
pub mod module_param;

pub mod prelude;
pub mod printk;
pub mod random;
Expand Down
Loading