40 #include "arch/isa_traits.hh" 41 #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);
99 Addr addr_lb = 0, addr_lb_len = 0, addr_first = 0, addr_next = 0;
100 const bool found_symbols =
101 symtab->findAddress(
"__log_buf", addr_lb) &&
102 symtab->findAddress(
"log_buf_len", addr_lb_len) &&
103 symtab->findAddress(
"log_first_idx", addr_first) &&
104 symtab->findAddress(
"log_next_idx", addr_next);
106 if (!found_symbols) {
107 warn(
"Failed to find kernel dmesg symbols.\n");
111 uint32_t log_buf_len =
113 uint32_t log_first_idx =
115 uint32_t log_next_idx =
118 if (log_first_idx >= log_buf_len || log_next_idx >= log_buf_len) {
119 warn(
"dmesg pointers/length corrupted\n");
126 if (log_first_idx < log_next_idx) {
127 length = log_next_idx - log_first_idx;
128 if (length < 0 || length > log_buf.size()) {
129 warn(
"Unexpected dmesg buffer length\n");
134 const int length_2 = log_buf_len - log_first_idx;
135 if (length_2 < 0 || length_2 + log_next_idx > log_buf.size()) {
136 warn(
"Unexpected dmesg buffer length\n");
139 length = log_buf_len;
140 proxy.
readBlob(addr_lb + log_first_idx, log_buf.data(), length_2);
141 proxy.
readBlob(addr_lb, log_buf.data() + length_2, log_next_idx);
145 const uint8_t *cur = log_buf.data(), *end = log_buf.data() +
length;
void ccprintf(cp::Print &print)
virtual System * getSystemPtr()=0
virtual const Loader::SymbolTable * symtab(ThreadContext *tc)=0
T gtoh(T value, ByteOrder guest_byte_order)
struct DmesgEntry M5_ATTR_PACKED
void dumpDmesg(ThreadContext *tc, std::ostream &os)
Dump Linux's dmesg log buffer to the an output stream.
static int dumpDmesgEntry(const uint8_t *base, const uint8_t *end, const ByteOrder bo, std::ostream &os)
virtual PortProxy & getVirtProxy()=0
T read(Addr address) const
Read sizeof(T) bytes from address and return as object T.
ByteOrder getGuestByteOrder() const
Get the guest byte order.
ThreadContext is the external interface to all thread state for anything outside of the CPU...
PortProxy Object Declaration.
Workload * workload
OS kernel.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
void readBlob(Addr addr, void *p, int size) const
Higher level interfaces based on the above.
This object is a proxy for a port or other object which implements the functional response protocol...
const ByteOrder GuestByteOrder