Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 .text
0003 #include <linux/linkage.h>
0004 #include <asm/segment.h>
0005 #include <asm/page.h>
0006 #include <asm/pgtable_32.h>
0007 
0008     .macro writepost,value
0009         movb $0x34, %al
0010         outb %al, $0x70
0011         movb $\value, %al
0012         outb %al, $0x71
0013     .endm
0014 
0015 wakeup_start:
0016     # OFW lands us here, running in protected mode, with a
0017     # kernel-compatible GDT already setup.
0018 
0019     # Clear any dangerous flags
0020     pushl $0
0021     popfl
0022 
0023     writepost 0x31
0024 
0025     # Set up %cr3
0026     movl $initial_page_table - __PAGE_OFFSET, %eax
0027     movl %eax, %cr3
0028 
0029     movl saved_cr4, %eax
0030     movl %eax, %cr4
0031 
0032     movl saved_cr0, %eax
0033     movl %eax, %cr0
0034 
0035     # Control registers were modified, pipeline resync is needed
0036     jmp 1f
0037 1:
0038 
0039     movw    $__KERNEL_DS, %ax
0040     movw    %ax, %ss
0041     movw    %ax, %ds
0042     movw    %ax, %es
0043     movw    %ax, %fs
0044     movw    %ax, %gs
0045 
0046     lgdt    saved_gdt
0047     lidt    saved_idt
0048     lldt    saved_ldt
0049     ljmp    $(__KERNEL_CS),$1f
0050 1:
0051     movl    %cr3, %eax
0052     movl    %eax, %cr3
0053     wbinvd
0054 
0055     # Go back to the return point
0056     jmp ret_point
0057 
0058 save_registers:
0059     sgdt  saved_gdt
0060     sidt  saved_idt
0061     sldt  saved_ldt
0062 
0063     pushl %edx
0064     movl %cr4, %edx
0065     movl %edx, saved_cr4
0066 
0067     movl %cr0, %edx
0068     movl %edx, saved_cr0
0069 
0070     popl %edx
0071 
0072     movl %ebx, saved_context_ebx
0073     movl %ebp, saved_context_ebp
0074     movl %esi, saved_context_esi
0075     movl %edi, saved_context_edi
0076 
0077     pushfl
0078     popl saved_context_eflags
0079 
0080     RET
0081 
0082 restore_registers:
0083     movl saved_context_ebp, %ebp
0084     movl saved_context_ebx, %ebx
0085     movl saved_context_esi, %esi
0086     movl saved_context_edi, %edi
0087 
0088     pushl saved_context_eflags
0089     popfl
0090 
0091     RET
0092 
0093 SYM_CODE_START(do_olpc_suspend_lowlevel)
0094     call    save_processor_state
0095     call    save_registers
0096 
0097     # This is the stack context we want to remember
0098     movl %esp, saved_context_esp
0099 
0100     pushl   $3
0101     call    xo1_do_sleep
0102 
0103     jmp wakeup_start
0104     .p2align 4,,7
0105 ret_point:
0106     movl    saved_context_esp, %esp
0107 
0108     writepost 0x32
0109 
0110     call    restore_registers
0111     call    restore_processor_state
0112     RET
0113 SYM_CODE_END(do_olpc_suspend_lowlevel)
0114 
0115 .data
0116 saved_gdt:             .long   0,0
0117 saved_idt:             .long   0,0
0118 saved_ldt:             .long   0
0119 saved_cr4:             .long   0
0120 saved_cr0:             .long   0
0121 saved_context_esp:     .long   0
0122 saved_context_edi:     .long   0
0123 saved_context_esi:     .long   0
0124 saved_context_ebx:     .long   0
0125 saved_context_ebp:     .long   0
0126 saved_context_eflags:  .long   0