Improve machine availability checking so that it absolutely never uses the legacy method if the machine has a device and the device has a CONFIG_BIOS setting.

This commit is contained in:
OBattler
2025-05-10 05:01:57 +02:00
parent e800f99f5a
commit 76d5fa79af
3 changed files with 52 additions and 33 deletions

View File

@@ -139,18 +139,24 @@ machine_init(void)
int
machine_available(int m)
{
int ret;
int ret = 0;
const device_t *dev = machine_get_device(m);
bios_only = 1;
if (dev != NULL)
ret = machine_device_available(dev);
/*
Only via machine_init_ex() if the device is NULL or
it lacks a CONFIG_BIOS field (or the CONFIG_BIOS field
is not the first in list.
*/
if (ret == 0) {
bios_only = 1;
ret = device_available(dev);
/* Do not check via machine_init_ex() if the device is not NULL and
it has a CONFIG_BIOS field. */
if ((dev == NULL) || (ret != -1))
ret = machine_init_ex(m);
bios_only = 0;
bios_only = 0;
} else if (ret == -2)
ret = 0;
return !!ret;
}