Userspace IO

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

 



Hi list

I'm a newbie to kernel development, so thanks for being patient.

I'm playing around with the new UIO framework. Basically I try to get access
to some registers on a custom ISA card from userspace. While it works
reading to and writing from the registers with ioread()/iowrite() from
the kernel, I can't seem to get it to work from userspace.

Here's what I've got so far:

 request_region(0x400, 0x40, "mydev");
 base = ioport_map(0x400, 0x40);

Now I'm able to read/write from kernel:

 printk("FPGA version %i\n", ioread8(base + 0x3E));

Now the UIO stuff:

 uio_info.mem[0].memtype = UIO_MEM_PHYS;
 uio_info.mem[0].addr = (unsigned long) base;
 uio_info.mem[0].size = 0x40;

 uio_register_device(dev, &uio_info);

That gives me the UIO device:

 $ lsuio
 uio0: name=uio_mydev, version=0.0.1, events=0
	map[0]: addr=0x00010400, size=64

>From userspace I do:

 uio_fd = open(/dev/uio0, O_RDWR);
 access_address = mmap(NULL, 0x10400, PROT_READ|PROT_WRITE,
	MAP_SHARED, uio_fd, 0);

If I understood correctly, I should now be able to read/write directly to
memory locations:

 printf("FPGA version: 0x%.2X\n", access_address[0x3E]);

Unfortunately it doesn't seem to work. Could someone point out any
obvious mistakes I might have made?

Thanks for your time,
Christoph

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux