locore.s revision 82957
14Srgrimes/*-
24Srgrimes * Copyright (c) 1990 The Regents of the University of California.
34Srgrimes * All rights reserved.
44Srgrimes *
54Srgrimes * This code is derived from software contributed to Berkeley by
64Srgrimes * William Jolitz.
74Srgrimes *
84Srgrimes * Redistribution and use in source and binary forms, with or without
94Srgrimes * modification, are permitted provided that the following conditions
104Srgrimes * are met:
114Srgrimes * 1. Redistributions of source code must retain the above copyright
124Srgrimes *    notice, this list of conditions and the following disclaimer.
134Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
144Srgrimes *    notice, this list of conditions and the following disclaimer in the
154Srgrimes *    documentation and/or other materials provided with the distribution.
164Srgrimes * 3. All advertising materials mentioning features or use of this software
174Srgrimes *    must display the following acknowledgement:
184Srgrimes *	This product includes software developed by the University of
194Srgrimes *	California, Berkeley and its contributors.
204Srgrimes * 4. Neither the name of the University nor the names of its contributors
214Srgrimes *    may be used to endorse or promote products derived from this software
224Srgrimes *    without specific prior written permission.
234Srgrimes *
244Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
254Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
264Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
274Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
284Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
294Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
304Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
314Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
324Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
334Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
344Srgrimes * SUCH DAMAGE.
354Srgrimes *
36556Srgrimes *	from: @(#)locore.s	7.3 (Berkeley) 5/13/91
3750477Speter * $FreeBSD: head/sys/i386/i386/locore.s 82957 2001-09-04 11:05:33Z peter $
3815392Sphk *
39757Sdg *		originally from: locore.s, by William F. Jolitz
40757Sdg *
41757Sdg *		Substantially rewritten by David Greenman, Rod Grimes,
4215392Sphk *			Bruce Evans, Wolfgang Solfrank, Poul-Henning Kamp
4315392Sphk *			and many others.
444Srgrimes */
454Srgrimes
4632358Seivind#include "opt_bootp.h"
4737272Sjmg#include "opt_nfsroot.h"
4814835Sbde
4914835Sbde#include <sys/syscall.h>
505908Sbde#include <sys/reboot.h>
514Srgrimes
5214835Sbde#include <machine/asmacros.h>
5314835Sbde#include <machine/cputypes.h>
5414835Sbde#include <machine/psl.h>
5515543Sphk#include <machine/pmap.h>
5614835Sbde#include <machine/specialreg.h>
5714835Sbde
5814835Sbde#include "assym.s"
5914835Sbde
6073017Speter#ifdef __AOUT__
6173017Speter#define	etext	_etext
6273017Speter#define	edata	_edata
6373017Speter#define	end	_end
6473017Speter#endif
6573017Speter
664Srgrimes/*
67757Sdg *	XXX
68757Sdg *
694Srgrimes * Note: This version greatly munged to avoid various assembler errors
704Srgrimes * that may be fixed in newer versions of gas. Perhaps newer versions
714Srgrimes * will have more pleasant appearance.
724Srgrimes */
734Srgrimes
74200Sdg/*
754Srgrimes * PTmap is recursive pagemap at top of virtual address space.
764Srgrimes * Within PTmap, the page directory can be found (third indirection).
7782307Sjulian *
7882307Sjulian * NOTE: PTDpde, PTmap, and PTD are being defined as address symbols.
7982307Sjulian * In C you access them directly, and not with a '*'. Storage is not being
8082308Speter * allocated. They will magically address the correct locations in KVM
8182394Speter * which C will treat as normal variables of the type they are defined in
8282307Sjulian * machine/pmap.h, i.e.  PTDpde = XX ; to set a PDE entry, NOT *PTDpde = XX;
834Srgrimes */
8473011Sjake	.globl	PTmap,PTD,PTDpde
8573011Sjake	.set	PTmap,(PTDPTDI << PDRSHIFT)
8673011Sjake	.set	PTD,PTmap + (PTDPTDI * PAGE_SIZE)
8773011Sjake	.set	PTDpde,PTD + (PTDPTDI * PDESIZE)
88592Srgrimes
893861Sbde/*
904Srgrimes * APTmap, APTD is the alternate recursive pagemap.
914Srgrimes * It's used when modifying another process's page tables.
9282307Sjulian * See the note above. It is true here as well.
934Srgrimes */
9473011Sjake	.globl	APTmap,APTD,APTDpde
9573011Sjake	.set	APTmap,APTDPTDI << PDRSHIFT
9673011Sjake	.set	APTD,APTmap + (APTDPTDI * PAGE_SIZE)
9773011Sjake	.set	APTDpde,PTD + (APTDPTDI * PDESIZE)
984Srgrimes
9970928Sjake#ifdef SMP
1004Srgrimes/*
10170928Sjake * Define layout of per-cpu address space.
10270928Sjake * This is "constructed" in locore.s on the BSP and in mp_machdep.c
10370928Sjake * for each AP.  DO NOT REORDER THESE WITHOUT UPDATING THE REST!
10470928Sjake */
10573011Sjake	.globl	SMP_prvspace, lapic
10673011Sjake	.set	SMP_prvspace,(MPPTDI << PDRSHIFT)
10773011Sjake	.set	lapic,SMP_prvspace + (NPTEPG-1) * PAGE_SIZE
10870928Sjake#endif /* SMP */
10970928Sjake
11070928Sjake/*
11182262Speter * Compiled KERNBASE location
11282262Speter */
11382262Speter	.globl	kernbase
11482262Speter	.set	kernbase,KERNBASE
11582262Speter
11682262Speter/*
117556Srgrimes * Globals
118556Srgrimes */
119556Srgrimes	.data
12014835Sbde	ALIGN_DATA		/* just to be sure */
121134Sdg
12225083Sjdp	.globl	HIDENAME(tmpstk)
12313729Sdg	.space	0x2000		/* space for tmpstk - temporary stack */
12425083SjdpHIDENAME(tmpstk):
1253842Sdg
12682957Speter	.globl	bootinfo
12773011Sjakebootinfo:	.space	BOOTINFO_SIZE		/* bootinfo that we can handle */
1284Srgrimes
12973011SjakeKERNend:	.long	0			/* phys addr end of kernel (just after bss) */
13015428Sphkphysfree:	.long	0			/* phys addr of next free page */
131757Sdg
13226812Speter#ifdef SMP
13373011Sjake		.globl	cpu0prvpage
13425164Spetercpu0pp:		.long	0			/* phys addr cpu0 private pg */
13573011Sjakecpu0prvpage:	.long	0			/* relocated version */
13625164Speter
13773011Sjake		.globl	SMPpt
13846129SluoqiSMPptpa:	.long	0			/* phys addr SMP page table */
13973011SjakeSMPpt:		.long	0			/* relocated version */
14026812Speter#endif /* SMP */
14125164Speter
14273011Sjake	.globl	IdlePTD
14373011SjakeIdlePTD:	.long	0			/* phys addr of kernel PTD */
1443861Sbde
14526812Speter#ifdef SMP
14673011Sjake	.globl	KPTphys
14726812Speter#endif
14873011SjakeKPTphys:	.long	0			/* phys addr of kernel page tables */
1494Srgrimes
15073011Sjake	.globl	proc0paddr
15173011Sjakeproc0paddr:	.long	0			/* address of proc 0 address space */
15224693Speterp0upa:		.long	0			/* phys addr of proc0's UPAGES */
153134Sdg
15437889Sjlemonvm86phystk:	.long	0			/* PA of vm86/bios stack */
15537889Sjlemon
15673011Sjake	.globl	vm86paddr, vm86pa
15773011Sjakevm86paddr:	.long	0			/* address of vm86 region */
15873011Sjakevm86pa:		.long	0			/* phys addr of vm86 region */
15934840Sjlemon
16015428Sphk#ifdef BDE_DEBUGGER
16115428Sphk	.globl	_bdb_exists			/* flag to indicate BDE debugger is present */
16215428Sphk_bdb_exists:	.long	0
16315428Sphk#endif
164718Swollman
16543434Skato#ifdef PC98
16673011Sjake	.globl	pc98_system_parameter
16773011Sjakepc98_system_parameter:
16843434Skato	.space	0x240
16943434Skato#endif
17015428Sphk
17115392Sphk/**********************************************************************
17215392Sphk *
17315392Sphk * Some handy macros
17415392Sphk *
175556Srgrimes */
176134Sdg
17715392Sphk#define R(foo) ((foo)-KERNBASE)
17815392Sphk
17915392Sphk#define ALLOCPAGES(foo) \
18015392Sphk	movl	R(physfree), %esi ; \
18115543Sphk	movl	$((foo)*PAGE_SIZE), %eax ; \
18215392Sphk	addl	%esi, %eax ; \
18315392Sphk	movl	%eax, R(physfree) ; \
18415392Sphk	movl	%esi, %edi ; \
18515543Sphk	movl	$((foo)*PAGE_SIZE),%ecx ; \
18615392Sphk	xorl	%eax,%eax ; \
18715428Sphk	cld ; \
18815428Sphk	rep ; \
18915428Sphk	stosb
19015392Sphk
191134Sdg/*
19215392Sphk * fillkpt
19315565Sphk *	eax = page frame address
19415565Sphk *	ebx = index into page table
19515392Sphk *	ecx = how many pages to map
19615565Sphk * 	base = base address of page dir/table
19715565Sphk *	prot = protection bits
198134Sdg */
19915565Sphk#define	fillkpt(base, prot)		  \
20019621Sdyson	shll	$2,%ebx			; \
20119621Sdyson	addl	base,%ebx		; \
20219621Sdyson	orl	$PG_V,%eax		; \
20319621Sdyson	orl	prot,%eax		; \
20415565Sphk1:	movl	%eax,(%ebx)		; \
20515565Sphk	addl	$PAGE_SIZE,%eax		; /* increment physical address */ \
20615565Sphk	addl	$4,%ebx			; /* next pte */ \
20715428Sphk	loop	1b
20815392Sphk
20915565Sphk/*
21015565Sphk * fillkptphys(prot)
21115565Sphk *	eax = physical address
21215565Sphk *	ecx = how many pages to map
21315565Sphk *	prot = protection bits
21415565Sphk */
21515565Sphk#define	fillkptphys(prot)		  \
21615565Sphk	movl	%eax, %ebx		; \
21715565Sphk	shrl	$PAGE_SHIFT, %ebx	; \
21873011Sjake	fillkpt(R(KPTphys), prot)
21915565Sphk
22015392Sphk	.text
22115392Sphk/**********************************************************************
22215392Sphk *
22315392Sphk * This is where the bootblocks start us, set the ball rolling...
22415392Sphk *
22515392Sphk */
2261321SdgNON_GPROF_ENTRY(btext)
2274Srgrimes
22824112Skato#ifdef PC98
22924112Skato	/* save SYSTEM PARAMETER for resume (NS/T or other) */
23043434Skato	movl	$0xa1400,%esi
23173011Sjake	movl	$R(pc98_system_parameter),%edi
23243434Skato	movl	$0x0240,%ecx
23324112Skato	cld
23424112Skato	rep
23524112Skato	movsb
23624112Skato#else	/* IBM-PC */
23715428Sphk#ifdef BDE_DEBUGGER
23815428Sphk#ifdef BIOS_STEALS_3K
23915428Sphk	cmpl	$0x0375c339,0x95504
24015428Sphk#else
24115428Sphk	cmpl	$0x0375c339,0x96104	/* XXX - debugger signature */
24215428Sphk#endif
24315428Sphk	jne	1f
24415428Sphk	movb	$1,R(_bdb_exists)
24515428Sphk1:
24615428Sphk#endif
24715392Sphk/* Tell the bios to warmboot next time */
24815392Sphk	movw	$0x1234,0x472
24954128Skato#endif	/* PC98 */
25015392Sphk
25115428Sphk/* Set up a real frame in case the double return in newboot is executed. */
2523384Srgrimes	pushl	%ebp
2533384Srgrimes	movl	%esp, %ebp
2543384Srgrimes
25515392Sphk/* Don't trust what the BIOS gives for eflags. */
2565603Sbde	pushl	$PSL_KERNEL
2572486Sdg	popfl
25815428Sphk
25915428Sphk/*
26015428Sphk * Don't trust what the BIOS gives for %fs and %gs.  Trust the bootstrap
26115428Sphk * to set %cs, %ds, %es and %ss.
26215428Sphk */
26315428Sphk	mov	%ds, %ax
2644217Sphk	mov	%ax, %fs
2654217Sphk	mov	%ax, %gs
2664217Sphk
26715392Sphk	call	recover_bootinfo
26815392Sphk
26915428Sphk/* Get onto a stack that we can trust. */
27015428Sphk/*
27115428Sphk * XXX this step is delayed in case recover_bootinfo needs to return via
27215428Sphk * the old stack, but it need not be, since recover_bootinfo actually
27315428Sphk * returns via the old frame.
27415428Sphk */
27525083Sjdp	movl	$R(HIDENAME(tmpstk)),%esp
27615392Sphk
27724112Skato#ifdef PC98
27843447Skato	/* pc98_machine_type & M_EPSON_PC98 */
27973011Sjake	testb	$0x02,R(pc98_system_parameter)+220
28024112Skato	jz	3f
28143447Skato	/* epson_machine_id <= 0x0b */
28273011Sjake	cmpb	$0x0b,R(pc98_system_parameter)+224
28324112Skato	ja	3f
28424112Skato
28524112Skato	/* count up memory */
28624112Skato	movl	$0x100000,%eax		/* next, talley remaining memory */
28724112Skato	movl	$0xFFF-0x100,%ecx
28824112Skato1:	movl	0(%eax),%ebx		/* save location to check */
28924112Skato	movl	$0xa55a5aa5,0(%eax)	/* write test pattern */
29024112Skato	cmpl	$0xa55a5aa5,0(%eax)	/* does not check yet for rollover */
29124112Skato	jne	2f
29224112Skato	movl	%ebx,0(%eax)		/* restore memory */
29324112Skato	addl	$PAGE_SIZE,%eax
29424112Skato	loop	1b
29524112Skato2:	subl	$0x100000,%eax
29624112Skato	shrl	$17,%eax
29773011Sjake	movb	%al,R(pc98_system_parameter)+1
29824112Skato3:
29958786Skato
30073011Sjake	movw	R(pc98_system_parameter+0x86),%ax
30173011Sjake	movw	%ax,R(cpu_id)
30224112Skato#endif
30324112Skato
30415392Sphk	call	identify_cpu
30515392Sphk
30615392Sphk/* clear bss */
30715428Sphk/*
30817120Sbde * XXX this should be done a little earlier.
30915428Sphk *
31017120Sbde * XXX we don't check that there is memory for our bss and page tables
31117120Sbde * before using it.
31215428Sphk *
31315428Sphk * XXX the boot program somewhat bogusly clears the bss.  We still have
31415428Sphk * to do it in case we were unzipped by kzipboot.  Then the boot program
31515428Sphk * only clears kzipboot's bss.
31615428Sphk *
31715428Sphk * XXX the gdt and idt are still somewhere in the boot program.  We
31815428Sphk * depend on the convention that the boot program is below 1MB and we
31915428Sphk * are above 1MB to keep the gdt and idt  away from the bss and page
32017120Sbde * tables.  The idt is only used if BDE_DEBUGGER is enabled.
32115428Sphk */
32273011Sjake	movl	$R(end),%ecx
32373011Sjake	movl	$R(edata),%edi
32415392Sphk	subl	%edi,%ecx
32515392Sphk	xorl	%eax,%eax
32615428Sphk	cld
32715428Sphk	rep
32815428Sphk	stosb
32915392Sphk
33015392Sphk	call	create_pagetables
33115392Sphk
33227993Sdyson/*
33327993Sdyson * If the CPU has support for VME, turn it on.
33427993Sdyson */
33573011Sjake	testl	$CPUID_VME, R(cpu_feature)
33627993Sdyson	jz	1f
33727993Sdyson	movl	%cr4, %eax
33827993Sdyson	orl	$CR4_VME, %eax
33927993Sdyson	movl	%eax, %cr4
34027993Sdyson1:
34127993Sdyson
34215428Sphk#ifdef BDE_DEBUGGER
34315428Sphk/*
34415428Sphk * Adjust as much as possible for paging before enabling paging so that the
34515428Sphk * adjustments can be traced.
34615428Sphk */
34715428Sphk	call	bdb_prepare_paging
34815428Sphk#endif
34915428Sphk
35015392Sphk/* Now enable paging */
35173011Sjake	movl	R(IdlePTD), %eax
35215392Sphk	movl	%eax,%cr3			/* load ptd addr into mmu */
35315392Sphk	movl	%cr0,%eax			/* get control word */
35415392Sphk	orl	$CR0_PE|CR0_PG,%eax		/* enable paging */
35515392Sphk	movl	%eax,%cr0			/* and let's page NOW! */
35615392Sphk
35715428Sphk#ifdef BDE_DEBUGGER
35815428Sphk/*
35915428Sphk * Complete the adjustments for paging so that we can keep tracing through
36017120Sbde * initi386() after the low (physical) addresses for the gdt and idt become
36115428Sphk * invalid.
36215428Sphk */
36315428Sphk	call	bdb_commit_paging
36415428Sphk#endif
36515428Sphk
36615428Sphk	pushl	$begin				/* jump to high virtualized address */
36715392Sphk	ret
36815392Sphk
36915392Sphk/* now running relocated at KERNBASE where the system is linked to run */
37015392Sphkbegin:
37115392Sphk	/* set up bootstrap stack */
37273011Sjake	movl	proc0paddr,%eax			/* location of in-kernel pages */
37365815Sbde	leal	UPAGES*PAGE_SIZE(%eax),%esp	/* bootstrap stack end location */
37465815Sbde
37565815Sbde	xorl	%ebp,%ebp			/* mark end of frames */
37665815Sbde
37773011Sjake	movl	IdlePTD,%esi
37815392Sphk	movl	%esi,PCB_CR3(%eax)
37915392Sphk
38082140Siwasaki	testl	$CPUID_PGE, R(cpu_feature)
38182140Siwasaki	jz	1f
38282140Siwasaki	movl	%cr4, %eax
38382140Siwasaki	orl	$CR4_PGE, %eax
38482140Siwasaki	movl	%eax, %cr4
38582140Siwasaki1:
38665815Sbde	pushl	physfree			/* value of first for init386(first) */
38773011Sjake	call	init386				/* wire 386 chip for unix operation */
38815392Sphk
38965815Sbde	/*
39065815Sbde	 * Clean up the stack in a way that db_numargs() understands, so
39165815Sbde	 * that backtraces in ddb don't underrun the stack.  Traps for
39265815Sbde	 * inaccessible memory are more fatal than usual this early.
39365815Sbde	 */
39465815Sbde	addl	$4,%esp
39565815Sbde
39673011Sjake	call	mi_startup			/* autoconfiguration, mountroot etc */
39765815Sbde	/* NOTREACHED */
39865815Sbde	addl	$0,%esp				/* for db_numargs() again */
39915392Sphk
40024691Speter/*
40115392Sphk * Signal trampoline, copied to top of user stack
40215392Sphk */
40315392SphkNON_GPROF_ENTRY(sigcode)
40460303Sobrien	call	*SIGF_HANDLER(%esp)		/* call signal handler */
40551984Smarcel	lea	SIGF_UC(%esp),%eax		/* get ucontext_t */
40615392Sphk	pushl	%eax
40752140Sluoqi	testl	$PSL_VM,UC_EFLAGS(%eax)
40852140Sluoqi	jne	9f
40952140Sluoqi	movl	UC_GS(%eax),%gs			/* restore %gs */
41052140Sluoqi9:
41152140Sluoqi	movl	$SYS_sigreturn,%eax
41251792Smarcel	pushl	%eax				/* junk to fake return addr. */
41351792Smarcel	int	$0x80				/* enter kernel with args */
41452140Sluoqi0:	jmp	0b
41552140Sluoqi
41625083Sjdp	ALIGN_TEXT
41773011Sjakeosigcode:
41860303Sobrien	call	*SIGF_HANDLER(%esp)		/* call signal handler */
41952140Sluoqi	lea	SIGF_SC(%esp),%eax		/* get sigcontext */
42052140Sluoqi	pushl	%eax
42152140Sluoqi	testl	$PSL_VM,SC_PS(%eax)
42252140Sluoqi	jne	9f
42352140Sluoqi	movl	SC_GS(%eax),%gs			/* restore %gs */
42452140Sluoqi9:
42552140Sluoqi	movl	$0x01d516,SC_TRAPNO(%eax)	/* magic: 0ldSiG */
42652140Sluoqi	movl	$SYS_sigreturn,%eax
42752140Sluoqi	pushl	%eax				/* junk to fake return addr. */
42852140Sluoqi	int	$0x80				/* enter kernel with args */
42952140Sluoqi0:	jmp	0b
43052140Sluoqi
43152140Sluoqi	ALIGN_TEXT
43273011Sjakeesigcode:
43315392Sphk
43415392Sphk	.data
43573011Sjake	.globl	szsigcode, szosigcode
43673011Sjakeszsigcode:
43773011Sjake	.long	esigcode-sigcode
43873011Sjakeszosigcode:
43973011Sjake	.long	esigcode-osigcode
44015428Sphk	.text
44115392Sphk
44215392Sphk/**********************************************************************
44315392Sphk *
44415392Sphk * Recover the bootinfo passed to us from the boot program
44515392Sphk *
44615392Sphk */
44715392Sphkrecover_bootinfo:
44815392Sphk	/*
4493284Srgrimes	 * This code is called in different ways depending on what loaded
4503284Srgrimes	 * and started the kernel.  This is used to detect how we get the
4513284Srgrimes	 * arguments from the other code and what we do with them.
4523284Srgrimes	 *
4533284Srgrimes	 * Old disk boot blocks:
4543284Srgrimes	 *	(*btext)(howto, bootdev, cyloffset, esym);
4553284Srgrimes	 *	[return address == 0, and can NOT be returned to]
4563284Srgrimes	 *	[cyloffset was not supported by the FreeBSD boot code
4573284Srgrimes	 *	 and always passed in as 0]
4583284Srgrimes	 *	[esym is also known as total in the boot code, and
4593284Srgrimes	 *	 was never properly supported by the FreeBSD boot code]
4603284Srgrimes	 *
4613284Srgrimes	 * Old diskless netboot code:
4623284Srgrimes	 *	(*btext)(0,0,0,0,&nfsdiskless,0,0,0);
4633284Srgrimes	 *	[return address != 0, and can NOT be returned to]
4643284Srgrimes	 *	If we are being booted by this code it will NOT work,
4653284Srgrimes	 *	so we are just going to halt if we find this case.
4663284Srgrimes	 *
4673284Srgrimes	 * New uniform boot code:
4683284Srgrimes	 *	(*btext)(howto, bootdev, 0, 0, 0, &bootinfo)
4693284Srgrimes	 *	[return address != 0, and can be returned to]
4703284Srgrimes	 *
4713284Srgrimes	 * There may seem to be a lot of wasted arguments in here, but
4723384Srgrimes	 * that is so the newer boot code can still load very old kernels
4733384Srgrimes	 * and old boot code can load new kernels.
4744Srgrimes	 */
4753284Srgrimes
4763284Srgrimes	/*
4773284Srgrimes	 * The old style disk boot blocks fake a frame on the stack and
4783284Srgrimes	 * did an lret to get here.  The frame on the stack has a return
4793284Srgrimes	 * address of 0.
4803284Srgrimes	 */
4813384Srgrimes	cmpl	$0,4(%ebp)
48215392Sphk	je	olddiskboot
4833284Srgrimes
4843284Srgrimes	/*
4853284Srgrimes	 * We have some form of return address, so this is either the
4863284Srgrimes	 * old diskless netboot code, or the new uniform code.  That can
48715428Sphk	 * be detected by looking at the 5th argument, if it is 0
48815428Sphk	 * we are being booted by the new uniform boot code.
4893284Srgrimes	 */
4903384Srgrimes	cmpl	$0,24(%ebp)
49115392Sphk	je	newboot
4923284Srgrimes
4933284Srgrimes	/*
4943284Srgrimes	 * Seems we have been loaded by the old diskless boot code, we
4953284Srgrimes	 * don't stand a chance of running as the diskless structure
4963284Srgrimes	 * changed considerably between the two, so just halt.
4973284Srgrimes	 */
4983284Srgrimes	 hlt
4993284Srgrimes
5003284Srgrimes	/*
5013384Srgrimes	 * We have been loaded by the new uniform boot code.
50215428Sphk	 * Let's check the bootinfo version, and if we do not understand
5033384Srgrimes	 * it we return to the loader with a status of 1 to indicate this error
5043284Srgrimes	 */
50515392Sphknewboot:
5063384Srgrimes	movl	28(%ebp),%ebx		/* &bootinfo.version */
5075908Sbde	movl	BI_VERSION(%ebx),%eax
5083384Srgrimes	cmpl	$1,%eax			/* We only understand version 1 */
5093384Srgrimes	je	1f
5103384Srgrimes	movl	$1,%eax			/* Return status */
5113384Srgrimes	leave
51215428Sphk	/*
51315428Sphk	 * XXX this returns to our caller's caller (as is required) since
51415428Sphk	 * we didn't set up a frame and our caller did.
51515428Sphk	 */
5163384Srgrimes	ret
5173284Srgrimes
5183384Srgrimes1:
5193284Srgrimes	/*
5203384Srgrimes	 * If we have a kernelname copy it in
5213384Srgrimes	 */
5225908Sbde	movl	BI_KERNELNAME(%ebx),%esi
5233384Srgrimes	cmpl	$0,%esi
5249344Sdg	je	2f			/* No kernelname */
5259344Sdg	movl	$MAXPATHLEN,%ecx	/* Brute force!!! */
52673011Sjake	movl	$R(kernelname),%edi
5279344Sdg	cmpb	$'/',(%esi)		/* Make sure it starts with a slash */
5289344Sdg	je	1f
5299344Sdg	movb	$'/',(%edi)
5309344Sdg	incl	%edi
5319344Sdg	decl	%ecx
5329344Sdg1:
5333384Srgrimes	cld
5343384Srgrimes	rep
5353384Srgrimes	movsb
5363384Srgrimes
5379344Sdg2:
53815428Sphk	/*
5395908Sbde	 * Determine the size of the boot loader's copy of the bootinfo
5405908Sbde	 * struct.  This is impossible to do properly because old versions
5415908Sbde	 * of the struct don't contain a size field and there are 2 old
5425908Sbde	 * versions with the same version number.
5434600Sphk	 */
5445908Sbde	movl	$BI_ENDCOMMON,%ecx	/* prepare for sizeless version */
5455908Sbde	testl	$RB_BOOTINFO,8(%ebp)	/* bi_size (and bootinfo) valid? */
5465908Sbde	je	got_bi_size		/* no, sizeless version */
5475908Sbde	movl	BI_SIZE(%ebx),%ecx
5485908Sbdegot_bi_size:
5495908Sbde
55015428Sphk	/*
5515908Sbde	 * Copy the common part of the bootinfo struct
5525908Sbde	 */
5534600Sphk	movl	%ebx,%esi
55473011Sjake	movl	$R(bootinfo),%edi
5555908Sbde	cmpl	$BOOTINFO_SIZE,%ecx
5565908Sbde	jbe	got_common_bi_size
5574600Sphk	movl	$BOOTINFO_SIZE,%ecx
5585908Sbdegot_common_bi_size:
5594600Sphk	cld
5604600Sphk	rep
5614600Sphk	movsb
5624600Sphk
56338063Smsmith#ifdef NFS_ROOT
56425837Stegge#ifndef BOOTP_NFSV3
5653384Srgrimes	/*
5663384Srgrimes	 * If we have a nfs_diskless structure copy it in
5673384Srgrimes	 */
5685908Sbde	movl	BI_NFS_DISKLESS(%ebx),%esi
5693384Srgrimes	cmpl	$0,%esi
57015428Sphk	je	olddiskboot
57173011Sjake	movl	$R(nfs_diskless),%edi
5723384Srgrimes	movl	$NFSDISKLESS_SIZE,%ecx
5733384Srgrimes	cld
5743384Srgrimes	rep
5753384Srgrimes	movsb
57673011Sjake	movl	$R(nfs_diskless_valid),%edi
5773795Sphk	movl	$1,(%edi)
5783406Sdg#endif
57925837Stegge#endif
5803384Srgrimes
5813384Srgrimes	/*
5823284Srgrimes	 * The old style disk boot.
5833284Srgrimes	 *	(*btext)(howto, bootdev, cyloffset, esym);
5843384Srgrimes	 * Note that the newer boot code just falls into here to pick
5853384Srgrimes	 * up howto and bootdev, cyloffset and esym are no longer used
5863284Srgrimes	 */
58715392Sphkolddiskboot:
5883384Srgrimes	movl	8(%ebp),%eax
58973011Sjake	movl	%eax,R(boothowto)
5903384Srgrimes	movl	12(%ebp),%eax
59173011Sjake	movl	%eax,R(bootdev)
5922783Ssos
59315392Sphk	ret
5943258Sdg
5951321Sdg
59615392Sphk/**********************************************************************
59715392Sphk *
59815392Sphk * Identify the CPU and initialize anything special about it
59915392Sphk *
60015392Sphk */
60115392Sphkidentify_cpu:
60215392Sphk
6031998Swollman	/* Try to toggle alignment check flag; does not exist on 386. */
6041998Swollman	pushfl
6051998Swollman	popl	%eax
6061998Swollman	movl	%eax,%ecx
6071998Swollman	orl	$PSL_AC,%eax
6081998Swollman	pushl	%eax
6091998Swollman	popfl
6101998Swollman	pushfl
6111998Swollman	popl	%eax
6121998Swollman	xorl	%ecx,%eax
6131998Swollman	andl	$PSL_AC,%eax
6141998Swollman	pushl	%ecx
6151998Swollman	popfl
6161998Swollman
6171998Swollman	testl	%eax,%eax
61824112Skato	jnz	try486
61924112Skato
62024112Skato	/* NexGen CPU does not have aligment check flag. */
62124112Skato	pushfl
62224112Skato	movl	$0x5555, %eax
62324112Skato	xorl	%edx, %edx
62424112Skato	movl	$2, %ecx
62524112Skato	clc
62624112Skato	divl	%ecx
62724112Skato	jz	trynexgen
62824112Skato	popfl
62973011Sjake	movl	$CPU_386,R(cpu)
63013081Sdg	jmp	3f
6311998Swollman
63224112Skatotrynexgen:
63327424Skato	popfl
63473011Sjake	movl	$CPU_NX586,R(cpu)
63573011Sjake	movl	$0x4778654e,R(cpu_vendor)	# store vendor string
63673011Sjake	movl	$0x72446e65,R(cpu_vendor+4)
63773011Sjake	movl	$0x6e657669,R(cpu_vendor+8)
63873011Sjake	movl	$0,R(cpu_vendor+12)
63924112Skato	jmp	3f
64024112Skato
64124112Skatotry486:	/* Try to toggle identification flag; does not exist on early 486s. */
6421998Swollman	pushfl
6431998Swollman	popl	%eax
6441998Swollman	movl	%eax,%ecx
6451998Swollman	xorl	$PSL_ID,%eax
6461998Swollman	pushl	%eax
6471998Swollman	popfl
6481998Swollman	pushfl
6491998Swollman	popl	%eax
6501998Swollman	xorl	%ecx,%eax
6511998Swollman	andl	$PSL_ID,%eax
6521998Swollman	pushl	%ecx
6531998Swollman	popfl
6541998Swollman
6551998Swollman	testl	%eax,%eax
65624112Skato	jnz	trycpuid
65773011Sjake	movl	$CPU_486,R(cpu)
6582495Spst
65924112Skato	/*
66024112Skato	 * Check Cyrix CPU
66124112Skato	 * Cyrix CPUs do not change the undefined flags following
66224112Skato	 * execution of the divide instruction which divides 5 by 2.
66324112Skato	 *
66424112Skato	 * Note: CPUID is enabled on M2, so it passes another way.
66524112Skato	 */
66624112Skato	pushfl
66724112Skato	movl	$0x5555, %eax
66824112Skato	xorl	%edx, %edx
66924112Skato	movl	$2, %ecx
67024112Skato	clc
67124112Skato	divl	%ecx
67224112Skato	jnc	trycyrix
67324112Skato	popfl
67424112Skato	jmp	3f		/* You may use Intel CPU. */
6752495Spst
67624112Skatotrycyrix:
67724112Skato	popfl
67824112Skato	/*
67924112Skato	 * IBM Bluelighting CPU also doesn't change the undefined flags.
68024112Skato	 * Because IBM doesn't disclose the information for Bluelighting
68124112Skato	 * CPU, we couldn't distinguish it from Cyrix's (including IBM
68224112Skato	 * brand of Cyrix CPUs).
68324112Skato	 */
68473011Sjake	movl	$0x69727943,R(cpu_vendor)	# store vendor string
68573011Sjake	movl	$0x736e4978,R(cpu_vendor+4)
68673011Sjake	movl	$0x64616574,R(cpu_vendor+8)
68713014Sdg	jmp	3f
6881998Swollman
68924112Skatotrycpuid:	/* Use the `cpuid' instruction. */
6901998Swollman	xorl	%eax,%eax
69169006Smarkm	cpuid					# cpuid 0
69273011Sjake	movl	%eax,R(cpu_high)		# highest capability
69373011Sjake	movl	%ebx,R(cpu_vendor)		# store vendor string
69473011Sjake	movl	%edx,R(cpu_vendor+4)
69573011Sjake	movl	%ecx,R(cpu_vendor+8)
69673011Sjake	movb	$0,R(cpu_vendor+12)
6971998Swollman
6981998Swollman	movl	$1,%eax
69969006Smarkm	cpuid					# cpuid 1
70073011Sjake	movl	%eax,R(cpu_id)			# store cpu_id
70173011Sjake	movl	%edx,R(cpu_feature)		# store cpu_feature
7026308Sphk	rorl	$8,%eax				# extract family type
7031998Swollman	andl	$15,%eax
7041998Swollman	cmpl	$5,%eax
7051998Swollman	jae	1f
7061998Swollman
7071998Swollman	/* less than Pentium; must be 486 */
70873011Sjake	movl	$CPU_486,R(cpu)
70913000Sdg	jmp	3f
71013000Sdg1:
71113000Sdg	/* a Pentium? */
71213000Sdg	cmpl	$5,%eax
71313000Sdg	jne	2f
71473011Sjake	movl	$CPU_586,R(cpu)
71513000Sdg	jmp	3f
716556Srgrimes2:
71713000Sdg	/* Greater than Pentium...call it a Pentium Pro */
71873011Sjake	movl	$CPU_686,R(cpu)
71913000Sdg3:
72015392Sphk	ret
721556Srgrimes
7224Srgrimes
72315392Sphk/**********************************************************************
724570Srgrimes *
72515428Sphk * Create the first page directory and its page tables.
72615392Sphk *
727570Srgrimes */
728570Srgrimes
72915392Sphkcreate_pagetables:
73015392Sphk
73115428Sphk/* Find end of kernel image (rounded up to a page boundary). */
73215392Sphk	movl	$R(_end),%esi
7334Srgrimes
73461422Sbde/* Include symbols, if any. */
73573011Sjake	movl	R(bootinfo+BI_ESYMTAB),%edi
7365908Sbde	testl	%edi,%edi
73715428Sphk	je	over_symalloc
7385908Sbde	movl	%edi,%esi
7395908Sbde	movl	$KERNBASE,%edi
74073011Sjake	addl	%edi,R(bootinfo+BI_SYMTAB)
74173011Sjake	addl	%edi,R(bootinfo+BI_ESYMTAB)
74215428Sphkover_symalloc:
7435908Sbde
74440081Smsmith/* If we are told where the end of the kernel space is, believe it. */
74573011Sjake	movl	R(bootinfo+BI_KERNEND),%edi
74640081Smsmith	testl	%edi,%edi
74740081Smsmith	je	no_kernend
74840081Smsmith	movl	%edi,%esi
74940081Smsmithno_kernend:
75040081Smsmith
75115565Sphk	addl	$PAGE_MASK,%esi
75215565Sphk	andl	$~PAGE_MASK,%esi
75373011Sjake	movl	%esi,R(KERNend)		/* save end of kernel */
75415428Sphk	movl	%esi,R(physfree)	/* next free page is at end of kernel */
755608Srgrimes
75615392Sphk/* Allocate Kernel Page Tables */
75715392Sphk	ALLOCPAGES(NKPT)
75873011Sjake	movl	%esi,R(KPTphys)
759757Sdg
76015392Sphk/* Allocate Page Table Directory */
76115392Sphk	ALLOCPAGES(1)
76273011Sjake	movl	%esi,R(IdlePTD)
7634Srgrimes
76415392Sphk/* Allocate UPAGES */
76515392Sphk	ALLOCPAGES(UPAGES)
76617120Sbde	movl	%esi,R(p0upa)
76715392Sphk	addl	$KERNBASE, %esi
76873011Sjake	movl	%esi, R(proc0paddr)
7694Srgrimes
77037889Sjlemon	ALLOCPAGES(1)			/* vm86/bios stack */
77137889Sjlemon	movl	%esi,R(vm86phystk)
77237889Sjlemon
77337889Sjlemon	ALLOCPAGES(3)			/* pgtable + ext + IOPAGES */
77473011Sjake	movl	%esi,R(vm86pa)
77534840Sjlemon	addl	$KERNBASE, %esi
77673011Sjake	movl	%esi, R(vm86paddr)
77734840Sjlemon
77826812Speter#ifdef SMP
77925164Speter/* Allocate cpu0's private data page */
78025164Speter	ALLOCPAGES(1)
78125164Speter	movl	%esi,R(cpu0pp)
78225164Speter	addl	$KERNBASE, %esi
78373011Sjake	movl	%esi, R(cpu0prvpage)	/* relocated to KVM space */
78425164Speter
78546129Sluoqi/* Allocate SMP page table page */
78625164Speter	ALLOCPAGES(1)
78746129Sluoqi	movl	%esi,R(SMPptpa)
78825164Speter	addl	$KERNBASE, %esi
78973011Sjake	movl	%esi, R(SMPpt)		/* relocated to KVM space */
79026812Speter#endif	/* SMP */
79125164Speter
79215392Sphk/* Map read-only from zero to the end of the kernel text section */
79315565Sphk	xorl	%eax, %eax
79415428Sphk#ifdef BDE_DEBUGGER
79515428Sphk/* If the debugger is present, actually map everything read-write. */
79615428Sphk	cmpl	$0,R(_bdb_exists)
79715428Sphk	jne	map_read_write
79815428Sphk#endif
79919621Sdyson	xorl	%edx,%edx
80027484Sdyson
80127484Sdyson#if !defined(SMP)
80273011Sjake	testl	$CPUID_PGE, R(cpu_feature)
80319621Sdyson	jz	2f
80419621Sdyson	orl	$PG_G,%edx
80527484Sdyson#endif
80619621Sdyson
80773011Sjake2:	movl	$R(etext),%ecx
80815565Sphk	addl	$PAGE_MASK,%ecx
80915565Sphk	shrl	$PAGE_SHIFT,%ecx
81019621Sdyson	fillkptphys(%edx)
811757Sdg
81215392Sphk/* Map read-write, data, bss and symbols */
81373011Sjake	movl	$R(etext),%eax
81415694Sphk	addl	$PAGE_MASK, %eax
81515694Sphk	andl	$~PAGE_MASK, %eax
81615428Sphkmap_read_write:
81719621Sdyson	movl	$PG_RW,%edx
81827484Sdyson#if !defined(SMP)
81973011Sjake	testl	$CPUID_PGE, R(cpu_feature)
82019621Sdyson	jz	1f
82119621Sdyson	orl	$PG_G,%edx
82227484Sdyson#endif
82319621Sdyson
82473011Sjake1:	movl	R(KERNend),%ecx
825757Sdg	subl	%eax,%ecx
82615543Sphk	shrl	$PAGE_SHIFT,%ecx
82719621Sdyson	fillkptphys(%edx)
828757Sdg
82915428Sphk/* Map page directory. */
83073011Sjake	movl	R(IdlePTD), %eax
83115392Sphk	movl	$1, %ecx
83219621Sdyson	fillkptphys($PG_RW)
833757Sdg
83417120Sbde/* Map proc0's UPAGES in the physical way ... */
83517120Sbde	movl	R(p0upa), %eax
83615392Sphk	movl	$UPAGES, %ecx
83719621Sdyson	fillkptphys($PG_RW)
8384Srgrimes
83915565Sphk/* Map ISA hole */
84015565Sphk	movl	$ISA_HOLE_START, %eax
84115565Sphk	movl	$ISA_HOLE_LENGTH>>PAGE_SHIFT, %ecx
84222130Sdg	fillkptphys($PG_RW)
84315565Sphk
84434840Sjlemon/* Map space for the vm86 region */
84537889Sjlemon	movl	R(vm86phystk), %eax
84634840Sjlemon	movl	$4, %ecx
84734840Sjlemon	fillkptphys($PG_RW)
84834840Sjlemon
84934840Sjlemon/* Map page 0 into the vm86 page table */
85034840Sjlemon	movl	$0, %eax
85134840Sjlemon	movl	$0, %ebx
85234840Sjlemon	movl	$1, %ecx
85373011Sjake	fillkpt(R(vm86pa), $PG_RW|PG_U)
85434840Sjlemon
85534840Sjlemon/* ...likewise for the ISA hole */
85634840Sjlemon	movl	$ISA_HOLE_START, %eax
85734840Sjlemon	movl	$ISA_HOLE_START>>PAGE_SHIFT, %ebx
85834840Sjlemon	movl	$ISA_HOLE_LENGTH>>PAGE_SHIFT, %ecx
85973011Sjake	fillkpt(R(vm86pa), $PG_RW|PG_U)
86034840Sjlemon
86126812Speter#ifdef SMP
86226812Speter/* Map cpu0's private page into global kmem (4K @ cpu0prvpage) */
86325164Speter	movl	R(cpu0pp), %eax
86425164Speter	movl	$1, %ecx
86525164Speter	fillkptphys($PG_RW)
86625164Speter
86746129Sluoqi/* Map SMP page table page into global kmem FWIW */
86846129Sluoqi	movl	R(SMPptpa), %eax
86925164Speter	movl	$1, %ecx
87025164Speter	fillkptphys($PG_RW)
87125164Speter
87246129Sluoqi/* Map the private page into the SMP page table */
87325164Speter	movl	R(cpu0pp), %eax
87425164Speter	movl	$0, %ebx		/* pte offset = 0 */
87525164Speter	movl	$1, %ecx		/* one private page coming right up */
87646129Sluoqi	fillkpt(R(SMPptpa), $PG_RW)
87725164Speter
87826812Speter/* ... and put the page table table in the pde. */
87946129Sluoqi	movl	R(SMPptpa), %eax
88025164Speter	movl	$MPPTDI, %ebx
88125164Speter	movl	$1, %ecx
88273011Sjake	fillkpt(R(IdlePTD), $PG_RW)
88334840Sjlemon
88434840Sjlemon/* Fakeup VA for the local apic to allow early traps. */
88534840Sjlemon	ALLOCPAGES(1)
88634840Sjlemon	movl	%esi, %eax
88746129Sluoqi	movl	$(NPTEPG-1), %ebx	/* pte offset = NTEPG-1 */
88834840Sjlemon	movl	$1, %ecx		/* one private pt coming right up */
88946129Sluoqi	fillkpt(R(SMPptpa), $PG_RW)
89026812Speter#endif	/* SMP */
89125164Speter
89215392Sphk/* install a pde for temporary double map of bottom of VA */
89373011Sjake	movl	R(KPTphys), %eax
89415565Sphk	xorl	%ebx, %ebx
89574283Speter	movl	$NKPT, %ecx
89673011Sjake	fillkpt(R(IdlePTD), $PG_RW)
8974Srgrimes
89815392Sphk/* install pde's for pt's */
89973011Sjake	movl	R(KPTphys), %eax
90015565Sphk	movl	$KPTDI, %ebx
90115565Sphk	movl	$NKPT, %ecx
90273011Sjake	fillkpt(R(IdlePTD), $PG_RW)
9034Srgrimes
90415392Sphk/* install a pde recursively mapping page directory as a page table */
90573011Sjake	movl	R(IdlePTD), %eax
90615565Sphk	movl	$PTDPTDI, %ebx
90715565Sphk	movl	$1,%ecx
90873011Sjake	fillkpt(R(IdlePTD), $PG_RW)
9094Srgrimes
9104Srgrimes	ret
91115428Sphk
91215428Sphk#ifdef BDE_DEBUGGER
91315428Sphkbdb_prepare_paging:
91415428Sphk	cmpl	$0,R(_bdb_exists)
91515428Sphk	je	bdb_prepare_paging_exit
91615428Sphk
91715428Sphk	subl	$6,%esp
91815428Sphk
91915428Sphk	/*
92015428Sphk	 * Copy and convert debugger entries from the bootstrap gdt and idt
92115428Sphk	 * to the kernel gdt and idt.  Everything is still in low memory.
92215428Sphk	 * Tracing continues to work after paging is enabled because the
92315428Sphk	 * low memory addresses remain valid until everything is relocated.
92415428Sphk	 * However, tracing through the setidt() that initializes the trace
92515428Sphk	 * trap will crash.
92615428Sphk	 */
92715428Sphk	sgdt	(%esp)
92815428Sphk	movl	2(%esp),%esi		/* base address of bootstrap gdt */
92915428Sphk	movl	$R(_gdt),%edi
93015428Sphk	movl	%edi,2(%esp)		/* prepare to load kernel gdt */
93115428Sphk	movl	$8*18/4,%ecx
93215428Sphk	cld
93315428Sphk	rep				/* copy gdt */
93415428Sphk	movsl
93515428Sphk	movl	$R(_gdt),-8+2(%edi)	/* adjust gdt self-ptr */
93615428Sphk	movb	$0x92,-8+5(%edi)
93715428Sphk	lgdt	(%esp)
93815428Sphk
93915428Sphk	sidt	(%esp)
94015428Sphk	movl	2(%esp),%esi		/* base address of current idt */
94115428Sphk	movl	8+4(%esi),%eax		/* convert dbg descriptor to ... */
94215428Sphk	movw	8(%esi),%ax
94315428Sphk	movl	%eax,R(bdb_dbg_ljmp+1)	/* ... immediate offset ... */
94415428Sphk	movl	8+2(%esi),%eax
94515428Sphk	movw	%ax,R(bdb_dbg_ljmp+5)	/* ... and selector for ljmp */
94615428Sphk	movl	24+4(%esi),%eax		/* same for bpt descriptor */
94715428Sphk	movw	24(%esi),%ax
94815428Sphk	movl	%eax,R(bdb_bpt_ljmp+1)
94915428Sphk	movl	24+2(%esi),%eax
95015428Sphk	movw	%ax,R(bdb_bpt_ljmp+5)
95148005Sbde	movl	R(_idt),%edi
95215428Sphk	movl	%edi,2(%esp)		/* prepare to load kernel idt */
95315428Sphk	movl	$8*4/4,%ecx
95415428Sphk	cld
95515428Sphk	rep				/* copy idt */
95615428Sphk	movsl
95715428Sphk	lidt	(%esp)
95815428Sphk
95915428Sphk	addl	$6,%esp
96015428Sphk
96115428Sphkbdb_prepare_paging_exit:
96215428Sphk	ret
96315428Sphk
96415428Sphk/* Relocate debugger gdt entries and gdt and idt pointers. */
96515428Sphkbdb_commit_paging:
96615428Sphk	cmpl	$0,_bdb_exists
96715428Sphk	je	bdb_commit_paging_exit
96815428Sphk
96973011Sjake	movl	$gdt+8*9,%eax		/* adjust slots 9-17 */
97015428Sphk	movl	$9,%ecx
97115428Sphkreloc_gdt:
97215428Sphk	movb	$KERNBASE>>24,7(%eax)	/* top byte of base addresses, was 0, */
97315428Sphk	addl	$8,%eax			/* now KERNBASE>>24 */
97415428Sphk	loop	reloc_gdt
97515428Sphk
97615428Sphk	subl	$6,%esp
97715428Sphk	sgdt	(%esp)
97815428Sphk	addl	$KERNBASE,2(%esp)
97915428Sphk	lgdt	(%esp)
98015428Sphk	sidt	(%esp)
98115428Sphk	addl	$KERNBASE,2(%esp)
98215428Sphk	lidt	(%esp)
98315428Sphk	addl	$6,%esp
98415428Sphk
98515428Sphk	int	$3
98615428Sphk
98715428Sphkbdb_commit_paging_exit:
98815428Sphk	ret
98915428Sphk
99015428Sphk#endif /* BDE_DEBUGGER */
991