class PciDev : public Module, PciDevIf

common/pci_dev.cc:
 
#include "pci.h"
#include "pci_dev.h"
bool dev_check_args();
bool dev_parse_arg(const char *arg);
bool dev_module_added(module_t *target, const char *target_name);
bool dev_module_deleted(module_t *target, const char *target_name);
int  dev_cfg_access(uint64_t offset, bool_t wr, uint32_t size, uint64_t *buf);
int  dev_interrupt_in(bool_t set, int dev_type, int dev_number, int line);
int  dev_write_le(uint8_t* mem, uint64_t *buf, uint64_t offset, uint32_t size);
int  dev_read_le(uint64_t *buf, uint8_t* mem, uint64_t offset, uint32_t size);
void dev_set_space(pci_space_t, uint64_t base, uint64_t size, int bar);
int  dev_dma_out(uint64_t vaddr, void *data, long count);
int  dev_dma_in(uint64_t vaddr, void *data, long count);
int  dev_set_int_pin(int pin, bool raise);
int  dev_set_int(bool raise);
const char *getBusName() { return bus_name ? bus_name : ""; };
int getDevice() { return device; };
int getFunction() { return function; };
virtual bool_t dump(FILE *);
virtual bool_t restore(FILE *);
int *interrupt_device_number;
int slot_irl[4];

Description

This is the base class for all PCI devices. (See modules/sample for an example.)

For example, the class hierarchy for device 'Sample' is shown below:

   Module
     PciDev (+ PciDevIf)
       Sample

PciDev handles some of the PCI device interfaces. Most interfaces, however, are handled in the device class (Sample). It is the responsibility of the device to call PciDev functions at various places.

dev_check_args and dev_parse_arg handle common arguments.

dev_module_added and dev_module_deleted handle configuration changes related to the PCI bus connection.

dev_cfg_access handles configuration space accesses common to all devices.

dev_interrupt_in requests a CPU interrupt. Interrupt resources are requested during initialization by setting interrupt_device_number and slot_irl. (See modules/serial/serial_mod.cc for an example.)

dev_set_int_pin and dev_set_int request an interrupt on pin A, B, C, or D. The second call uses the default pin set in configuration space (CONFIG_INTERRUPT_PIN, 0x3d). Interrupt resources are allocated automatically for these four pins.

dev_write_le and dev_read_le are utilities that convert between big and little endian.

dev_set_space initializes a Base Address Register (BAR). Devices typically have a fixed (or maximum) I/O or memory size. This call associates a size and PCI space type with a BAR.

dev_dma_out and dev_dma_in request DMA I/O to or from physical memory. The requests are passed upstream, through the PCI bus, to the host bridge (for example, schizo). The host bridge translates PCI addresses to physical memory addresses using its I/O MMU.

dump and restore handle DR for PCI devices. If a device also defines dump, it must call PciDev::dump() explicitly. Same for restore. See modules ll, serial, or parrot for examples.