rust: add `bindings` crate
This crate contains the bindings to the C side of the kernel. Calling C (in general, FFI) is assumed to be unsafe in Rust and, in many cases, this is accurate. For instance, virtually all C functions that take a pointer are unsafe since, typically, it will be dereferenced at some point (and in most cases there is no way for the callee to check its validity beforehand). Since one of the goals of using Rust in the kernel is precisely to avoid unsafe code in "leaf" kernel modules (e.g. drivers), these bindings should not be used directly by them. Instead, these bindings need to be wrapped into safe abstractions. These abstractions provide a safe API that kernel modules can use. In this way, unsafe code in kernel modules is minimized. Reviewed-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org> Co-developed-by: NAlex Gaynor <alex.gaynor@gmail.com> Signed-off-by: NAlex Gaynor <alex.gaynor@gmail.com> Co-developed-by: NFinn Behrens <me@kloenk.de> Signed-off-by: NFinn Behrens <me@kloenk.de> Co-developed-by: NWedson Almeida Filho <wedsonaf@google.com> Signed-off-by: NWedson Almeida Filho <wedsonaf@google.com> Co-developed-by: NSven Van Asbroeck <thesven73@gmail.com> Signed-off-by: NSven Van Asbroeck <thesven73@gmail.com> Co-developed-by: NGary Guo <gary@garyguo.net> Signed-off-by: NGary Guo <gary@garyguo.net> Co-developed-by: NMaciej Falkowski <m.falkowski@samsung.com> Signed-off-by: NMaciej Falkowski <m.falkowski@samsung.com> Co-developed-by: NJiapeng Chong <jiapeng.chong@linux.alibaba.com> Signed-off-by: NJiapeng Chong <jiapeng.chong@linux.alibaba.com> Co-developed-by: NBjörn Roy Baron <bjorn3_gh@protonmail.com> Signed-off-by: NBjörn Roy Baron <bjorn3_gh@protonmail.com> Signed-off-by: NMiguel Ojeda <ojeda@kernel.org>
Showing
rust/bindings/bindings_helper.h
0 → 100644
rust/bindings/lib.rs
0 → 100644
想要评论请 注册 或 登录