WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 15 of 15] hvmloader: add code to generate a $PIR tabl

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 15 of 15] hvmloader: add code to generate a $PIR table
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Wed, 1 Jun 2011 10:40:10 +0100
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Delivery-date: Wed, 01 Jun 2011 02:52:54 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1306921195@xxxxxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <patchbomb.1306921195@xxxxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.6.4
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1306918266 -3600
# Node ID b47bc708c79191ee7ca15d4e642a4609fe26d88b
# Parent  7e6e8594316a62193f9ab629ee2b8848224cce22
hvmloader: add code to generate a $PIR table.

Does not replace the table hardcoded in ROMBIOS (it ain't broke) but is used
for SeaBIOS.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r 7e6e8594316a -r b47bc708c791 tools/firmware/hvmloader/Makefile
--- a/tools/firmware/hvmloader/Makefile Wed Jun 01 09:46:20 2011 +0100
+++ b/tools/firmware/hvmloader/Makefile Wed Jun 01 09:51:06 2011 +0100
@@ -30,7 +30,7 @@ CFLAGS += $(CFLAGS_xeninclude)
 
 OBJS  = hvmloader.o mp_tables.o util.o smbios.o 
 OBJS += 32bitbios_support.o smp.o cacheattr.o xenbus.o
-OBJS += e820.o pci.o
+OBJS += e820.o pci.o pir.o
 ifeq ($(debug),y)
 OBJS += tests.o
 endif
diff -r 7e6e8594316a -r b47bc708c791 tools/firmware/hvmloader/config.h
--- a/tools/firmware/hvmloader/config.h Wed Jun 01 09:46:20 2011 +0100
+++ b/tools/firmware/hvmloader/config.h Wed Jun 01 09:51:06 2011 +0100
@@ -31,6 +31,7 @@ struct bios_config {
     void (*acpi_build_tables)(void);
     void (*create_mp_tables)(void);
     void (*create_smbios_tables)(void);
+    void (*create_pir_tables)(void);
 };
 
 extern struct bios_config rombios_config;
diff -r 7e6e8594316a -r b47bc708c791 tools/firmware/hvmloader/hvmloader.c
--- a/tools/firmware/hvmloader/hvmloader.c      Wed Jun 01 09:46:20 2011 +0100
+++ b/tools/firmware/hvmloader/hvmloader.c      Wed Jun 01 09:51:06 2011 +0100
@@ -423,9 +423,12 @@ int main(void)
     if (bios->bios_relocate)
         bios->bios_relocate();
 
-    if ( bios->create_mp_tables &&
-         ( (hvm_info->nr_vcpus > 1) || hvm_info->apic_mode ) )
-        bios->create_mp_tables();
+    if ( (hvm_info->nr_vcpus > 1) || hvm_info->apic_mode ) {
+        if ( bios->create_mp_tables )
+            bios->create_mp_tables();
+        if ( bios->create_pir_tables )
+            bios->create_pir_tables();
+    }
 
     if ( bios->load_roms )
     {
diff -r 7e6e8594316a -r b47bc708c791 tools/firmware/hvmloader/pir.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/firmware/hvmloader/pir.c    Wed Jun 01 09:51:06 2011 +0100
@@ -0,0 +1,67 @@
+/*
+ * pir.c: Support for genrating $PIR tables.
+ *
+ * Copyright (c) 2011 Citrix Systems Inc
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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.
+ */
+
+#include "config.h"
+#include "pir_types.h"
+#include "util.h"
+
+/*
+ * The structure of these tables is described in
+ * http://www.microsoft.com/taiwan/whdc/archive/pciirq.mspx
+ */
+unsigned long create_pir_tables(void)
+{
+    int length = sizeof(struct pir_table) + sizeof(struct 
pir_slot)*NR_PIR_SLOTS;
+    struct pir_table *pir = scratch_alloc(length, 0);
+    int i, checksum;
+
+    memset(pir, 0, length);
+
+    memcpy(pir->signature, "$PIR", 4);
+    pir->version = 0x0100;
+    pir->length = length;
+
+    pir->router_bus = 0;
+    pir->router_devfn = PCI_ISA_DEVFN;
+    pir->router_vid = 0x8086;
+    pir->router_did = 0x122e;
+
+    pir->pci_irqs = 0x0000;
+
+    for ( i = 0 ; i < NR_PIR_SLOTS; i++ )
+    {
+        struct pir_slot *slot = &pir->slots[i];
+        slot->slot = i;
+        slot->bus = 0;
+        slot->dev = i<<3;
+        slot->link_a = 0x60 + (i+1)%4;
+        slot->bitmap_a = PCI_ISA_IRQ_MASK;
+        slot->link_b = 0x60 + (i+2)%4;
+        slot->bitmap_b = PCI_ISA_IRQ_MASK;
+        slot->link_c = 0x60 + (i+3)%4;
+        slot->bitmap_c = PCI_ISA_IRQ_MASK;
+        slot->link_d = 0x60 + (i+4)%4;
+        slot->bitmap_d = PCI_ISA_IRQ_MASK;
+    }
+
+    checksum = 0;
+    for ( i = 0; i < length; i++)
+    {
+        checksum += ((int8_t *)pir)[i];
+    }
+    pir->checksum = -checksum;
+
+    return (unsigned long)pir;
+}
diff -r 7e6e8594316a -r b47bc708c791 tools/firmware/hvmloader/pir_types.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/firmware/hvmloader/pir_types.h      Wed Jun 01 09:51:06 2011 +0100
@@ -0,0 +1,61 @@
+/*
+ * pir_types.h - data structure definitions for Xen HVM $PIR support
+ *
+ * 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) Citrix Systems, 2011
+ *
+ * See the PCI Interrupt Routing spec for more detail:
+ *   http://www.microsoft.com/taiwan/whdc/archive/pciirq.mspx
+ */
+
+#ifndef PIR_TYPES_H
+#define PIR_TYPES_H
+
+#include <stdint.h>
+
+#define NR_PIR_SLOTS 6
+
+struct pir_slot {
+    uint8_t bus;
+    uint8_t dev;
+    uint8_t link_a;
+    uint16_t bitmap_a;
+    uint8_t link_b;
+    uint16_t bitmap_b;
+    uint8_t link_c;
+    uint16_t bitmap_c;
+    uint8_t link_d;
+    uint16_t bitmap_d;
+    uint8_t slot;
+    uint8_t reserved;
+} __attribute__ ((packed));
+
+struct pir_table {
+    char signature[4];
+    uint16_t version;
+    uint16_t length;
+    uint8_t router_bus;
+    uint8_t router_devfn;
+    uint16_t pci_irqs;
+    uint16_t router_vid;
+    uint16_t router_did;
+    uint32_t miniport_data;
+    uint8_t reserved[11];
+    uint8_t checksum;
+    struct pir_slot slots[0];
+} __attribute__ ((packed));
+
+#endif
diff -r 7e6e8594316a -r b47bc708c791 tools/firmware/hvmloader/rombios.c
--- a/tools/firmware/hvmloader/rombios.c        Wed Jun 01 09:46:20 2011 +0100
+++ b/tools/firmware/hvmloader/rombios.c        Wed Jun 01 09:51:06 2011 +0100
@@ -187,6 +187,7 @@ struct bios_config rombios_config =  {
     .acpi_build_tables = rombios_acpi_build_tables,
     .create_mp_tables = rombios_create_mp_tables,
     .create_smbios_tables = rombios_create_smbios_tables,
+    .create_pir_tables = NULL, /* embedded in ROMBIOS */
 };
 
 /*
diff -r 7e6e8594316a -r b47bc708c791 tools/firmware/hvmloader/seabios.c
--- a/tools/firmware/hvmloader/seabios.c        Wed Jun 01 09:46:20 2011 +0100
+++ b/tools/firmware/hvmloader/seabios.c        Wed Jun 01 09:51:06 2011 +0100
@@ -107,6 +107,11 @@ static void seabios_create_smbios_tables
     add_table(ep);
 }
 
+static void seabios_create_pir_tables(void)
+{
+    add_table(create_pir_tables());
+}
+
 static void seabios_setup_e820(void)
 {
     struct seabios_info *info = (void *)BIOS_INFO_PHYSICAL_ADDRESS;
@@ -142,6 +147,7 @@ struct bios_config seabios_config = {
     .acpi_build_tables = seabios_acpi_build_tables,
     .create_mp_tables = seabios_create_mp_tables,
     .create_smbios_tables = seabios_create_smbios_tables,
+    .create_pir_tables = seabios_create_pir_tables,
 };
 
 /*
diff -r 7e6e8594316a -r b47bc708c791 tools/firmware/hvmloader/util.h
--- a/tools/firmware/hvmloader/util.h   Wed Jun 01 09:46:20 2011 +0100
+++ b/tools/firmware/hvmloader/util.h   Wed Jun 01 09:51:06 2011 +0100
@@ -195,6 +195,8 @@ unsigned long create_mp_tables(void *tab
 void hvm_write_smbios_tables(unsigned long ep,
                            unsigned long smbios_start,
                            unsigned long smbios_end);
+unsigned long create_pir_tables(void);
+
 void smp_initialise(void);
 
 #include "e820.h"

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

<Prev in Thread] Current Thread [Next in Thread>