From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.66.144.98 with SMTP id sl2mr35978419pab.32.1431977148325; Mon, 18 May 2015 12:25:48 -0700 (PDT) X-Received: by 10.140.27.140 with SMTP id 12mr80678qgx.30.1431977148260; Mon, 18 May 2015 12:25:48 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newspeer1.nac.net!border2.nntp.dca1.giganews.com!nntp.giganews.com!j8no4994500igd.0!news-out.google.com!k20ni33429qgd.0!nntp.google.com!z60no2027991qgd.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 18 May 2015 12:25:48 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=105.237.126.3; posting-account=orbgeAkAAADzWCTlruxuX_Ts4lIq8C5J NNTP-Posting-Host: 105.237.126.3 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <8759d49e-c30a-4c71-a3e5-fd7a818a30f6@googlegroups.com> Subject: Re: Linux kernel module - memory allocation From: jan.de.kruyf@gmail.com Injection-Date: Mon, 18 May 2015 19:25:48 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:25908 Date: 2015-05-18T12:25:48-07:00 List-Id: Hallo, I am feeling brave at the moment so I am messing with this stuff. You might be more informed than I am at this moment on certain aspects, but= perhaps some of my observations might be of help. =20 So this is what I found: read this book until you know it backward: https://lwn.net/Kernel/LDD3/ Then you really need the kernel source or the kernel dev headers to be able= to do any module, unless Android is more advanced in this respect (which I= doubt) Next get the source of a tiny module with the makefile and study it until y= ou know it backward, including all the kernel special tricks. then run the make file and see how the build process pulls itself into lots= of knots in order to do the right thing. You might have to find out how to= make it speak to you. On Linux it is like this: 'make V=3D1'. Then you might be able to extract some Ada definitions with a play module t= hat includes the C headerfiles of interest. (and some of those then come fr= om the kernel dev packet.) To do that you need to repeat the -I stanzas tha= t you saw when you build the module above, on the command line, so you get = your c header files from the right places. (some of the -I's need path expa= nsion since the module make process changes directory to the place where th= e kernel-dev files are) Then there are lots of booby traps in the Ada versions, because gnat does n= ot know everything. for instance a little program that is defined as an inl= ine in a headerfile is taken for gospel by gnat but it will not link when y= ou try to use it, since there is no code for it in the kernel. So you must = write a wrapper in c. Somewhere in the discussion I saw "no runtime". This is obsolete now. you a= re supposed to have some runtime even if it is empty, I suppose. But you ca= n definitely not use the normal gnat runtime since it pulls clib in. I did make myself a small runtime for my Arm work which seems to behave qui= te well. It does have a secondary stack also. It just needs porting back to= x86. In that runtime you need some of the stuff that the compiler wants in order= to successfully build your program. Like a way of obtaining memory when yo= u initialize a struct from a pointer.=20 As soon as the compiler complains about some missing symbol with lots of un= derscores in it, you can be sure that something is missing in your runtime = and you either need to drop that language feature or you need to fix up you= r runtime. So I am still looking into the runtime thing, but there is a lot to look i= nto at the moment. And the runtime is sort of cut cake. I will probably put= some wrappers into it for the more delicate stuff. At the same time I did decide to use an existing piece of c code to give me= a framework in which to mess with Ada. A bit later I might find ways of ex= panding the Ada bit, but at the moment I am happy with working code no matt= er what language. Btw do tell us where you found this funny gnatmake switch "gnatmake .. -mcm= odel=3Dkernel ... We are willing to learn . . .=20 Now let me quickly read Simons great find at pegasoft. May the peace be with you. j.