|
|
|
|
|
|
|
|
|
|
xen-ia64-devel
[Xen-ia64-devel] [PATCH] GFW: VgaInit: allocate memory for vram under 32
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 <=
|
|
|
|
|