mrfioc2  2.3.0
evrdump.c
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2010 Brookhaven Science Associates, as Operator of
3 * Brookhaven National Laboratory.
4 * mrfioc2 is distributed subject to a Software License Agreement found
5 * in file LICENSE that is included with this distribution.
6 \*************************************************************************/
7 /*
8  * Author: Michael Davidsaver <mdavidsaver@gmail.com>
9  */
10 
11 #include <stdlib.h>
12 #include <stdio.h>
13 #include <errno.h>
14 
15 #include <epicsTypes.h>
16 #include <errlog.h>
17 #include <devLibPCI.h>
18 
19 #include "mrmpci.h"
20 
21 #ifndef _WIN32
22 epicsShareFunc void devLibPCIRegisterBaseDefault(void);
23 #endif
24 
25 static const epicsPCIID mrmevrs[] = {
26  DEVPCI_SUBDEVICE_SUBVENDOR(PCI_DEVICE_ID_PLX_9030, PCI_VENDOR_ID_PLX,
28  ,DEVPCI_SUBDEVICE_SUBVENDOR(PCI_DEVICE_ID_PLX_9030, PCI_VENDOR_ID_PLX,
30  ,DEVPCI_SUBDEVICE_SUBVENDOR(PCI_DEVICE_ID_PLX_9056, PCI_VENDOR_ID_PLX,
32  ,DEVPCI_SUBDEVICE_SUBVENDOR(PCI_DEVICE_ID_EC_30, PCI_VENDOR_ID_LATTICE,
34  ,DEVPCI_END
35 };
36 
37 typedef struct {
38  int bar, len, offset;
39 } args;
40 
41 int printevr(void* raw,const epicsPCIDevice* dev)
42 {
43  epicsUInt32 i, offset, length;
44  args *a=raw;
45  volatile epicsUInt32 *base;
46 
47  devPCIShowDevice(2,dev);
48 
49  if (devPCIToLocalAddr(dev, a->bar, (volatile void**)(void *)&base, DEVLIB_MAP_UIO1TO1)) {
50  fprintf(stderr,"Failed to map bar 0x%x\n", a->bar);
51  return 0;
52  }
53 
54  offset = (epicsUInt32)a->offset;
55  length = (epicsUInt32)a->len;
56 
57  for (i=offset/4; i < (offset + length)/4; i++) {
58  if(i%4==0)
59  printf("\n%08x : ", 4*i);
60 
61  printf("%08x ",base[i]);
62 
63  }
64  printf("\n");
65  return 0;
66 }
67 
68 int main(int argc, char* argv[])
69 {
70  args a = {0,0x80,0};
71 
72 #ifndef _WIN32
74 #endif
75 
76  fprintf(stderr,"Usage: evrdump [BAR#] [Length] [offset]\n");
77 
78  if (argc>=2) a.bar=atoi(argv[1]);
79  if (argc>=3) a.len=atoi(argv[2]);
80  if (argc>=4) a.offset=atoi(argv[3]);
81 
82  devPCIFindCB(mrmevrs, &printevr, &a, 0);
83 
84  return 0;
85 }
int main(int argc, char *argv[])
Definition: evrdump.c:68
#define PCI_DEVICE_ID_MRF_PMCEVR_230
Definition: mrmpci.h:33
Definition: evrdump.c:37
#define PCI_VENDOR_ID_LATTICE
Definition: uio_mrf.c:44
int bar
Definition: evrdump.c:38
#define PCI_VENDOR_ID_PLX
Definition: plx9030.h:37
#define PCI_DEVICE_ID_MRF_PXIEVR_230
Definition: mrmpci.h:34
#define PCI_VENDOR_ID_MRF
Definition: uio_mrf.c:41
#define PCI_DEVICE_ID_EC_30
Definition: uio_mrf.c:46
#define PCI_DEVICE_ID_MRF_EVRTG_300E
Definition: mrmpci.h:36
#define PCI_DEVICE_ID_MRF_EVRTG_300
Definition: mrmpci.h:35
epicsShareFunc void devLibPCIRegisterBaseDefault(void)
int len
Definition: evrdump.c:38
int offset
Definition: evrdump.c:38
#define PCI_DEVICE_ID_PLX_9056
Definition: uio_mrf.c:51
#define PCI_DEVICE_ID_PLX_9030
Definition: uio_mrf.c:50
int printevr(void *raw, const epicsPCIDevice *dev)
Definition: evrdump.c:41