Improve empty bios file entry support
This commit is contained in:
73
src/device.c
73
src/device.c
@@ -390,22 +390,21 @@ device_get_priv(const device_t *dev)
|
|||||||
int
|
int
|
||||||
device_available(const device_t *dev)
|
device_available(const device_t *dev)
|
||||||
{
|
{
|
||||||
const device_config_t *config = NULL;
|
|
||||||
const device_config_bios_t *bios = NULL;
|
|
||||||
|
|
||||||
if (dev != NULL) {
|
if (dev != NULL) {
|
||||||
config = dev->config;
|
const device_config_t *config = dev->config;
|
||||||
if (config != NULL) {
|
if (config != NULL) {
|
||||||
while (config->type != CONFIG_END) {
|
while (config->type != CONFIG_END) {
|
||||||
if (config->type == CONFIG_BIOS) {
|
if (config->type == CONFIG_BIOS) {
|
||||||
int roms_present = 0;
|
int roms_present = 0;
|
||||||
|
const device_config_bios_t *bios = (const device_config_bios_t *) config->bios;
|
||||||
bios = (const device_config_bios_t *) config->bios;
|
|
||||||
|
|
||||||
/* Go through the ROM's in the device configuration. */
|
/* Go through the ROM's in the device configuration. */
|
||||||
while (bios->files_no != 0) {
|
while ((bios != NULL) &&
|
||||||
|
(bios->name != NULL) &&
|
||||||
|
(bios->internal_name != NULL) &&
|
||||||
|
(bios->files_no != 0)) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (int bf = 0; bf < bios->files_no; bf++)
|
for (uint8_t bf = 0; bf < bios->files_no; bf++)
|
||||||
i += !!rom_present(bios->files[bf]);
|
i += !!rom_present(bios->files[bf]);
|
||||||
if (i == bios->files_no)
|
if (i == bios->files_no)
|
||||||
roms_present++;
|
roms_present++;
|
||||||
@@ -432,16 +431,16 @@ device_available(const device_t *dev)
|
|||||||
uint8_t
|
uint8_t
|
||||||
device_get_bios_type(const device_t *dev, const char *internal_name)
|
device_get_bios_type(const device_t *dev, const char *internal_name)
|
||||||
{
|
{
|
||||||
const device_config_t *config = NULL;
|
|
||||||
const device_config_bios_t *bios = NULL;
|
|
||||||
|
|
||||||
if (dev != NULL) {
|
if (dev != NULL) {
|
||||||
config = dev->config;
|
const device_config_t *config = dev->config;
|
||||||
if (config != NULL) {
|
if (config != NULL) {
|
||||||
while (config->type != CONFIG_END) {
|
while (config->type != CONFIG_END) {
|
||||||
if (config->type == CONFIG_BIOS) {
|
if (config->type == CONFIG_BIOS) {
|
||||||
bios = config->bios;
|
const device_config_bios_t *bios = (const device_config_bios_t *) config->bios;
|
||||||
while (bios->files_no != 0) {
|
while ((bios != NULL) &&
|
||||||
|
(bios->name != NULL) &&
|
||||||
|
(bios->internal_name != NULL) &&
|
||||||
|
(bios->files_no != 0)) {
|
||||||
if (!strcmp(internal_name, bios->internal_name))
|
if (!strcmp(internal_name, bios->internal_name))
|
||||||
return bios->bios_type;
|
return bios->bios_type;
|
||||||
bios++;
|
bios++;
|
||||||
@@ -458,16 +457,16 @@ device_get_bios_type(const device_t *dev, const char *internal_name)
|
|||||||
uint8_t
|
uint8_t
|
||||||
device_get_bios_num_files(const device_t *dev, const char *internal_name)
|
device_get_bios_num_files(const device_t *dev, const char *internal_name)
|
||||||
{
|
{
|
||||||
const device_config_t *config = NULL;
|
|
||||||
const device_config_bios_t *bios = NULL;
|
|
||||||
|
|
||||||
if (dev != NULL) {
|
if (dev != NULL) {
|
||||||
config = dev->config;
|
const device_config_t *config = dev->config;
|
||||||
if (config != NULL) {
|
if (config != NULL) {
|
||||||
while (config->type != CONFIG_END) {
|
while (config->type != CONFIG_END) {
|
||||||
if (config->type == CONFIG_BIOS) {
|
if (config->type == CONFIG_BIOS) {
|
||||||
bios = config->bios;
|
const device_config_bios_t *bios = (const device_config_bios_t *) config->bios;
|
||||||
while (bios->files_no != 0) {
|
while ((bios != NULL) &&
|
||||||
|
(bios->name != NULL) &&
|
||||||
|
(bios->internal_name != NULL) &&
|
||||||
|
(bios->files_no != 0)) {
|
||||||
if (!strcmp(internal_name, bios->internal_name))
|
if (!strcmp(internal_name, bios->internal_name))
|
||||||
return bios->files_no;
|
return bios->files_no;
|
||||||
bios++;
|
bios++;
|
||||||
@@ -484,16 +483,16 @@ device_get_bios_num_files(const device_t *dev, const char *internal_name)
|
|||||||
uint32_t
|
uint32_t
|
||||||
device_get_bios_local(const device_t *dev, const char *internal_name)
|
device_get_bios_local(const device_t *dev, const char *internal_name)
|
||||||
{
|
{
|
||||||
const device_config_t *config = NULL;
|
|
||||||
const device_config_bios_t *bios = NULL;
|
|
||||||
|
|
||||||
if (dev != NULL) {
|
if (dev != NULL) {
|
||||||
config = dev->config;
|
const device_config_t *config = dev->config;
|
||||||
if (config != NULL) {
|
if (config != NULL) {
|
||||||
while (config->type != CONFIG_END) {
|
while (config->type != CONFIG_END) {
|
||||||
if (config->type == CONFIG_BIOS) {
|
if (config->type == CONFIG_BIOS) {
|
||||||
bios = config->bios;
|
const device_config_bios_t *bios = (const device_config_bios_t *) config->bios;
|
||||||
while (bios->files_no != 0) {
|
while ((bios != NULL) &&
|
||||||
|
(bios->name != NULL) &&
|
||||||
|
(bios->internal_name != NULL) &&
|
||||||
|
(bios->files_no != 0)) {
|
||||||
printf("Internal name was: %s", internal_name);
|
printf("Internal name was: %s", internal_name);
|
||||||
if (!strcmp(internal_name, bios->internal_name))
|
if (!strcmp(internal_name, bios->internal_name))
|
||||||
return bios->local;
|
return bios->local;
|
||||||
@@ -511,18 +510,18 @@ device_get_bios_local(const device_t *dev, const char *internal_name)
|
|||||||
uint32_t
|
uint32_t
|
||||||
device_get_bios_file_size(const device_t *dev, const char *internal_name)
|
device_get_bios_file_size(const device_t *dev, const char *internal_name)
|
||||||
{
|
{
|
||||||
const device_config_t *config = NULL;
|
|
||||||
const device_config_bios_t *bios = NULL;
|
|
||||||
|
|
||||||
if (dev != NULL) {
|
if (dev != NULL) {
|
||||||
config = dev->config;
|
const device_config_t *config = dev->config;
|
||||||
if (config != NULL) {
|
if (config != NULL) {
|
||||||
while (config->type != CONFIG_END) {
|
while (config->type != CONFIG_END) {
|
||||||
if (config->type == CONFIG_BIOS) {
|
if (config->type == CONFIG_BIOS) {
|
||||||
bios = config->bios;
|
const device_config_bios_t *bios = (const device_config_bios_t *) config->bios;
|
||||||
|
|
||||||
/* Go through the ROM's in the device configuration. */
|
/* Go through the ROM's in the device configuration. */
|
||||||
while (bios->files_no != 0) {
|
while ((bios != NULL) &&
|
||||||
|
(bios->name != NULL) &&
|
||||||
|
(bios->internal_name != NULL) &&
|
||||||
|
(bios->files_no != 0)) {
|
||||||
if (!strcmp(internal_name, bios->internal_name))
|
if (!strcmp(internal_name, bios->internal_name))
|
||||||
return bios->size;
|
return bios->size;
|
||||||
bios++;
|
bios++;
|
||||||
@@ -539,18 +538,20 @@ device_get_bios_file_size(const device_t *dev, const char *internal_name)
|
|||||||
const char *
|
const char *
|
||||||
device_get_bios_file(const device_t *dev, const char *internal_name, int file_no)
|
device_get_bios_file(const device_t *dev, const char *internal_name, int file_no)
|
||||||
{
|
{
|
||||||
const device_config_t *config = NULL;
|
|
||||||
const device_config_bios_t *bios = NULL;
|
const device_config_bios_t *bios = NULL;
|
||||||
|
|
||||||
if (dev != NULL) {
|
if (dev != NULL) {
|
||||||
config = dev->config;
|
const device_config_t *config = dev->config;
|
||||||
if (config != NULL) {
|
if (config != NULL) {
|
||||||
while (config->type != CONFIG_END) {
|
while (config->type != CONFIG_END) {
|
||||||
if (config->type == CONFIG_BIOS) {
|
if (config->type == CONFIG_BIOS) {
|
||||||
bios = config->bios;
|
const device_config_bios_t *bios = (const device_config_bios_t *) config->bios;
|
||||||
|
|
||||||
/* Go through the ROM's in the device configuration. */
|
/* Go through the ROM's in the device configuration. */
|
||||||
while (bios->files_no != 0) {
|
while ((bios != NULL) &&
|
||||||
|
(bios->name != NULL) &&
|
||||||
|
(bios->internal_name != NULL) &&
|
||||||
|
(bios->files_no != 0)) {
|
||||||
if (!strcmp(internal_name, bios->internal_name)) {
|
if (!strcmp(internal_name, bios->internal_name)) {
|
||||||
if (file_no < bios->files_no)
|
if (file_no < bios->files_no)
|
||||||
return bios->files[file_no];
|
return bios->files[file_no];
|
||||||
|
|||||||
@@ -242,8 +242,12 @@ DeviceConfig::ProcessConfig(void *dc, const void *c, const bool is_dep)
|
|||||||
int currentIndex = -1;
|
int currentIndex = -1;
|
||||||
|
|
||||||
q = 0;
|
q = 0;
|
||||||
for (auto *bios = config->bios; (bios != nullptr) && (bios->name != nullptr) &&
|
for (auto *bios = config->bios; (bios != nullptr) &&
|
||||||
(strlen(bios->name) > 0); ++bios) {
|
(bios->name != nullptr) &&
|
||||||
|
(bios->internal_name != nullptr) &&
|
||||||
|
(strlen(bios->name) > 0) &&
|
||||||
|
(strlen(bios->internal_name) > 0) &&
|
||||||
|
(bios->files_no > 0); ++bios) {
|
||||||
p = 0;
|
p = 0;
|
||||||
for (int d = 0; d < bios->files_no; d++)
|
for (int d = 0; d < bios->files_no; d++)
|
||||||
p += !!rom_present(const_cast<char *>(bios->files[d]));
|
p += !!rom_present(const_cast<char *>(bios->files[d]));
|
||||||
|
|||||||
Reference in New Issue
Block a user