Subject: Re: com rumblings...
To: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
From: Garrett D'Amore <garrett_damore@tadpole.com>
List: tech-kern
Date: 06/15/2006 09:45:51
Izumi Tsutsui wrote:
> garrett_damore@tadpole.com wrote:
>
>
>> Note that the handle and tag are cached in local variables. It was
>> harder to do this cleanly in the new code with register access macros,
>> so my new code looks like the following. Ultimately, there could be a
>> performance impact depending on how smart the optimizer is:
>>
>> struct com_regs {
>> bus_tag_t iot;
>> bus_handle_t ioh;
>> #ifdef COM_REGSMAP
>> bus_size_t map[16];
>> #endif
>> };
>>
>
> - Why don't you put map[] member to struct com_softc?
>
Because lots of com routines don't actually have/use the softc.
Particularly stuff that might be used with console/kgdb support. This
common structure lives in the softc, and can also live outside the softc
for use in code that doesn't have the softc.
> - Where is "COM_REGSMAP" defined in your code?
>
In conf/files (or rather, opt_com.h)
> Is it possible to define it only if a particular MD
> attachment which requires special layout is configured?
>
Yes. Stick it in MD config file (e.g. I have it in files.alchemy and
files.atheros, but not in i386.)
> - Do all MD attachments have to initialize map[] array
> if COM_REGSMAP is defined?
>
No, there is a default "COM_INIT_REGS" that initializes this for
standard 16550 layout.
> (I'm afraid it might make cnattach functions more complicated)
>
Actually, it makes them smaller. I've already converted a bunch of
them. Look in gdamore-uart branch. :-)
>
>> #define OUTB(r, o, v) bus_space_write_1(r->iot, r->ioh, r->map[o], v)
>>
>
> BTW, I don't like names like OUTB/INB.
> I prefer COM_WRITE_REG_1 or so.
>
Generally I do to, in new code. But there were a *lot* of these, and I
was going to have to reformat a bunch of code if I did this. I figured
this was actually more readable. I can change it if folks really want
me to -- its easy to do with global subst/replace, but then I have to go
reformat a bunch of lines that will be too long for a single line. :-)
-- Garrett
> ---
> Izumi Tsutsui
>
--
Garrett D'Amore, Principal Software Engineer
Tadpole Computer / Computing Technologies Division,
General Dynamics C4 Systems
http://www.tadpolecomputer.com/
Phone: 951 325-2134 Fax: 951 325-2191