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 433 qemu_irq *esp_reset, *le_reset;
434 434 qemu_irq *fdc_tc;
435 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 438 int ret;
438 439 char buf[1024];
439 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 475 (unsigned int)(hwdef->max_mem / (1024 * 1024)));
475 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 481 /* load boot prom */
480   - prom_offset = RAM_size + hwdef->vram_size;
  482 + prom_offset = qemu_ram_alloc(PROM_SIZE_MAX);
481 483 cpu_register_physical_memory(hwdef->slavio_base,
482 484 (PROM_SIZE_MAX + TARGET_PAGE_SIZE - 1) &
483 485 TARGET_PAGE_MASK,
... ... @@ -494,7 +496,6 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size,
494 496 buf);
495 497 exit(1);
496 498 }
497   - prom_offset += (ret + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK;
498 499  
499 500 /* set up devices */
500 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 508 if (hwdef->idreg_base != (target_phys_addr_t)-1) {
508 509 static const uint8_t idreg_data[] = { 0xfe, 0x81, 0x01, 0x03 };
509 510  
  511 + idreg_offset = qemu_ram_alloc(sizeof(idreg_data));
510 512 cpu_register_physical_memory(hwdef->idreg_base, sizeof(idreg_data),
511   - prom_offset | IO_MEM_ROM);
  513 + idreg_offset | IO_MEM_ROM);
512 514 cpu_physical_memory_write_rom(hwdef->idreg_base, idreg_data,
513 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 529 fprintf(stderr, "qemu: Unsupported depth: %d\n", graphic_depth);
528 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 534 hwdef->vram_size, graphic_width, graphic_height, graphic_depth);
532 535  
533 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 1263 qemu_irq *cpu_irqs[MAX_CPUS], *sbi_irq, *sbi_cpu_irq,
1261 1264 *espdma_irq, *ledma_irq;
1262 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 1268 int ret;
1265 1269 char buf[1024];
1266 1270 int drive_index;
... ... @@ -1299,10 +1303,11 @@ static void sun4d_hw_init(const struct sun4d_hwdef *hwdef, ram_addr_t RAM_size,
1299 1303 (unsigned int)(hwdef->max_mem / (1024 * 1024)));
1300 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 1309 /* load boot prom */
1305   - prom_offset = RAM_size + hwdef->vram_size;
  1310 + prom_offset = qemu_ram_alloc(PROM_SIZE_MAX);
1306 1311 cpu_register_physical_memory(hwdef->slavio_base,
1307 1312 (PROM_SIZE_MAX + TARGET_PAGE_SIZE - 1) &
1308 1313 TARGET_PAGE_MASK,
... ... @@ -1339,7 +1344,8 @@ static void sun4d_hw_init(const struct sun4d_hwdef *hwdef, ram_addr_t RAM_size,
1339 1344 fprintf(stderr, "qemu: Unsupported depth: %d\n", graphic_depth);
1340 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 1349 hwdef->vram_size, graphic_width, graphic_height, graphic_depth);
1344 1350  
1345 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 1487 qemu_irq *cpu_irqs, *slavio_irq, *espdma_irq, *ledma_irq;
1482 1488 qemu_irq *esp_reset, *le_reset;
1483 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 1492 int ret;
1486 1493 char buf[1024];
1487 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 1519 (unsigned int)(hwdef->max_mem / (1024 * 1024)));
1513 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 1525 /* load boot prom */
1518   - prom_offset = RAM_size + hwdef->vram_size;
  1526 + prom_offset = qemu_ram_alloc(PROM_SIZE_MAX);
1519 1527 cpu_register_physical_memory(hwdef->slavio_base,
1520 1528 (PROM_SIZE_MAX + TARGET_PAGE_SIZE - 1) &
1521 1529 TARGET_PAGE_MASK,
... ... @@ -1532,7 +1540,6 @@ static void sun4c_hw_init(const struct sun4c_hwdef *hwdef, ram_addr_t RAM_size,
1532 1540 buf);
1533 1541 exit(1);
1534 1542 }
1535   - prom_offset += (ret + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK;
1536 1543  
1537 1544 /* set up devices */
1538 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 1559 fprintf(stderr, "qemu: Unsupported depth: %d\n", graphic_depth);
1553 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 1564 hwdef->vram_size, graphic_width, graphic_height, graphic_depth);
1557 1565  
1558 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 344 m48t59_t *nvram;
345 345 int ret, linux_boot;
346 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 349 PCIBus *pci_bus;
349 350 QEMUBH *bh;
350 351 qemu_irq *irq;
... ... @@ -387,9 +388,10 @@ static void sun4uv_init(ram_addr_t RAM_size, int vga_ram_size,
387 388 env->npc = env->pc + 4;
388 389  
389 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 395 cpu_register_physical_memory(hwdef->prom_addr,
394 396 (PROM_SIZE_MAX + TARGET_PAGE_SIZE) &
395 397 TARGET_PAGE_MASK,
... ... @@ -451,8 +453,9 @@ static void sun4uv_init(ram_addr_t RAM_size, int vga_ram_size,
451 453 }
452 454 pci_bus = pci_apb_init(APB_SPECIAL_BASE, APB_MEM_BASE, NULL);
453 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 460 i = 0;
458 461 if (hwdef->console_serial_base) {
... ...