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

[Xen-devel] [PATCH RFC 13/20] acpi/hvmloader: Add stdio.h, string.h and x86.h



Users of ACPI builder will need to provide their own implemetations of
strncpy(), memcpy, memset() and printf declared in stdio.h and string.h.
For hvmloader we provide those two as wrappers around utul.h.

Some x86-specific definitions move to ACPI builder's x86.h file so that
users won't have to re-define them themselves.

Explicitly define a few things that are currently available to to build.c
via util.h.

Remove unnecessary #include "../config.h" from static_tables.c

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
---
 tools/firmware/hvmloader/Makefile             |  2 +-
 tools/firmware/hvmloader/acpi/build.c         | 23 +++++++++++++++++------
 tools/firmware/hvmloader/acpi/static_tables.c |  1 -
 tools/firmware/hvmloader/acpi/x86.h           | 14 ++++++++++++++
 tools/firmware/hvmloader/config.h             | 10 ----------
 tools/firmware/hvmloader/hvmloader.c          |  1 +
 tools/firmware/hvmloader/mp_tables.c          |  1 +
 tools/firmware/hvmloader/pci.c                |  1 +
 tools/firmware/hvmloader/pir.c                |  1 +
 tools/firmware/hvmloader/smp.c                |  1 +
 tools/firmware/hvmloader/stdio.h              |  7 +++++++
 tools/firmware/hvmloader/string.h             |  7 +++++++
 tools/firmware/hvmloader/util.c               |  1 +
 13 files changed, 52 insertions(+), 18 deletions(-)
 create mode 100644 tools/firmware/hvmloader/acpi/x86.h
 create mode 100644 tools/firmware/hvmloader/stdio.h
 create mode 100644 tools/firmware/hvmloader/string.h

diff --git a/tools/firmware/hvmloader/Makefile 
b/tools/firmware/hvmloader/Makefile
index ef66019..c778174 100644
--- a/tools/firmware/hvmloader/Makefile
+++ b/tools/firmware/hvmloader/Makefile
@@ -36,7 +36,7 @@ ACPI_PATH = $(XEN_ROOT)/tools/firmware/hvmloader/acpi
 vpath %.c $(ACPI_PATH)
 ACPI_FILES = dsdt_anycpu.c dsdt_15cpu.c static_tables.c dsdt_anycpu_qemu_xen.c 
build.c
 ACPI_SRC = $(patsubst %.c,$(ACPI_PATH)/%.c,$(ACPI_FILES))
-CFLAGS += -I$(ACPI_PATH)
+CFLAGS += -I$(ACPI_PATH) -I.
 
 OBJS  = hvmloader.o mp_tables.o util.o smbios.o 
 OBJS += smp.o cacheattr.o xenbus.o vnuma.o
diff --git a/tools/firmware/hvmloader/acpi/build.c 
b/tools/firmware/hvmloader/acpi/build.c
index 941dd0b..09c1ed3 100644
--- a/tools/firmware/hvmloader/acpi/build.c
+++ b/tools/firmware/hvmloader/acpi/build.c
@@ -15,14 +15,16 @@
  * this program; If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <stdio.h>
+#include <string.h>
+
 #include "acpi2_0.h"
 #include "ssdt_s3.h"
 #include "ssdt_s4.h"
 #include "ssdt_tpm.h"
 #include "ssdt_pm.h"
-#include "../config.h"
-#include "../util.h"
-#include "../vnuma.h"
+#include "x86.h"
+#include <xen/hvm/hvm_info_table.h>
 #include <xen/hvm/hvm_xs_strings.h>
 #include <xen/hvm/params.h>
 
@@ -30,6 +32,12 @@
 
 #define align16(sz)        (((sz) + 15) & ~15)
 #define fixed_strcpy(d, s) strncpy((d), (s), sizeof(d))
+#ifndef offsetof
+#define offsetof(t, m) ((unsigned long)&((t *)0)->m)
+#endif
+#ifndef NULL
+#define NULL ((void *)0)
+#endif
 
 extern struct acpi_20_rsdp Rsdp;
 extern struct acpi_20_rsdt Rsdt;
@@ -41,6 +49,11 @@ extern struct acpi_20_waet Waet;
 /* Number of processor objects in the chosen DSDT. */
 static unsigned int nr_processor_objects;
 
+static inline int __test_bit(unsigned int b, void *p)
+{
+    return !!(((uint8_t *)p)[b>>3] & (1u<<(b&7)));
+}
+
 static void set_checksum(
     void *table, uint32_t checksum_offset, uint32_t length)
 {
@@ -136,7 +149,7 @@ static struct acpi_20_madt *construct_madt(struct 
acpi_config *config)
         lapic->acpi_processor_id = i;
         lapic->apic_id = LAPIC_ID(i);
         lapic->flags = ((i < config->nr_vcpus) &&
-                        test_bit(i, config->vcpu_online)
+                        __test_bit(i, config->vcpu_online)
                         ? ACPI_LOCAL_APIC_ENABLED : 0);
         lapic++;
     }
@@ -238,8 +251,6 @@ static struct acpi_20_srat *construct_srat(struct 
acpi_config *config)
         memory++;
     }
 
-    ASSERT(((unsigned long)memory) - ((unsigned long)p) == size);
-
     srat->header.length = size;
     set_checksum(srat, offsetof(struct acpi_header, checksum), size);
 
diff --git a/tools/firmware/hvmloader/acpi/static_tables.c 
b/tools/firmware/hvmloader/acpi/static_tables.c
index f4d627b..d4db030 100644
--- a/tools/firmware/hvmloader/acpi/static_tables.c
+++ b/tools/firmware/hvmloader/acpi/static_tables.c
@@ -16,7 +16,6 @@
  */
 
 #include "acpi2_0.h"
-#include "../config.h"
 
 /*
  * Firmware ACPI Control Structure (FACS).
diff --git a/tools/firmware/hvmloader/acpi/x86.h 
b/tools/firmware/hvmloader/acpi/x86.h
new file mode 100644
index 0000000..99a2d5c
--- /dev/null
+++ b/tools/firmware/hvmloader/acpi/x86.h
@@ -0,0 +1,14 @@
+#ifndef __ACPI_X86_H__
+#define __ACPI_X86_H__
+
+#define IOAPIC_BASE_ADDRESS 0xfec00000
+#define IOAPIC_ID           0x01
+#define IOAPIC_VERSION      0x11
+
+#define LAPIC_BASE_ADDRESS  0xfee00000
+#define LAPIC_ID(vcpu_id)   ((vcpu_id) * 2)
+
+#define PCI_ISA_DEVFN       0x08    /* dev 1, fn 0 */
+#define PCI_ISA_IRQ_MASK    0x0c20U /* ISA IRQs 5,10,11 are PCI connected */
+
+#endif /* __ACPI_X86_H__ */
diff --git a/tools/firmware/hvmloader/config.h 
b/tools/firmware/hvmloader/config.h
index 6253155..9d1eacb 100644
--- a/tools/firmware/hvmloader/config.h
+++ b/tools/firmware/hvmloader/config.h
@@ -42,16 +42,6 @@ extern struct bios_config ovmf_config;
 #define PAGE_SHIFT 12
 #define PAGE_SIZE  (1ul << PAGE_SHIFT)
 
-#define IOAPIC_BASE_ADDRESS 0xfec00000
-#define IOAPIC_ID           0x01
-#define IOAPIC_VERSION      0x11
-
-#define LAPIC_BASE_ADDRESS  0xfee00000
-#define LAPIC_ID(vcpu_id)   ((vcpu_id) * 2)
-
-#define PCI_ISA_DEVFN       0x08    /* dev 1, fn 0 */
-#define PCI_ISA_IRQ_MASK    0x0c20U /* ISA IRQs 5,10,11 are PCI connected */
-
 /* MMIO hole: Hardcoded defaults, which can be dynamically expanded. */
 #define PCI_MEM_END         0xfc000000
 
