gddr6x temp reading rtx 4090

This commit is contained in:
Ole Algoritme
2022-11-27 05:53:00 +01:00
parent 01b3926703
commit 58e52f4125
2 changed files with 19 additions and 17 deletions

18
gddr6.c
View File

@@ -54,31 +54,31 @@ int main(int argc, char **argv) {
} }
if (cnum >= nva_cardsnum) { if (cnum >= nva_cardsnum) {
if (nva_cardsnum) if (nva_cardsnum)
fprintf (stderr, "No valid card.\n"); fprintf (stderr, "No valid card.\n");
else else
fprintf (stderr, "No cards found.\n"); fprintf (stderr, "No cards found.\n");
return 1; return 1;
} }
if (mask & NVIDIA_MMIO_MASK_PMC) { if (mask & NVIDIA_MMIO_MASK_PMC) {
uint32_t pmc_boot_0 = nva_rd32(cnum, NV_PMC_BOOT_0); uint32_t pmc_boot_0 = nva_rd32(cnum, NV_PMC_BOOT_0);
struct pmc_id id; struct pmc_id id;
PMC_ID(pmc_boot_0, &id); PMC_ID(pmc_boot_0, &id);
switch (id.gpu_id) { switch (id.gpu_id) {
uint32_t offset; uint32_t offset;
case 0xb72: { // ga102 case 0xb72: { // ga102
// TODO: temps over 100 might fail // TODO: temps over 100 might fail
offset = 0x0000E2A8; offset = 0x0000E2A8;
read_temps(cnum, offset); read_temps(cnum, offset);
} }
break; break;
case 0xb74: { // ga104 case 0xb74: { // ga104
offset = 0x0000EE50; offset = 0x0000EE50;
read_temps(cnum, offset); read_temps(cnum, offset);
} }
break; break;
default: default:

View File

@@ -7,21 +7,23 @@
#include <fcntl.h> #include <fcntl.h>
#include <sys/mman.h> #include <sys/mman.h>
int main(int argc, char **argv)
int main(int argc, char **argv)
{ {
int fd; int fd;
int map_size = 4096UL; int map_size = 4096UL;
void *map_base, *virt_addr; void *map_base, *virt_addr;
uint32_t read_result, base_offset, temp; uint32_t read_result, base_offset, temp;
uint32_t bar = 0xFB000000; //uint32_t bar = 0xFB000000; // GA102 + GA104
uint32_t offset = bar + 0x0000E2A8; // GA102 uint32_t bar = 0xEC000000; // AD102 (RTX 4090)
uint32_t offset = bar + 0x0000E2A8; // GA102 + AD102
//uint32_t offset = bar + 0x0000EE50; // GA104 //uint32_t offset = bar + 0x0000EE50; // GA104
char *MEM_RES = "\x2f\x64\x65\x76\x2f\x6d\x65\x6d"; char *MEM_RES = "\x2f\x64\x65\x76\x2f\x6d\x65\x6d";
while (1) while (1)
{ {
if ((fd = open(MEM_RES, O_RDWR | O_SYNC)) == -1) if ((fd = open(MEM_RES, O_RDWR | O_SYNC)) == -1)
{ {
printf("Can't read memory. Are you r00t?\n"); printf("Can't read memory. Are you r00t?\n");
exit(-1); exit(-1);
@@ -30,7 +32,7 @@ int main(int argc, char **argv)
base_offset = offset & ~(sysconf(_SC_PAGE_SIZE)-1); base_offset = offset & ~(sysconf(_SC_PAGE_SIZE)-1);
map_base = mmap(0, map_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, base_offset); map_base = mmap(0, map_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, base_offset);
if (!map_base) if (!map_base)
{ {
printf("Can't map memory. Are you r00t?\n"); printf("Can't map memory. Are you r00t?\n");
exit(-1); exit(-1);
@@ -42,7 +44,7 @@ int main(int argc, char **argv)
printf("\rGDDR6X VRAM Temp: %d°c", temp); printf("\rGDDR6X VRAM Temp: %d°c", temp);
fflush(stdout); fflush(stdout);
if (munmap(map_base, map_size) == -1) if (munmap(map_base, map_size) == -1)
{ {
printf("Can't unmap memory!\n"); printf("Can't unmap memory!\n");
exit(-1); exit(-1);
@@ -53,4 +55,4 @@ int main(int argc, char **argv)
} }
return 0; return 0;
} }