mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
Merge tag 'pull-or1k-20220904' of https://github.com/stffrdhrn/qemu into staging
OpenRISC updates for 7.2.0 Updates to add the OpenRISC virt plaform to QEMU. Highlights include: - New virt plaform with, virtio and pci bus support - OpenRISC support for MTTCG - Goldfish RTC device endianness is configurable now # -----BEGIN PGP SIGNATURE----- # # iQIzBAABCAAdFiEE2cRzVK74bBA6Je/xw7McLV5mJ+QFAmMURl4ACgkQw7McLV5m # J+TAVg/6A1HFazEBDzyVvg5BWfusvPMv1gWyAXQVbZDdoEVP5ilJq3Xz2vlOWu+Q # 46WHAncQH8KGWlS7x4Qk9X1tOU+9LCTa0aBqa1ARAle/wGKJeQ2QkmQM7lnAAtFt # ON9pDOrj85cNVp7ly/rZqmOkYorUtSblKllOigPaxZozfSA2FuoYwc7vLxy/ICk0 # 6RbRUKiIvqvNxhT0q13buIiqhtQAOLC2/Rrlp/CqUm+nrNlSVQIMC57ddNoopUFN # I6jb5UxyHtQSlWX6zsLjvho9hlZCuA9IIG7B4qS4/kyC7XJGmOICb3A7QSmfaUxy # HtEsaImjjhCUnJs8fhDHqyYnUu6JcXMRv61hIr7GNK/g3enpBzG1Otu5jsyHgzEX # SaachdFUibLJSj/+K4YOaT9luAc0Yvx9vArnXD+2wGg3kHTSDUNv2nFdyLyn5PNM # sZ9gx6gTEFI7iaeHEZM/doKdlHubddA/GH4DLy2fwZN7EyIsbll9TDJ8icqu1UBT # KpQdN55VeVqdOEvKUSXxsAK8aRtTjlEErKinufz1yyrg5Lw9XgH1xtTft+rJyXPu # Lw0hMHYqeaWhNUgnli/ByTY7yd+wC/ukNFQLUlMiDte337Lx9H//MOVvyl6Y5ARE # jIWt1JlTyuhj+txJrGZMvBrc2ZQ6fF/4HXc/xyGK7eJnEWZIzkY= # =BzgX # -----END PGP SIGNATURE----- # gpg: Signature made Sun 04 Sep 2022 02:31:58 EDT # gpg: using RSA key D9C47354AEF86C103A25EFF1C3B31C2D5E6627E4 # gpg: Good signature from "Stafford Horne <shorne@gmail.com>" [unknown] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: D9C4 7354 AEF8 6C10 3A25 EFF1 C3B3 1C2D 5E66 27E4 * tag 'pull-or1k-20220904' of https://github.com/stffrdhrn/qemu: docs/system: openrisc: Add OpenRISC documentation hw/openrisc: virt: pass random seed to fdt target/openrisc: Interrupt handling fixes target/openrisc: Enable MTTCG target/openrisc: Add interrupted CPU to log hw/openrisc: Initialize timer time at startup hw/openrisc: Add PCI bus support to virt hw/openrisc: Add the OpenRISC virtual machine goldfish_rtc: Add big-endian property target/openrisc: Fix memory reading in debugger hw/openrisc: Split re-usable boot time apis out to boot.c Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
@@ -3,3 +3,4 @@
|
||||
# Boards:
|
||||
#
|
||||
CONFIG_OR1K_SIM=y
|
||||
CONFIG_OR1K_VIRT=y
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
TARGET_ARCH=openrisc
|
||||
TARGET_SUPPORTS_MTTCG=y
|
||||
TARGET_BIG_ENDIAN=y
|
||||
TARGET_NEED_FDT=y
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
CPU Features
|
||||
============
|
||||
|
||||
The QEMU emulation of the OpenRISC architecture provides following built in
|
||||
features.
|
||||
|
||||
- Shadow GPRs
|
||||
- MMU TLB with 128 entries, 1 way
|
||||
- Power Management (PM)
|
||||
- Programmable Interrupt Controller (PIC)
|
||||
- Tick Timer
|
||||
|
||||
These features are on by default and the presence can be confirmed by checking
|
||||
the contents of the Unit Presence Register (``UPR``) and CPU Configuration
|
||||
Register (``CPUCFGR``).
|
||||
@@ -0,0 +1,17 @@
|
||||
OpenRISC 1000 CPU architecture support
|
||||
======================================
|
||||
|
||||
QEMU's TCG emulation includes support for the OpenRISC or1200 implementation of
|
||||
the OpenRISC 1000 cpu architecture.
|
||||
|
||||
The or1200 cpu also has support for the following instruction subsets:
|
||||
|
||||
- ORBIS32 (OpenRISC Basic Instruction Set)
|
||||
- ORFPX32 (OpenRISC Floating-Point eXtension)
|
||||
|
||||
In addition to the instruction subsets the QEMU TCG emulation also has support
|
||||
for most Class II (optional) instructions.
|
||||
|
||||
For information on all OpenRISC instructions please refer to the latest
|
||||
architecture manual available on the OpenRISC website in the
|
||||
`OpenRISC Architecture <https://openrisc.io/architecture>`_ section.
|
||||
@@ -0,0 +1,43 @@
|
||||
Or1ksim board
|
||||
=============
|
||||
|
||||
The QEMU Or1ksim machine emulates the standard OpenRISC board simulator which is
|
||||
also the standard SoC configuration.
|
||||
|
||||
Supported devices
|
||||
-----------------
|
||||
|
||||
* 16550A UART
|
||||
* ETHOC Ethernet controller
|
||||
* SMP (OpenRISC multicore using ompic)
|
||||
|
||||
Boot options
|
||||
------------
|
||||
|
||||
The Or1ksim machine can be started using the ``-kernel`` and ``-initrd`` options
|
||||
to load a Linux kernel and optional disk image.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ qemu-system-or1k -cpu or1220 -M or1k-sim -nographic \
|
||||
-kernel vmlinux \
|
||||
-initrd initramfs.cpio.gz \
|
||||
-m 128
|
||||
|
||||
Linux guest kernel configuration
|
||||
""""""""""""""""""""""""""""""""
|
||||
|
||||
The 'or1ksim_defconfig' for Linux openrisc kernels includes the right
|
||||
drivers for the or1ksim machine. If you would like to run an SMP system
|
||||
choose the 'simple_smp_defconfig' config.
|
||||
|
||||
Hardware configuration information
|
||||
""""""""""""""""""""""""""""""""""
|
||||
|
||||
The ``or1k-sim`` board automatically generates a device tree blob ("dtb")
|
||||
which it passes to the guest. This provides information about the
|
||||
addresses, interrupt lines and other configuration of the various devices
|
||||
in the system.
|
||||
|
||||
The location of the DTB will be passed in register ``r3`` to the guest operating
|
||||
system.
|
||||
@@ -0,0 +1,50 @@
|
||||
'virt' generic virtual platform
|
||||
===============================
|
||||
|
||||
The ``virt`` board is a platform which does not correspond to any
|
||||
real hardware; it is designed for use in virtual machines.
|
||||
It is the recommended board type if you simply want to run
|
||||
a guest such as Linux and do not care about reproducing the
|
||||
idiosyncrasies and limitations of a particular bit of real-world
|
||||
hardware.
|
||||
|
||||
Supported devices
|
||||
-----------------
|
||||
|
||||
* PCI/PCIe devices
|
||||
* 8 virtio-mmio transport devices
|
||||
* 16550A UART
|
||||
* Goldfish RTC
|
||||
* SiFive Test device for poweroff and reboot
|
||||
* SMP (OpenRISC multicore using ompic)
|
||||
|
||||
Boot options
|
||||
------------
|
||||
|
||||
The virt machine can be started using the ``-kernel`` and ``-initrd`` options
|
||||
to load a Linux kernel and optional disk image. For example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ qemu-system-or1k -cpu or1220 -M or1k-sim -nographic \
|
||||
-device virtio-net-device,netdev=user -netdev user,id=user,net=10.9.0.1/24,host=10.9.0.100 \
|
||||
-device virtio-blk-device,drive=d0 -drive file=virt.qcow2,id=d0,if=none,format=qcow2 \
|
||||
-kernel vmlinux \
|
||||
-initrd initramfs.cpio.gz \
|
||||
-m 128
|
||||
|
||||
Linux guest kernel configuration
|
||||
""""""""""""""""""""""""""""""""
|
||||
|
||||
The 'virt_defconfig' for Linux openrisc kernels includes the right drivers for
|
||||
the ``virt`` machine.
|
||||
|
||||
Hardware configuration information
|
||||
""""""""""""""""""""""""""""""""""
|
||||
|
||||
The ``virt`` board automatically generates a device tree blob ("dtb") which it
|
||||
passes to the guest. This provides information about the addresses, interrupt
|
||||
lines and other configuration of the various devices in the system.
|
||||
|
||||
The location of the DTB will be passed in register ``r3`` to the guest operating
|
||||
system.
|
||||
@@ -0,0 +1,71 @@
|
||||
.. _OpenRISC-System-emulator:
|
||||
|
||||
OpenRISC System emulator
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
QEMU can emulate 32-bit OpenRISC CPUs using the ``qemu-system-or1k`` executable.
|
||||
|
||||
OpenRISC CPUs are generally built into "system-on-chip" (SoC) designs that run
|
||||
on FPGAs. These SoCs are based on the same core architecture as the or1ksim
|
||||
(the original OpenRISC instruction level simulator) which QEMU supports. For
|
||||
this reason QEMU does not need to support many different boards to support the
|
||||
OpenRISC hardware ecosystem.
|
||||
|
||||
The OpenRISC CPU supported by QEMU is the ``or1200``, it supports an MMU and can
|
||||
run linux.
|
||||
|
||||
Choosing a board model
|
||||
======================
|
||||
|
||||
For QEMU's OpenRISC system emulation, you must specify which board model you
|
||||
want to use with the ``-M`` or ``--machine`` option; the default machine is
|
||||
``or1k-sim``.
|
||||
|
||||
If you intend to boot Linux, it is possible to have a single kernel image that
|
||||
will boot on any of the QEMU machines. To do this one would compile all required
|
||||
drivers into the kernel. This is possible because QEMU will create a device tree
|
||||
structure that describes the QEMU machine and pass a pointer to the structure to
|
||||
the kernel. The kernel can then use this to configure itself for the machine.
|
||||
|
||||
However, typically users will have specific firmware images for a specific machine.
|
||||
|
||||
If you already have a system image or a kernel that works on hardware and you
|
||||
want to boot with QEMU, check whether QEMU lists that machine in its ``-machine
|
||||
help`` output. If it is listed, then you can probably use that board model. If
|
||||
it is not listed, then unfortunately your image will almost certainly not boot
|
||||
on QEMU. (You might be able to extract the filesystem and use that with a
|
||||
different kernel which boots on a system that QEMU does emulate.)
|
||||
|
||||
If you don't care about reproducing the idiosyncrasies of a particular
|
||||
bit of hardware, such as small amount of RAM, no PCI or other hard disk, etc.,
|
||||
and just want to run Linux, the best option is to use the ``virt`` board. This
|
||||
is a platform which doesn't correspond to any real hardware and is designed for
|
||||
use in virtual machines. You'll need to compile Linux with a suitable
|
||||
configuration for running on the ``virt`` board. ``virt`` supports PCI, virtio
|
||||
and large amounts of RAM.
|
||||
|
||||
Board-specific documentation
|
||||
============================
|
||||
|
||||
..
|
||||
This table of contents should be kept sorted alphabetically
|
||||
by the title text of each file, which isn't the same ordering
|
||||
as an alphabetical sort by filename.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
openrisc/or1k-sim
|
||||
openrisc/virt
|
||||
|
||||
Emulated CPU architecture support
|
||||
=================================
|
||||
|
||||
.. toctree::
|
||||
openrisc/emulation
|
||||
|
||||
OpenRISC CPU features
|
||||
=====================
|
||||
|
||||
.. toctree::
|
||||
openrisc/cpu-features
|
||||
@@ -21,6 +21,7 @@ Contents:
|
||||
target-m68k
|
||||
target-mips
|
||||
target-ppc
|
||||
target-openrisc
|
||||
target-riscv
|
||||
target-rx
|
||||
target-s390x
|
||||
|
||||
@@ -173,6 +173,7 @@ static void virt_init(MachineState *machine)
|
||||
io_base = VIRT_GF_RTC_MMIO_BASE;
|
||||
for (i = 0; i < VIRT_GF_RTC_NB; i++) {
|
||||
dev = qdev_new(TYPE_GOLDFISH_RTC);
|
||||
qdev_prop_set_bit(dev, "big-endian", true);
|
||||
sysbus = SYS_BUS_DEVICE(dev);
|
||||
sysbus_realize_and_unref(sysbus, &error_fatal);
|
||||
sysbus_mmio_map(sysbus, 0, io_base);
|
||||
|
||||
@@ -4,3 +4,15 @@ config OR1K_SIM
|
||||
select OPENCORES_ETH
|
||||
select OMPIC
|
||||
select SPLIT_IRQ
|
||||
|
||||
config OR1K_VIRT
|
||||
bool
|
||||
imply PCI_DEVICES
|
||||
imply VIRTIO_VGA
|
||||
imply TEST_DEVICES
|
||||
select PCI
|
||||
select PCI_EXPRESS_GENERIC_BRIDGE
|
||||
select GOLDFISH_RTC
|
||||
select SERIAL
|
||||
select SIFIVE_TEST
|
||||
select VIRTIO_MMIO
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*
|
||||
* QEMU OpenRISC boot helpers.
|
||||
*
|
||||
* (c) 2022 Stafford Horne <shorne@gmail.com>
|
||||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "cpu.h"
|
||||
#include "exec/cpu-defs.h"
|
||||
#include "elf.h"
|
||||
#include "hw/loader.h"
|
||||
#include "hw/openrisc/boot.h"
|
||||
#include "sysemu/device_tree.h"
|
||||
#include "sysemu/qtest.h"
|
||||
|
||||
#include <libfdt.h>
|
||||
|
||||
#define KERNEL_LOAD_ADDR 0x100
|
||||
|
||||
hwaddr openrisc_load_kernel(ram_addr_t ram_size,
|
||||
const char *kernel_filename,
|
||||
uint32_t *bootstrap_pc)
|
||||
{
|
||||
long kernel_size;
|
||||
uint64_t elf_entry;
|
||||
uint64_t high_addr;
|
||||
hwaddr entry;
|
||||
|
||||
if (kernel_filename && !qtest_enabled()) {
|
||||
kernel_size = load_elf(kernel_filename, NULL, NULL, NULL,
|
||||
&elf_entry, NULL, &high_addr, NULL, 1,
|
||||
EM_OPENRISC, 1, 0);
|
||||
entry = elf_entry;
|
||||
if (kernel_size < 0) {
|
||||
kernel_size = load_uimage(kernel_filename,
|
||||
&entry, NULL, NULL, NULL, NULL);
|
||||
high_addr = entry + kernel_size;
|
||||
}
|
||||
if (kernel_size < 0) {
|
||||
kernel_size = load_image_targphys(kernel_filename,
|
||||
KERNEL_LOAD_ADDR,
|
||||
ram_size - KERNEL_LOAD_ADDR);
|
||||
high_addr = KERNEL_LOAD_ADDR + kernel_size;
|
||||
}
|
||||
|
||||
if (entry <= 0) {
|
||||
entry = KERNEL_LOAD_ADDR;
|
||||
}
|
||||
|
||||
if (kernel_size < 0) {
|
||||
error_report("couldn't load the kernel '%s'", kernel_filename);
|
||||
exit(1);
|
||||
}
|
||||
*bootstrap_pc = entry;
|
||||
|
||||
return high_addr;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
hwaddr openrisc_load_initrd(void *fdt, const char *filename,
|
||||
hwaddr load_start, uint64_t mem_size)
|
||||
{
|
||||
int size;
|
||||
hwaddr start;
|
||||
|
||||
/* We put the initrd right after the kernel; page aligned. */
|
||||
start = TARGET_PAGE_ALIGN(load_start);
|
||||
|
||||
size = load_ramdisk(filename, start, mem_size - start);
|
||||
if (size < 0) {
|
||||
size = load_image_targphys(filename, start, mem_size - start);
|
||||
if (size < 0) {
|
||||
error_report("could not load ramdisk '%s'", filename);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (fdt) {
|
||||
qemu_fdt_setprop_cell(fdt, "/chosen",
|
||||
"linux,initrd-start", start);
|
||||
qemu_fdt_setprop_cell(fdt, "/chosen",
|
||||
"linux,initrd-end", start + size);
|
||||
}
|
||||
|
||||
return start + size;
|
||||
}
|
||||
|
||||
uint32_t openrisc_load_fdt(void *fdt, hwaddr load_start,
|
||||
uint64_t mem_size)
|
||||
{
|
||||
uint32_t fdt_addr;
|
||||
int ret;
|
||||
int fdtsize = fdt_totalsize(fdt);
|
||||
|
||||
if (fdtsize <= 0) {
|
||||
error_report("invalid device-tree");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* We put fdt right after the kernel and/or initrd. */
|
||||
fdt_addr = TARGET_PAGE_ALIGN(load_start);
|
||||
|
||||
ret = fdt_pack(fdt);
|
||||
/* Should only fail if we've built a corrupted tree */
|
||||
g_assert(ret == 0);
|
||||
/* copy in the device tree */
|
||||
qemu_fdt_dumpdtb(fdt, fdtsize);
|
||||
|
||||
rom_add_blob_fixed_as("fdt", fdt, fdtsize, fdt_addr,
|
||||
&address_space_memory);
|
||||
|
||||
return fdt_addr;
|
||||
}
|
||||
+21
-1
@@ -22,6 +22,7 @@
|
||||
#include "cpu.h"
|
||||
#include "migration/vmstate.h"
|
||||
#include "qemu/timer.h"
|
||||
#include "sysemu/reset.h"
|
||||
|
||||
#define TIMER_PERIOD 50 /* 50 ns period for 20 MHz timer */
|
||||
|
||||
@@ -122,6 +123,24 @@ static void openrisc_timer_cb(void *opaque)
|
||||
qemu_cpu_kick(CPU(cpu));
|
||||
}
|
||||
|
||||
/* Reset the per CPU counter state. */
|
||||
static void openrisc_count_reset(void *opaque)
|
||||
{
|
||||
OpenRISCCPU *cpu = opaque;
|
||||
|
||||
if (cpu->env.is_counting) {
|
||||
cpu_openrisc_count_stop(cpu);
|
||||
}
|
||||
cpu->env.ttmr = 0x00000000;
|
||||
}
|
||||
|
||||
/* Reset the global timer state. */
|
||||
static void openrisc_timer_reset(void *opaque)
|
||||
{
|
||||
or1k_timer->ttcr = 0x00000000;
|
||||
or1k_timer->last_clk = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
|
||||
}
|
||||
|
||||
static const VMStateDescription vmstate_or1k_timer = {
|
||||
.name = "or1k_timer",
|
||||
.version_id = 1,
|
||||
@@ -136,10 +155,11 @@ static const VMStateDescription vmstate_or1k_timer = {
|
||||
void cpu_openrisc_clock_init(OpenRISCCPU *cpu)
|
||||
{
|
||||
cpu->env.timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, &openrisc_timer_cb, cpu);
|
||||
cpu->env.ttmr = 0x00000000;
|
||||
|
||||
qemu_register_reset(openrisc_count_reset, cpu);
|
||||
if (or1k_timer == NULL) {
|
||||
or1k_timer = g_new0(OR1KTimerState, 1);
|
||||
qemu_register_reset(openrisc_timer_reset, cpu);
|
||||
vmstate_register(NULL, 0, &vmstate_or1k_timer, or1k_timer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
openrisc_ss = ss.source_set()
|
||||
openrisc_ss.add(files('cputimer.c'))
|
||||
openrisc_ss.add(files('boot.c'))
|
||||
openrisc_ss.add(when: 'CONFIG_OR1K_SIM', if_true: [files('openrisc_sim.c'), fdt])
|
||||
openrisc_ss.add(when: 'CONFIG_OR1K_VIRT', if_true: [files('virt.c'), fdt])
|
||||
|
||||
hw_arch += {'openrisc': openrisc_ss}
|
||||
|
||||
+6
-100
@@ -24,10 +24,9 @@
|
||||
#include "cpu.h"
|
||||
#include "hw/irq.h"
|
||||
#include "hw/boards.h"
|
||||
#include "elf.h"
|
||||
#include "hw/char/serial.h"
|
||||
#include "net/net.h"
|
||||
#include "hw/loader.h"
|
||||
#include "hw/openrisc/boot.h"
|
||||
#include "hw/qdev-properties.h"
|
||||
#include "exec/address-spaces.h"
|
||||
#include "sysemu/device_tree.h"
|
||||
@@ -283,101 +282,6 @@ static void openrisc_sim_serial_init(Or1ksimState *state, hwaddr base,
|
||||
g_free(nodename);
|
||||
}
|
||||
|
||||
static hwaddr openrisc_load_kernel(ram_addr_t ram_size,
|
||||
const char *kernel_filename)
|
||||
{
|
||||
long kernel_size;
|
||||
uint64_t elf_entry;
|
||||
uint64_t high_addr;
|
||||
hwaddr entry;
|
||||
|
||||
if (kernel_filename && !qtest_enabled()) {
|
||||
kernel_size = load_elf(kernel_filename, NULL, NULL, NULL,
|
||||
&elf_entry, NULL, &high_addr, NULL, 1,
|
||||
EM_OPENRISC, 1, 0);
|
||||
entry = elf_entry;
|
||||
if (kernel_size < 0) {
|
||||
kernel_size = load_uimage(kernel_filename,
|
||||
&entry, NULL, NULL, NULL, NULL);
|
||||
high_addr = entry + kernel_size;
|
||||
}
|
||||
if (kernel_size < 0) {
|
||||
kernel_size = load_image_targphys(kernel_filename,
|
||||
KERNEL_LOAD_ADDR,
|
||||
ram_size - KERNEL_LOAD_ADDR);
|
||||
high_addr = KERNEL_LOAD_ADDR + kernel_size;
|
||||
}
|
||||
|
||||
if (entry <= 0) {
|
||||
entry = KERNEL_LOAD_ADDR;
|
||||
}
|
||||
|
||||
if (kernel_size < 0) {
|
||||
error_report("couldn't load the kernel '%s'", kernel_filename);
|
||||
exit(1);
|
||||
}
|
||||
boot_info.bootstrap_pc = entry;
|
||||
|
||||
return high_addr;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static hwaddr openrisc_load_initrd(Or1ksimState *state, const char *filename,
|
||||
hwaddr load_start, uint64_t mem_size)
|
||||
{
|
||||
void *fdt = state->fdt;
|
||||
int size;
|
||||
hwaddr start;
|
||||
|
||||
/* We put the initrd right after the kernel; page aligned. */
|
||||
start = TARGET_PAGE_ALIGN(load_start);
|
||||
|
||||
size = load_ramdisk(filename, start, mem_size - start);
|
||||
if (size < 0) {
|
||||
size = load_image_targphys(filename, start, mem_size - start);
|
||||
if (size < 0) {
|
||||
error_report("could not load ramdisk '%s'", filename);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
qemu_fdt_setprop_cell(fdt, "/chosen",
|
||||
"linux,initrd-start", start);
|
||||
qemu_fdt_setprop_cell(fdt, "/chosen",
|
||||
"linux,initrd-end", start + size);
|
||||
|
||||
return start + size;
|
||||
}
|
||||
|
||||
static uint32_t openrisc_load_fdt(Or1ksimState *state, hwaddr load_start,
|
||||
uint64_t mem_size)
|
||||
{
|
||||
void *fdt = state->fdt;
|
||||
uint32_t fdt_addr;
|
||||
int ret;
|
||||
int fdtsize = fdt_totalsize(fdt);
|
||||
|
||||
if (fdtsize <= 0) {
|
||||
error_report("invalid device-tree");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* We put fdt right after the kernel and/or initrd. */
|
||||
fdt_addr = TARGET_PAGE_ALIGN(load_start);
|
||||
|
||||
ret = fdt_pack(fdt);
|
||||
/* Should only fail if we've built a corrupted tree */
|
||||
g_assert(ret == 0);
|
||||
/* copy in the device tree */
|
||||
qemu_fdt_dumpdtb(fdt, fdtsize);
|
||||
|
||||
rom_add_blob_fixed_as("fdt", fdt, fdtsize, fdt_addr,
|
||||
&address_space_memory);
|
||||
|
||||
return fdt_addr;
|
||||
}
|
||||
|
||||
static void openrisc_sim_init(MachineState *machine)
|
||||
{
|
||||
ram_addr_t ram_size = machine->ram_size;
|
||||
@@ -428,13 +332,15 @@ static void openrisc_sim_init(MachineState *machine)
|
||||
or1ksim_memmap[OR1KSIM_UART].size,
|
||||
smp_cpus, cpus, OR1KSIM_UART_IRQ, n);
|
||||
|
||||
load_addr = openrisc_load_kernel(ram_size, kernel_filename);
|
||||
load_addr = openrisc_load_kernel(ram_size, kernel_filename,
|
||||
&boot_info.bootstrap_pc);
|
||||
if (load_addr > 0) {
|
||||
if (machine->initrd_filename) {
|
||||
load_addr = openrisc_load_initrd(state, machine->initrd_filename,
|
||||
load_addr = openrisc_load_initrd(state->fdt,
|
||||
machine->initrd_filename,
|
||||
load_addr, machine->ram_size);
|
||||
}
|
||||
boot_info.fdt_addr = openrisc_load_fdt(state, load_addr,
|
||||
boot_info.fdt_addr = openrisc_load_fdt(state->fdt, load_addr,
|
||||
machine->ram_size);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+28
-9
@@ -216,14 +216,25 @@ static int goldfish_rtc_post_load(void *opaque, int version_id)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const MemoryRegionOps goldfish_rtc_ops = {
|
||||
.read = goldfish_rtc_read,
|
||||
.write = goldfish_rtc_write,
|
||||
.endianness = DEVICE_NATIVE_ENDIAN,
|
||||
.valid = {
|
||||
.min_access_size = 4,
|
||||
.max_access_size = 4
|
||||
}
|
||||
static const MemoryRegionOps goldfish_rtc_ops[2] = {
|
||||
[false] = {
|
||||
.read = goldfish_rtc_read,
|
||||
.write = goldfish_rtc_write,
|
||||
.endianness = DEVICE_LITTLE_ENDIAN,
|
||||
.valid = {
|
||||
.min_access_size = 4,
|
||||
.max_access_size = 4
|
||||
}
|
||||
},
|
||||
[true] = {
|
||||
.read = goldfish_rtc_read,
|
||||
.write = goldfish_rtc_write,
|
||||
.endianness = DEVICE_BIG_ENDIAN,
|
||||
.valid = {
|
||||
.min_access_size = 4,
|
||||
.max_access_size = 4
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
static const VMStateDescription goldfish_rtc_vmstate = {
|
||||
@@ -265,7 +276,8 @@ static void goldfish_rtc_realize(DeviceState *d, Error **errp)
|
||||
SysBusDevice *dev = SYS_BUS_DEVICE(d);
|
||||
GoldfishRTCState *s = GOLDFISH_RTC(d);
|
||||
|
||||
memory_region_init_io(&s->iomem, OBJECT(s), &goldfish_rtc_ops, s,
|
||||
memory_region_init_io(&s->iomem, OBJECT(s),
|
||||
&goldfish_rtc_ops[s->big_endian], s,
|
||||
"goldfish_rtc", 0x24);
|
||||
sysbus_init_mmio(dev, &s->iomem);
|
||||
|
||||
@@ -274,10 +286,17 @@ static void goldfish_rtc_realize(DeviceState *d, Error **errp)
|
||||
s->timer = timer_new_ns(rtc_clock, goldfish_rtc_interrupt, s);
|
||||
}
|
||||
|
||||
static Property goldfish_rtc_properties[] = {
|
||||
DEFINE_PROP_BOOL("big-endian", GoldfishRTCState, big_endian,
|
||||
false),
|
||||
DEFINE_PROP_END_OF_LIST(),
|
||||
};
|
||||
|
||||
static void goldfish_rtc_class_init(ObjectClass *klass, void *data)
|
||||
{
|
||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||
|
||||
device_class_set_props(dc, goldfish_rtc_properties);
|
||||
dc->realize = goldfish_rtc_realize;
|
||||
dc->reset = goldfish_rtc_reset;
|
||||
dc->vmsd = &goldfish_rtc_vmstate;
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* QEMU OpenRISC boot helpers.
|
||||
*
|
||||
* Copyright (c) 2022 Stafford Horne <shorne@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2 or later, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef OPENRISC_BOOT_H
|
||||
#define OPENRISC_BOOT_H
|
||||
|
||||
#include "exec/cpu-defs.h"
|
||||
|
||||
hwaddr openrisc_load_kernel(ram_addr_t ram_size,
|
||||
const char *kernel_filename,
|
||||
uint32_t *bootstrap_pc);
|
||||
|
||||
hwaddr openrisc_load_initrd(void *fdt, const char *filename,
|
||||
hwaddr load_start, uint64_t mem_size);
|
||||
|
||||
uint32_t openrisc_load_fdt(void *fdt, hwaddr load_start,
|
||||
uint64_t mem_size);
|
||||
|
||||
#endif /* OPENRISC_BOOT_H */
|
||||
@@ -42,6 +42,8 @@ struct GoldfishRTCState {
|
||||
uint32_t irq_pending;
|
||||
uint32_t irq_enabled;
|
||||
uint32_t time_high;
|
||||
|
||||
bool big_endian;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -98,7 +98,6 @@ static void openrisc_cpu_set_irq(void *opaque, int irq, int level)
|
||||
cpu_interrupt(cs, CPU_INTERRUPT_HARD);
|
||||
} else {
|
||||
cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD);
|
||||
cpu->env.picsr = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#include "hw/core/cpu.h"
|
||||
#include "qom/object.h"
|
||||
|
||||
#define TCG_GUEST_DEFAULT_MO (0)
|
||||
|
||||
#define TYPE_OPENRISC_CPU "or1k-cpu"
|
||||
|
||||
OBJECT_DECLARE_CPU_TYPE(OpenRISCCPU, OpenRISCCPUClass, OPENRISC_CPU)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user