Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2007-07

Linux Kernel and FPC

6 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

ik

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

Reply by email

Michael Van Canneyt
to ik
ik wrote 7 lines
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 ?

Relatively hard: you must write a complete RTL for it. Once that is done, the rest should be easy.

Are there any kernel modules that already been binded into FPC ? such as th ones that will give me printk ?

Not that I know of.

Are there any known examples of someone that already made a Linux kernel module using FPC ?

Again, not that I know of...

Michael.

Reply by email

Micha Nelissen
to Michael Van Canneyt
Michael Van Canneyt wrote 5 lines
> And I was thinking in implementing it using FPC. > My question is, how hard can it be ? Relatively hard: you must write a complete RTL for it. Once that is done, the rest should be easy.

I don't think you would want to use a regular pascal RTL in a kernel module. I'd say "just" translate the kernel C headers for interfacing, and arrange the linking process to work well. Compile without system unit. Use mode fpc to prevent usage of objpas unit, although perhaps it doesn't have real dependencies on system unit. Disadvantage of linux kernel is that its API changes a little bit with each release, so keeping the bindings up to date may require more maintenance than other libraries.

Micha

Reply by email

Alain Michaud
to ik: I have found the following guide: http://www.linuxdevcenter.com/pub/a/linux/2007/07/05/dev…

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 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

ik wrote 15 lines
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

Reply by email

ik
to Alain Michaud
Alain Michaud wrote 60 lines
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 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

The more I read about it, the more I believe that I need more time to implement my freePOS FPC based kernel rather then to use Linux one... The problem is that I do not have time, and only papers for memory management system that I wish to implement as the first part...

Reply by email

Michael Van Canneyt
to ik
ik wrote 66 lines
On 7/9/07, Alain Michaud wrote: > 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 > 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 > The more I read about it, the more I believe that I need more time to implement my freePOS FPC based kernel rather then to use Linux one... The problem is that I do not have time, and only papers for memory management system that I wish to implement as the first part...

Try the delphineos kernel. it's written using FPC.

http://sourceforge.net/projects/delphine

Michael.

Reply by email