Results 1 to 3 of 3
I have this in kernel module:
/*global scope declared*/
static char array[10]={1,2,3,4,5,6,7,8,9,10};
and I have functions for open close read and write works perfectly, i want to share the `array[8]` ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 08-08-2012 #1Just Joined!
- Join Date
- Aug 2012
- Posts
- 3
Kernel/Why do i get Unhandled fault: imprecise external abort?
I have this in kernel module:
/*global scope declared*/
static char array[10]={1,2,3,4,5,6,7,8,9,10};
and I have functions for open close read and write works perfectly, i want to share the `array[8]` with the user space application in the bottom of this page.
**in the kernel module:**
static int *my_mmap (struct file *filep, struct vm_area_struct *vma ) {
if (remap_pfn_range(vma,
vma->vm_start,
virt_to_phys(array)>> PAGE_SHIFT,
10,
vma->vm_page_prot) < 0) {
printk("remap_pfn_range failed\n");
return -EIO;
}
return 0;
**the application in user-space's source code:**
#define LEN (64*1024)
/* prototype for thread routine */
#define FILE_PATH "/dev/my_module"
int main()
{
int i=0;
int fd = open(FILE_PATH,O_RDWR);
int* vadr = mmap(0, LEN, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
for (i=0;i<10;++i){
printf("%d",*(vadr+i));
}
return 0;
}
I get `imprecise external abort` and no output from vadr, why is that?
- 08-11-2012 #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
- 10,153
Please post code inside code blocks, like this:
It make it a lot easier to read. In any case, this is not sufficient to help you. Please post ALL of your kernel module code, and how you access it from your user-space code.Code:/*global scope declared*/ static char array[10]={1,2,3,4,5,6,7,8,9,10}; static int *my_mmap (struct file *filep, struct vm_area_struct *vma ) { if (remap_pfn_range(vma, vma->vm_start, virt_to_phys(array)>> PAGE_SHIFT, 10, vma->vm_page_prot) < 0) { printk("remap_pfn_range failed\n"); return -EIO; } return 0; } // the application in user-space's source code:** #define LEN (64*1024) /* prototype for thread routine */ #define FILE_PATH "/dev/my_module" int main() { int i=0; int fd = open(FILE_PATH,O_RDWR); int* vadr = mmap(0, LEN, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); for (i=0;i<10;++i) { printf("%d",*(vadr+i)); } return 0; }Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 08-12-2012 #3Just Joined!
- Join Date
- Aug 2012
- Posts
- 3
Thanks,
My question is, how do I share memory between a kernel module and user space even if the block of data is not aligned to a page size.
For example how do I share the
declared in a kernel module with a user application?Code:/*global scope declared*/ static char array[10]={1,2,3,4,5,6,7,8,9,10};
thanks


Reply With Quote
