URL
https://opencores.org/ocsvn/funbase_ip_library/funbase_ip_library/trunk
Subversion Repositories funbase_ip_library
Compare Revisions
- This comparison shows the changes necessary to convert path
/
- from Rev 5 to Rev 6
- ↔ Reverse comparison
Rev 5 → Rev 6
/funbase_ip_library/trunk/Flexiblis/ip.swp.api/fb_pcie_api/1.0/fb_pcie_api.1.0.xml
0,0 → 1,17
<?xml version="1.0" encoding="UTF-8"?> |
<!--Created by Kactus 2 document generator 11:05:25 pe loka 7 2011--> |
<spirit:busDefinition> |
<spirit:vendor>Flexiblis</spirit:vendor> |
<spirit:library>ip.swp.api</spirit:library> |
<spirit:name>fb_pcie_api</spirit:name> |
<spirit:version>1.0</spirit:version> |
<spirit:directConnection>true</spirit:directConnection> |
<spirit:isAddressable>true</spirit:isAddressable> |
<spirit:vendorExtensions> |
<kactus2:extensions> |
<kactus2:kts_attributes> |
<kactus2:kts_busdef_type>BusAPI</kactus2:kts_busdef_type> |
</kactus2:kts_attributes> |
</kactus2:extensions> |
</spirit:vendorExtensions> |
</spirit:busDefinition> |
/funbase_ip_library/trunk/Flexiblis/ip.swp.driver/fb_pcie_driver/1.0/src/userspace/io_ctrl.h
0,0 → 1,62
/** @file io_ctrl.h |
* Funbase io main header file. |
*/ |
|
/* |
This confidential and proprietary software may be used only as |
authorized by a licensing agreement from Flexibilis Oy. |
|
(C) COPYRIGHT 2008-2010 FLEXIBILIS OY, ALL RIGHTS RESERVED |
|
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
|
/******************************************************************************* |
* $Id: fbd.h 10667 2010-03-10 17:43:28Z timokosk $ |
*******************************************************************************/ |
|
#ifndef _IO_CTRL_H_ |
#define _IO_CTRL_H_ |
|
#include <stdio.h> |
#include <stdint.h> |
|
/** |
* Read 32 bit value from FPGA. |
* @param fd Character device fd. |
* @param address Address in FPGA internal bus. |
* @param data Read value is returned here. |
* @return 0 on success or negative error code. |
*/ |
int read32(int fd, uint32_t address, uint32_t * data); |
|
/** |
* Read 64 bit value from FPGA. |
* @param fd Character device fd. |
* @param address Address in FPGA internal bus. |
* @param data Read value is returned here. |
* @return 0 on success or negative error code. |
*/ |
int read64(int fd, uint32_t address, uint64_t * data); |
|
/** |
* Write 32 bit value to FPGA. |
* @param fd Character device fd. |
* @param address Address in FPGA internal bus. |
* @param data Data to write. |
* @return 0 on success or negative error code. |
*/ |
int write32(int fd, uint32_t address, uint32_t data); |
|
/** |
* Write 64 bit value to FPGA. |
* @param fd Character device fd. |
* @param address Address in FPGA internal bus. |
* @param data Data to write. |
* @return 0 on success or negative error code. |
*/ |
int write64(int fd, uint32_t address, uint64_t data); |
|
#endif // _IO_CTRL_H_ |
/funbase_ip_library/trunk/Flexiblis/ip.swp.driver/fb_pcie_driver/1.0/src/userspace/main.c
0,0 → 1,53
/** @file main.c |
* Funbase io. |
*/ |
|
/* |
This confidential and proprietary software may be used only as |
authorized by a licensing agreement from Flexibilis Oy. |
|
(C) COPYRIGHT 2008-2010 FLEXIBILIS OY, ALL RIGHTS RESERVED |
|
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
|
/******************************************************************************* |
* $Id: main.c 10668 2010-03-10 18:50:42Z timokosk $ |
*******************************************************************************/ |
#include <sys/types.h> |
#include <sys/stat.h> |
#include <fcntl.h> |
#include <sys/ioctl.h> |
#include <sys/wait.h> |
#include <stdio.h> |
#include <stdint.h> |
#include <stdlib.h> |
#include <unistd.h> |
#include <string.h> |
|
#include <fbd_ioctl.h> |
|
#include "io_ctrl.h" |
|
int main(void){ |
int ret = 0; |
int fd = 0; |
uint32_t address = 0; |
uint32_t data = 0; |
|
fd = open(FBD_CTRL_DEV, O_RDWR | O_NONBLOCK); |
if( fd < 0) { |
perror("open"); |
return -1; |
} |
|
ret = read32(fd, address, &data); |
|
printf("Read from address 0x%08x data 0x%08x\n", address, data); |
|
close(fd); |
|
return 0; |
} |
/funbase_ip_library/trunk/Flexiblis/ip.swp.driver/fb_pcie_driver/1.0/src/userspace/io_ctrl.c
0,0 → 1,120
/** @file funbase_io.c |
* Funbase io. |
*/ |
|
/* |
This confidential and proprietary software may be used only as |
authorized by a licensing agreement from Flexibilis Oy. |
|
(C) COPYRIGHT 2008-2010 FLEXIBILIS OY, ALL RIGHTS RESERVED |
|
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
|
/******************************************************************************* |
* $Id: io_ctrl.c 10668 2010-03-10 18:50:42Z timokosk $ |
*******************************************************************************/ |
#include <sys/types.h> |
#include <sys/stat.h> |
#include <fcntl.h> |
#include <sys/ioctl.h> |
#include <sys/wait.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdint.h> |
#include <unistd.h> |
#include <string.h> |
|
#include <fbd_ioctl.h> |
|
/** |
* Read 32 bit value from FPGA. |
* @param fd Character device fd. |
* @param address Address in FPGA internal bus. |
* @param data Read value is returned here. |
* @return 0 on success or negative error code. |
*/ |
int read32(int fd, uint32_t address, uint32_t * data) |
{ |
struct fbd_cmd_struct fbd_cmd; |
|
fbd_cmd.address = address; |
if( ioctl(fd, FBD_IOCTL_READ_DATA32, &fbd_cmd) != 0 ){ |
perror("ioctl"); |
return -1; |
} |
|
*data = fbd_cmd.data32; |
|
return 0; |
} |
|
/** |
* Read 64 bit value from FPGA. |
* @param fd Character device fd. |
* @param address Address in FPGA internal bus. |
* @param data Read value is returned here. |
* @return 0 on success or negative error code. |
*/ |
int read64(int fd, uint32_t address, uint64_t * data) |
{ |
struct fbd_cmd_struct fbd_cmd; |
|
fbd_cmd.address = address; |
if( ioctl(fd, FBD_IOCTL_READ_DATA64, &fbd_cmd) != 0 ){ |
perror("ioctl"); |
return -1; |
} |
|
*data = fbd_cmd.data64; |
|
return 0; |
} |
|
/** |
* Write 32 bit value to FPGA. |
* @param fd Character device fd. |
* @param address Address in FPGA internal bus. |
* @param data Data to write. |
* @return 0 on success or negative error code. |
*/ |
int write32(int fd, uint32_t address, uint32_t data) |
{ |
struct fbd_cmd_struct fbd_cmd; |
|
fbd_cmd.address = address; |
fbd_cmd.data32 = data; |
|
if( ioctl(fd, FBD_IOCTL_WRITE_DATA32, &fbd_cmd) != 0 ){ |
perror("ioctl"); |
return -1; |
} |
|
return 0; |
} |
|
/** |
* Write 64 bit value to FPGA. |
* @param fd Character device fd. |
* @param address Address in FPGA internal bus. |
* @param data Data to write. |
* @return 0 on success or negative error code. |
*/ |
int write64(int fd, uint32_t address, uint64_t data) |
{ |
struct fbd_cmd_struct fbd_cmd; |
|
fbd_cmd.address = address; |
fbd_cmd.data64 = data; |
|
if( ioctl(fd, FBD_IOCTL_WRITE_DATA64, &fbd_cmd) != 0 ){ |
perror("ioctl"); |
return -1; |
} |
|
|
return 0; |
} |
|
/funbase_ip_library/trunk/Flexiblis/ip.swp.driver/fb_pcie_driver/1.0/src/userspace/Makefile
0,0 → 1,43
# Makefile for Funbase io |
|
SHELL = /bin/sh |
|
#### Start of system configuration section. #### |
srcdir = . |
CC = gcc -rdynamic -O |
RM = rm -rf |
|
# Directories. |
prefix = /usr/local |
bindir = $(prefix)/bin |
|
LIBS = |
LIBDIRS = |
INCLUDES = -I../driver |
CDEBUG = -g |
CFLAGS = $(CDEBUG) $(INCLUDES) -Wall -O0 |
LDFLAGS = -g $(LIBDIRS) $(LIBS) |
|
#### End of system configuration section. #### |
|
OBJ = main.o io_ctrl.o |
HDR = *.h |
|
PROG = io_ctrl |
|
.c.o: |
$(CC) -c $(CFLAGS) -o $@ $< |
|
all: $(PROG) |
|
$(PROG): $(OBJ) |
$(CC) $(LDFLAGS) -o $@ $(OBJ) |
|
$(OBJ): $(HDR) |
|
install: all |
cp $(PROG) $(bindir)/ |
|
clean: |
$(RM) $(PROG) $(OBJ) |
|
/funbase_ip_library/trunk/Flexiblis/ip.swp.driver/fb_pcie_driver/1.0/src/driver/fbd_main.c
0,0 → 1,243
/** @file fbd_main.c |
* Funbase device driver main file. |
*/ |
|
/* |
This confidential and proprietary software may be used only as |
authorized by a licensing agreement from Flexibilis Oy. |
|
(C) COPYRIGHT 2008-2010 FLEXIBILIS OY, ALL RIGHTS RESERVED |
|
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
|
/******************************************************************************* |
* $Id: fbd_main.c 10668 2010-03-10 18:50:42Z timokosk $ |
*******************************************************************************/ |
|
#if !defined(__OPTIMIZE__) |
#warning You must compile this file with the correct options! |
#warning See the last lines of the source file. |
#error You must compile this driver with "-O". |
#endif |
|
#include <linux/mm.h> |
#include <linux/random.h> |
#include <linux/module.h> |
#include <linux/kernel.h> |
#include <linux/string.h> |
#include <linux/timer.h> |
#include <linux/errno.h> |
#include <linux/ioport.h> |
#include <linux/slab.h> |
#include <linux/interrupt.h> |
#include <linux/pci.h> |
#include <linux/init.h> |
#include <linux/mii.h> |
#include <linux/netdevice.h> |
#include <linux/etherdevice.h> |
#include <linux/skbuff.h> |
#include <linux/ethtool.h> |
#include <linux/proc_fs.h> |
#include <asm/uaccess.h> |
#include <asm/processor.h> |
#include <asm/unaligned.h> |
#include <asm/bitops.h> |
#include <asm/io.h> |
#include <linux/version.h> |
|
#include "fbd.h" |
#include "fbd_ioctl.h" |
|
#define PCI_IOTYPE (PCI_USES_MASTER | PCI_USES_MEM | PCI_ADDR0) |
|
static struct pci_device_id fbd_pci_tbl[] __devinitdata = { |
{0x1172, 0x0008, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, //Altera |
{0,} |
}; |
|
//supported FBD devices: |
#define NUMBER_OF_SUPPORTED_PCI_DEVICES 1 |
struct supported_pci_device |
supported_pci_devices[NUMBER_OF_SUPPORTED_PCI_DEVICES] = { |
{0x1172, 0x0008, "Altera Stratix GX PCIe DevKit", MSI_ALTERA}, |
}; |
|
//global variables: |
#ifdef MODULE //if compiled as a kernel module |
MODULE_DESCRIPTION("Flexibilis Funbase device driver"); |
MODULE_AUTHOR("Timo Koskiahde"); |
MODULE_DEVICE_TABLE(pci, fbd_pci_tbl); |
MODULE_LICENSE("Proprietary"); |
#endif //MODULE |
|
// Static data |
static struct fbd_private fbd_priv; |
|
|
//functions: |
static int __devinit fbd_init_one_pci(struct pci_dev *pdev, |
const struct pci_device_id *ent); |
static void __devexit fbd_remove_one_pci(struct pci_dev *pdev); |
static int __init fbd_init(void); |
static void __exit fbd_cleanup(void); |
|
/** |
* Init one Funbase device that is in PCI bus. |
*/ |
static int __devinit fbd_init_one_pci(struct pci_dev *pdev, |
const struct pci_device_id *ent) |
{ |
unsigned long pci_ioaddr; |
int pci_device_type; //in supported_pci_devices -list |
int pci_device_identified = 0; |
int error; |
|
error = pci_enable_device(pdev); |
if (error) { |
printk("FBD: warning: pci_enable_device returned %x.\n", error); |
return error; |
} |
|
error = pci_request_regions(pdev, DRV_NAME); |
if (error) { |
printk("FBD: cannot allocate io region\n"); |
return error; |
} |
|
pci_set_master(pdev); |
|
pci_ioaddr = pci_resource_start(pdev, 0); |
printk(" FBD: PCI io address for FBD: 0x%lx.\n", pci_ioaddr); |
pci_ioaddr = (long) ioremap_nocache(pci_ioaddr, PCI_SIZE); |
printk(" FBD: Remapped to: 0x%lx.\n", pci_ioaddr); |
|
if (!pci_ioaddr) { |
printk("FBD: unable to remap io region\n"); |
goto err_out_3; |
} |
|
//check which kind of a PCI device we have here: |
for (pci_device_type = 0; |
pci_device_type < NUMBER_OF_SUPPORTED_PCI_DEVICES; |
pci_device_type++) { |
if (pdev->vendor != |
supported_pci_devices[pci_device_type].pci_vendor_id) |
continue; |
if (pdev->device != |
supported_pci_devices[pci_device_type].pci_device_id) |
continue; |
pci_device_identified = 1; |
goto identified; |
} |
if (!pci_device_identified) { |
printk |
("FBD: PCI device with vendor id 0x%x and device id 0x%x not supported by this driver.\n", |
pdev->vendor, pdev->device); |
goto err_out_2; |
} |
|
identified: |
//tell the user what kind of a PCI device we are: |
printk("FBD: Identified PCI device: %s\n", |
supported_pci_devices[pci_device_type].pci_device_name); |
printk(" FBD: PCI device vendor id 0x%x and device id 0x%x.\n", |
pdev->vendor, pdev->device); |
|
//enable msi interrupts if msi supported |
if (supported_pci_devices[pci_device_type].msi_supported) { |
#ifndef CONFIG_PCI_MSI |
printk |
("FBD: Must enable MSI support in kernel to be able to use PCI Express version of FBD.\n"); |
goto err_out_2; |
#else //CONFIG_PCI_MSI |
if (supported_pci_devices[pci_device_type].msi_supported == |
MSI_ALTERA) { |
outl(1 << 7, pci_ioaddr + 0x20000 + 0x50); //Enabling MSI in Altera PCI Express core |
} |
error = pci_enable_msi(pdev); |
if (error) { |
printk("FBD: unable to enable MSI, error 0x%x", error); |
} else { |
printk("FBD: FBD enabled MSI succesfully.\n"); |
} |
#endif //CONFIG_PCI_MSI |
} |
// fill fbd_private |
fbd_priv.device_id = 0; //TODO |
fbd_priv.revision_id = 0; //TODO |
fbd_priv.base_addr = pci_ioaddr; |
fbd_priv.pci_dev = pdev; |
|
// Open char device |
fbd_register_char_device(&fbd_priv); |
|
return 0; |
err_out_2: |
iounmap((void *) pci_ioaddr); |
err_out_3: |
pci_release_regions(pdev); |
return -ENODEV; |
} |
|
|
/** |
* Remove PCI device from the system. |
*/ |
static void __devexit fbd_remove_one_pci(struct pci_dev *pdev) |
{ |
|
fbd_unregister_char_device(&fbd_priv); |
#ifdef CONFIG_PCI_MSI |
pci_disable_msi(pdev); |
#endif |
pci_release_regions(pdev); //release io areas |
// iounmap ((void *) pci_resource_start (pdev, 0)); |
iounmap((void *) fbd_priv.base_addr); |
pci_set_drvdata(pdev, NULL); |
} |
|
/** |
* PCI driver data. |
*/ |
static struct pci_driver fbd_driver = { |
name:DRV_NAME, |
id_table:fbd_pci_tbl, |
probe:fbd_init_one_pci, |
remove:fbd_remove_one_pci, |
}; |
|
/** |
* Init the FBD driver. |
*/ |
static int __init fbd_init(void) |
{ |
int res; |
|
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,20) |
res = pci_register_driver(&fbd_driver); //init PCI devices |
#else |
res = pci_module_init(&fbd_driver); //init PCI devices |
#endif |
|
if (res) |
goto errout; |
|
return 0; |
|
errout: |
return res; |
} |
|
/** |
* Remove the FBD driver from the system. |
*/ |
static void __exit fbd_cleanup(void) |
{ |
pci_unregister_driver(&fbd_driver); |
} |
|
module_init(fbd_init); |
module_exit(fbd_cleanup); |
/funbase_ip_library/trunk/Flexiblis/ip.swp.driver/fb_pcie_driver/1.0/src/driver/fbd.h
0,0 → 1,54
/** @file fbd.h |
* Funbase device driver main header file. |
*/ |
|
/* |
This confidential and proprietary software may be used only as |
authorized by a licensing agreement from Flexibilis Oy. |
|
(C) COPYRIGHT 2008-2010 FLEXIBILIS OY, ALL RIGHTS RESERVED |
|
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
|
/******************************************************************************* |
* $Id: fbd.h 10668 2010-03-10 18:50:42Z timokosk $ |
*******************************************************************************/ |
|
#ifndef _FBD_H_ |
#define _FBD_H_ |
|
//#define DBG_PRINT(xyz...) printk(xyz) //enable debug printings |
#define DBG_PRINT(xyz...) //disable debug printings |
|
#define DRV_NAME "FBD" |
|
#define PCI_SIZE 0x100000 //the size of the PCI io region |
|
//PCI devices supported |
struct supported_pci_device { |
unsigned long pci_vendor_id; |
unsigned long pci_device_id; |
char pci_device_name[50]; |
#define NO_MSI 0x0 |
#define MSI 0x1 |
#define MSI_ALTERA 0x2 |
int msi_supported; |
}; |
|
|
struct fbd_private { //data specific to one certain fbd device |
int device_id; //device id of this device |
int revision_id; //revision id of this device |
unsigned int base_addr; |
|
struct pci_dev *pci_dev; // FBD as a PCI device |
}; |
|
// ioctl register functions |
int fbd_register_char_device(struct fbd_private *fbd); |
int fbd_unregister_char_device(struct fbd_private *fbd); |
|
#endif // _FBD_H_ |
/funbase_ip_library/trunk/Flexiblis/ip.swp.driver/fb_pcie_driver/1.0/src/driver/fbd_ioctl.c
0,0 → 1,231
/** @file fbd_ioctl.c |
* Funbase device driver ioctl file. |
*/ |
|
/* |
This confidential and proprietary software may be used only as |
authorized by a licensing agreement from Flexibilis Oy. |
|
(C) COPYRIGHT 2008-2010 FLEXIBILIS OY, ALL RIGHTS RESERVED |
|
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
|
/******************************************************************************* |
* $Id: fbd_ioctl.c 10668 2010-03-10 18:50:42Z timokosk $ |
*******************************************************************************/ |
#include <linux/mm.h> |
#include <linux/random.h> |
#include <linux/module.h> |
#include <linux/kernel.h> |
#include <linux/string.h> |
#include <linux/timer.h> |
#include <linux/errno.h> |
#include <linux/ioport.h> |
#include <linux/slab.h> |
#include <linux/interrupt.h> |
#include <linux/pci.h> |
#include <linux/init.h> |
#include <linux/netdevice.h> |
#include <linux/etherdevice.h> |
#include <linux/skbuff.h> |
#include <linux/ethtool.h> |
#include <linux/proc_fs.h> |
#include <asm/uaccess.h> |
#include <asm/processor.h> |
#include <asm/unaligned.h> |
#include <asm/bitops.h> |
#include <asm/io.h> |
#include <asm/delay.h> |
#include <linux/version.h> |
#include <asm/div64.h> |
#include <linux/wait.h> |
|
#include "fbd_ioctl.h" |
#include "fbd.h" |
|
#define MAX_DEVICES 1 |
int char_dev_major = 0; |
struct fbd_private *dev_fbd = 0; |
static int fbd_char_open(struct inode *inode, struct file *filp); |
static int fbd_char_release(struct inode *inode, struct file *filp); |
static int fbd_char_ioctl(struct inode *inode, struct file *filp, |
unsigned int cmd, unsigned long arg); |
|
/** |
* Character device file operations. |
*/ |
struct file_operations fbd_char_fops = { |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) |
owner:THIS_MODULE, |
#endif |
ioctl:fbd_char_ioctl, |
open:fbd_char_open, |
release:fbd_char_release, |
}; |
|
/** |
* Open character device. Called when file is opened in userspace. |
*/ |
static int fbd_char_open(struct inode *inode, struct file *filp) |
{ |
unsigned int minor = MINOR(inode->i_rdev); |
|
if (!dev_fbd) { |
return -EFAULT; |
} |
|
if (minor >= MAX_DEVICES) { |
return -ENODEV; |
} |
filp->f_op = &fbd_char_fops; |
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) |
MOD_INC_USE_COUNT; |
#endif |
return 0; |
} |
|
/** |
* Close character device. Called when file is closed in userspace. |
*/ |
static int fbd_char_release(struct inode *inode, struct file *filp) |
{ |
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) |
MOD_DEC_USE_COUNT; |
#endif |
return 0; |
} |
|
/** |
* IOCTL command. Called by ioctl from userspace. |
*/ |
static int fbd_char_ioctl(struct inode *inode, struct file *filp, |
unsigned int cmd, unsigned long arg) |
{ |
unsigned int minor = MINOR(inode->i_rdev); |
unsigned long ioaddr = 0; |
int retval = 0; |
struct fbd_cmd_struct fbd_cmd; |
u32 address = 0; |
|
DBG_PRINT(KERN_INFO " %s: ioctl_call 0x%x called for device 0x%x.\n", |
DRV_NAME, cmd, minor); |
|
if (minor >= MAX_DEVICES) { |
return -ENODEV; |
} |
|
if (!dev_fbd) { |
return -EFAULT; |
} |
|
ioaddr = dev_fbd->base_addr; |
|
DBG_PRINT(KERN_INFO " %s: base address is 0x%lx.\n", DRV_NAME, |
ioaddr); |
|
if (_IOC_DIR(cmd) & (_IOC_READ | _IOC_WRITE)) { |
if (!access_ok(VERIFY_READ, (void *) arg, _IOC_SIZE(cmd))) { |
return -EFAULT; |
} |
if (!access_ok(VERIFY_WRITE, (void *) arg, _IOC_SIZE(cmd))) { |
return -EFAULT; |
} |
} |
if (_IOC_DIR(cmd) & _IOC_WRITE) { |
if (!access_ok(VERIFY_READ, (void *) arg, _IOC_SIZE(cmd))) { |
return -EFAULT; |
} |
} |
|
switch (cmd) { |
case FBD_IOCTL_READ_DATA64: //read data |
case FBD_IOCTL_READ_DATA32: //read data |
if (copy_from_user(&fbd_cmd, (void *) arg, _IOC_SIZE(cmd))) { |
printk(KERN_INFO " %s: error in ioctl call 0x%x\n", DRV_NAME, |
cmd); |
return -ENOTTY; |
} |
address = ioaddr + fbd_cmd.address; |
if (cmd == FBD_IOCTL_READ_DATA64) { |
fbd_cmd.data64 = *((u64 *) address); |
DBG_PRINT(KERN_INFO " %s: read64 from 0x%x: 0x%llx\n", |
DRV_NAME, address, fbd_cmd.data64); |
} else { |
fbd_cmd.data32 = *((u32 *) address); |
DBG_PRINT(KERN_INFO " %s: read32 from 0x%x: 0x%x\n", |
DRV_NAME, address, fbd_cmd.data32); |
} |
if (copy_to_user((void *) arg, &fbd_cmd, _IOC_SIZE(cmd))) { |
printk(KERN_INFO " %s: error in ioctl call 0x%x\n", DRV_NAME, |
cmd); |
return -ENOTTY; |
} |
break; |
case FBD_IOCTL_WRITE_DATA64: //write data |
case FBD_IOCTL_WRITE_DATA32: //write data |
if (copy_from_user(&fbd_cmd, (void *) arg, _IOC_SIZE(cmd))) { |
printk(KERN_INFO " %s: error in ioctl call 0x%x\n", DRV_NAME, |
cmd); |
return -ENOTTY; |
} |
address = ioaddr + fbd_cmd.address; |
if (cmd == FBD_IOCTL_WRITE_DATA64) { |
*((u64 *) address) = fbd_cmd.data64; |
DBG_PRINT(KERN_INFO " %s: write64 to 0x%x: 0x%llx\n", DRV_NAME, |
address, fbd_cmd.data64); |
} else { |
*((u32 *) address) = fbd_cmd.data32; |
DBG_PRINT(KERN_INFO " %s: write32 to 0x%x: 0x%x\n", DRV_NAME, |
address, fbd_cmd.data32); |
} |
break; |
default: |
printk(KERN_WARNING " %s: Unknown ioctl command 0x%x.\n", DRV_NAME, |
cmd); |
return -ENOTTY; |
} |
return retval; |
} |
|
/** |
* Register character device. Called from module init. |
* @param fbd Module private data. |
* @return 0 on success or negative error code. |
*/ |
int fbd_register_char_device(struct fbd_private *fbd) |
{ |
int error; |
|
error = register_chrdev(0 /*dynamic */ , DRV_NAME, &fbd_char_fops); |
|
if (error < 0) { |
printk(KERN_WARNING "%s: unable to register char device.\n", |
DRV_NAME); |
} else { |
char_dev_major = error; |
dev_fbd = fbd; |
DBG_PRINT("%s: registered char device, major:0x%x.\n", DRV_NAME, |
char_dev_major); |
error = 0; |
} |
|
return error; |
} |
|
/** |
* Unregister character device. Called from module close. |
* @param fbd Module private data. |
* @return 0 on success or negative error code. |
*/ |
int fbd_unregister_char_device(struct fbd_private *fbd) |
{ |
|
dev_fbd = 0; |
|
unregister_chrdev(char_dev_major, DRV_NAME); |
|
return 0; |
} |
/funbase_ip_library/trunk/Flexiblis/ip.swp.driver/fb_pcie_driver/1.0/src/driver/fbd_ioctl.h
0,0 → 1,45
/** @file fbd_ioctl.h |
* Funbase device driver ioctl header file. |
*/ |
|
/* |
This confidential and proprietary software may be used only as |
authorized by a licensing agreement from Flexibilis Oy. |
|
(C) COPYRIGHT 2008-2010 FLEXIBILIS OY, ALL RIGHTS RESERVED |
|
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
|
/******************************************************************************* |
* $Id: fbd_ioctl.h 10668 2010-03-10 18:50:42Z timokosk $ |
*******************************************************************************/ |
|
#ifndef _FBD_IOCTL_H_ |
#define _FBD_IOCTL_H_ |
|
#define FBD_IOCTL_MAGIC 0x39 |
#define FBD_CTRL_DEV "/dev/fbd0" // ioctl device, used form userspace |
|
|
/** |
* FBD commands. |
*/ |
struct fbd_cmd_struct { |
uint32_t address; ///< bus address |
union { |
uint32_t data32; ///< data to write, place for read data |
uint64_t data64; |
}; |
}; |
|
// read from address |
#define FBD_IOCTL_READ_DATA64 _IOWR(FBD_IOCTL_MAGIC,40, struct fbd_cmd_struct) |
#define FBD_IOCTL_READ_DATA32 _IOWR(FBD_IOCTL_MAGIC,41, struct fbd_cmd_struct) |
// write to address |
#define FBD_IOCTL_WRITE_DATA64 _IOW(FBD_IOCTL_MAGIC,50, struct fbd_cmd_struct) |
#define FBD_IOCTL_WRITE_DATA32 _IOW(FBD_IOCTL_MAGIC,51, struct fbd_cmd_struct) |
|
#endif // _FBD_IOCTL_H_ |
/funbase_ip_library/trunk/Flexiblis/ip.swp.driver/fb_pcie_driver/1.0/src/driver/Makefile
0,0 → 1,11
obj-m += fbd.o |
fbd-objs := fbd_main.o fbd_ioctl.o |
|
KDIR := /lib/modules/$(shell uname -r)/build |
PWD := $(shell pwd) |
|
all: |
$(MAKE) -C $(KDIR) M=$(PWD) modules |
clean: |
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) clean |
rm -f *.o *~ |
/funbase_ip_library/trunk/Flexiblis/ip.swp.driver/fb_pcie_driver/1.0/README.TXT
0,0 → 1,3
This is README for Funbase PCIe Linux Driver |
|
|
/funbase_ip_library/trunk/Flexiblis/ip.swp.driver/fb_pcie_driver/1.0/fb_pcie_driver.1.0.xml
0,0 → 1,64
<?xml version="1.0" encoding="UTF-8"?> |
<!--Created by Kactus 2 document generator 11:28:47 pe loka 7 2011--> |
<spirit:component> |
<spirit:vendor>Flexiblis</spirit:vendor> |
<spirit:library>ip.swp.driver</spirit:library> |
<spirit:name>fb_pcie_driver</spirit:name> |
<spirit:version>1.0</spirit:version> |
<spirit:busInterfaces> |
<spirit:busInterface> |
<spirit:name>fb_pcie_api</spirit:name> |
<spirit:busType spirit:vendor="Flexiblis" spirit:library="ip.swp.api" spirit:name="fb_pcie_api" spirit:version="1.0"/> |
<spirit:master/> |
<spirit:connectionRequired>false</spirit:connectionRequired> |
<spirit:bitsInLau>8</spirit:bitsInLau> |
<spirit:endianness>little</spirit:endianness> |
</spirit:busInterface> |
</spirit:busInterfaces> |
<spirit:model/> |
<spirit:fileSets> |
<spirit:fileSet> |
<spirit:name>cSources</spirit:name> |
<spirit:file> |
<spirit:name>src/driver/fbd_main.c</spirit:name> |
<spirit:fileType>cSource</spirit:fileType> |
<spirit:isIncludeFile spirit:externalDeclarations="false">false</spirit:isIncludeFile> |
<spirit:buildCommand> |
<spirit:replaceDefaultFlags>false</spirit:replaceDefaultFlags> |
</spirit:buildCommand> |
</spirit:file> |
<spirit:file> |
<spirit:name>src/driver/fbd.h</spirit:name> |
<spirit:fileType>cSource</spirit:fileType> |
<spirit:isIncludeFile spirit:externalDeclarations="false">false</spirit:isIncludeFile> |
<spirit:buildCommand> |
<spirit:replaceDefaultFlags>false</spirit:replaceDefaultFlags> |
</spirit:buildCommand> |
</spirit:file> |
<spirit:file> |
<spirit:name>src/driver/fbd_ioctl.c</spirit:name> |
<spirit:fileType>cSource</spirit:fileType> |
<spirit:isIncludeFile spirit:externalDeclarations="false">false</spirit:isIncludeFile> |
<spirit:buildCommand> |
<spirit:replaceDefaultFlags>false</spirit:replaceDefaultFlags> |
</spirit:buildCommand> |
</spirit:file> |
<spirit:file> |
<spirit:name>src/driver/fbd_ioctl.h</spirit:name> |
<spirit:fileType>cSource</spirit:fileType> |
<spirit:isIncludeFile spirit:externalDeclarations="false">false</spirit:isIncludeFile> |
<spirit:buildCommand> |
<spirit:replaceDefaultFlags>false</spirit:replaceDefaultFlags> |
</spirit:buildCommand> |
</spirit:file> |
</spirit:fileSet> |
</spirit:fileSets> |
<spirit:vendorExtensions> |
<kactus2:extensions> |
<kactus2:kts_attributes> |
<kactus2:kts_implementation>SW</kactus2:kts_implementation> |
<kactus2:kts_sw_type>Platform</kactus2:kts_sw_type> |
</kactus2:kts_attributes> |
</kactus2:extensions> |
</spirit:vendorExtensions> |
</spirit:component> |