Begin work on rust versions of modules
This commit is contained in:
parent
1f2cc50f26
commit
91f8ca7f49
23 changed files with 53 additions and 9 deletions
10
lang_rust/01_basic_module/Makefile
Normal file
10
lang_rust/01_basic_module/Makefile
Normal file
|
@ -0,0 +1,10 @@
|
|||
obj-m += test_module.o
|
||||
|
||||
all:
|
||||
make -C $(LINUX_MODULES_FOLDER)/build M=$(PWD) LLVM=1 modules
|
||||
|
||||
clean:
|
||||
make -C $(LINUX_MODULES_FOLDER)/build M=$(PWD) LLVM=1 clean
|
||||
|
||||
rust-analyzer:
|
||||
make -C $(LINUX_MODULES_FOLDER)/build M=$(PWD) LLVM=1 rust-analyzer
|
25
lang_rust/01_basic_module/test_module.rs
Normal file
25
lang_rust/01_basic_module/test_module.rs
Normal file
|
@ -0,0 +1,25 @@
|
|||
use kernel::prelude::*;
|
||||
|
||||
module! {
|
||||
type: RustOutOfTree,
|
||||
name: "test_module",
|
||||
author: "Florian RICHER <florian.richer@protonmail.com>",
|
||||
description: "Un module noyau qui affiche un message",
|
||||
license: "GPL",
|
||||
}
|
||||
|
||||
struct RustOutOfTree;
|
||||
|
||||
impl kernel::Module for RustOutOfTree {
|
||||
fn init(_module: &'static ThisModule) -> Result<Self> {
|
||||
pr_info!("Bonjour! Le module est chargé.\n");
|
||||
|
||||
Ok(RustOutOfTree)
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for RustOutOfTree {
|
||||
fn drop(&mut self) {
|
||||
pr_info!("Au revoir! Le module est déchargé.\n");
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue