Commit 5c6602c5468a1408686abce6cdb2617ee462a333

Authored by blueswir1
1 parent 05330448

Use qemu_ram_alloc

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5630 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 2 changed files with 31 additions and 20 deletions
hw/sun4m.c
@@ -433,7 +433,8 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size, @@ -433,7 +433,8 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size,
433 qemu_irq *esp_reset, *le_reset; 433 qemu_irq *esp_reset, *le_reset;
434 qemu_irq *fdc_tc; 434 qemu_irq *fdc_tc;
435 qemu_irq *cpu_halt; 435 qemu_irq *cpu_halt;
436 - unsigned long prom_offset, kernel_size; 436 + ram_addr_t ram_offset, prom_offset, tcx_offset, idreg_offset;
  437 + unsigned long kernel_size;
437 int ret; 438 int ret;
438 char buf[1024]; 439 char buf[1024];
439 BlockDriverState *fd[MAX_FD]; 440 BlockDriverState *fd[MAX_FD];
@@ -474,10 +475,11 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size, @@ -474,10 +475,11 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size,
474 (unsigned int)(hwdef->max_mem / (1024 * 1024))); 475 (unsigned int)(hwdef->max_mem / (1024 * 1024)));
475 exit(1); 476 exit(1);
476 } 477 }
477 - cpu_register_physical_memory(0, RAM_size, 0); 478 + ram_offset = qemu_ram_alloc(RAM_size);
  479 + cpu_register_physical_memory(0, RAM_size, ram_offset);
478 480
479 /* load boot prom */ 481 /* load boot prom */
480 - prom_offset = RAM_size + hwdef->vram_size; 482 + prom_offset = qemu_ram_alloc(PROM_SIZE_MAX);
481 cpu_register_physical_memory(hwdef->slavio_base, 483 cpu_register_physical_memory(hwdef->slavio_base,
482 (PROM_SIZE_MAX + TARGET_PAGE_SIZE - 1) & 484 (PROM_SIZE_MAX + TARGET_PAGE_SIZE - 1) &
483 TARGET_PAGE_MASK, 485 TARGET_PAGE_MASK,
@@ -494,7 +496,6 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size, @@ -494,7 +496,6 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size,
494 buf); 496 buf);
495 exit(1); 497 exit(1);
496 } 498 }
497 - prom_offset += (ret + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK;  
498 499
499 /* set up devices */ 500 /* set up devices */
500 slavio_intctl = slavio_intctl_init(hwdef->intctl_base, 501 slavio_intctl = slavio_intctl_init(hwdef->intctl_base,
@@ -507,8 +508,9 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size, @@ -507,8 +508,9 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size,
507 if (hwdef->idreg_base != (target_phys_addr_t)-1) { 508 if (hwdef->idreg_base != (target_phys_addr_t)-1) {
508 static const uint8_t idreg_data[] = { 0xfe, 0x81, 0x01, 0x03 }; 509 static const uint8_t idreg_data[] = { 0xfe, 0x81, 0x01, 0x03 };
509 510
  511 + idreg_offset = qemu_ram_alloc(sizeof(idreg_data));
510 cpu_register_physical_memory(hwdef->idreg_base, sizeof(idreg_data), 512 cpu_register_physical_memory(hwdef->idreg_base, sizeof(idreg_data),
511 - prom_offset | IO_MEM_ROM); 513 + idreg_offset | IO_MEM_ROM);
512 cpu_physical_memory_write_rom(hwdef->idreg_base, idreg_data, 514 cpu_physical_memory_write_rom(hwdef->idreg_base, idreg_data,
513 sizeof(idreg_data)); 515 sizeof(idreg_data));
514 } 516 }
@@ -527,7 +529,8 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size, @@ -527,7 +529,8 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size,
527 fprintf(stderr, "qemu: Unsupported depth: %d\n", graphic_depth); 529 fprintf(stderr, "qemu: Unsupported depth: %d\n", graphic_depth);
528 exit (1); 530 exit (1);
529 } 531 }
530 - tcx_init(ds, hwdef->tcx_base, phys_ram_base + RAM_size, RAM_size, 532 + tcx_offset = qemu_ram_alloc(hwdef->vram_size);
  533 + tcx_init(ds, hwdef->tcx_base, phys_ram_base + tcx_offset, tcx_offset,
531 hwdef->vram_size, graphic_width, graphic_height, graphic_depth); 534 hwdef->vram_size, graphic_width, graphic_height, graphic_depth);
532 535
533 if (nd_table[0].model == NULL 536 if (nd_table[0].model == NULL
@@ -1260,7 +1263,8 @@ static void sun4d_hw_init(const struct sun4d_hwdef *hwdef, ram_addr_t RAM_size, @@ -1260,7 +1263,8 @@ static void sun4d_hw_init(const struct sun4d_hwdef *hwdef, ram_addr_t RAM_size,
1260 qemu_irq *cpu_irqs[MAX_CPUS], *sbi_irq, *sbi_cpu_irq, 1263 qemu_irq *cpu_irqs[MAX_CPUS], *sbi_irq, *sbi_cpu_irq,
1261 *espdma_irq, *ledma_irq; 1264 *espdma_irq, *ledma_irq;
1262 qemu_irq *esp_reset, *le_reset; 1265 qemu_irq *esp_reset, *le_reset;
1263 - unsigned long prom_offset, kernel_size; 1266 + ram_addr_t ram_offset, prom_offset, tcx_offset;
  1267 + unsigned long kernel_size;
1264 int ret; 1268 int ret;
1265 char buf[1024]; 1269 char buf[1024];
1266 int drive_index; 1270 int drive_index;
@@ -1299,10 +1303,11 @@ static void sun4d_hw_init(const struct sun4d_hwdef *hwdef, ram_addr_t RAM_size, @@ -1299,10 +1303,11 @@ static void sun4d_hw_init(const struct sun4d_hwdef *hwdef, ram_addr_t RAM_size,
1299 (unsigned int)(hwdef->max_mem / (1024 * 1024))); 1303 (unsigned int)(hwdef->max_mem / (1024 * 1024)));
1300 exit(1); 1304 exit(1);
1301 } 1305 }
1302 - cpu_register_physical_memory(0, RAM_size, 0); 1306 + ram_offset = qemu_ram_alloc(RAM_size);
  1307 + cpu_register_physical_memory(0, RAM_size, ram_offset);
1303 1308
1304 /* load boot prom */ 1309 /* load boot prom */
1305 - prom_offset = RAM_size + hwdef->vram_size; 1310 + prom_offset = qemu_ram_alloc(PROM_SIZE_MAX);
1306 cpu_register_physical_memory(hwdef->slavio_base, 1311 cpu_register_physical_memory(hwdef->slavio_base,
1307 (PROM_SIZE_MAX + TARGET_PAGE_SIZE - 1) & 1312 (PROM_SIZE_MAX + TARGET_PAGE_SIZE - 1) &
1308 TARGET_PAGE_MASK, 1313 TARGET_PAGE_MASK,
@@ -1339,7 +1344,8 @@ static void sun4d_hw_init(const struct sun4d_hwdef *hwdef, ram_addr_t RAM_size, @@ -1339,7 +1344,8 @@ static void sun4d_hw_init(const struct sun4d_hwdef *hwdef, ram_addr_t RAM_size,
1339 fprintf(stderr, "qemu: Unsupported depth: %d\n", graphic_depth); 1344 fprintf(stderr, "qemu: Unsupported depth: %d\n", graphic_depth);
1340 exit (1); 1345 exit (1);
1341 } 1346 }
1342 - tcx_init(ds, hwdef->tcx_base, phys_ram_base + RAM_size, RAM_size, 1347 + tcx_offset = qemu_ram_alloc(hwdef->vram_size);
  1348 + tcx_init(ds, hwdef->tcx_base, phys_ram_base + tcx_offset, tcx_offset,
1343 hwdef->vram_size, graphic_width, graphic_height, graphic_depth); 1349 hwdef->vram_size, graphic_width, graphic_height, graphic_depth);
1344 1350
1345 if (nd_table[0].model == NULL 1351 if (nd_table[0].model == NULL
@@ -1481,7 +1487,8 @@ static void sun4c_hw_init(const struct sun4c_hwdef *hwdef, ram_addr_t RAM_size, @@ -1481,7 +1487,8 @@ static void sun4c_hw_init(const struct sun4c_hwdef *hwdef, ram_addr_t RAM_size,
1481 qemu_irq *cpu_irqs, *slavio_irq, *espdma_irq, *ledma_irq; 1487 qemu_irq *cpu_irqs, *slavio_irq, *espdma_irq, *ledma_irq;
1482 qemu_irq *esp_reset, *le_reset; 1488 qemu_irq *esp_reset, *le_reset;
1483 qemu_irq *fdc_tc; 1489 qemu_irq *fdc_tc;
1484 - unsigned long prom_offset, kernel_size; 1490 + ram_addr_t ram_offset, prom_offset, tcx_offset;
  1491 + unsigned long kernel_size;
1485 int ret; 1492 int ret;
1486 char buf[1024]; 1493 char buf[1024];
1487 BlockDriverState *fd[MAX_FD]; 1494 BlockDriverState *fd[MAX_FD];
@@ -1512,10 +1519,11 @@ static void sun4c_hw_init(const struct sun4c_hwdef *hwdef, ram_addr_t RAM_size, @@ -1512,10 +1519,11 @@ static void sun4c_hw_init(const struct sun4c_hwdef *hwdef, ram_addr_t RAM_size,
1512 (unsigned int)(hwdef->max_mem / (1024 * 1024))); 1519 (unsigned int)(hwdef->max_mem / (1024 * 1024)));
1513 exit(1); 1520 exit(1);
1514 } 1521 }
1515 - cpu_register_physical_memory(0, RAM_size, 0); 1522 + ram_offset = qemu_ram_alloc(RAM_size);
  1523 + cpu_register_physical_memory(0, RAM_size, ram_offset);
1516 1524
1517 /* load boot prom */ 1525 /* load boot prom */
1518 - prom_offset = RAM_size + hwdef->vram_size; 1526 + prom_offset = qemu_ram_alloc(PROM_SIZE_MAX);
1519 cpu_register_physical_memory(hwdef->slavio_base, 1527 cpu_register_physical_memory(hwdef->slavio_base,
1520 (PROM_SIZE_MAX + TARGET_PAGE_SIZE - 1) & 1528 (PROM_SIZE_MAX + TARGET_PAGE_SIZE - 1) &
1521 TARGET_PAGE_MASK, 1529 TARGET_PAGE_MASK,
@@ -1532,7 +1540,6 @@ static void sun4c_hw_init(const struct sun4c_hwdef *hwdef, ram_addr_t RAM_size, @@ -1532,7 +1540,6 @@ static void sun4c_hw_init(const struct sun4c_hwdef *hwdef, ram_addr_t RAM_size,
1532 buf); 1540 buf);
1533 exit(1); 1541 exit(1);
1534 } 1542 }
1535 - prom_offset += (ret + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK;  
1536 1543
1537 /* set up devices */ 1544 /* set up devices */
1538 slavio_intctl = sun4c_intctl_init(hwdef->intctl_base, 1545 slavio_intctl = sun4c_intctl_init(hwdef->intctl_base,
@@ -1552,7 +1559,8 @@ static void sun4c_hw_init(const struct sun4c_hwdef *hwdef, ram_addr_t RAM_size, @@ -1552,7 +1559,8 @@ static void sun4c_hw_init(const struct sun4c_hwdef *hwdef, ram_addr_t RAM_size,
1552 fprintf(stderr, "qemu: Unsupported depth: %d\n", graphic_depth); 1559 fprintf(stderr, "qemu: Unsupported depth: %d\n", graphic_depth);
1553 exit (1); 1560 exit (1);
1554 } 1561 }
1555 - tcx_init(ds, hwdef->tcx_base, phys_ram_base + RAM_size, RAM_size, 1562 + tcx_offset = qemu_ram_alloc(hwdef->vram_size);
  1563 + tcx_init(ds, hwdef->tcx_base, phys_ram_base + tcx_offset, tcx_offset,
1556 hwdef->vram_size, graphic_width, graphic_height, graphic_depth); 1564 hwdef->vram_size, graphic_width, graphic_height, graphic_depth);
1557 1565
1558 if (nd_table[0].model == NULL 1566 if (nd_table[0].model == NULL
hw/sun4u.c
@@ -344,7 +344,8 @@ static void sun4uv_init(ram_addr_t RAM_size, int vga_ram_size, @@ -344,7 +344,8 @@ static void sun4uv_init(ram_addr_t RAM_size, int vga_ram_size,
344 m48t59_t *nvram; 344 m48t59_t *nvram;
345 int ret, linux_boot; 345 int ret, linux_boot;
346 unsigned int i; 346 unsigned int i;
347 - long prom_offset, initrd_size, kernel_size; 347 + ram_addr_t ram_offset, prom_offset, vga_ram_offset;
  348 + long initrd_size, kernel_size;
348 PCIBus *pci_bus; 349 PCIBus *pci_bus;
349 QEMUBH *bh; 350 QEMUBH *bh;
350 qemu_irq *irq; 351 qemu_irq *irq;
@@ -387,9 +388,10 @@ static void sun4uv_init(ram_addr_t RAM_size, int vga_ram_size, @@ -387,9 +388,10 @@ static void sun4uv_init(ram_addr_t RAM_size, int vga_ram_size,
387 env->npc = env->pc + 4; 388 env->npc = env->pc + 4;
388 389
389 /* allocate RAM */ 390 /* allocate RAM */
390 - cpu_register_physical_memory(0, RAM_size, 0); 391 + ram_offset = qemu_ram_alloc(RAM_size);
  392 + cpu_register_physical_memory(0, RAM_size, ram_offset);
391 393
392 - prom_offset = RAM_size + vga_ram_size; 394 + prom_offset = qemu_ram_alloc(PROM_SIZE_MAX);
393 cpu_register_physical_memory(hwdef->prom_addr, 395 cpu_register_physical_memory(hwdef->prom_addr,
394 (PROM_SIZE_MAX + TARGET_PAGE_SIZE) & 396 (PROM_SIZE_MAX + TARGET_PAGE_SIZE) &
395 TARGET_PAGE_MASK, 397 TARGET_PAGE_MASK,
@@ -451,8 +453,9 @@ static void sun4uv_init(ram_addr_t RAM_size, int vga_ram_size, @@ -451,8 +453,9 @@ static void sun4uv_init(ram_addr_t RAM_size, int vga_ram_size,
451 } 453 }
452 pci_bus = pci_apb_init(APB_SPECIAL_BASE, APB_MEM_BASE, NULL); 454 pci_bus = pci_apb_init(APB_SPECIAL_BASE, APB_MEM_BASE, NULL);
453 isa_mem_base = VGA_BASE; 455 isa_mem_base = VGA_BASE;
454 - pci_cirrus_vga_init(pci_bus, ds, phys_ram_base + RAM_size, RAM_size,  
455 - vga_ram_size); 456 + vga_ram_offset = qemu_ram_alloc(vga_ram_size);
  457 + pci_cirrus_vga_init(pci_bus, ds, phys_ram_base + vga_ram_offset,
  458 + vga_ram_offset, vga_ram_size);
456 459
457 i = 0; 460 i = 0;
458 if (hwdef->console_serial_base) { 461 if (hwdef->console_serial_base) {