Diff for /qemu/console.c between versions 1.1.1.8 and 1.1.1.9

version 1.1.1.8, 2018/04/24 17:34:10 version 1.1.1.9, 2018/04/24 18:23:39
Line 154  struct TextConsole { Line 154  struct TextConsole {
     QEMUTimer *kbd_timer;      QEMUTimer *kbd_timer;
 };  };
   
   static DisplayState *display_state;
 static TextConsole *active_console;  static TextConsole *active_console;
 static TextConsole *consoles[MAX_CONSOLES];  static TextConsole *consoles[MAX_CONSOLES];
 static int nb_consoles = 0;  static int nb_consoles = 0;
Line 166  void vga_hw_update(void) Line 167  void vga_hw_update(void)
   
 void vga_hw_invalidate(void)  void vga_hw_invalidate(void)
 {  {
     if (active_console->hw_invalidate)      if (active_console && active_console->hw_invalidate)
         active_console->hw_invalidate(active_console->hw);          active_console->hw_invalidate(active_console->hw);
 }  }
   
Line 828  static void console_clear_xy(TextConsole Line 829  static void console_clear_xy(TextConsole
     TextCell *c = &s->cells[y1 * s->width + x];      TextCell *c = &s->cells[y1 * s->width + x];
     c->ch = ' ';      c->ch = ' ';
     c->t_attrib = s->t_attrib_default;      c->t_attrib = s->t_attrib_default;
     c++;  
     update_xy(s, x, y);      update_xy(s, x, y);
 }  }
   
