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 <asm/smp.h>
11
12
13 /* address in low memory of the wakeup routine. */
14 unsigned long acpi_wakeup_address = 0;
15 unsigned long acpi_video_flags;
16 extern char wakeup_start, wakeup_end;
17
18 extern void zap_low_mappings(void);
19
20 extern unsigned long FASTCALL(acpi_copy_wakeup_routine(unsigned long));
21
22 static void init_low_mapping(pgd_t *pgd, int pgd_limit)
23 {
24 int pgd_ofs = 0;
25
26 while ((pgd_ofs < pgd_limit) && (pgd_ofs + USER_PTRS_PER_PGD < PTRS_PER_PGD)) {
27 set_pgd(pgd, *(pgd+USER_PTRS_PER_PGD));
28 pgd_ofs++, pgd++;
29 }
30 }
31
32 /**
33 * acpi_save_state_mem - save kernel state
34 *
35 * Create an identity mapped page table and copy the wakeup routine to
36 * low memory.
37 */
38 int acpi_save_state_mem (void)
39 {
40 if (!acpi_wakeup_address)
41 return 1;
42 init_low_mapping(swapper_pg_dir, USER_PTRS_PER_PGD);
43 memcpy((void *) acpi_wakeup_address, &wakeup_start, &wakeup_end - &wakeup_start);
44 acpi_copy_wakeup_routine(acpi_wakeup_address);
45
46 return 0;
47 }
48
49 /**
50 * acpi_save_state_disk - save kernel state to disk
51 *
52 */
53 int acpi_save_state_disk (void)
54 {
55 return 1;
56 }
57
58 /*
59 * acpi_restore_state - undo effects of acpi_save_state_mem
60 */
61 void acpi_restore_state_mem (void)
62 {
63 zap_low_mappings();
64 }
65
66 /**
67 * acpi_reserve_bootmem - do _very_ early ACPI initialisation
68 *
69 * We allocate a page from the first 1MB of memory for the wakeup
70 * routine for when we come back from a sleep state. The
71 * runtime allocator allows specification of <16MB pages, but not
72 * <1MB pages.
73 */
74 void __init acpi_reserve_bootmem(void)
75 {
76 if ((&wakeup_end - &wakeup_start) > PAGE_SIZE) {
77 printk(KERN_ERR "ACPI: Wakeup code way too big, S3 disabled.\n");
78 return;
79 }
80
81 acpi_wakeup_address = (unsigned long)alloc_bootmem_low(PAGE_SIZE);
82 if (!acpi_wakeup_address)
83 printk(KERN_ERR "ACPI: Cannot allocate lowmem, S3 disabled.\n");
84 }
85
86 static int __init acpi_sleep_setup(char *str)
87 {
88 while ((str != NULL) && (*str != '\0')) {
89 if (strncmp(str, "s3_bios", 7) == 0)
90 acpi_video_flags = 1;
91 if (strncmp(str, "s3_mode", 7) == 0)
92 acpi_video_flags |= 2;
93 str = strchr(str, ',');
94 if (str != NULL)
95 str += strspn(str, ", \t");
96 }
97 return 1;
98 }
99
100
101 __setup("acpi_sleep=", acpi_sleep_setup);
102
|
This page was automatically generated by the
LXR engine.
|