From 0bd9d0e973fbe5498d7b6e5ada9872b63a40e3ae Mon Sep 17 00:00:00 2001 From: joevt Date: Sun, 11 Dec 2022 11:09:02 -0800 Subject: [PATCH] Fix HWComponent name initialization. First, remove name override for subclasses of HWComponent (Chaos and ScsiBus) because HWComponent has its own name field. HWComponent name should be set as early as possible in the constructor so it can be used in log messages. PCIDevice should set name of HWComponent (through MMIODevice) in its constructor, using the name that is given to its constructor. For Bandit and Grackle, they don't need to set the HWComponent name since its PCIDevice constructor will now do it. Chaos is not a PCIDevice so it should set the MMIODevice name itself. Why does PCIDevice have a name that is separate from the HWComponent name? --- devices/common/pci/bandit.cpp | 4 ++-- devices/common/pci/bandit.h | 1 - devices/common/pci/pcidevice.cpp | 1 + devices/common/scsi/scsi.h | 2 -- devices/memctrl/mpc106.cpp | 2 -- 5 files changed, 3 insertions(+), 7 deletions(-) diff --git a/devices/common/pci/bandit.cpp b/devices/common/pci/bandit.cpp index 9056e81..4358c5e 100644 --- a/devices/common/pci/bandit.cpp +++ b/devices/common/pci/bandit.cpp @@ -298,6 +298,8 @@ void Bandit::verbose_address_space() Chaos::Chaos(std::string name) : PCIHost() { + this->name = name; + supports_types(HWCompType::PCI_HOST); MemCtrlBase *mem_ctrl = dynamic_cast @@ -308,8 +310,6 @@ Chaos::Chaos(std::string name) : PCIHost() // base_addr + 0x800000 --> CONFIG_ADDR // base_addr + 0xC00000 --> CONFIG_DATA mem_ctrl->add_mmio_region(0xF0000000UL, 0x01000000, this); - - this->name = name; } uint32_t Chaos::read(uint32_t rgn_start, uint32_t offset, int size) diff --git a/devices/common/pci/bandit.h b/devices/common/pci/bandit.h index cbd4ebf..edb991c7 100644 --- a/devices/common/pci/bandit.h +++ b/devices/common/pci/bandit.h @@ -102,7 +102,6 @@ public: void write(uint32_t rgn_start, uint32_t offset, uint32_t value, int size); private: - std::string name; uint32_t config_addr; }; diff --git a/devices/common/pci/pcidevice.cpp b/devices/common/pci/pcidevice.cpp index a4ba484..6ad4e25 100644 --- a/devices/common/pci/pcidevice.cpp +++ b/devices/common/pci/pcidevice.cpp @@ -31,6 +31,7 @@ along with this program. If not, see . PCIDevice::PCIDevice(std::string name) { + this->name = name; this->pci_name = name; this->pci_rd_stat = [this]() { return this->status; }; diff --git a/devices/common/scsi/scsi.h b/devices/common/scsi/scsi.h index 56f6af0..b87b4f3 100644 --- a/devices/common/scsi/scsi.h +++ b/devices/common/scsi/scsi.h @@ -104,8 +104,6 @@ protected: void change_bus_phase(int initiator_id); private: - std::string name; - // SCSI devices registered with this bus std::array devices; diff --git a/devices/memctrl/mpc106.cpp b/devices/memctrl/mpc106.cpp index dc9eb89..9c23611 100644 --- a/devices/memctrl/mpc106.cpp +++ b/devices/memctrl/mpc106.cpp @@ -37,8 +37,6 @@ along with this program. If not, see . MPC106::MPC106() : MemCtrlBase(), PCIDevice("Grackle"), PCIHost() { - this->name = "Grackle"; - supports_types(HWCompType::MEM_CTRL | HWCompType::MMIO_DEV | HWCompType::PCI_HOST | HWCompType::PCI_DEV);