Blackwell die, system, and VRAM temps.

Code reorganization to better support non-iCX cards.
This commit is contained in:
2026-09-30 00:16:02 -07:00
parent cecc34f0a6
commit bfbc978da8
11 changed files with 381 additions and 222 deletions
+39
View File
@@ -2,6 +2,10 @@
#include <string.h>
#include <stdlib.h>
#include <limits.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include "card.h"
@@ -29,6 +33,7 @@ unsigned short read_pci_id(char *device_path, char *field)
return (unsigned short)strtoul(buf, NULL, 16);
}
/* Read a PCI ID from the name of an Nvidia i2c device */
char *read_nvidia_pci_address(char *device_path)
{
char file_path[PATH_MAX];
@@ -55,3 +60,37 @@ char *read_nvidia_pci_address(char *device_path)
return ret;
}
/* Open an mmap to the BAR0 of a PCI device using its /sys/bus/pci device files */
void mmap_bar0(struct card_info *card)
{
char resource_path[PATH_MAX];
snprintf(resource_path, sizeof(resource_path), "%s/resource0", card->pci_dev_path);
/* Open FD on the resource file */
int fd = open(resource_path, O_RDONLY);
if (fd == -1) {
printf("Unable to open %s\n", resource_path);
card->bar0_mmap = NULL;
return;
}
/* Figure out the size of BAR0 fomr the size of the resource file */
struct stat st;
if (fstat(fd, &st) == -1) {
printf("Unable to stat %s\n", resource_path);
close(fd);
card->bar0_mmap = NULL;
return;
}
/* mmap the bar0 resource file */
card->bar0_mmap = mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
if (card->bar0_mmap == MAP_FAILED) {
printf("Unable to mmap %s\n", resource_path);
card->bar0_mmap = NULL;
}
/* mmap stays open after the FD has been closed */
close(fd);
}