Skip to main content

intel_crashlog/
errata.rs

1// Copyright (C) 2025 Intel Corporation
2// SPDX-License-Identifier: MIT
3
4//! Collection of erratas present in the Intel(R) Crash Log technology
5//!
6//! The `erratas` collected in this module are reflecting the errors or corrections that had to be
7//! implemented in some products regarding the structure of the Crash Log record layout.
8
9use crate::header::{Version, record_types};
10
11/// Collection of Intel Crash Log erratas
12pub struct Errata {
13    /// Type0 server legacy header
14    ///
15    /// Some Intel(R) products in the server segment are using legacy Crash Log record headers with
16    /// Type0, which has a different layout compared with the currently defined Type0 Header.
17    ///
18    pub type0_legacy_server: bool,
19
20    /// Type0 server legacy header box record
21    ///
22    /// Some Intel(R) products in the server segment that are using the legacy Crash Log record
23    /// header with Type0 are using the PCORE record type with the same functionality as a BOX
24    /// record.
25    pub type0_legacy_server_box: bool,
26
27    /// Core record using record size in bytes
28    ///
29    /// The Crash Log headers have their sizes in DWORDs, but for some products that are using
30    /// ECORE and PCORE Crash Log records, their sizes are written in bytes.
31    pub core_record_size_bytes: bool,
32
33    /// Type0 legacy header
34    ///
35    /// Some Intel(R) products in the discrete GPU segment are using legacy Crash Log record
36    /// headers with type0, which has a different layout compared with the currently defined Type0
37    /// Header.
38    pub type0_legacy_gpu: bool,
39}
40
41const GNR_SP_PRODUCT_ID: u32 = 0x2f;
42const SRF_SP_PRODUCT_ID: u32 = 0x82;
43const CGC_PRODUCT_ID: u32 = 0x85;
44const CWF_SP_PRODUCT_ID: u32 = 0x8e;
45const SERVER_LEGACY_PRODUCT_IDS: [u32; 3] =
46    [GNR_SP_PRODUCT_ID, SRF_SP_PRODUCT_ID, CWF_SP_PRODUCT_ID];
47
48const BMG_X3_PRODUCT_ID: u32 = 0x5d;
49const BMG_G31_PRODUCT_ID: u32 = 0x5e;
50const BMG_X2_PRODUCT_ID: u32 = 0x5f;
51const CRI_PRODUCT_ID: u32 = 0xb6;
52const GPU_LEGACY_PRODUCT_IDS: [u32; 4] = [
53    BMG_X3_PRODUCT_ID,
54    BMG_G31_PRODUCT_ID,
55    BMG_X2_PRODUCT_ID,
56    CRI_PRODUCT_ID,
57];
58
59impl Errata {
60    pub fn from_version(version: &Version) -> Self {
61        let type0_legacy_server =
62            version.header_type == 0 && SERVER_LEGACY_PRODUCT_IDS.contains(&version.product_id);
63
64        let type0_legacy_gpu =
65            version.header_type == 0 && GPU_LEGACY_PRODUCT_IDS.contains(&version.product_id);
66
67        let type0_legacy_server_box =
68            type0_legacy_server && version.record_type == record_types::PCORE;
69
70        let ecore_record_with_size_in_bytes =
71            version.record_type == record_types::ECORE && version.product_id < 0x96;
72
73        let pcore_record_with_size_in_bytes = version.record_type == record_types::PCORE
74            && (version.product_id < 0x71 || version.product_id == CGC_PRODUCT_ID);
75
76        let core_record_size_bytes = !type0_legacy_server
77            && !type0_legacy_gpu
78            && (ecore_record_with_size_in_bytes || pcore_record_with_size_in_bytes);
79
80        Errata {
81            type0_legacy_server,
82            type0_legacy_server_box,
83            core_record_size_bytes,
84            type0_legacy_gpu,
85        }
86    }
87}