Browse Source

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

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 8 years ago
parent
commit
196f0f2551

+ 0
- 3
src/arch/i386/interface/syslinux/comboot_call.c View File

661
 	__asm__ __volatile__ (
661
 	__asm__ __volatile__ (
662
 		TEXT16_CODE ( "\nint20_wrapper:\n\t"
662
 		TEXT16_CODE ( "\nint20_wrapper:\n\t"
663
 		              "pushl %0\n\t"
663
 		              "pushl %0\n\t"
664
-		              "pushw %%cs\n\t"
665
 		              "call prot_call\n\t"
664
 		              "call prot_call\n\t"
666
 			      "clc\n\t"
665
 			      "clc\n\t"
667
 			      "call patch_cf\n\t"
666
 			      "call patch_cf\n\t"
673
 	__asm__ __volatile__ (
672
 	__asm__ __volatile__ (
674
 		TEXT16_CODE ( "\nint21_wrapper:\n\t"
673
 		TEXT16_CODE ( "\nint21_wrapper:\n\t"
675
 		              "pushl %0\n\t"
674
 		              "pushl %0\n\t"
676
-		              "pushw %%cs\n\t"
677
 		              "call prot_call\n\t"
675
 		              "call prot_call\n\t"
678
 			      "clc\n\t"
676
 			      "clc\n\t"
679
 			      "call patch_cf\n\t"
677
 			      "call patch_cf\n\t"
685
 	__asm__  __volatile__ (
683
 	__asm__  __volatile__ (
686
 		TEXT16_CODE ( "\nint22_wrapper:\n\t"
684
 		TEXT16_CODE ( "\nint22_wrapper:\n\t"
687
 		              "pushl %0\n\t"
685
 		              "pushl %0\n\t"
688
-		              "pushw %%cs\n\t"
689
 		              "call prot_call\n\t"
686
 		              "call prot_call\n\t"
690
 			      "clc\n\t"
687
 			      "clc\n\t"
691
 			      "call patch_cf\n\t"
688
 			      "call patch_cf\n\t"

+ 0
- 1
src/arch/x86/core/dumpregs.c View File

7
 		TEXT16_CODE ( ".globl dump_regs\n\t"
7
 		TEXT16_CODE ( ".globl dump_regs\n\t"
8
 			      "\ndump_regs:\n\t"
8
 			      "\ndump_regs:\n\t"
9
 			      "pushl $_dump_regs\n\t"
9
 			      "pushl $_dump_regs\n\t"
10
-			      "pushw %%cs\n\t"
11
 			      "call prot_call\n\t"
10
 			      "call prot_call\n\t"
12
 			      "ret\n\t" ) : : );
11
 			      "ret\n\t" ) : : );
13
 
12
 

+ 0
- 1
src/arch/x86/interface/pcbios/bios_console.c View File

534
 			      "cmpb $0, %%cs:bios_inject_lock\n\t"
534
 			      "cmpb $0, %%cs:bios_inject_lock\n\t"
535
 			      "jnz 1f\n\t"
535
 			      "jnz 1f\n\t"
536
 			      "pushl %0\n\t"
536
 			      "pushl %0\n\t"
537
-			      "pushw %%cs\n\t"
538
 			      "call prot_call\n\t"
537
 			      "call prot_call\n\t"
539
 			      "\n1:\n\t"
538
 			      "\n1:\n\t"
540
 			      "popfw\n\t"
539
 			      "popfw\n\t"

+ 0
- 1
src/arch/x86/interface/pcbios/int13.c View File

1481
 			     "orb $0, %%al\n\t" 
1481
 			     "orb $0, %%al\n\t" 
1482
 			     "stc\n\t"
1482
 			     "stc\n\t"
1483
 			     "pushl %0\n\t"
1483
 			     "pushl %0\n\t"
1484
-			     "pushw %%cs\n\t"
1485
 			     "call prot_call\n\t"
1484
 			     "call prot_call\n\t"
1486
 			     /* Chain if OF not set */
1485
 			     /* Chain if OF not set */
1487
 			     "jo 1f\n\t"
1486
 			     "jo 1f\n\t"

+ 0
- 1
src/arch/x86/interface/pxe/pxe_entry.S View File

121
 	.code16
121
 	.code16
122
 pxenv_entry:
122
 pxenv_entry:
123
 	pushl	$pxe_api_call
123
 	pushl	$pxe_api_call
124
-	pushw	%cs
125
 	call	prot_call
124
 	call	prot_call
126
 	lret
125
 	lret
127
 	.size	pxenv_entry, . - pxenv_entry
126
 	.size	pxenv_entry, . - pxenv_entry

+ 0
- 1
src/arch/x86/prefix/dskprefix.S View File

371
 	.section ".text16", "awx", @progbits
371
 	.section ".text16", "awx", @progbits
372
 1:
372
 1:
373
 	pushl	$main
373
 	pushl	$main
374
-	pushw	%cs
375
 	call	prot_call
374
 	call	prot_call
376
 
375
 
377
 	/* Uninstall iPXE */
376
 	/* Uninstall iPXE */

+ 0
- 1
src/arch/x86/prefix/exeprefix.S View File

149
 
149
 
150
 	/* Run iPXE */
150
 	/* Run iPXE */
151
 	pushl	$main
151
 	pushl	$main
152
-	pushw	%cs
153
 	call	prot_call
152
 	call	prot_call
154
 
153
 
155
 	/* Uninstall iPXE */
154
 	/* Uninstall iPXE */

+ 0
- 1
src/arch/x86/prefix/hdprefix.S View File

100
 	.section ".text16", "awx", @progbits
100
 	.section ".text16", "awx", @progbits
101
 1:
101
 1:
102
 	pushl	$main
102
 	pushl	$main
103
-	pushw	%cs
104
 	call	prot_call
103
 	call	prot_call
105
 
104
 
106
 	/* Uninstall iPXE */
105
 	/* Uninstall iPXE */

+ 0
- 1
src/arch/x86/prefix/libprefix.S View File

888
 	 */
888
 	 */
889
 	progress "  relocate\n"
889
 	progress "  relocate\n"
890
 	pushl	$relocate
890
 	pushl	$relocate
891
-	pushw	%cs
892
 	call	prot_call
891
 	call	prot_call
893
 
892
 
894
 	/* Jump back to .prefix segment */
893
 	/* Jump back to .prefix segment */

+ 0
- 1
src/arch/x86/prefix/lkrnprefix.S View File

198
 
198
 
199
 	/* Run iPXE */
199
 	/* Run iPXE */
200
 	pushl	$main
200
 	pushl	$main
201
-	pushw	%cs
202
 	call	prot_call
201
 	call	prot_call
203
 
202
 
204
 	/* Uninstall iPXE */
203
 	/* Uninstall iPXE */

+ 0
- 1
src/arch/x86/prefix/nbiprefix.S View File

67
 	.section ".text16", "awx", @progbits
67
 	.section ".text16", "awx", @progbits
68
 1:
68
 1:
69
 	pushl	$main
69
 	pushl	$main
70
-	pushw	%cs
71
 	call	prot_call
70
 	call	prot_call
72
 
71
 
73
 	/* Uninstall iPXE */
72
 	/* Uninstall iPXE */

+ 0
- 1
src/arch/x86/prefix/pxeprefix.S View File

821
 
821
 
822
 	/* Run main program */
822
 	/* Run main program */
823
 	pushl	$main
823
 	pushl	$main
824
-	pushw	%cs
825
 	call	prot_call
824
 	call	prot_call
826
 
825
 
827
 	/* Uninstall iPXE */
826
 	/* Uninstall iPXE */

+ 0
- 1
src/arch/x86/prefix/romprefix.S View File

808
 
808
 
809
 	/* Call main() */
809
 	/* Call main() */
810
 	pushl	$main
810
 	pushl	$main
811
-	pushw	%cs
812
 	call	prot_call
811
 	call	prot_call
813
 
812
 
814
 	/* Set up flat real mode for return to BIOS */
813
 	/* Set up flat real mode for return to BIOS */

+ 0
- 1
src/arch/x86/prefix/undiloader.S View File

46
 1:
46
 1:
47
 	/* Call UNDI loader C code */
47
 	/* Call UNDI loader C code */
48
 	pushl	$pxe_loader_call
48
 	pushl	$pxe_loader_call
49
-	pushw	%cs
50
 	call	prot_call
49
 	call	prot_call
51
 
50
 
52
 1:	/* Restore registers and return */
51
 1:	/* Restore registers and return */

+ 6
- 6
src/arch/x86/transitions/librm.S View File

132
 
132
 
133
 	/* Initialise IDT */
133
 	/* Initialise IDT */
134
 	pushl	$init_idt
134
 	pushl	$init_idt
135
-	pushw	%cs
136
 	call	prot_call
135
 	call	prot_call
137
 
136
 
138
 	/* Restore registers */
137
 	/* Restore registers */
358
 	.long 0 /* Base */
357
 	.long 0 /* Base */
359
 
358
 
360
 /****************************************************************************
359
 /****************************************************************************
361
- * prot_call (real-mode far call, 16-bit real-mode far return address)
360
+ * prot_call (real-mode near call, 16-bit real-mode near return address)
362
  *
361
  *
363
  * Call a specific C function in the protected-mode code.  The
362
  * Call a specific C function in the protected-mode code.  The
364
  * prototype of the C function must be
363
  * prototype of the C function must be
384
  *
383
  *
385
  * Example usage:
384
  * Example usage:
386
  *	pushl	$pxe_api_call
385
  *	pushl	$pxe_api_call
387
- *	pushw	%cs
388
  *	call	prot_call
386
  *	call	prot_call
389
  * to call in to the C function
387
  * to call in to the C function
390
  *      void pxe_api_call ( struct i386_all_regs *ix86 );
388
  *      void pxe_api_call ( struct i386_all_regs *ix86 );
394
 PC_OFFSET_GDT:		.space	6
392
 PC_OFFSET_GDT:		.space	6
395
 PC_OFFSET_IDT:		.space	6
393
 PC_OFFSET_IDT:		.space	6
396
 PC_OFFSET_IX86:		.space	SIZEOF_I386_ALL_REGS
394
 PC_OFFSET_IX86:		.space	SIZEOF_I386_ALL_REGS
397
-PC_OFFSET_RETADDR:	.space	4
395
+PC_OFFSET_PADDING:	.space	2 /* for alignment */
396
+PC_OFFSET_RETADDR:	.space	2
398
 PC_OFFSET_FUNCTION:	.space	4
397
 PC_OFFSET_FUNCTION:	.space	4
399
 PC_OFFSET_END:
398
 PC_OFFSET_END:
400
 	.previous
399
 	.previous
404
 	.globl prot_call
403
 	.globl prot_call
405
 prot_call:
404
 prot_call:
406
 	/* Preserve registers, flags and GDT on external RM stack */
405
 	/* Preserve registers, flags and GDT on external RM stack */
406
+	pushfw	/* padding */
407
 	pushfl
407
 	pushfl
408
 	pushal
408
 	pushal
409
 	pushw	%gs
409
 	pushw	%gs
455
 	 */
455
 	 */
456
 	addr32 movl -20(%esp), %esp
456
 	addr32 movl -20(%esp), %esp
457
 	popfl
457
 	popfl
458
-	lret	$4
458
+	popfw	/* padding */
459
+	ret	$4
459
 
460
 
460
 /****************************************************************************
461
 /****************************************************************************
461
  * real_call (protected-mode near call, 32-bit virtual return address)
462
  * real_call (protected-mode near call, 32-bit virtual return address)
554
 	movb	$0x8f, real_ds + 6
555
 	movb	$0x8f, real_ds + 6
555
 	/* Call dummy protected-mode function */
556
 	/* Call dummy protected-mode function */
556
 	pushl	$flatten_dummy
557
 	pushl	$flatten_dummy
557
-	pushw	%cs
558
 	call	prot_call
558
 	call	prot_call
559
 	/* Restore GDT */
559
 	/* Restore GDT */
560
 	movb	$0x00, real_cs + 6
560
 	movb	$0x00, real_cs + 6

+ 0
- 1
src/arch/x86/transitions/librm_test.c View File

106
 		__asm__ __volatile__ ( REAL_CODE ( "rdtsc\n\t"
106
 		__asm__ __volatile__ ( REAL_CODE ( "rdtsc\n\t"
107
 						   "movl %k0, %k2\n\t"
107
 						   "movl %k0, %k2\n\t"
108
 						   "pushl %k3\n\t"
108
 						   "pushl %k3\n\t"
109
-						   "pushw %%cs\n\t"
110
 						   "call prot_call\n\t"
109
 						   "call prot_call\n\t"
111
 						   "rdtsc\n\t" )
110
 						   "rdtsc\n\t" )
112
 				       : "=a" ( stopped ), "=d" ( discard_d ),
111
 				       : "=a" ( stopped ), "=d" ( discard_d ),

Loading…
Cancel
Save