WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-ia64-devel

[Xen-ia64-devel] [PATCH] GFW: VgaInit: allocate memory for vram under 32

To: tgingold@xxxxxxx, xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-ia64-devel] [PATCH] GFW: VgaInit: allocate memory for vram under 32bit.
From: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>
Date: Mon, 22 Sep 2008 11:17:35 +0900
Cc:
Delivery-date: Sun, 21 Sep 2008 19:17:38 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-ia64-devel-request@lists.xensource.com?subject=help>
List-id: Discussion of the ia64 port of Xen <xen-ia64-devel.lists.xensource.com>
List-post: <mailto:xen-ia64-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-ia64-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.6i
VgaInit: allocate memory for vram under 32bit.

AllocateAlignedRuntimePages() may return higher memory
which can't be addressed by 32bits.
Allocate 32bit addressable memory explicitly using
gBS directly.

Signed-off-by: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>

diff -r a64ddf64593d 
edk2-sparse/EdkQemuPkg/Chipset/PcCompatible/VgaInit/Dxe/XenVRam.c
--- a/edk2-sparse/EdkQemuPkg/Chipset/PcCompatible/VgaInit/Dxe/XenVRam.c Fri Sep 
19 12:05:21 2008 +0900
+++ b/edk2-sparse/EdkQemuPkg/Chipset/PcCompatible/VgaInit/Dxe/XenVRam.c Fri Sep 
19 15:50:00 2008 +0900
@@ -55,8 +55,12 @@
   UINTN                        Device;
   CONST UINTN          Function = 0;
 
-  VOID                 *VgaRam;
-  UINT64               Data64;
+  UINTN                        Pages;
+  UINTN                        UnalignedPages;
+  UINTN                        AlignedMask;
+  EFI_STATUS           Status;
+  EFI_PHYSICAL_ADDRESS Memory;
+  EFI_PHYSICAL_ADDRESS VgaRam;
   UINT32               Data32;
   UINT32               Bar0;
 
@@ -88,22 +92,25 @@
     return;
   }
 
-  VgaRam = AllocateAlignedRuntimePages (VGA_RAM_PAGES, XEN_PAGE_SIZE);
-  if (VgaRam == NULL) {
+  Pages = VGA_RAM_PAGES + EFI_SIZE_TO_PAGES (XEN_PAGE_SIZE) - 1;
+  Memory = 0xffffffff; // 32bit
+  Status = gBS->AllocatePages (AllocateMaxAddress, EfiRuntimeServicesData, 
Pages, &Memory);
+  if (Status != EFI_SUCCESS) {
     return;
   }
-  ZeroMem (VgaRam, VGA_RAM_PAGES << EFI_PAGE_SHIFT);
+  AlignedMask = ~(XEN_PAGE_SIZE - 1);
+  VgaRam = (UINTN) Memory & AlignedMask;
+  UnalignedPages = EFI_SIZE_TO_PAGES (VgaRam - Memory);
+  if (UnalignedPages > 0) {
+    gBS->FreePages (Memory, UnalignedPages);
+  }
+  UnalignedPages = Pages - (UnalignedPages + VGA_RAM_PAGES);
+  if (UnalignedPages > 0) {
+    gBS->FreePages (VgaRam + VGA_RAM_SIZE, UnalignedPages);
+  }
+  ZeroMem ((VOID*) VgaRam, VGA_RAM_SIZE);
 
-  Data64 = (UINT64)VgaRam;
-  Data32 = (UINT32)VgaRam;
-  if (Data64 != Data32) {
-    //
-    // At this moment, 32bit is only supported by qemu-dm
-    //
-    FreeAlignedPages (VgaRam, VGA_RAM_PAGES);
-    return;
-  }
-
+  Data32 = VgaRam; // discard upper bit
   Bar0 = PciRead32 (
                PCI_LIB_ADDRESS (
                        Bus,


-- 
yamahata

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-ia64-devel] [PATCH] GFW: VgaInit: allocate memory for vram under 32bit., Isaku Yamahata <=