2009-03-02 19:42:42 +03:00
|
|
|
/*
|
2012-07-02 17:03:19 +04:00
|
|
|
* QEMU PowerPC e500-based platforms
|
2009-03-02 19:42:42 +03:00
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Freescale Semiconductor, Inc. All rights reserved.
|
|
|
|
*
|
|
|
|
* Author: Yu Liu, <yu.liu@freescale.com>
|
|
|
|
*
|
|
|
|
* This file is derived from hw/ppc440_bamboo.c,
|
|
|
|
* the copyright for that material belongs to the original owners.
|
|
|
|
*
|
|
|
|
* This is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
2016-01-26 21:16:58 +03:00
|
|
|
#include "qemu/osdep.h"
|
2020-10-28 14:36:57 +03:00
|
|
|
#include "qemu/datadir.h"
|
2018-06-25 15:42:24 +03:00
|
|
|
#include "qemu/units.h"
|
2022-07-12 16:51:14 +03:00
|
|
|
#include "qemu/guest-random.h"
|
include/qemu/osdep.h: Don't include qapi/error.h
Commit 57cb38b included qapi/error.h into qemu/osdep.h to get the
Error typedef. Since then, we've moved to include qemu/osdep.h
everywhere. Its file comment explains: "To avoid getting into
possible circular include dependencies, this file should not include
any other QEMU headers, with the exceptions of config-host.h,
compiler.h, os-posix.h and os-win32.h, all of which are doing a
similar job to this file and are under similar constraints."
qapi/error.h doesn't do a similar job, and it doesn't adhere to
similar constraints: it includes qapi-types.h. That's in excess of
100KiB of crap most .c files don't actually need.
Add the typedef to qemu/typedefs.h, and include that instead of
qapi/error.h. Include qapi/error.h in .c files that need it and don't
get it now. Include qapi-types.h in qom/object.h for uint16List.
Update scripts/clean-includes accordingly. Update it further to match
reality: replace config.h by config-target.h, add sysemu/os-posix.h,
sysemu/os-win32.h. Update the list of includes in the qemu/osdep.h
comment quoted above similarly.
This reduces the number of objects depending on qapi/error.h from "all
of them" to less than a third. Unfortunately, the number depending on
qapi-types.h shrinks only a little. More work is needed for that one.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
[Fix compilation without the spice devel packages. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-03-14 11:01:28 +03:00
|
|
|
#include "qapi/error.h"
|
2012-07-02 17:03:20 +04:00
|
|
|
#include "e500.h"
|
2012-10-10 08:28:28 +04:00
|
|
|
#include "e500-ccsr.h"
|
2012-10-24 10:43:34 +04:00
|
|
|
#include "net/net.h"
|
2012-12-17 21:20:00 +04:00
|
|
|
#include "qemu/config-file.h"
|
2022-10-19 00:01:44 +03:00
|
|
|
#include "hw/block/flash.h"
|
2013-02-05 20:06:20 +04:00
|
|
|
#include "hw/char/serial.h"
|
2012-12-12 16:24:50 +04:00
|
|
|
#include "hw/pci/pci.h"
|
2022-10-19 00:01:44 +03:00
|
|
|
#include "sysemu/block-backend-io.h"
|
2012-12-17 21:20:04 +04:00
|
|
|
#include "sysemu/sysemu.h"
|
|
|
|
#include "sysemu/kvm.h"
|
2019-08-12 08:23:38 +03:00
|
|
|
#include "sysemu/reset.h"
|
2019-08-12 08:23:59 +03:00
|
|
|
#include "sysemu/runstate.h"
|
2009-03-02 19:42:42 +03:00
|
|
|
#include "kvm_ppc.h"
|
2012-12-17 21:20:04 +04:00
|
|
|
#include "sysemu/device_tree.h"
|
2013-02-05 20:06:20 +04:00
|
|
|
#include "hw/ppc/openpic.h"
|
2018-02-28 23:32:39 +03:00
|
|
|
#include "hw/ppc/openpic_kvm.h"
|
2013-02-05 20:06:20 +04:00
|
|
|
#include "hw/ppc/ppc.h"
|
2019-08-12 08:23:51 +03:00
|
|
|
#include "hw/qdev-properties.h"
|
2012-07-02 17:03:18 +04:00
|
|
|
#include "hw/loader.h"
|
2009-09-20 18:58:02 +04:00
|
|
|
#include "elf.h"
|
2012-07-02 17:03:18 +04:00
|
|
|
#include "hw/sysbus.h"
|
2012-12-17 21:20:00 +04:00
|
|
|
#include "qemu/host-utils.h"
|
2018-02-01 14:18:46 +03:00
|
|
|
#include "qemu/option.h"
|
2013-02-05 20:06:20 +04:00
|
|
|
#include "hw/pci-host/ppce500.h"
|
2014-07-01 18:27:09 +04:00
|
|
|
#include "qemu/error-report.h"
|
|
|
|
#include "hw/platform-bus.h"
|
2014-07-02 01:30:06 +04:00
|
|
|
#include "hw/net/fsl_etsec/etsec.h"
|
2019-03-06 13:28:12 +03:00
|
|
|
#include "hw/i2c/i2c.h"
|
2019-08-12 08:23:42 +03:00
|
|
|
#include "hw/irq.h"
|
2022-11-02 01:29:34 +03:00
|
|
|
#include "hw/sd/sdhci.h"
|
|
|
|
#include "hw/misc/unimp.h"
|
2009-03-02 19:42:42 +03:00
|
|
|
|
2013-04-29 08:40:56 +04:00
|
|
|
#define EPAPR_MAGIC (0x45504150)
|
2012-08-22 18:55:40 +04:00
|
|
|
#define DTC_LOAD_PAD 0x1800000
|
2010-02-02 11:49:03 +03:00
|
|
|
#define DTC_PAD_MASK 0xFFFFF
|
2018-06-25 15:42:24 +03:00
|
|
|
#define DTB_MAX_SIZE (8 * MiB)
|
2010-02-02 11:49:03 +03:00
|
|
|
#define INITRD_LOAD_PAD 0x2000000
|
|
|
|
#define INITRD_PAD_MASK 0xFFFFFF
|
2009-03-02 19:42:42 +03:00
|
|
|
|
2018-06-25 15:42:24 +03:00
|
|
|
#define RAM_SIZES_ALIGN (64 * MiB)
|
2009-03-02 19:42:42 +03:00
|
|
|
|
2012-07-02 17:03:19 +04:00
|
|
|
/* TODO: parameterize */
|
2012-06-06 02:30:36 +04:00
|
|
|
#define MPC8544_CCSRBAR_SIZE 0x00100000ULL
|
2012-10-10 08:28:27 +04:00
|
|
|
#define MPC8544_MPIC_REGS_OFFSET 0x40000ULL
|
2012-12-08 17:26:37 +04:00
|
|
|
#define MPC8544_MSI_REGS_OFFSET 0x41600ULL
|
2012-10-10 08:28:27 +04:00
|
|
|
#define MPC8544_SERIAL0_REGS_OFFSET 0x4500ULL
|
|
|
|
#define MPC8544_SERIAL1_REGS_OFFSET 0x4600ULL
|
|
|
|
#define MPC8544_PCI_REGS_OFFSET 0x8000ULL
|
2012-06-06 02:30:36 +04:00
|
|
|
#define MPC8544_PCI_REGS_SIZE 0x1000ULL
|
2022-11-02 01:29:34 +03:00
|
|
|
#define MPC85XX_ESDHC_REGS_OFFSET 0x2e000ULL
|
|
|
|
#define MPC85XX_ESDHC_REGS_SIZE 0x1000ULL
|
2012-10-10 08:28:27 +04:00
|
|
|
#define MPC8544_UTIL_OFFSET 0xe0000ULL
|
2014-10-01 18:00:49 +04:00
|
|
|
#define MPC8XXX_GPIO_OFFSET 0x000FF000ULL
|
2019-03-06 13:28:12 +03:00
|
|
|
#define MPC8544_I2C_REGS_OFFSET 0x3000ULL
|
2014-12-19 17:20:37 +03:00
|
|
|
#define MPC8XXX_GPIO_IRQ 47
|
2019-03-06 13:28:12 +03:00
|
|
|
#define MPC8544_I2C_IRQ 43
|
2022-11-02 01:29:34 +03:00
|
|
|
#define MPC85XX_ESDHC_IRQ 72
|
2019-03-06 13:28:12 +03:00
|
|
|
#define RTC_REGS_OFFSET 0x68
|
2009-03-02 19:42:42 +03:00
|
|
|
|
2021-02-03 17:24:47 +03:00
|
|
|
#define PLATFORM_CLK_FREQ_HZ (400 * 1000 * 1000)
|
|
|
|
|
2011-05-01 01:34:53 +04:00
|
|
|
struct boot_info
|
|
|
|
{
|
|
|
|
uint32_t dt_base;
|
2012-05-19 02:48:50 +04:00
|
|
|
uint32_t dt_size;
|
2011-05-01 01:34:53 +04:00
|
|
|
uint32_t entry;
|
|
|
|
};
|
|
|
|
|
2012-12-12 16:47:07 +04:00
|
|
|
static uint32_t *pci_map_create(void *fdt, uint32_t mpic, int first_slot,
|
|
|
|
int nr_slots, int *len)
|
2012-05-17 17:34:34 +04:00
|
|
|
{
|
2012-12-12 16:47:07 +04:00
|
|
|
int i = 0;
|
|
|
|
int slot;
|
|
|
|
int pci_irq;
|
2012-12-13 04:16:24 +04:00
|
|
|
int host_irq;
|
2012-12-12 16:47:07 +04:00
|
|
|
int last_slot = first_slot + nr_slots;
|
|
|
|
uint32_t *pci_map;
|
|
|
|
|
|
|
|
*len = nr_slots * 4 * 7 * sizeof(uint32_t);
|
|
|
|
pci_map = g_malloc(*len);
|
|
|
|
|
|
|
|
for (slot = first_slot; slot < last_slot; slot++) {
|
|
|
|
for (pci_irq = 0; pci_irq < 4; pci_irq++) {
|
|
|
|
pci_map[i++] = cpu_to_be32(slot << 11);
|
|
|
|
pci_map[i++] = cpu_to_be32(0x0);
|
|
|
|
pci_map[i++] = cpu_to_be32(0x0);
|
|
|
|
pci_map[i++] = cpu_to_be32(pci_irq + 1);
|
|
|
|
pci_map[i++] = cpu_to_be32(mpic);
|
2012-12-13 04:16:24 +04:00
|
|
|
host_irq = ppce500_pci_map_irq_slot(slot, pci_irq);
|
|
|
|
pci_map[i++] = cpu_to_be32(host_irq + 1);
|
2012-12-12 16:47:07 +04:00
|
|
|
pci_map[i++] = cpu_to_be32(0x1);
|
|
|
|
}
|
2012-05-17 17:34:34 +04:00
|
|
|
}
|
2012-12-12 16:47:07 +04:00
|
|
|
|
|
|
|
assert((i * sizeof(uint32_t)) == *len);
|
|
|
|
|
|
|
|
return pci_map;
|
2012-05-17 17:34:34 +04:00
|
|
|
}
|
|
|
|
|
2012-06-06 03:19:40 +04:00
|
|
|
static void dt_serial_create(void *fdt, unsigned long long offset,
|
|
|
|
const char *soc, const char *mpic,
|
|
|
|
const char *alias, int idx, bool defcon)
|
|
|
|
{
|
ppc: e500: use g_strdup_printf() instead of snprintf()
qemu-system-ppc fails to build with GCC 8.0.1:
/home/hsp/src/qemu-master/hw/ppc/e500.c: In function ‘ppce500_load_device_tree’:
/home/hsp/src/qemu-master/hw/ppc/e500.c:442:37: error: ‘/pic@’
directive output may be truncated writing 5 bytes into a region of
size between 1 and 128 [-Werror=format-truncation=]
snprintf(mpic, sizeof(mpic), "%s/pic@%llx", soc, MPC8544_MPIC_REGS_OFFSET);
^~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 11 and 138 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:470:39: error:
‘/global-utilities@’ directive output may be truncated writing 18
bytes into a region of size between 1 and 128
[-Werror=format-truncation=]
snprintf(gutil, sizeof(gutil), "%s/global-utilities@%llx", soc,
^~~~~~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 24 and 151 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:477:36: error: ‘/msi@’
directive output may be truncated writing 5 bytes into a region of
size between 0 and 127 [-Werror=format-truncation=]
snprintf(msi, sizeof(msi), "/%s/msi@%llx", soc, MPC8544_MSI_REGS_OFFSET);
^~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 12 and 139 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fix this by converting e500 to use g_strdup_printf()+g_free() instead
of snprintf(). This is done globally, even for call sites that don't
break build, since this is the preferred practice in QEMU.
Reported-by: Howard Spoelstra <hsp.cat7@gmail.com>
Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 152568372989.443627.900708381919207053.stgit@bahia.lan
Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2018-05-07 12:02:09 +03:00
|
|
|
char *ser;
|
2012-06-06 03:19:40 +04:00
|
|
|
|
ppc: e500: use g_strdup_printf() instead of snprintf()
qemu-system-ppc fails to build with GCC 8.0.1:
/home/hsp/src/qemu-master/hw/ppc/e500.c: In function ‘ppce500_load_device_tree’:
/home/hsp/src/qemu-master/hw/ppc/e500.c:442:37: error: ‘/pic@’
directive output may be truncated writing 5 bytes into a region of
size between 1 and 128 [-Werror=format-truncation=]
snprintf(mpic, sizeof(mpic), "%s/pic@%llx", soc, MPC8544_MPIC_REGS_OFFSET);
^~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 11 and 138 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:470:39: error:
‘/global-utilities@’ directive output may be truncated writing 18
bytes into a region of size between 1 and 128
[-Werror=format-truncation=]
snprintf(gutil, sizeof(gutil), "%s/global-utilities@%llx", soc,
^~~~~~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 24 and 151 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:477:36: error: ‘/msi@’
directive output may be truncated writing 5 bytes into a region of
size between 0 and 127 [-Werror=format-truncation=]
snprintf(msi, sizeof(msi), "/%s/msi@%llx", soc, MPC8544_MSI_REGS_OFFSET);
^~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 12 and 139 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fix this by converting e500 to use g_strdup_printf()+g_free() instead
of snprintf(). This is done globally, even for call sites that don't
break build, since this is the preferred practice in QEMU.
Reported-by: Howard Spoelstra <hsp.cat7@gmail.com>
Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 152568372989.443627.900708381919207053.stgit@bahia.lan
Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2018-05-07 12:02:09 +03:00
|
|
|
ser = g_strdup_printf("%s/serial@%llx", soc, offset);
|
2013-11-11 12:14:41 +04:00
|
|
|
qemu_fdt_add_subnode(fdt, ser);
|
|
|
|
qemu_fdt_setprop_string(fdt, ser, "device_type", "serial");
|
|
|
|
qemu_fdt_setprop_string(fdt, ser, "compatible", "ns16550");
|
|
|
|
qemu_fdt_setprop_cells(fdt, ser, "reg", offset, 0x100);
|
|
|
|
qemu_fdt_setprop_cell(fdt, ser, "cell-index", idx);
|
2021-02-03 17:24:48 +03:00
|
|
|
qemu_fdt_setprop_cell(fdt, ser, "clock-frequency", PLATFORM_CLK_FREQ_HZ);
|
2013-11-11 12:14:41 +04:00
|
|
|
qemu_fdt_setprop_cells(fdt, ser, "interrupts", 42, 2);
|
|
|
|
qemu_fdt_setprop_phandle(fdt, ser, "interrupt-parent", mpic);
|
|
|
|
qemu_fdt_setprop_string(fdt, "/aliases", alias, ser);
|
2012-06-06 03:19:40 +04:00
|
|
|
|
|
|
|
if (defcon) {
|
2018-03-01 09:05:50 +03:00
|
|
|
/*
|
|
|
|
* "linux,stdout-path" and "stdout" properties are deprecated by linux
|
|
|
|
* kernel. New platforms should only use the "stdout-path" property. Set
|
|
|
|
* the new property and continue using older property to remain
|
|
|
|
* compatible with the existing firmware.
|
|
|
|
*/
|
2013-11-11 12:14:41 +04:00
|
|
|
qemu_fdt_setprop_string(fdt, "/chosen", "linux,stdout-path", ser);
|
2018-03-01 09:05:50 +03:00
|
|
|
qemu_fdt_setprop_string(fdt, "/chosen", "stdout-path", ser);
|
2012-06-06 03:19:40 +04:00
|
|
|
}
|
ppc: e500: use g_strdup_printf() instead of snprintf()
qemu-system-ppc fails to build with GCC 8.0.1:
/home/hsp/src/qemu-master/hw/ppc/e500.c: In function ‘ppce500_load_device_tree’:
/home/hsp/src/qemu-master/hw/ppc/e500.c:442:37: error: ‘/pic@’
directive output may be truncated writing 5 bytes into a region of
size between 1 and 128 [-Werror=format-truncation=]
snprintf(mpic, sizeof(mpic), "%s/pic@%llx", soc, MPC8544_MPIC_REGS_OFFSET);
^~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 11 and 138 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:470:39: error:
‘/global-utilities@’ directive output may be truncated writing 18
bytes into a region of size between 1 and 128
[-Werror=format-truncation=]
snprintf(gutil, sizeof(gutil), "%s/global-utilities@%llx", soc,
^~~~~~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 24 and 151 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:477:36: error: ‘/msi@’
directive output may be truncated writing 5 bytes into a region of
size between 0 and 127 [-Werror=format-truncation=]
snprintf(msi, sizeof(msi), "/%s/msi@%llx", soc, MPC8544_MSI_REGS_OFFSET);
^~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 12 and 139 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fix this by converting e500 to use g_strdup_printf()+g_free() instead
of snprintf(). This is done globally, even for call sites that don't
break build, since this is the preferred practice in QEMU.
Reported-by: Howard Spoelstra <hsp.cat7@gmail.com>
Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 152568372989.443627.900708381919207053.stgit@bahia.lan
Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2018-05-07 12:02:09 +03:00
|
|
|
g_free(ser);
|
2012-06-06 03:19:40 +04:00
|
|
|
}
|
|
|
|
|
2014-10-01 18:00:49 +04:00
|
|
|
static void create_dt_mpc8xxx_gpio(void *fdt, const char *soc, const char *mpic)
|
|
|
|
{
|
|
|
|
hwaddr mmio0 = MPC8XXX_GPIO_OFFSET;
|
|
|
|
int irq0 = MPC8XXX_GPIO_IRQ;
|
|
|
|
gchar *node = g_strdup_printf("%s/gpio@%"PRIx64, soc, mmio0);
|
2014-10-01 18:05:47 +04:00
|
|
|
gchar *poweroff = g_strdup_printf("%s/power-off", soc);
|
|
|
|
int gpio_ph;
|
2014-10-01 18:00:49 +04:00
|
|
|
|
|
|
|
qemu_fdt_add_subnode(fdt, node);
|
|
|
|
qemu_fdt_setprop_string(fdt, node, "compatible", "fsl,qoriq-gpio");
|
|
|
|
qemu_fdt_setprop_cells(fdt, node, "reg", mmio0, 0x1000);
|
|
|
|
qemu_fdt_setprop_cells(fdt, node, "interrupts", irq0, 0x2);
|
|
|
|
qemu_fdt_setprop_phandle(fdt, node, "interrupt-parent", mpic);
|
|
|
|
qemu_fdt_setprop_cells(fdt, node, "#gpio-cells", 2);
|
|
|
|
qemu_fdt_setprop(fdt, node, "gpio-controller", NULL, 0);
|
2014-10-01 18:05:47 +04:00
|
|
|
gpio_ph = qemu_fdt_alloc_phandle(fdt);
|
|
|
|
qemu_fdt_setprop_cell(fdt, node, "phandle", gpio_ph);
|
|
|
|
qemu_fdt_setprop_cell(fdt, node, "linux,phandle", gpio_ph);
|
|
|
|
|
|
|
|
/* Power Off Pin */
|
|
|
|
qemu_fdt_add_subnode(fdt, poweroff);
|
|
|
|
qemu_fdt_setprop_string(fdt, poweroff, "compatible", "gpio-poweroff");
|
|
|
|
qemu_fdt_setprop_cells(fdt, poweroff, "gpios", gpio_ph, 0, 0);
|
2014-10-01 18:00:49 +04:00
|
|
|
|
|
|
|
g_free(node);
|
2014-10-01 18:05:47 +04:00
|
|
|
g_free(poweroff);
|
2014-10-01 18:00:49 +04:00
|
|
|
}
|
|
|
|
|
2019-03-06 13:28:12 +03:00
|
|
|
static void dt_rtc_create(void *fdt, const char *i2c, const char *alias)
|
|
|
|
{
|
|
|
|
int offset = RTC_REGS_OFFSET;
|
|
|
|
|
|
|
|
gchar *rtc = g_strdup_printf("%s/rtc@%"PRIx32, i2c, offset);
|
|
|
|
qemu_fdt_add_subnode(fdt, rtc);
|
|
|
|
qemu_fdt_setprop_string(fdt, rtc, "compatible", "pericom,pt7c4338");
|
|
|
|
qemu_fdt_setprop_cells(fdt, rtc, "reg", offset);
|
|
|
|
qemu_fdt_setprop_string(fdt, "/aliases", alias, rtc);
|
|
|
|
|
|
|
|
g_free(rtc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dt_i2c_create(void *fdt, const char *soc, const char *mpic,
|
|
|
|
const char *alias)
|
|
|
|
{
|
|
|
|
hwaddr mmio0 = MPC8544_I2C_REGS_OFFSET;
|
|
|
|
int irq0 = MPC8544_I2C_IRQ;
|
|
|
|
|
|
|
|
gchar *i2c = g_strdup_printf("%s/i2c@%"PRIx64, soc, mmio0);
|
|
|
|
qemu_fdt_add_subnode(fdt, i2c);
|
|
|
|
qemu_fdt_setprop_string(fdt, i2c, "device_type", "i2c");
|
|
|
|
qemu_fdt_setprop_string(fdt, i2c, "compatible", "fsl-i2c");
|
|
|
|
qemu_fdt_setprop_cells(fdt, i2c, "reg", mmio0, 0x14);
|
|
|
|
qemu_fdt_setprop_cells(fdt, i2c, "cell-index", 0);
|
|
|
|
qemu_fdt_setprop_cells(fdt, i2c, "interrupts", irq0, 0x2);
|
|
|
|
qemu_fdt_setprop_phandle(fdt, i2c, "interrupt-parent", mpic);
|
|
|
|
qemu_fdt_setprop_string(fdt, "/aliases", alias, i2c);
|
|
|
|
|
|
|
|
g_free(i2c);
|
|
|
|
}
|
|
|
|
|
2022-11-02 01:29:34 +03:00
|
|
|
static void dt_sdhc_create(void *fdt, const char *parent, const char *mpic)
|
|
|
|
{
|
|
|
|
hwaddr mmio = MPC85XX_ESDHC_REGS_OFFSET;
|
|
|
|
hwaddr size = MPC85XX_ESDHC_REGS_SIZE;
|
|
|
|
int irq = MPC85XX_ESDHC_IRQ;
|
|
|
|
g_autofree char *name = NULL;
|
|
|
|
|
|
|
|
name = g_strdup_printf("%s/sdhc@%" PRIx64, parent, mmio);
|
|
|
|
qemu_fdt_add_subnode(fdt, name);
|
|
|
|
qemu_fdt_setprop(fdt, name, "sdhci,auto-cmd12", NULL, 0);
|
|
|
|
qemu_fdt_setprop_phandle(fdt, name, "interrupt-parent", mpic);
|
|
|
|
qemu_fdt_setprop_cells(fdt, name, "bus-width", 4);
|
|
|
|
qemu_fdt_setprop_cells(fdt, name, "interrupts", irq, 0x2);
|
|
|
|
qemu_fdt_setprop_cells(fdt, name, "reg", mmio, size);
|
|
|
|
qemu_fdt_setprop_string(fdt, name, "compatible", "fsl,esdhc");
|
|
|
|
}
|
2019-03-06 13:28:12 +03:00
|
|
|
|
2014-07-01 18:27:09 +04:00
|
|
|
typedef struct PlatformDevtreeData {
|
|
|
|
void *fdt;
|
|
|
|
const char *mpic;
|
|
|
|
int irq_start;
|
|
|
|
const char *node;
|
|
|
|
PlatformBusDevice *pbus;
|
|
|
|
} PlatformDevtreeData;
|
|
|
|
|
2014-07-02 01:30:06 +04:00
|
|
|
static int create_devtree_etsec(SysBusDevice *sbdev, PlatformDevtreeData *data)
|
|
|
|
{
|
|
|
|
eTSEC *etsec = ETSEC_COMMON(sbdev);
|
|
|
|
PlatformBusDevice *pbus = data->pbus;
|
|
|
|
hwaddr mmio0 = platform_bus_get_mmio_addr(pbus, sbdev, 0);
|
|
|
|
int irq0 = platform_bus_get_irqn(pbus, sbdev, 0);
|
|
|
|
int irq1 = platform_bus_get_irqn(pbus, sbdev, 1);
|
|
|
|
int irq2 = platform_bus_get_irqn(pbus, sbdev, 2);
|
2023-01-25 16:00:23 +03:00
|
|
|
gchar *node = g_strdup_printf("%s/ethernet@%"PRIx64, data->node, mmio0);
|
2014-07-02 01:30:06 +04:00
|
|
|
gchar *group = g_strdup_printf("%s/queue-group", node);
|
|
|
|
void *fdt = data->fdt;
|
|
|
|
|
|
|
|
assert((int64_t)mmio0 >= 0);
|
|
|
|
assert(irq0 >= 0);
|
|
|
|
assert(irq1 >= 0);
|
|
|
|
assert(irq2 >= 0);
|
|
|
|
|
|
|
|
qemu_fdt_add_subnode(fdt, node);
|
2021-02-24 12:28:39 +03:00
|
|
|
qemu_fdt_setprop(fdt, node, "ranges", NULL, 0);
|
2014-07-02 01:30:06 +04:00
|
|
|
qemu_fdt_setprop_string(fdt, node, "device_type", "network");
|
|
|
|
qemu_fdt_setprop_string(fdt, node, "compatible", "fsl,etsec2");
|
|
|
|
qemu_fdt_setprop_string(fdt, node, "model", "eTSEC");
|
|
|
|
qemu_fdt_setprop(fdt, node, "local-mac-address", etsec->conf.macaddr.a, 6);
|
|
|
|
qemu_fdt_setprop_cells(fdt, node, "fixed-link", 0, 1, 1000, 0, 0);
|
2021-03-11 11:16:08 +03:00
|
|
|
qemu_fdt_setprop_cells(fdt, node, "#size-cells", 1);
|
|
|
|
qemu_fdt_setprop_cells(fdt, node, "#address-cells", 1);
|
2014-07-02 01:30:06 +04:00
|
|
|
|
|
|
|
qemu_fdt_add_subnode(fdt, group);
|
|
|
|
qemu_fdt_setprop_cells(fdt, group, "reg", mmio0, 0x1000);
|
|
|
|
qemu_fdt_setprop_cells(fdt, group, "interrupts",
|
|
|
|
data->irq_start + irq0, 0x2,
|
|
|
|
data->irq_start + irq1, 0x2,
|
|
|
|
data->irq_start + irq2, 0x2);
|
|
|
|
|
|
|
|
g_free(node);
|
|
|
|
g_free(group);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-09-21 08:23:53 +03:00
|
|
|
static void sysbus_device_create_devtree(SysBusDevice *sbdev, void *opaque)
|
2014-07-01 18:27:09 +04:00
|
|
|
{
|
|
|
|
PlatformDevtreeData *data = opaque;
|
|
|
|
bool matched = false;
|
|
|
|
|
2014-07-02 01:30:06 +04:00
|
|
|
if (object_dynamic_cast(OBJECT(sbdev), TYPE_ETSEC_COMMON)) {
|
|
|
|
create_devtree_etsec(sbdev, data);
|
|
|
|
matched = true;
|
|
|
|
}
|
|
|
|
|
2014-07-01 18:27:09 +04:00
|
|
|
if (!matched) {
|
|
|
|
error_report("Device %s is not supported by this machine yet.",
|
|
|
|
qdev_fw_name(DEVICE(sbdev)));
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-19 00:01:44 +03:00
|
|
|
static void create_devtree_flash(SysBusDevice *sbdev,
|
|
|
|
PlatformDevtreeData *data)
|
|
|
|
{
|
|
|
|
g_autofree char *name = NULL;
|
|
|
|
uint64_t num_blocks = object_property_get_uint(OBJECT(sbdev),
|
|
|
|
"num-blocks",
|
|
|
|
&error_fatal);
|
|
|
|
uint64_t sector_length = object_property_get_uint(OBJECT(sbdev),
|
|
|
|
"sector-length",
|
|
|
|
&error_fatal);
|
|
|
|
uint64_t bank_width = object_property_get_uint(OBJECT(sbdev),
|
|
|
|
"width",
|
|
|
|
&error_fatal);
|
|
|
|
hwaddr flashbase = 0;
|
|
|
|
hwaddr flashsize = num_blocks * sector_length;
|
|
|
|
void *fdt = data->fdt;
|
|
|
|
|
|
|
|
name = g_strdup_printf("%s/nor@%" PRIx64, data->node, flashbase);
|
|
|
|
qemu_fdt_add_subnode(fdt, name);
|
|
|
|
qemu_fdt_setprop_string(fdt, name, "compatible", "cfi-flash");
|
|
|
|
qemu_fdt_setprop_sized_cells(fdt, name, "reg",
|
|
|
|
1, flashbase, 1, flashsize);
|
|
|
|
qemu_fdt_setprop_cell(fdt, name, "bank-width", bank_width);
|
|
|
|
}
|
|
|
|
|
2018-05-10 20:10:56 +03:00
|
|
|
static void platform_bus_create_devtree(PPCE500MachineState *pms,
|
2018-04-18 17:28:02 +03:00
|
|
|
void *fdt, const char *mpic)
|
2014-07-01 18:27:09 +04:00
|
|
|
{
|
2018-05-10 20:10:56 +03:00
|
|
|
const PPCE500MachineClass *pmc = PPCE500_MACHINE_GET_CLASS(pms);
|
2018-04-18 17:28:02 +03:00
|
|
|
gchar *node = g_strdup_printf("/platform@%"PRIx64, pmc->platform_bus_base);
|
2014-07-01 18:27:09 +04:00
|
|
|
const char platcomp[] = "qemu,platform\0simple-bus";
|
2018-04-18 17:28:02 +03:00
|
|
|
uint64_t addr = pmc->platform_bus_base;
|
|
|
|
uint64_t size = pmc->platform_bus_size;
|
|
|
|
int irq_start = pmc->platform_bus_first_irq;
|
2022-10-19 00:01:44 +03:00
|
|
|
SysBusDevice *sbdev;
|
|
|
|
bool ambiguous;
|
2014-07-01 18:27:09 +04:00
|
|
|
|
|
|
|
/* Create a /platform node that we can put all devices into */
|
|
|
|
|
|
|
|
qemu_fdt_add_subnode(fdt, node);
|
|
|
|
qemu_fdt_setprop(fdt, node, "compatible", platcomp, sizeof(platcomp));
|
|
|
|
|
|
|
|
/* Our platform bus region is less than 32bit big, so 1 cell is enough for
|
|
|
|
address and size */
|
|
|
|
qemu_fdt_setprop_cells(fdt, node, "#size-cells", 1);
|
|
|
|
qemu_fdt_setprop_cells(fdt, node, "#address-cells", 1);
|
|
|
|
qemu_fdt_setprop_cells(fdt, node, "ranges", 0, addr >> 32, addr, size);
|
|
|
|
|
|
|
|
qemu_fdt_setprop_phandle(fdt, node, "interrupt-parent", mpic);
|
|
|
|
|
2018-05-10 20:10:56 +03:00
|
|
|
/* Create dt nodes for dynamic devices */
|
|
|
|
PlatformDevtreeData data = {
|
|
|
|
.fdt = fdt,
|
|
|
|
.mpic = mpic,
|
|
|
|
.irq_start = irq_start,
|
|
|
|
.node = node,
|
|
|
|
.pbus = pms->pbus_dev,
|
|
|
|
};
|
2014-07-01 18:27:09 +04:00
|
|
|
|
2018-05-10 20:10:56 +03:00
|
|
|
/* Loop through all dynamic sysbus devices and create nodes for them */
|
|
|
|
foreach_dynamic_sysbus_device(sysbus_device_create_devtree, &data);
|
2014-07-01 18:27:09 +04:00
|
|
|
|
2022-10-19 00:01:44 +03:00
|
|
|
sbdev = SYS_BUS_DEVICE(object_resolve_path_type("", TYPE_PFLASH_CFI01,
|
|
|
|
&ambiguous));
|
|
|
|
if (sbdev) {
|
|
|
|
assert(!ambiguous);
|
|
|
|
create_devtree_flash(sbdev, &data);
|
|
|
|
}
|
|
|
|
|
2014-07-01 18:27:09 +04:00
|
|
|
g_free(node);
|
|
|
|
}
|
|
|
|
|
2018-04-18 17:28:02 +03:00
|
|
|
static int ppce500_load_device_tree(PPCE500MachineState *pms,
|
2012-10-23 14:30:10 +04:00
|
|
|
hwaddr addr,
|
|
|
|
hwaddr initrd_base,
|
2013-07-19 14:56:24 +04:00
|
|
|
hwaddr initrd_size,
|
2014-01-20 03:21:04 +04:00
|
|
|
hwaddr kernel_base,
|
|
|
|
hwaddr kernel_size,
|
2013-07-19 14:56:24 +04:00
|
|
|
bool dry_run)
|
2009-03-02 19:42:42 +03:00
|
|
|
{
|
2018-04-18 17:28:02 +03:00
|
|
|
MachineState *machine = MACHINE(pms);
|
2019-05-18 23:54:22 +03:00
|
|
|
unsigned int smp_cpus = machine->smp.cpus;
|
2018-04-18 17:28:02 +03:00
|
|
|
const PPCE500MachineClass *pmc = PPCE500_MACHINE_GET_CLASS(pms);
|
2013-07-19 14:56:24 +04:00
|
|
|
CPUPPCState *env = first_cpu->env_ptr;
|
2010-02-27 21:47:22 +03:00
|
|
|
int ret = -1;
|
2014-05-07 18:42:57 +04:00
|
|
|
uint64_t mem_reg_property[] = { 0, cpu_to_be64(machine->ram_size) };
|
2009-04-10 20:23:59 +04:00
|
|
|
int fdt_size;
|
2010-02-27 21:47:22 +03:00
|
|
|
void *fdt;
|
2011-06-16 01:34:04 +04:00
|
|
|
uint8_t hypercall[16];
|
2021-02-03 17:24:47 +03:00
|
|
|
uint32_t clock_freq = PLATFORM_CLK_FREQ_HZ;
|
|
|
|
uint32_t tb_freq = PLATFORM_CLK_FREQ_HZ;
|
2011-07-21 05:01:11 +04:00
|
|
|
int i;
|
2012-06-06 02:20:20 +04:00
|
|
|
char compatible_sb[] = "fsl,mpc8544-immr\0simple-bus";
|
ppc: e500: use g_strdup_printf() instead of snprintf()
qemu-system-ppc fails to build with GCC 8.0.1:
/home/hsp/src/qemu-master/hw/ppc/e500.c: In function ‘ppce500_load_device_tree’:
/home/hsp/src/qemu-master/hw/ppc/e500.c:442:37: error: ‘/pic@’
directive output may be truncated writing 5 bytes into a region of
size between 1 and 128 [-Werror=format-truncation=]
snprintf(mpic, sizeof(mpic), "%s/pic@%llx", soc, MPC8544_MPIC_REGS_OFFSET);
^~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 11 and 138 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:470:39: error:
‘/global-utilities@’ directive output may be truncated writing 18
bytes into a region of size between 1 and 128
[-Werror=format-truncation=]
snprintf(gutil, sizeof(gutil), "%s/global-utilities@%llx", soc,
^~~~~~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 24 and 151 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:477:36: error: ‘/msi@’
directive output may be truncated writing 5 bytes into a region of
size between 0 and 127 [-Werror=format-truncation=]
snprintf(msi, sizeof(msi), "/%s/msi@%llx", soc, MPC8544_MSI_REGS_OFFSET);
^~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 12 and 139 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fix this by converting e500 to use g_strdup_printf()+g_free() instead
of snprintf(). This is done globally, even for call sites that don't
break build, since this is the preferred practice in QEMU.
Reported-by: Howard Spoelstra <hsp.cat7@gmail.com>
Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 152568372989.443627.900708381919207053.stgit@bahia.lan
Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2018-05-07 12:02:09 +03:00
|
|
|
char *soc;
|
|
|
|
char *mpic;
|
2012-05-17 16:51:51 +04:00
|
|
|
uint32_t mpic_ph;
|
2012-12-08 17:26:37 +04:00
|
|
|
uint32_t msi_ph;
|
ppc: e500: use g_strdup_printf() instead of snprintf()
qemu-system-ppc fails to build with GCC 8.0.1:
/home/hsp/src/qemu-master/hw/ppc/e500.c: In function ‘ppce500_load_device_tree’:
/home/hsp/src/qemu-master/hw/ppc/e500.c:442:37: error: ‘/pic@’
directive output may be truncated writing 5 bytes into a region of
size between 1 and 128 [-Werror=format-truncation=]
snprintf(mpic, sizeof(mpic), "%s/pic@%llx", soc, MPC8544_MPIC_REGS_OFFSET);
^~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 11 and 138 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:470:39: error:
‘/global-utilities@’ directive output may be truncated writing 18
bytes into a region of size between 1 and 128
[-Werror=format-truncation=]
snprintf(gutil, sizeof(gutil), "%s/global-utilities@%llx", soc,
^~~~~~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 24 and 151 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:477:36: error: ‘/msi@’
directive output may be truncated writing 5 bytes into a region of
size between 0 and 127 [-Werror=format-truncation=]
snprintf(msi, sizeof(msi), "/%s/msi@%llx", soc, MPC8544_MSI_REGS_OFFSET);
^~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 12 and 139 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fix this by converting e500 to use g_strdup_printf()+g_free() instead
of snprintf(). This is done globally, even for call sites that don't
break build, since this is the preferred practice in QEMU.
Reported-by: Howard Spoelstra <hsp.cat7@gmail.com>
Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 152568372989.443627.900708381919207053.stgit@bahia.lan
Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2018-05-07 12:02:09 +03:00
|
|
|
char *gutil;
|
|
|
|
char *pci;
|
|
|
|
char *msi;
|
2012-12-12 16:47:07 +04:00
|
|
|
uint32_t *pci_map = NULL;
|
|
|
|
int len;
|
2012-06-06 02:25:06 +04:00
|
|
|
uint32_t pci_ranges[14] =
|
|
|
|
{
|
2018-04-18 17:28:02 +03:00
|
|
|
0x2000000, 0x0, pmc->pci_mmio_bus_base,
|
|
|
|
pmc->pci_mmio_base >> 32, pmc->pci_mmio_base,
|
2012-06-06 02:25:06 +04:00
|
|
|
0x0, 0x20000000,
|
|
|
|
|
|
|
|
0x1000000, 0x0, 0x0,
|
2018-04-18 17:28:02 +03:00
|
|
|
pmc->pci_pio_base >> 32, pmc->pci_pio_base,
|
2012-06-06 02:25:06 +04:00
|
|
|
0x0, 0x10000,
|
|
|
|
};
|
2020-11-02 17:44:36 +03:00
|
|
|
const char *dtb_file = machine->dtb;
|
|
|
|
const char *toplevel_compat = machine->dt_compatible;
|
2022-07-12 16:51:14 +03:00
|
|
|
uint8_t rng_seed[32];
|
2012-05-22 16:28:50 +04:00
|
|
|
|
|
|
|
if (dtb_file) {
|
|
|
|
char *filename;
|
|
|
|
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, dtb_file);
|
|
|
|
if (!filename) {
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
fdt = load_device_tree(filename, &fdt_size);
|
2015-02-28 20:27:43 +03:00
|
|
|
g_free(filename);
|
2012-05-22 16:28:50 +04:00
|
|
|
if (!fdt) {
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
goto done;
|
|
|
|
}
|
2009-03-02 19:42:42 +03:00
|
|
|
|
2012-05-17 17:50:14 +04:00
|
|
|
fdt = create_device_tree(&fdt_size);
|
2009-05-30 03:52:44 +04:00
|
|
|
if (fdt == NULL) {
|
|
|
|
goto out;
|
|
|
|
}
|
2009-03-02 19:42:42 +03:00
|
|
|
|
|
|
|
/* Manipulate device tree in memory. */
|
2013-11-11 12:14:41 +04:00
|
|
|
qemu_fdt_setprop_cell(fdt, "/", "#address-cells", 2);
|
|
|
|
qemu_fdt_setprop_cell(fdt, "/", "#size-cells", 2);
|
2012-05-17 14:20:50 +04:00
|
|
|
|
2013-11-11 12:14:41 +04:00
|
|
|
qemu_fdt_add_subnode(fdt, "/memory");
|
|
|
|
qemu_fdt_setprop_string(fdt, "/memory", "device_type", "memory");
|
|
|
|
qemu_fdt_setprop(fdt, "/memory", "reg", mem_reg_property,
|
|
|
|
sizeof(mem_reg_property));
|
2009-03-02 19:42:42 +03:00
|
|
|
|
2013-11-11 12:14:41 +04:00
|
|
|
qemu_fdt_add_subnode(fdt, "/chosen");
|
2011-05-01 01:34:53 +04:00
|
|
|
if (initrd_size) {
|
2013-11-11 12:14:41 +04:00
|
|
|
ret = qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-start",
|
|
|
|
initrd_base);
|
2011-05-01 01:34:53 +04:00
|
|
|
if (ret < 0) {
|
|
|
|
fprintf(stderr, "couldn't set /chosen/linux,initrd-start\n");
|
|
|
|
}
|
2009-03-02 19:42:42 +03:00
|
|
|
|
2013-11-11 12:14:41 +04:00
|
|
|
ret = qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-end",
|
|
|
|
(initrd_base + initrd_size));
|
2011-05-01 01:34:53 +04:00
|
|
|
if (ret < 0) {
|
|
|
|
fprintf(stderr, "couldn't set /chosen/linux,initrd-end\n");
|
|
|
|
}
|
2014-01-20 03:21:04 +04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (kernel_base != -1ULL) {
|
|
|
|
qemu_fdt_setprop_cells(fdt, "/chosen", "qemu,boot-kernel",
|
|
|
|
kernel_base >> 32, kernel_base,
|
|
|
|
kernel_size >> 32, kernel_size);
|
2011-05-01 01:34:53 +04:00
|
|
|
}
|
2009-03-02 19:42:42 +03:00
|
|
|
|
2013-11-11 12:14:41 +04:00
|
|
|
ret = qemu_fdt_setprop_string(fdt, "/chosen", "bootargs",
|
2014-05-07 18:42:57 +04:00
|
|
|
machine->kernel_cmdline);
|
2009-03-02 19:42:42 +03:00
|
|
|
if (ret < 0)
|
|
|
|
fprintf(stderr, "couldn't set /chosen/bootargs\n");
|
|
|
|
|
2022-07-12 16:51:14 +03:00
|
|
|
qemu_guest_getrandom_nofail(rng_seed, sizeof(rng_seed));
|
|
|
|
qemu_fdt_setprop(fdt, "/chosen", "rng-seed", rng_seed, sizeof(rng_seed));
|
|
|
|
|
2009-03-02 19:42:42 +03:00
|
|
|
if (kvm_enabled()) {
|
2011-07-21 04:34:11 +04:00
|
|
|
/* Read out host's frequencies */
|
|
|
|
clock_freq = kvmppc_get_clockfreq();
|
|
|
|
tb_freq = kvmppc_get_tbfreq();
|
2011-06-16 01:34:04 +04:00
|
|
|
|
|
|
|
/* indicate KVM hypercall interface */
|
2013-11-11 12:14:41 +04:00
|
|
|
qemu_fdt_add_subnode(fdt, "/hypervisor");
|
|
|
|
qemu_fdt_setprop_string(fdt, "/hypervisor", "compatible",
|
|
|
|
"linux,kvm");
|
2011-06-16 01:34:04 +04:00
|
|
|
kvmppc_get_hypercall(env, hypercall, sizeof(hypercall));
|
2013-11-11 12:14:41 +04:00
|
|
|
qemu_fdt_setprop(fdt, "/hypervisor", "hcall-instructions",
|
|
|
|
hypercall, sizeof(hypercall));
|
2013-01-03 16:37:02 +04:00
|
|
|
/* if KVM supports the idle hcall, set property indicating this */
|
|
|
|
if (kvmppc_get_hasidle(env)) {
|
2013-11-11 12:14:41 +04:00
|
|
|
qemu_fdt_setprop(fdt, "/hypervisor", "has-idle", NULL, 0);
|
2013-01-03 16:37:02 +04:00
|
|
|
}
|
2009-03-02 19:42:42 +03:00
|
|
|
}
|
2011-05-01 01:34:53 +04:00
|
|
|
|
2012-05-17 13:48:16 +04:00
|
|
|
/* Create CPU nodes */
|
2013-11-11 12:14:41 +04:00
|
|
|
qemu_fdt_add_subnode(fdt, "/cpus");
|
|
|
|
qemu_fdt_setprop_cell(fdt, "/cpus", "#address-cells", 1);
|
|
|
|
qemu_fdt_setprop_cell(fdt, "/cpus", "#size-cells", 0);
|
2012-05-17 13:48:16 +04:00
|
|
|
|
2011-07-23 12:56:40 +04:00
|
|
|
/* We need to generate the cpu nodes in reverse order, so Linux can pick
|
|
|
|
the first node as boot node and be happy */
|
|
|
|
for (i = smp_cpus - 1; i >= 0; i--) {
|
2013-02-15 18:21:13 +04:00
|
|
|
CPUState *cpu;
|
ppc: e500: use g_strdup_printf() instead of snprintf()
qemu-system-ppc fails to build with GCC 8.0.1:
/home/hsp/src/qemu-master/hw/ppc/e500.c: In function ‘ppce500_load_device_tree’:
/home/hsp/src/qemu-master/hw/ppc/e500.c:442:37: error: ‘/pic@’
directive output may be truncated writing 5 bytes into a region of
size between 1 and 128 [-Werror=format-truncation=]
snprintf(mpic, sizeof(mpic), "%s/pic@%llx", soc, MPC8544_MPIC_REGS_OFFSET);
^~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 11 and 138 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:470:39: error:
‘/global-utilities@’ directive output may be truncated writing 18
bytes into a region of size between 1 and 128
[-Werror=format-truncation=]
snprintf(gutil, sizeof(gutil), "%s/global-utilities@%llx", soc,
^~~~~~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 24 and 151 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:477:36: error: ‘/msi@’
directive output may be truncated writing 5 bytes into a region of
size between 0 and 127 [-Werror=format-truncation=]
snprintf(msi, sizeof(msi), "/%s/msi@%llx", soc, MPC8544_MSI_REGS_OFFSET);
^~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 12 and 139 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fix this by converting e500 to use g_strdup_printf()+g_free() instead
of snprintf(). This is done globally, even for call sites that don't
break build, since this is the preferred practice in QEMU.
Reported-by: Howard Spoelstra <hsp.cat7@gmail.com>
Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 152568372989.443627.900708381919207053.stgit@bahia.lan
Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2018-05-07 12:02:09 +03:00
|
|
|
char *cpu_name;
|
2018-04-18 17:28:02 +03:00
|
|
|
uint64_t cpu_release_addr = pmc->spin_base + (i * 0x20);
|
2011-07-21 05:06:12 +04:00
|
|
|
|
2013-02-15 18:21:13 +04:00
|
|
|
cpu = qemu_get_cpu(i);
|
2012-12-17 09:18:02 +04:00
|
|
|
if (cpu == NULL) {
|
2011-07-23 12:56:40 +04:00
|
|
|
continue;
|
|
|
|
}
|
2013-02-15 18:21:13 +04:00
|
|
|
env = cpu->env_ptr;
|
2011-07-23 12:56:40 +04:00
|
|
|
|
ppc: e500: use g_strdup_printf() instead of snprintf()
qemu-system-ppc fails to build with GCC 8.0.1:
/home/hsp/src/qemu-master/hw/ppc/e500.c: In function ‘ppce500_load_device_tree’:
/home/hsp/src/qemu-master/hw/ppc/e500.c:442:37: error: ‘/pic@’
directive output may be truncated writing 5 bytes into a region of
size between 1 and 128 [-Werror=format-truncation=]
snprintf(mpic, sizeof(mpic), "%s/pic@%llx", soc, MPC8544_MPIC_REGS_OFFSET);
^~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 11 and 138 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:470:39: error:
‘/global-utilities@’ directive output may be truncated writing 18
bytes into a region of size between 1 and 128
[-Werror=format-truncation=]
snprintf(gutil, sizeof(gutil), "%s/global-utilities@%llx", soc,
^~~~~~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 24 and 151 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:477:36: error: ‘/msi@’
directive output may be truncated writing 5 bytes into a region of
size between 0 and 127 [-Werror=format-truncation=]
snprintf(msi, sizeof(msi), "/%s/msi@%llx", soc, MPC8544_MSI_REGS_OFFSET);
^~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 12 and 139 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fix this by converting e500 to use g_strdup_printf()+g_free() instead
of snprintf(). This is done globally, even for call sites that don't
break build, since this is the preferred practice in QEMU.
Reported-by: Howard Spoelstra <hsp.cat7@gmail.com>
Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 152568372989.443627.900708381919207053.stgit@bahia.lan
Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2018-05-07 12:02:09 +03:00
|
|
|
cpu_name = g_strdup_printf("/cpus/PowerPC,8544@%x", i);
|
2013-11-11 12:14:41 +04:00
|
|
|
qemu_fdt_add_subnode(fdt, cpu_name);
|
|
|
|
qemu_fdt_setprop_cell(fdt, cpu_name, "clock-frequency", clock_freq);
|
|
|
|
qemu_fdt_setprop_cell(fdt, cpu_name, "timebase-frequency", tb_freq);
|
|
|
|
qemu_fdt_setprop_string(fdt, cpu_name, "device_type", "cpu");
|
2017-08-03 09:28:36 +03:00
|
|
|
qemu_fdt_setprop_cell(fdt, cpu_name, "reg", i);
|
2013-11-11 12:14:41 +04:00
|
|
|
qemu_fdt_setprop_cell(fdt, cpu_name, "d-cache-line-size",
|
|
|
|
env->dcache_line_size);
|
|
|
|
qemu_fdt_setprop_cell(fdt, cpu_name, "i-cache-line-size",
|
|
|
|
env->icache_line_size);
|
|
|
|
qemu_fdt_setprop_cell(fdt, cpu_name, "d-cache-size", 0x8000);
|
|
|
|
qemu_fdt_setprop_cell(fdt, cpu_name, "i-cache-size", 0x8000);
|
|
|
|
qemu_fdt_setprop_cell(fdt, cpu_name, "bus-frequency", 0);
|
2012-12-17 09:18:02 +04:00
|
|
|
if (cpu->cpu_index) {
|
2013-11-11 12:14:41 +04:00
|
|
|
qemu_fdt_setprop_string(fdt, cpu_name, "status", "disabled");
|
|
|
|
qemu_fdt_setprop_string(fdt, cpu_name, "enable-method",
|
|
|
|
"spin-table");
|
|
|
|
qemu_fdt_setprop_u64(fdt, cpu_name, "cpu-release-addr",
|
|
|
|
cpu_release_addr);
|
2011-07-23 12:56:40 +04:00
|
|
|
} else {
|
2013-11-11 12:14:41 +04:00
|
|
|
qemu_fdt_setprop_string(fdt, cpu_name, "status", "okay");
|
2011-07-23 12:56:40 +04:00
|
|
|
}
|
ppc: e500: use g_strdup_printf() instead of snprintf()
qemu-system-ppc fails to build with GCC 8.0.1:
/home/hsp/src/qemu-master/hw/ppc/e500.c: In function ‘ppce500_load_device_tree’:
/home/hsp/src/qemu-master/hw/ppc/e500.c:442:37: error: ‘/pic@’
directive output may be truncated writing 5 bytes into a region of
size between 1 and 128 [-Werror=format-truncation=]
snprintf(mpic, sizeof(mpic), "%s/pic@%llx", soc, MPC8544_MPIC_REGS_OFFSET);
^~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 11 and 138 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:470:39: error:
‘/global-utilities@’ directive output may be truncated writing 18
bytes into a region of size between 1 and 128
[-Werror=format-truncation=]
snprintf(gutil, sizeof(gutil), "%s/global-utilities@%llx", soc,
^~~~~~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 24 and 151 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:477:36: error: ‘/msi@’
directive output may be truncated writing 5 bytes into a region of
size between 0 and 127 [-Werror=format-truncation=]
snprintf(msi, sizeof(msi), "/%s/msi@%llx", soc, MPC8544_MSI_REGS_OFFSET);
^~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 12 and 139 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fix this by converting e500 to use g_strdup_printf()+g_free() instead
of snprintf(). This is done globally, even for call sites that don't
break build, since this is the preferred practice in QEMU.
Reported-by: Howard Spoelstra <hsp.cat7@gmail.com>
Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 152568372989.443627.900708381919207053.stgit@bahia.lan
Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2018-05-07 12:02:09 +03:00
|
|
|
g_free(cpu_name);
|
2009-03-02 19:42:42 +03:00
|
|
|
}
|
|
|
|
|
2013-11-11 12:14:41 +04:00
|
|
|
qemu_fdt_add_subnode(fdt, "/aliases");
|
2012-05-17 16:51:07 +04:00
|
|
|
/* XXX These should go into their respective devices' code */
|
ppc: e500: use g_strdup_printf() instead of snprintf()
qemu-system-ppc fails to build with GCC 8.0.1:
/home/hsp/src/qemu-master/hw/ppc/e500.c: In function ‘ppce500_load_device_tree’:
/home/hsp/src/qemu-master/hw/ppc/e500.c:442:37: error: ‘/pic@’
directive output may be truncated writing 5 bytes into a region of
size between 1 and 128 [-Werror=format-truncation=]
snprintf(mpic, sizeof(mpic), "%s/pic@%llx", soc, MPC8544_MPIC_REGS_OFFSET);
^~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 11 and 138 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:470:39: error:
‘/global-utilities@’ directive output may be truncated writing 18
bytes into a region of size between 1 and 128
[-Werror=format-truncation=]
snprintf(gutil, sizeof(gutil), "%s/global-utilities@%llx", soc,
^~~~~~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 24 and 151 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:477:36: error: ‘/msi@’
directive output may be truncated writing 5 bytes into a region of
size between 0 and 127 [-Werror=format-truncation=]
snprintf(msi, sizeof(msi), "/%s/msi@%llx", soc, MPC8544_MSI_REGS_OFFSET);
^~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 12 and 139 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fix this by converting e500 to use g_strdup_printf()+g_free() instead
of snprintf(). This is done globally, even for call sites that don't
break build, since this is the preferred practice in QEMU.
Reported-by: Howard Spoelstra <hsp.cat7@gmail.com>
Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 152568372989.443627.900708381919207053.stgit@bahia.lan
Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2018-05-07 12:02:09 +03:00
|
|
|
soc = g_strdup_printf("/soc@%"PRIx64, pmc->ccsrbar_base);
|
2013-11-11 12:14:41 +04:00
|
|
|
qemu_fdt_add_subnode(fdt, soc);
|
|
|
|
qemu_fdt_setprop_string(fdt, soc, "device_type", "soc");
|
|
|
|
qemu_fdt_setprop(fdt, soc, "compatible", compatible_sb,
|
|
|
|
sizeof(compatible_sb));
|
|
|
|
qemu_fdt_setprop_cell(fdt, soc, "#address-cells", 1);
|
|
|
|
qemu_fdt_setprop_cell(fdt, soc, "#size-cells", 1);
|
|
|
|
qemu_fdt_setprop_cells(fdt, soc, "ranges", 0x0,
|
2018-04-18 17:28:02 +03:00
|
|
|
pmc->ccsrbar_base >> 32, pmc->ccsrbar_base,
|
2013-11-11 12:14:41 +04:00
|
|
|
MPC8544_CCSRBAR_SIZE);
|
2012-05-17 16:51:07 +04:00
|
|
|
/* XXX should contain a reasonable value */
|
2013-11-11 12:14:41 +04:00
|
|
|
qemu_fdt_setprop_cell(fdt, soc, "bus-frequency", 0);
|
2012-05-17 16:51:07 +04:00
|
|
|
|
ppc: e500: use g_strdup_printf() instead of snprintf()
qemu-system-ppc fails to build with GCC 8.0.1:
/home/hsp/src/qemu-master/hw/ppc/e500.c: In function ‘ppce500_load_device_tree’:
/home/hsp/src/qemu-master/hw/ppc/e500.c:442:37: error: ‘/pic@’
directive output may be truncated writing 5 bytes into a region of
size between 1 and 128 [-Werror=format-truncation=]
snprintf(mpic, sizeof(mpic), "%s/pic@%llx", soc, MPC8544_MPIC_REGS_OFFSET);
^~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 11 and 138 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:470:39: error:
‘/global-utilities@’ directive output may be truncated writing 18
bytes into a region of size between 1 and 128
[-Werror=format-truncation=]
snprintf(gutil, sizeof(gutil), "%s/global-utilities@%llx", soc,
^~~~~~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 24 and 151 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:477:36: error: ‘/msi@’
directive output may be truncated writing 5 bytes into a region of
size between 0 and 127 [-Werror=format-truncation=]
snprintf(msi, sizeof(msi), "/%s/msi@%llx", soc, MPC8544_MSI_REGS_OFFSET);
^~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 12 and 139 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fix this by converting e500 to use g_strdup_printf()+g_free() instead
of snprintf(). This is done globally, even for call sites that don't
break build, since this is the preferred practice in QEMU.
Reported-by: Howard Spoelstra <hsp.cat7@gmail.com>
Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 152568372989.443627.900708381919207053.stgit@bahia.lan
Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2018-05-07 12:02:09 +03:00
|
|
|
mpic = g_strdup_printf("%s/pic@%llx", soc, MPC8544_MPIC_REGS_OFFSET);
|
2013-11-11 12:14:41 +04:00
|
|
|
qemu_fdt_add_subnode(fdt, mpic);
|
|
|
|
qemu_fdt_setprop_string(fdt, mpic, "device_type", "open-pic");
|
|
|
|
qemu_fdt_setprop_string(fdt, mpic, "compatible", "fsl,mpic");
|
|
|
|
qemu_fdt_setprop_cells(fdt, mpic, "reg", MPC8544_MPIC_REGS_OFFSET,
|
|
|
|
0x40000);
|
|
|
|
qemu_fdt_setprop_cell(fdt, mpic, "#address-cells", 0);
|
|
|
|
qemu_fdt_setprop_cell(fdt, mpic, "#interrupt-cells", 2);
|
|
|
|
mpic_ph = qemu_fdt_alloc_phandle(fdt);
|
|
|
|
qemu_fdt_setprop_cell(fdt, mpic, "phandle", mpic_ph);
|
|
|
|
qemu_fdt_setprop_cell(fdt, mpic, "linux,phandle", mpic_ph);
|
|
|
|
qemu_fdt_setprop(fdt, mpic, "interrupt-controller", NULL, 0);
|
2012-05-17 16:51:51 +04:00
|
|
|
|
2012-05-17 16:51:34 +04:00
|
|
|
/*
|
|
|
|
* We have to generate ser1 first, because Linux takes the first
|
|
|
|
* device it finds in the dt as serial output device. And we generate
|
|
|
|
* devices in reverse order to the dt.
|
|
|
|
*/
|
2018-04-20 17:52:43 +03:00
|
|
|
if (serial_hd(1)) {
|
2014-06-04 15:48:18 +04:00
|
|
|
dt_serial_create(fdt, MPC8544_SERIAL1_REGS_OFFSET,
|
|
|
|
soc, mpic, "serial1", 1, false);
|
|
|
|
}
|
|
|
|
|
2018-04-20 17:52:43 +03:00
|
|
|
if (serial_hd(0)) {
|
2014-06-04 15:48:18 +04:00
|
|
|
dt_serial_create(fdt, MPC8544_SERIAL0_REGS_OFFSET,
|
|
|
|
soc, mpic, "serial0", 0, true);
|
|
|
|
}
|
2012-05-17 16:51:34 +04:00
|
|
|
|
2019-03-06 13:28:12 +03:00
|
|
|
/* i2c */
|
|
|
|
dt_i2c_create(fdt, soc, mpic, "i2c");
|
|
|
|
|
|
|
|
dt_rtc_create(fdt, "i2c", "rtc");
|
|
|
|
|
2022-11-02 01:29:34 +03:00
|
|
|
/* sdhc */
|
|
|
|
if (pmc->has_esdhc) {
|
|
|
|
dt_sdhc_create(fdt, soc, mpic);
|
|
|
|
}
|
2019-03-06 13:28:12 +03:00
|
|
|
|
ppc: e500: use g_strdup_printf() instead of snprintf()
qemu-system-ppc fails to build with GCC 8.0.1:
/home/hsp/src/qemu-master/hw/ppc/e500.c: In function ‘ppce500_load_device_tree’:
/home/hsp/src/qemu-master/hw/ppc/e500.c:442:37: error: ‘/pic@’
directive output may be truncated writing 5 bytes into a region of
size between 1 and 128 [-Werror=format-truncation=]
snprintf(mpic, sizeof(mpic), "%s/pic@%llx", soc, MPC8544_MPIC_REGS_OFFSET);
^~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 11 and 138 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:470:39: error:
‘/global-utilities@’ directive output may be truncated writing 18
bytes into a region of size between 1 and 128
[-Werror=format-truncation=]
snprintf(gutil, sizeof(gutil), "%s/global-utilities@%llx", soc,
^~~~~~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 24 and 151 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:477:36: error: ‘/msi@’
directive output may be truncated writing 5 bytes into a region of
size between 0 and 127 [-Werror=format-truncation=]
snprintf(msi, sizeof(msi), "/%s/msi@%llx", soc, MPC8544_MSI_REGS_OFFSET);
^~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 12 and 139 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fix this by converting e500 to use g_strdup_printf()+g_free() instead
of snprintf(). This is done globally, even for call sites that don't
break build, since this is the preferred practice in QEMU.
Reported-by: Howard Spoelstra <hsp.cat7@gmail.com>
Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 152568372989.443627.900708381919207053.stgit@bahia.lan
Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2018-05-07 12:02:09 +03:00
|
|
|
gutil = g_strdup_printf("%s/global-utilities@%llx", soc,
|
|
|
|
MPC8544_UTIL_OFFSET);
|
2013-11-11 12:14:41 +04:00
|
|
|
qemu_fdt_add_subnode(fdt, gutil);
|
|
|
|
qemu_fdt_setprop_string(fdt, gutil, "compatible", "fsl,mpc8544-guts");
|
|
|
|
qemu_fdt_setprop_cells(fdt, gutil, "reg", MPC8544_UTIL_OFFSET, 0x1000);
|
|
|
|
qemu_fdt_setprop(fdt, gutil, "fsl,has-rstcr", NULL, 0);
|
ppc: e500: use g_strdup_printf() instead of snprintf()
qemu-system-ppc fails to build with GCC 8.0.1:
/home/hsp/src/qemu-master/hw/ppc/e500.c: In function ‘ppce500_load_device_tree’:
/home/hsp/src/qemu-master/hw/ppc/e500.c:442:37: error: ‘/pic@’
directive output may be truncated writing 5 bytes into a region of
size between 1 and 128 [-Werror=format-truncation=]
snprintf(mpic, sizeof(mpic), "%s/pic@%llx", soc, MPC8544_MPIC_REGS_OFFSET);
^~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 11 and 138 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:470:39: error:
‘/global-utilities@’ directive output may be truncated writing 18
bytes into a region of size between 1 and 128
[-Werror=format-truncation=]
snprintf(gutil, sizeof(gutil), "%s/global-utilities@%llx", soc,
^~~~~~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 24 and 151 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:477:36: error: ‘/msi@’
directive output may be truncated writing 5 bytes into a region of
size between 0 and 127 [-Werror=format-truncation=]
snprintf(msi, sizeof(msi), "/%s/msi@%llx", soc, MPC8544_MSI_REGS_OFFSET);
^~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 12 and 139 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fix this by converting e500 to use g_strdup_printf()+g_free() instead
of snprintf(). This is done globally, even for call sites that don't
break build, since this is the preferred practice in QEMU.
Reported-by: Howard Spoelstra <hsp.cat7@gmail.com>
Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 152568372989.443627.900708381919207053.stgit@bahia.lan
Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2018-05-07 12:02:09 +03:00
|
|
|
g_free(gutil);
|
2012-05-17 16:52:46 +04:00
|
|
|
|
ppc: e500: use g_strdup_printf() instead of snprintf()
qemu-system-ppc fails to build with GCC 8.0.1:
/home/hsp/src/qemu-master/hw/ppc/e500.c: In function ‘ppce500_load_device_tree’:
/home/hsp/src/qemu-master/hw/ppc/e500.c:442:37: error: ‘/pic@’
directive output may be truncated writing 5 bytes into a region of
size between 1 and 128 [-Werror=format-truncation=]
snprintf(mpic, sizeof(mpic), "%s/pic@%llx", soc, MPC8544_MPIC_REGS_OFFSET);
^~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 11 and 138 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:470:39: error:
‘/global-utilities@’ directive output may be truncated writing 18
bytes into a region of size between 1 and 128
[-Werror=format-truncation=]
snprintf(gutil, sizeof(gutil), "%s/global-utilities@%llx", soc,
^~~~~~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 24 and 151 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:477:36: error: ‘/msi@’
directive output may be truncated writing 5 bytes into a region of
size between 0 and 127 [-Werror=format-truncation=]
snprintf(msi, sizeof(msi), "/%s/msi@%llx", soc, MPC8544_MSI_REGS_OFFSET);
^~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 12 and 139 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fix this by converting e500 to use g_strdup_printf()+g_free() instead
of snprintf(). This is done globally, even for call sites that don't
break build, since this is the preferred practice in QEMU.
Reported-by: Howard Spoelstra <hsp.cat7@gmail.com>
Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 152568372989.443627.900708381919207053.stgit@bahia.lan
Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2018-05-07 12:02:09 +03:00
|
|
|
msi = g_strdup_printf("/%s/msi@%llx", soc, MPC8544_MSI_REGS_OFFSET);
|
2013-11-11 12:14:41 +04:00
|
|
|
qemu_fdt_add_subnode(fdt, msi);
|
|
|
|
qemu_fdt_setprop_string(fdt, msi, "compatible", "fsl,mpic-msi");
|
|
|
|
qemu_fdt_setprop_cells(fdt, msi, "reg", MPC8544_MSI_REGS_OFFSET, 0x200);
|
|
|
|
msi_ph = qemu_fdt_alloc_phandle(fdt);
|
|
|
|
qemu_fdt_setprop_cells(fdt, msi, "msi-available-ranges", 0x0, 0x100);
|
|
|
|
qemu_fdt_setprop_phandle(fdt, msi, "interrupt-parent", mpic);
|
|
|
|
qemu_fdt_setprop_cells(fdt, msi, "interrupts",
|
2012-12-08 17:26:37 +04:00
|
|
|
0xe0, 0x0,
|
|
|
|
0xe1, 0x0,
|
|
|
|
0xe2, 0x0,
|
|
|
|
0xe3, 0x0,
|
|
|
|
0xe4, 0x0,
|
|
|
|
0xe5, 0x0,
|
|
|
|
0xe6, 0x0,
|
|
|
|
0xe7, 0x0);
|
2013-11-11 12:14:41 +04:00
|
|
|
qemu_fdt_setprop_cell(fdt, msi, "phandle", msi_ph);
|
|
|
|
qemu_fdt_setprop_cell(fdt, msi, "linux,phandle", msi_ph);
|
ppc: e500: use g_strdup_printf() instead of snprintf()
qemu-system-ppc fails to build with GCC 8.0.1:
/home/hsp/src/qemu-master/hw/ppc/e500.c: In function ‘ppce500_load_device_tree’:
/home/hsp/src/qemu-master/hw/ppc/e500.c:442:37: error: ‘/pic@’
directive output may be truncated writing 5 bytes into a region of
size between 1 and 128 [-Werror=format-truncation=]
snprintf(mpic, sizeof(mpic), "%s/pic@%llx", soc, MPC8544_MPIC_REGS_OFFSET);
^~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 11 and 138 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:470:39: error:
‘/global-utilities@’ directive output may be truncated writing 18
bytes into a region of size between 1 and 128
[-Werror=format-truncation=]
snprintf(gutil, sizeof(gutil), "%s/global-utilities@%llx", soc,
^~~~~~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 24 and 151 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:477:36: error: ‘/msi@’
directive output may be truncated writing 5 bytes into a region of
size between 0 and 127 [-Werror=format-truncation=]
snprintf(msi, sizeof(msi), "/%s/msi@%llx", soc, MPC8544_MSI_REGS_OFFSET);
^~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 12 and 139 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fix this by converting e500 to use g_strdup_printf()+g_free() instead
of snprintf(). This is done globally, even for call sites that don't
break build, since this is the preferred practice in QEMU.
Reported-by: Howard Spoelstra <hsp.cat7@gmail.com>
Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 152568372989.443627.900708381919207053.stgit@bahia.lan
Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2018-05-07 12:02:09 +03:00
|
|
|
g_free(msi);
|
2012-12-08 17:26:37 +04:00
|
|
|
|
ppc: e500: use g_strdup_printf() instead of snprintf()
qemu-system-ppc fails to build with GCC 8.0.1:
/home/hsp/src/qemu-master/hw/ppc/e500.c: In function ‘ppce500_load_device_tree’:
/home/hsp/src/qemu-master/hw/ppc/e500.c:442:37: error: ‘/pic@’
directive output may be truncated writing 5 bytes into a region of
size between 1 and 128 [-Werror=format-truncation=]
snprintf(mpic, sizeof(mpic), "%s/pic@%llx", soc, MPC8544_MPIC_REGS_OFFSET);
^~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 11 and 138 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:470:39: error:
‘/global-utilities@’ directive output may be truncated writing 18
bytes into a region of size between 1 and 128
[-Werror=format-truncation=]
snprintf(gutil, sizeof(gutil), "%s/global-utilities@%llx", soc,
^~~~~~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 24 and 151 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:477:36: error: ‘/msi@’
directive output may be truncated writing 5 bytes into a region of
size between 0 and 127 [-Werror=format-truncation=]
snprintf(msi, sizeof(msi), "/%s/msi@%llx", soc, MPC8544_MSI_REGS_OFFSET);
^~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 12 and 139 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fix this by converting e500 to use g_strdup_printf()+g_free() instead
of snprintf(). This is done globally, even for call sites that don't
break build, since this is the preferred practice in QEMU.
Reported-by: Howard Spoelstra <hsp.cat7@gmail.com>
Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 152568372989.443627.900708381919207053.stgit@bahia.lan
Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2018-05-07 12:02:09 +03:00
|
|
|
pci = g_strdup_printf("/pci@%llx",
|
|
|
|
pmc->ccsrbar_base + MPC8544_PCI_REGS_OFFSET);
|
2013-11-11 12:14:41 +04:00
|
|
|
qemu_fdt_add_subnode(fdt, pci);
|
|
|
|
qemu_fdt_setprop_cell(fdt, pci, "cell-index", 0);
|
|
|
|
qemu_fdt_setprop_string(fdt, pci, "compatible", "fsl,mpc8540-pci");
|
|
|
|
qemu_fdt_setprop_string(fdt, pci, "device_type", "pci");
|
|
|
|
qemu_fdt_setprop_cells(fdt, pci, "interrupt-map-mask", 0xf800, 0x0,
|
|
|
|
0x0, 0x7);
|
|
|
|
pci_map = pci_map_create(fdt, qemu_fdt_get_phandle(fdt, mpic),
|
2018-04-18 17:28:02 +03:00
|
|
|
pmc->pci_first_slot, pmc->pci_nr_slots,
|
2012-12-12 16:53:53 +04:00
|
|
|
&len);
|
2013-11-11 12:14:41 +04:00
|
|
|
qemu_fdt_setprop(fdt, pci, "interrupt-map", pci_map, len);
|
|
|
|
qemu_fdt_setprop_phandle(fdt, pci, "interrupt-parent", mpic);
|
|
|
|
qemu_fdt_setprop_cells(fdt, pci, "interrupts", 24, 2);
|
|
|
|
qemu_fdt_setprop_cells(fdt, pci, "bus-range", 0, 255);
|
2012-06-06 02:25:06 +04:00
|
|
|
for (i = 0; i < 14; i++) {
|
2012-05-17 17:34:34 +04:00
|
|
|
pci_ranges[i] = cpu_to_be32(pci_ranges[i]);
|
|
|
|
}
|
2013-11-11 12:14:41 +04:00
|
|
|
qemu_fdt_setprop_cell(fdt, pci, "fsl,msi", msi_ph);
|
|
|
|
qemu_fdt_setprop(fdt, pci, "ranges", pci_ranges, sizeof(pci_ranges));
|
2014-11-07 18:50:44 +03:00
|
|
|
qemu_fdt_setprop_cells(fdt, pci, "reg",
|
2018-04-18 17:28:02 +03:00
|
|
|
(pmc->ccsrbar_base + MPC8544_PCI_REGS_OFFSET) >> 32,
|
|
|
|
(pmc->ccsrbar_base + MPC8544_PCI_REGS_OFFSET),
|
2014-11-07 18:50:44 +03:00
|
|
|
0, 0x1000);
|
2013-11-11 12:14:41 +04:00
|
|
|
qemu_fdt_setprop_cell(fdt, pci, "clock-frequency", 66666666);
|
|
|
|
qemu_fdt_setprop_cell(fdt, pci, "#interrupt-cells", 1);
|
|
|
|
qemu_fdt_setprop_cell(fdt, pci, "#size-cells", 2);
|
|
|
|
qemu_fdt_setprop_cell(fdt, pci, "#address-cells", 3);
|
|
|
|
qemu_fdt_setprop_string(fdt, "/aliases", "pci0", pci);
|
ppc: e500: use g_strdup_printf() instead of snprintf()
qemu-system-ppc fails to build with GCC 8.0.1:
/home/hsp/src/qemu-master/hw/ppc/e500.c: In function ‘ppce500_load_device_tree’:
/home/hsp/src/qemu-master/hw/ppc/e500.c:442:37: error: ‘/pic@’
directive output may be truncated writing 5 bytes into a region of
size between 1 and 128 [-Werror=format-truncation=]
snprintf(mpic, sizeof(mpic), "%s/pic@%llx", soc, MPC8544_MPIC_REGS_OFFSET);
^~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 11 and 138 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:470:39: error:
‘/global-utilities@’ directive output may be truncated writing 18
bytes into a region of size between 1 and 128
[-Werror=format-truncation=]
snprintf(gutil, sizeof(gutil), "%s/global-utilities@%llx", soc,
^~~~~~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 24 and 151 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:477:36: error: ‘/msi@’
directive output may be truncated writing 5 bytes into a region of
size between 0 and 127 [-Werror=format-truncation=]
snprintf(msi, sizeof(msi), "/%s/msi@%llx", soc, MPC8544_MSI_REGS_OFFSET);
^~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 12 and 139 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fix this by converting e500 to use g_strdup_printf()+g_free() instead
of snprintf(). This is done globally, even for call sites that don't
break build, since this is the preferred practice in QEMU.
Reported-by: Howard Spoelstra <hsp.cat7@gmail.com>
Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 152568372989.443627.900708381919207053.stgit@bahia.lan
Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2018-05-07 12:02:09 +03:00
|
|
|
g_free(pci);
|
2012-05-17 17:34:34 +04:00
|
|
|
|
2018-04-18 17:28:02 +03:00
|
|
|
if (pmc->has_mpc8xxx_gpio) {
|
2014-10-01 18:00:49 +04:00
|
|
|
create_dt_mpc8xxx_gpio(fdt, soc, mpic);
|
|
|
|
}
|
ppc: e500: use g_strdup_printf() instead of snprintf()
qemu-system-ppc fails to build with GCC 8.0.1:
/home/hsp/src/qemu-master/hw/ppc/e500.c: In function ‘ppce500_load_device_tree’:
/home/hsp/src/qemu-master/hw/ppc/e500.c:442:37: error: ‘/pic@’
directive output may be truncated writing 5 bytes into a region of
size between 1 and 128 [-Werror=format-truncation=]
snprintf(mpic, sizeof(mpic), "%s/pic@%llx", soc, MPC8544_MPIC_REGS_OFFSET);
^~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 11 and 138 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:470:39: error:
‘/global-utilities@’ directive output may be truncated writing 18
bytes into a region of size between 1 and 128
[-Werror=format-truncation=]
snprintf(gutil, sizeof(gutil), "%s/global-utilities@%llx", soc,
^~~~~~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 24 and 151 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:477:36: error: ‘/msi@’
directive output may be truncated writing 5 bytes into a region of
size between 0 and 127 [-Werror=format-truncation=]
snprintf(msi, sizeof(msi), "/%s/msi@%llx", soc, MPC8544_MSI_REGS_OFFSET);
^~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 12 and 139 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fix this by converting e500 to use g_strdup_printf()+g_free() instead
of snprintf(). This is done globally, even for call sites that don't
break build, since this is the preferred practice in QEMU.
Reported-by: Howard Spoelstra <hsp.cat7@gmail.com>
Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 152568372989.443627.900708381919207053.stgit@bahia.lan
Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2018-05-07 12:02:09 +03:00
|
|
|
g_free(soc);
|
2014-10-01 18:00:49 +04:00
|
|
|
|
2023-01-25 16:00:22 +03:00
|
|
|
platform_bus_create_devtree(pms, fdt, mpic);
|
|
|
|
|
ppc: e500: use g_strdup_printf() instead of snprintf()
qemu-system-ppc fails to build with GCC 8.0.1:
/home/hsp/src/qemu-master/hw/ppc/e500.c: In function ‘ppce500_load_device_tree’:
/home/hsp/src/qemu-master/hw/ppc/e500.c:442:37: error: ‘/pic@’
directive output may be truncated writing 5 bytes into a region of
size between 1 and 128 [-Werror=format-truncation=]
snprintf(mpic, sizeof(mpic), "%s/pic@%llx", soc, MPC8544_MPIC_REGS_OFFSET);
^~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 11 and 138 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:470:39: error:
‘/global-utilities@’ directive output may be truncated writing 18
bytes into a region of size between 1 and 128
[-Werror=format-truncation=]
snprintf(gutil, sizeof(gutil), "%s/global-utilities@%llx", soc,
^~~~~~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 24 and 151 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/hsp/src/qemu-master/hw/ppc/e500.c:477:36: error: ‘/msi@’
directive output may be truncated writing 5 bytes into a region of
size between 0 and 127 [-Werror=format-truncation=]
snprintf(msi, sizeof(msi), "/%s/msi@%llx", soc, MPC8544_MSI_REGS_OFFSET);
^~~~~
In file included from /usr/include/stdio.h:862,
from /home/hsp/src/qemu-master/include/qemu/osdep.h:68,
from /home/hsp/src/qemu-master/hw/ppc/e500.c:17:
/usr/include/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’
output between 12 and 139 bytes into a destination of size 128
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fix this by converting e500 to use g_strdup_printf()+g_free() instead
of snprintf(). This is done globally, even for call sites that don't
break build, since this is the preferred practice in QEMU.
Reported-by: Howard Spoelstra <hsp.cat7@gmail.com>
Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 152568372989.443627.900708381919207053.stgit@bahia.lan
Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2018-05-07 12:02:09 +03:00
|
|
|
g_free(mpic);
|
2014-07-01 18:27:09 +04:00
|
|
|
|
2018-04-18 17:28:02 +03:00
|
|
|
pmc->fixup_devtree(fdt);
|
2012-07-02 17:03:20 +04:00
|
|
|
|
|
|
|
if (toplevel_compat) {
|
2013-11-11 12:14:41 +04:00
|
|
|
qemu_fdt_setprop(fdt, "/", "compatible", toplevel_compat,
|
|
|
|
strlen(toplevel_compat) + 1);
|
2012-07-02 17:03:20 +04:00
|
|
|
}
|
|
|
|
|
2012-05-22 16:28:50 +04:00
|
|
|
done:
|
2013-07-19 14:56:24 +04:00
|
|
|
if (!dry_run) {
|
2013-11-11 12:14:41 +04:00
|
|
|
qemu_fdt_dumpdtb(fdt, fdt_size);
|
2013-07-19 14:56:24 +04:00
|
|
|
cpu_physical_memory_write(addr, fdt, fdt_size);
|
2023-01-25 16:00:21 +03:00
|
|
|
|
|
|
|
/* Set machine->fdt for 'dumpdtb' QMP/HMP command */
|
|
|
|
g_free(machine->fdt);
|
|
|
|
machine->fdt = fdt;
|
|
|
|
} else {
|
|
|
|
g_free(fdt);
|
2012-05-19 02:48:50 +04:00
|
|
|
}
|
|
|
|
ret = fdt_size;
|
2009-04-10 20:23:59 +04:00
|
|
|
|
2009-03-02 19:42:42 +03:00
|
|
|
out:
|
2012-12-12 16:47:07 +04:00
|
|
|
g_free(pci_map);
|
2009-03-02 19:42:42 +03:00
|
|
|
|
2010-02-02 11:49:02 +03:00
|
|
|
return ret;
|
2009-03-02 19:42:42 +03:00
|
|
|
}
|
|
|
|
|
2013-07-19 14:56:24 +04:00
|
|
|
typedef struct DeviceTreeParams {
|
2018-04-18 17:28:02 +03:00
|
|
|
PPCE500MachineState *machine;
|
2013-07-19 14:56:24 +04:00
|
|
|
hwaddr addr;
|
|
|
|
hwaddr initrd_base;
|
|
|
|
hwaddr initrd_size;
|
2014-01-20 03:21:04 +04:00
|
|
|
hwaddr kernel_base;
|
|
|
|
hwaddr kernel_size;
|
2014-07-01 18:27:09 +04:00
|
|
|
Notifier notifier;
|
2013-07-19 14:56:24 +04:00
|
|
|
} DeviceTreeParams;
|
|
|
|
|
|
|
|
static void ppce500_reset_device_tree(void *opaque)
|
|
|
|
{
|
|
|
|
DeviceTreeParams *p = opaque;
|
2018-04-18 17:28:02 +03:00
|
|
|
ppce500_load_device_tree(p->machine, p->addr, p->initrd_base,
|
2014-01-20 03:21:04 +04:00
|
|
|
p->initrd_size, p->kernel_base, p->kernel_size,
|
|
|
|
false);
|
2013-07-19 14:56:24 +04:00
|
|
|
}
|
|
|
|
|
2014-07-01 18:27:09 +04:00
|
|
|
static void ppce500_init_notify(Notifier *notifier, void *data)
|
|
|
|
{
|
|
|
|
DeviceTreeParams *p = container_of(notifier, DeviceTreeParams, notifier);
|
|
|
|
ppce500_reset_device_tree(p);
|
|
|
|
}
|
|
|
|
|
2018-04-18 17:28:02 +03:00
|
|
|
static int ppce500_prep_device_tree(PPCE500MachineState *machine,
|
2013-07-19 14:56:24 +04:00
|
|
|
hwaddr addr,
|
|
|
|
hwaddr initrd_base,
|
2014-01-20 03:21:04 +04:00
|
|
|
hwaddr initrd_size,
|
|
|
|
hwaddr kernel_base,
|
|
|
|
hwaddr kernel_size)
|
2013-07-19 14:56:24 +04:00
|
|
|
{
|
|
|
|
DeviceTreeParams *p = g_new(DeviceTreeParams, 1);
|
2014-05-07 18:42:57 +04:00
|
|
|
p->machine = machine;
|
2013-07-19 14:56:24 +04:00
|
|
|
p->addr = addr;
|
|
|
|
p->initrd_base = initrd_base;
|
|
|
|
p->initrd_size = initrd_size;
|
2014-01-20 03:21:04 +04:00
|
|
|
p->kernel_base = kernel_base;
|
|
|
|
p->kernel_size = kernel_size;
|
2013-07-19 14:56:24 +04:00
|
|
|
|
|
|
|
qemu_register_reset(ppce500_reset_device_tree, p);
|
2014-07-01 18:27:09 +04:00
|
|
|
p->notifier.notify = ppce500_init_notify;
|
|
|
|
qemu_add_machine_init_done_notifier(&p->notifier);
|
2013-07-19 14:56:24 +04:00
|
|
|
|
|
|
|
/* Issue the device tree loader once, so that we get the size of the blob */
|
2018-04-18 17:28:02 +03:00
|
|
|
return ppce500_load_device_tree(machine, addr, initrd_base, initrd_size,
|
|
|
|
kernel_base, kernel_size, true);
|
2013-07-19 14:56:24 +04:00
|
|
|
}
|
|
|
|
|
2016-06-28 16:50:05 +03:00
|
|
|
hwaddr booke206_page_size_to_tlb(uint64_t size)
|
2011-06-16 20:45:43 +04:00
|
|
|
{
|
2018-06-25 15:42:24 +03:00
|
|
|
return 63 - clz64(size / KiB);
|
2011-06-16 20:45:43 +04:00
|
|
|
}
|
|
|
|
|
2013-04-29 08:40:56 +04:00
|
|
|
static int booke206_initial_map_tsize(CPUPPCState *env)
|
2011-05-01 01:34:53 +04:00
|
|
|
{
|
2012-05-19 02:48:50 +04:00
|
|
|
struct boot_info *bi = env->load_info;
|
2013-04-29 08:40:56 +04:00
|
|
|
hwaddr dt_end;
|
2012-05-19 02:48:50 +04:00
|
|
|
int ps;
|
|
|
|
|
|
|
|
/* Our initial TLB entry needs to cover everything from 0 to
|
|
|
|
the device tree top */
|
|
|
|
dt_end = bi->dt_base + bi->dt_size;
|
|
|
|
ps = booke206_page_size_to_tlb(dt_end) + 1;
|
2012-10-04 20:52:21 +04:00
|
|
|
if (ps & 1) {
|
|
|
|
/* e500v2 can only do even TLB size bits */
|
|
|
|
ps++;
|
|
|
|
}
|
2013-04-29 08:40:56 +04:00
|
|
|
return ps;
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint64_t mmubooke_initial_mapsize(CPUPPCState *env)
|
|
|
|
{
|
|
|
|
int tsize;
|
|
|
|
|
|
|
|
tsize = booke206_initial_map_tsize(env);
|
|
|
|
return (1ULL << 10 << tsize);
|
|
|
|
}
|
|
|
|
|
2022-12-16 17:57:09 +03:00
|
|
|
/* Create -kernel TLB entries for BookE. */
|
2013-04-29 08:40:56 +04:00
|
|
|
static void mmubooke_create_initial_mapping(CPUPPCState *env)
|
|
|
|
{
|
|
|
|
ppcmas_tlb_t *tlb = booke206_get_tlbm(env, 1, 0, 0);
|
|
|
|
hwaddr size;
|
|
|
|
int ps;
|
|
|
|
|
|
|
|
ps = booke206_initial_map_tsize(env);
|
2012-05-19 02:48:50 +04:00
|
|
|
size = (ps << MAS1_TSIZE_SHIFT);
|
2011-06-16 20:45:43 +04:00
|
|
|
tlb->mas1 = MAS1_VALID | size;
|
2012-05-19 02:48:50 +04:00
|
|
|
tlb->mas2 = 0;
|
|
|
|
tlb->mas7_3 = 0;
|
2011-06-16 20:45:43 +04:00
|
|
|
tlb->mas7_3 |= MAS3_UR | MAS3_UW | MAS3_UX | MAS3_SR | MAS3_SW | MAS3_SX;
|
2011-08-31 15:26:56 +04:00
|
|
|
|
2023-04-04 12:14:58 +03:00
|
|
|
#ifdef CONFIG_KVM
|
2011-08-31 15:26:56 +04:00
|
|
|
env->tlb_dirty = true;
|
2023-04-04 12:14:58 +03:00
|
|
|
#endif
|
2011-05-01 01:34:53 +04:00
|
|
|
}
|
|
|
|
|
2012-07-02 17:03:19 +04:00
|
|
|
static void ppce500_cpu_reset_sec(void *opaque)
|
2011-07-22 15:32:29 +04:00
|
|
|
{
|
2012-05-04 04:09:06 +04:00
|
|
|
PowerPCCPU *cpu = opaque;
|
2013-01-17 21:51:17 +04:00
|
|
|
CPUState *cs = CPU(cpu);
|
2011-07-22 15:32:29 +04:00
|
|
|
|
2013-01-17 21:51:17 +04:00
|
|
|
cpu_reset(cs);
|
2011-07-22 15:32:29 +04:00
|
|
|
|
2013-08-26 10:31:06 +04:00
|
|
|
cs->exception_index = EXCP_HLT;
|
2011-05-01 01:34:53 +04:00
|
|
|
}
|
|
|
|
|
2012-07-02 17:03:19 +04:00
|
|
|
static void ppce500_cpu_reset(void *opaque)
|
2011-05-01 01:34:53 +04:00
|
|
|
{
|
2012-05-04 04:09:06 +04:00
|
|
|
PowerPCCPU *cpu = opaque;
|
2013-01-17 21:51:17 +04:00
|
|
|
CPUState *cs = CPU(cpu);
|
2012-05-04 04:09:06 +04:00
|
|
|
CPUPPCState *env = &cpu->env;
|
2011-05-01 01:34:53 +04:00
|
|
|
struct boot_info *bi = env->load_info;
|
|
|
|
|
2013-01-17 21:51:17 +04:00
|
|
|
cpu_reset(cs);
|
2011-05-01 01:34:53 +04:00
|
|
|
|
|
|
|
/* Set initial guest state. */
|
2013-01-17 21:51:17 +04:00
|
|
|
cs->halted = 0;
|
2018-06-25 15:42:24 +03:00
|
|
|
env->gpr[1] = (16 * MiB) - 8;
|
2011-05-01 01:34:53 +04:00
|
|
|
env->gpr[3] = bi->dt_base;
|
2013-04-29 08:40:56 +04:00
|
|
|
env->gpr[4] = 0;
|
|
|
|
env->gpr[5] = 0;
|
|
|
|
env->gpr[6] = EPAPR_MAGIC;
|
|
|
|
env->gpr[7] = mmubooke_initial_mapsize(env);
|
|
|
|
env->gpr[8] = 0;
|
|
|
|
env->gpr[9] = 0;
|
2011-05-01 01:34:53 +04:00
|
|
|
env->nip = bi->entry;
|
2012-05-19 02:48:50 +04:00
|
|
|
mmubooke_create_initial_mapping(env);
|
2011-05-01 01:34:53 +04:00
|
|
|
}
|
|
|
|
|
2018-04-18 17:28:02 +03:00
|
|
|
static DeviceState *ppce500_init_mpic_qemu(PPCE500MachineState *pms,
|
2018-11-27 16:06:31 +03:00
|
|
|
IrqLines *irqs)
|
2013-04-15 17:19:33 +04:00
|
|
|
{
|
|
|
|
DeviceState *dev;
|
|
|
|
SysBusDevice *s;
|
|
|
|
int i, j, k;
|
2018-04-18 17:28:02 +03:00
|
|
|
MachineState *machine = MACHINE(pms);
|
2019-05-18 23:54:22 +03:00
|
|
|
unsigned int smp_cpus = machine->smp.cpus;
|
2018-04-18 17:28:02 +03:00
|
|
|
const PPCE500MachineClass *pmc = PPCE500_MACHINE_GET_CLASS(pms);
|
2013-04-15 17:19:33 +04:00
|
|
|
|
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 08:31:58 +03:00
|
|
|
dev = qdev_new(TYPE_OPENPIC);
|
qom: Drop parameter @errp of object_property_add() & friends
The only way object_property_add() can fail is when a property with
the same name already exists. Since our property names are all
hardcoded, failure is a programming error, and the appropriate way to
handle it is passing &error_abort.
Same for its variants, except for object_property_add_child(), which
additionally fails when the child already has a parent. Parentage is
also under program control, so this is a programming error, too.
We have a bit over 500 callers. Almost half of them pass
&error_abort, slightly fewer ignore errors, one test case handles
errors, and the remaining few callers pass them to their own callers.
The previous few commits demonstrated once again that ignoring
programming errors is a bad idea.
Of the few ones that pass on errors, several violate the Error API.
The Error ** argument must be NULL, &error_abort, &error_fatal, or a
pointer to a variable containing NULL. Passing an argument of the
latter kind twice without clearing it in between is wrong: if the
first call sets an error, it no longer points to NULL for the second
call. ich9_pm_add_properties(), sparc32_ledma_realize(),
sparc32_dma_realize(), xilinx_axidma_realize(), xilinx_enet_realize()
are wrong that way.
When the one appropriate choice of argument is &error_abort, letting
users pick the argument is a bad idea.
Drop parameter @errp and assert the preconditions instead.
There's one exception to "duplicate property name is a programming
error": the way object_property_add() implements the magic (and
undocumented) "automatic arrayification". Don't drop @errp there.
Instead, rename object_property_add() to object_property_try_add(),
and add the obvious wrapper object_property_add().
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200505152926.18877-15-armbru@redhat.com>
[Two semantic rebase conflicts resolved]
2020-05-05 18:29:22 +03:00
|
|
|
object_property_add_child(OBJECT(machine), "pic", OBJECT(dev));
|
2018-04-18 17:28:02 +03:00
|
|
|
qdev_prop_set_uint32(dev, "model", pmc->mpic_version);
|
2013-06-13 00:32:51 +04:00
|
|
|
qdev_prop_set_uint32(dev, "nb_cpus", smp_cpus);
|
|
|
|
|
2013-04-15 17:19:33 +04: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 08:32:34 +03:00
|
|
|
sysbus_realize_and_unref(s, &error_fatal);
|
2013-04-15 17:19:33 +04:00
|
|
|
|
|
|
|
k = 0;
|
|
|
|
for (i = 0; i < smp_cpus; i++) {
|
|
|
|
for (j = 0; j < OPENPIC_OUTPUT_NB; j++) {
|
2018-11-27 16:06:31 +03:00
|
|
|
sysbus_connect_irq(s, k++, irqs[i].irq[j]);
|
2013-04-15 17:19:33 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-13 00:32:51 +04:00
|
|
|
return dev;
|
|
|
|
}
|
|
|
|
|
2018-04-18 17:28:02 +03:00
|
|
|
static DeviceState *ppce500_init_mpic_kvm(const PPCE500MachineClass *pmc,
|
2018-11-27 16:06:31 +03:00
|
|
|
IrqLines *irqs, Error **errp)
|
2013-06-13 00:32:51 +04:00
|
|
|
{
|
|
|
|
DeviceState *dev;
|
|
|
|
CPUState *cs;
|
|
|
|
|
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 08:31:58 +03:00
|
|
|
dev = qdev_new(TYPE_KVM_OPENPIC);
|
2018-04-18 17:28:02 +03:00
|
|
|
qdev_prop_set_uint32(dev, "model", pmc->mpic_version);
|
2013-06-13 00:32:51 +04:00
|
|
|
|
error: Eliminate error_propagate() with Coccinelle, part 1
When all we do with an Error we receive into a local variable is
propagating to somewhere else, we can just as well receive it there
right away. Convert
if (!foo(..., &err)) {
...
error_propagate(errp, err);
...
return ...
}
to
if (!foo(..., errp)) {
...
...
return ...
}
where nothing else needs @err. Coccinelle script:
@rule1 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
binary operator op;
constant c1, c2;
symbol false;
@@
if (
(
- fun(args, &err, args2)
+ fun(args, errp, args2)
|
- !fun(args, &err, args2)
+ !fun(args, errp, args2)
|
- fun(args, &err, args2) op c1
+ fun(args, errp, args2) op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
)
}
@rule2 forall@
identifier fun, err, errp, lbl;
expression list args, args2;
expression var;
binary operator op;
constant c1, c2;
symbol false;
@@
- var = fun(args, &err, args2);
+ var = fun(args, errp, args2);
... when != err
if (
(
var
|
!var
|
var op c1
)
)
{
... when != err
when != lbl:
when strict
- error_propagate(errp, err);
... when != err
(
return;
|
return c2;
|
return false;
|
return var;
)
}
@depends on rule1 || rule2@
identifier err;
@@
- Error *err = NULL;
... when != err
Not exactly elegant, I'm afraid.
The "when != lbl:" is necessary to avoid transforming
if (fun(args, &err)) {
goto out
}
...
out:
error_propagate(errp, err);
even though other paths to label out still need the error_propagate().
For an actual example, see sclp_realize().
Without the "when strict", Coccinelle transforms vfio_msix_setup(),
incorrectly. I don't know what exactly "when strict" does, only that
it helps here.
The match of return is narrower than what I want, but I can't figure
out how to express "return where the operand doesn't use @err". For
an example where it's too narrow, see vfio_intx_enable().
Silently fails to convert hw/arm/armsse.c, because Coccinelle gets
confused by ARMSSE being used both as typedef and function-like macro
there. Converted manually.
Line breaks tidied up manually. One nested declaration of @local_err
deleted manually. Preexisting unwanted blank line dropped in
hw/riscv/sifive_e.c.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200707160613.848843-35-armbru@redhat.com>
2020-07-07 19:06:02 +03:00
|
|
|
if (!sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), errp)) {
|
2015-02-05 12:34:47 +03:00
|
|
|
object_unparent(OBJECT(dev));
|
2013-06-13 00:32:51 +04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-06-25 01:50:24 +04:00
|
|
|
CPU_FOREACH(cs) {
|
2013-06-13 00:32:51 +04:00
|
|
|
if (kvm_openpic_connect_vcpu(dev, cs)) {
|
|
|
|
fprintf(stderr, "%s: failed to connect vcpu to irqchip\n",
|
|
|
|
__func__);
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return dev;
|
|
|
|
}
|
|
|
|
|
2018-04-18 17:28:02 +03:00
|
|
|
static DeviceState *ppce500_init_mpic(PPCE500MachineState *pms,
|
2017-10-20 17:38:52 +03:00
|
|
|
MemoryRegion *ccsr,
|
2018-11-27 16:06:31 +03:00
|
|
|
IrqLines *irqs)
|
2013-06-13 00:32:51 +04:00
|
|
|
{
|
2018-04-18 17:28:02 +03:00
|
|
|
const PPCE500MachineClass *pmc = PPCE500_MACHINE_GET_CLASS(pms);
|
2013-06-13 00:32:51 +04:00
|
|
|
DeviceState *dev = NULL;
|
|
|
|
SysBusDevice *s;
|
|
|
|
|
|
|
|
if (kvm_enabled()) {
|
2015-02-05 12:34:47 +03:00
|
|
|
Error *err = NULL;
|
2013-06-13 00:32:51 +04:00
|
|
|
|
2019-11-13 13:17:12 +03:00
|
|
|
if (kvm_kernel_irqchip_allowed()) {
|
2018-04-18 17:28:02 +03:00
|
|
|
dev = ppce500_init_mpic_kvm(pmc, irqs, &err);
|
2013-06-13 00:32:51 +04:00
|
|
|
}
|
2019-11-13 13:17:12 +03:00
|
|
|
if (kvm_kernel_irqchip_required() && !dev) {
|
2015-12-18 18:35:14 +03:00
|
|
|
error_reportf_err(err,
|
|
|
|
"kernel_irqchip requested but unavailable: ");
|
2015-02-05 12:34:47 +03:00
|
|
|
exit(1);
|
2013-06-13 00:32:51 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!dev) {
|
2018-04-18 17:28:02 +03:00
|
|
|
dev = ppce500_init_mpic_qemu(pms, irqs);
|
2013-06-13 00:32:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
s = SYS_BUS_DEVICE(dev);
|
2013-04-15 17:19:33 +04:00
|
|
|
memory_region_add_subregion(ccsr, MPC8544_MPIC_REGS_OFFSET,
|
|
|
|
s->mmio[0].memory);
|
|
|
|
|
2017-10-20 17:38:52 +03:00
|
|
|
return dev;
|
2013-04-15 17:19:33 +04:00
|
|
|
}
|
|
|
|
|
2014-10-01 18:05:47 +04:00
|
|
|
static void ppce500_power_off(void *opaque, int line, int on)
|
|
|
|
{
|
|
|
|
if (on) {
|
2017-05-16 00:41:13 +03:00
|
|
|
qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
|
2014-10-01 18:05:47 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-18 17:28:02 +03:00
|
|
|
void ppce500_init(MachineState *machine)
|
2009-03-02 19:42:42 +03:00
|
|
|
{
|
2011-08-12 03:07:16 +04:00
|
|
|
MemoryRegion *address_space_mem = get_system_memory();
|
2018-04-18 17:28:02 +03:00
|
|
|
PPCE500MachineState *pms = PPCE500_MACHINE(machine);
|
|
|
|
const PPCE500MachineClass *pmc = PPCE500_MACHINE_GET_CLASS(machine);
|
2023-05-12 15:40:20 +03:00
|
|
|
MachineClass *mc = MACHINE_CLASS(pmc);
|
2009-03-02 19:42:42 +03:00
|
|
|
PCIBus *pci_bus;
|
2012-03-14 04:38:23 +04:00
|
|
|
CPUPPCState *env = NULL;
|
2014-01-20 03:27:25 +04:00
|
|
|
uint64_t loadaddr;
|
|
|
|
hwaddr kernel_base = -1LL;
|
|
|
|
int kernel_size = 0;
|
|
|
|
hwaddr dt_base = 0;
|
|
|
|
hwaddr initrd_base = 0;
|
|
|
|
int initrd_size = 0;
|
|
|
|
hwaddr cur_base = 0;
|
|
|
|
char *filename;
|
2018-03-02 14:20:13 +03:00
|
|
|
const char *payload_name;
|
|
|
|
bool kernel_as_payload;
|
2014-01-20 03:27:25 +04:00
|
|
|
hwaddr bios_entry = 0;
|
2018-03-02 14:20:13 +03:00
|
|
|
target_long payload_size;
|
2022-12-16 17:57:08 +03:00
|
|
|
struct boot_info *boot_info = NULL;
|
2014-01-20 03:27:25 +04:00
|
|
|
int dt_size;
|
2013-04-15 17:19:33 +04:00
|
|
|
int i;
|
2019-05-18 23:54:22 +03:00
|
|
|
unsigned int smp_cpus = machine->smp.cpus;
|
2014-05-12 13:45:39 +04:00
|
|
|
/* irq num for pin INTA, INTB, INTC and INTD is 1, 2, 3 and
|
|
|
|
* 4 respectively */
|
|
|
|
unsigned int pci_irq_nrs[PCI_NUM_PINS] = {1, 2, 3, 4};
|
2018-11-27 16:06:31 +03:00
|
|
|
IrqLines *irqs;
|
2017-10-20 17:38:52 +03:00
|
|
|
DeviceState *dev, *mpicdev;
|
2022-10-19 00:01:44 +03:00
|
|
|
DriveInfo *dinfo;
|
2012-03-14 04:38:23 +04:00
|
|
|
CPUPPCState *firstenv = NULL;
|
2012-10-10 08:28:28 +04:00
|
|
|
MemoryRegion *ccsr_addr_space;
|
2012-10-10 08:28:27 +04:00
|
|
|
SysBusDevice *s;
|
2012-10-10 08:28:28 +04:00
|
|
|
PPCE500CCSRState *ccsr;
|
2019-03-06 13:28:12 +03:00
|
|
|
I2CBus *i2c;
|
2009-03-02 19:42:42 +03:00
|
|
|
|
2018-11-27 16:06:31 +03:00
|
|
|
irqs = g_new0(IrqLines, smp_cpus);
|
2011-07-21 03:41:16 +04:00
|
|
|
for (i = 0; i < smp_cpus; i++) {
|
2012-05-03 07:43:05 +04:00
|
|
|
PowerPCCPU *cpu;
|
2012-12-17 09:18:02 +04:00
|
|
|
CPUState *cs;
|
2012-05-03 07:43:05 +04:00
|
|
|
|
2020-08-26 08:55:31 +03:00
|
|
|
cpu = POWERPC_CPU(object_new(machine->cpu_type));
|
2012-05-03 07:43:05 +04:00
|
|
|
env = &cpu->env;
|
2012-12-17 09:18:02 +04:00
|
|
|
cs = CPU(cpu);
|
2009-03-02 19:42:42 +03:00
|
|
|
|
2017-01-26 13:15:59 +03:00
|
|
|
if (env->mmu_model != POWERPC_MMU_BOOKE206) {
|
hw/ppc: Replace fprintf(stderr, "*\n" with error_report()
Replace a large number of the fprintf(stderr, "*\n" calls with
error_report(). The functions were renamed with these commands and then
compiler issues where manually fixed.
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
Some lines were then manually tweaked to pass checkpatch and some curly
braces were added to match QEMU style.
Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
Cc: qemu-ppc@nongnu.org
Conversions that aren't followed by exit() dropped, because they might
be inappropriate.
Also trim trailing punctuation from error messages.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20180203084315.20497-10-armbru@redhat.com>
2018-02-03 11:43:10 +03:00
|
|
|
error_report("MMU model %i not supported by this machine",
|
|
|
|
env->mmu_model);
|
2017-01-26 13:15:59 +03:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2020-08-26 08:55:31 +03:00
|
|
|
/*
|
|
|
|
* Secondary CPU starts in halted state for now. Needs to change
|
|
|
|
* when implementing non-kernel boot.
|
|
|
|
*/
|
|
|
|
object_property_set_bool(OBJECT(cs), "start-powered-off", i != 0,
|
|
|
|
&error_fatal);
|
|
|
|
qdev_realize_and_unref(DEVICE(cs), NULL, &error_fatal);
|
|
|
|
|
2011-07-21 03:41:16 +04:00
|
|
|
if (!firstenv) {
|
|
|
|
firstenv = env;
|
|
|
|
}
|
2009-03-02 19:42:42 +03:00
|
|
|
|
2022-07-05 17:58:13 +03:00
|
|
|
irqs[i].irq[OPENPIC_OUTPUT_INT] =
|
|
|
|
qdev_get_gpio_in(DEVICE(cpu), PPCE500_INPUT_INT);
|
|
|
|
irqs[i].irq[OPENPIC_OUTPUT_CINT] =
|
|
|
|
qdev_get_gpio_in(DEVICE(cpu), PPCE500_INPUT_CINT);
|
2014-04-03 22:45:27 +04:00
|
|
|
env->spr_cb[SPR_BOOKE_PIR].default_value = cs->cpu_index = i;
|
2018-04-18 17:28:02 +03:00
|
|
|
env->mpic_iack = pmc->ccsrbar_base + MPC8544_MPIC_REGS_OFFSET + 0xa0;
|
2011-05-01 01:34:53 +04:00
|
|
|
|
2021-02-03 17:24:47 +03:00
|
|
|
ppc_booke_timers_init(cpu, PLATFORM_CLK_FREQ_HZ, PPC_TIMER_E500);
|
2011-07-21 03:41:16 +04:00
|
|
|
|
|
|
|
/* Register reset handler */
|
2011-07-22 15:32:29 +04:00
|
|
|
if (!i) {
|
|
|
|
/* Primary CPU */
|
2022-03-15 17:41:56 +03:00
|
|
|
boot_info = g_new0(struct boot_info, 1);
|
2012-07-02 17:03:19 +04:00
|
|
|
qemu_register_reset(ppce500_cpu_reset, cpu);
|
2011-07-22 15:32:29 +04:00
|
|
|
env->load_info = boot_info;
|
|
|
|
} else {
|
|
|
|
/* Secondary CPUs */
|
2012-07-02 17:03:19 +04:00
|
|
|
qemu_register_reset(ppce500_cpu_reset_sec, cpu);
|
2011-07-22 15:32:29 +04:00
|
|
|
}
|
2011-07-21 03:41:16 +04:00
|
|
|
}
|
2011-05-01 01:34:53 +04:00
|
|
|
|
2011-07-21 03:41:16 +04:00
|
|
|
env = firstenv;
|
2011-05-01 01:34:53 +04:00
|
|
|
|
2020-02-19 19:09:32 +03:00
|
|
|
if (!QEMU_IS_ALIGNED(machine->ram_size, RAM_SIZES_ALIGN)) {
|
|
|
|
error_report("RAM size must be multiple of %" PRIu64, RAM_SIZES_ALIGN);
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
2009-03-02 19:42:42 +03:00
|
|
|
|
|
|
|
/* Register Memory */
|
2020-02-19 19:09:33 +03:00
|
|
|
memory_region_add_subregion(address_space_mem, 0, machine->ram);
|
2009-03-02 19:42:42 +03:00
|
|
|
|
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 08:31:58 +03:00
|
|
|
dev = qdev_new("e500-ccsr");
|
2022-12-16 17:57:07 +03:00
|
|
|
object_property_add_child(OBJECT(machine), "e500-ccsr", OBJECT(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 08:32:34 +03:00
|
|
|
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
|
2012-10-10 08:28:28 +04:00
|
|
|
ccsr = CCSR(dev);
|
|
|
|
ccsr_addr_space = &ccsr->ccsr_space;
|
2018-04-18 17:28:02 +03:00
|
|
|
memory_region_add_subregion(address_space_mem, pmc->ccsrbar_base,
|
2012-10-10 08:28:28 +04:00
|
|
|
ccsr_addr_space);
|
2012-10-10 08:28:27 +04:00
|
|
|
|
2018-04-18 17:28:02 +03:00
|
|
|
mpicdev = ppce500_init_mpic(pms, ccsr_addr_space, irqs);
|
2020-12-04 10:58:22 +03:00
|
|
|
g_free(irqs);
|
2012-12-08 08:17:14 +04:00
|
|
|
|
2009-03-02 19:42:42 +03:00
|
|
|
/* Serial */
|
2018-04-20 17:52:43 +03:00
|
|
|
if (serial_hd(0)) {
|
2012-10-10 08:28:28 +04:00
|
|
|
serial_mm_init(ccsr_addr_space, MPC8544_SERIAL0_REGS_OFFSET,
|
2017-10-20 17:38:52 +03:00
|
|
|
0, qdev_get_gpio_in(mpicdev, 42), 399193,
|
2018-04-20 17:52:43 +03:00
|
|
|
serial_hd(0), DEVICE_BIG_ENDIAN);
|
2010-03-21 22:47:11 +03:00
|
|
|
}
|
2009-03-02 19:42:42 +03:00
|
|
|
|
2018-04-20 17:52:43 +03:00
|
|
|
if (serial_hd(1)) {
|
2012-10-10 08:28:28 +04:00
|
|
|
serial_mm_init(ccsr_addr_space, MPC8544_SERIAL1_REGS_OFFSET,
|
2017-10-20 17:38:52 +03:00
|
|
|
0, qdev_get_gpio_in(mpicdev, 42), 399193,
|
2018-04-20 17:52:43 +03:00
|
|
|
serial_hd(1), DEVICE_BIG_ENDIAN);
|
2010-03-21 22:47:11 +03:00
|
|
|
}
|
2022-11-02 01:29:34 +03:00
|
|
|
|
|
|
|
/* I2C */
|
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 08:31:58 +03:00
|
|
|
dev = qdev_new("mpc-i2c");
|
2019-03-06 13:28:12 +03: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 08:32:34 +03:00
|
|
|
sysbus_realize_and_unref(s, &error_fatal);
|
2019-03-06 13:28:12 +03:00
|
|
|
sysbus_connect_irq(s, 0, qdev_get_gpio_in(mpicdev, MPC8544_I2C_IRQ));
|
|
|
|
memory_region_add_subregion(ccsr_addr_space, MPC8544_I2C_REGS_OFFSET,
|
|
|
|
sysbus_mmio_get_region(s, 0));
|
|
|
|
i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c");
|
2020-07-06 01:41:53 +03:00
|
|
|
i2c_slave_create_simple(i2c, "ds1338", RTC_REGS_OFFSET);
|
2019-03-06 13:28:12 +03:00
|
|
|
|
2022-11-02 01:29:34 +03:00
|
|
|
/* eSDHC */
|
|
|
|
if (pmc->has_esdhc) {
|
2023-01-25 16:00:24 +03:00
|
|
|
dev = qdev_new(TYPE_UNIMPLEMENTED_DEVICE);
|
|
|
|
qdev_prop_set_string(dev, "name", "esdhc");
|
|
|
|
qdev_prop_set_uint64(dev, "size", MPC85XX_ESDHC_REGS_SIZE);
|
|
|
|
s = SYS_BUS_DEVICE(dev);
|
|
|
|
sysbus_realize_and_unref(s, &error_fatal);
|
|
|
|
memory_region_add_subregion(ccsr_addr_space, MPC85XX_ESDHC_REGS_OFFSET,
|
|
|
|
sysbus_mmio_get_region(s, 0));
|
2022-11-02 01:29:34 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Compatible with:
|
|
|
|
* - SD Host Controller Specification Version 2.0 Part A2
|
|
|
|
* (See MPC8569E Reference Manual)
|
|
|
|
*/
|
|
|
|
dev = qdev_new(TYPE_SYSBUS_SDHCI);
|
|
|
|
qdev_prop_set_uint8(dev, "sd-spec-version", 2);
|
|
|
|
qdev_prop_set_uint8(dev, "endianness", DEVICE_BIG_ENDIAN);
|
|
|
|
s = SYS_BUS_DEVICE(dev);
|
|
|
|
sysbus_realize_and_unref(s, &error_fatal);
|
|
|
|
sysbus_connect_irq(s, 0, qdev_get_gpio_in(mpicdev, MPC85XX_ESDHC_IRQ));
|
|
|
|
memory_region_add_subregion(ccsr_addr_space, MPC85XX_ESDHC_REGS_OFFSET,
|
|
|
|
sysbus_mmio_get_region(s, 0));
|
|
|
|
}
|
2009-03-02 19:42:42 +03:00
|
|
|
|
2011-06-02 15:53:40 +04:00
|
|
|
/* General Utility device */
|
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 08:31:58 +03:00
|
|
|
dev = qdev_new("mpc8544-guts");
|
2012-10-10 08:28:27 +04: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 08:32:34 +03:00
|
|
|
sysbus_realize_and_unref(s, &error_fatal);
|
2012-10-10 08:28:28 +04:00
|
|
|
memory_region_add_subregion(ccsr_addr_space, MPC8544_UTIL_OFFSET,
|
2012-10-10 08:28:27 +04:00
|
|
|
sysbus_mmio_get_region(s, 0));
|
2011-06-02 15:53:40 +04:00
|
|
|
|
2009-03-02 19:42:42 +03:00
|
|
|
/* PCI */
|
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 08:31:58 +03:00
|
|
|
dev = qdev_new("e500-pcihost");
|
2022-12-16 17:57:07 +03:00
|
|
|
object_property_add_child(OBJECT(machine), "pci-host", OBJECT(dev));
|
2018-04-18 17:28:02 +03:00
|
|
|
qdev_prop_set_uint32(dev, "first_slot", pmc->pci_first_slot);
|
2014-05-12 13:45:40 +04:00
|
|
|
qdev_prop_set_uint32(dev, "first_pin_irq", pci_irq_nrs[0]);
|
2012-10-10 08:28:27 +04: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 08:32:34 +03:00
|
|
|
sysbus_realize_and_unref(s, &error_fatal);
|
2014-05-12 13:45:39 +04:00
|
|
|
for (i = 0; i < PCI_NUM_PINS; i++) {
|
2017-10-20 17:38:52 +03:00
|
|
|
sysbus_connect_irq(s, i, qdev_get_gpio_in(mpicdev, pci_irq_nrs[i]));
|
2014-05-12 13:45:39 +04:00
|
|
|
}
|
|
|
|
|
2012-10-10 08:28:28 +04:00
|
|
|
memory_region_add_subregion(ccsr_addr_space, MPC8544_PCI_REGS_OFFSET,
|
2012-10-10 08:28:27 +04:00
|
|
|
sysbus_mmio_get_region(s, 0));
|
|
|
|
|
2011-05-27 05:23:26 +04:00
|
|
|
pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci.0");
|
2009-03-02 19:42:42 +03:00
|
|
|
if (!pci_bus)
|
|
|
|
printf("couldn't create PCI controller!\n");
|
|
|
|
|
|
|
|
if (pci_bus) {
|
|
|
|
/* Register network interfaces. */
|
|
|
|
for (i = 0; i < nb_nics; i++) {
|
2023-05-12 15:40:20 +03:00
|
|
|
pci_nic_init_nofail(&nd_table[i], pci_bus, mc->default_nic, NULL);
|
2009-03-02 19:42:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-22 15:32:29 +04:00
|
|
|
/* Register spinning region */
|
2018-04-18 17:28:02 +03:00
|
|
|
sysbus_create_simple("e500-spin", pmc->spin_base, NULL);
|
2011-07-22 15:32:29 +04:00
|
|
|
|
2018-04-18 17:28:02 +03:00
|
|
|
if (pmc->has_mpc8xxx_gpio) {
|
2014-10-01 18:05:47 +04:00
|
|
|
qemu_irq poweroff_irq;
|
|
|
|
|
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 08:31:58 +03:00
|
|
|
dev = qdev_new("mpc8xxx_gpio");
|
2014-10-01 18:00:49 +04: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 08:32:34 +03:00
|
|
|
sysbus_realize_and_unref(s, &error_fatal);
|
2017-10-20 17:38:52 +03:00
|
|
|
sysbus_connect_irq(s, 0, qdev_get_gpio_in(mpicdev, MPC8XXX_GPIO_IRQ));
|
2014-10-01 18:00:49 +04:00
|
|
|
memory_region_add_subregion(ccsr_addr_space, MPC8XXX_GPIO_OFFSET,
|
|
|
|
sysbus_mmio_get_region(s, 0));
|
2014-10-01 18:05:47 +04:00
|
|
|
|
|
|
|
/* Power Off GPIO at Pin 0 */
|
|
|
|
poweroff_irq = qemu_allocate_irq(ppce500_power_off, NULL, 0);
|
|
|
|
qdev_connect_gpio_out(dev, 0, poweroff_irq);
|
2014-10-01 18:00:49 +04:00
|
|
|
}
|
|
|
|
|
2014-07-01 18:27:09 +04:00
|
|
|
/* Platform Bus Device */
|
2022-10-03 23:31:36 +03:00
|
|
|
dev = qdev_new(TYPE_PLATFORM_BUS_DEVICE);
|
|
|
|
dev->id = g_strdup(TYPE_PLATFORM_BUS_DEVICE);
|
|
|
|
qdev_prop_set_uint32(dev, "num_irqs", pmc->platform_bus_num_irqs);
|
|
|
|
qdev_prop_set_uint32(dev, "mmio_size", pmc->platform_bus_size);
|
|
|
|
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
|
|
|
|
pms->pbus_dev = PLATFORM_BUS_DEVICE(dev);
|
2014-07-01 18:27:09 +04:00
|
|
|
|
2022-10-03 23:31:36 +03:00
|
|
|
s = SYS_BUS_DEVICE(pms->pbus_dev);
|
|
|
|
for (i = 0; i < pmc->platform_bus_num_irqs; i++) {
|
|
|
|
int irqn = pmc->platform_bus_first_irq + i;
|
|
|
|
sysbus_connect_irq(s, i, qdev_get_gpio_in(mpicdev, irqn));
|
2014-07-01 18:27:09 +04:00
|
|
|
}
|
|
|
|
|
2022-10-03 23:31:36 +03:00
|
|
|
memory_region_add_subregion(address_space_mem,
|
|
|
|
pmc->platform_bus_base,
|
|
|
|
&pms->pbus_dev->mmio);
|
|
|
|
|
2022-10-19 00:01:44 +03:00
|
|
|
dinfo = drive_get(IF_PFLASH, 0, 0);
|
|
|
|
if (dinfo) {
|
|
|
|
BlockBackend *blk = blk_by_legacy_dinfo(dinfo);
|
|
|
|
BlockDriverState *bs = blk_bs(blk);
|
|
|
|
uint64_t mmio_size = memory_region_size(&pms->pbus_dev->mmio);
|
|
|
|
uint64_t size = bdrv_getlength(bs);
|
|
|
|
uint32_t sector_len = 64 * KiB;
|
|
|
|
|
|
|
|
if (!is_power_of_2(size)) {
|
|
|
|
error_report("Size of pflash file must be a power of two.");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (size > mmio_size) {
|
|
|
|
error_report("Size of pflash file must not be bigger than %" PRIu64
|
|
|
|
" bytes.", mmio_size);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!QEMU_IS_ALIGNED(size, sector_len)) {
|
|
|
|
error_report("Size of pflash file must be a multiple of %" PRIu32
|
|
|
|
".", sector_len);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
dev = qdev_new(TYPE_PFLASH_CFI01);
|
|
|
|
qdev_prop_set_drive(dev, "drive", blk);
|
|
|
|
qdev_prop_set_uint32(dev, "num-blocks", size / sector_len);
|
|
|
|
qdev_prop_set_uint64(dev, "sector-length", sector_len);
|
|
|
|
qdev_prop_set_uint8(dev, "width", 2);
|
|
|
|
qdev_prop_set_bit(dev, "big-endian", true);
|
|
|
|
qdev_prop_set_uint16(dev, "id0", 0x89);
|
|
|
|
qdev_prop_set_uint16(dev, "id1", 0x18);
|
|
|
|
qdev_prop_set_uint16(dev, "id2", 0x0000);
|
|
|
|
qdev_prop_set_uint16(dev, "id3", 0x0);
|
|
|
|
qdev_prop_set_string(dev, "name", "e500.flash");
|
|
|
|
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
|
|
|
|
|
|
|
|
memory_region_add_subregion(&pms->pbus_dev->mmio, 0,
|
|
|
|
pflash_cfi01_get_memory(PFLASH_CFI01(dev)));
|
|
|
|
}
|
|
|
|
|
2018-03-02 14:20:13 +03:00
|
|
|
/*
|
|
|
|
* Smart firmware defaults ahead!
|
|
|
|
*
|
|
|
|
* We follow the following table to select which payload we execute.
|
|
|
|
*
|
|
|
|
* -kernel | -bios | payload
|
|
|
|
* ---------+-------+---------
|
|
|
|
* N | Y | u-boot
|
|
|
|
* N | N | u-boot
|
|
|
|
* Y | Y | u-boot
|
|
|
|
* Y | N | kernel
|
|
|
|
*
|
|
|
|
* This ensures backwards compatibility with how we used to expose
|
|
|
|
* -kernel to users but allows them to run through u-boot as well.
|
|
|
|
*/
|
|
|
|
kernel_as_payload = false;
|
2020-10-26 17:30:23 +03:00
|
|
|
if (machine->firmware == NULL) {
|
2018-03-02 14:20:13 +03:00
|
|
|
if (machine->kernel_filename) {
|
|
|
|
payload_name = machine->kernel_filename;
|
|
|
|
kernel_as_payload = true;
|
|
|
|
} else {
|
|
|
|
payload_name = "u-boot.e500";
|
|
|
|
}
|
|
|
|
} else {
|
2020-10-26 17:30:23 +03:00
|
|
|
payload_name = machine->firmware;
|
2018-03-02 14:20:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, payload_name);
|
2020-03-24 15:12:16 +03:00
|
|
|
if (!filename) {
|
|
|
|
error_report("could not find firmware/kernel file '%s'", payload_name);
|
|
|
|
exit(1);
|
|
|
|
}
|
2018-03-02 14:20:13 +03:00
|
|
|
|
2019-01-15 15:18:03 +03:00
|
|
|
payload_size = load_elf(filename, NULL, NULL, NULL,
|
2020-01-27 01:55:04 +03:00
|
|
|
&bios_entry, &loadaddr, NULL, NULL,
|
2018-03-02 14:20:13 +03:00
|
|
|
1, PPC_ELF_MACHINE, 0, 0);
|
|
|
|
if (payload_size < 0) {
|
|
|
|
/*
|
|
|
|
* Hrm. No ELF image? Try a uImage, maybe someone is giving us an
|
|
|
|
* ePAPR compliant kernel
|
|
|
|
*/
|
2019-01-07 11:31:50 +03:00
|
|
|
loadaddr = LOAD_UIMAGE_LOADADDR_INVALID;
|
2018-03-02 14:20:13 +03:00
|
|
|
payload_size = load_uimage(filename, &bios_entry, &loadaddr, NULL,
|
|
|
|
NULL, NULL);
|
|
|
|
if (payload_size < 0) {
|
2018-09-21 05:05:30 +03:00
|
|
|
error_report("could not load firmware '%s'", filename);
|
2018-03-02 14:20:13 +03:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free(filename);
|
|
|
|
|
|
|
|
if (kernel_as_payload) {
|
|
|
|
kernel_base = loadaddr;
|
|
|
|
kernel_size = payload_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
cur_base = loadaddr + payload_size;
|
2018-06-25 15:42:24 +03:00
|
|
|
if (cur_base < 32 * MiB) {
|
2018-03-08 14:50:36 +03:00
|
|
|
/* u-boot occupies memory up to 32MB, so load blobs above */
|
2018-06-25 15:42:24 +03:00
|
|
|
cur_base = 32 * MiB;
|
2018-03-08 14:50:36 +03:00
|
|
|
}
|
2018-03-02 14:20:13 +03:00
|
|
|
|
|
|
|
/* Load bare kernel only if no bios/u-boot has been provided */
|
|
|
|
if (machine->kernel_filename && !kernel_as_payload) {
|
2014-01-20 03:27:25 +04:00
|
|
|
kernel_base = cur_base;
|
|
|
|
kernel_size = load_image_targphys(machine->kernel_filename,
|
|
|
|
cur_base,
|
2020-02-19 19:09:32 +03:00
|
|
|
machine->ram_size - cur_base);
|
2009-03-02 19:42:42 +03:00
|
|
|
if (kernel_size < 0) {
|
hw/ppc: Replace fprintf(stderr, "*\n" with error_report()
Replace a large number of the fprintf(stderr, "*\n" calls with
error_report(). The functions were renamed with these commands and then
compiler issues where manually fixed.
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
Some lines were then manually tweaked to pass checkpatch and some curly
braces were added to match QEMU style.
Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
Cc: qemu-ppc@nongnu.org
Conversions that aren't followed by exit() dropped, because they might
be inappropriate.
Also trim trailing punctuation from error messages.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20180203084315.20497-10-armbru@redhat.com>
2018-02-03 11:43:10 +03:00
|
|
|
error_report("could not load kernel '%s'",
|
|
|
|
machine->kernel_filename);
|
2009-03-02 19:42:42 +03:00
|
|
|
exit(1);
|
|
|
|
}
|
2013-01-14 23:24:16 +04:00
|
|
|
|
2014-01-20 03:27:25 +04:00
|
|
|
cur_base += kernel_size;
|
2009-03-02 19:42:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Load initrd. */
|
2014-05-07 18:42:57 +04:00
|
|
|
if (machine->initrd_filename) {
|
2013-01-14 23:24:16 +04:00
|
|
|
initrd_base = (cur_base + INITRD_LOAD_PAD) & ~INITRD_PAD_MASK;
|
2014-05-07 18:42:57 +04:00
|
|
|
initrd_size = load_image_targphys(machine->initrd_filename, initrd_base,
|
2020-02-19 19:09:32 +03:00
|
|
|
machine->ram_size - initrd_base);
|
2009-03-02 19:42:42 +03:00
|
|
|
|
|
|
|
if (initrd_size < 0) {
|
hw/ppc: Replace fprintf(stderr, "*\n" with error_report()
Replace a large number of the fprintf(stderr, "*\n" calls with
error_report(). The functions were renamed with these commands and then
compiler issues where manually fixed.
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
Some lines were then manually tweaked to pass checkpatch and some curly
braces were added to match QEMU style.
Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
Cc: qemu-ppc@nongnu.org
Conversions that aren't followed by exit() dropped, because they might
be inappropriate.
Also trim trailing punctuation from error messages.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20180203084315.20497-10-armbru@redhat.com>
2018-02-03 11:43:10 +03:00
|
|
|
error_report("could not load initial ram disk '%s'",
|
|
|
|
machine->initrd_filename);
|
2009-03-02 19:42:42 +03:00
|
|
|
exit(1);
|
|
|
|
}
|
2013-01-14 23:24:16 +04:00
|
|
|
|
|
|
|
cur_base = initrd_base + initrd_size;
|
2009-03-02 19:42:42 +03:00
|
|
|
}
|
|
|
|
|
2014-01-20 03:27:25 +04:00
|
|
|
/*
|
2018-03-02 14:20:13 +03:00
|
|
|
* Reserve space for dtb behind the kernel image because Linux has a bug
|
|
|
|
* where it can only handle the dtb if it's within the first 64MB of where
|
|
|
|
* <kernel> starts. dtb cannot not reach initrd_base because INITRD_LOAD_PAD
|
|
|
|
* ensures enough space between kernel and initrd.
|
2014-01-20 03:27:25 +04:00
|
|
|
*/
|
2018-03-02 14:20:13 +03:00
|
|
|
dt_base = (loadaddr + payload_size + DTC_LOAD_PAD) & ~DTC_PAD_MASK;
|
2020-02-19 19:09:32 +03:00
|
|
|
if (dt_base + DTB_MAX_SIZE > machine->ram_size) {
|
2018-09-21 05:05:30 +03:00
|
|
|
error_report("not enough memory for device tree");
|
2009-03-02 19:42:42 +03:00
|
|
|
exit(1);
|
2014-01-20 03:27:25 +04:00
|
|
|
}
|
2009-03-02 19:42:42 +03:00
|
|
|
|
2018-04-18 17:28:02 +03:00
|
|
|
dt_size = ppce500_prep_device_tree(pms, dt_base,
|
2014-01-20 03:27:25 +04:00
|
|
|
initrd_base, initrd_size,
|
|
|
|
kernel_base, kernel_size);
|
|
|
|
if (dt_size < 0) {
|
hw/ppc: Replace fprintf(stderr, "*\n" with error_report()
Replace a large number of the fprintf(stderr, "*\n" calls with
error_report(). The functions were renamed with these commands and then
compiler issues where manually fixed.
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
{} +
Some lines were then manually tweaked to pass checkpatch and some curly
braces were added to match QEMU style.
Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
Cc: qemu-ppc@nongnu.org
Conversions that aren't followed by exit() dropped, because they might
be inappropriate.
Also trim trailing punctuation from error messages.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20180203084315.20497-10-armbru@redhat.com>
2018-02-03 11:43:10 +03:00
|
|
|
error_report("couldn't load device tree");
|
2014-01-20 03:27:25 +04:00
|
|
|
exit(1);
|
2009-03-02 19:42:42 +03:00
|
|
|
}
|
2014-01-20 03:27:25 +04:00
|
|
|
assert(dt_size < DTB_MAX_SIZE);
|
|
|
|
|
|
|
|
boot_info->entry = bios_entry;
|
|
|
|
boot_info->dt_base = dt_base;
|
|
|
|
boot_info->dt_size = dt_size;
|
2009-03-02 19:42:42 +03:00
|
|
|
}
|
2012-10-10 08:28:28 +04:00
|
|
|
|
2017-01-06 03:26:26 +03:00
|
|
|
static void e500_ccsr_initfn(Object *obj)
|
2012-10-10 08:28:28 +04:00
|
|
|
{
|
2017-01-06 03:26:26 +03:00
|
|
|
PPCE500CCSRState *ccsr = CCSR(obj);
|
|
|
|
memory_region_init(&ccsr->ccsr_space, obj, "e500-ccsr",
|
2012-10-10 08:28:28 +04:00
|
|
|
MPC8544_CCSRBAR_SIZE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const TypeInfo e500_ccsr_info = {
|
|
|
|
.name = TYPE_CCSR,
|
|
|
|
.parent = TYPE_SYS_BUS_DEVICE,
|
|
|
|
.instance_size = sizeof(PPCE500CCSRState),
|
2017-01-06 03:26:26 +03:00
|
|
|
.instance_init = e500_ccsr_initfn,
|
2012-10-10 08:28:28 +04:00
|
|
|
};
|
|
|
|
|
2018-04-18 17:28:02 +03:00
|
|
|
static const TypeInfo ppce500_info = {
|
|
|
|
.name = TYPE_PPCE500_MACHINE,
|
|
|
|
.parent = TYPE_MACHINE,
|
|
|
|
.abstract = true,
|
2018-05-10 20:10:56 +03:00
|
|
|
.instance_size = sizeof(PPCE500MachineState),
|
2018-04-18 17:28:02 +03:00
|
|
|
.class_size = sizeof(PPCE500MachineClass),
|
|
|
|
};
|
|
|
|
|
2012-10-10 08:28:28 +04:00
|
|
|
static void e500_register_types(void)
|
|
|
|
{
|
|
|
|
type_register_static(&e500_ccsr_info);
|
2018-04-18 17:28:02 +03:00
|
|
|
type_register_static(&ppce500_info);
|
2012-10-10 08:28:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
type_init(e500_register_types)
|