Difference between revisions of "linux/kernel/module language feature"

From Free Pascal wiki
Jump to navigationJump to search
m (Fixed template loop; added categories)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
=overview=
+
=Overview=
 +
 
 
The purpose of this page is to give a specification of a FPC feature allowing writing (Linux) kernel modules using FPC. The main purpose is to an easy syntax hiding all the details of sectioning and linking. The ultimate goal of these wiki pages is to provide a proposal for a future support of natural linux kernel module support in particular and driver support in general (for win32...) A dedicated page module language feature is intended to provide specification for this future support.
 
The purpose of this page is to give a specification of a FPC feature allowing writing (Linux) kernel modules using FPC. The main purpose is to an easy syntax hiding all the details of sectioning and linking. The ultimate goal of these wiki pages is to provide a proposal for a future support of natural linux kernel module support in particular and driver support in general (for win32...) A dedicated page module language feature is intended to provide specification for this future support.
 +
 
=Language enhancement=
 
=Language enhancement=
This proposal is based on adding a new keyword '''module''' triggering a special linking mechanism. Please note that this keyword '''module''' is already recognized by GPC for other purpose. The concept is very similar, however the use is different. Indeed, GPC modules are intended to be linked to programs, however these featured modules are intended to be loadable by the kernel. This lattest doesn't, of course, prevent the former.
+
This proposal is based on adding a new keyword '''module''' triggering a special linking mechanism. Please note that this keyword '''module''' is already recognized by GPC for other purpose. The concept is very similar, however the use is different. Indeed, GPC modules are intended to be linked to programs, however these featured modules are intended to be loadable by the kernel. The latter doesn't, of course, prevent the former.
  
 
The easiest way to illustrate this is using the following example
 
The easiest way to illustrate this is using the following example
 +
 +
<syntaxhighlight lang="pascal">
 
  module kpmod;
 
  module kpmod;
 
  uses unit1, unit2,...unitn;
 
  uses unit1, unit2,...unitn;
Line 20: Line 24:
 
   printk(KERN_INFO + 'Module "%s" is being unloaded'#10, MODULE_NAME);
 
   printk(KERN_INFO + 'Module "%s" is being unloaded'#10, MODULE_NAME);
 
  end.
 
  end.
 +
</syntaxhighlight>
  
 
=Working details=
 
=Working details=
 +
 +
[[Category:Linux]]
 +
[[Category:Proposals]]

Latest revision as of 08:53, 26 January 2020

Overview

The purpose of this page is to give a specification of a FPC feature allowing writing (Linux) kernel modules using FPC. The main purpose is to an easy syntax hiding all the details of sectioning and linking. The ultimate goal of these wiki pages is to provide a proposal for a future support of natural linux kernel module support in particular and driver support in general (for win32...) A dedicated page module language feature is intended to provide specification for this future support.

Language enhancement

This proposal is based on adding a new keyword module triggering a special linking mechanism. Please note that this keyword module is already recognized by GPC for other purpose. The concept is very similar, however the use is different. Indeed, GPC modules are intended to be linked to programs, however these featured modules are intended to be loadable by the kernel. The latter doesn't, of course, prevent the former.

The easiest way to illustrate this is using the following example

 module kpmod;
 uses unit1, unit2,...unitn;
 const
  MODULE_NAME = 'kpmod';
 type
   TType = some type;
 const 
   aConst = a value;
 initialization
   {Module initialization code}
   printk(KERN_INFO + 'Module "%s" is being loaded'#10, MODULE_NAME);
 finalization
   {Module cleanup code}
   printk(KERN_INFO + 'Module "%s" is being unloaded'#10, MODULE_NAME);
 end.

Working details