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

[Xen-devel] Re: [Qemu-devel] [PATCH 06/15] xen: Add the Xen platform pci device


  • To: stefano.stabellini@xxxxxxxxxxxxx
  • From: Blue Swirl <blauwirbel@xxxxxxxxx>
  • Date: Thu, 12 Aug 2010 18:26:49 +0000
  • Cc: Anthony.Perard@xxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxx, qemu-devel@xxxxxxxxxx
  • Delivery-date: Thu, 12 Aug 2010 11:28:52 -0700
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=K1+IywDWbhgewa6dfSQ6AnIa9VE/TIOQxsSeMLsNkE/mCPK1ndRs7i3WlQZlDy0REr FVAJgXPLgKK1WKr3VwDd9Fd/9f8jB58ss0yybO1TeoO5J6G0Hg9DQkv73cCvGjyfjWBv Rj5GOHXawwIlR3mziiFAAKirTo6OJrWEtGs5M=
  • List-id: Xen developer discussion <xen-devel.lists.xensource.com>

On Thu, Aug 12, 2010 at 2:09 PM,  <stefano.stabellini@xxxxxxxxxxxxx> wrote:
> From: Anthony PERARD <anthony.perard@xxxxxxxxxx>
>
> Introduce a new emulated PCI device, specific to fully virtualized Xen
> guests. ÂThe device is necessary for PV on HVM drivers to work.

The code should be converted to qdev and VMState.

>
> Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
> Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
> ---
> ÂMakefile.target   |  Â1 +
> Âhw/xen_machine_fv.c | Â Â4 +
> Âhw/xen_platform.c  | Â452 
> +++++++++++++++++++++++++++++++++++++++++++++++++++
> Âhw/xen_platform.h  |  Â9 +
> Â4 files changed, 466 insertions(+), 0 deletions(-)
> Âcreate mode 100644 hw/xen_platform.c
> Âcreate mode 100644 hw/xen_platform.h
>
> diff --git a/Makefile.target b/Makefile.target
> index d1b63f2..1984cdd 100644
> --- a/Makefile.target
> +++ b/Makefile.target
> @@ -324,6 +324,7 @@ obj-xen-y += pc.o
> Âobj-xen-y += piix_pci.o
> Âobj-xen-y += mc146818rtc.o
> Âobj-xen-y += xenstore.o
> +obj-xen-y += xen_platform.o
>
> Âobj-xen-y += xen_mapcache.o
> Âobj-xen-y += stub-functions.o
> diff --git a/hw/xen_machine_fv.c b/hw/xen_machine_fv.c
> index 114addf..ec826e7 100644
> --- a/hw/xen_machine_fv.c
> +++ b/hw/xen_machine_fv.c
> @@ -35,6 +35,7 @@
> Â#include "xen_common.h"
> Â#include "xen_backend.h"
> Â#include "xenstore.h"
> +#include "xen_platform.h"
> Â#include "xen/hvm/hvm_info_table.h"
>
> Â#define MAX_IDE_BUS 2
> @@ -93,6 +94,9 @@ static void xen_init_fv(ram_addr_t ram_size,
>
> Â Â pc_vga_init(pci_bus);
>
> + Â Âpci_xen_platform_init(pci_bus);
> + Â Âplatform_fixed_ioport_init();
> +
> Â Â /* init basic PC hardware */
> Â Â pc_basic_device_init(isa_irq, &floppy_controller, &rtc_state);
>
> diff --git a/hw/xen_platform.c b/hw/xen_platform.c
> new file mode 100644
> index 0000000..85d3f8b
> --- /dev/null
> +++ b/hw/xen_platform.c
> @@ -0,0 +1,452 @@
> +/*
> + * XEN platform pci device, formerly known as the event channel device
> + *
> + * Copyright (c) 2003-2004 Intel Corp.
> + * Copyright (c) 2006 XenSource
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a 
> copy
> + * of this software and associated documentation files (the "Software"), to 
> deal
> + * in the Software without restriction, including without limitation the 
> rights
> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> + * copies of the Software, and to permit persons to whom the Software is
> + * furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included in
> + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
> FROM,
> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> + * THE SOFTWARE.
> + */
> +
> +#include "hw.h"
> +#include "pc.h"
> +#include "pci.h"
> +#include "irq.h"
> +#include "xen_common.h"
> +#include "net.h"
> +#include "xen_platform.h"
> +#include "xen_backend.h"
> +#include "qemu-log.h"
> +
> +#include <assert.h>
> +#include <xenguest.h>
> +
> +static int drivers_blacklisted;
> +static uint16_t driver_product_version;
> +static int throttling_disabled;
> +static char log_buffer[4096];
> +static int log_buffer_off;
> +
> +static uint8_t platform_flags;

A lot of static variables. Could you put these to PCIXenPlatformState?

> +
> +#define PFFLAG_ROM_LOCK 1 /* Sets whether ROM memory area is RW or RO */
> +
> +typedef struct PCIXenPlatformState
> +{
> + Â ÂPCIDevice Âpci_dev;
> +} PCIXenPlatformState;
> +
> +
> +/* We throttle access to dom0 syslog, to avoid DOS attacks. ÂThis is
> + Â modelled as a token bucket, with one token for every byte of log.
> + Â The bucket size is 128KB (->1024 lines of 128 bytes each) and
> + Â refills at 256B/s. ÂIt starts full. ÂThe guest is blocked if no
> + Â tokens are available when it tries to generate a log message. */
> +#define BUCKET_MAX_SIZE (128*1024)
> +#define BUCKET_FILL_RATE 256
> +
> +static void throttle(unsigned count)
> +{
> + Â Âstatic unsigned available;
> + Â Âstatic struct timespec last_refil;
> + Â Âstatic int started;
> + Â Âstatic int warned;
> +
> + Â Âstruct timespec waiting_for, now;
> + Â Âdouble delay;
> + Â Âstruct timespec ts;
> +
> + Â Âif (throttling_disabled)
> + Â Â Â Âreturn;
> +
> + Â Âif (!started) {
> + Â Â Â Âclock_gettime(CLOCK_MONOTONIC, &last_refil);
> + Â Â Â Âavailable = BUCKET_MAX_SIZE;
> + Â Â Â Âstarted = 1;
> + Â Â}
> +
> + Â Âif (count > BUCKET_MAX_SIZE) {
> + Â Â Â Âfprintf(stderr, "tried to get %d tokens, but bucket size is %d\n",
> + Â Â Â Â Â Â Â ÂBUCKET_MAX_SIZE, count);
> + Â Â Â Âexit(1);
> + Â Â}
> +
> + Â Âif (available < count) {
> + Â Â Â Â/* The bucket is empty. ÂRefil it */
> +
> + Â Â Â Â/* When will it be full enough to handle this request? */
> + Â Â Â Âdelay = (double)(count - available) / BUCKET_FILL_RATE;
> + Â Â Â Âwaiting_for = last_refil;
> + Â Â Â Âwaiting_for.tv_sec += delay;
> + Â Â Â Âwaiting_for.tv_nsec += (delay - (int)delay) * 1e9;
> + Â Â Â Âif (waiting_for.tv_nsec >= 1000000000) {
> + Â Â Â Â Â Âwaiting_for.tv_nsec -= 1000000000;
> + Â Â Â Â Â Âwaiting_for.tv_sec++;
> + Â Â Â Â}
> +
> + Â Â Â Â/* How long do we have to wait? (might be negative) */
> + Â Â Â Âclock_gettime(CLOCK_MONOTONIC, &now);
> + Â Â Â Âts.tv_sec = waiting_for.tv_sec - now.tv_sec;
> + Â Â Â Âts.tv_nsec = waiting_for.tv_nsec - now.tv_nsec;
> + Â Â Â Âif (ts.tv_nsec < 0) {
> + Â Â Â Â Â Âts.tv_sec--;
> + Â Â Â Â Â Âts.tv_nsec += 1000000000;
> + Â Â Â Â}
> +
> + Â Â Â Â/* Wait for it. */
> + Â Â Â Âif (ts.tv_sec > 0 ||
> + Â Â Â Â Â Â(ts.tv_sec == 0 && ts.tv_nsec > 0)) {
> + Â Â Â Â Â Âif (!warned) {
> + Â Â Â Â Â Â Â Âfprintf(stderr, "throttling guest access to syslog");
> + Â Â Â Â Â Â Â Âwarned = 1;
> + Â Â Â Â Â Â}
> + Â Â Â Â Â Âwhile (nanosleep(&ts, &ts) < 0 && errno == EINTR)
> + Â Â Â Â Â Â Â Â;
> + Â Â Â Â}
> +
> + Â Â Â Â/* Refil */
> + Â Â Â Âclock_gettime(CLOCK_MONOTONIC, &now);
> + Â Â Â Âdelay = (now.tv_sec - last_refil.tv_sec) +
> + Â Â Â Â Â Â(now.tv_nsec - last_refil.tv_nsec) * 1.0e-9;
> + Â Â Â Âavailable += BUCKET_FILL_RATE * delay;
> + Â Â Â Âif (available > BUCKET_MAX_SIZE)
> + Â Â Â Â Â Âavailable = BUCKET_MAX_SIZE;
> + Â Â Â Âlast_refil = now;
> + Â Â}
> +
> + Â Âassert(available >= count);
> +
> + Â Âavailable -= count;
> +}
> +
> +#define UNPLUG_ALL_IDE_DISKS 1
> +#define UNPLUG_ALL_NICS 2
> +#define UNPLUG_AUX_IDE_DISKS 4

These should go to the top of the file. Are they even used, the
function below doesn't?

> +
> +static void platform_fixed_ioport_write2(void *opaque, uint32_t addr, 
> uint32_t val)
> +{
> + Â Âswitch (addr - 0x10) {

0x10 should be a #define, which should be used...

> + Â Âcase 0:
> + Â Â Â Â/* Unplug devices. ÂValue is a bitmask of which devices to
> + Â Â Â Â Â unplug, with bit 0 the IDE devices, bit 1 the network
> + Â Â Â Â Â devices, and bit 2 the non-primary-master IDE devices. */
> + Â Â Â Âbreak;
> + Â Âcase 2:
> + Â Â Â Âswitch (val) {
> + Â Â Â Âcase 1:
> + Â Â Â Â Â Âfprintf(stderr, "Citrix Windows PV drivers loaded in guest\n");
> + Â Â Â Â Â Âbreak;
> + Â Â Â Âcase 0:
> + Â Â Â Â Â Âfprintf(stderr, "Guest claimed to be running PV product 0?\n");
> + Â Â Â Â Â Âbreak;
> + Â Â Â Âdefault:
> + Â Â Â Â Â Âfprintf(stderr, "Unknown PV product %d loaded in guest\n", val);
> + Â Â Â Â Â Âbreak;
> + Â Â Â Â}
> + Â Â Â Âdriver_product_version = val;
> + Â Â Â Âbreak;
> + Â Â}
> +}
> +
> +static void platform_fixed_ioport_write4(void *opaque, uint32_t addr,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â uint32_t val)
> +{
> + Â Âswitch (addr - 0x10) {

... here ...

> + Â Âcase 0:
> + Â Â Â Â/* PV driver version */
> + Â Â Â Âbreak;
> + Â Â}
> +}
> +
> +static void platform_fixed_ioport_write1(void *opaque, uint32_t addr, 
> uint32_t val)
> +{
> + Â Âswitch (addr - 0x10) {

... here ...

> + Â Âcase 0: /* Platform flags */ {
> + Â Â Â Âhvmmem_type_t mem_type = (val & PFFLAG_ROM_LOCK) ?
> + Â Â Â Â Â ÂHVMMEM_ram_ro : HVMMEM_ram_rw;
> + Â Â Â Âif (xc_hvm_set_mem_type(xen_xc, xen_domid, mem_type, 0xc0, 0x40))
> + Â Â Â Â Â Âfprintf(stderr,"platform_fixed_ioport: unable to change ro/rw "
> + Â Â Â Â Â Â Â Â Â Â"state of ROM memory area!\n");

Please introduce a macro (DPRINTF) and use that.

> + Â Â Â Âelse {
> + Â Â Â Â Â Âplatform_flags = val & PFFLAG_ROM_LOCK;
> + Â Â Â Â Â Âfprintf(stderr,"platform_fixed_ioport: changed ro/rw "
> + Â Â Â Â Â Â Â Â Â Â"state of ROM memory area. now is %s state.\n",
> + Â Â Â Â Â Â Â Â Â Â(mem_type == HVMMEM_ram_ro ? "ro":"rw"));
> + Â Â Â Â}
> + Â Â Â Âbreak;
> + Â Â}
> + Â Âcase 2:
> + Â Â Â Â/* Send bytes to syslog */
> + Â Â Â Âif (val == '\n' || log_buffer_off == sizeof(log_buffer) - 1) {
> + Â Â Â Â Â Â/* Flush buffer */
> + Â Â Â Â Â Âlog_buffer[log_buffer_off] = 0;
> + Â Â Â Â Â Âthrottle(log_buffer_off);
> + Â Â Â Â Â Âfprintf(stderr, "%s\n", log_buffer);
> + Â Â Â Â Â Âlog_buffer_off = 0;
> + Â Â Â Â Â Âbreak;
> + Â Â Â Â}
> + Â Â Â Âlog_buffer[log_buffer_off++] = val;
> + Â Â Â Âbreak;
> + Â Â}
> +}
> +
> +static uint32_t platform_fixed_ioport_read2(void *opaque, uint32_t addr)
> +{
> + Â Âswitch (addr - 0x10) {

... here ...

> + Â Âcase 0:
> + Â Â Â Âif (drivers_blacklisted) {
> + Â Â Â Â Â Â/* The drivers will recognise this magic number and refuse
> + Â Â Â Â Â Â * to do anything. */
> + Â Â Â Â Â Âreturn 0xd249;
> + Â Â Â Â} else {
> + Â Â Â Â Â Â/* Magic value so that you can identify the interface. */
> + Â Â Â Â Â Âreturn 0x49d2;
> + Â Â Â Â}
> + Â Âdefault:
> + Â Â Â Âreturn 0xffff;
> + Â Â}
> +}
> +
> +static uint32_t platform_fixed_ioport_read1(void *opaque, uint32_t addr)
> +{
> + Â Âswitch (addr - 0x10) {

... here ...

> + Â Âcase 0:
> + Â Â Â Â/* Platform flags */
> + Â Â Â Âreturn platform_flags;
> + Â Âcase 2:
> + Â Â Â Â/* Version number */
> + Â Â Â Âreturn 1;
> + Â Âdefault:
> + Â Â Â Âreturn 0xff;
> + Â Â}
> +}
> +
> +static void platform_fixed_ioport_save(QEMUFile *f, void *opaque)
> +{
> + Â Âqemu_put_8s(f, &platform_flags);
> +}
> +
> +static int platform_fixed_ioport_load(QEMUFile *f, void *opaque, int 
> version_id)
> +{
> + Â Âuint8_t flags;
> +
> + Â Âif (version_id > 1)
> + Â Â Â Âreturn -EINVAL;
> +
> + Â Âqemu_get_8s(f, &flags);
> + Â Âplatform_fixed_ioport_write1(NULL, 0x10, flags);
> +
> + Â Âreturn 0;
> +}
> +
> +void platform_fixed_ioport_init(void)
> +{
> + Â Âregister_savevm(NULL, "platform_fixed_ioport", 0, 1, 
> platform_fixed_ioport_save,
> + Â Â Â Â Â Â Â Â Â Âplatform_fixed_ioport_load, NULL);

Please use VMState instead.

> +
> + Â Âregister_ioport_write(0x10, 16, 4, platform_fixed_ioport_write4, NULL);

and here and below. In fact, just s/0x10/XEN_PLATFORM_IOPORT/g.

> + Â Âregister_ioport_write(0x10, 16, 2, platform_fixed_ioport_write2, NULL);
> + Â Âregister_ioport_write(0x10, 16, 1, platform_fixed_ioport_write1, NULL);
> + Â Âregister_ioport_read(0x10, 16, 2, platform_fixed_ioport_read2, NULL);
> + Â Âregister_ioport_read(0x10, 16, 1, platform_fixed_ioport_read1, NULL);
> +
> + Â Âplatform_fixed_ioport_write1(NULL, 0x10, 0);

Introduce a reset function which performs something similar.

> +}
> +
> +static uint32_t xen_platform_ioport_readb(void *opaque, uint32_t addr)
> +{
> + Â Âaddr &= 0xff;
> +
> + Â Âreturn (addr == 0) ? platform_fixed_ioport_read1(NULL, 0x10) : ~0u;

Just use if.

> +}
> +
> +static void xen_platform_ioport_writeb(void *opaque, uint32_t addr, uint32_t 
> val)
> +{
> + Â Âaddr &= 0xff;
> + Â Âval Â&= 0xff;
> +
> + Â Âswitch (addr) {
> + Â Âcase 0: /* Platform flags */
> + Â Â Â Âplatform_fixed_ioport_write1(NULL, 0x10, val);
> + Â Â Â Âbreak;
> + Â Âcase 8:
> + Â Â Â Â{
> + Â Â Â Â Â Âif (val == '\n' || log_buffer_off == sizeof(log_buffer) - 1) {
> + Â Â Â Â Â Â Â Â/* Flush buffer */
> + Â Â Â Â Â Â Â Âlog_buffer[log_buffer_off] = 0;
> + Â Â Â Â Â Â Â Âthrottle(log_buffer_off);
> + Â Â Â Â Â Â Â Âfprintf(stderr, "%s\n", log_buffer);
> + Â Â Â Â Â Â Â Âlog_buffer_off = 0;
> + Â Â Â Â Â Â Â Âbreak;
> + Â Â Â Â Â Â}
> + Â Â Â Â Â Âlog_buffer[log_buffer_off++] = val;
> + Â Â Â Â}
> + Â Â Â Âbreak;
> + Â Âdefault:
> + Â Â Â Âbreak;
> + Â Â}
> +}
> +
> +static void platform_ioport_map(PCIDevice *pci_dev, int region_num, pcibus_t 
> addr, pcibus_t size, int type)
> +{
> + Â ÂPCIXenPlatformState *d = (PCIXenPlatformState *)pci_dev;

Useless cast in C. Moreover, you should use DO_UPCAST or container_of.

> + Â Âregister_ioport_write(addr, size, 1, xen_platform_ioport_writeb, d);
> + Â Âregister_ioport_read(addr, size, 1, xen_platform_ioport_readb, d);
> +}
> +
> +static uint32_t platform_mmio_read(void *opaque, target_phys_addr_t addr)
> +{
> + Â Âstatic int warnings = 0;
> + Â Âif (warnings < 5) {
> + Â Â Â Âfprintf(stderr, "Warning: attempted read from physical address "
> + Â Â Â Â Â Â Â Â"0x%"PRIx64" in xen platform mmio space\n", (uint64_t)addr);

Instead of the cast, you should use TARGET_FMT_plx.

> + Â Â Â Âwarnings++;
> + Â Â}
> + Â Âreturn 0;
> +}
> +
> +static void platform_mmio_write(void *opaque, target_phys_addr_t addr,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âuint32_t val)
> +{
> + Â Âstatic int warnings = 0;
> + Â Âif (warnings < 5) {
> + Â Â Â Âfprintf(stderr, "Warning: attempted write of 0x%x to physical "
> + Â Â Â Â Â Â Â Â"address 0x%"PRIx64" in xen platform mmio space\n",
> + Â Â Â Â Â Â Â Âval, (uint64_t)addr);
> + Â Â Â Âwarnings++;
> + Â Â}
> + Â Âreturn;
> +}
> +
> +static CPUReadMemoryFunc *platform_mmio_read_funcs[3] = {

These should be 'const'.

> + Â Âplatform_mmio_read,
> + Â Âplatform_mmio_read,
> + Â Âplatform_mmio_read,
> +};
> +
> +static CPUWriteMemoryFunc *platform_mmio_write_funcs[3] = {
> + Â Âplatform_mmio_write,
> + Â Âplatform_mmio_write,
> + Â Âplatform_mmio_write,
> +};
> +
> +static void platform_mmio_map(PCIDevice *d, int region_num,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âpcibus_t addr, pcibus_t size, int type)
> +{
> + Â Âint mmio_io_addr;
> +
> + Â Âmmio_io_addr = cpu_register_io_memory(platform_mmio_read_funcs,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âplatform_mmio_write_funcs, NULL);
> +
> + Â Âcpu_register_physical_memory(addr, 0x1000000, mmio_io_addr);
> +}
> +
> +struct pci_config_header {
> + Â Âuint16_t vendor_id;
> + Â Âuint16_t device_id;
> + Â Âuint16_t command;
> + Â Âuint16_t status;
> + Â Âuint8_t Ârevision;
> + Â Âuint8_t Âapi;
> + Â Âuint8_t Âsubclass;
> + Â Âuint8_t Âclass;
> + Â Âuint8_t Âcache_line_size; /* Units of 32 bit words */
> + Â Âuint8_t Âlatency_timer; /* In units of bus cycles */
> + Â Âuint8_t Âheader_type; /* Should be 0 */
> + Â Âuint8_t Âbist; /* Built in self test */
> + Â Âuint32_t base_address_regs[6];
> + Â Âuint32_t reserved1;
> + Â Âuint16_t subsystem_vendor_id;
> + Â Âuint16_t subsystem_id;
> + Â Âuint32_t rom_addr;
> + Â Âuint32_t reserved3;
> + Â Âuint32_t reserved4;
> + Â Âuint8_t Âinterrupt_line;
> + Â Âuint8_t Âinterrupt_pin;
> + Â Âuint8_t Âmin_gnt;
> + Â Âuint8_t Âmax_lat;
> +};

Why can't you use the facilities from pci.h?

> +
> +static void xen_pci_save(QEMUFile *f, void *opaque)
> +{
> + Â ÂPCIXenPlatformState *d = opaque;
> + Â Âuint64_t t = 0;
> +
> + Â Âpci_device_save(&d->pci_dev, f);
> + Â Âqemu_put_be64s(f, &t);
> +}
> +
> +static int xen_pci_load(QEMUFile *f, void *opaque, int version_id)
> +{
> + Â ÂPCIXenPlatformState *d = opaque;
> + Â Âint ret;
> +
> + Â Âif (version_id > 3)
> + Â Â Â Âreturn -EINVAL;
> +
> + Â Âret = pci_device_load(&d->pci_dev, f);
> + Â Âif (ret < 0)
> + Â Â Â Âreturn ret;
> +
> + Â Âif (version_id >= 2) {
> + Â Â Â Âif (version_id == 2) {
> + Â Â Â Â Â Âuint8_t flags;
> + Â Â Â Â Â Âqemu_get_8s(f, &flags);
> + Â Â Â Â Â Âxen_platform_ioport_writeb(d, 0, flags);
> + Â Â Â Â}
> + Â Â Â Âqemu_get_be64(f);
> + Â Â}
> +
> + Â Âreturn 0;
> +}
> +
> +void pci_xen_platform_init(PCIBus *bus)
> +{
> + Â ÂPCIXenPlatformState *d;
> + Â Âstruct pci_config_header *pch;
> +
> + Â Âprintf("Register xen platform.\n");
> + Â Âd = (PCIXenPlatformState *)pci_register_device(
> + Â Â Â Âbus, "xen-platform", sizeof(PCIXenPlatformState), -1, NULL, NULL);
> + Â Âpch = (struct pci_config_header *)d->pci_dev.config;
> + Â Âpch->vendor_id = 0x5853;

You should use pci_set_word etc. Please add 0x5853 to pci_ids.h.

> + Â Âpch->device_id = 0x0001;
> + Â Âpch->command = 3; /* IO and memory access */
> + Â Âpch->revision = 1;
> + Â Âpch->api = 0;
> + Â Âpch->subclass = 0x80; /* Other */
> + Â Âpch->class = 0xff; /* Unclassified device class */
> + Â Âpch->header_type = 0;
> + Â Âpch->interrupt_pin = 1;
> +
> + Â Â/* Microsoft WHQL requires non-zero subsystem IDs. */
> + Â Â/* http://www.pcisig.com/reflector/msg02205.html. Â*/
> + Â Âpch->subsystem_vendor_id = pch->vendor_id; /* Duplicate vendor id. Â*/
> +  Âpch->subsystem_id    Â= 0x0001;     /* Hardcode sub-id as 1. */
> +
> + Â Âpci_register_bar(&d->pci_dev, 0, 0x100,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â PCI_BASE_ADDRESS_SPACE_IO, platform_ioport_map);
> +
> + Â Â/* reserve 16MB mmio address for share memory*/
> + Â Âpci_register_bar(&d->pci_dev, 1, 0x1000000,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â PCI_BASE_ADDRESS_MEM_PREFETCH, platform_mmio_map);
> +
> + Â Âregister_savevm(NULL, "platform", 0, 3, xen_pci_save, xen_pci_load, d);
> + Â Âprintf("Done register platform.\n");
> +}
> +
> diff --git a/hw/xen_platform.h b/hw/xen_platform.h
> new file mode 100644
> index 0000000..6eeff22
> --- /dev/null
> +++ b/hw/xen_platform.h
> @@ -0,0 +1,9 @@
> +#ifndef XEN_PLATFORM_H
> +#define XEN_PLATFORM_H
> +
> +#include "hw/pci.h"
> +
> +void pci_xen_platform_init(PCIBus *bus);
> +void platform_fixed_ioport_init(void);
> +
> +#endif
> --
> 1.7.0.4
>
>
>

_______________________________________________
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®.