uefi_specs/hyperv/advanced_logger.rs
1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4//! Types and constants defined by Project Mu's Advanced Logger package,
5//! used in the Hyper-V UEFI firmware.
6
7#![warn(missing_docs)]
8
9use crate::uefi::time::EFI_TIME;
10use zerocopy::FromBytes;
11use zerocopy::Immutable;
12use zerocopy::KnownLayout;
13
14/// Phase value for SEC
15pub const SEC_PHASE: u16 = 0x0001;
16
17/// Phase value for PEI CORE
18pub const PEI_CORE_PHASE: u16 = 0x0002;
19
20/// Phase value for PEI64
21pub const PEI64_PHASE: u16 = 0x0003;
22
23/// Phase value for DXE
24pub const DXE_PHASE: u16 = 0x0004;
25
26/// Phase value for RUNTIME
27pub const RUNTIME_PHASE: u16 = 0x0005;
28
29/// Phase value for MM CORE
30pub const MM_CORE_PHASE: u16 = 0x0006;
31
32/// Phase value for MM
33pub const MM_PHASE: u16 = 0x0007;
34
35/// Phase value for SMM CORE
36pub const SMM_CORE_PHASE: u16 = 0x0008;
37
38/// Maps phase values to their descriptive names
39pub const PHASE_NAMES: &[(u16, &str)] = &[
40 (SEC_PHASE, "SEC"),
41 (PEI_CORE_PHASE, "PEI_CORE"),
42 (PEI64_PHASE, "PEI64"),
43 (DXE_PHASE, "DXE"),
44 (RUNTIME_PHASE, "RUNTIME"),
45 (MM_CORE_PHASE, "MM_CORE"),
46 (MM_PHASE, "MM"),
47 (SMM_CORE_PHASE, "SMM_CORE"),
48];
49
50/// Advanced Logger Info signature
51pub const SIG_HEADER: [u8; 4] = *b"ALOG";
52
53/// Advanced Logger Entry signature
54pub const SIG_ENTRY: [u8; 4] = *b"ALM2";
55
56/// UEFI Advanced Logger Info Header, which is shared
57/// with the Advanced Logger Package in UEFI. The entries
58/// live right after.
59#[repr(C)]
60#[derive(Debug, Copy, Clone, FromBytes, Immutable, KnownLayout)]
61pub struct AdvancedLoggerInfo {
62 /// Signature 'ALOG'
63 pub signature: u32,
64 /// Current Version
65 pub version: u16,
66 /// Reserved for future
67 pub reserved: [u16; 3],
68 /// Offset from LoggerInfo to start of log
69 pub log_buffer_offset: u32,
70 /// Reserved field
71 pub reserved4: u32,
72 /// Offset from LoggerInfo to where to store next log entry
73 pub log_current_offset: u32,
74 /// Number of bytes of messages missed
75 pub discarded_size: u32,
76 /// Size of allocated buffer
77 pub log_buffer_size: u32,
78 /// Log in permanent RAM
79 pub in_permanent_ram: u8,
80 /// After ExitBootServices
81 pub at_runtime: u8,
82 /// After VirtualAddressChange
83 pub gone_virtual: u8,
84 /// HdwPort initialized
85 pub hdw_port_initialized: u8,
86 /// HdwPort is Disabled
87 pub hdw_port_disabled: u8,
88 /// Reserved field
89 pub reserved2: [u8; 3],
90 /// Ticks per second for log timing
91 pub timer_frequency: u64,
92 /// Ticks when Time Acquired
93 pub ticks_at_time: u64,
94 /// Uefi Time Field
95 pub time: EFI_TIME,
96 /// Logging level to be printed at hw port
97 pub hw_print_level: u32,
98 /// Reserved field
99 pub reserved3: u32,
100}
101
102/// UEFI Advanced Logger Entry, which is shared with the
103/// Advanced Logger Package in UEFI. The messages live
104/// right after.
105#[repr(C, packed)]
106#[derive(Debug, Copy, Clone, FromBytes, Immutable, KnownLayout)]
107pub struct AdvancedLoggerMessageEntryV2 {
108 /// Signature 'ALM2'
109 pub signature: u32,
110 /// Major version of the advanced logger message structure.
111 pub major_version: u8,
112 /// Minor version of the advanced logger message structure.
113 pub minor_version: u8,
114 /// Debug level
115 pub debug_level: u32,
116 /// Time stamp
117 pub time_stamp: u64,
118 /// Boot phase that produced this message entry
119 pub phase: u16,
120 /// Number of bytes in the Message
121 pub message_len: u16,
122 /// Offset of the message from the start of the structure.
123 pub message_offset: u16,
124 // Rust prevents C flexible array members, but "message_text: [u8; _]" would be here
125}