Skip to content

Commit 08f67c0

Browse files
dingusdevjoevt
andcommitted
Add get_type_str + get_entry+str
Co-Authored-By: joevt <950609+joevt@users.noreply.github.com>
1 parent c3005ce commit 08f67c0

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

devices/memctrl/memctrlbase.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,50 @@ MemCtrlBase::~MemCtrlBase() {
4242
this->address_map.clear();
4343
}
4444

45+
static std::string get_type_str(uint32_t type) {
46+
std::string str;
47+
if (type & RT_ROM) {
48+
if (str.length())
49+
str += ",";
50+
str += "ROM";
51+
};
52+
if (type & RT_RAM) {
53+
if (str.length())
54+
str += ",";
55+
str += "RAM";
56+
};
57+
if (type & RT_MMIO) {
58+
if (str.length())
59+
str += ",";
60+
str += "MMIO";
61+
};
62+
if (type & RT_MIRROR) {
63+
if (str.length())
64+
str += ",";
65+
str += "MIRROR";
66+
};
67+
return str;
68+
}
69+
70+
71+
static std::string get_entry_str(const AddressMapEntry* entry) {
72+
std::string str;
73+
char buf[50];
74+
if (entry) {
75+
snprintf(buf, sizeof(buf), "0x%08X..0x%08X", entry->start, entry->end);
76+
str = std::string(buf) + " (" + get_type_str(entry->type) + ")";
77+
if (entry->devobj)
78+
str += " (" + entry->devobj->get_name() + ")";
79+
if (entry->type & RT_MIRROR) {
80+
snprintf(buf, sizeof(buf), " -> 0x%08X", entry->mirror);
81+
str += std::string(buf);
82+
}
83+
} else {
84+
str = "null";
85+
}
86+
return str;
87+
}
88+
4589

4690
static inline bool match_mem_entry(const AddressMapEntry* entry,
4791
const uint32_t start, const uint32_t end,

0 commit comments

Comments
 (0)