1 # 2 # Copyright (c) 2004, Intel Corporation. All rights reserved.<BR> 3 # This program and the accompanying materials 4 # are licensed and made available under the terms and conditions of the BSD License 5 # which accompanies this distribution. The full text of the license may be found at 6 # http://opensource.org/licenses/bsd-license.php 7 # 8 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 9 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 10 # 11 # Module Name: 12 # 13 # ProcessorAsms.Asm 14 # 15 # 16 # 17 #include "EfiBind.h" 18 #------------------------------------------------------------------------------ 19 20 .686P: 21 .MMX: 22 #.MODEL SMALL 23 .CODE: 24 #------------------------------------------------------------------------------ 25 26 .globl ASM_PFX(TransferControlSetJump) 27 .globl ASM_PFX(TransferControlLongJump) 28 .globl ASM_PFX(SwitchStacks) 29 .globl ASM_PFX(SwitchIplStacks) 30 31 #define EFI_SUCCESS 0 32 #define EFI_WARN_RETURN_FROM_LONG_JUMP 5 33 34 # 35 # typedef struct { 36 # UINT32 ebx; 37 # UINT32 esi; 38 # UINT32 edi; 39 # UINT32 ebp; 40 # UINT32 esp; 41 # UINT32 eip; 42 #} EFI_JUMP_BUFFER; 43 # 44 45 #typedef 46 #EFI_STATUS 47 #(EFIAPI *EFI_PEI_TRANSFER_CONTROL_SET_JUMP) ( 48 # IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL *This, 49 # OUT EFI_JUMP_BUFFER *Context 50 # ); 51 # 52 #Routine Description: 53 # 54 # This routine implements the IA32 variant of the SetJump call. Its 55 # responsibility is to store system state information for a possible 56 # subsequent LongJump. 57 # 58 #Arguments: 59 # 60 # Pointer to CPU context save buffer. 61 # 62 #Returns: 63 # 64 # EFI_SUCCESS 65 # 66 ASM_PFX(TransferControlSetJump): 67 push %ebp 68 mov %esp,%ebp 69 mov 0x8(%ebp),%eax 70 mov 0xc(%ebp),%ecx 71 mov %ebx,(%ecx) 72 mov %esi,0x4(%ecx) 73 mov %edi,0x8(%ecx) 74 mov 0x0(%ebp),%eax 75 mov %eax,0xc(%ecx) 76 lea 0x4(%ebp),%eax 77 mov %eax,0x10(%ecx) 78 mov 0x4(%ebp),%eax 79 mov %eax,0x14(%ecx) 80 mov $0x0,%eax 81 leave 82 ret 83 84 #typedef 85 #EFI_STATUS 86 #(EFIAPI *EFI_PEI_TRANSFER_CONTROL_LONG_JUMP) ( 87 # IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL *This, 88 # IN EFI_JUMP_BUFFER *Context 89 # ); 90 # 91 # Routine Description: 92 # 93 # This routine implements the IA32 variant of the LongJump call. Its 94 # responsibility is restore the system state to the Context Buffer and 95 # pass control back. 96 # 97 # Arguments: 98 # 99 # Pointer to CPU context save buffer. 100 # 101 # Returns: 102 # 103 # EFI_WARN_RETURN_FROM_LONG_JUMP 104 # 105 106 ASM_PFX(TransferControlLongJump): 107 push %ebp 108 mov %esp,%ebp 109 push %ebx 110 push %esi 111 push %edi 112 mov 0x8(%ebp),%eax 113 mov $0x5,%eax 114 mov 0xc(%ebp),%ecx 115 mov (%ecx),%ebx 116 mov 0x4(%ecx),%esi 117 mov 0x8(%ecx),%edi 118 mov 0xc(%ecx),%ebp 119 mov 0x10(%ecx),%esp 120 add $0x4,%esp 121 jmp *0x14(%ecx) 122 mov $0x5,%eax 123 pop %edi 124 pop %esi 125 pop %ebx 126 leave 127 ret 128 129 # 130 # Routine Description: 131 # This allows the caller to switch the stack and goes to the new entry point 132 # 133 # Arguments: 134 # EntryPoint - Pointer to the location to enter 135 # Parameter - Parameter to pass in 136 # NewStack - New Location of the stack 137 # NewBsp - New BSP 138 # 139 # Returns: 140 # 141 # Nothing. Goes to the Entry Point passing in the new parameters 142 # 143 #SwitchStacks PROC C \ 144 # EntryPoint:PTR DWORD, \ 145 # Parameter:DWORD, \ 146 # NewStack:PTR DWORD, \ 147 # NewBsp:PTR DWORD 148 ASM_PFX(SwitchStacks): 149 push %ebp 150 mov %esp,%ebp 151 push %ebx 152 mov 0x14(%ebp),%eax 153 mov 0xc(%ebp),%ebx 154 mov 0x8(%ebp),%ecx 155 mov 0x10(%ebp),%eax 156 mov %eax,%esp 157 push %ebx 158 push $0x0 159 jmp *%ecx 160 pop %ebx 161 leave 162 ret 163 164 165 166 167 # 168 # Routine Description: 169 # This allows the caller to switch the stack and goes to the new entry point 170 # 171 # Arguments: 172 # EntryPoint - Pointer to the location to enter 173 # Parameter1/Parameter2 - Parameter to pass in 174 # NewStack - New Location of the stack 175 # NewBsp - New BSP 176 # 177 # Returns: 178 # 179 # Nothing. Goes to the Entry Point passing in the new parameters 180 # 181 #SwitchIplStacks PROC C \ 182 # EntryPoint:PTR DWORD, \ 183 # Parameter1:DWORD, \ 184 # Parameter2:DWORD, \ 185 # NewStack:PTR DWORD, \ 186 # NewBsp:PTR DWORD 187 ASM_PFX(SwitchIplStacks): 188 push %ebp 189 mov %esp,%ebp 190 push %ebx 191 mov 0x18(%ebp),%eax 192 mov 0xc(%ebp),%ebx 193 mov 0x10(%ebp),%edx 194 mov 0x8(%ebp),%ecx 195 mov 0x14(%ebp),%eax 196 mov %eax,%esp 197 push %edx 198 push %ebx 199 call *%ecx 200 pop %ebx 201 leave 202 ret 203 204 #SwitchIplStacks ENDP 205 206 207 208