* Anthony Liguori <[EMAIL PROTECTED]> [2007-12-07 14:49]: > Ryan Harper wrote: > >5 files changed, 754 insertions(+), 2 deletions(-) > >Makefile.target | 4 > >hw/pc.c | 47 ++++ > >smbios.c | 519 > >+++++++++++++++++++++++++++++++++++++++++++++++++++++++ > >smbios_types.h | 182 +++++++++++++++++++ > >sysemu.h | 4 > > > > > ># HG changeset patch > ># User Ryan Harper <[EMAIL PROTECTED]> > ># Date 1197058922 21600 > ># Node ID 37bf559ffcf74bfe62ec038c5818e4cf29b817f5 > ># Parent 25082b761acbe8b7fa535dedb4a53e02ef74128d > >export SMBIOS/DMI tables to PC machines. > > > >This patch introduces code to generate PC SMBIOS/DMI tables and load them > >into machine memory. The resultant machine can use standard tools like > >dmidecode to examine the in-memory generated table. > > > >Signed-off-by: Ryan Harper <[EMAIL PROTECTED]> > > > >diff -r 25082b761acb -r 37bf559ffcf7 Makefile.target > >--- a/Makefile.target Wed Dec 05 03:23:38 2007 +0000 > >+++ b/Makefile.target Fri Dec 07 14:22:02 2007 -0600 > >@@ -396,7 +396,7 @@ endif > > endif > > > > # must use static linking to avoid leaving stuff in virtual address space > >-VL_OBJS=vl.o osdep.o monitor.o pci.o loader.o isa_mmio.o > >+VL_OBJS=vl.o osdep.o monitor.o pci.o loader.o isa_mmio.o smbios.o > > > > smbios is x86 specific so you should move this down to one of the ifeq > ($(TARGET_BASE_ARCH), i386) guards. >
OK > > # XXX: suppress QEMU_TOOL tests > > VL_OBJS+=block-raw.o > > > >@@ -535,7 +535,7 @@ ifndef CONFIG_DARWIN > > ifndef CONFIG_DARWIN > > ifndef CONFIG_WIN32 > > ifndef CONFIG_SOLARIS > >-VL_LIBS+=-lutil > >+VL_LIBS+=-lutil -luuid > > endif > > endif > > endif > >diff -r 25082b761acb -r 37bf559ffcf7 hw/pc.c > >--- a/hw/pc.c Wed Dec 05 03:23:38 2007 +0000 > >+++ b/hw/pc.c Fri Dec 07 14:22:02 2007 -0600 > >@@ -44,6 +44,13 @@ > > > > #define MAX_IDE_BUS 2 > > > >+/* Hole in BIOS space between 0xF0000 and 0xFFF0 for DMI entry point */ > >+#define SMBIOS_ENTRY 0x000fac00 > >+ > >+/* ensure SMBIOS tables have enough room to support MAX_CPUS number of > >+ * processor entries */ > >+#define SMBIOS_EXTRA (5 << 12) > >+ > > static fdctrl_t *floppy_controller; > > static RTCState *rtc_state; > > static PITState *pit; > >@@ -832,6 +839,46 @@ static void pc_init1(int ram_size, int v > > } > > } > > > >+ { > >+ ram_addr_t smbios_offset, entrypoint_offset, smbios_base; > >+ uint32_t smbios_phys; > >+ int smbios_size > > > > It's better to not have these open segments in the middle of functions. > You can either move the variable declarations to the top of the function > or split out into a separate function. Easy enough, I'll adjust. > >+ /* phys_ram_base + bios_offset implies 0xe0000 in guest ram */ > >+ smbios_base = (ram_addr_t)phys_ram_base + bios_offset; > >+ > >+ /* take a guess at smbios size */ > >+ smbios_size = (SMBIOS_EXTRA-1) & ~4095; > >+ > >+ /* we only have 32k of space between rombios32 and rombios16 */ > >+ if (smbios_size > SMBIOS_MAXIMUM_SIZE) { > >+ fprintf(stderr, "qemu: SMBIOS image size too big (%u), max > >%u\n", > >+ smbios_size, SMBIOS_MAXIMUM_SIZE); > >+ exit(1); > >+ } > >+ > >+ /* smbios is composed of two regions, an entry point table and > >+ * a second table of all of the data. These regions will live > >+ * at different phyiscal addresses so we need to reserve space > >+ * for two locations > >+ * NB: Entry point is a fixed size (0x1f) > >+ */ > >+ > >+ /* use the hole between end of rombios32 and start of > >+ * rombios16 @ 0xf0000 */ > >+ smbios_phys = 0xf0000 - smbios_size; > >+ smbios_offset = (ram_addr_t)(smbios_phys - 0xe0000); > >+ entrypoint_offset = (ram_addr_t)(SMBIOS_ENTRY - 0xe0000); > >+ > >+ ret = load_smbios_tables((uint8_t *)smbios_base + > >entrypoint_offset, > >+ (uint8_t *)smbios_base + smbios_offset, > >+ smbios_phys); > >+ if (ret < 0) { > >+ fprintf(stderr, "qemu: could not generate SMBIOS\n"); > >+ exit(1); > >+ } > >+ } > >+ > > /* map all the bios at the top of memory */ > > cpu_register_physical_memory((uint32_t)(-bios_size), > > bios_size, bios_offset | IO_MEM_ROM); > >diff -r 25082b761acb -r 37bf559ffcf7 smbios.c > >--- /dev/null Thu Jan 01 00:00:00 1970 +0000 > >+++ b/smbios.c Fri Dec 07 14:22:02 2007 -0600 > >@@ -0,0 +1,519 @@ > >+/* > >+ * smbios.c - Generate SMBIOS tables for Xen HVM domU's. > >+ * - Adapted for QEMU/KVM > >+ * > >+ * This program is free software; you can redistribute it and/or modify > >+ * it under the terms of the GNU General Public License as published by > >+ * the Free Software Foundation; either version 2 of the License, or > >+ * (at your option) any later version. > >+ * > >+ * This program is distributed in the hope that it will be useful, > >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of > >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > >+ * GNU General Public License for more details. > >+ * > >+ * You should have received a copy of the GNU General Public License > >+ * along with this program; if not, write to the Free Software > >+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, > >USA. > >+ * > >+ * Copyright (C) IBM Corporation, 2006, 2007 > >+ * > >+ * Authors: Andrew D. Ball <[EMAIL PROTECTED]> > >+ * Ryan Harper <[EMAIL PROTECTED]> > >+ */ > >+ > >+#include <stdio.h> > >+#include <stdint.h> > >+#include <string.h> > >+#include <uuid/uuid.h> > >+#include "hw/hw.h" > >+#include "sysemu.h" > >+#include "smbios_types.h" > >+#include "config-host.h" > >+ > >+CPUState *first_cpu; > > > > This should probably be static. doh, should be extern actually since it's defined elsewhere. -- Ryan Harper Software Engineer; Linux Technology Center IBM Corp., Austin, Tx (512) 838-9253 T/L: 678-9253 [EMAIL PROTECTED]