xref: /freebsd/sys/i386/linux/linux_locore.asm (revision 7029da5c36f2d3cf6bb6c81bf551229f416399e8)
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/*
11 * To avoid excess stack frame the signal trampoline code emulates
12 * the 'call' instruction.
13 */
14NON_GPROF_ENTRY(linux_sigcode)
15	movl	%esp, %ebx			/* preserve sigframe */
16	call .getip0
17.getip0:
18	popl	%eax
19	add	$.startsigcode-.getip0, %eax	/* ret address */
20	push	%eax
21	jmp	*LINUX_SIGF_HANDLER(%ebx)
22.startsigcode:
23	popl	%eax				/* gcc unwind code need this */
24	movl	$LINUX_SYS_linux_sigreturn,%eax	/* linux_sigreturn() */
25	int	$0x80				/* enter kernel with args */
26.endsigcode:
270:	jmp	0b
28
29NON_GPROF_ENTRY(linux_rt_sigcode)
30	leal	LINUX_RT_SIGF_UC(%esp),%ebx	/* linux ucp */
31	leal	LINUX_RT_SIGF_SC(%ebx),%ecx	/* linux sigcontext */
32	movl	%esp, %edi
33	call	.getip1
34.getip1:
35	popl	%eax
36	add	$.startrtsigcode-.getip1, %eax	/* ret address */
37	push	%eax
38	jmp	*LINUX_RT_SIGF_HANDLER(%edi)
39.startrtsigcode:
40	movl	$LINUX_SYS_linux_rt_sigreturn,%eax   /* linux_rt_sigreturn() */
41	int	$0x80				/* enter kernel with args */
42.endrtsigcode:
430:	jmp	0b
44
45NON_GPROF_ENTRY(linux_vsyscall)
46.startvsyscall:
47	int $0x80
48	ret
49.endvsyscall:
50
51#if 0
52	.section .note.Linux, "a",@note
53	.long 2f - 1f		/* namesz */
54	.balign 4
55	.long 4f - 3f		/* descsz */
56	.long 0
571:
58	.asciz "Linux"
592:
60	.balign 4
613:
62	.long LINUX_VERSION_CODE
634:
64	.balign 4
65	.previous
66#endif
67
68#define do_cfa_expr(offset)						\
69	.byte 0x0f;			/* DW_CFA_def_cfa_expression */	\
70	.uleb128 11f-10f;		/*   length */			\
7110:	.byte 0x74;			/*     DW_OP_breg4 */		\
72	.sleb128 offset;		/*      offset */		\
73	.byte 0x06;			/*     DW_OP_deref */		\
7411:
75
76
77	/* CIE */
78	.section .eh_frame,"a",@progbits
79.LSTARTFRAMEDLSI1:
80	.long .LENDCIEDLSI1-.LSTARTCIEDLSI1
81.LSTARTCIEDLSI1:
82	.long 0					/* CIE ID */
83	.byte 1					/* Version number */
84	.string "zRS"				/* NULL-terminated
85						 * augmentation string
86						 */
87	.uleb128 1				/* Code alignment factor */
88	.sleb128 -4				/* Data alignment factor */
89	.byte 8					/* Return address
90						 * register column
91						 */
92	.uleb128 1				/* Augmentation value length */
93	.byte 0x1b				/* DW_EH_PE_pcrel|DW_EH_PE_sdata4. */
94	.byte 0					/* DW_CFA_nop */
95	.align 4
96.LENDCIEDLSI1:
97
98	/* FDE */
99	.long .LENDFDEDLSI1-.LSTARTFDEDLSI1	/* Length FDE */
100.LSTARTFDEDLSI1:
101	.long .LSTARTFDEDLSI1-.LSTARTFRAMEDLSI1 /* CIE pointer */
102	.long .startsigcode-.			/* PC-relative start address */
103	.long .endsigcode-.startsigcode
104	.uleb128 0				/* Augmentation */
105	do_cfa_expr(LINUX_SIGF_SC-8)
106	.align 4
107.LENDFDEDLSI1:
108
109	.long .LENDFDEDLSI2-.LSTARTFDEDLSI2	/* Length FDE */
110.LSTARTFDEDLSI2:
111	.long .LSTARTFDEDLSI2-.LSTARTFRAMEDLSI1	/* CIE pointer */
112	.long .startrtsigcode-.			/* PC-relative start address */
113	.long .endrtsigcode-.startrtsigcode
114	.uleb128 0				/* Augmentation */
115	do_cfa_expr(LINUX_RT_SIGF_SC-4+LINUX_SC_ESP)
116	.align 4
117.LENDFDEDLSI2:
118	.previous
119
120	.section .eh_frame,"a",@progbits
121.LSTARTFRAMEDLSI2:
122	.long .LENDCIEDLSI2-.LSTARTCIEDLSI2
123.LSTARTCIEDLSI2:
124	.long 0					/* CIE ID */
125	.byte 1					/* Version number */
126	.string "zR"				/* NULL-terminated
127						 * augmentation string
128						 */
129	.uleb128 1				/* Code alignment factor */
130	.sleb128 -4				/* Data alignment factor */
131	.byte 8					/* Return address register column */
132	.uleb128 1				/* Augmentation value length */
133	.byte 0x1b				/* DW_EH_PE_pcrel|DW_EH_PE_sdata4. */
134	.byte 0x0c				/* DW_CFA_def_cfa */
135	.uleb128 4
136	.uleb128 4
137	.byte 0x88				/* DW_CFA_offset, column 0x8 */
138	.uleb128 1
139	.align 4
140.LENDCIEDLSI2:
141	.long .LENDFDEDLSI3-.LSTARTFDEDLSI3 /* Length FDE */
142.LSTARTFDEDLSI3:
143	.long .LSTARTFDEDLSI3-.LSTARTFRAMEDLSI2 /* CIE pointer */
144	.long .startvsyscall-.			/* PC-relative start address */
145	.long .endvsyscall-.startvsyscall
146	.uleb128 0
147	.align 4
148.LENDFDEDLSI3:
149	.previous
150