<p><br>Hi All,</p>
<p>I m using the Linux 2.6(2.6.23-rc2) from Grants for ML-403 and I tried to add a new driver for a hardware based stream. When I created the device node and executed the application, I could see that the printk's in the driver are getting executed for open, release and ioctl. For read, the function doesnt seem calling the drivers read routine and exits with -1. However the same is called when I do a cat < /dev/devnode. Am I missing something ?
</p>
<p>--------------------------------------------------------------------------------------------------------------<br><Code Snip - Driver></p>
<p>static struct file_operations co_stream_fops = {<br> .owner = THIS_MODULE,<br> .open = co_stream_open,<br> .read = co_stream_read,<br> .write = co_stream_write,<br>// .ioctl = co_stream_ioctl,
<br> .release = co_stream_release<br>};</p>
<p>static int __init co_stream_init(void)<br>{<br> unsigned int *tmp;<br> int i=0;<br> dbprintk("Welcome !!!\n");</p>
<p> if (!request_mem_region(STREAM_PHY_ADDR, STREAM_PHY_SIZE, DRIVER_NAME) )<br> {<br> printk("Failed to lock the memory...\n");<br> goto out;<br> }</p>
<p> if (!(remapped_address = ioremap(STREAM_PHY_ADDR, STREAM_PHY_SIZE)) )<br> {<br> printk("Failed to remap...\n");<br> goto out;<br> }</p>
<p> printk("Address remapped to 0x%08X.\n", remapped_address);</p>
<p> Major = register_chrdev( 0, DEVICE_NAME, &co_stream_fops); <========= Registered fops</p>
<p> if (Major < 0)<br> {<br> printk("Registration of the device failed.\n\n");<br> goto out;<br> }</p>
<p>}</p>
<p><br>static ssize_t co_stream_read(struct file *filp, char __user *buf, size_t size, loff_t *l)<br>{<br> printk("\n co_stream_read() is called.\n");<br> int data,status;</p>
<p> /* Wait while empty. */<br> while (((status=readl( ((volatile unsigned char*) remapped_address) + 8)&3))==0)<br>...<br>--------------------------------------------------------------------------------------------------------------
<br><Code Snip - Application></p>
<p><br> printf("CPU listening for hello...\n\r");<br> for ( i = 0; i < 10; i++ ) {<br> cstream_read(hello_in, &hi, sizeof(int));<br> printf("FPGA hardware says: %d\n\r", hi);
<br> }</p>
<p>int cstream_read(cstream stream, void *buffer, int size)</p>
<p>{<br> int nbytes;<br> /* TO ADD : Error handing calls here */</p>
<p> printf("Value of stream = 0x%08X, stream->fd = %d. \n",<br> stream, stream->fd);</p>
<p> printf("Value of buffer = 0x%08X, size = %d. \n", buffer, size );</p>
<p> if (stream) {<br> nbytes = read(stream->fd, buffer, size);<br> printf("read bytes from hardware = %d.\n", nbytes);<br> }<br> else<br> printf("stream is NULL here.\n");</p>
<p> return(0);<br>}</p>
<p>--------------------------------------------------------------------------------------------------------------<br><From System.map></p>
<p>c00de4d0 t sysrq_handle_reboot<br>c00de4fc T handle_sysrq<br>c00de524 t co_stream_write<br>c00de550 t co_stream_release<br>c00de598 t co_stream_open<br>c00de624 t co_stream_read<br>c00de760 t __uart_start</p>
<p>----------------------------------------<br><From console output fops dump></p>
<p>[ 0.383898] Welcome !!!<br>[ 0.384445] Address remapped to 0xC5000000.<br>[ 0.384628]<br>[ 0.384653]<br>[ 0.384675] Impulse Costream assigned with Major = 254.<br>[ 0.384743] Memory dump of fops structure.
<br>[ 0.384803] Address : 0xC01CA350, 0x00000000.<br>[ 0.384867] Address : 0xC01CA354, 0x00000000.<br>[ 0.384932] Address : 0xC01CA358, 0xC00DE624.<br>[ 0.384996] Address : 0xC01CA35C, 0xC00DE524.<br>[ 0.385060
] Address : 0xC01CA360, 0x00000000.<br>[ 0.385122] Address : 0xC01CA364, 0x00000000.<br>[ 0.385185] Address : 0xC01CA368, 0x00000000.<br>[ 0.385248] Address : 0xC01CA36C, 0x00000000.<br>[ 0.385311] Address : 0xC01CA370, 0x00000000.
<br>[ 0.385374] Address : 0xC01CA374, 0x00000000.<br>[ 0.385437] Address : 0xC01CA378, 0x00000000.<br>[ 0.385499] Address : 0xC01CA37C, 0x00000000.<br>[ 0.385565] Address : 0xC01CA380, 0xC00DE598.<br>[ 0.385627
] Address : 0xC01CA384, 0x00000000.<br>[ 0.385693] Address : 0xC01CA388, 0xC00DE550.<br>[ 0.385756] Address : 0xC01CA38C, 0x00000000.<br>[ 0.385818] Address : 0xC01CA390, 0x00000000.<br>[ 0.385881] Address : 0xC01CA394, 0x00000000.
<br>[ 0.385944] Address : 0xC01CA398, 0x00000000.<br>[ 0.386007] Address : 0xC01CA39C, 0x00000000.<br>[ 0.386070] Address : 0xC01CA3A0, 0x00000000.<br>[ 0.386133] Address : 0xC01CA3A4, 0x00000000.<br>[ 0.386196
] Address : 0xC01CA3A8, 0x00000000.<br>[ 0.386259] Address : 0xC01CA3AC, 0x00000000.</p>
<div>Any help or pointers would be helpful. </div>
<div><br>Thanks and Regards,<br>Ramkumar.</div>
<p><br> </p>