xref: /freebsd/sys/i386/linux/linux_locore.asm (revision efe014e6b177ba1b0d70f7df751f5066d4eafe9b)
1/* $FreeBSD$ */
2
3#include "linux_assym.h"			/* system definitions */
4#include <machine/asmacros.h>			/* miscellaneous asm macros */
5
6#include <i386/linux/linux_syscall.h>		/* system call numbers */
7
8#include "assym.inc"
9
10	.data
11
12	.globl linux_platform
13linux_platform:
14	.asciz "i686"
15
16	.text
17
18/*
19 * To avoid excess stack frame the signal trampoline code emulates
20 * the 'call' instruction.
21 */
22ENTRY(__kernel_sigreturn)
23	movl	%esp, %ebx			/* preserve sigframe */
24	call .getip0
25.getip0:
26	popl	%eax
27	add	$.startsigcode-.getip0, %eax	/* ret address */
28	push	%eax
29	jmp	*LINUX_SIGF_HANDLER(%ebx)
30.startsigcode:
31	popl	%eax				/* gcc unwind code need this */
32	movl	$LINUX_SYS_linux_sigreturn,%eax	/* linux_sigreturn() */
33	int	$0x80				/* enter kernel with args */
34.endsigcode:
350:	jmp	0b
36
37ENTRY(__kernel_rt_sigreturn)
38	leal	LINUX_RT_SIGF_UC(%esp),%ebx	/* linux ucp */
39	leal	LINUX_RT_SIGF_SC(%ebx),%ecx	/* linux sigcontext */
40	movl	%esp, %edi
41	call	.getip1
42.getip1:
43	popl	%eax
44	add	$.startrtsigcode-.getip1, %eax	/* ret address */
45	push	%eax
46	jmp	*LINUX_RT_SIGF_HANDLER(%edi)
47.startrtsigcode:
48	movl	$LINUX_SYS_linux_rt_sigreturn,%eax   /* linux_rt_sigreturn() */
49	int	$0x80				/* enter kernel with args */
50.endrtsigcode:
510:	jmp	0b
52
53ENTRY(__kernel_vsyscall)
54.startvsyscall:
55	int $0x80
56	ret
57.endvsyscall:
58
59#if 0
60	.section .note.Linux, "a",@note
61	.long 2f - 1f		/* namesz */
62	.balign 4
63	.long 4f - 3f		/* descsz */
64	.long 0
651:
66	.asciz "Linux"
672:
68	.balign 4
693:
70	.long LINUX_VERSION_CODE
714:
72	.balign 4
73	.previous
74#endif
75
76#define do_cfa_expr(offset)						\
77	.byte 0x0f;			/* DW_CFA_def_cfa_expression */	\
78	.uleb128 11f-10f;		/*   length */			\
7910:	.byte 0x74;			/*     DW_OP_breg4 */		\
80	.sleb128 offset;		/*      offset */		\
81	.byte 0x06;			/*     DW_OP_deref */		\
8211:
83
84
85	/* CIE */
86	.section .eh_frame,"a",@progbits
87.LSTARTFRAMEDLSI1:
88	.long .LENDCIEDLSI1-.LSTARTCIEDLSI1
89.LSTARTCIEDLSI1:
90	.long 0					/* CIE ID */
91	.byte 1					/* Version number */
92	.string "zRS"				/* NULL-terminated
93						 * augmentation string
94						 */
95	.uleb128 1				/* Code alignment factor */
96	.sleb128 -4				/* Data alignment factor */
97	.byte 8					/* Return address
98						 * register column
99						 */
100	.uleb128 1				/* Augmentation value length */
101	.byte 0x1b				/* DW_EH_PE_pcrel|DW_EH_PE_sdata4. */
102	.byte 0					/* DW_CFA_nop */
103	.align 4
104.LENDCIEDLSI1:
105
106	/* FDE */
107	.long .LENDFDEDLSI1-.LSTARTFDEDLSI1	/* Length FDE */
108.LSTARTFDEDLSI1:
109	.long .LSTARTFDEDLSI1-.LSTARTFRAMEDLSI1 /* CIE pointer */
110	.long .startsigcode-.			/* PC-relative start address */
111	.long .endsigcode-.startsigcode
112	.uleb128 0				/* Augmentation */
113	do_cfa_expr(LINUX_SIGF_SC-8)
114	.align 4
115.LENDFDEDLSI1:
116
117	.long .LENDFDEDLSI2-.LSTARTFDEDLSI2	/* Length FDE */
118.LSTARTFDEDLSI2:
119	.long .LSTARTFDEDLSI2-.LSTARTFRAMEDLSI1	/* CIE pointer */
120	.long .startrtsigcode-.			/* PC-relative start address */
121	.long .endrtsigcode-.startrtsigcode
122	.uleb128 0				/* Augmentation */
123	do_cfa_expr(LINUX_RT_SIGF_SC-4+LINUX_SC_ESP)
124	.align 4
125.LENDFDEDLSI2:
126	.previous
127
128	.section .eh_frame,"a",@progbits
129.LSTARTFRAMEDLSI2:
130	.long .LENDCIEDLSI2-.LSTARTCIEDLSI2
131.LSTARTCIEDLSI2:
132	.long 0					/* CIE ID */
133	.byte 1					/* Version number */
134	.string "zR"				/* NULL-terminated
135						 * augmentation string
136						 */
137	.uleb128 1				/* Code alignment factor */
138	.sleb128 -4				/* Data alignment factor */
139	.byte 8					/* Return address register column */
140	.uleb128 1				/* Augmentation value length */
141	.byte 0x1b				/* DW_EH_PE_pcrel|DW_EH_PE_sdata4. */
142	.byte 0x0c				/* DW_CFA_def_cfa */
143	.uleb128 4
144	.uleb128 4
145	.byte 0x88				/* DW_CFA_offset, column 0x8 */
146	.uleb128 1
147	.align 4
148.LENDCIEDLSI2:
149	.long .LENDFDEDLSI3-.LSTARTFDEDLSI3 /* Length FDE */
150.LSTARTFDEDLSI3:
151	.long .LSTARTFDEDLSI3-.LSTARTFRAMEDLSI2 /* CIE pointer */
152	.long .startvsyscall-.			/* PC-relative start address */
153	.long .endvsyscall-.startvsyscall
154	.uleb128 0
155	.align 4
156.LENDFDEDLSI3:
157	.previous
158