Skip to content

Commit

Permalink
fix the rtc emulation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
yajin authored and mthuurne committed Jul 21, 2010
1 parent 6fadf05 commit 8d1a3a9
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions hw/mips_jz.c
Expand Up @@ -52,7 +52,7 @@
#define DEBUG_LCDC (1<<0x5) #define DEBUG_LCDC (1<<0x5)
#define DEBUG_DMA (1<<0x6) #define DEBUG_DMA (1<<0x6)
#define DEBUG_SADC (1<<0x7) #define DEBUG_SADC (1<<0x7)
#define DEBUG_FLAG DEBUG_SADC //(DEBUG_CPM|DEBUG_EMC|DEBUG_GPIO \ #define DEBUG_FLAG 0 //(DEBUG_CPM|DEBUG_EMC|DEBUG_GPIO
// | DEBUG_RTC | DEBUG_TCU | DEBUG_LCDC | DEBUG_DMA) // | DEBUG_RTC | DEBUG_TCU | DEBUG_LCDC | DEBUG_DMA)
//DEBUG_TCU// (DEBUG_CPM|DEBUG_EMC|DEBUG_GPIO //DEBUG_TCU// (DEBUG_CPM|DEBUG_EMC|DEBUG_GPIO
// | DEBUG_RTC | DEBUG_TCU | DEBUG_LCDC | DEBUG_DMA) // | DEBUG_RTC | DEBUG_TCU | DEBUG_LCDC | DEBUG_DMA)
Expand Down Expand Up @@ -1380,7 +1380,7 @@ struct jz4740_rtc_s
struct jz_state_s *soc; struct jz_state_s *soc;


QEMUTimer *hz_tm; QEMUTimer *hz_tm;
//struct tm tm; struct tm tm;
//int sec_offset; //int sec_offset;
int64_t next; int64_t next;


Expand All @@ -1401,11 +1401,17 @@ struct jz4740_rtc_s


static void jz4740_rtc_update_interrupt(struct jz4740_rtc_s *s) static void jz4740_rtc_update_interrupt(struct jz4740_rtc_s *s)
{ {
/* if (((s->rtcsr & 0x40) && (s->rtcsr & 0x20)) if (!s->rtcsr&0x1)
|| ((s->rtcsr & 0x10) && (s->rtcsr & 0x8))) return;
qemu_set_irq(s->irq, 1);*/
//else if (((s->rtccr & 0x40) && (s->rtccr & 0x20))
// qemu_set_irq(s->irq, 0); || ((s->rtccr & 0x10) && (s->rtccr & 0x8)))
{
debug_out(DEBUG_RTC,"s->rtccr %x \n",s->rtcsr);
qemu_set_irq(s->irq, 1);
}


} }


static inline void jz4740_rtc_start(struct jz4740_rtc_s *s) static inline void jz4740_rtc_start(struct jz4740_rtc_s *s)
Expand Down Expand Up @@ -1443,14 +1449,12 @@ static void jz4740_rtc_hz(void *opaque)


static void jz4740_rtc_reset(struct jz4740_rtc_s *s) static void jz4740_rtc_reset(struct jz4740_rtc_s *s)
{ {

s->rtccr = 0x81; s->rtccr = 0x81;

s->next = 1000; s->next = 1000;


/*Maybe rtcsr need to be saved to file */ /*Maybe rtcsr need to be saved to file */
s->rtcsr = 0; s->rtcsr = time(NULL);
//s->sec_offset = 0;
//qemu_get_timedate(&s->tm, s->sec_offset);
jz4740_rtc_start(s); jz4740_rtc_start(s);


} }
Expand Down Expand Up @@ -1500,22 +1504,20 @@ static void jz4740_rtc_write(void *opaque, target_phys_addr_t addr,
switch (addr) switch (addr)
{ {
case 0x0: case 0x0:
s->rtccr = value & 0x2d; s->rtccr = value & 0x7d;
if (!value & 0x40) if (!value & 0x40)
s->rtccr &= ~0x40; s->rtccr &= ~0x40;
if (!value & 0x10) if (!value & 0x10)
s->rtccr &= ~0x10; s->rtccr &= ~0x10;
if (s->rtccr & 0x1) if (s->rtccr & 0x1)
{ {
//jz4740_rtc_start(s); jz4740_rtc_start(s);
jz4740_rtc_update_interrupt(s);
} }
else else
jz4740_rtc_stop(s); jz4740_rtc_stop(s);
break; break;
case 0x4: case 0x4:
s->rtcsr = value; s->rtcsr = value;
//s->sec_offset = qemu_timedate_diff(&s->tm);
break; break;
case 0x8: case 0x8:
s->rtcsar = value; s->rtcsar = value;
Expand Down

0 comments on commit 8d1a3a9

Please sign in to comment.