porting fpIoctl() to windows

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

porting fpIoctl() to windows

Marc Santhoff
Hi,

on FreeBSD I use fpOpen, fpIoctl, etc. to drive some generic device. In
my porting efforts to win32 I have found the more generic FileOpen, but
no equivalent of fpIoctl or it's underlying unix system call ioctl().

An old win32.hlp told me Windows has "DeviceIoCtl()", but I'm not really
sure if this is what I need. At least there is ntohing about this
funtion in the RTL sources of fps 2.0.2.

How can I port this calls?

TIA,
Marc


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: porting fpIoctl() to windows

Alain Michaud
Hi,

I use FpIOctl from "BaseUnix" . My platform is Linux. I do FpOpen then
FpIOCTL. It works!

However:

The kernel 2.6 has a new naming convention for the function number. See
the file: asm/ioctl.h

This file contains many constants and the final call number is assembled
from the direction type, device number, function number, etc...

I wanted to write a unit that would simulate this file (ioctl.h), but,
this header file contains mainly macros. I do not think that it is
possible to write some Pascal code that would in fact be a macro! If
someone knows if it possible to write macros in Pascal please tell me.


In the mean time, I calculate the function number "by hand", knowing the
device number, function number, IO_RW, etc... Or if I use a precedure do
do this, then this will slow the program down.

For the Windows platform, I can not help you sorry.  

Thank you

Alain Michaud


On Mon, 2006-05-29 at 22:47 +0200, Marc Santhoff wrote:

> Hi,
>
> on FreeBSD I use fpOpen, fpIoctl, etc. to drive some generic device. In
> my porting efforts to win32 I have found the more generic FileOpen, but
> no equivalent of fpIoctl or it's underlying unix system call ioctl().
>
> An old win32.hlp told me Windows has "DeviceIoCtl()", but I'm not really
> sure if this is what I need. At least there is ntohing about this
> funtion in the RTL sources of fps 2.0.2.
>
> How can I port this calls?
>
> TIA,
> Marc
>
>
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: porting fpIoctl() to windows

Jonas Maebe-2

On 29 May 2006, at 23:09, Alain Michaud wrote:

> In the mean time, I calculate the function number "by hand",  
> knowing the
> device number, function number, IO_RW, etc... Or if I use a  
> precedure do
> do this, then this will slow the program down.

It should be no problem to use (inline or not)functions. The cost of  
a system call dwarfs the time that may be needed to shift and "or" a  
few numbers together (even if you add in the cost of a regular call).


Jonas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: porting fpIoctl() to windows

Burkhard Carstens-3
In reply to this post by Marc Santhoff
Am Montag, 29. Mai 2006 22:47 schrieb Marc Santhoff:

> Hi,
>
> on FreeBSD I use fpOpen, fpIoctl, etc. to drive some generic device.
> In my porting efforts to win32 I have found the more generic
> FileOpen, but no equivalent of fpIoctl or it's underlying unix system
> call ioctl().
>
> An old win32.hlp told me Windows has "DeviceIoCtl()", but I'm not
> really sure if this is what I need. At least there is ntohing about
> this funtion in the RTL sources of fps 2.0.2.

DeviceIOControl is the one I use in Delphi to talk to my vxd driver ..
it is linked to kernel32.dll. Should be pretty much what you want.

> How can I port this calls?

check, how other winapi calls are implemented ..
I am not that far yet. Did it in Delphi, but now trying to do it on
linux ..

Burkhard

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: porting fpIoctl() to windows

Micha Nelissen
In reply to this post by Alain Michaud
Alain Michaud wrote:
> In the mean time, I calculate the function number "by hand", knowing the
> device number, function number, IO_RW, etc... Or if I use a precedure do
> do this, then this will slow the program down.

AFAIK, these numbers are mostly constants, so you need to do this work
only once.

Micha
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: porting fpIoctl() to windows

Felipe Monteiro de Carvalho
In reply to this post by Alain Michaud
On 5/29/06, Alain Michaud <[hidden email]> wrote:
> I wanted to write a unit that would simulate this file (ioctl.h), but,
> this header file contains mainly macros. I do not think that it is
> possible to write some Pascal code that would in fact be a macro! If
> someone knows if it possible to write macros in Pascal please tell me.

You canĀ“t. Transform macros into functions. Some macros can also be
substituted directly into the code.

--
Felipe Monteiro de Carvalho
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: porting fpIoctl() to windows

Marc Santhoff
In reply to this post by Burkhard Carstens-3
Am Montag, den 29.05.2006, 23:30 +0200 schrieb Burkhard Carstens:

> Am Montag, 29. Mai 2006 22:47 schrieb Marc Santhoff:
> > Hi,
> >
> > on FreeBSD I use fpOpen, fpIoctl, etc. to drive some generic device.
> > In my porting efforts to win32 I have found the more generic
> > FileOpen, but no equivalent of fpIoctl or it's underlying unix system
> > call ioctl().
> >
> > An old win32.hlp told me Windows has "DeviceIoCtl()", but I'm not
> > really sure if this is what I need. At least there is ntohing about
> > this funtion in the RTL sources of fps 2.0.2.
>
> DeviceIOControl is the one I use in Delphi to talk to my vxd driver ..
> it is linked to kernel32.dll. Should be pretty much what you want.

Okay, I'll give it a try. I oly wanted to make sure there is no meore
general (in sense of platform independant) way to do it and my docs are
not to old.

> > How can I port this calls?
>
> check, how other winapi calls are implemented ..
> I am not that far yet. Did it in Delphi, but now trying to do it on
> linux ..

This is where I'm coming from (FreeBSD should be as much Posix as Linux,
I think).

Somewhere deep down in the darkness of NT and OS/2 there must be
artefacts of Unix in Windows 2k and XP. ;)

Regards,
Marc


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal