All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jan Beulich" <jbeulich@novell.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] linux/x86: Obtain EDD info from Xen
Date: Tue, 19 Jun 2007 11:43:13 +0100	[thread overview]
Message-ID: <4677CF61.76E4.0078.0@novell.com> (raw)

Subject: Obtain EDD info from Xen

Taken from our 2.6.22-rc4 tree and made apply - without further testing.
The patch contains the necessary adjustment to the public headers - if
that's being pushed to the linux tree automatically, the respective hunk
must be removed before applying.

Signed-off-by: Jan Beulich <jbeulich@novell.com>

Index: head-2007-05-31/arch/i386/kernel/setup-xen.c
===================================================================
--- head-2007-05-31.orig/arch/i386/kernel/setup-xen.c	2007-06-04 14:09:07.000000000 +0200
+++ head-2007-05-31/arch/i386/kernel/setup-xen.c	2007-06-01 16:59:22.000000000 +0200
@@ -66,6 +66,7 @@
 #include <xen/interface/physdev.h>
 #include <xen/interface/memory.h>
 #include <xen/features.h>
+#include <xen/firmware.h>
 #include <xen/xencons.h>
 #include <setup_arch.h>
 #include <bios_ebda.h>
@@ -170,6 +171,7 @@ struct edd edd;
 #ifdef CONFIG_EDD_MODULE
 EXPORT_SYMBOL(edd);
 #endif
+#ifndef CONFIG_XEN
 /**
  * copy_edd() - Copy the BIOS EDD information
  *              from boot_params into a safe place.
@@ -182,6 +184,7 @@ static inline void copy_edd(void)
      edd.mbr_signature_nr = EDD_MBR_SIG_NR;
      edd.edd_info_nr = EDD_NR;
 }
+#endif
 #else
 static inline void copy_edd(void)
 {
Index: head-2007-05-31/arch/x86_64/kernel/setup-xen.c
===================================================================
--- head-2007-05-31.orig/arch/x86_64/kernel/setup-xen.c	2007-06-04 14:09:07.000000000 +0200
+++ head-2007-05-31/arch/x86_64/kernel/setup-xen.c	2007-06-01 16:59:22.000000000 +0200
@@ -71,6 +71,7 @@
 #include <asm/hypervisor.h>
 #include <xen/interface/nmi.h>
 #include <xen/features.h>
+#include <xen/firmware.h>
 #include <xen/xencons.h>
 #define PFN_UP(x)       (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
 #define PFN_PHYS(x)     ((x) << PAGE_SHIFT)
@@ -225,6 +226,7 @@ struct edd edd;
 #ifdef CONFIG_EDD_MODULE
 EXPORT_SYMBOL(edd);
 #endif
+#ifndef CONFIG_XEN
 /**
  * copy_edd() - Copy the BIOS EDD information
  *              from boot_params into a safe place.
@@ -237,6 +239,7 @@ static inline void copy_edd(void)
      edd.mbr_signature_nr = EDD_MBR_SIG_NR;
      edd.edd_info_nr = EDD_NR;
 }
+#endif
 #else
 static inline void copy_edd(void)
 {
Index: head-2007-05-31/drivers/firmware/Kconfig
===================================================================
--- head-2007-05-31.orig/drivers/firmware/Kconfig	2007-06-04 14:09:07.000000000 +0200
+++ head-2007-05-31/drivers/firmware/Kconfig	2007-06-01 16:59:22.000000000 +0200
@@ -8,7 +8,6 @@ menu "Firmware Drivers"
 config EDD
 	tristate "BIOS Enhanced Disk Drive calls determine boot disk"
 	depends on !IA64
-	depends on !XEN
 	help
 	  Say Y or M here if you want to enable BIOS Enhanced Disk Drive
 	  Services real mode BIOS calls to determine which disk
Index: head-2007-05-31/drivers/xen/core/Makefile
===================================================================
--- head-2007-05-31.orig/drivers/xen/core/Makefile	2007-06-04 14:09:07.000000000 +0200
+++ head-2007-05-31/drivers/xen/core/Makefile	2007-06-04 14:09:17.000000000 +0200
@@ -2,7 +2,7 @@
 # Makefile for the linux kernel.
 #
 
-obj-y := evtchn.o gnttab.o features.o reboot.o machine_reboot.o
+obj-y := evtchn.o gnttab.o features.o reboot.o machine_reboot.o firmware.o
 
 obj-$(CONFIG_PROC_FS)		+= xen_proc.o
 obj-$(CONFIG_SYSFS)		+= hypervisor_sysfs.o
Index: head-2007-05-31/drivers/xen/core/firmware.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ head-2007-05-31/drivers/xen/core/firmware.c	2007-06-01 16:59:22.000000000 +0200
@@ -0,0 +1,61 @@
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/edd.h>
+#include <xen/interface/platform.h>
+#include <asm/hypervisor.h>
+
+#if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
+void __init copy_edd(void)
+{
+	int ret;
+	xen_platform_op_t op;
+
+	if (!is_initial_xendomain())
+		return;
+
+	op.cmd = XENPF_firmware_info;
+
+	for (op.u.firmware_info.index = 0, ret = 0;
+	     ret != -ESRCH && ret != -ENOSYS && edd.edd_info_nr < EDDMAXNR;
+	     ++op.u.firmware_info.index) {
+		struct edd_info *info = edd.edd_info + edd.edd_info_nr;
+
+		op.u.firmware_info.type = XEN_FW_EDD_INFO;
+		ret = HYPERVISOR_platform_op(&op);
+		if (ret)
+			continue;
+		info->device            = op.u.firmware_info.u.edd_info.device;
+		info->version           = op.u.firmware_info.u.edd_info.version;
+		info->interface_support = op.u.firmware_info.u.edd_info.interface;
+
+		op.u.firmware_info.type = XEN_FW_DISK_INFO;
+		ret = HYPERVISOR_platform_op(&op);
+		if (ret)
+			continue;
+		info->legacy_max_cylinder      = op.u.firmware_info.u.disk_info.max_cylinder;
+		info->legacy_max_head          = op.u.firmware_info.u.disk_info.max_head;
+		info->legacy_sectors_per_track = op.u.firmware_info.u.disk_info.sectors_per_track;
+
+		op.u.firmware_info.type = XEN_FW_EDD_PARAMS;
+		info->params.length = sizeof(info->params);
+		set_xen_guest_handle(op.u.firmware_info.u.edd_params, &info->params);
+		ret = HYPERVISOR_platform_op(&op);
+		if (ret)
+			continue;
+
+		++edd.edd_info_nr;
+	}
+
+	op.u.firmware_info.type = XEN_FW_MBR_SIGNATURE;
+	for (op.u.firmware_info.index = 0, ret = 0;
+	     ret != -ESRCH && ret != -ENOSYS && edd.mbr_signature_nr < EDD_MBR_SIG_MAX;
+	     ++op.u.firmware_info.index) {
+
+		ret = HYPERVISOR_platform_op(&op);
+		if (ret)
+			continue;
+		edd.mbr_signature[edd.mbr_signature_nr++] = op.u.firmware_info.u.mbr_signature;
+	}
+}
+#endif
Index: head-2007-05-31/include/xen/firmware.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ head-2007-05-31/include/xen/firmware.h	2007-06-01 16:59:22.000000000 +0200
@@ -0,0 +1,6 @@
+#ifndef __XEN_FIRMWARE_H__
+#define __XEN_FIRMWARE_H__
+
+void copy_edd(void);
+
+#endif /* __XEN_FIRMWARE_H__ */
Index: head-2007-05-31/include/xen/interface/platform.h
===================================================================
--- head-2007-05-31.orig/include/xen/interface/platform.h	2007-06-04 14:09:07.000000000 +0200
+++ head-2007-05-31/include/xen/interface/platform.h	2007-06-01 16:59:22.000000000 +0200
@@ -114,6 +114,35 @@ struct xenpf_platform_quirk {
 typedef struct xenpf_platform_quirk xenpf_platform_quirk_t;
 DEFINE_XEN_GUEST_HANDLE(xenpf_platform_quirk_t);
 
+#define XENPF_firmware_info       50
+#define XEN_FW_DISK_INFO          1 /* from int 13 AH=08 */
+#define XEN_FW_EDD_INFO           2 /* from int 13 AH=41 */
+#define XEN_FW_EDD_PARAMS         3 /* from int 13 AH=48 */
+#define XEN_FW_MBR_SIGNATURE      4
+struct xenpf_firmware_info {
+    /* IN variables. */
+    uint32_t type;
+    uint32_t index;
+    /* OUT variables. */
+    union {
+        struct {
+            uint16_t max_cylinder;
+            uint8_t max_head;
+            uint8_t sectors_per_track;
+        } disk_info;
+        struct {
+            uint8_t device;
+            uint8_t version;
+            uint16_t interface;
+        } edd_info;
+        /* first uint16_t of buffer must be set to buffer size */
+        XEN_GUEST_HANDLE(void) edd_params;
+        uint32_t mbr_signature;
+    } u;
+};
+typedef struct xenpf_firmware_info xenpf_firmware_info_t;
+DEFINE_XEN_GUEST_HANDLE(xenpf_firmware_info_t);
+
 struct xen_platform_op {
     uint32_t cmd;
     uint32_t interface_version; /* XENPF_INTERFACE_VERSION */
@@ -124,6 +153,7 @@ struct xen_platform_op {
         struct xenpf_read_memtype      read_memtype;
         struct xenpf_microcode_update  microcode;
         struct xenpf_platform_quirk    platform_quirk;
+        struct xenpf_firmware_info     firmware_info;
         uint8_t                        pad[128];
     } u;
 };

             reply	other threads:[~2007-06-19 10:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-19 10:43 Jan Beulich [this message]
2007-06-21 21:05 ` [PATCH] linux/x86: Obtain EDD info from Xen Jeremy Fitzhardinge
2007-06-21 21:40   ` Keir Fraser

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=4677CF61.76E4.0078.0@novell.com \
    --to=jbeulich@novell.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.