devLib2  2.12
osdPciShared.h
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2010 Brookhaven Science Associates, as Operator of
3 * Brookhaven National Laboratory.
4 * devLib2 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 #ifndef OSDPCISHARED_H_INC
12 #define OSDPCISHARED_H_INC
13 
14 #include "devLibPCIOSD.h"
15 
16 #include <dbDefs.h>
17 #include <shareLib.h>
18 
19 /* Subtract member byte offset, returning pointer to parent object
20  *
21  * Added in Base 3.14.11
22  */
23 #ifndef CONTAINER
24 # ifdef __GNUC__
25 # define CONTAINER(ptr, structure, member) ({ \
26  const __typeof(((structure*)0)->member) *_ptr = (ptr); \
27  (structure*)((char*)_ptr - offsetof(structure, member)); \
28  })
29 # else
30 # define CONTAINER(ptr, structure, member) \
31  ((structure*)((char*)(ptr) - offsetof(structure, member)))
32 # endif
33 #endif
34 
35 struct osdPCIDevice {
36  epicsPCIDevice dev; /* "public" data */
37 
38  /* Can be used to cache values */
39  /* (PCI bus addresses are not program space pointers!) */
40  epicsUInt32 base[PCIBARCOUNT];
41  epicsUInt32 len[PCIBARCOUNT];
42  epicsUInt32 erom;
43 
44  ELLNODE node;
45 
46  void *drvpvt; /* for out of tree drivers */
47 };
48 typedef struct osdPCIDevice osdPCIDevice;
49 
50 INLINE
52 pcidev2osd(const epicsPCIDevice *devptr)
53 {
54  return CONTAINER((epicsPCIDevice*)devptr,osdPCIDevice,dev);
55 }
56 
57 int
59  const epicsPCIID *idlist,
60  devPCISearchFn searchfn,
61  void *arg,
62  unsigned int opt /* always 0 */
63 );
64 
65 int
67  const epicsPCIDevice* dev,
68  unsigned int bar,
69  volatile void **ppLocalAddr,
70  unsigned int opt
71 );
72 
73 int
75  const epicsPCIDevice* dev,
76  unsigned int bar,
77  epicsUInt32 *len
78 );
79 
80 int
82  const epicsPCIDevice *dev,
83  unsigned offset,
84  void *pArg,
85  devPCIAccessMode mode
86 );
87 
88 int sharedDevPCIInit(void);
89 
90 #endif /* OSDPCISHARED_H_INC */
int sharedDevPCIConfigAccess(const epicsPCIDevice *dev, unsigned offset, void *pArg, devPCIAccessMode mode)
Definition: osdPciShared.c:296
int(* devPCISearchFn)(void *ptr, const epicsPCIDevice *dev)
PCI search callback prototype.
Definition: devLibPCI.h:136
int sharedDevPCIBarLen(const epicsPCIDevice *dev, unsigned int bar, epicsUInt32 *len)
Definition: osdPciShared.c:230
epicsUInt32 len[PCIBARCOUNT]
Definition: osdPciShared.h:41
int sharedDevPCIToLocalAddr(const epicsPCIDevice *dev, unsigned int bar, volatile void **ppLocalAddr, unsigned int opt)
Definition: osdPciShared.c:194
void * drvpvt
Definition: osdPciShared.h:46
epicsPCIDevice dev
Definition: osdPciShared.h:36
int sharedDevPCIFindCB(const epicsPCIID *idlist, devPCISearchFn searchfn, void *arg, unsigned int opt)
Definition: osdPciShared.c:146
devPCIAccessMode
Definition: devLibPCIImpl.h:27
int sharedDevPCIInit(void)
Definition: osdPciShared.c:36
ELLNODE node
Definition: osdPciShared.h:44
#define CONTAINER(ptr, structure, member)
Definition: osdPciShared.h:30
#define PCIBARCOUNT
The maximum number of base address registers (BARs).
Definition: devLibPCI.h:126
Device token.
Definition: devLibPCI.h:112
epicsUInt32 base[PCIBARCOUNT]
Definition: osdPciShared.h:40
PCI device identifier.
Definition: devLibPCI.h:55
epicsUInt32 erom
Definition: osdPciShared.h:42
INLINE osdPCIDevice * pcidev2osd(const epicsPCIDevice *devptr)
Definition: osdPciShared.h:52