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

[Xen-changelog] [xen-unstable] Add utilities needed for SMBIOS generation to hvmloader.



# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Node ID 4210049a5854e1dce1aba9a4aaffb0d8fff2fa01
# Parent  963a67ab81307e7e67a0a38be76582e5a507531e
Add utilities needed for SMBIOS generation to hvmloader.
Signed-off-by: Andrew D. Ball <aball@xxxxxxxxxx>
---
 tools/firmware/hvmloader/hvmloader.c |    9 ---
 tools/firmware/hvmloader/util.c      |   80 +++++++++++++++++++++++++++++++++++
 tools/firmware/hvmloader/util.h      |   12 +++++
 3 files changed, 92 insertions(+), 9 deletions(-)

diff -r 963a67ab8130 -r 4210049a5854 tools/firmware/hvmloader/hvmloader.c
--- a/tools/firmware/hvmloader/hvmloader.c      Mon Aug 14 16:41:20 2006 +0100
+++ b/tools/firmware/hvmloader/hvmloader.c      Mon Aug 14 17:28:25 2006 +0100
@@ -116,15 +116,6 @@ check_amd(void)
 }
 
 static void
-cpuid(uint32_t idx, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx)
-{
-       __asm__ __volatile__(
-               "cpuid"
-               : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx)
-               : "0" (idx) );
-}
-
-static void
 wrmsr(uint32_t idx, uint64_t v)
 {
        __asm__ __volatile__(
diff -r 963a67ab8130 -r 4210049a5854 tools/firmware/hvmloader/util.c
--- a/tools/firmware/hvmloader/util.c   Mon Aug 14 16:41:20 2006 +0100
+++ b/tools/firmware/hvmloader/util.c   Mon Aug 14 17:28:25 2006 +0100
@@ -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)
 {
@@ -94,3 +95,82 @@ void puts(const char *s)
        while (*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)
+{
+       __asm__ __volatile__(
+               "cpuid"
+               : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx)
+               : "0" (idx) );
+}
+
diff -r 963a67ab8130 -r 4210049a5854 tools/firmware/hvmloader/util.h
--- a/tools/firmware/hvmloader/util.h   Mon Aug 14 16:41:20 2006 +0100
+++ b/tools/firmware/hvmloader/util.h   Mon Aug 14 17:28:25 2006 +0100
@@ -8,9 +8,21 @@ void outb(uint16_t addr, uint8_t val);
 /* I/O input */
 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-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

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