]>
Commit | Line | Data |
---|---|---|
4fc2fba8 PM |
1 | /* |
2 | * sleep.c - x86-specific ACPI sleep support. | |
3 | * | |
4 | * Copyright (C) 2001-2003 Patrick Mochel | |
5 | * Copyright (C) 2001-2003 Pavel Machek <pavel@suse.cz> | |
6 | */ | |
7 | ||
8 | #include <linux/acpi.h> | |
9 | #include <linux/bootmem.h> | |
10 | #include <linux/dmi.h> | |
11 | #include <linux/cpumask.h> | |
12 | ||
13 | #include <asm/smp.h> | |
14 | ||
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; | |
19 | ||
20 | extern unsigned long acpi_copy_wakeup_routine(unsigned long); | |
21 | ||
22 | /** | |
23 | * acpi_save_state_mem - save kernel state | |
24 | * | |
25 | * Create an identity mapped page table and copy the wakeup routine to | |
26 | * low memory. | |
27 | */ | |
28 | int acpi_save_state_mem(void) | |
29 | { | |
30 | if (!acpi_wakeup_address) { | |
31 | printk(KERN_ERR "Could not allocate memory during boot, S3 disabled\n"); | |
32 | return -ENOMEM; | |
33 | } | |
34 | memcpy((void *)acpi_wakeup_address, &wakeup_start, | |
35 | &wakeup_end - &wakeup_start); | |
36 | acpi_copy_wakeup_routine(acpi_wakeup_address); | |
37 | ||
38 | return 0; | |
39 | } | |
40 | ||
41 | /* | |
42 | * acpi_restore_state - undo effects of acpi_save_state_mem | |
43 | */ | |
44 | void acpi_restore_state_mem(void) | |
45 | { | |
46 | } | |
47 | ||
48 | ||
49 | /** | |
50 | * acpi_reserve_bootmem - do _very_ early ACPI initialisation | |
51 | * | |
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. | |
56 | */ | |
57 | void __init acpi_reserve_bootmem(void) | |
58 | { | |
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; | |
63 | } | |
64 | ||
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"); | |
68 | } | |
69 | ||
70 | ||
71 | static int __init acpi_sleep_setup(char *str) | |
72 | { | |
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"); | |
83 | } | |
84 | return 1; | |
85 | } | |
86 | ||
87 | __setup("acpi_sleep=", acpi_sleep_setup); |