Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

pcidev_conf_write(3) [netbsd man page]

PCI(3)							   BSD Library Functions Manual 						    PCI(3)

NAME
pci -- library interface for PCI bus access LIBRARY
PCI Bus Access Library (libpci, -lpci) SYNOPSIS
#include <pci.h> int pcibus_conf_read(int pcifd, u_int bus, u_int dev, u_int func, u_int reg, pcireg_t *valp); int pcibus_conf_write(int pcifd, u_int bus, u_int dev, u_int func, u_int reg, pcireg_t val); int pcidev_conf_read(int devfd, u_int reg, pcireg_t *valp); int pcidev_conf_write(int devfd, u_int reg, pcireg_t val); char * pci_findvendor(pcireg_t id_reg); void pci_devinfo(pcireg_t id_reg, pcireg_t class_reg, char *devinfo, size_t len); void pci_conf_print(int pcifd, u_int bus, u_int dev, u_int func); DESCRIPTION
The pci library provides support for accessing the PCI bus by user programs. These functions are available in the libpci library. Programs should be linked with -lpci. CONFIGURATION SPACE FUNCTIONS
The following functions are used to access PCI configuration space: pcibus_conf_read() Access the PCI configuration register reg on the device located at bus, dev, func, and place the result in *valp. pcifd must be an open file descriptor to a PCI bus within the target PCI domain. pcibus_conf_write() Write the value specified by val into the PCI configuration register reg on the device located at bus, dev, func. pcifd must be an open file descriptor to a PCI bus within the target PCI domain. pcidev_conf_read() Access the PCI configuration register reg on the device associated with the open file descriptor devfd and place the result in *valp. pcidev_conf_write() Write the value specified by val into the PCI configuration register reg on the device associated with the open file descriptor devfd. MISCELLANEOUS FUNCTIONS
The following miscellaneous functions are available: pci_findvendor() Return an ASCII description of the PCI vendor in the PCI ID register id_reg. pci_devinfo() Return an ASCII description of the PCI vendor, PCI product, and PCI class specified by the PCI ID register id_reg and PCI class ID reg- ister class_reg. The description is placed into the buffer pointed to by devinfo; the size of that buffer is specified in len. pci_conf_print() Print the PCI configuration information for the device located at bus, dev, func. pcifd must be an open file descriptor to a PCI bus within the target PCI domain. RETURN VALUES
The pcibus_conf_read(), pcibus_conf_write(), pcidev_conf_read(), and pcidev_conf_write() functions return 0 on success and -1 on failure. The pci_findvendor() function returns NULL if the PCI vendor description cannot be found. SEE ALSO
pci(4) HISTORY
The pcibus_conf_read(), pcibus_conf_write(), pcidev_conf_read(), pcidev_conf_write(), pci_findvendor(), pci_devinfo(), and pci_conf_print() functions first appeared in NetBSD 1.6. BSD
April 24, 2004 BSD

Check Out this Related Man Page

PCI(9)							   BSD Kernel Developer's Manual						    PCI(9)

