Hello!
I'm new in this mailing list so don'b be cruel if I duplicate
I can't read or wriht my physical memory from user space
Can anybody tell me what I do wrong?
In kernel:
init_module(void)
{
...
register_chrdev(0,"phys_mem",&phys_fops);
...
}
struct file_operations phys_fops={
...
phys_mmap,
...}
struct vm_operations_struct m_vm_ops = {
vma_open,
vma_close,
...
vma_no_page }
unsigned long vma_no_page(struct vm_area_struct *vma,unsigned long
address,int write)
{
pgd_t *pdg; pmd_t *pmd; pte_t pte;
ulong virt,phys;
virt = address & PAGW_MASK;
phys = vma->vm_offset + virt - vma->vm_start;
remap_page_range(virt,phys,PAGE_SIZE,vma->vm_page_prot);
pgd = pgd_offset(current->mm,address);
pmd = pmd_offset(pgd,address);
pte = pte_offset(pmd,address);
return pte_page(*pte);
}
int phys_mmap(struct file *p_file,struct vm_area_struct *vma)
{
if( remap_page_range(vma->vm_start,vma->vm_offset,vma->vm_end -
vma->vm_start,vma->vm_page_prot))
return -EAGAIN;
vma->vm_ops = &m_vm_ops;
MOD_INC_USE_COUNT;
return 0;
}
vma_open/close/()
{ MOD_INC/DEC/_USE_COUNT; }
In User Spase
{
...
int f = open("phys_mem",O_RDWR);
int i;
void *p = mmap(NULL,4,PROT_READ_PROT_WRITE,MAP_SHARED,f,MyPhysAddr);
memcpy(&i,p,4); /* If read */
munmap(p,4);
close(f);
return i;
}
And if I read somthing from zero to 128M I always reciev 1
What wrong?????????
What did I forget to do???
Any sugestions?
Regards
Alexey
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Mon Feb 07 2000 - 21:00:11 EST