diff options
author | Simon Quigley <tsimonq2@ubuntu.com> | 2017-06-19 14:38:31 -0500 |
---|---|---|
committer | Simon Quigley <tsimonq2@ubuntu.com> | 2017-06-19 14:38:31 -0500 |
commit | a08438bda21b3e0d7db2db2360d040841970104d (patch) | |
tree | f8a13a1e368bfbd14fe2d9492d6d5824eb5712ce /pci.c | |
parent | 8c1612d32c5682a86216adb8c8d11ce715fe5475 (diff) |
Import Upstream version 0.3.7pre
Diffstat (limited to 'pci.c')
-rw-r--r-- | pci.c | 137 |
1 files changed, 44 insertions, 93 deletions
@@ -11,117 +11,67 @@ void hi_show_pci_info(MainWindow *mainwindow, PCIDevice *device) { - GtkWidget *hbox, *vbox, *label; gchar *buf; -#ifdef GTK2 - GtkWidget *pixmap; - - pixmap = gtk_image_new_from_file(IMG_PREFIX "pci.png"); - gtk_widget_show(pixmap); -#endif if(!device) return; - hbox = gtk_hbox_new(FALSE, 2); - gtk_container_set_border_width(GTK_CONTAINER(hbox), 4); - gtk_widget_show(hbox); - - if(mainwindow->framec) - gtk_widget_destroy(mainwindow->framec); - - gtk_container_add(GTK_CONTAINER(mainwindow->frame), hbox); - mainwindow->framec = hbox; - - gtk_frame_set_label(GTK_FRAME(mainwindow->frame), device->category); - -#ifdef GTK2 - gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, FALSE, 0); -#endif - - vbox = gtk_vbox_new(FALSE, 2); - gtk_widget_show(vbox); - gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0); + gtk_window_set_title(GTK_WINDOW(mainwindow->det_window->window), device->category); + detail_window_set_icon(mainwindow->det_window, IMG_PREFIX "pci.png"); + detail_window_set_dev_name(mainwindow->det_window, device->name); + detail_window_set_dev_type(mainwindow->det_window, device->category); -#ifdef GTK2 - buf = g_strdup_printf("<b>%s</b>", device->name); - label = gtk_label_new(buf); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_label_set_selectable(GTK_LABEL(label), TRUE); + if (device->irq) + detail_window_append_info_int(mainwindow->det_window, "IRQ", + device->irq, FALSE); - g_free(buf); -#else - label = gtk_label_new(device->name); -#endif - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - - if(device->irq) { - buf = g_strdup_printf("IRQ: %d", device->irq); - - label = gtk_label_new(buf); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - - g_free(buf); - } - if(device->io_addr) { - buf = g_strdup_printf(_("I/O address: 0x%x to 0x%x"), device->io_addr, + buf = g_strdup_printf(_("0x%x to 0x%x"), device->io_addr, device->io_addr_end); - label = gtk_label_new(buf); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - + detail_window_append_info(mainwindow->det_window, + _("I/O Address"), buf); g_free(buf); } if(device->memory) { - buf = g_strdup_printf(_("Memory: %ld %s"), + buf = g_strdup_printf(_("%d%s"), (device->memory <= 1024) ? device->memory : device->memory / 1000, (device->memory <= 1024) ? "bytes" : "KB"); - label = gtk_label_new(buf); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); + detail_window_append_info(mainwindow->det_window, + _("Memory"), buf); g_free(buf); } if(device->freq) { - buf = g_strdup_printf(_("Frequency: %dMHz"), device->freq); - - label = gtk_label_new(buf); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - - g_free(buf); - } + buf = g_strdup_printf(_("%dMHz"), device->freq); - if(device->latency) { - buf = g_strdup_printf(_("Latency: %d"), device->latency); - - label = gtk_label_new(buf); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); + detail_window_append_info(mainwindow->det_window, + _("Frequency"), buf); g_free(buf); } - if(device->bus_master) { - label = gtk_label_new(_("Bus master")); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - } + if (device->latency) + detail_window_append_info_int(mainwindow->det_window, + _("Latency"), device->latency, + FALSE); + + detail_window_append_info(mainwindow->det_window, _("Bus master"), + (gchar*)((device->bus_master) ? _("Yes") : _("No"))); - buf = g_strdup_printf(_("Bus: %d, Device: %d, Function: %d"), - device->bus, device->device, device->function); + detail_window_append_separator(mainwindow->det_window); - label = gtk_label_new(buf); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - g_free(buf); + detail_window_append_info_int(mainwindow->det_window, _("Domain"), + device->domain, FALSE); + detail_window_append_info_int(mainwindow->det_window, _("Bus"), + device->bus, FALSE); + detail_window_append_info_int(mainwindow->det_window, _("Device"), + device->device, FALSE); + detail_window_append_info_int(mainwindow->det_window, _("Function"), + device->function, FALSE); } #ifdef USE_LSPCI @@ -130,7 +80,7 @@ PCIDevice *hi_scan_pci(void) FILE *lspci; gchar buffer[256], *buf; gint n=0; - PCIDevice *pci_dev, *pci; + PCIDevice *pci_dev = NULL, *pci; pci = NULL; @@ -139,12 +89,13 @@ PCIDevice *hi_scan_pci(void) while(fgets(buffer, 256, lspci)){ buf = g_strstrip(buffer); + if(!strncmp(buf, "Flags", 5)){ gint irq=0, freq=0, latency=0, i; gchar **list; buf+=7; - + pci_dev->bus_master = FALSE; list = g_strsplit(buf, ", ", 10); @@ -155,20 +106,17 @@ PCIDevice *hi_scan_pci(void) sscanf(list[i], "IRQ %d", &irq); else if(strstr(list[i], "Mhz")) sscanf(list[i], "%dMhz", &freq); - else - if(!strncmp(list[i], "bus master", 10)) + else if(!strncmp(list[i], "bus master", 10)) pci_dev->bus_master = TRUE; else if(!strncmp(list[i], "latency", 7)) sscanf(list[i], "latency %d", &latency); } g_strfreev(list); - if (irq) pci_dev->irq = irq; - if (freq) pci_dev->freq = freq; + if (irq) pci_dev->irq = irq; + if (freq) pci_dev->freq = freq; if (latency) pci_dev->latency = latency; - } - - else if(!strncmp(buf, "Memory at", 9) && + } else if(!strncmp(buf, "Memory at", 9) && strstr(buf, "[size=")) { gulong mem; gchar unit; @@ -181,14 +129,16 @@ PCIDevice *hi_scan_pci(void) (unit == 'M') ? 1024 * 1000 : (unit == 'G') ? 1024 * 1000 * 1000 : 1; - pci_dev->memory += mem; - } else if(!strncmp(buf, "I/O", 3)){ + pci_dev->memory += mem; + + } else if(!strncmp(buf, "I/O", 3)){ guint io_addr, io_size; sscanf(buf, "I/O ports at %x [size=%d]", &io_addr, &io_size); pci_dev->io_addr = io_addr; pci_dev->io_addr_end = io_addr+io_size; + } else if((buf[0] >= '0' && buf[0] <= '9') && buf[4] == ':'){ gint bus, device, function, domain; gpointer start, end; @@ -200,6 +150,7 @@ PCIDevice *hi_scan_pci(void) sscanf(buf, "%x:%x:%x.%d", &domain, &bus, &device, &function); + pci_dev->domain = domain; pci_dev->bus = bus; pci_dev->device = device; pci_dev->function = function; |