---
name: "pci_disable_busmaster"
section: "9"
platform: "linux"
package: "freebsd-manpages"
version: "6.0-5"
release: "Debian 4.0 (Etch)"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/pci_disable_busmaster"
---

# pci\_disable\_busmaster(9)

PCI bus interface

## 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\_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\_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 functionality to the user.

- PCI\_POWERSTATE\_D1

  Class-specific low-power state in which device context may or may not be lot. Busses in this state cannot do anything 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.

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)](/pci/4.md), [pciconf(8)](/pciconf/8.md), [bus\_alloc\_resource(9)](/bus_alloc_resource/9.md), [bus\_dma(9)](/bus_dma/9.md), [bus\_release\_resource(9)](/bus_release_resource/9.md), [bus\_setup\_intr(9)](/bus_setup_intr/9.md), [bus\_teardown\_intr(9)](/bus_teardown_intr/9.md), [devclass(9)](/devclass/9.md), [device(9)](/device/9.md), [driver(9)](/driver/9.md), [rman(9)](/rman/9.md) “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.
