From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LVoxF-0000Es-O5 for qemu-devel@nongnu.org; Sat, 07 Feb 2009 10:18:49 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LVoxE-0000EQ-Tc for qemu-devel@nongnu.org; Sat, 07 Feb 2009 10:18:48 -0500 Received: from [199.232.76.173] (port=48916 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LVoxE-0000EJ-GD for qemu-devel@nongnu.org; Sat, 07 Feb 2009 10:18:48 -0500 Received: from savannah.gnu.org ([199.232.41.3]:43435 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LVoxE-0003FK-9M for qemu-devel@nongnu.org; Sat, 07 Feb 2009 10:18:48 -0500 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1LVoxD-0008S8-NN for qemu-devel@nongnu.org; Sat, 07 Feb 2009 15:18:47 +0000 Received: from aurel32 by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1LVoxD-0008S4-GD for qemu-devel@nongnu.org; Sat, 07 Feb 2009 15:18:47 +0000 MIME-Version: 1.0 Errors-To: aurel32 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Aurelien Jarno Message-Id: Date: Sat, 07 Feb 2009 15:18:47 +0000 Subject: [Qemu-devel] [6549] SH4: fix TMU init Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 6549 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6549 Author: aurel32 Date: 2009-02-07 15:18:47 +0000 (Sat, 07 Feb 2009) Log Message: ----------- SH4: fix TMU init Init the TMU and the ptimer with the correct cpu reset value Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD Signed-off-by: Aurelien Jarno Modified Paths: -------------- trunk/hw/sh_timer.c Modified: trunk/hw/sh_timer.c =================================================================== --- trunk/hw/sh_timer.c 2009-02-07 15:18:14 UTC (rev 6548) +++ trunk/hw/sh_timer.c 2009-02-07 15:18:47 UTC (rev 6549) @@ -25,6 +25,11 @@ #define TIMER_FEAT_CAPT (1 << 0) #define TIMER_FEAT_EXTCLK (1 << 1) +#define OFFSET_TCOR 0 +#define OFFSET_TCNT 1 +#define OFFSET_TCR 2 +#define OFFSET_TCPR 3 + typedef struct { ptimer_state *timer; uint32_t tcnt; @@ -57,13 +62,13 @@ sh_timer_state *s = (sh_timer_state *)opaque; switch (offset >> 2) { - case 0: + case OFFSET_TCOR: return s->tcor; - case 1: + case OFFSET_TCNT: return ptimer_get_count(s->timer); - case 2: + case OFFSET_TCR: return s->tcr | (s->int_level ? TIMER_TCR_UNF : 0); - case 3: + case OFFSET_TCPR: if (s->feat & TIMER_FEAT_CAPT) return s->tcpr; default: @@ -80,15 +85,15 @@ int freq; switch (offset >> 2) { - case 0: + case OFFSET_TCOR: s->tcor = value; ptimer_set_limit(s->timer, s->tcor, 0); break; - case 1: + case OFFSET_TCNT: s->tcnt = value; ptimer_set_count(s->timer, s->tcnt); break; - case 2: + case OFFSET_TCR: if (s->enabled) { /* Pause the timer if it is running. This may cause some inaccuracy dure to rounding, but avoids a whole lot of other @@ -145,7 +150,7 @@ ptimer_run(s->timer, 0); } break; - case 3: + case OFFSET_TCPR: if (s->feat & TIMER_FEAT_CAPT) { s->tcpr = value; break; @@ -196,12 +201,17 @@ s->tcor = 0xffffffff; s->tcnt = 0xffffffff; s->tcpr = 0xdeadbeef; - s->tcor = 0; + s->tcr = 0; s->enabled = 0; s->irq = irq; bh = qemu_bh_new(sh_timer_tick, s); s->timer = ptimer_init(bh); + + sh_timer_write(s, OFFSET_TCOR >> 2, s->tcor); + sh_timer_write(s, OFFSET_TCNT >> 2, s->tcnt); + sh_timer_write(s, OFFSET_TCPR >> 2, s->tcpr); + sh_timer_write(s, OFFSET_TCR >> 2, s->tcpr); /* ??? Save/restore. */ return s; }