[v0.11] Adding uarch backend for intel iGPUs
This commit is contained in:
13
src/intel/chips.hpp
Normal file
13
src/intel/chips.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef __INTEL_GPUCHIPS__
|
||||
#define __INTEL_GPUCHIPS__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef uint32_t GPUCHIP;
|
||||
|
||||
enum {
|
||||
CHIP_UNKNOWN_INTEL,
|
||||
CHIP_UHDG_620,
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "intel.hpp"
|
||||
#include "uarch.hpp"
|
||||
#include "chips.hpp"
|
||||
#include "../common/pci.hpp"
|
||||
#include "../common/global.hpp"
|
||||
|
||||
@@ -11,8 +12,11 @@ struct gpu_info* get_gpu_info_intel() {
|
||||
const char* name = "UHD Graphics XXX";
|
||||
|
||||
gpu->vendor = GPU_VENDOR_INTEL;
|
||||
gpu->name = (char *) emalloc(sizeof(char) * (strlen(name) + 1));
|
||||
strcpy(gpu->name, name);
|
||||
|
||||
struct pci_dev *devices = get_pci_devices_from_pciutils();
|
||||
gpu->pci = get_pci_from_pciutils(devices, PCI_VENDOR_ID_INTEL);
|
||||
gpu->arch = get_uarch_from_pci(gpu->pci);
|
||||
gpu->name = get_name_from_uarch(gpu->arch);
|
||||
|
||||
return gpu;
|
||||
}
|
||||
|
||||
17
src/intel/pci.cpp
Normal file
17
src/intel/pci.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "pci.hpp"
|
||||
#include "chips.hpp"
|
||||
#include "../common/global.hpp"
|
||||
#include "../common/pci.hpp"
|
||||
|
||||
#define CHECK_PCI_START if (false) {}
|
||||
#define CHECK_PCI(pci, id, chip) \
|
||||
else if (pci->device_id == id) return chip;
|
||||
#define CHECK_PCI_END else { printBug("TODOO"); return CHIP_UNKNOWN_INTEL; }
|
||||
|
||||
GPUCHIP get_chip_from_pci(struct pci* pci) {
|
||||
CHECK_PCI_START
|
||||
CHECK_PCI(pci, 0x5917, CHIP_UHDG_620)
|
||||
CHECK_PCI_END
|
||||
}
|
||||
20
src/intel/pci.hpp
Normal file
20
src/intel/pci.hpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef __PCI_INTEL__
|
||||
#define __PCI_INTEL__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../common/pci.hpp"
|
||||
#include "chips.hpp"
|
||||
|
||||
/*
|
||||
* doc: https://wiki.osdev.org/PCI#Class_Codes
|
||||
* https://pci-ids.ucw.cz/read/PC
|
||||
*/
|
||||
#define PCI_VENDOR_ID_INTEL 0x8086
|
||||
|
||||
struct pci;
|
||||
|
||||
struct pci* get_pci_from_pciutils(struct pci_dev *devices);
|
||||
GPUCHIP get_chip_from_pci(struct pci* pci);
|
||||
|
||||
#endif
|
||||
59
src/intel/uarch.cpp
Normal file
59
src/intel/uarch.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
#include <stdint.h>
|
||||
#include <cstddef>
|
||||
#include <string.h>
|
||||
|
||||
#include "../common/uarch.hpp"
|
||||
#include "../common/global.hpp"
|
||||
#include "../common/gpu.hpp"
|
||||
#include "chips.hpp"
|
||||
|
||||
// Data not available
|
||||
#define NA -1
|
||||
|
||||
// Unknown manufacturing process
|
||||
#define UNK -1
|
||||
|
||||
// MICROARCH values
|
||||
enum {
|
||||
UARCH_UNKNOWN,
|
||||
UARCH_GEN9,
|
||||
UARCH_GEN9_5,
|
||||
};
|
||||
|
||||
static const char *uarch_str[] = {
|
||||
/*[ARCH_UNKNOWN = */ STRING_UNKNOWN,
|
||||
/*[ARCH_GEN9] = */ "Gen9",
|
||||
/*[ARCH_GEN9.5] = */ "Gen9.5",
|
||||
};
|
||||
|
||||
#define CHECK_UARCH_START if (false) {}
|
||||
#define CHECK_UARCH(arch, chip_, str, uarch, process) \
|
||||
else if (arch->chip == chip_) fill_uarch(arch, str, uarch, process);
|
||||
#define CHECK_UARCH_END else { printBug("map_chip_to_uarch: Unknown chip id: %d", arch->chip); fill_uarch(arch, STRING_UNKNOWN, UARCH_UNKNOWN, 0); }
|
||||
|
||||
void fill_uarch(struct uarch* arch, char const *str, MICROARCH u, uint32_t process) {
|
||||
arch->chip_str = (char *) emalloc(sizeof(char) * (strlen(str)+1));
|
||||
strcpy(arch->chip_str, str);
|
||||
arch->uarch = u;
|
||||
arch->process = process;
|
||||
}
|
||||
|
||||
void map_chip_to_uarch(struct uarch* arch) {
|
||||
CHECK_UARCH_START
|
||||
CHECK_UARCH(arch, CHIP_UHDG_620, "UHD Graphics 620", UARCH_GEN9_5, 14)
|
||||
CHECK_UARCH_END
|
||||
}
|
||||
|
||||
struct uarch* get_uarch_from_pci(struct pci* pci) {
|
||||
struct uarch* arch = (struct uarch*) emalloc(sizeof(struct uarch));
|
||||
|
||||
arch->chip_str = NULL;
|
||||
arch->chip = get_chip_from_pci(pci);
|
||||
map_chip_to_uarch(arch);
|
||||
|
||||
return arch;
|
||||
}
|
||||
|
||||
char* get_name_from_uarch(struct uarch* arch) {
|
||||
return arch->chip_str;
|
||||
}
|
||||
@@ -3,4 +3,9 @@
|
||||
|
||||
#include "../common/gpu.hpp"
|
||||
|
||||
struct uarch;
|
||||
|
||||
struct uarch* get_uarch_from_pci(struct pci* pci);
|
||||
char* get_name_from_uarch(struct uarch* arch);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user