xref: /titanic_50/usr/src/cmd/mdb/sparc/v9/kmdb/kmdb_start.s (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License").  You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22/*
23 * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24 * Use is subject to license terms.
25 */
26
27#pragma ident	"%Z%%M%	%I%	%E% SMI"
28
29#include <sys/asm_linkage.h>
30#include <sys/privregs.h>
31
32#if defined(__lint)
33#include <kmdb/kmdb_start.h>
34#endif
35
36#include <kmdb/kaif_asmutil.h>
37
38/*
39 * This routine is called for the initial trip into the debugger.  We need
40 * to switch over to the debugger stack (which we also need to initialize)
41 * before entering the debugger.  Subsequent re-entries will longjmp their
42 * way in.
43 */
44#if defined(__lint)
45void
46kmdb_first_start(void)
47{
48}
49#else	/* __lint */
50
51	ENTRY(kmdb_first_start)
52
53	GET_NWIN(%g1, %g2);	/* %g1 is scratch, %g2 set to nwin-1 */
54	sub	%g2, 1, %g2
55
56	wrpr	%g2, %cansave
57	wrpr	%g0, %canrestore
58
59	set	kmdb_main_stack, %g1
60	ldx	[%g1], %g1
61
62	set	kmdb_main_stack_size, %g2
63	ldx	[%g2], %g2
64
65	add	%g1, %g2, %g1
66	sub	%g1, 1, %g1
67	and	%g1, -STACK_ALIGN64, %g1
68	sub	%g1, SA64(MINFRAME) + V9BIAS64, %sp
69
70	mov	0, %fp
71	save	%sp, -SA64(MINFRAME64), %sp
72
73	/* start the debugger */
74	call	kmdb_main
75	nop
76
77	SET_SIZE(kmdb_first_start)
78#endif
79
80