From b3793b8a9183d6019f557263bbddd647e1918394 Mon Sep 17 00:00:00 2001 From: BALATON Zoltan <balaton@eik.bme.hu> Date: Fri, 29 Oct 2021 23:02:09 +0200 Subject: hw/sh4: Coding style: Remove tabs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Yoshinori Sato <ysato@users.sourceforge.jp> Message-Id: <2d9b2c470ec022cc85a25b3e5de337b5e794f7f6.1635541329.git.balaton@eik.bme.hu> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- hw/intc/sh_intc.c | 220 +++++++++++++++++++++++++++--------------------------- 1 file changed, 110 insertions(+), 110 deletions(-) (limited to 'hw/intc/sh_intc.c') diff --git a/hw/intc/sh_intc.c b/hw/intc/sh_intc.c index 72a55e3..a269b8f 100644 --- a/hw/intc/sh_intc.c +++ b/hw/intc/sh_intc.c @@ -20,7 +20,7 @@ #define INTC_A7(x) ((x) & 0x1fffffff) void sh_intc_toggle_source(struct intc_source *source, - int enable_adj, int assert_adj) + int enable_adj, int assert_adj) { int enable_changed = 0; int pending_changed = 0; @@ -54,22 +54,22 @@ void sh_intc_toggle_source(struct intc_source *source, if (source->parent->pending == 0) { cpu_reset_interrupt(first_cpu, CPU_INTERRUPT_HARD); } - } + } } if (enable_changed || assert_adj || pending_changed) { #ifdef DEBUG_INTC_SOURCES printf("sh_intc: (%d/%d/%d/%d) interrupt source 0x%x %s%s%s\n", - source->parent->pending, - source->asserted, - source->enable_count, - source->enable_max, - source->vect, - source->asserted ? "asserted " : - assert_adj ? "deasserted" : "", - enable_changed == 1 ? "enabled " : - enable_changed == -1 ? "disabled " : "", - source->pending ? "pending" : ""); + source->parent->pending, + source->asserted, + source->enable_count, + source->enable_max, + source->vect, + source->asserted ? "asserted " : + assert_adj ? "deasserted" : "", + enable_changed == 1 ? "enabled " : + enable_changed == -1 ? "disabled " : "", + source->pending ? "pending" : ""); #endif } } @@ -99,13 +99,13 @@ int sh_intc_get_pending_vector(struct intc_desc *desc, int imask) for (i = 0; i < desc->nr_sources; i++) { struct intc_source *source = desc->sources + i; - if (source->pending) { + if (source->pending) { #ifdef DEBUG_INTC_SOURCES printf("sh_intc: (%d) returning interrupt source 0x%x\n", - desc->pending, source->vect); + desc->pending, source->vect); #endif return source->vect; - } + } } abort(); @@ -119,16 +119,16 @@ int sh_intc_get_pending_vector(struct intc_desc *desc, int imask) #define INTC_MODE_IS_PRIO 8 static unsigned int sh_intc_mode(unsigned long address, - unsigned long set_reg, unsigned long clr_reg) + unsigned long set_reg, unsigned long clr_reg) { if ((address != INTC_A7(set_reg)) && - (address != INTC_A7(clr_reg))) + (address != INTC_A7(clr_reg))) return INTC_MODE_NONE; if (set_reg && clr_reg) { if (address == INTC_A7(set_reg)) return INTC_MODE_DUAL_SET; - else + else return INTC_MODE_DUAL_CLR; } @@ -139,12 +139,12 @@ static unsigned int sh_intc_mode(unsigned long address, } static void sh_intc_locate(struct intc_desc *desc, - unsigned long address, - unsigned long **datap, - intc_enum **enums, - unsigned int *first, - unsigned int *width, - unsigned int *modep) + unsigned long address, + unsigned long **datap, + intc_enum **enums, + unsigned int *first, + unsigned int *width, + unsigned int *modep) { unsigned int i, mode; @@ -152,54 +152,54 @@ static void sh_intc_locate(struct intc_desc *desc, if (desc->mask_regs) { for (i = 0; i < desc->nr_mask_regs; i++) { - struct intc_mask_reg *mr = desc->mask_regs + i; + struct intc_mask_reg *mr = desc->mask_regs + i; - mode = sh_intc_mode(address, mr->set_reg, mr->clr_reg); - if (mode == INTC_MODE_NONE) + mode = sh_intc_mode(address, mr->set_reg, mr->clr_reg); + if (mode == INTC_MODE_NONE) continue; - *modep = mode; - *datap = &mr->value; - *enums = mr->enum_ids; - *first = mr->reg_width - 1; - *width = 1; - return; - } + *modep = mode; + *datap = &mr->value; + *enums = mr->enum_ids; + *first = mr->reg_width - 1; + *width = 1; + return; + } } if (desc->prio_regs) { for (i = 0; i < desc->nr_prio_regs; i++) { - struct intc_prio_reg *pr = desc->prio_regs + i; + struct intc_prio_reg *pr = desc->prio_regs + i; - mode = sh_intc_mode(address, pr->set_reg, pr->clr_reg); - if (mode == INTC_MODE_NONE) + mode = sh_intc_mode(address, pr->set_reg, pr->clr_reg); + if (mode == INTC_MODE_NONE) continue; - *modep = mode | INTC_MODE_IS_PRIO; - *datap = &pr->value; - *enums = pr->enum_ids; - *first = (pr->reg_width / pr->field_width) - 1; - *width = pr->field_width; - return; - } + *modep = mode | INTC_MODE_IS_PRIO; + *datap = &pr->value; + *enums = pr->enum_ids; + *first = (pr->reg_width / pr->field_width) - 1; + *width = pr->field_width; + return; + } } abort(); } static void sh_intc_toggle_mask(struct intc_desc *desc, intc_enum id, - int enable, int is_group) + int enable, int is_group) { struct intc_source *source = desc->sources + id; if (!id) - return; + return; if (!source->next_enum_id && (!source->enable_max || !source->vect)) { #ifdef DEBUG_INTC_SOURCES printf("sh_intc: reserved interrupt source %d modified\n", id); #endif - return; + return; } if (source->vect) @@ -237,7 +237,7 @@ static uint64_t sh_intc_read(void *opaque, hwaddr offset, #endif sh_intc_locate(desc, (unsigned long)offset, &valuep, - &enum_ids, &first, &width, &mode); + &enum_ids, &first, &width, &mode); return *valuep; } @@ -258,7 +258,7 @@ static void sh_intc_write(void *opaque, hwaddr offset, #endif sh_intc_locate(desc, (unsigned long)offset, &valuep, - &enum_ids, &first, &width, &mode); + &enum_ids, &first, &width, &mode); switch (mode) { case INTC_MODE_ENABLE_REG | INTC_MODE_IS_PRIO: break; @@ -270,11 +270,11 @@ static void sh_intc_write(void *opaque, hwaddr offset, for (k = 0; k <= first; k++) { mask = ((1 << width) - 1) << ((first - k) * width); - if ((*valuep & mask) == (value & mask)) + if ((*valuep & mask) == (value & mask)) continue; #if 0 - printf("k = %d, first = %d, enum = %d, mask = 0x%08x\n", - k, first, enum_ids[k], (unsigned int)mask); + printf("k = %d, first = %d, enum = %d, mask = 0x%08x\n", + k, first, enum_ids[k], (unsigned int)mask); #endif sh_intc_toggle_mask(desc, enum_ids[k], value & mask, 0); } @@ -301,11 +301,11 @@ struct intc_source *sh_intc_source(struct intc_desc *desc, intc_enum id) } static unsigned int sh_intc_register(MemoryRegion *sysmem, - struct intc_desc *desc, - const unsigned long address, - const char *type, - const char *action, - const unsigned int index) + struct intc_desc *desc, + const unsigned long address, + const char *type, + const char *action, + const unsigned int index) { char name[60]; MemoryRegion *iomem, *iomem_p4, *iomem_a7; @@ -333,74 +333,74 @@ static unsigned int sh_intc_register(MemoryRegion *sysmem, } static void sh_intc_register_source(struct intc_desc *desc, - intc_enum source, - struct intc_group *groups, - int nr_groups) + intc_enum source, + struct intc_group *groups, + int nr_groups) { unsigned int i, k; struct intc_source *s; if (desc->mask_regs) { for (i = 0; i < desc->nr_mask_regs; i++) { - struct intc_mask_reg *mr = desc->mask_regs + i; + struct intc_mask_reg *mr = desc->mask_regs + i; - for (k = 0; k < ARRAY_SIZE(mr->enum_ids); k++) { + for (k = 0; k < ARRAY_SIZE(mr->enum_ids); k++) { if (mr->enum_ids[k] != source) continue; - s = sh_intc_source(desc, mr->enum_ids[k]); - if (s) + s = sh_intc_source(desc, mr->enum_ids[k]); + if (s) s->enable_max++; - } - } + } + } } if (desc->prio_regs) { for (i = 0; i < desc->nr_prio_regs; i++) { - struct intc_prio_reg *pr = desc->prio_regs + i; + struct intc_prio_reg *pr = desc->prio_regs + i; - for (k = 0; k < ARRAY_SIZE(pr->enum_ids); k++) { + for (k = 0; k < ARRAY_SIZE(pr->enum_ids); k++) { if (pr->enum_ids[k] != source) continue; - s = sh_intc_source(desc, pr->enum_ids[k]); - if (s) + s = sh_intc_source(desc, pr->enum_ids[k]); + if (s) s->enable_max++; - } - } + } + } } if (groups) { for (i = 0; i < nr_groups; i++) { - struct intc_group *gr = groups + i; + struct intc_group *gr = groups + i; - for (k = 0; k < ARRAY_SIZE(gr->enum_ids); k++) { + for (k = 0; k < ARRAY_SIZE(gr->enum_ids); k++) { if (gr->enum_ids[k] != source) continue; - s = sh_intc_source(desc, gr->enum_ids[k]); - if (s) + s = sh_intc_source(desc, gr->enum_ids[k]); + if (s) s->enable_max++; - } - } + } + } } } void sh_intc_register_sources(struct intc_desc *desc, - struct intc_vect *vectors, - int nr_vectors, - struct intc_group *groups, - int nr_groups) + struct intc_vect *vectors, + int nr_vectors, + struct intc_group *groups, + int nr_groups) { unsigned int i, k; struct intc_source *s; for (i = 0; i < nr_vectors; i++) { - struct intc_vect *vect = vectors + i; + struct intc_vect *vect = vectors + i; - sh_intc_register_source(desc, vect->enum_id, groups, nr_groups); - s = sh_intc_source(desc, vect->enum_id); + 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; @@ -413,34 +413,34 @@ void sh_intc_register_sources(struct intc_desc *desc, if (groups) { for (i = 0; i < nr_groups; i++) { - struct intc_group *gr = groups + i; + struct intc_group *gr = groups + i; - s = sh_intc_source(desc, gr->enum_id); - s->next_enum_id = gr->enum_ids[0]; + s = sh_intc_source(desc, gr->enum_id); + s->next_enum_id = gr->enum_ids[0]; - for (k = 1; k < ARRAY_SIZE(gr->enum_ids); k++) { + for (k = 1; k < ARRAY_SIZE(gr->enum_ids); k++) { if (!gr->enum_ids[k]) continue; - s = sh_intc_source(desc, gr->enum_ids[k - 1]); - s->next_enum_id = gr->enum_ids[k]; - } + s = sh_intc_source(desc, gr->enum_ids[k - 1]); + s->next_enum_id = gr->enum_ids[k]; + } #ifdef DEBUG_INTC_SOURCES - printf("sh_intc: registered group %d (%d/%d)\n", - gr->enum_id, s->enable_count, s->enable_max); + printf("sh_intc: registered group %d (%d/%d)\n", + gr->enum_id, s->enable_count, s->enable_max); #endif - } + } } } int sh_intc_init(MemoryRegion *sysmem, - struct intc_desc *desc, - int nr_sources, - struct intc_mask_reg *mask_regs, - int nr_mask_regs, - struct intc_prio_reg *prio_regs, - int nr_prio_regs) + struct intc_desc *desc, + int nr_sources, + struct intc_mask_reg *mask_regs, + int nr_mask_regs, + struct intc_prio_reg *prio_regs, + int nr_prio_regs) { unsigned int i, j; @@ -474,24 +474,24 @@ int sh_intc_init(MemoryRegion *sysmem, reg_struct->action##_reg, #type, #action, j if (desc->mask_regs) { for (i = 0; i < desc->nr_mask_regs; i++) { - struct intc_mask_reg *mr = desc->mask_regs + i; + struct intc_mask_reg *mr = desc->mask_regs + i; j += sh_intc_register(sysmem, desc, INT_REG_PARAMS(mr, mask, set, j)); j += sh_intc_register(sysmem, desc, INT_REG_PARAMS(mr, mask, clr, j)); - } + } } if (desc->prio_regs) { for (i = 0; i < desc->nr_prio_regs; i++) { - struct intc_prio_reg *pr = desc->prio_regs + i; + struct intc_prio_reg *pr = desc->prio_regs + i; j += sh_intc_register(sysmem, desc, INT_REG_PARAMS(pr, prio, set, j)); j += sh_intc_register(sysmem, desc, INT_REG_PARAMS(pr, prio, clr, j)); - } + } } #undef INT_REG_PARAMS @@ -505,10 +505,10 @@ void sh_intc_set_irl(void *opaque, int n, int level) struct intc_source *s = opaque; int i, irl = level ^ 15; for (i = 0; (s = sh_intc_source(s->parent, s->next_enum_id)); i++) { - if (i == irl) - sh_intc_toggle_source(s, s->enable_count?0:1, s->asserted?0:1); - else - if (s->asserted) - sh_intc_toggle_source(s, 0, -1); + if (i == irl) + sh_intc_toggle_source(s, s->enable_count?0:1, s->asserted?0:1); + else + if (s->asserted) + sh_intc_toggle_source(s, 0, -1); } } -- cgit v1.1 From 221389657aa77ced7a17936747f288193e321d3f Mon Sep 17 00:00:00 2001 From: BALATON Zoltan <balaton@eik.bme.hu> Date: Fri, 29 Oct 2021 23:02:09 +0200 Subject: hw/sh4: Coding style: Fix multi-line comments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Yoshinori Sato <ysato@users.sourceforge.jp> Message-Id: <3f192c699f4e5949ec0fcc436e5610f50afe2dbf.1635541329.git.balaton@eik.bme.hu> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- hw/intc/sh_intc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'hw/intc/sh_intc.c') diff --git a/hw/intc/sh_intc.c b/hw/intc/sh_intc.c index a269b8f..84eec7d 100644 --- a/hw/intc/sh_intc.c +++ b/hw/intc/sh_intc.c @@ -450,8 +450,7 @@ int sh_intc_init(MemoryRegion *sysmem, desc->nr_mask_regs = nr_mask_regs; desc->prio_regs = prio_regs; desc->nr_prio_regs = nr_prio_regs; - /* Allocate 4 MemoryRegions per register (2 actions * 2 aliases). - **/ + /* Allocate 4 MemoryRegions per register (2 actions * 2 aliases) */ desc->iomem_aliases = g_new0(MemoryRegion, (nr_mask_regs + nr_prio_regs) * 4); @@ -498,8 +497,10 @@ int sh_intc_init(MemoryRegion *sysmem, return 0; } -/* Assert level <n> IRL interrupt. - 0:deassert. 1:lowest priority,... 15:highest priority. */ +/* + * Assert level <n> IRL interrupt. + * 0:deassert. 1:lowest priority,... 15:highest priority + */ void sh_intc_set_irl(void *opaque, int n, int level) { struct intc_source *s = opaque; -- cgit v1.1 From f94bff1337ff525e2ff458b8e4cd57f9561acde3 Mon Sep 17 00:00:00 2001 From: BALATON Zoltan <balaton@eik.bme.hu> Date: Fri, 29 Oct 2021 23:02:09 +0200 Subject: hw/sh4: Coding style: White space fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Yoshinori Sato <ysato@users.sourceforge.jp> Message-Id: <91698c54fa493a4cfe93546211206439787d4b78.1635541329.git.balaton@eik.bme.hu> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- hw/intc/sh_intc.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) (limited to 'hw/intc/sh_intc.c') diff --git a/hw/intc/sh_intc.c b/hw/intc/sh_intc.c index 84eec7d..6700508 100644 --- a/hw/intc/sh_intc.c +++ b/hw/intc/sh_intc.c @@ -71,18 +71,18 @@ void sh_intc_toggle_source(struct intc_source *source, enable_changed == -1 ? "disabled " : "", source->pending ? "pending" : ""); #endif - } + } } -static void sh_intc_set_irq (void *opaque, int n, int level) +static void sh_intc_set_irq(void *opaque, int n, int level) { - struct intc_desc *desc = opaque; - struct intc_source *source = &(desc->sources[n]); + struct intc_desc *desc = opaque; + struct intc_source *source = &(desc->sources[n]); - if (level && !source->asserted) - sh_intc_toggle_source(source, 0, 1); - else if (!level && source->asserted) - sh_intc_toggle_source(source, 0, -1); + if (level && !source->asserted) + sh_intc_toggle_source(source, 0, 1); + else if (!level && source->asserted) + sh_intc_toggle_source(source, 0, -1); } int sh_intc_get_pending_vector(struct intc_desc *desc, int imask) @@ -236,7 +236,7 @@ static uint64_t sh_intc_read(void *opaque, hwaddr offset, printf("sh_intc_read 0x%lx\n", (unsigned long) offset); #endif - sh_intc_locate(desc, (unsigned long)offset, &valuep, + sh_intc_locate(desc, (unsigned long)offset, &valuep, &enum_ids, &first, &width, &mode); return *valuep; } @@ -257,14 +257,20 @@ static void sh_intc_write(void *opaque, hwaddr offset, printf("sh_intc_write 0x%lx 0x%08x\n", (unsigned long) offset, value); #endif - sh_intc_locate(desc, (unsigned long)offset, &valuep, + sh_intc_locate(desc, (unsigned long)offset, &valuep, &enum_ids, &first, &width, &mode); switch (mode) { - 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: abort(); + 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: + abort(); } for (k = 0; k <= first; k++) { @@ -465,7 +471,7 @@ int sh_intc_init(MemoryRegion *sysmem, } desc->irqs = qemu_allocate_irqs(sh_intc_set_irq, desc, nr_sources); - + memory_region_init_io(&desc->iomem, NULL, &sh_intc_ops, desc, "interrupt-controller", 0x100000000ULL); @@ -507,7 +513,8 @@ void sh_intc_set_irl(void *opaque, int n, int level) int i, irl = level ^ 15; for (i = 0; (s = sh_intc_source(s->parent, s->next_enum_id)); i++) { if (i == irl) - sh_intc_toggle_source(s, s->enable_count?0:1, s->asserted?0:1); + sh_intc_toggle_source(s, s->enable_count ? 0 : 1, + s->asserted ? 0 : 1); else if (s->asserted) sh_intc_toggle_source(s, 0, -1); -- cgit v1.1 From ac3c9e74c1ee1071e5be692a611c5ee261b9b581 Mon Sep 17 00:00:00 2001 From: BALATON Zoltan <balaton@eik.bme.hu> Date: Fri, 29 Oct 2021 23:02:09 +0200 Subject: hw/sh4: Coding style: Add missing braces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Yoshinori Sato <ysato@users.sourceforge.jp> Message-Id: <b53a8cbcf57207fbd6408db1007b3e82008d60f7.1635541329.git.balaton@eik.bme.hu> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- hw/intc/sh_intc.c | 87 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 47 insertions(+), 40 deletions(-) (limited to 'hw/intc/sh_intc.c') diff --git a/hw/intc/sh_intc.c b/hw/intc/sh_intc.c index 6700508..eddad7c 100644 --- a/hw/intc/sh_intc.c +++ b/hw/intc/sh_intc.c @@ -26,23 +26,23 @@ void sh_intc_toggle_source(struct intc_source *source, int pending_changed = 0; int old_pending; - if ((source->enable_count == source->enable_max) && (enable_adj == -1)) + if ((source->enable_count == source->enable_max) && (enable_adj == -1)) { enable_changed = -1; - + } source->enable_count += enable_adj; - if (source->enable_count == source->enable_max) + if (source->enable_count == source->enable_max) { enable_changed = 1; - + } source->asserted += assert_adj; old_pending = source->pending; source->pending = source->asserted && (source->enable_count == source->enable_max); - if (old_pending != source->pending) + if (old_pending != source->pending) { pending_changed = 1; - + } if (pending_changed) { if (source->pending) { source->parent->pending++; @@ -79,10 +79,11 @@ static void sh_intc_set_irq(void *opaque, int n, int level) struct intc_desc *desc = opaque; struct intc_source *source = &(desc->sources[n]); - if (level && !source->asserted) - sh_intc_toggle_source(source, 0, 1); - else if (!level && source->asserted) - sh_intc_toggle_source(source, 0, -1); + if (level && !source->asserted) { + sh_intc_toggle_source(source, 0, 1); + } else if (!level && source->asserted) { + sh_intc_toggle_source(source, 0, -1); + } } int sh_intc_get_pending_vector(struct intc_desc *desc, int imask) @@ -126,16 +127,18 @@ static unsigned int sh_intc_mode(unsigned long address, return INTC_MODE_NONE; if (set_reg && clr_reg) { - if (address == INTC_A7(set_reg)) + if (address == INTC_A7(set_reg)) { return INTC_MODE_DUAL_SET; - else + } else { return INTC_MODE_DUAL_CLR; + } } - if (set_reg) + if (set_reg) { return INTC_MODE_ENABLE_REG; - else + } else { return INTC_MODE_MASK_REG; + } } static void sh_intc_locate(struct intc_desc *desc, @@ -155,9 +158,9 @@ static void sh_intc_locate(struct intc_desc *desc, struct intc_mask_reg *mr = desc->mask_regs + i; mode = sh_intc_mode(address, mr->set_reg, mr->clr_reg); - if (mode == INTC_MODE_NONE) + if (mode == INTC_MODE_NONE) { continue; - + } *modep = mode; *datap = &mr->value; *enums = mr->enum_ids; @@ -172,9 +175,9 @@ static void sh_intc_locate(struct intc_desc *desc, struct intc_prio_reg *pr = desc->prio_regs + i; mode = sh_intc_mode(address, pr->set_reg, pr->clr_reg); - if (mode == INTC_MODE_NONE) + if (mode == INTC_MODE_NONE) { continue; - + } *modep = mode | INTC_MODE_IS_PRIO; *datap = &pr->value; *enums = pr->enum_ids; @@ -192,9 +195,9 @@ static void sh_intc_toggle_mask(struct intc_desc *desc, intc_enum id, { struct intc_source *source = desc->sources + id; - if (!id) + if (!id) { return; - + } if (!source->next_enum_id && (!source->enable_max || !source->vect)) { #ifdef DEBUG_INTC_SOURCES printf("sh_intc: reserved interrupt source %d modified\n", id); @@ -202,9 +205,9 @@ static void sh_intc_toggle_mask(struct intc_desc *desc, intc_enum id, return; } - if (source->vect) + if (source->vect) { sh_intc_toggle_source(source, enable ? 1 : -1, 0); - + } #ifdef DEBUG_INTC else { printf("setting interrupt group %d to %d\n", id, !!enable); @@ -276,8 +279,9 @@ static void sh_intc_write(void *opaque, hwaddr offset, for (k = 0; k <= first; k++) { mask = ((1 << width) - 1) << ((first - k) * width); - if ((*valuep & mask) == (value & mask)) + if ((*valuep & mask) == (value & mask)) { continue; + } #if 0 printf("k = %d, first = %d, enum = %d, mask = 0x%08x\n", k, first, enum_ids[k], (unsigned int)mask); @@ -300,9 +304,9 @@ static const MemoryRegionOps sh_intc_ops = { struct intc_source *sh_intc_source(struct intc_desc *desc, intc_enum id) { - if (id) + if (id) { return desc->sources + id; - + } return NULL; } @@ -351,12 +355,13 @@ static void sh_intc_register_source(struct intc_desc *desc, struct intc_mask_reg *mr = desc->mask_regs + i; for (k = 0; k < ARRAY_SIZE(mr->enum_ids); k++) { - if (mr->enum_ids[k] != source) + if (mr->enum_ids[k] != source) { continue; - + } s = sh_intc_source(desc, mr->enum_ids[k]); - if (s) + if (s) { s->enable_max++; + } } } } @@ -366,12 +371,13 @@ static void sh_intc_register_source(struct intc_desc *desc, struct intc_prio_reg *pr = desc->prio_regs + i; for (k = 0; k < ARRAY_SIZE(pr->enum_ids); k++) { - if (pr->enum_ids[k] != source) + if (pr->enum_ids[k] != source) { continue; - + } s = sh_intc_source(desc, pr->enum_ids[k]); - if (s) + if (s) { s->enable_max++; + } } } } @@ -381,12 +387,13 @@ static void sh_intc_register_source(struct intc_desc *desc, struct intc_group *gr = groups + i; for (k = 0; k < ARRAY_SIZE(gr->enum_ids); k++) { - if (gr->enum_ids[k] != source) + if (gr->enum_ids[k] != source) { continue; - + } s = sh_intc_source(desc, gr->enum_ids[k]); - if (s) + if (s) { s->enable_max++; + } } } } @@ -425,9 +432,9 @@ void sh_intc_register_sources(struct intc_desc *desc, s->next_enum_id = gr->enum_ids[0]; for (k = 1; k < ARRAY_SIZE(gr->enum_ids); k++) { - if (!gr->enum_ids[k]) + if (!gr->enum_ids[k]) { continue; - + } s = sh_intc_source(desc, gr->enum_ids[k - 1]); s->next_enum_id = gr->enum_ids[k]; } @@ -512,11 +519,11 @@ void sh_intc_set_irl(void *opaque, int n, int level) struct intc_source *s = opaque; int i, irl = level ^ 15; for (i = 0; (s = sh_intc_source(s->parent, s->next_enum_id)); i++) { - if (i == irl) + if (i == irl) { sh_intc_toggle_source(s, s->enable_count ? 0 : 1, s->asserted ? 0 : 1); - else - if (s->asserted) - sh_intc_toggle_source(s, 0, -1); + } else if (s->asserted) { + sh_intc_toggle_source(s, 0, -1); + } } } -- cgit v1.1 From ad52cfc13750662fd003565e8035bb8ffbd4f0ef Mon Sep 17 00:00:00 2001 From: BALATON Zoltan <balaton@eik.bme.hu> Date: Fri, 29 Oct 2021 23:02:09 +0200 Subject: hw/sh4: Change debug printfs to traces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <b776043e811ab3caf200515e1350bdcccd1cc47b.1635541329.git.balaton@eik.bme.hu> [PMD: Fixed format strings for 32-bit hosts] Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- hw/intc/sh_intc.c | 79 ++++++++++++++----------------------------------------- 1 file changed, 20 insertions(+), 59 deletions(-) (limited to 'hw/intc/sh_intc.c') diff --git a/hw/intc/sh_intc.c b/hw/intc/sh_intc.c index eddad7c..673606b 100644 --- a/hw/intc/sh_intc.c +++ b/hw/intc/sh_intc.c @@ -9,13 +9,12 @@ */ #include "qemu/osdep.h" +#include "qemu/log.h" #include "cpu.h" #include "hw/sh4/sh_intc.h" #include "hw/irq.h" #include "hw/sh4/sh.h" - -//#define DEBUG_INTC -//#define DEBUG_INTC_SOURCES +#include "trace.h" #define INTC_A7(x) ((x) & 0x1fffffff) @@ -57,20 +56,14 @@ void sh_intc_toggle_source(struct intc_source *source, } } - if (enable_changed || assert_adj || pending_changed) { -#ifdef DEBUG_INTC_SOURCES - printf("sh_intc: (%d/%d/%d/%d) interrupt source 0x%x %s%s%s\n", - source->parent->pending, - source->asserted, - source->enable_count, - source->enable_max, - source->vect, - source->asserted ? "asserted " : - assert_adj ? "deasserted" : "", - enable_changed == 1 ? "enabled " : - enable_changed == -1 ? "disabled " : "", - source->pending ? "pending" : ""); -#endif + if (enable_changed || assert_adj || pending_changed) { + trace_sh_intc_sources(source->parent->pending, source->asserted, + source->enable_count, source->enable_max, + source->vect, source->asserted ? "asserted " : + assert_adj ? "deasserted" : "", + enable_changed == 1 ? "enabled " : + enable_changed == -1 ? "disabled " : "", + source->pending ? "pending" : ""); } } @@ -101,10 +94,7 @@ int sh_intc_get_pending_vector(struct intc_desc *desc, int imask) struct intc_source *source = desc->sources + i; if (source->pending) { -#ifdef DEBUG_INTC_SOURCES - printf("sh_intc: (%d) returning interrupt source 0x%x\n", - desc->pending, source->vect); -#endif + trace_sh_intc_pending(desc->pending, source->vect); return source->vect; } } @@ -199,30 +189,22 @@ static void sh_intc_toggle_mask(struct intc_desc *desc, intc_enum id, return; } if (!source->next_enum_id && (!source->enable_max || !source->vect)) { -#ifdef DEBUG_INTC_SOURCES - printf("sh_intc: reserved interrupt source %d modified\n", id); -#endif + qemu_log_mask(LOG_UNIMP, + "sh_intc: reserved interrupt source %d modified\n", id); return; } if (source->vect) { sh_intc_toggle_source(source, enable ? 1 : -1, 0); } -#ifdef DEBUG_INTC - else { - printf("setting interrupt group %d to %d\n", id, !!enable); - } -#endif if ((is_group || !source->vect) && source->next_enum_id) { sh_intc_toggle_mask(desc, source->next_enum_id, enable, 1); } -#ifdef DEBUG_INTC if (!source->vect) { - printf("setting interrupt group %d to %d - done\n", id, !!enable); + trace_sh_intc_set(id, !!enable); } -#endif } static uint64_t sh_intc_read(void *opaque, hwaddr offset, @@ -235,12 +217,9 @@ static uint64_t sh_intc_read(void *opaque, hwaddr offset, unsigned int mode = 0; unsigned long *valuep; -#ifdef DEBUG_INTC - printf("sh_intc_read 0x%lx\n", (unsigned long) offset); -#endif - sh_intc_locate(desc, (unsigned long)offset, &valuep, &enum_ids, &first, &width, &mode); + trace_sh_intc_read(size, (uint64_t)offset, *valuep); return *valuep; } @@ -256,13 +235,9 @@ static void sh_intc_write(void *opaque, hwaddr offset, unsigned long *valuep; unsigned long mask; -#ifdef DEBUG_INTC - printf("sh_intc_write 0x%lx 0x%08x\n", (unsigned long) offset, value); -#endif - + trace_sh_intc_write(size, (uint64_t)offset, value); sh_intc_locate(desc, (unsigned long)offset, &valuep, &enum_ids, &first, &width, &mode); - switch (mode) { case INTC_MODE_ENABLE_REG | INTC_MODE_IS_PRIO: break; @@ -282,18 +257,10 @@ static void sh_intc_write(void *opaque, hwaddr offset, if ((*valuep & mask) == (value & mask)) { continue; } -#if 0 - printf("k = %d, first = %d, enum = %d, mask = 0x%08x\n", - k, first, enum_ids[k], (unsigned int)mask); -#endif sh_intc_toggle_mask(desc, enum_ids[k], value & mask, 0); } *valuep = value; - -#ifdef DEBUG_INTC - printf("sh_intc_write 0x%lx -> 0x%08x\n", (unsigned long) offset, value); -#endif } static const MemoryRegionOps sh_intc_ops = { @@ -416,11 +383,8 @@ void sh_intc_register_sources(struct intc_desc *desc, s = sh_intc_source(desc, vect->enum_id); 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); -#endif + trace_sh_intc_register("source", vect->enum_id, s->vect, + s->enable_count, s->enable_max); } } @@ -438,11 +402,8 @@ void sh_intc_register_sources(struct intc_desc *desc, s = sh_intc_source(desc, gr->enum_ids[k - 1]); s->next_enum_id = gr->enum_ids[k]; } - -#ifdef DEBUG_INTC_SOURCES - printf("sh_intc: registered group %d (%d/%d)\n", - gr->enum_id, s->enable_count, s->enable_max); -#endif + trace_sh_intc_register("group", gr->enum_id, 0xffff, + s->enable_count, s->enable_max); } } } -- cgit v1.1 From cfaf2806e87b0eb962866e041a0fd75a524394d8 Mon Sep 17 00:00:00 2001 From: BALATON Zoltan <balaton@eik.bme.hu> Date: Fri, 29 Oct 2021 23:02:09 +0200 Subject: hw/intc/sh_intc: Use existing macro instead of local one MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The INTC_A7 local macro does the same as the A7ADDR from include/sh/sh.h so use the latter and drop the local macro definition. Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <53f033477c73b7c9b021d36033c590416d6199c7.1635541329.git.balaton@eik.bme.hu> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- hw/intc/sh_intc.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'hw/intc/sh_intc.c') diff --git a/hw/intc/sh_intc.c b/hw/intc/sh_intc.c index 673606b..a98953d 100644 --- a/hw/intc/sh_intc.c +++ b/hw/intc/sh_intc.c @@ -16,8 +16,6 @@ #include "hw/sh4/sh.h" #include "trace.h" -#define INTC_A7(x) ((x) & 0x1fffffff) - void sh_intc_toggle_source(struct intc_source *source, int enable_adj, int assert_adj) { @@ -112,12 +110,12 @@ int sh_intc_get_pending_vector(struct intc_desc *desc, int imask) static unsigned int sh_intc_mode(unsigned long address, unsigned long set_reg, unsigned long clr_reg) { - if ((address != INTC_A7(set_reg)) && - (address != INTC_A7(clr_reg))) + if ((address != A7ADDR(set_reg)) && + (address != A7ADDR(clr_reg))) return INTC_MODE_NONE; if (set_reg && clr_reg) { - if (address == INTC_A7(set_reg)) { + if (address == A7ADDR(set_reg)) { return INTC_MODE_DUAL_SET; } else { return INTC_MODE_DUAL_CLR; @@ -297,11 +295,11 @@ static unsigned int sh_intc_register(MemoryRegion *sysmem, #define SH_INTC_IOMEM_FORMAT "interrupt-controller-%s-%s-%s" snprintf(name, sizeof(name), SH_INTC_IOMEM_FORMAT, type, action, "p4"); - memory_region_init_alias(iomem_p4, NULL, name, iomem, INTC_A7(address), 4); + memory_region_init_alias(iomem_p4, NULL, name, iomem, A7ADDR(address), 4); memory_region_add_subregion(sysmem, P4ADDR(address), iomem_p4); snprintf(name, sizeof(name), SH_INTC_IOMEM_FORMAT, type, action, "a7"); - memory_region_init_alias(iomem_a7, NULL, name, iomem, INTC_A7(address), 4); + memory_region_init_alias(iomem_a7, NULL, name, iomem, A7ADDR(address), 4); memory_region_add_subregion(sysmem, A7ADDR(address), iomem_a7); #undef SH_INTC_IOMEM_FORMAT -- cgit v1.1 From dc6f1734b704e5563e4c512393e2629799093681 Mon Sep 17 00:00:00 2001 From: BALATON Zoltan <balaton@eik.bme.hu> Date: Fri, 29 Oct 2021 23:02:09 +0200 Subject: hw/intc/sh_intc: Turn some defines into an enum MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Turn the INTC_MODE defines into an enum and clean up the function returning these to make it clearer by removing nested ifs and superfluous parenthesis. The one remaining #define is a flag which is moved further apart by changing its value from 8 to 0x80 to leave some spare bits as this is or-ed with the enum value at some places. Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu> Message-Id: <4adf4e1ac9d2e728e5a536c69e310d77f0c4455a.1635541329.git.balaton@eik.bme.hu> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- hw/intc/sh_intc.c | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-) (limited to 'hw/intc/sh_intc.c') diff --git a/hw/intc/sh_intc.c b/hw/intc/sh_intc.c index a98953d..f0ef831 100644 --- a/hw/intc/sh_intc.c +++ b/hw/intc/sh_intc.c @@ -100,33 +100,26 @@ int sh_intc_get_pending_vector(struct intc_desc *desc, int imask) abort(); } -#define INTC_MODE_NONE 0 -#define INTC_MODE_DUAL_SET 1 -#define INTC_MODE_DUAL_CLR 2 -#define INTC_MODE_ENABLE_REG 3 -#define INTC_MODE_MASK_REG 4 -#define INTC_MODE_IS_PRIO 8 - -static unsigned int sh_intc_mode(unsigned long address, - unsigned long set_reg, unsigned long clr_reg) +typedef enum { + INTC_MODE_NONE, + INTC_MODE_DUAL_SET, + INTC_MODE_DUAL_CLR, + INTC_MODE_ENABLE_REG, + INTC_MODE_MASK_REG, +} SHIntCMode; +#define INTC_MODE_IS_PRIO 0x80 + +static SHIntCMode sh_intc_mode(unsigned long address, unsigned long set_reg, + unsigned long clr_reg) { - if ((address != A7ADDR(set_reg)) && - (address != A7ADDR(clr_reg))) + if (address != A7ADDR(set_reg) && address != A7ADDR(clr_reg)) { return INTC_MODE_NONE; - - if (set_reg && clr_reg) { - if (address == A7ADDR(set_reg)) { - return INTC_MODE_DUAL_SET; - } else { - return INTC_MODE_DUAL_CLR; - } } - - if (set_reg) { - return INTC_MODE_ENABLE_REG; - } else { - return INTC_MODE_MASK_REG; + if (set_reg && clr_reg) { + return address == A7ADDR(set_reg) ? + INTC_MODE_DUAL_SET : INTC_MODE_DUAL_CLR; } + return set_reg ? INTC_MODE_ENABLE_REG : INTC_MODE_MASK_REG; } static void sh_intc_locate(struct intc_desc *desc, @@ -137,7 +130,8 @@ static void sh_intc_locate(struct intc_desc *desc, unsigned int *width, unsigned int *modep) { - unsigned int i, mode; + SHIntCMode mode; + unsigned int i; /* this is slow but works for now */ -- cgit v1.1 From 81d18cd48a87205bed159586fd3ca524a36bd49a Mon Sep 17 00:00:00 2001 From: BALATON Zoltan <balaton@eik.bme.hu> Date: Fri, 29 Oct 2021 23:02:09 +0200 Subject: hw/intc/sh_intc: Rename iomem region MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rename the iomem region to "intc" from "interrupt-controller" which makes the info mtree output less wide as it is already too wide because of all the aliases. Also drop the format macro which was only used twice in close proximity so we can just use the literal string instead without a macro definition. Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-Id: <cb6402dab6b44c804142b5cf9af68e6398cb613f.1635541329.git.balaton@eik.bme.hu> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- hw/intc/sh_intc.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'hw/intc/sh_intc.c') diff --git a/hw/intc/sh_intc.c b/hw/intc/sh_intc.c index f0ef831..175d12b 100644 --- a/hw/intc/sh_intc.c +++ b/hw/intc/sh_intc.c @@ -287,15 +287,13 @@ static unsigned int sh_intc_register(MemoryRegion *sysmem, iomem_p4 = desc->iomem_aliases + index; iomem_a7 = iomem_p4 + 1; -#define SH_INTC_IOMEM_FORMAT "interrupt-controller-%s-%s-%s" - snprintf(name, sizeof(name), SH_INTC_IOMEM_FORMAT, type, action, "p4"); + snprintf(name, sizeof(name), "intc-%s-%s-%s", type, action, "p4"); memory_region_init_alias(iomem_p4, NULL, name, iomem, A7ADDR(address), 4); memory_region_add_subregion(sysmem, P4ADDR(address), iomem_p4); - snprintf(name, sizeof(name), SH_INTC_IOMEM_FORMAT, type, action, "a7"); + snprintf(name, sizeof(name), "intc-%s-%s-%s", type, action, "a7"); memory_region_init_alias(iomem_a7, NULL, name, iomem, A7ADDR(address), 4); memory_region_add_subregion(sysmem, A7ADDR(address), iomem_a7); -#undef SH_INTC_IOMEM_FORMAT /* used to increment aliases index */ return 2; @@ -431,9 +429,8 @@ int sh_intc_init(MemoryRegion *sysmem, } desc->irqs = qemu_allocate_irqs(sh_intc_set_irq, desc, nr_sources); - - memory_region_init_io(&desc->iomem, NULL, &sh_intc_ops, desc, - "interrupt-controller", 0x100000000ULL); + memory_region_init_io(&desc->iomem, NULL, &sh_intc_ops, desc, "intc", + 0x100000000ULL); #define INT_REG_PARAMS(reg_struct, type, action, j) \ reg_struct->action##_reg, #type, #action, j -- cgit v1.1 From 92d1d3ada11dfb338bb96b6405d6938901182488 Mon Sep 17 00:00:00 2001 From: BALATON Zoltan <balaton@eik.bme.hu> Date: Fri, 29 Oct 2021 23:02:09 +0200 Subject: hw/intc/sh_intc: Drop another useless macro MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The INT_REG_PARAMS macro was only used a few times within one function on adjacent lines and is actually more complex than writing out the parameters so simplify it by expanding the macro at call sites and dropping the #define. Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <d3bdfdc5ab5ae1c51a6c6c38bde3829a99f85ce5.1635541329.git.balaton@eik.bme.hu> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- hw/intc/sh_intc.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'hw/intc/sh_intc.c') diff --git a/hw/intc/sh_intc.c b/hw/intc/sh_intc.c index 175d12b..b908be0 100644 --- a/hw/intc/sh_intc.c +++ b/hw/intc/sh_intc.c @@ -432,16 +432,12 @@ int sh_intc_init(MemoryRegion *sysmem, memory_region_init_io(&desc->iomem, NULL, &sh_intc_ops, desc, "intc", 0x100000000ULL); -#define INT_REG_PARAMS(reg_struct, type, action, j) \ - reg_struct->action##_reg, #type, #action, j if (desc->mask_regs) { for (i = 0; i < desc->nr_mask_regs; i++) { struct intc_mask_reg *mr = desc->mask_regs + i; - j += sh_intc_register(sysmem, desc, - INT_REG_PARAMS(mr, mask, set, j)); - j += sh_intc_register(sysmem, desc, - INT_REG_PARAMS(mr, mask, clr, j)); + j += sh_intc_register(sysmem, desc, mr->set_reg, "mask", "set", j); + j += sh_intc_register(sysmem, desc, mr->clr_reg, "mask", "clr", j); } } @@ -449,13 +445,10 @@ int sh_intc_init(MemoryRegion *sysmem, for (i = 0; i < desc->nr_prio_regs; i++) { struct intc_prio_reg *pr = desc->prio_regs + i; - j += sh_intc_register(sysmem, desc, - INT_REG_PARAMS(pr, prio, set, j)); - j += sh_intc_register(sysmem, desc, - INT_REG_PARAMS(pr, prio, clr, j)); + j += sh_intc_register(sysmem, desc, pr->set_reg, "prio", "set", j); + j += sh_intc_register(sysmem, desc, pr->clr_reg, "prio", "clr", j); } } -#undef INT_REG_PARAMS return 0; } -- cgit v1.1 From 51cb902baca1ccfba270fa5a1f230d85301a68e6 Mon Sep 17 00:00:00 2001 From: BALATON Zoltan <balaton@eik.bme.hu> Date: Fri, 29 Oct 2021 23:02:09 +0200 Subject: hw/intc/sh_intc: Move sh_intc_register() closer to its only user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The sh_intc_register() function is only used at one place. Move them together so it's easier to see what's going on. Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-Id: <49f2742bc67cba7164385fafad204ab1e1bd3a0b.1635541329.git.balaton@eik.bme.hu> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- hw/intc/sh_intc.c | 60 +++++++++++++++++++++++++++---------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) (limited to 'hw/intc/sh_intc.c') diff --git a/hw/intc/sh_intc.c b/hw/intc/sh_intc.c index b908be0..1a2824f 100644 --- a/hw/intc/sh_intc.c +++ b/hw/intc/sh_intc.c @@ -269,36 +269,6 @@ struct intc_source *sh_intc_source(struct intc_desc *desc, intc_enum id) return NULL; } -static unsigned int sh_intc_register(MemoryRegion *sysmem, - struct intc_desc *desc, - const unsigned long address, - const char *type, - const char *action, - const unsigned int index) -{ - char name[60]; - MemoryRegion *iomem, *iomem_p4, *iomem_a7; - - if (!address) { - return 0; - } - - iomem = &desc->iomem; - iomem_p4 = desc->iomem_aliases + index; - iomem_a7 = iomem_p4 + 1; - - snprintf(name, sizeof(name), "intc-%s-%s-%s", type, action, "p4"); - memory_region_init_alias(iomem_p4, NULL, name, iomem, A7ADDR(address), 4); - memory_region_add_subregion(sysmem, P4ADDR(address), iomem_p4); - - snprintf(name, sizeof(name), "intc-%s-%s-%s", type, action, "a7"); - memory_region_init_alias(iomem_a7, NULL, name, iomem, A7ADDR(address), 4); - memory_region_add_subregion(sysmem, A7ADDR(address), iomem_a7); - - /* used to increment aliases index */ - return 2; -} - static void sh_intc_register_source(struct intc_desc *desc, intc_enum source, struct intc_group *groups, @@ -398,6 +368,36 @@ void sh_intc_register_sources(struct intc_desc *desc, } } +static unsigned int sh_intc_register(MemoryRegion *sysmem, + struct intc_desc *desc, + const unsigned long address, + const char *type, + const char *action, + const unsigned int index) +{ + char name[60]; + MemoryRegion *iomem, *iomem_p4, *iomem_a7; + + if (!address) { + return 0; + } + + iomem = &desc->iomem; + iomem_p4 = desc->iomem_aliases + index; + iomem_a7 = iomem_p4 + 1; + + snprintf(name, sizeof(name), "intc-%s-%s-%s", type, action, "p4"); + memory_region_init_alias(iomem_p4, NULL, name, iomem, A7ADDR(address), 4); + memory_region_add_subregion(sysmem, P4ADDR(address), iomem_p4); + + snprintf(name, sizeof(name), "intc-%s-%s-%s", type, action, "a7"); + memory_region_init_alias(iomem_a7, NULL, name, iomem, A7ADDR(address), 4); + memory_region_add_subregion(sysmem, A7ADDR(address), iomem_a7); + + /* used to increment aliases index */ + return 2; +} + int sh_intc_init(MemoryRegion *sysmem, struct intc_desc *desc, int nr_sources, -- cgit v1.1 From 46ea1f8236ffdf80c52dad79ee7d2dc18ed5eda1 Mon Sep 17 00:00:00 2001 From: BALATON Zoltan <balaton@eik.bme.hu> Date: Fri, 29 Oct 2021 23:02:09 +0200 Subject: hw/intc/sh_intc: Remove excessive parenthesis MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Drop unneded parenthesis and split up one complex expression to write it with less brackets so it's easier to follow. Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-Id: <a48e849e5b803a952ed15a2502cfece2bde68934.1635541329.git.balaton@eik.bme.hu> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- hw/intc/sh_intc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'hw/intc/sh_intc.c') diff --git a/hw/intc/sh_intc.c b/hw/intc/sh_intc.c index 1a2824f..416581d 100644 --- a/hw/intc/sh_intc.c +++ b/hw/intc/sh_intc.c @@ -23,7 +23,7 @@ void sh_intc_toggle_source(struct intc_source *source, int pending_changed = 0; int old_pending; - if ((source->enable_count == source->enable_max) && (enable_adj == -1)) { + if (source->enable_count == source->enable_max && enable_adj == -1) { enable_changed = -1; } source->enable_count += enable_adj; @@ -68,7 +68,7 @@ void sh_intc_toggle_source(struct intc_source *source, static void sh_intc_set_irq(void *opaque, int n, int level) { struct intc_desc *desc = opaque; - struct intc_source *source = &(desc->sources[n]); + struct intc_source *source = &desc->sources[n]; if (level && !source->asserted) { sh_intc_toggle_source(source, 0, 1); @@ -163,7 +163,7 @@ static void sh_intc_locate(struct intc_desc *desc, *modep = mode | INTC_MODE_IS_PRIO; *datap = &pr->value; *enums = pr->enum_ids; - *first = (pr->reg_width / pr->field_width) - 1; + *first = pr->reg_width / pr->field_width - 1; *width = pr->field_width; return; } @@ -244,7 +244,8 @@ static void sh_intc_write(void *opaque, hwaddr offset, } for (k = 0; k <= first; k++) { - mask = ((1 << width) - 1) << ((first - k) * width); + mask = (1 << width) - 1; + mask <<= (first - k) * width; if ((*valuep & mask) == (value & mask)) { continue; -- cgit v1.1 From 12201fe38a592695eea647c9600d08a4622c1431 Mon Sep 17 00:00:00 2001 From: BALATON Zoltan <balaton@eik.bme.hu> Date: Fri, 29 Oct 2021 23:02:09 +0200 Subject: hw/intc/sh_intc: Use array index instead of pointer arithmetics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Address of element i is one word thus clearer than array + i. Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-Id: <f49c9b1dee1fcaf374b092d862a6821907d5fcdc.1635541329.git.balaton@eik.bme.hu> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- hw/intc/sh_intc.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'hw/intc/sh_intc.c') diff --git a/hw/intc/sh_intc.c b/hw/intc/sh_intc.c index 416581d..e6e0142 100644 --- a/hw/intc/sh_intc.c +++ b/hw/intc/sh_intc.c @@ -89,7 +89,7 @@ int sh_intc_get_pending_vector(struct intc_desc *desc, int imask) } for (i = 0; i < desc->nr_sources; i++) { - struct intc_source *source = desc->sources + i; + struct intc_source *source = &desc->sources[i]; if (source->pending) { trace_sh_intc_pending(desc->pending, source->vect); @@ -137,7 +137,7 @@ static void sh_intc_locate(struct intc_desc *desc, if (desc->mask_regs) { for (i = 0; i < desc->nr_mask_regs; i++) { - struct intc_mask_reg *mr = desc->mask_regs + i; + struct intc_mask_reg *mr = &desc->mask_regs[i]; mode = sh_intc_mode(address, mr->set_reg, mr->clr_reg); if (mode == INTC_MODE_NONE) { @@ -154,7 +154,7 @@ static void sh_intc_locate(struct intc_desc *desc, if (desc->prio_regs) { for (i = 0; i < desc->nr_prio_regs; i++) { - struct intc_prio_reg *pr = desc->prio_regs + i; + struct intc_prio_reg *pr = &desc->prio_regs[i]; mode = sh_intc_mode(address, pr->set_reg, pr->clr_reg); if (mode == INTC_MODE_NONE) { @@ -175,7 +175,7 @@ static void sh_intc_locate(struct intc_desc *desc, static void sh_intc_toggle_mask(struct intc_desc *desc, intc_enum id, int enable, int is_group) { - struct intc_source *source = desc->sources + id; + struct intc_source *source = &desc->sources[id]; if (!id) { return; @@ -265,7 +265,7 @@ static const MemoryRegionOps sh_intc_ops = { struct intc_source *sh_intc_source(struct intc_desc *desc, intc_enum id) { if (id) { - return desc->sources + id; + return &desc->sources[id]; } return NULL; } @@ -280,7 +280,7 @@ static void sh_intc_register_source(struct intc_desc *desc, if (desc->mask_regs) { for (i = 0; i < desc->nr_mask_regs; i++) { - struct intc_mask_reg *mr = desc->mask_regs + i; + struct intc_mask_reg *mr = &desc->mask_regs[i]; for (k = 0; k < ARRAY_SIZE(mr->enum_ids); k++) { if (mr->enum_ids[k] != source) { @@ -296,7 +296,7 @@ static void sh_intc_register_source(struct intc_desc *desc, if (desc->prio_regs) { for (i = 0; i < desc->nr_prio_regs; i++) { - struct intc_prio_reg *pr = desc->prio_regs + i; + struct intc_prio_reg *pr = &desc->prio_regs[i]; for (k = 0; k < ARRAY_SIZE(pr->enum_ids); k++) { if (pr->enum_ids[k] != source) { @@ -312,7 +312,7 @@ static void sh_intc_register_source(struct intc_desc *desc, if (groups) { for (i = 0; i < nr_groups; i++) { - struct intc_group *gr = groups + i; + struct intc_group *gr = &groups[i]; for (k = 0; k < ARRAY_SIZE(gr->enum_ids); k++) { if (gr->enum_ids[k] != source) { @@ -338,7 +338,7 @@ void sh_intc_register_sources(struct intc_desc *desc, struct intc_source *s; for (i = 0; i < nr_vectors; i++) { - struct intc_vect *vect = vectors + i; + struct intc_vect *vect = &vectors[i]; sh_intc_register_source(desc, vect->enum_id, groups, nr_groups); s = sh_intc_source(desc, vect->enum_id); @@ -351,7 +351,7 @@ void sh_intc_register_sources(struct intc_desc *desc, if (groups) { for (i = 0; i < nr_groups; i++) { - struct intc_group *gr = groups + i; + struct intc_group *gr = &groups[i]; s = sh_intc_source(desc, gr->enum_id); s->next_enum_id = gr->enum_ids[0]; @@ -384,7 +384,7 @@ static unsigned int sh_intc_register(MemoryRegion *sysmem, } iomem = &desc->iomem; - iomem_p4 = desc->iomem_aliases + index; + iomem_p4 = &desc->iomem_aliases[index]; iomem_a7 = iomem_p4 + 1; snprintf(name, sizeof(name), "intc-%s-%s-%s", type, action, "p4"); @@ -424,7 +424,7 @@ int sh_intc_init(MemoryRegion *sysmem, desc->sources = g_malloc0(i); for (i = 0; i < desc->nr_sources; i++) { - struct intc_source *source = desc->sources + i; + struct intc_source *source = &desc->sources[i]; source->parent = desc; } @@ -435,7 +435,7 @@ int sh_intc_init(MemoryRegion *sysmem, if (desc->mask_regs) { for (i = 0; i < desc->nr_mask_regs; i++) { - struct intc_mask_reg *mr = desc->mask_regs + i; + struct intc_mask_reg *mr = &desc->mask_regs[i]; j += sh_intc_register(sysmem, desc, mr->set_reg, "mask", "set", j); j += sh_intc_register(sysmem, desc, mr->clr_reg, "mask", "clr", j); @@ -444,7 +444,7 @@ int sh_intc_init(MemoryRegion *sysmem, if (desc->prio_regs) { for (i = 0; i < desc->nr_prio_regs; i++) { - struct intc_prio_reg *pr = desc->prio_regs + i; + struct intc_prio_reg *pr = &desc->prio_regs[i]; j += sh_intc_register(sysmem, desc, pr->set_reg, "prio", "set", j); j += sh_intc_register(sysmem, desc, pr->clr_reg, "prio", "clr", j); -- cgit v1.1 From 9b12fb10b731d8d9cbb6cc0bf200d1c48de7f20d Mon Sep 17 00:00:00 2001 From: BALATON Zoltan <balaton@eik.bme.hu> Date: Fri, 29 Oct 2021 23:02:09 +0200 Subject: hw/intc/sh_intc: Inline and drop sh_intc_source() function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This function is very simple and provides no advantage. Call sites become simpler without it so just write it in line and drop the separate function. Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-Id: <a98d1f7f94e91a42796b7d91e9153a7eaa3d1c44.1635541329.git.balaton@eik.bme.hu> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- hw/intc/sh_intc.c | 54 ++++++++++++++++++++++-------------------------------- 1 file changed, 22 insertions(+), 32 deletions(-) (limited to 'hw/intc/sh_intc.c') diff --git a/hw/intc/sh_intc.c b/hw/intc/sh_intc.c index e6e0142..9995213 100644 --- a/hw/intc/sh_intc.c +++ b/hw/intc/sh_intc.c @@ -262,33 +262,22 @@ static const MemoryRegionOps sh_intc_ops = { .endianness = DEVICE_NATIVE_ENDIAN, }; -struct intc_source *sh_intc_source(struct intc_desc *desc, intc_enum id) -{ - if (id) { - return &desc->sources[id]; - } - return NULL; -} - static void sh_intc_register_source(struct intc_desc *desc, intc_enum source, struct intc_group *groups, int nr_groups) { unsigned int i, k; - struct intc_source *s; + intc_enum id; if (desc->mask_regs) { for (i = 0; i < desc->nr_mask_regs; i++) { struct intc_mask_reg *mr = &desc->mask_regs[i]; for (k = 0; k < ARRAY_SIZE(mr->enum_ids); k++) { - if (mr->enum_ids[k] != source) { - continue; - } - s = sh_intc_source(desc, mr->enum_ids[k]); - if (s) { - s->enable_max++; + id = mr->enum_ids[k]; + if (id && id == source) { + desc->sources[id].enable_max++; } } } @@ -299,12 +288,9 @@ static void sh_intc_register_source(struct intc_desc *desc, struct intc_prio_reg *pr = &desc->prio_regs[i]; for (k = 0; k < ARRAY_SIZE(pr->enum_ids); k++) { - if (pr->enum_ids[k] != source) { - continue; - } - s = sh_intc_source(desc, pr->enum_ids[k]); - if (s) { - s->enable_max++; + id = pr->enum_ids[k]; + if (id && id == source) { + desc->sources[id].enable_max++; } } } @@ -315,12 +301,9 @@ static void sh_intc_register_source(struct intc_desc *desc, struct intc_group *gr = &groups[i]; for (k = 0; k < ARRAY_SIZE(gr->enum_ids); k++) { - if (gr->enum_ids[k] != source) { - continue; - } - s = sh_intc_source(desc, gr->enum_ids[k]); - if (s) { - s->enable_max++; + id = gr->enum_ids[k]; + if (id && id == source) { + desc->sources[id].enable_max++; } } } @@ -335,14 +318,16 @@ void sh_intc_register_sources(struct intc_desc *desc, int nr_groups) { unsigned int i, k; + intc_enum id; struct intc_source *s; for (i = 0; i < nr_vectors; i++) { struct intc_vect *vect = &vectors[i]; sh_intc_register_source(desc, vect->enum_id, groups, nr_groups); - s = sh_intc_source(desc, vect->enum_id); - if (s) { + id = vect->enum_id; + if (id) { + s = &desc->sources[id]; s->vect = vect->vect; trace_sh_intc_register("source", vect->enum_id, s->vect, s->enable_count, s->enable_max); @@ -353,14 +338,16 @@ void sh_intc_register_sources(struct intc_desc *desc, for (i = 0; i < nr_groups; i++) { struct intc_group *gr = &groups[i]; - s = sh_intc_source(desc, gr->enum_id); + id = gr->enum_id; + s = &desc->sources[id]; s->next_enum_id = gr->enum_ids[0]; for (k = 1; k < ARRAY_SIZE(gr->enum_ids); k++) { if (!gr->enum_ids[k]) { continue; } - s = sh_intc_source(desc, gr->enum_ids[k - 1]); + id = gr->enum_ids[k - 1]; + s = &desc->sources[id]; s->next_enum_id = gr->enum_ids[k]; } trace_sh_intc_register("group", gr->enum_id, 0xffff, @@ -462,7 +449,10 @@ void sh_intc_set_irl(void *opaque, int n, int level) { struct intc_source *s = opaque; int i, irl = level ^ 15; - for (i = 0; (s = sh_intc_source(s->parent, s->next_enum_id)); i++) { + intc_enum id = s->next_enum_id; + + for (i = 0; id; id = s->next_enum_id, i++) { + s = &s->parent->sources[id]; if (i == irl) { sh_intc_toggle_source(s, s->enable_count ? 0 : 1, s->asserted ? 0 : 1); -- cgit v1.1 From 85208f7a9756948ed16ef09d7982584528904430 Mon Sep 17 00:00:00 2001 From: BALATON Zoltan <balaton@eik.bme.hu> Date: Fri, 29 Oct 2021 23:02:09 +0200 Subject: hw/intc/sh_intc: Replace abort() with g_assert_not_reached() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All the places that call abort should not happen which is better marked by g_assert_not_reached. Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-Id: <039e6a784532f2af27f8adeafdb8e0391722f567.1635541329.git.balaton@eik.bme.hu> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- hw/intc/sh_intc.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'hw/intc/sh_intc.c') diff --git a/hw/intc/sh_intc.c b/hw/intc/sh_intc.c index 9995213..a0db742 100644 --- a/hw/intc/sh_intc.c +++ b/hw/intc/sh_intc.c @@ -96,8 +96,7 @@ int sh_intc_get_pending_vector(struct intc_desc *desc, int imask) return source->vect; } } - - abort(); + g_assert_not_reached(); } typedef enum { @@ -168,8 +167,7 @@ static void sh_intc_locate(struct intc_desc *desc, return; } } - - abort(); + g_assert_not_reached(); } static void sh_intc_toggle_mask(struct intc_desc *desc, intc_enum id, @@ -240,7 +238,7 @@ static void sh_intc_write(void *opaque, hwaddr offset, value = *valuep & ~value; break; default: - abort(); + g_assert_not_reached(); } for (k = 0; k <= first; k++) { -- cgit v1.1 From 418a221c2b8a97838980e61cdfef356ec6976e4b Mon Sep 17 00:00:00 2001 From: BALATON Zoltan <balaton@eik.bme.hu> Date: Fri, 29 Oct 2021 23:02:09 +0200 Subject: hw/intc/sh_intc: Avoid using continue in loops MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of if !expr continue else do something it is more straight forward to say if expr then do something, especially if the action is just a few lines. Remove such uses of continue to make the code easier to follow. Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <0efaa5e7a1a3ee11f82b3bb1942c287576c67f8b.1635541329.git.balaton@eik.bme.hu> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- hw/intc/sh_intc.c | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) (limited to 'hw/intc/sh_intc.c') diff --git a/hw/intc/sh_intc.c b/hw/intc/sh_intc.c index a0db742..1a363d4 100644 --- a/hw/intc/sh_intc.c +++ b/hw/intc/sh_intc.c @@ -139,15 +139,14 @@ static void sh_intc_locate(struct intc_desc *desc, struct intc_mask_reg *mr = &desc->mask_regs[i]; mode = sh_intc_mode(address, mr->set_reg, mr->clr_reg); - if (mode == INTC_MODE_NONE) { - continue; + if (mode != INTC_MODE_NONE) { + *modep = mode; + *datap = &mr->value; + *enums = mr->enum_ids; + *first = mr->reg_width - 1; + *width = 1; + return; } - *modep = mode; - *datap = &mr->value; - *enums = mr->enum_ids; - *first = mr->reg_width - 1; - *width = 1; - return; } } @@ -156,15 +155,14 @@ static void sh_intc_locate(struct intc_desc *desc, struct intc_prio_reg *pr = &desc->prio_regs[i]; mode = sh_intc_mode(address, pr->set_reg, pr->clr_reg); - if (mode == INTC_MODE_NONE) { - continue; + if (mode != INTC_MODE_NONE) { + *modep = mode | INTC_MODE_IS_PRIO; + *datap = &pr->value; + *enums = pr->enum_ids; + *first = pr->reg_width / pr->field_width - 1; + *width = pr->field_width; + return; } - *modep = mode | INTC_MODE_IS_PRIO; - *datap = &pr->value; - *enums = pr->enum_ids; - *first = pr->reg_width / pr->field_width - 1; - *width = pr->field_width; - return; } } g_assert_not_reached(); @@ -245,10 +243,9 @@ static void sh_intc_write(void *opaque, hwaddr offset, mask = (1 << width) - 1; mask <<= (first - k) * width; - if ((*valuep & mask) == (value & mask)) { - continue; + if ((*valuep & mask) != (value & mask)) { + sh_intc_toggle_mask(desc, enum_ids[k], value & mask, 0); } - sh_intc_toggle_mask(desc, enum_ids[k], value & mask, 0); } *valuep = value; @@ -341,12 +338,11 @@ void sh_intc_register_sources(struct intc_desc *desc, s->next_enum_id = gr->enum_ids[0]; for (k = 1; k < ARRAY_SIZE(gr->enum_ids); k++) { - if (!gr->enum_ids[k]) { - continue; + if (gr->enum_ids[k]) { + id = gr->enum_ids[k - 1]; + s = &desc->sources[id]; + s->next_enum_id = gr->enum_ids[k]; } - id = gr->enum_ids[k - 1]; - s = &desc->sources[id]; - s->next_enum_id = gr->enum_ids[k]; } trace_sh_intc_register("group", gr->enum_id, 0xffff, s->enable_count, s->enable_max); -- cgit v1.1 From 36cf5ee8852a3aac56be160ad87cc49974278c46 Mon Sep 17 00:00:00 2001 From: BALATON Zoltan <balaton@eik.bme.hu> Date: Fri, 29 Oct 2021 23:02:09 +0200 Subject: hw/intc/sh_intc: Simplify allocating sources array MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use g_new0 instead of g_malloc0 and avoid some unneeded temporary variable assignments. Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-Id: <72efc4f2c4ff8b96848d03dca08e4541ee4076f6.1635541329.git.balaton@eik.bme.hu> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- hw/intc/sh_intc.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'hw/intc/sh_intc.c') diff --git a/hw/intc/sh_intc.c b/hw/intc/sh_intc.c index 1a363d4..3356b42 100644 --- a/hw/intc/sh_intc.c +++ b/hw/intc/sh_intc.c @@ -399,21 +399,14 @@ int sh_intc_init(MemoryRegion *sysmem, /* Allocate 4 MemoryRegions per register (2 actions * 2 aliases) */ desc->iomem_aliases = g_new0(MemoryRegion, (nr_mask_regs + nr_prio_regs) * 4); - - j = 0; - i = sizeof(struct intc_source) * nr_sources; - desc->sources = g_malloc0(i); - - for (i = 0; i < desc->nr_sources; i++) { - struct intc_source *source = &desc->sources[i]; - - source->parent = desc; + desc->sources = g_new0(struct intc_source, nr_sources); + for (i = 0; i < nr_sources; i++) { + desc->sources[i].parent = desc; } - desc->irqs = qemu_allocate_irqs(sh_intc_set_irq, desc, nr_sources); memory_region_init_io(&desc->iomem, NULL, &sh_intc_ops, desc, "intc", 0x100000000ULL); - + j = 0; if (desc->mask_regs) { for (i = 0; i < desc->nr_mask_regs; i++) { struct intc_mask_reg *mr = &desc->mask_regs[i]; -- cgit v1.1 From 32331787896104022deb024906f1cca9606cfdc6 Mon Sep 17 00:00:00 2001 From: BALATON Zoltan <balaton@eik.bme.hu> Date: Fri, 29 Oct 2021 23:02:09 +0200 Subject: hw/intc/sh_intc: Remove unneeded local variable initialisers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The sh_intc_locate function will either init these or not return so no need to initialise them. Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-Id: <15e04aa665c68ab5df47bbf505346d413be2fc1c.1635541329.git.balaton@eik.bme.hu> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- hw/intc/sh_intc.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'hw/intc/sh_intc.c') diff --git a/hw/intc/sh_intc.c b/hw/intc/sh_intc.c index 3356b42..c9b0b0c 100644 --- a/hw/intc/sh_intc.c +++ b/hw/intc/sh_intc.c @@ -195,14 +195,13 @@ static void sh_intc_toggle_mask(struct intc_desc *desc, intc_enum id, } } -static uint64_t sh_intc_read(void *opaque, hwaddr offset, - unsigned size) +static uint64_t sh_intc_read(void *opaque, hwaddr offset, unsigned size) { struct intc_desc *desc = opaque; - intc_enum *enum_ids = NULL; - unsigned int first = 0; - unsigned int width = 0; - unsigned int mode = 0; + intc_enum *enum_ids; + unsigned int first; + unsigned int width; + unsigned int mode; unsigned long *valuep; sh_intc_locate(desc, (unsigned long)offset, &valuep, @@ -215,12 +214,12 @@ static void sh_intc_write(void *opaque, hwaddr offset, uint64_t value, unsigned size) { struct intc_desc *desc = opaque; - intc_enum *enum_ids = NULL; - unsigned int first = 0; - unsigned int width = 0; - unsigned int mode = 0; - unsigned int k; + intc_enum *enum_ids; + unsigned int first; + unsigned int width; + unsigned int mode; unsigned long *valuep; + unsigned int k; unsigned long mask; trace_sh_intc_write(size, (uint64_t)offset, value); -- cgit v1.1