Index Home About Blog
From: (John R. Mashey)
Newsgroups: comp.arch,comp.std.c
Subject: Re: Fortran type notation (was Re: 64 bit advantage?)
Date: 7 Apr 1999 05:32:51 GMT

In article <>, Eric Hildum
<> writes:

|> With regard to I/O, yes, byte level operations are important on the
|> transmission side in certain protocols. However, would this be a
|> property of the I/O controller, rather than the CPU? How many of the
|> fields in a packet are really bytes, as opposed to bit flags, words,
|> long words, and strings?

|> Dave Hansen wrote:
|> > On Mon, 05 Apr 1999 11:09:11 +0900, Eric Hildum
|> > <> wrote:
|> >
|> > >It is not clear to me that byte level addressing is all that useful
|> > >anymore.
|> >
|> > Two letters for you.  I/O.

Dave was perhaps a bit terse ... but any I/O programmer knows what he means,
which is that on most micro-based systems (but not IBM mainframes, for example),
I/O devices are programmed via memory-mapped I/O control and status registers.
These have the following characteristics:
1) Many I/O devices come on boards that go into standard busses.

2) The devices specify the addressing layout of the registers, for their
own convenience, and C structs must describe what's there, not what you
wish was there.  The normal thing is to define a struct for each
set of device registers and just use a volatile pointer to access it.

3) To save gates and address space, devices frequently pack registers
into 8, 16, 32, and 64-bit fields.

4) Writes, and sometimes reads sometimes cause side-effects in the device,
i.e., volatile is a good thing.

5) If a device register is 32-bits wide, and you do a 32-bit read, all is
well; if you do 2 16-bit reads and try to put the data together,
you may get surprised.

6) If there are 4 8-bit registers packed together, and you use 1 32-bit read to
get all 4 values, you may also get surprised (you'll probably just get
the byte at the address of the 32-bit word.)

7) There are tricks for faking this ... but in general, if you want
straightforward ports of device drivers, or you want binary-distributed
OSs to work, and you want access to a wide variety of I/O device cards
outside your own design ... you'll have byte addressing that
straightforwardly generates (address, size, R|W) acccesses, not just
(address, 32-bits, R|W).

8) AMD29Ks started with byte addressing and word accesses.
Alphas started with byte addressing and word or doubleword accesses.
Both ended up adding 8- and 16-bit accesses...

-john mashey    DISCLAIMER: <generic disclaimer: I speak for me only...>
EMAIL:  DDD: 650-933-3090 FAX: 650-933-4392
USPS:   Silicon Graphics/Cray Research 40U-005,
2011 N. Shoreline Blvd, Mountain View, CA 94043-1389

Index Home About Blog