fw_dbg.rs0.00%
1
// Copyright 2026 Google LLC2
//3
// Licensed under the Apache License, Version 2.0 (the "License");4
// you may not use this file except in compliance with the License.5
// You may obtain a copy of the License at6
//7
// https://www.apache.org/licenses/LICENSE-2.08
//9
// Unless required by applicable law or agreed to in writing, software10
// distributed under the License is distributed on an "AS IS" BASIS,11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12
// See the License for the specific language governing permissions and13
// limitations under the License.14
15
use parking_lot::Mutex;16
17
use crate::device::{MmioDev, Pause, Result};18
use crate::mem;19
use crate::mem::emulated::{Action, Mmio};20
21
#[derive(Debug, Default)]22
pub struct FwDbg {23
buffer: Mutex<Vec<u8>>,24
}25
26
impl FwDbg {27
pub fn new() -> Self {28
FwDbg::default()29
}30
}31
32
impl Mmio for FwDbg {33
fn size(&self) -> u64 {34
135
}36
37
fn read(&self, _offset: u64, _size: u8) -> mem::Result<u64> {38
Ok(0xe9)39
}40
41
fn write(&self, _offset: u64, _size: u8, val: u64) -> mem::Result<Action> {42
let mut buffer = self.buffer.lock();43
if val as u8 == b'\n' {44
log::debug!("{}", String::from_utf8_lossy(&buffer));45
buffer.clear();46
} else {47
buffer.push(val as u8);48
}49
Ok(Action::None)50
}51
}52
53
impl Pause for FwDbg {54
fn pause(&self) -> Result<()> {55
Ok(())56
}57
58
fn resume(&self) -> Result<()> {59
Ok(())60
}61
}62
63
impl MmioDev for FwDbg {}64