2021-08-07 02:30:02 +00:00
|
|
|
#include "dma.h"
|
|
|
|
|
2022-02-09 00:02:47 +00:00
|
|
|
#include "common/util/Assert.h"
|
2021-08-07 02:30:02 +00:00
|
|
|
|
2024-03-06 03:11:52 +00:00
|
|
|
#include "fmt/core.h"
|
2022-06-23 03:37:46 +00:00
|
|
|
|
2024-07-27 00:31:32 +00:00
|
|
|
std::string DmaTag::print() const {
|
2021-08-07 02:30:02 +00:00
|
|
|
std::string result;
|
|
|
|
const char* mode_names[8] = {"refe", "cnt", "next", "ref", "refs", "call", "ret", "end"};
|
|
|
|
result += fmt::format("TAG: 0x{:08x} {:4s} qwc 0x{:04x}", addr, mode_names[(int)kind], qwc);
|
|
|
|
if (spr) {
|
|
|
|
result += " SPR";
|
|
|
|
}
|
|
|
|
result += "\n";
|
|
|
|
return result;
|
|
|
|
}
|
2021-08-07 22:57:13 +00:00
|
|
|
|
2024-07-27 00:31:32 +00:00
|
|
|
std::string VifCode::print() const {
|
2021-08-07 22:57:13 +00:00
|
|
|
std::string result;
|
|
|
|
|
|
|
|
switch (kind) {
|
2021-08-10 01:42:05 +00:00
|
|
|
case Kind::NOP:
|
|
|
|
result = "NOP";
|
|
|
|
break;
|
2021-09-26 15:41:58 +00:00
|
|
|
case Kind::STCYCL: {
|
|
|
|
VifCodeStcycl stcycl(immediate);
|
|
|
|
result = fmt::format("STCYCL cl: {} wl: {}", stcycl.cl, stcycl.wl);
|
|
|
|
} break;
|
2021-08-10 01:42:05 +00:00
|
|
|
case Kind::OFFSET:
|
2022-02-25 03:33:10 +00:00
|
|
|
result = fmt::format("OFFSET 0x{:x}", immediate);
|
2021-08-10 01:42:05 +00:00
|
|
|
break;
|
|
|
|
case Kind::BASE:
|
2022-02-25 03:33:10 +00:00
|
|
|
result = fmt::format("BASE 0x{:x}", immediate);
|
2021-08-10 01:42:05 +00:00
|
|
|
break;
|
|
|
|
case Kind::ITOP:
|
|
|
|
result = "ITOP";
|
|
|
|
break;
|
|
|
|
case Kind::STMOD:
|
2021-10-31 17:12:50 +00:00
|
|
|
result = fmt::format("STMOD 0b{:b}", immediate);
|
2021-08-10 01:42:05 +00:00
|
|
|
break;
|
|
|
|
case Kind::MSK3PATH:
|
|
|
|
result = "MSK3PATH";
|
|
|
|
break;
|
|
|
|
case Kind::MARK:
|
|
|
|
result = "MARK";
|
|
|
|
break;
|
|
|
|
case Kind::FLUSHE:
|
|
|
|
result = "FLUSHE";
|
|
|
|
break;
|
|
|
|
case Kind::FLUSH:
|
|
|
|
result = "FLUSH";
|
|
|
|
break;
|
|
|
|
case Kind::FLUSHA:
|
|
|
|
result = "FLUSHA";
|
|
|
|
break;
|
|
|
|
case Kind::MSCAL:
|
2022-02-04 03:45:41 +00:00
|
|
|
result = fmt::format("MSCAL 0x{:x}", immediate);
|
2021-08-10 01:42:05 +00:00
|
|
|
break;
|
|
|
|
case Kind::MSCNT:
|
|
|
|
result = "MSCNT";
|
|
|
|
break;
|
|
|
|
case Kind::MSCALF:
|
2022-02-25 03:33:10 +00:00
|
|
|
result = fmt::format("MSCALF 0x{:x}", immediate);
|
2021-08-10 01:42:05 +00:00
|
|
|
break;
|
|
|
|
case Kind::STMASK:
|
|
|
|
result = "STMASK";
|
|
|
|
break;
|
|
|
|
case Kind::STROW:
|
|
|
|
result = "STROW";
|
|
|
|
break;
|
|
|
|
case Kind::STCOL:
|
|
|
|
result = "STCOL";
|
|
|
|
break;
|
|
|
|
case Kind::MPG:
|
|
|
|
result = "MPG";
|
|
|
|
break;
|
|
|
|
case Kind::DIRECT:
|
|
|
|
result = "DIRECT";
|
|
|
|
break;
|
|
|
|
case Kind::DIRECTHL:
|
|
|
|
result = "DIRECTHL";
|
|
|
|
break;
|
2022-05-28 23:28:19 +00:00
|
|
|
case Kind::PC_PORT:
|
|
|
|
result = "PC_PORT";
|
|
|
|
break;
|
2021-10-31 17:12:50 +00:00
|
|
|
case Kind::UNPACK_V4_8: {
|
|
|
|
VifCodeUnpack up(*this);
|
|
|
|
result = fmt::format("UNPACK-V4-8: {} addr: {} us: {} tops: {}", num, up.addr_qw,
|
|
|
|
up.is_unsigned, up.use_tops_flag);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Kind::UNPACK_V4_16: {
|
|
|
|
VifCodeUnpack up(*this);
|
|
|
|
result = fmt::format("UNPACK-V4-16: {} addr: {} us: {} tops: {}", num, up.addr_qw,
|
|
|
|
up.is_unsigned, up.use_tops_flag);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Kind::UNPACK_V4_32: {
|
|
|
|
VifCodeUnpack up(*this);
|
|
|
|
result = fmt::format("UNPACK-V4-32: {} addr: {} us: {} tops: {}", num, up.addr_qw,
|
|
|
|
up.is_unsigned, up.use_tops_flag);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Kind::UNPACK_V3_32: {
|
|
|
|
VifCodeUnpack up(*this);
|
|
|
|
result = fmt::format("UNPACK-V3-32: {} addr: {} us: {} tops: {}", num, up.addr_qw,
|
|
|
|
up.is_unsigned, up.use_tops_flag);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2022-02-25 03:33:10 +00:00
|
|
|
case Kind::UNPACK_V2_16: {
|
|
|
|
VifCodeUnpack up(*this);
|
|
|
|
result = fmt::format("UNPACK-V2-16: {} addr: {} us: {} tops: {}", num, up.addr_qw,
|
|
|
|
up.is_unsigned, up.use_tops_flag);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-08-07 22:57:13 +00:00
|
|
|
default:
|
2021-09-26 15:41:58 +00:00
|
|
|
result = "???";
|
2022-04-12 22:48:27 +00:00
|
|
|
ASSERT_MSG(false, fmt::format("Unhandled vif code {}", (int)kind));
|
2021-08-07 22:57:13 +00:00
|
|
|
break;
|
|
|
|
}
|
2021-08-10 01:42:05 +00:00
|
|
|
// TODO: the rest of the VIF code.
|
2021-08-07 22:57:13 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|