Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
4bcb37f
Add pci dep
stsdc Apr 14, 2025
c3d652a
Add libpci dep
stsdc Apr 14, 2025
0e473c7
libpci-dev
stsdc Apr 14, 2025
0cded21
missed space
stsdc Apr 14, 2025
4e76d37
Try to use LIB_VERSION
stsdc Apr 14, 2025
de6631f
Add Access and Dev structs
stsdc Apr 14, 2025
2ae3a75
wip
stsdc Apr 15, 2025
d28b3b7
Use struct in cname
stsdc Apr 15, 2025
3ad5375
Merge branch 'main' into stsdc/libpci
stsdc Apr 15, 2025
14ba09b
Add pci_scan_bus
stsdc Apr 16, 2025
db42263
Merge branch 'main' into stsdc/libpci
stsdc Apr 16, 2025
0225d12
Update structs according to ver. 3.10.0
stsdc Apr 18, 2025
709aa5f
Make pci_init a standalone function
stsdc Apr 18, 2025
79b6341
list all pci addresses
stsdc Apr 18, 2025
f04f8b2
Introduce pci_lookup_name
stsdc Apr 22, 2025
e9a2c54
remove ref
stsdc Apr 22, 2025
b9175ce
Merge branch 'main' into stsdc/libpci
stsdc Apr 24, 2025
1d5b3e2
convert Access to class
stsdc Apr 25, 2025
803e0cc
Reintroduce pci_cleanup as destroy_function for Access class
stsdc Apr 26, 2025
866a188
standalone functions are now methods of Access class
stsdc Apr 26, 2025
f40af61
Introduce class Dev; use free_function
stsdc Apr 26, 2025
3c84ebf
Return unowned nullable string in lookup_name
stsdc Apr 26, 2025
7b208dc
Introduce fill_info
stsdc Apr 26, 2025
275330a
Add Version annotations
stsdc Apr 26, 2025
377dc0a
Add subsys_vendor_id and subsys_id; add missing FILL consts
stsdc Apr 27, 2025
aee4527
Drop SessionManager and use libpci to get GPU name
stsdc Apr 30, 2025
0e653a5
fix lint
stsdc Apr 30, 2025
88c4809
Merge branch 'main' into stsdc/libpci
stsdc May 1, 2025
d520256
Reintroduce GPU monitoring; introduce multiple GPU support foundament
stsdc May 1, 2025
a144858
Fix for Intel graphics
stsdc May 2, 2025
3d731c6
A bit better debug messages
stsdc May 2, 2025
a53d166
Consider 3D cotroller as a GPU
stsdc May 2, 2025
b3d94a6
Update Resources.vala
stsdc May 2, 2025
5b63050
Add Intel GPU dummy class
stsdc May 6, 2025
e525adc
Add proper vendor name to the GPU name
stsdc May 6, 2025
2619151
Display not supported label for Intel and Nvidia gpus
stsdc May 6, 2025
b037a45
lint
stsdc May 6, 2025
b556be3
Improve comment styling for hints and docs
stsdc May 6, 2025
1a11d19
Add comment
stsdc May 6, 2025
6d3e51b
Merge branch 'main' into stsdc/libpci
stsdc May 7, 2025
889b100
Remove obsolete code
stsdc May 8, 2025
7b78697
Update src/Views/SystemView/SystemView.vala
stsdc May 8, 2025
f50b8ef
Refactoring: atomize comments; put literals into consts
stsdc May 8, 2025
0718cc9
Remove space at the start of the file
stsdc May 8, 2025
fd47986
Make it clear that Intel GPU needs implementation.
stsdc May 8, 2025
585ba6c
Add libpci-dev to readme
stsdc May 8, 2025
e03f0b5
Use pci consts from Utils
stsdc May 8, 2025
fa2c3c2
Use switch-case for GPU detection
stsdc May 9, 2025
62fbc45
Use for loop for detecting GPU
stsdc May 9, 2025
4478ad7
make sysfs path in nvidia protected
stsdc May 9, 2025
b933672
Explicit setting properties without digging into the method in the in…
ryonakano May 10, 2025
acff8e4
Compare GPU types instead of string properties
stsdc May 10, 2025
fc97d56
Merge branch 'stsdc/libpci' into ryonakano/libpci-proposal
stsdc May 10, 2025
3804207
Update names of IGPU methods
stsdc May 10, 2025
7175da7
Display pretty version of libpci
stsdc May 11, 2025
5bc7216
Use LIBPCI_* consts to display pretty version
stsdc May 12, 2025
e6e746f
Move PCI defines to independant source
ryonakano May 13, 2025
c18f0c0
Add Flags attribute to enum LookupMode
stsdc May 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
apt install -y libgala-dev libgee-0.8-dev libglib2.0-dev libgranite-dev libgtk-3-dev libhandy-1-dev \
libdbus-glib-1-dev libwnck-3-dev libgtop2-dev libwingpanel-3.0-dev libudisks2-dev \
libxnvctrl0 libxnvctrl-dev libcurl4-gnutls-dev libflatpak-dev libjson-glib-dev \
liblivechart-1-dev \
liblivechart-1-dev libpci-dev \
meson valac sassc git
- name: Build
run: |
Expand Down
2 changes: 2 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ app_dependencies = [
meson.get_compiler('vala').find_library('posix'),
meson.get_compiler('c').find_library('XNVCtrl'),
meson.get_compiler('c').find_library('X11'),
meson.get_compiler('c').find_library('pci'),
meson.get_compiler('vala').find_library('pci', dirs: vapidir),
meson.get_compiler('vala').find_library('libxnvctrl', dirs: vapidir),
]

