dma: Add name to dma classes.
For logging purposes, each DMA channel should have a name.
This commit is contained in:
parent
f5bb484226
commit
b0dc893a05
|
@ -68,7 +68,7 @@ uint8_t DMAChannel::interpret_cmd() {
|
|||
case DBDMA_Cmd::INPUT_MORE:
|
||||
case DBDMA_Cmd::INPUT_LAST:
|
||||
if (cmd_struct.cmd_key & 7) {
|
||||
LOG_F(ERROR, "Key > 0 not implemented");
|
||||
LOG_F(ERROR, "%s: Key > 0 not implemented", this->get_name().c_str());
|
||||
break;
|
||||
}
|
||||
res = mmu_map_dma_mem(cmd_struct.address, cmd_struct.req_count, false);
|
||||
|
@ -78,12 +78,14 @@ uint8_t DMAChannel::interpret_cmd() {
|
|||
break;
|
||||
case DBDMA_Cmd::STORE_QUAD:
|
||||
if ((cmd_struct.cmd_key & 7) != 6)
|
||||
LOG_F(9, "Invalid key %d in STORE_QUAD", cmd_struct.cmd_key & 7);
|
||||
LOG_F(9, "%s: Invalid key %d in STORE_QUAD", this->get_name().c_str(),
|
||||
cmd_struct.cmd_key & 7);
|
||||
this->xfer_quad(&cmd_struct, true);
|
||||
break;
|
||||
case DBDMA_Cmd::LOAD_QUAD:
|
||||
if ((cmd_struct.cmd_key & 7) != 6)
|
||||
LOG_F(9, "Invalid key %d in LOAD_QUAD", cmd_struct.cmd_key & 7);
|
||||
LOG_F(9, "%s: Invalid key %d in LOAD_QUAD", this->get_name().c_str(),
|
||||
cmd_struct.cmd_key & 7);
|
||||
this->xfer_quad(&cmd_struct, false);
|
||||
break;
|
||||
case DBDMA_Cmd::NOP:
|
||||
|
@ -94,7 +96,8 @@ uint8_t DMAChannel::interpret_cmd() {
|
|||
this->cmd_in_progress = false;
|
||||
break;
|
||||
default:
|
||||
LOG_F(ERROR, "Unsupported DMA command 0x%X", this->cur_cmd);
|
||||
LOG_F(ERROR, "%s: Unsupported DMA command 0x%X", this->get_name().c_str(),
|
||||
this->cur_cmd);
|
||||
this->ch_stat |= CH_STAT_DEAD;
|
||||
this->ch_stat &= ~CH_STAT_ACTIVE;
|
||||
}
|
||||
|
@ -103,7 +106,6 @@ uint8_t DMAChannel::interpret_cmd() {
|
|||
}
|
||||
|
||||
void DMAChannel::finish_cmd() {
|
||||
DMACmd cmd_struct;
|
||||
bool branch_taken = false;
|
||||
|
||||
// obtain real pointer to the descriptor of the command to be finished
|
||||
|
@ -209,7 +211,8 @@ void DMAChannel::xfer_quad(const DMACmd *cmd_desc, const bool is_store) {
|
|||
}
|
||||
|
||||
if (cmd_desc->cmd_bits & 0xC)
|
||||
ABORT_F("DBDMA: cmd_bits.b should be zero for LOAD/STORE_QUAD!");
|
||||
ABORT_F("%s: cmd_bits.b should be zero for LOAD/STORE_QUAD!",
|
||||
this->get_name().c_str());
|
||||
|
||||
this->finish_cmd();
|
||||
}
|
||||
|
@ -240,7 +243,8 @@ void DMAChannel::update_irq() {
|
|||
|
||||
uint32_t DMAChannel::reg_read(uint32_t offset, int size) {
|
||||
if (size != 4) {
|
||||
ABORT_F("DBDMA: non-DWORD read from a DMA channel not supported");
|
||||
ABORT_F("%s: non-DWORD read from a DMA channel not supported",
|
||||
this->get_name().c_str());
|
||||
}
|
||||
|
||||
switch (offset) {
|
||||
|
@ -251,7 +255,8 @@ uint32_t DMAChannel::reg_read(uint32_t offset, int size) {
|
|||
case DMAReg::CMD_PTR_LO:
|
||||
return BYTESWAP_32(this->cmd_ptr);
|
||||
default:
|
||||
LOG_F(WARNING, "Unsupported DMA channel register 0x%X", offset);
|
||||
LOG_F(WARNING, "%s: Unsupported DMA channel register read at 0x%X",
|
||||
this->get_name().c_str(), offset);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -261,7 +266,8 @@ void DMAChannel::reg_write(uint32_t offset, uint32_t value, int size) {
|
|||
uint16_t mask, old_stat, new_stat;
|
||||
|
||||
if (size != 4) {
|
||||
ABORT_F("DBDMA: non-DWORD writes to a DMA channel not supported");
|
||||
ABORT_F("%s: non-DWORD writes to a DMA channel not supported",
|
||||
this->get_name().c_str());
|
||||
}
|
||||
|
||||
value = BYTESWAP_32(value);
|
||||
|
@ -271,7 +277,7 @@ void DMAChannel::reg_write(uint32_t offset, uint32_t value, int size) {
|
|||
case DMAReg::CH_CTRL:
|
||||
mask = value >> 16;
|
||||
new_stat = (value & mask & 0xF0FFU) | (old_stat & ~mask);
|
||||
LOG_F(9, "New ChannelStatus value = 0x%X", new_stat);
|
||||
LOG_F(9, "%s: New ChannelStatus value = 0x%X", this->get_name().c_str(), new_stat);
|
||||
|
||||
// update ch_stat.s0...s7 if requested (needed for interrupt generation)
|
||||
if ((new_stat & 0xFF) != (old_stat & 0xFF)) {
|
||||
|
@ -321,7 +327,8 @@ void DMAChannel::reg_write(uint32_t offset, uint32_t value, int size) {
|
|||
case DMAReg::CMD_PTR_LO:
|
||||
if (!(this->ch_stat & CH_STAT_RUN) && !(this->ch_stat & CH_STAT_ACTIVE)) {
|
||||
this->cmd_ptr = value;
|
||||
LOG_F(9, "CommandPtrLo set to 0x%X", this->cmd_ptr);
|
||||
LOG_F(9, "%s: CommandPtrLo set to 0x%X", this->get_name().c_str(),
|
||||
this->cmd_ptr);
|
||||
}
|
||||
break;
|
||||
case DMAReg::INT_SELECT:
|
||||
|
@ -334,7 +341,8 @@ void DMAChannel::reg_write(uint32_t offset, uint32_t value, int size) {
|
|||
this->wait_select = value & 0xFF00FFUL;
|
||||
break;
|
||||
default:
|
||||
LOG_F(WARNING, "Unsupported DMA channel register 0x%X", offset);
|
||||
LOG_F(WARNING, "%s: Unsupported DMA channel register write at 0x%X",
|
||||
this->get_name().c_str(), offset);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -344,7 +352,7 @@ DmaPullResult DMAChannel::pull_data(uint32_t req_len, uint32_t *avail_len, uint8
|
|||
|
||||
if (this->ch_stat & CH_STAT_DEAD || !(this->ch_stat & CH_STAT_ACTIVE)) {
|
||||
// dead or idle channel? -> no more data
|
||||
LOG_F(WARNING, "Dead/idle channel -> no more data");
|
||||
LOG_F(WARNING, "%s: Dead/idle channel -> no more data", this->get_name().c_str());
|
||||
return DmaPullResult::NoMoreData;
|
||||
}
|
||||
|
||||
|
@ -356,13 +364,14 @@ DmaPullResult DMAChannel::pull_data(uint32_t req_len, uint32_t *avail_len, uint8
|
|||
// dequeue data if any
|
||||
if (this->queue_len) {
|
||||
if (this->queue_len >= req_len) {
|
||||
LOG_F(9, "Return req_len = %d data", req_len);
|
||||
LOG_F(9, "%s: Return req_len = %d data", this->get_name().c_str(), req_len);
|
||||
*p_data = this->queue_data;
|
||||
*avail_len = req_len;
|
||||
this->queue_len -= req_len;
|
||||
this->queue_data += req_len;
|
||||
} else { // return less data than req_len
|
||||
LOG_F(9, "Return queue_len = %d data", this->queue_len);
|
||||
LOG_F(9, "%s: Return queue_len = %d data", this->get_name().c_str(),
|
||||
this->queue_len);
|
||||
*p_data = this->queue_data;
|
||||
*avail_len = this->queue_len;
|
||||
this->queue_len = 0;
|
||||
|
@ -375,7 +384,8 @@ DmaPullResult DMAChannel::pull_data(uint32_t req_len, uint32_t *avail_len, uint8
|
|||
|
||||
int DMAChannel::push_data(const char* src_ptr, int len) {
|
||||
if (this->ch_stat & CH_STAT_DEAD || !(this->ch_stat & CH_STAT_ACTIVE)) {
|
||||
LOG_F(WARNING, "DBDMA: attempt to push data to dead/idle channel");
|
||||
LOG_F(WARNING, "%s: attempt to push data to dead/idle channel",
|
||||
this->get_name().c_str());
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -410,7 +420,8 @@ bool DMAChannel::is_active() {
|
|||
|
||||
void DMAChannel::start() {
|
||||
if (this->ch_stat & CH_STAT_PAUSE) {
|
||||
LOG_F(WARNING, "Cannot start DMA channel, PAUSE bit is set");
|
||||
LOG_F(WARNING, "%s: Cannot start DMA channel, PAUSE bit is set",
|
||||
this->get_name().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -433,21 +444,22 @@ void DMAChannel::start() {
|
|||
|
||||
void DMAChannel::resume() {
|
||||
if (this->ch_stat & CH_STAT_PAUSE) {
|
||||
LOG_F(WARNING, "Cannot resume DMA channel, PAUSE bit is set");
|
||||
LOG_F(WARNING, "%s: Cannot resume DMA channel, PAUSE bit is set",
|
||||
this->get_name().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
LOG_F(INFO, "Resuming DMA channel");
|
||||
LOG_F(INFO, "%s: Resuming DMA channel", this->get_name().c_str());
|
||||
}
|
||||
|
||||
void DMAChannel::abort() {
|
||||
LOG_F(9, "Aborting DMA channel");
|
||||
LOG_F(9, "%s: Aborting DMA channel", this->get_name().c_str());
|
||||
if (this->stop_cb)
|
||||
this->stop_cb();
|
||||
}
|
||||
|
||||
void DMAChannel::pause() {
|
||||
LOG_F(INFO, "Pausing DMA channel");
|
||||
LOG_F(INFO, "%s: Pausing DMA channel", this->get_name().c_str());
|
||||
if (this->stop_cb)
|
||||
this->stop_cb();
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ typedef std::function<void(void)> DbdmaCallback;
|
|||
|
||||
class DMAChannel : public DmaBidirChannel {
|
||||
public:
|
||||
DMAChannel() = default;
|
||||
DMAChannel(std::string name) : DmaBidirChannel(name) {}
|
||||
~DMAChannel() = default;
|
||||
|
||||
void set_callbacks(DbdmaCallback start_cb, DbdmaCallback stop_cb);
|
||||
|
|
|
@ -24,7 +24,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||
#ifndef DMA_CORE_H
|
||||
#define DMA_CORE_H
|
||||
|
||||
#include <cinttypes>
|
||||
#include <string>
|
||||
|
||||
enum DmaPullResult : int {
|
||||
MoreData, // data source has more data to be pulled
|
||||
|
@ -33,18 +33,39 @@ enum DmaPullResult : int {
|
|||
|
||||
class DmaOutChannel {
|
||||
public:
|
||||
DmaOutChannel(std::string name) { this->name = name; };
|
||||
|
||||
virtual bool is_active() { return true; };
|
||||
virtual DmaPullResult pull_data(uint32_t req_len, uint32_t *avail_len,
|
||||
uint8_t **p_data) = 0;
|
||||
|
||||
std::string get_name(void) { return this->name; };
|
||||
|
||||
private:
|
||||
std::string name;
|
||||
};
|
||||
|
||||
class DmaInChannel {
|
||||
public:
|
||||
virtual int push_data(const char* src_ptr, int len) = 0;
|
||||
DmaInChannel(std::string name) { this->name = name; };
|
||||
|
||||
virtual int push_data(const char* src_ptr, int len) = 0;
|
||||
std::string get_name(void) { return this->name; };
|
||||
|
||||
private:
|
||||
std::string name;
|
||||
};
|
||||
|
||||
// Base class for bidirectional DMA channels.
|
||||
class DmaBidirChannel : public DmaOutChannel, public DmaInChannel {
|
||||
public:
|
||||
DmaBidirChannel(std::string name) : DmaOutChannel(name + " Out"),
|
||||
DmaInChannel(name + std::string(" In")) { this->name = name; };
|
||||
|
||||
std::string get_name(void) { return this->name; };
|
||||
|
||||
private:
|
||||
std::string name;
|
||||
};
|
||||
|
||||
#endif // DMA_CORE_H
|
||||
|
|
|
@ -65,7 +65,7 @@ AMIC::AMIC() : MMIODevice()
|
|||
|
||||
// connect serial HW
|
||||
this->escc = dynamic_cast<EsccController*>(gMachineObj->get_comp_by_name("Escc"));
|
||||
this->escc_xmit_b_dma = std::unique_ptr<AmicSerialXmitDma>(new AmicSerialXmitDma());
|
||||
this->escc_xmit_b_dma = std::unique_ptr<AmicSerialXmitDma>(new AmicSerialXmitDma("EsccBXmit"));
|
||||
|
||||
// connect Ethernet HW
|
||||
this->mace = dynamic_cast<MaceController*>(gMachineObj->get_comp_by_name("Mace"));
|
||||
|
@ -533,7 +533,7 @@ void AMIC::ack_dma_int(uint32_t irq_id, uint8_t irq_line_state) {
|
|||
}
|
||||
|
||||
// ============================ Sound DMA stuff ================================
|
||||
AmicSndOutDma::AmicSndOutDma()
|
||||
AmicSndOutDma::AmicSndOutDma() : DmaOutChannel("SndOut")
|
||||
{
|
||||
this->dma_out_ctrl = 0;
|
||||
this->enabled = false;
|
||||
|
|
|
@ -127,7 +127,7 @@ private:
|
|||
/** AMIC-specific floppy DMA implementation. */
|
||||
class AmicFloppyDma : public DmaBidirChannel {
|
||||
public:
|
||||
AmicFloppyDma() = default;
|
||||
AmicFloppyDma() : DmaBidirChannel("floppy") {}
|
||||
~AmicFloppyDma() = default;
|
||||
|
||||
void reinit(const uint32_t addr_ptr, const uint16_t byte_cnt);
|
||||
|
@ -148,7 +148,7 @@ private:
|
|||
/** AMIC specific Serial Transmit DMA channel. */
|
||||
class AmicSerialXmitDma : public DmaOutChannel {
|
||||
public:
|
||||
AmicSerialXmitDma() = default;
|
||||
AmicSerialXmitDma(std::string name) : DmaOutChannel(name) {}
|
||||
~AmicSerialXmitDma() = default;
|
||||
|
||||
void write_ctrl(const uint8_t value);
|
||||
|
@ -166,7 +166,7 @@ private:
|
|||
/** AMIC-specific SCSI DMA implementation. */
|
||||
class AmicScsiDma : public DmaBidirChannel {
|
||||
public:
|
||||
AmicScsiDma() = default;
|
||||
AmicScsiDma() : DmaBidirChannel("Scsi") {}
|
||||
~AmicScsiDma() = default;
|
||||
|
||||
void reinit(const uint32_t addr_ptr);
|
||||
|
|
|
@ -57,7 +57,7 @@ GrandCentral::GrandCentral() : PCIDevice("mac-io/grandcentral"), InterruptCtrl()
|
|||
|
||||
// initialize sound chip and its DMA output channel, then wire them together
|
||||
this->awacs = std::unique_ptr<AwacsScreamer> (new AwacsScreamer());
|
||||
this->snd_out_dma = std::unique_ptr<DMAChannel> (new DMAChannel());
|
||||
this->snd_out_dma = std::unique_ptr<DMAChannel> (new DMAChannel("snd_out"));
|
||||
this->awacs->set_dma_out(this->snd_out_dma.get());
|
||||
this->snd_out_dma->set_callbacks(
|
||||
std::bind(&AwacsScreamer::dma_out_start, this->awacs.get()),
|
||||
|
@ -74,14 +74,14 @@ GrandCentral::GrandCentral() : PCIDevice("mac-io/grandcentral"), InterruptCtrl()
|
|||
this->mesh_stub = std::unique_ptr<MeshStub>(new MeshStub());
|
||||
this->mesh = dynamic_cast<MeshController*>(this->mesh_stub.get());
|
||||
} else {
|
||||
this->mesh_dma = std::unique_ptr<DMAChannel> (new DMAChannel());
|
||||
this->mesh_dma = std::unique_ptr<DMAChannel> (new DMAChannel("mesh_scsi"));
|
||||
this->mesh_dma->register_dma_int(this, this->register_dma_int(IntSrc::DMA_SCSI_MESH));
|
||||
this->mesh->set_dma_channel(this->mesh_dma.get());
|
||||
}
|
||||
|
||||
// connect external SCSI controller (Curio) to its DMA channel
|
||||
this->ext_scsi = dynamic_cast<Sc53C94*>(gMachineObj->get_comp_by_name("Sc53C94"));
|
||||
this->ext_scsi_dma = std::unique_ptr<DMAChannel> (new DMAChannel());
|
||||
this->ext_scsi_dma = std::unique_ptr<DMAChannel> (new DMAChannel("curio_scsi"));
|
||||
this->ext_scsi_dma->register_dma_int(this, this->register_dma_int(IntSrc::DMA_SCSI_CURIO));
|
||||
this->ext_scsi->set_dma_channel(this->ext_scsi_dma.get());
|
||||
|
||||
|
@ -90,7 +90,7 @@ GrandCentral::GrandCentral() : PCIDevice("mac-io/grandcentral"), InterruptCtrl()
|
|||
|
||||
// connect floppy disk HW
|
||||
this->swim3 = dynamic_cast<Swim3::Swim3Ctrl*>(gMachineObj->get_comp_by_name("Swim3"));
|
||||
this->floppy_dma = std::unique_ptr<DMAChannel> (new DMAChannel());
|
||||
this->floppy_dma = std::unique_ptr<DMAChannel> (new DMAChannel("floppy"));
|
||||
this->swim3->set_dma_channel(this->floppy_dma.get());
|
||||
this->floppy_dma->register_dma_int(this, this->register_dma_int(IntSrc::DMA_SWIM3));
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ HeathrowIC::HeathrowIC() : PCIDevice("mac-io/heathrow"), InterruptCtrl()
|
|||
// find appropriate sound chip, create a DMA output channel for sound,
|
||||
// then wire everything together
|
||||
this->snd_codec = dynamic_cast<MacioSndCodec*>(gMachineObj->get_comp_by_type(HWCompType::SND_CODEC));
|
||||
this->snd_out_dma = std::unique_ptr<DMAChannel> (new DMAChannel());
|
||||
this->snd_out_dma = std::unique_ptr<DMAChannel> (new DMAChannel("snd_out"));
|
||||
this->snd_codec->set_dma_out(this->snd_out_dma.get());
|
||||
this->snd_out_dma->set_callbacks(
|
||||
std::bind(&AwacsScreamer::dma_out_start, this->snd_codec),
|
||||
|
@ -79,7 +79,7 @@ HeathrowIC::HeathrowIC() : PCIDevice("mac-io/heathrow"), InterruptCtrl()
|
|||
|
||||
// connect SCSI HW and the corresponding DMA channel
|
||||
this->mesh = dynamic_cast<MeshController*>(gMachineObj->get_comp_by_name("MeshHeathrow"));
|
||||
this->scsi_dma = std::unique_ptr<DMAChannel> (new DMAChannel());
|
||||
this->scsi_dma = std::unique_ptr<DMAChannel> (new DMAChannel("mesh"));
|
||||
|
||||
// connect IDE HW
|
||||
this->ide_0 = dynamic_cast<IdeChannel*>(gMachineObj->get_comp_by_name("Ide0"));
|
||||
|
@ -90,14 +90,14 @@ HeathrowIC::HeathrowIC() : PCIDevice("mac-io/heathrow"), InterruptCtrl()
|
|||
|
||||
// connect floppy disk HW and initialize its DMA channel
|
||||
this->swim3 = dynamic_cast<Swim3::Swim3Ctrl*>(gMachineObj->get_comp_by_name("Swim3"));
|
||||
this->floppy_dma = std::unique_ptr<DMAChannel> (new DMAChannel());
|
||||
this->floppy_dma = std::unique_ptr<DMAChannel> (new DMAChannel("floppy"));
|
||||
this->swim3->set_dma_channel(this->floppy_dma.get());
|
||||
this->floppy_dma->register_dma_int(this, 2);
|
||||
|
||||
// connect Ethernet HW
|
||||
this->bmac = dynamic_cast<BigMac*>(gMachineObj->get_comp_by_type(HWCompType::ETHER_MAC));
|
||||
this->enet_xmit_dma = std::unique_ptr<DMAChannel> (new DMAChannel());
|
||||
this->enet_rcv_dma = std::unique_ptr<DMAChannel> (new DMAChannel());
|
||||
this->enet_xmit_dma = std::unique_ptr<DMAChannel> (new DMAChannel("BmacTx"));
|
||||
this->enet_rcv_dma = std::unique_ptr<DMAChannel> (new DMAChannel("BmacRx"));
|
||||
|
||||
// set EMMO pin status (active low)
|
||||
this->emmo_pin = GET_BIN_PROP("emmo") ^ 1;
|
||||
|
|
|
@ -52,7 +52,7 @@ OHare::OHare() : PCIDevice("mac-io/ohare"), InterruptCtrl()
|
|||
|
||||
// initialize sound chip and its DMA output channel, then wire them together
|
||||
this->awacs = std::unique_ptr<AwacsScreamer> (new AwacsScreamer());
|
||||
this->snd_out_dma = std::unique_ptr<DMAChannel> (new DMAChannel());
|
||||
this->snd_out_dma = std::unique_ptr<DMAChannel> (new DMAChannel("snd_out"));
|
||||
this->awacs->set_dma_out(this->snd_out_dma.get());
|
||||
this->snd_out_dma->set_callbacks(
|
||||
std::bind(&AwacsScreamer::dma_out_start, this->awacs.get()),
|
||||
|
|
Loading…
Reference in New Issue