2017-10-01 22:11:45 +02:00
|
|
|
/*
|
|
|
|
* QEMU HPPA hardware system emulator.
|
|
|
|
* Copyright 2018 Helge Deller <deller@gmx.de>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "qemu/osdep.h"
|
|
|
|
#include "qemu-common.h"
|
2020-10-28 12:36:57 +01:00
|
|
|
#include "qemu/datadir.h"
|
2017-10-01 22:11:45 +02:00
|
|
|
#include "cpu.h"
|
|
|
|
#include "elf.h"
|
|
|
|
#include "hw/loader.h"
|
|
|
|
#include "qemu/error-report.h"
|
2019-08-12 07:23:38 +02:00
|
|
|
#include "sysemu/reset.h"
|
2017-10-01 22:11:45 +02:00
|
|
|
#include "sysemu/sysemu.h"
|
2020-08-26 17:45:43 +02:00
|
|
|
#include "sysemu/runstate.h"
|
2019-10-04 01:03:53 +02:00
|
|
|
#include "hw/rtc/mc146818rtc.h"
|
2017-10-01 22:11:45 +02:00
|
|
|
#include "hw/timer/i8254.h"
|
|
|
|
#include "hw/char/serial.h"
|
2019-12-20 22:15:08 +01:00
|
|
|
#include "hw/net/lasi_82596.h"
|
2022-01-05 23:09:04 +01:00
|
|
|
#include "hw/nmi.h"
|
2018-05-03 21:50:25 +02:00
|
|
|
#include "hppa_sys.h"
|
2018-06-25 14:42:11 +02:00
|
|
|
#include "qemu/units.h"
|
2017-10-01 22:11:45 +02:00
|
|
|
#include "qapi/error.h"
|
2019-12-12 17:15:43 +01:00
|
|
|
#include "net/net.h"
|
2018-02-04 07:41:41 +01:00
|
|
|
#include "qemu/log.h"
|
2020-02-28 12:46:40 +01:00
|
|
|
#include "net/net.h"
|
2017-10-01 22:11:45 +02:00
|
|
|
|
2017-10-08 22:47:27 +02:00
|
|
|
#define MAX_IDE_BUS 2
|
|
|
|
|
2020-07-27 22:43:44 +02:00
|
|
|
#define MIN_SEABIOS_HPPA_VERSION 1 /* require at least this fw version */
|
|
|
|
|
2020-08-26 17:45:43 +02:00
|
|
|
#define HPA_POWER_BUTTON (FIRMWARE_END - 0x10)
|
|
|
|
|
|
|
|
static void hppa_powerdown_req(Notifier *n, void *opaque)
|
|
|
|
{
|
|
|
|
hwaddr soft_power_reg = HPA_POWER_BUTTON;
|
|
|
|
uint32_t val;
|
|
|
|
|
|
|
|
val = ldl_be_phys(&address_space_memory, soft_power_reg);
|
|
|
|
if ((val >> 8) == 0) {
|
|
|
|
/* immediately shut down when under hardware control */
|
|
|
|
qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* clear bit 31 to indicate that the power switch was pressed. */
|
|
|
|
val &= ~1;
|
|
|
|
stl_be_phys(&address_space_memory, soft_power_reg, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Notifier hppa_system_powerdown_notifier = {
|
|
|
|
.notify = hppa_powerdown_req
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2017-10-08 22:47:27 +02:00
|
|
|
static ISABus *hppa_isa_bus(void)
|
|
|
|
{
|
|
|
|
ISABus *isa_bus;
|
|
|
|
qemu_irq *isa_irqs;
|
|
|
|
MemoryRegion *isa_region;
|
|
|
|
|
|
|
|
isa_region = g_new(MemoryRegion, 1);
|
|
|
|
memory_region_init_io(isa_region, NULL, &hppa_pci_ignore_ops,
|
|
|
|
NULL, "isa-io", 0x800);
|
|
|
|
memory_region_add_subregion(get_system_memory(), IDE_HPA,
|
|
|
|
isa_region);
|
|
|
|
|
|
|
|
isa_bus = isa_bus_new(NULL, get_system_memory(), isa_region,
|
|
|
|
&error_abort);
|
|
|
|
isa_irqs = i8259_init(isa_bus,
|
|
|
|
/* qemu_allocate_irq(dino_set_isa_irq, s, 0)); */
|
|
|
|
NULL);
|
|
|
|
isa_bus_irqs(isa_bus, isa_irqs);
|
|
|
|
|
|
|
|
return isa_bus;
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint64_t cpu_hppa_to_phys(void *opaque, uint64_t addr)
|
|
|
|
{
|
|
|
|
addr &= (0x10000000 - 1);
|
|
|
|
return addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HPPACPU *cpu[HPPA_MAX_CPUS];
|
|
|
|
static uint64_t firmware_entry;
|
2017-10-01 22:11:45 +02:00
|
|
|
|
2020-08-09 17:06:50 +02:00
|
|
|
static void fw_cfg_boot_set(void *opaque, const char *boot_device,
|
|
|
|
Error **errp)
|
|
|
|
{
|
|
|
|
fw_cfg_modify_i16(opaque, FW_CFG_BOOT_DEVICE, boot_device[0]);
|
|
|
|
}
|
|
|
|
|
2020-07-27 22:43:44 +02:00
|
|
|
static FWCfgState *create_fw_cfg(MachineState *ms)
|
|
|
|
{
|
|
|
|
FWCfgState *fw_cfg;
|
|
|
|
uint64_t val;
|
|
|
|
|
2020-09-02 21:21:01 +02:00
|
|
|
fw_cfg = fw_cfg_init_mem(FW_CFG_IO_BASE, FW_CFG_IO_BASE + 4);
|
2020-07-27 22:43:44 +02:00
|
|
|
fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, ms->smp.cpus);
|
|
|
|
fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, HPPA_MAX_CPUS);
|
2020-10-28 11:19:23 +01:00
|
|
|
fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, ms->ram_size);
|
2020-07-27 22:43:44 +02:00
|
|
|
|
|
|
|
val = cpu_to_le64(MIN_SEABIOS_HPPA_VERSION);
|
|
|
|
fw_cfg_add_file(fw_cfg, "/etc/firmware-min-version",
|
|
|
|
g_memdup(&val, sizeof(val)), sizeof(val));
|
|
|
|
|
2020-08-27 13:10:32 +02:00
|
|
|
val = cpu_to_le64(HPPA_TLB_ENTRIES);
|
|
|
|
fw_cfg_add_file(fw_cfg, "/etc/cpu/tlb_entries",
|
|
|
|
g_memdup(&val, sizeof(val)), sizeof(val));
|
|
|
|
|
|
|
|
val = cpu_to_le64(HPPA_BTLB_ENTRIES);
|
|
|
|
fw_cfg_add_file(fw_cfg, "/etc/cpu/btlb_entries",
|
|
|
|
g_memdup(&val, sizeof(val)), sizeof(val));
|
|
|
|
|
2020-08-26 17:45:43 +02:00
|
|
|
val = cpu_to_le64(HPA_POWER_BUTTON);
|
|
|
|
fw_cfg_add_file(fw_cfg, "/etc/power-button-addr",
|
|
|
|
g_memdup(&val, sizeof(val)), sizeof(val));
|
|
|
|
|
2020-08-09 17:06:50 +02:00
|
|
|
fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, ms->boot_order[0]);
|
|
|
|
qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
|
|
|
|
|
2020-07-27 22:43:44 +02:00
|
|
|
return fw_cfg;
|
|
|
|
}
|
|
|
|
|
2017-10-01 22:11:45 +02:00
|
|
|
static void machine_hppa_init(MachineState *machine)
|
|
|
|
{
|
2017-10-08 22:47:27 +02:00
|
|
|
const char *kernel_filename = machine->kernel_filename;
|
|
|
|
const char *kernel_cmdline = machine->kernel_cmdline;
|
|
|
|
const char *initrd_filename = machine->initrd_filename;
|
2018-09-19 19:20:58 +02:00
|
|
|
DeviceState *dev;
|
2017-10-08 22:47:27 +02:00
|
|
|
PCIBus *pci_bus;
|
|
|
|
ISABus *isa_bus;
|
|
|
|
qemu_irq rtc_irq, serial_irq;
|
|
|
|
char *firmware_filename;
|
|
|
|
uint64_t firmware_low, firmware_high;
|
|
|
|
long size;
|
|
|
|
uint64_t kernel_entry = 0, kernel_low, kernel_high;
|
|
|
|
MemoryRegion *addr_space = get_system_memory();
|
|
|
|
MemoryRegion *rom_region;
|
|
|
|
MemoryRegion *cpu_region;
|
|
|
|
long i;
|
2019-05-18 22:54:27 +02:00
|
|
|
unsigned int smp_cpus = machine->smp.cpus;
|
2019-12-20 22:15:11 +01:00
|
|
|
SysBusDevice *s;
|
2017-10-08 22:47:27 +02:00
|
|
|
|
|
|
|
/* Create CPUs. */
|
|
|
|
for (i = 0; i < smp_cpus; i++) {
|
2019-10-01 15:36:24 +02:00
|
|
|
char *name = g_strdup_printf("cpu%ld-io-eir", i);
|
2017-10-08 22:47:27 +02:00
|
|
|
cpu[i] = HPPA_CPU(cpu_create(machine->cpu_type));
|
|
|
|
|
|
|
|
cpu_region = g_new(MemoryRegion, 1);
|
|
|
|
memory_region_init_io(cpu_region, OBJECT(cpu[i]), &hppa_io_eir_ops,
|
2019-10-01 15:36:24 +02:00
|
|
|
cpu[i], name, 4);
|
2017-10-08 22:47:27 +02:00
|
|
|
memory_region_add_subregion(addr_space, CPU_HPA + i * 0x1000,
|
|
|
|
cpu_region);
|
2019-10-01 15:36:24 +02:00
|
|
|
g_free(name);
|
2017-10-08 22:47:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Main memory region. */
|
2020-01-09 01:05:24 +01:00
|
|
|
if (machine->ram_size > 3 * GiB) {
|
|
|
|
error_report("RAM size is currently restricted to 3GB");
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
2020-02-19 17:09:15 +01:00
|
|
|
memory_region_add_subregion_overlap(addr_space, 0, machine->ram, -1);
|
|
|
|
|
2017-10-08 22:47:27 +02:00
|
|
|
|
2019-12-20 22:15:08 +01:00
|
|
|
/* Init Lasi chip */
|
|
|
|
lasi_init(addr_space);
|
|
|
|
|
2017-10-08 22:47:27 +02:00
|
|
|
/* Init Dino (PCI host bus chip). */
|
|
|
|
pci_bus = dino_init(addr_space, &rtc_irq, &serial_irq);
|
|
|
|
assert(pci_bus);
|
|
|
|
|
|
|
|
/* Create ISA bus. */
|
|
|
|
isa_bus = hppa_isa_bus();
|
|
|
|
assert(isa_bus);
|
|
|
|
|
|
|
|
/* Realtime clock, used by firmware for PDC_TOD call. */
|
|
|
|
mc146818_rtc_init(isa_bus, 2000, rtc_irq);
|
|
|
|
|
|
|
|
/* Serial code setup. */
|
2018-04-20 16:52:43 +02:00
|
|
|
if (serial_hd(0)) {
|
2017-10-08 22:47:27 +02:00
|
|
|
uint32_t addr = DINO_UART_HPA + 0x800;
|
|
|
|
serial_mm_init(addr_space, addr, 0, serial_irq,
|
2018-04-20 16:52:43 +02:00
|
|
|
115200, serial_hd(0), DEVICE_BIG_ENDIAN);
|
2017-10-08 22:47:27 +02:00
|
|
|
}
|
|
|
|
|
2020-07-27 22:43:44 +02:00
|
|
|
/* fw_cfg configuration interface */
|
|
|
|
create_fw_cfg(machine);
|
|
|
|
|
2017-10-08 22:47:27 +02:00
|
|
|
/* SCSI disk setup. */
|
2018-09-19 19:20:58 +02:00
|
|
|
dev = DEVICE(pci_create_simple(pci_bus, -1, "lsi53c895a"));
|
|
|
|
lsi53c8xx_handle_legacy_cmdline(dev);
|
2017-10-08 22:47:27 +02:00
|
|
|
|
2019-12-20 22:15:11 +01:00
|
|
|
/* Graphics setup. */
|
|
|
|
if (machine->enable_graphics && vga_interface_type != VGA_NONE) {
|
qdev: Convert uses of qdev_create() with Coccinelle
This is the transformation explained in the commit before previous.
Takes care of just one pattern that needs conversion. More to come in
this series.
Coccinelle script:
@ depends on !(file in "hw/arm/highbank.c")@
expression bus, type_name, dev, expr;
@@
- dev = qdev_create(bus, type_name);
+ dev = qdev_new(type_name);
... when != dev = expr
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, bus, &error_fatal);
@@
expression bus, type_name, dev, expr;
identifier DOWN;
@@
- dev = DOWN(qdev_create(bus, type_name));
+ dev = DOWN(qdev_new(type_name));
... when != dev = expr
- qdev_init_nofail(DEVICE(dev));
+ qdev_realize_and_unref(DEVICE(dev), bus, &error_fatal);
@@
expression bus, type_name, expr;
identifier dev;
@@
- DeviceState *dev = qdev_create(bus, type_name);
+ DeviceState *dev = qdev_new(type_name);
... when != dev = expr
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, bus, &error_fatal);
@@
expression bus, type_name, dev, expr, errp;
symbol true;
@@
- dev = qdev_create(bus, type_name);
+ dev = qdev_new(type_name);
... when != dev = expr
- object_property_set_bool(OBJECT(dev), true, "realized", errp);
+ qdev_realize_and_unref(dev, bus, errp);
@@
expression bus, type_name, expr, errp;
identifier dev;
symbol true;
@@
- DeviceState *dev = qdev_create(bus, type_name);
+ DeviceState *dev = qdev_new(type_name);
... when != dev = expr
- object_property_set_bool(OBJECT(dev), true, "realized", errp);
+ qdev_realize_and_unref(dev, bus, errp);
The first rule exempts hw/arm/highbank.c, because it matches along two
control flow paths there, with different @type_name. Covered by the
next commit's manual conversions.
Missing #include "qapi/error.h" added manually.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-10-armbru@redhat.com>
[Conflicts in hw/misc/empty_slot.c and hw/sparc/leon3.c resolved]
2020-06-10 07:31:58 +02:00
|
|
|
dev = qdev_new("artist");
|
2019-12-20 22:15:11 +01:00
|
|
|
s = SYS_BUS_DEVICE(dev);
|
sysbus: Convert to sysbus_realize() etc. with Coccinelle
Convert from qdev_realize(), qdev_realize_and_unref() with null @bus
argument to sysbus_realize(), sysbus_realize_and_unref().
Coccinelle script:
@@
expression dev, errp;
@@
- qdev_realize(DEVICE(dev), NULL, errp);
+ sysbus_realize(SYS_BUS_DEVICE(dev), errp);
@@
expression sysbus_dev, dev, errp;
@@
+ sysbus_dev = SYS_BUS_DEVICE(dev);
- qdev_realize_and_unref(dev, NULL, errp);
+ sysbus_realize_and_unref(sysbus_dev, errp);
- sysbus_dev = SYS_BUS_DEVICE(dev);
@@
expression sysbus_dev, dev, errp;
expression expr;
@@
sysbus_dev = SYS_BUS_DEVICE(dev);
... when != dev = expr;
- qdev_realize_and_unref(dev, NULL, errp);
+ sysbus_realize_and_unref(sysbus_dev, errp);
@@
expression dev, errp;
@@
- qdev_realize_and_unref(DEVICE(dev), NULL, errp);
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), errp);
@@
expression dev, errp;
@@
- qdev_realize_and_unref(dev, NULL, errp);
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), errp);
Whitespace changes minimized manually.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-46-armbru@redhat.com>
[Conflicts in hw/misc/empty_slot.c and hw/sparc/leon3.c resolved]
2020-06-10 07:32:34 +02:00
|
|
|
sysbus_realize_and_unref(s, &error_fatal);
|
2019-12-20 22:15:11 +01:00
|
|
|
sysbus_mmio_map(s, 0, LASI_GFX_HPA);
|
|
|
|
sysbus_mmio_map(s, 1, ARTIST_FB_ADDR);
|
|
|
|
}
|
|
|
|
|
2019-12-21 23:25:30 +01:00
|
|
|
/* Network setup. */
|
2017-10-08 22:47:27 +02:00
|
|
|
for (i = 0; i < nb_nics; i++) {
|
2019-12-20 22:15:08 +01:00
|
|
|
if (!enable_lasi_lan()) {
|
2019-12-21 23:25:30 +01:00
|
|
|
pci_nic_init_nofail(&nd_table[i], pci_bus, "tulip", NULL);
|
2019-12-20 22:15:08 +01:00
|
|
|
}
|
2017-10-08 22:47:27 +02:00
|
|
|
}
|
|
|
|
|
2020-08-26 17:45:43 +02:00
|
|
|
/* register power switch emulation */
|
|
|
|
qemu_register_powerdown_notifier(&hppa_system_powerdown_notifier);
|
|
|
|
|
2017-10-08 22:47:27 +02:00
|
|
|
/* Load firmware. Given that this is not "real" firmware,
|
|
|
|
but one explicitly written for the emulation, we might as
|
|
|
|
well load it directly from an ELF image. */
|
|
|
|
firmware_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS,
|
2020-10-26 15:30:17 +01:00
|
|
|
machine->firmware ?: "hppa-firmware.img");
|
2017-10-08 22:47:27 +02:00
|
|
|
if (firmware_filename == NULL) {
|
|
|
|
error_report("no firmware provided");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2019-01-15 13:18:03 +01:00
|
|
|
size = load_elf(firmware_filename, NULL, NULL, NULL,
|
2020-01-26 23:55:04 +01:00
|
|
|
&firmware_entry, &firmware_low, &firmware_high, NULL,
|
2017-10-08 22:47:27 +02:00
|
|
|
true, EM_PARISC, 0, 0);
|
|
|
|
|
|
|
|
/* Unfortunately, load_elf sign-extends reading elf32. */
|
|
|
|
firmware_entry = (target_ureg)firmware_entry;
|
|
|
|
firmware_low = (target_ureg)firmware_low;
|
|
|
|
firmware_high = (target_ureg)firmware_high;
|
|
|
|
|
|
|
|
if (size < 0) {
|
|
|
|
error_report("could not load firmware '%s'", firmware_filename);
|
|
|
|
exit(1);
|
|
|
|
}
|
2018-02-04 07:41:41 +01:00
|
|
|
qemu_log_mask(CPU_LOG_PAGE, "Firmware loaded at 0x%08" PRIx64
|
|
|
|
"-0x%08" PRIx64 ", entry at 0x%08" PRIx64 ".\n",
|
|
|
|
firmware_low, firmware_high, firmware_entry);
|
2020-01-09 01:05:23 +01:00
|
|
|
if (firmware_low < FIRMWARE_START || firmware_high >= FIRMWARE_END) {
|
2017-10-08 22:47:27 +02:00
|
|
|
error_report("Firmware overlaps with memory or IO space");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
g_free(firmware_filename);
|
|
|
|
|
|
|
|
rom_region = g_new(MemoryRegion, 1);
|
2019-10-08 13:33:18 +02:00
|
|
|
memory_region_init_ram(rom_region, NULL, "firmware",
|
|
|
|
(FIRMWARE_END - FIRMWARE_START), &error_fatal);
|
2017-10-08 22:47:27 +02:00
|
|
|
memory_region_add_subregion(addr_space, FIRMWARE_START, rom_region);
|
|
|
|
|
|
|
|
/* Load kernel */
|
|
|
|
if (kernel_filename) {
|
2019-01-15 13:18:03 +01:00
|
|
|
size = load_elf(kernel_filename, NULL, &cpu_hppa_to_phys,
|
2020-01-26 23:55:04 +01:00
|
|
|
NULL, &kernel_entry, &kernel_low, &kernel_high, NULL,
|
2017-10-08 22:47:27 +02:00
|
|
|
true, EM_PARISC, 0, 0);
|
|
|
|
|
|
|
|
/* Unfortunately, load_elf sign-extends reading elf32. */
|
|
|
|
kernel_entry = (target_ureg) cpu_hppa_to_phys(NULL, kernel_entry);
|
|
|
|
kernel_low = (target_ureg)kernel_low;
|
|
|
|
kernel_high = (target_ureg)kernel_high;
|
|
|
|
|
|
|
|
if (size < 0) {
|
|
|
|
error_report("could not load kernel '%s'", kernel_filename);
|
|
|
|
exit(1);
|
|
|
|
}
|
2018-02-04 07:41:41 +01:00
|
|
|
qemu_log_mask(CPU_LOG_PAGE, "Kernel loaded at 0x%08" PRIx64
|
|
|
|
"-0x%08" PRIx64 ", entry at 0x%08" PRIx64
|
2018-06-25 14:42:11 +02:00
|
|
|
", size %" PRIu64 " kB\n",
|
|
|
|
kernel_low, kernel_high, kernel_entry, size / KiB);
|
2017-10-08 22:47:27 +02:00
|
|
|
|
|
|
|
if (kernel_cmdline) {
|
|
|
|
cpu[0]->env.gr[24] = 0x4000;
|
|
|
|
pstrcpy_targphys("cmdline", cpu[0]->env.gr[24],
|
|
|
|
TARGET_PAGE_SIZE, kernel_cmdline);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (initrd_filename) {
|
|
|
|
ram_addr_t initrd_base;
|
2018-09-13 12:07:13 +02:00
|
|
|
int64_t initrd_size;
|
2017-10-08 22:47:27 +02:00
|
|
|
|
|
|
|
initrd_size = get_image_size(initrd_filename);
|
|
|
|
if (initrd_size < 0) {
|
|
|
|
error_report("could not load initial ram disk '%s'",
|
|
|
|
initrd_filename);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Load the initrd image high in memory.
|
|
|
|
Mirror the algorithm used by palo:
|
|
|
|
(1) Due to sign-extension problems and PDC,
|
|
|
|
put the initrd no higher than 1G.
|
|
|
|
(2) Reserve 64k for stack. */
|
2020-10-28 11:19:23 +01:00
|
|
|
initrd_base = MIN(machine->ram_size, 1 * GiB);
|
2018-06-25 14:42:11 +02:00
|
|
|
initrd_base = initrd_base - 64 * KiB;
|
2017-10-08 22:47:27 +02:00
|
|
|
initrd_base = (initrd_base - initrd_size) & TARGET_PAGE_MASK;
|
|
|
|
|
|
|
|
if (initrd_base < kernel_high) {
|
|
|
|
error_report("kernel and initial ram disk too large!");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
load_image_targphys(initrd_filename, initrd_base, initrd_size);
|
|
|
|
cpu[0]->env.gr[23] = initrd_base;
|
|
|
|
cpu[0]->env.gr[22] = initrd_base + initrd_size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!kernel_entry) {
|
|
|
|
/* When booting via firmware, tell firmware if we want interactive
|
|
|
|
* mode (kernel_entry=1), and to boot from CD (gr[24]='d')
|
|
|
|
* or hard disc * (gr[24]='c').
|
|
|
|
*/
|
|
|
|
kernel_entry = boot_menu ? 1 : 0;
|
|
|
|
cpu[0]->env.gr[24] = machine->boot_order[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We jump to the firmware entry routine and pass the
|
|
|
|
* various parameters in registers. After firmware initialization,
|
|
|
|
* firmware will start the Linux kernel with ramdisk and cmdline.
|
|
|
|
*/
|
2020-10-28 11:19:23 +01:00
|
|
|
cpu[0]->env.gr[26] = machine->ram_size;
|
2017-10-08 22:47:27 +02:00
|
|
|
cpu[0]->env.gr[25] = kernel_entry;
|
|
|
|
|
|
|
|
/* tell firmware how many SMP CPUs to present in inventory table */
|
|
|
|
cpu[0]->env.gr[21] = smp_cpus;
|
2020-09-02 21:21:01 +02:00
|
|
|
|
|
|
|
/* tell firmware fw_cfg port */
|
|
|
|
cpu[0]->env.gr[19] = FW_CFG_IO_BASE;
|
2017-10-01 22:11:45 +02:00
|
|
|
}
|
|
|
|
|
2019-05-18 22:54:20 +02:00
|
|
|
static void hppa_machine_reset(MachineState *ms)
|
2017-10-08 22:47:27 +02:00
|
|
|
{
|
2019-05-18 22:54:27 +02:00
|
|
|
unsigned int smp_cpus = ms->smp.cpus;
|
2017-10-08 22:47:27 +02:00
|
|
|
int i;
|
|
|
|
|
|
|
|
qemu_devices_reset();
|
|
|
|
|
|
|
|
/* Start all CPUs at the firmware entry point.
|
|
|
|
* Monarch CPU will initialize firmware, secondary CPUs
|
|
|
|
* will enter a small idle look and wait for rendevouz. */
|
|
|
|
for (i = 0; i < smp_cpus; i++) {
|
|
|
|
cpu_set_pc(CPU(cpu[i]), firmware_entry);
|
|
|
|
cpu[i]->env.gr[5] = CPU_HPA + i * 0x1000;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* already initialized by machine_hppa_init()? */
|
2020-10-28 11:19:23 +01:00
|
|
|
if (cpu[0]->env.gr[26] == ms->ram_size) {
|
2017-10-08 22:47:27 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-10-28 11:19:23 +01:00
|
|
|
cpu[0]->env.gr[26] = ms->ram_size;
|
2017-10-08 22:47:27 +02:00
|
|
|
cpu[0]->env.gr[25] = 0; /* no firmware boot menu */
|
|
|
|
cpu[0]->env.gr[24] = 'c';
|
|
|
|
/* gr22/gr23 unused, no initrd while reboot. */
|
|
|
|
cpu[0]->env.gr[21] = smp_cpus;
|
2020-09-02 21:21:01 +02:00
|
|
|
/* tell firmware fw_cfg port */
|
|
|
|
cpu[0]->env.gr[19] = FW_CFG_IO_BASE;
|
2017-10-08 22:47:27 +02:00
|
|
|
}
|
|
|
|
|
2022-01-05 23:09:04 +01:00
|
|
|
static void hppa_nmi(NMIState *n, int cpu_index, Error **errp)
|
|
|
|
{
|
|
|
|
CPUState *cs;
|
|
|
|
|
|
|
|
CPU_FOREACH(cs) {
|
|
|
|
cpu_interrupt(cs, CPU_INTERRUPT_NMI);
|
|
|
|
}
|
|
|
|
}
|
2017-10-08 22:47:27 +02:00
|
|
|
|
2017-10-01 22:11:45 +02:00
|
|
|
static void machine_hppa_machine_init(MachineClass *mc)
|
|
|
|
{
|
|
|
|
mc->desc = "HPPA generic machine";
|
2017-10-08 22:47:27 +02:00
|
|
|
mc->default_cpu_type = TYPE_HPPA_CPU;
|
2017-10-01 22:11:45 +02:00
|
|
|
mc->init = machine_hppa_init;
|
2017-10-08 22:47:27 +02:00
|
|
|
mc->reset = hppa_machine_reset;
|
2017-10-01 22:11:45 +02:00
|
|
|
mc->block_default_type = IF_SCSI;
|
2017-10-08 22:47:27 +02:00
|
|
|
mc->max_cpus = HPPA_MAX_CPUS;
|
|
|
|
mc->default_cpus = 1;
|
2020-02-07 17:19:47 +01:00
|
|
|
mc->is_default = true;
|
2018-06-25 14:41:57 +02:00
|
|
|
mc->default_ram_size = 512 * MiB;
|
2017-10-01 22:11:45 +02:00
|
|
|
mc->default_boot_order = "cd";
|
2020-02-19 17:09:15 +01:00
|
|
|
mc->default_ram_id = "ram";
|
2017-10-01 22:11:45 +02:00
|
|
|
}
|
|
|
|
|
2022-01-05 23:09:04 +01:00
|
|
|
static void machine_hppa_machine_init_class_init(ObjectClass *oc, void *data)
|
|
|
|
{
|
|
|
|
MachineClass *mc = MACHINE_CLASS(oc);
|
|
|
|
machine_hppa_machine_init(mc);
|
|
|
|
|
|
|
|
NMIClass *nc = NMI_CLASS(oc);
|
|
|
|
nc->nmi_monitor_handler = hppa_nmi;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const TypeInfo machine_hppa_machine_init_typeinfo = {
|
|
|
|
.name = ("hppa" "-machine"),
|
|
|
|
.parent = "machine",
|
|
|
|
.class_init = machine_hppa_machine_init_class_init,
|
|
|
|
.interfaces = (InterfaceInfo[]) {
|
|
|
|
{ TYPE_NMI },
|
|
|
|
{ }
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static void machine_hppa_machine_init_register_types(void)
|
|
|
|
{
|
|
|
|
type_register_static(&machine_hppa_machine_init_typeinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
type_init(machine_hppa_machine_init_register_types)
|