]> Git Repo - qemu.git/blobdiff - hw/sh_intc.c
hda: do not mix output and input stream states, RHBZ #740493
[qemu.git] / hw / sh_intc.c
index 136e7dd216dd943e2516680858a6302d293adc0a..e07424f2a1651b2d9bb0b740ae0dad0006acca09 100644 (file)
@@ -5,10 +5,9 @@
  * Based on sh_timer.c and arm_timer.c by Paul Brook
  * Copyright (c) 2005-2006 CodeSourcery.
  *
- * This code is licenced under the GPL.
+ * This code is licensed under the GPL.
  */
 
-#include <assert.h>
 #include "sh_intc.h"
 #include "hw.h"
 #include "sh.h"
@@ -17,7 +16,6 @@
 //#define DEBUG_INTC_SOURCES
 
 #define INTC_A7(x) ((x) & 0x1fffffff)
-#define INTC_ARRAY(x) (sizeof(x) / sizeof(x[0]))
 
 void sh_intc_toggle_source(struct intc_source *source,
                           int enable_adj, int assert_adj)
@@ -107,7 +105,7 @@ int sh_intc_get_pending_vector(struct intc_desc *desc, int imask)
        }
     }
 
-    assert(0);
+    abort();
 }
 
 #define INTC_MODE_NONE       0
@@ -183,7 +181,7 @@ static void sh_intc_locate(struct intc_desc *desc,
        }
     }
 
-    assert(0);
+    abort();
 }
 
 static void sh_intc_toggle_mask(struct intc_desc *desc, intc_enum id,
@@ -262,7 +260,7 @@ static void sh_intc_write(void *opaque, target_phys_addr_t offset,
     case INTC_MODE_ENABLE_REG | INTC_MODE_IS_PRIO: break;
     case INTC_MODE_DUAL_SET: value |= *valuep; break;
     case INTC_MODE_DUAL_CLR: value = *valuep & ~value; break;
-    default: assert(0);
+    default: abort();
     }
 
     for (k = 0; k <= first; k++) {
@@ -284,13 +282,13 @@ static void sh_intc_write(void *opaque, target_phys_addr_t offset,
 #endif
 }
 
-static CPUReadMemoryFunc *sh_intc_readfn[] = {
+static CPUReadMemoryFunc * const sh_intc_readfn[] = {
     sh_intc_read,
     sh_intc_read,
     sh_intc_read
 };
 
-static CPUWriteMemoryFunc *sh_intc_writefn[] = {
+static CPUWriteMemoryFunc * const sh_intc_writefn[] = {
     sh_intc_write,
     sh_intc_write,
     sh_intc_write
@@ -327,7 +325,7 @@ static void sh_intc_register_source(struct intc_desc *desc,
         for (i = 0; i < desc->nr_mask_regs; i++) {
            struct intc_mask_reg *mr = desc->mask_regs + i;
 
-           for (k = 0; k < INTC_ARRAY(mr->enum_ids); k++) {
+           for (k = 0; k < ARRAY_SIZE(mr->enum_ids); k++) {
                 if (mr->enum_ids[k] != source)
                     continue;
 
@@ -342,7 +340,7 @@ static void sh_intc_register_source(struct intc_desc *desc,
         for (i = 0; i < desc->nr_prio_regs; i++) {
            struct intc_prio_reg *pr = desc->prio_regs + i;
 
-           for (k = 0; k < INTC_ARRAY(pr->enum_ids); k++) {
+           for (k = 0; k < ARRAY_SIZE(pr->enum_ids); k++) {
                 if (pr->enum_ids[k] != source)
                     continue;
 
@@ -357,7 +355,7 @@ static void sh_intc_register_source(struct intc_desc *desc,
         for (i = 0; i < nr_groups; i++) {
            struct intc_group *gr = groups + i;
 
-           for (k = 0; k < INTC_ARRAY(gr->enum_ids); k++) {
+           for (k = 0; k < ARRAY_SIZE(gr->enum_ids); k++) {
                 if (gr->enum_ids[k] != source)
                     continue;
 
@@ -384,13 +382,14 @@ void sh_intc_register_sources(struct intc_desc *desc,
 
        sh_intc_register_source(desc, vect->enum_id, groups, nr_groups);
        s = sh_intc_source(desc, vect->enum_id);
-       if (s)
-           s->vect = vect->vect;
+        if (s) {
+            s->vect = vect->vect;
 
 #ifdef DEBUG_INTC_SOURCES
-       printf("sh_intc: registered source %d -> 0x%04x (%d/%d)\n",
-              vect->enum_id, s->vect, s->enable_count, s->enable_max);
+            printf("sh_intc: registered source %d -> 0x%04x (%d/%d)\n",
+                   vect->enum_id, s->vect, s->enable_count, s->enable_max);
 #endif
+        }
     }
 
     if (groups) {
@@ -400,7 +399,7 @@ void sh_intc_register_sources(struct intc_desc *desc,
            s = sh_intc_source(desc, gr->enum_id);
            s->next_enum_id = gr->enum_ids[0];
 
-           for (k = 1; k < INTC_ARRAY(gr->enum_ids); k++) {
+           for (k = 1; k < ARRAY_SIZE(gr->enum_ids); k++) {
                 if (!gr->enum_ids[k])
                     continue;
 
@@ -433,11 +432,8 @@ int sh_intc_init(struct intc_desc *desc,
     desc->nr_prio_regs = nr_prio_regs;
 
     i = sizeof(struct intc_source) * nr_sources;
-    desc->sources = malloc(i);
-    if (!desc->sources)
-        return -1;
+    desc->sources = g_malloc0(i);
 
-    memset(desc->sources, 0, i);
     for (i = 0; i < desc->nr_sources; i++) {
         struct intc_source *source = desc->sources + i;
 
@@ -446,8 +442,9 @@ int sh_intc_init(struct intc_desc *desc,
 
     desc->irqs = qemu_allocate_irqs(sh_intc_set_irq, desc, nr_sources);
  
-    desc->iomemtype = cpu_register_io_memory(0, sh_intc_readfn,
-                                            sh_intc_writefn, desc);
+    desc->iomemtype = cpu_register_io_memory(sh_intc_readfn,
+                                            sh_intc_writefn, desc,
+                                             DEVICE_NATIVE_ENDIAN);
     if (desc->mask_regs) {
         for (i = 0; i < desc->nr_mask_regs; i++) {
            struct intc_mask_reg *mr = desc->mask_regs + i;
This page took 0.027413 seconds and 4 git commands to generate.