Subversion Repositories HelenOS

Rev

Rev 2726 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2726 Rev 2782
1
/* crt0-efi-ia64.S - IA-64 EFI startup code.
1
/* crt0-efi-ia64.S - IA-64 EFI startup code.
2
   Copyright (C) 1999 Hewlett-Packard Co.
2
   Copyright (C) 1999 Hewlett-Packard Co.
3
	Contributed by David Mosberger <davidm@hpl.hp.com>.
3
	Contributed by David Mosberger <davidm@hpl.hp.com>.
4
 
4
 
5
   This file is part of GNU-EFI, the GNU EFI development environment.
5
   This file is part of GNU-EFI, the GNU EFI development environment.
6
 
6
 
7
   GNU EFI is free software; you can redistribute it and/or modify
7
   GNU EFI is free software; you can redistribute it and/or modify
8
   it under the terms of the GNU General Public License as published by
8
   it under the terms of the GNU General Public License as published by
9
   the Free Software Foundation; either version 2, or (at your option)
9
   the Free Software Foundation; either version 2, or (at your option)
10
   any later version.
10
   any later version.
11
 
11
 
12
   GNU EFI is distributed in the hope that it will be useful,
12
   GNU EFI is distributed in the hope that it will be useful,
13
   but WITHOUT ANY WARRANTY; without even the implied warranty of
13
   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
   GNU General Public License for more details.
15
   GNU General Public License for more details.
16
 
16
 
17
   You should have received a copy of the GNU General Public License
17
   You should have received a copy of the GNU General Public License
18
   along with GNU EFI; see the file COPYING.  If not, write to the Free
18
   along with GNU EFI; see the file COPYING.  If not, write to the Free
19
   Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19
   Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20
   02111-1307, USA. */
20
   02111-1307, USA. */
21
 
21
 
22
	.text
22
	.text
23
	.psr abi64
23
	.psr abi64
24
	.psr lsb
24
	.psr lsb
25
	.lsb
25
	.lsb
26
 
26
 
27
	.proc _start
27
	.proc _start
28
_start:
28
_start:
29
	alloc loc0=ar.pfs,2,2,2,0
29
	alloc loc0=ar.pfs,2,2,2,0
30
	mov loc1=rp
30
	mov loc1=rp
31
	movl out0=@gprel(ImageBase)	// out0 <- ImageBase (ldbase)
31
	movl out0=@gprel(ImageBase)	// out0 <- ImageBase (ldbase)
32
	;;
32
	;;
33
	add out0=out0,gp
33
	add out0=out0,gp
34
	movl out1=@gprel(_DYNAMIC)	// out1 <- _DYNAMIC
34
	movl out1=@gprel(_DYNAMIC)	// out1 <- _DYNAMIC
35
	;;		// avoid WAW on CFM
35
	;;		// avoid WAW on CFM
36
	add out1=out1,gp
36
	add out1=out1,gp
37
	br.call.sptk.few rp=_relocate
37
	br.call.sptk.few rp=_relocate
38
.Lret0:	
38
.Lret0:	
39
	cmp.ne p6,p0=r0,r8		// r8 == EFI_SUCCESS?
39
	cmp.ne p6,p0=r0,r8		// r8 == EFI_SUCCESS?
40
(p6)	br.cond.sptk.few .exit		// no ->
40
(p6)	br.cond.sptk.few .exit		// no ->
41
 
41
 
42
.Lret1:
42
.Lret1:
43
 
43
 
44
	mov out0=in0			// image handle
44
	mov out0=in0			// image handle
45
	mov out1=in1			// systab
45
	mov out1=in1			// systab
46
	br.call.sptk.few rp=efi_main
46
	br.call.sptk.few rp=efi_main
47
.Lret2:
47
.Lret2:
48
.exit:
48
.exit:
49
	mov ar.pfs=loc0
49
	mov ar.pfs=loc0
50
	mov rp=loc1
50
	mov rp=loc1
51
	;;
51
	;;
52
	br.ret.sptk.few rp
52
	br.ret.sptk.few rp
53
 
53
 
54
	.endp _start
54
	.endp _start
55
 
55
 
56
 
56
 
57
	// PE32+ wants a PLABEL, not the code address of the entry point:
57
	// PE32+ wants a PLABEL, not the code address of the entry point:
58
 
58
 
59
	.align 16
59
	.align 16
60
	.global _start_plabel
60
	.global _start_plabel
61
	.section .plabel, "a"
61
	.section .plabel, "a"
62
_start_plabel:
62
_start_plabel:
63
	data8	_start
63
	data8	_start
64
	data8	__gp
64
	data8	__gp
65
 
65
 
66
	// hand-craft a .reloc section for the plabel:
66
	// hand-craft a .reloc section for the plabel:
67
 
67
 
68
#define IMAGE_REL_BASED_DIR64	10
68
#define IMAGE_REL_BASED_DIR64	10
69
 
69
 
70
	.section .reloc, "a"
70
	.section .reloc, "a"
71
	data4	_start_plabel				// Page RVA
71
	data4	_start_plabel				// Page RVA
72
	data4	12					// Block Size (2*4+2*2)
72
	data4	12					// Block Size (2*4+2*2)
73
	data2	(IMAGE_REL_BASED_DIR64<<12) +  0	// reloc for plabel's entry point
73
	data2	(IMAGE_REL_BASED_DIR64<<12) +  0	// reloc for plabel's entry point
74
	data2	(IMAGE_REL_BASED_DIR64<<12) +  8	// reloc for plabel's global pointer
74
	data2	(IMAGE_REL_BASED_DIR64<<12) +  8	// reloc for plabel's global pointer
75
 
75