[PATCH] xtensa platform-iss network: remove no-op ioctl handler
[linux-2.6/libata-dev.git] / arch / i386 / power / cpu.c
blob50a0bef8c85f691bc135167e595dc5b6521a8ec0
1 /*
2 * Suspend support specific for i386.
4 * Distribute under GPLv2
6 * Copyright (c) 2002 Pavel Machek <pavel@suse.cz>
7 * Copyright (c) 2001 Patrick Mochel <mochel@osdl.org>
8 */
10 #include <linux/config.h>
11 #include <linux/module.h>
12 #include <linux/suspend.h>
14 static struct saved_context saved_context;
16 unsigned long saved_context_ebx;
17 unsigned long saved_context_esp, saved_context_ebp;
18 unsigned long saved_context_esi, saved_context_edi;
19 unsigned long saved_context_eflags;
21 void __save_processor_state(struct saved_context *ctxt)
23 kernel_fpu_begin();
26 * descriptor tables
28 store_gdt(&ctxt->gdt_limit);
29 store_idt(&ctxt->idt_limit);
30 store_tr(ctxt->tr);
33 * segment registers
35 savesegment(es, ctxt->es);
36 savesegment(fs, ctxt->fs);
37 savesegment(gs, ctxt->gs);
38 savesegment(ss, ctxt->ss);
41 * control registers
43 ctxt->cr0 = read_cr0();
44 ctxt->cr2 = read_cr2();
45 ctxt->cr3 = read_cr3();
46 ctxt->cr4 = read_cr4();
49 void save_processor_state(void)
51 __save_processor_state(&saved_context);
54 static void do_fpu_end(void)
57 * Restore FPU regs if necessary.
59 kernel_fpu_end();
62 static void fix_processor_context(void)
64 int cpu = smp_processor_id();
65 struct tss_struct * t = &per_cpu(init_tss, cpu);
67 set_tss_desc(cpu,t); /* This just modifies memory; should not be necessary. But... This is necessary, because 386 hardware has concept of busy TSS or some similar stupidity. */
69 load_TR_desc(); /* This does ltr */
70 load_LDT(&current->active_mm->context); /* This does lldt */
73 * Now maybe reload the debug registers
75 if (current->thread.debugreg[7]){
76 set_debugreg(current->thread.debugreg[0], 0);
77 set_debugreg(current->thread.debugreg[1], 1);
78 set_debugreg(current->thread.debugreg[2], 2);
79 set_debugreg(current->thread.debugreg[3], 3);
80 /* no 4 and 5 */
81 set_debugreg(current->thread.debugreg[6], 6);
82 set_debugreg(current->thread.debugreg[7], 7);
87 void __restore_processor_state(struct saved_context *ctxt)
90 * control registers
92 write_cr4(ctxt->cr4);
93 write_cr3(ctxt->cr3);
94 write_cr2(ctxt->cr2);
95 write_cr2(ctxt->cr0);
98 * now restore the descriptor tables to their proper values
99 * ltr is done i fix_processor_context().
101 load_gdt(&ctxt->gdt_limit);
102 load_idt(&ctxt->idt_limit);
105 * segment registers
107 loadsegment(es, ctxt->es);
108 loadsegment(fs, ctxt->fs);
109 loadsegment(gs, ctxt->gs);
110 loadsegment(ss, ctxt->ss);
113 * sysenter MSRs
115 if (boot_cpu_has(X86_FEATURE_SEP))
116 enable_sep_cpu();
118 fix_processor_context();
119 do_fpu_end();
120 mtrr_ap_init();
121 mcheck_init(&boot_cpu_data);
124 void restore_processor_state(void)
126 __restore_processor_state(&saved_context);
129 /* Needed by apm.c */
130 EXPORT_SYMBOL(save_processor_state);
131 EXPORT_SYMBOL(restore_processor_state);