From: "Dan'l Miller" <optikos@verizon.net>
Subject: Re: Kernel Syscall from Ada?
Date: Thu, 12 Jul 2018 12:07:58 -0700 (PDT)
Date: 2018-07-12T12:07:58-07:00 [thread overview]
Message-ID: <e9c05e73-ea72-4fc5-a671-fecd3fdf0c11@googlegroups.com> (raw)
In-Reply-To: <nkhn72$4lt$1@franka.jacob-sparre.dk>
On Thursday, June 23, 2016 at 5:18:14 PM UTC-5, Randy Brukardt wrote:
> "Diogenes" wrote in message
> news:2048d6d6-04e2-4e2c-9483-e3769da59781@googlegroups.com...
> >Is there a simple way to make a direct (Linux)Kernel syscall from Ada
> >without
> >using the system C library? i.e. Make a direct call as in Assembler?
>
> On almost all modern systems, a system call IS a call to some C subprogram.
> (On Windows, they're calls into a DLL; Linux appears similar although I've
> never studied the details.) There's nothing like the set-registers and trap
> like there was in the old days on MS-DOS, XENIX, and other systems.
>
> So the only way to make a system call is via aspect Import to the needed C
> routine. (On Windows, I''d expect that a program that didn't do any system
> calls would be much smaller than a "normal" program; Windows needs some
> stuff added to every program; it doesn't have anything to do with Ada
> per-se.)
>
> Randy.
One of the more succinct summaries of the legacy 8086, 32-bit x86, and 64-bit x86-64:
https://stackoverflow.com/questions/12806584/what-is-better-int-0x80-or-syscall
Randy is mostly accurate: interrupt 80₁₆ has faded into antiquity and currently everything about system calls boils down to C subprograms.
Conversely, the syscall mechanism is best thought of as an •assembly• subprogram (and calling convention) that crosses a ring boundary whose syscall-table array of assembly subprograms does have some vague resemblance to the old interrupt 80₁₆ vector table. (No processor manufacturer would hardcode C-language conventions into their silicon for context switches between protection rings. It is all C out of habit, not hardware-imposed necessity.)
Conceivably Ada could present its own array of Ada subprograms in its own syscall-table, so that Ada would not come down to invoking C subprograms in userspace. An Ada-centric new distribution of Linux (or BSD Unix or GNU Hurd or any other operating system, for that matter) would be needed to add an Ada-only syscall vector/lookup table (LUT) in addition to the current C-only syscall LUT. But such a new distro of Ada-Linux (or Ada-BSD or Ada-Hurd) could showcase 100%-Ada software in userspace, encourage Ada programming in kernelspace, and use that Ada-based package manager announced recently on c.l.a.
lucid explanation of 32-bit sysenter:
http://articles.manugarg.com/systemcallinlinux2_6.html
a taste of VDSO to avoid a userspace-to-kernelspace context switch for some would-be/has-been syscalls:
https://en.wikipedia.org/wiki/VDSO
the complexity of on which processors AMD syscall versus Intel sysenter instructions are supported or not:
https://ReverseEngineering.stackexchange.com/questions/16454/struggling-between-syscall-or-sysenter-windows
next prev parent reply other threads:[~2018-07-12 19:07 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-23 8:36 Kernel Syscall from Ada? Diogenes
2016-06-23 10:58 ` Björn Lundin
2016-06-23 16:28 ` Per Sandberg
2016-06-23 22:18 ` Randy Brukardt
2018-07-12 19:07 ` Dan'l Miller [this message]
2018-07-12 20:59 ` Randy Brukardt
2016-06-24 1:13 ` Xavier Petit
2016-06-24 22:23 ` Florian Weimer
2018-07-11 22:38 ` alexgrantbenedict
2018-07-12 1:32 ` Dan'l Miller
2018-07-12 8:19 ` Lucretia
2018-07-12 15:27 ` Dan'l Miller
2018-07-12 17:27 ` Lucretia
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox