ia64/xen-unstable

changeset 19037:d400a51a2f46

x86, hvm: stdvga improvements

* enables linear framebuffer and VBE 3.0 extensions.
* add a number of new resolutions, up to 2560x1600, and including
* widescreen modes common to modern displays.
* Introduce configurable video ram size through the "videoram" config
* file option, shrinking default video ram used to 4 Megs (thus
* eliminating 4 wasted megs/VM that have been the case until now), but
* allowing users to specify up to 16 Megs of vram, to support the
* extreme high resolutions such as 2560x1600x32.

Signed-off-by: Trolle Selander <trolle.selander@eu.citrix.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Jan 14 10:51:58 2009 +0000 (2009-01-14)
parents 4f6a2bbdff3f
children cc542ebe4853
files tools/firmware/vgabios/vbe.c tools/firmware/vgabios/vbe.h tools/firmware/vgabios/vbetables-gen.c tools/firmware/vgabios/vgabios.c tools/libxc/xc_hvm_build.c tools/python/xen/xend/XendConfig.py tools/python/xen/xend/image.py tools/python/xen/xm/create.py
line diff
     1.1 --- a/tools/firmware/vgabios/vbe.c	Tue Jan 13 15:53:47 2009 +0000
     1.2 +++ b/tools/firmware/vgabios/vbe.c	Wed Jan 14 10:51:58 2009 +0000
     1.3 @@ -38,8 +38,6 @@
     1.4  #include "vbe.h"
     1.5  #include "vbetables.h"
     1.6  
     1.7 -#define VBE_TOTAL_VIDEO_MEMORY_DIV_64K (VBE_DISPI_TOTAL_VIDEO_MEMORY_MB*1024/64)
     1.8 -
     1.9  // The current OEM Software Revision of this VBE Bios
    1.10  #define VBE_OEM_SOFTWARE_REV 0x0002;
    1.11  
    1.12 @@ -821,7 +819,8 @@ Bit16u *AX;Bit16u ES;Bit16u DI;
    1.13          vbe_info_block.VideoModePtr_Off= DI + 34;
    1.14  
    1.15          // VBE Total Memory (in 64b blocks)
    1.16 -        vbe_info_block.TotalMemory = VBE_TOTAL_VIDEO_MEMORY_DIV_64K;
    1.17 +        outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_VIDEO_MEMORY_64K);
    1.18 +        vbe_info_block.TotalMemory = inw(VBE_DISPI_IOPORT_DATA);
    1.19  
    1.20          if (vbe2_info)
    1.21  	{
    1.22 @@ -846,7 +845,8 @@ Bit16u *AX;Bit16u ES;Bit16u DI;
    1.23          do
    1.24          {
    1.25                  if ((cur_info->info.XResolution <= dispi_get_max_xres()) &&
    1.26 -                    (cur_info->info.BitsPerPixel <= dispi_get_max_bpp())) {
    1.27 +                    (cur_info->info.BitsPerPixel <= dispi_get_max_bpp()) &&
    1.28 +                    (cur_info->info.XResolution * cur_info->info.XResolution * cur_info->info.BitsPerPixel <= vbe_info_block.TotalMemory << 19 )) {
    1.29  #ifdef DEBUG
    1.30                    printf("VBE found mode %x => %x\n", cur_info->mode,cur_mode);
    1.31  #endif
    1.32 @@ -855,7 +855,7 @@ Bit16u *AX;Bit16u ES;Bit16u DI;
    1.33                    cur_ptr+=2;
    1.34                  } else {
    1.35  #ifdef DEBUG
    1.36 -                  printf("VBE mode %x (xres=%x / bpp=%02x) not supported by display\n", cur_info->mode,cur_info->info.XResolution,cur_info->info.BitsPerPixel);
    1.37 +                  printf("VBE mode %x (xres=%x / bpp=%02x) not supported \n", cur_info->mode,cur_info->info.XResolution,cur_info->info.BitsPerPixel);
    1.38  #endif
    1.39                  }
    1.40                  cur_info++;
    1.41 @@ -913,7 +913,13 @@ Bit16u *AX;Bit16u CX; Bit16u ES;Bit16u D
    1.42                    info.WinFuncPtr = 0xC0000000UL;
    1.43                    *(Bit16u *)&(info.WinFuncPtr) = (Bit16u)(dispi_set_bank_farcall);
    1.44                  }
    1.45 -                
    1.46 +                outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_LFB_ADDRESS_H);
    1.47 +                info.PhysBasePtr = inw(VBE_DISPI_IOPORT_DATA);
    1.48 +                info.PhysBasePtr = info.PhysBasePtr << 16;
    1.49 +#if 0					
    1.50 +                outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_LFB_ADDRESS_L);
    1.51 +                info.PhysBasePtr |= inw(VBE_DISPI_IOPORT_DATA);
    1.52 +#endif 							
    1.53                  result = 0x4f;
    1.54          }
    1.55          else
     2.1 --- a/tools/firmware/vgabios/vbe.h	Tue Jan 13 15:53:47 2009 +0000
     2.2 +++ b/tools/firmware/vgabios/vbe.h	Wed Jan 14 10:51:58 2009 +0000
     2.3 @@ -275,39 +275,41 @@ typedef struct ModeInfoListItem
     2.4  //        like 0xE0000000
     2.5  
     2.6  
     2.7 -  #define VBE_DISPI_BANK_ADDRESS          0xA0000
     2.8 -  #define VBE_DISPI_BANK_SIZE_KB          64
     2.9 +  #define VBE_DISPI_BANK_ADDRESS           0xA0000
    2.10 +  #define VBE_DISPI_BANK_SIZE_KB           64
    2.11    
    2.12 -  #define VBE_DISPI_MAX_XRES              1024
    2.13 -  #define VBE_DISPI_MAX_YRES              768
    2.14 +  #define VBE_DISPI_MAX_XRES               2560
    2.15 +  #define VBE_DISPI_MAX_YRES               1600
    2.16    
    2.17 -  #define VBE_DISPI_IOPORT_INDEX          0x01CE
    2.18 -  #define VBE_DISPI_IOPORT_DATA           0x01CF
    2.19 +  #define VBE_DISPI_IOPORT_INDEX           0x01CE
    2.20 +  #define VBE_DISPI_IOPORT_DATA            0x01CF
    2.21    
    2.22 -  #define VBE_DISPI_INDEX_ID              0x0
    2.23 -  #define VBE_DISPI_INDEX_XRES            0x1
    2.24 -  #define VBE_DISPI_INDEX_YRES            0x2
    2.25 -  #define VBE_DISPI_INDEX_BPP             0x3
    2.26 -  #define VBE_DISPI_INDEX_ENABLE          0x4
    2.27 -  #define VBE_DISPI_INDEX_BANK            0x5
    2.28 -  #define VBE_DISPI_INDEX_VIRT_WIDTH      0x6
    2.29 -  #define VBE_DISPI_INDEX_VIRT_HEIGHT     0x7
    2.30 -  #define VBE_DISPI_INDEX_X_OFFSET        0x8
    2.31 -  #define VBE_DISPI_INDEX_Y_OFFSET        0x9
    2.32 -      
    2.33 -  #define VBE_DISPI_ID0                   0xB0C0
    2.34 -  #define VBE_DISPI_ID1                   0xB0C1
    2.35 -  #define VBE_DISPI_ID2                   0xB0C2
    2.36 -  #define VBE_DISPI_ID3                   0xB0C3
    2.37 -  #define VBE_DISPI_ID4                   0xB0C4
    2.38 -  
    2.39 -  #define VBE_DISPI_DISABLED              0x00
    2.40 -  #define VBE_DISPI_ENABLED               0x01
    2.41 -  #define VBE_DISPI_GETCAPS               0x02
    2.42 -  #define VBE_DISPI_8BIT_DAC              0x20
    2.43 -  #define VBE_DISPI_LFB_ENABLED           0x40
    2.44 -  #define VBE_DISPI_NOCLEARMEM            0x80
    2.45 -  
    2.46 -  #define VBE_DISPI_LFB_PHYSICAL_ADDRESS  0xE0000000
    2.47 +  #define VBE_DISPI_INDEX_ID               0x0
    2.48 +  #define VBE_DISPI_INDEX_XRES             0x1
    2.49 +  #define VBE_DISPI_INDEX_YRES             0x2
    2.50 +  #define VBE_DISPI_INDEX_BPP              0x3
    2.51 +  #define VBE_DISPI_INDEX_ENABLE           0x4
    2.52 +  #define VBE_DISPI_INDEX_BANK             0x5
    2.53 +  #define VBE_DISPI_INDEX_VIRT_WIDTH       0x6
    2.54 +  #define VBE_DISPI_INDEX_VIRT_HEIGHT      0x7
    2.55 +  #define VBE_DISPI_INDEX_X_OFFSET         0x8
    2.56 +  #define VBE_DISPI_INDEX_Y_OFFSET         0x9
    2.57 +  #define VBE_DISPI_INDEX_VIDEO_MEMORY_64K 0xa
    2.58 +  #define VBE_DISPI_INDEX_LFB_ADDRESS_H    0xb
    2.59 +  #define VBE_DISPI_INDEX_LFB_ADDRESS_L    0xc
    2.60 +
    2.61 +  #define VBE_DISPI_LFB_PHYSICAL_ADDRESS   0xE0000000
    2.62 +  #define VBE_DISPI_ID0                    0xB0C0
    2.63 +  #define VBE_DISPI_ID1                    0xB0C1
    2.64 +  #define VBE_DISPI_ID2                    0xB0C2
    2.65 +  #define VBE_DISPI_ID3                    0xB0C3
    2.66 +  #define VBE_DISPI_ID4                    0xB0C4
    2.67 +
    2.68 +  #define VBE_DISPI_DISABLED               0x00
    2.69 +  #define VBE_DISPI_ENABLED                0x01
    2.70 +  #define VBE_DISPI_GETCAPS                0x02
    2.71 +  #define VBE_DISPI_8BIT_DAC               0x20
    2.72 +  #define VBE_DISPI_LFB_ENABLED            0x40
    2.73 +  #define VBE_DISPI_NOCLEARMEM             0x80
    2.74  
    2.75  #endif
     3.1 --- a/tools/firmware/vgabios/vbetables-gen.c	Tue Jan 13 15:53:47 2009 +0000
     3.2 +++ b/tools/firmware/vgabios/vbetables-gen.c	Wed Jan 14 10:51:58 2009 +0000
     3.3 @@ -2,7 +2,7 @@
     3.4  #include <stdlib.h>
     3.5  #include <stdio.h>
     3.6  
     3.7 -#define VBE_DISPI_TOTAL_VIDEO_MEMORY_MB 8
     3.8 +#define VBE_DISPI_TOTAL_VIDEO_MEMORY_MB 16
     3.9  
    3.10  typedef struct {
    3.11      int width;
    3.12 @@ -42,19 +42,40 @@ ModeInfo modes[] = {
    3.13  { 1600, 1200, 24                      , 0x11F},
    3.14  
    3.15        /* BOCHS/PLE, 86 'own' mode numbers */
    3.16 -{ 320, 200, 32                        , 0x140},
    3.17 -{ 640, 400, 32                        , 0x141},
    3.18 -{ 640, 480, 32                        , 0x142},
    3.19 -{ 800, 600, 32                        , 0x143},
    3.20 -{ 1024, 768, 32                       , 0x144},
    3.21 -{ 1280, 1024, 32                      , 0x145},
    3.22 -{ 320, 200, 8                           , 0x146},
    3.23 -{ 1600, 1200, 32                      , 0x147},
    3.24 -{ 1152, 864, 8                      , 0x148},
    3.25 +{ 320, 200, 32                       , 0x140},
    3.26 +{ 640, 400, 32                       , 0x141},
    3.27 +{ 640, 480, 32                       , 0x142},
    3.28 +{ 800, 600, 32                       , 0x143},
    3.29 +{ 1024, 768, 32                      , 0x144},
    3.30 +{ 1280, 1024, 32                     , 0x145},
    3.31 +{ 320, 200, 8                        , 0x146},
    3.32 +{ 1600, 1200, 32                     , 0x147},
    3.33 +{ 1152, 864, 8                       , 0x148},
    3.34  { 1152, 864, 15                      , 0x149},
    3.35  { 1152, 864, 16                      , 0x14a},
    3.36  { 1152, 864, 24                      , 0x14b},
    3.37  { 1152, 864, 32                      , 0x14c},
    3.38 +{ 1280, 800, 16                      , 0x178},
    3.39 +{ 1280, 800, 24                      , 0x179},
    3.40 +{ 1280, 800, 32                      , 0x17a},
    3.41 +{ 1280, 960, 16                      , 0x17b},
    3.42 +{ 1280, 960, 24                      , 0x17c},
    3.43 +{ 1280, 960, 32                      , 0x17d},
    3.44 +{ 1440, 900, 16                      , 0x17e},
    3.45 +{ 1440, 900, 24                      , 0x17f},
    3.46 +{ 1440, 900, 32                      , 0x180},
    3.47 +{ 1400, 1050, 16                     , 0x181},
    3.48 +{ 1400, 1050, 24                     , 0x182},
    3.49 +{ 1400, 1050, 32                     , 0x183},
    3.50 +{ 1680, 1050, 16                     , 0x184},
    3.51 +{ 1680, 1050, 24                     , 0x185},
    3.52 +{ 1680, 1050, 32                     , 0x186},
    3.53 +{ 1920, 1200, 16                     , 0x187},
    3.54 +{ 1920, 1200, 24                     , 0x188},
    3.55 +{ 1920, 1200, 32                     , 0x189},
    3.56 +{ 2560, 1600, 16                     , 0x18a},
    3.57 +{ 2560, 1600, 24                     , 0x18b},
    3.58 +{ 2560, 1600, 32                     , 0x18c},
    3.59  { 0, },
    3.60  };
    3.61  
     4.1 --- a/tools/firmware/vgabios/vgabios.c	Tue Jan 13 15:53:47 2009 +0000
     4.2 +++ b/tools/firmware/vgabios/vgabios.c	Wed Jan 14 10:51:58 2009 +0000
     4.3 @@ -3811,9 +3811,9 @@ void printf(s)
     4.4          for (i=0; i<format_width; i++) {
     4.5            nibble = (arg >> (4 * digit)) & 0x000f;
     4.6            if (nibble <= 9)
     4.7 -            outb(0x0500, nibble + '0');
     4.8 +            outb(0xe9, nibble + '0');
     4.9            else
    4.10 -            outb(0x0500, (nibble - 10) + 'A');
    4.11 +            outb(0xe9, (nibble - 10) + 'A');
    4.12            digit--;
    4.13            }
    4.14          in_format = 0;
    4.15 @@ -3823,7 +3823,7 @@ void printf(s)
    4.16        //  }
    4.17        }
    4.18      else {
    4.19 -      outb(0x0500, c);
    4.20 +      outb(0xe9, c);
    4.21        }
    4.22      s ++;
    4.23      }
     5.1 --- a/tools/libxc/xc_hvm_build.c	Tue Jan 13 15:53:47 2009 +0000
     5.2 +++ b/tools/libxc/xc_hvm_build.c	Wed Jan 14 10:51:58 2009 +0000
     5.3 @@ -28,7 +28,7 @@
     5.4  #define SPECIALPAGE_IDENT_PT 3
     5.5  #define SPECIALPAGE_SHINFO   4
     5.6  #define NR_SPECIAL_PAGES     5
     5.7 -#define special_pfn(x) (0x100000u - NR_SPECIAL_PAGES + (x))
     5.8 +#define special_pfn(x) (0xff000u - NR_SPECIAL_PAGES + (x))
     5.9  
    5.10  static void build_hvm_info(void *hvm_info_page, uint64_t mem_size)
    5.11  {
     6.1 --- a/tools/python/xen/xend/XendConfig.py	Tue Jan 13 15:53:47 2009 +0000
     6.2 +++ b/tools/python/xen/xend/XendConfig.py	Wed Jan 14 10:51:58 2009 +0000
     6.3 @@ -149,6 +149,7 @@ XENAPI_PLATFORM_CFG_TYPES = {
     6.4      'opengl': int,
     6.5      'soundhw': str,
     6.6      'stdvga': int,
     6.7 +    'videoram': int,
     6.8      'usb': int,
     6.9      'usbdevice': str,
    6.10      'hpet': int,
     7.1 --- a/tools/python/xen/xend/image.py	Tue Jan 13 15:53:47 2009 +0000
     7.2 +++ b/tools/python/xen/xend/image.py	Wed Jan 14 10:51:58 2009 +0000
     7.3 @@ -265,6 +265,10 @@ class ImageHandler:
     7.4              ret.append('-nographic')
     7.5              return ret
     7.6  
     7.7 +        vram = str(vmConfig['platform'].get('videoram',4))
     7.8 +        ret.append('-videoram')
     7.9 +        ret.append(vram)
    7.10 +
    7.11          vnc_config = {}
    7.12          has_vnc = int(vmConfig['platform'].get('vnc', 0)) != 0
    7.13          has_sdl = int(vmConfig['platform'].get('sdl', 0)) != 0
    7.14 @@ -833,6 +837,7 @@ class IA64_HVM_ImageHandler(HVMImageHand
    7.15      def configure(self, vmConfig):
    7.16          HVMImageHandler.configure(self, vmConfig)
    7.17          self.vhpt = int(vmConfig['platform'].get('vhpt',  0))
    7.18 +        self.vramsize = int(vmConfig['platform'].get('videoram',4)) * 1024
    7.19  
    7.20      def buildDomain(self):
    7.21          xc.nvram_init(self.vm.getName(), self.vm.getDomid())
    7.22 @@ -847,8 +852,8 @@ class IA64_HVM_ImageHandler(HVMImageHand
    7.23          # buffer io page, buffer pio page and memmap info page
    7.24          extra_pages = 1024 + 5
    7.25          mem_kb += extra_pages * page_kb
    7.26 -        # Add 8 MiB overhead for QEMU's video RAM.
    7.27 -        return mem_kb + 8192
    7.28 +        mem_kb += self.vramsize
    7.29 +        return mem_kb
    7.30  
    7.31      def getRequiredInitialReservation(self):
    7.32          return self.vm.getMemoryTarget()
    7.33 @@ -882,6 +887,7 @@ class X86_HVM_ImageHandler(HVMImageHandl
    7.34      def configure(self, vmConfig):
    7.35          HVMImageHandler.configure(self, vmConfig)
    7.36          self.pae = int(vmConfig['platform'].get('pae',  0))
    7.37 +        self.vramsize = int(vmConfig['platform'].get('videoram',4)) * 1024
    7.38  
    7.39      def buildDomain(self):
    7.40          xc.hvm_set_param(self.vm.getDomid(), HVM_PARAM_PAE_ENABLED, self.pae)
    7.41 @@ -890,8 +896,7 @@ class X86_HVM_ImageHandler(HVMImageHandl
    7.42          return rc
    7.43  
    7.44      def getRequiredAvailableMemory(self, mem_kb):
    7.45 -        # Add 8 MiB overhead for QEMU's video RAM.
    7.46 -        return mem_kb + 8192
    7.47 +        return mem_kb + self.vramsize
    7.48  
    7.49      def getRequiredInitialReservation(self):
    7.50          return self.vm.getMemoryTarget()
     8.1 --- a/tools/python/xen/xm/create.py	Tue Jan 13 15:53:47 2009 +0000
     8.2 +++ b/tools/python/xen/xm/create.py	Wed Jan 14 10:51:58 2009 +0000
     8.3 @@ -526,9 +526,9 @@ gopts.var('vncunused', val='',
     8.4            use="""Try to find an unused port for the VNC server.
     8.5            Only valid when vnc=1.""")
     8.6  
     8.7 -gopts.var('videoram', val='',
     8.8 -          fn=set_value, default=None,
     8.9 -          use="""Maximum amount of videoram PV guest can allocate
    8.10 +gopts.var('videoram', val='MEMORY',
    8.11 +          fn=set_int, default=4,
    8.12 +          use="""Maximum amount of videoram a guest can allocate
    8.13            for frame buffer.""")
    8.14  
    8.15  gopts.var('sdl', val='',
    8.16 @@ -884,7 +884,7 @@ def configure_hvm(config_image, vals):
    8.17      """Create the config for HVM devices.
    8.18      """
    8.19      args = [ 'device_model', 'pae', 'vcpus', 'boot', 'fda', 'fdb', 'timer_mode',
    8.20 -             'localtime', 'serial', 'stdvga', 'isa', 'nographic', 'soundhw',
    8.21 +             'localtime', 'serial', 'stdvga', 'videoram', 'isa', 'nographic', 'soundhw',
    8.22               'vnc', 'vncdisplay', 'vncunused', 'vncconsole', 'vnclisten',
    8.23               'sdl', 'display', 'xauthority', 'rtc_timeoffset', 'monitor',
    8.24               'acpi', 'apic', 'usb', 'usbdevice', 'keymap', 'pci', 'hpet',