Article:Talking to hardware under QNX Neutrino

Eric Berdahl wrote:

In article <8vgjsj$q6j$> 1@inn.qnx.com> >, “Debbie Kane” <> debbie@qnx.com
wrote:

  1. Memory-mapped resources
    For some devices, registers are accessed via regular memory operations.
    To
    gain access to a device’s registers, you need to map them to a pointer in
    the driver’s virtual address space. This can be done by calling
    mmap_device_memory().

volatile uint32_t regbase; / device has 32-bit registers */

regbase = mmap_device_memory(NULL, info.BaseAddressSize[0],
PROT_READ|PROT_WRITE|PROT_NOCACHE, 0,
info.CpuBaseAddress[0]);

Note that we specified the PROT_NOCACHE flag. This ensures that the CPU
won’t defer or omit read/write cycles to the device’s registers, nor will
it
deliver the reads or writes to the registers in a different order than
the
driver issued them.

This is good for allowing a driver to access its device’s registers, but
what about something like a video card’s frame buffer? The difference is
that it is a common practice to memory map the frame buffer into the
client’s address space so the client application can render directly
into the frame buffer. On other operating systems (e.g. linux), this can
be done by mmap’ing the device:

fd = open("/dev/mypcicard", O_RDWR);
base = mmap(NULL, myFrameBufferSize,
PROT_NOCACHE | PROT_READ | PROT_WRITE,
0, fd, 0 /* start of frame buffer */);

There must be a pair of BaseAddressSize[] /
CpuBaseAddress[] which is referencing the frame
buffer of your device. So it should be possible to
use mmap() or
mmap_device_memory().

Armin

Warren,

Could you send me your email address I’ve lost it :wink:

  • Mario

Armin Steinhoff <A-Steinhoff@web_.de> wrote:

“In addition, QNX Software has integrated a high
level of Linux compatibility into its new platform
so that Linux developers will feel right at home.”

Armin - Linux Developers != Linux Kernel Developers. This is refeering
to the userland processes that run on Linux - things like KDE and Gnome
and GTK and all the text/console based applications. It is talking about
the fact that one does not need to learn QNX’s internal IPC mechanisms
and internal API to write software for QNX if you are used to writing software
for Linux/UNIX.

The PCI library calls are dealing with the same
PCI standard, regardless if I use
LINUX or QNX4 … so there are no reasons to
introduce a set of proprietary library calls which
are incompatible to QNX4 and LINUX.

Well, I am pretty sure that the QNX4 calls are different then the Linux
calls so I am confused by this statement. It would seem to me that under
this argument we could not win? As a programmer who used Neutrino to do
a PCI based device driver with nothing but the QNX2000 beta and the helpviewer
I thought that the pci_*() functions were very logical and very easy to deal
with - now that I work @ QSSL this hasn’t changed much. :slight_smile:

Given that QNX4 and Linux (and FreeBSD, etc, etc) have different PCI space
interfaces why not just make a library? The end goal is the same on all
platforms. In fact, I made such a library for a talk Sebastien gave @
ESC in Septemeber. It provided a simple framework for doing a character
device on both Linux and QNX - using the same core source for doing the
“real” work. It took me about 1 night. If someone actually spent some
serious time on it one could provide a framework that allowed more complex
drivers to be built.

chris

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

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

“Armin Steinhoff” <A-Steinhoff@web_.de> wrote in message
news:3A220C07.8060C2C6@web_.de…

Warren Peece wrote:

[ clip …]

Okay maybe I’m partially blind,

Not your problem … learn to handle criticism or
“go bitch somewhere else”.

Armin

Ah, but you see Armin it’s apparently you that’s blind. Because what I was
saying was that I failed to find anywhere in that paragraph where it said
that QNX’s device driver model was identical to the one used in Linux,
therefore if you were right then I must be blind. I wasn’t admitting that
you were right and I just missed it the first time, it’s still not there,
and it never was, and it never will be. Fortunately for me and
unfortunately for your argument, I’m not blind, and that paragraph in no way
insinuates anything about QNX6 compatibility with Linux at the device driver
level no matter how much you twist the meaning of what I say.

