📄 pciio.h
字号:
/* $Id$ * * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * * Copyright (C) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved. */#ifndef _ASM_SN_PCI_PCIIO_H#define _ASM_SN_PCI_PCIIO_H/* * pciio.h -- platform-independent PCI interface */#ifdef __KERNEL__#include <linux/config.h>#include <linux/ioport.h>#include <asm/sn/ioerror.h>#include <asm/sn/driver.h>#include <asm/sn/invent.h>#include <asm/sn/hcl.h>#else#include <linux/config.h>#include <linux/ioport.h>#include <ioerror.h>#include <driver.h>#include <hcl.h>#endif#ifndef __ASSEMBLY__#ifdef __KERNEL__#include <asm/sn/dmamap.h>#include <asm/sn/alenlist.h>#else#include <dmamap.h>#include <alenlist.h>#endiftypedef int pciio_vendor_id_t;#define PCIIO_VENDOR_ID_NONE (-1)typedef int pciio_device_id_t;#define PCIIO_DEVICE_ID_NONE (-1)typedef uint8_t pciio_bus_t; /* PCI bus number (0..255) */typedef uint8_t pciio_slot_t; /* PCI slot number (0..31, 255) */typedef uint8_t pciio_function_t; /* PCI func number (0..7, 255) */#define PCIIO_SLOTS ((pciio_slot_t)32)#define PCIIO_FUNCS ((pciio_function_t)8)#define PCIIO_SLOT_NONE ((pciio_slot_t)255)#define PCIIO_FUNC_NONE ((pciio_function_t)255)typedef int pciio_intr_line_t; /* PCI interrupt line(s) */#define PCIIO_INTR_LINE(n) (0x1 << (n))#define PCIIO_INTR_LINE_A (0x1)#define PCIIO_INTR_LINE_B (0x2)#define PCIIO_INTR_LINE_C (0x4)#define PCIIO_INTR_LINE_D (0x8)typedef int pciio_space_t; /* PCI address space designation */#define PCIIO_SPACE_NONE (0)#define PCIIO_SPACE_ROM (1)#define PCIIO_SPACE_IO (2)/* PCIIO_SPACE_ (3) */#define PCIIO_SPACE_MEM (4)#define PCIIO_SPACE_MEM32 (5)#define PCIIO_SPACE_MEM64 (6)#define PCIIO_SPACE_CFG (7)#define PCIIO_SPACE_WIN0 (8)#define PCIIO_SPACE_WIN(n) (PCIIO_SPACE_WIN0+(n)) /* 8..13 *//* PCIIO_SPACE_ (14) */#define PCIIO_SPACE_BAD (15)#if 1 /* does anyone really use these? */#define PCIIO_SPACE_USER0 (20)#define PCIIO_SPACE_USER(n) (PCIIO_SPACE_USER0+(n)) /* 20 .. ? */#endif/* * PCI_NOWHERE is the error value returned in * place of a PCI address when there is no * corresponding address. */#define PCI_NOWHERE (0)/* * Acceptable flag bits for pciio service calls * * PCIIO_FIXED: require that mappings be established * using fixed sharable resources; address * translation results will be permanently * available. (PIOMAP_FIXED and DMAMAP_FIXED are * the same numeric value and are acceptable). * PCIIO_NOSLEEP: if any part of the operation would * sleep waiting for resoruces, return an error * instead. (PIOMAP_NOSLEEP and DMAMAP_NOSLEEP are * the same numeric value and are acceptable). * PCIIO_INPLACE: when operating on alenlist structures, * reuse the source alenlist rather than creating a * new one. (PIOMAP_INPLACE and DMAMAP_INPLACE are * the same numeric value and are acceptable). * * PCIIO_DMA_CMD: configure this stream as a * generic "command" stream. Generally this * means turn off prefetchers and write * gatherers, and whatever else might be * necessary to make command ring DMAs * work as expected. * PCIIO_DMA_DATA: configure this stream as a * generic "data" stream. Generally, this * means turning on prefetchers and write * gatherers, and anything else that might * increase the DMA throughput (short of * using "high priority" or "real time" * resources that may lower overall system * performance). * PCIIO_DMA_A64: this device is capable of * using 64-bit DMA addresses. Unless this * flag is specified, it is assumed that * the DMA address must be in the low 4G * of PCI space. * PCIIO_PREFETCH: if there are prefetchers * available, they can be turned on. * PCIIO_NOPREFETCH: any prefetchers along * the dma path should be turned off. * PCIIO_WRITE_GATHER: if there are write gatherers * available, they can be turned on. * PCIIO_NOWRITE_GATHER: any write gatherers along * the dma path should be turned off. * * PCIIO_BYTE_STREAM: the DMA stream represents a group * of ordered bytes. Arrange all byte swapping * hardware so that the bytes land in the correct * order. This is a common setting for data * channels, but is NOT implied by PCIIO_DMA_DATA. * PCIIO_WORD_VALUES: the DMA stream is used to * communicate quantities stored in multiple bytes, * and the device doing the DMA is little-endian; * arrange any swapping hardware so that * 32-bit-wide values are maintained. This is a * common setting for command rings that contain * DMA addresses and counts, but is NOT implied by * PCIIO_DMA_CMD. CPU Accesses to 16-bit fields * must have their address xor-ed with 2, and * accesses to individual bytes must have their * addresses xor-ed with 3 relative to what the * device expects. * * NOTE: any "provider specific" flags that * conflict with the generic flags will * override the generic flags, locally * at that provider. * * Also, note that PCI-generic flags (PCIIO_) are * in bits 0-14. The upper bits, 15-31, are reserved * for PCI implementation-specific flags. */#define PCIIO_FIXED DMAMAP_FIXED#define PCIIO_NOSLEEP DMAMAP_NOSLEEP#define PCIIO_INPLACE DMAMAP_INPLACE#define PCIIO_DMA_CMD 0x0010#define PCIIO_DMA_DATA 0x0020#define PCIIO_DMA_A64 0x0040#define PCIIO_WRITE_GATHER 0x0100#define PCIIO_NOWRITE_GATHER 0x0200#define PCIIO_PREFETCH 0x0400#define PCIIO_NOPREFETCH 0x0800/* Requesting an endianness setting that the * underlieing hardware can not support * WILL result in a failure to allocate * dmamaps or complete a dmatrans. */#define PCIIO_BYTE_STREAM 0x1000 /* set BYTE SWAP for "byte stream" */#define PCIIO_WORD_VALUES 0x2000 /* set BYTE SWAP for "word values" *//* * Interface to deal with PCI endianness. * The driver calls pciio_endian_set once, supplying the actual endianness of * the device and the desired endianness. On SGI systems, only use LITTLE if * dealing with a driver that does software swizzling. Most of the time, * it's preferable to request BIG. The return value indicates the endianness * that is actually achieved. On systems that support hardware swizzling, * the achieved endianness will be the desired endianness. On systems without * swizzle hardware, the achieved endianness will be the device's endianness. */typedef enum pciio_endian_e { PCIDMA_ENDIAN_BIG, PCIDMA_ENDIAN_LITTLE} pciio_endian_t;/* * handles of various sorts */typedef struct pciio_piomap_s *pciio_piomap_t;typedef struct pciio_dmamap_s *pciio_dmamap_t;typedef struct pciio_intr_s *pciio_intr_t;typedef struct pciio_info_s *pciio_info_t;typedef struct pciio_piospace_s *pciio_piospace_t;typedef struct pciio_win_info_s *pciio_win_info_t;typedef struct pciio_win_map_s *pciio_win_map_t;typedef struct pciio_win_alloc_s *pciio_win_alloc_t;/* PIO MANAGEMENT *//* * A NOTE ON PCI PIO ADDRESSES * * PCI supports three different address spaces: CFG * space, MEM space and I/O space. Further, each * card always accepts CFG accesses at an address * based on which slot it is attached to, but can * decode up to six address ranges. * * Assignment of the base address registers for all * PCI devices is handled centrally; most commonly, * device drivers will want to talk to offsets * within one or another of the address ranges. In * order to do this, which of these "address * spaces" the PIO is directed into must be encoded * in the flag word. * * We reserve the right to defer allocation of PCI * address space for a device window until the * driver makes a piomap_alloc or piotrans_addr * request. * * If a device driver mucks with its device's base * registers through a PIO mapping to CFG space, * results of further PIO through the corresponding * window are UNDEFINED. * * Windows are named by the index in the base * address register set for the device of the * desired register; IN THE CASE OF 64 BIT base * registers, the index should be to the word of * the register that contains the mapping type * bits; since the PCI CFG space is natively * organized little-endian fashion, this is the * first of the two words. * * AT THE MOMENT, any required corrections for * endianness are the responsibility of the device * driver; not all platforms support control in * hardware of byteswapping hardware. We anticipate * providing flag bits to the PIO and DMA * management interfaces to request different * configurations of byteswapping hardware. * * PIO Accesses to CFG space via the "Bridge" ASIC * used in IP30 platforms preserve the native byte * significance within the 32-bit word; byte * addresses for single byte accesses need to be * XORed with 3, and addresses for 16-bit accesses * need to be XORed with 2. * * The IOC3 used on IP30, and other SGI PCI devices * as well, require use of 32-bit accesses to their * configuration space registers. Any potential PCI * bus providers need to be aware of this requirement. */#define PCIIO_PIOMAP_CFG (0x1)#define PCIIO_PIOMAP_MEM (0x2)#define PCIIO_PIOMAP_IO (0x4)#define PCIIO_PIOMAP_WIN(n) (0x8+(n))typedef pciio_piomap_tpciio_piomap_alloc_f (vertex_hdl_t dev, /* set up mapping for this device */ device_desc_t dev_desc, /* device descriptor */ pciio_space_t space, /* which address space */ iopaddr_t pcipio_addr, /* starting address */ size_t byte_count, size_t byte_count_max, /* maximum size of a mapping */ unsigned flags); /* defined in sys/pio.h */typedef voidpciio_piomap_free_f (pciio_piomap_t pciio_piomap);typedef caddr_tpciio_piomap_addr_f (pciio_piomap_t pciio_piomap, /* mapping resources */ iopaddr_t pciio_addr, /* map for this pcipio address */ size_t byte_count); /* map this many bytes */typedef voidpciio_piomap_done_f (pciio_piomap_t pciio_piomap);typedef caddr_tpciio_piotrans_addr_f (vertex_hdl_t dev, /* translate for this device */ device_desc_t dev_desc, /* device descriptor */ pciio_space_t space, /* which address space */ iopaddr_t pciio_addr, /* starting address */ size_t byte_count, /* map this many bytes */ unsigned flags);typedef caddr_tpciio_pio_addr_f (vertex_hdl_t dev, /* translate for this device */ device_desc_t dev_desc, /* device descriptor */ pciio_space_t space, /* which address space */ iopaddr_t pciio_addr, /* starting address */ size_t byte_count, /* map this many bytes */ pciio_piomap_t *mapp, /* in case a piomap was needed */ unsigned flags);typedef iopaddr_tpciio_piospace_alloc_f (vertex_hdl_t dev, /* PIO space for this device */ device_desc_t dev_desc, /* Device descriptor */ pciio_space_t space, /* which address space */ size_t byte_count, /* Number of bytes of space */ size_t alignment); /* Alignment of allocation */typedef voidpciio_piospace_free_f (vertex_hdl_t dev, /* Device freeing space */ pciio_space_t space, /* Which space is freed */ iopaddr_t pci_addr, /* Address being freed */ size_t size); /* Size freed *//* DMA MANAGEMENT */typedef pciio_dmamap_tpciio_dmamap_alloc_f (vertex_hdl_t dev, /* set up mappings for this device */ device_desc_t dev_desc, /* device descriptor */ size_t byte_count_max, /* max size of a mapping */ unsigned flags); /* defined in dma.h */typedef voidpciio_dmamap_free_f (pciio_dmamap_t dmamap);typedef iopaddr_tpciio_dmamap_addr_f (pciio_dmamap_t dmamap, /* use these mapping resources */ paddr_t paddr, /* map for this address */ size_t byte_count); /* map this many bytes */typedef voidpciio_dmamap_done_f (pciio_dmamap_t dmamap);typedef iopaddr_tpciio_dmatrans_addr_f (vertex_hdl_t dev, /* translate for this device */ device_desc_t dev_desc, /* device descriptor */ paddr_t paddr, /* system physical address */ size_t byte_count, /* length */ unsigned flags); /* defined in dma.h */typedef voidpciio_dmamap_drain_f (pciio_dmamap_t map);typedef voidpciio_dmaaddr_drain_f (vertex_hdl_t vhdl, paddr_t addr, size_t bytes);typedef voidpciio_dmalist_drain_f (vertex_hdl_t vhdl, alenlist_t list);/* INTERRUPT MANAGEMENT */typedef pciio_intr_tpciio_intr_alloc_f (vertex_hdl_t dev, /* which PCI device */ device_desc_t dev_desc, /* device descriptor */ pciio_intr_line_t lines, /* which line(s) will be used */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -