Software Interrupts

Hello,

I really tried not to bother anyone about my question. I searched the
Internet and QNX site the best I could for the information I wanted,
but couldn’t find anything.

I am wondering about QNX Neutrino/RTP/whatever. I am moving away from
DPMI ASM programming, and may have some misconceptions about
programming under a POSIX+ELF ASM environment. Please ignore any
errors I make.

My question has to do with system services: Is there any way to access
POSIX or system services using software interrupts under QNX RTP?

For example: DOS has INT 21h (among others). BeOS has INT 25h. Linux,
FreeBSD, AtheOS, and others have INT 80h whereby POSIX services can be
accessed.

I heard that Be Inc. didn’t want to publish this information. Maybe
because these features are undocumented, not official, and reliance on
software interrupts is just plain bad? So, should I assume QSSL has
the same policy? I also heard that many portable operating systems do
not allow software interrupts, because not all hardware architectures
support them.

Although software interrupts are considered slow, linking to shared
objects in ASM can get pretty hairy and time-consuming. Plus reliance
on LIBC or any such libraries almost defeats the purpose of ASM
programming in the first place. So, in many cases it is preferable to
use software interrupts.

As well, any information on interrupts and functions would complement
an existing effort to provide a portable POSIX ASM environment
(targeted for embedded systems) nicely.
(http://linuxassembly.org/asmutils.html)


Thank you,

Dylan.

Dylan Bowker <dbowker@incentre.net> wrote:

Hello,

I really tried not to bother anyone about my question. I searched the
Internet and QNX site the best I could for the information I wanted,
but couldn’t find anything.

I am wondering about QNX Neutrino/RTP/whatever. I am moving away from
DPMI ASM programming, and may have some misconceptions about
programming under a POSIX+ELF ASM environment. Please ignore any
errors I make.

My question has to do with system services: Is there any way to access
POSIX or system services using software interrupts under QNX RTP?

For example: DOS has INT 21h (among others). BeOS has INT 25h. Linux,
FreeBSD, AtheOS, and others have INT 80h whereby POSIX services can be
accessed.

Hm, Let’s see if I can explain this :slight_smile:

“software interrupt”, or on under other CPU platform, “system trap”,
is usually a way to moving from “user mode” to “system(kernel) mode”,
to access “system services” (or what we called “kernel calls”).

Yes. NTO using a “INT xx” (on x86 platform of cause) to jump into kernel,
since the source of libc is opened (cvs.qnx.com), I suppose you can
figure out how to do that. This is not documented, and is not the way
we recommanded people to do.

However, the real question is, what really is you want?

NTO is a “message passing, micro kernel”. By that, it means, most
of the “POSIX or system services” you imaged, probably end up talking
(send data) to another process instead of kernel calls. For example,
a “socket()” call, end up findout the process taking care of
tcpip, (the io-net process), and “MsgSend()” a request to io-net.
check out the libc source, you may supprised there are so few “kernel
calls” there.

Finally, if you still feel you want to do the ASM programming, you
can write you own program in ASM, and call the C cover function of
kernel calls, and static link your ASM with out libc.

-xtang

“Xiaodan Tang” <xtang@qnx.com> wrote in message
news:9ipj1o$mf8$1@nntp.qnx.com

However, the real question is, what really is you want?

NTO is a “message passing, micro kernel”. By that, it means, most
of the “POSIX or system services” you imaged, probably end up talking
(send data) to another process instead of kernel calls. For example,
a “socket()” call, end up findout the process taking care of
tcpip, (the io-net process), and “MsgSend()” a request to io-net.
check out the libc source, you may supprised there are so few “kernel
calls” there.

How would one ‘MsgSend() to another process’ without using software
interrupts? You need capability to manipulate 2 independent address spaces,
so you need to be in kernel mode. Yes, most libc calls are just cover for
MsgSend, but since MsgSend is kernel call it effectively means most libc
calls end up as ‘INT xx’ inside MsgSend anyway …

  • igor

Igor Kovalenko <kovalenko@home.com> wrote:

“Xiaodan Tang” <> xtang@qnx.com> > wrote in message
news:9ipj1o$mf8$> 1@nntp.qnx.com> …
However, the real question is, what really is you want?

NTO is a “message passing, micro kernel”. By that, it means, most
of the “POSIX or system services” you imaged, probably end up talking
(send data) to another process instead of kernel calls. For example,
a “socket()” call, end up findout the process taking care of
tcpip, (the io-net process), and “MsgSend()” a request to io-net.
check out the libc source, you may supprised there are so few “kernel
calls” there.


How would one ‘MsgSend() to another process’ without using software
interrupts? You need capability to manipulate 2 independent address spaces,
so you need to be in kernel mode. Yes, most libc calls are just cover for
MsgSend, but since MsgSend is kernel call it effectively means most libc
calls end up as ‘INT xx’ inside MsgSend anyway …

Oh, yeah, you have to use “MsgSend() system services”, and to do that,
you will need to call the libc cover function, or directly play with
INT xx if you kmnow what you are doing…

What I want to point out is, losts of “POSIX calls” ends up in a
“MsgSend() system services”, not like other system, you need all
sorts of “system services” to cover open/read/write/close.

-xtang

Hurm…

Since the kernel calls are generated by a script when you build the
c library you can’t just browse them in cvs. So, if you checkout the
whole clib from cvs.qnx.com you should be able to have it generate the
x86 system calls. I belive it uses “int 0x28” or sysenter (depends on the
cpu generation).

chris



Xiaodan Tang <xtang@qnx.com> wrote:

Igor Kovalenko <> kovalenko@home.com> > wrote:
“Xiaodan Tang” <> xtang@qnx.com> > wrote in message
news:9ipj1o$mf8$> 1@nntp.qnx.com> …
However, the real question is, what really is you want?

NTO is a “message passing, micro kernel”. By that, it means, most
of the “POSIX or system services” you imaged, probably end up talking
(send data) to another process instead of kernel calls. For example,
a “socket()” call, end up findout the process taking care of
tcpip, (the io-net process), and “MsgSend()” a request to io-net.
check out the libc source, you may supprised there are so few “kernel
calls” there.


How would one ‘MsgSend() to another process’ without using software
interrupts? You need capability to manipulate 2 independent address spaces,
so you need to be in kernel mode. Yes, most libc calls are just cover for
MsgSend, but since MsgSend is kernel call it effectively means most libc
calls end up as ‘INT xx’ inside MsgSend anyway …

Oh, yeah, you have to use “MsgSend() system services”, and to do that,
you will need to call the libc cover function, or directly play with
INT xx if you kmnow what you are doing…

What I want to point out is, losts of “POSIX calls” ends up in a
“MsgSend() system services”, not like other system, you need all
sorts of “system services” to cover open/read/write/close.

-xtang

cdm@qnx.com > “The faster I go, the behinder I get.”

Chris McKillop – Lewis Carroll –
Software Engineer, QSSL
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Hello Dylan,

It might help if you could give us an expample of what you consider a
typical instance where “Software Interrupts” and ASM is needed. We can then
go through your [simple] example in the QNX way.

David S. Alessio
Systemic Realtime Design, LLC.



“Xiaodan Tang” <xtang@qnx.com> wrote in message
news:9ipj1o$mf8$1@nntp.qnx.com

Dylan Bowker <> dbowker@incentre.net> > wrote:
Hello,

I really tried not to bother anyone about my question. I searched the
Internet and QNX site the best I could for the information I wanted,
but couldn’t find anything.

I am wondering about QNX Neutrino/RTP/whatever. I am moving away from
DPMI ASM programming, and may have some misconceptions about
programming under a POSIX+ELF ASM environment. Please ignore any
errors I make.

My question has to do with system services: Is there any way to access
POSIX or system services using software interrupts under QNX RTP?

For example: DOS has INT 21h (among others). BeOS has INT 25h. Linux,
FreeBSD, AtheOS, and others have INT 80h whereby POSIX services can be
accessed.

Hm, Let’s see if I can explain this > :slight_smile:

“software interrupt”, or on under other CPU platform, “system trap”,
is usually a way to moving from “user mode” to “system(kernel) mode”,
to access “system services” (or what we called “kernel calls”).

Yes. NTO using a “INT xx” (on x86 platform of cause) to jump into kernel,
since the source of libc is opened (cvs.qnx.com), I suppose you can
figure out how to do that. This is not documented, and is not the way
we recommanded people to do.

However, the real question is, what really is you want?

NTO is a “message passing, micro kernel”. By that, it means, most
of the “POSIX or system services” you imaged, probably end up talking
(send data) to another process instead of kernel calls. For example,
a “socket()” call, end up findout the process taking care of
tcpip, (the io-net process), and “MsgSend()” a request to io-net.
check out the libc source, you may supprised there are so few “kernel
calls” there.

Finally, if you still feel you want to do the ASM programming, you
can write you own program in ASM, and call the C cover function of
kernel calls, and static link your ASM with out libc.

-xtang

Note: I originally tried posting this message through google groups
(http://groups.google.com/groups?hl=en&safe=off&group=qdn.public.qnxrt
p.devtools) but it did not seem to come through. So I am reposting
through QNX’s news server.


Ave David,

It might help if you could give us an expample of what you consider
a typical instance where “Software Interrupts” and ASM is needed.
We can then go through your [simple] example in the QNX way.

Well I can give you examples for DOS, Linux, etc. But here is an
example of how to open a file in ASM running under a decent DPMI
extender:

mov edx, filename ; Point DS:EDX to filename.
mov al, file_read ; Open file for “read” access.
mov ah, 3Dh ; Function 3Dh: Extended DOS: Open file.
int 21h ; Do the dirty deed.

These are generally referred to as “fastcalls.” I did some more 'net
scouring and found out that [people believe] QNX RTP supports both
message passing services and POSIX services using software interrupts.

I could not get the LIBC source to build. I found a C script that
generates a list of interrupt functions for message passing. (But I
couldn’t get it to compile either.) And I couldn’t find much about the
mystical QNX POSIX “fastcalls” that I presume exist. Unfortunately my
knowledge of C is nil! (I am an ASM-only man.) I have no idea what’s
going on in there!

Unless QSSL is dead against doing these “fastcalls,” I assume there
must be a lot of people there that could answer this question blind-
folded?

If I were a real hacker I probably could have figured this out weeks
ago! But I’m not. :slight_smile: Even after two QSSL people have already tried to
spell it out for me. Thanks for the help anyway. :slight_smile:

So I am still working on the parts I can in DOS. Hopefully I can make
some progress on this problem soon.

Dylan.

Previously, Dylan Bowker wrote in qdn.public.qnxrtp.devtools:

Well I can give you examples for DOS, Linux, etc. But here is an
example of how to open a file in ASM running under a decent DPMI
extender:

mov edx, filename ; Point DS:EDX to filename.
mov al, file_read ; Open file for “read” access.
mov ah, 3Dh ; Function 3Dh: Extended DOS: Open file.
int 21h ; Do the dirty deed.

This is handled with either open() or fopen(). There is
no faster way.

These are generally referred to as “fastcalls.” I did some more 'net
scouring and found out that [people believe] QNX RTP supports both
message passing services and POSIX services using software interrupts.

Underlying open() and fopen() are calls to Send() which send a
message to the appropriate resource manager.

Underlying the Send() is an int call or a trap depending on the
hardware.

I could not get the LIBC source to build. I found a C script that
generates a list of interrupt functions for message passing. (But I
couldn’t get it to compile either.) And I couldn’t find much about the
mystical QNX POSIX “fastcalls” that I presume exist. Unfortunately my
knowledge of C is nil! (I am an ASM-only man.) I have no idea what’s
going on in there!

As far as I know there are no mystical fastcalls. You can call open and
fopen from assembler as in something like this:

mv eax,open_options
push eax
mv eax,filename
push eax
call fopen

Unless QSSL is dead against doing these “fastcalls,” I assume there
must be a lot of people there that could answer this question blind-
folded?

You question is based on a few misconceptions. The first is
that there is some route around the Posix calls that is
somehow faster. The majority of overhead in an open call
is not in the involkation. Here’s my guess as to where
the time goes from most to least.

  1. Waiting for disk I/O if any
  2. Searching file system caches for hits
  3. Message passing of open request (a context switch
  4. Message passing to find resource manager (a context switch
  5. executing code in fopen() if you are using it rather than open()
  6. involkation processing

Hope this helps.


Mitchell Schoenbrun --------- maschoen@pobox.com