linux-mips
[Top] [All Lists]

au1200 mae mmap problem

To: linux-mips@linux-mips.org
Subject: au1200 mae mmap problem
From: yzzhang@sy-imatec.com
Date: Thu, 12 Jan 2006 04:06:32 +0800
Original-recipient: rfc822;linux-mips@linux-mips.org
Sender: linux-mips-bounce@linux-mips.org
I wrote a simple program to test Au1200 MAE.
The result is always that program will return -1 because pmms->struct_size=0, 
though it is assigned
a value of 0xdc during initialization in the kernel.
anyone could explain the reason for me? Thanks in advance. 
-----------------------------------------------------------------------
In user space:
  if ((fmae = open("/dev/mae", O_RDWR)) < 0) {
        printf("mae open failed.\n");
        return -1;
    }
 gMemSize = ioctl(fmae, AU1XXXMAE_INIT, &ioc);
 maeaddr = mmap (0, gMemSize, PROT_READ|PROT_WRITE, MAP_SHARED | MAP_NONCACHED, 
fmae, 0);
 if (maeaddr == MAP_FAILED)
    {
        printf("mae: attempt to map memory failed.\n");
        return -1;
    }
 pmms = (PMAE_MASTER_T)maeaddr;
 if (pmms->struct_size < sizeof(MAE_MASTER_T))
    {
      printf("mae_driver, structure size mismatch: driver=%x 
interface=%d\n",pmms->struct_size, sizeof(MAE_MASTER_T));
        return -1;
    }

-----------------------------------------------------------------------------------------
In kernel space,au1200's driver is listed as below: 

int au1xxxmae_mmap(struct file *filp, struct vm_area_struct *vma ) 
{
    unsigned long size = vma->vm_end - vma->vm_start;
    unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
    offset += mae_phys_address;
    vma->vm_page_prot = pgprot_cached(vma->vm_page_prot);    
    if(remap_pfn_range(vma, vma->vm_start, offset >> PAGE_SHIFT, size, 
vma->vm_page_prot))    
    {
         DBGPRINT(ERRORS,"Could not remap the page range\n");
         return -EFAULT;
    }

    vma->vm_flags &= ~VM_IO;
    vma->vm_ops = &au1xxx_vmaops;
    au1xxx_vma_open(vma);
    return 0;
}

void init_mae_structs(void) 
{
    unsigned char k,x[10];

    pmms = (PMAE_MASTER_T) KRNL_MAE_MASTER_STRUCT; // pmms means ptr to mae 
master struct
    // initialize the master structure
    memset((PVOID)KRNL_MAE_MASTER_STRUCT, 0, sizeof(MAE_MASTER_T));
    pmms->struct_size=sizeof(MAE_MASTER_T);   //pmms->struct_size = 0xdc
    ... ... 
}




<Prev in Thread] Current Thread [Next in Thread>