[librm] Rename prot_call() to virt_call()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
pull/45/head
Michael Brown 2016-02-22 00:49:08 +00:00
parent 4c1f2486e6
commit e2cf3138f0
4 changed files with 39 additions and 39 deletions

View File

@ -58,7 +58,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
*/ */
.macro virtcall function .macro virtcall function
pushl $VIRTUAL(\function) pushl $VIRTUAL(\function)
call prot_call call virt_call
.endm .endm
#else /* ASSEMBLY */ #else /* ASSEMBLY */
@ -76,7 +76,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
*/ */
#define VIRT_CALL( function ) \ #define VIRT_CALL( function ) \
"pushl $( " _S2 ( VIRTUAL ( function ) ) " )\n\t" \ "pushl $( " _S2 ( VIRTUAL ( function ) ) " )\n\t" \
"call prot_call\n\t" "call virt_call\n\t"
/* Variables in librm.S */ /* Variables in librm.S */
extern const unsigned long virt_offset; extern const unsigned long virt_offset;

View File

@ -167,7 +167,7 @@ struct i386_seg_regs {
* *
* @endcode * @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. * and pass in a pointer to this structure.
* *
*/ */

View File

@ -640,19 +640,19 @@ intr_to_prot:
.equ _intr_to_virt, 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 * Call a specific C function in the protected-mode code. The
* prototype of the C function must be * prototype of the C function must be
* void function ( struct i386_all_regs *ix86 ); * void function ( struct i386_all_regs *ix86 );
* ix86 will point to a struct containing the real-mode registers * 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 * function explicitly overwrites values in ix86. Interrupt status
* and GDT will also be preserved. Gate A20 will be enabled. * 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 * remaining intact in order to return, since everything relevant is
* copied to the protected-mode stack for the duration of the call. * 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 * In particular, this means that a real-mode prefix can make a call
@ -666,26 +666,26 @@ intr_to_prot:
* *
* Example usage: * Example usage:
* pushl $pxe_api_call * pushl $pxe_api_call
* call prot_call * call virt_call
* to call in to the C function * to call in to the C function
* void pxe_api_call ( struct i386_all_regs *ix86 ); * void pxe_api_call ( struct i386_all_regs *ix86 );
**************************************************************************** ****************************************************************************
*/ */
.struct 0 .struct 0
PC_OFFSET_GDT: .space 6 VC_OFFSET_GDT: .space 6
PC_OFFSET_IDT: .space 6 VC_OFFSET_IDT: .space 6
PC_OFFSET_IX86: .space SIZEOF_I386_ALL_REGS VC_OFFSET_IX86: .space SIZEOF_I386_ALL_REGS
PC_OFFSET_PADDING: .space 2 /* for alignment */ VC_OFFSET_PADDING: .space 2 /* for alignment */
PC_OFFSET_RETADDR: .space 2 VC_OFFSET_RETADDR: .space 2
PC_OFFSET_PARAMS: VC_OFFSET_PARAMS:
PC_OFFSET_FUNCTION: .space 4 VC_OFFSET_FUNCTION: .space 4
PC_OFFSET_END: VC_OFFSET_END:
.previous .previous
.section ".text16.prot_call", "ax", @progbits .section ".text16.virt_call", "ax", @progbits
.code16 .code16
.globl prot_call .globl virt_call
prot_call: virt_call:
/* Preserve registers, flags and GDT on external RM stack */ /* Preserve registers, flags and GDT on external RM stack */
pushfw /* padding */ pushfw /* padding */
pushfl pushfl
@ -696,37 +696,37 @@ prot_call:
pushw %ds pushw %ds
pushw %ss pushw %ss
pushw %cs pushw %cs
subw $PC_OFFSET_IX86, %sp subw $VC_OFFSET_IX86, %sp
movw %sp, %bp movw %sp, %bp
sidt PC_OFFSET_IDT(%bp) sidt VC_OFFSET_IDT(%bp)
sgdt PC_OFFSET_GDT(%bp) sgdt VC_OFFSET_GDT(%bp)
/* For sanity's sake, clear the direction flag as soon as possible */ /* For sanity's sake, clear the direction flag as soon as possible */
cld cld
/* Switch to protected mode and move register dump to PM stack */ /* Switch to protected mode and move register dump to PM stack */
movl $PC_OFFSET_END, %ecx movl $VC_OFFSET_END, %ecx
pushl $VIRTUAL(pc_pmode) pushl $VIRTUAL(vc_pmode)
jmp real_to_prot jmp real_to_prot
.section ".text.prot_call", "ax", @progbits .section ".text.virt_call", "ax", @progbits
.code32 .code32
pc_pmode: vc_pmode:
/* Call function */ /* Call function */
leal PC_OFFSET_IX86(%esp), %eax leal VC_OFFSET_IX86(%esp), %eax
pushl %eax pushl %eax
call *(PC_OFFSET_FUNCTION+4)(%esp) call *(VC_OFFSET_FUNCTION+4)(%esp)
popl %eax /* discard */ popl %eax /* discard */
/* Switch to real mode and move register dump back to RM stack */ /* 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 movl %esp, %esi
pushl $pc_rmode pushl $vc_rmode
jmp prot_to_real jmp prot_to_real
.section ".text16.prot_call", "ax", @progbits .section ".text16.virt_call", "ax", @progbits
.code16 .code16
pc_rmode: vc_rmode:
/* Restore registers and flags and return */ /* 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 %ds
popw %es popw %es
popw %fs popw %fs
@ -742,7 +742,7 @@ pc_rmode:
popfw /* padding */ popfw /* padding */
/* Return and discard function parameters */ /* 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) * real_call (protected-mode near call, 32-bit virtual return address)

View File

@ -52,8 +52,8 @@ static struct profiler r2p_profiler __profiler = { .name = "r2p" };
/** Real-mode call profiler */ /** Real-mode call profiler */
static struct profiler real_call_profiler __profiler = { .name = "real_call" }; static struct profiler real_call_profiler __profiler = { .name = "real_call" };
/** Protected-mode call profiler */ /** Virtual call profiler */
static struct profiler prot_call_profiler __profiler = { .name = "prot_call" }; static struct profiler virt_call_profiler __profiler = { .name = "virt_call" };
/** /**
* Dummy function for profiling tests * Dummy function for profiling tests
@ -101,7 +101,7 @@ static void librm_test_exec ( void ) {
profile_stop ( &real_call_profiler ); profile_stop ( &real_call_profiler );
} }
/* Profile complete protected-mode call cycle */ /* Profile complete virtual call cycle */
for ( i = 0 ; i < PROFILE_COUNT ; i++ ) { for ( i = 0 ; i < PROFILE_COUNT ; i++ ) {
__asm__ __volatile__ ( REAL_CODE ( "rdtsc\n\t" __asm__ __volatile__ ( REAL_CODE ( "rdtsc\n\t"
"movl %k0, %k2\n\t" "movl %k0, %k2\n\t"
@ -109,8 +109,8 @@ static void librm_test_exec ( void ) {
"rdtsc\n\t" ) "rdtsc\n\t" )
: "=a" ( stopped ), "=d" ( discard_d ), : "=a" ( stopped ), "=d" ( discard_d ),
"=R" ( started ) : ); "=R" ( started ) : );
profile_start_at ( &prot_call_profiler, started ); profile_start_at ( &virt_call_profiler, started );
profile_stop_at ( &prot_call_profiler, stopped ); profile_stop_at ( &virt_call_profiler, stopped );
} }
} }