Main Page | Namespace List | Class Hierarchy | Compound List | File List | Namespace Members | Compound Members | File Members | Related Pages

guppi.h

Go to the documentation of this file.
00001 /*
00002  * 
00003  * Copyright 1996 Massachusetts Institute of Technology
00004  *
00005  * Permission to use, copy, modify, distribute, and sell this software and its
00006  * documentation for any purpose is hereby granted without fee, provided that
00007  * the above copyright notice appear in all copies and that both that
00008  * copyright notice and this permission notice appear in supporting
00009  * documentation, and that the name of M.I.T. not be used in advertising or
00010  * publicity pertaining to distribution of the software without specific,
00011  * written prior permission.  M.I.T. makes no representations about the
00012  * suitability of this software for any purpose.  It is provided "as is"
00013  * without express or implied warranty.
00014  *
00015  */
00016 #ifndef _LINUX_GUPPI_H
00017 #define _LINUX_GUPPI_H
00018 
00019 #include <linux/ioctl.h>
00020 #include <linux/pci.h>
00021 
00022 #ifdef __KERNEL__
00023 #include <asm/spinlock.h>
00024 #endif
00025 
00026 #ifndef   PCI_VENDOR_ID_TNS  
00027 #define   PCI_VENDOR_ID_TNS     0x6969
00028 #endif
00029 
00030 #ifndef   PCI_DEVICE_ID_GUPPI
00031 #define   PCI_DEVICE_ID_GUPPI   0x9696 
00032 #endif
00033 
00034 #define   NR_CARDS              1
00035 
00036 /*
00037  *  Thingys for extracting fields from registers
00038  */
00039 
00040 /* Control Register Masks */
00041 
00042 #define GUP_TXDATA_FIFO_RS     0x00000001
00043 #define GUP_RXDATA_FIFO_RS     0x00000002
00044 #define GUP_TXPG_FIFO_RS       0x00000004
00045 #define GUP_RXPG_FIFO_RS       0x00000008
00046 #define GUP_RXREG_RS           0x00000010
00047 #define GUP_TXREG_RS           0x00000020
00048 #define GUP_BCK_CTRL           0x000003c0
00049 #define GUP_BCK_RS             0x00000400
00050 #define GUP_PROG_FLAGS         0x00000800
00051 #define GUP_USE_AEFLAG         0x00001000
00052 #define GUP_BCK_EN             0x00002000
00053 #define GUP_TX_EN              0x00004000
00054 #define GUP_RX_EN              0x00008000
00055 #define GUP_FAVOR_TX           0x00010000
00056 #define GUP_FAVOR_RX           0x00020000
00057 #define GUP_TXDONEINT_EN       0x00040000
00058 #define GUP_RXPGAEINT_EN       0x00080000
00059 #define GUP_TXPGAEINT_EN       0x00100000
00060 #define GUP_BCKSTATINT_EN      0x00200000
00061 
00062 #define GUP_TXDONE_INT_RS      0x00400000
00063 #define GUP_RXPGAE_INT_RS      0x00800000
00064 #define GUP_TXPGAE_INT_RS      0x01000000
00065 #define GUP_BCKSTAT_INT_RS     0x02000000
00066 #define GUP_BCSTATINT_REG      0x3c000000
00067 
00068 #define GUP_RX_RS              0x0080001a
00069 #define GUP_TX_RS              0x01400025
00070 #define GUP_ALL_RS             0x03c0003f
00071 #define GUP_INT_MASK           0x03c00000
00072 
00073 /* Status Register Masks */
00074 // AE = almost-empty flag (can generate interrupt)
00075 // AF = almost-full flag (can stall Xlinix)
00076 
00077 #define GUP_BCKID              0x0000000f
00078 #define GUP_BCKSTAT            0x000000f0
00079 #define GUP_TXDAT_FLAGS        0x00001f00
00080   #define GUP_TXDAT_EF         0x00000100 
00081   #define GUP_TXDAT_AE         0x00000200 
00082   #define GUP_TXDAT_HF         0x00000400 
00083   #define GUP_TXDAT_AF         0x00000800 
00084   #define GUP_TXDAT_FF         0x00001000  
00085 
00086 #define GUP_RXDAT_FLAGS        0x0003e000
00087   #define GUP_RXDAT_EF         0x00002000 
00088   #define GUP_RXDAT_AE         0x00004000 
00089   #define GUP_RXDAT_HF         0x00008000 
00090   #define GUP_RXDAT_AF         0x00010000 
00091   #define GUP_RXDAT_FF         0x00020000  
00092 
00093 #define GUP_TXPG_FLAGS         0x007c0000
00094   #define GUP_TXPG_EF          0x00040000 
00095   #define GUP_TXPG_AE          0x00080000 
00096   #define GUP_TXPG_HF          0x00100000 
00097   #define GUP_TXPG_AF          0x00200000 
00098   #define GUP_TXPG_FF          0x00400000  
00099 
00100 #define GUP_RXPG_FLAGS         0x0f800000
00101   #define GUP_RXPG_EF          0x00800000 
00102   #define GUP_RXPG_AE          0x01000000 
00103   #define GUP_RXPG_HF          0x02000000 
00104   #define GUP_RXPG_AF          0x04000000 
00105   #define GUP_RXPG_FF          0x08000000  
00106 
00107 #define GUP_TX_PENDING         0x10000000
00108 #define GUP_RX_PENDING         0x20000000
00109 #define GUP_LAST_TRANS         0x40000000
00110 
00111 /*
00112  * Offsets from base address to various CSR registers 
00113  */
00114 
00115 #define GUP_CONTROL_OFF        0x00000000
00116 #define GUP_STATUS_OFF         0x00000004
00117 #define GUP_TXPGADDR_OFF       0x00000008
00118 #define GUP_RXPGADDR_OFF       0x0000000c
00119 
00120 /*
00121  * Offsets from base address into FIFO spaces
00122  */
00123 
00124 #define GUP_DATA_FIFO_OFF      0x00000400
00125 #define GUP_TXPG_FIFO_OFF      0x00000800
00126 #define GUP_RXPG_FIFO_OFF      0x00000c00
00127 
00128 /*
00129  * Guppi structures (I/O buffers, control registers, and general board info)
00130  */
00131 
00132 struct guppi_status {
00133   unsigned int index; //index of the first valid page (this page is valid if num>0)
00134   unsigned int num; //number of valid pages at index
00135 
00136   //number of pages that had to be thrown away becuase
00137   //the buffer was full since the last status check
00138   //if this is >0 then num should ==
00139   //the number of pages in the entire buffer
00140   unsigned int lost; 
00141 };
00142 
00143 #ifdef __KERNEL__
00144 
00145 struct guppi_buf {
00146   char                  *buf; //pointer to the data
00147   unsigned long         *busaddrs; //list of physical addresses
00148 };
00149 
00150 struct   guppi_reg {
00151   volatile unsigned int gup_ctrl;      /* GuPPI Control Register */
00152   volatile unsigned int gup_stat;      /* GuPPI Status Register  */
00153   volatile unsigned int gup_txpgreg;   /* GuPPI Transmit Page Register */
00154   volatile unsigned int gup_rxpgreg;   /* GuPPI Receive Page Register */
00155 };
00156 
00157 struct   guppi_board {
00158   unsigned long        base_addr;
00159   unsigned long        phys_addr;
00160   int                  irq;
00161   //unsigned char        gup_bus;
00162   struct pci_dev *dev;
00163   unsigned int         minor;
00164   unsigned int         users;
00165   spinlock_t           lock;
00166 
00167   /* stuff for receive starts here */
00168   unsigned int rxbufsize; //in pages
00169   unsigned char        is_rxing;
00170   unsigned int         rxoverruns;
00171   struct guppi_buf *rx_buffer;
00172 
00173   //indexs are all into the rx_buffer->physaddrs[] array
00174   unsigned int rx_empty_index; //start of empty pages
00175   unsigned int rx_user_index; //start of user's pages
00176   //number of empty pages = (rx_user_index - rx_empty_index) % rxbufsize
00177   //unless rx_user_index == rx_empty_index in which case
00178   //       0 if rx_user_num > 0;
00179   //       rxbufsize if rx_user_num = 0;
00180  
00181   //number of pages user knows about and is working with
00182   unsigned int rx_user_num;
00183 
00184   struct guppi_buf *rxjunkpage;
00185 
00186 
00187   /* stuff for transmit starts here */
00188   unsigned int txbufsize; //in pages
00189   unsigned char        is_txing;
00190   unsigned int         txoverruns;
00191   struct guppi_buf *tx_buffer;
00192 
00193   //indexs are all into the tx_buffer->physaddrs[] array
00194   unsigned int tx_empty_index; //start of empty pages
00195   unsigned int tx_user_index; //start of user's pages
00196   //number of empty pages = (tx_user_index - tx_empty_index) % txbufsize
00197   //unless tx_user_index == tx_empty_index in which case
00198   //       0 if tx_user_num > 0;
00199   //       txbufsize if tx_user_num = 0;
00200  
00201   //number of pages user knows about and is working with
00202   unsigned int tx_user_num;
00203 
00204   struct guppi_buf *txjunkpage;
00205 
00206   struct guppi_board   *next;
00207 };
00208 
00209 /*
00210  * GuPPI major device number 
00211  */
00212 
00213 #define GUPPI_MAJOR  127
00214 
00215 /*
00216  * Size of Transmit Data FIFO (in Dwords)
00217  */
00218 
00219 #define TXFIFOSIZE   1024
00220 
00221 /*
00222  * Size of Receive Data FIFO (in Dwords)
00223  */
00224 
00225 #define RXFIFOSIZE   1024
00226 
00227 //low water mark (almost empty) on receive fifo(generate interrupt)
00228 //FIX: what should this be
00229 #define RXAEPAGES    400 
00230 
00231 //high water mark (almost full) on receive fifo
00232 #define RXAFPAGES    (RXFIFOSIZE-2)
00233 
00234 //how close to get to the high water mark
00235 //(if the Guppi gets within 2 (?) of AF, the flag gets asserted...
00236 //FIX what should this be
00237 #define RXSAFETY 20
00238 
00239 //low water mark (almost empty) on receive fifo(generate interrupt)
00240 //FIX: what should this be
00241 #define TXAEPAGES    400 
00242 
00243 //high water mark (almost full) on receive fifo
00244 #define TXAFPAGES    (TXFIFOSIZE-2)
00245 
00246 //how close to get to the high water mark
00247 //(if the Guppi gets within 2 (?) of AF, the flag gets asserted...
00248 //FIX what should this be
00249 #define TXSAFETY 20
00250 
00251 #endif
00252 
00253 /*
00254  * Guppi IOCTL commands
00255  *   note a file descriptor must be for reading OR writing, not both
00256  *   so we can use the same codes for start/stop, etc.
00257  */
00258 
00259 /* Read a Dword from the 21050 configuration space */
00260 #define GIOCBRDRD   _IOR( 'G', 0x00, unsigned long )
00261 
00262 /* Write a Dword from the 21050 configuration space */
00263 #define GIOCBRDWR   _IOW( 'G', 0x01, unsigned long )
00264 
00265 /* Read a Dword from the GuPPI configuration space */
00266 #define GIOCGUPRD   _IOR( 'G', 0x02, unsigned long )
00267 
00268 /* Write a Dword from the GuPPI configuration space */
00269 #define GIOCGUPWR   _IOW( 'G', 0x03, unsigned long )
00270 
00271 /* Read a Dword from the Host Bridge configuration space */
00272 #define GIOCTSCRD   _IOR( 'G', 0x04, unsigned long )
00273 
00274 /* Write a Dword from the Host Bridge configuration space */
00275 #define GIOCTSCWR   _IOW( 'G', 0x05, unsigned long )
00276 
00277 /* Set standard buffer size to some number of pages */
00278 #define GIOCSETBUFSIZE  _IOW( 'G', 0x06, unsigned int )
00279 
00280 /* Start up the DMA/interrupt driver */
00281 #define GIOCSTART _IO( 'G', 0x07 )
00282 
00283 /* Stop the DMA/interrupt driver */
00284 #define GIOCSTOP  _IO( 'G', 0x08 )
00285 
00286 /* Tell the driver the user is done with a range of pages and get the */
00287 /*  range of pages the user can use as well as the number of overruns */
00288 #define GIOCSETGETSTATUS _IOWR( 'G', 0x09, struct guppi_status )
00289 
00290 /* guppi_init procedure to load driver as part of built-in kernel */
00291 extern int guppi_init(void);
00292 
00293 #endif /* _LINUX_GUPPI_H */

Generated on Tue Mar 30 21:31:49 2004 for GNU Radio by doxygen 1.3.2