pnpio.h
上传用户:sy_wanhua
上传日期:2013-07-25
资源大小:3048k
文件大小:8k
- /*
- * ISA Plug & Play support
- * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
- *
- * Modified by Ed Okerson <eokerson@quicknet.net> to work with the 2.2.x
- * series of Linux kernels. 11/17/99
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
- /*
- * This file adds all the things that exist in Linux 2.3.28 that are used
- * by the isapnp code, but do not exist in Linux 2.2.x. To avoid
- * trashing the 2.2.x pci_dev and pci_bus structs, I renamed them here to
- * pnp_dev and pnp_bus for the use of this code. Drivers that use these
- * structs shoud use compiler conditionals to determine which name to use
- * based on the Linux kernel version the module is being built for.
- *
- */
- #define DEVICE_COUNT_COMPATIBLE 4
- #define DEVICE_COUNT_IRQ 2
- #define DEVICE_COUNT_DMA 2
- #define DEVICE_COUNT_RESOURCE 12
- struct resource {
- const char *name;
- unsigned long start, end;
- unsigned long flags;
- struct resource *parent, *sibling, *child;
- };
- /*
- * IO resources have these defined flags.
- */
- #define IORESOURCE_BITS 0x000000ff /* Bus-specific bits */
- #define IORESOURCE_IO 0x00000100 /* Resource type */
- #define IORESOURCE_MEM 0x00000200
- #define IORESOURCE_IRQ 0x00000400
- #define IORESOURCE_DMA 0x00000800
- #define IORESOURCE_PREFETCH 0x00001000 /* No side effects */
- #define IORESOURCE_READONLY 0x00002000
- #define IORESOURCE_CACHEABLE 0x00004000
- #define IORESOURCE_RANGELENGTH 0x00008000
- #define IORESOURCE_SHADOWABLE 0x00010000
- #define IORESOURCE_UNSET 0x20000000
- #define IORESOURCE_AUTO 0x40000000
- #define IORESOURCE_BUSY 0x80000000 /* Driver has marked this resource busy */
- /* ISA PnP IRQ specific bits (IORESOURCE_BITS) */
- #define IORESOURCE_IRQ_HIGHEDGE (1<<0)
- #define IORESOURCE_IRQ_LOWEDGE (1<<1)
- #define IORESOURCE_IRQ_HIGHLEVEL (1<<2)
- #define IORESOURCE_IRQ_LOWLEVEL (1<<3)
- /* ISA PnP DMA specific bits (IORESOURCE_BITS) */
- #define IORESOURCE_DMA_TYPE_MASK (3<<0)
- #define IORESOURCE_DMA_8BIT (0<<0)
- #define IORESOURCE_DMA_8AND16BIT (1<<0)
- #define IORESOURCE_DMA_16BIT (2<<0)
- #define IORESOURCE_DMA_MASTER (1<<2)
- #define IORESOURCE_DMA_BYTE (1<<3)
- #define IORESOURCE_DMA_WORD (1<<4)
- #define IORESOURCE_DMA_SPEED_MASK (3<<6)
- #define IORESOURCE_DMA_COMPATIBLE (0<<6)
- #define IORESOURCE_DMA_TYPEA (1<<6)
- #define IORESOURCE_DMA_TYPEB (2<<6)
- #define IORESOURCE_DMA_TYPEF (3<<6)
- /* ISA PnP memory I/O specific bits (IORESOURCE_BITS) */
- #define IORESOURCE_MEM_WRITEABLE (1<<0) /* dup: IORESOURCE_READONLY */
- #define IORESOURCE_MEM_CACHEABLE (1<<1) /* dup: IORESOURCE_CACHEABLE */
- #define IORESOURCE_MEM_RANGELENGTH (1<<2) /* dup: IORESOURCE_RANGELENGTH */
- #define IORESOURCE_MEM_TYPE_MASK (3<<3)
- #define IORESOURCE_MEM_8BIT (0<<3)
- #define IORESOURCE_MEM_16BIT (1<<3)
- #define IORESOURCE_MEM_8AND16BIT (2<<3)
- #define IORESOURCE_MEM_SHADOWABLE (1<<5) /* dup: IORESOURCE_SHADOWABLE */
- #define IORESOURCE_MEM_EXPANSIONROM (1<<6)
- /* PC/ISA/whatever - the normal PC address spaces: IO and memory */
- extern struct resource ioport_resource;
- extern struct resource iomem_resource;
- extern int get_resource_list(struct resource *, char *buf, int size);
- extern int request_resource(struct resource *root, struct resource *new);
- extern int release_resource(struct resource *new);
- extern int allocate_resource(struct resource *root, struct resource *new,
- unsigned long size,
- unsigned long min, unsigned long max,
- unsigned long align);
- /* Convenience shorthand with allocation */
- //#define request_region(start,n,name) __request_region(&ioport_resource, (start), (n), (name))
- #define request_mem_region(start,n,name) __request_region(&iomem_resource, (start), (n), (name))
- extern struct resource * __request_region(struct resource *, unsigned long start, unsigned long n, const char *name);
- /*
- * This is actually the new pci_dev structure, but we can't use that name
- * without stomping on the old one the kernel still uses.
- */
- struct pnp_dev {
- int active; /* device is active */
- int ro; /* Read/Only */
- struct pnp_bus *bus; /* bus this device is on */
- struct pnp_dev *sibling; /* next device on this bus */
- struct pnp_dev *next; /* chain of all devices */
-
- void *sysdata; /* hook for sys-specific extension */
- struct proc_dir_entry *procent; /* device entry in /proc/bus/pci */
- unsigned int devfn; /* encoded device & function index */
- unsigned short vendor;
- unsigned short device;
- unsigned short subsystem_vendor;
- unsigned short subsystem_device;
- unsigned int class; /* 3 bytes: (base,sub,prog-if) */
- u8 hdr_type; /* PCI header type (`multi' flag masked out) */
- u8 rom_base_reg; /* Which config register controls the ROM */
-
- unsigned short regs;
-
- /* device is compatible with these IDs */
- unsigned short vendor_compatible[DEVICE_COUNT_COMPATIBLE];
- unsigned short device_compatible[DEVICE_COUNT_COMPATIBLE];
-
- /*
- * Instead of touching interrupt line and base address registers
- * directly, use the values stored here. They might be different!
- */
- unsigned int irq;
- struct resource resource[DEVICE_COUNT_RESOURCE]; /* I/O and memory
- regions + expansion ROMs */
- struct resource dma_resource[DEVICE_COUNT_DMA];
- struct resource irq_resource[DEVICE_COUNT_IRQ];
-
- char name[48]; /* Device name */
- char slot_name[8]; /* Slot name */
-
- int (*prepare)(struct pnp_dev *dev);
- int (*activate)(struct pnp_dev *dev);
- int (*deactivate)(struct pnp_dev *dev);
- };
- /*
- * This is actually the new pci_bus structure, but we can't use that name
- * without stomping on the old one the kernel still uses.
- */
- struct pnp_bus {
- struct pnp_bus *parent; /* parent bus this bridge is on */
- struct pnp_bus *children; /* chain of P2P bridges on this bus */
- struct pnp_bus *next; /* chain of all PCI buses */
- struct pci_ops *ops; /* configuration access functions */
- struct pnp_dev *self; /* bridge device as seen by parent */
- struct pnp_dev *devices; /* devices behind this bridge */
- struct resource *resource[4]; /* address space routed to this bus */
-
- void *sysdata; /* hook for sys-specific extension */
- struct proc_dir_entry *procdir; /* directory entry in /proc/bus/pci */
-
- unsigned char number; /* bus number */
- unsigned char primary; /* number of primary bridge */
- unsigned char secondary; /* number of secondary bridge */
- unsigned char subordinate; /* max number of subordinate buses */
- char name[48];
- unsigned short vendor;
- unsigned short device;
- unsigned int serial; /* serial number */
- unsigned char pnpver; /* Plug & Play version */
- unsigned char productver; /* product version */
- unsigned char checksum; /* if zero - checksum passed */
- unsigned char pad1;
- };
-
- extern struct pnp_bus *pnp_root; /* root bus */
- extern struct pnp_dev *pnp_devices; /* list of all devices */