--- nono/vm/virtio_def.cpp 2026/04/29 17:05:25 1.1 +++ nono/vm/virtio_def.cpp 2026/04/29 17:05:29 1.1.1.2 @@ -16,8 +16,10 @@ VirtIO::DeviceIDStr(uint32 id) { static const char * const idnames[] = { "invalid", - "Network Card", // 1 - "Block Device", // 2 + "Network Device", // 1 + "Block Device", // 2 + "Console Device", // 3 + "Entropy Device", // 4 }; assert(id < countof(idnames)); return idnames[id]; @@ -43,13 +45,29 @@ VirtIO::StatusBits(uint32 status) } std::string str; - for (int i = 0; i < countof(table); i++) { - if ((status & table[i].bit) != 0) { - str += ','; - str += table[i].name; + for (; status != 0; ) { + // lowest は立ってる一番下のビットだけ取り出したもの + decltype(status) lowest = status & (-status); + + str += ','; + bool found = false; + for (int i = 0; i < countof(table); i++) { + if (table[i].bit == lowest) { + str += table[i].name; + found = true; + break; + } + } + if (found == false) { + str += string_format("b%u", __builtin_ctz(lowest)); } + + status &= ~lowest; } + if (str.empty()) { + return "<>"; + } str[0] = '<'; str += '>'; return str;