aboutsummaryrefslogtreecommitdiffstats
path: root/gpxe/src/arch/i386/prefix/nbiprefix.S
blob: 4fb4acb13f8de0de91401f3dac798e273f6c61e6 (plain)
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
74
75
76
77
	.text
	.arch i386
	.code16
	.section ".prefix", "ax", @progbits
	.org 0

nbi_header:
	
/*****************************************************************************
 * NBI file header
 *****************************************************************************
 */
file_header:
	.long	0x1b031336	/* Signature */
	.byte	0x04		/* 16 bytes header, no vendor info */
	.byte	0
	.byte	0
	.byte	0		/* No flags */
	.word	0x0000, 0x07c0	/* Load header to 0x07c0:0x0000 */
	.word	entry, 0x07c0	/* Start execution at 0x07c0:entry */
	.size	file_header, . - file_header

/*****************************************************************************
 * NBI segment header
 *****************************************************************************
 */
segment_header:
	.byte	0x04		/* 16 bytes header, no vendor info */
	.byte	0
	.byte	0
	.byte	0x04		/* Last segment */
	.long	0x00007e00
imglen:	.long	_filesz - 512
memlen:	.long	_filesz - 512
	.size	segment_header, . - segment_header

	.section ".zinfo.fixup", "a", @progbits	/* Compressor fixups */
	.ascii	"SUBL"
	.long	imglen
	.long	1
	.long	0
	.ascii	"SUBL"
	.long	memlen
	.long	1
	.long	0
	.previous

/*****************************************************************************
 * NBI entry point
 *****************************************************************************
 */
entry:
	/* Install gPXE */
	call	install

	/* Jump to .text16 segment */
	pushw	%ax
	pushw	$1f
	lret
	.section ".text16", "awx", @progbits
1:
	pushl	$main
	pushw	%cs
	call	prot_call
	popl	%ecx /* discard */

	/* Uninstall gPXE */
	call	uninstall

	/* Reboot system */
	int $0x19

	.previous
	.size	entry, . - entry

nbi_header_end:
	.org 512