xref: /titanic_50/usr/src/uts/intel/sys/kdi_machimpl.h (revision 843e19887f64dde75055cf8842fc4db2171eff45)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5ae115bc7Smrj  * Common Development and Distribution License (the "License").
6ae115bc7Smrj  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22ae115bc7Smrj  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef _SYS_KDI_MACHIMPL_H
277c478bd9Sstevel@tonic-gate #define	_SYS_KDI_MACHIMPL_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate /*
327c478bd9Sstevel@tonic-gate  * The Kernel/Debugger interface.  The operations provided by the kdi_t,
337c478bd9Sstevel@tonic-gate  * defined below, comprise the Debugger -> Kernel portion of the interface,
347c478bd9Sstevel@tonic-gate  * and are to be used only when the system has been stopped.
357c478bd9Sstevel@tonic-gate  */
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #include <sys/modctl.h>
387c478bd9Sstevel@tonic-gate #include <sys/types.h>
39ae115bc7Smrj #include <sys/cpuvar.h>
40ae115bc7Smrj #include <sys/kdi_regs.h>
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate #ifdef __cplusplus
437c478bd9Sstevel@tonic-gate extern "C" {
447c478bd9Sstevel@tonic-gate #endif
457c478bd9Sstevel@tonic-gate 
46ae115bc7Smrj typedef void (*kdi_main_t)(kdi_cpusave_t *);
477c478bd9Sstevel@tonic-gate 
48ae115bc7Smrj typedef struct kdi_memrange {
49ae115bc7Smrj 	caddr_t mr_base;
50ae115bc7Smrj 	caddr_t mr_lim;
51ae115bc7Smrj } kdi_memrange_t;
52ae115bc7Smrj 
53ae115bc7Smrj #define	KDI_MEMRANGES_MAX	2
54ae115bc7Smrj 
55ae115bc7Smrj typedef struct kdi_mach {
56ae115bc7Smrj 	void (*mkdi_activate)(kdi_main_t, kdi_cpusave_t *, uint_t);
57ae115bc7Smrj 	void (*mkdi_deactivate)(void);
58ae115bc7Smrj 
59ae115bc7Smrj 	void (*mkdi_idt_switch)(kdi_cpusave_t *);
60ae115bc7Smrj 
61ae115bc7Smrj 	void (*mkdi_update_drreg)(kdi_drreg_t *);
62ae115bc7Smrj 	void (*mkdi_set_debug_msrs)(kdi_msr_t *);
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate 	uintptr_t (*mkdi_get_userlimit)(void);
657c478bd9Sstevel@tonic-gate 
66ae115bc7Smrj 	int (*mkdi_get_cpuinfo)(uint_t *, uint_t *, uint_t *);
677c478bd9Sstevel@tonic-gate 
68ae115bc7Smrj 	void (*mkdi_stop_slaves)(int, int);
697c478bd9Sstevel@tonic-gate 
70ae115bc7Smrj 	void (*mkdi_start_slaves)(void);
717c478bd9Sstevel@tonic-gate 
72ae115bc7Smrj 	void (*mkdi_slave_wait)(void);
73ae115bc7Smrj 
74ae115bc7Smrj 	void (*mkdi_memrange_add)(caddr_t, size_t);
75ae115bc7Smrj 
76ae115bc7Smrj 	void (*mkdi_reboot)(void);
777c478bd9Sstevel@tonic-gate } kdi_mach_t;
787c478bd9Sstevel@tonic-gate 
79ae115bc7Smrj #define	mkdi_activate			kdi_mach.mkdi_activate
80ae115bc7Smrj #define	mkdi_deactivate			kdi_mach.mkdi_deactivate
81ae115bc7Smrj #define	mkdi_idt_switch			kdi_mach.mkdi_idt_switch
82ae115bc7Smrj #define	mkdi_update_drreg		kdi_mach.mkdi_update_drreg
83ae115bc7Smrj #define	mkdi_set_debug_msrs		kdi_mach.mkdi_set_debug_msrs
847c478bd9Sstevel@tonic-gate #define	mkdi_get_userlimit		kdi_mach.mkdi_get_userlimit
85ae115bc7Smrj #define	mkdi_get_cpuinfo		kdi_mach.mkdi_get_cpuinfo
86ae115bc7Smrj #define	mkdi_stop_slaves		kdi_mach.mkdi_stop_slaves
87ae115bc7Smrj #define	mkdi_start_slaves		kdi_mach.mkdi_start_slaves
88ae115bc7Smrj #define	mkdi_slave_wait			kdi_mach.mkdi_slave_wait
89ae115bc7Smrj #define	mkdi_memrange_add		kdi_mach.mkdi_memrange_add
90ae115bc7Smrj #define	mkdi_reboot			kdi_mach.mkdi_reboot
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate extern void hat_kdi_init(void);
937c478bd9Sstevel@tonic-gate 
94ae115bc7Smrj extern ulong_t kdi_getdr0(void), kdi_getdr1(void), kdi_getdr2(void);
95ae115bc7Smrj extern ulong_t kdi_getdr3(void), kdi_getdr6(void), kdi_getdr7(void);
96ae115bc7Smrj extern void kdi_setdr0(ulong_t), kdi_setdr1(ulong_t), kdi_setdr2(ulong_t);
97ae115bc7Smrj extern void kdi_setdr3(ulong_t), kdi_setdr6(ulong_t), kdi_setdr7(ulong_t);
98ae115bc7Smrj extern ulong_t kdi_dreg_get(int);
99ae115bc7Smrj extern void kdi_dreg_set(int, ulong_t);
100ae115bc7Smrj extern void kdi_update_drreg(kdi_drreg_t *);
101ae115bc7Smrj extern void kdi_set_debug_msrs(kdi_msr_t *);
102ae115bc7Smrj extern void kdi_cpu_debug_init(kdi_cpusave_t *);
103ae115bc7Smrj 
104ae115bc7Smrj extern void kdi_cpu_init(void);
105ae115bc7Smrj extern void kdi_xc_others(int, void (*)(void));
106ae115bc7Smrj extern void kdi_start_slaves(void);
107ae115bc7Smrj extern void kdi_slave_wait(void);
108ae115bc7Smrj 
109ae115bc7Smrj extern void kdi_idtr_set(gate_desc_t *, size_t);
110ae115bc7Smrj extern void kdi_idt_write(struct gate_desc *, uint_t);
111ae115bc7Smrj extern void kdi_idt_sync(void);
112ae115bc7Smrj extern void kdi_idt_switch(kdi_cpusave_t *);
113*843e1988Sjohnlev #ifdef __xpv
114*843e1988Sjohnlev extern void kdi_idtr_write(desctbr_t *);
115*843e1988Sjohnlev #else
116ae115bc7Smrj #define	kdi_idtr_write(idtr) wr_idtr(idtr)
117*843e1988Sjohnlev #endif
118ae115bc7Smrj 
119ae115bc7Smrj extern void kdi_activate(kdi_main_t, kdi_cpusave_t *, uint_t);
120ae115bc7Smrj extern void kdi_deactivate(void);
121ae115bc7Smrj extern void kdi_stop_slaves(int, int);
122ae115bc7Smrj extern void kdi_memrange_add(caddr_t, size_t);
123ae115bc7Smrj extern void kdi_reboot(void);
1247c478bd9Sstevel@tonic-gate 
1257c478bd9Sstevel@tonic-gate #ifdef __cplusplus
1267c478bd9Sstevel@tonic-gate }
1277c478bd9Sstevel@tonic-gate #endif
1287c478bd9Sstevel@tonic-gate 
1297c478bd9Sstevel@tonic-gate #endif /* _SYS_KDI_MACHIMPL_H */
130