qemu-arm
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-arm] [Qemu-devel] Changes to Broadcom(BCM) files and Raspberry


From: John Bradley
Subject: Re: [Qemu-arm] [Qemu-devel] Changes to Broadcom(BCM) files and Raspberry Pi files. Addition of PanelEmu
Date: Tue, 16 May 2017 13:51:36 +0000 (UTC)

"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 Bradley
Tel: 07896 839635
Skype: flypie125
125B Grove Street
Edge Hill
Liverpool L7 7AF


On Tuesday, 16 May 2017, 9:56, Geert Martin Ijewski <address@hidden> wrote:


Am 14.05.2017 um 02:42 schrieb John Bradley via Qemu-devel:
>>From 7f74f048f135d9c9c230a9e90f72451c841c6d35 Mon Sep 17 00:00:00 2001
> From: John Bradley <address@hidden>
> 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
>
> Signed-off-by: John Bradley <address@hidden>
> ---
> [ ... snip ... ]
> diff --git a/util/PanelEmu.c b/util/PanelEmu.c
> new file mode 100644
> index 0000000000..59c87d2747
> --- /dev/null
> +++ b/util/PanelEmu.c
> @@ -0,0 +1,293 @@
> +/*
> + * Emulation for Rasp PI GPIO via Server connected to via Socket
> + *
> + */
> +#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
> +#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;
> +
> +#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;
> [ ... snip ... ]
> +/* 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]