mirror of https://github.com/ipxe/ipxe.git
[librm] Rename prot_call() to virt_call()
Signed-off-by: Michael Brown <mcb30@ipxe.org>pull/45/head
parent
4c1f2486e6
commit
e2cf3138f0
|
@ -58,7 +58,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
|||
*/
|
||||
.macro virtcall function
|
||||
pushl $VIRTUAL(\function)
|
||||
call prot_call
|
||||
call virt_call
|
||||
.endm
|
||||
|
||||
#else /* ASSEMBLY */
|
||||
|
@ -76,7 +76,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
|||
*/
|
||||
#define VIRT_CALL( function ) \
|
||||
"pushl $( " _S2 ( VIRTUAL ( function ) ) " )\n\t" \
|
||||
"call prot_call\n\t"
|
||||
"call virt_call\n\t"
|
||||
|
||||
/* Variables in librm.S */
|
||||
extern const unsigned long virt_offset;
|
||||
|
|
|
@ -167,7 +167,7 @@ struct i386_seg_regs {
|
|||
*
|
||||
* @endcode
|
||||
*
|
||||
* prot_call() and kir_call() create this data structure on the stack
|
||||
* virt_call() and kir_call() create this data structure on the stack
|
||||
* and pass in a pointer to this structure.
|
||||
*
|
||||
*/
|
||||
|
|
|
@ -640,19 +640,19 @@ intr_to_prot:
|
|||
.equ _intr_to_virt, intr_to_prot
|
||||
|
||||
/****************************************************************************
|
||||
* prot_call (real-mode near call, 16-bit real-mode near return address)
|
||||
* virt_call (real-mode near call, 16-bit real-mode near return address)
|
||||
*
|
||||
* Call a specific C function in the protected-mode code. The
|
||||
* prototype of the C function must be
|
||||
* void function ( struct i386_all_regs *ix86 );
|
||||
* ix86 will point to a struct containing the real-mode registers
|
||||
* at entry to prot_call.
|
||||
* at entry to virt_call().
|
||||
*
|
||||
* All registers will be preserved across prot_call(), unless the C
|
||||
* All registers will be preserved across virt_call(), unless the C
|
||||
* function explicitly overwrites values in ix86. Interrupt status
|
||||
* and GDT will also be preserved. Gate A20 will be enabled.
|
||||
*
|
||||
* Note that prot_call() does not rely on the real-mode stack
|
||||
* Note that virt_call() does not rely on the real-mode stack
|
||||
* remaining intact in order to return, since everything relevant is
|
||||
* copied to the protected-mode stack for the duration of the call.
|
||||
* In particular, this means that a real-mode prefix can make a call
|
||||
|
@ -666,26 +666,26 @@ intr_to_prot:
|
|||
*
|
||||
* Example usage:
|
||||
* pushl $pxe_api_call
|
||||
* call prot_call
|
||||
* call virt_call
|
||||
* to call in to the C function
|
||||
* void pxe_api_call ( struct i386_all_regs *ix86 );
|
||||
****************************************************************************
|
||||
*/
|
||||
.struct 0
|
||||
PC_OFFSET_GDT: .space 6
|
||||
PC_OFFSET_IDT: .space 6
|
||||
PC_OFFSET_IX86: .space SIZEOF_I386_ALL_REGS
|
||||
PC_OFFSET_PADDING: .space 2 /* for alignment */
|
||||
PC_OFFSET_RETADDR: .space 2
|
||||
PC_OFFSET_PARAMS:
|
||||
PC_OFFSET_FUNCTION: .space 4
|
||||
PC_OFFSET_END:
|
||||
VC_OFFSET_GDT: .space 6
|
||||
VC_OFFSET_IDT: .space 6
|
||||
VC_OFFSET_IX86: .space SIZEOF_I386_ALL_REGS
|
||||
VC_OFFSET_PADDING: .space 2 /* for alignment */
|
||||
VC_OFFSET_RETADDR: .space 2
|
||||
VC_OFFSET_PARAMS:
|
||||
VC_OFFSET_FUNCTION: .space 4
|
||||
VC_OFFSET_END:
|
||||
.previous
|
||||
|
||||
.section ".text16.prot_call", "ax", @progbits
|
||||
.section ".text16.virt_call", "ax", @progbits
|
||||
.code16
|
||||
.globl prot_call
|
||||
prot_call:
|
||||
.globl virt_call
|
||||
virt_call:
|
||||
/* Preserve registers, flags and GDT on external RM stack */
|
||||
pushfw /* padding */
|
||||
pushfl
|
||||
|
@ -696,37 +696,37 @@ prot_call:
|
|||
pushw %ds
|
||||
pushw %ss
|
||||
pushw %cs
|
||||
subw $PC_OFFSET_IX86, %sp
|
||||
subw $VC_OFFSET_IX86, %sp
|
||||
movw %sp, %bp
|
||||
sidt PC_OFFSET_IDT(%bp)
|
||||
sgdt PC_OFFSET_GDT(%bp)
|
||||
sidt VC_OFFSET_IDT(%bp)
|
||||
sgdt VC_OFFSET_GDT(%bp)
|
||||
|
||||
/* For sanity's sake, clear the direction flag as soon as possible */
|
||||
cld
|
||||
|
||||
/* Switch to protected mode and move register dump to PM stack */
|
||||
movl $PC_OFFSET_END, %ecx
|
||||
pushl $VIRTUAL(pc_pmode)
|
||||
movl $VC_OFFSET_END, %ecx
|
||||
pushl $VIRTUAL(vc_pmode)
|
||||
jmp real_to_prot
|
||||
.section ".text.prot_call", "ax", @progbits
|
||||
.section ".text.virt_call", "ax", @progbits
|
||||
.code32
|
||||
pc_pmode:
|
||||
vc_pmode:
|
||||
/* Call function */
|
||||
leal PC_OFFSET_IX86(%esp), %eax
|
||||
leal VC_OFFSET_IX86(%esp), %eax
|
||||
pushl %eax
|
||||
call *(PC_OFFSET_FUNCTION+4)(%esp)
|
||||
call *(VC_OFFSET_FUNCTION+4)(%esp)
|
||||
popl %eax /* discard */
|
||||
|
||||
/* Switch to real mode and move register dump back to RM stack */
|
||||
movl $PC_OFFSET_END, %ecx
|
||||
movl $VC_OFFSET_END, %ecx
|
||||
movl %esp, %esi
|
||||
pushl $pc_rmode
|
||||
pushl $vc_rmode
|
||||
jmp prot_to_real
|
||||
.section ".text16.prot_call", "ax", @progbits
|
||||
.section ".text16.virt_call", "ax", @progbits
|
||||
.code16
|
||||
pc_rmode:
|
||||
vc_rmode:
|
||||
/* Restore registers and flags and return */
|
||||
addw $( PC_OFFSET_IX86 + 4 /* also skip %cs and %ss */ ), %sp
|
||||
addw $( VC_OFFSET_IX86 + 4 /* also skip %cs and %ss */ ), %sp
|
||||
popw %ds
|
||||
popw %es
|
||||
popw %fs
|
||||
|
@ -742,7 +742,7 @@ pc_rmode:
|
|||
popfw /* padding */
|
||||
|
||||
/* Return and discard function parameters */
|
||||
ret $( PC_OFFSET_END - PC_OFFSET_PARAMS )
|
||||
ret $( VC_OFFSET_END - VC_OFFSET_PARAMS )
|
||||
|
||||
/****************************************************************************
|
||||
* real_call (protected-mode near call, 32-bit virtual return address)
|
||||
|
|
|
@ -52,8 +52,8 @@ static struct profiler r2p_profiler __profiler = { .name = "r2p" };
|
|||
/** Real-mode call profiler */
|
||||
static struct profiler real_call_profiler __profiler = { .name = "real_call" };
|
||||
|
||||
/** Protected-mode call profiler */
|
||||
static struct profiler prot_call_profiler __profiler = { .name = "prot_call" };
|
||||
/** Virtual call profiler */
|
||||
static struct profiler virt_call_profiler __profiler = { .name = "virt_call" };
|
||||
|
||||
/**
|
||||
* Dummy function for profiling tests
|
||||
|
@ -101,7 +101,7 @@ static void librm_test_exec ( void ) {
|
|||
profile_stop ( &real_call_profiler );
|
||||
}
|
||||
|
||||
/* Profile complete protected-mode call cycle */
|
||||
/* Profile complete virtual call cycle */
|
||||
for ( i = 0 ; i < PROFILE_COUNT ; i++ ) {
|
||||
__asm__ __volatile__ ( REAL_CODE ( "rdtsc\n\t"
|
||||
"movl %k0, %k2\n\t"
|
||||
|
@ -109,8 +109,8 @@ static void librm_test_exec ( void ) {
|
|||
"rdtsc\n\t" )
|
||||
: "=a" ( stopped ), "=d" ( discard_d ),
|
||||
"=R" ( started ) : );
|
||||
profile_start_at ( &prot_call_profiler, started );
|
||||
profile_stop_at ( &prot_call_profiler, stopped );
|
||||
profile_start_at ( &virt_call_profiler, started );
|
||||
profile_stop_at ( &virt_call_profiler, stopped );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue