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

[Xen-devel] [PATCH] HVM SMBIOS v3 [3/5]


  • To: xen-devel@xxxxxxxxxxxxxxxxxxx
  • From: "Andrew D. Ball" <aball@xxxxxxxxxx>
  • Date: Mon, 14 Aug 2006 13:43:53 -0400
  • Delivery-date: Mon, 14 Aug 2006 10:45:31 -0700
  • List-id: Xen developer discussion <xen-devel.lists.xensource.com>

[HVM] Add utilities needed for SMBIOS table generation to hvmloader.

Signed-off-by: Andrew D. Ball <aball@xxxxxxxxxx>

diff -r 71ea74b28d09 -r 92402d267e87 tools/firmware/hvmloader/util.c
--- a/tools/firmware/hvmloader/util.c   Mon Aug 14 11:18:07 2006 -0400
+++ b/tools/firmware/hvmloader/util.c   Mon Aug 14 11:26:45 2006 -0400
@@ -20,6 +20,7 @@
 
 #include "../acpi/acpi2_0.h"  /* for ACPI_PHYSICAL_ADDRESS */
 #include "util.h"
+#include <stdint.h>
 
 void outw(uint16_t addr, uint16_t val)
 {
@@ -95,6 +96,75 @@ void puts(const char *s)
                outb(0xE9, *s++);
 }
 
+char *
+strcpy(char *dest, const char *src)
+{
+    char *p = dest;
+    while (*src)
+        *p++ = *src++;
+    *p = 0;
+    return dest;
+}
+
+char *
+strncpy(char *dest, const char *src, unsigned n)
+{
+    int i = 0;
+    char *p = dest;
+
+    /* write non-NUL characters from src into dest until we run
+       out of room in dest or encounter a NUL in src */
+    while (i < n && *src) {
+        *p++ = *src++;
+        ++i;
+    }
+
+    /* pad remaining bytes of dest with NUL bytes */
+    while (i < n) {
+        *p++ = 0;
+        ++i;
+    }
+
+    return dest;
+}
+
+unsigned
+strlen(const char *s)
+{
+    int i = 0;
+    while (*s++)
+        ++i;
+    return i;
+}
+
+void *
+memset(void *s, int c, unsigned n)
+{
+    uint8_t b = (uint8_t) c;
+    uint8_t *p = (uint8_t *)s;
+    int i;
+    for (i = 0; i < n; ++i)
+        *p++ = b;
+    return s;
+}
+
+int
+memcmp(const void *s1, const void *s2, unsigned n)
+{
+    unsigned i;
+    uint8_t *p1 = (uint8_t *) s1;
+    uint8_t *p2 = (uint8_t *) s2;
+
+    for (i = 0; i < n; ++i) {
+        if (p1[i] < p2[i])
+            return -1;
+        else if (p1[i] > p2[i])
+            return 1;
+    }
+
+    return 0;
+}
+
 void
 cpuid(uint32_t idx, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx)
 {
diff -r 71ea74b28d09 -r 92402d267e87 tools/firmware/hvmloader/util.h
--- a/tools/firmware/hvmloader/util.h   Mon Aug 14 11:18:07 2006 -0400
+++ b/tools/firmware/hvmloader/util.h   Mon Aug 14 11:26:45 2006 -0400
@@ -11,10 +11,17 @@ uint8_t inb(uint16_t addr);
 /* Do cpuid instruction, with operation 'idx' */
 void
 cpuid(uint32_t idx, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t 
*edx);
+/* return number of vcpus */
+int get_vcpu_nr(void);
 
 /* String and memory functions */
 int strcmp(const char *cs, const char *ct);
+char *strcpy(char *dest, const char *src);
+char *strncpy(char *dest, const char *src, unsigned n);
+unsigned strlen(const char *s);
+int memcmp(const void *s1, const void *s2, unsigned n);
 void *memcpy(void *dest, const void *src, unsigned n);
+void *memset(void *s, int c, unsigned n);
 char *itoa(char *a, unsigned int i);
 
 /* Debug output */



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


 


Rackspace

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