Re: Mmap problem (VM_DENYWRITE)

From: Richard B. Johnson
Date: Mon May 24 2004 - 15:25:13 EST


On Mon, 24 May 2004, shanthi kiran pendyala wrote:

> Hi,
>
> <<I am not subscribed to this list b'cos of the volume of emails. Please
> include my email in the reply.>>

>
> ===================================================================
> My mmap implementation is as follow


Can't you just use ioremap_nocache(FPGA_CSR_ADDR_START, MMAP_SIZE);

>
> #define FPGA_CSR_ADDR_START 0x10940000
> #define FPGA_CSR_ADDR_END 0x1095ffff
> #define MMAP_SIZE (FPGA_CSR_ADDR_END + 1 - FPGA_CSR_ADDR_START)
>

> }
> ================================================================
> I try to access to the device memory region with this user space test
> program
> ....
> fpga_fd = open("/dev/mem", O_RDWR);


If you want to get the physical address from your driver, just
make an ioctl() to return it. In the meantime, mmap() with this
fd.


>
> if(cde_fd < 0) {
> printf("can't open %s err %d\n", FPGA_DEV_FILE_NAME, fpga_fd);
> goto finish;
> }
>
> hint = 0x10000000;
> fpga_csr_start = mmap(hint, MMAP_SIZE,
> PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED,
> fpga_fd, FPGA_CSR_ADDR_START);
>
> if (fpga_csr_start == (void *)-1 ) {
|_______________ Read docs, don't assume!!

> printf(" error in mmap errno %d", errno);
> goto finish;
> }

close(fpga_fd); // Not needed anymore

>
> ...
> ============================================================================
>

Cheers,
Dick Johnson
Penguin : Linux version 2.4.26 on an i686 machine (5570.56 BogoMips).
Note 96.31% of all statistics are fiction.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/