The Prisoner <nospam@[EMAIL PROTECTED]
> wrote:
> Jens Thoms Toerring wrote:
> > The Prisoner <nospam@[EMAIL PROTECTED]
> wrote:
> >
> >>I was reading about interrupts, and I got to thinking it would be a
real
> >>neat thing to use interrupts for program-wide exception handling. What
I
> >>haven't been able to find is a clear guide or example program for how
to
> >>install a C function into the IDT.
> >
> >
> > This is completely system dependent (assuming a system has an
> > "IDT" at all and the operating system lets you get at something
> > that low level which many probably won't, even if you have root
> > or admistrator privileges). And what about a multi-tasking
> > system? Just think about the situation that you would get in
> > if each programs would mess around with the IDT. I guess the
> > only system this could somehow be made to work would be DOS.
> > If that's you're system you probably better ask in a group
> > that specializes on system specific programming under DOS.
> Are you 100% sure about that? I understood that in Real Mode, the IVT is
> used, while in Protected Mode the IDT is used. So it should be possible
> to make use of the IDT under Windows or Linux.
I don't know about Windows but I am rather sure that Linux won't
let you get at something that essential for the systems health
from a userland program (I would also guess that Windows will
also not let you do that unless the guys in Redmond completely
lost their minds;-). And, while we're talking about Linux, that
would only work (if it would be possible at all) when running
on a x86-like architecture (the IDT seems to be something rather
x86-specific). But Linux runs on lots of different architectures
which may use completely different methods for dealing with
interrupts. So if you want to write for "Linux" stick to standard
C (plus the system specific extensions from e.g. POSIX you can't
avoid) and don't try to throw assembler into the mix (unless you
have an extremely specialized project to do, but exception hand-
ling for failures of memory allocations don't sound like that).
> What I don't know is how to write a function's address into the IDT...
Again, absolutely system specific. On an x86-kind of architecture
(in protected mode) I think you will have to read the IDTR regis-
ter (something you can't do with C, you will have to resort to
assembler and which other architectures rather likely don't have),
calculate where the slot for the function pointer is and write the
functions address there. If you really want to do something like
that you will have to get yourself the specifications for your
processor and figure it out from there.
But none of this has really anything to do with the language C,
the topic of this group. Several things needed can't be done in
C and those that can be done could also be done using some other
language...
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@[EMAIL PROTECTED]
\__________________________ http://toerring.de


|