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

[Xen-devel] [PATCH 08 of 15] hvmloader: Add a simple "scratch allocator"

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 08 of 15] hvmloader: Add a simple "scratch allocator"
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Wed, 1 Jun 2011 10:40:03 +0100
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Delivery-date: Wed, 01 Jun 2011 02:55:30 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1306921195@xxxxxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <patchbomb.1306921195@xxxxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.6.4
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1306917394 -3600
# Node ID 3c920f4ec4f24e1c134749972d5762aa009ee3dc
# Parent  673d9039cd5972d496fa1dbdb2b783a6696c3fbb
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 673d9039cd59 -r 3c920f4ec4f2 tools/firmware/hvmloader/config.h
--- a/tools/firmware/hvmloader/config.h Wed Jun 01 09:35:41 2011 +0100
+++ b/tools/firmware/hvmloader/config.h Wed Jun 01 09:36:34 2011 +0100
@@ -62,6 +62,8 @@ extern unsigned long pci_mem_start, pci_
 #define VGABIOS_PHYSICAL_ADDRESS      0x000C0000
 #define HVMLOADER_PHYSICAL_ADDRESS    0x00100000
 
+extern unsigned long scratch_start;
+
 #endif /* __HVMLOADER_CONFIG_H__ */
 
 /*
diff -r 673d9039cd59 -r 3c920f4ec4f2 tools/firmware/hvmloader/hvmloader.c
--- a/tools/firmware/hvmloader/hvmloader.c      Wed Jun 01 09:35:41 2011 +0100
+++ b/tools/firmware/hvmloader/hvmloader.c      Wed Jun 01 09:36:34 2011 +0100
@@ -110,6 +110,8 @@ asm (
     "    .text                       \n"
     );
 
+unsigned long scratch_start = SCRATCH_PHYSICAL_ADDRESS;
+
 static void init_hypercalls(void)
 {
     uint32_t eax, ebx, ecx, edx;
@@ -481,6 +483,9 @@ int main(void)
     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 673d9039cd59 -r 3c920f4ec4f2 tools/firmware/hvmloader/pci.c
--- a/tools/firmware/hvmloader/pci.c    Wed Jun 01 09:35:41 2011 +0100
+++ b/tools/firmware/hvmloader/pci.c    Wed Jun 01 09:36:34 2011 +0100
@@ -48,7 +48,7 @@ void pci_setup(void)
     /* 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 673d9039cd59 -r 3c920f4ec4f2 tools/firmware/hvmloader/rombios.c
--- a/tools/firmware/hvmloader/rombios.c        Wed Jun 01 09:35:41 2011 +0100
+++ b/tools/firmware/hvmloader/rombios.c        Wed Jun 01 09:36:34 2011 +0100
@@ -138,7 +138,7 @@ static void rombios_create_mp_tables(voi
 
 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 673d9039cd59 -r 3c920f4ec4f2 tools/firmware/hvmloader/util.c
--- a/tools/firmware/hvmloader/util.c   Wed Jun 01 09:35:41 2011 +0100
+++ b/tools/firmware/hvmloader/util.c   Wed Jun 01 09:36:34 2011 +0100
@@ -362,6 +362,24 @@ void *mem_alloc(uint32_t size, uint32_t 
     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 673d9039cd59 -r 3c920f4ec4f2 tools/firmware/hvmloader/util.h
--- a/tools/firmware/hvmloader/util.h   Wed Jun 01 09:35:41 2011 +0100
+++ b/tools/firmware/hvmloader/util.h   Wed Jun 01 09:36:34 2011 +0100
@@ -168,6 +168,9 @@ int vprintf(const char *fmt, va_list ap)
 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-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>