[librm] Convert prot_call() to a real-mode near call

Signed-off-by: Michael Brown <mcb30@ipxe.org>
pull/45/head
Michael Brown 2016-02-18 16:36:04 +00:00
parent df2509db95
commit 196f0f2551
16 changed files with 6 additions and 23 deletions

View File

@ -661,7 +661,6 @@ void hook_comboot_interrupts ( ) {
__asm__ __volatile__ ( __asm__ __volatile__ (
TEXT16_CODE ( "\nint20_wrapper:\n\t" TEXT16_CODE ( "\nint20_wrapper:\n\t"
"pushl %0\n\t" "pushl %0\n\t"
"pushw %%cs\n\t"
"call prot_call\n\t" "call prot_call\n\t"
"clc\n\t" "clc\n\t"
"call patch_cf\n\t" "call patch_cf\n\t"
@ -673,7 +672,6 @@ void hook_comboot_interrupts ( ) {
__asm__ __volatile__ ( __asm__ __volatile__ (
TEXT16_CODE ( "\nint21_wrapper:\n\t" TEXT16_CODE ( "\nint21_wrapper:\n\t"
"pushl %0\n\t" "pushl %0\n\t"
"pushw %%cs\n\t"
"call prot_call\n\t" "call prot_call\n\t"
"clc\n\t" "clc\n\t"
"call patch_cf\n\t" "call patch_cf\n\t"
@ -685,7 +683,6 @@ void hook_comboot_interrupts ( ) {
__asm__ __volatile__ ( __asm__ __volatile__ (
TEXT16_CODE ( "\nint22_wrapper:\n\t" TEXT16_CODE ( "\nint22_wrapper:\n\t"
"pushl %0\n\t" "pushl %0\n\t"
"pushw %%cs\n\t"
"call prot_call\n\t" "call prot_call\n\t"
"clc\n\t" "clc\n\t"
"call patch_cf\n\t" "call patch_cf\n\t"

View File

@ -7,7 +7,6 @@ void __asmcall _dump_regs ( struct i386_all_regs *ix86 ) {
TEXT16_CODE ( ".globl dump_regs\n\t" TEXT16_CODE ( ".globl dump_regs\n\t"
"\ndump_regs:\n\t" "\ndump_regs:\n\t"
"pushl $_dump_regs\n\t" "pushl $_dump_regs\n\t"
"pushw %%cs\n\t"
"call prot_call\n\t" "call prot_call\n\t"
"ret\n\t" ) : : ); "ret\n\t" ) : : );

View File

@ -534,7 +534,6 @@ static void bios_inject_startup ( void ) {
"cmpb $0, %%cs:bios_inject_lock\n\t" "cmpb $0, %%cs:bios_inject_lock\n\t"
"jnz 1f\n\t" "jnz 1f\n\t"
"pushl %0\n\t" "pushl %0\n\t"
"pushw %%cs\n\t"
"call prot_call\n\t" "call prot_call\n\t"
"\n1:\n\t" "\n1:\n\t"
"popfw\n\t" "popfw\n\t"

View File

@ -1481,7 +1481,6 @@ static void int13_hook_vector ( void ) {
"orb $0, %%al\n\t" "orb $0, %%al\n\t"
"stc\n\t" "stc\n\t"
"pushl %0\n\t" "pushl %0\n\t"
"pushw %%cs\n\t"
"call prot_call\n\t" "call prot_call\n\t"
/* Chain if OF not set */ /* Chain if OF not set */
"jo 1f\n\t" "jo 1f\n\t"

View File

@ -121,7 +121,6 @@ pxenv_null_entry:
.code16 .code16
pxenv_entry: pxenv_entry:
pushl $pxe_api_call pushl $pxe_api_call
pushw %cs
call prot_call call prot_call
lret lret
.size pxenv_entry, . - pxenv_entry .size pxenv_entry, . - pxenv_entry

View File

@ -371,7 +371,6 @@ start_runtime:
.section ".text16", "awx", @progbits .section ".text16", "awx", @progbits
1: 1:
pushl $main pushl $main
pushw %cs
call prot_call call prot_call
/* Uninstall iPXE */ /* Uninstall iPXE */

View File

@ -149,7 +149,6 @@ _exe_start:
/* Run iPXE */ /* Run iPXE */
pushl $main pushl $main
pushw %cs
call prot_call call prot_call
/* Uninstall iPXE */ /* Uninstall iPXE */

View File

@ -100,7 +100,6 @@ start_image:
.section ".text16", "awx", @progbits .section ".text16", "awx", @progbits
1: 1:
pushl $main pushl $main
pushw %cs
call prot_call call prot_call
/* Uninstall iPXE */ /* Uninstall iPXE */

View File

@ -888,7 +888,6 @@ payload_death_message:
*/ */
progress " relocate\n" progress " relocate\n"
pushl $relocate pushl $relocate
pushw %cs
call prot_call call prot_call
/* Jump back to .prefix segment */ /* Jump back to .prefix segment */

View File

@ -198,7 +198,6 @@ no_cmd_line:
/* Run iPXE */ /* Run iPXE */
pushl $main pushl $main
pushw %cs
call prot_call call prot_call
/* Uninstall iPXE */ /* Uninstall iPXE */

View File

@ -67,7 +67,6 @@ _nbi_start:
.section ".text16", "awx", @progbits .section ".text16", "awx", @progbits
1: 1:
pushl $main pushl $main
pushw %cs
call prot_call call prot_call
/* Uninstall iPXE */ /* Uninstall iPXE */

View File

@ -821,7 +821,6 @@ run_ipxe:
/* Run main program */ /* Run main program */
pushl $main pushl $main
pushw %cs
call prot_call call prot_call
/* Uninstall iPXE */ /* Uninstall iPXE */

View File

@ -808,7 +808,6 @@ exec: /* Set %ds = %cs */
/* Call main() */ /* Call main() */
pushl $main pushl $main
pushw %cs
call prot_call call prot_call
/* Set up flat real mode for return to BIOS */ /* Set up flat real mode for return to BIOS */

View File

@ -46,7 +46,6 @@ undiloader:
1: 1:
/* Call UNDI loader C code */ /* Call UNDI loader C code */
pushl $pxe_loader_call pushl $pxe_loader_call
pushw %cs
call prot_call call prot_call
1: /* Restore registers and return */ 1: /* Restore registers and return */

View File

@ -132,7 +132,6 @@ init_librm:
/* Initialise IDT */ /* Initialise IDT */
pushl $init_idt pushl $init_idt
pushw %cs
call prot_call call prot_call
/* Restore registers */ /* Restore registers */
@ -358,7 +357,7 @@ rm_gdtr:
.long 0 /* Base */ .long 0 /* Base */
/**************************************************************************** /****************************************************************************
* prot_call (real-mode far call, 16-bit real-mode far return address) * prot_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
@ -384,7 +383,6 @@ rm_gdtr:
* *
* Example usage: * Example usage:
* pushl $pxe_api_call * pushl $pxe_api_call
* pushw %cs
* call prot_call * call prot_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 );
@ -394,7 +392,8 @@ rm_gdtr:
PC_OFFSET_GDT: .space 6 PC_OFFSET_GDT: .space 6
PC_OFFSET_IDT: .space 6 PC_OFFSET_IDT: .space 6
PC_OFFSET_IX86: .space SIZEOF_I386_ALL_REGS PC_OFFSET_IX86: .space SIZEOF_I386_ALL_REGS
PC_OFFSET_RETADDR: .space 4 PC_OFFSET_PADDING: .space 2 /* for alignment */
PC_OFFSET_RETADDR: .space 2
PC_OFFSET_FUNCTION: .space 4 PC_OFFSET_FUNCTION: .space 4
PC_OFFSET_END: PC_OFFSET_END:
.previous .previous
@ -404,6 +403,7 @@ PC_OFFSET_END:
.globl prot_call .globl prot_call
prot_call: prot_call:
/* Preserve registers, flags and GDT on external RM stack */ /* Preserve registers, flags and GDT on external RM stack */
pushfw /* padding */
pushfl pushfl
pushal pushal
pushw %gs pushw %gs
@ -455,7 +455,8 @@ pc_rmode:
*/ */
addr32 movl -20(%esp), %esp addr32 movl -20(%esp), %esp
popfl popfl
lret $4 popfw /* padding */
ret $4
/**************************************************************************** /****************************************************************************
* real_call (protected-mode near call, 32-bit virtual return address) * real_call (protected-mode near call, 32-bit virtual return address)
@ -554,7 +555,6 @@ flatten_real_mode:
movb $0x8f, real_ds + 6 movb $0x8f, real_ds + 6
/* Call dummy protected-mode function */ /* Call dummy protected-mode function */
pushl $flatten_dummy pushl $flatten_dummy
pushw %cs
call prot_call call prot_call
/* Restore GDT */ /* Restore GDT */
movb $0x00, real_cs + 6 movb $0x00, real_cs + 6

View File

@ -106,7 +106,6 @@ static void librm_test_exec ( void ) {
__asm__ __volatile__ ( REAL_CODE ( "rdtsc\n\t" __asm__ __volatile__ ( REAL_CODE ( "rdtsc\n\t"
"movl %k0, %k2\n\t" "movl %k0, %k2\n\t"
"pushl %k3\n\t" "pushl %k3\n\t"
"pushw %%cs\n\t"
"call prot_call\n\t" "call prot_call\n\t"
"rdtsc\n\t" ) "rdtsc\n\t" )
: "=a" ( stopped ), "=d" ( discard_d ), : "=a" ( stopped ), "=d" ( discard_d ),