Main Page | Modules | Class List | File List | Class Members | File Members | Related Pages

pci.c File Reference

PCI Support. More...

#include <l4/env/errno.h>
#include <l4/generic_io/libio.h>
#include <l4/dde_linux/dde.h>
#include <linux/pci.h>
#include <linux/list.h>
#include "internal.h"
#include "__config.h"

Go to the source code of this file.

Classes

struct  pcidevs
 PCI device structure array. More...

struct  pci_pool
 the pool More...

struct  pci_page
 cacheable header for 'allocation' bytes More...


PCI memory pools (consistent DMA mappings...)

Pool allocator ...

wraps the pci_alloc_consistent page allocator, so small blocks are easily used by drivers for bus mastering controllers. This should probably be sharing the guts of the slab allocator.

#define POOL_TIMEOUT_JIFFIES   ((100 /* msec */ * HZ) / 1000)
#define POOL_POISON_BYTE   0xa7
pci_poolpci_pool_create (const char *name, struct pci_dev *pdev, size_t size, size_t align, size_t allocation, int flags)
 Create a pool of pci consistent memory blocks, for dma.

pci_pagepool_alloc_page (struct pci_pool *pool, int mem_flags)
int is_page_busy (int blocks, unsigned long *bitmap)
void pool_free_page (struct pci_pool *pool, struct pci_page *page)
void pci_pool_destroy (struct pci_pool *pool)
 Destroy a pool of pci memory blocks.

void * pci_pool_alloc (struct pci_pool *pool, int mem_flags, dma_addr_t *handle)
 Get a block of consistent memory.

pci_pagepool_find_page (struct pci_pool *pool, dma_addr_t dma)
void pci_pool_free (struct pci_pool *pool, void *vaddr, dma_addr_t dma)
 Put block back into pci pool.

void * pci_alloc_consistent (struct pci_dev *hwdev, size_t size, dma_addr_t *dma_handle)
 Allocation of PCI consistent DMA Memory.

void pci_free_consistent (struct pci_dev *hwdev, size_t size, void *vaddr, dma_addr_t dma_handle)
 Deallocation of PCI consistent DMA Memory.

int pci_set_dma_mask (struct pci_dev *dev, u64 mask)

Functions for Linux backward compatibility

This is from drivers/pci/compat.c

#define PCI_OP(rw, size, type)
 Configuration space access function creation (old interface).

int pcibios_find_device (unsigned short vendor, unsigned short device, unsigned short index, unsigned char *bus, unsigned char *devfn)
 Find ...


Module variables

 LIST_HEAD (pci_devices)
 list of all PCI devices (must be global)

pcidevs pcidevs [PCI_DEVICES]
 PCI device structure array.

pci_bus pcibus
 virtual PCI bus

int _initialized = 0
 initialization flag


Exploration of bus/attached devices and drivers

const struct pci_device_id * pci_match_device (const struct pci_device_id *ids, const struct pci_dev *dev)
 Check device against ID table.

int pci_announce_device (struct pci_driver *drv, struct pci_dev *dev)
 Check device - driver compatibility.

pci_driver * pci_dev_driver (const struct pci_dev *dev)
 Get PCI driver of given device.

int pci_register_driver (struct pci_driver *drv)
 Register PCI driver.

void pci_unregister_driver (struct pci_driver *drv)
 Unregister PCI driver.

pci_dev * pci_find_device (unsigned int vendor, unsigned int device, const struct pci_dev *from)
 Find PCI Device on vendor and device IDs.

pci_dev * pci_find_subsys (unsigned int vendor, unsigned int device, unsigned int ss_vendor, unsigned int ss_device, const struct pci_dev *from)
 Find PCI Device on vendor, subvendor, device and subdevice IDs.

pci_dev * pci_find_slot (unsigned int bus, unsigned int devfn)
 Find PCI Device on Slot.

pci_dev * pci_find_class (unsigned int class, const struct pci_dev *from)
 Find PCI Device on Class.

int pci_find_capability (struct pci_dev *dev, int cap)

Device setup (bus mastering, enable/disable)

int pci_enable_device (struct pci_dev *dev)
 Enable PCI Device.

void pci_disable_device (struct pci_dev *dev)
 Disable PCI Device.

void pci_set_master (struct pci_dev *dev)
 Set Busmastering for PCI Device.


Power Management related functions

int pci_set_power_state (struct pci_dev *dev, int state)
 Set PM State for PCI Device.


PCI device related resources

Todo:
implementation


void pci_release_region (struct pci_dev *pdev, int bar)
 Release a PCI bar : PCI device whose resources were previously reserved by pci_request_region : BAR to release.

int pci_request_region (struct pci_dev *pdev, int bar, char *res_name)
 Reserve PCI I/O and memory resource : PCI device whose resources are to be reserved : BAR to be reserved : Name to be associated with resource.

void pci_release_regions (struct pci_dev *pdev)
 Release reserved PCI I/O and memory resources : PCI device whose resources were previously reserved by pci_request_regions.

int pci_request_regions (struct pci_dev *pdev, char *res_name)
 Reserve PCI I/O and memory resources : PCI device whose resources are to be reserved : Name to be associated with resource.


Configuration space access

int pci_read_config_byte (struct pci_dev *dev, int pos, l4_uint8_t *val)
 PCI Configuration Space access - read byte.

int pci_read_config_word (struct pci_dev *dev, int pos, l4_uint16_t *val)
 PCI Configuration Space access - read word.

