[Top] [All Lists]

Re: Timer setup code for DS5000/200

Subject: Re: Timer setup code for DS5000/200
From: (Paul Antoine)
Date: Wed, 4 Dec 1996 18:25:59 +1100 (EST)
In-reply-to: <> from "Michael Engel" at Nov 30, 96 01:51:32 am
Organization: Softway Pty Ltd
Hi folks,

Michael Engel wrote:

> well, this is the promised timer setup code that obviously works on my
> DS5000/200 and produces interrupts ... I still haven't got the interrupt 
> handler to return where it should, maybe Paul can help out with that.

I certainly can!

>       /* WARNING :
>          This actually reads out time and date information, but manages
>          to mess up somehow with the RTC so that I get a ?RTC error on next
>          reboot and time/date information is reset to 0.0h 1.1.1972 (?) !! */

You should wait until there's no update in progress, but this isn't why
you're getting ?RTC errors on boot...

> I'm enabling interrupts via the following code sequence :
> [decstation_setup.S]
> decstation_setup_int:
>                 NESTED(decstation_setup_int, FR_SIZE, ra)
>                 .set    noat
>                   mfc0 k0, CP0_STATUS 
nop needed here I think!
>                   ori  k0,0x0f15 
>                   mtc0 k0, CP0_STATUS
nop needed here I think!

> I inserted lots of pmax_printf calls in the interrupt handling code, and it
> never seems to call an interrupt routine (which should printk some panic
> message ...). Basically, it runs up to 

Remember printk and PANIC do *not* work yet - as the console driver
has not been written.  Repeat after me: "pmax_printf is a hack..."

> in dec_entry.S which is supposed to call the interrupt handler, right ?

Well, it would if the table was set up right...

> Failing that, I simply tried to increment the jiffies counter in 
> head.S in except_vec3 via

This is a better thing to do, but...

> NESTED(except_vec3, 0, sp)
>       .set    noat
>       SAVE_ALL
>       lw      t0, jiffies
>       add     t0, 1
>       sw      t0, jiffies

The SAVE_ALL has no corresponding RESTORE_ALL so you're going to loose
the stack after a while, and if you use k0/k1 you should have no probs.

Another problem is that the assembler will try to us $at given the
sequence above, try:

        la      k0,jiffies
        lw      k1,(k0)
        addiu   k1,1
        sw      k1,(k0)

...which seems correct to me, but still doesn't make them jiffies jump
the way I think it should... <sigh>  Maybe I've been away from MIPS
assembler too long...

My suggestion would be to limit this to just toggling the LED as an

> just to get a BogoMips number :-) and return via

The BogoMips will only print if the console driver is working, unless
you use pmax_printf in place of printk in calibrate_delay.  The other
problem you'll encounter is that the code leading up to calibrate_delay,
specifically some of the initialisation code isn't happy with interrupts
turned on!

>       mfc0    k0, CP0_EPC
>       nop
>       jr      k0
>       rfe
> as Ralf proposed in a previous mail.
> Well, this code doesn't return where is should. I get periodic interrupts,
> but the kernel code refuses to run any further.

Hmmm... at least one of the reasons for this is that you're not clearing
the interrupt on the RTC, so that as soon as the rfe completes it leaps
straight back into the exception routine... try:

        la      k0,0xbfe80030           # addr of RTC reg C on 5000/200
        lw      k1,(k0)

...which reads Register C and clears the pending interrupt on the RTC in
a 5000/200 (the appropriate addr for 5000/2x is 0xbc200030 for anyone
else that's following this and playing along :-).

Paul M. Antoine,                                        Net:
Softway Pty Ltd                                         WWW:
PO Box 305, Strawberry Hills, NSW 2012, Australia       Tel: +61 2 9698 2322
Level 2, 79 Myrtle St, Chippendale, NSW 2008, Australia Fax: +61 2 9699 9174

"It is the lack of acceptance of diversity which threatens to 
 destroy society, NOT the free expression of it." - Me.

<Prev in Thread] Current Thread [Next in Thread>