Commit 68af3f249157f2538fea806622c45f537d65c9bc

Authored by blueswir1
1 parent 0a645949

Add it_shift

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6547 c046a42c-6fe2-441c-8c8c-71466251a162
hw/mac_nvram.c
@@ -40,6 +40,7 @@ do { printf("NVR: " fmt , ##args); } while (0) @@ -40,6 +40,7 @@ do { printf("NVR: " fmt , ##args); } while (0)
40 struct MacIONVRAMState { 40 struct MacIONVRAMState {
41 target_phys_addr_t size; 41 target_phys_addr_t size;
42 int mem_index; 42 int mem_index;
  43 + unsigned int it_shift;
43 uint8_t *data; 44 uint8_t *data;
44 }; 45 };
45 46
@@ -75,7 +76,7 @@ static void macio_nvram_writeb (void *opaque, @@ -75,7 +76,7 @@ static void macio_nvram_writeb (void *opaque,
75 { 76 {
76 MacIONVRAMState *s = opaque; 77 MacIONVRAMState *s = opaque;
77 78
78 - addr = (addr >> 4) & (s->size - 1); 79 + addr = (addr >> s->it_shift) & (s->size - 1);
79 s->data[addr] = value; 80 s->data[addr] = value;
80 NVR_DPRINTF("writeb addr %04x val %x\n", (int)addr, value); 81 NVR_DPRINTF("writeb addr %04x val %x\n", (int)addr, value);
81 } 82 }
@@ -85,7 +86,7 @@ static uint32_t macio_nvram_readb (void *opaque, target_phys_addr_t addr) @@ -85,7 +86,7 @@ static uint32_t macio_nvram_readb (void *opaque, target_phys_addr_t addr)
85 MacIONVRAMState *s = opaque; 86 MacIONVRAMState *s = opaque;
86 uint32_t value; 87 uint32_t value;
87 88
88 - addr = (addr >> 4) & (s->size - 1); 89 + addr = (addr >> s->it_shift) & (s->size - 1);
89 value = s->data[addr]; 90 value = s->data[addr];
90 NVR_DPRINTF("readb addr %04x val %x\n", (int)addr, value); 91 NVR_DPRINTF("readb addr %04x val %x\n", (int)addr, value);
91 92
@@ -127,13 +128,15 @@ static void macio_nvram_reset(void *opaque) @@ -127,13 +128,15 @@ static void macio_nvram_reset(void *opaque)
127 { 128 {
128 } 129 }
129 130
130 -MacIONVRAMState *macio_nvram_init (int *mem_index, target_phys_addr_t size) 131 +MacIONVRAMState *macio_nvram_init (int *mem_index, target_phys_addr_t size,
  132 + unsigned int it_shift)
131 { 133 {
132 MacIONVRAMState *s; 134 MacIONVRAMState *s;
133 135
134 s = qemu_mallocz(sizeof(MacIONVRAMState)); 136 s = qemu_mallocz(sizeof(MacIONVRAMState));
135 s->data = qemu_mallocz(size); 137 s->data = qemu_mallocz(size);
136 s->size = size; 138 s->size = size;
  139 + s->it_shift = it_shift;
137 140
138 s->mem_index = cpu_register_io_memory(0, nvram_read, nvram_write, s); 141 s->mem_index = cpu_register_io_memory(0, nvram_read, nvram_write, s);
139 *mem_index = s->mem_index; 142 *mem_index = s->mem_index;
@@ -150,7 +153,8 @@ void macio_nvram_map (void *opaque, target_phys_addr_t mem_base) @@ -150,7 +153,8 @@ void macio_nvram_map (void *opaque, target_phys_addr_t mem_base)
150 MacIONVRAMState *s; 153 MacIONVRAMState *s;
151 154
152 s = opaque; 155 s = opaque;
153 - cpu_register_physical_memory(mem_base, s->size << 4, s->mem_index); 156 + cpu_register_physical_memory(mem_base, s->size << s->it_shift,
  157 + s->mem_index);
154 } 158 }
155 159
156 /* Set up a system OpenBIOS NVRAM partition */ 160 /* Set up a system OpenBIOS NVRAM partition */
hw/ppc_chrp.c
@@ -328,7 +328,7 @@ static void ppc_core99_init (ram_addr_t ram_size, int vga_ram_size, @@ -328,7 +328,7 @@ static void ppc_core99_init (ram_addr_t ram_size, int vga_ram_size,
328 graphic_depth = 15; 328 graphic_depth = 15;
329 #if 0 /* XXX: this is ugly but needed for now, or OHW won't boot */ 329 #if 0 /* XXX: this is ugly but needed for now, or OHW won't boot */
330 /* The NewWorld NVRAM is not located in the MacIO device */ 330 /* The NewWorld NVRAM is not located in the MacIO device */
331 - nvr = macio_nvram_init(&nvram_mem_index, 0x2000); 331 + nvr = macio_nvram_init(&nvram_mem_index, 0x2000, 1);
332 pmac_format_nvram_partition(nvr, 0x2000); 332 pmac_format_nvram_partition(nvr, 0x2000);
333 macio_nvram_map(nvr, 0xFFF04000); 333 macio_nvram_map(nvr, 0xFFF04000);
334 nvram.opaque = nvr; 334 nvram.opaque = nvr;
hw/ppc_mac.h
@@ -64,7 +64,8 @@ PCIBus *pci_pmac_init(qemu_irq *pic); @@ -64,7 +64,8 @@ PCIBus *pci_pmac_init(qemu_irq *pic);
64 /* Mac NVRAM */ 64 /* Mac NVRAM */
65 typedef struct MacIONVRAMState MacIONVRAMState; 65 typedef struct MacIONVRAMState MacIONVRAMState;
66 66
67 -MacIONVRAMState *macio_nvram_init (int *mem_index, target_phys_addr_t size); 67 +MacIONVRAMState *macio_nvram_init (int *mem_index, target_phys_addr_t size,
  68 + unsigned int it_shift);
68 void macio_nvram_map (void *opaque, target_phys_addr_t mem_base); 69 void macio_nvram_map (void *opaque, target_phys_addr_t mem_base);
69 void pmac_format_nvram_partition (MacIONVRAMState *nvr, int len); 70 void pmac_format_nvram_partition (MacIONVRAMState *nvr, int len);
70 uint32_t macio_nvram_read (void *opaque, uint32_t addr); 71 uint32_t macio_nvram_read (void *opaque, uint32_t addr);
hw/ppc_oldworld.c
@@ -357,7 +357,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size, int vga_ram_size, @@ -357,7 +357,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size, int vga_ram_size,
357 adb_kbd_init(&adb_bus); 357 adb_kbd_init(&adb_bus);
358 adb_mouse_init(&adb_bus); 358 adb_mouse_init(&adb_bus);
359 359
360 - nvr = macio_nvram_init(&nvram_mem_index, 0x2000); 360 + nvr = macio_nvram_init(&nvram_mem_index, 0x2000, 4);
361 pmac_format_nvram_partition(nvr, 0x2000); 361 pmac_format_nvram_partition(nvr, 0x2000);
362 362
363 macio_init(pci_bus, PCI_DEVICE_ID_APPLE_343S1201, 1, pic_mem_index, 363 macio_init(pci_bus, PCI_DEVICE_ID_APPLE_343S1201, 1, pic_mem_index,