Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: yzzhang@sy-imatec.com
To: linux-mips@linux-mips.org
Cc: linux-cvs@linux-mips.org
Subject: au1200 mae mmap problem
Date: Thu, 12 Jan 2006 04:00:45 +0800	[thread overview]
Message-ID: <20060111200045.51145.qmail@sina.com> (raw)

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
    ... ... 
}

             reply	other threads:[~2006-01-11 19:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-11 20:00 yzzhang [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-01-11 20:06 au1200 mae mmap problem yzzhang
2006-01-11 20:00 yzzhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060111200045.51145.qmail@sina.com \
    --to=yzzhang@sy-imatec.com \
    --cc=linux-cvs@linux-mips.org \
    --cc=linux-mips@linux-mips.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox