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 2007 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _SYS_KDI_MACHIMPL_H 27 #define _SYS_KDI_MACHIMPL_H 28 29 #pragma ident "%Z%%M% %I% %E% SMI" 30 31 /* 32 * The Kernel/Debugger interface. The operations provided by the kdi_t, 33 * defined below, comprise the Debugger -> Kernel portion of the interface, 34 * and are to be used only when the system has been stopped. 35 */ 36 37 #include <sys/modctl.h> 38 #include <sys/types.h> 39 #include <sys/cpuvar.h> 40 #include <sys/kdi_regs.h> 41 42 #ifdef __cplusplus 43 extern "C" { 44 #endif 45 46 typedef void (*kdi_main_t)(kdi_cpusave_t *); 47 48 typedef struct kdi_memrange { 49 caddr_t mr_base; 50 caddr_t mr_lim; 51 } kdi_memrange_t; 52 53 #define KDI_MEMRANGES_MAX 2 54 55 typedef struct kdi_mach { 56 void (*mkdi_activate)(kdi_main_t, kdi_cpusave_t *, uint_t); 57 void (*mkdi_deactivate)(void); 58 59 void (*mkdi_idt_switch)(kdi_cpusave_t *); 60 61 void (*mkdi_update_drreg)(kdi_drreg_t *); 62 void (*mkdi_set_debug_msrs)(kdi_msr_t *); 63 64 uintptr_t (*mkdi_get_userlimit)(void); 65 66 int (*mkdi_get_cpuinfo)(uint_t *, uint_t *, uint_t *); 67 68 void (*mkdi_stop_slaves)(int, int); 69 70 void (*mkdi_start_slaves)(void); 71 72 void (*mkdi_slave_wait)(void); 73 74 void (*mkdi_memrange_add)(caddr_t, size_t); 75 76 void (*mkdi_reboot)(void); 77 } kdi_mach_t; 78 79 #define mkdi_activate kdi_mach.mkdi_activate 80 #define mkdi_deactivate kdi_mach.mkdi_deactivate 81 #define mkdi_idt_switch kdi_mach.mkdi_idt_switch 82 #define mkdi_update_drreg kdi_mach.mkdi_update_drreg 83 #define mkdi_set_debug_msrs kdi_mach.mkdi_set_debug_msrs 84 #define mkdi_get_userlimit kdi_mach.mkdi_get_userlimit 85 #define mkdi_get_cpuinfo kdi_mach.mkdi_get_cpuinfo 86 #define mkdi_stop_slaves kdi_mach.mkdi_stop_slaves 87 #define mkdi_start_slaves kdi_mach.mkdi_start_slaves 88 #define mkdi_slave_wait kdi_mach.mkdi_slave_wait 89 #define mkdi_memrange_add kdi_mach.mkdi_memrange_add 90 #define mkdi_reboot kdi_mach.mkdi_reboot 91 92 extern void hat_kdi_init(void); 93 94 extern ulong_t kdi_getdr0(void), kdi_getdr1(void), kdi_getdr2(void); 95 extern ulong_t kdi_getdr3(void), kdi_getdr6(void), kdi_getdr7(void); 96 extern void kdi_setdr0(ulong_t), kdi_setdr1(ulong_t), kdi_setdr2(ulong_t); 97 extern void kdi_setdr3(ulong_t), kdi_setdr6(ulong_t), kdi_setdr7(ulong_t); 98 extern ulong_t kdi_dreg_get(int); 99 extern void kdi_dreg_set(int, ulong_t); 100 extern void kdi_update_drreg(kdi_drreg_t *); 101 extern void kdi_set_debug_msrs(kdi_msr_t *); 102 extern void kdi_cpu_debug_init(kdi_cpusave_t *); 103 104 extern void kdi_cpu_init(void); 105 extern void kdi_xc_others(int, void (*)(void)); 106 extern void kdi_start_slaves(void); 107 extern void kdi_slave_wait(void); 108 109 extern void kdi_idtr_set(gate_desc_t *, size_t); 110 extern void kdi_idt_write(struct gate_desc *, uint_t); 111 extern void kdi_idt_sync(void); 112 extern void kdi_idt_switch(kdi_cpusave_t *); 113 #ifdef __xpv 114 extern void kdi_idtr_write(desctbr_t *); 115 #else 116 #define kdi_idtr_write(idtr) wr_idtr(idtr) 117 #endif 118 119 extern void kdi_activate(kdi_main_t, kdi_cpusave_t *, uint_t); 120 extern void kdi_deactivate(void); 121 extern void kdi_stop_slaves(int, int); 122 extern void kdi_memrange_add(caddr_t, size_t); 123 extern void kdi_reboot(void); 124 125 #ifdef __cplusplus 126 } 127 #endif 128 129 #endif /* _SYS_KDI_MACHIMPL_H */