Results 1 to 7 of 7
hi all i am new to in this device driver
i have mapped memmory from 0xc8000 to 0xc8007
by using the function request_mem_region
it got mapped as i found it ...
- 11-09-2010 #1Just Joined!
- Join Date
- Apr 2010
- Posts
- 13
PROBLEM in ' outb ' and ' inb ' comands
hi all i am new to in this device driver
i have mapped memmory from 0xc8000 to 0xc8007
by using the function request_mem_region
it got mapped as i found it in cat /proc/iomem in my system
after that i did
int ptr=3,value;
outb(ptr,0xc8000);
value=inb(oxc8000);
printk("value=%d",value);
but in output it is showing value= 255 and not 3
i googled this problem and many places it is saying that because of io permision to port it may give the problem so i did iopl(3)
in my application program
but still this error i am getting plz suggest me something
- 11-09-2010 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,970
What is the port address? Is it 0xC8000? If so, then you have reversed the arguments for outb().
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 11-10-2010 #3Just Joined!
- Join Date
- Apr 2010
- Posts
- 13
when i did cat /proc/iomem i saw this 0xc8000 space was empty
so i registered this memory , i thought i can access the memmory address with read write operation
so i used outb and inb
0xc8000 is not a port addrss , is that i cant access memmory address of my PC?
- 11-10-2010 #4Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,970
No, you can't use I/O operations on memory normally. You can map the physical address into your process virtual memory space and read/write it normally, just like setting/reading any address. FYI, on many embedded systems I/O ports are mapped to memory by device drivers to make it easier for normal applications to read and write to them.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 11-11-2010 #5Just Joined!
- Join Date
- Apr 2010
- Posts
- 13
yes sir i got ur point,,i googled about this problem
and came to know about ioremap function
but how can i use that function ?
syntax:
void* iormeap(unsigned long offset, unsigned long size);
first argument: if i want to access portb register on my arm board whose address is
0x4c00000c(from datasheet) ,so unsigned long offset=0x4c00000c
second argument : here i am confused what should i give is the size means page size
unkowingly i gave unsigned long size=4096;
and is the return value is virtual address ?
plz clear my doubt sir
- 11-11-2010 #6Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,970
Several issues:
1. The address has to be on a page boundary, so you would use 0x4c000000
2. The size should be a page size, which you can get with the function getpagesize()
3. This does not necessarily map the port address into virtual memory. You should use the i/o helper functions readb/writeb/readw/writew/readl/writel functions to actually read/write the port address, which is derived by adding the offset (0xc in your example) to the address returned by ioremap().
4. You should REALLY read the kernel man pages (available online) to better understand what is going on here. Kernel driver programming is not for the "newbie" unless you are a very fast learner.Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 11-16-2010 #7Just Joined!
- Join Date
- Apr 2010
- Posts
- 13
[solved]
thanks for ur support
the function ioremap_nocache allocates the physical memory and gives the virtual address for it
syntax:
void* ioremap_nocache(physical address, pagesize);
example:
void * virt;
virt=ioremap_nocache(0x4c00000c,4096);
to reffer that address use
*((unsigned long *)virt)=0x2;


Reply With Quote