SOURCES (LINUX_2_6): acpi-dsdt-initrd-v0.7d-2.6.12.patch (NEW), ac...

arekm arekm at pld-linux.org
Thu Aug 11 18:49:14 CEST 2005


Author: arekm                        Date: Thu Aug 11 16:49:14 2005 GMT
Module: SOURCES                       Tag: LINUX_2_6
---- Log message:
- new, ACPI DSDT in initrd support

---- Files affected:
SOURCES:
   acpi-dsdt-initrd-v0.7d-2.6.12.patch (NONE -> 1.1.2.1)  (NEW), acpi-dsdt-initramfs-fix-2.6.10-cleanup.patch (NONE -> 1.1.2.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/acpi-dsdt-initrd-v0.7d-2.6.12.patch
diff -u /dev/null SOURCES/acpi-dsdt-initrd-v0.7d-2.6.12.patch:1.1.2.1
--- /dev/null	Thu Aug 11 18:49:14 2005
+++ SOURCES/acpi-dsdt-initrd-v0.7d-2.6.12.patch	Thu Aug 11 18:49:09 2005
@@ -0,0 +1,156 @@
+diff -urpN -X /home/eric/dontdiff linux-2.6.12-rc6.orig/Documentation/dsdt-initrd.txt linux-2.6.12-rc6/Documentation/dsdt-initrd.txt
+--- linux-2.6.12-rc6.orig/Documentation/dsdt-initrd.txt	1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.12-rc6/Documentation/dsdt-initrd.txt	2005-06-12 10:54:37.000000000 +0200
+@@ -0,0 +1,48 @@
++ACPI Custom DSDT read from initrd
++
++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
++2004 maintained by Eric Piel < eric dot piel at tremplin-utc dot net >
++
++This option is intended for people who 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 occurs 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. If you don't have
++any initrd yet, you can just specify the table as an initrd file (in lilo or
++grub) and it will work. Otherwise you have to separate the DSDT from the rest
++by a signature. Do it like it:
++echo -n "INITRDDSDT123DSDT123" >> /boot/initrd #magic signature
++cat DSDT.aml >> /boot/initrd
++
++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.
++
++
+diff -urpN -X /home/eric/dontdiff linux-2.6.12-rc6.orig/drivers/acpi/Kconfig linux-2.6.12-rc6/drivers/acpi/Kconfig
+--- linux-2.6.12-rc6.orig/drivers/acpi/Kconfig	2005-06-12 10:51:51.000000000 +0200
++++ linux-2.6.12-rc6/drivers/acpi/Kconfig	2005-06-12 10:55:46.000000000 +0200
+@@ -248,6 +248,22 @@ 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 initrd"
++	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 you want to use
++	  a customized DSDT, please use the mkinitrd tool (mkinitrd package) to
++	  attach the DSDT to the initrd. For more details see
++	  file: Documentation/dsdt-initrd.txt . If there is no table found in the
++	  initrd, the DSDT from the BIOS is used.
++
++	  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"
+ 	depends on ACPI_INTERPRETER
+diff -urpN -X /home/eric/dontdiff linux-2.6.12-rc6.orig/drivers/acpi/osl.c linux-2.6.12-rc6/drivers/acpi/osl.c
+--- linux-2.6.12-rc6.orig/drivers/acpi/osl.c	2005-06-12 10:51:51.000000000 +0200
++++ linux-2.6.12-rc6/drivers/acpi/osl.c	2005-06-12 10:54:37.000000000 +0200
+@@ -35,6 +35,7 @@
+ #include <linux/interrupt.h>
+ #include <linux/kmod.h>
+ #include <linux/delay.h>
++#include <linux/initrd.h>
+ #include <linux/workqueue.h>
+ #include <linux/nmi.h>
+ #include <acpi/acpi.h>
+@@ -246,6 +247,43 @@ acpi_os_predefined_override (const struc
+ 	return AE_OK;
+ }
+ 
++#ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD
++struct acpi_table_header * acpi_find_dsdt_initrd(void)
++{
++	unsigned char start_signature[] = "INITRDDSDT123DSDT123";
++	unsigned char *data = (unsigned char*)initrd_start;
++	unsigned char *dsdt_start = NULL;
++
++	if (!initrd_start)
++		return NULL;
++
++	printk(KERN_INFO PREFIX "Looking for DSDT in initrd...");
++	if ((initrd_end - initrd_start) > 4 && 
++		!strncmp((unsigned char*)initrd_start, "DSDT", 4))
++		/* found DSDT at start of initrd */
++		dsdt_start = (unsigned char*)initrd_start; 
++	else { /* searching for start signature in initrd */
++		for (; data < (unsigned char*)initrd_end; data++) {
++			if (!strncmp(data, start_signature,
++					   sizeof(start_signature) - 1)) {
++				dsdt_start = data + sizeof(start_signature) - 1;
++				break;
++			}
++		}
++	}
++	/* check if head of dsdt is valid */
++	if (dsdt_start && !strncmp(dsdt_start, "DSDT", 4)) {
++		printk(" found (at offset 0x%02x).\n", 
++			(unsigned int) (dsdt_start - (unsigned char*)initrd_start));
++		return (struct acpi_table_header*)dsdt_start;
++	} else
++		printk(" not found.\n");
++	
++	/* no DSDT found */
++	return NULL;
++}
++#endif
++
+ acpi_status
+ acpi_os_table_override (struct acpi_table_header *existing_table,
+ 			struct acpi_table_header **new_table)
+@@ -253,13 +291,18 @@ acpi_os_table_override (struct acpi_tabl
+ 	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;
+ }

================================================================
Index: SOURCES/acpi-dsdt-initramfs-fix-2.6.10-cleanup.patch
diff -u /dev/null SOURCES/acpi-dsdt-initramfs-fix-2.6.10-cleanup.patch:1.1.2.1
--- /dev/null	Thu Aug 11 18:49:14 2005
+++ SOURCES/acpi-dsdt-initramfs-fix-2.6.10-cleanup.patch	Thu Aug 11 18:49:09 2005
@@ -0,0 +1,59 @@
+--- linux-2.6.11-rc4/./init/initramfs.c.bak	2005-02-23 00:42:19.000000000 +0100
++++ linux-2.6.11-rc4/./init/initramfs.c	2005-02-23 00:53:42.000000000 +0100
+@@ -468,6 +468,31 @@ extern char __initramfs_start[], __initr
+ #include <linux/initrd.h>
+ #endif
+ 
++#ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD
++/*
++ * Locates the beginning of the acpi dsdt in the init image
++ * - returns NULL if it's not found
++ */
++static unsigned char* __init find_dsdt(void)
++{
++	unsigned char start_signature[] = "INITRDDSDT123DSDT123";
++	unsigned char *data = (unsigned char*)initrd_start;
++
++	if (!initrd_start)
++		return NULL;
++
++	//find the start signature:
++	for (; data < (unsigned char*)initrd_end && 
++		strncmp(data, start_signature, sizeof(start_signature) - 1); 
++		data++); 
++
++	//was the signature found?
++	return (data < (unsigned char*)initrd_end) ? data : NULL;
++}
++#else
++static inline unsigned char* find_dsdt(void) {return NULL;}
++#endif
++
+ void __init populate_rootfs(void)
+ {
+ 	char *err = unpack_to_rootfs(__initramfs_start,
+@@ -477,13 +502,22 @@ void __init populate_rootfs(void)
+ #ifdef CONFIG_BLK_DEV_INITRD
+ 	if (initrd_start) {
+ 		int fd;
++		unsigned long initramfs_len;
++		unsigned char* acpi_dsdt_start = find_dsdt();
++
++		//check to see if there's a DSDT in the image:
++		if (acpi_dsdt_start)
++			initramfs_len = (unsigned long)acpi_dsdt_start - initrd_start;
++		else
++			initramfs_len = initrd_end - initrd_start;
++
+ 		printk(KERN_INFO "checking if image is initramfs...");
+ 		err = unpack_to_rootfs((char *)initrd_start,
+-			initrd_end - initrd_start, 1);
++			initramfs_len, 1);
+ 		if (!err) {
+ 			printk(" it is\n");
+ 			unpack_to_rootfs((char *)initrd_start,
+-				initrd_end - initrd_start, 0);
++				initramfs_len, 0);
+ 			free_initrd_mem(initrd_start, initrd_end);
+ 			return;
+ 		}
================================================================



More information about the pld-cvs-commit mailing list