[fpc-pascal] Linux Kernel and FPC

Alain Michaud Alain.Michaud at nrc-cnrc.gc.ca
Mon Jul 9 22:34:42 CEST 2007


Hi,

  last year I have written a very small driver using the "char" model,
ie. that is put in src/linux/drivers/char something very simple to
read/write a few bytes on an output port. I would have been glad to
write it in pascal, but I do not think it would be possible at all. I
finally did it this way:

 -- The "kernel" part is written in C/asm but the code is as simple as
possible

  -- The "user" part is written in FPC

  -- The interface to the kernel is done using a few functions thru
IOCTL interface.

Now, why not doing the kernel part in FPC?

   Well, The .h files that you need to translate to the interface
section of your unit are very long and difficult to understand. Plus
they contain some macro definitions which are platform specfic.

     For example if you use the ASM instruction "outb" to write one byte
on  a port in your driver source code you would use "_outb" which in
fact is a macro specially tuned for your platform !!  The same is true
for most procedure or instructions that you use when when programming in
kernel space. Even a simple "move" instruction has to be "spinlocked" 

  In conclusion, I gave up ! It is so simple to adapt an example from a
C textbook and although I do not know any C at all I could write to my
I/O port whitin a fey days.
  
Good luck 

Alain


 

       

  

On Fri, 2007-07-06 at 23:05 +0300, ik wrote:
> Hi,
> 
> I have found the following guide:
> http://www.linuxdevcenter.com/pub/a/linux/2007/07/05/devhelloworld-a-simple-introduction-to-device-drivers-under-linux.html
> 
> And I was thinking in implementing it using FPC.
> My question is, how hard can it be ?
> Are there any kernel modules that already been binded into FPC ? such
> as th ones that will give me printk ?
> 
> Are there any known examples of someone that already made a Linux
> kernel module using FPC ?
> 
> Thanks,
> Ido




More information about the fpc-pascal mailing list