Results 1 to 1 of 1
Hi all, The problem: I'm running an embedded Linux kernel, and I want to obtain a real memory address from user space. After goggeling a little, I found that the ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 02-25-2010 #1
- Join Date
- Feb 2010
Accessing real addresses in user space using mmap() and /dev/mem
I'm running an embedded Linux kernel, and I want to obtain a real memory address from user space.
After goggeling a little, I found that the only way was to use mmap to access /dev/mem.
But I never used mmap, and everything I read about it didn't help me much more.
Si, I wondered if someone could explain me how I could do in my case?
What I want to do:
I want to load a program in memory, in order to make it available from another processor, that has access to the DDR, but not to the flash memory where program is stored.
Here is the code I use:
// Open file and get its size FILE* program = fopen(argv,"rb"); fseek(program, 0, SEEK_END); long program_size = ftell(program); fseek(program, 0, SEEK_SET); // Prepare memory to copy it in void* program_address = malloc(program_size+1); FILE* memory_stream = fmemopen(program_real_address, program_size + 1, "wb"); printf("Program address: 0x%x\n", (int)program_address); // Do the copy int temp; while ((temp = getc(program)) != EOF) putc(temp, memory_stream); fclose(memory_stream); fclose(program);
if anyone could help me, just telling how I could use mmap in my case?