EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

2002  2003  2004  2005  2006  2007  2008  <20092010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 2002  2003  2004  2005  2006  2007  2008  <20092010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: RE: devLib ruminations
From: "Davidsaver, Michael" <[email protected]>
To: "Andrew Johnson" <[email protected]>, <[email protected]>
Date: Fri, 13 Nov 2009 18:15:53 -0500
This patch set puts all the existing public devLib functions under the function pointer table.  It will break outside users of the plugin, but the fix is not difficult.  The only thing it doesn't addressed is the global epicsAddressTypeName variable, but fixing that would mean a change to the public API.

I have tested this on RTEMS, but not vxWorks.

0001 and 0002 - There are already table entries for (dis)connect VME interrupts.  Use them.

0003 - Add VME interrupt in use to the table.

0004 - Mark all OSD functions as static

0005 - Move table definition to a separate file

0006 - Reorganize devLib.h to group functions by bus type

0007 - use sharelib.h extern macro for public variables

-----Original Message-----
From: [email protected] on behalf of Davidsaver, Michael
Sent: Fri 11/13/2009 8:40 AM
To: Andrew Johnson; [email protected]
Subject: RE: devLib ruminations
 
Hi Andrew,

Thanks for the comments.
                        
> On Tuesday 10 November 2009 14:13:18 Davidsaver, Michael wrote:
> >                                                              
> > 1) No 'virtual os' table behind the devLib PCI api.          
>                                                                
> I think a virtual table would still be useful for the multiple platforms that 
> devLib has to be able to support - the plug-in defines the boundary between   
> the generic API and the platform-specific code.  If you don't do that, you    
> either have to define a platform interface separately, or implement the devLib 
> PCI code separately for each platform.                                         

Instead of function pointers I would just use the usual osi+osd function pairs.  User calls osiFoo() which does some common operations, then osiFoo() calls osdFoo() which is specialized for the target.

> We have discovered that in practice it makes life much simpler to be able to   
> compile and create libraries containing our device support code for all our    
> IOC platforms, even though there is no actual devLib VME implementation        
> available for Solaris or Darwin (yet).  The place where an error should be     
> reported would be when trying to link an IOC executable on a platform that has 
> no plug-in; I'd prefer that it not be quite as late as run-time if possible    
> though.                                                                        

In an expanded devLib PCI code needs to be able to work for targets which have no VME support, and vice versa.

While I would agree that run-time is too late, I think that link-time is also too late.  Missing symbols are not a very friendly way to find out.  Compile time is better since more informative error messages can be given with the #error directive.

