On Tue, Sep 26, 2017 at 4:04 AM, Mihail Abakumov <mikhail.abaku...@ispras.ru> wrote: > Added chardev for listening to windbg. Target device is a parameter in the > '-windbg' option. > > Signed-off-by: Mihail Abakumov <mikhail.abaku...@ispras.ru> > Signed-off-by: Pavel Dovgalyuk <dovga...@ispras.ru> > Signed-off-by: Dmitriy Koltunov <koltu...@ispras.ru>
Acked-by: Alistair Francis <alistair.fran...@xilinx.com> Thanks, Alistair > --- > windbgstub.c | 26 ++++++++++++++++++++++++++ > 1 file changed, 26 insertions(+) > > diff --git a/windbgstub.c b/windbgstub.c > index 60a380c213..378d1b911f 100755 > --- a/windbgstub.c > +++ b/windbgstub.c > @@ -10,6 +10,7 @@ > */ > > #include "qemu/osdep.h" > +#include "qapi/error.h" > #include "chardev/char.h" > #include "chardev/char-fe.h" > #include "exec/windbgstub.h" > @@ -18,12 +19,26 @@ > typedef struct WindbgState { > bool is_loaded; > > + CharBackend chr; > + > uint32_t ctrl_packet_id; > uint32_t data_packet_id; > } WindbgState; > > static WindbgState *windbg_state; > > +static int windbg_chr_can_receive(void *opaque) > +{ > + return PACKET_MAX_SIZE; > +} > + > +static void windbg_chr_receive(void *opaque, const uint8_t *buf, int size) > +{ > + if (windbg_state->is_loaded) { > + /* T0D0: parse data */ > + } > +} > + > static void windbg_exit(void) > { > g_free(windbg_state); > @@ -31,6 +46,8 @@ static void windbg_exit(void) > > int windbg_server_start(const char *device) > { > + Chardev *chr = NULL; > + > if (windbg_state) { > WINDBG_ERROR("Multiple instances are not supported"); > exit(1); > @@ -40,6 +57,15 @@ int windbg_server_start(const char *device) > windbg_state->ctrl_packet_id = RESET_PACKET_ID; > windbg_state->data_packet_id = INITIAL_PACKET_ID; > > + chr = qemu_chr_new_noreplay(WINDBG, device); > + if (!chr) { > + return -1; > + } > + > + qemu_chr_fe_init(&windbg_state->chr, chr, &error_abort); > + qemu_chr_fe_set_handlers(&windbg_state->chr, windbg_chr_can_receive, > + windbg_chr_receive, NULL, NULL, NULL, NULL, > true); > + > atexit(windbg_exit); > return 0; > } > >