Skip to content

Commit bb9de70

Browse files
committed
[test] kernel/protocols: Add log buffer as OCP source
Introduce a fake log buffer struct and implement on top of it the new trait. This will be dropped once the real log buffer will be introduced. Signed-off-by: Nicola Ramacciotti <niko.ramak@gmail.com>
1 parent b1f4329 commit bb9de70

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

kernel/src/protocols/ocp.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ use zerocopy::{Immutable, IntoBytes};
1919
const OCP_SOURCE_NAME_LEN: usize = 124;
2020
const OCP_SOURCE_ENTRY_SIZE: usize = 128;
2121

22-
const OCP_SOURCES_LEN: usize = 0;
22+
const OCP_SOURCES_LEN: usize = 1;
2323

24-
static OCP_SOURCES: [&dyn OcpSourceOperations; OCP_SOURCES_LEN] = [];
24+
static OCP_SOURCES: [&dyn OcpSourceOperations; OCP_SOURCES_LEN] = [&LOG_BUFFER];
2525

2626
// OCP protocol services
2727
const SVSM_OCP_LIST: u32 = 0;
@@ -34,6 +34,26 @@ const LOW_32_BITS: u64 = 0xffff_ffff;
3434
pub const OBSERVABILITY_CONFIGURATION_PROTOCOL_VERSION_MIN: u32 = 1;
3535
pub const OBSERVABILITY_CONFIGURATION_PROTOCOL_VERSION_MAX: u32 = 1;
3636

37+
struct LogBuffer {
38+
ocp_source_entry: OcpSource,
39+
}
40+
41+
impl LogBuffer {
42+
const fn new(name: &str, writable: bool) -> Self {
43+
Self {
44+
ocp_source_entry: OcpSource::new(writable, name),
45+
}
46+
}
47+
}
48+
49+
impl OcpSourceOperations for LogBuffer {
50+
fn get_source_entry(&self) -> &OcpSource {
51+
&self.ocp_source_entry
52+
}
53+
}
54+
55+
static LOG_BUFFER: LogBuffer = LogBuffer::new("LogBuffer", false);
56+
3757
#[bitfield(u32)]
3858
#[derive(IntoBytes, Immutable)]
3959
struct OcpSourceFlags {

0 commit comments

Comments
 (0)