I would make 2 changes.  First, osi/os/default/devLib*.c would contain a stub implementation to give something to link against.  Second, create a header called osi/os/*/devLibConfig.h which would #define HAVE_DEVLIBVME and HAVE_DEVLIBPCI.  Trying to include 'devLibPCI.h' when HAVE_DEVLIBPCI is not defined would be an #error.

Call this the 'autoconf' approach.

> <snip>                                                                         
>                                                                                
> > 3) Add callback hooks for some specific operations.  This could be used      
> > for BSP specific quirks.  Before and after read/write probing would be       
> > one example.                                                                 
>                                                                                
> Can't the BSP wrap its own probe routine if necessary?  VxWorks allow its BSPs 
> to do that: vxMemProbe() vectors through the _func_vxMemProbeHook function     
> pointer which the BSP usually sets.  I'm not sure this should be part of       
> devLib.                                                                        

Fine.  I just wanted to put this out as a possibility.

> > So far I have been working with the 'virtual os' table concept.  I have      
> > been in contact with Graham Waters of TRIUMF about their use of Linux        
> > with devLib.  It looks like a straight forward piece of code which wraps     
> > a vendor provided library for the Universe2.  It is not designed to          
> > insert itself at runtime.                                                    
>                                                                                
> Right, but it doesn't require any changes to Base to use it; when you compile  
> Base for Linux you don't know whether you're going to be using the TRIUMF      
> plugin or not.  I don't want there to be a configuration switch, because we    
> need to be able to use the same build of Base to create both kinds of IOC.  If 
> there's an alternative to the 'virtual os' table though I'd like to hear it
> (some vxWorks targets don't support weak symbols by the way, so they won't
> help).

I think what you mean is that you don't want a single global configuration switch.  You are correct that this wouldn't work.

> > I have begun to wonder about the wisdom of maintaining the 'virtual os'
> > plugin interface when there is only one plugin for it.  This is
> > especially true for the PCI interface.  Both RTEMS and VxWorks have one
> > uniform complete interface for PCI access, and Linux has none (for
> > userspace).
>
> I don't follow your statement that "there is only one plugin for it."  Both
> RTEMS and vxWorks provide plug-ins for the interface.  The issue that I have
> with it is that a number of routines were added to devLib that don't go
> through the function table, duplicating existing functionality in some cases.

Yes, they each provide _A_ plugin.  There is _A_ plugin for Linux.  The plugin functionality is not being used.

I agree that if we use the pointer table it should be all or nothing.  I have a patch set from the code-a-thon which corrects the current situation, which I will post later today.

> <snip>
>
> > However, most people will only deal with systems having a single VME
> > bridge (bus #0).  The question is if it is worthwhile to change the api
> > for a corner case?
>
> I like Ralph's idea, which also gives you more flexibility to change the API
> if you need to.

The question was: Should devLibVME handle multiple VME bridges?  This sounds like a yes.

If so then the above only applies to the purposed new PCI part of devLib.  The VME part would still use a pointer table, or rather tables.


Michael









From 72418c428b7ce2c6e56356b3aaeac3029dccfc9f Mon Sep 17 00:00:00 2001
From: Michael Davidsaver <davidsav@md-laptop.(none)>
Date: Wed, 1 Apr 2009 12:06:45 -0400
Subject: [PATCH] add jumping VME interrupt routines to independent implementation

Adds implementations which use the virtual os table to invoke the
OS specific call.
---
 src/libCom/osi/devLib.c |   62 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 62 insertions(+), 0 deletions(-)

diff --git a/src/libCom/osi/devLib.c b/src/libCom/osi/devLib.c
index 224824f..675637d 100644
--- a/src/libCom/osi/devLib.c
+++ b/src/libCom/osi/devLib.c
@@ -907,6 +907,68 @@ long devNoResponseProbe (epicsAddressType addrType,
     return SUCCESS;
 }
 
+long devConnectInterruptVME(
+unsigned	vectorNumber,
+void		(*pFunction)(void *),
+void		*parameter )
+{
+    long status;
+
+    if (!devLibInitFlag) {
+        status = devLibInit();
+        if (status) {
+            return status;
+        }
+    }
+
+    return (*pdevLibVirtualOS->pDevConnectInterruptVME) (vectorNumber, 
+                    pFunction, parameter);
+}
+
+long devDisconnectInterruptVME(
+unsigned		vectorNumber,
+void			(*pFunction)(void *) )
+{
+    long status;
+
+    if (!devLibInitFlag) {
+        status = devLibInit();
+        if (status) {
+            return status;
+        }
+    }
+
+    return (*pdevLibVirtualOS->pDevDisconnectInterruptVME) (vectorNumber, pFunction);
+}
+
+long devEnableInterruptLevelVME (unsigned level)
+{
+    long status;
+
+    if (!devLibInitFlag) {
+        status = devLibInit();
+        if (status) {
+            return status;
+        }
+    }
+
+    return (*pdevLibVirtualOS->pDevEnableInterruptLevelVME) (level);
+}
+
+long devDisableInterruptLevelVME (unsigned level)
+{
+    long status;
+
+    if (!devLibInitFlag) {
+        status = devLibInit();
+        if (status) {
+            return status;
+        }
+    }
+
+    return (*pdevLibVirtualOS->pDevDisableInterruptLevelVME) (level);
+}
+
 /*
  * devConnectInterrupt ()
  *
-- 
1.5.6.5

From cb1bb413db3b2ef9cd9f14a57f86a4aca734f87a Mon Sep 17 00:00:00 2001
From: Michael Davidsaver <[email protected]>
Date: Thu, 20 Aug 2009 10:13:52 -0400
Subject: [PATCH] rename conflicting functions

---
 src/libCom/osi/os/RTEMS/devLibOSD.c   |   26 ++++++++++++++++++++------
 src/libCom/osi/os/vxWorks/devLibOSD.c |   28 +++++++++++++++++++++-------
 2 files changed, 41 insertions(+), 13 deletions(-)

diff --git a/src/libCom/osi/os/RTEMS/devLibOSD.c b/src/libCom/osi/os/RTEMS/devLibOSD.c
index 5e434b5..2d00e40 100644
--- a/src/libCom/osi/os/RTEMS/devLibOSD.c
+++ b/src/libCom/osi/os/RTEMS/devLibOSD.c
@@ -87,6 +87,20 @@ long rtmsDevReadProbe (unsigned wordSize, volatile const void *ptr, void *pValue
  */
 long rtmsDevWriteProbe (unsigned wordSize, volatile void *ptr, const void *pValue);
 
+static long rtmsDevConnectInterruptVME (
+    unsigned vectorNumber,
+    void (*pFunction)(),
+    void  *parameter);
+
+static long rtmsDevDisconnectInterruptVME (
+    unsigned vectorNumber,
+    void (*pFunction)() 
+);
+
+static long rtmsDevEnableInterruptLevelVME (unsigned level);
+
+static long rtmsDevDisableInterruptLevelVME (unsigned level);
+
 /* RTEMS specific init */
 
 /*devA24Malloc and devA24Free are not implemented*/
@@ -99,8 +113,8 @@ static long rtmsDevInit(void);
  */
 static devLibVirtualOS rtemsVirtualOS = {
     rtmsDevMapAddr, rtmsDevReadProbe, rtmsDevWriteProbe, 
-    devConnectInterruptVME, devDisconnectInterruptVME,
-    devEnableInterruptLevelVME, devDisableInterruptLevelVME,
+    rtmsDevConnectInterruptVME, rtmsDevDisconnectInterruptVME,
+    rtmsDevEnableInterruptLevelVME, rtmsDevDisableInterruptLevelVME,
     devA24Malloc,devA24Free,rtmsDevInit
 };
 devLibVirtualOS *pdevLibVirtualOS = &rtemsVirtualOS;
@@ -119,7 +133,7 @@ rtmsDevInit(void)
  *
  * wrapper to minimize driver dependency on OS
  */
