locore.s revision 2783
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * William Jolitz.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 *    notice, this list of conditions and the following disclaimer in the
15 *    documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 *    must display the following acknowledgement:
18 *	This product includes software developed by the University of
19 *	California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 *    may be used to endorse or promote products derived from this software
22 *    without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 *	from: @(#)locore.s	7.3 (Berkeley) 5/13/91
37 *	$Id: locore.s,v 1.27 1994/09/12 11:38:06 davidg Exp $
38 */
39
40/*
41 * locore.s:	FreeBSD machine support for the Intel 386
42 *		originally from: locore.s, by William F. Jolitz
43 *
44 *		Substantially rewritten by David Greenman, Rod Grimes,
45 *			Bruce Evans, Wolfgang Solfrank, and many others.
46 */
47
48#include "npx.h"			/* for NNPX */
49#include "assym.s"			/* system definitions */
50#include <machine/psl.h>		/* processor status longword defs */
51#include <machine/pte.h>		/* page table entry definitions */
52#include <sys/errno.h>			/* error return codes */
53#include <machine/specialreg.h>		/* x86 special registers */
54#include <machine/cputypes.h>		/* x86 cpu type definitions */
55#include <sys/syscall.h>		/* system call numbers */
56#include <machine/asmacros.h>		/* miscellaneous asm macros */
57
58/*
59 *	XXX
60 *
61 * Note: This version greatly munged to avoid various assembler errors
62 * that may be fixed in newer versions of gas. Perhaps newer versions
63 * will have more pleasant appearance.
64 */
65
66/*
67 * PTmap is recursive pagemap at top of virtual address space.
68 * Within PTmap, the page directory can be found (third indirection).
69 */
70	.globl	_PTmap,_PTD,_PTDpde,_Sysmap
71	.set	_PTmap,PTDPTDI << PDRSHIFT
72	.set	_PTD,_PTmap + (PTDPTDI * NBPG)
73	.set	_PTDpde,_PTD + (PTDPTDI * PDESIZE)
74
75/* Sysmap is the base address of the kernel page tables */
76	.set	_Sysmap,_PTmap + (KPTDI * NBPG)
77
78/*
79 * APTmap, APTD is the alternate recursive pagemap.
80 * It's used when modifying another process's page tables.
81 */
82	.globl	_APTmap,_APTD,_APTDpde
83	.set	_APTmap,APTDPTDI << PDRSHIFT
84	.set	_APTD,_APTmap + (APTDPTDI * NBPG)
85	.set	_APTDpde,_PTD + (APTDPTDI * PDESIZE)
86
87/*
88 * Access to each processes kernel stack is via a region of
89 * per-process address space (at the beginning), immediatly above
90 * the user process stack.
91 */
92	.set	_kstack,USRSTACK
93	.globl	_kstack
94
95/*
96 * Globals
97 */
98	.data
99	.globl	_esym
100_esym:	.long	0				/* ptr to end of syms */
101
102	.globl	_boothowto,_bootdev,_curpcb
103
104	.globl	_cpu,_cold,_atdevbase,_cpu_vendor,_cpu_id
105
106 	.globl	_video_mode_ptr
107
108_cpu:	.long	0				/* are we 386, 386sx, or 486 */
109_cpu_id:	.long	0			/* stepping ID */
110_cpu_vendor:	.space	20			/* CPU origin code */
111_video_mode_ptr:	.long 0
112_cold:	.long	1				/* cold till we are not */
113_atdevbase:	.long	0			/* location of start of iomem in virtual */
114_atdevphys:	.long	0			/* location of device mapping ptes (phys) */
115
116	.globl	_KERNend
117_KERNend:	.long	0			/* phys addr end of kernel (just after bss) */
118
119	.globl	_IdlePTD,_KPTphys
120_IdlePTD:	.long	0			/* phys addr of kernel PTD */
121_KPTphys:	.long	0			/* phys addr of kernel page tables */
122
123	.globl	_cyloffset
124_cyloffset:	.long	0			/* cylinder offset from boot blocks */
125
126	.globl	_proc0paddr
127_proc0paddr:	.long	0			/* address of proc 0 address space */
128
129#ifdef BDE_DEBUGGER
130	.globl	_bdb_exists			/* flag to indicate BDE debugger is available */
131_bdb_exists:	.long	0
132#endif
133
134	.globl	tmpstk
135	.space	0x1000
136tmpstk:
137
138
139/*
140 * System Initialization
141 */
142	.text
143
144/*
145 * btext: beginning of text section.
146 * Also the entry point (jumped to directly from the boot blocks).
147 */
148NON_GPROF_ENTRY(btext)
149	movw	$0x1234,0x472			/* warm boot */
150	jmp	1f
151	.org	0x500				/* space for BIOS variables */
152
153 1:
154	/* Don't trust what the BIOS gives for eflags. */
155	pushl	$PSL_MBO
156	popfl
157
158	/*
159	 * pass parameters on stack (howto, bootdev, unit, cyloffset, esym)
160	 * note: (%esp) is return address of boot
161	 * ( if we want to hold onto /boot, it's physical %esp up to _end)
162	 */
163	movl	4(%esp),%eax
164	movl	%eax,_boothowto-KERNBASE
165	movl	8(%esp),%eax
166	movl	%eax,_bootdev-KERNBASE
167	movl	12(%esp),%eax
168	movl	%eax,_cyloffset-KERNBASE
169	movl	16(%esp),%eax
170	addl	$KERNBASE,%eax
171	movl	%eax,_esym-KERNBASE
172
173	/* get the BIOS video mode pointer */
174 	movl	$0x4a8, %ecx
175 	movl	(%ecx), %eax
176 	movl	%eax, %ecx
177 	shrl	$12, %ecx
178 	andl	$0xffff0000, %ecx
179 	andl	$0x0000ffff, %eax
180 	orl	%ecx, %eax
181 	movl	(%eax), %eax
182 	movl	%eax, %ecx
183 	shrl	$12, %ecx
184 	andl	$0xffff0000, %ecx
185 	andl	$0x0000ffff, %eax
186 	orl	%ecx, %eax
187 	addl	$KERNBASE, %eax
188 	movl	%eax, _video_mode_ptr-KERNBASE
189
190#ifdef DISKLESS					/* Copy diskless structure */
191	movl	_nfs_diskless_size-KERNBASE,%ecx
192	movl	20(%esp),%esi
193	movl	$(_nfs_diskless-KERNBASE),%edi
194	cld
195	rep
196	movsb
197#endif
198
199	/* Find out our CPU type. */
200
201	/* Try to toggle alignment check flag; does not exist on 386. */
202	pushfl
203	popl	%eax
204	movl	%eax,%ecx
205	orl	$PSL_AC,%eax
206	pushl	%eax
207	popfl
208	pushfl
209	popl	%eax
210	xorl	%ecx,%eax
211	andl	$PSL_AC,%eax
212	pushl	%ecx
213	popfl
214
215	testl	%eax,%eax
216	jnz	1f
217	movl	$CPU_386,_cpu-KERNBASE
218	jmp	2f
219
2201:	/* Try to toggle identification flag; does not exist on early 486s. */
221	pushfl
222	popl	%eax
223	movl	%eax,%ecx
224	xorl	$PSL_ID,%eax
225	pushl	%eax
226	popfl
227	pushfl
228	popl	%eax
229	xorl	%ecx,%eax
230	andl	$PSL_ID,%eax
231	pushl	%ecx
232	popfl
233
234	testl	%eax,%eax
235	jnz	1f
236	movl	$CPU_486,_cpu-KERNBASE
237
238	/* check for Cyrix 486DLC -- based on check routine  */
239	/* documented in "Cx486SLC/e SMM Programmer's Guide" */
240	xorw	%dx,%dx
241	cmpw	%dx,%dx			# set flags to known state
242	pushfw
243	popw	%cx			# store flags in ecx
244	movw	$0xffff,%ax
245	movw	$0x0004,%bx
246	divw	%bx
247	pushfw
248	popw	%ax
249	andw	$0x08d5,%ax		# mask off important bits
250	andw	$0x08d5,%cx
251	cmpw	%ax,%cx
252
253	jnz	2f			# if flags changed, Intel chip
254
255	movl	$CPU_486DLC,_cpu-KERNBASE # set CPU value for Cyrix
256	movl	$0x69727943,_cpu_vendor-KERNBASE	# store vendor string
257	movw	$0x0078,_cpu_vendor-KERNBASE+4
258
259	invd				# Start with guaranteed clean cache
260	/* Disable caching of the ISA hole only. */
261	movb	$CCR0,%al		# Configuration Register index (CCR0)
262	outb	%al,$0x22
263	inb	$0x23,%al
264	orb	$CCR0_NC1,%al
265	outb	%al,$0x23
266	invd
267	jmp	2f
268
2691:	/* Use the `cpuid' instruction. */
270	xorl	%eax,%eax
271	.byte	0x0f,0xa2		# cpuid 0
272	movl	%ebx,_cpu_vendor-KERNBASE	# store vendor string
273	movl	%edx,_cpu_vendor+4-KERNBASE
274	movl	%ecx,_cpu_vendor+8-KERNBASE
275	movb	$0,_cpu_vendor+12-KERNBASE
276
277	movl	$1,%eax
278	.byte	0x0f,0xa2		# cpuid 1
279	movl	%eax,_cpu_id-KERNBASE		# store cpu_id
280	rorl	$8,%eax			# extract family type
281	andl	$15,%eax
282	cmpl	$5,%eax
283	jae	1f
284
285	/* less than Pentium; must be 486 */
286	movl	$CPU_486,_cpu-KERNBASE
287	jmp	2f
288
2891:	movl	$CPU_586,_cpu-KERNBASE
2902:
291
292	/*
293	 * Finished with old stack; load new %esp now instead of later so
294	 * we can trace this code without having to worry about the trace
295	 * trap clobbering the memory test or the zeroing of the bss+bootstrap
296	 * page tables.
297	 *
298	 * XXX - wdboot clears the bss after testing that this is safe.
299	 * This is too wasteful - memory below 640K is scarce.  The boot
300	 * program should check:
301	 *	text+data <= &stack_variable - more_space_for_stack
302	 *	text+data+bss+pad+space_for_page_tables <= end_of_memory
303	 * Oops, the gdt is in the carcass of the boot program so clearing
304	 * the rest of memory is still not possible.
305	 */
306	movl	$tmpstk-KERNBASE,%esp		/* bootstrap stack end location */
307
308/*
309 * Virtual address space of kernel:
310 *
311 *	text | data | bss | [syms] | page dir | proc0 kernel stack | usr stk map | Sysmap
312 *      pages:                          1         UPAGES (2)             1         NKPT (7)
313 */
314
315/* find end of kernel image */
316	movl	$_end-KERNBASE,%ecx
317	addl	$NBPG-1,%ecx			/* page align up */
318	andl	$~(NBPG-1),%ecx
319	movl	%ecx,%esi			/* esi = start of free memory */
320	movl	%ecx,_KERNend-KERNBASE		/* save end of kernel */
321
322/* clear bss */
323	movl	$_edata-KERNBASE,%edi
324	subl	%edi,%ecx			/* get amount to clear */
325	xorl	%eax,%eax			/* specify zero fill */
326	cld
327	rep
328	stosb
329
330/*
331 * The value in esi is both the end of the kernel bss and a pointer to
332 * the kernel page directory, and is used by the rest of locore to build
333 * the tables.
334 * esi + 1(page dir) + 2(UPAGES) + 1(p0stack) + NKPT(number of kernel
335 * page table pages) is then passed on the stack to init386(first) as
336 * the value first. esi should ALWAYS be page aligned!!
337 */
338	movl	%esi,%ecx			/* Get current first availiable address */
339
340/* clear pagetables, page directory, stack, etc... */
341	movl	%esi,%edi			/* base (page directory) */
342	movl	$((1+UPAGES+1+NKPT)*NBPG),%ecx	/* amount to clear */
343	xorl	%eax,%eax			/* specify zero fill */
344	cld
345	rep
346	stosb
347
348/* physical address of Idle proc/kernel page directory */
349	movl	%esi,_IdlePTD-KERNBASE
350
351/*
352 * fillkpt
353 *	eax = (page frame address | control | status) == pte
354 *	ebx = address of page table
355 *	ecx = how many pages to map
356 */
357#define	fillkpt		\
3581:	movl	%eax,(%ebx)	; \
359	addl	$NBPG,%eax	; /* increment physical address */ \
360	addl	$4,%ebx		; /* next pte */ \
361	loop	1b		;
362
363/*
364 * Map Kernel
365 *
366 * First step - build page tables
367 */
368#if defined (KGDB) || defined (BDE_DEBUGGER)
369	movl	_KERNend-KERNBASE,%ecx		/* this much memory, */
370	shrl	$PGSHIFT,%ecx			/* for this many PTEs */
371#ifdef BDE_DEBUGGER
372	cmpl	$0xa0,%ecx			/* XXX - cover debugger pages */
373	jae	1f
374	movl	$0xa0,%ecx
3751:
376#endif /* BDE_DEBUGGER */
377	movl	$PG_V|PG_KW,%eax		/* kernel R/W, valid */
378	lea	((1+UPAGES+1)*NBPG)(%esi),%ebx	/* phys addr of kernel PT base */
379	movl	%ebx,_KPTphys-KERNBASE		/* save in global */
380	fillkpt
381
382#else /* !KGDB && !BDE_DEBUGGER */
383	/* write protect kernel text (doesn't do a thing for 386's - only 486's) */
384	movl	$_etext-KERNBASE,%ecx		/* get size of text */
385	shrl	$PGSHIFT,%ecx			/* for this many PTEs */
386	movl	$PG_V|PG_KR,%eax		/* specify read only */
387	lea	((1+UPAGES+1)*NBPG)(%esi),%ebx	/* phys addr of kernel PT base */
388	movl	%ebx,_KPTphys-KERNBASE		/* save in global */
389	fillkpt
390
391	/* data and bss are r/w */
392	andl	$PG_FRAME,%eax			/* strip to just addr of bss */
393	movl	_KERNend-KERNBASE,%ecx		/* calculate size */
394	subl	%eax,%ecx
395	shrl	$PGSHIFT,%ecx
396	orl	$PG_V|PG_KW,%eax		/* valid, kernel read/write */
397	fillkpt
398#endif /* KGDB || BDE_DEBUGGER */
399
400/* now initialize the page dir, upages, p0stack PT, and page tables */
401
402	movl	$(1+UPAGES+1+NKPT),%ecx	/* number of PTEs */
403	movl	%esi,%eax			/* phys address of PTD */
404	andl	$PG_FRAME,%eax			/* convert to PFN, should be a NOP */
405	orl	$PG_V|PG_KW,%eax		/* valid, kernel read/write */
406	movl	%esi,%ebx			/* calculate pte offset to ptd */
407	shrl	$PGSHIFT-2,%ebx
408	addl	%esi,%ebx			/* address of page directory */
409	addl	$((1+UPAGES+1)*NBPG),%ebx	/* offset to kernel page tables */
410	fillkpt
411
412/* map I/O memory map */
413
414	movl    _KPTphys-KERNBASE,%ebx		/* base of kernel page tables */
415	lea     (0xa0 * PTESIZE)(%ebx),%ebx	/* hardwire ISA hole at KERNBASE + 0xa0000 */
416	movl	$0x100-0xa0,%ecx		/* for this many pte s, */
417	movl	$(0xa0000|PG_V|PG_KW|PG_N),%eax	/* valid, kernel read/write, non-cacheable */
418	movl	%ebx,_atdevphys-KERNBASE	/* save phys addr of ptes */
419	fillkpt
420
421 /* map proc 0's kernel stack into user page table page */
422
423	movl	$UPAGES,%ecx			/* for this many pte s, */
424	lea	(1*NBPG)(%esi),%eax		/* physical address in proc 0 */
425	lea	(KERNBASE)(%eax),%edx		/* change into virtual addr */
426	movl	%edx,_proc0paddr-KERNBASE	/* save VA for proc 0 init */
427	orl	$PG_V|PG_KW,%eax		/* valid, kernel read/write */
428	lea	((1+UPAGES)*NBPG)(%esi),%ebx	/* addr of stack page table in proc 0 */
429	addl	$(KSTKPTEOFF * PTESIZE),%ebx	/* offset to kernel stack PTE */
430	fillkpt
431
432/*
433 * Initialize kernel page table directory
434 */
435	/* install a pde for temporary double map of bottom of VA */
436	movl	_KPTphys-KERNBASE,%eax
437	orl     $PG_V|PG_KW,%eax		/* valid, kernel read/write */
438	movl	%eax,(%esi)			/* which is where temp maps! */
439
440	/* initialize kernel pde's */
441	movl	$(NKPT),%ecx			/* for this many PDEs */
442	lea	(KPTDI*PDESIZE)(%esi),%ebx	/* offset of pde for kernel */
443	fillkpt
444
445	/* install a pde recursively mapping page directory as a page table! */
446	movl	%esi,%eax			/* phys address of ptd in proc 0 */
447	orl	$PG_V|PG_KW,%eax		/* pde entry is valid */
448	movl	%eax,PTDPTDI*PDESIZE(%esi)	/* which is where PTmap maps! */
449
450	/* install a pde to map kernel stack for proc 0 */
451	lea	((1+UPAGES)*NBPG)(%esi),%eax	/* physical address of pt in proc 0 */
452	orl	$PG_V|PG_KW,%eax		/* pde entry is valid */
453	movl	%eax,KSTKPTDI*PDESIZE(%esi)	/* which is where kernel stack maps! */
454
455#ifdef BDE_DEBUGGER
456	/* copy and convert stuff from old gdt and idt for debugger */
457
458	cmpl	$0x0375c339,0x96104		/* XXX - debugger signature */
459	jne	1f
460	movb	$1,_bdb_exists-KERNBASE
4611:
462	pushal
463	subl	$2*6,%esp
464
465	sgdt	(%esp)
466	movl	2(%esp),%esi			/* base address of current gdt */
467	movl	$_gdt-KERNBASE,%edi
468	movl	%edi,2(%esp)
469	movl	$8*18/4,%ecx
470	cld
471	rep					/* copy gdt */
472	movsl
473	movl	$_gdt-KERNBASE,-8+2(%edi)	/* adjust gdt self-ptr */
474	movb	$0x92,-8+5(%edi)
475
476	sidt	6(%esp)
477	movl	6+2(%esp),%esi			/* base address of current idt */
478	movl	8+4(%esi),%eax			/* convert dbg descriptor to ... */
479	movw	8(%esi),%ax
480	movl	%eax,bdb_dbg_ljmp+1-KERNBASE	/* ... immediate offset ... */
481	movl	8+2(%esi),%eax
482	movw	%ax,bdb_dbg_ljmp+5-KERNBASE	/* ... and selector for ljmp */
483	movl	24+4(%esi),%eax			/* same for bpt descriptor */
484	movw	24(%esi),%ax
485	movl	%eax,bdb_bpt_ljmp+1-KERNBASE
486	movl	24+2(%esi),%eax
487	movw	%ax,bdb_bpt_ljmp+5-KERNBASE
488
489	movl	$_idt-KERNBASE,%edi
490	movl	%edi,6+2(%esp)
491	movl	$8*4/4,%ecx
492	cld
493	rep					/* copy idt */
494	movsl
495
496	lgdt	(%esp)
497	lidt	6(%esp)
498
499	addl	$2*6,%esp
500	popal
501#endif /* BDE_DEBUGGER */
502
503	/* load base of page directory and enable mapping */
504	movl	%esi,%eax			/* phys address of ptd in proc 0 */
505	movl	%eax,%cr3			/* load ptd addr into mmu */
506	movl	%cr0,%eax			/* get control word */
507	orl	$CR0_PE|CR0_PG,%eax		/* enable paging */
508	movl	%eax,%cr0			/* and let's page NOW! */
509
510	pushl	$begin				/* jump to high mem */
511	ret
512
513begin: /* now running relocated at KERNBASE where the system is linked to run */
514
515	.globl _Crtat				/* XXX - locore should not know about */
516	movl	_Crtat,%eax			/* variables of device drivers (pccons)! */
517	subl	$(KERNBASE+0xA0000),%eax
518	movl	_atdevphys,%edx			/* get pte PA */
519	subl	_KPTphys,%edx			/* remove base of ptes, now have phys offset */
520	shll	$PGSHIFT-2,%edx			/* corresponding to virt offset */
521	addl	$KERNBASE,%edx			/* add virtual base */
522	movl	%edx,_atdevbase
523	addl	%eax,%edx
524	movl	%edx,_Crtat
525
526	/* set up bootstrap stack - 48 bytes */
527	movl	$_kstack+UPAGES*NBPG-4*12,%esp	/* bootstrap stack end location */
528	xorl	%eax,%eax			/* mark end of frames */
529	movl	%eax,%ebp
530	movl	_proc0paddr,%eax
531	movl	%esi,PCB_CR3(%eax)
532
533#ifdef BDE_DEBUGGER
534	/* relocate debugger gdt entries */
535
536	movl	$_gdt+8*9,%eax			/* adjust slots 9-17 */
537	movl	$9,%ecx
538reloc_gdt:
539	movb	$KERNBASE>>24,7(%eax)		/* top byte of base addresses, was 0, */
540	addl	$8,%eax				/* now KERNBASE>>24 */
541	loop	reloc_gdt
542
543	cmpl	$0,_bdb_exists
544	je	1f
545	int	$3
5461:
547#endif /* BDE_DEBUGGER */
548
549	/*
550	 * Skip over the page tables and the kernel stack
551	 */
552	lea	((1+UPAGES+1+NKPT)*NBPG)(%esi),%esi
553
554	pushl	%esi				/* value of first for init386(first) */
555	call	_init386			/* wire 386 chip for unix operation */
556	popl	%esi
557
558	.globl	__ucodesel,__udatasel
559
560	pushl	$0				/* unused */
561	pushl	__udatasel			/* ss */
562	pushl	$0				/* esp - filled in by execve() */
563	pushl	$PSL_USERSET			/* eflags (ring 0, int enab) */
564	pushl	__ucodesel			/* cs */
565	pushl	$0				/* eip - filled in by execve() */
566	subl	$(12*4),%esp			/* space for rest of registers */
567
568	pushl	%esp				/* call main with frame pointer */
569	call	_main				/* autoconfiguration, mountroot etc */
570
571	addl	$(13*4),%esp			/* back to a frame we can return with */
572
573	/*
574	 * now we've run main() and determined what cpu-type we are, we can
575	 * enable WP mode on i486 cpus and above.
576	 */
577#if defined(I486_CPU) || defined(I586_CPU)
578	cmpl    $CPUCLASS_386,_cpu_class
579	je	1f
580	movl	%cr0,%eax			/* get control word */
581	orl	$CR0_WP,%eax			/* enable write protect for all modes */
582	movl	%eax,%cr0			/* and do it */
583#endif
584	/*
585	 * on return from main(), we are process 1
586	 * set up address space and stack so that we can 'return' to user mode
587	 */
5881:
589	movl	__ucodesel,%eax
590	movl	__udatasel,%ecx
591
592	movl	%cx,%ds
593	movl	%cx,%es
594	movl	%ax,%fs				/* double map cs to fs */
595	movl	%cx,%gs				/* and ds to gs */
596	iret					/* goto user! */
597
598#define LCALL(x,y)	.byte 0x9a ; .long y ; .word x
599
600NON_GPROF_ENTRY(sigcode)
601	call	SIGF_HANDLER(%esp)
602	lea	SIGF_SC(%esp),%eax		/* scp (the call may have clobbered the */
603						/* copy at 8(%esp)) */
604	pushl	%eax
605	pushl	%eax				/* junk to fake return address */
606	movl	$103,%eax			/* XXX sigreturn() */
607	LCALL(0x7,0)				/* enter kernel with args on stack */
608	hlt					/* never gets here */
609
610	.globl	_szsigcode
611_szsigcode:
612	.long	_szsigcode-_sigcode
613