<div dir="ltr"><div><div><div>I guess your reading is wrong. If you are mapping 16KB of physical address from 0x03900000. The mapping is as follows. <br><br></div>0x03900000 to 0x03903FFF --> 0xEA880000 to 0xEA883FFF<br>
<br></div>For every iteration you are reading 4 bytes. hence you have to reduce your loop as follows and also declare tcpm_base as unsigned int *<br><br></div>unsigned int __iomem *tcpm_base;<br><br><div><div><div><div><font face="courier new, monospace"> *tcpm_base = ioremap_nocache(0x03900000, SZ_16KB);</font></div>
<div><font face="courier new, monospace"> printk("Virtual addresss %x\n",tcpm_base);</font></div><div><font face="courier new, monospace"> if(tcpm_base!=NULL)</font></div><div><font face="courier new, monospace"> {</font></div>
<div><font face="courier new, monospace"> printk("Jiffies %x %ld\n\n\n\n", jiffies, jiffies);</font></div><div><font face="courier new, monospace"> for(i=0;i<<b>0xFFF</b>;i++)</font></div>
<div><font face="courier new, monospace"> src = readl(tcpm_base+i);</font></div><div><font face="courier new, monospace"> printk("%d\n",src);</font></div><div><font face="courier new, monospace"> printk("Jiffies %x %ld\n\n\n\n", jiffies, jiffies);</font></div>
<div><font face="courier new, monospace"> }</font></div><div><font face="courier new, monospace"> else</font></div><div><font face="courier new, monospace"> printk("unable to map \n");</font></div>
<br><br></div><div>Regards,<br>Prabhu<br></div></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Feb 28, 2013 at 4:41 PM, Prabhu nath <span dir="ltr"><<a href="mailto:gprabhunath@gmail.com" target="_blank">gprabhunath@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Yes, ioremap() maps the given physical address to contiguous Kernel virtual address above high_memory and returns the first address of the mapped kernel virtual address.<br>
<br>Regards,<br>Prabhu<br><br></div>
<div class="gmail_extra"><br><br><div class="gmail_quote"><div class="im">On Thu, Feb 28, 2013 at 4:06 PM, sandeep kumar <span dir="ltr"><<a href="mailto:coolsandyforyou@gmail.com" target="_blank">coolsandyforyou@gmail.com</a>></span> wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><br clear="all"><div>Hi All</div><div>Please find a piece of code that i wrote in my driver,</div>
<div><div>
</div><div><font face="courier new, monospace">void __iomem *tcpm_base = ioremap_nocache(0x03900000, SZ_16KB);</font></div>
<div><font face="courier new, monospace"> printk("Virtual addresss %x\n",tcpm_base);</font></div><div><font face="courier new, monospace"> if(tcpm_base!=NULL)</font></div><div><font face="courier new, monospace"> {</font></div>
<div><font face="courier new, monospace"> printk("Jiffies %x %ld\n\n\n\n", jiffies, jiffies);</font></div><div><font face="courier new, monospace"> for(i=0;i<(SZ_16KB-1);i++)</font></div>
<div><font face="courier new, monospace"> src = readl(tcpm_base+i);</font></div><div><font face="courier new, monospace"> printk("%d\n",src);</font></div><div><font face="courier new, monospace"> printk("Jiffies %x %ld\n\n\n\n", jiffies, jiffies);</font></div>
<div><font face="courier new, monospace"> }</font></div><div><font face="courier new, monospace"> else</font></div><div><font face="courier new, monospace"> printk("unable to map \n");</font></div>
<div><br></div><div><br></div><div>When i execute this code, i am seeing a kernel panic telling</div><div>----- LOG --------</div><div><div><font face="verdana, sans-serif">"Virtual addresss ea880000"</font></div>
<div><font face="verdana, sans-serif">"Unable to handle kernel paging request at virtual address ea890000"</font><br></div><div><font face="verdana, sans-serif">-----LOG-----</font></div><div><font face="verdana, sans-serif"><br>
</font></div><div>If you observe,</div><div>virtual address of <span style="font-family:'courier new',monospace">tcpm_base is </span><span style="font-family:verdana,sans-serif">ea880000.</span></div>
<div><span style="font-family:verdana,sans-serif">if ioremap() returns all contigious memory, There should be no dereferencing of "</span><span style="font-family:verdana,sans-serif">ea890000"(the max address should be ea88fffe)</span></div>
<div><span style="font-family:verdana,sans-serif"><br></span></div><div><span style="font-family:verdana,sans-serif">But in kernel logs show, it is dereferencing that address.</span></div><div><span style="font-family:verdana,sans-serif"><br>
</span></div><div><span style="font-family:verdana,sans-serif">My question now is...</span></div><div><span style="font-family:verdana,sans-serif">doesn't ioremap() returns contigious address space?</span></div>
<div><br></div><div><br></div></div></div>With regards,<br>Sandeep Kumar Anantapalli,<br>
</div>
<br></div></div>_______________________________________________<br>
Kernelnewbies mailing list<br>
<a href="mailto:Kernelnewbies@kernelnewbies.org" target="_blank">Kernelnewbies@kernelnewbies.org</a><br>
<a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>