xref: /titanic_50/usr/src/cmd/mdb/intel/kmdb/kaif.h (revision 03831d35f7499c87d51205817c93e9a8d42c4bae)
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 #ifndef _KAIF_H
28 #define	_KAIF_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifndef _ASM
33 #include <sys/kdi.h>
34 #include <sys/types.h>
35 #include <sys/segments.h>
36 #include <kmdb/kaif_regs.h>
37 #endif
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 #define	KAIF_MASTER_CPUID_UNSET		-1
44 
45 #define	KAIF_CPU_CMD_RESUME		0
46 #define	KAIF_CPU_CMD_RESUME_MASTER	1
47 #define	KAIF_CPU_CMD_SWITCH		2
48 #define	KAIF_CPU_CMD_PASS_TO_KERNEL	3
49 #define	KAIF_CPU_CMD_REBOOT		4
50 
51 #define	KAIF_CPU_STATE_NONE		0
52 #define	KAIF_CPU_STATE_MASTER		1
53 #define	KAIF_CPU_STATE_SLAVE		2
54 
55 #ifndef _ASM
56 
57 typedef struct kaif_memrange {
58 	caddr_t mr_base;
59 	caddr_t mr_lim;
60 } kaif_memrange_t;
61 
62 extern kaif_memrange_t kaif_memranges[];
63 extern int kaif_nmemranges;
64 
65 extern kaif_cpusave_t *kaif_cpusave;
66 extern int kaif_ncpusave;
67 extern int kaif_master_cpuid;
68 
69 extern uint32_t kaif_cs;
70 extern uint32_t	kaif_ds;
71 extern uint32_t	kaif_fs;
72 extern uint32_t	kaif_gs;
73 
74 extern char kaif_slave_entry_patch;
75 
76 extern struct gate_desc kaif_idt[];
77 extern desctbr_t kaif_idtr;
78 extern size_t kaif_ivct_size;
79 extern int kaif_trap_switch;
80 
81 extern uintptr_t kaif_kernel_handler;
82 extern uintptr_t kaif_sys_sysenter;
83 
84 extern void kaif_trap_set_debugger(void);
85 extern void kaif_trap_set_saved(kaif_cpusave_t *);
86 
87 extern uintptr_t kaif_invoke(uintptr_t, uint_t, const uintptr_t[]);
88 
89 extern void kaif_nmiint(void);
90 extern void kaif_cmnint(void);
91 extern void kaif_enter(void);
92 extern void kaif_slave_entry(void);
93 extern int kaif_debugger_entry(kaif_cpusave_t *);
94 
95 extern void kaif_mod_loaded(struct modctl *);
96 extern void kaif_mod_unloading(struct modctl *);
97 
98 extern void kaif_cpu_debug_init(kaif_cpusave_t *);
99 
100 extern void kaif_idt_init(void);
101 extern void kaif_idt_write(gate_desc_t *, uint_t);
102 extern void kaif_idt_patch(caddr_t, size_t);
103 extern uintptr_t kaif_kernel_trap2hdlr(int);
104 
105 extern void kaif_activate(kdi_debugvec_t **, uint_t);
106 extern void kaif_deactivate(void);
107 
108 extern int kaif_memrange_add(caddr_t, size_t);
109 
110 extern void get_idt(desctbr_t *);
111 extern void set_idt(desctbr_t *);
112 
113 #endif
114 
115 #ifdef __cplusplus
116 }
117 #endif
118 
119 #endif /* _KAIF_H */
120