Rename variables and rearrange code to please gcc -Wshadow checks


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3023 c046a42c-6fe2-441c-8c8c-71466251a162
diff --git a/hw/sun4m.c b/hw/sun4m.c
index 2f7f22e..eb69ef8 100644
--- a/hw/sun4m.c
+++ b/hw/sun4m.c
@@ -154,8 +154,6 @@
     m48t59_write(nvram, start + 1, sum & 0xff);
 }
 
-static m48t59_t *nvram;
-
 extern int nographic;
 
 static void nvram_init(m48t59_t *nvram, uint8_t *macaddr, const char *cmdline,
@@ -292,13 +290,13 @@
     env->halted = 1;
 }
 
-static void sun4m_hw_init(const struct hwdef *hwdef, int ram_size,
-                          DisplayState *ds, const char *cpu_model)
+static void *sun4m_hw_init(const struct hwdef *hwdef, int RAM_size,
+                           DisplayState *ds, const char *cpu_model)
 
 {
     CPUState *env, *envs[MAX_CPUS];
     unsigned int i;
-    void *iommu, *espdma, *ledma, *main_esp;
+    void *iommu, *espdma, *ledma, *main_esp, *nvram;
     const sparc_def_t *def;
     qemu_irq *cpu_irqs[MAX_CPUS], *slavio_irq, *slavio_cpu_irq,
         *espdma_irq, *ledma_irq;
@@ -328,7 +326,7 @@
         cpu_irqs[i] = qemu_allocate_irqs(dummy_cpu_set_irq, NULL, MAX_PILS);
 
     /* allocate RAM */
-    cpu_register_physical_memory(0, ram_size, 0);
+    cpu_register_physical_memory(0, RAM_size, 0);
 
     iommu = iommu_init(hwdef->iommu_base);
     slavio_intctl = slavio_intctl_init(hwdef->intctl_base,
@@ -347,7 +345,7 @@
         fprintf(stderr, "qemu: Unsupported depth: %d\n", graphic_depth);
         exit (1);
     }
-    tcx_init(ds, hwdef->tcx_base, phys_ram_base + ram_size, ram_size,
+    tcx_init(ds, hwdef->tcx_base, phys_ram_base + RAM_size, RAM_size,
              hwdef->vram_size, graphic_width, graphic_height, graphic_depth);
 
     if (nd_table[0].model == NULL
@@ -388,13 +386,16 @@
                                    slavio_irq[hwdef->me_irq]);
     if (hwdef->cs_base != (target_phys_addr_t)-1)
         cs_init(hwdef->cs_base, hwdef->cs_irq, slavio_intctl);
+
+    return nvram;
 }
 
-static void sun4m_load_kernel(long vram_size, int ram_size, int boot_device,
+static void sun4m_load_kernel(long vram_size, int RAM_size, int boot_device,
                               const char *kernel_filename,
                               const char *kernel_cmdline,
                               const char *initrd_filename,
-                              int machine_id)
+                              int machine_id,
+                              void *nvram)
 {
     int ret, linux_boot;
     char buf[1024];
@@ -403,7 +404,7 @@
 
     linux_boot = (kernel_filename != NULL);
 
-    prom_offset = ram_size + vram_size;
+    prom_offset = RAM_size + vram_size;
     cpu_register_physical_memory(PROM_ADDR, 
                                  (PROM_SIZE_MAX + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK, 
                                  prom_offset | IO_MEM_ROM);
@@ -451,7 +452,7 @@
         }
     }
     nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, kernel_cmdline,
-               boot_device, ram_size, kernel_size, graphic_width,
+               boot_device, RAM_size, kernel_size, graphic_width,
                graphic_height, graphic_depth, machine_id);
 }
 
@@ -524,46 +525,48 @@
     },
 };
 
-static void sun4m_common_init(int ram_size, int boot_device, DisplayState *ds,
+static void sun4m_common_init(int RAM_size, int boot_device, DisplayState *ds,
                               const char *kernel_filename, const char *kernel_cmdline,
                               const char *initrd_filename, const char *cpu_model,
                               unsigned int machine, int max_ram)
 {
-    if ((unsigned int)ram_size > (unsigned int)max_ram) {
+    void *nvram;
+
+    if ((unsigned int)RAM_size > (unsigned int)max_ram) {
         fprintf(stderr, "qemu: Too much memory for this machine: %d, maximum %d\n",
-                (unsigned int)ram_size / (1024 * 1024),
+                (unsigned int)RAM_size / (1024 * 1024),
                 (unsigned int)max_ram / (1024 * 1024));
         exit(1);
     }
-    sun4m_hw_init(&hwdefs[machine], ram_size, ds, cpu_model);
+    nvram = sun4m_hw_init(&hwdefs[machine], RAM_size, ds, cpu_model);
 
-    sun4m_load_kernel(hwdefs[machine].vram_size, ram_size, boot_device,
+    sun4m_load_kernel(hwdefs[machine].vram_size, RAM_size, boot_device,
                       kernel_filename, kernel_cmdline, initrd_filename,
-                      hwdefs[machine].machine_id);
+                      hwdefs[machine].machine_id, nvram);
 }
 
 /* SPARCstation 5 hardware initialisation */
-static void ss5_init(int ram_size, int vga_ram_size, int boot_device,
+static void ss5_init(int RAM_size, int vga_ram_size, int boot_device,
                        DisplayState *ds, const char **fd_filename, int snapshot,
                        const char *kernel_filename, const char *kernel_cmdline,
                        const char *initrd_filename, const char *cpu_model)
 {
     if (cpu_model == NULL)
         cpu_model = "Fujitsu MB86904";
-    sun4m_common_init(ram_size, boot_device, ds, kernel_filename,
+    sun4m_common_init(RAM_size, boot_device, ds, kernel_filename,
                       kernel_cmdline, initrd_filename, cpu_model,
                       0, 0x10000000);
 }
 
 /* SPARCstation 10 hardware initialisation */
-static void ss10_init(int ram_size, int vga_ram_size, int boot_device,
+static void ss10_init(int RAM_size, int vga_ram_size, int boot_device,
                             DisplayState *ds, const char **fd_filename, int snapshot,
                             const char *kernel_filename, const char *kernel_cmdline,
                             const char *initrd_filename, const char *cpu_model)
 {
     if (cpu_model == NULL)
         cpu_model = "TI SuperSparc II";
-    sun4m_common_init(ram_size, boot_device, ds, kernel_filename,
+    sun4m_common_init(RAM_size, boot_device, ds, kernel_filename,
                       kernel_cmdline, initrd_filename, cpu_model,
                       1, PROM_ADDR); // XXX prom overlap, actually first 4GB ok
 }