[arch-commits] CVS update of arch/build/kernels/kernel26 (1 file)

Tobias Powalowski tpowa at archlinux.org
Sun Apr 29 02:50:29 EDT 2007


    Date: Sunday, April 29, 2007 @ 02:50:29
  Author: tpowa
    Path: /home/cvs-arch/arch/build/kernels/kernel26

   Added: acpi-dsdt-initrd-v0.8.4-2.6.21.patch (1.1)

'upgpkg: added missing dsdt patch'


--------------------------------------+
 acpi-dsdt-initrd-v0.8.4-2.6.21.patch |  275 +++++++++++++++++++++++++++++++++
 1 file changed, 275 insertions(+)


Index: arch/build/kernels/kernel26/acpi-dsdt-initrd-v0.8.4-2.6.21.patch
diff -u /dev/null arch/build/kernels/kernel26/acpi-dsdt-initrd-v0.8.4-2.6.21.patch:1.1
--- /dev/null	Sun Apr 29 02:50:29 2007
+++ arch/build/kernels/kernel26/acpi-dsdt-initrd-v0.8.4-2.6.21.patch	Sun Apr 29 02:50:29 2007
@@ -0,0 +1,275 @@
+diff -urpN -X linux-2.6.21/Documentation/dontdiff linux-2.6.21-rc4.bak/Documentation/dsdt-initrd.txt linux-2.6.21/Documentation/dsdt-initrd.txt
+--- linux-2.6.21-rc4.bak/Documentation/dsdt-initrd.txt	1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.21/Documentation/dsdt-initrd.txt	2007-03-03 23:06:58.000000000 +0100
+@@ -0,0 +1,98 @@
++ACPI Custom DSDT read from initramfs
++
++2003 by Markuss Gaugusch < dsdt at gaugusch dot org >
++Special thanks go to Thomas Renninger from SuSE, who updated the patch for
++2.6.0 and later modified it to read inside initramfs
++2004 - 2007 maintained by Eric Piel < eric dot piel at tremplin-utc dot net >
++
++This option is intended for people who would like to hack their DSDT and don't want
++to recompile their kernel after every change. It can also be useful to distros
++which offers pre-compiled kernels and want to allow their users to use a
++modified DSDT. In the Kernel config, enable the initial RAM filesystem support
++(in Device Drivers|Block Devices) and enable ACPI_CUSTOM_DSDT_INITRD at the ACPI
++options (General Setup|ACPI Support|Read custom DSDT from initrd).
++
++A custom DSDT (Differentiated System Description Table) is useful when your
++computer uses ACPI but problems occur due to broken implementation. Typically,
++your computer works but there are some troubles with the hardware detection or
++the power management. You can check that troubles come from errors in the DSDT by
++activating the ACPI debug option and reading the logs. This table is provided
++by the BIOS, therefore it might be a good idea to check for BIOS update on your
++vendor website before going any further. Errors are often caused by vendors
++testing their hardware only with Windows or because there is code which is
++executed only on a specific OS with a specific version and Linux hasn't been
++considered during the development.
++
++Before you run away from customising your DSDT, you should note that already
++corrected tables are available for a fair amount of computers on this web-page:
++http://acpi.sf.net/dsdt . If you are part of the unluckies who cannot find
++their hardware in this database, you can modify your DSDT by yourself. This
++process is less painful than it sounds. Download the Intel ASL 
++compiler/decompiler at http://www.intel.com/technology/IAPC/acpi/downloads.htm .
++As root, you then have to dump your DSDT and decompile it. By using the
++compiler messages as well as the kernel ACPI debug messages and the reference book
++(available at the Intel website and also at http://www.acpi.info), it is quite
++easy to obtain a fully working table.
++
++Once your new DSDT is ready you'll have to add it to an initrd so that the
++kernel can read the table at the very beginning of the boot. As the file has
++to be accessed very early during the boot process the initrd has to be an
++initramfs. The file is contained into the initramfs under the name /DSDT.aml .
++To obtain such an initrd, you might have to modify your mkinitrd script or you
++can add it later to the initrd with the script appended to this document. The
++command will look like:
++initrd-add-dsdt initrd.img my-dsdt.aml
++
++In case you don't use any initrd, the possibilities you have are to either start
++using one (try mkinitrd or yaird), or use the "Include Custom DSDT" configure
++option to directly include your DSDT inside the kernel.
++
++The message "Looking for DSDT in initramfs..." will tell you if the DSDT was
++found or not. If you need to update your DSDT, generate a new initrd and
++perform the steps above. Don't forget that with Lilo, you'll have to re-run it.
++
++
++======================= Here starts initrd-add-dsdt ===============================
++#!/bin/bash
++# Adds a DSDT file to the initrd (if it's an initramfs)
++# first argument is the name of archive
++# second argurment is the name of the file to add
++# The file will be copied as /DSDT.aml
++
++# 20060126: fix "Premature end of file" with some old cpio (Roland Robic)
++# 20060205: this time it should really work
++
++# check the arguments
++if [ $# -ne 2 ]; then
++	program_name=$(basename $0)
++	echo "\
++$program_name: too few arguments
++Usage: $program_name initrd-name.img DSDT-to-add.aml
++Adds a DSDT file to an initrd (in initramfs format)
++
++  initrd-name.img: filename of the initrd in initramfs format
++  DSDT-to-add.aml: filename of the DSDT file to add
++  " 1>&2
++    exit 1
++fi
++
++# we should check it's an initramfs
++
++tempcpio=$(mktemp -d)
++# cleanup on exit, hangup, interrupt, quit, termination
++trap 'rm -rf $tempcpio' 0 1 2 3 15
++
++# extract the archive
++gunzip -c "$1" > "$tempcpio"/initramfs.cpio || exit 1
++
++# copy the DSDT file at the root of the directory so that we can call it "/DSDT.aml"
++cp -f "$2" "$tempcpio"/DSDT.aml
++
++# add the file
++cd "$tempcpio"
++(echo DSDT.aml | cpio --quiet -H newc -o -A -O "$tempcpio"/initramfs.cpio) || exit 1
++cd "$OLDPWD"
++
++# re-compress the archive
++gzip -c "$tempcpio"/initramfs.cpio > "$1"
++
+diff -urpN -X linux-2.6.21/Documentation/dontdiff linux-2.6.21-rc4.bak/drivers/acpi/Kconfig linux-2.6.21/drivers/acpi/Kconfig
+--- linux-2.6.21-rc4.bak/drivers/acpi/Kconfig	2007-03-18 12:58:03.000000000 +0100
++++ linux-2.6.21/drivers/acpi/Kconfig	2007-03-17 01:28:53.000000000 +0100
+@@ -298,6 +298,23 @@ config ACPI_CUSTOM_DSDT_FILE
+ 	  Enter the full path name to the file which includes the AmlCode
+ 	  declaration.
+ 
++config ACPI_CUSTOM_DSDT_INITRD
++	bool "Read Custom DSDT from initramfs"
++	depends on BLK_DEV_INITRD
++	default y
++	help
++	  The DSDT (Differentiated System Description Table) often needs to be
++	  overridden because of broken BIOS implementations. If this feature is
++	  activated you will be able to provide a customized DSDT by adding it
++	  to your initramfs.  For now you need to use a special mkinitrd tool.
++	  For more details see <file:Documentation/dsdt-initrd.txt> or 
++	  <http://gaugusch.at/kernel.shtml>. If there is no table found, it 
++	  will fallback to the custom DSDT in-kernel (if activated) or to the
++	  DSDT from the BIOS.
++
++	  Even if you do not need a new one at the moment, you may want to use a
++	  better implemented DSDT later. It is safe to say Y here.
++
+ config ACPI_BLACKLIST_YEAR
+ 	int "Disable ACPI for systems before Jan 1st this year" if X86_32
+ 	default 0
+diff -urpN -X linux-2.6.21/Documentation/dontdiff linux-2.6.21-rc4.bak/drivers/acpi/osl.c linux-2.6.21/drivers/acpi/osl.c
+--- linux-2.6.21-rc4.bak/drivers/acpi/osl.c	2007-03-18 12:55:13.000000000 +0100
++++ linux-2.6.21/drivers/acpi/osl.c	2007-03-17 10:26:06.000000000 +0100
+@@ -256,6 +256,67 @@ acpi_os_predefined_override(const struct
+ 	return AE_OK;
+ }
+ 
++#ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD
++struct acpi_table_header * acpi_find_dsdt_initrd(void)
++{
++	struct file *firmware_file;
++	mm_segment_t oldfs;
++	unsigned long len, len2;
++	struct acpi_table_header *dsdt_buffer, *ret = NULL;
++	struct kstat stat;
++	/* maybe this could be an argument on the cmd line, but let's keep it simple for now */
++	char *ramfs_dsdt_name = "/DSDT.aml";
++
++	printk(KERN_INFO PREFIX "Looking for DSDT in initramfs... ");
++
++	/* 
++	 * Never do this at home, only the user-space is allowed to open a file.
++	 * The clean way would be to use the firmware loader. But this code must be run
++	 * before there is any userspace available. So we need a static/init firmware 
++	 * infrastructure, which doesn't exist yet...
++	 */
++	if (vfs_stat(ramfs_dsdt_name, &stat) < 0) {
++		printk("error, file %s not found.\n", ramfs_dsdt_name);
++		return ret;
++	}
++
++	len = stat.size;
++	/* check especially against empty files */
++	if (len <= 4) {
++		printk("error file is too small, only %lu bytes.\n", len);
++		return ret;
++	}
++
++	firmware_file = filp_open(ramfs_dsdt_name, O_RDONLY, 0);
++	if (IS_ERR(firmware_file)) {
++		printk("error, could not open file %s.\n", ramfs_dsdt_name);
++		return ret;
++	}
++
++	dsdt_buffer = ACPI_ALLOCATE(len);
++	if (!dsdt_buffer) {
++		printk("error when allocating %lu bytes of memory.\n", len);
++		goto err;
++	}
++
++	oldfs = get_fs();
++	set_fs(KERNEL_DS);
++	len2 = vfs_read(firmware_file, (char __user *)dsdt_buffer, len, &firmware_file->f_pos);
++	set_fs(oldfs);
++	if (len2 < len) {
++		printk("error trying to read %lu bytes from %s.\n", len, ramfs_dsdt_name);
++		ACPI_FREE(dsdt_buffer);
++		goto err;
++	}
++
++	printk("successfully read %lu bytes from %s.\n", len, ramfs_dsdt_name);
++	ret = dsdt_buffer;
++err:
++	filp_close(firmware_file, NULL);
++	return ret;
++}
++#endif
++
+ acpi_status
+ acpi_os_table_override(struct acpi_table_header * existing_table,
+ 		       struct acpi_table_header ** new_table)
+@@ -263,13 +324,18 @@ acpi_os_table_override(struct acpi_table
+ 	if (!existing_table || !new_table)
+ 		return AE_BAD_PARAMETER;
+ 
++	*new_table = NULL;
++
+ #ifdef CONFIG_ACPI_CUSTOM_DSDT
+ 	if (strncmp(existing_table->signature, "DSDT", 4) == 0)
+ 		*new_table = (struct acpi_table_header *)AmlCode;
+-	else
+-		*new_table = NULL;
+-#else
+-	*new_table = NULL;
++#endif
++#ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD
++	if (strncmp(existing_table->signature, "DSDT", 4) == 0) {
++		struct acpi_table_header* initrd_table = acpi_find_dsdt_initrd();
++		if (initrd_table)
++			*new_table = initrd_table;
++	}
+ #endif
+ 	return AE_OK;
+ }
+diff -urpN -X linux-2.6.21/Documentation/dontdiff linux-2.6.21-rc4.bak/init/initramfs.c linux-2.6.21/init/initramfs.c
+--- linux-2.6.21-rc4.bak/init/initramfs.c	2007-03-18 12:56:47.000000000 +0100
++++ linux-2.6.21/init/initramfs.c	2007-03-03 23:07:05.000000000 +0100
+@@ -541,6 +541,26 @@ skip:
+ 
+ #endif
+ 
++/* Tries to read the initramfs if it's already there, for ACPI Table Overiding */
++void __init early_populate_rootfs(void)
++{
++	char *err = unpack_to_rootfs(__initramfs_start,
++			 __initramfs_end - __initramfs_start, 0);
++	if (err)
++		return;
++#ifdef CONFIG_BLK_DEV_INITRD
++	if (initrd_start) {
++		printk(KERN_INFO "Early unpacking initramfs...");
++		err = unpack_to_rootfs((char *)initrd_start,
++			initrd_end - initrd_start, 0);
++		if (err)
++			return;
++		printk(" done\n");
++	}
++#endif
++	return;
++}
++
+ static int __init populate_rootfs(void)
+ {
+ 	char *err = unpack_to_rootfs(__initramfs_start,
+diff -urpN -X linux-2.6.21/Documentation/dontdiff linux-2.6.21-rc4.bak/init/main.c linux-2.6.21/init/main.c
+--- linux-2.6.21-rc4.bak/init/main.c	2007-03-18 12:56:47.000000000 +0100
++++ linux-2.6.21/init/main.c	2007-03-03 23:07:05.000000000 +0100
+@@ -97,8 +97,10 @@ extern void free_initmem(void);
+ extern void prepare_namespace(void);
+ #ifdef	CONFIG_ACPI
+ extern void acpi_early_init(void);
++extern void early_populate_rootfs(void);
+ #else
+ static inline void acpi_early_init(void) { }
++static inline void early_populate_rootfs(void) { }
+ #endif
+ #ifndef CONFIG_DEBUG_RODATA
+ static inline void mark_rodata_ro(void) { }
+@@ -635,6 +637,7 @@ asmlinkage void __init start_kernel(void
+ 
+ 	check_bugs();
+ 
++	early_populate_rootfs(); /* For DSDT override from initramfs */
+ 	acpi_early_init(); /* before LAPIC and SMP init */
+ 
+ 	/* Do the rest non-__init'ed, we're now alive */




More information about the arch-commits mailing list