QEMU-Devel Archive mirror
 help / color / mirror / Atom feed
From: BALATON Zoltan <balaton@eik.bme.hu>
To: Alexey Kardashevskiy <aik@ozlabs.ru>
Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org,
	David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [RFC PATCH 4/5] ppc/pegasos2: Use Virtual Open Firmware as firmware replacement
Date: Tue, 15 Jun 2021 11:44:19 +0200 (CEST)	[thread overview]
Message-ID: <2bd3b42-6556-e47c-c590-bb52e22b2577@eik.bme.hu> (raw)
In-Reply-To: <55582a05-160a-ac1d-75ac-7e636fa2fd7d@ozlabs.ru>

On Tue, 15 Jun 2021, Alexey Kardashevskiy wrote:
> On 6/7/21 01:46, BALATON Zoltan wrote:
>> The pegasos2 board comes with an Open Firmware compliant ROM based on
>> SmartFirmware but it has some changes that are not open source
>> therefore the ROM binary cannot be included in QEMU. Guests running on
>> the board however depend on services provided by the firmware. The
>> Virtual Open Firmware recently added to QEMU imlements a minimal set
>> of these services to allow some guests to boot without the original
>> firmware. This patch adds VOF as the default firmware for pegasos2
>> which allows booting Linux and MorphOS via -kernel option while a ROM
>> image can still be used with -bios for guests that don't run with VOF.
>> 
>> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
>> ---
>>   hw/ppc/Kconfig    |   1 +
>>   hw/ppc/pegasos2.c | 622 +++++++++++++++++++++++++++++++++++++++++++++-
>>   2 files changed, 621 insertions(+), 2 deletions(-)
>> 
>> diff --git a/hw/ppc/Kconfig b/hw/ppc/Kconfig
>> index b895720b28..0eb48128fe 100644
>> --- a/hw/ppc/Kconfig
>> +++ b/hw/ppc/Kconfig
>> @@ -75,6 +75,7 @@ config PEGASOS2
>>       select VT82C686
>>       select IDE_VIA
>>       select SMBUS_EEPROM
>> +    select VOF
>>   # This should come with VT82C686
>>       select ACPI_X86
>>   diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c
>> index 07971175c9..91e5fa8fbe 100644
>> --- a/hw/ppc/pegasos2.c
>> +++ b/hw/ppc/pegasos2.c
[...]
>> +static void add_pci_device(PCIBus *bus, PCIDevice *d, void *opaque)
>> +{
>> +    FDTInfo *fi = opaque;
>> +    GString *node = g_string_new(NULL);
>> +    uint32_t cells[(PCI_NUM_REGIONS + 1) * 5];
>> +    int i, j;
>> +    const char *name = NULL;
>> +    g_autofree const gchar *pn = g_strdup_printf("pci%x,%x",
>> + 
>> pci_get_word(&d->config[PCI_VENDOR_ID]),
>> + 
>> pci_get_word(&d->config[PCI_DEVICE_ID]));
>> +
>> +    for (i = 0; device_map[i].id; i++) {
>> +        if (!strcmp(pn, device_map[i].id)) {
>> +            name = device_map[i].name;
>> +            break;
>> +        }
>> +    }
>> +    g_string_printf(node, "%s/%s@%x", fi->path, (name ?: pn),
>> +                    PCI_SLOT(d->devfn));
>> +    if (PCI_FUNC(d->devfn)) {
>> +        g_string_append_printf(node, ",%x", PCI_FUNC(d->devfn));
>> +    }
>> +
>> +    qemu_fdt_add_subnode(fi->fdt, node->str);
>> +    if (device_map[i].dtf) {
>> +        FDTInfo cfi = { fi->fdt, node->str };
>> +        device_map[i].dtf(bus, d, &cfi);
>> +    }
>> +    cells[0] = cpu_to_be32(d->devfn << 8);
>> +    cells[1] = 0;
>> +    cells[2] = 0;
>> +    cells[3] = 0;
>> +    cells[4] = 0;
>> +    j = 5;
>> +    for (i = 0; i < PCI_NUM_REGIONS; i++) {
>> +        if (!d->io_regions[i].size) {
>> +            continue;
>> +        }
>> +        cells[j] = cpu_to_be32(d->devfn << 8 | (PCI_BASE_ADDRESS_0 + i * 
>> 4));
>> +        if (d->io_regions[i].type & PCI_BASE_ADDRESS_SPACE_IO) {
>> +            cells[j] |= cpu_to_be32(1 << 24);
>> +        } else {
>> +            cells[j] |= cpu_to_be32(2 << 24);
>> +            if (d->io_regions[i].type & PCI_BASE_ADDRESS_MEM_PREFETCH) {
>> +                cells[j] |= cpu_to_be32(4 << 28);
>> +            }
>> +        }
>> +        cells[j + 1] = 0;
>> +        cells[j + 2] = 0;
>> +        cells[j + 3] = cpu_to_be32(d->io_regions[i].size >> 32);
>> +        cells[j + 4] = cpu_to_be32(d->io_regions[i].size);
>> +        j += 5;
>> +    }
>
>
> btw I was wondering if Linux on pegasos2 could assign resources when 
> /chosen/linux,pci-probe-only is in the FDT, could not it? Or the serial 
> device does not probe and Linux does not boot?

Linux probes PCI devices by itself but MorphOS relies on the device tree 
entries so I need at least the reg properties for that then it will map 
the BARs but I think it won't scan the bus otherwise. You still seem to 
add PCI devices in spapr too, at least I think I've got the idea for this 
function above from there.

Regards,
BALATON Zoltan


  reply	other threads:[~2021-06-15  9:45 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-06 15:46 [RFC PATCH 0/5] ppc/Pegasos2 VOF BALATON Zoltan
2021-06-06 15:46 ` [RFC PATCH 2/5] ppc/pegasos2: Introduce Pegasos2MachineState structure BALATON Zoltan
2021-06-06 19:04   ` Philippe Mathieu-Daudé
2021-06-06 20:35     ` BALATON Zoltan
2021-06-06 15:46 ` [RFC PATCH 4/5] ppc/pegasos2: Use Virtual Open Firmware as firmware replacement BALATON Zoltan
2021-06-15  7:09   ` Alexey Kardashevskiy
2021-06-15  9:44     ` BALATON Zoltan [this message]
2021-06-16  4:58       ` Alexey Kardashevskiy
2021-06-16 10:38         ` BALATON Zoltan
2021-06-06 15:46 ` [RFC PATCH 3/5] target/ppc: Allow virtual hypervisor on CPU without HV BALATON Zoltan
2021-06-06 15:46 ` [RFC PATCH 1/5] Misc VOF fixes BALATON Zoltan
2021-06-06 15:46 ` [RFC PATCH 5/5] ppc/pegasos2: Implement some RTAS functions with VOF BALATON Zoltan
2021-06-09  7:39 ` [RFC PATCH 0/5] ppc/Pegasos2 VOF Alexey Kardashevskiy
2021-06-09 10:28   ` BALATON Zoltan
2021-06-10  7:14     ` Alexey Kardashevskiy
2021-06-10  8:25       ` David Gibson
2021-06-10 10:04         ` BALATON Zoltan
2021-06-10 10:37           ` David Gibson
2021-06-10 12:33           ` R: " luigi burdo
2021-06-10 12:52             ` BALATON Zoltan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2bd3b42-6556-e47c-c590-bb52e22b2577@eik.bme.hu \
    --to=balaton@eik.bme.hu \
    --cc=aik@ozlabs.ru \
    --cc=david@gibson.dropbear.id.au \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).