Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2001-2002 Pavel Machek <pavel@suse.cz> |
| 3 | * Based on code |
| 4 | * Copyright 2001 Patrick Mochel <mochel@osdl.org> |
| 5 | */ |
| 6 | #include <asm/desc.h> |
| 7 | #include <asm/i387.h> |
| 8 | |
| 9 | static inline int |
| 10 | arch_prepare_suspend(void) |
| 11 | { |
| 12 | /* If you want to make non-PSE machine work, turn off paging |
| 13 | in swsusp_arch_suspend. swsusp_pg_dir should have identity mapping, so |
| 14 | it could work... */ |
| 15 | if (!cpu_has_pse) { |
| 16 | printk(KERN_ERR "PSE is required for swsusp.\n"); |
| 17 | return -EPERM; |
| 18 | } |
| 19 | return 0; |
| 20 | } |
| 21 | |
| 22 | /* image of the saved processor state */ |
| 23 | struct saved_context { |
| 24 | u16 es, fs, gs, ss; |
| 25 | unsigned long cr0, cr2, cr3, cr4; |
| 26 | u16 gdt_pad; |
| 27 | u16 gdt_limit; |
| 28 | unsigned long gdt_base; |
| 29 | u16 idt_pad; |
| 30 | u16 idt_limit; |
| 31 | unsigned long idt_base; |
| 32 | u16 ldt; |
| 33 | u16 tss; |
| 34 | unsigned long tr; |
| 35 | unsigned long safety; |
| 36 | unsigned long return_address; |
| 37 | } __attribute__((packed)); |
| 38 | |
| 39 | #define loaddebug(thread,register) \ |
| 40 | __asm__("movl %0,%%db" #register \ |
| 41 | : /* no output */ \ |
| 42 | :"r" ((thread)->debugreg[register])) |
| 43 | |
| 44 | #ifdef CONFIG_ACPI_SLEEP |
| 45 | extern unsigned long saved_eip; |
| 46 | extern unsigned long saved_esp; |
| 47 | extern unsigned long saved_ebp; |
| 48 | extern unsigned long saved_ebx; |
| 49 | extern unsigned long saved_esi; |
| 50 | extern unsigned long saved_edi; |
| 51 | |
| 52 | static inline void acpi_save_register_state(unsigned long return_point) |
| 53 | { |
| 54 | saved_eip = return_point; |
| 55 | asm volatile ("movl %%esp,%0" : "=m" (saved_esp)); |
| 56 | asm volatile ("movl %%ebp,%0" : "=m" (saved_ebp)); |
| 57 | asm volatile ("movl %%ebx,%0" : "=m" (saved_ebx)); |
| 58 | asm volatile ("movl %%edi,%0" : "=m" (saved_edi)); |
| 59 | asm volatile ("movl %%esi,%0" : "=m" (saved_esi)); |
| 60 | } |
| 61 | |
| 62 | #define acpi_restore_register_state() do {} while (0) |
| 63 | |
| 64 | /* routines for saving/restoring kernel state */ |
| 65 | extern int acpi_save_state_mem(void); |
| 66 | #endif |