comp.lang.ada
 help / color / mirror / Atom feed
From: Markus Kuhn <Markus.Kuhn@cl.cam.ac.uk>
Subject: Re: Using GNAT for Linux kernel hacking
Date: 1998/04/10
Date: 1998-04-10T00:00:00+00:00	[thread overview]
Message-ID: <352E296B.23588C29@cl.cam.ac.uk> (raw)
In-Reply-To: m37m4y6iy2.fsf@fred.muc.de


Andi Kleen wrote:
> I would be careful with Ada programs in kernel space. GNAT has a rather
> complex runtime library that is required to work, and this library
> might not work completely in kernel space. For example there are several
> caveats:
> - Memory allocation works differently than in user space.
> - The kernel stack is limited to 4K (and it is only safe to use 2-3K
> to keep enough space for interrupt handlers)
> - There is no libc in kernel space, so the runtime library might need
> stubs.
> - Ada tasking and protected types probably won't work [unless it is
> especially ported]
> 
> I'm not saying that it is impossible to write ada kernel drivers, just
> that it might require more work than one would naively think at first.
> Of course once the runtime library is ported it'll be easier.

Well, the situation is not that much different from C. If you
write C code in the kernel, you also have lots of special rules
to follow. You can't use malloc() and other standard library
functions in C as well. You won't be allowed to "with" most of
the common Ada packages just like you can't "#include" most of the
C libary functions in the kernel.

The only advantage that C has over Ada and C++ for kernel programming
is that in C, there is much less going on "between the lines" of your
source code, i.e. less automatically inserted code for finalization,
tasking, synchronization, memory deallocation, exception handling,
garbage collection, etc. that could cause bad surprises if executed
in the kernel. Also package elaboration might have to be done
differently in a kernel context, i.e. at boot or module load time.

There sure must be a way to deactivate or prevent these between-the-
lines calls to the run-time library. After all, how else would you
be able to use Ada in order to write such a run-time library in
the first place? Do the Controlled and Restricted pragmas offer
something along those lines?

Is there any documentation available about the interface between
the code generated by GNAT and the GNAT runtime library, especially
concerning things like tasking and memory management? I have
found some old documentation in

  http://www.cs.fsu.edu/~baker/ftp/pub/PART/GNARL/gid-1.32.ps.gz

Is this still up-to-date?

Markus

-- 
Markus G. Kuhn, Security Group, Computer Lab, Cambridge University, UK
email: mkuhn at acm.org,  home page: <http://www.cl.cam.ac.uk/~mgk25/>




  reply	other threads:[~1998-04-10  0:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-04-08  0:00 2nd help about handling HW interrupt and apologizes jtapasai
1998-04-08  0:00 ` Markus Kuhn
1998-04-10  0:00   ` Andi Kleen
1998-04-10  0:00     ` Markus Kuhn [this message]
1998-04-10  0:00     ` Simon Wright
1998-04-10  0:00     ` Geert Bosch
1998-04-11  0:00       ` Andi Kleen
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox