Skip to contentSkip to conversation

x86: Early platform detection based on boot param subarch id

PATCH In review Thomas Gleixner 2 participants 6 messages Aug 30, 2009 – Sep 1, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover x86: Early platform detection based on boot param subarch id

Moorestown needs to tweak x86_init functions in the early boot process. Moorestown can be identified by subarch id in the boot params. The following series implements the necessary change in the early boot code and hooks up MRST early setup.

Thanks,

tglx

#1 lore raw

PATCH 1/3 x86: Add early platform detection

Platforms like Moorestown require early setup and want to avoid the call to reserve_ebda_region. The x86_init override is too late when the MRST detection happens in setup_arch. Move the default i386 x86_init overrides and the call to reserve_ebda_region into a separate function which is called as the default of a switch case depending on the hardware_subarch id in boot params. This allows us to add a case for MRST and let MRST have its own early setup function.

---
 arch/x86/include/asm/x86_init.h |    3 +--
 arch/x86/kernel/head32.c        |   22 +++++++++++++++++-----
 arch/x86/kernel/head64.c        |    3 ++-
 arch/x86/kernel/x86_init.c      |    1 -
 4 files changed, 20 insertions(+), 9 deletions(-)
arch/x86/include/asm/x86_init.h +1 -2
Index: linux-2.6-tip/arch/x86/include/asm/x86_init.h
===================================================================
@@ -2,6 +2,7 @@
 #define _ASM_X86_PLATFORM_H
 
 #include <asm/pgtable_types.h>
+#include <asm/bootparam.h>
 
 struct mpc_bus;
 struct mpc_cpu;
