[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

mmap problems on 7750R Solution Engine



I'm trying to get a driver originally written for i386 working on sh4/Solution Engine 7750R.

We are using kernel 2.4.18 from Codescape and have kernel debugging using the Codescape environment.  The base system is a Debian sh4 tarball.

We are accessing physical memory (graphics card) at the following addresses:

	Frame buffer: 	0x400,0000 
	Registers:	0x500,0000
	Other:	        0x580,0000 (write-only)
			(commas for clarity only)

These can be addressed in kernel space through addresses 0xa400,0000, 0xa500,0000 and 0xa580,0000 without problem.  However, if I mmap them into user space, using our driver, access to 0x580,0000 fails (Codescape, our debugger, loses contact with the board - saying "the debug stub is not responding")

After stripping unrelated code from the driver, the open/realease handlers just return success and the mmap handler is as shown below.  In the code below, you can see kernel space accesses to the device through 0xa400,0000 and 0xa580,0000 etc, which work fine.

int my_mmap(struct file* pFile, struct vm_area_struct* ps_vma)
{
	unsigned long bytes  = ps_vma->vm_end - ps_vma->vm_start;
	int res;
	ps_vma->vm_flags |= VM_RESERVED;
	memset (0xa4000000, 0, 0x1000000);
	* (unsigned long *) 0xa5800000 = 0;
	* (unsigned long *) 0xa5900000 = 0;
	* (unsigned long *) 0xa5a00000 = 0;
	* (unsigned long *) 0xa5b00000 = 0;
	* (unsigned long *) 0xa5c00000 = 0;
	
	res = io_remap_page_range (ps_vma->vm_start,
			(ps_vma->vm_pgoff << PAGE_SHIFT)+ 0x4000000,
			 bytes, 
			 ps_vma->vm_page_prot );
	if (res) {
		PVR_DPF((PVR_DBG_ERROR,"Failed to map contiguous pages."));
		return -ENXIO;
	}
	return 0;
} // my_mmap

The user-land code that accesses this is just:

	dev = open (DEVICE, O_RDWR);
	if (dev<0) {
		perror (DEVICE);
		exit (EXIT_FAILURE);
	}
	fb = mmap (0, mapLength, PROT_WRITE, MAP_SHARED, dev, mapOffset);
	if (!fb) {
		perror ("mmap");
		exit (EXIT_FAILURE);
	}
	memset (fb, 0, writeLength);

Here, mapOffset, mapLength and writeLength are entered on the command line.
This succeeds for 0x4000000 but not for 0x5800000.

Any ideas as to where the problem might lie greatfully accepted. I have spent several days on this and have run out of ideas of what to try next.
Thanks in advance
William



Reply to: