Add posti-initialization to HW components.

This commit is contained in:
Maxim Poliakovski 2022-01-21 11:16:34 +01:00
parent 4867a68e11
commit c1208b398e
5 changed files with 35 additions and 1 deletions

View File

@ -57,6 +57,10 @@ public:
virtual bool supports_type(HWCompType type) = 0;
virtual int device_postinit() {
return 0;
};
protected:
std::string name;
};

View File

@ -119,3 +119,20 @@ HWComponent* MachineBase::get_comp_by_type(HWCompType type) {
return NULL;
}
}
int MachineBase::postinit_devices()
{
for (auto it = this->comp_map.begin(); it != this->comp_map.end(); it++) {
if (it->second->device_postinit()) {
return -1;
}
}
for (auto it = this->subdev_map.begin(); it != this->subdev_map.end(); it++) {
if (it->second->device_postinit()) {
return -1;
}
}
return 0;
}

View File

@ -43,6 +43,7 @@ public:
void add_alias(std::string name, std::string alias);
HWComponent* get_comp_by_name(std::string name);
HWComponent* get_comp_by_type(HWCompType type);
int postinit_devices();
private:
std::string name;

View File

@ -103,6 +103,12 @@ int create_gossamer(std::string& id) {
/* Init virtual CPU and request MPC750 CPU aka G3 */
ppc_cpu_init(grackle_obj, PPC_VER::MPC750);
// post-initialize all devices
if (gMachineObj->postinit_devices()) {
LOG_F(ERROR, "Could not post-initialize devices!\n");
return -1;
}
/* check for a floppy image to be inserted into the virtual superdrive */
std::string fdd_path = GET_STR_PROP("fdd_img");
if (!fdd_path.empty()) {

View File

@ -59,7 +59,7 @@ int create_pdm(std::string& id) {
/* get raw pointer to HMC object */
HMC* hmc_obj = dynamic_cast<HMC*>(gMachineObj->get_comp_by_name("HMC"));
/* allocate machine ID register and tell we're running PowerMac 6100 */
// allocate machine ID register and tell we're running PowerMac 6100
// TODO: add a possibility to select another machine
// to be used with the same ROM
gMachineObj->add_component("MachineID", new NubusMacID(0x3010));
@ -87,6 +87,12 @@ int create_pdm(std::string& id) {
/* Init virtual CPU and request MPC601 */
ppc_cpu_init(hmc_obj, PPC_VER::MPC601);
// post-initialize all devices
if (gMachineObj->postinit_devices()) {
LOG_F(ERROR, "Could not post-initialize devices!\n");
return -1;
}
/* check for a floppy image to be inserted into the virtual superdrive */
std::string fdd_path = GET_STR_PROP("fdd_img");
if (!fdd_path.empty()) {