* au1200 mae mmap problem
@ 2006-01-11 20:00 yzzhang
0 siblings, 0 replies; 3+ messages in thread
From: yzzhang @ 2006-01-11 20:00 UTC (permalink / raw)
To: linux-mips; +Cc: linux-cvs
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
... ...
}
^ permalink raw reply [flat|nested] 3+ messages in thread* au1200 mae mmap problem
@ 2006-01-11 20:06 yzzhang
0 siblings, 0 replies; 3+ messages in thread
From: yzzhang @ 2006-01-11 20:06 UTC (permalink / raw)
To: linux-mips
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
... ...
}
^ permalink raw reply [flat|nested] 3+ messages in thread* au1200 mae mmap problem
@ 2006-01-11 20:00 yzzhang
0 siblings, 0 replies; 3+ messages in thread
From: yzzhang @ 2006-01-11 20:00 UTC (permalink / raw)
To: linux-mips; +Cc: linux-cvs
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
... ...
}
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-01-11 20:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-11 20:00 au1200 mae mmap problem yzzhang
-- strict thread matches above, loose matches on Subject: below --
2006-01-11 20:06 yzzhang
2006-01-11 20:00 yzzhang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.