Skip to content

Commit 0d1124d

Browse files
Improve logging
1 parent e8dbb5a commit 0d1124d

4 files changed

Lines changed: 20 additions & 7 deletions

File tree

dsp-to-serial/compile.sh

100644100755
File mode changed.

dsp-to-serial/src/communication_handler.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,28 @@
1-
use std::{ffi::c_void, time::Duration};
1+
use std::{ffi::c_void, fmt::Debug, time::Duration};
22

33
use nix::libc::{msync, MS_INVALIDATE};
44

55
use crate::{kbuf::UserWrapperBufData, msgbox::MsgboxEndpoint, sharespace::Sharespace};
66

77

88
#[repr(C)]
9-
#[derive(Default, Debug)]
9+
#[derive(Default)]
1010
pub struct MsgHead {
1111
pub read_addr: u32,
1212
pub write_addr: u32,
1313
pub init_state: u32,
1414
}
1515

16+
impl Debug for MsgHead {
17+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
18+
write!(
19+
f,
20+
"MsgHead {{ read_addr: 0x{:x}, write_addr: 0x{:x}, init_state: 0x{:x} }}",
21+
self.read_addr, self.write_addr, self.init_state
22+
)
23+
}
24+
}
25+
1626
impl MsgHead {
1727
fn from_bytes(bytes: &[u8; 12]) -> Self {
1828
let read_addr = u32::from_le_bytes(bytes[0..4].try_into().unwrap());
@@ -83,7 +93,9 @@ impl CommunicationHandler {
8393
head.write_addr = self.user_buf.buf.pa;
8494

8595
self.sharespace.write_buffer.as_mut()[SHARE_SPACE_HEAD_OFFSET..]
86-
.copy_from_slice(&head.to_bytes())
96+
.copy_from_slice(&head.to_bytes());
97+
98+
println!("Wrote ARM head to sharespace mmap at offset 0x{:x}: {:?}", SHARE_SPACE_HEAD_OFFSET, head);
8799
}
88100

89101
// pVirArmBuf

dsp-to-serial/src/kbuf.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ pub fn kbuf_use_new_buf(arm_write_addr: u32) -> Result<UserWrapperBufData, Appli
5858
let mgr_fd = open("/dev/kbuf-mgr-0", OFlag::O_RDWR, Mode::empty())?;
5959
let mgr_fd_raw = mgr_fd.as_raw_fd();
6060

61-
println!("{:#?}", &buf_data);
62-
6361
unsafe { wrap_ioctl_negative_invalid(kbuf_mgr_dev_create_buf(mgr_fd_raw, &mut buf_data))? };
6462

63+
println!("Created kbuf at physical address 0x{:x}", buf_data.pa);
64+
6565
let map_dev_path = format!("/dev/kbuf-map-{}-{}", buf_data.minor, u8_slice_to_string(&buf_data.name));
6666

6767
println!("Mapping kbuf device at path: {}", map_dev_path);

dsp-to-serial/src/sharespace.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ pub struct DspSharespace {
3333
pub debug_msg: DebugMessage,
3434
}
3535

36+
#[derive(Debug)]
3637
enum ChooseShareSpace {
3738
ChooseDspWriteSpace = 0,
3839
ChooseArmWriteSpace = 1,
@@ -49,13 +50,13 @@ fn choose_sharespace(
4950
let raw_fd = fd.as_raw_fd();
5051
wrap_ioctl_negative_invalid(unsafe { read_debug_message(raw_fd, msg) })?;
5152

52-
println!("Before choose: {:#?}", msg);
53-
5453
msg.mmap_phy_addr = match choose {
5554
ChooseShareSpace::ChooseDspWriteSpace => msg.dsp_write_addr,
5655
ChooseShareSpace::ChooseArmWriteSpace => msg.arm_write_addr,
5756
};
5857

58+
println!("Init sharespace {:?} to 0x{:x}", choose, msg.mmap_phy_addr);
59+
5960
wrap_ioctl_negative_invalid(unsafe { write_debug_message(raw_fd, msg) })?;
6061

6162
Ok(())

0 commit comments

Comments
 (0)