So here we have an instance of you quoting some advertising in support of
your claim that QNX is not following through with their promises of Linux
compatibility, and that advertising doesn’t support your claim at all. Now
instead of either finding something that really does support your claim or
backing off and saying that perhaps you misunderstood what was intended by
that advertising, you decide to accuse me of not taking criticism very well.
It appears that perhaps you should consider your own advice.

The mechanics of your English are excellent, so I find it extremely
frustrating that you repeatedly fail to grasp what appear to be the
extremely simple concepts between Linux compatibility and being exactly like
Linux down to the header files at the device driver level. QNX in no way
insinuated that would be the case, and in fact went out of their way to say
that writing QNX device drivers is substantially different than on other
systems. They consider those differences, as do I, a major benefit. So why
in the world do you persist in claiming that they said otherwise? It’s pure
fantasy and highlights a glaring lack of understanding on your part. Even
after repeatedly having it explained to you, you continue to act as though
you have some sort of a valid point. In this instance you do not have a
valid point, and your persistance in asserting that you do is costing your
credibility dearly.

-Warren “asbestos longjohns” Peece

Chris McKillop wrote:

Armin Steinhoff <A-Steinhoff@web_.de> wrote:

“In addition, QNX Software has integrated a high
level of Linux compatibility into its new platform
so that Linux developers will feel right at home.”


Armin - Linux Developers != Linux Kernel Developers. This is refeering
to the userland processes that run on Linux - things like KDE and Gnome
and GTK and all the text/console based applications. It is talking about
the fact that one does not need to learn QNX’s internal IPC mechanisms
and internal API to write software for QNX if you are used to writing software
for Linux/UNIX.

Chris … see the initial posting of Eric Behrdal.
I think he is describing a typical situation. His
question about the documentation of io_funcmmap()
is un-anwered until now. If QSSL is interested to
solve their deficiency in drivers they should
provide a detailed and consistent documentation
about the appropriate interfaces.
Yes, there is huge work done but there are still
annoying information leaks if you trying to ‘do
your own thing’. (see the Eric questions …)

The PCI library calls are dealing with the same
PCI standard, regardless if I use
LINUX or QNX4 … so there are no reasons to
introduce a set of proprietary library calls which
are incompatible to QNX4 and LINUX.


Well, I am pretty sure that the QNX4 calls are different then the Linux
calls so I am confused by this statement.

“incompatible to QNX4 and LINUX” means for me
‘incompatible with QNX4’ and ‘incompatible with
LINUX’ … so in what direction are you guys
going?

It would seem to me that under
this argument we could not win? As a programmer who used Neutrino to do
a PCI based device driver with nothing but the QNX2000 beta and the helpviewer
I thought that the pci_*() functions were very logical and very easy to deal
with - now that I work @ QSSL this hasn’t changed much. > :slight_smile:

I don’t see problems to handle the pci_* functions
… if the docs are consistent.
An expierenced developer would ‘interpret’ the
provided structures ( with some trial and errors
probbably) rigth … but what about the PCI
newbies ??

Given that QNX4 and Linux (and FreeBSD, etc, etc) have different PCI space
interfaces why not just make a library? The end goal is the same on all
platforms. In fact, I made such a library for a talk Sebastien gave @
ESC in Septemeber. It provided a simple framework for doing a character
device on both Linux and QNX - using the same core source for doing the
“real” work. It took me about 1 night. If someone actually spent some
serious time on it one could provide a framework that allowed more complex
drivers to be built.

Are there any vaible approaches possible with
UNIX98 standard or UDI ?

Armin

Armin Steinhoff <A-Steinhoff@web_.de> :
“In addition, QNX Software has integrated a high level
of Linux compatibility into its new platform so that
Linux developers will feel right at home.”

