Subject: Re: evbmips and MIPS3 timecounters committed
To: Frank Kardel <kardel@NetBSD.org>
From: Garrett D'Amore <garrett_damore@tadpole.com>
List: port-evbmips
Date: 09/02/2006 00:24:40
Frank Kardel wrote:
> Garrett D'Amore wrote:
>
>> Frank Kardel wrote:
>>  
>>
>>> Garrett D'Amore wrote:
>>>
> [...]
>
>> I'll run the regression later.  My test machine has tiny memory and runs
>> over NFS, so I can't promise that those won't impact the results.  This
>> is the nature of the embedded port. :-)  But at least with a 10 second
>> test, sleep and /bin/time seemed to correlate and match an external
>> stop-watch.
>>
>>  
>>
> Good.
>
>>> [...]
>>>
>>> Would it be possible to refactor the part for all mips 3 based ports?
>>>   
>>
>> Yes.  There isn't much there actually.  I even considered doing this in
>> arch/mips/, but right now the mips ports do their clock setup each
>> separately.  So it takes some effort (not much) to do that.
>>  
>>
> There are more constructs like that. The time pickup from the RTC chip
> with the decision whether to use file system time or rtc time could be
> refactored into MI. MD just needs to provide an RTC reading and
> setting function.
> And that could even be refactored by using a device concept to get
> access to
> the RTC and thus allow sharing of chip access code. (I don't know
> whether this is
> the most pressing topic but it would simplfy ports again)

Actually, looking at evbmips inittodr(), I think that routine could
easily be moved.  In fact, I dont' see even one line in that code that
is port specific.  Not even CPU-specific -- the whole code could
probably be moved into kern_todr.c or somesuch.

Of course, it does require ports (RTCs) to use the TODR set up.  But
this would move some code out of ports.  (My version in evbmips also
deals with the case where no RTC is present, which does occur for some
real hardware.)

Now as far as the MD implementation of delay() and cpu_initclocks(), and
by association the clock interrupt handler in interrupt.c, that stuff
could easily be refactored for ports that share a MIPS3 COP0
implementation.  (I.e. pretty much any modern MIPS machine.)

But doing so might require adding a call frame to the interrupt handling
logic for the clock interrupt (it is currently in-lined) or macro ugliness.

And then there is the question of how do you enable this partially? 
'Cause I don't want to convert all ports -- I'm just not going to do
that.  I don't have hardware for any MIPS other than evbmips. :-)


-- 
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