xref: /titanic_50/usr/src/cmd/mdb/intel/kmdb/kaif.h (revision c77a61a72b5ecdc507d6cf104142edd371a16c84)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _KAIF_H
27 #define	_KAIF_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifndef _ASM
32 #include <sys/kdi.h>
33 #include <sys/types.h>
34 #include <sys/segments.h>
35 #include <kmdb/kaif_regs.h>
36 #endif
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 #define	KAIF_MASTER_CPUID_UNSET		-1
43 
44 #define	KAIF_CPU_CMD_RESUME		0
45 #define	KAIF_CPU_CMD_RESUME_MASTER	1
46 #define	KAIF_CPU_CMD_SWITCH		2
47 #define	KAIF_CPU_CMD_PASS_TO_KERNEL	3
48 #define	KAIF_CPU_CMD_REBOOT		4
49 
50 #define	KAIF_CPU_STATE_NONE		0
51 #define	KAIF_CPU_STATE_MASTER		1
52 #define	KAIF_CPU_STATE_SLAVE		2
53 
54 #ifndef _ASM
55 
56 typedef struct kaif_memrange {
57 	caddr_t mr_base;
58 	caddr_t mr_lim;
59 } kaif_memrange_t;
60 
61 extern kaif_memrange_t kaif_memranges[];
62 extern int kaif_nmemranges;
63 
64 extern kaif_cpusave_t *kaif_cpusave;
65 extern int kaif_ncpusave;
66 extern int kaif_master_cpuid;
67 
68 extern uint32_t kaif_cs;
69 extern uint32_t	kaif_ds;
70 extern uint32_t	kaif_fs;
71 extern uint32_t	kaif_gs;
72 
73 extern char kaif_slave_entry_patch;
74 
75 extern struct gate_desc kaif_idt[];
76 extern desctbr_t kaif_idtr;
77 extern size_t kaif_ivct_size;
78 extern int kaif_trap_switch;
79 
80 extern uintptr_t kaif_kernel_handler;
81 extern uintptr_t kaif_sys_sysenter;
82 extern uintptr_t kaif_brand_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