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-changelog

[Xen-changelog] [xen-unstable] hvmloader: Add a simple "scratch allocato

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] hvmloader: Add a simple "scratch allocator"
From: Xen patchbot-unstable <patchbot@xxxxxxx>
Date: Thu, 16 Jun 2011 11:12:14 +0100
Delivery-date: Thu, 16 Jun 2011 03:23:59 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1306943188 -3600
# Node ID 26c6382ea52ab18410a62d59683e9f36bc239330
# Parent  07af563619b59d91975aecaf92bf204ab3dfdd58
hvmloader: Add a simple "scratch allocator"

Returns memory which is passed to the subsequent BIOS but can be
reused once the contents is consumed. An example of this would be a
BIOS table which the BIOS consumes by copying rather than simply
referencing.

Users which need a temporary scratch buffer for internal use
scratch_start which follows these allocations.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---


diff -r 07af563619b5 -r 26c6382ea52a tools/firmware/hvmloader/config.h
--- a/tools/firmware/hvmloader/config.h Wed Jun 01 16:45:05 2011 +0100
+++ b/tools/firmware/hvmloader/config.h Wed Jun 01 16:46:28 2011 +0100
@@ -62,6 +62,8 @@
 #define VGABIOS_PHYSICAL_ADDRESS      0x000C0000
 #define HVMLOADER_PHYSICAL_ADDRESS    0x00100000
 
+extern unsigned long scratch_start;
+
 #endif /* __HVMLOADER_CONFIG_H__ */
 
 /*
diff -r 07af563619b5 -r 26c6382ea52a tools/firmware/hvmloader/hvmloader.c
--- a/tools/firmware/hvmloader/hvmloader.c      Wed Jun 01 16:45:05 2011 +0100
+++ b/tools/firmware/hvmloader/hvmloader.c      Wed Jun 01 16:46:28 2011 +0100
@@ -110,6 +110,8 @@
     "    .text                       \n"
     );
 
+unsigned long scratch_start = SCRATCH_PHYSICAL_ADDRESS;
+
 static void init_hypercalls(void)
 {
     uint32_t eax, ebx, ecx, edx;
@@ -481,6 +483,9 @@
     cmos_write_memory_size();
 
     printf("BIOS map:\n");
+    if ( SCRATCH_PHYSICAL_ADDRESS != scratch_start )
+        printf(" %05x-%05lx: Scratch space\n",
+               SCRATCH_PHYSICAL_ADDRESS, scratch_start);
     if ( vgabios_sz )
         printf(" %05x-%05x: VGA BIOS\n",
                VGABIOS_PHYSICAL_ADDRESS,
diff -r 07af563619b5 -r 26c6382ea52a tools/firmware/hvmloader/pci.c
--- a/tools/firmware/hvmloader/pci.c    Wed Jun 01 16:45:05 2011 +0100
+++ b/tools/firmware/hvmloader/pci.c    Wed Jun 01 16:46:28 2011 +0100
@@ -48,7 +48,7 @@
     /* Create a list of device BARs in descending order of size. */
     struct bars {
         uint32_t devfn, bar_reg, bar_sz;
-    } *bars = (struct bars *)SCRATCH_PHYSICAL_ADDRESS;
+    } *bars = (struct bars *)scratch_start;
     unsigned int i, nr_bars = 0;
 
     /* Program PCI-ISA bridge with appropriate link routes. */
diff -r 07af563619b5 -r 26c6382ea52a tools/firmware/hvmloader/rombios.c
--- a/tools/firmware/hvmloader/rombios.c        Wed Jun 01 16:45:05 2011 +0100
+++ b/tools/firmware/hvmloader/rombios.c        Wed Jun 01 16:46:28 2011 +0100
@@ -138,7 +138,7 @@
 
 static void rombios_create_smbios_tables(void)
 {
-    hvm_write_smbios_tables(SCRATCH_PHYSICAL_ADDRESS,
+    hvm_write_smbios_tables(scratch_start,
                             SMBIOS_PHYSICAL_ADDRESS,
                             SMBIOS_PHYSICAL_END);
 }
diff -r 07af563619b5 -r 26c6382ea52a tools/firmware/hvmloader/util.c
--- a/tools/firmware/hvmloader/util.c   Wed Jun 01 16:45:05 2011 +0100
+++ b/tools/firmware/hvmloader/util.c   Wed Jun 01 16:46:28 2011 +0100
@@ -362,6 +362,24 @@
     return (void *)(unsigned long)s;
 }
 
+void *scratch_alloc(uint32_t size, uint32_t align)
+{
+    uint32_t s, e;
+
+    /* Align to at least one kilobyte. */
+    if ( align < 1024 )
+        align = 1024;
+
+    s = (scratch_start + align - 1) & ~(align - 1);
+    e = s + size - 1;
+
+    BUG_ON(e < s);
+
+    scratch_start = e;
+
+    return (void *)(unsigned long)s;
+}
+
 uint32_t ioapic_read(uint32_t reg)
 {
     *(volatile uint32_t *)(IOAPIC_BASE_ADDRESS + 0x00) = reg;
diff -r 07af563619b5 -r 26c6382ea52a tools/firmware/hvmloader/util.h
--- a/tools/firmware/hvmloader/util.h   Wed Jun 01 16:45:05 2011 +0100
+++ b/tools/firmware/hvmloader/util.h   Wed Jun 01 16:46:28 2011 +0100
@@ -168,6 +168,9 @@
 void *mem_alloc(uint32_t size, uint32_t align);
 #define virt_to_phys(v) ((unsigned long)(v))
 
+/* Allocate memory in a scratch region */
+void *scratch_alloc(uint32_t size, uint32_t align);
+
 /* Connect our xenbus client to the backend.  
  * Call once, before any other xenbus actions. */
 void xenbus_setup(void);

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] hvmloader: Add a simple "scratch allocator", Xen patchbot-unstable <=