Jeez, Armin, give it a rest. I have to agree with the other
gentleman here; you are way off base.

← greenboy —<<<

“Armin Steinhoff” <A-Steinhoff@web_.de> wrote in message
news:3A228C34.48287B8F@web_.de…

| Chris McKillop wrote:
| >
| > Armin Steinhoff <A-Steinhoff@web_.de> wrote:
| > >
| > > “In addition, QNX Software has integrated a high
| > > level of Linux compatibility into its new platform
| > > so that Linux developers will feel right at home.”
| > >
| >
| > Armin - Linux Developers != Linux Kernel Developers. This is refeering
| > to the userland processes that run on Linux - things like KDE and Gnome
| > and GTK and all the text/console based applications. It is talking about
| > the fact that one does not need to learn QNX’s internal IPC mechanisms
| > and internal API to write software for QNX if you are used to writing
software
| > for Linux/UNIX.
|
| Chris … see the initial posting of Eric Behrdal.
| I think he is describing a typical situation. His
| question about the documentation of io_funcmmap()
| is un-anwered until now. If QSSL is interested to
| solve their deficiency in drivers they should
| provide a detailed and consistent documentation
| about the appropriate interfaces.
| Yes, there is huge work done but there are still
| annoying information leaks if you trying to ‘do
| your own thing’. (see the Eric questions …)

As I said before Armin, yes I agree that documentation can almost always be
made clearer. Instead of simply saying that the documentation needs work,
please take the time to point out the individual areas that leave questions in
your mind so the documentation folks can review those sections. This will be
greatly appreciated by the staff and the rest of us as well.

As for your response to Chris, you failed to grasp his point. He is responding
to your use of that quote as proof that QNX is not providing Linux
compatibility at the device driver level. Funny thing is, he’s saying exactly
what I said, that the quote does not in any way specify 100% compatibility down
to the device driver level. So now you have it from a QNX staffer that this
was never their intent. If that is still what you truly believe it to say,
then you are mistaken. So you cannot dismiss his point by referring to Eric
having problems with the documentation. Doing so does not make any sense. You
responded to point “A” by pointing out a different problem we’ll call “B”, then
act as if you have addressed point “A” when in reality you have not.

| > >
| > > The PCI library calls are dealing with the same
| > > PCI standard, regardless if I use
| > > LINUX or QNX4 … so there are no reasons to
| > > introduce a set of proprietary library calls which
| > > are incompatible to QNX4 and LINUX.
| > >
| >
| > Well, I am pretty sure that the QNX4 calls are different then the Linux
| > calls so I am confused by this statement.
|
| “incompatible to QNX4 and LINUX” means for me
| ‘incompatible with QNX4’ and ‘incompatible with
| LINUX’ … so in what direction are you guys
| going?

How about if I lay it out for you. “QNX6 is not, will not be, and was never
intended to be compatible with either QNX4 or Linux at the device driver
level.” If you don’t understand that, then it’s no wonder you’re having
problems. The direction they’re going is what they feel is the best direction
for QNX6, which is in my opinion better than QNX4 and Linux and would only have
been hampered if they had attempted to build in compatibility with either down
at the very lowest levels.

| > It would seem to me that under
| > this argument we could not win? As a programmer who used Neutrino to do
| > a PCI based device driver with nothing but the QNX2000 beta and the
helpviewer
| > I thought that the pci_() functions were very logical and very easy to
deal
| > with - now that I work @ QSSL this hasn’t changed much. :slight_smile:
|
| I don’t see problems to handle the pci_
functions
| … if the docs are consistent.
|
| An expierenced developer would ‘interpret’ the
| provided structures ( with some trial and errors
| probbably) rigth … but what about the PCI
| newbies ??

If people do not understand the PCI specification then how can you expect them
to write a device driver? The fact of the matter is that a certain level of
expertise is necessary to write device drivers. You have it, I have it, if
there’s someone who’s just starting out, they can certainly ask us for help and
we will gladly provide it. Then they will also have it. This is of course not
an excuse for poor documentation, and I agree with you that every effort should
be made to thoroughly and completely document the entire interface.

-Warren

| > Given that QNX4 and Linux (and FreeBSD, etc, etc) have different PCI space
| > interfaces why not just make a library? The end goal is the same on all
| > platforms. In fact, I made such a library for a talk Sebastien gave @
| > ESC in Septemeber. It provided a simple framework for doing a character
| > device on both Linux and QNX - using the same core source for doing the
| > “real” work. It took me about 1 night. If someone actually spent some
| > serious time on it one could provide a framework that allowed more complex
| > drivers to be built.
|
| Are there any vaible approaches possible with
| UNIX98 standard or UDI ?
|
| Armin

In article <3A222A0C.6DC9BAD5@web_.de>, Armin Steinhoff
<A-Steinhoff@web_.de> wrote:

Eric Berdahl wrote:
This is good for allowing a driver to access its device’s registers,
but
what about something like a video card’s frame buffer? The difference
is
that it is a common practice to memory map the frame buffer into the
client’s address space so the client application can render directly
into the frame buffer. On other operating systems (e.g. linux), this
can
be done by mmap’ing the device:

fd = open("/dev/mypcicard", O_RDWR);
base = mmap(NULL, myFrameBufferSize,
PROT_NOCACHE | PROT_READ | PROT_WRITE,
0, fd, 0 /* start of frame buffer */);


There must be a pair of BaseAddressSize[] /
CpuBaseAddress[] which is referencing the frame
buffer of your device. So it should be possible to
use mmap() or
mmap_device_memory().

Yes, if one is root one can do that very easily. The problem I was
having was allowing a non-root process to map that same memory area with
the driver (a root process) providing whatever help was necessary. The
trouble was finding out what “whatever help was necessary” meant.

In article <3A228C34.48287B8F@web_.de>, Armin Steinhoff
<A-Steinhoff@web_.de> wrote:

Chris McKillop wrote:
Armin - Linux Developers != Linux Kernel Developers. This is refeering
to the userland processes that run on Linux - things like KDE and Gnome
and GTK and all the text/console based applications. It is talking
about
the fact that one does not need to learn QNX’s internal IPC mechanisms
and internal API to write software for QNX if you are used to writing
software
for Linux/UNIX.

Chris … see the initial posting of Eric Behrdal.
I think he is describing a typical situation. His
question about the documentation of io_funcmmap()
is un-anwered until now. If QSSL is interested to
solve their deficiency in drivers they should
provide a detailed and consistent documentation
about the appropriate interfaces.
Yes, there is huge work done but there are still
annoying information leaks if you trying to ‘do
your own thing’. (see the Eric questions …)

As the author of that initial posting, I will chime in exactly once in
this sub-thread.

I have seen QSSL’s advertising about linux compatibility for QNX and
Neutrino. I’m also a driver developer and I never once considered that
drivers would be portable from linux to Neutrino. Never. If they were, I
wouldn’t be using Neutrino. Linux drivers run as modules of the kernel.
The fact that Neutrino drivers do not is a huge benefit to driver
developers. Linux drivers run with the scheduler completely turned off.
The fact that Neutrino drivers are full fledged threaded processes, with
the scheduler doing its thing all the time is great.

The linux kernel is fine for what the linux kernel does. Neutrino is
fine for what Neutrino does. Driver people generally understand that
drivers need to be written for the kernel, not the high-level APIs.
Driver people also generally understand that no two distinct kernels in
the world have the same driver model except in extraordinary
circumstances.

Furthermore, my posting was not meant to imply that Neutrino should or
should not implement their driver model to be like linux. Rather, I had
a specific problem: how to map a part of my card’s memory into a
non-root client process with the tacit approval of the driver. I used
our existing linux driver’s solution as an example of how we solved the
problem on that operating system. I also asked if that solution was
appropriate in Neutrino. It was not. Thanks to the suggestions and
patience of several individuals at QSSL and elsewhere, I now have a
working solution in Neutrino.

And, for the record, the Neutrino solution is better, IMHO. If anyone
should be stealing driver models, it is linux from Neutrino. Not the
other way around.

My two cents.
Eric

Eric Berdahl <berdahl@intelligentparadigm.com> wrote:

Here’s the code I use:

fd = shm_open("/quackfb", O_RDWR | O_CREAT, 0777);
if (-1 == fd)
perror(“shm_open”);

if (-1 == ftruncate(fd, theSize))
perror(“ftruncate”);

if (-1 == shm_ctl(fd, SHMCTL_PHYS, thePhysicalAddr, theSize))
perror(“shm_ctl”);

When I run this from my driver, I get an error from shm_ctl
(errno=ENOSYS).

Not sure if this had been answered later in this thread alreay,
but you can not call shm_ctl on a shared memory object that is flagged
special (think it’s special at least). The call to ftruncate will
flag it as special. If you drop the ftruncate it should work better.
This also means you can only call shm_ctl once as well.

-Peter

“Armin Steinhoff” <A-Steinhoff@web_.de> wrote in message
news:3A22CE43.79ED84B8@web_.de…

| My last 2 cencts:
|
| Using the same LIBRARY STANDARD ( for instance the
| POSIX standard, LINUX ‘lib standard’ or QNX4 ‘lib
| standard’ ) for drivers doesn’t mean that the
| drivers must share the same driver model … e.g.
| LINUX drivers and NTO drivers are completely
| different but they are using the same standard for
| POSIX threads.
|
| We have the same situation if we take the LINUX or
| QNX4 PCI library definitions as a standard. IMHO
| …we are just winners when we follow IT standards
| …
|
| Armin

My last two cents (hey, stop clapping!):

Generally speaking, I agree with the concept that following a standard can be
but is not always a good thing. In this particular example, I believe that the
implementation of the QNX6 driver structure deviates sufficiently from the QNX4
as well as Linux implementations so as to warrant its own unique approach.
After all is said and done, in a couple of years we’ll be thinking of it as the
QNX6 standard anyway.

Ladies and Gentlemen, thank you all for joining us today. Be sure to pick up
your free gift sets by the door on your way out, and remember to tip your
waiters and waitresses as they’ve all done a fine job for us this evening.
Thank you, and good night. :wink:

-Warren

Eric Berdahl wrote:

In article <3A228C34.48287B8F@web_.de>, Armin Steinhoff
A-Steinhoff@web_.de> wrote:

Chris McKillop wrote:
Armin - Linux Developers != Linux Kernel Developers. This is refeering
to the userland processes that run on Linux - things like KDE and Gnome
and GTK and all the text/console based applications. It is talking
about
the fact that one does not need to learn QNX’s internal IPC mechanisms
and internal API to write software for QNX if you are used to writing
software
for Linux/UNIX.

Chris … see the initial posting of Eric Behrdal.
I think he is describing a typical situation. His
question about the documentation of io_funcmmap()
is un-anwered until now. If QSSL is interested to
solve their deficiency in drivers they should
provide a detailed and consistent documentation
about the appropriate interfaces.
Yes, there is huge work done but there are still
annoying information leaks if you trying to ‘do
your own thing’. (see the Eric questions …)

As the author of that initial posting, I will chime in exactly once in
this sub-thread.

[ clip … ]
And, for the record, the Neutrino solution is better, IMHO. If anyone
should be stealing driver models, it is linux from Neutrino. Not the
other way around.

My last 2 cencts:

Using the same LIBRARY STANDARD ( for instance the
POSIX standard, LINUX ‘lib standard’ or QNX4 ‘lib
standard’ ) for drivers doesn’t mean that the
drivers must share the same driver model … e.g.
LINUX drivers and NTO drivers are completely
different but they are using the same standard for
POSIX threads.

We have the same situation if we take the LINUX or
QNX4 PCI library definitions as a standard. IMHO
…we are just winners when we follow IT standards

Armin

Not sure about PHYSICAL, but if you don’t ftruncate() normal region you’ll
get SIGBUS referencing it.

  • igor

<pgraves@qnx.com> wrote in message news:8vuck7$eg5$1@nntp.qnx.com

Eric Berdahl <> berdahl@intelligentparadigm.com> > wrote:
SNIP

Here’s the code I use:

fd = shm_open("/quackfb", O_RDWR | O_CREAT, 0777);
if (-1 == fd)
perror(“shm_open”);

if (-1 == ftruncate(fd, theSize))
perror(“ftruncate”);

if (-1 == shm_ctl(fd, SHMCTL_PHYS, thePhysicalAddr, theSize))
perror(“shm_ctl”);

When I run this from my driver, I get an error from shm_ctl
(errno=ENOSYS).


Not sure if this had been answered later in this thread alreay,
but you can not call shm_ctl on a shared memory object that is flagged
special (think it’s special at least). The call to ftruncate will
flag it as special. If you drop the ftruncate it should work better.
This also means you can only call shm_ctl once as well.

-Peter

If you don’t use the shm_ctl you will. But the shm_ctl will
do the resize for you based on the size you pass it. But
once you call ftruncate you can no longer call shm_ctl, and
you can only call shm_ctl once.

-Peter

Igor Kovalenko <kovalenko@home.com> wrote:

Not sure about PHYSICAL, but if you don’t ftruncate() normal region you’ll
get SIGBUS referencing it.

  • igor

pgraves@qnx.com> > wrote in message news:8vuck7$eg5$> 1@nntp.qnx.com> …
Eric Berdahl <> berdahl@intelligentparadigm.com> > wrote:
SNIP

Here’s the code I use:

fd = shm_open("/quackfb", O_RDWR | O_CREAT, 0777);
if (-1 == fd)
perror(“shm_open”);

if (-1 == ftruncate(fd, theSize))
perror(“ftruncate”);

if (-1 == shm_ctl(fd, SHMCTL_PHYS, thePhysicalAddr, theSize))
perror(“shm_ctl”);

When I run this from my driver, I get an error from shm_ctl
(errno=ENOSYS).


Not sure if this had been answered later in this thread alreay,
but you can not call shm_ctl on a shared memory object that is flagged
special (think it’s special at least). The call to ftruncate will
flag it as special. If you drop the ftruncate it should work better.
This also means you can only call shm_ctl once as well.

-Peter

Hi

Only core OS services reside in “kernel”
address space – everything else, including device drivers, reside in
“process” or “user” address space.

With InterruptAttach(), the driver’s “handler” function is called directly
by the kernel. Since it’s running in kernel space, the hander is severely
restricted in what it can do. From within this handler, it isn’t safe to
call most of the C library functions. Also, if you spend too much time in
the handler, other processes and interrupt handlers of a lower or equal
priority won’t be able to run. Doing too much work in the interrupt
handler
can negatively affect the system’s realtime responsiveness.

As I understand, this is potential way to kill all system through any device
driver, not?
Because of huge amount of hardware QSSL can’t check any driver from hardware
vendors.
Security is made a sacrifice to performance in this case, right?
Can you provide some comparison in performance of two interrupt-handling
methods?

With best regards
Boris

“btr” <btr_@mail.ru> wrote in message news:9191lj$55r$1@inn.qnx.com

Hi

Only core OS services reside in “kernel”
address space – everything else, including device drivers, reside in
“process” or “user” address space.

With InterruptAttach(), the driver’s “handler” function is called
directly
by the kernel. Since it’s running in kernel space, the hander is
severely
restricted in what it can do. From within this handler, it isn’t safe to
call most of the C library functions. Also, if you spend too much time
in
the handler, other processes and interrupt handlers of a lower or equal
priority won’t be able to run. Doing too much work in the interrupt
handler
can negatively affect the system’s realtime responsiveness.

As I understand, this is potential way to kill all system through any
device
driver, not?
Because of huge amount of hardware QSSL can’t check any driver from
hardware
vendors.
Security is made a sacrifice to performance in this case, right?
Can you provide some comparison in performance of two interrupt-handling
methods?

Downside of InterruptAttachEvent() method is that event will be delivered
and your thread scheduled to run even if the event is not really yours
(since interrupts can be shared on PCI). A real interrupt handler could
check the source of interrupt and return value based on that check.

  • igor

btr <btr_@mail.ru> wrote:

Hi

Only core OS services reside in “kernel”
address space – everything else, including device drivers, reside in
“process” or “user” address space.

With InterruptAttach(), the driver’s “handler” function is called directly
by the kernel. Since it’s running in kernel space, the hander is severely
restricted in what it can do. From within this handler, it isn’t safe to
call most of the C library functions. Also, if you spend too much time in
the handler, other processes and interrupt handlers of a lower or equal
priority won’t be able to run. Doing too much work in the interrupt
handler
can negatively affect the system’s realtime responsiveness.

As I understand, this is potential way to kill all system through any device
driver, not?
Because of huge amount of hardware QSSL can’t check any driver from hardware
vendors.
Security is made a sacrifice to performance in this case, right?

Yes, a device driver can easily take down the system. However, an
app or driver which wants to bang at hardware, or attach an interrupt
handler, needs to run at “root” privilidge. It is presumed that “root”
will only install well-behaved drivers on the system.

Can you provide some comparison in performance of two interrupt-handling
methods?

The InterruptAttach() method will have a much lower latency, since
in the case of InterruptAttachEvent(), you have to wait 'til your
thread gets scheduled, before you can respond to the interrupt.

The exact latencies obviously vary from machine to machine. The
system load (whether there are higher-priority interrupts being
serviced), and the priority of the thread handling an
interrupt event also come into play.

Some devices (e.g. a serial device with a small (or no) FIFO), might use
InterruptAttach(), and retrieve the data from the hardware and buffer
it in the interrupt handler, to be processed later by higher-level
software. This would necessary to avoid overruns and data loss,
if there was not time to retrieve the data from the hardware,
before a user-level thread could be scheduled.

With best regards
Boris

Hi,
I read this aricle. Article is very much informative. But it does not
talk about DMAs.
Either ISA or PCI. I’m looking for API to convert my virtual address to
physical address
which I can use to initiate DMA over PCI from a PCI device.

-Sachin
“David Donohoe” <ddonohoe@qnx.com> wrote in message
news:93nb49$68u$1@nntp.qnx.com

btr <> btr_@mail.ru> > wrote:
Hi

Only core OS services reside in “kernel”
address space – everything else, including device drivers, reside in
“process” or “user” address space.

With InterruptAttach(), the driver’s “handler” function is called
directly
by the kernel. Since it’s running in kernel space, the hander is
severely
restricted in what it can do. From within this handler, it isn’t safe
to
call most of the C library functions. Also, if you spend too much time
in
the handler, other processes and interrupt handlers of a lower or equal
priority won’t be able to run. Doing too much work in the interrupt
handler
can negatively affect the system’s realtime responsiveness.

As I understand, this is potential way to kill all system through any
device
driver, not?
Because of huge amount of hardware QSSL can’t check any driver from
hardware
vendors.
Security is made a sacrifice to performance in this case, right?

Yes, a device driver can easily take down the system. However, an
app or driver which wants to bang at hardware, or attach an interrupt
handler, needs to run at “root” privilidge. It is presumed that “root”
will only install well-behaved drivers on the system.

Can you provide some comparison in performance of two interrupt-handling
methods?

The InterruptAttach() method will have a much lower latency, since
in the case of InterruptAttachEvent(), you have to wait 'til your
thread gets scheduled, before you can respond to the interrupt.

The exact latencies obviously vary from machine to machine. The
system load (whether there are higher-priority interrupts being
serviced), and the priority of the thread handling an
interrupt event also come into play.

Some devices (e.g. a serial device with a small (or no) FIFO), might use
InterruptAttach(), and retrieve the data from the hardware and buffer
it in the interrupt handler, to be processed later by higher-level
software. This would necessary to avoid overruns and data loss,
if there was not time to retrieve the data from the hardware,
before a user-level thread could be scheduled.

With best regards
Boris

sachin <vaidyasd@hotmail.com> wrote:

Hi,
I read this aricle. Article is very much informative. But it does not
talk about DMAs.
Either ISA or PCI. I’m looking for API to convert my virtual address to
physical address
which I can use to initiate DMA over PCI from a PCI device.

mphys ()

returns a PA given a VA. If you need multiple page-sized chunks, run mphys()
over page-sized-aligned chunks of memory and return multiple PAs.

Ie, if page-size == 4k, and you have a 10k chunk, knowing that the PA maps
to 4k sized PA chunks, divide the 10k chunk into 3 or 4 (depending on alignment)
4k-aligned chunks of VA space. Then run mphys() on the start block of each
4k chunk. This will return the start of each 4k-sized PA. Optionally coallesce
the multiple 4k PA chunks into larger chunks if they’re contiguous.

Cheers,
-RK

-Sachin
“David Donohoe” <> ddonohoe@qnx.com> > wrote in message
news:93nb49$68u$> 1@nntp.qnx.com> …
btr <> btr_@mail.ru> > wrote:
Hi

Only core OS services reside in “kernel”
address space – everything else, including device drivers, reside in
“process” or “user” address space.

With InterruptAttach(), the driver’s “handler” function is called
directly
by the kernel. Since it’s running in kernel space, the hander is
severely
restricted in what it can do. From within this handler, it isn’t safe
to
call most of the C library functions. Also, if you spend too much time
in
the handler, other processes and interrupt handlers of a lower or equal
priority won’t be able to run. Doing too much work in the interrupt
handler
can negatively affect the system’s realtime responsiveness.

As I understand, this is potential way to kill all system through any
device
driver, not?
Because of huge amount of hardware QSSL can’t check any driver from
hardware
vendors.
Security is made a sacrifice to performance in this case, right?

Yes, a device driver can easily take down the system. However, an
app or driver which wants to bang at hardware, or attach an interrupt
handler, needs to run at “root” privilidge. It is presumed that “root”
will only install well-behaved drivers on the system.

Can you provide some comparison in performance of two interrupt-handling
methods?

The InterruptAttach() method will have a much lower latency, since
in the case of InterruptAttachEvent(), you have to wait 'til your
thread gets scheduled, before you can respond to the interrupt.

The exact latencies obviously vary from machine to machine. The
system load (whether there are higher-priority interrupts being
serviced), and the priority of the thread handling an
interrupt event also come into play.

Some devices (e.g. a serial device with a small (or no) FIFO), might use
InterruptAttach(), and retrieve the data from the hardware and buffer
it in the interrupt handler, to be processed later by higher-level
software. This would necessary to avoid overruns and data loss,
if there was not time to retrieve the data from the hardware,
before a user-level thread could be scheduled.

With best regards
Boris
\


Robert Krten, PARSE Software Devices +1 613 599 8316.
Realtime Systems Architecture, Books, Video-based and Instructor-led
Training and Consulting at www.parse.com.
Email my initials at parse dot com.

sachin <vaidyasd@hotmail.com> wrote:

Hi,
I read this aricle. Article is very much informative. But it does not
talk about DMAs.
Either ISA or PCI. I’m looking for API to convert my virtual address to
physical address
which I can use to initiate DMA over PCI from a PCI device.

That reminds me, I was planning a second article :wink:

You can get the physical address with mem_offset64().

There may also be a translation between addresses on the CPU bus
and those on the PCI bus; look at the CpuBmstrTranslation
member of the pci_dev_info structure. (You can get away with
ignoring it on x86, though, since it’s zero).

Dave