SOURCES (LINUX_2_6_14): acpi-dsdt-initrd-v0.8b-2.6.14.patch (NEW) ...

arekm arekm at pld-linux.org
Sat Jan 14 18:09:56 CET 2006


Author: arekm                        Date: Sat Jan 14 17:09:56 2006 GMT
Module: SOURCES                       Tag: LINUX_2_6_14
---- Log message:
- updated to 0.8b

---- Files affected:
SOURCES:
   acpi-dsdt-initrd-v0.8b-2.6.14.patch (NONE -> 1.1.2.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/acpi-dsdt-initrd-v0.8b-2.6.14.patch
diff -u /dev/null SOURCES/acpi-dsdt-initrd-v0.8b-2.6.14.patch:1.1.2.1
--- /dev/null	Sat Jan 14 18:09:56 2006
+++ SOURCES/acpi-dsdt-initrd-v0.8b-2.6.14.patch	Sat Jan 14 18:09:51 2006
@@ -0,0 +1,297 @@
+diff -X /home/eric/dontdiff -urpN linux-2.6.14.bak/Documentation/dsdt-initrd.txt linux-2.6.14/Documentation/dsdt-initrd.txt
+--- linux-2.6.14.bak/Documentation/dsdt-initrd.txt	1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.14/Documentation/dsdt-initrd.txt	2005-11-06 18:42:59.000000000 +0100
+@@ -0,0 +1,83 @@
++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, 2005 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 ramdisk (not as module!) and initrd
++(in 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 initrd.img DSDT.aml
++
++The message "Looking for DSDT in initrd..." 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 ================================
++#!/bin/bash
++# Adds a 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
++
++# check the arguments
++if [ $# -ne 2 ]; then
++        program_name=$(basename $0)
++        echo "\
++$program_name: too few arguments
++Usage: $program_name initrd-name.img file-to-add
++Adds a file to an initrd (in initramfs format)
++
++  initrd-name.img: filename of the initrd in initramfs format
++  file-to-add: filename of the file to add
++  " 1>&2
++    exit 1
++fi
++
++tempcpio=$(mktemp)
++# cleanup on exit, hangup, interrupt, quit, termination
++trap 'rm -f $tempcpio' 0 1 2 3 15
++
++# extract the archive
++gunzip -c "$1" > $tempcpio || exit 1
++
++# add the file
++(echo "$2" | cpio --quiet -c -o -A -O $tempcpio) || exit 1
++
++# re-compress the archive
++gzip -c $tempcpio > "$1"
++
+diff -X /home/eric/dontdiff -urpN linux-2.6.14.bak/drivers/acpi/Kconfig linux-2.6.14/drivers/acpi/Kconfig
+--- linux-2.6.14.bak/drivers/acpi/Kconfig	2005-11-06 14:53:27.000000000 +0100
++++ linux-2.6.14/drivers/acpi/Kconfig	2005-11-06 15:53:41.000000000 +0100
+@@ -249,6 +249,23 @@ config ACPI_CUSTOM_DSDT_FILE
+ 	help
+ 	  Enter the full path name to the file wich includes the AmlCode declaration.
+ 
++config ACPI_CUSTOM_DSDT_INITRD
++	bool "Read Custom DSDT from initramfs"
++	depends on X86
++	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
++	  initrd (initramfs only). For now you need to use a special mkinitrd tool.
++	  For more details see file: Documentation/dsdt-initrd.txt . 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
+ 	default 0
+diff -X /home/eric/dontdiff -urpN linux-2.6.14.bak/drivers/acpi/osl.c linux-2.6.14/drivers/acpi/osl.c
+--- linux-2.6.14.bak/drivers/acpi/osl.c	2005-11-06 14:53:27.000000000 +0100
++++ linux-2.6.14/drivers/acpi/osl.c	2005-11-10 00:17:43.000000000 +0100
+@@ -44,6 +44,7 @@
+ #include <asm/uaccess.h>
+ 
+ #include <linux/efi.h>
++#include <linux/syscalls.h>
+ 
+ #define _COMPONENT		ACPI_OS_SERVICES
+ ACPI_MODULE_NAME("osl")
+@@ -70,6 +71,10 @@ extern char line_buf[80];
+ int acpi_specific_hotkey_enabled = TRUE;
+ EXPORT_SYMBOL(acpi_specific_hotkey_enabled);
+ 
++#ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD
++int acpi_must_unregister_table = FALSE;
++#endif
++
+ static unsigned int acpi_irq_irq;
+ static acpi_osd_handler acpi_irq_handler;
+ static void *acpi_irq_context;
+@@ -244,6 +249,63 @@ acpi_os_predefined_override(const struct
+ 	return AE_OK;
+ }
+ 
++#ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD
++struct acpi_table_header * acpi_find_dsdt_initrd(void)
++{
++	int fd;
++	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 static/init firmware,
++	 * which doesn't exist yet...
++	 */
++	fd = sys_open(ramfs_dsdt_name, O_RDONLY, 0);
++	if (fd < 0) {
++		printk("error, could not open file %s.\n", ramfs_dsdt_name);
++		return ret;
++	}
++
++	if (vfs_stat(ramfs_dsdt_name, &stat) < 0) {
++		printk("error getting stats for file %s.\n", ramfs_dsdt_name);
++		goto err;
++	}
++
++	len = stat.size;
++	/* check especially against empty files */
++	if (len < 4) {
++		printk("error file is too small, only %lu bytes.\n", len);
++		goto err;
++	}
++
++	dsdt_buffer = ACPI_MEM_ALLOCATE(len);
++	if (!dsdt_buffer) {
++		printk("error when allocating %lu bytes of memory.\n", len);
++		goto err;
++	}
++
++	len2 = sys_read(fd, (char __user *)dsdt_buffer, len);
++	if (len2 < len ) {
++		printk("error trying to read %lu bytes from %s.\n", len, ramfs_dsdt_name);
++		ACPI_MEM_FREE(dsdt_buffer);
++		goto err;
++	}
++
++	printk("successfully read %lu bytes from %s.\n", len, ramfs_dsdt_name);
++	ret = dsdt_buffer;
++err:
++	sys_close(fd);
++	return ret;
++}
++#endif
++
+ acpi_status
+ acpi_os_table_override(struct acpi_table_header * existing_table,
+ 		       struct acpi_table_header ** new_table)
+@@ -251,13 +313,20 @@ 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;
++			acpi_must_unregister_table = TRUE;
++		}
++	}
+ #endif
+ 	return AE_OK;
+ }
+diff -X /home/eric/dontdiff -urpN linux-2.6.14.bak/drivers/acpi/tables/tbget.c linux-2.6.14/drivers/acpi/tables/tbget.c
+--- linux-2.6.14.bak/drivers/acpi/tables/tbget.c	2005-10-16 13:16:28.000000000 +0200
++++ linux-2.6.14/drivers/acpi/tables/tbget.c	2005-11-06 16:26:51.000000000 +0100
+@@ -272,6 +272,14 @@ acpi_tb_table_override(struct acpi_table
+ 	address.pointer.logical = new_table;
+ 
+ 	status = acpi_tb_get_this_table(&address, new_table, table_info);
++
++#ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD
++	if (acpi_must_unregister_table) {
++		ACPI_MEM_FREE(new_table);
++		acpi_must_unregister_table = FALSE;
++	}
++#endif
++
+ 	if (ACPI_FAILURE(status)) {
+ 		ACPI_REPORT_ERROR(("Could not copy override ACPI table, %s\n",
+ 				   acpi_format_exception(status)));
+diff -X /home/eric/dontdiff -urpN linux-2.6.14.bak/include/acpi/acpiosxf.h linux-2.6.14/include/acpi/acpiosxf.h
+--- linux-2.6.14.bak/include/acpi/acpiosxf.h	2005-11-10 00:17:12.000000000 +0100
++++ linux-2.6.14/include/acpi/acpiosxf.h	2005-11-10 00:16:08.000000000 +0100
+@@ -91,6 +91,10 @@ acpi_status
+ acpi_os_table_override(struct acpi_table_header *existing_table,
+ 		       struct acpi_table_header **new_table);
+ 
++#ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD
++extern int acpi_must_unregister_table;
++#endif
++
+ /*
+  * Synchronization primitives
+  */
+diff -X /home/eric/dontdiff -urpN linux-2.6.14.bak/init/main.c linux-2.6.14/init/main.c
+--- linux-2.6.14.bak/init/main.c	2005-10-16 13:17:05.000000000 +0200
++++ linux-2.6.14/init/main.c	2005-11-06 15:53:41.000000000 +0100
+@@ -540,8 +540,6 @@ asmlinkage void __init start_kernel(void
+ 
+ 	check_bugs();
+ 
+-	acpi_early_init(); /* before LAPIC and SMP init */
+-
+ 	/* Do the rest non-__init'ed, we're now alive */
+ 	rest_init();
+ }
+@@ -671,6 +669,14 @@ static int init(void * unused)
+ 	 */
+ 	child_reaper = current;
+ 
++	/*
++	 * Do this before initcalls, because some drivers want to access
++	 * firmware files.
++	 */
++	populate_rootfs();
++
++	acpi_early_init(); /* before LAPIC and SMP init */
++
+ 	/* Sets up cpus_possible() */
+ 	smp_prepare_cpus(max_cpus);
+ 
+@@ -682,12 +688,6 @@ static int init(void * unused)
+ 
+ 	cpuset_init_smp();
+ 
+-	/*
+-	 * Do this before initcalls, because some drivers want to access
+-	 * firmware files.
+-	 */
+-	populate_rootfs();
+-
+ 	do_basic_setup();
+ 
+ 	/*
================================================================


More information about the pld-cvs-commit mailing list