From 71fc47a9adf8ee89e5c96a47222915c5485ac437 Mon Sep 17 00:00:00 2001 From: Markus Gaugusch Date: Tue, 5 Feb 2008 00:04:06 +0100 Subject: ACPI: basic initramfs DSDT override support The basics of DSDT from initramfs. In case this option is selected, populate_rootfs() is called a bit earlier to have the initramfs content available during ACPI initialization. This is a very similar path to the one available at http://gaugusch.at/kernel.shtml but with some update in the documentation, default set to No and the change of populate_rootfs() the "Jeff Mahony way" (which avoids reading the initramfs twice). Signed-off-by: Thomas Renninger Signed-off-by: Eric Piel Signed-off-by: Len Brown --- Documentation/acpi/dsdt-initrd.txt | 99 ++++++++++++++++++++++++++++++++++++++ drivers/acpi/Kconfig | 17 +++++++ drivers/acpi/osl.c | 73 ++++++++++++++++++++++++++-- init/initramfs.c | 8 ++- init/main.c | 7 +++ 5 files changed, 199 insertions(+), 5 deletions(-) create mode 100644 Documentation/acpi/dsdt-initrd.txt diff --git a/Documentation/acpi/dsdt-initrd.txt b/Documentation/acpi/dsdt-initrd.txt new file mode 100644 index 00000000000..736043359df --- /dev/null +++ b/Documentation/acpi/dsdt-initrd.txt @@ -0,0 +1,99 @@ +ACPI Custom DSDT read from initramfs + +2003 by Markus Gaugusch < dsdt at gaugusch dot at > +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 - 2008 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 General Setup) and enable ACPI_CUSTOM_DSDT_INITRD at the ACPI +options (General Setup|ACPI Support|Read Custom DSDT from initramfs). + +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 . Be careful though, to work correctly a DSDT has to +match closely the hardware, including the amount of RAM, the frequency of the +processor and the PCI cards present! 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 initramfs 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 initramfs has to be an +initramfs. The file is contained into the initramfs under the name /DSDT.aml . +To obtain such an initramfs, you might have to modify your initramfs script or +you can add it later to the initramfs with the script appended to this +document. The command will look like: +initramfs-add-dsdt initramfs.img my-dsdt.aml + +In case you don't use any initramfs, 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 initramfs and +perform the steps above. Don't forget that with Lilo, you'll have to re-run it. + + +====================== Here starts initramfs-add-dsdt ========================== +#!/bin/bash +# Adds a DSDT file to the initrd (if it's an initramfs) +# first argument is the name of archive +# second argument 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 --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index ccf6ea95f68..0442ae153a2 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -274,6 +274,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 n + 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. If your mkinitrd tool does not support this feature + a script is provided in the documentation. For more details see + or . + If there is no table found, it will fall-back 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 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 --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index e53fb516f9d..131936e7ff1 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -312,6 +312,66 @@ acpi_os_predefined_override(const struct acpi_predefined_names *init_val, 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; + 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("not found.\n"); + 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) @@ -319,13 +379,18 @@ acpi_os_table_override(struct acpi_table_header * existing_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 --git a/init/initramfs.c b/init/initramfs.c index d53fee8d860..c0b1e0533d8 100644 --- a/init/initramfs.c +++ b/init/initramfs.c @@ -538,7 +538,7 @@ skip: initrd_end = 0; } -static int __init populate_rootfs(void) +int __init populate_rootfs(void) { char *err = unpack_to_rootfs(__initramfs_start, __initramfs_end - __initramfs_start, 0); @@ -577,4 +577,10 @@ static int __init populate_rootfs(void) } return 0; } +#ifndef CONFIG_ACPI_CUSTOM_DSDT_INITRD +/* + * if this option is enabled, populate_rootfs() is called _earlier_ in the + * boot sequence. This insures that the ACPI initialisation can find the file. + */ rootfs_initcall(populate_rootfs); +#endif diff --git a/init/main.c b/init/main.c index c691f5f7fc2..2a78932f6c0 100644 --- a/init/main.c +++ b/init/main.c @@ -102,6 +102,12 @@ static inline void mark_rodata_ro(void) { } extern void tc_init(void); #endif +#ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD +extern int populate_rootfs(void); +#else +static inline void populate_rootfs(void) {} +#endif + enum system_states system_state; EXPORT_SYMBOL(system_state); @@ -648,6 +654,7 @@ asmlinkage void __init start_kernel(void) check_bugs(); + 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 */ -- cgit v1.2.3 From 6ed31e92e94830c138fbd470486383380710069a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Piel?= Date: Tue, 5 Feb 2008 00:04:50 +0100 Subject: ACPI: Taint kernel on ACPI table override (format corrected) When an ACPI table is overridden (for now this can happen only for DSDT) display a big warning and taint the kernel with flag A. Signed-off-by: Eric Piel Signed-off-by: Len Brown --- drivers/acpi/osl.c | 7 +++++++ include/linux/kernel.h | 1 + kernel/panic.c | 5 +++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 131936e7ff1..bbd8360bfb2 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -392,6 +392,13 @@ acpi_os_table_override(struct acpi_table_header * existing_table, *new_table = initrd_table; } #endif + if (*new_table != NULL) { + printk(KERN_WARNING PREFIX "Override [%4.4s-%8.8s], " + "this is unsafe: tainting kernel\n", + existing_table->signature, + existing_table->oem_table_id); + add_taint(TAINT_OVERRIDDEN_ACPI_TABLE); + } return AE_OK; } diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 18222f267bc..9e01f376840 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -243,6 +243,7 @@ extern enum system_states { #define TAINT_BAD_PAGE (1<<5) #define TAINT_USER (1<<6) #define TAINT_DIE (1<<7) +#define TAINT_OVERRIDDEN_ACPI_TABLE (1<<8) extern void dump_stack(void) __cold; diff --git a/kernel/panic.c b/kernel/panic.c index d9e90cfe329..24af9f8bac9 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -161,7 +161,7 @@ const char *print_tainted(void) { static char buf[20]; if (tainted) { - snprintf(buf, sizeof(buf), "Tainted: %c%c%c%c%c%c%c%c", + snprintf(buf, sizeof(buf), "Tainted: %c%c%c%c%c%c%c%c%c", tainted & TAINT_PROPRIETARY_MODULE ? 'P' : 'G', tainted & TAINT_FORCED_MODULE ? 'F' : ' ', tainted & TAINT_UNSAFE_SMP ? 'S' : ' ', @@ -169,7 +169,8 @@ const char *print_tainted(void) tainted & TAINT_MACHINE_CHECK ? 'M' : ' ', tainted & TAINT_BAD_PAGE ? 'B' : ' ', tainted & TAINT_USER ? 'U' : ' ', - tainted & TAINT_DIE ? 'D' : ' '); + tainted & TAINT_DIE ? 'D' : ' ', + tainted & TAINT_OVERRIDDEN_ACPI_TABLE ? 'A' : ' '); } else snprintf(buf, sizeof(buf), "Not tainted"); -- cgit v1.2.3 From 9cbc7960288d28aec95257af59854e1d14ba23b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Piel?= Date: Tue, 5 Feb 2008 00:04:58 +0100 Subject: ACPI: Add "acpi_no_initrd_override" kernel parameter The acpi_no_initrd_override parameter permits to disable the load of an ACPI table from the initramfs. Signed-off-by: Eric Piel Signed-off-by: Len Brown --- Documentation/kernel-parameters.txt | 3 +++ drivers/acpi/osl.c | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 8fd5aa40585..ef2316a1a73 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -175,6 +175,9 @@ and is between 256 and 4096 characters. It is defined in the file acpi_no_auto_ssdt [HW,ACPI] Disable automatic loading of SSDT + acpi_no_initrd_override [KNL,ACPI] + Disable loading custom ACPI tables from the initramfs + acpi_os_name= [HW,ACPI] Tell ACPI BIOS the name of the OS Format: To spoof as Windows 98: ="Microsoft Windows" diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index bbd8360bfb2..2b41bdddbeb 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -77,6 +77,10 @@ static struct workqueue_struct *kacpi_notify_wq; #define OSI_STRING_LENGTH_MAX 64 /* arbitrary */ static char osi_additional_string[OSI_STRING_LENGTH_MAX]; +#ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD +static int acpi_no_initrd_override; +#endif + /* * "Ode to _OSI(Linux)" * @@ -386,7 +390,8 @@ acpi_os_table_override(struct acpi_table_header * existing_table, *new_table = (struct acpi_table_header *)AmlCode; #endif #ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD - if (strncmp(existing_table->signature, "DSDT", 4) == 0) { + if ((strncmp(existing_table->signature, "DSDT", 4) == 0) && + !acpi_no_initrd_override) { struct acpi_table_header *initrd_table = acpi_find_dsdt_initrd(); if (initrd_table) *new_table = initrd_table; @@ -402,6 +407,15 @@ acpi_os_table_override(struct acpi_table_header * existing_table, return AE_OK; } +#ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD +int __init acpi_no_initrd_override_setup(char *s) +{ + acpi_no_initrd_override = 1; + return 1; +} +__setup("acpi_no_initrd_override", acpi_no_initrd_override_setup); +#endif + static irqreturn_t acpi_irq(int irq, void *dev_id) { return (*acpi_irq_handler) (acpi_irq_context) ? IRQ_HANDLED : IRQ_NONE; -- cgit v1.2.3 From d89e9d6b4930c6505ac3ed35f57ab7f4311d6cf6 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Wed, 6 Feb 2008 19:28:02 -0500 Subject: ACPI: update DSDT override documentation Signed-off-by: Len Brown --- Documentation/acpi/dsdt-initrd.txt | 99 -------------------------------- Documentation/acpi/dsdt-override.txt | 15 +++++ Documentation/acpi/initramfs-add-dsdt.sh | 43 ++++++++++++++ drivers/acpi/Kconfig | 22 +++---- 4 files changed, 67 insertions(+), 112 deletions(-) delete mode 100644 Documentation/acpi/dsdt-initrd.txt create mode 100644 Documentation/acpi/dsdt-override.txt create mode 100755 Documentation/acpi/initramfs-add-dsdt.sh diff --git a/Documentation/acpi/dsdt-initrd.txt b/Documentation/acpi/dsdt-initrd.txt deleted file mode 100644 index 736043359df..00000000000 --- a/Documentation/acpi/dsdt-initrd.txt +++ /dev/null @@ -1,99 +0,0 @@ -ACPI Custom DSDT read from initramfs - -2003 by Markus Gaugusch < dsdt at gaugusch dot at > -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 - 2008 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 General Setup) and enable ACPI_CUSTOM_DSDT_INITRD at the ACPI -options (General Setup|ACPI Support|Read Custom DSDT from initramfs). - -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 . Be careful though, to work correctly a DSDT has to -match closely the hardware, including the amount of RAM, the frequency of the -processor and the PCI cards present! 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 initramfs 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 initramfs has to be an -initramfs. The file is contained into the initramfs under the name /DSDT.aml . -To obtain such an initramfs, you might have to modify your initramfs script or -you can add it later to the initramfs with the script appended to this -document. The command will look like: -initramfs-add-dsdt initramfs.img my-dsdt.aml - -In case you don't use any initramfs, 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 initramfs and -perform the steps above. Don't forget that with Lilo, you'll have to re-run it. - - -====================== Here starts initramfs-add-dsdt ========================== -#!/bin/bash -# Adds a DSDT file to the initrd (if it's an initramfs) -# first argument is the name of archive -# second argument 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 --git a/Documentation/acpi/dsdt-override.txt b/Documentation/acpi/dsdt-override.txt new file mode 100644 index 00000000000..5008f256a2d --- /dev/null +++ b/Documentation/acpi/dsdt-override.txt @@ -0,0 +1,15 @@ +Linux supports two methods of overriding the BIOS DSDT: + +CONFIG_ACPI_CUSTOM_DSDT builds the image into the kernel. + +CONFIG_ACPI_CUSTOM_DSDT_INITRD adds the image to the initrd. + +When to use these methods is described in detail on the +Linux/ACPI home page: +http://www.lesswatts.org/projects/acpi/overridingDSDT.php + +Note that if both options are used, the DSDT supplied +by the INITRD method takes precedence. + +Documentation/initramfs-add-dsdt.sh is provided for convenience +for use with the CONFIG_ACPI_CUSTOM_DSDT_INITRD method. diff --git a/Documentation/acpi/initramfs-add-dsdt.sh b/Documentation/acpi/initramfs-add-dsdt.sh new file mode 100755 index 00000000000..17ef6e838e1 --- /dev/null +++ b/Documentation/acpi/initramfs-add-dsdt.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# Adds a DSDT file to the initrd (if it's an initramfs) +# first argument is the name of archive +# second argument 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 --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 0442ae153a2..c8e83204458 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -263,8 +263,10 @@ config ACPI_CUSTOM_DSDT depends on !STANDALONE default n help - This option is to load a custom ACPI DSDT - If you don't know what that is, say N. + This option supports a custom DSDT by linking it into the kernel. + See Documentation/acpi/dsdt-override.txt + + If unsure, say N. config ACPI_CUSTOM_DSDT_FILE string "Custom DSDT Table file to include" @@ -279,17 +281,11 @@ config ACPI_CUSTOM_DSDT_INITRD depends on BLK_DEV_INITRD default n 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. If your mkinitrd tool does not support this feature - a script is provided in the documentation. For more details see - or . - If there is no table found, it will fall-back 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 DSDT later. It is safe to say Y here. + This option supports a custom DSDT by optionally loading it from initrd. + See Documentation/acpi/dsdt-override.txt + + If you are not using this feature now, but may use it 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 -- cgit v1.2.3 From 04d94886b47b5133915021dcfb1108a8576f6ea7 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Wed, 6 Feb 2008 19:49:54 -0500 Subject: ACPI: update intrd DSDT override console messages also, address some checkpatch.pl violations Signed-off-by: Len Brown --- drivers/acpi/osl.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 2b41bdddbeb..2a400e08e74 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -326,49 +326,50 @@ struct acpi_table_header *acpi_find_dsdt_initrd(void) struct kstat stat; char *ramfs_dsdt_name = "/DSDT.aml"; - printk(KERN_INFO PREFIX "Looking for DSDT in initramfs... "); + printk(KERN_INFO PREFIX "Checking initramfs for custom DSDT"); /* * 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... + * The clean way would be to use the firmware loader. + * But this code must be run before there is any userspace available. + * A static/init firmware infrastructure doesn't exist yet... */ - if (vfs_stat(ramfs_dsdt_name, &stat) < 0) { - printk("not found.\n"); + if (vfs_stat(ramfs_dsdt_name, &stat) < 0) return ret; - } len = stat.size; /* check especially against empty files */ if (len <= 4) { - printk("error, file is too small: only %lu bytes.\n", len); + printk(KERN_ERR PREFIX "Failed: DSDT 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); + printk(KERN_ERR PREFIX "Failed to open %s.\n", ramfs_dsdt_name); return ret; } - dsdt_buffer = ACPI_ALLOCATE(len); + dsdt_buffer = kmalloc(len, GFP_ATOMIC); if (!dsdt_buffer) { - printk("error when allocating %lu bytes of memory.\n", len); + printk(KERN_ERR PREFIX "Failed to allocate %lu bytes.\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); + 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); + printk(KERN_ERR PREFIX "Failed 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); + printk(KERN_INFO PREFIX "Found %lu byte DSDT in %s.\n", + len, ramfs_dsdt_name); ret = dsdt_buffer; err: filp_close(firmware_file, NULL); @@ -392,7 +393,9 @@ acpi_os_table_override(struct acpi_table_header * existing_table, #ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD if ((strncmp(existing_table->signature, "DSDT", 4) == 0) && !acpi_no_initrd_override) { - struct acpi_table_header *initrd_table = acpi_find_dsdt_initrd(); + struct acpi_table_header *initrd_table; + + initrd_table = acpi_find_dsdt_initrd(); if (initrd_table) *new_table = initrd_table; } -- cgit v1.2.3