Merge branch 'dmi-const' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik...
[linux-2.6/btrfs-unstable.git] / arch / x86 / kernel / acpi / sleep_32.c
blob10699489cfe7f776e9666ad588cf8265b21642b1
1 /*
2 * sleep.c - x86-specific ACPI sleep support.
4 * Copyright (C) 2001-2003 Patrick Mochel
5 * Copyright (C) 2001-2003 Pavel Machek <pavel@suse.cz>
6 */
8 #include <linux/acpi.h>
9 #include <linux/bootmem.h>
10 #include <linux/dmi.h>
11 #include <linux/cpumask.h>
13 #include <asm/smp.h>
15 /* address in low memory of the wakeup routine. */
16 unsigned long acpi_wakeup_address = 0;
17 unsigned long acpi_realmode_flags;
18 extern char wakeup_start, wakeup_end;
20 extern unsigned long FASTCALL(acpi_copy_wakeup_routine(unsigned long));
22 /**
23 * acpi_save_state_mem - save kernel state
25 * Create an identity mapped page table and copy the wakeup routine to
26 * low memory.
28 int acpi_save_state_mem(void)
30 if (!acpi_wakeup_address)
31 return 1;
32 memcpy((void *)acpi_wakeup_address, &wakeup_start,
33 &wakeup_end - &wakeup_start);
34 acpi_copy_wakeup_routine(acpi_wakeup_address);
36 return 0;
40 * acpi_restore_state - undo effects of acpi_save_state_mem
42 void acpi_restore_state_mem(void)
46 /**
47 * acpi_reserve_bootmem - do _very_ early ACPI initialisation
49 * We allocate a page from the first 1MB of memory for the wakeup
50 * routine for when we come back from a sleep state. The
51 * runtime allocator allows specification of <16MB pages, but not
52 * <1MB pages.
54 void __init acpi_reserve_bootmem(void)
56 if ((&wakeup_end - &wakeup_start) > PAGE_SIZE) {
57 printk(KERN_ERR
58 "ACPI: Wakeup code way too big, S3 disabled.\n");
59 return;
62 acpi_wakeup_address = (unsigned long)alloc_bootmem_low(PAGE_SIZE);
63 if (!acpi_wakeup_address)
64 printk(KERN_ERR "ACPI: Cannot allocate lowmem, S3 disabled.\n");
67 static int __init acpi_sleep_setup(char *str)
69 while ((str != NULL) && (*str != '\0')) {
70 if (strncmp(str, "s3_bios", 7) == 0)
71 acpi_realmode_flags |= 1;
72 if (strncmp(str, "s3_mode", 7) == 0)
73 acpi_realmode_flags |= 2;
74 if (strncmp(str, "s3_beep", 7) == 0)
75 acpi_realmode_flags |= 4;
76 str = strchr(str, ',');
77 if (str != NULL)
78 str += strspn(str, ", \t");
80 return 1;
83 __setup("acpi_sleep=", acpi_sleep_setup);
85 /* Ouch, we want to delete this. We already have better version in userspace, in
86 s2ram from suspend.sf.net project */
87 static __init int reset_videomode_after_s3(const struct dmi_system_id *d)
89 acpi_realmode_flags |= 2;
90 return 0;
93 static __initdata struct dmi_system_id acpisleep_dmi_table[] = {
94 { /* Reset video mode after returning from ACPI S3 sleep */
95 .callback = reset_videomode_after_s3,
96 .ident = "Toshiba Satellite 4030cdt",
97 .matches = {
98 DMI_MATCH(DMI_PRODUCT_NAME, "S4030CDT/4.3"),
104 static int __init acpisleep_dmi_init(void)
106 dmi_check_system(acpisleep_dmi_table);
107 return 0;
110 core_initcall(acpisleep_dmi_init);