From: Jinhyung Choi Date: Fri, 18 Dec 2015 09:25:43 +0000 (+0900) Subject: hds: count available pci slots X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.2~122 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=05463ad8aae83dd4f49484fd4c66389eafbaccb9;p=sdk%2Femulator%2Fqemu.git hds: count available pci slots PCI slots are limited as PCI_SLOT_MAX which is 32. For the stability of using HDS, the max connection should be set. This function will be used by ECS for it. Change-Id: Id67a2550ddfffff24feb1df04a7b8b2e912237b8 Signed-off-by: Jinhyung Choi --- diff --git a/tizen/src/util/hds.c b/tizen/src/util/hds.c index f1ccec8c78..de7a33ea66 100644 --- a/tizen/src/util/hds.c +++ b/tizen/src/util/hds.c @@ -28,6 +28,8 @@ */ #include "hds.h" +#include "qmp-commands.h" +#include "hw/pci/pci.h" #include "debug_ch.h" MULTI_DEBUG_CHANNEL(qemu, hds); @@ -235,3 +237,34 @@ char* get_hds_lists(void) return list_hds; } + +int hds_get_pci_available_slot_num(void) +{ + Error *err = NULL; + PciInfoList *info; + PciDeviceInfoList *dev; + int pci_num = 0; + + info = qmp_query_pci(&err); + if (err) { + LOG_WARNING("PCI devices not supported\n"); + error_free(err); + return 0; + } + + assert(info != NULL); + assert(info->value != NULL); + + for (dev = info->value->devices; dev; dev = dev->next) { + if (dev->value->function == 0) { + pci_num++; + } + } + + error_free(err); + qapi_free_PciInfoList(info); + + LOG_INFO("# of PCI devices: %d, available: %d\n", pci_num, PCI_SLOT_MAX - pci_num); + + return PCI_SLOT_MAX - pci_num; +} diff --git a/tizen/src/util/hds.h b/tizen/src/util/hds.h index dcc8ce246a..f49323b4cf 100644 --- a/tizen/src/util/hds.h +++ b/tizen/src/util/hds.h @@ -51,5 +51,6 @@ bool is_hds_attached(const char* id); void set_hds_attached(const char* id, bool attached); char* get_hds_lists(void); +int hds_get_pci_available_slot_num(void); #endif // _HDS_