A
aarklon
Hi,
I used to argue at this point that using memory-mapped IO made it
easier to write device drivers in C, since you could map devices to C
structures. Unfortunately, modern C compilers pad structures for
performance reasons, and trying to coerce the compiler into producing
the memory layout you really want is non-portable and deprecated. So
I'm leaving the argument in place, but it's really for historical
interest at this point. The comments about trying to create in and out
instructions do remain valid, however.
Also, when writing device drivers in C, it's a lot easier to work
with when devices are in memory space. Let's suppose you have a simple
device (for concreteness, let's look at the A/D convertor on an HC11.
It's controlled by five registers (not counting the OPTION register),
located at addresses $1030-$1034. We can define a struct that looks
like this:
see:- http://www.cs.nmsu.edu/~pfeiffer/classes/473/notes/io.html
I used to argue at this point that using memory-mapped IO made it
easier to write device drivers in C, since you could map devices to C
structures. Unfortunately, modern C compilers pad structures for
performance reasons, and trying to coerce the compiler into producing
the memory layout you really want is non-portable and deprecated. So
I'm leaving the argument in place, but it's really for historical
interest at this point. The comments about trying to create in and out
instructions do remain valid, however.
Also, when writing device drivers in C, it's a lot easier to work
with when devices are in memory space. Let's suppose you have a simple
device (for concreteness, let's look at the A/D convertor on an HC11.
It's controlled by five registers (not counting the OPTION register),
located at addresses $1030-$1034. We can define a struct that looks
like this:
see:- http://www.cs.nmsu.edu/~pfeiffer/classes/473/notes/io.html