aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/acpi/sleep.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/kernel/acpi/sleep.c')
-rw-r--r--arch/x86/kernel/acpi/sleep.c74
1 files changed, 12 insertions, 62 deletions
diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
index 69fd72aa5594..ff93bc1b09c3 100644
--- a/arch/x86/kernel/acpi/sleep.c
+++ b/arch/x86/kernel/acpi/sleep.c
@@ -12,45 +12,34 @@
12#include <linux/cpumask.h> 12#include <linux/cpumask.h>
13#include <asm/segment.h> 13#include <asm/segment.h>
14#include <asm/desc.h> 14#include <asm/desc.h>
15
16#ifdef CONFIG_X86_32
17#include <asm/pgtable.h> 15#include <asm/pgtable.h>
18#endif 16#include <asm/cacheflush.h>
19 17
20#include "realmode/wakeup.h" 18#include "realmode/wakeup.h"
21#include "sleep.h" 19#include "sleep.h"
22 20
23unsigned long acpi_wakeup_address;
24unsigned long acpi_realmode_flags; 21unsigned long acpi_realmode_flags;
25 22
26/* address in low memory of the wakeup routine. */
27static unsigned long acpi_realmode;
28
29#if defined(CONFIG_SMP) && defined(CONFIG_64BIT) 23#if defined(CONFIG_SMP) && defined(CONFIG_64BIT)
30static char temp_stack[4096]; 24static char temp_stack[4096];
31#endif 25#endif
32 26
33/** 27/**
34 * acpi_save_state_mem - save kernel state 28 * acpi_suspend_lowlevel - save kernel state
35 * 29 *
36 * Create an identity mapped page table and copy the wakeup routine to 30 * Create an identity mapped page table and copy the wakeup routine to
37 * low memory. 31 * low memory.
38 *
39 * Note that this is too late to change acpi_wakeup_address.
40 */ 32 */
41int acpi_save_state_mem(void) 33int acpi_suspend_lowlevel(void)
42{ 34{
43 struct wakeup_header *header; 35 struct wakeup_header *header;
36 /* address in low memory of the wakeup routine. */
37 char *acpi_realmode;
44 38
45 if (!acpi_realmode) { 39 acpi_realmode = TRAMPOLINE_SYM(acpi_wakeup_code);
46 printk(KERN_ERR "Could not allocate memory during boot, "
47 "S3 disabled\n");
48 return -ENOMEM;
49 }
50 memcpy((void *)acpi_realmode, &wakeup_code_start, WAKEUP_SIZE);
51 40
52 header = (struct wakeup_header *)(acpi_realmode + HEADER_OFFSET); 41 header = (struct wakeup_header *)(acpi_realmode + WAKEUP_HEADER_OFFSET);
53 if (header->signature != 0x51ee1111) { 42 if (header->signature != WAKEUP_HEADER_SIGNATURE) {
54 printk(KERN_ERR "wakeup header does not match\n"); 43 printk(KERN_ERR "wakeup header does not match\n");
55 return -EINVAL; 44 return -EINVAL;
56 } 45 }
@@ -70,9 +59,7 @@ int acpi_save_state_mem(void)
70 /* GDT[0]: GDT self-pointer */ 59 /* GDT[0]: GDT self-pointer */
71 header->wakeup_gdt[0] = 60 header->wakeup_gdt[0] =
72 (u64)(sizeof(header->wakeup_gdt) - 1) + 61 (u64)(sizeof(header->wakeup_gdt) - 1) +
73 ((u64)(acpi_wakeup_address + 62 ((u64)__pa(&header->wakeup_gdt) << 16);
74 ((char *)&header->wakeup_gdt - (char *)acpi_realmode))
75 << 16);
76 /* GDT[1]: big real mode-like code segment */ 63 /* GDT[1]: big real mode-like code segment */
77 header->wakeup_gdt[1] = 64 header->wakeup_gdt[1] =
78 GDT_ENTRY(0x809b, acpi_wakeup_address, 0xfffff); 65 GDT_ENTRY(0x809b, acpi_wakeup_address, 0xfffff);
@@ -98,9 +85,9 @@ int acpi_save_state_mem(void)
98 header->pmode_cr3 = (u32)__pa(&initial_page_table); 85 header->pmode_cr3 = (u32)__pa(&initial_page_table);
99 saved_magic = 0x12345678; 86 saved_magic = 0x12345678;
100#else /* CONFIG_64BIT */ 87#else /* CONFIG_64BIT */
101 header->trampoline_segment = setup_trampoline() >> 4; 88 header->trampoline_segment = trampoline_address() >> 4;
102#ifdef CONFIG_SMP 89#ifdef CONFIG_SMP
103 stack_start.sp = temp_stack + sizeof(temp_stack); 90 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
104 early_gdt_descr.address = 91 early_gdt_descr.address =
105 (unsigned long)get_cpu_gdt_table(smp_processor_id()); 92 (unsigned long)get_cpu_gdt_table(smp_processor_id());
106 initial_gs = per_cpu_offset(smp_processor_id()); 93 initial_gs = per_cpu_offset(smp_processor_id());
@@ -109,47 +96,10 @@ int acpi_save_state_mem(void)
109 saved_magic = 0x123456789abcdef0L; 96 saved_magic = 0x123456789abcdef0L;
110#endif /* CONFIG_64BIT */ 97#endif /* CONFIG_64BIT */
111 98
99 do_suspend_lowlevel();
112 return 0; 100 return 0;
113} 101}
114 102
115/*
116 * acpi_restore_state - undo effects of acpi_save_state_mem
117 */
118void acpi_restore_state_mem(void)
119{
120}
121
122
123/**
124 * acpi_reserve_wakeup_memory - do _very_ early ACPI initialisation
125 *
126 * We allocate a page from the first 1MB of memory for the wakeup
127 * routine for when we come back from a sleep state. The
128 * runtime allocator allows specification of <16MB pages, but not
129 * <1MB pages.
130 */
131void __init acpi_reserve_wakeup_memory(void)
132{
133 phys_addr_t mem;
134
135 if ((&wakeup_code_end - &wakeup_code_start) > WAKEUP_SIZE) {
136 printk(KERN_ERR
137 "ACPI: Wakeup code way too big, S3 disabled.\n");
138 return;
139 }
140
141 mem = memblock_find_in_range(0, 1<<20, WAKEUP_SIZE, PAGE_SIZE);
142
143 if (mem == MEMBLOCK_ERROR) {
144 printk(KERN_ERR "ACPI: Cannot allocate lowmem, S3 disabled.\n");
145 return;
146 }
147 acpi_realmode = (unsigned long) phys_to_virt(mem);
148 acpi_wakeup_address = mem;
149 memblock_x86_reserve_range(mem, mem + WAKEUP_SIZE, "ACPI WAKEUP");
150}
151
152
153static int __init acpi_sleep_setup(char *str) 103static int __init acpi_sleep_setup(char *str)
154{ 104{
155 while ((str != NULL) && (*str != '\0')) { 105 while ((str != NULL) && (*str != '\0')) {