| | |
Read and write of memory mapped address
![]() |
•
•
Join Date: Jun 2008
Posts: 66
Reputation:
Solved Threads: 0
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.
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.
Ambarish
•
•
Join Date: Jun 2008
Posts: 66
Reputation:
Solved Threads: 0
•
•
•
•
If you can't figure out code tags after 60+ posts, what makes you think kernel programming is for you?
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.
Ambarish
•
•
•
•
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.
![]() |
Similar Threads
- Getting an exception "Attempted to read or write protected memory." Why? (C#)
- Attempted to read/write protected memory (VB.NET)
- Creating a memory mapped file (C++)
- Image read and write operations in turbo C (C)
- CD/RW and floppy drives will not read or write (Storage)
- Question about file read/write (Java)
- XP SP2 installation error: "unable to read from or write to the database" (Windows NT / 2000 / XP)
Other Threads in the Kernels and Modules Forum
- Previous Thread: Kernal based project
- Next Thread: process struck at write() call
| Thread Tools | Search this Thread |






