All of lore.kernel.org
 help / color / mirror / Atom feed
From: Akio Takebe <takebe_akio@jp.fujitsu.com>
To: xen-devel <xen-devel@lists.xensource.com>
Subject: [Patch][2/2][BIOS] Support BCV table
Date: Thu, 26 Mar 2009 22:43:44 +0900	[thread overview]
Message-ID: <49CB8690.6090800@jp.fujitsu.com> (raw)
In-Reply-To: <49CB85BC.3010806@jp.fujitsu.com>

[-- Attachment #1: Type: text/plain, Size: 116 bytes --]

Hi,

This patch is qemu parts.

Signed-off-by: Akio Takebe <takebe_akio@jp.fujitsu.com>

Best Regards,

Akio Takebe

[-- Attachment #2: bcv.qemu.patch --]
[-- Type: text/x-diff, Size: 5756 bytes --]

diff --git a/hw/pass-through.c b/hw/pass-through.c
index f23bdbb..43a5e20 100644
--- a/hw/pass-through.c
+++ b/hw/pass-through.c
@@ -27,6 +27,8 @@
 #include "pci/pci.h"
 #include "pt-msi.h"
 #include "qemu-xen.h"
+#include "xen/hvm/hvm_info_table.h"
+#include <sys/mman.h>
 #include <unistd.h>
 
 struct php_dev {
@@ -3634,6 +3636,60 @@ static int pt_pmcsr_reg_restore(struct pt_dev *ptdev,
     return 0;
 }
 
+static int
+pt_register_bootable_device(uint32_t e_devfn, int pci_boot)
+{
+    uint8_t *hvm_info_page;
+    struct hvm_info_table *hvm_info;
+    int i;
+    uint8_t sum;
+    uint32_t devfn; 
+    int rc = -1;
+
+    if (pci_boot <= 0 ) {
+        PT_LOG("Error: pci_boot=%d\n", pci_boot);
+        goto out;
+    }
+
+    hvm_info_page = xc_map_foreign_range(xc_handle, domid, XC_PAGE_SIZE,
+                                            PROT_READ|PROT_WRITE, HVM_INFO_PFN);
+    if (hvm_info_page == NULL){
+        PT_LOG("Error: xc_map_foreign_rage(HVM_INFO_PFN) error %d\n", errno);
+        goto out;
+    }
+    hvm_info = (struct hvm_info_table *)(hvm_info_page+HVM_INFO_OFFSET);
+
+    if ( strncmp(hvm_info->signature, "HVM INFO", 8) ) {
+        PT_LOG("Error: Bad hvm info signature(%s)\n", hvm_info->signature);
+        goto free;
+    }
+
+    for ( i = 0; i < MAX_PCI_BOOT; i++ ) { 
+        if ( hvm_info->pci_sbdf[i] == 0 ) {
+            hvm_info->pci_sbdf[i] = e_devfn;
+            break;
+        } else {
+            if ( i == MAX_PCI_BOOT ){
+                PT_LOG("Error: cannot enable bootable option (devfn=%x:%x)\n",
+                        (e_devfn>>3)&&0x1f, e_devfn&&0x7);
+                goto free;
+            }
+        }
+    }
+
+    hvm_info->checksum = 0;
+    for ( i = 0, sum = 0; i < hvm_info->length; i++ )
+        sum += ((uint8_t *)hvm_info)[i];
+    hvm_info->checksum = -sum;
+    rc = 0;
+
+free:
+    munmap(hvm_info_page, XC_PAGE_SIZE);
+out:
+    return rc;
+}
+
+
 struct pt_dev * register_real_device(PCIBus *e_bus,
         const char *e_dev_name, int e_devfn, uint8_t r_bus, uint8_t r_dev,
         uint8_t r_func, uint32_t machine_irq, struct pci_access *pci_access,
@@ -3647,6 +3703,7 @@ struct pt_dev * register_real_device(PCIBus *e_bus,
     int free_slot = -1;
     char *key, *val;
     int msi_translate, power_mgmt;
+    int pci_boot = 0;
 
     PT_LOG("Assigning real physical device %02x:%02x.%x ...\n",
         r_bus, r_dev, r_func);
@@ -3716,6 +3773,19 @@ struct pt_dev * register_real_device(PCIBus *e_bus,
             else
                 PT_LOG("Error: unrecognized value for power_mgmt=\n");
         }
+        else if (strcmp(key, "boot") == 0)
+            if (strcmp(val, "0") == 0 || strcmp(val, "no") == 0)
+            {
+                PT_LOG("Disable boot option\n");
+                pci_boot = 0;
+            }
+            else if (strcmp(val, "1") == 0 || strcmp(val, "yes") == 0)
+            {
+                PT_LOG("Enable boot option\n");
+                pci_boot = 1;
+            }
+            else
+                PT_LOG("Error: unrecognized value for boot=\n");
         else
             PT_LOG("Error: unrecognized PCI assignment option \"%s=%s\"\n", key, val);
 
@@ -3810,6 +3880,12 @@ struct pt_dev * register_real_device(PCIBus *e_bus,
             *(uint16_t *)(&assigned_device->dev.config[0x04]));
     }
 
+    if (pci_boot){
+        rc = pt_register_bootable_device(e_devfn, pci_boot);
+        if ( rc < 0 )
+            return NULL;
+    }
+
 out:
     PT_LOG("Real physical device %02x:%02x.%x registered successfuly!\n"
            "IRQ type = %s\n", r_bus, r_dev, r_func,
diff --git a/hw/pc.c b/hw/pc.c
index 878069d..bd376a0 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -215,6 +215,8 @@ static int boot_device2nibble(char boot_device)
         return 0x03; /* CD-ROM boot */
     case 'n':
         return 0x04; /* Network boot */
+    case 'p':
+        return 0x05; /* Pass-trough device */
     }
     return 0;
 }
diff --git a/vl.c b/vl.c
index 5801e42..9476218 100644
--- a/vl.c
+++ b/vl.c
@@ -3944,7 +3944,9 @@ static void help(int exitcode)
            "-mtdblock file  use 'file' as on-board Flash memory image\n"
            "-sd file        use 'file' as SecureDigital card image\n"
            "-pflash file    use 'file' as a parallel flash image\n"
-           "-boot [a|c|d|n] boot on floppy (a), hard disk (c), CD-ROM (d), or network (n)\n"
+           "-boot [a|c|d|n|p]\n"
+           "                boot on floppy (a), hard disk (c), CD-ROM (d), network (n)\n"
+           "                or PCI pass-through(p)\n"
            "-snapshot       write to temporary files instead of disk image files\n"
            "-m megs         set virtual RAM size to megs MB [default=%d]\n"
 #ifndef _WIN32
@@ -4982,7 +4984,8 @@ int main(int argc, char **argv, char **envp)
                          * a b     : floppy disk drives
                          * c ... f : IDE disk drives
                          * g ... m : machine implementation dependant drives
-                         * n ... p : network devices
+                         * n ... o : network devices
+                         * p       : PCI pass-through devices
                          * It's up to each machine implementation to check
                          * if the given boot devices match the actual hardware
                          * implementation and firmware features.
@@ -5525,7 +5528,7 @@ int main(int argc, char **argv, char **envp)
         kqemu_allowed = 0;
 #endif
     linux_boot = (kernel_filename != NULL);
-    net_boot = (boot_devices_bitmap >> ('n' - 'a')) & 0xF;
+    net_boot = (boot_devices_bitmap >> ('n' - 'a')) & 0x2;
 
     if (!linux_boot && net_boot == 0 &&
         !machine->nodisk_ok && nb_drives_opt == 0)

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

  parent reply	other threads:[~2009-03-26 13:43 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-26 13:40 [Patch][0/2][BIOS] Support BCV table Akio Takebe
2009-03-26 13:42 ` Akio Takebe
2009-03-26 13:46   ` [Patch][1/2][BIOS] " Akio Takebe
2009-03-26 13:43 ` Akio Takebe [this message]
2009-03-26 14:36   ` [Patch][2/2][BIOS] " Keir Fraser
2009-03-27  0:48     ` Akio Takebe
2009-03-27  4:44       ` Akio Takebe
2009-03-27  9:02         ` Keir Fraser
2009-03-27  9:00       ` Keir Fraser
2009-03-27 10:23         ` Akio Takebe
2009-03-27 10:31           ` Akio Takebe
2009-03-27 13:49             ` Keir Fraser
2009-03-27 14:22               ` Akio Takebe
2009-03-30  6:50             ` Akio Takebe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49CB8690.6090800@jp.fujitsu.com \
    --to=takebe_akio@jp.fujitsu.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.