+/* device copied from sys/compat/linuxkpi/common/include/linux/pci.h */
+struct device {
+#ifndef __FBSD__
+ struct device *parent;
+ struct list_head irqents;
+#endif /*__FBSD__*/
+ device_t bsddev;
+#ifndef __FBSD__
+ /*
+ * The following flag is used to determine if the LinuxKPI is
+ * responsible for detaching the BSD device or not. If the
+ * LinuxKPI got the BSD device using devclass_get_device(), it
+ * must not try to detach or delete it, because it's already
+ * done somewhere else.
+ */
+ bool bsddev_attached_here;
+ struct device_driver *driver;
+ struct device_type *type;
+ dev_t devt;
+ struct class *class;
+ void (*release)(struct device *dev);
+ struct kobject kobj;
+ uint64_t *dma_mask;
+ void *driver_data;
+ unsigned int irq;
+#define LINUX_IRQ_INVALID 65535
+ unsigned int irq_start;
+ unsigned int irq_end;
+ const struct attribute_group **groups;
+ struct fwnode_handle *fwnode;
+
+ spinlock_t devres_lock;
+ struct list_head devres_head;
+#endif /*__FBSD__*/
+};
+
+/* pci_dev copied from sys/compat/linuxkpi/common/include/linux/pci.h */
+struct pci_dev {
+ struct device dev;
+#ifndef __FBSD__
+ struct list_head links;
+ struct pci_driver *pdrv;
+ struct pci_bus *bus;
+ uint64_t dma_mask;
+#endif
+ uint16_t device;
+ uint16_t vendor;
+#ifndef __FBSD__
+ uint16_t subsystem_vendor;
+ uint16_t subsystem_device;
+ unsigned int irq;
+#endif
+ unsigned int devfn;
+#ifndef __FBSD__
+ uint32_t class;
+ uint8_t revision;
+ bool msi_enabled;
+#endif
+};
+/* amdgpu_device copied from <https://github.com/freebsd/drm-kmod/blob/750746f938420b1351a39fe864e7d41ae5ae7648/drivers/gpu/drm/amd/amdgpu/amdgpu.h>*/
+/* AMD_ACPI_DESCRIPTION_HEADER copied from <https://github.com/freebsd/drm-kmod/blob/750746f938420b1351a39fe864e7d41ae5ae7648/drivers/gpu/drm/amd/include/atombios.h>*/
+typedef struct {
+ ULONG Signature;
+ ULONG TableLength; //Length
+ UCHAR Revision;
+ UCHAR Checksum;
+ UCHAR OemId[6];
+ UCHAR OemTableId[8]; //UINT64 OemTableId;
+ ULONG OemRevision;
+ ULONG CreatorId;
+ ULONG CreatorRevision;
+} AMD_ACPI_DESCRIPTION_HEADER;
+
+/* UEFI_ACPI_VFCT copied from <https://github.com/freebsd/drm-kmod/blob/750746f938420b1351a39fe864e7d41ae5ae7648/drivers/gpu/drm/amd/include/atombios.h>*/
+typedef struct {
+ AMD_ACPI_DESCRIPTION_HEADER SHeader;
+ UCHAR TableUUID[16]; //0x24
+ ULONG VBIOSImageOffset; //0x34. Offset to the first GOP_VBIOS_CONTENT block from the beginning of the stucture.
+ ULONG Lib1ImageOffset; //0x38. Offset to the first GOP_LIB1_CONTENT block from the beginning of the stucture.
+ ULONG Reserved[4]; //0x3C
+}UEFI_ACPI_VFCT;
+
+/* VFCT_IMAGE_HEADER copied from <https://github.com/freebsd/drm-kmod/blob/750746f938420b1351a39fe864e7d41ae5ae7648/drivers/gpu/drm/amd/include/atombios.h>*/
+typedef struct {
+ ULONG PCIBus; //0x4C
+ ULONG PCIDevice; //0x50
+ ULONG PCIFunction; //0x54
+ USHORT VendorID; //0x58
+ USHORT DeviceID; //0x5A
+ USHORT SSVID; //0x5C
+ USHORT SSID; //0x5E
+ ULONG Revision; //0x60
+ ULONG ImageLength; //0x64
+}VFCT_IMAGE_HEADER;
+
+
+/* GOP_VBIOS_CONTENT copied from <https://github.com/freebsd/drm-kmod/blob/750746f938420b1351a39fe864e7d41ae5ae7648/drivers/gpu/drm/amd/include/atombios.h>*/
+typedef struct {
+ VFCT_IMAGE_HEADER VbiosHeader;
+ UCHAR VbiosContent[1];
+}GOP_VBIOS_CONTENT;
+
+#endif /*__FBSD__*/
+
+/*
+ * Copyright 2008 Advanced Micro Devices, Inc.
+ * Copyright 2008 Red Hat Inc.
+ * Copyright 2009 Jerome Glisse.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR