summaryrefslogtreecommitdiffstats
path: root/src/include/device/pci_type.h
blob: 088693c8b21f4787d0f9a7ca02406bc2781a8528 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* SPDX-License-Identifier: GPL-2.0-only */
/* This file is part of the coreboot project. */

#ifndef DEVICE_PCI_TYPE_H
#define DEVICE_PCI_TYPE_H

#include <stdint.h>

typedef u32 pci_devfn_t;

/* Convert pci_devfn_t to offset in MMCONF space.
 * As it is one-to-one,  nothing needs to be done. */
#define PCI_DEVFN_OFFSET(x) ((x))

#define PCI_DEV(SEGBUS, DEV, FN) ( \
	(((SEGBUS) & 0xFFF) << 20) | \
	(((DEV) & 0x1F) << 15) | \
	(((FN)  & 0x07) << 12))

#define PCI_DEV_INVALID (0xffffffffU)

#if 1
/* FIXME: For most of the time in ramstage, we get valid device pointer
 * from calling the driver entry points. The assert should only be used
 * with searches like pcidev_behind(), and only if caller does not make
 * the check themselves.
 */
#define PCI_BDF(dev) pcidev_assert((dev))
#else
#define PCI_BDF(dev) pcidev_bdf((dev))
#endif

#endif /* DEVICE_PCI_TYPE_H */