NAME
pci, pci_read_config, pci_write_config, pci_enable_busmaster, pci_disable_busmaster, pci_enable_io, pci_disable_io, pci_set_powerstate, pci_get_powerstate, pci_find_bsf, pci_find_dbsf, pci_find_device -- PCI bus interface SYNOPSIS
#include <sys/bus.h> #include <dev/pci/pcivar.h> #include <dev/pci/pcireg.h> #include <machine/pci_cfgreg.h> void pci_write_config(device_t dev, int reg, uint32_t val, int width); int pci_enable_busmaster(device_t dev); int pci_disable_busmaster(device_t dev); int pci_enable_io(device_t dev, int space); int pci_disable_io(device_t dev, int space); int pci_set_powerstate(device_t dev, int state); int pci_get_powerstate(device_t dev); uint32_t pci_read_config(device_t dev, int reg, int width); device_t pci_find_bsf(uint8_t bus, uint8_t slot, uint8_t func); device_t pci_find_dbsf(uint32_t domain, uint8_t bus, uint8_t slot, uint8_t func); device_t pci_find_device(uint16_t vendor, uint16_t device); DESCRIPTION
The pci set of functions are used for managing PCI devices. The pci_read_config() function is used to read data from the PCI configuration space of the device dev, at offset reg, with width specifying the size of the access. The pci_write_config() function is used to write the value val to the PCI configuration space of the device dev, at offset reg, with width specifying the size of the access. The pci_enable_busmaster() function enables PCI bus mastering for the device dev, by setting the PCIM_CMD_BUSMASTEREN bit in the PCIR_COMMAND register. The pci_disable_busmaster() function clears this bit. The pci_enable_io() function enables memory or I/O port address decoding for the device dev, by setting the PCIM_CMD_MEMEN or PCIM_CMD_PORTEN bit in the PCIR_COMMAND register appropriately. The pci_disable_io() function clears the appropriate bit. The space argument specifies which resource is affected; this can be either SYS_RES_MEMORY or SYS_RES_IOPORT as appropriate. NOTE: These functions should be used in preference to manually manipulating the configuration space. The pci_get_powerstate() function returns the current ACPI power state of the device dev. If the device does not support power management capabilities, then the default state of PCI_POWERSTATE_D0 is returned. The following power states are defined by ACPI: PCI_POWERSTATE_D0 State in which device is on and running. It is receiving full power from the system and delivering full functional- ity to the user. PCI_POWERSTATE_D1 Class-specific low-power state in which device context may or may not be lost. Busses in this state cannot do any- thing to the bus, to force devices to lose context. PCI_POWERSTATE_D2 Class-specific low-power state in which device context may or may not be lost. Attains greater power savings than PCI_POWERSTATE_D1. Busses in this state can cause devices to lose some context. Devices must be prepared for the bus to be in this state or higher. PCI_POWERSTATE_D3 State in which the device is off and not running. Device context is lost, and power from the device can be removed. PCI_POWERSTATE_UNKNOWN State of the device is unknown. The pci_set_powerstate() function is used to transition the device dev to the ACPI power state state. It checks to see if the device is PCI 2.2 compliant. If so, it checks the capabilities pointer to determine which power states the device supports. If the device does not have power management capabilities, the default state of PCI_POWERSTATE_D0 is set. The pci_find_bsf() function looks up the device_t of a PCI device, given its bus, slot, and func. The slot number actually refers to the number of the device on the bus, which does not necessarily indicate its geographic location in terms of a physical slot. Note that in case the system has multiple PCI domains, the pci_find_bsf() function only searches the first one. Actually, it is equivalent to: pci_find_dbsf(0, bus, slot, func); The pci_find_dbsf() function looks up the device_t of a PCI device, given its domain, bus, slot, and func. The slot number actually refers to the number of the device on the bus, which does not necessarily indicate its geographic location in terms of a physical slot. The pci_find_device() function looks up the device_t of a PCI device, given its vendor and device IDs. Note that there can be multiple matches for this search; this function only returns the first matching device. IMPLEMENTATION NOTES
The pci_addr_t type varies according to the size of the PCI bus address space on the target architecture. SEE ALSO
pci(4), pciconf(8), bus_alloc_resource(9), bus_dma(9), bus_release_resource(9), bus_setup_intr(9), bus_teardown_intr(9), devclass(9), device(9), driver(9), rman(9) "NewBus", FreeBSD Developers' Handbook, http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/developers-handbook/. Shanley and Anderson, PCI System Architecture, Addison-Wesley, 2nd Edition, ISBN 0-201-30974-2. AUTHORS
This manual page was written by Bruce M Simpson <bms@FreeBSD.org>. BUGS
The kernel PCI code has a number of references to ``slot numbers''. These do not refer to the geographic location of PCI devices, but to the device number assigned by the combination of the PCI IDSEL mechanism and the platform firmware. This should be taken note of when working with the kernel PCI code. BSD
September 30, 2007 BSD
Man Page