42 #include "arch/isa_traits.hh"
43 #include "config/the_isa.hh"
60 const size_t max_length = end -
base;
63 if (max_length <
sizeof(de)) {
64 warn(
"Malformed dmesg entry\n");
68 memcpy(&de, base,
sizeof(de));
73 if (de.
len <
sizeof(de) ||
74 max_length < de.
len ||
77 warn(
"Malformed dmesg entry:\n");
78 warn(
"\tMax length: %i\n", max_length);
85 os.write((
char *)base +
sizeof(de), de.
text_len);
98 Addr addr_lb = 0, addr_lb_len = 0, addr_first = 0, addr_next = 0;
99 const bool found_symbols =
102 symtab->
findAddress(
"log_first_idx", addr_first) &&
105 if (!found_symbols) {
106 warn(
"Failed to find kernel dmesg symbols.\n");
110 uint32_t log_buf_len = proxy.readGtoH<uint32_t>(addr_lb_len);
111 uint32_t log_first_idx = proxy.readGtoH<uint32_t>(addr_first);
112 uint32_t log_next_idx = proxy.readGtoH<uint32_t>(addr_next);
114 if (log_first_idx >= log_buf_len || log_next_idx >= log_buf_len) {
115 warn(
"dmesg pointers/length corrupted\n");
122 if (log_first_idx < log_next_idx) {
123 length = log_next_idx - log_first_idx;
124 if (length < 0 || length > log_buf.size()) {
125 warn(
"Unexpected dmesg buffer length\n");
128 proxy.readBlob(addr_lb + log_first_idx, log_buf.data(),
length);
130 const int length_2 = log_buf_len - log_first_idx;
131 if (length_2 < 0 || length_2 + log_next_idx > log_buf.size()) {
132 warn(
"Unexpected dmesg buffer length\n");
135 length = log_buf_len;
136 proxy.readBlob(addr_lb + log_first_idx, log_buf.data(), length_2);
137 proxy.readBlob(addr_lb, log_buf.data() + length_2, log_next_idx);
141 const uint8_t *cur = log_buf.data(), *end = log_buf.data() +
length;
void ccprintf(cp::Print &print)
A TranslatingPortProxy in FS mode translates a virtual address to a physical address and then calls t...
virtual System * getSystemPtr()=0
struct DmesgEntry M5_ATTR_PACKED
void dumpDmesg(ThreadContext *tc, std::ostream &os)
Dump Linux's dmesg log buffer to the an output stream.
bool findAddress(const std::string &symbol, Addr &address) const
ThreadContext is the external interface to all thread state for anything outside of the CPU...
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
SymbolTable * kernelSymtab
kernel symbol table
static int dumpDmesgEntry(const uint8_t *base, const uint8_t *end, std::ostream &os)
TranslatingPortProxy Object Declaration for FS.