Skip to content
This repository was archived by the owner on Mar 7, 2021. It is now read-only.

Refs #150 -- document println #166

Merged
merged 3 commits into from
Sep 2, 2019
Merged
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
7 changes: 7 additions & 0 deletions src/printk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ extern "C" {
fn printk_helper(s: *const u8, len: c_int) -> c_int;
}

#[doc(hidden)]
pub fn printk(s: &[u8]) {
// TODO: I believe printk never fails
unsafe { printk_helper(s.as_ptr(), s.len() as c_int) };
Expand All @@ -17,6 +18,7 @@ pub fn printk(s: &[u8]) {
// From kernel/print/printk.c
const LOG_LINE_MAX: usize = 1024 - 32;

#[doc(hidden)]
pub struct LogLineWriter {
data: [u8; LOG_LINE_MAX],
pos: usize,
Expand Down Expand Up @@ -45,6 +47,11 @@ impl fmt::Write for LogLineWriter {
}
}

/// [`println!`] functions the same as it does in `std`, except instead of
/// printing to `stdout`, it writes to the kernel console at the `KERN_INFO`
/// level.
///
/// [`println!`]: https://doc.rust-lang.org/stable/std/macro.println.html
#[macro_export]
macro_rules! println {
() => ({
Expand Down