Skip to content

Commit eef24ea

Browse files
committed
Add usize param to examples
1 parent bb701e9 commit eef24ea

File tree

6 files changed

+31
-2
lines changed

6 files changed

+31
-2
lines changed

.github/workflows/ci.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ jobs:
153153
# Run
154154
- run: ${{ env.BUILD_DIR }}usr/gen_init_cpio .github/workflows/qemu-initramfs.desc > qemu-initramfs.img
155155

156-
- run: qemu-system-${{ env.QEMU_ARCH }} -kernel ${{ env.BUILD_DIR }}${{ env.IMAGE_PATH }} -initrd qemu-initramfs.img -M ${{ env.QEMU_MACHINE }} -cpu ${{ env.QEMU_CPU }} -smp 2 -nographic -no-reboot -append '${{ env.QEMU_APPEND }} rust_example.my_i32=123321 rust_example.my_str=🦀mod rust_example.my_invbool=y rust_example_2.my_i32=234432' | tee qemu-stdout.log
156+
- run: qemu-system-${{ env.QEMU_ARCH }} -kernel ${{ env.BUILD_DIR }}${{ env.IMAGE_PATH }} -initrd qemu-initramfs.img -M ${{ env.QEMU_MACHINE }} -cpu ${{ env.QEMU_CPU }} -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' | tee qemu-stdout.log
157157

158158
# Check
159159
- run: grep -F '] Rust Example (init)' qemu-stdout.log
@@ -166,6 +166,11 @@ jobs:
166166
- run: "grep -F '] [3] my_i32: 345543' qemu-stdout.log"
167167
- run: "grep -F '] [4] my_i32: 456654' qemu-stdout.log"
168168

169+
- run: "grep -F '] my_usize: 42' qemu-stdout.log"
170+
- run: "grep -F '] [2] my_usize: 42' qemu-stdout.log"
171+
- run: "grep -F '] [3] my_usize: 42' qemu-stdout.log"
172+
- run: "grep -F '] [4] my_usize: 84' qemu-stdout.log"
173+
169174
- run: "grep '\\] my_str: 🦀mod\\s*$' qemu-stdout.log"
170175
- run: "grep '\\] \\[2\\] my_str: default str val\\s*$' qemu-stdout.log"
171176
- run: "grep '\\] \\[3\\] my_str: 🦀mod\\s*$' qemu-stdout.log"

.github/workflows/qemu-init.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
busybox insmod rust_example_3.ko my_i32=345543 my_str=🦀mod
4-
busybox insmod rust_example_4.ko my_i32=456654
4+
busybox insmod rust_example_4.ko my_i32=456654 my_usize=84
55
busybox rmmod rust_example_3.ko
66
busybox rmmod rust_example_4.ko
77

drivers/char/rust_example.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ module! {
3131
permissions: 0o644,
3232
description: b"Example of a string param",
3333
},
34+
my_usize: usize {
35+
default: 42,
36+
permissions: 0o644,
37+
description: b"Example of usize",
38+
},
3439
},
3540
}
3641

@@ -63,6 +68,7 @@ impl KernelModule for RustExample {
6368
" my_str: {}",
6469
core::str::from_utf8(my_str.read(&lock))?
6570
);
71+
println!(" my_usize: {}", my_usize.read(&lock));
6672
}
6773

6874
// Including this large variable on the stack will trigger

drivers/char/rust_example_2.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ module! {
2828
permissions: 0o644,
2929
description: b"Example of a string param",
3030
},
31+
my_usize: usize {
32+
default: 42,
33+
permissions: 0o644,
34+
description: b"Example of usize",
35+
},
3136
},
3237
}
3338

@@ -48,6 +53,7 @@ impl KernelModule for RustExample2 {
4853
"[2] my_str: {}",
4954
core::str::from_utf8(my_str.read(&lock))?
5055
);
56+
println!("[2] my_usize: {}", my_usize.read(&lock));
5157
}
5258

5359
// Including this large variable on the stack will trigger

drivers/char/rust_example_3.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ module! {
2828
permissions: 0o644,
2929
description: b"Example of a string param",
3030
},
31+
my_usize: usize {
32+
default: 42,
33+
permissions: 0o644,
34+
description: b"Example of usize",
35+
},
3136
},
3237
}
3338

@@ -48,6 +53,7 @@ impl KernelModule for RustExample3 {
4853
"[3] my_str: {}",
4954
core::str::from_utf8(my_str.read(&lock))?
5055
);
56+
println!("[3] my_usize: {}", my_usize.read(&lock));
5157
}
5258

5359
// Including this large variable on the stack will trigger

drivers/char/rust_example_4.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ module! {
2828
permissions: 0o644,
2929
description: b"Example of a string param",
3030
},
31+
my_usize: usize {
32+
default: 42,
33+
permissions: 0o644,
34+
description: b"Example of usize",
35+
},
3136
},
3237
}
3338

@@ -48,6 +53,7 @@ impl KernelModule for RustExample4 {
4853
"[4] my_str: {}",
4954
core::str::from_utf8(my_str.read(&lock))?
5055
);
56+
println!("[4] my_usize: {}", my_usize.read(&lock));
5157
}
5258

5359
// Including this large variable on the stack will trigger

0 commit comments

Comments
 (0)