diff --git a/tools/firmware/hvmloader/hvmloader.c 
b/tools/firmware/hvmloader/hvmloader.c
index c8311a1..5fe8007 100644
--- a/tools/firmware/hvmloader/hvmloader.c
+++ b/tools/firmware/hvmloader/hvmloader.c
@@ -24,6 +24,7 @@
 #include "config.h"
 #include "pci_regs.h"
 #include "apic_regs.h"
+#include "x86.h"
 #include "acpi2_0.h"
 #include "vnuma.h"
 #include <xen/version.h>
diff --git a/tools/firmware/hvmloader/mp_tables.c 
b/tools/firmware/hvmloader/mp_tables.c
index 69c2885..4d21304 100644
--- a/tools/firmware/hvmloader/mp_tables.c
+++ b/tools/firmware/hvmloader/mp_tables.c
@@ -29,6 +29,7 @@
 
 #include <stdint.h>
 #include "config.h"
+#include "x86.h"
 
 /* number of non-processor MP table entries */
 #define NR_NONPROC_ENTRIES     18
diff --git a/tools/firmware/hvmloader/pci.c b/tools/firmware/hvmloader/pci.c
index 4eb1a31..1813ffa 100644
--- a/tools/firmware/hvmloader/pci.c
+++ b/tools/firmware/hvmloader/pci.c
@@ -22,6 +22,7 @@
 #include "util.h"
 #include "hypercall.h"
 #include "config.h"
+#include "x86.h"
 #include "pci_regs.h"
 
 #include <xen/memory.h>
diff --git a/tools/firmware/hvmloader/pir.c b/tools/firmware/hvmloader/pir.c
index cc420dd..d238a14 100644
--- a/tools/firmware/hvmloader/pir.c
+++ b/tools/firmware/hvmloader/pir.c
@@ -14,6 +14,7 @@
  */
 
 #include "config.h"
+#include "x86.h"
 #include "pir_types.h"
 #include "util.h"
 
diff --git a/tools/firmware/hvmloader/smp.c b/tools/firmware/hvmloader/smp.c
index 082b17f..ae309b3 100644
--- a/tools/firmware/hvmloader/smp.c
+++ b/tools/firmware/hvmloader/smp.c
@@ -21,6 +21,7 @@
 
 #include "util.h"
 #include "config.h"
+#include "x86.h"
 #include "apic_regs.h"
 
 #define AP_BOOT_EIP 0x1000
diff --git a/tools/firmware/hvmloader/stdio.h b/tools/firmware/hvmloader/stdio.h
new file mode 100644
index 0000000..6475ce8
--- /dev/null
+++ b/tools/firmware/hvmloader/stdio.h
@@ -0,0 +1,7 @@
+#ifndef __HVMLOADER_STDIO_H_
+#define __HVMLOADER_STDIO_H_
+
+/* Declaration for printf */
+#include "util.h"
+
+#endif
diff --git a/tools/firmware/hvmloader/string.h 
b/tools/firmware/hvmloader/string.h
new file mode 100644
index 0000000..a6085e2
--- /dev/null
+++ b/tools/firmware/hvmloader/string.h
@@ -0,0 +1,7 @@
+#ifndef __HVMLOADER_STRING_H_
+#define __HVMLOADER_STRING_H_
+
+/* Declarations for memset, memcpy, strcpy */
+#include "util.h"
+
+#endif
diff --git a/tools/firmware/hvmloader/util.c b/tools/firmware/hvmloader/util.c
index a21d3cb..c111f61 100644
--- a/tools/firmware/hvmloader/util.c
+++ b/tools/firmware/hvmloader/util.c
@@ -22,6 +22,7 @@
 #include "hypercall.h"
 #include "ctype.h"
 #include "vnuma.h"
+#include "x86.h"
 #include "acpi2_0.h"
 #include <stdint.h>
 #include <xen/xen.h>
-- 
2.4.3


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

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