Skip to content

Commit

Permalink
Add option to pass the full device name to C API
Browse files Browse the repository at this point in the history
  • Loading branch information
lerwys committed Dec 15, 2014
1 parent 648882f commit ccd0bb7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion include/pcie/lib/pciDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ typedef struct {
#define PD_DIR_TODEVICE 1
#define PD_DIR_FROMDEVICE 2

int pd_open( int dev, pd_device_t *pci_handle );
int pd_open( int dev, pd_device_t *pci_handle, char *dev_entry );
int pd_close( pd_device_t *pci_handle );

/* Kernel Memory Functions */
Expand Down
22 changes: 14 additions & 8 deletions lib/pcie/pciDriver_Capi.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ int pd_getpagemask() {
return pagemask;
}

int pd_open( int dev, pd_device_t *pci_handle )
int pd_open( int dev, pd_device_t *pci_handle, char *dev_entry )
{
int ret;

Expand All @@ -68,17 +68,23 @@ int pd_open( int dev, pd_device_t *pci_handle )
return -1;

pci_handle->device = dev;
sprintf( pci_handle->name, "/dev/fpga%d", dev );

ret = open( pci_handle->name, O_RDWR );
if (ret < 0)
return -1;
if ( dev_entry ) {
snprintf( pci_handle->name, sizeof( pci_handle->name ), dev_entry );
}
else {
snprintf( pci_handle->name, sizeof( pci_handle->name ), "/dev/fpga%d", dev );
}

pci_handle->handle = ret;
ret = open( pci_handle->name, O_RDWR );
if (ret < 0)
return -1;

pthread_mutex_init( &pci_handle->mmap_mutex, NULL );
pci_handle->handle = ret;

return 0;
pthread_mutex_init( &pci_handle->mmap_mutex, NULL );

return 0;
}

int pd_close(pd_device_t *pci_handle)
Expand Down

0 comments on commit ccd0bb7

Please sign in to comment.