Committer: Michael Beasley <mike@snafu.setup>
[mikesnafu-overlay.git] / arch / x86 / kernel / acpi / sleep.c
blob6bc815cd8cb32e219dd9bdf14fbd13cb717253ea
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 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 printk(KERN_ERR "Could not allocate memory during boot, S3 disabled\n");
32 return -ENOMEM;
34 memcpy((void *)acpi_wakeup_address, &wakeup_start,
35 &wakeup_end - &wakeup_start);
36 acpi_copy_wakeup_routine(acpi_wakeup_address);
38 return 0;
42 * acpi_restore_state - undo effects of acpi_save_state_mem
44 void acpi_restore_state_mem(void)
49 /**
50 * acpi_reserve_bootmem - do _very_ early ACPI initialisation
52 * We allocate a page from the first 1MB of memory for the wakeup
53 * routine for when we come back from a sleep state. The
54 * runtime allocator allows specification of <16MB pages, but not
55 * <1MB pages.
57 void __init acpi_reserve_bootmem(void)
59 if ((&wakeup_end - &wakeup_start) > PAGE_SIZE*2) {
60 printk(KERN_ERR
61 "ACPI: Wakeup code way too big, S3 disabled.\n");
62 return;
65 acpi_wakeup_address = (unsigned long)alloc_bootmem_low(PAGE_SIZE*2);
66 if (!acpi_wakeup_address)
67 printk(KERN_ERR "ACPI: Cannot allocate lowmem, S3 disabled.\n");
71 static int __init acpi_sleep_setup(char *str)
73 while ((str != NULL) && (*str != '\0')) {
74 if (strncmp(str, "s3_bios", 7) == 0)
75 acpi_realmode_flags |= 1;
76 if (strncmp(str, "s3_mode", 7) == 0)
77 acpi_realmode_flags |= 2;
78 if (strncmp(str, "s3_beep", 7) == 0)
79 acpi_realmode_flags |= 4;
80 str = strchr(str, ',');
81 if (str != NULL)
82 str += strspn(str, ", \t");
84 return 1;
87 __setup("acpi_sleep=", acpi_sleep_setup);