On 11/21/12, Peter Gavin <[email protected]> wrote:
> On Tue, Nov 20, 2012 at 6:21 PM, Julius Baxter
> <[email protected]>wrote:
>
>> This is probably a contentious point, but why shouldn't writing to
>> unimplemented SPRs be alright? Does it say anything about this in the
>> spec?
>>
>
> I remember coming across this problem in the past, and I think my initial
> implementation of mtspr would trigger an error or something like that for
> unknown SPRs, because it wasn't clear what else should happen.  Then I
> found the mtspr we're talking about now, and so I explicitly allowed zero
> to be written to the TTMR register without raising an error.  At some point
> I changed it so they don't raise an error, but instead just print a warning
> to the screen and resume with no other effect.  I think this is the only
> time an unimplemented SPR gets written to in libgloss, newlib, or libgcc.
>

It would be simple enough to test the UPR and find out if the timer
unit is present, and if so, clear the TTMR. Perhaps that should be
done.

> I don't think the manual explicitly states that writing unimplemented SPRs
> has no effect.  A search of a few related terms didn't bring it up, and
> it's not in section 4.3.

Yes, I think it doesn't say either way if it should be treated with an
exception or the like. I'm in favor of stating that writes to
unimplemented SPRs should essentially be a l.nop. We're already saying
unimplemented SPRs read as 0 with the " Unused SPR space read as zero
" addition to the spec.

I know Ruben was keen on raising exceptions for accessing
unimplemented SPR space but I'm not a fan simply because it requires
more implementation complexity, and it's not obvious which exception
should be raised. Illegal instruction maybe is best? I really don't
know why you'd go to this length to catch obvious software bugs. I
mean, it's just going to be either an incorrectly written bit of
assembler (easily picked up by looking in the trace and seeing the
calculated SPR is wrong) or attempting to use a unit which is not
present (dumping the UPR will show you that the implementation doesn't
have the unit you're attempting to use - even better, make the code
check the UPR before running those bits of code.)

Cheers

Julius
_______________________________________________
OpenRISC mailing list
[email protected]
http://lists.openrisc.net/listinfo/openrisc

Reply via email to