Char driver for mSGDMA.
More...
#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/cdev.h>
#include <linux/slab.h>
#include <linux/fs.h>
#include <linux/types.h>
#include <linux/device.h>
#include <linux/string.h>
#include <asm/uaccess.h>
#include <linux/pci.h>
#include "BEST_PCIe.h"
#include "BEST_PCIe_internal.h"
#include "BEST_dma_device.h"
#include "msgdma/descriptor_regs.h"
#include "msgdma/csr_regs.h"
|
|
#define | debug_print(fmt, args...) do { if (DEBUG_DMA_PRINT) printk( KERN_DEBUG fmt, ##args); } while (0) |
| |
|
#define | ceil(x, y) ({ unsigned long __x = (x), __y = (y); (__x + __y - 1) / __y; }) |
| |
|
|
| MODULE_LICENSE ("GPL") |
| |
| void | dma_read (struct dma_dev_struct *dev, uint64_t read_addr, uint64_t write_addr, uint32_t len) |
| | Reads from DMA. More...
|
| |
| void | dma_enable_int (struct dma_dev_struct *dev) |
| | Enables DMA interrupt. More...
|
| |
| void | dma_disable_int (struct dma_dev_struct *dev) |
| | Disables DMA interrupt. More...
|
| |
| void | dma_reset (struct dma_dev_struct *dev) |
| | Resets DMA. More...
|
| |
| int | dma_char_open (struct inode *inode, struct file *file) |
| | Opens char device (stores dev struct in pirvate data) More...
|
| |
| ssize_t | dma_char_read (struct file *file, char __user *buf, size_t count, loff_t *pos) |
| | Reads from char device. More...
|
| |
| void | dma_advance_buf (struct dma_dev_struct *dev) |
| | Advacnes to next buffer, returns pointer to it. More...
|
| |
| int | dma_dev_create (struct dma_dev_struct *dev, struct class *best_class) |
| | Creates new DMA char device. More...
|
| |
| void | dma_dev_remove (struct dma_dev_struct *dev, struct class *best_class) |
| | Removes DMA char device. More...
|
| |
| int | dma_dev_allocate_buffers (struct pci_dev *dev, struct dma_dev_struct *dma) |
| | Allocates DMA buffers. More...
|
| |
| void | dma_dev_free_buffers (struct pci_dev *dev, struct dma_dev_struct *dma) |
| | Frees DMA buffers. More...
|
| |
|
| static const struct file_operations | dma_char_fops |
| |
Advacnes to next buffer, returns pointer to it.
- Parameters
-
| dev | DMA structure |
| buf_to_write | Returns address of a buffer to write to |
| int dma_char_open |
( |
struct inode * |
inode, |
|
|
struct file * |
file |
|
) |
| |
Opens char device (stores dev struct in pirvate data)
- Parameters
-
| inode | Index node structure |
| file | File structure |
- Returns
- 0 on success, negative number on fail
| ssize_t dma_char_read |
( |
struct file * |
file, |
|
|
char __user * |
buf, |
|
|
size_t |
count, |
|
|
loff_t * |
pos |
|
) |
| |
Reads from char device.
- Parameters
-
| file | File structure (path, ...) |
| buf | Buffer to read to |
| count | Number of bytes to read |
| pos | |
- Returns
- Numbers of bytes successfully read
| int dma_dev_allocate_buffers |
( |
struct pci_dev * |
dev, |
|
|
struct dma_dev_struct * |
dma |
|
) |
| |
Allocates DMA buffers.
- Parameters
-
| dev | PCI device |
| dma | DMA strucutre to allocate memory |
Fields buf_number and buf_len must have valid values
| int dma_dev_create |
( |
struct dma_dev_struct * |
dev, |
|
|
struct class * |
best_class |
|
) |
| |
Creates new DMA char device.
- Parameters
-
| dev | Structure with DMA info |
| best_class | Class which this device will be part of |
Creates new char device, which represents FPGA mSGDMA Allowed operation on device is read(), which returns most recent data from buffers
| void dma_dev_free_buffers |
( |
struct pci_dev * |
dev, |
|
|
struct dma_dev_struct * |
dma |
|
) |
| |
Frees DMA buffers.
- Parameters
-
| dev | PCI device |
| dma | DMA strucutre to allocate memory |
| void dma_dev_remove |
( |
struct dma_dev_struct * |
dev, |
|
|
struct class * |
best_class |
|
) |
| |
Removes DMA char device.
- Parameters
-
| dev | Structure with DMA info |
| best_class | Class which this device will be part of |
Disables DMA interrupt.
- Parameters
-
| board | Pointer to structure with board specific data |
Enables DMA interrupt.
- Parameters
-
| board | Pointer to structure with board specific data |
| void dma_read |
( |
struct dma_dev_struct * |
dev, |
|
|
uint64_t |
read_addr, |
|
|
uint64_t |
write_addr, |
|
|
uint32_t |
len |
|
) |
| |
Reads from DMA.
- Parameters
-
| board | Pointer to structure with board specific data |
| read_addr | Address to read from (Avalon MM for this application) |
| write_addr | Address to write to (should be in DMA space, physical) |
| len | Number of bytes to transfer |
Resets DMA.
- Parameters
-
| board | Pointer to structure with board specific data |
| const struct file_operations dma_char_fops |
|
static |
Initial value:= {
.owner = THIS_MODULE,
}
ssize_t dma_char_read(struct file *file, char __user *buf, size_t count, loff_t *pos)
Reads from char device.
Definition: BEST_dma_device.c:157
int dma_char_open(struct inode *inode, struct file *file)
Opens char device (stores dev struct in pirvate data)
Definition: BEST_dma_device.c:130