Begin work on rust versions of modules

This commit is contained in:
Florian RICHER 2025-02-26 17:08:49 +01:00
parent 1f2cc50f26
commit 91f8ca7f49
23 changed files with 53 additions and 9 deletions

View 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

View 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");
}
}