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

Re: [Xen-ia64-devel] [PATCH][GFW] allocate xen vram area and tell xen pci chip.



On Wed, Sep 10, 2008 at 12:17:46PM +0200, tgingold@xxxxxxx wrote:
> Quoting Isaku Yamahata <yamahata@xxxxxxxxxxxxx>:
> 
> > allocate xen vram area and tell xen pci chip.
> > This is GFW counter part of xen-unstable 18383:dade7f0bdc8d.
> 
> Hi Isaku,
> 
> this looks to be slightly over-complex.  Why not programming the VGA
> inside VgaInit ?

Because ioemu requires that tells xen chip before starting programming
the VGA. After initializing VGA, it's too late to tell ioemu
address of memory for vram.

I had looked for better way to defer its initialization, but I couldn't 
find it. So I resorted to call it directly from BdsPlatform.c


> BTW, you don't need to look for the PciIo protocol.  Just use one of the
> PciIoLib.

Okay. I'll look into it.

> 
> Tristan.
> 
> >
> > Signed-off-by: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>
> >
> > diff -r 830ed5449dd4
> > edk2-sparse/EdkQemuPkg/Chipset/PcCompatible/VgaInit/Dxe/VgaInit.c
> > --- a/edk2-sparse/EdkQemuPkg/Chipset/PcCompatible/VgaInit/Dxe/VgaInit.c     
> > Wed
> > May 14 11:22:58 2008 +0900
> > +++ b/edk2-sparse/EdkQemuPkg/Chipset/PcCompatible/VgaInit/Dxe/VgaInit.c     
> > Wed
> > Sep 10 17:32:02 2008 +0900
> > @@ -34,7 +34,7 @@
> >     Digital Equipment Corporation
> >  */
> >
> > -#include <VgaBios.h>
> > +#include "VgaBios.h"
> >
> >  extern const unsigned char console_font[];
> >  static const unsigned int palette[] = {
> > diff -r 830ed5449dd4 edk2-sparse/EdkXenPkg/Dxe/Bds/Bds.msa
> > --- a/edk2-sparse/EdkXenPkg/Dxe/Bds/Bds.msa Wed May 14 11:22:58 2008 +0900
> > +++ b/edk2-sparse/EdkXenPkg/Dxe/Bds/Bds.msa Wed Sep 10 17:32:02 2008 +0900
> > @@ -57,6 +57,9 @@
> >        <Keyword>EdkGenericPlatformBdsLib</Keyword>
> >      </LibraryClass>
> >      <LibraryClass Usage="ALWAYS_CONSUMED">
> > +      <Keyword>IoLib</Keyword>
> > +    </LibraryClass>
> > +    <LibraryClass Usage="ALWAYS_CONSUMED">
> >        <Keyword>PcdLib</Keyword>
> >      </LibraryClass>
> >    </LibraryClassDefinitions>
> > @@ -110,5 +113,17 @@
> >        <DefaultValue>0xF0</DefaultValue>
> >        <HelpText>Devices for default console.  0x01: com1, 0x02: com2, 0x10:
> > kbd, 0x20: vga</HelpText>
> >      </PcdEntry>
> > +    <PcdEntry PcdItemType="FEATURE_FLAG" Usage="ALWAYS_CONSUMED">
> > +      <C_Name>PcdVgaInitAtBoot</C_Name>
> > +      <TokenSpaceGuidCName>gEfiEdkQemuTokenSpaceGuid</TokenSpaceGuidCName>
> > +      <DefaultValue>TRUE</DefaultValue>
> > +      <HelpText>Initialise in text mode the Vga at module boot</HelpText>
> > +    </PcdEntry>
> > +    <PcdEntry PcdItemType="FEATURE_FLAG" Usage="ALWAYS_CONSUMED">
> > +      <C_Name>PcdVgaInitAtExit</C_Name>
> > +      <TokenSpaceGuidCName>gEfiEdkQemuTokenSpaceGuid</TokenSpaceGuidCName>
> > +      <DefaultValue>FALSE</DefaultValue>
> > +      <HelpText>Initialise in text mode the Vga at module exit</HelpText>
> > +    </PcdEntry>
> >    </PcdCoded>
> > -</ModuleSurfaceArea>
> > \ No newline at end of file
> > +</ModuleSurfaceArea>
> > diff -r 830ed5449dd4 edk2-sparse/EdkXenPkg/Dxe/Bds/BdsPlatform.c
> > --- a/edk2-sparse/EdkXenPkg/Dxe/Bds/BdsPlatform.c   Wed May 14 11:22:58 2008
> > +0900
> > +++ b/edk2-sparse/EdkXenPkg/Dxe/Bds/BdsPlatform.c   Wed Sep 10 17:32:02 2008
> > +0900
> > @@ -633,6 +633,89 @@
> >    return EFI_SUCCESS;
> >  }
> >
> > +//
> > +// PCI Xen device
> > +//
> > +#include "../../../EdkQemuPkg/Chipset/PcCompatible/VgaInit/Dxe/VgaInit.c"
> > +#include "../../../EdkQemuPkg/Chipset/PcCompatible/VgaInit/Dxe/Font.c"
> > +
> > +STATIC VOID
> > +__InitializeVga (VOID)
> > +{
> > +  InitializeVga (NULL, NULL);
> > +}
> > +
> > +#define XEN_PLATFORM_VENDOR_ID     0x5853
> > +#define XEN_PLATFORM_DEVICE_ID     0x0001
> > +
> > +// See if the device is an enabled XEN device.
> > +#define IS_PCI_XEN_PLATFORM(Pci)                   \
> > +  ((Pci)->Hdr.VendorId == XEN_PLATFORM_VENDOR_ID &&        \
> > +   (Pci)->Hdr.DeviceId == XEN_PLATFORM_DEVICE_ID)
> > +
> > +#define XEN_PAGE_SIZE              (16 * 1024)
> > +#define VGA_RAM_SIZE               (8192 * 1024)
> > +// Round up to XEN_PAGE_SIZE
> > +#define VGA_RAM_PAGES              (((VGA_RAM_SIZE + (XEN_PAGE_SIZE - 1)) /
> > XEN_PAGE_SIZE) * XEN_PAGE_SIZE) / (4 * 1024)
> > +
> > +//
> > +// Use BAR 0
> > +// Offset 4 bytes
> > +//
> > +#define XEN_BAR_INDEX              0
> > +#define XEN_VGA_OFFSET             4
> > +
> > +STATIC VOID
> > +PreparePciXenDevicePath (
> > +  IN EFI_PCI_IO_PROTOCOL *PciIo
> > +  )
> > +{
> > +  STATIC BOOLEAN   Initialized = FALSE;
> > +  VOID                     *VgaRam = NULL;
> > +  UINT64           Data64;
> > +  UINT32           Data32;
> > +  EFI_STATUS            Status;
> > +
> > +
> > +  if (Initialized)
> > +    return;
> > +
> > +  //
> > +  // XXX: exclusion. only once.
> > +  //
> > +  VgaRam = AllocateAlignedReservedPages (VGA_RAM_PAGES, XEN_PAGE_SIZE);
> > +  if (VgaRam == NULL) {
> > +    return;
> > +  }
> > +  ZeroMem (VgaRam, VGA_RAM_PAGES * 4 * 1024);
> > +
> > +  Data64 = (UINT64)VgaRam;
> > +  Data32 = (UINT32)VgaRam;
> > +  if (Data64 == Data32) {
> > +    //
> > +    // At this moment, 32bit is only supported by qemu-dm
> > +    //
> > +    Status = PciIo->Io.Write (
> > +                         PciIo,
> > +                         EfiPciIoWidthUint32,
> > +                         XEN_BAR_INDEX,
> > +                         XEN_VGA_OFFSET,
> > +                         1,
> > +                         &Data32
> > +                         );
> > +  } else {
> > +    Status = EFI_OUT_OF_RESOURCES;
> > +  }
> > +
> > +  if (!EFI_ERROR(Status)) {
> > +    Initialized = TRUE;
> > +  } else {
> > +    if (VgaRam) {
> > +      FreeAlignedPages (VgaRam, VGA_RAM_PAGES);
> > +    }
> > +  }
> > +}
> > +
> >  STATIC
> >  EFI_STATUS
> >  DetectAndPreparePlatformPciDevicePath (
> > @@ -677,6 +760,37 @@
> >    if (EFI_ERROR (Status)) {
> >      return Status;
> >    }
> > +
> > +  for (Index = 0; Index < HandleCount; Index++) {
> > +    Status = gBS->HandleProtocol (HandleBuffer[Index],
> > &gEfiPciIoProtocolGuid, (VOID *)&PciIo);
> > +    if (EFI_ERROR (Status)) {
> > +      continue;
> > +    }
> > +
> > +    //
> > +    // Check for all PCI device
> > +    //
> > +    Status = PciIo->Pci.Read (
> > +                      PciIo,
> > +                      EfiPciIoWidthUint32,
> > +                      0,
> > +                      sizeof (Pci) / sizeof (UINT32),
> > +                      &Pci
> > +                      );
> > +    if (EFI_ERROR (Status)) {
> > +      continue;
> > +    }
> > +
> > +    //
> > +    // Here we allocate memory for vram
> > +    // and tell ioemu its guest physical address
> > +    //
> > +    if (IS_PCI_XEN_PLATFORM (&Pci)) {
> > +      PreparePciXenDevicePath (PciIo);
> > +      continue;
> > +    }
> > +  }
> > +  __InitializeVga ();
> >
> >    for (Index = 0; Index < HandleCount; Index++) {
> >      Status = gBS->HandleProtocol (HandleBuffer[Index],
> > &gEfiPciIoProtocolGuid, (VOID *)&PciIo);
> > @@ -1118,6 +1232,7 @@
> >      // In no-configuration boot mode, we can connect the
> >      // console directly.
> >      //
> > +    __InitializeVga ();
> >      BdsLibConnectAllDefaultConsoles ();
> >      PlatformBdsDiagnostics (IGNORE, TRUE);
> >
> > diff -r 830ed5449dd4 edk2-sparse/EdkXenPkg/Xen-Ipf.fpd
> > --- a/edk2-sparse/EdkXenPkg/Xen-Ipf.fpd     Wed May 14 11:22:58 2008 +0900
> > +++ b/edk2-sparse/EdkXenPkg/Xen-Ipf.fpd     Wed Sep 10 17:32:02 2008 +0900
> > @@ -3420,81 +3420,6 @@
> >          <FfsFormatKey>RT_DRIVER</FfsFormatKey>
> >        </ModuleSaBuildOptions>
> >      </ModuleSA>
> > -    <!--Mod: VgaInit Type: DXE_DRIVER Path:
> > EdkQemuPkg/Chipset/PcCompatible/VgaInit/Dxe/VgaInit.msa-->
> > -    <ModuleSA ModuleGuid="4a5f2240-a321-4a49-b3e7-ddec10ada5e7"
> > ModuleVersion="0.1" PackageGuid="a538d0f5-0a85-4084-9776-9aca53f14c9b"
> > PackageVersion="0.1" SupArchList="IPF">
> > -      <Libraries>
> > -        <!--Pkg: MdePkg Mod: UefiDriverEntryPoint Path:
> > MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.msa-->
> > -        <Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556"
> > ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"
> > PackageVersion="0.3"/>
> > -        <!--Pkg: MdePkg Mod: UefiRuntimeServicesTableLib Path:
> > MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.msa-->
> > -        <Instance ModuleGuid="19cbbb97-ff61-45ff-8c3f-dfa66dd118c8"
> > ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"
> > PackageVersion="0.3"/>
> > -        <!--Pkg: MdePkg Mod: UefiBootServicesTableLib Path:
> > MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.msa-->
> > -        <Instance ModuleGuid="ff5c7a2c-ab7a-4366-8616-11c6e53247b6"
> > ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"
> > PackageVersion="0.3"/>
> > -        <!--Pkg: MdePkg Mod: BaseLib Path:
> > MdePkg/Library/BaseLib/BaseLib.msa-->
> > -        <Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30"
> > ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"
> > PackageVersion="0.3"/>
> > -        <!--Pkg: MdePkg Mod: BaseDebugLibNull Path:
> > MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.msa-->
> > -        <Instance ModuleGuid="9ba1d976-0624-41a3-8650-28165e8d9ae8"
> > ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"
> > PackageVersion="0.3"/>
> > -        <!--Pkg: MdePkg Mod: DxeIoLibCpuIo Path:
> > MdePkg/Library/DxeIoLibCpuIo/DxeIoLibCpuIo.msa-->
> > -        <Instance ModuleGuid="e94cd42a-3aad-4ea0-9b09-945891c60ccd"
> > ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"
> > PackageVersion="0.3"/>
> > -        <!--Pkg: MdePkg Mod: BasePcdLibNull Path:
> > MdePkg/Library/BasePcdLibNull/BasePcdLibNull.msa-->
> > -        <Instance ModuleGuid="40096a3a-5c2a-4fbc-aef7-5475dd7ab334"
> > ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"
> > PackageVersion="0.3"/>
> > -        <!--Pkg: MdePkg Mod: BaseMemoryLib Path:
> > MdePkg/Library/BaseMemoryLib/BaseMemoryLib.msa-->
> > -        <Instance ModuleGuid="fd44e603-002a-4b29-9f5f-529e815b6165"
> > ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"
> > PackageVersion="0.3"/>
> > -      </Libraries>
> > -      <PcdBuildDefinition>
> > -        <PcdData ItemType="FEATURE_FLAG">
> > -          <C_Name>PcdVgaInitAtBoot</C_Name>
> > -          <Token>0x1000</Token>
> > -
> > <TokenSpaceGuidCName>gEfiEdkQemuTokenSpaceGuid</TokenSpaceGuidCName>
> > -          <DatumType>BOOLEAN</DatumType>
> > -          <MaxDatumSize>1</MaxDatumSize>
> > -          <Value>TRUE</Value>
> > -        </PcdData>
> > -        <PcdData ItemType="FEATURE_FLAG">
> > -          <C_Name>PcdVgaInitAtExit</C_Name>
> > -          <Token>0x1001</Token>
> > -
> > <TokenSpaceGuidCName>gEfiEdkQemuTokenSpaceGuid</TokenSpaceGuidCName>
> > -          <DatumType>BOOLEAN</DatumType>
> > -          <MaxDatumSize>1</MaxDatumSize>
> > -          <Value>FALSE</Value>
> > -        </PcdData>
> > -        <PcdData ItemType="FIXED_AT_BUILD">
> > -          <C_Name>PcdMaximumUnicodeStringLength</C_Name>
> > -          <Token>0x00000001</Token>
> > -
> > <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
> > -          <DatumType>UINT32</DatumType>
> > -          <MaxDatumSize>4</MaxDatumSize>
> > -          <Value>1000000</Value>
> > -        </PcdData>
> > -        <PcdData ItemType="FIXED_AT_BUILD">
> > -          <C_Name>PcdMaximumAsciiStringLength</C_Name>
> > -          <Token>0x00000002</Token>
> > -
> > <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
> > -          <DatumType>UINT32</DatumType>
> > -          <MaxDatumSize>4</MaxDatumSize>
> > -          <Value>1000000</Value>
> > -        </PcdData>
> > -        <PcdData ItemType="FIXED_AT_BUILD">
> > -          <C_Name>PcdMaximumLinkedListLength</C_Name>
> > -          <Token>0x00000003</Token>
> > -
> > <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
> > -          <DatumType>UINT32</DatumType>
> > -          <MaxDatumSize>4</MaxDatumSize>
> > -          <Value>1000000</Value>
> > -        </PcdData>
> > -        <PcdData ItemType="FIXED_AT_BUILD">
> > -          <C_Name>PcdSpinLockTimeout</C_Name>
> > -          <Token>0x00000004</Token>
> > -
> > <TokenSpaceGuidCName>gEfiMdePkgTokenSpaceGuid</TokenSpaceGuidCName>
> > -          <DatumType>UINT32</DatumType>
> > -          <MaxDatumSize>4</MaxDatumSize>
> > -          <Value>10000000</Value>
> > -        </PcdData>
> > -      </PcdBuildDefinition>
> > -      <ModuleSaBuildOptions>
> > -        <FvBinding>FV_RECOVERY</FvBinding>
> > -        <FfsFormatKey>BS_DRIVER</FfsFormatKey>
> > -      </ModuleSaBuildOptions>
> > -    </ModuleSA>
> >      <!--Mod: VgaClass Type: DXE_DRIVER Path:
> > EdkQemuPkg/Dxe/VgaClass/Dxe/VgaClass.msa-->
> >      <ModuleSA ModuleGuid="6fcd0b4e-5441-4de0-9634-444abb9d9add"
> > ModuleVersion="0.1" PackageGuid="a538d0f5-0a85-4084-9776-9aca53f14c9b"
> > PackageVersion="0.1" SupArchList="IPF">
> >        <Libraries>
> > @@ -3722,6 +3647,8 @@
> >          <Instance ModuleGuid="ea55bada-d488-427b-9d2d-227e0aaa3707"
> > ModuleVersion="1.0" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"
> > PackageVersion="0.3"/>
> >          <!--Pkg: MdePkg Mod: BasePerformanceLibNull Path:
> > MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.msa-->
> >          <Instance ModuleGuid="FC120ED3-40E1-46dc-8C9C-AAE3CA139ACF"
> > ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"
> > PackageVersion="0.3"/>
> > +        <!--Pkg: MdePkg Mod: DxeIoLibCpuIo Path:
> > MdePkg/Library/DxeIoLibCpuIo/DxeIoLibCpuIo.msa-->
> > +        <Instance ModuleGuid="e94cd42a-3aad-4ea0-9b09-945891c60ccd"
> > ModuleVersion="1.0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"
> > PackageVersion="0.3"/>
> >        </Libraries>
> >        <PcdBuildDefinition>
> >          <PcdData ItemType="FIXED_AT_BUILD">
> > @@ -3811,6 +3738,22 @@
> >            <DatumType>UINT32</DatumType>
> >            <MaxDatumSize>4</MaxDatumSize>
> >            <Value>0xF0</Value>
> > +        </PcdData>
> > +        <PcdData ItemType="FEATURE_FLAG">
> > +          <C_Name>PcdVgaInitAtBoot</C_Name>
> > +          <Token>0x1000</Token>
> > +
> > <TokenSpaceGuidCName>gEfiEdkQemuTokenSpaceGuid</TokenSpaceGuidCName>
> > +          <DatumType>BOOLEAN</DatumType>
> > +          <MaxDatumSize>1</MaxDatumSize>
> > +          <Value>TRUE</Value>
> > +        </PcdData>
> > +        <PcdData ItemType="FEATURE_FLAG">
> > +          <C_Name>PcdVgaInitAtExit</C_Name>
> > +          <Token>0x1001</Token>
> > +
> > <TokenSpaceGuidCName>gEfiEdkQemuTokenSpaceGuid</TokenSpaceGuidCName>
> > +          <DatumType>BOOLEAN</DatumType>
> > +          <MaxDatumSize>1</MaxDatumSize>
> > +          <Value>FALSE</Value>
> >          </PcdData>
> >        </PcdBuildDefinition>
> >        <ModuleSaBuildOptions>
> > @@ -4058,7 +4001,6 @@
> >          <Module ModuleGuid="0a9aef1e-dc49-49c1-8441-c4afec2155bc"
> > ModuleVersion="0.1" PackageGuid="a538d0f5-0a85-4084-9776-9aca53f14c9b"
> > PackageVersion="0.1" Arch="IPF"/>
> >          <Module ModuleGuid="bcbbc6fb-abd8-4786-88f9-430c2e36efae"
> > ModuleVersion="0.1" PackageGuid="a538d0f5-0a85-4084-9776-9aca53f14c9b"
> > PackageVersion="0.1" Arch="IPF"/>
> >          <Module ModuleGuid="F099D67F-71AE-4c36-B2A3-DCEB0EB2B7D8"
> > ModuleVersion="1.0" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"
> > PackageVersion="0.3" Arch="IPF"/>
> > -        <Module ModuleGuid="4a5f2240-a321-4a49-b3e7-ddec10ada5e7"
> > ModuleVersion="0.1" PackageGuid="a538d0f5-0a85-4084-9776-9aca53f14c9b"
> > PackageVersion="0.1" Arch="IPF"/>
> >          <Module ModuleGuid="FCD337AB-B1D3-4EF8-957C-8048606FF670"
> > ModuleVersion="1.0" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"
> > PackageVersion="0.3" Arch="IPF"/>
> >          <Module ModuleGuid="b17df127-fa3f-46eb-80c5-0c2d7104839a"
> > ModuleVersion="0.1" PackageGuid="35e704ab-48ea-456b-a93f-25516984446b"
> > PackageVersion="0.1" Arch="IPF"/>
> >          <Module ModuleGuid="51ccf399-4fdf-4e55-a45b-e123f84d456a"
> > ModuleVersion="1.0" PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"
> > PackageVersion="0.3" Arch="IPF"/>
> >
> >
> >
> > _______________________________________________
> > Xen-ia64-devel mailing list
> > Xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
> > http://lists.xensource.com/xen-ia64-devel
> >
> 
> 
> 
> _______________________________________________
> Xen-ia64-devel mailing list
> Xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
> http://lists.xensource.com/xen-ia64-devel
> 

-- 
yamahata

_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ia64-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.