From f7384bf0851fff772562fb622e4c8fcc55289128 Mon Sep 17 00:00:00 2001 From: SarahW Date: Sat, 24 Feb 2018 15:52:28 +0000 Subject: [PATCH] Display warning when a PCI device can not be initialised due to insufficient available PCI slots. --- src/device.c | 3 +++ src/device.h | 2 ++ src/pci.c | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/src/device.c b/src/device.c index c94b7b2..1e0572f 100644 --- a/src/device.c +++ b/src/device.c @@ -9,6 +9,7 @@ static void *device_priv[256]; static device_t *devices[256]; static device_t *current_device; +char *current_device_name = NULL; void device_init() { @@ -27,6 +28,7 @@ void device_add(device_t *d) fatal("device_add : too many devices\n"); current_device = d; + current_device_name = d->name; if (d->init != NULL) { @@ -37,6 +39,7 @@ void device_add(device_t *d) devices[c] = d; device_priv[c] = priv; + current_device_name = NULL; } void device_close_all() diff --git a/src/device.h b/src/device.h index 67bdda1..38a46bc 100644 --- a/src/device.h +++ b/src/device.h @@ -44,6 +44,8 @@ void device_speed_changed(); void device_force_redraw(); void device_add_status_info(char *s, int max_len); +extern char *current_device_name; + int device_get_config_int(char *name); char *device_get_config_string(char *name); diff --git a/src/pci.c b/src/pci.c index 8e9694d..8102fd7 100644 --- a/src/pci.c +++ b/src/pci.c @@ -1,4 +1,5 @@ #include "ibm.h" +#include "device.h" #include "io.h" #include "mem.h" #include "pic.h" @@ -218,5 +219,9 @@ int pci_add(uint8_t (*read)(int func, int addr, void *priv), void (*write)(int f } } + if (current_device_name) + warning("Failed to initialise PCI device '%s' due to insufficient available slots", current_device_name); + else + warning("Failed to initialise PCI device due to insufficient available slots"); return -1; }