Subversion Repositories HelenOS

Rev

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

Rev 2726 Rev 3343
1
/* crt0-efi-ia32.S - x86 EFI startup code.
1
/* crt0-efi-ia32.S - x86 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
	.align 4
23
	.align 4
24
 
24
 
25
	.globl _start
25
	.globl _start
26
_start:
26
_start:
27
	pushl %ebp
27
	pushl %ebp
28
	movl %esp,%ebp
28
	movl %esp,%ebp
29
 
29
 
30
	pushl 12(%ebp)			# copy "image" argument
30
	pushl 12(%ebp)			# copy "image" argument
31
	pushl  8(%ebp)			# copy "systab" argument
31
	pushl  8(%ebp)			# copy "systab" argument
32
 
32
 
33
	call 0f
33
	call 0f
34
0:	popl %eax
34
0:	popl %eax
35
	movl %eax,%ebx
35
	movl %eax,%ebx
36
 
36
 
37
	addl $ImageBase-0b,%eax		# %eax = ldbase
37
	addl $ImageBase-0b,%eax		# %eax = ldbase
38
	addl $_DYNAMIC-0b,%ebx		# %ebx = _DYNAMIC
38
	addl $_DYNAMIC-0b,%ebx		# %ebx = _DYNAMIC
39
 
39
 
40
	pushl %ebx			# pass _DYNAMIC as second argument
40
	pushl %ebx			# pass _DYNAMIC as second argument
41
	pushl %eax			# pass ldbase as first argument
41
	pushl %eax			# pass ldbase as first argument
42
	call _relocate
42
	call _relocate
43
	popl %ebx
43
	popl %ebx
44
	popl %ebx
44
	popl %ebx
45
 	testl %eax,%eax
45
 	testl %eax,%eax
46
 	jne .exit
46
 	jne .exit
47
  
47
  
48
  	call efi_main			# call app with "image" and "systab" argument
48
  	call efi_main			# call app with "image" and "systab" argument
49
 
49
 
50
.exit:	leave
50
.exit:	leave
51
  	ret
51
  	ret
52
 
52
 
53
 	// hand-craft a dummy .reloc section so EFI knows it's a relocatable executable:
53
 	// hand-craft a dummy .reloc section so EFI knows it's a relocatable executable:
54
 
54
 
55
 	.data
55
 	.data
56
dummy:	.long	0
56
dummy:	.long	0
57
 
57
 
58
#define IMAGE_REL_ABSOLUTE	0
58
#define IMAGE_REL_ABSOLUTE	0
59
 	.section .reloc, "a"
59
 	.section .reloc, "a"
60
 	.long	dummy					// Page RVA
60
 	.long	dummy					// Page RVA
61
 	.long	10					// Block Size (2*4+2)
61
 	.long	10					// Block Size (2*4+2)
62
 	.word	(IMAGE_REL_ABSOLUTE<<12) +  0		// reloc for dummy
62
 	.word	(IMAGE_REL_ABSOLUTE<<12) +  0		// reloc for dummy
63
 
63