Diff for /qemu/qemu-char.c between versions 1.1.1.1 and 1.1.1.2

version 1.1.1.1, 2018/04/24 16:50:33 version 1.1.1.2, 2018/04/24 16:56:27
Line 101 Line 101
 /***********************************************************/  /***********************************************************/
 /* character device */  /* character device */
   
   static TAILQ_HEAD(CharDriverStateHead, CharDriverState) chardevs =
       TAILQ_HEAD_INITIALIZER(chardevs);
   static int initial_reset_issued;
   
 static void qemu_chr_event(CharDriverState *s, int event)  static void qemu_chr_event(CharDriverState *s, int event)
 {  {
     if (!s->chr_event)      if (!s->chr_event)
Line 118  static void qemu_chr_reset_bh(void *opaq Line 122  static void qemu_chr_reset_bh(void *opaq
   
 void qemu_chr_reset(CharDriverState *s)  void qemu_chr_reset(CharDriverState *s)
 {  {
     if (s->bh == NULL) {      if (s->bh == NULL && initial_reset_issued) {
         s->bh = qemu_bh_new(qemu_chr_reset_bh, s);          s->bh = qemu_bh_new(qemu_chr_reset_bh, s);
         qemu_bh_schedule(s->bh);          qemu_bh_schedule(s->bh);
     }      }
 }  }
   
   void qemu_chr_initial_reset(void)
   {
       CharDriverState *chr;
   
       initial_reset_issued = 1;
   
       TAILQ_FOREACH(chr, &chardevs, next) {
           qemu_chr_reset(chr);
       }
   }
   
 int qemu_chr_write(CharDriverState *s, const uint8_t *buf, int len)  int qemu_chr_write(CharDriverState *s, const uint8_t *buf, int len)
 {  {
     return s->chr_write(s, buf, len);      return s->chr_write(s, buf, len);
Line 210  typedef struct { Line 225  typedef struct {
     IOEventHandler *chr_event[MAX_MUX];      IOEventHandler *chr_event[MAX_MUX];
     void *ext_opaque[MAX_MUX];      void *ext_opaque[MAX_MUX];
     CharDriverState *drv;      CharDriverState *drv;
     unsigned char buffer[MUX_BUFFER_SIZE];  
     int prod;  
     int cons;  
     int mux_cnt;      int mux_cnt;
     int term_got_escape;      int term_got_escape;
     int max_size;      int max_size;
       /* Intermediate input buffer allows to catch escape sequences even if the
          currently active device is not accepting any input - but only until it
          is full as well. */
       unsigned char buffer[MAX_MUX][MUX_BUFFER_SIZE];
       int prod[MAX_MUX];
       int cons[MAX_MUX];
 } MuxDriver;  } MuxDriver;
   
   
Line 345  static void mux_chr_accept_input(CharDri Line 363  static void mux_chr_accept_input(CharDri
     int m = chr->focus;      int m = chr->focus;
     MuxDriver *d = chr->opaque;      MuxDriver *d = chr->opaque;
   
     while (d->prod != d->cons &&      while (d->prod[m] != d->cons[m] &&
            d->chr_can_read[m] &&             d->chr_can_read[m] &&
            d->chr_can_read[m](d->ext_opaque[m])) {             d->chr_can_read[m](d->ext_opaque[m])) {
         d->chr_read[m](d->ext_opaque[m],          d->chr_read[m](d->ext_opaque[m],
                        &d->buffer[d->cons++ & MUX_BUFFER_MASK], 1);                         &d->buffer[m][d->cons[m]++ & MUX_BUFFER_MASK], 1);
     }      }
 }  }
   
Line 357  static int mux_chr_can_read(void *opaque Line 375  static int mux_chr_can_read(void *opaque
 {  {
     CharDriverState *chr = opaque;      CharDriverState *chr = opaque;
     MuxDriver *d = chr->opaque;      MuxDriver *d = chr->opaque;
       int m = chr->focus;
   
     if ((d->prod - d->cons) < MUX_BUFFER_SIZE)      if ((d->prod[m] - d->cons[m]) < MUX_BUFFER_SIZE)
         return 1;          return 1;
     if (d->chr_can_read[chr->focus])      if (d->chr_can_read[m])
         return d->chr_can_read[chr->focus](d->ext_opaque[chr->focus]);          return d->chr_can_read[m](d->ext_opaque[m]);
     return 0;      return 0;
 }  }
   
Line 376  static void mux_chr_read(void *opaque, c Line 395  static void mux_chr_read(void *opaque, c
   
     for(i = 0; i < size; i++)      for(i = 0; i < size; i++)
         if (mux_proc_byte(chr, d, buf[i])) {          if (mux_proc_byte(chr, d, buf[i])) {
             if (d->prod == d->cons &&              if (d->prod[m] == d->cons[m] &&
                 d->chr_can_read[m] &&                  d->chr_can_read[m] &&
                 d->chr_can_read[m](d->ext_opaque[m]))                  d->chr_can_read[m](d->ext_opaque[m]))
                 d->chr_read[m](d->ext_opaque[m], &buf[i], 1);                  d->chr_read[m](d->ext_opaque[m], &buf[i], 1);
             else              else
                 d->buffer[d->prod++ & MUX_BUFFER_MASK] = buf[i];                  d->buffer[m][d->prod[m]++ & MUX_BUFFER_MASK] = buf[i];
         }          }
 }  }
   
Line 2076  static CharDriverState *qemu_chr_open_tc Line 2095  static CharDriverState *qemu_chr_open_tc
     return NULL;      return NULL;
 }  }
   
 static TAILQ_HEAD(CharDriverStateHead, CharDriverState) chardevs  
 = TAILQ_HEAD_INITIALIZER(chardevs);  
   
 CharDriverState *qemu_chr_open(const char *label, const char *filename, void (*init)(struct CharDriverState *s))  CharDriverState *qemu_chr_open(const char *label, const char *filename, void (*init)(struct CharDriverState *s))
 {  {
     const char *p;      const char *p;

Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.2


unix.superglobalmegacorp.com