coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
iommu.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <device/device.h>
4 #include <device/pci.h>
5 #include <device/pci_ids.h>
6 #include <lib.h>
7 
8 static void iommu_read_resources(struct device *dev)
9 {
10  struct resource *res;
11 
12  /* Get the normal pci resources of this device */
14 
15  /* IOMMU MMIO registers */
16  res = new_resource(dev, 0x44);
17  res->size = 512 * 1024;
18  res->align = log2(res->size);
19  res->gran = log2(res->size);
20  res->limit = 0xffffffff; /* 4G */
21  res->flags = IORESOURCE_MEM;
22 }
23 
24 static struct device_operations iommu_ops = {
26  .set_resources = pci_dev_set_resources,
27  .enable_resources = pci_dev_enable_resources,
28  .ops_pci = &pci_dev_ops_pci,
29 };
30 
31 static const struct pci_driver iommu_driver __pci_driver = {
32  .ops = &iommu_ops,
33  .vendor = PCI_VID_AMD,
35 };
struct resource * new_resource(struct device *dev, unsigned int index)
See if a resource structure already exists for a given index and if not allocate one.
Definition: device_util.c:346
static int log2(u32 x)
Definition: lib.h:53
static struct device_operations iommu_ops
Definition: iommu.c:24
static void iommu_read_resources(struct device *dev)
Definition: iommu.c:8
static const struct pci_driver iommu_driver __pci_driver
Definition: iommu.c:31
void pci_dev_enable_resources(struct device *dev)
Definition: pci_device.c:721
void pci_dev_read_resources(struct device *dev)
Definition: pci_device.c:534
struct pci_operations pci_dev_ops_pci
Default device operation for PCI devices.
Definition: pci_device.c:911
void pci_dev_set_resources(struct device *dev)
Definition: pci_device.c:691
#define PCI_VID_AMD
Definition: pci_ids.h:496
#define PCI_DID_AMD_16H_MODEL_303F_NB_IOMMU
Definition: pci_ids.h:512
#define IORESOURCE_MEM
Definition: resource.h:10
void(* read_resources)(struct device *dev)
Definition: device.h:39
Definition: device.h:107
unsigned long flags
Definition: resource.h:49
unsigned char align
Definition: resource.h:51
resource_t limit
Definition: resource.h:47
unsigned char gran
Definition: resource.h:52
resource_t size
Definition: resource.h:46