/tmp/l4check/full_tree/trunk/l4/pkg/dde_linux/lib/src/pci.c File Reference

PCI Support. More...

#include <l4/env/errno.h>
#include <l4/generic_io/libio.h>
#include <l4/sigma0/kip.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
struct 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.
static struct pci_pagepool_alloc_page (struct pci_pool *pool, int mem_flags)
static int is_page_busy (int blocks, unsigned long *bitmap)
static 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.
static struct 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

static struct pci_bus pcibus
 virtual PCI bus
static int _initialized = 0
 initialization flag
 LIST_HEAD (pci_devices)
 list of all PCI devices (must be global)

Functions

static l4io_pdev_t __pci_get_handle (struct pci_dev *linus)
 Get L4IO device handle for given device.
static 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 (void)
 Initalize PCI module.
Exploration of bus/attached devices and drivers
struct pci_device_id * pci_match_device (const struct pci_device_id *ids, const struct pci_dev *dev)
 Check device against ID table.
static int pci_announce_device (struct pci_driver *drv, struct pci_dev *dev)
 Check device - driver compatibility.
struct 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.
struct pci_dev * pci_find_device (unsigned int vendor, unsigned int device, const struct pci_dev *from)
 Find PCI Device on vendor and device IDs.
struct 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.
struct pci_dev * pci_find_slot (unsigned int bus, unsigned int devfn)
 Find PCI Device on Slot.
struct 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.
int pci_set_mwi (struct pci_dev *dev)
 FIXME Dummy (could also go into L4IO.
void pci_clear_mwi (struct pci_dev *dev)
 FIXME Dummy (should also go into L4IO.
Power Management related functions
int pci_set_power_state (struct pci_dev *dev, int state)
 Set PM State for PCI Device.
int pci_enable_wake (struct pci_dev *dev, u32 state, int enable)
 FIXME Dummy (could also go into L4IO.
int pci_save_state (struct pci_dev *dev, u32 *buffer)
 FIXME Dummy (could also go into L4IO.
int pci_restore_state (struct pci_dev *dev, u32 *buffer)
 FIXME Dummy (could also go into L4IO.
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.


Detailed Description

PCI Support.

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

Definition in file pci.c.


Function Documentation

static 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 91 of file pci.c.

static 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 103 of file pci.c.

static 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 175 of file pci.c.

struct pci_device_id* pci_match_device ( const struct pci_device_id *  ids,
const struct pci_dev *  dev 
) [read]

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 152 of file pci.c.

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 961 of file pci.c.

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 538 of file pci.c.

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 601 of file pci.c.

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 564 of file pci.c.

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 621 of file pci.c.


Variable Documentation

struct pci_bus pcibus [static]

Initial value:

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

Definition at line 75 of file pci.c.


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