aboutsummaryrefslogtreecommitdiff
path: root/hw/sun4m.c
diff options
context:
space:
mode:
authorblueswir1 <blueswir1@c046a42c-6fe2-441c-8c8c-71466251a162>2008-05-12 17:22:13 +0000
committerblueswir1 <blueswir1@c046a42c-6fe2-441c-8c8c-71466251a162>2008-05-12 17:22:13 +0000
commit293f78bc1b33e4da0fce3d59a7cc8426db8eb04c (patch)
treef14e8e9a4dcd26fe9f98dd02805d86373204d974 /hw/sun4m.c
parent5af451868c5bd93ea24672b0fa1b765cbd563cc6 (diff)
downloadqemu-293f78bc1b33e4da0fce3d59a7cc8426db8eb04c.zip
qemu-293f78bc1b33e4da0fce3d59a7cc8426db8eb04c.tar.gz
qemu-293f78bc1b33e4da0fce3d59a7cc8426db8eb04c.tar.bz2
Remove most uses of phys_ram_base (initial patch by Ian Jackson)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4442 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'hw/sun4m.c')
-rw-r--r--hw/sun4m.c49
1 files changed, 27 insertions, 22 deletions
diff --git a/hw/sun4m.c b/hw/sun4m.c
index 5e0eca4..af7278c 100644
--- a/hw/sun4m.c
+++ b/hw/sun4m.c
@@ -182,7 +182,7 @@ static void nvram_init(m48t59_t *nvram, uint8_t *macaddr, const char *cmdline,
header->kernel_image = cpu_to_be64((uint64_t)KERNEL_LOAD_ADDR);
header->kernel_size = cpu_to_be64((uint64_t)kernel_size);
if (cmdline) {
- strcpy(phys_ram_base + CMDLINE_ADDR, cmdline);
+ pstrcpy_targphys(CMDLINE_ADDR, TARGET_PAGE_SIZE, cmdline);
header->cmdline = cpu_to_be64((uint64_t)CMDLINE_ADDR);
header->cmdline_size = cpu_to_be64((uint64_t)strlen(cmdline));
}
@@ -315,7 +315,8 @@ static void secondary_cpu_reset(void *opaque)
}
static unsigned long sun4m_load_kernel(const char *kernel_filename,
- const char *initrd_filename)
+ const char *initrd_filename,
+ ram_addr_t RAM_size)
{
int linux_boot;
unsigned int i;
@@ -328,11 +329,12 @@ static unsigned long sun4m_load_kernel(const char *kernel_filename,
kernel_size = load_elf(kernel_filename, -0xf0000000ULL, NULL, NULL,
NULL);
if (kernel_size < 0)
- kernel_size = load_aout(kernel_filename,
- phys_ram_base + KERNEL_LOAD_ADDR);
+ kernel_size = load_aout(kernel_filename, KERNEL_LOAD_ADDR,
+ RAM_size - KERNEL_LOAD_ADDR);
if (kernel_size < 0)
- kernel_size = load_image(kernel_filename,
- phys_ram_base + KERNEL_LOAD_ADDR);
+ kernel_size = load_image_targphys(kernel_filename,
+ KERNEL_LOAD_ADDR,
+ RAM_size - KERNEL_LOAD_ADDR);
if (kernel_size < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n",
kernel_filename);
@@ -342,8 +344,9 @@ static unsigned long sun4m_load_kernel(const char *kernel_filename,
/* load initrd */
initrd_size = 0;
if (initrd_filename) {
- initrd_size = load_image(initrd_filename,
- phys_ram_base + INITRD_LOAD_ADDR);
+ initrd_size = load_image_targphys(initrd_filename,
+ INITRD_LOAD_ADDR,
+ RAM_size - INITRD_LOAD_ADDR);
if (initrd_size < 0) {
fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
initrd_filename);
@@ -352,12 +355,9 @@ static unsigned long sun4m_load_kernel(const char *kernel_filename,
}
if (initrd_size > 0) {
for (i = 0; i < 64 * TARGET_PAGE_SIZE; i += TARGET_PAGE_SIZE) {
- if (ldl_raw(phys_ram_base + KERNEL_LOAD_ADDR + i)
- == 0x48647253) { // HdrS
- stl_raw(phys_ram_base + KERNEL_LOAD_ADDR + i + 16,
- INITRD_LOAD_ADDR);
- stl_raw(phys_ram_base + KERNEL_LOAD_ADDR + i + 20,
- initrd_size);
+ if (ldl_phys(KERNEL_LOAD_ADDR + i) == 0x48647253) { // HdrS
+ stl_phys(KERNEL_LOAD_ADDR + i + 16, INITRD_LOAD_ADDR);
+ stl_phys(KERNEL_LOAD_ADDR + i + 20, initrd_size);
break;
}
}
@@ -435,7 +435,7 @@ static void sun4m_hw_init(const struct hwdef *hwdef, ram_addr_t RAM_size,
snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
ret = load_elf(buf, hwdef->slavio_base - PROM_VADDR, NULL, NULL, NULL);
if (ret < 0 || ret > PROM_SIZE_MAX)
- ret = load_image(buf, phys_ram_base + prom_offset);
+ ret = load_image_targphys(buf, prom_offset, PROM_SIZE_MAX);
if (ret < 0 || ret > PROM_SIZE_MAX) {
fprintf(stderr, "qemu: could not load prom '%s'\n",
buf);
@@ -452,10 +452,12 @@ static void sun4m_hw_init(const struct hwdef *hwdef, ram_addr_t RAM_size,
hwdef->clock_irq);
if (hwdef->idreg_base != (target_phys_addr_t)-1) {
- stl_raw(phys_ram_base + prom_offset, 0xfe810103);
+ static const uint8_t idreg_data[] = { 0xfe, 0x81, 0x01, 0x03 };
- cpu_register_physical_memory(hwdef->idreg_base, sizeof(uint32_t),
+ cpu_register_physical_memory(hwdef->idreg_base, sizeof(idreg_data),
prom_offset | IO_MEM_ROM);
+ cpu_physical_memory_write_rom(hwdef->idreg_base, idreg_data,
+ sizeof(idreg_data));
}
iommu = iommu_init(hwdef->iommu_base, hwdef->iommu_version,
@@ -534,7 +536,8 @@ static void sun4m_hw_init(const struct hwdef *hwdef, ram_addr_t RAM_size,
if (hwdef->cs_base != (target_phys_addr_t)-1)
cs_init(hwdef->cs_base, hwdef->cs_irq, slavio_intctl);
- kernel_size = sun4m_load_kernel(kernel_filename, initrd_filename);
+ kernel_size = sun4m_load_kernel(kernel_filename, initrd_filename,
+ RAM_size);
nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, kernel_cmdline,
boot_device, RAM_size, kernel_size, graphic_width,
@@ -602,7 +605,7 @@ static void sun4c_hw_init(const struct hwdef *hwdef, ram_addr_t RAM_size,
snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
ret = load_elf(buf, hwdef->slavio_base - PROM_VADDR, NULL, NULL, NULL);
if (ret < 0 || ret > PROM_SIZE_MAX)
- ret = load_image(buf, phys_ram_base + prom_offset);
+ ret = load_image_targphys(buf, prom_offset, PROM_SIZE_MAX);
if (ret < 0 || ret > PROM_SIZE_MAX) {
fprintf(stderr, "qemu: could not load prom '%s'\n",
buf);
@@ -683,7 +686,8 @@ static void sun4c_hw_init(const struct hwdef *hwdef, ram_addr_t RAM_size,
esp_scsi_attach(main_esp, drives_table[drive_index].bdrv, i);
}
- kernel_size = sun4m_load_kernel(kernel_filename, initrd_filename);
+ kernel_size = sun4m_load_kernel(kernel_filename, initrd_filename,
+ RAM_size);
nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, kernel_cmdline,
boot_device, RAM_size, kernel_size, graphic_width,
@@ -1417,7 +1421,7 @@ static void sun4d_hw_init(const struct sun4d_hwdef *hwdef, ram_addr_t RAM_size,
snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
ret = load_elf(buf, hwdef->slavio_base - PROM_VADDR, NULL, NULL, NULL);
if (ret < 0 || ret > PROM_SIZE_MAX)
- ret = load_image(buf, phys_ram_base + prom_offset);
+ ret = load_image_targphys(buf, prom_offset, PROM_SIZE_MAX);
if (ret < 0 || ret > PROM_SIZE_MAX) {
fprintf(stderr, "qemu: could not load prom '%s'\n",
buf);
@@ -1486,7 +1490,8 @@ static void sun4d_hw_init(const struct sun4d_hwdef *hwdef, ram_addr_t RAM_size,
esp_scsi_attach(main_esp, drives_table[drive_index].bdrv, i);
}
- kernel_size = sun4m_load_kernel(kernel_filename, initrd_filename);
+ kernel_size = sun4m_load_kernel(kernel_filename, initrd_filename,
+ RAM_size);
nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, kernel_cmdline,
boot_device, RAM_size, kernel_size, graphic_width,