Skip to content

Commit

Permalink
Imported Upstream version 2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
mdavidsaver committed Jan 28, 2016
1 parent b59d126 commit 8391f4b
Show file tree
Hide file tree
Showing 21 changed files with 412 additions and 96 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
README.md export-subst
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
/include/
/lib/
O.*/
*.local
1 change: 1 addition & 0 deletions .hgtags
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ da086a6d94ae8b2f2447dd3eba39dd6ff929a35e 2.2
921aed1b0b86ada325b9e5fe70acfd383636e008 2.3
4ceac34e67b963a6be0a2c6f032004f337568912 2.4
9dd68ea8e138c64e1f6c1a8e874ba8629dc8b07e 2.5
8f9f3f208d469f694812a0c8333d8316443919d0 2.6
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
sudo: false
language: c
env:
- BASE=3.14 STATIC=shared
- BASE=3.14 STATIC=static
- BASE=3.15 STATIC=shared
- BASE=3.15 STATIC=static
- BASE=3.16 STATIC=shared
- BASE=3.16 STATIC=static
install: ./build-deps.sh
script:
- make -j2
- make -s runtests
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
devLib2 - Library for direct MMIO access to PCI and VME64x
==========================================================

Michael Davidsaver <[email protected]>

[Documentation and example](http://epics.sourceforge.net/devlib2/)

Releases are found at:

[http://sourceforge.net/projects/epics/files/](http://sourceforge.net/projects/epics/files/)

Requires: [EPICS Base](http://www.aps.anl.gov/epics/) >= 3.14.8.2

VCS sources

```shell
git clone https://github.com/epics-modules/devlib2.git
```

This is file is generated from git revision edceda7bf90fa7de9108c01a2dc7185806fe4575

<a href="https://travis-ci.org/epics-modules/devlib2"><img src="https://travis-ci.org/epics-modules/devlib2.svg">CI Build Status</img></a>
39 changes: 0 additions & 39 deletions README.txt

This file was deleted.

43 changes: 43 additions & 0 deletions build-deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/sh
set -e -x

# Build base for use with https://travis-ci.org
#
# Set environment variables
# BASE= 3.14 3.15 or 3.16 (VCS branch)
# STATIC= static or shared

die() {
echo "$1" >&2
exit 1
}

[ "$BASE" ] || die "Set BASE"

CDIR="$HOME/.cache/base-$BASE-$STATIC"

if [ ! -e "$CDIR/built" ]
then
install -d "$CDIR"
( cd "$CDIR" && git clone --depth 50 --branch $BASE https://github.com/epics-base/epics-base.git base )

EPICS_BASE="$CDIR/base"

case "$STATIC" in
static)
cat << EOF >> "$EPICS_BASE/configure/CONFIG_SITE"
SHARED_LIBRARIES=NO
STATIC_BUILD=YES
EOF
;;
*) ;;
esac

make -C "$EPICS_BASE" -j2

touch "$CDIR/built"
fi

EPICS_HOST_ARCH=`sh $EPICS_BASE/startup/EpicsHostArch`

echo "EPICS_BASE=$EPICS_BASE" > configure/RELEASE.local
8 changes: 8 additions & 0 deletions common/os/vxWorks/epicsMMIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,21 @@
* functions to do the same thing though, so we can't use them.
*/

#ifdef __cplusplus
extern "C" {
#endif

UINT8 sysPciInByte(UINT8 *addr);
void sysPciOutByte(UINT8 *addr, UINT8 data);
UINT16 sysPciInWord(UINT16 *addr);
void sysPciOutWord(UINT16 *addr, UINT16 data);
UINT32 sysPciInLong (UINT32 *addr);
void sysPciOutLong (UINT32 *addr, UINT32 data);

#ifdef __cplusplus
}
#endif

#define ioread8(address) sysPciInByte((UINT8 *)(address))
#define iowrite8(address,data) sysPciOutByte((UINT8 *)(address), (epicsUInt8)(data))

Expand Down
6 changes: 5 additions & 1 deletion configure/RELEASE
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@

TEMPLATE_TOP=$(EPICS_BASE)/templates/makeBaseApp/top

# The definitions shown below can also be placed in an untracked RELEASE.local
-include $(TOP)/../RELEASE.local
-include $(TOP)/configure/RELEASE.local

## Required Modules ##

# EPICS_BASE usually appears last so other apps can override stuff:
EPICS_BASE=/usr/lib/epics
#EPICS_BASE=/usr/lib/epics
2 changes: 1 addition & 1 deletion documentation/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ PROJECT_NAME = devLib2
# This could be handy for archiving the generated documentation or
# if some version control system is used.

PROJECT_NUMBER = 2.5
PROJECT_NUMBER = 2.7

# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
Expand Down
20 changes: 17 additions & 3 deletions documentation/mainpage.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ and bug fixes for the 3.14.x and 3.15.x series.
Releases can be found at @url http://sourceforge.net/projects/epics/files/devlib2/
This module is versioned with Mercurial and can be viewed at
VCS source browser
@url https://github.com/epics-modules/devlib2
Or checked out with
Expand Down Expand Up @@ -78,6 +78,20 @@ the width and order of accesses.
@section changelog Changelog
@subsection ver27 2.7 (Jan. 2016)
@li configure: optionally include \$(TOP)/configure/RELEASE.local and \$(TOP)/../RELEASE.local.
\$(EPICS_BASE) is no longer defined by default in configure/RELEASE and must
be explicitly set in one of the possible RELEASE* files.
@li Fix compile failure on vxWorks (Eric Bjorklund)
@li Add missing extern "C" in epicsMMIO.h for vxWorks (Eric Bjorklund)
@li In epicsMMIODef.h replace 'inline' with 'static inline' for C compatibility.
@li RTEMS: handle BSPs with offset PCI addresses
@li pci/linux: devPCIDebug>1 enables more debug output when searching/matching PCI devices.
@li pci/linux: fix error preventing use of uio devices other than uio0.
@li vme: add vmewrite(), vmeirqattach(), and vmeirq() iocsh commands
for debugging/development with VME devices.
@subsection ver26 2.6 (May 2015)
@li VCS repository moved to github.com
Expand Down Expand Up @@ -201,10 +215,10 @@ this is the only piece of information required to access the card.
Below is an example implementation of myPCICardSetup().
@code
static const struct VMECSRID mydevids[] = {...}
static const epicsPCIID mydevids[] = {...}
int
myVMECardSetup(const char* port,
myPCICardSetup(const char* port,
int b,
int d,
int f)
Expand Down
65 changes: 37 additions & 28 deletions pciApp/os/Linux/devLibPCIOSD.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,32 +282,27 @@ struct locations_t {
{NULL,NULL}
};

static
int match_uio(const char *pat, const struct dirent *ent)
{
unsigned int X;
/* poor mans regexp... */
return sscanf(ent->d_name, pat, &X)==1;
}

static
int find_uio_number2(const char* dname, const char* pat)
{
int ret=-1;
DIR *d;
struct dirent *ent;

if(devPCIDebug>2)
errlogPrintf("Looking for UIO dir in %s with %s\n", dname, pat);

d=opendir(dname);
if (!d)
return ret;

while ((ent=readdir(d))!=NULL) {
if (!match_uio(pat, ent))
continue;
if (sscanf(ent->d_name, pat, &ret)==1) {
int num, sts = sscanf(ent->d_name, pat, &num);
if(devPCIDebug>2) errlogPrintf(" Check %s gives %d %d\n", ent->d_name, sts, num);
if (sts==1) {
ret = num;
break;
}
ret=-1;
}

closedir(d);
Expand Down Expand Up @@ -338,12 +333,12 @@ find_uio_number(const struct osdPCIDevice* osd)
ret = find_uio_number2(devdir, curloc->name);
free (devdir);

if (ret == 0)
return 0;
if (ret != -1)
return ret;
}
errlogPrintf("Failed to open uio device for PCI device %04x:%02x:%02x.%x: %s\n",
osd->dev.domain, osd->dev.bus, osd->dev.device, osd->dev.function, strerror(errno));
return ret;
return -1;
}

static
Expand Down Expand Up @@ -643,38 +638,52 @@ linuxDevPCIFindCB(

cur=ellFirst(&devices);
for(; cur; cur=ellNext(cur)){
unsigned i;
curdev=CONTAINER(cur,osdPCIDevice,node);
epicsMutexMustLock(curdev->devLock);

for(search=idlist; search->device!=DEVPCI_LAST_DEVICE; search++){
if(devPCIDebug>1)
printf("Consider %d:%d.%d\n", curdev->dev.bus, curdev->dev.device, curdev->dev.function);

for(search=idlist, i=0; search->device!=DEVPCI_LAST_DEVICE; search++, i++){

if(search->device!=DEVPCI_ANY_DEVICE &&
search->device!=curdev->dev.id.device)
search->device!=curdev->dev.id.device) {
if(devPCIDebug>1) printf(" %u mismatch device %x %x\n", i,
(unsigned)search->device, (unsigned)curdev->dev.id.device);
continue;
else
if(search->vendor!=DEVPCI_ANY_DEVICE &&
search->vendor!=curdev->dev.id.vendor)
} else
if(search->vendor!=DEVPCI_ANY_VENDOR &&
search->vendor!=curdev->dev.id.vendor) {
if(devPCIDebug>1) printf(" %u mismatch vendor\n", i);
continue;
else
} else
if( search->sub_device!=DEVPCI_ANY_SUBDEVICE &&
search->sub_device!=curdev->dev.id.sub_device
)
) {
if(devPCIDebug>1) printf(" %u mismatch subdevice\n", i);
continue;
else
} else
if( search->sub_vendor!=DEVPCI_ANY_SUBVENDOR &&
search->sub_vendor!=curdev->dev.id.sub_vendor
)
) {
if(devPCIDebug>1) printf(" %u mismatch subvendor\n", i);
continue;
else
} else
if( search->pci_class!=DEVPCI_ANY_CLASS &&
search->pci_class!=curdev->dev.id.pci_class
)
) {
if(devPCIDebug>1) printf(" %u mismatch class\n", i);
continue;
else
} else
if( search->revision!=DEVPCI_ANY_REVISION &&
search->revision!=curdev->dev.id.revision
)
) {
if(devPCIDebug>1) printf(" %u mismatch revision\n", i);
continue;
}
if(devPCIDebug>1)
printf(" %u Match\n", i);

/* Match found */

Expand Down
11 changes: 11 additions & 0 deletions pciApp/os/RTEMS/devLibPCIOSD.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <rtems/pci.h>
#include <rtems/endian.h>
#include <rtems/irq.h>
#include <bsp.h>

/* 0 <= N <= 5 */
#define PCI_BASE_ADDRESS(N) ( PCI_BASE_ADDRESS_0 + 4*(N) )
Expand All @@ -18,4 +19,14 @@ typedef uint32_t PCIUINT32;
# define PCI_HEADER_MULTI_FUNC 0x80
#endif

#if defined(PCI_MEM_BASE)
# define PCI_MEM_OFFSET PCI_MEM_BASE
#endif

#if defined(_IO_BASE)
# define PCI_IO_OFFSET _IO_BASE
#elif defined(_ISA_MEM_BASE)
# define PCI_IO_OFFSET _ISA_MEM_BASE
#endif

#endif /* OSDPCI_H_INC */
8 changes: 7 additions & 1 deletion pciApp/os/vxWorks/devLibPCIOSD.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
* equivalent.
*/

#ifndef PCIUINT32
typedef uint32_t PCIUINT32;
#endif

#define pci_find_device pciFindDevice

#define pci_read_config_byte pciConfigInByte
Expand All @@ -26,7 +30,9 @@
#define pci_write_config_dword pciConfigOutLong

#define PCI_HEADER_TYPE PCI_CFG_HEADER_TYPE
#define PCI_HEADER_TYPE_BRIDGE PCI_HEADER_PCI_PCI
#ifndef PCI_HEADER_TYPE_BRIDGE
# define PCI_HEADER_TYPE_BRIDGE PCI_HEADER_PCI_PCI
#endif

/* 0 <= N <= 5 */
#define PCI_BASE_ADDRESS(N) ( PCI_CFG_BASE_ADDRESS_0 + 4*(N) )
Expand Down
Loading

0 comments on commit 8391f4b

Please sign in to comment.