fpgafs/fpgafs.h

95 lines
3.1 KiB
C

/* *****************************************************************
* (C) Copyright 2007 Benjamin Krill <ben@codiert.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* 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. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
* MA 02110-1301 USA
* *****************************************************************/
#ifndef FPGAFS_H
#define FPGAFS_H
#include <linux/kref.h>
#include <linux/mutex.h>
#include <linux/spinlock.h>
#include <linux/fs.h>
/* magic number the file system */
enum {
FPGAFS_MAGIC = 0x4255AA42,
};
struct fpga_context {
char *load_buf;
int lldrv;
int bla;
};
struct fpgafs_inode_info {
struct fpga_context *i_ctx;
struct inode vfs_inode;
};
extern struct tree_descr fpgafs_dir_contents[];
#define FPGAFS_I(inode) \
container_of(inode, struct fpgafs_inode_info, vfs_inode)
/* command definitions */
#define BLA 0
/* low level driver */
struct fpgafs_lldrv {
char name[5];
int (*init) (void);
int (*exit) (void);
int (*send) (struct fpga_context *ctx, const char __user *buf, int len);
int (*recv) (struct fpga_context *ctx, unsigned char *buf, int len);
int (*cmd) (struct fpga_context *ctx, const char __user *buf, int len);
int (*stat) (struct fpga_context *ctx, unsigned char *buf, int len);
int (*read_load) (struct fpga_context *ctx, unsigned char *buf, int len);
int (*write_load) (struct fpga_context *ctx, const char __user *buf, int len);
};
int fpgafs_register_lldrv(struct fpgafs_lldrv *drv);
int fpgafs_unregister_lldrv(struct fpgafs_lldrv *drv);
ssize_t fpgafs_send_data(struct file *file, const char __user *buf,
size_t len, loff_t *pos);
ssize_t fpgafs_recv_data(struct file *file, char __user *buf,
size_t len, loff_t *pos);
ssize_t fpgafs_write_load(struct file *file, const char __user *buf,
size_t len, loff_t *pos);
ssize_t fpgafs_read_load(struct file *file, char __user *buf,
size_t len, loff_t *pos);
ssize_t fpgafs_write_lldrv(struct file *file, const char __user *buf,
size_t len, loff_t *pos);
ssize_t fpgafs_read_lldrv(struct file *file, char __user *buf,
size_t len, loff_t *pos);
ssize_t fpgafs_read_stat(struct file *file, char __user *buf,
size_t len, loff_t *pos);
ssize_t fpgafs_write_cmd(struct file *file, const char __user *buf,
size_t len, loff_t *pos);
struct fpga_context* alloc_fpga_context(void);
void free_fpga_context(struct fpga_context *ctx);
#endif /* FPGAFS_H */