Skip to content

re-applying prev changes #4

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

Closed
wants to merge 4 commits into from
Closed
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
16 changes: 11 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ jobs:
timeout-minutes: 20

strategy:
fail-fast: false
matrix:
arch: [x86_64, arm64]
toolchain: [gcc, clang, llvm]
config: [debug, release]
rustc: [2021-01-02]
rustc: [2021-01-21]
output: [src] # [src, build]
install: [rustup] # [rustup, standalone]
sysroot: [common] # [common, custom]
Expand All @@ -27,23 +28,23 @@ jobs:
- arch: x86_64
toolchain: gcc
config: debug
rustc: 2021-01-09
rustc: 2021-01-21
output: build
install: rustup
sysroot: custom

- arch: arm64
toolchain: clang
config: release
rustc: 2021-01-16
rustc: 2021-01-21
output: build
install: standalone
sysroot: common

- arch: x86_64
toolchain: llvm
config: debug
rustc: 2021-01-19
rustc: 2021-01-21
output: build
install: standalone
sysroot: custom
Expand Down Expand Up @@ -156,7 +157,7 @@ jobs:
# Run
- run: ${{ env.BUILD_DIR }}usr/gen_init_cpio .github/workflows/qemu-initramfs.desc > qemu-initramfs.img

- 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_2.my_i32=234432' | tee qemu-stdout.log
- 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

# Check
- run: grep -F '] Rust Example (init)' qemu-stdout.log
Expand All @@ -169,6 +170,11 @@ jobs:
- run: "grep -F '] [3] my_i32: 345543' qemu-stdout.log"
- run: "grep -F '] [4] my_i32: 456654' qemu-stdout.log"

- run: "grep '\\] my_str: 🦀mod\\s*$' qemu-stdout.log"
- run: "grep '\\] \\[2\\] my_str: default str val\\s*$' qemu-stdout.log"
- run: "grep '\\] \\[3\\] my_str: 🦀mod\\s*$' qemu-stdout.log"
- run: "grep '\\] \\[4\\] my_str: default str val\\s*$' qemu-stdout.log"

- run: grep -F '] [3] Rust Example (exit)' qemu-stdout.log
- run: grep -F '] [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,6 +1,6 @@
#!/bin/sh

busybox insmod rust_example_3.ko my_i32=345543
busybox insmod rust_example_3.ko my_i32=345543 my_str=🦀mod
busybox insmod rust_example_4.ko my_i32=456654
busybox rmmod rust_example_3.ko
busybox rmmod rust_example_4.ko
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
*.o
*.o.*
*.patch
*.rlib
*.rmeta
*.s
*.so
*.so.dbg
Expand Down
2 changes: 1 addition & 1 deletion Documentation/rust/quick-start.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ rustc
*****

A recent *nightly* Rust toolchain (with, at least, ``rustc``) is required,
e.g. ``nightly-2021-01-02``. Our goal is to use a stable toolchain as soon
e.g. ``nightly-2021-01-21``. Our goal is to use a stable toolchain as soon
as possible, but for the moment we depend on a handful of nightly features.

If you are using ``rustup``, run::
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ KBUILD_CFLAGS := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
-Werror=return-type -Wno-format-security \
-std=gnu89
KBUILD_CPPFLAGS := -D__KERNEL__
KBUILD_RUSTCFLAGS := --emit=dep-info,obj,link -Zbinary_dep_depinfo=y \
KBUILD_RUSTCFLAGS := --emit=dep-info,obj,metadata -Zbinary_dep_depinfo=y \
-Cpanic=abort -Cembed-bitcode=n -Clto=n -Crpath=n \
-Cforce-unwind-tables=n -Ccodegen-units=1 \
-Zsymbol-mangling-version=v0
Expand Down Expand Up @@ -1874,7 +1874,7 @@ clean: $(clean-dirs)
$(call cmd,rmfiles)
@find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \
\( -name '*.[aios]' -o -name '*.ko' -o -name '.*.cmd' \
-o -name '*.rlib' \
-o -name '*.rmeta' \
-o -name '*.ko.*' \
-o -name '*.dtb' -o -name '*.dtb.S' -o -name '*.dt.yaml' \
-o -name '*.dwo' -o -name '*.lst' \
Expand Down
9 changes: 9 additions & 0 deletions drivers/char/rust_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ module! {
permissions: 0o644,
description: b"Example of i32",
},
my_str: &str {
default: "default str val",
permissions: 0o644,
description: b"Example of a string param",
},
},
}

Expand All @@ -51,6 +56,10 @@ impl KernelModule for RustExample {
println!("Parameters:");
println!(" my_bool: {}", my_bool.read());
println!(" my_i32: {}", my_i32.read());
println!(
" my_str: {}",
my_str.read().expect("Expected valid UTF8 parameter")
);

Ok(RustExample {
message: "on the heap!".to_owned(),
Expand Down
9 changes: 9 additions & 0 deletions drivers/char/rust_example_2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ module! {
permissions: 0o644,
description: b"Example of i32",
},
my_str: &str {
default: "default str val",
permissions: 0o644,
description: b"Example of a string param",
},
},
}

Expand All @@ -36,6 +41,10 @@ impl KernelModule for RustExample2 {
println!("[2] Parameters:");
println!("[2] my_bool: {}", my_bool.read());
println!("[2] my_i32: {}", my_i32.read());
println!(
"[2] my_str: {}",
my_str.read().expect("Expected valid UTF8 parameter")
);
Ok(RustExample2 {
message: "on the heap!".to_owned(),
})
Expand Down
10 changes: 10 additions & 0 deletions drivers/char/rust_example_3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ module! {
permissions: 0o644,
description: b"Example of i32",
},
my_str: &str {
default: "default str val",
permissions: 0o644,
description: b"Example of a string param",
},
},
}

Expand All @@ -36,6 +41,11 @@ impl KernelModule for RustExample3 {
println!("[3] Parameters:");
println!("[3] my_bool: {}", my_bool.read());
println!("[3] my_i32: {}", my_i32.read());
println!(
"[3] my_str: {}",
my_str.read().expect("Expected valid UTF8 parameter")
);

Ok(RustExample3 {
message: "on the heap!".to_owned(),
})
Expand Down
9 changes: 9 additions & 0 deletions drivers/char/rust_example_4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ module! {
permissions: 0o644,
description: b"Example of i32",
},
my_str: &str {
default: "default str val",
permissions: 0o644,
description: b"Example of a string param",
},
},
}

Expand All @@ -36,6 +41,10 @@ impl KernelModule for RustExample4 {
println!("[4] Parameters:");
println!("[4] my_bool: {}", my_bool.read());
println!("[4] my_i32: {}", my_i32.read());
println!(
"[4] my_str: {}",
my_str.read().expect("Expected valid UTF8 parameter")
);
Ok(RustExample4 {
message: "on the heap!".to_owned(),
})
Expand Down
2 changes: 1 addition & 1 deletion rust/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ $(objtree)/rust/exports_kernel_generated.h: $(objtree)/rust/kernel.o FORCE

quiet_cmd_rustc_procmacro = RUSTC P $@
cmd_rustc_procmacro = \
$(RUSTC) $(rustc_flags) --edition 2018 --extern proc_macro \
$(RUSTC) $(rustc_flags) --emit=dep-info,link --edition 2018 --extern proc_macro \
--crate-type proc-macro --out-dir $(objtree)/rust/ \
--crate-name $(patsubst lib%.so,%,$(notdir $@)) $<; \
mv $(objtree)/rust/$(patsubst lib%.so,%,$(notdir $@)).d $(depfile); \
Expand Down
Loading