mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-05 22:00:11 +01:00
nouveau: add nv_device_uuid
Cc: mesa-stable Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30455>
This commit is contained in:
parent
9c15875d4d
commit
826d00617c
1 changed files with 24 additions and 0 deletions
|
|
@ -1,6 +1,9 @@
|
|||
#ifndef NV_DEVINFO_H
|
||||
#define NV_DEVINFO_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "util/macros.h"
|
||||
|
||||
#define NVIDIA_VENDOR_ID 0x10de
|
||||
|
|
@ -46,4 +49,25 @@ struct nv_device_info {
|
|||
uint64_t bar_size_B;
|
||||
};
|
||||
|
||||
static inline void
|
||||
nv_device_uuid(const struct nv_device_info *info, uint8_t *uuid, size_t len, bool vm_bind)
|
||||
{
|
||||
uint16_t vendor_id = NVIDIA_VENDOR_ID;
|
||||
|
||||
assert(len >= 16);
|
||||
|
||||
memset(uuid, 0, len);
|
||||
memcpy(&uuid[0], &info->chipset, 2);
|
||||
memcpy(&uuid[2], &vendor_id, 2);
|
||||
memcpy(&uuid[4], &info->device_id, 2);
|
||||
|
||||
if (info->type != NV_DEVICE_TYPE_SOC) {
|
||||
memcpy(&uuid[6], &info->pci.domain, 2);
|
||||
uuid[8] = info->pci.bus;
|
||||
uuid[9] = info->pci.dev;
|
||||
uuid[10] = info->pci.func;
|
||||
}
|
||||
uuid[11] = vm_bind;
|
||||
}
|
||||
|
||||
#endif /* NV_DEVINFO_H */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue