diff options
| -rw-r--r-- | arch/x86/kernel/tboot.c | 53 |
1 files changed, 40 insertions, 13 deletions
diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c index 1ab80120894..a183beffe39 100644 --- a/arch/x86/kernel/tboot.c +++ b/arch/x86/kernel/tboot.c | |||
| @@ -34,6 +34,7 @@ | |||
| 34 | #include <asm/pgtable.h> | 34 | #include <asm/pgtable.h> |
| 35 | #include <asm/pgalloc.h> | 35 | #include <asm/pgalloc.h> |
| 36 | #include <asm/fixmap.h> | 36 | #include <asm/fixmap.h> |
| 37 | #include <asm/proto.h> | ||
| 37 | #include <asm/setup.h> | 38 | #include <asm/setup.h> |
| 38 | #include <asm/tboot.h> | 39 | #include <asm/tboot.h> |
| 39 | #include <asm/e820.h> | 40 | #include <asm/e820.h> |
| @@ -164,25 +165,51 @@ void tboot_create_trampoline(void) | |||
| 164 | map_base = PFN_DOWN(tboot->tboot_base); | 165 | map_base = PFN_DOWN(tboot->tboot_base); |
| 165 | map_size = PFN_UP(tboot->tboot_size); | 166 | map_size = PFN_UP(tboot->tboot_size); |
| 166 | if (map_tboot_pages(map_base << PAGE_SHIFT, map_base, map_size)) | 167 | if (map_tboot_pages(map_base << PAGE_SHIFT, map_base, map_size)) |
| 167 | panic("tboot: Error mapping tboot pages (mfns) @ 0x%x, 0x%x\n", map_base, map_size); | 168 | panic("tboot: Error mapping tboot pages (mfns) @ 0x%x, 0x%x\n", |
| 169 | map_base, map_size); | ||
| 168 | } | 170 | } |
| 169 | 171 | ||
| 170 | static void set_mac_regions(void) | 172 | #ifdef CONFIG_ACPI_SLEEP |
| 173 | |||
| 174 | static void add_mac_region(phys_addr_t start, unsigned long size) | ||
| 171 | { | 175 | { |
| 172 | tboot->num_mac_regions = 3; | 176 | struct tboot_mac_region *mr; |
| 177 | phys_addr_t end = start + size; | ||
| 178 | |||
| 179 | if (start && size) { | ||
| 180 | mr = &tboot->mac_regions[tboot->num_mac_regions++]; | ||
| 181 | mr->start = round_down(start, PAGE_SIZE); | ||
| 182 | mr->size = round_up(end, PAGE_SIZE) - mr->start; | ||
| 183 | } | ||
| 184 | } | ||
| 185 | |||
| 186 | static int tboot_setup_sleep(void) | ||
| 187 | { | ||
| 188 | tboot->num_mac_regions = 0; | ||
| 189 | |||
| 173 | /* S3 resume code */ | 190 | /* S3 resume code */ |
| 174 | tboot->mac_regions[0].start = PFN_PHYS(PFN_DOWN(acpi_wakeup_address)); | 191 | add_mac_region(acpi_wakeup_address, WAKEUP_SIZE); |
| 175 | tboot->mac_regions[0].size = PFN_UP(WAKEUP_SIZE) << PAGE_SHIFT; | ||
| 176 | /* AP trampoline code */ | 192 | /* AP trampoline code */ |
| 177 | tboot->mac_regions[1].start = | 193 | add_mac_region(virt_to_phys(trampoline_base), TRAMPOLINE_SIZE); |
| 178 | PFN_PHYS(PFN_DOWN(virt_to_phys(trampoline_base))); | ||
| 179 | tboot->mac_regions[1].size = PFN_UP(TRAMPOLINE_SIZE) << PAGE_SHIFT; | ||
| 180 | /* kernel code + data + bss */ | 194 | /* kernel code + data + bss */ |
| 181 | tboot->mac_regions[2].start = PFN_PHYS(PFN_DOWN(virt_to_phys(&_text))); | 195 | add_mac_region(virt_to_phys(_text), _end - _text); |
| 182 | tboot->mac_regions[2].size = PFN_PHYS(PFN_UP(virt_to_phys(&_end))) - | 196 | |
| 183 | PFN_PHYS(PFN_DOWN(virt_to_phys(&_text))); | 197 | tboot->acpi_sinfo.kernel_s3_resume_vector = acpi_wakeup_address; |
| 198 | |||
| 199 | return 0; | ||
| 184 | } | 200 | } |
| 185 | 201 | ||
| 202 | #else /* no CONFIG_ACPI_SLEEP */ | ||
| 203 | |||
| 204 | static int tboot_setup_sleep(void) | ||
| 205 | { | ||
| 206 | /* S3 shutdown requested, but S3 not supported by the kernel... */ | ||
| 207 | BUG(); | ||
| 208 | return -1; | ||
| 209 | } | ||
| 210 | |||
| 211 | #endif | ||
| 212 | |||
| 186 | void tboot_shutdown(u32 shutdown_type) | 213 | void tboot_shutdown(u32 shutdown_type) |
| 187 | { | 214 | { |
| 188 | void (*shutdown)(void); | 215 | void (*shutdown)(void); |
| @@ -200,7 +227,8 @@ void tboot_shutdown(u32 shutdown_type) | |||
| 200 | 227 | ||
| 201 | /* if this is S3 then set regions to MAC */ | 228 | /* if this is S3 then set regions to MAC */ |
| 202 | if (shutdown_type == TB_SHUTDOWN_S3) | 229 | if (shutdown_type == TB_SHUTDOWN_S3) |
| 203 | set_mac_regions(); | 230 | if (tboot_setup_sleep()) |
| 231 | return; | ||
| 204 | 232 | ||
| 205 | tboot->shutdown_type = shutdown_type; | 233 | tboot->shutdown_type = shutdown_type; |
| 206 | 234 | ||
| @@ -253,7 +281,6 @@ void tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control) | |||
| 253 | tboot->acpi_sinfo.pm1b_cnt_val = pm1b_control; | 281 | tboot->acpi_sinfo.pm1b_cnt_val = pm1b_control; |
| 254 | /* we always use the 32b wakeup vector */ | 282 | /* we always use the 32b wakeup vector */ |
| 255 | tboot->acpi_sinfo.vector_width = 32; | 283 | tboot->acpi_sinfo.vector_width = 32; |
| 256 | tboot->acpi_sinfo.kernel_s3_resume_vector = acpi_wakeup_address; | ||
| 257 | 284 | ||
| 258 | if (sleep_state >= ACPI_S_STATE_COUNT || | 285 | if (sleep_state >= ACPI_S_STATE_COUNT || |
| 259 | acpi_shutdown_map[sleep_state] == -1) { | 286 | acpi_shutdown_map[sleep_state] == -1) { |
