pimp up the debug low level driver
git-svn-id: svn+ssh://en.codiert.org/home/staff/ben/dev/misc.svn/projects/fpgafs@398 766a2236-cff9-0310-b0c0-a81a5f92509a
This commit is contained in:
parent
11762c3dab
commit
96948e503d
@ -8,16 +8,44 @@
|
||||
#include <linux/mm.h>
|
||||
#include "fpgafs.h"
|
||||
|
||||
#define MEM_SIZE 255
|
||||
/* some test memory */
|
||||
static char *mem;
|
||||
|
||||
static int fpgafs_send_data_dbg(struct fpga_context *ctx, const char __user *buf, int len)
|
||||
{
|
||||
printk("fpgafs: send data DEBUG\n");
|
||||
return 0;
|
||||
u32 cp = 0;
|
||||
u8 __user *usr;
|
||||
|
||||
if (mem == NULL)
|
||||
return -EBUSY;
|
||||
|
||||
len = (len > MEM_SIZE)?MEM_SIZE:len;
|
||||
|
||||
if (len < 2)
|
||||
return -EINVAL;
|
||||
|
||||
if (!access_ok(VERIFY_READ, buf, len))
|
||||
return -EFAULT;
|
||||
|
||||
while (cp < len) {
|
||||
usr = (u8*)&buf[cp];
|
||||
if (__get_user(mem[cp], usr))
|
||||
return -EFAULT;
|
||||
cp++;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
static int fpgafs_recv_data_dbg(struct fpga_context *ctx, unsigned char *buf, int len)
|
||||
{
|
||||
printk("fpgafs: receive data DEBUG\n");
|
||||
return 4;
|
||||
len = (len > MEM_SIZE)?MEM_SIZE:len;
|
||||
if (copy_to_user(buf, mem, len))
|
||||
return -EFAULT;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
static int fpgafs_read_load_dbg(struct fpga_context *ctx, unsigned char *buf, int len)
|
||||
@ -59,10 +87,23 @@ static int fpgafs_write_load_dbg(struct fpga_context *ctx, const char __user *bu
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
static int fpgafs_init_dbg(void)
|
||||
{
|
||||
mem = kmalloc(MEM_SIZE,GFP_USER);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fpgafs_exit_dbg(void)
|
||||
{
|
||||
kfree(mem);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct fpgafs_lldrv fpgafs_lldrv_dbg = {
|
||||
.name = "dbg",
|
||||
.init = NULL,
|
||||
.exit = NULL,
|
||||
.init = fpgafs_init_dbg,
|
||||
.exit = fpgafs_exit_dbg,
|
||||
.send = &fpgafs_send_data_dbg,
|
||||
.recv = &fpgafs_recv_data_dbg,
|
||||
.read_load = &fpgafs_read_load_dbg,
|
||||
|
Loading…
Reference in New Issue
Block a user