Skip to content

Commit ce98b8f

Browse files
authored
Separated cert log related structs from buffer_dumper.h (#9700)
* Separated cert log related structs from buffer_dumper.h, so it could be included in windbg ext Also, now that cert log buffer allocation is shared with KMD made change related to it * Made suggested changes by github-copilot and rebase with master * Changed #define to constexpr for UC_LOG_ENTRY_SIZE * Incorporated code review feedback
1 parent c11ccaa commit ce98b8f

3 files changed

Lines changed: 39 additions & 13 deletions

File tree

src/runtime_src/core/common/api/xrt_bo.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,7 @@ alloc(const device_type& device, size_t sz, xrtBufferFlags flags, xrtMemoryGroup
11671167
return alloc_hbuf(device, xrt_core::aligned_alloc(get_alignment(), sz), sz, flags, grp);
11681168
#endif
11691169
case XCL_BO_FLAGS_CACHEABLE:
1170+
case XCL_BO_FLAGS_KERNBUF:
11701171
case XCL_BO_FLAGS_SVM:
11711172
case XCL_BO_FLAGS_HOST_ONLY:
11721173
case XCL_BO_FLAGS_P2P:
@@ -1733,10 +1734,12 @@ compose_internal_bo_flags(use_type type)
17331734
case use_type::dtrace:
17341735
case use_type::host_only:
17351736
case use_type::uc_debug:
1736-
case use_type::log:
17371737
case use_type::scratch_pad:
17381738
flags.flags = XRT_BO_FLAGS_HOST_ONLY;
17391739
break;
1740+
case use_type::log:
1741+
flags.flags = XRT_BO_FLAGS_CARVEOUT;
1742+
break;
17401743
default:
17411744
throw std::runtime_error("create_bo is called with invalid buffer type\n");
17421745
}

src/runtime_src/core/common/buffer_dumper.h

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved.
33
#ifndef xrtcore_util_buffer_dumper_h_
44
#define xrtcore_util_buffer_dumper_h_
5+
#include "core/common/uc_log.h"
56
#include "core/include/xrt/xrt_bo.h"
67

78
#include <atomic>
@@ -48,18 +49,8 @@ class buffer_dumper
4849
bool dump_bin_format = false; // Dump in binary format when enabled
4950
};
5051

51-
// Log entry struct for uc log binary format
52-
struct log_entry
53-
{
54-
uint32_t length = 0; // Log entry length in number of words
55-
uint32_t ts_high = 0; // Timestamp high 32 bits
56-
uint32_t ts_low = 0; // Timestamp low 32 bits
57-
uint32_t file_id = 0; // ID of log source file
58-
uint32_t line_num = 0; // Line number of log in source file
59-
uint32_t log_id = 0; // ID of format string
60-
uint32_t argument1 = 0; // First argument (present if length > 6)
61-
uint32_t argument2 = 0; // Second argument (present if length > 7)
62-
};
52+
// Log entry layout: shared definition in uc_log.h
53+
using log_entry = uc_log_entry;
6354

6455
private:
6556
config m_config;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
// Copyright (C) 2026 Advanced Micro Devices, Inc. All rights reserved.
3+
#ifndef xrtcore_common_uc_log_h_
4+
#define xrtcore_common_uc_log_h_
5+
6+
#include <cstddef>
7+
#include <cstdint>
8+
#include <type_traits>
9+
10+
namespace xrt_core {
11+
12+
/// UC device log ring entry. Used by buffer_dumper and host-side tools
13+
/// (e.g. WinDbg extension) without pulling in buffer_dumper / xrt::bo.
14+
struct uc_log_entry
15+
{
16+
uint32_t length = 0; // Log entry length in number of words
17+
uint32_t ts_high = 0; // Timestamp high 32 bits
18+
uint32_t ts_low = 0; // Timestamp low 32 bits
19+
uint32_t file_id = 0; // ID of log source file
20+
uint32_t line_num = 0; // Line number of log in source file
21+
uint32_t log_id = 0; // ID of format string (see uc_log_schema.h)
22+
uint32_t argument1 = 0; // First argument (present if length > word offset of argument1)
23+
uint32_t argument2 = 0; // Second argument (present if length > word offset of argument2)
24+
};
25+
26+
inline constexpr std::size_t uc_log_entry_size = 32;
27+
static_assert(std::is_standard_layout_v<uc_log_entry>, "uc_log_entry layout");
28+
static_assert(sizeof(uc_log_entry) == uc_log_entry_size, "uc_log_entry size");
29+
30+
} // namespace xrt_core
31+
32+
#endif

0 commit comments

Comments
 (0)