File operations on a Windows Driver (character device)
Wed May 27 15:59:00 GMT 2015
Thanks Mark and Corinna.
I'm sorry for the
I wont make those mistakes in the future, I promise.
Returning on the issue, I've decided to open the device with the
open() provided by Cygwin
and then intercept the IOCTLs and change them with the Win32
_get_osfhandle() for the handle of the device).
At this point I can even implement the mmap with an IOCTL without
problems as I explained
in a previous mail.
I cannot use the read/write calls because I need to access the kernel
memory directly with
the mmap; in this way I can get better performances.
The last (and main) problem I'm facing is the poll()/select(); I've
seen that doing a poll() on
this kind of device always returns "1" because in
select.cc->select_stuff::poll() the function
pointer s->peek is NULL and in that way the counter "n" is always increased.
What I need to do is something that can be compiled under VS2013 and
for compatibility with applications already written for linux OS; I
was thinking to open a
WSK socket and associate it with every new "open" made from userspace so that a
userspace program can use the poll indifferently if compiled under Cygwin or
under a native environment.
What I don't know is if this way is a smart one or if there is a
clever way to do this:
have you got something to suggest?
Thanks very much everyone for the help
2015-05-27 14:09 GMT+02:00 Corinna Vinschen <email@example.com>:
> On May 18 17:33, Alessio Faina wrote:
>> Ok thanks, I've been able to find the character device under
>> "/proc/sys/DosDevices/Global/deviceName"; now I'm stuck with the mmap
>> implementation; when I do mmap in the userland program it returns me
>> errno 19 (#define ENODEV 19 /* No such device */) obviously because
>> I haven't set anything in the kernel module; there's a way to make visible a
>> portion of memory to be used by the mmap in the kernel? The memory is Non Paged
>> and allocated with a ExAllocatePoolWithTag in 'win terms'.
> The problem is that the /proc/sys interface is only implemented for
> very basic operations. There's no ioctl and mmap implemented for
> arbitrary devices in Cygwin.
> To get your device working, you have to either implement support for it
> in Cygwin, or you have to use native W32 or NT calls to access your
> Alternatively: Since you can open the device, read/write should be
> possible. If you implement all interaction with your device (send
> comands, request map address, etc) in the driver as specially crafted
> read/write calls, you should be able to communicate with it from Cygwin
> applications without having to implement a Cygwin file handler.
> Corinna Vinschen Please, send mails regarding Cygwin to
> Cygwin Maintainer cygwin AT cygwin DOT com
> Red Hat
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
More information about the Cygwin