summaryrefslogtreecommitdiffstats
path: root/src/arch/x86/prefix/undiloader.S
blob: 33573230bfca464d1e0ba37a39deecb555584960 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

#include <librm.h>

	.section ".note.GNU-stack", "", @progbits
	.code16
	.arch i386
	.section ".prefix", "ax", @progbits

/* UNDI loader
 *
 * Called by an external program to load our PXE stack.
 */
	.globl	undiloader
undiloader:
	/* Save registers */
	pushl	%esi
	pushl	%edi
	pushl	%ebp
	pushw	%ds
	pushw	%es
	pushw	%bx

	/* ROM segment address to %ds */
	pushw	%cs
	popw	%ds

	/* UNDI loader parameter structure address into %es:%di */
	movw	%sp, %bx
	movw	%ss:22(%bx), %di
	movw	%ss:24(%bx), %es

	/* Install to specified real-mode addresses */
	pushw	%di
	movw	%es:12(%di), %bx
	movw	%es:14(%di), %ax
	movl	image_source, %esi
	call	undiloader_source
	xorl	%edi, %edi
	orl	$0xffffffff, %ebp	/* Allow arbitrary relocation */
	call	install_prealloc
	popw	%di

	/* Jump to .text16 segment */
	pushw	%ax
	pushw	$1f
	lret
	.section ".text16", "ax", @progbits
1:
	/* Call UNDI loader C code */
	virtcall pxe_loader_call

1:	/* Restore registers and return */
	popw	%bx
	popw	%es
	popw	%ds
	popl	%ebp
	popl	%edi
	popl	%esi
	lret

/* Update image source address for UNDI loader
 *
 * Parameters:
 *   %esi : Image source address
 * Returns:
 *   %esi : Image source address
 */
	.section ".prefix", "ax", @progbits
	.globl	undiloader_source
	.weak	undiloader_source
undiloader_source:
	ret