switch from bar0 in tables to using probed bar0 pcie values #1
This commit is contained in:
68
gddr6.c
68
gddr6.c
@@ -19,43 +19,42 @@
|
||||
} while(0)
|
||||
|
||||
|
||||
// variables
|
||||
int fd;
|
||||
void *map_base;
|
||||
// variables
|
||||
int fd;
|
||||
void *map_base;
|
||||
|
||||
|
||||
// device struct
|
||||
struct device
|
||||
{
|
||||
// device struct
|
||||
struct device
|
||||
{
|
||||
uint32_t bar0;
|
||||
uint32_t offset;
|
||||
uint16_t dev_id;
|
||||
const char *vram;
|
||||
const char *arch;
|
||||
const char *name;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
// device table
|
||||
static const struct device dev_table[] =
|
||||
{
|
||||
{ .bar0 = 0xEC000000, .offset = 0x0000E2A8, .dev_id = 0x2684, .vram = "GDDR6X", .arch = "AD102", .name = "RTX 4090" },
|
||||
{ .bar0 = 0xFB000000, .offset = 0x0000E2A8, .dev_id = 0x2204, .vram = "GDDR6X", .arch = "GA102", .name = "RTX 3090" },
|
||||
{ .bar0 = 0xFA000000, .offset = 0x0000E2A8, .dev_id = 0x2204, .vram = "GDDR6X", .arch = "GA102", .name = "RTX 3090" },
|
||||
{ .bar0 = 0xFB000000, .offset = 0x0000EE50, .dev_id = 0x2484, .vram = "GDDR6", .arch = "GA104", .name = "RTX 3070" },
|
||||
{ .bar0 = 0xFB000000, .offset = 0x0000EE50, .dev_id = 0x2488, .vram = "GDDR6", .arch = "GA104", .name = "RTX 3070-LHR" },
|
||||
};
|
||||
// device table
|
||||
struct device dev_table[] =
|
||||
{
|
||||
{ .offset = 0x0000E2A8, .dev_id = 0x2684, .vram = "GDDR6X", .arch = "AD102", .name = "RTX 4090" },
|
||||
{ .offset = 0x0000E2A8, .dev_id = 0x2204, .vram = "GDDR6X", .arch = "GA102", .name = "RTX 3090" },
|
||||
{ .offset = 0x0000EE50, .dev_id = 0x2484, .vram = "GDDR6", .arch = "GA104", .name = "RTX 3070" },
|
||||
{ .offset = 0x0000EE50, .dev_id = 0x2488, .vram = "GDDR6", .arch = "GA104", .name = "RTX 3070-LHR" },
|
||||
};
|
||||
|
||||
|
||||
// prototypes
|
||||
void cleanup(int signal);
|
||||
void cleanup_sig_handler(void);
|
||||
struct device *pci_detect_dev(void);
|
||||
// prototypes
|
||||
void cleanup(int signal);
|
||||
void cleanup_sig_handler(void);
|
||||
struct device *pci_detect_dev(void);
|
||||
|
||||
|
||||
// cleanup
|
||||
void cleanup(int signal)
|
||||
{
|
||||
// cleanup
|
||||
void cleanup(int signal)
|
||||
{
|
||||
if (signal == SIGHUP || signal == SIGINT || signal == SIGTERM)
|
||||
{
|
||||
if (map_base != (void *) -1)
|
||||
@@ -64,12 +63,12 @@ void cleanup(int signal)
|
||||
close(fd);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// cleanup signal handler
|
||||
void cleanup_sig_handler(void)
|
||||
{
|
||||
// cleanup signal handler
|
||||
void cleanup_sig_handler(void)
|
||||
{
|
||||
struct sigaction sa;
|
||||
sa.sa_handler = &cleanup;
|
||||
sa.sa_flags = 0;
|
||||
@@ -83,12 +82,12 @@ void cleanup_sig_handler(void)
|
||||
|
||||
if (sigaction(SIGTERM, &sa, NULL) < 0)
|
||||
perror("Cannot handle SIGTERM");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// pci device detection
|
||||
struct device *pci_detect_dev(void)
|
||||
{
|
||||
// pci device detection
|
||||
struct device *pci_detect_dev(void)
|
||||
{
|
||||
struct pci_access *pacc = NULL;
|
||||
struct pci_dev *pci_dev = NULL;
|
||||
struct device *device = NULL;
|
||||
@@ -107,12 +106,7 @@ struct device *pci_detect_dev(void)
|
||||
if (pci_dev->device_id == dev_table[i].dev_id)
|
||||
{
|
||||
device = (struct device *) &dev_table[i];
|
||||
|
||||
if (pci_dev->base_addr[0] != device->bar0)
|
||||
{
|
||||
device->bar0 = pci_dev->base_addr[0];
|
||||
}
|
||||
|
||||
device->bar0 = (pci_dev->base_addr[0] & 0xFFFFFFFF);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user