diff options
author | Pavel Machek <pavel@ucw.cz> | 2008-01-30 07:32:54 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-01-30 07:32:54 -0500 |
commit | 4fc2fba804cae404d2665e23b8cbd46d5f63a07e (patch) | |
tree | 62818ab9c261872fb58473fdbb6c04f7beb439d2 /arch/x86/kernel/acpi/sleep.c | |
parent | 8a19da7b7f16d8360e39035f6ab96686e835522b (diff) |
x86: unify arch/x86/kernel/acpi/sleep*.c
Unify arch/x86/kernel/acpi/sleep*.c
Pretty trivial unification; when two functions differed, it was
usually in error handling, and better of the two was picked up.
Signed-off-by: Pavel Machek <pavel@suse.cz>
Looks-okay-to: Rafael J. Wysocki <rjw@sisk.pl>
Tested-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/acpi/sleep.c')
-rw-r--r-- | arch/x86/kernel/acpi/sleep.c | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c new file mode 100644 index 000000000000..6bc815cd8cb3 --- /dev/null +++ b/arch/x86/kernel/acpi/sleep.c | |||
@@ -0,0 +1,87 @@ | |||
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); | ||