x86: make arch/x86/kernel/acpi/wakeup_32.S use a separate
While examining vmlinux namelist on i386 (nm -v vmlinux) I noticed :
c01021d0 t es7000_rename_gsi
c010221a T es7000_start_cpu
<Big Hole>
c0103000 T thread_saved_pc
and
c0113218 T acpi_restore_state_mem
c0113219 T acpi_save_state_mem
<Big Hole>
c0114000 t wakeup_code
This is because arch/x86/kernel/acpi/wakeup_32.S forces a .text alignment
of 4096 bytes. (I have no idea if it is really needed, since
arch/x86/kernel/acpi/wakeup_64.S uses a 16 bytes alignment *only*)
So arch/x86/kernel/built-in.o also has this alignment
arch/x86/kernel/built-in.o: file format elf32-i386
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00018c94 00000000 00000000 00001000 2**12
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
But as arch/x86/kernel/acpi/wakeup_32.o is not the first object linked
into arch/x86/kernel/built-in.o, linker had to build several holes to meet
alignement requirements, because of .o nestings in the kbuild process.
This can be solved by using a special section, .text.page_aligned, so that
no holes are needed.
# size vmlinux.before vmlinux.after
text data bss dec hex filename
4619942 422838 458752 5501532 53f25c vmlinux.before
4610534 422838 458752 5492124 53cd9c vmlinux.after
This saves 9408 bytes
Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-01-30 05:32:50 -07:00
|
|
|
.section .text.page_aligned
|
2005-04-16 16:20:36 -06:00
|
|
|
#include <linux/linkage.h>
|
|
|
|
#include <asm/segment.h>
|
2009-02-13 12:14:01 -07:00
|
|
|
#include <asm/page_types.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2008-04-10 15:28:10 -06:00
|
|
|
# Copyright 2003, 2008 Pavel Machek <pavel@suse.cz>, distribute under GPLv2
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
.code32
|
|
|
|
ALIGN
|
|
|
|
|
2008-04-10 15:28:10 -06:00
|
|
|
ENTRY(wakeup_pmode_return)
|
2005-04-16 16:20:36 -06:00
|
|
|
wakeup_pmode_return:
|
|
|
|
movw $__KERNEL_DS, %ax
|
|
|
|
movw %ax, %ss
|
|
|
|
movw %ax, %ds
|
|
|
|
movw %ax, %es
|
|
|
|
movw %ax, %fs
|
|
|
|
movw %ax, %gs
|
|
|
|
|
|
|
|
# reload the gdt, as we need the full 32 bit address
|
|
|
|
lgdt saved_gdt
|
|
|
|
lidt saved_idt
|
|
|
|
lldt saved_ldt
|
2008-04-10 15:28:10 -06:00
|
|
|
ljmp $(__KERNEL_CS), $1f
|
2005-04-16 16:20:36 -06:00
|
|
|
1:
|
|
|
|
movl %cr3, %eax
|
|
|
|
movl %eax, %cr3
|
|
|
|
wbinvd
|
|
|
|
|
|
|
|
# and restore the stack ... but you need gdt for this to work
|
|
|
|
movl saved_context_esp, %esp
|
|
|
|
|
|
|
|
movl %cs:saved_magic, %eax
|
|
|
|
cmpl $0x12345678, %eax
|
|
|
|
jne bogus_magic
|
|
|
|
|
|
|
|
# jump to place where we left off
|
2008-04-10 15:28:10 -06:00
|
|
|
movl saved_eip, %eax
|
2005-04-16 16:20:36 -06:00
|
|
|
jmp *%eax
|
|
|
|
|
|
|
|
bogus_magic:
|
|
|
|
jmp bogus_magic
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-04-10 15:28:10 -06:00
|
|
|
save_registers:
|
2005-04-16 16:20:36 -06:00
|
|
|
sgdt saved_gdt
|
|
|
|
sidt saved_idt
|
|
|
|
sldt saved_ldt
|
|
|
|
str saved_tss
|
|
|
|
|
|
|
|
leal 4(%esp), %eax
|
|
|
|
movl %eax, saved_context_esp
|
2008-04-10 15:28:10 -06:00
|
|
|
movl %ebx, saved_context_ebx
|
|
|
|
movl %ebp, saved_context_ebp
|
|
|
|
movl %esi, saved_context_esi
|
|
|
|
movl %edi, saved_context_edi
|
|
|
|
pushfl
|
|
|
|
popl saved_context_eflags
|
|
|
|
|
|
|
|
movl $ret_point, saved_eip
|
2005-04-16 16:20:36 -06:00
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
restore_registers:
|
2008-04-10 15:28:10 -06:00
|
|
|
movl saved_context_ebp, %ebp
|
|
|
|
movl saved_context_ebx, %ebx
|
|
|
|
movl saved_context_esi, %esi
|
|
|
|
movl saved_context_edi, %edi
|
|
|
|
pushl saved_context_eflags
|
|
|
|
popfl
|
|
|
|
ret
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
ENTRY(do_suspend_lowlevel)
|
|
|
|
call save_processor_state
|
|
|
|
call save_registers
|
|
|
|
pushl $3
|
|
|
|
call acpi_enter_sleep_state
|
|
|
|
addl $4, %esp
|
2006-08-14 23:37:31 -06:00
|
|
|
|
|
|
|
# In case of S3 failure, we'll emerge here. Jump
|
|
|
|
# to ret_point to recover
|
|
|
|
jmp ret_point
|
2005-04-16 16:20:36 -06:00
|
|
|
.p2align 4,,7
|
|
|
|
ret_point:
|
|
|
|
call restore_registers
|
|
|
|
call restore_processor_state
|
|
|
|
ret
|
|
|
|
|
2006-06-23 03:04:50 -06:00
|
|
|
.data
|
2005-04-16 16:20:36 -06:00
|
|
|
ALIGN
|
2006-06-23 03:04:50 -06:00
|
|
|
ENTRY(saved_magic) .long 0
|
|
|
|
ENTRY(saved_eip) .long 0
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
# saved registers
|
|
|
|
saved_gdt: .long 0,0
|
|
|
|
saved_idt: .long 0,0
|
|
|
|
saved_ldt: .long 0
|
|
|
|
saved_tss: .long 0
|
|
|
|
|