@@ -34,14 +35,12 @@ struct x86_init_mpparse {
  * @probe_roms:			probe BIOS roms
  * @reserve_resources:		reserve the standard resources for the
  *				platform
- * @reserve_ebda_region:	reserve the extended bios data area
  * @memory_setup:		platform specific memory setup
  *
  */
 struct x86_init_resources {
 	void (*probe_roms)(void);
 	void (*reserve_resources)(void);
-	void (*reserve_ebda_region)(void);
 	char *(*memory_setup)(void);
 };
 
arch/x86/kernel/head32.c +17 -5
Index: linux-2.6-tip/arch/x86/kernel/head32.c
===================================================================
@@ -15,6 +15,17 @@
 #include <asm/trampoline.h>
 #include <asm/apic.h>
 #include <asm/io_apic.h>
+#include <asm/bios_ebda.h>
+
+static void __init i386_default_early_setup(void)
+{
+	/* Initilize 32bit specific setup functions */
+	x86_init.resources.probe_roms = probe_roms;
+	x86_init.resources.reserve_resources = i386_reserve_resources;
+	x86_init.mpparse.setup_ioapic_ids = setup_ioapic_ids_from_mpc;
+
+	reserve_ebda_region();
+}
 
 void __init i386_start_kernel(void)
 {
@@ -31,12 +42,13 @@ void __init i386_start_kernel(void)
 		reserve_early(ramdisk_image, ramdisk_end, "RAMDISK");
 	}
 #endif
-	/* Initilize 32bit specific setup functions */
-	x86_init.resources.probe_roms = probe_roms;
-	x86_init.resources.reserve_resources = i386_reserve_resources;
-	x86_init.mpparse.setup_ioapic_ids = setup_ioapic_ids_from_mpc;
 
-	x86_init.resources.reserve_ebda_region();
+	/* Call the subarch specific early setup function */
+	switch (boot_params.hdr.hardware_subarch) {
+	default:
+		i386_default_early_setup();
+		break;
+	}
 
 	/*
 	 * At this point everything still needed from the boot loader
arch/x86/kernel/head64.c +2 -1
Index: linux-2.6-tip/arch/x86/kernel/head64.c
===================================================================
@@ -24,6 +24,7 @@
 #include <asm/kdebug.h>
 #include <asm/e820.h>
 #include <asm/trampoline.h>
+#include <asm/bios_ebda.h>
 
 static void __init zap_identity_mappings(void)
 {
@@ -111,7 +112,7 @@ void __init x86_64_start_reservations(ch
 	}
 #endif
 
-	x86_init.resources.reserve_ebda_region();
+	reserve_ebda_region();
 
 	/*
 	 * At this point everything still needed from the boot loader
arch/x86/kernel/x86_init.c +0 -1
Index: linux-2.6-tip/arch/x86/kernel/x86_init.c
===================================================================
@@ -28,7 +28,6 @@ struct __initdata x86_init_ops x86_init 
 	.resources = {
 		.probe_roms		= x86_init_noop,
 		.reserve_resources	= reserve_standard_io_resources,
-		.reserve_ebda_region	= reserve_ebda_region,
 		.memory_setup		= default_machine_specific_memory_setup,
 	},
 
#2 lore raw

PATCH 2/3 x86/boot: adding hw subarch ID for Moorestown

In reply to Thomas Gleixner

From: Jacob Pan <[email protected]>
Date: Thu, 11 Jun 2009 20:34:47 -0700
Subject: [patch 2/3] [PATCH] x86/boot: adding hw subarch ID for Moorestown

x86 bootprotocol 2.07 has introduced hardware_subarch ID in the boot parameters provided by FW. We use it to identify Moorestown platforms.

The subarchitecture ID will help select a set of platform features and x86_quirks.

[ tglx: Cleanup and paravirt fix ]

---
 Documentation/x86/boot.txt       |    1 +
 arch/x86/include/asm/bootparam.h |   10 ++++++++++
 arch/x86/kernel/head_32.S        |    1 +
 3 files changed, 12 insertions(+)
Documentation/x86/boot.txt +1 -0
Index: linux-2.6-tip/Documentation/x86/boot.txt
===================================================================
@@ -599,6 +599,7 @@ Protocol:	2.07+
   0x00000000	The default x86/PC environment
   0x00000001	lguest
   0x00000002	Xen
+  0x00000003	Moorestown MID
 
 Field name:	hardware_subarch_data
 Type:		write (subarch-dependent)
arch/x86/include/asm/bootparam.h +10 -0
Index: linux-2.6-tip/arch/x86/include/asm/bootparam.h
===================================================================
@@ -109,4 +109,14 @@ struct boot_params {
 	__u8  _pad9[276];				/* 0xeec */
 } __attribute__((packed));
 
+enum {
+	X86_SUBARCH_PC = 0,
+	X86_SUBARCH_LGUEST,
+	X86_SUBARCH_XEN,
+	X86_SUBARCH_MRST,
+	X86_NR_SUBARCHS,
+};
+
+
+
 #endif /* _ASM_X86_BOOTPARAM_H */
arch/x86/kernel/head_32.S +1 -0
Index: linux-2.6-tip/arch/x86/kernel/head_32.S
===================================================================
@@ -157,6 +157,7 @@ subarch_entries:
 	.long default_entry		/* normal x86/PC */
 	.long lguest_entry		/* lguest hypervisor */
 	.long xen_entry			/* Xen hypervisor */
+	.long default_entry		/* Moorestown MID */
 num_subarch_entries = (. - subarch_entries) / 4
 .previous
 #endif /* CONFIG_PARAVIRT */
#3 lore raw

Re: [patch 2/3] x86/boot: adding hw subarch ID for Moorestown

Hi,

I think there is a typo (copy/paste error), see below:

Quoted 57 lines · On Sun, 30 Aug 2009 13:46:28 -0000 Thomas Gleixner <[email protected]> wrote:

From: Jacob Pan <[email protected]>
Date: Thu, 11 Jun 2009 20:34:47 -0700
Subject: [patch 2/3] [PATCH] x86/boot: adding hw subarch ID for Moorestown

x86 bootprotocol 2.07 has introduced hardware_subarch ID in the boot parameters provided by FW. We use it to identify Moorestown platforms.

The subarchitecture ID will help select a set of platform features and x86_quirks.

[ tglx: Cleanup and paravirt fix ]

---
 Documentation/x86/boot.txt       |    1 +
 arch/x86/include/asm/bootparam.h |   10 ++++++++++
 arch/x86/kernel/head_32.S        |    1 +
 3 files changed, 12 insertions(+)

Index: linux-2.6-tip/Documentation/x86/boot.txt
===================================================================

Documentation/x86/boot.txt +1 -0
@@ -599,6 +599,7 @@ Protocol:	2.07+
   0x00000000	The default x86/PC environment
   0x00000001	lguest
   0x00000002	Xen
+  0x00000003	Moorestown MID
 
 Field name:	hardware_subarch_data
 Type:		write (subarch-dependent)

Index: linux-2.6-tip/arch/x86/include/asm/bootparam.h
===================================================================

arch/x86/include/asm/bootparam.h +10 -0
@@ -109,4 +109,14 @@ struct boot_params {
 	__u8  _pad9[276];				/* 0xeec */
 } __attribute__((packed));
 
+enum {
+	X86_SUBARCH_PC = 0,
+	X86_SUBARCH_LGUEST,
+	X86_SUBARCH_XEN,
+	X86_SUBARCH_MRST,
+	X86_NR_SUBARCHS,
+};
+
+
+
 #endif /* _ASM_X86_BOOTPARAM_H */

Index: linux-2.6-tip/arch/x86/kernel/head_32.S
===================================================================

arch/x86/kernel/head_32.S subarch_entries: · line 160

Quoted 4 lines
arch/x86/kernel/head_32.S +1 -0
@@ -157,6 +157,7 @@ subarch_entries:
 	.long default_entry		/* normal x86/PC */
 	.long lguest_entry		/* lguest hypervisor */
 	.long xen_entry			/* Xen hypervisor */
+	.long default_entry		/* Moorestown MID */

Typo: s/default_entry/mrst_entry

arch/x86/kernel/head_32.S subarch_entries: · line 163

Quoted 3 lines
arch/x86/kernel/head_32.S +0 -0
 num_subarch_entries = (. - subarch_entries) / 4
 .previous
 #endif /* CONFIG_PARAVIRT */

Daniele
--

#4 lore raw

Re: [patch 2/3] x86/boot: adding hw subarch ID for Moorestown

Quoted 14 lines · Daniele Calore

I think there is a typo (copy/paste error), see below:

arch/x86/kernel/head_32.S subarch_entries: · line 160

Quoted 10 lines

#endif /* _ASM_X86_BOOTPARAM_H */
Index: linux-2.6-tip/arch/x86/kernel/head_32.S
===================================================================

arch/x86/kernel/head_32.S +1 -0
@@ -157,6 +157,7 @@ subarch_entries:
 	.long default_entry		/* normal x86/PC */
 	.long lguest_entry		/* lguest hypervisor */
 	.long xen_entry			/* Xen hypervisor */
+	.long default_entry		/* Moorestown MID */

Typo: s/default_entry/mrst_entry

That's not a typo. :)

MRST will not go via an separate entry it uses the default one and we evaluate the hardware_subarch id later in i386_start_kernel. That change is just necessecary that a paravirt enabled kernel does not end up in bad_subarch for the MRST id.

Thanks,

tglx

#5 lore raw

PATCH 3/3 x86: Add Moorestown early detection

In reply to Thomas Gleixner

Moorestown MID devices need to be detected early in the boot process to setup and do not call x86_default_early_setup as there is no EBDA region to reserve.

[ Copied the minimal code from Jacobs latest MRST series ]

---
 arch/x86/Kconfig             |   13 +++++++++++++
 arch/x86/include/asm/setup.h |    6 ++++++
 arch/x86/kernel/Makefile     |    1 +
 arch/x86/kernel/head32.c     |    3 +++
 arch/x86/kernel/mrst.c       |   24 ++++++++++++++++++++++++
 5 files changed, 47 insertions(+)
arch/x86/Kconfig +13 -0
Index: linux-2.6-tip/arch/x86/Kconfig
===================================================================
@@ -318,6 +318,7 @@ config X86_EXTENDED_PLATFORM
 		SGI 320/540 (Visual Workstation)
 		Summit/EXA (IBM x440)
 		Unisys ES7000 IA32 series
+		Moorestown MID devices
 
 	  If you have one of these systems, or if you want to build a
 	  generic distribution kernel, say Y here - otherwise say N.
@@ -377,6 +378,18 @@ config X86_ELAN
 
 	  If unsure, choose "PC-compatible" instead.
 
+config X86_MRST
+       bool "Moorestown MID platform"
+	depends on X86_32
+	depends on X86_EXTENDED_PLATFORM
+	---help---
+	  Moorestown is Intel's Low Power Intel Architecture (LPIA) based Moblin
+	  Internet Device(MID) platform. Moorestown consists of two chips:
+	  Lincroft (CPU core, graphics, and memory controller) and Langwell IOH.
+	  Unlike standard x86 PCs, Moorestown does not have many legacy devices
+	  nor standard legacy replacement devices/features. e.g. Moorestown does
+	  not contain i8259, i8254, HPET, legacy BIOS, most of the io ports.
+
 config X86_RDC321X
 	bool "RDC R-321x SoC"
 	depends on X86_32
arch/x86/include/asm/setup.h +6 -0
Index: linux-2.6-tip/arch/x86/include/asm/setup.h
===================================================================
@@ -49,6 +49,12 @@ extern void reserve_standard_io_resource
 extern void i386_reserve_resources(void);
 extern void setup_default_timer_irq(void);
 
+#ifdef CONFIG_X86_MRST
+extern void x86_mrst_early_setup(void);
+#else
+static inline void x86_mrst_early_setup(void) { }
+#endif
+
 #ifndef _SETUP
 
 /*
arch/x86/kernel/Makefile +1 -0
Index: linux-2.6-tip/arch/x86/kernel/Makefile
===================================================================
@@ -104,6 +104,7 @@ obj-$(CONFIG_SCx200)		+= scx200.o
 scx200-y			+= scx200_32.o
 
 obj-$(CONFIG_OLPC)		+= olpc.o
+obj-$(CONFIG_X86_MRST)		+= mrst.o
 
 microcode-y				:= microcode_core.o
 microcode-$(CONFIG_MICROCODE_INTEL)	+= microcode_intel.o
arch/x86/kernel/head32.c +3 -0
Index: linux-2.6-tip/arch/x86/kernel/head32.c
===================================================================
@@ -45,6 +45,9 @@ void __init i386_start_kernel(void)
 
 	/* Call the subarch specific early setup function */
 	switch (boot_params.hdr.hardware_subarch) {
+	case X86_SUBARCH_MRST:
+		x86_mrst_early_setup();
+		break;
 	default:
 		i386_default_early_setup();
 		break;
arch/x86/kernel/mrst.c new file +24 -0
Index: linux-2.6-tip/arch/x86/kernel/mrst.c
===================================================================
@@ -0,0 +1,24 @@
+/*
+ * mrst.c: Intel Moorestown platform specific setup code
+ *
+ * (C) Copyright 2008 Intel Corporation
+ * Author: Jacob Pan ([email protected])
+ *
+ * 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; version 2
+ * of the License.
+ */
+#include <linux/init.h>
+
+#include <asm/setup.h>
+
+/*
+ * Moorestown specific x86_init function overrides and early setup
+ * calls.
+ */
+void __init x86_mrst_early_setup(void)
+{
+	x86_init.resources.probe_roms = x86_init_noop;
+	x86_init.resources.reserve_resources = x86_init_noop;
+}