Commit 6341fdcb7841f364a6102ce2b3c375e6c0d7560e

Authored by blueswir1
1 parent 37191109

Fix CPU timer interrupts


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3876 c046a42c-6fe2-441c-8c8c-71466251a162
hw/slavio_intctl.c
... ... @@ -70,7 +70,8 @@ typedef struct SLAVIO_INTCTLState {
70 70 #define INTCTLM_MASK 0x1f
71 71 #define MASTER_IRQ_MASK ~0x0fa2007f
72 72 #define MASTER_DISABLE 0x80000000
73   -#define CPU_IRQ_MASK 0xfffe0000
  73 +#define CPU_SOFTIRQ_MASK 0xfffe0000
  74 +#define CPU_HARDIRQ_MASK 0x0000fffe
74 75 #define CPU_IRQ_INT15_IN 0x0004000
75 76 #define CPU_IRQ_INT15_MASK 0x80000000
76 77  
... ... @@ -111,13 +112,13 @@ static void slavio_intctl_mem_writel(void *opaque, target_phys_addr_t addr, uint
111 112 case 1: // clear pending softints
112 113 if (val & CPU_IRQ_INT15_IN)
113 114 val |= CPU_IRQ_INT15_MASK;
114   - val &= CPU_IRQ_MASK;
  115 + val &= CPU_SOFTIRQ_MASK;
115 116 s->intreg_pending[cpu] &= ~val;
116 117 slavio_check_interrupts(s);
117 118 DPRINTF("Cleared cpu %d irq mask %x, curmask %x\n", cpu, val, s->intreg_pending[cpu]);
118 119 break;
119 120 case 2: // set softint
120   - val &= CPU_IRQ_MASK;
  121 + val &= CPU_SOFTIRQ_MASK;
121 122 s->intreg_pending[cpu] |= val;
122 123 slavio_check_interrupts(s);
123 124 DPRINTF("Set cpu %d irq mask %x, curmask %x\n", cpu, val, s->intreg_pending[cpu]);
... ... @@ -256,8 +257,9 @@ static void slavio_check_interrupts(void *opaque)
256 257 if (pending & (1 << j))
257 258 pil_pending |= 1 << s->intbit_to_level[j];
258 259 }
  260 + pil_pending |= s->intreg_pending[i] & CPU_HARDIRQ_MASK;
259 261 }
260   - pil_pending |= (s->intreg_pending[i] & CPU_IRQ_MASK) >> 16;
  262 + pil_pending |= (s->intreg_pending[i] & CPU_SOFTIRQ_MASK) >> 16;
261 263  
262 264 for (j = 0; j < MAX_PILS; j++) {
263 265 if (pil_pending & (1 << j)) {
... ... @@ -386,7 +388,7 @@ void *slavio_intctl_init(target_phys_addr_t addr, target_phys_addr_t addrg,
386 388 *irq = qemu_allocate_irqs(slavio_set_irq, s, 32);
387 389  
388 390 *cpu_irq = qemu_allocate_irqs(slavio_set_timer_irq_cpu, s, MAX_CPUS);
389   - s->cputimer_bit = 1 << s->intbit_to_level[cputimer];
  391 + s->cputimer_bit = 1 << cputimer;
390 392 slavio_intctl_reset(s);
391 393 return s;
392 394 }
... ...
hw/slavio_timer.c
... ... @@ -253,6 +253,8 @@ static void slavio_timer_mem_writel(void *opaque, target_phys_addr_t addr,
253 253 if (val & (1 << i)) {
254 254 qemu_irq_lower(s->slave[i]->irq);
255 255 s->slave[i]->limit = -1ULL;
  256 + } else {
  257 + ptimer_stop(s->slave[i]->timer);
256 258 }
257 259 if ((val & (1 << i)) != (s->slave_mode & (1 << i))) {
258 260 ptimer_stop(s->slave[i]->timer);
... ...
hw/sun4m.c
... ... @@ -88,8 +88,9 @@ struct hwdef {
88 88 uint32_t ecc_version;
89 89 target_phys_addr_t sun4c_intctl_base, sun4c_counter_base;
90 90 long vram_size, nvram_size;
91   - // IRQ numbers are not PIL ones, but master interrupt controller register
92   - // bit numbers
  91 + // IRQ numbers are not PIL ones, but master interrupt controller
  92 + // register bit numbers except for clock_irq, which indexes cpu
  93 + // interrupt controller register
93 94 int intctl_g_intr, esp_irq, le_irq, clock_irq, clock1_irq;
94 95 int ser_irq, ms_kb_irq, fd_irq, me_irq, cs_irq;
95 96 int machine_id; // For NVRAM
... ... @@ -691,7 +692,7 @@ static const struct hwdef hwdefs[] = {
691 692 .nvram_size = 0x2000,
692 693 .esp_irq = 18,
693 694 .le_irq = 16,
694   - .clock_irq = 7,
  695 + .clock_irq = 14,
695 696 .clock1_irq = 19,
696 697 .ms_kb_irq = 14,
697 698 .ser_irq = 15,
... ... @@ -732,7 +733,7 @@ static const struct hwdef hwdefs[] = {
732 733 .nvram_size = 0x2000,
733 734 .esp_irq = 18,
734 735 .le_irq = 16,
735   - .clock_irq = 7,
  736 + .clock_irq = 14,
736 737 .clock1_irq = 19,
737 738 .ms_kb_irq = 14,
738 739 .ser_irq = 15,
... ... @@ -773,7 +774,7 @@ static const struct hwdef hwdefs[] = {
773 774 .nvram_size = 0x2000,
774 775 .esp_irq = 18,
775 776 .le_irq = 16,
776   - .clock_irq = 7,
  777 + .clock_irq = 14,
777 778 .clock1_irq = 19,
778 779 .ms_kb_irq = 14,
779 780 .ser_irq = 15,
... ... @@ -814,7 +815,7 @@ static const struct hwdef hwdefs[] = {
814 815 .nvram_size = 0x2000,
815 816 .esp_irq = 18,
816 817 .le_irq = 16,
817   - .clock_irq = 7,
  818 + .clock_irq = 14,
818 819 .clock1_irq = 19,
819 820 .ms_kb_irq = 14,
820 821 .ser_irq = 15,
... ...