-long devConnectInterruptVME (
+static long rtmsDevConnectInterruptVME (
     unsigned vectorNumber,
     void (*pFunction)(),
     void  *parameter)
@@ -152,7 +166,7 @@ long devConnectInterruptVME (
  *  an interrupt handler that was installed by another driver
  *
  */
-long devDisconnectInterruptVME (
+static long rtmsDevDisconnectInterruptVME (
     unsigned vectorNumber,
     void (*pFunction)() 
 )
@@ -188,7 +202,7 @@ long devDisconnectInterruptVME (
 /*
  * enable VME interrupt level
  */
-long devEnableInterruptLevelVME (unsigned level)
+static long rtmsDevEnableInterruptLevelVME (unsigned level)
 {
     return BSP_enableVME_int_lvl(level);
 }
@@ -196,7 +210,7 @@ long devEnableInterruptLevelVME (unsigned level)
 /*
  * disable VME interrupt level
  */
-long devDisableInterruptLevelVME (unsigned level)
+static long rtmsDevDisableInterruptLevelVME (unsigned level)
 {
     return BSP_disableVME_int_lvl(level);
 }
diff --git a/src/libCom/osi/os/vxWorks/devLibOSD.c b/src/libCom/osi/os/vxWorks/devLibOSD.c
index 22ec4ba..ee59aaf 100644
--- a/src/libCom/osi/os/vxWorks/devLibOSD.c
+++ b/src/libCom/osi/os/vxWorks/devLibOSD.c
@@ -114,13 +114,27 @@ static void *devA24Malloc(size_t size);
 static void devA24Free(void *pBlock);
 static long devInit(void) { return 0;}
 
+static long vxDevConnectInterruptVME (
+    unsigned vectorNumber,
+    void (*pFunction)(),
+    void  *parameter);
+
+static long vxDevDisconnectInterruptVME (
+    unsigned vectorNumber,
+    void (*pFunction)() 
+);
+
+static long vxDevEnableInterruptLevelVME (unsigned level);
+
+static long vxDevDisableInterruptLevelVME (unsigned level);
+
 /*
  * used by dynamic bind in devLib.c
  */
 static devLibVirtualOS vxVirtualOS = {
     vxDevMapAddr, vxDevReadProbe, vxDevWriteProbe, 
-    devConnectInterruptVME, devDisconnectInterruptVME,
-    devEnableInterruptLevelVME, devDisableInterruptLevelVME,
+    vxDevConnectInterruptVME, vxDevDisconnectInterruptVME,
+    vxDevEnableInterruptLevelVME, vxDevDisableInterruptLevelVME,
     devA24Malloc,devA24Free,devInit
 };
 devLibVirtualOS *pdevLibVirtualOS = &vxVirtualOS;
@@ -130,7 +144,7 @@ devLibVirtualOS *pdevLibVirtualOS = &vxVirtualOS;
  *
  * wrapper to minimize driver dependency on vxWorks
  */
-long devConnectInterruptVME (
+static long vxDevConnectInterruptVME (
     unsigned vectorNumber,
     void (*pFunction)(),
     void  *parameter)
@@ -154,7 +168,7 @@ long devConnectInterruptVME (
 
 /*
  *
- *  devDisconnectInterruptVME()
+ *  vxDevDisconnectInterruptVME()
  *
  *  wrapper to minimize driver dependency on vxWorks
  *
@@ -163,7 +177,7 @@ long devConnectInterruptVME (
  *  an interrupt handler that was installed by another driver
  *
  */
-long devDisconnectInterruptVME (
+static long vxDevDisconnectInterruptVME (
     unsigned vectorNumber,
     void (*pFunction)() 
 )
@@ -198,7 +212,7 @@ long devDisconnectInterruptVME (
 /*
  * enable VME interrupt level
  */
-long devEnableInterruptLevelVME (unsigned level)
+static long vxDevEnableInterruptLevelVME (unsigned level)
 {
 #   if CPU_FAMILY != I80X86 
         int s;
@@ -250,7 +264,7 @@ long devDisableInterruptLevelISA (unsigned level)
 /*
  * disable VME interrupt level
  */
-long devDisableInterruptLevelVME (unsigned level)
+static long vxDevDisableInterruptLevelVME (unsigned level)
 {
 #   if CPU_FAMILY != I80X86
         int s;
-- 
1.5.6.5

From 921dc559da24f1199002324e184e85f440fcf2c6 Mon Sep 17 00:00:00 2001
From: Michael Davidsaver <davidsav@md-laptop.(none)>
Date: Wed, 1 Apr 2009 12:08:38 -0400
Subject: [PATCH] add devInterruptInUseVME to function table

Add test for interrupt handler function to the virtual os table.
Adds a stub implementation to devLib.c
Renames OS implementations functions for RTEMS and vxWorks to avoid symbol name conflicts
---
 src/libCom/osi/devLib.c               |   14 ++++++++++++++
 src/libCom/osi/devLib.h               |    5 +++++
 src/libCom/osi/os/RTEMS/devLibOSD.c   |    6 ++++--
 src/libCom/osi/os/vxWorks/devLibOSD.c |    6 ++++--
 4 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/src/libCom/osi/devLib.c b/src/libCom/osi/devLib.c
index 675637d..489dba7 100644
--- a/src/libCom/osi/devLib.c
+++ b/src/libCom/osi/devLib.c
@@ -941,6 +941,20 @@ void			(*pFunction)(void *) )
     return (*pdevLibVirtualOS->pDevDisconnectInterruptVME) (vectorNumber, pFunction);
 }
 
+int devInterruptInUseVME (unsigned level)
+{
+    long status;
+
+    if (!devLibInitFlag) {
+        status = devLibInit();
+        if (status) {
+            return status;
+        }
+    }
+
+    return (*pdevLibVirtualOS->pDevInterruptInUseVME) (level);
+}
+
 long devEnableInterruptLevelVME (unsigned level)
 {
     long status;
diff --git a/src/libCom/osi/devLib.h b/src/libCom/osi/devLib.h
index fcd5497..a04967d 100644
--- a/src/libCom/osi/devLib.h
+++ b/src/libCom/osi/devLib.h
@@ -330,6 +330,11 @@ typedef struct devLibVirtualOS {
         void *(*pDevA24Malloc)(size_t nbytes);
         void (*pDevA24Free)(void *pBlock);
         long (*pDevInit)(void);
+
+	/*
+	 * test if VME interrupt has an ISR connected
+	 */
+	int (*pDevInterruptInUseVME) (unsigned vectorNumber);
 }devLibVirtualOS;
 epicsShareExtern devLibVirtualOS *pdevLibVirtualOS;
 
diff --git a/src/libCom/osi/os/RTEMS/devLibOSD.c b/src/libCom/osi/os/RTEMS/devLibOSD.c
index 2d00e40..89f3fb8 100644
--- a/src/libCom/osi/os/RTEMS/devLibOSD.c
+++ b/src/libCom/osi/os/RTEMS/devLibOSD.c
@@ -101,6 +101,8 @@ static long rtmsDevEnableInterruptLevelVME (unsigned level);
 
 static long rtmsDevDisableInterruptLevelVME (unsigned level);
 
+static int rtemsDevInterruptInUseVME (unsigned vectorNumber);
+
 /* RTEMS specific init */
 
 /*devA24Malloc and devA24Free are not implemented*/
@@ -115,7 +117,7 @@ static devLibVirtualOS rtemsVirtualOS = {
     rtmsDevMapAddr, rtmsDevReadProbe, rtmsDevWriteProbe, 
     rtmsDevConnectInterruptVME, rtmsDevDisconnectInterruptVME,
     rtmsDevEnableInterruptLevelVME, rtmsDevDisableInterruptLevelVME,
-    devA24Malloc,devA24Free,rtmsDevInit
+    devA24Malloc,devA24Free,rtmsDevInit,rtemsDevInterruptInUseVME
 };
 devLibVirtualOS *pdevLibVirtualOS = &rtemsVirtualOS;
 
@@ -296,7 +298,7 @@ static myISR *isrFetch(unsigned vectorNumber, void **parg)
 /*
  * determine if a VME interrupt vector is in use
  */
-int devInterruptInUseVME (unsigned vectorNumber)
+static int rtemsDevInterruptInUseVME (unsigned vectorNumber)
 {
     int i;
     myISR *psub;
diff --git a/src/libCom/osi/os/vxWorks/devLibOSD.c b/src/libCom/osi/os/vxWorks/devLibOSD.c
index ee59aaf..97e00e3 100644
--- a/src/libCom/osi/os/vxWorks/devLibOSD.c
+++ b/src/libCom/osi/os/vxWorks/devLibOSD.c
@@ -128,6 +128,8 @@ static long vxDevEnableInterruptLevelVME (unsigned level);
 
 static long vxDevDisableInterruptLevelVME (unsigned level);
 
+static int vxDevInterruptInUseVME (unsigned vectorNumber);
+
 /*
  * used by dynamic bind in devLib.c
  */
@@ -135,7 +137,7 @@ static devLibVirtualOS vxVirtualOS = {
     vxDevMapAddr, vxDevReadProbe, vxDevWriteProbe, 
     vxDevConnectInterruptVME, vxDevDisconnectInterruptVME,
     vxDevEnableInterruptLevelVME, vxDevDisableInterruptLevelVME,
-    devA24Malloc,devA24Free,devInit
+    devA24Malloc,devA24Free,devInit,vxDevInterruptInUseVME
 };
 devLibVirtualOS *pdevLibVirtualOS = &vxVirtualOS;
 
@@ -373,7 +375,7 @@ static myISR *isrFetch(unsigned vectorNumber)
 /*
  * determine if a VME interrupt vector is in use
  */
-int devInterruptInUseVME (unsigned vectorNumber)
+static int vxDevInterruptInUseVME (unsigned vectorNumber)
 {
 #if CPU_FAMILY == PPC
     return FALSE;
-- 
1.5.6.5

From c8e5a27448af5d7fc6b61f8b2201608cdbbd69a3 Mon Sep 17 00:00:00 2001
From: Michael Davidsaver <davidsav@md-laptop.(none)>
Date: Wed, 1 Apr 2009 14:16:31 -0400
Subject: [PATCH] mark all implimentation functions as static

---
 src/libCom/osi/os/RTEMS/devLibOSD.c   |   12 ++++++------
 src/libCom/osi/os/vxWorks/devLibOSD.c |    4 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/libCom/osi/os/RTEMS/devLibOSD.c b/src/libCom/osi/os/RTEMS/devLibOSD.c
index 89f3fb8..2abb3de 100644
--- a/src/libCom/osi/os/RTEMS/devLibOSD.c
+++ b/src/libCom/osi/os/RTEMS/devLibOSD.c
@@ -36,7 +36,7 @@ static myISR *isrFetch(unsigned vectorNumber, void **parg);
  * this routine needs to be in the symbol table
  * for this code to work correctly
  */
-void unsolicitedHandlerEPICS(int vectorNumber);
+static void unsolicitedHandlerEPICS(int vectorNumber);
 
 static myISR *defaultHandlerAddr[]={
     (myISR*)unsolicitedHandlerEPICS,
@@ -79,13 +79,13 @@ static long rtmsDevMapAddr (epicsAddressType addrType, unsigned options,
  * a bus error safe "wordSize" read at the specified address which returns 
  * unsuccessful status if the device isnt present
  */
-long rtmsDevReadProbe (unsigned wordSize, volatile const void *ptr, void *pValue);
+static long rtmsDevReadProbe (unsigned wordSize, volatile const void *ptr, void *pValue);
 
 /*
  * a bus error safe "wordSize" write at the specified address which returns 
  * unsuccessful status if the device isnt present
  */
-long rtmsDevWriteProbe (unsigned wordSize, volatile void *ptr, const void *pValue);
+static long rtmsDevWriteProbe (unsigned wordSize, volatile void *ptr, const void *pValue);
 
 static long rtmsDevConnectInterruptVME (
     unsigned vectorNumber,
@@ -250,7 +250,7 @@ static long rtmsDevMapAddr (epicsAddressType addrType, unsigned options,
  * unsuccessful status if the device isnt present
  */
 rtems_status_code bspExtMemProbe(void *addr, int write, int size, void *pval);
-long rtmsDevReadProbe (unsigned wordSize, volatile const void *ptr, void *pValue)
+static long rtmsDevReadProbe (unsigned wordSize, volatile const void *ptr, void *pValue)
 {
     long status;
 
@@ -269,7 +269,7 @@ long rtmsDevReadProbe (unsigned wordSize, volatile const void *ptr, void *pValue
  * a bus error safe "wordSize" write at the specified address which returns 
  * unsuccessful status if the device isnt present
  */
-long rtmsDevWriteProbe (unsigned wordSize, volatile void *ptr, const void *pValue)
+static long rtmsDevWriteProbe (unsigned wordSize, volatile void *ptr, const void *pValue)
 {
     long status;
 
@@ -335,7 +335,7 @@ static int rtemsDevInterruptInUseVME (unsigned vectorNumber)
  *  macro to declare handler prototypes...
  *
  */
-void unsolicitedHandlerEPICS(int vectorNumber)
+static void unsolicitedHandlerEPICS(int vectorNumber)
 {
     /*
      * call epicInterruptContextMessage()
diff --git a/src/libCom/osi/os/vxWorks/devLibOSD.c b/src/libCom/osi/os/vxWorks/devLibOSD.c
index 97e00e3..6bf6fbd 100644
--- a/src/libCom/osi/os/vxWorks/devLibOSD.c
+++ b/src/libCom/osi/os/vxWorks/devLibOSD.c
@@ -52,7 +52,7 @@ static myISR *isrFetch(unsigned vectorNumber);
  * this routine needs to be in the symbol table
  * for this code to work correctly
  */
-void unsolicitedHandlerEPICS(int vectorNumber);
+static void unsolicitedHandlerEPICS(int vectorNumber);
 
 /*
  * this is in veclist.c
@@ -413,7 +413,7 @@ static int vxDevInterruptInUseVME (unsigned vectorNumber)
  *  disconnected vector
  *
  */
-void unsolicitedHandlerEPICS(int vectorNumber)
+static void unsolicitedHandlerEPICS(int vectorNumber)
 {
     /*
      * call logMsg() and not errMessage()
-- 
1.5.6.5

From 65a72d9d698472c59ba7b6582a2887ffe053d7bc Mon Sep 17 00:00:00 2001
From: Michael Davidsaver <davidsav@md-laptop.(none)>
Date: Wed, 1 Apr 2009 14:20:27 -0400
Subject: [PATCH] move "virtual os" definition to a seperate file

The virtual os table is not something ordinary devLib users
should know or care about.
---
 src/libCom/Makefile            |    1 +
 src/libCom/osi/devLib.c        |    3 +
 src/libCom/osi/devLib.h        |   73 ++++++------------------------
 src/libCom/osi/devLibVMEImpl.h |   97 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 116 insertions(+), 58 deletions(-)
 create mode 100644 src/libCom/osi/devLibVMEImpl.h

diff --git a/src/libCom/Makefile b/src/libCom/Makefile
index 3d251f3..01e5170 100644
--- a/src/libCom/Makefile
+++ b/src/libCom/Makefile
@@ -192,6 +192,7 @@ INC += epicsStdioRedirect.h
 INC += epicsGetopt.h
 
 INC += devLib.h
+INC += devLibImpl.h
 INC += osdVME.h
 
 SRCS += epicsThread.cpp
diff --git a/src/libCom/osi/devLib.c b/src/libCom/osi/devLib.c
index 489dba7..5a49653 100644
--- a/src/libCom/osi/devLib.c
+++ b/src/libCom/osi/devLib.c
@@ -29,7 +29,10 @@ static const char sccsID[] = "@(#) devLib.c,v 1.1.2.11 2009/07/09 16:37:23 anj E
 #include "epicsMutex.h"
 #include "errlog.h"
 #include "ellLib.h"
+
+#define NO_DEVLIB_COMPAT
 #include "devLib.h"
+#include "devLibImpl.h"
 
 static ELLLIST addrAlloc[atLast];
 static ELLLIST addrFree[atLast];
diff --git a/src/libCom/osi/devLib.h b/src/libCom/osi/devLib.h
index a04967d..fc2c837 100644
--- a/src/libCom/osi/devLib.h
+++ b/src/libCom/osi/devLib.h
@@ -46,6 +46,21 @@ typedef enum {
  */
 extern const char *epicsAddressTypeName[];
 
+#ifdef __cplusplus
+}
+#endif
+
+/*
+ * To retain compatibility include everything by default
+ */
+#ifndef NO_DEVLIB_COMPAT
+#  include  "devLibImpl.h"
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 epicsShareFunc long devAddressMap(void); /* print an address map */
 
 /*
@@ -281,64 +296,6 @@ epicsShareFunc void devLibA24Free(void *pBlock);
 #define devPtrAlignTest(PTR) (!(devCreateAlignmentMask(*PTR)&(long)(PTR)))
 
 /*
- * virtual OS layer for devLib.c
- */
-typedef struct devLibVirtualOS {
-	/*
-	 * maps logical address to physical address, but does not detect
-	 * two device drivers that are using the same address range
-	 */
-	long (*pDevMapAddr) (epicsAddressType addrType, unsigned options,
-			size_t logicalAddress, size_t size, volatile void **ppPhysicalAddress);
-
-	/*
-	 * a bus error safe "wordSize" read at the specified address which returns 
-	 * unsuccessful status if the device isnt present
-	 */
-	long (*pDevReadProbe) (unsigned wordSize, volatile const void *ptr, void *pValueRead);
-
-	/*
-	 * a bus error safe "wordSize" write at the specified address which returns 
-	 * unsuccessful status if the device isnt present
-	 */
-	long (*pDevWriteProbe) (unsigned wordSize, volatile void *ptr, const void *pValueWritten);
-
-	/*
-	 * connect ISR to a VME interrupt vector
-	 * (required for backwards compatibility)
-	 */
-	long (*pDevConnectInterruptVME) (unsigned vectorNumber, 
-						void (*pFunction)(void *), void  *parameter);
-
-	/*
-	 * disconnect ISR from a VME interrupt vector
-	 * (required for backwards compatibility)
-	 */
-	long (*pDevDisconnectInterruptVME) (unsigned vectorNumber,
-						void (*pFunction)(void *));
-
-	/*
-	 * enable VME interrupt level
-	 */
-	long (*pDevEnableInterruptLevelVME) (unsigned level);
-
-	/*
-	 * disable VME interrupt level
-	 */
-	long (*pDevDisableInterruptLevelVME) (unsigned level);
-        /* malloc/free A24 address space */
-        void *(*pDevA24Malloc)(size_t nbytes);
-        void (*pDevA24Free)(void *pBlock);
-        long (*pDevInit)(void);
-
-	/*
-	 * test if VME interrupt has an ISR connected
-	 */
-	int (*pDevInterruptInUseVME) (unsigned vectorNumber);
-}devLibVirtualOS;
-epicsShareExtern devLibVirtualOS *pdevLibVirtualOS;
-
-/*
  * error codes (and messages) associated with devLib.c
  */
 #define S_dev_success 0
diff --git a/src/libCom/osi/devLibVMEImpl.h b/src/libCom/osi/devLibVMEImpl.h
new file mode 100644
index 0000000..775bc3b
--- /dev/null
+++ b/src/libCom/osi/devLibVMEImpl.h
@@ -0,0 +1,97 @@
+/*************************************************************************\
+* Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne
+*     National Laboratory.
+* Copyright (c) 2002 The Regents of the University of California, as
+*     Operator of Los Alamos National Laboratory.
+* EPICS BASE is distributed subject to a Software License Agreement found
+* in file LICENSE that is included with this distribution. 
+\*************************************************************************/
+/* devLibImpl.h */
+/*  */
+
+/*
+ * Original Author: Marty Kraimer 
+ *  Author:     Jeff Hill
+ *  Date:       03-10-93
+ */
+
+#ifndef INCdevLibImplh
+#define INCdevLibImplh 1
+
+#include "dbDefs.h"
+#include "shareLib.h"
+#include "devLib.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * virtual OS layer for devLib.c
+ *
+ * The global virtual OS table pdevLibVirtualOS controls
+ * the behaviour of the functions defined in devLib.h.
+ * All of which call into the functions found in this table
+ * to perform system specific tasks.
+ */
+typedef struct devLibVirtualOS {
+	/*
+	 * maps logical address to physical address, but does not detect
+	 * two device drivers that are using the same address range
+	 */
+	long (*pDevMapAddr) (epicsAddressType addrType, unsigned options,
+			size_t logicalAddress, size_t size, volatile void **ppPhysicalAddress);
+
+	/*
+	 * a bus error safe "wordSize" read at the specified address which returns 
+	 * unsuccessful status if the device isnt present
+	 */
+	long (*pDevReadProbe) (unsigned wordSize, volatile const void *ptr, void *pValueRead);
+
+	/*
+	 * a bus error safe "wordSize" write at the specified address which returns 
+	 * unsuccessful status if the device isnt present
+	 */
+	long (*pDevWriteProbe) (unsigned wordSize, volatile void *ptr, const void *pValueWritten);
+
+	/*
+	 * connect ISR to a VME interrupt vector
+	 * (required for backwards compatibility)
+	 */
+	long (*pDevConnectInterruptVME) (unsigned vectorNumber, 
+						void (*pFunction)(void *), void  *parameter);
+
+	/*
+	 * disconnect ISR from a VME interrupt vector
+	 * (required for backwards compatibility)
+	 */
+	long (*pDevDisconnectInterruptVME) (unsigned vectorNumber,
+						void (*pFunction)(void *));
+
+	/*
+	 * enable VME interrupt level
+	 */
+	long (*pDevEnableInterruptLevelVME) (unsigned level);
+
+	/*
+	 * disable VME interrupt level
+	 */
+	long (*pDevDisableInterruptLevelVME) (unsigned level);
+        /* malloc/free A24 address space */
+        void *(*pDevA24Malloc)(size_t nbytes);
+        void (*pDevA24Free)(void *pBlock);
+        long (*pDevInit)(void);
+
+	/*
+	 * test if VME interrupt has an ISR connected
+	 */
+	int (*pDevInterruptInUseVME) (unsigned vectorNumber);
+}devLibVirtualOS;
+
+epicsShareExtern devLibVirtualOS *pdevLibVirtualOS;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* INCdevLibImplh */
-- 
1.5.6.5

From 2806a2844764a13eae31302cb7e34c6e0d5f6c5d Mon Sep 17 00:00:00 2001
From: Michael Davidsaver <davidsav@md-laptop.(none)>
Date: Wed, 1 Apr 2009 11:50:12 -0400
Subject: [PATCH] reorganize devLib.h

Group functions by bus type with general functions at the top

add macro to exclude deprecated api
---
 src/libCom/osi/devLib.h |  164 +++++++++++++++++++++++++++++------------------
 1 files changed, 102 insertions(+), 62 deletions(-)

diff --git a/src/libCom/osi/devLib.h b/src/libCom/osi/devLib.h
index fc2c837..38fe471 100644
--- a/src/libCom/osi/devLib.h
+++ b/src/libCom/osi/devLib.h
@@ -61,6 +61,12 @@ extern const char *epicsAddressTypeName[];
 extern "C" {
 #endif
 
+/*
+ *  General API
+ *
+ *  This section applies to all bus types
+ */
+
 epicsShareFunc long devAddressMap(void); /* print an address map */
 
 /*
@@ -129,6 +135,12 @@ epicsShareFunc long devAllocAddress(
 			volatile void **pLocalAddress);
 
 /*
+ * VME API
+ *
+ * Functions in this section apply only to the VME bus type
+ */
+
+/*
  * connect ISR to a VME interrupt vector
  */
 epicsShareFunc long devConnectInterruptVME(
@@ -137,6 +149,48 @@ epicsShareFunc long devConnectInterruptVME(
 			void  *parameter);
 
 /*
+ * disconnect ISR from a VME interrupt vector
+ *
+ * The parameter pFunction should be set to the C function pointer that 
+ * was connected. It is used as a key to prevent a driver from inadvertently
+ * removing an interrupt handler that it didn't install 
+ */
+epicsShareFunc long devDisconnectInterruptVME(
+			unsigned vectorNumber,
+			void (*pFunction)(void *));
+
+/*
+ * determine if a VME interrupt vector is in use
+ *
+ * returns boolean
+ */
+epicsShareFunc int devInterruptInUseVME (unsigned vectorNumber);
+
+/*
+ * enable VME interrupt level
+ */
+epicsShareFunc long devEnableInterruptLevelVME (unsigned level);
+
+/*
+ * disable VME interrupt level
+ */
+epicsShareFunc long devDisableInterruptLevelVME (unsigned level);
+
+/*
+ * Routines to allocate and free memory in the A24 memory region.
+ *
+ */
+epicsShareFunc void *devLibA24Malloc(size_t);
+epicsShareFunc void *devLibA24Calloc(size_t);
+epicsShareFunc void devLibA24Free(void *pBlock);
+
+/*
+ * ISA API
+ *
+ * Functions in this section apply only to the ISA bus type
+ */
+
+/*
  * connect ISR to an ISA interrupt level
  * (not implemented)
  * (API should be reviewed)
@@ -147,40 +201,54 @@ epicsShareFunc long devConnectInterruptISA(
 			void  *parameter);
 
 /*
- * connect ISR to a PCI interrupt
+ * disconnect ISR from an ISA interrupt level
  * (not implemented)
  * (API should be reviewed)
- */
-epicsShareFunc long devConnectInterruptPCI(
-			unsigned bus,
-			unsigned device,
-			unsigned function,
-			void (*pFunction)(void *),
-			void  *parameter);
-
-/*
- * disconnect ISR from a VME interrupt vector
  *
  * The parameter pFunction should be set to the C function pointer that 
  * was connected. It is used as a key to prevent a driver from inadvertently
  * removing an interrupt handler that it didn't install 
  */
-epicsShareFunc long devDisconnectInterruptVME(
-			unsigned vectorNumber,
+epicsShareFunc long devDisconnectInterruptISA(
+			unsigned interruptLevel,
 			void (*pFunction)(void *));
 
 /*
- * disconnect ISR from an ISA interrupt level
+ * determine if an ISA interrupt level is in use
  * (not implemented)
- * (API should be reviewed)
  *
- * The parameter pFunction should be set to the C function pointer that 
- * was connected. It is used as a key to prevent a driver from inadvertently
- * removing an interrupt handler that it didn't install 
+ * returns boolean
  */
-epicsShareFunc long devDisconnectInterruptISA(
-			unsigned interruptLevel,
-			void (*pFunction)(void *));
+epicsShareFunc int devInterruptLevelInUseISA (unsigned interruptLevel);
+
+/*
+ * enable ISA interrupt level
+ */
+epicsShareFunc long devEnableInterruptLevelISA (unsigned level);
+
+/*
+ * disable ISA interrupt level
+ */
+epicsShareFunc long devDisableInterruptLevelISA (unsigned level);
+
+
+/*
+ * PCI API
+ *
+ * Functions in this section apply only to the ISA bus type
+ */
+
+/*
+ * connect ISR to a PCI interrupt
+ * (not implemented)
+ * (API should be reviewed)
+ */
+epicsShareFunc long devConnectInterruptPCI(
+			unsigned bus,
+			unsigned device,
+			unsigned function,
+			void (*pFunction)(void *),
+			void  *parameter);
 
 /*
  * disconnect ISR from a PCI interrupt
@@ -198,21 +266,6 @@ epicsShareFunc long devDisconnectInterruptPCI(
 			void (*pFunction)(void *));
 
 /*
- * determine if a VME interrupt vector is in use
- *
- * returns boolean
- */
-epicsShareFunc int devInterruptInUseVME (unsigned vectorNumber);
-
-/*
- * determine if an ISA interrupt level is in use
- * (not implemented)
- *
- * returns boolean
- */
-epicsShareFunc int devInterruptLevelInUseISA (unsigned interruptLevel);
-
-/*
  * determine if a PCI interrupt is in use
  * (not implemented)
  *
@@ -221,17 +274,6 @@ epicsShareFunc int devInterruptLevelInUseISA (unsigned interruptLevel);
 epicsShareFunc int devInterruptInUsePCI (unsigned bus, unsigned device, 
 							  unsigned function);
 
-typedef enum {intVME, intVXI, intISA} epicsInterruptType;
-
-/*
- * enable VME interrupt level
- */
-epicsShareFunc long devEnableInterruptLevelVME (unsigned level);
-
-/*
- * enable ISA interrupt level
- */
-epicsShareFunc long devEnableInterruptLevelISA (unsigned level);
 
 /*
  * not implemented - API needs to be reviewed 
@@ -240,28 +282,15 @@ epicsShareFunc long devEnableInterruptLevelPCI (unsigned level,
 			unsigned bus, unsigned device, unsigned function);
 
 /*
- * disable VME interrupt level
- */
-epicsShareFunc long devDisableInterruptLevelVME (unsigned level);
-
-/*
- * disable ISA interrupt level
- */
-epicsShareFunc long devDisableInterruptLevelISA (unsigned level);
-
-/*
  * not implemented - API needs to be reviewed 
  */
 epicsShareFunc long devDisableInterruptLevelPCI (unsigned level,
 			unsigned bus, unsigned device, unsigned function);
 
+
 /*
- * Routines to allocate and free memory in the A24 memory region.
- *
+ * Support macros
  */
-epicsShareFunc void *devLibA24Malloc(size_t);
-epicsShareFunc void *devLibA24Calloc(size_t);
-epicsShareFunc void devLibA24Free(void *pBlock);
 
 /*
  * Normalize a digital value and convert it to type TYPE
@@ -336,6 +365,15 @@ epicsShareFunc void devLibA24Free(void *pBlock);
 #define S_dev_badCRCSR (M_devLib| 35) /*Invalid VME CR/CSR address*/
 #define S_dev_vxWorksIntEnFail S_dev_intEnFail
 
+
+/*
+ * Deprecated interface
+ */
+
+#ifndef NO_DEVLIB_OLD_INTERFACE
+
+typedef enum {intVME, intVXI, intISA} epicsInterruptType;
+
 /*
  * NOTE: this routine has been deprecated. It exists
  * for backwards compatibility purposes only.
@@ -394,6 +432,8 @@ epicsShareFunc long devDisableInterruptLevel (
  */
 epicsShareFunc long locationProbe (epicsAddressType addrType, char *pLocation);
 
+#endif /* NO_DEVLIB_OLD_INTERFACE */
+
 /*
  * Some vxWorks convenience routines
  */
-- 
1.5.6.5

From b73c21b411144385eafd88896f6f3df267ce2219 Mon Sep 17 00:00:00 2001
From: Michael Davidsaver <davidsav@md-laptop.(none)>
Date: Wed, 1 Apr 2009 11:50:44 -0400
Subject: [PATCH] use epics extern macro

---
 src/libCom/osi/devLib.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/libCom/osi/devLib.h b/src/libCom/osi/devLib.h
index 38fe471..85347f8 100644
--- a/src/libCom/osi/devLib.h
+++ b/src/libCom/osi/devLib.h
@@ -44,7 +44,7 @@ typedef enum {
  * pointer to an array of strings for each of
  * the above address types
  */
-extern const char *epicsAddressTypeName[];
+epicsShareExtern const char *epicsAddressTypeName[];
 
 #ifdef __cplusplus
 }
-- 
1.5.6.5


References:
devLib ruminations Davidsaver, Michael
Re: devLib ruminations Andrew Johnson
RE: devLib ruminations Davidsaver, Michael

Navigate by Date:
Prev: Re: devLib ruminations Andrew Johnson
Next: RE: devLib ruminations Davidsaver, Michael
Index: 2002  2003  2004  2005  2006  2007  2008  <20092010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: RE: devLib ruminations Davidsaver, Michael
Next: why doesnt the include file install set the file permisions to unwritable? Jeff Hill
Index: 2002  2003  2004  2005  2006  2007  2008  <20092010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 02 Feb 2012 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·