Line 1265  static TextConsole *new_console(DisplayS Line 1265  static TextConsole *new_console(DisplayS
     return s;      return s;
 }  }
   
   static DisplaySurface* defaultallocator_create_displaysurface(int width, int height)
   {
       DisplaySurface *surface = (DisplaySurface*) qemu_mallocz(sizeof(DisplaySurface));
   
       surface->width = width;
       surface->height = height;
       surface->linesize = width * 4;
       surface->pf = qemu_default_pixelformat(32);
   #ifdef HOST_WORDS_BIGENDIAN
       surface->flags = QEMU_ALLOCATED_FLAG | QEMU_BIG_ENDIAN_FLAG;
   #else
       surface->flags = QEMU_ALLOCATED_FLAG;
   #endif
       surface->data = (uint8_t*) qemu_mallocz(surface->linesize * surface->height);
   
       return surface;
   }
   
   static DisplaySurface* defaultallocator_resize_displaysurface(DisplaySurface *surface,
                                             int width, int height)
   {
       surface->width = width;
       surface->height = height;
       surface->linesize = width * 4;
       surface->pf = qemu_default_pixelformat(32);
       if (surface->flags & QEMU_ALLOCATED_FLAG)
           surface->data = (uint8_t*) qemu_realloc(surface->data, surface->linesize * surface->height);
       else
           surface->data = (uint8_t*) qemu_malloc(surface->linesize * surface->height);
   #ifdef HOST_WORDS_BIGENDIAN
       surface->flags = QEMU_ALLOCATED_FLAG | QEMU_BIG_ENDIAN_FLAG;
   #else
       surface->flags = QEMU_ALLOCATED_FLAG;
   #endif
   
       return surface;
   }
   
   DisplaySurface* qemu_create_displaysurface_from(int width, int height, int bpp,
                                                 int linesize, uint8_t *data)
   {
       DisplaySurface *surface = (DisplaySurface*) qemu_mallocz(sizeof(DisplaySurface));
   
       surface->width = width;
       surface->height = height;
       surface->linesize = linesize;
       surface->pf = qemu_default_pixelformat(bpp);
   #ifdef HOST_WORDS_BIGENDIAN
       surface->flags = QEMU_BIG_ENDIAN_FLAG;
   #endif
       surface->data = data;
   
       return surface;
   }
   
   static void defaultallocator_free_displaysurface(DisplaySurface *surface)
   {
       if (surface == NULL)
           return;
       if (surface->flags & QEMU_ALLOCATED_FLAG)
           qemu_free(surface->data);
       qemu_free(surface);
   }
   
   static struct DisplayAllocator default_allocator = {
       defaultallocator_create_displaysurface,
       defaultallocator_resize_displaysurface,
       defaultallocator_free_displaysurface
   };
   
   static void dumb_display_init(void)
   {
       DisplayState *ds = qemu_mallocz(sizeof(DisplayState));
       ds->allocator = &default_allocator;
       ds->surface = qemu_create_displaysurface(ds, 640, 480);
       register_displaystate(ds);
   }
   
   /***********************************************************/
   /* register display */
   
   void register_displaystate(DisplayState *ds)
   {
       DisplayState **s;
       s = &display_state;
       while (*s != NULL)
           s = &(*s)->next;
       ds->next = NULL;
       *s = ds;
   }
   
   DisplayState *get_displaystate(void)
   {
       if (!display_state) {
           dumb_display_init ();
       }
       return display_state;
   }
   
   DisplayAllocator *register_displayallocator(DisplayState *ds, DisplayAllocator *da)
   {
       if(ds->allocator ==  &default_allocator) {
           DisplaySurface *surf;
           surf = da->create_displaysurface(ds_get_width(ds), ds_get_height(ds));
           defaultallocator_free_displaysurface(ds->surface);
           ds->surface = surf;
           ds->allocator = da;
       }
       return ds->allocator;
   }
   
 DisplayState *graphic_console_init(vga_hw_update_ptr update,  DisplayState *graphic_console_init(vga_hw_update_ptr update,
                                    vga_hw_invalidate_ptr invalidate,                                     vga_hw_invalidate_ptr invalidate,
                                    vga_hw_screen_dump_ptr screen_dump,                                     vga_hw_screen_dump_ptr screen_dump,
Line 1510  PixelFormat qemu_default_pixelformat(int Line 1621  PixelFormat qemu_default_pixelformat(int
     pf.depth = bpp == 32 ? 24 : bpp;      pf.depth = bpp == 32 ? 24 : bpp;
   
     switch (bpp) {      switch (bpp) {
           case 15:
               pf.bits_per_pixel = 16;
               pf.bytes_per_pixel = 2;
               pf.rmask = 0x00007c00;
               pf.gmask = 0x000003E0;
               pf.bmask = 0x0000001F;
               pf.rmax = 31;
               pf.gmax = 31;
               pf.bmax = 31;
               pf.rshift = 10;
               pf.gshift = 5;
               pf.bshift = 0;
               pf.rbits = 5;
               pf.gbits = 5;
               pf.bbits = 5;
               break;
         case 16:          case 16:
             pf.rmask = 0x0000F800;              pf.rmask = 0x0000F800;
             pf.gmask = 0x000007E0;              pf.gmask = 0x000007E0;
Line 1559  PixelFormat qemu_default_pixelformat(int Line 1686  PixelFormat qemu_default_pixelformat(int
     }      }
     return pf;      return pf;
 }  }
   
 DisplaySurface* defaultallocator_create_displaysurface(int width, int height)  
 {  
     DisplaySurface *surface = (DisplaySurface*) qemu_mallocz(sizeof(DisplaySurface));  
   
     surface->width = width;  
     surface->height = height;  
     surface->linesize = width * 4;  
     surface->pf = qemu_default_pixelformat(32);  
 #ifdef HOST_WORDS_BIGENDIAN  
     surface->flags = QEMU_ALLOCATED_FLAG | QEMU_BIG_ENDIAN_FLAG;  
 #else  
     surface->flags = QEMU_ALLOCATED_FLAG;  
 #endif  
     surface->data = (uint8_t*) qemu_mallocz(surface->linesize * surface->height);  
   
     return surface;  
 }  
   
 DisplaySurface* defaultallocator_resize_displaysurface(DisplaySurface *surface,  
                                           int width, int height)  
 {  
     surface->width = width;  
     surface->height = height;  
     surface->linesize = width * 4;  
     surface->pf = qemu_default_pixelformat(32);  
     if (surface->flags & QEMU_ALLOCATED_FLAG)  
         surface->data = (uint8_t*) qemu_realloc(surface->data, surface->linesize * surface->height);  
     else  
         surface->data = (uint8_t*) qemu_malloc(surface->linesize * surface->height);  
 #ifdef HOST_WORDS_BIGENDIAN  
     surface->flags = QEMU_ALLOCATED_FLAG | QEMU_BIG_ENDIAN_FLAG;  
 #else  
     surface->flags = QEMU_ALLOCATED_FLAG;  
 #endif  
   
     return surface;  
 }  
   
 DisplaySurface* qemu_create_displaysurface_from(int width, int height, int bpp,  
                                               int linesize, uint8_t *data)  
 {  
     DisplaySurface *surface = (DisplaySurface*) qemu_mallocz(sizeof(DisplaySurface));  
   
     surface->width = width;  
     surface->height = height;  
     surface->linesize = linesize;  
     surface->pf = qemu_default_pixelformat(bpp);  
 #ifdef HOST_WORDS_BIGENDIAN  
     surface->flags = QEMU_BIG_ENDIAN_FLAG;  
 #endif  
     surface->data = data;  
   
     return surface;  
 }  
   
 void defaultallocator_free_displaysurface(DisplaySurface *surface)  
 {  
     if (surface == NULL)  
         return;  
     if (surface->flags & QEMU_ALLOCATED_FLAG)  
         qemu_free(surface->data);  
     qemu_free(surface);  
 }  

Removed from v.1.1.1.8  
changed lines
  Added in v.1.1.1.9


unix.superglobalmegacorp.com