summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9964d39)
raw | patch | inline | side by side (parent: 9964d39)
author | Sandeep Nair <a0875039@ares-ubuntu> | |
Thu, 14 Jun 2012 23:07:06 +0000 (19:07 -0400) | ||
committer | Sandeep Nair <a0875039@ares-ubuntu> | |
Thu, 14 Jun 2012 23:07:06 +0000 (19:07 -0400) |
ti/runtime/netapi/tools/module/Makefile | patch | blob | history | |
ti/runtime/netapi/tools/module/netapimod.c | patch | blob | history | |
ti/runtime/netapi/tools/module/netapimod.h | patch | blob | history |
index 6020ed375310b56b92c81d9c0bc891ecdde69d07..f0f229be83c50729450a789215c0bccda2327215 100644 (file)
# General Public License for more details.
#
-KDIR ?= ../linux-appleton
+KDIR ?= ~/linux-appleton
obj-m += netapimod.o
diff --git a/ti/runtime/netapi/tools/module/netapimod.c b/ti/runtime/netapi/tools/module/netapimod.c
index 2cbf7facc93cf6252933b380c55dd5339b8176de..30bdb01b73d51a1c47ac6a4f81ce0005705996be 100644 (file)
static dma_addr_t dmaAddr; // physical address of region
static void * cpuAddr=NULL; //va for above
static void * userVmaStart = NULL;
+static unsigned int memSize = NETAPIMOD_MEMSZ;
//extern long davinci_ck_get_arm_rate(void);
static void MPU_Enable_userModeAccess(void)
@@ -217,7 +218,8 @@ static long netapimod_ioctl(struct file *filp, unsigned int cmd, unsigned long a
return -EFAULT;
}
- physp = (unsigned long)dmaAddr + (block.addr - (unsigned long)userVmaStart);
+ physp = (unsigned long)dmaAddr +
+ (block.addr - (unsigned long)userVmaStart);
switch (cmd & ~NETAPIMOD_IOCMAGIC) {
case NETAPIMOD_IOCCACHEWB:
@@ -240,17 +242,19 @@ static long netapimod_ioctl(struct file *filp, unsigned int cmd, unsigned long a
} /* switch cmd */
__D("CACHE%s%s ioctl returned vaddr=0x%p size=0x%x paddr=0x%p.\n",
- cmd & NETAPIMOD_WB ? "WB" : "", cmd & NETAPIMOD_INV ? "INV" : "", (void *)block.addr, block.size, (void *)physp);
+ cmd & NETAPIMOD_WB ? "WB" : "",
+ cmd & NETAPIMOD_INV ? "INV" : "",
+ (void *)block.addr, block.size, (void *)physp);
break;
case NETAPIMOD_IOCGETSIZE:
__D("GETSIZE ioctl received.\n");
- if (put_user((unsigned long)NETAPIMOD_MEMSZ, argp)) {
+ if (put_user((unsigned long)memSize, argp)) {
return -EFAULT;
}
- __D("GETSIZE returning %#1x\n", (unsigned int)NETAPIMOD_MEMSZ);
+ __D("GETSIZE returning %#1x\n", (unsigned int)memSize);
break;
default:
static int __init netapimod_init_module(void)
{
void * priv = NULL;
+ int ret;
__D("init\n");
- create_proc_read_entry(NETAPIMOD_DEVNAME, 0, NULL, netapimod_init_proc, (void *)priv);
+ create_proc_read_entry(NETAPIMOD_DEVNAME, 0, NULL, netapimod_init_proc,
+ (void *)priv);
//enable user access to qmss h/w
MPU_Enable_userModeAccess();
/* allocate space from CMA */
- cpuAddr = dma_alloc_coherent(NULL, NETAPIMOD_MEMSZ, &dmaAddr, GFP_KERNEL);
+ cpuAddr = dma_alloc_coherent(NULL, memSize, &dmaAddr, GFP_KERNEL);
if (!cpuAddr) {
__E("Error allocating from CMA.\n");
- return -ENOMEM;
+ ret = -ENOMEM;
+ goto cleanup_proc;
+ } else {
+ __D("Allocated 0x%x size memory from CMA.\n",memSize);
}
netapimod_major = register_chrdev(0, NETAPIMOD_DEVNAME, &netapimod_fxns);
if (netapimod_major < 0) {
__E("Failed to allocate major number.\n");
- return -ENODEV;
+ ret = -ENODEV;
+ goto cleanup_mem;
}
__D("Allocated major number: %d\n", netapimod_major);
netapimod_class = class_create(THIS_MODULE, NETAPIMOD_DEVNAME);
if (IS_ERR(netapimod_class)) {
__E("Error creating netapi device class.\n");
- return PTR_ERR(netapimod_class);
+ ret = PTR_ERR(netapimod_class);
+ goto cleanup_dev;
}
- device_create(netapimod_class, NULL, MKDEV(netapimod_major, 0), NULL, NETAPIMOD_DEVNAME);
+ device_create(netapimod_class, NULL, MKDEV(netapimod_major, 0), NULL,
+ NETAPIMOD_DEVNAME);
__D("module loaded\n");
return 0;
+
+cleanup_dev:
+ unregister_chrdev(netapimod_major, NETAPIMOD_DEVNAME);
+cleanup_mem:
+ dma_free_coherent(NULL, memSize, cpuAddr, dmaAddr);
+cleanup_proc:
+ remove_proc_entry(NETAPIMOD_DEVNAME, NULL);
+
+ return ret;
}
/*********************************************************************************
class_destroy(netapimod_class);
/* Free CMA buffer */
- dma_free_coherent(NULL, NETAPIMOD_MEMSZ, cpuAddr, dmaAddr);
+ dma_free_coherent(NULL, memSize, cpuAddr, dmaAddr);
/* Remove netapi proc entry */
remove_proc_entry(NETAPIMOD_DEVNAME, NULL);
MODULE_LICENSE("GPL v2");
MODULE_AUTHOR("Texas Instruments Incorporated");
-MODULE_DESCRIPTION("TI NETAPI core module.");
+MODULE_DESCRIPTION("TI NETAPI core module.");
MODULE_SUPPORTED_DEVICE("Texas Instruments netapi");
+module_param(memSize, uint, 0);
+MODULE_PARM_DESC(memSize, "Size of DMA coherent memory to be allocated");
diff --git a/ti/runtime/netapi/tools/module/netapimod.h b/ti/runtime/netapi/tools/module/netapimod.h
index 6d16835b306da36853fe0ba5292c4b1e4700a671..f61c6e9ff818a1310ec9c3b35314340ecb25fd60 100644 (file)
#define NETAPIMOD_IOCCMDMASK 0x000000ff
-/* Size of DMA coherent memory to be allocated */
-#define NETAPIMOD_MEMSZ 0x200000
+/* Default size of DMA coherent memory to be allocated */
+#define NETAPIMOD_MEMSZ 0xf00000
/* MMAP offsets */
/* Offset to map CMA allocated memory */