943,739 Members | Top Members by Rank

Ad:
Jul 8th, 2009
0

Read and write of memory mapped address

Expand Post »
HI,

I new to linux device drivers.
I am developing HDLC driver.
I dont know how to read and write data in memory mapped address.
Please help.

/*code*/

#define REG_MAP_ADDR 0x50400000

/* Registers */
typedef struct {
u16 MOD;
u16 STATUS;
u16 TBASE;
u16 Tx;
u16 TxBD;
u16 RBASE;
u16 MAX_BUFF_LEN;
u16 Rx;
u16 RxBD;
}reg_map_1ch_t;

typedef struct {
reg_map_1ch_t reg_ch[16];
}reg_map_t;


reg_map_t *reg_map;
unsigned short data=0;
volatile unsigned short *base_addr;

reg_map = ioremap_nocache(REG_MAP_ADDR, sizeof(reg_map_t));

/*now i have to read and write the data of memory mapped address.
Give me idea. I did as follows */

base_addr = (volatile unsigned short *)reg_map;
data = (unsigned short)(*(base_addr));
printk(KERN_ALERT "Before Write Read Data: %d\n", data);

data = 1;
base_addr[0] = data;

data = (unsigned short)(*(base_addr));
printk(KERN_ALERT "After Write Read Data: %d\n", data);

I did Above code in init module, when i am inserting the module, system will reboot.
Whats the error.
i am not getting error, just reboots the system.
Reputation Points: 25
Solved Threads: 0
Junior Poster in Training
ambarisha.kn is offline Offline
66 posts
since Jun 2008
Jul 8th, 2009
0

Re: Read and write of memory mapped address

If you can't figure out code tags after 60+ posts, what makes you think kernel programming is for you?
Last edited by Salem; Jul 8th, 2009 at 1:55 pm.
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005
Jul 8th, 2009
-1

Re: Read and write of memory mapped address

Click to Expand / Collapse  Quote originally posted by Salem ...
If you can't figure out code tags after 60+ posts, what makes you think kernel programming is for you?
who the hell are you, you are not the person to speak about ability.
Ofcourse i am not brillinat than you, but u have some manners.
First learn how to behave.

If you dont know manners, your knowledge is waste.

I know how to use tags, but in hurry i have not used tags.
Thats it.

If you know answer reply to the post else dont blame others.
I think For this purpose u made 5000+ posts.
Reputation Points: 25
Solved Threads: 0
Junior Poster in Training
ambarisha.kn is offline Offline
66 posts
since Jun 2008
Jul 25th, 2009
0

Re: Read and write of memory mapped address

who the hell are you, you are not the person to speak about ability.
Ofcourse i am not brillinat than you, but u have some manners.
First learn how to behave.

If you dont know manners, your knowledge is waste.

I know how to use tags, but in hurry i have not used tags.
Thats it.

If you know answer reply to the post else dont blame others.
I think For this purpose u made 5000+ posts.
They are the forum rules. Doesn't matter if you are in a hurry. If you know how to do it, then do it and you will not get replies such as the above.
Moderator
Featured Poster
Reputation Points: 1142
Solved Threads: 982
Most Valuable Poster
crunchie is offline Offline
12,163 posts
since Feb 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Linux Kernel and Hardware Setup Forum Timeline: Unmounting portable HDD
Next Thread in Linux Kernel and Hardware Setup Forum Timeline: Touchpad from Elantech not working on ubuntu 9





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC