pci_dma.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:3k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * pci_dma.h
  3.  * Copyright (C) 2001 Mike Corrigan & Dave Engebretsen IBM Corporation
  4.  * 
  5.  * This program is free software; you can redistribute it and/or modify
  6.  * it under the terms of the GNU General Public License as published by
  7.  * the Free Software Foundation; either version 2 of the License, or
  8.  * (at your option) any later version.
  9.  * 
  10.  * This program is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU General Public License for more details.
  14.  * 
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program; if not, write to the Free Software
  17.  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  18.  */
  19. #ifndef _PCI_DMA_H
  20. #define _PCI_DMA_H
  21. #include <asm/types.h>
  22. #include <linux/spinlock.h>
  23. /*
  24.  * NUM_TCE_LEVELS defines the largest contiguous block
  25.  * of dma (tce) space we can get.  NUM_TCE_LEVELS = 10 
  26.  * allows up to 2**9 pages (512 * 4096) = 2 MB
  27.  */
  28. #define NUM_TCE_LEVELS 10
  29. #define NO_TCE ((dma_addr_t)-1)
  30. /*
  31.  * Tces come in two formats, one for the virtual bus and a different
  32.  * format for PCI
  33.  */
  34. #define TCE_VB  0
  35. #define TCE_PCI 1
  36. union Tce {
  37.     u64 wholeTce;
  38. struct {
  39. u64 cacheBits :6; /* Cache hash bits - not used */
  40. u64 rsvd :6;
  41. u64 rpn :40; /* Absolute page number */
  42. u64 valid :1; /* Tce is valid (vb only) */
  43. u64 allIo :1; /* Tce is valid for all lps (vb only) */
  44. u64 lpIndex :8; /* LpIndex for user of TCE (vb only) */
  45. u64 pciWrite :1; /* Write allowed (pci only) */
  46. u64 readWrite :1; /* Read allowed (pci), Write allowed (vb) */
  47. } tceBits;
  48. };
  49. struct Bitmap {
  50. unsigned long numBits;
  51. unsigned long numBytes;
  52. unsigned char * map;
  53. };
  54. struct MultiLevelBitmap {
  55. unsigned long  maxLevel;
  56. struct Bitmap  level[NUM_TCE_LEVELS];
  57. };
  58. struct TceTable {
  59. u64 busNumber;
  60. u64 size;
  61. u64 startOffset;
  62. u64     base;                   /* pSeries native only */
  63. u64 index;
  64. u64 tceType;
  65. spinlock_t lock;
  66. struct MultiLevelBitmap mlbm;
  67. };
  68. struct TceTableManagerCB {
  69. u64 busNumber; /* Bus number for this tce table */
  70. u64 start; /* Will be NULL for secondary */
  71. u64 totalSize; /* Size (in pages) of whole table */
  72. u64 startOffset; /* Index into real tce table of the
  73.    start of our section */
  74. u64 size; /* Size (in pages) of our section */
  75. u64 index; /* Index of this tce table (token?) */
  76. u16 maxTceTableIndex; /* Max num of tables for partition */
  77. u8 virtualBusFlag; /* Flag to indicate virtual bus */
  78.   u8 logicalSlot; /* IOA Tce Slot Index */
  79.   u8 rsvd[4];
  80. };
  81. extern struct TceTable virtBusTceTable; /* Tce table for virtual bus */
  82. extern void create_tce_tables(void);
  83. extern void create_pci_bus_tce_table(unsigned long);
  84. void tce_init_pSeries(void);
  85. void tce_init_iSeries(void);
  86. #endif