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?
This commit is contained in:
joevt 2022-12-11 11:09:02 -08:00
parent 5aaae40d94
commit 0bd9d0e973
5 changed files with 3 additions and 7 deletions

View File

@ -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<MemCtrlBase *>
@ -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)

View File

@ -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;
};

View File

@ -31,6 +31,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
PCIDevice::PCIDevice(std::string name)
{
this->name = name;
this->pci_name = name;
this->pci_rd_stat = [this]() { return this->status; };

View File

@ -104,8 +104,6 @@ protected:
void change_bus_phase(int initiator_id);
private:
std::string name;
// SCSI devices registered with this bus
std::array<ScsiDevice*, SCSI_MAX_DEVS> devices;

View File

@ -37,8 +37,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
MPC106::MPC106() : MemCtrlBase(), PCIDevice("Grackle"), PCIHost()
{
this->name = "Grackle";
supports_types(HWCompType::MEM_CTRL | HWCompType::MMIO_DEV |
HWCompType::PCI_HOST | HWCompType::PCI_DEV);