int pci_read_config_dword (struct pci_dev *dev, int pos, l4_uint32_t *val)
 PCI Configuration Space access - read double word.

int pci_write_config_byte (struct pci_dev *dev, int pos, l4_uint8_t val)
 PCI Configuration Space access - write byte.

int pci_write_config_word (struct pci_dev *dev, int pos, l4_uint16_t val)
 PCI Configuration Space access - write word.

int pci_write_config_dword (struct pci_dev *dev, int pos, l4_uint32_t val)
 PCI Configuration Space access - write double word.


Functions

l4io_pdev_t __pci_get_handle (struct pci_dev *linus)
 Get L4IO device handle for given device.

void __pci_io_to_linux (l4io_pci_dev_t *l4io, struct pci_dev *linus)
 Convert IO's pci_dev to Linux' pci_dev struct.

int l4dde_pci_init ()
 Initalize PCI module.


Detailed Description

PCI Support.

Date:
08/28/2003
Author:
Christian Helmuth <ch12@os.inf.tu-dresden.de>

Definition in file pci.c.


Function Documentation

l4io_pdev_t __pci_get_handle struct pci_dev *  linus  )  [inline, static]
 

Get L4IO device handle for given device.

Parameters:
linus Linux device
Returns:
l4io handle for device or 0 if not found

Definition at line 90 of file pci.c.

Referenced by l4dde_pci_init(), pci_disable_device(), pci_enable_device(), pci_read_config_byte(), pci_read_config_dword(), pci_read_config_word(), pci_set_master(), pci_set_power_state(), pci_write_config_byte(), pci_write_config_dword(), and pci_write_config_word().

void __pci_io_to_linux l4io_pci_dev_t *  l4io,
struct pci_dev *  linus
[inline, static]
 

Convert IO's pci_dev to Linux' pci_dev struct.

Parameters:
l4io IO device
linus Linux device

Test:
krishna: don't know about `struct resource' pointers?

Definition at line 102 of file pci.c.

References pcibus.

Referenced by l4dde_pci_init().

int pci_announce_device struct pci_driver *  drv,
struct pci_dev *  dev
[static]
 

Check device - driver compatibility.

Parameters:
drv device driver structure
dev PCI device structure
Returns:
1 if driver claims device; 0 otherwise

Definition at line 174 of file pci.c.

References pci_match_device().

Referenced by pci_register_driver().

const struct pci_device_id* pci_match_device const struct pci_device_id *  ids,
const struct pci_dev *  dev
 

Check device against ID table.

Parameters:
ids ID table
dev target device
Returns:
matching device id
Simple helper for device id matching check.

Definition at line 151 of file pci.c.

Referenced by pci_announce_device().

void pci_pool_free struct pci_pool pool,
void *  vaddr,
dma_addr_t  dma
 

Put block back into pci pool.

Parameters:
pool the pci pool holding the block
vaddr virtual address of block
dma dma address of block
Caller promises neither device nor driver will again touch this block unless it is first re-allocated.

Definition at line 917 of file pci.c.

References pci_pool::dev, pci_pool::flags, pci_pool::lock, pci_pool::name, pci_pool::size, and pci_pool::waitq.

void pci_release_region struct pci_dev *  pdev,
int  bar
 

Release a PCI bar : PCI device whose resources were previously reserved by pci_request_region : BAR to release.

Releases the PCI I/O and memory resources previously reserved by a successful call to pci_request_region. Call this function only after all use of the PCI regions has ceased.

Definition at line 494 of file pci.c.

References release_mem_region(), and release_region().

Referenced by pci_release_regions(), and pci_request_regions().

void pci_release_regions struct pci_dev *  pdev  ) 
 

Release reserved PCI I/O and memory resources : PCI device whose resources were previously reserved by pci_request_regions.

Releases all PCI I/O and memory resources previously reserved by a successful call to pci_request_regions. Call this function only after all use of the PCI regions has ceased.

Definition at line 557 of file pci.c.

References pci_release_region().

int pci_request_region struct pci_dev *  pdev,
int  bar,
char *  res_name
 

Reserve PCI I/O and memory resource : PCI device whose resources are to be reserved : BAR to be reserved : Name to be associated with resource.

Mark the PCI region associated with PCI device BR as being reserved by owner . Do not access any address inside the PCI regions unless this call returns successfully.

Returns 0 on success, or EBUSY on error. A warning message is also printed on failure.

Definition at line 520 of file pci.c.

References request_mem_region(), and request_region().

Referenced by pci_request_regions().

int pci_request_regions struct pci_dev *  pdev,
char *  res_name
 

Reserve PCI I/O and memory resources : PCI device whose resources are to be reserved : Name to be associated with resource.

Mark all PCI regions associated with PCI device as being reserved by owner . Do not access any address inside the PCI regions unless this call returns successfully.

Returns 0 on success, or EBUSY on error. A warning message is also printed on failure.

Definition at line 577 of file pci.c.

References pci_release_region(), and pci_request_region().


Variable Documentation

struct pci_bus pcibus [static]
 

Initial value:

{
  name:    "LINUX DDE PCI BUS",
  number:  0,
}
virtual PCI bus

Definition at line 74 of file pci.c.

Referenced by __pci_io_to_linux(), and l4dde_pci_init().


Linux DDE, written by Christian Helmuth  © 2003 Technische Universitaet Dresden