mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-23 21:54:27 +02:00
Added AsmSwitchStackAndBackingStore() to BaseLib.h for stack switching on IPF.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1305 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
4a6a5026fc
commit
681dbac98c
@ -4987,4 +4987,36 @@ AsmPrepareAndThunk16 (
|
|||||||
IN OUT THUNK_CONTEXT *ThunkContext
|
IN OUT THUNK_CONTEXT *ThunkContext
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Transfers control to a function starting with a new stack.
|
||||||
|
|
||||||
|
Transfers control to the function specified by EntryPoint using the new stack
|
||||||
|
specified by NewStack and passing in the parameters specified by Context1 and
|
||||||
|
Context2. Context1 and Context2 are optional and may be NULL. The function
|
||||||
|
EntryPoint must never return.
|
||||||
|
|
||||||
|
If EntryPoint is NULL, then ASSERT().
|
||||||
|
If NewStack is NULL, then ASSERT().
|
||||||
|
|
||||||
|
@param EntryPoint A pointer to function to call with the new stack.
|
||||||
|
@param Context1 A pointer to the context to pass into the EntryPoint
|
||||||
|
function.
|
||||||
|
@param Context2 A pointer to the context to pass into the EntryPoint
|
||||||
|
function.
|
||||||
|
@param NewStack A pointer to the new stack to use for the EntryPoint
|
||||||
|
function.
|
||||||
|
@param NewBsp A pointer to the new memory location for RSE backing
|
||||||
|
store.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
AsmSwitchStackAndBackingStore (
|
||||||
|
IN SWITCH_STACK_ENTRY_POINT EntryPoint,
|
||||||
|
IN VOID *Context1, OPTIONAL
|
||||||
|
IN VOID *Context2, OPTIONAL
|
||||||
|
IN VOID *NewStack,
|
||||||
|
IN VOID *NewBsp
|
||||||
|
);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,122 +1,50 @@
|
|||||||
//++
|
/// @file
|
||||||
// Copyright (c) 2006, Intel Corporation
|
/// IPF specific SwitchStack() function
|
||||||
// All rights reserved. This program and the accompanying materials
|
///
|
||||||
// are licensed and made available under the terms and conditions of the BSD License
|
/// Copyright (c) 2006, Intel Corporation
|
||||||
// which accompanies this distribution. The full text of the license may be found at
|
/// All rights reserved. This program and the accompanying materials
|
||||||
// http://opensource.org/licenses/bsd-license.php
|
/// are licensed and made available under the terms and conditions of the BSD License
|
||||||
//
|
/// which accompanies this distribution. The full text of the license may be found at
|
||||||
// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
/// http://opensource.org/licenses/bsd-license.php
|
||||||
// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
///
|
||||||
//
|
/// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
// Module Name:
|
/// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
//
|
///
|
||||||
// SwitchStack.s
|
/// Module Name: SwitchStack.s
|
||||||
//
|
///
|
||||||
// Abstract:
|
///
|
||||||
//
|
|
||||||
// Contains an implementation of a stack switch for the Itanium-based architecture.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Revision History:
|
|
||||||
//
|
|
||||||
//--
|
|
||||||
|
|
||||||
.file "SwitchStack.s"
|
.auto
|
||||||
|
.text
|
||||||
|
|
||||||
#include "asm.h"
|
.proc AsmSwitchStackAndBackingStore
|
||||||
#include "ia_64gen.h"
|
.type AsmSwitchStackAndBackingStore, @function
|
||||||
|
.regstk 5, 0, 0, 0
|
||||||
|
AsmSwitchStackAndBackingStore::
|
||||||
|
mov r14 = ar.rsc
|
||||||
|
movl r2 = ~((((1 << 14) - 1) << 16) | 3)
|
||||||
|
|
||||||
// Define hardware RSE Configuration Register
|
mov r17 = in1
|
||||||
//
|
mov r18 = in2
|
||||||
// RS Configuration (RSC) bit field positions
|
and r2 = r14, r2
|
||||||
|
|
||||||
#define RSC_MODE 0
|
mov ar.rsc = r2
|
||||||
#define RSC_PL 2
|
mov sp = in3
|
||||||
#define RSC_BE 4
|
mov r19 = in4
|
||||||
// RSC bits 5-15 reserved
|
|
||||||
#define RSC_MBZ0 5
|
|
||||||
#define RSC_MBZ0_V 0x3ff
|
|
||||||
#define RSC_LOADRS 16
|
|
||||||
#define RSC_LOADRS_LEN 14
|
|
||||||
// RSC bits 30-63 reserved
|
|
||||||
#define RSC_MBZ1 30
|
|
||||||
#define RSC_MBZ1_V 0x3ffffffffULL
|
|
||||||
|
|
||||||
// RSC modes
|
ld8.nt1 r16 = [in0], 8
|
||||||
// Lazy
|
ld8.nta gp = [in0]
|
||||||
#define RSC_MODE_LY (0x0)
|
mov r3 = -1
|
||||||
// Store intensive
|
|
||||||
#define RSC_MODE_SI (0x1)
|
|
||||||
// Load intensive
|
|
||||||
#define RSC_MODE_LI (0x2)
|
|
||||||
// Eager
|
|
||||||
#define RSC_MODE_EA (0x3)
|
|
||||||
|
|
||||||
// RSC Endian bit values
|
loadrs
|
||||||
#define RSC_BE_LITTLE 0
|
mov ar.bspstore = r19
|
||||||
#define RSC_BE_BIG 1
|
mov b7 = r16
|
||||||
|
|
||||||
// RSC while in kernel: enabled, little endian, pl = 0, eager mode
|
|
||||||
#define RSC_KERNEL ((RSC_MODE_EA<<RSC_MODE) | (RSC_BE_LITTLE<<RSC_BE))
|
|
||||||
// Lazy RSC in kernel: enabled, little endian, pl = 0, lazy mode
|
|
||||||
#define RSC_KERNEL_LAZ ((RSC_MODE_LY<<RSC_MODE) | (RSC_BE_LITTLE<<RSC_BE))
|
|
||||||
// RSE disabled: disabled, pl = 0, little endian, eager mode
|
|
||||||
#define RSC_KERNEL_DISABLED ((RSC_MODE_LY<<RSC_MODE) | (RSC_BE_LITTLE<<RSC_BE))
|
|
||||||
|
|
||||||
|
|
||||||
//VOID
|
|
||||||
//InternalSwitchStack (
|
|
||||||
// VOID *ContinuationFunction,
|
|
||||||
// UINTN Parameter,
|
|
||||||
// UINTN NewTopOfStack,
|
|
||||||
// UINTN NewBSPStore OPTIONAL
|
|
||||||
//)
|
|
||||||
///*++
|
|
||||||
//
|
|
||||||
//Input Arguments
|
|
||||||
//
|
|
||||||
// ContinuationFunction - This is a pointer to the PLABEL of the function that should be called once the
|
|
||||||
// new stack has been created.
|
|
||||||
// Parameter - The parameter to pass to the continuation function
|
|
||||||
// NewTopOfStack - This is the new top of the memory stack for ensuing code. This is mandatory and
|
|
||||||
// should be non-zero
|
|
||||||
// NewBSPStore - This is the new BSP store for the ensuing code. It is optional on IA-32 and mandatory on Itanium-based platform.
|
|
||||||
//
|
|
||||||
//--*/
|
|
||||||
|
|
||||||
PROCEDURE_ENTRY(InternalSwitchStack)
|
|
||||||
|
|
||||||
mov r16 = -0x10;;
|
|
||||||
and r16 = r34, r16;; // get new stack value in R16, 0 the last nibble.
|
|
||||||
mov r15 = r35;; // Get new BspStore into R15
|
|
||||||
mov r13 = r32;; // this is a pointer to the PLABEL of the continuation function.
|
|
||||||
mov r17 = r33;; // this is the parameter to pass to the continuation function
|
|
||||||
|
|
||||||
alloc r11=0,0,0,0 // Set 0-size frame
|
|
||||||
;;
|
|
||||||
flushrs;;
|
|
||||||
|
|
||||||
mov r21 = RSC_KERNEL_DISABLED // for rse disable
|
|
||||||
;;
|
|
||||||
mov ar.rsc = r21 // turn off RSE
|
|
||||||
|
|
||||||
add sp = r0, r16;; // transfer to the EFI stack
|
|
||||||
mov ar.bspstore = r15 // switch to EFI BSP
|
|
||||||
invala // change of ar.bspstore needs invala.
|
|
||||||
|
|
||||||
mov r18 = RSC_KERNEL_LAZ // RSC enabled, Lazy mode
|
|
||||||
;;
|
|
||||||
mov ar.rsc = r18 // turn rse on, in kernel mode
|
|
||||||
;;
|
|
||||||
alloc r11=0,0,1,0;; // alloc 0 outs going to ensuing DXE IPL service
|
|
||||||
mov out0 = r17
|
|
||||||
ld8 r16 = [r13],8;; // r16 = address of continuation function from the PLABEL
|
|
||||||
ld8 gp = [r13] // gp = gp of continuation function from the PLABEL
|
|
||||||
mov b6 = r16
|
|
||||||
;;
|
|
||||||
br.call.sptk.few b0=b6;; // Call the continuation function
|
|
||||||
;;
|
|
||||||
PROCEDURE_EXIT(InternalSwitchStack)
|
|
||||||
|
|
||||||
|
alloc r2 = ar.pfs, 0, 0, 2, 0
|
||||||
|
mov out0 = r17
|
||||||
|
mov out1 = r18
|
||||||
|
|
||||||
|
mov ar.rnat = r3
|
||||||
|
mov ar.rsc = r14
|
||||||
|
br.call.sptk.many b0 = b7
|
||||||
|
.endp AsmSwitchStackAndBackingStore
|
||||||
|
Loading…
x
Reference in New Issue
Block a user