1use bitfield_struct::bitfield;
7use guid::Guid;
8use zerocopy::FromBytes;
9use zerocopy::Immutable;
10use zerocopy::IntoBytes;
11use zerocopy::KnownLayout;
12use zerocopy::Unaligned;
13
14pub const CRASHDUMP_GUID: Guid = guid::guid!("427b03e7-4ceb-4286-b5fc-486f4a1dd439");
15
16pub const MAX_DUMP_PAYLOAD_SIZE: usize = 16 * 1024;
19
20#[bitfield(u64)]
22#[derive(IntoBytes, FromBytes, Immutable, KnownLayout, PartialEq, Eq)]
23pub struct Capabilities {
24 pub windows_config_v1: bool,
25 pub linux_config_v1: bool,
26 #[bits(62)]
27 pub reserved: u64,
28}
29
30open_enum::open_enum! {
31 #[derive(IntoBytes, FromBytes, Immutable, KnownLayout)]
33 pub enum DumpType: u32 {
34 NONE = 0x00000000,
35 ELF = 0x00000001,
36 KDUMP = 0x00000002,
37 }
38}
39
40#[derive(Debug, Copy, Clone, PartialEq, Eq, IntoBytes, FromBytes, Immutable, KnownLayout)]
42#[repr(C, packed)]
43pub struct ConfigV1 {
44 pub max_dump_size: u64,
45 pub dump_type: DumpType,
46}
47
48#[derive(Debug, Copy, Clone, PartialEq, Eq, IntoBytes, FromBytes, Immutable, KnownLayout)]
50#[repr(C, packed)]
51pub struct CompletionInfoV1 {
52 pub major_version: u32,
53 pub minor_version: u32,
54 pub version_banner: [u8; 256],
55 pub vtl: u8,
56}
57
58open_enum::open_enum! {
64 #[derive(IntoBytes, FromBytes, Immutable, KnownLayout)]
66 pub enum MessageType : u64 {
67 INVALID = 0, REQUEST_GET_CAPABILITIES_V1 = 0x00000001,
71 REQUEST_GET_WINDOWS_DUMP_CONFIG_V1 = 0x00000002,
72 REQUEST_WINDOWS_DUMP_START_V1 = 0x00000003,
73 REQUEST_WINDOWS_DUMP_WRITE_V1 = 0x00000004,
74 REQUEST_WINDOWS_DUMP_COMPLETE_V1 = 0x00000005,
75 REQUEST_GET_NIX_DUMP_CONFIG_V1 = 0x00000102,
76 REQUEST_NIX_DUMP_START_V1 = 0x00000103,
77 REQUEST_NIX_DUMP_WRITE_V1 = 0x00000104,
78 REQUEST_NIX_DUMP_COMPLETE_V1 = 0x00000105,
79
80 RESPONSE_GET_CAPABILITIES_V1 = 0x00010001,
82 RESPONSE_GET_WINDOWS_DUMP_CONFIG_V1 = 0x00010002,
83 RESPONSE_WINDOWS_DUMP_START_V1 = 0x00010003,
84 RESPONSE_WINDOWS_DUMP_WRITE_V1 = 0x00010004,
85 RESPONSE_WINDOWS_DUMP_COMPLETE_V1 = 0x00010005,
86 RESPONSE_GET_NIX_DUMP_CONFIG_V1 = 0x00010102,
87 RESPONSE_NIX_DUMP_START_V1 = 0x00010103,
88 RESPONSE_NIX_DUMP_WRITE_V1 = 0x00010104,
89 RESPONSE_NIX_DUMP_COMPLETE_V1 = 0x00010105,
90 }
91}
92
93#[derive(Debug, Copy, Clone, PartialEq, Eq, IntoBytes, FromBytes, Immutable, KnownLayout)]
95#[repr(C, packed)]
96pub struct Header {
97 pub activity_id: Guid,
99 pub message_type: MessageType,
100}
101
102#[derive(Debug, Copy, Clone, PartialEq, Eq, IntoBytes, FromBytes, Immutable, KnownLayout)]
104#[repr(C, packed)]
105pub struct DumpCapabilitiesRequestV1 {
106 pub header: Header,
107}
108
109#[derive(Debug, Copy, Clone, PartialEq, Eq, IntoBytes, FromBytes, Immutable, KnownLayout)]
111#[repr(C, packed)]
112pub struct DumpCapabilitiesResponseV1 {
113 pub header: Header,
114 pub capabilities: Capabilities,
115}
116
117#[derive(Debug, Copy, Clone, PartialEq, Eq, IntoBytes, FromBytes, Immutable, KnownLayout)]
119#[repr(C, packed)]
120pub struct DumpConfigRequestV1 {
121 pub header: Header,
122}
123
124#[derive(Debug, Copy, Clone, PartialEq, Eq, IntoBytes, FromBytes, Immutable, KnownLayout)]
126#[repr(C, packed)]
127pub struct DumpConfigResponseV1 {
128 pub header: Header,
129 pub config: ConfigV1,
130}
131
132#[derive(Debug, Copy, Clone, PartialEq, Eq, IntoBytes, FromBytes, Immutable, KnownLayout)]
134#[repr(C, packed)]
135pub struct DumpStartRequestV1 {
136 pub header: Header,
137}
138
139#[derive(Debug, Copy, Clone, PartialEq, Eq, IntoBytes, FromBytes, Immutable, KnownLayout)]
141#[repr(C, packed)]
142pub struct DumpStartResponseV1 {
143 pub header: Header,
144 pub status: i32,
146}
147
148#[derive(
151 Debug, Copy, Clone, PartialEq, Eq, IntoBytes, FromBytes, Immutable, KnownLayout, Unaligned,
152)]
153#[repr(C, packed)]
154pub struct DumpWriteRequestV1 {
155 pub header: Header,
156 pub offset: u64,
157 pub size: u32,
158}
159
160#[derive(Debug, Copy, Clone, PartialEq, Eq, IntoBytes, FromBytes, Immutable, KnownLayout)]
163#[repr(C, packed)]
164pub struct DumpWriteResponseV1 {
165 pub header: Header,
166 pub status: i32,
168}
169
170#[derive(Debug, Copy, Clone, PartialEq, Eq, IntoBytes, FromBytes, Immutable, KnownLayout)]
172#[repr(C, packed)]
173pub struct DumpCompleteRequestV1 {
174 pub header: Header,
175 pub info: CompletionInfoV1,
176}