diff options
Diffstat (limited to 'rsnix/src/klog.rs')
| -rw-r--r-- | rsnix/src/klog.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/rsnix/src/klog.rs b/rsnix/src/klog.rs index 5da5094..2e1fc82 100644 --- a/rsnix/src/klog.rs +++ b/rsnix/src/klog.rs | |||
| @@ -21,7 +21,11 @@ extern crate alloc; | |||
| 21 | use alloc::string::String; | 21 | use alloc::string::String; |
| 22 | 22 | ||
| 23 | pub const MAX_LINES: usize = 128; | 23 | pub const MAX_LINES: usize = 128; |
| 24 | pub const MAX_LINE: usize = 128; | 24 | /// Max bytes stored per line. Wide enough that no real line truncates |
| 25 | /// at any plausible terminal width (a 240-col 4K framebuffer row is | ||
| 26 | /// still under this) — long lines flow in full and the terminal wraps | ||
| 27 | /// them at the screen edge instead of cutting them off. | ||
| 28 | pub const MAX_LINE: usize = 512; | ||
| 25 | 29 | ||
| 26 | struct Ring { | 30 | struct Ring { |
| 27 | /// Sequence counter for the next line to be appended (total ever). | 31 | /// Sequence counter for the next line to be appended (total ever). |
| @@ -36,7 +40,7 @@ struct Ring { | |||
| 36 | /// the timer is running (early-boot PIT reads are uninitialised). | 40 | /// the timer is running (early-boot PIT reads are uninitialised). |
| 37 | last_ms: u64, | 41 | last_ms: u64, |
| 38 | ms: [u64; MAX_LINES], | 42 | ms: [u64; MAX_LINES], |
| 39 | lens: [u8; MAX_LINES], | 43 | lens: [u16; MAX_LINES], |
| 40 | bytes: [[u8; MAX_LINE]; MAX_LINES], | 44 | bytes: [[u8; MAX_LINE]; MAX_LINES], |
| 41 | } | 45 | } |
| 42 | 46 | ||
| @@ -74,7 +78,7 @@ pub fn append(line: &str, mut ms: u64) { | |||
| 74 | } | 78 | } |
| 75 | r.ms[r.next] = ms; | 79 | r.ms[r.next] = ms; |
| 76 | r.bytes[r.next][..n].copy_from_slice(&b[..n]); | 80 | r.bytes[r.next][..n].copy_from_slice(&b[..n]); |
| 77 | r.lens[r.next] = n as u8; | 81 | r.lens[r.next] = n as u16; |
| 78 | r.next = (r.next + 1) % MAX_LINES; | 82 | r.next = (r.next + 1) % MAX_LINES; |
| 79 | r.seq += 1; | 83 | r.seq += 1; |
| 80 | } | 84 | } |