Expand Down
14 changes: 14 additions & 0 deletions src/Monitor.vala
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,20 @@ namespace Monitor {
print (" Monitor %s \n", VCS_TAG);
print ("\n");

print ("libpci ver: %d \n", Pci.LIB_VERSION);

Pci.Dev *pci_device;
Pci.Access *pci_access;

pci_access = Pci.pci_alloc ();
Pci.pci_scan_bus (pci_access); // segfault

pci_device = pci_access.devices;
print ("%04x", pci_device.domain_16);




// add command line options
try {
var opt_context = new OptionContext ("");
Expand Down
128 changes: 128 additions & 0 deletions vapi/pci.vapi
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
[CCode (cheader_filename = "pci/pci.h", cprefix = "pci_", has_type_id = false)]
namespace Pci {

public const int LIB_VERSION;

[CCode (cname = "int", cprefix = "PCI_ACCESS_", has_type_id = false)]
public enum AccessType {
AUTO, /* Autodetection */
SYS_BUS_PCI, /* Linux /sys/bus/pci */
PROC_BUS_PCI, /* Linux /proc/bus/pci */
I386_TYPE1, /* i386 ports, type 1 */
I386_TYPE2, /* i386 ports, type 2 */
FBSD_DEVICE, /* FreeBSD /dev/pci */
AIX_DEVICE, /* /dev/pci0, /dev/bus0, etc. */
NBSD_LIBPCI, /* NetBSD libpci */
OBSD_DEVICE, /* OpenBSD /dev/pci */
DUMP, /* Dump file */
DARWIN, /* Darwin */
SYLIXOS_DEVICE, /* SylixOS pci */
HURD, /* GNU/Hurd */
WIN32_CFGMGR32, /* Win32 cfgmgr32.dll */
WIN32_KLDBG, /* Win32 kldbgdrv.sys */
WIN32_SYSDBG, /* Win32 NT SysDbg */
MMIO_TYPE1, /* MMIO ports, type 1 */
MMIO_TYPE1_EXT, /* MMIO ports, type 1 extended */
// ECAM, /* PCIe ECAM via /dev/mem */
AOS_EXPANSION, /* AmigaOS Expansion library */
MAX
}

[SimpleType, CCode (cname = "pciaddr_t", has_type_id = false)]
public struct PciAddr : uint64 { }

[CCode (cname = "pci_cap", has_type_id = false)]
public struct Cap {
Cap *next;
uint16 id; /* PCI_CAP_ID_xxx */
uint16 type; /* PCI_CAP_xxx */
uint addr; /* Position in the config space */
}

[CCode (cname = "struct pci_access", destroy_function = "pci_cleanup", has_type_id = false)]
public struct Access {
/* Options you can change: */
uint method; /* Access method */
int writeable; /* Open in read/write mode */
int buscentric; /* Bus-centric view of the world */

char *id_file_name; /* Name of ID list file (use pci_set_name_list_path()) */
int free_id_name; /* Set if id_file_name is malloced */
int numeric_ids; /* Enforce PCI_LOOKUP_NUMERIC (>1 => PCI_LOOKUP_MIXED) */

uint id_lookup_mode; /* pci_lookup_mode flags which are set automatically */
/* Default: PCI_LOOKUP_CACHE */

int debugging; /* Turn on debugging messages */

/* Functions you can override: */
// void (*error)(char *msg, ...) PCI_PRINTF (1,2) PCI_NONRET; /* Write error message and quit */
// void (*warning)(char *msg, ...) PCI_PRINTF (1,2); /* Write a warning message */
// void (*debug)(char *msg, ...) PCI_PRINTF (1,2); /* Write a debugging message */

Dev *devices; /* Devices found on this bus */

[CCode (cname = "pci_init")]
public Access (Access acess);
}

/* Initialize PCI access */
[CCode (cname = "pci_alloc")]
Access *pci_alloc ();

/* Scanning of devices */
[CCode (cname = "pci_scan_bus")]
void pci_scan_bus(Access *acc);


[CCode (cname = "struct pci_dev", has_type_id = false)]
public struct Dev {
Dev *next; /* Next device in the chain */
uint16 domain_16; /* 16-bit version of the PCI domain for backward compatibility */
/* 0xffff if the real domain doesn't fit in 16 bits */

/* Bus inside domain, device and function */
uint8 bus;
uint8 dev;
uint8 func;

/* These fields are set by pci_fill_info() */
uint known_fields; /* Set of info fields already known (see pci_fill_info()) */

/* Identity of the device */
uint16 vendor_id;
uint16 device_id;

uint16 device_class; /* PCI device class */
int irq; /* IRQ number */
PciAddr base_addr[6]; /* Base addresses including flags in lower bits */
PciAddr size[6]; /* Region sizes */
PciAddr rom_base_addr; /* Expansion ROM base address */
PciAddr rom_size; /* Expansion ROM size */
Cap *first_cap; /* List of capabilities */
char *phy_slot; /* Physical slot */
char *module_alias; /* Linux kernel module alias */
char *label; /* Device name as exported by BIOS */
int numa_node; /* NUMA node */
PciAddr flags[6]; /* PCI_IORESOURCE_* flags for regions */
PciAddr rom_flags; /* PCI_IORESOURCE_* flags for expansion ROM */
int domain; /* PCI domain (host bridge) */
PciAddr bridge_base_addr[4]; /* Bridge base addresses (without flags) */
PciAddr bridge_size[4]; /* Bridge sizes */
PciAddr bridge_flags[4]; /* PCI_IORESOURCE_* flags for bridge addresses */

/* Programming interface for device_class and revision id */
uint8 prog_if;
uint8 rev_id;

/* Subsystem vendor id and subsystem id */
uint16 subsys_vendor_id;
uint16 subsys_id;
Dev *parent; /* Parent device, does not have to be always accessible */
int no_config_access; /* No access to config space for this device */
uint32 rcd_link_cap; /* Link Capabilities register for Restricted CXL Devices */
uint16 rcd_link_status; /* Link Status register for RCD */
uint16 rcd_link_ctrl; /* Link Control register for RCD */
}

}
Loading