linux/drivers/pci/access.c

// SPDX-License-Identifier: GPL-2.0
#include <linux/pci.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/ioport.h>
#include <linux/wait.h>

#include "pci.h"

/*
 * This interrupt-safe spinlock protects all accesses to PCI
 * configuration space.
 */

DEFINE_RAW_SPINLOCK();

/*
 * Wrappers for all PCI configuration access functions.  They just check
 * alignment, do locking and call the low-level functions pointed to
 * by pci_dev->ops.
 */

#define PCI_byte_BAD
#define PCI_word_BAD
#define PCI_dword_BAD

#ifdef CONFIG_PCI_LOCKLESS_CONFIG
#define pci_lock_config(f)
#define pci_unlock_config(f)
#else
#define pci_lock_config
#define pci_unlock_config
#endif

#define PCI_OP_READ(size, type, len)

#define PCI_OP_WRITE(size, type, len)

PCI_OP_READ()
PCI_OP_READ()
PCI_OP_READ()
PCI_OP_WRITE()
PCI_OP_WRITE()
PCI_OP_WRITE()

EXPORT_SYMBOL();
EXPORT_SYMBOL();
EXPORT_SYMBOL();
EXPORT_SYMBOL();
EXPORT_SYMBOL();
EXPORT_SYMBOL();

int pci_generic_config_read(struct pci_bus *bus, unsigned int devfn,
			    int where, int size, u32 *val)
{}
EXPORT_SYMBOL_GPL();

int pci_generic_config_write(struct pci_bus *bus, unsigned int devfn,
			     int where, int size, u32 val)
{}
EXPORT_SYMBOL_GPL();

int pci_generic_config_read32(struct pci_bus *bus, unsigned int devfn,
			      int where, int size, u32 *val)
{}
EXPORT_SYMBOL_GPL();

int pci_generic_config_write32(struct pci_bus *bus, unsigned int devfn,
			       int where, int size, u32 val)
{}
EXPORT_SYMBOL_GPL();

/**
 * pci_bus_set_ops - Set raw operations of pci bus
 * @bus:	pci bus struct
 * @ops:	new raw operations
 *
 * Return previous raw operations
 */
struct pci_ops *pci_bus_set_ops(struct pci_bus *bus, struct pci_ops *ops)
{}
EXPORT_SYMBOL();

/*
 * The following routines are to prevent the user from accessing PCI config
 * space when it's unsafe to do so.  Some devices require this during BIST and
 * we're required to prevent it during D-state transitions.
 *
 * We have a bit per device to indicate it's blocked and a global wait queue
 * for callers to sleep on until devices are unblocked.
 */
static DECLARE_WAIT_QUEUE_HEAD(pci_cfg_wait);

static noinline void pci_wait_cfg(struct pci_dev *dev)
	__must_hold(&pci_lock)
{}

/* Returns 0 on success, negative values indicate error. */
#define PCI_USER_READ_CONFIG(size, type)

/* Returns 0 on success, negative values indicate error. */
#define PCI_USER_WRITE_CONFIG(size, type)

PCI_USER_READ_CONFIG()
PCI_USER_READ_CONFIG()
PCI_USER_READ_CONFIG()
PCI_USER_WRITE_CONFIG()
PCI_USER_WRITE_CONFIG()
PCI_USER_WRITE_CONFIG()

/**
 * pci_cfg_access_lock - Lock PCI config reads/writes
 * @dev:	pci device struct
 *
 * When access is locked, any userspace reads or writes to config
 * space and concurrent lock requests will sleep until access is
 * allowed via pci_cfg_access_unlock() again.
 */
void pci_cfg_access_lock(struct pci_dev *dev)
{}
EXPORT_SYMBOL_GPL();

/**
 * pci_cfg_access_trylock - try to lock PCI config reads/writes
 * @dev:	pci device struct
 *
 * Same as pci_cfg_access_lock, but will return 0 if access is
 * already locked, 1 otherwise. This function can be used from
 * atomic contexts.
 */
bool pci_cfg_access_trylock(struct pci_dev *dev)
{}
EXPORT_SYMBOL_GPL();

/**
 * pci_cfg_access_unlock - Unlock PCI config reads/writes
 * @dev:	pci device struct
 *
 * This function allows PCI config accesses to resume.
 */
void pci_cfg_access_unlock(struct pci_dev *dev)
{}
EXPORT_SYMBOL_GPL();

static inline int pcie_cap_version(const struct pci_dev *dev)
{}

bool pcie_cap_has_lnkctl(const struct pci_dev *dev)
{}

bool pcie_cap_has_lnkctl2(const struct pci_dev *dev)
{}

static inline bool pcie_cap_has_sltctl(const struct pci_dev *dev)
{}

bool pcie_cap_has_rtctl(const struct pci_dev *dev)
{}

static bool pcie_capability_reg_implemented(struct pci_dev *dev, int pos)
{}

/*
 * Note that these accessor functions are only for the "PCI Express
 * Capability" (see PCIe spec r3.0, sec 7.8).  They do not apply to the
 * other "PCI Express Extended Capabilities" (AER, VC, ACS, MFVC, etc.)
 */
int pcie_capability_read_word(struct pci_dev *dev, int pos, u16 *val)
{}
EXPORT_SYMBOL();

int pcie_capability_read_dword(struct pci_dev *dev, int pos, u32 *val)
{}
EXPORT_SYMBOL();

int pcie_capability_write_word(struct pci_dev *dev, int pos, u16 val)
{}
EXPORT_SYMBOL();

int pcie_capability_write_dword(struct pci_dev *dev, int pos, u32 val)
{}
EXPORT_SYMBOL();

int pcie_capability_clear_and_set_word_unlocked(struct pci_dev *dev, int pos,
						u16 clear, u16 set)
{}
EXPORT_SYMBOL();

int pcie_capability_clear_and_set_word_locked(struct pci_dev *dev, int pos,
					      u16 clear, u16 set)
{}
EXPORT_SYMBOL();

int pcie_capability_clear_and_set_dword(struct pci_dev *dev, int pos,
					u32 clear, u32 set)
{}
EXPORT_SYMBOL();

int pci_read_config_byte(const struct pci_dev *dev, int where, u8 *val)
{}
EXPORT_SYMBOL();

int pci_read_config_word(const struct pci_dev *dev, int where, u16 *val)
{}
EXPORT_SYMBOL();

int pci_read_config_dword(const struct pci_dev *dev, int where,
					u32 *val)
{}
EXPORT_SYMBOL();

int pci_write_config_byte(const struct pci_dev *dev, int where, u8 val)
{}
EXPORT_SYMBOL();

int pci_write_config_word(const struct pci_dev *dev, int where, u16 val)
{}
EXPORT_SYMBOL();

int pci_write_config_dword(const struct pci_dev *dev, int where,
					 u32 val)
{}
EXPORT_SYMBOL();

void pci_clear_and_set_config_dword(const struct pci_dev *dev, int pos,
				    u32 clear, u32 set)
{}
EXPORT_SYMBOL();