Lines Matching +full:core +full:- +full:module
1 // SPDX-License-Identifier: GPL-2.0
9 //! modules written in Rust) depends on [`core`] and this crate.
16 // Please see https://github.com/Rust-for-Linux/linux/issues/2 for details on
59 // Allow proc-macros to refer to `::kernel` inside the `kernel` crate (this crate).
153 /// The top level entrypoint to implementing a kernel module.
156 pub trait Module: Sized + Sync + Send { interface
157 /// Called at module initialization time.
159 /// Use this method to perform whatever setup or registration your module
163 fn init(module: &'static ThisModule) -> error::Result<Self>; in init()
166 /// A module that is pinned and initialised in-place.
168 /// Creates an initialiser for the module.
170 /// It is called when the module is loaded.
171 fn init(module: &'static ThisModule) -> impl pin_init::PinInit<Self, error::Error>; in init()
174 impl<T: Module> InPlaceModule for T {
175 fn init(module: &'static ThisModule) -> impl pin_init::PinInit<Self, error::Error> { in init()
177 let m = <Self as Module>::init(module)?; in init()
189 /// Metadata attached to a [`Module`] or [`InPlaceModule`].
191 /// The name of the module as specified in the `module!` macro.
198 pub struct ThisModule(*mut bindings::module);
200 // SAFETY: `THIS_MODULE` may be used from all threads within a module.
209 pub const unsafe fn from_ptr(ptr: *mut bindings::module) -> ThisModule { in from_ptr()
213 /// Access the raw pointer for this module.
216 pub const fn as_ptr(&self) -> *mut bindings::module { in as_ptr() argument
223 fn panic(info: &core::panic::PanicInfo<'_>) -> ! { in panic()
255 /// // in-bounds of the same allocation as `b_ptr`.
257 /// assert!(core::ptr::eq(&test, test_alias));
262 let offset: usize = ::core::mem::offset_of!($Container, $($fields)*);
279 ::core::concat!($($asm),*)
292 ::core::arch::asm!( $($asm)*, options(att_syntax), $($rest)* )
300 // For non-x86 arches we just pass through to `asm!`.
305 ::core::arch::asm!( $($asm)*, $($rest)* )
313 /// [`Location`]: core::panic::Location
322 /// let caller = core::panic::Location::caller();
325 /// // - A path like "rust/kernel/example.rs" if `file_as_c_str()` is available.
326 /// // - "<Location::file_as_c_str() not supported>" otherwise.
340 pub fn file_from_location<'a>(loc: &'a core::panic::Location<'a>) -> &'a core::ffi::CStr { in file_from_location()