Skip to contentSkip to conversation

Changes to Broadcom(BCM) files and Raspberry Pi files. Addition of PanelEmu

Qemu-devel John Bradley via Qemu-devel 5 participants 9 messages May 14, 2017 – May 16, 2017 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 1 line

From 7f74f048f135d9c9c230a9e90f72451c841c6d35 Mon Sep 17 00:00:00 2001

From: John Bradley <[email protected]>
Date: Sat, 13 May 2017 23:07:47 +0100
Subject: [PATCH] Changes to Broadcom(BCM) files and Raspberry Pi files. Addition of PanelEmu

The files add the ability to attach, via TCP, a panel emulator The include a unification of several PD Raspberry PI additions A modification to dev-network to all circle SDK WWW client to work The DummyPanel is not included but available at
https://github.com/flypie/GDummyPanel.git

---

.gitignore                           |   54 ++
hw/arm/Makefile.objs                 |    2 +-
hw/arm/bcm2835.c                     |  114 ++++
hw/arm/bcm2835_peripherals.c         |  104 ++++
hw/arm/bcm2836.c                     |    3 +-
hw/arm/raspi.c                       |   77 ++-
hw/gpio/bcm2835_gpio.c               |  333 ++++++-----
hw/misc/Makefile.objs                |    2 +
hw/misc/bcm2835_mphi.c               |  163 ++++++
hw/misc/bcm2835_power.c              |  106 ++++
hw/timer/Makefile.objs               |    2 +
hw/timer/bcm2835_st.c                |  202 +++++++
hw/timer/bcm2835_timer.c             |  224 +++++++
hw/usb/Makefile.objs                 |    4 +-
hw/usb/bcm2835_usb.c                 |  604 +++++++++++++++++++
hw/usb/bcm2835_usb_regs.h            | 1061 ++++++++++++++++++++++++++++++++++
hw/usb/dev-network.c                 |    2 +-
include/hw/arm/bcm2835.h             |   37 ++
include/hw/arm/bcm2835_peripherals.h |   10 +
include/hw/gpio/bcm2835_gpio.h       |    5 +
include/hw/intc/bcm2835_control.h    |   53 ++
include/hw/intc/bcm2836_control.h    |    2 +
include/hw/misc/bcm2835_mphi.h       |   28 +
include/hw/misc/bcm2835_power.h      |   22 +
include/hw/timer/bcm2835_st.h        |   25 +
include/hw/timer/bcm2835_timer.h     |   32 +
include/hw/usb/bcm2835_usb.h         |   78 +++
include/qemu/PanelEmu.h              |   53 ++
util/Makefile.objs                   |    1 +
util/PanelEmu.c                      |  293 ++++++++++
30 files changed, 3547 insertions(+), 149 deletions(-)

create mode 100644 hw/arm/bcm2835.c
create mode 100644 hw/misc/bcm2835_mphi.c create mode 100644 hw/misc/bcm2835_power.c create mode 100644 hw/timer/bcm2835_st.c create mode 100644 hw/timer/bcm2835_timer.c create mode 100644 hw/usb/bcm2835_usb.c create mode 100644 hw/usb/bcm2835_usb_regs.h create mode 100644 include/hw/arm/bcm2835.h create mode 100644 include/hw/intc/bcm2835_control.h create mode 100644 include/hw/misc/bcm2835_mphi.h create mode 100644 include/hw/misc/bcm2835_power.h create mode 100644 include/hw/timer/bcm2835_st.h create mode 100644 include/hw/timer/bcm2835_timer.h create mode 100644 include/hw/usb/bcm2835_usb.h create mode 100644 include/qemu/PanelEmu.h create mode 100644 util/PanelEmu.c

.gitignore +1 -0
index 55a001e3b8..08e0ac978f 100644
@@ -1,3 +1,4 @@
+/bin

/config-devices.*
/config-all-devices.*
/config-all-disas.*
@@ -131,3 +132,56 @@ trace-dtrace-root.h trace-dtrace-root.dtrace
trace-ust-all.h
trace-ust-all.c
+
+bin/debug/x86_64-w64-mingw64/Makefile
+
+bin/debug/x86_64-w64-mingw64/arm-softmmu/Makefile
+ +bin/debug/x86_64-w64-mingw64/arm-softmmu/config-devices.mak +
+# Compiled source #
+###################
+*.com
+*.class
+*.dll
+*.exe
+*.o
+*.so
+
+# Packages #
+############
+# it's better to unpack these files and commit the raw source +# git has its own built in compression methods +*.7z
+*.dmg
+*.gz
+*.iso
+*.jar
+*.rar
+*.tar
+*.zip
+
+# Logs and databases #
+######################
+*.log
+*.sql
+*.sqlite
+
+# OS generated files #
+######################
+.DS_Store
+.DS_Store?
+._*
+.Spotlight-V100
+.Trashes
+ehthumbs.db
+Thumbs.db
+.cproject
+.project
+### NetBeans ###
+nbproject/private/
+build/
+nbbuild/
+dist/
+nbdist/
+.nb-gradle/

hw/arm/Makefile.objs +0 -0
index 4c5c4ee76c..35b2da24f5 100644
@@ -11,7 +11,7 @@ obj-y += armv7m.o exynos4210.o pxa2xx.o pxa2xx_gpio.o pxa2xx_pic.o

obj-$(CONFIG_DIGIC) += digic.o
obj-y += omap1.o omap2.o strongarm.o obj-$(CONFIG_ALLWINNER_A10) += allwinner-a10.o cubieboard.o -obj-$(CONFIG_RASPI) += bcm2835_peripherals.o bcm2836.o raspi.o +obj-$(CONFIG_RASPI) += bcm2835.o bcm2835_peripherals.o bcm2836.o raspi.o obj-$(CONFIG_STM32F205_SOC) += stm32f205_soc.o obj-$(CONFIG_XLNX_ZYNQMP) += xlnx-zynqmp.o xlnx-ep108.o obj-$(CONFIG_FSL_IMX25) += fsl-imx25.o imx25_pdk.o

hw/arm/bcm2835.c new file +114 -0

114 lines not on this page · raw message

hw/arm/bcm2835_peripherals.c +0 -0
index 369ef1e3bd..e0e8525eab 100644
@@ -56,6 +56,29 @@ static void bcm2835_peripherals_init(Object *obj)

object_property_add_child(obj, "aux", OBJECT(&s->aux), NULL); qdev_set_parent_bus(DEVICE(&s->aux), sysbus_get_default());

+    /* System timer */
+    object_initialize(&s->st, sizeof(s->st), TYPE_BCM2835_ST);
+    object_property_add_child(obj, "systimer", OBJECT(&s->st), NULL);
+    qdev_set_parent_bus(DEVICE(&s->st), sysbus_get_default());
+
+    /* ARM timer */
+    object_initialize(&s->timer, sizeof(s->timer), TYPE_BCM2835_TIMER);
+    object_property_add_child(obj, "armtimer", OBJECT(&s->timer), NULL);
+    qdev_set_parent_bus(DEVICE(&s->timer), sysbus_get_default());
+
+    /* USB controller */
+    object_initialize(&s->usb, sizeof(s->usb), TYPE_BCM2835_USB);
+    object_property_add_child(obj, "usb", OBJECT(&s->usb), NULL);
+    qdev_set_parent_bus(DEVICE(&s->usb), sysbus_get_default());

+
+ object_property_add_const_link(OBJECT(&s->usb), "dma_mr",
+ OBJECT(&s->gpu_bus_mr), &error_abort);
+

+    /* MPHI - Message-based Parallel Host Interface */
+    object_initialize(&s->mphi, sizeof(s->mphi), TYPE_BCM2835_MPHI);
+    object_property_add_child(obj, "mphi", OBJECT(&s->mphi), NULL);
+    qdev_set_parent_bus(DEVICE(&s->mphi), sysbus_get_default());

+
/* Mailboxes */
object_initialize(&s->mboxes, sizeof(s->mboxes), TYPE_BCM2835_MBOX); object_property_add_child(obj, "mbox", OBJECT(&s->mboxes), NULL); @@ -64,6 +87,11 @@ static void bcm2835_peripherals_init(Object *obj) object_property_add_const_link(OBJECT(&s->mboxes), "mbox-mr", OBJECT(&s->mbox_mr), &error_abort);

+    /* Power management */
+    object_initialize(&s->power, sizeof(s->power), TYPE_BCM2835_POWER);
+    object_property_add_child(obj, "power", OBJECT(&s->power), NULL);
+    qdev_set_parent_bus(DEVICE(&s->power), sysbus_get_default());

+
/* Framebuffer */
object_initialize(&s->fb, sizeof(s->fb), TYPE_BCM2835_FB); object_property_add_child(obj, "fb", OBJECT(&s->fb), NULL);
@@ -179,6 +207,7 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) sysbus_connect_irq(s->uart0, 0,
qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ,
INTERRUPT_UART));
+
/* AUX / UART1 */
qdev_prop_set_chr(DEVICE(&s->aux), "chardev", serial_hds[1]);

@@ -194,6 +223,67 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ,
INTERRUPT_AUX));

+    /* System timer */
+    object_property_set_bool(OBJECT(&s->st), true, "realized", &err);
+    if (err) {

+ error_propagate(errp, err);
+ return;
+ }
+
+ memory_region_add_subregion(&s->peri_mr, ST_OFFSET,
+ sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->st), 0));
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->st), 0,
+ qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ,
+ INTERRUPT_TIMER0));
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->st), 1,
+ qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ,
+ INTERRUPT_TIMER1));
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->st), 2,
+ qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ,
+ INTERRUPT_TIMER2));
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->st), 3,
+ qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ,
+ INTERRUPT_TIMER3));
+

+    /* ARM timer */
+    object_property_set_bool(OBJECT(&s->timer), true, "realized", &err);
+    if (err) {

+ error_propagate(errp, err);
+ return;
+ }
+
+ memory_region_add_subregion(&s->peri_mr, ARMCTRL_TIMER0_1_OFFSET,
+ sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->timer), 0));
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->timer), 0,
+ qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_ARM_IRQ,
+ INTERRUPT_ARM_TIMER));
+

+    /* USB controller */
+    object_property_set_bool(OBJECT(&s->usb), true, "realized", &err);
+    if (err) {

+ error_propagate(errp, err);
+ return;
+ }
+
+ memory_region_add_subregion(&s->peri_mr, USB_OFFSET,
+ sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->usb), 0));
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->usb), 0,
+ qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ,
+ INTERRUPT_USB));
+

+    /* MPHI - Message-based Parallel Host Interface */
+    object_property_set_bool(OBJECT(&s->mphi), true, "realized", &err);
+    if (err) {

+ error_propagate(errp, err);
+ return;
+ }
+
+ memory_region_add_subregion(&s->peri_mr, MPHI_OFFSET,
+ sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->mphi), 0));
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->mphi), 0,
+ qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ,
+ INTERRUPT_HOSTPORT));
+
/* Mailboxes */
object_property_set_bool(OBJECT(&s->mboxes), true, "realized", &err);
if (err) {
@@ -207,6 +297,18 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_ARM_IRQ, INTERRUPT_ARM_MAILBOX));

+    /* Power management */
+    object_property_set_bool(OBJECT(&s->power), true, "realized", &err);
+    if (err) {

+ error_propagate(errp, err);
+ return;
+ }
+
+ memory_region_add_subregion(&s->mbox_mr, MBOX_CHAN_POWER << MBOX_AS_CHAN_SHIFT,
+ sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->power), 0));
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->power), 0,
+ qdev_get_gpio_in(DEVICE(&s->mboxes), MBOX_CHAN_POWER));
+
/* Framebuffer */
vcram_size = (uint32_t)object_property_get_int(OBJECT(s), "vcram-size", &err);
@@ -338,6 +440,8 @@ static void bcm2835_peripherals_class_init(ObjectClass *oc, void *data) DeviceClass *dc = DEVICE_CLASS(oc);

dc->realize = bcm2835_peripherals_realize;
+ /* Reason: realize() method uses qemu_char_get_next_serial() */
+ dc->cannot_instantiate_with_device_add_yet = true;
}

static const TypeInfo bcm2835_peripherals_type_info = {

hw/arm/bcm2836.c +0 -0
index 8c43291112..5f1bd15b24 100644
@@ -27,7 +27,7 @@ static void bcm2836_init(Object *obj)

{
BCM2836State *s = BCM2836(obj);
int n;
-
+
for (n = 0; n < BCM2836_NCPUS; n++) { object_initialize(&s->cpus[n], sizeof(s->cpus[n]),
"cortex-a15-" TYPE_ARM_CPU);
@@ -106,6 +106,7 @@ static void bcm2836_realize(DeviceState *dev, Error **errp) /* Mirror bcm2836, which has clusterid set to 0xf
* TODO: this should be converted to a property of ARM_CPU
*/
+
s->cpus[n].mp_affinity = 0xF00 | n;

/* set periphbase/CBAR value for CPU-local registers */

hw/arm/raspi.c +0 -0
index 2b295f14c4..8ed2d9785d 100644
@@ -4,6 +4,8 @@

*
* Rasperry Pi 2 emulation Copyright (c) 2015, Microsoft
* Written by Andrew Baumann
+ *
+ * Merge into QEMU root fork John Bradley April 2017 *
* This code is licensed under the GNU GPLv2 and later. */
@@ -12,6 +14,7 @@
#include "qapi/error.h"
#include "qemu-common.h"
#include "cpu.h"
+#include "hw/arm/bcm2835.h"
#include "hw/arm/bcm2836.h"
#include "qemu/error-report.h"
#include "hw/boards.h"
@@ -27,10 +30,20 @@
/* Table of Linux board IDs for different Pi versions */ static const int raspi_boardid[] = {[1] = 0xc42, [2] = 0xc43};

-typedef struct RasPiState {
+/* Table of board revisions
+ * https://github.com/AndrewFromMelbourne/raspberry_pi_revision/blob/master/README.md
+ */
+static const uint32_t raspi_boardrev[] = {[1] = 0x10, [2] = 0xa21041}; +
+typedef struct RasPi1State {
+ BCM2835State soc;
+ MemoryRegion ram;
+} RasPi1State;
+
+typedef struct RasPi2State {
BCM2836State soc;
MemoryRegion ram;
-} RasPiState;
+} RasPi2State;

static void write_smpboot(ARMCPU *cpu, const struct arm_boot_info *info)
{
@@ -113,9 +126,53 @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) arm_load_kernel(ARM_CPU(first_cpu), &binfo);
}

+static void raspi1_init(MachineState *machine)
+{

+    RasPi1State *s = g_new0(RasPi1State, 1);
+    uint32_t vcram_size;
+    DriveInfo *di;
+    BlockBackend *blk;
+    BusState *bus;
+    DeviceState *carddev;

+
+ object_initialize(&s->soc, sizeof(s->soc), TYPE_BCM2835);
+ object_property_add_child(OBJECT(machine), "soc", OBJECT(&s->soc),
+ &error_abort);
+
+ /* Allocate and map RAM */
+ memory_region_allocate_system_memory(&s->ram, OBJECT(machine), "ram",
+ machine->ram_size);
+ /* FIXME: Remove when we have custom CPU address space support */
+ memory_region_add_subregion_overlap(get_system_memory(), 0, &s->ram, 0);
+
+ /* Setup the SOC */
+ object_property_add_const_link(OBJECT(&s->soc), "ram", OBJECT(&s->ram),
+ &error_abort);
+// object_property_set_int(OBJECT(&s->soc), smp_cpus, "enabled-cpus",
+// &error_abort);
+ object_property_set_int(OBJECT(&s->soc), 0xa21041, "board-rev",
+ &error_abort);
+ object_property_set_bool(OBJECT(&s->soc), true, "realized", &error_abort);
+

+    /* Create and plug in the SD cards */
+    di = drive_get_next(IF_SD);
+    blk = di ? blk_by_legacy_dinfo(di) : NULL;
+    bus = qdev_get_child_bus(DEVICE(&s->soc), "sd-bus");
+    if (bus == NULL) {
+        error_report("No SD bus found in SOC object");
+        exit(1);
+    }
+    carddev = qdev_create(bus, TYPE_SD_CARD);
+    qdev_prop_set_drive(carddev, "drive", blk, &error_fatal);
+    object_property_set_bool(OBJECT(carddev), true, "realized", &error_fatal);

+
+ vcram_size = object_property_get_int(OBJECT(&s->soc), "vcram-size",
+ &error_abort);
+ setup_boot(machine, 1, machine->ram_size - vcram_size);
+}
static void raspi2_init(MachineState *machine)
{
- RasPiState *s = g_new0(RasPiState, 1);
+ RasPi2State *s = g_new0(RasPi2State, 1);
uint32_t vcram_size;
DriveInfo *di;
BlockBackend *blk;
@@ -158,6 +215,20 @@ static void raspi2_init(MachineState *machine) setup_boot(machine, 2, machine->ram_size - vcram_size); }

+
+static void raspi1_machine_init(MachineClass *mc) +{

+    mc->desc = "Raspberry Pi 1";
+    mc->init = raspi1_init;
+    mc->block_default_type = IF_SD;
+    mc->no_parallel = 1;
+    mc->no_floppy = 1;
+    mc->no_cdrom = 1;
+    mc->max_cpus = BCM2835_NCPUS;
+    mc->default_ram_size = 512 * 1024 * 1024;

+};
+DEFINE_MACHINE("raspi1", raspi1_machine_init)
+
static void raspi2_machine_init(MachineClass *mc)
{
mc->desc = "Raspberry Pi 2";

hw/gpio/bcm2835_gpio.c +0 -0
index acc2e3cf9e..37be668d2a 100644
@@ -19,6 +19,8 @@

#include "hw/sd/sd.h"
#include "hw/gpio/bcm2835_gpio.h"

+
+

#define GPFSEL0   0x00
#define GPFSEL1   0x04
#define GPFSEL2   0x08

@@ -53,9 +55,9 @@ static uint32_t gpfsel_get(BCM2835GpioState *s, uint8_t reg) {
int i;
uint32_t value = 0;
- for (i = 0; i < 10; i++) {
+ for (i = 0; i < 10; i ++) {
uint32_t index = 10 * reg + i;
- if (index < sizeof(s->fsel)) {
+ if (index < sizeof (s->fsel)) {
value |= (s->fsel[index] & 0x7) << (3 * i);
}
}
@@ -65,9 +67,9 @@ static uint32_t gpfsel_get(BCM2835GpioState *s, uint8_t reg) static void gpfsel_set(BCM2835GpioState *s, uint8_t reg, uint32_t value)
{
int i;
- for (i = 0; i < 10; i++) {
+ for (i = 0; i < 10; i ++) {
uint32_t index = 10 * reg + i;
- if (index < sizeof(s->fsel)) {
+ if (index < sizeof (s->fsel)) {
int fsel = (value >> (3 * i)) & 0x7;
s->fsel[index] = fsel;
}
@@ -75,24 +77,24 @@ static void gpfsel_set(BCM2835GpioState *s, uint8_t reg, uint32_t value)

/* SD controller selection (48-53) */
if (s->sd_fsel != 0

-            && (s->fsel[48] == 0) /* SD_CLK_R */
-            && (s->fsel[49] == 0) /* SD_CMD_R */
-            && (s->fsel[50] == 0) /* SD_DATA0_R */
-            && (s->fsel[51] == 0) /* SD_DATA1_R */
-            && (s->fsel[52] == 0) /* SD_DATA2_R */
-            && (s->fsel[53] == 0) /* SD_DATA3_R */
-            ) {
+        && (s->fsel[48] == 0) /* SD_CLK_R */
+        && (s->fsel[49] == 0) /* SD_CMD_R */
+        && (s->fsel[50] == 0) /* SD_DATA0_R */
+        && (s->fsel[51] == 0) /* SD_DATA1_R */
+        && (s->fsel[52] == 0) /* SD_DATA2_R */
+        && (s->fsel[53] == 0) /* SD_DATA3_R */
+        ) {

/* SDHCI controller selected */ sdbus_reparent_card(s->sdbus_sdhost, s->sdbus_sdhci); s->sd_fsel = 0;
} else if (s->sd_fsel != 4

-            && (s->fsel[48] == 4) /* SD_CLK_R */
-            && (s->fsel[49] == 4) /* SD_CMD_R */
-            && (s->fsel[50] == 4) /* SD_DATA0_R */
-            && (s->fsel[51] == 4) /* SD_DATA1_R */
-            && (s->fsel[52] == 4) /* SD_DATA2_R */
-            && (s->fsel[53] == 4) /* SD_DATA3_R */
-            ) {
+               && (s->fsel[48] == 4) /* SD_CLK_R */
+               && (s->fsel[49] == 4) /* SD_CMD_R */
+               && (s->fsel[50] == 4) /* SD_DATA0_R */
+               && (s->fsel[51] == 4) /* SD_DATA1_R */
+               && (s->fsel[52] == 4) /* SD_DATA2_R */
+               && (s->fsel[53] == 4) /* SD_DATA3_R */
+               ) {

/* SDHost controller selected */ sdbus_reparent_card(s->sdbus_sdhci, s->sdbus_sdhost);
s->sd_fsel = 4;
@@ -108,13 +110,13 @@ static int gpfsel_is_out(BCM2835GpioState *s, int index) }

static void gpset(BCM2835GpioState *s,
- uint32_t val, uint8_t start, uint8_t count, uint32_t *lev)
+ uint32_t val, uint8_t start, uint8_t count, uint32_t *lev)
{
- uint32_t changes = val & ~*lev;
+ uint32_t changes = val & ~ *lev;
uint32_t cur = 1;

int i;
- for (i = 0; i < count; i++) {
+ for (i = 0; i < count; i ++) {
if ((changes & cur) && (gpfsel_is_out(s, start + i))) { qemu_set_irq(s->out[start + i], 1);
}
@@ -125,132 +127,165 @@ static void gpset(BCM2835GpioState *s, }

static void gpclr(BCM2835GpioState *s,
- uint32_t val, uint8_t start, uint8_t count, uint32_t *lev)
+ uint32_t val, uint8_t start, uint8_t count, uint32_t *lev)
{
uint32_t changes = val & *lev;
uint32_t cur = 1;

int i;
- for (i = 0; i < count; i++) {
+ for (i = 0; i < count; i ++) {
if ((changes & cur) && (gpfsel_is_out(s, start + i))) { qemu_set_irq(s->out[start + i], 0);
}
cur <<= 1;
}

- *lev &= ~val;
+ *lev &= ~ val;
}

-static uint64_t bcm2835_gpio_read(void *opaque, hwaddr offset,
- unsigned size)
+static uint64_t bcm2835_gpio_read(void *opaque, hwaddr offset, unsigned size) {
- BCM2835GpioState *s = (BCM2835GpioState *)opaque;
+ BCM2835GpioState *s = (BCM2835GpioState *) opaque;
+
+ uint64_t Data;

switch (offset) {

-    case GPFSEL0:
-    case GPFSEL1:
-    case GPFSEL2:
-    case GPFSEL3:
-    case GPFSEL4:
-    case GPFSEL5:

- return gpfsel_get(s, offset / 4);
- case GPSET0:
- case GPSET1:
- /* Write Only */
- return 0;
- case GPCLR0:
- case GPCLR1:
- /* Write Only */
- return 0;
- case GPLEV0:
- return s->lev0;
- case GPLEV1:
- return s->lev1;

-    case GPEDS0:
-    case GPEDS1:
-    case GPREN0:
-    case GPREN1:
-    case GPFEN0:
-    case GPFEN1:
-    case GPHEN0:
-    case GPHEN1:
-    case GPLEN0:
-    case GPLEN1:
-    case GPAREN0:
-    case GPAREN1:
-    case GPAFEN0:
-    case GPAFEN1:
-    case GPPUD:
-    case GPPUDCLK0:
-    case GPPUDCLK1:

- /* Not implemented */
- return 0;
- default:
- qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset %"HWADDR_PRIx"\n",
- __func__, offset);

-        break;
+        case GPFSEL0:
+        case GPFSEL1:
+        case GPFSEL2:
+        case GPFSEL3:
+        case GPFSEL4:
+        case GPFSEL5:

+ return gpfsel_get(s, offset / 4);
+ case GPSET0:
+ case GPSET1:
+ /* Write Only */
+ return 0;
+ case GPCLR0:
+ case GPCLR1:
+ /* Write Only */
+ return 0;
+ case GPLEV0:
+ if (s->panel.socket != - 1) {
+ if (panel_read(&s->panel, &Data)) {
+ s->lev0 = (uint32_t) Data;
+ s->lev1 = (uint32_t) (Data >> 32);
+ }
+ }
+ return s->lev0;
+ case GPLEV1:
+ if (s->panel.socket != - 1) {
+ if (panel_read(&s->panel, &Data)) {
+ s->lev0 = (uint32_t) Data;
+ s->lev1 = (uint32_t) (Data >> 32);
+ }
+ }
+ return s->lev1;

+        case GPEDS0:
+        case GPEDS1:
+        case GPREN0:
+        case GPREN1:
+        case GPFEN0:
+        case GPFEN1:
+        case GPHEN0:
+        case GPHEN1:
+        case GPLEN0:
+        case GPLEN1:
+        case GPAREN0:
+        case GPAREN1:
+        case GPAFEN0:
+        case GPAFEN1:
+        case GPPUD:
+        case GPPUDCLK0:
+        case GPPUDCLK1:

+ /* Not implemented */
+ return 0;
+ default:
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset %"HWADDR_PRIx"\n",
+ __func__, offset);
+ break;
}

return 0;
}

static void bcm2835_gpio_write(void *opaque, hwaddr offset,
- uint64_t value, unsigned size)
+ uint64_t value, unsigned size)
{

-    BCM2835GpioState *s = (BCM2835GpioState *)opaque;
+    BCM2835GpioState *s = (BCM2835GpioState *) opaque;
+    uint64_t Data;

+

switch (offset) {

-    case GPFSEL0:
-    case GPFSEL1:
-    case GPFSEL2:
-    case GPFSEL3:
-    case GPFSEL4:
-    case GPFSEL5:

- gpfsel_set(s, offset / 4, value);
- break;
- case GPSET0:
- gpset(s, value, 0, 32, &s->lev0);
- break;
- case GPSET1:
- gpset(s, value, 32, 22, &s->lev1);
- break;
- case GPCLR0:
- gpclr(s, value, 0, 32, &s->lev0);
- break;
- case GPCLR1:
- gpclr(s, value, 32, 22, &s->lev1);
- break;
- case GPLEV0:
- case GPLEV1:
- /* Read Only */
- break;

-    case GPEDS0:
-    case GPEDS1:
-    case GPREN0:
-    case GPREN1:
-    case GPFEN0:
-    case GPFEN1:
-    case GPHEN0:
-    case GPHEN1:
-    case GPLEN0:
-    case GPLEN1:
-    case GPAREN0:
-    case GPAREN1:
-    case GPAFEN0:
-    case GPAFEN1:
-    case GPPUD:
-    case GPPUDCLK0:
-    case GPPUDCLK1:
-        /* Not implemented */
-        break;
-    default:
-        goto err_out;
+        case GPFSEL0:
+        case GPFSEL1:
+        case GPFSEL2:
+        case GPFSEL3:
+        case GPFSEL4:
+        case GPFSEL5:

+ gpfsel_set(s, offset / 4, value);
+ break;
+ case GPSET0:
+ gpset(s, value, 0, 32, &s->lev0);
+ if (s->panel.socket != - 1) {
+ Data = value;
+ senddatatopanel(&s->panel, Data, true); //John Bradley dummy GPIO Panel
+ }
+ break;
+ case GPSET1:
+ gpset(s, value, 32, 22, &s->lev1);
+ if (s->panel.socket != - 1) {

+                Data = value;
+                Data <<= 32;
+                senddatatopanel(&s->panel, Data, true); //John Bradley dummy GPIO Panel

+ }
+ break;
+ case GPCLR0:
+ gpclr(s, value, 0, 32, &s->lev0);
+ if (s->panel.socket != - 1) {
+ Data = value;
+ senddatatopanel(&s->panel, Data, false); //John Bradley dummy GPIO Panel
+ }
+ break;
+ case GPCLR1:
+ gpclr(s, value, 32, 22, &s->lev1);
+ if (s->panel.socket != - 1) {

+                Data = value;
+                Data <<= 32;
+                senddatatopanel(&s->panel, Data, false); //John Bradley dummy GPIO Panel

+ }
+ break;
+ case GPLEV0:
+ case GPLEV1:
+ /* Read Only */
+ break;

+        case GPEDS0:
+        case GPEDS1:
+        case GPREN0:
+        case GPREN1:
+        case GPFEN0:
+        case GPFEN1:
+        case GPHEN0:
+        case GPHEN1:
+        case GPLEN0:
+        case GPLEN1:
+        case GPAREN0:
+        case GPAREN1:
+        case GPAFEN0:
+        case GPAFEN1:
+        case GPPUD:
+        case GPPUDCLK0:
+        case GPPUDCLK1:

+ /* Not implemented */
+ break;
+ default:
+ goto err_out;
}
return;

err_out:
qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset %"HWADDR_PRIx"\n",
- __func__, offset);
+ __func__, offset);
}

static void bcm2835_gpio_reset(DeviceState *dev)
@@ -258,7 +293,7 @@ static void bcm2835_gpio_reset(DeviceState *dev) BCM2835GpioState *s = BCM2835_GPIO(dev);

int i;
- for (i = 0; i < 6; i++) {
+ for (i = 0; i < 6; i ++) {
gpfsel_set(s, i, 0);
}

@@ -272,21 +307,22 @@ static void bcm2835_gpio_reset(DeviceState *dev) }

static const MemoryRegionOps bcm2835_gpio_ops = {

-    .read = bcm2835_gpio_read,
-    .write = bcm2835_gpio_write,
-    .endianness = DEVICE_NATIVE_ENDIAN,
+                                                 .read = bcm2835_gpio_read,
+                                                 .write = bcm2835_gpio_write,
+                                                 .endianness = DEVICE_NATIVE_ENDIAN,

};

static const VMStateDescription vmstate_bcm2835_gpio = {

-    .name = "bcm2835_gpio",
-    .version_id = 1,
-    .minimum_version_id = 1,
-    .fields = (VMStateField[]) {
-        VMSTATE_UINT8_ARRAY(fsel, BCM2835GpioState, 54),
-        VMSTATE_UINT32(lev0, BCM2835GpioState),
-        VMSTATE_UINT32(lev1, BCM2835GpioState),
-        VMSTATE_UINT8(sd_fsel, BCM2835GpioState),
-        VMSTATE_END_OF_LIST()
+                                                        .name = "bcm2835_gpio",
+                                                        .version_id = 1,
+                                                        .minimum_version_id = 1,
+                                                        .fields = (VMStateField[])
+    {
+     VMSTATE_UINT8_ARRAY(fsel, BCM2835GpioState, 54),
+     VMSTATE_UINT32(lev0, BCM2835GpioState),
+     VMSTATE_UINT32(lev1, BCM2835GpioState),
+     VMSTATE_UINT8(sd_fsel, BCM2835GpioState),
+     VMSTATE_END_OF_LIST()

}
};

@@ -296,13 +332,26 @@ static void bcm2835_gpio_init(Object *obj) DeviceState *dev = DEVICE(obj);
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);

- qbus_create_inplace(&s->sdbus, sizeof(s->sdbus),
+ qbus_create_inplace(&s->sdbus, sizeof (s->sdbus),
TYPE_SD_BUS, DEVICE(s), "sd-bus");

memory_region_init_io(&s->iomem, obj,
- &bcm2835_gpio_ops, s, "bcm2835_gpio", 0x1000);
+ &bcm2835_gpio_ops, s, "bcm2835_gpio", 0x1000);
sysbus_init_mmio(sbd, &s->iomem);
qdev_init_gpio_out(dev, s->out, 54);
+
+ int err;
+

+    /* Get access to the GPIO panel, program will quit on fail */
+    err = panel_open(&s->panel);
+    if (err) {
+        printf("Couldn't connect to a GPIO panel\n"); //John Bradley dummy GPIO Panel
+    } else {
+        sendpincount(&s->panel, 54); //PI Has 54 Pins
+        sendenabledmap(&s->panel, 0x003FFFFFFFFFFFFC); //Pins 0 & 1 are I2C so disable
+        sendinputmap(&s->panel, 0x0000000000000000); //There are no dedicated input pins I know off
+        sendoutputmap(&s->panel, 0x0000800000000000); //Pin 53 is dedicated output LED

+ }
}

static void bcm2835_gpio_realize(DeviceState *dev, Error **errp)
@@ -314,7 +363,7 @@ static void bcm2835_gpio_realize(DeviceState *dev, Error **errp) obj = object_property_get_link(OBJECT(dev), "sdbus-sdhci", &err);
if (obj == NULL) {
error_setg(errp, "%s: required sdhci link not found: %s",
- __func__, error_get_pretty(err));
+ __func__, error_get_pretty(err));
return;
}
s->sdbus_sdhci = SD_BUS(obj);
@@ -322,7 +371,7 @@ static void bcm2835_gpio_realize(DeviceState *dev, Error **errp) obj = object_property_get_link(OBJECT(dev), "sdbus-sdhost", &err);
if (obj == NULL) {
error_setg(errp, "%s: required sdhost link not found: %s",
- __func__, error_get_pretty(err));
+ __func__, error_get_pretty(err));
return;
}
s->sdbus_sdhost = SD_BUS(obj);
@@ -332,17 +381,17 @@ static void bcm2835_gpio_class_init(ObjectClass *klass, void *data) {
DeviceClass *dc = DEVICE_CLASS(klass);

-    dc->vmsd = &vmstate_bcm2835_gpio;
-    dc->realize = &bcm2835_gpio_realize;
-    dc->reset = &bcm2835_gpio_reset;
+    dc->vmsd = & vmstate_bcm2835_gpio;
+    dc->realize = & bcm2835_gpio_realize;
+    dc->reset = & bcm2835_gpio_reset;

}

static const TypeInfo bcm2835_gpio_info = {

-    .name          = TYPE_BCM2835_GPIO,
-    .parent        = TYPE_SYS_BUS_DEVICE,
-    .instance_size = sizeof(BCM2835GpioState),
-    .instance_init = bcm2835_gpio_init,
-    .class_init    = bcm2835_gpio_class_init,
+                                           .name = TYPE_BCM2835_GPIO,
+                                           .parent = TYPE_SYS_BUS_DEVICE,
+                                           .instance_size = sizeof (BCM2835GpioState),
+                                           .instance_init = bcm2835_gpio_init,
+                                           .class_init = bcm2835_gpio_class_init,

};

static void bcm2835_gpio_register_types(void)

hw/misc/Makefile.objs +0 -0
index c8b489390f..fd0cc922ee 100644
@@ -41,6 +41,8 @@ obj-$(CONFIG_OMAP) += omap_l4.o

obj-$(CONFIG_OMAP) += omap_sdrc.o
obj-$(CONFIG_OMAP) += omap_tap.o
obj-$(CONFIG_RASPI) += bcm2835_mbox.o
+obj-$(CONFIG_RASPI) += bcm2835_mphi.o
+obj-$(CONFIG_RASPI) += bcm2835_power.o
obj-$(CONFIG_RASPI) += bcm2835_property.o
obj-$(CONFIG_RASPI) += bcm2835_rng.o
obj-$(CONFIG_SLAVIO) += slavio_misc.o

hw/misc/bcm2835_mphi.c new file +163 -0

163 lines not on this page · raw message

hw/misc/bcm2835_power.c new file +106 -0

106 lines not on this page · raw message

hw/timer/Makefile.objs +0 -0
index dd6f27e2a3..7beccc8747 100644
@@ -29,6 +29,8 @@ obj-$(CONFIG_EXYNOS4) += exynos4210_rtc.o

obj-$(CONFIG_OMAP) += omap_gptimer.o
obj-$(CONFIG_OMAP) += omap_synctimer.o
obj-$(CONFIG_PXA2XX) += pxa2xx_timer.o
+obj-$(CONFIG_RASPI) += bcm2835_st.o
+obj-$(CONFIG_RASPI) += bcm2835_timer.o
obj-$(CONFIG_SH4) += sh_timer.o
obj-$(CONFIG_DIGIC) += digic-timer.o
obj-$(CONFIG_MIPS_CPS) += mips_gictimer.o

hw/timer/bcm2835_st.c new file +202 -0

202 lines not on this page · raw message

hw/timer/bcm2835_timer.c new file +224 -0

224 lines not on this page · raw message

hw/usb/Makefile.objs +0 -0
index 5958be8ce3..9ac7cb4c41 100644
@@ -40,5 +40,7 @@ common-obj-$(CONFIG_USB_REDIR) += redirect.o quirks.o

common-obj-y += $(patsubst %,host-%.o,$(HOST_USB))

ifeq ($(CONFIG_USB_LIBUSB),y)
-common-obj-$(CONFIG_XEN) += xen-usb.o
+common-obj-$(CONFIG_XEN_BACKEND) += xen-usb.o
endif
+
+obj-$(CONFIG_RASPI) += bcm2835_usb.o

hw/usb/bcm2835_usb.c new file +604 -0

604 lines not on this page · raw message

hw/usb/bcm2835_usb_regs.h new file +1061 -0

1,061 lines not on this page · raw message

hw/usb/dev-network.c +0 -0
index 85fc81bf43..3d97b5d489 100644
@@ -1201,7 +1201,7 @@ static void usb_net_handle_dataout(USBNetState *s, USBPacket *p)

s->out_ptr += sz;

if (!is_rndis(s)) {
- if (p->iov.size < 64) {
+ /*if (p->iov.size < 64)*/ {
qemu_send_packet(qemu_get_queue(s->nic), s->out_buf, s->out_ptr); s->out_ptr = 0;
}

include/hw/arm/bcm2835.h new file +37 -0
new file mode 100644
index 0000000000..9ea8ddd572
@@ -0,0 +1,37 @@
+/*
+ * Raspberry Pi emulation (c) 2012 Gregory Estrade
+ * Upstreaming code cleanup [including bcm2835_*] (c) 2013 Jan Petrous
+ *
+ * Rasperry Pi 2 emulation and refactoring Copyright (c) 2015, Microsoft
+ * Written by Andrew Baumann
+ *
+ * Moved to Qemu root from Old Rasp
+ * John Bradley April 2017
+ * 
+ * This code is licensed under the GNU GPLv2 and later.
+ */
+
+#ifndef BCM2835_H
+#define BCM2835_H
+
+#include "hw/arm/arm.h"
+#include "hw/arm/bcm2835_peripherals.h"
+#include "hw/intc/bcm2835_control.h"
+
+#define TYPE_BCM2835 "bcm2835"
+#define BCM2835(obj) OBJECT_CHECK(BCM2835State, (obj), TYPE_BCM2835)
+
+#define BCM2835_NCPUS 1
+
+typedef struct BCM2835State {
+    /*< private >*/
+    DeviceState parent_obj;
+    /*< public >*/
+
+    uint32_t enabled_cpus;
+    ARMCPU cpus[BCM2835_NCPUS];
+ 
+    BCM2835PeripheralState peripherals;
+} BCM2835State;
+
+#endif /* BCM2835_H */
include/hw/arm/bcm2835_peripherals.h +0 -0
index 122b286de7..ef28b51066 100644
@@ -18,12 +18,17 @@

#include "hw/display/bcm2835_fb.h"
#include "hw/dma/bcm2835_dma.h"
#include "hw/intc/bcm2835_ic.h"
+#include "hw/misc/bcm2835_mphi.h"
+#include "hw/misc/bcm2835_power.h"
#include "hw/misc/bcm2835_property.h"
#include "hw/misc/bcm2835_rng.h"
#include "hw/misc/bcm2835_mbox.h"
#include "hw/sd/sdhci.h"
#include "hw/sd/bcm2835_sdhost.h"
#include "hw/gpio/bcm2835_gpio.h"
+#include "hw/timer/bcm2835_st.h"
+#include "hw/timer/bcm2835_timer.h"
+#include "hw/usb/bcm2835_usb.h"

#define TYPE_BCM2835_PERIPHERALS "bcm2835-peripherals" #define BCM2835_PERIPHERALS(obj) \
@@ -43,10 +48,15 @@ typedef struct BCM2835PeripheralState { BCM2835FBState fb;
BCM2835DMAState dma;
BCM2835ICState ic;
+ BCM2835MphiState mphi;
+ BCM2835PowerState power;
BCM2835PropertyState property;
BCM2835RngState rng;
BCM2835MboxState mboxes;
SDHCIState sdhci;

+    BCM2835StState st;
+    BCM2835TimerState timer;
+    BCM2835UsbState usb;

BCM2835SDHostState sdhost;
BCM2835GpioState gpio;
} BCM2835PeripheralState;

include/hw/gpio/bcm2835_gpio.h +0 -0
index 9f8e0c720c..73cfda6a6b 100644
@@ -16,6 +16,8 @@
 

#include "hw/sd/sd.h"

+#include "qemu/PanelEmu.h"
+
typedef struct BCM2835GpioState {
SysBusDevice parent_obj;

@@ -30,6 +32,9 @@ typedef struct BCM2835GpioState { uint32_t lev0, lev1;
uint8_t sd_fsel;
qemu_irq out[54];
+
+ panel_connection_t panel;
+
} BCM2835GpioState;

#define TYPE_BCM2835_GPIO "bcm2835_gpio"

include/hw/intc/bcm2835_control.h new file +53 -0

53 lines not on this page · raw message

include/hw/intc/bcm2836_control.h +0 -0
index 613f3c4186..768b4d4930 100644
@@ -5,6 +5,8 @@

* Rasperry Pi 2 emulation and refactoring Copyright (c) 2015, Microsoft
* Written by Andrew Baumann
*
+ * Merge into QEMU root fork John Bradley April 2017
+ *
* This code is licensed under the GNU GPLv2 and later.
*/

include/hw/misc/bcm2835_mphi.h new file +28 -0
new file mode 100644
index 0000000000..72824a9ff5
@@ -0,0 +1,28 @@
+/*
+ * Raspberry Pi emulation (c) 2012 Gregory Estrade
+ * This code is licensed under the GNU GPLv2 and later.
+ */
+
+#ifndef BCM2835_MPHI_H
+#define BCM2835_MPHI_H
+
+#include "hw/sysbus.h"
+
+#define TYPE_BCM2835_MPHI "bcm2835-mphi"
+#define BCM2835_MPHI(obj) \
+        OBJECT_CHECK(BCM2835MphiState, (obj), TYPE_BCM2835_MPHI)
+
+typedef struct {
+    SysBusDevice busdev;
+    MemoryRegion iomem;
+
+    uint32_t mphi_base;
+    uint32_t mphi_ctrl;
+    uint32_t mphi_outdda;
+    uint32_t mphi_outddb;
+    uint32_t mphi_intstat;
+
+    qemu_irq irq;
+} BCM2835MphiState;
+
+#endif
include/hw/misc/bcm2835_power.h new file +22 -0
new file mode 100644
index 0000000000..a19e7f4930
@@ -0,0 +1,22 @@
+/*
+ * Raspberry Pi emulation (c) 2012 Gregory Estrade
+ * This code is licensed under the GNU GPLv2 and later.
+ */
+
+#ifndef BCM2835_POWER_H
+#define BCM2835_POWER_H
+
+#include "hw/sysbus.h"
+
+#define TYPE_BCM2835_POWER "bcm2835-power"
+#define BCM2835_POWER(obj) \
+        OBJECT_CHECK(BCM2835PowerState, (obj), TYPE_BCM2835_POWER)
+
+typedef struct {
+    SysBusDevice busdev;
+    MemoryRegion iomem;
+    int pending;
+    qemu_irq mbox_irq;
+} BCM2835PowerState;
+
+#endif
include/hw/timer/bcm2835_st.h new file +25 -0
new file mode 100644
index 0000000000..11dc312711
@@ -0,0 +1,25 @@
+/*
+ * Raspberry Pi emulation (c) 2012 Gregory Estrade
+ * This code is licensed under the GNU GPLv2 and later.
+ */
+
+#ifndef BCM2835_ST_H
+#define BCM2835_ST_H
+
+#include "hw/sysbus.h"
+#include "qemu/timer.h"
+
+#define TYPE_BCM2835_ST "bcm2835_st"
+#define BCM2835_ST(obj) OBJECT_CHECK(BCM2835StState, (obj), TYPE_BCM2835_ST)
+
+typedef struct BCM2835StState {
+    SysBusDevice busdev;
+    MemoryRegion iomem;
+    QEMUTimer *timer;
+    uint32_t compare[4];
+    uint32_t match;
+    uint32_t next;
+    qemu_irq irq[4];
+} BCM2835StState;
+
+#endif
include/hw/timer/bcm2835_timer.h new file +32 -0
new file mode 100644
index 0000000000..e2a0a76f01
@@ -0,0 +1,32 @@
+/*
+ * Raspberry Pi emulation (c) 2012 Gregory Estrade
+ * This code is licensed under the GNU GPLv2 and later.
+ */
+
+#ifndef BCM2835_TIMER_H
+#define BCM2835_TIMER_H
+
+#include "hw/sysbus.h"
+#include "hw/ptimer.h"
+
+#define TYPE_BCM2835_TIMER "bcm2835_timer"
+#define BCM2835_TIMER(obj) \
+        OBJECT_CHECK(BCM2835TimerState, (obj), TYPE_BCM2835_TIMER)
+
+typedef struct {
+    SysBusDevice busdev;
+    MemoryRegion iomem;
+
+    qemu_irq irq;
+
+    uint32_t load;
+    uint32_t control;
+    uint32_t raw_irq;
+    uint32_t prediv;
+    uint32_t frc_value;
+
+    ptimer_state *timer;
+    ptimer_state *frc_timer;
+} BCM2835TimerState;
+
+#endif
include/hw/usb/bcm2835_usb.h new file +78 -0

78 lines not on this page · raw message

include/qemu/PanelEmu.h new file +53 -0

53 lines not on this page · raw message

util/Makefile.objs +0 -0
index c6205ebf86..8316ed79ba 100644
@@ -43,3 +43,4 @@ util-obj-y += qdist.o

util-obj-y += qht.o
util-obj-y += range.o
util-obj-y += systemd.o
+util-obj-y += PanelEmu.o
\ No newline at end of file

util/PanelEmu.c new file +293 -0

196 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.13.0.windows.1

Part of the diff is not shown here. View the raw message.

#2 lore raw
Quoted 6 lines · John Bradley via Qemu-devel

From 7f74f048f135d9c9c230a9e90f72451c841c6d35 Mon Sep 17 00:00:00 2001
From: John Bradley <[email protected]>
Date: Sat, 13 May 2017 23:07:47 +0100
Subject: [PATCH] Changes to Broadcom(BCM) files and Raspberry Pi files. Addition of PanelEmu

Quoted 7 lines

The files add the ability to attach, via TCP, a panel emulator The include a unification of several PD Raspberry PI additions A modification to dev-network to all circle SDK WWW client to work The DummyPanel is not included but available at
https://github.com/flypie/GDummyPanel.git

Hey John,

Thanks for the patch!

Unfortunately this patch is too long to review, you need to split the patch up into shorter more readable patches. Otherwise it's too hard to people to understand what you are changing and why.

There are some details here:
http://wiki.qemu.org/Contribute/SubmitAPatch about how to split up patches. Each patch applied in order shouldn't break any compilation or runtime. Generally the flow is to add the logic in earlier patches and then connect it and switch it on in the later patches.

Try splitting up adding/editing each individual device and send that our first. That is generally the easiest to review/accept.

Thanks,

Alistair

Quoted 49 lines

---

.gitignore                           |   54 ++
hw/arm/Makefile.objs                 |    2 +-
hw/arm/bcm2835.c                     |  114 ++++
hw/arm/bcm2835_peripherals.c         |  104 ++++
hw/arm/bcm2836.c                     |    3 +-
hw/arm/raspi.c                       |   77 ++-
hw/gpio/bcm2835_gpio.c               |  333 ++++++-----
hw/misc/Makefile.objs                |    2 +
hw/misc/bcm2835_mphi.c               |  163 ++++++
hw/misc/bcm2835_power.c              |  106 ++++
hw/timer/Makefile.objs               |    2 +
hw/timer/bcm2835_st.c                |  202 +++++++
hw/timer/bcm2835_timer.c             |  224 +++++++
hw/usb/Makefile.objs                 |    4 +-
hw/usb/bcm2835_usb.c                 |  604 +++++++++++++++++++
hw/usb/bcm2835_usb_regs.h            | 1061 ++++++++++++++++++++++++++++++++++
hw/usb/dev-network.c                 |    2 +-
include/hw/arm/bcm2835.h             |   37 ++
include/hw/arm/bcm2835_peripherals.h |   10 +
include/hw/gpio/bcm2835_gpio.h       |    5 +
include/hw/intc/bcm2835_control.h    |   53 ++
include/hw/intc/bcm2836_control.h    |    2 +
include/hw/misc/bcm2835_mphi.h       |   28 +
include/hw/misc/bcm2835_power.h      |   22 +
include/hw/timer/bcm2835_st.h        |   25 +
include/hw/timer/bcm2835_timer.h     |   32 +
include/hw/usb/bcm2835_usb.h         |   78 +++
include/qemu/PanelEmu.h              |   53 ++
util/Makefile.objs                   |    1 +
util/PanelEmu.c                      |  293 ++++++++++
30 files changed, 3547 insertions(+), 149 deletions(-)

create mode 100644 hw/arm/bcm2835.c
create mode 100644 hw/misc/bcm2835_mphi.c create mode 100644 hw/misc/bcm2835_power.c create mode 100644 hw/timer/bcm2835_st.c create mode 100644 hw/timer/bcm2835_timer.c create mode 100644 hw/usb/bcm2835_usb.c create mode 100644 hw/usb/bcm2835_usb_regs.h create mode 100644 include/hw/arm/bcm2835.h create mode 100644 include/hw/intc/bcm2835_control.h create mode 100644 include/hw/misc/bcm2835_mphi.h create mode 100644 include/hw/misc/bcm2835_power.h create mode 100644 include/hw/timer/bcm2835_st.h create mode 100644 include/hw/timer/bcm2835_timer.h create mode 100644 include/hw/usb/bcm2835_usb.h create mode 100644 include/qemu/PanelEmu.h create mode 100644 util/PanelEmu.c

#3 lore raw

Hi,
That is going to be very difficult as a lot of the changes are interlinked the vast majority of the patch is new files. John BradleyTel: 07896 839635Skype: flypie125 125B Grove StreetEdge Hill Liverpool L7 7AF

On Monday, 15 May 2017, 17:54, Alistair Francis <[email protected]> wrote:

Quoted 6 lines · John Bradley via Qemu-devel

From 7f74f048f135d9c9c230a9e90f72451c841c6d35 Mon Sep 17 00:00:00 2001
From: John Bradley <[email protected]>
Date: Sat, 13 May 2017 23:07:47 +0100
Subject: [PATCH] Changes to Broadcom(BCM) files and Raspberry Pi files. Addition of PanelEmu

Quoted 7 lines

The files add the ability to attach, via TCP, a panel emulator The include a unification of several PD Raspberry PI additions A modification to dev-network to all circle SDK WWW client to work The DummyPanel is not included but available at
https://github.com/flypie/GDummyPanel.git

Hey John,

Thanks for the patch!

Unfortunately this patch is too long to review, you need to split the patch up into shorter more readable patches. Otherwise it's too hard to people to understand what you are changing and why.

There are some details here:
http://wiki.qemu.org/Contribute/SubmitAPatch about how to split up patches. Each patch applied in order shouldn't break any compilation or runtime. Generally the flow is to add the logic in earlier patches and then connect it and switch it on in the later patches.

Try splitting up adding/editing each individual device and send that our first. That is generally the easiest to review/accept.

Thanks,

Alistair

Quoted 49 lines

---
.gitignore                          |  54 ++
hw/arm/Makefile.objs                |    2 +-
hw/arm/bcm2835.c                    |  114 ++++ hw/arm/bcm2835_peripherals.c        |  104 ++++
hw/arm/bcm2836.c                    |    3 +-
hw/arm/raspi.c                      |  77 ++- hw/gpio/bcm2835_gpio.c              |  333 ++++++----- hw/misc/Makefile.objs                |    2 + hw/misc/bcm2835_mphi.c              |  163 ++++++ hw/misc/bcm2835_power.c              |  106 ++++ hw/timer/Makefile.objs              |    2 + hw/timer/bcm2835_st.c                |  202 +++++++ hw/timer/bcm2835_timer.c            |  224 +++++++ hw/usb/Makefile.objs                |    4 +- hw/usb/bcm2835_usb.c                |  604 +++++++++++++++++++ hw/usb/bcm2835_usb_regs.h            | 1061 ++++++++++++++++++++++++++++++++++ hw/usb/dev-network.c                |    2 +- include/hw/arm/bcm2835.h            |  37 ++ include/hw/arm/bcm2835_peripherals.h |  10 +

include/hw/gpio/bcm2835_gpio.h      |    5 +
include/hw/intc/bcm2835_control.h    |  53 ++
include/hw/intc/bcm2836_control.h    |    2 +
include/hw/misc/bcm2835_mphi.h      |  28 +

include/hw/misc/bcm2835_power.h      |  22 + include/hw/timer/bcm2835_st.h        |  25 + include/hw/timer/bcm2835_timer.h    |  32 + include/hw/usb/bcm2835_usb.h        |  78 +++ include/qemu/PanelEmu.h              |  53 ++ util/Makefile.objs                  |    1 + util/PanelEmu.c                      |  293 ++++++++++

30 files changed, 3547 insertions(+), 149 deletions(-)

create mode 100644 hw/arm/bcm2835.c
create mode 100644 hw/misc/bcm2835_mphi.c create mode 100644 hw/misc/bcm2835_power.c create mode 100644 hw/timer/bcm2835_st.c create mode 100644 hw/timer/bcm2835_timer.c create mode 100644 hw/usb/bcm2835_usb.c create mode 100644 hw/usb/bcm2835_usb_regs.h create mode 100644 include/hw/arm/bcm2835.h create mode 100644 include/hw/intc/bcm2835_control.h create mode 100644 include/hw/misc/bcm2835_mphi.h create mode 100644 include/hw/misc/bcm2835_power.h create mode 100644 include/hw/timer/bcm2835_st.h create mode 100644 include/hw/timer/bcm2835_timer.h create mode 100644 include/hw/usb/bcm2835_usb.h create mode 100644 include/qemu/PanelEmu.h create mode 100644 util/PanelEmu.c

#4 lore raw

Hi John,

Quoted 2 lines

That is going to be very difficult as a lot of the changes are interlinked the vast majority of the patch is new files.

I rebased your branch on latest qemu/master here:

https://github.com/philmd/qemu/tree/flypie-GDummyPanel-rebased

It is much easier to follow now, the big XML files you added/removed also disappeared (gitk was crashing 'Out Of Memory' trying to look at your tree).

I hope it can help you to continue reordering in smaller patches.

Regards,

Phil.

Quoted 75 lines · Alistair Francis

Hey John,

Thanks for the patch!

Unfortunately this patch is too long to review, you need to split the patch up into shorter more readable patches. Otherwise it's too hard to people to understand what you are changing and why.

There are some details here:
http://wiki.qemu.org/Contribute/SubmitAPatch
<http://wiki.qemu.org/Contribute/SubmitAPatch>about how to split up patches. Each patch applied in order shouldn't break any compilation or runtime. Generally the flow is to add the logic in earlier patches and then connect it and switch it on in the later patches.

Try splitting up adding/editing each individual device and send that our first. That is generally the easiest to review/accept.

Thanks,

Alistair

Quoted 13 lines

---

.gitignore                          |  54 ++
hw/arm/Makefile.objs                |    2 +-
hw/arm/bcm2835.c                    |  114 ++++
hw/arm/bcm2835_peripherals.c        |  104 ++++
hw/arm/bcm2836.c                    |    3 +-
hw/arm/raspi.c                      |  77 ++-
hw/gpio/bcm2835_gpio.c              |  333 ++++++-----

hw/misc/Makefile.objs | 2 +
hw/misc/bcm2835_mphi.c | 163 ++++++
hw/misc/bcm2835_power.c | 106 ++++
hw/timer/Makefile.objs | 2 +
hw/timer/bcm2835_st.c | 202 +++++++

Quoted 4 lines
hw/timer/bcm2835_timer.c            |  224 +++++++
hw/usb/Makefile.objs                |    4 +-
hw/usb/bcm2835_usb.c                |  604 +++++++++++++++++++

hw/usb/bcm2835_usb_regs.h | 1061

++++++++++++++++++++++++++++++++++

Quoted 32 lines

hw/usb/dev-network.c | 2 +-
include/hw/arm/bcm2835.h | 37 ++
include/hw/arm/bcm2835_peripherals.h | 10 +
include/hw/gpio/bcm2835_gpio.h | 5 +
include/hw/intc/bcm2835_control.h | 53 ++
include/hw/intc/bcm2836_control.h | 2 +
include/hw/misc/bcm2835_mphi.h | 28 +

include/hw/misc/bcm2835_power.h      |  22 +
include/hw/timer/bcm2835_st.h        |  25 +
include/hw/timer/bcm2835_timer.h    |  32 +
include/hw/usb/bcm2835_usb.h        |  78 +++
include/qemu/PanelEmu.h              |  53 ++
util/Makefile.objs                  |    1 +
util/PanelEmu.c                      |  293 ++++++++++
30 files changed, 3547 insertions(+), 149 deletions(-)

create mode 100644 hw/arm/bcm2835.c
create mode 100644 hw/misc/bcm2835_mphi.c create mode 100644 hw/misc/bcm2835_power.c create mode 100644 hw/timer/bcm2835_st.c create mode 100644 hw/timer/bcm2835_timer.c create mode 100644 hw/usb/bcm2835_usb.c create mode 100644 hw/usb/bcm2835_usb_regs.h create mode 100644 include/hw/arm/bcm2835.h create mode 100644 include/hw/intc/bcm2835_control.h create mode 100644 include/hw/misc/bcm2835_mphi.h create mode 100644 include/hw/misc/bcm2835_power.h create mode 100644 include/hw/timer/bcm2835_st.h create mode 100644 include/hw/timer/bcm2835_timer.h create mode 100644 include/hw/usb/bcm2835_usb.h create mode 100644 include/qemu/PanelEmu.h create mode 100644 util/PanelEmu.c

#5 lore raw

Hi,
The XML files in the base are not in the patch. They where net beans files. I can easily get it into 3 files, one large at 91KB but contains only new files and so is easy to read. Could be smaller but seems pointless.

another which is about 19KB of quite simple changes to mostly make files.
Then one 15KB which quite straight forward when you look at it. Applying them in that order should allow step wise addition. I've uploaded them to a share if anyone wants to comment.

The 3 files are new.patch

|  
|   
|   
|   |    |

|

|
|
| |
new.patch
Shared with Dropbox | |

|

|

 mod1.patch

|  
|   
|   
|   |    |

|

|
|
| |
mod1.patch
Shared with Dropbox | |

|

|

and
 a_hw_gpio_bcm2835_gpio.c.patch

|  
|   
|   
|   |    |

|

|
|
| |
a_hw_gpio_bcm2835_gpio.c.patch
Shared with Dropbox | |

|

|

John BradleyTel: 07896 839635Skype: flypie125 125B Grove StreetEdge Hill Liverpool L7 7AF

    On Tuesday, 16 May 2017, 0:20, Philippe Mathieu-Daudé <[email protected]> wrote:

Hi John,

Quoted 2 lines

That is going to be very difficult as a lot of the changes are interlinked the vast majority of the patch is new files.

I rebased your branch on latest qemu/master here:

https://github.com/philmd/qemu/tree/flypie-GDummyPanel-rebased

It is much easier to follow now, the big XML files you added/removed also disappeared (gitk was crashing 'Out Of Memory' trying to look at your tree).

I hope it can help you to continue reordering in smaller patches.

Regards,

Phil.

Quoted 75 lines · Alistair Francis

Hey John,

Thanks for the patch!

Unfortunately this patch is too long to review, you need to split the patch up into shorter more readable patches. Otherwise it's too hard to people to understand what you are changing and why.

There are some details here:
http://wiki.qemu.org/Contribute/SubmitAPatch
<http://wiki.qemu.org/Contribute/SubmitAPatch>about how to split up patches. Each patch applied in order shouldn't break any compilation or runtime. Generally the flow is to add the logic in earlier patches and then connect it and switch it on in the later patches.

Try splitting up adding/editing each individual device and send that our first. That is generally the easiest to review/accept.

Thanks,

Alistair

Quoted 9 lines

---
.gitignore                          |  54 ++ hw/arm/Makefile.objs                |    2 +- hw/arm/bcm2835.c                    |  114 ++++ hw/arm/bcm2835_peripherals.c        |  104 ++++ hw/arm/bcm2836.c                    |    3 +- hw/arm/raspi.c                      |  77 ++- hw/gpio/bcm2835_gpio.c              |  333 ++++++----- hw/misc/Makefile.objs                |    2 +

Quoted 8 lines

hw/misc/bcm2835_mphi.c              |  163 ++++++ hw/misc/bcm2835_power.c              |  106 ++++ hw/timer/Makefile.objs              |    2 + hw/timer/bcm2835_st.c                |  202 +++++++ hw/timer/bcm2835_timer.c            |  224 +++++++ hw/usb/Makefile.objs                |    4 +- hw/usb/bcm2835_usb.c                |  604 +++++++++++++++++++ hw/usb/bcm2835_usb_regs.h            | 1061

++++++++++++++++++++++++++++++++++

Quoted 32 lines

hw/usb/dev-network.c                |    2 +- include/hw/arm/bcm2835.h            |  37 ++ include/hw/arm/bcm2835_peripherals.h |  10 +

include/hw/gpio/bcm2835_gpio.h      |    5 +
include/hw/intc/bcm2835_control.h    |  53 ++
include/hw/intc/bcm2836_control.h    |    2 +
include/hw/misc/bcm2835_mphi.h      |  28 +

include/hw/misc/bcm2835_power.h      |  22 + include/hw/timer/bcm2835_st.h        |  25 + include/hw/timer/bcm2835_timer.h    |  32 + include/hw/usb/bcm2835_usb.h        |  78 +++ include/qemu/PanelEmu.h              |  53 ++ util/Makefile.objs                  |    1 + util/PanelEmu.c                      |  293 ++++++++++

30 files changed, 3547 insertions(+), 149 deletions(-)

create mode 100644 hw/arm/bcm2835.c
create mode 100644 hw/misc/bcm2835_mphi.c create mode 100644 hw/misc/bcm2835_power.c create mode 100644 hw/timer/bcm2835_st.c create mode 100644 hw/timer/bcm2835_timer.c create mode 100644 hw/usb/bcm2835_usb.c create mode 100644 hw/usb/bcm2835_usb_regs.h create mode 100644 include/hw/arm/bcm2835.h create mode 100644 include/hw/intc/bcm2835_control.h create mode 100644 include/hw/misc/bcm2835_mphi.h create mode 100644 include/hw/misc/bcm2835_power.h create mode 100644 include/hw/timer/bcm2835_st.h create mode 100644 include/hw/timer/bcm2835_timer.h create mode 100644 include/hw/usb/bcm2835_usb.h create mode 100644 include/qemu/PanelEmu.h create mode 100644 util/PanelEmu.c

#6 lore raw

Am 16.05.2017 um 02:01 schrieb John Bradley via Qemu-devel:

Quoted 3 lines

Hi,
The XML files in the base are not in the patch. They where net beans files. I can easily get it into 3 files, one large at 91KB but contains only new files and so is easy to read. Could be smaller but seems pointless.

I think what Alistar meant was something along the lines of:
patch/commit 1) add the remaining bcm2835 devices from Markus Armbruster's code to QEMU (btw: any reason why that hasn't been done? The USB stuff does seem nice to have) -- with a more meaningful commit title
2) add utils/panelemu.c and the include
3) bcm2835 now uses the emupanel
and then your other commits e.g.
4) USB CDC Ethernet driver dropped packets
5) emupanel: fixed compilation errors on linux
6) emupanel: removed last blocking I/O

Along the way you also seem to fix indentation in other code a lot, that makes following the patches more confusing than they need to be. It's harder to gauge at a quick glance whether you changed something meaingul or not.

Maybe even send a RFC just detailing the protocol, because it's probably important to get that right from the start.

Geert

Quoted 173 lines

another which is about 19KB of quite simple changes to mostly make files.
Then one 15KB which quite straight forward when you look at it. Applying them in that order should allow step wise addition. I've uploaded them to a share if anyone wants to comment.

The 3 files are new.patch

|
|
|
|   |    |
   |

|
|
| |
new.patch
Shared with Dropbox | |

|

|

mod1.patch

|
|
|
|   |    |
   |

|
|
| |
mod1.patch
Shared with Dropbox | |

|

|

and
a_hw_gpio_bcm2835_gpio.c.patch

|
|
|
|   |    |
   |

|
|
| |
a_hw_gpio_bcm2835_gpio.c.patch
Shared with Dropbox | |

|

|

John BradleyTel: 07896 839635Skype: flypie125 125B Grove StreetEdge Hill Liverpool L7 7AF

    On Tuesday, 16 May 2017, 0:20, Philippe Mathieu-Daudé <[email protected]> wrote:

Hi John,

Quoted 2 lines

That is going to be very difficult as a lot of the changes are interlinked the vast majority of the patch is new files.

I rebased your branch on latest qemu/master here:

https://github.com/philmd/qemu/tree/flypie-GDummyPanel-rebased

It is much easier to follow now, the big XML files you added/removed also disappeared (gitk was crashing 'Out Of Memory' trying to look at your tree).

I hope it can help you to continue reordering in smaller patches.

Regards,

Phil.

Quoted 75 lines · Alistair Francis

Hey John,

Thanks for the patch!

Unfortunately this patch is too long to review, you need to split the patch up into shorter more readable patches. Otherwise it's too hard to people to understand what you are changing and why.

There are some details here:
http://wiki.qemu.org/Contribute/SubmitAPatch
<http://wiki.qemu.org/Contribute/SubmitAPatch>about how to split up patches. Each patch applied in order shouldn't break any compilation or runtime. Generally the flow is to add the logic in earlier patches and then connect it and switch it on in the later patches.

Try splitting up adding/editing each individual device and send that our first. That is generally the easiest to review/accept.

Thanks,

Alistair

Quoted 13 lines

---

.gitignore                          |  54 ++
hw/arm/Makefile.objs                |    2 +-
hw/arm/bcm2835.c                    |  114 ++++
hw/arm/bcm2835_peripherals.c        |  104 ++++
hw/arm/bcm2836.c                    |    3 +-
hw/arm/raspi.c                      |  77 ++-
hw/gpio/bcm2835_gpio.c              |  333 ++++++-----

hw/misc/Makefile.objs | 2 +
hw/misc/bcm2835_mphi.c | 163 ++++++
hw/misc/bcm2835_power.c | 106 ++++
hw/timer/Makefile.objs | 2 +
hw/timer/bcm2835_st.c | 202 +++++++

Quoted 4 lines
hw/timer/bcm2835_timer.c            |  224 +++++++
hw/usb/Makefile.objs                |    4 +-
hw/usb/bcm2835_usb.c                |  604 +++++++++++++++++++

hw/usb/bcm2835_usb_regs.h | 1061

++++++++++++++++++++++++++++++++++

Quoted 32 lines

hw/usb/dev-network.c | 2 +-
include/hw/arm/bcm2835.h | 37 ++
include/hw/arm/bcm2835_peripherals.h | 10 +
include/hw/gpio/bcm2835_gpio.h | 5 +
include/hw/intc/bcm2835_control.h | 53 ++
include/hw/intc/bcm2836_control.h | 2 +
include/hw/misc/bcm2835_mphi.h | 28 +

include/hw/misc/bcm2835_power.h      |  22 +
include/hw/timer/bcm2835_st.h        |  25 +
include/hw/timer/bcm2835_timer.h    |  32 +
include/hw/usb/bcm2835_usb.h        |  78 +++
include/qemu/PanelEmu.h              |  53 ++
util/Makefile.objs                  |    1 +
util/PanelEmu.c                      |  293 ++++++++++
30 files changed, 3547 insertions(+), 149 deletions(-)

create mode 100644 hw/arm/bcm2835.c
create mode 100644 hw/misc/bcm2835_mphi.c create mode 100644 hw/misc/bcm2835_power.c create mode 100644 hw/timer/bcm2835_st.c create mode 100644 hw/timer/bcm2835_timer.c create mode 100644 hw/usb/bcm2835_usb.c create mode 100644 hw/usb/bcm2835_usb_regs.h create mode 100644 include/hw/arm/bcm2835.h create mode 100644 include/hw/intc/bcm2835_control.h create mode 100644 include/hw/misc/bcm2835_mphi.h create mode 100644 include/hw/misc/bcm2835_power.h create mode 100644 include/hw/timer/bcm2835_st.h create mode 100644 include/hw/timer/bcm2835_timer.h create mode 100644 include/hw/usb/bcm2835_usb.h create mode 100644 include/qemu/PanelEmu.h create mode 100644 util/PanelEmu.c

#8 lore raw
In reply to John Bradley via Qemu-devel

Am 14.05.2017 um 02:42 schrieb John Bradley via Qemu-devel:

Quoted 24 lines
Quoted 1 line

From 7f74f048f135d9c9c230a9e90f72451c841c6d35 Mon Sep 17 00:00:00 2001

From: John Bradley <[email protected]>
Date: Sat, 13 May 2017 23:07:47 +0100
Subject: [PATCH] Changes to Broadcom(BCM) files and Raspberry Pi files. Addition of PanelEmu

The files add the ability to attach, via TCP, a panel emulator The include a unification of several PD Raspberry PI additions A modification to dev-network to all circle SDK WWW client to work The DummyPanel is not included but available at
https://github.com/flypie/GDummyPanel.git

---
[ ... snip ... ]

util/PanelEmu.c new file +3 -0
new file mode 100644
index 0000000000..59c87d2747
@@ -0,0 +1,293 @@
+/*
+ * Emulation for Rasp PI GPIO via Server connected to via Socket
+ *

util/PanelEmu.c line 13

Quoted 10 lines
util/PanelEmu.c new file +10 -0
+ */
+#include "qemu/osdep.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <memory.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/types.h>
+#ifdef __MINGW32__

I think that should be #ifdef _WIN32.
Maybe in the far future QEMU could also be compiled with Visual Studio or any other windows compiler

Quoted 21 lines
util/PanelEmu.c new file +21 -0
+#include <winsock2.h>
+#else
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#endif
+
+
+#include "qemu/PanelEmu.h"
+
+typedef enum
+{
+    MACHINEDESC = 0,
+    PINSTOPANEL = 1,
+    READREQ = 2,
+    PINCOUNT = 3,
+    ENABLEMAP = 4,
+    INPUTMAP = 5,
+    OUTPUTMAP = 6,
+    PINSTOQEMU = 7
+} PacketType;

util/PanelEmu.c line 44

Quoted 10 lines
util/PanelEmu.c new file +10 -0
+
+#define MAXPACKET   255
+
+#define PACKETLEN   0  //Includes Packet Length
+#define PACKETTYPE  1
+
+typedef struct
+{
+    unsigned short int Data[MAXPACKET];
+} CommandPacket;

Why not something like
typedef struct

{
    uint8_t len;
    uint8_t type;
    union {
        struct {
            uint8_t cnt;
        } pinCount;
        struct {
            uint16_t pin0to15;
            uint16_t pin16to31;
            uint16_t pin32to47;
            uint16_t pin48to63;
        } dataUpdate;
        /* todo: other packet types */
    };
} CommandPacket;

util/PanelEmu.c line 230

Quoted 7 lines

[ ... snip ... ]

util/PanelEmu.c new file +6 -0
+/* Set a pin to a specified value */
+void senddatatopanel(panel_connection_t* h, uint64_t pin, bool val)
+{
+    CommandPacket Pkt;
+
+    Pkt.Data[PACKETLEN] = (char *) &Pkt.Data[6 + 1]-(char *) &Pkt.Data[0];

what's the use of this pointer aritmethic instead of just 6?

Geert

#9 lore raw

"I think that should be #ifdef _WIN32.
Maybe in the far future QEMU could also be compiled with Visual Studio
or any other windows compiler"
The reason for doing it this way is that MINGW64, which is the dev platform I uses on Windows10, does not include a port of the GNU Socket library so I have to use the native Win Sock Library.
"Why not something like
typedef struct
{
    uint8_t len;
    uint8_t type;
    union {
        struct {
            uint8_t cnt;
        } pinCount;
        struct {
            uint16_t pin0to15;
            uint16_t pin16to31;
            uint16_t pin32to47;
            uint16_t pin48to63;
        } dataUpdate;
        /* todo: other packet types */
    };
} CommandPacket;"

The problem with that is packing. I tried to do it that way but the different compilers I am using for QEMU and GDummyPanel pack and align in different way and no collection of pragmas and directives could make them pack the same. While writing this I have also noticed I have made an implicit assumption about the endedness of the data, which is not good. Also keep in mind someone may write a client in any language from Fortran, Forth to Python.

"what's the use of this pointer aritmethic instead of just 6?"

This is a similar attempt at robustness across compilers.

John BradleyTel: 07896 839635Skype: flypie125 125B Grove StreetEdge Hill Liverpool L7 7AF

On Tuesday, 16 May 2017, 9:56, Geert Martin Ijewski <[email protected]> wrote:

Am 14.05.2017 um 02:42 schrieb John Bradley via Qemu-devel:

Quoted 24 lines
Quoted 1 line

From 7f74f048f135d9c9c230a9e90f72451c841c6d35 Mon Sep 17 00:00:00 2001

From: John Bradley <[email protected]>
Date: Sat, 13 May 2017 23:07:47 +0100
Subject: [PATCH] Changes to Broadcom(BCM) files and Raspberry Pi files. Addition of PanelEmu

The files add the ability to attach, via TCP, a panel emulator The include a unification of several PD Raspberry PI additions A modification to dev-network to all circle SDK WWW client to work The DummyPanel is not included but available at
https://github.com/flypie/GDummyPanel.git

---
[ ... snip ... ]

util/PanelEmu.c new file +3 -0
new file mode 100644
index 0000000000..59c87d2747
@@ -0,0 +1,293 @@
+/*
+ * Emulation for Rasp PI GPIO via Server connected to via Socket
+ *

util/PanelEmu.c line 13

Quoted 10 lines
util/PanelEmu.c new file +10 -0
+ */
+#include "qemu/osdep.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <memory.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/types.h>
+#ifdef __MINGW32__

I think that should be #ifdef _WIN32.
Maybe in the far future QEMU could also be compiled with Visual Studio or any other windows compiler

Quoted 21 lines
util/PanelEmu.c new file +21 -0
+#include <winsock2.h>
+#else
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#endif
+
+
+#include "qemu/PanelEmu.h"
+
+typedef enum
+{
+    MACHINEDESC = 0,
+    PINSTOPANEL = 1,
+    READREQ = 2,
+    PINCOUNT = 3,
+    ENABLEMAP = 4,
+    INPUTMAP = 5,
+    OUTPUTMAP = 6,
+    PINSTOQEMU = 7
+} PacketType;

util/PanelEmu.c line 44

Quoted 10 lines
util/PanelEmu.c new file +10 -0
+
+#define MAXPACKET  255
+
+#define PACKETLEN  0  //Includes Packet Length
+#define PACKETTYPE  1
+
+typedef struct
+{
+    unsigned short int Data[MAXPACKET];
+} CommandPacket;

Why not something like
typedef struct
{
    uint8_t len;
    uint8_t type;
    union {
        struct {
            uint8_t cnt;
        } pinCount;
        struct {
            uint16_t pin0to15;
            uint16_t pin16to31;
            uint16_t pin32to47;
            uint16_t pin48to63;
        } dataUpdate;
        /* todo: other packet types */
    };
} CommandPacket;

util/PanelEmu.c line 230

Quoted 7 lines

[ ... snip ... ]

util/PanelEmu.c new file +6 -0
+/* Set a pin to a specified value */
+void senddatatopanel(panel_connection_t* h, uint64_t pin, bool val)
+{
+    CommandPacket Pkt;
+
+    Pkt.Data[PACKETLEN] = (char *) &Pkt.Data[6 + 1]-(char *) &Pkt.Data[0];

what's the use of this pointer aritmethic instead of just 6?

Geert

#7 lore raw
In reply to Geert Martin Ijewski

The idea of an RFC is good, but with it I would like to have a demo. Something with no mass implementation to worry about and this would be it. I should also add a version number to the initialisation of the protocol to increase robustness, between versions. I'll call this one V 0. John BradleyTel: 07896 839635Skype: flypie125 125B Grove StreetEdge Hill Liverpool L7 7AF

On Tuesday, 16 May 2017, 9:56, Geert Martin Ijewski <[email protected]> wrote:

Am 16.05.2017 um 02:01 schrieb John Bradley via Qemu-devel:

Quoted 3 lines

Hi,
The XML files in the base are not in the patch. They where net beans files. I can easily get it into 3 files, one large at 91KB but contains only new files and so is easy to read. Could be smaller but seems pointless.

I think what Alistar meant was something along the lines of:
patch/commit 1) add the remaining bcm2835 devices from Markus Armbruster's code to QEMU (btw: any reason why that hasn't been done? The USB stuff does seem nice to have)
-- with a more meaningful commit title
2) add utils/panelemu.c and the include
3) bcm2835 now uses the emupanel
and then your other commits e.g.
4) USB CDC Ethernet driver dropped packets
5) emupanel: fixed compilation errors on linux
6) emupanel: removed last blocking I/O

Along the way you also seem to fix indentation in other code a lot, that makes following the patches more confusing than they need to be. It's harder to gauge at a quick glance whether you changed something meaingul or not.

Maybe even send a RFC just detailing the protocol, because it's probably important to get that right from the start.

Geert

Quoted 173 lines

another which is about 19KB of quite simple changes to mostly make files.
Then one 15KB which quite straight forward when you look at it. Applying them in that order should allow step wise addition. I've uploaded them to a share if anyone wants to comment.

The 3 files are new.patch

|
|
|
|  |    |

    |

  |
|
|    |
new.patch
  Shared with Dropbox  |  |

  |

  |

  mod1.patch

|
|
|
|  |    |

    |

  |
|
|    |
mod1.patch
  Shared with Dropbox  |  |

  |

  |

and
  a_hw_gpio_bcm2835_gpio.c.patch

|
|
|
|  |    |

    |

  |
|
|    |
a_hw_gpio_bcm2835_gpio.c.patch
  Shared with Dropbox  |  |

  |

  |

John BradleyTel: 07896 839635Skype: flypie125 125B Grove StreetEdge Hill Liverpool L7 7AF

    On Tuesday, 16 May 2017, 0:20, Philippe Mathieu-Daudé <[email protected]> wrote:

  Hi John,

Quoted 2 lines

That is going to be very difficult as a lot of the changes are interlinked the vast majority of the patch is new files.

I rebased your branch on latest qemu/master here:

https://github.com/philmd/qemu/tree/flypie-GDummyPanel-rebased

It is much easier to follow now, the big XML files you added/removed also disappeared (gitk was crashing 'Out Of Memory' trying to look at your tree).

I hope it can help you to continue reordering in smaller patches.

Regards,

Phil.

Quoted 75 lines · Alistair Francis

Hey John,

Thanks for the patch!

Unfortunately this patch is too long to review, you need to split the patch up into shorter more readable patches. Otherwise it's too hard to people to understand what you are changing and why.

There are some details here:
http://wiki.qemu.org/Contribute/SubmitAPatch
<http://wiki.qemu.org/Contribute/SubmitAPatch>about how to split up patches. Each patch applied in order shouldn't break any compilation or runtime. Generally the flow is to add the logic in earlier patches and then connect it and switch it on in the later patches.

Try splitting up adding/editing each individual device and send that our first. That is generally the easiest to review/accept.

Thanks,

Alistair

Quoted 9 lines

---
.gitignore                          |  54 ++ hw/arm/Makefile.objs                |    2 +- hw/arm/bcm2835.c                    |  114 ++++ hw/arm/bcm2835_peripherals.c        |  104 ++++ hw/arm/bcm2836.c                    |    3 +- hw/arm/raspi.c                      |  77 ++- hw/gpio/bcm2835_gpio.c              |  333 ++++++----- hw/misc/Makefile.objs                |    2 +

Quoted 8 lines

hw/misc/bcm2835_mphi.c              |  163 ++++++ hw/misc/bcm2835_power.c              |  106 ++++ hw/timer/Makefile.objs              |    2 + hw/timer/bcm2835_st.c                |  202 +++++++ hw/timer/bcm2835_timer.c            |  224 +++++++ hw/usb/Makefile.objs                |    4 +- hw/usb/bcm2835_usb.c                |  604 +++++++++++++++++++ hw/usb/bcm2835_usb_regs.h            | 1061

++++++++++++++++++++++++++++++++++

Quoted 32 lines

hw/usb/dev-network.c                |    2 +- include/hw/arm/bcm2835.h            |  37 ++ include/hw/arm/bcm2835_peripherals.h |  10 +

include/hw/gpio/bcm2835_gpio.h      |    5 +
include/hw/intc/bcm2835_control.h    |  53 ++
include/hw/intc/bcm2836_control.h    |    2 +
include/hw/misc/bcm2835_mphi.h      |  28 +

include/hw/misc/bcm2835_power.h      |  22 + include/hw/timer/bcm2835_st.h        |  25 + include/hw/timer/bcm2835_timer.h    |  32 + include/hw/usb/bcm2835_usb.h        |  78 +++ include/qemu/PanelEmu.h              |  53 ++ util/Makefile.objs                  |    1 + util/PanelEmu.c                      |  293 ++++++++++

30 files changed, 3547 insertions(+), 149 deletions(-)

create mode 100644 hw/arm/bcm2835.c
create mode 100644 hw/misc/bcm2835_mphi.c create mode 100644 hw/misc/bcm2835_power.c create mode 100644 hw/timer/bcm2835_st.c create mode 100644 hw/timer/bcm2835_timer.c create mode 100644 hw/usb/bcm2835_usb.c create mode 100644 hw/usb/bcm2835_usb_regs.h create mode 100644 include/hw/arm/bcm2835.h create mode 100644 include/hw/intc/bcm2835_control.h create mode 100644 include/hw/misc/bcm2835_mphi.h create mode 100644 include/hw/misc/bcm2835_power.h create mode 100644 include/hw/timer/bcm2835_st.h create mode 100644 include/hw/timer/bcm2835_timer.h create mode 100644 include/hw/usb/bcm2835_usb.h create mode 100644 include/qemu/PanelEmu.h create mode 100644 util/PanelEmu.c