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 * Copyright 2018 Joyent, Inc. 26 */ 27 28 #ifndef _SYS_KDI_MACHIMPL_H 29 #define _SYS_KDI_MACHIMPL_H 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 63 uintptr_t (*mkdi_get_userlimit)(void); 64 65 int (*mkdi_get_cpuinfo)(uint_t *, uint_t *, uint_t *); 66 67 void (*mkdi_stop_slaves)(int, int); 68 69 void (*mkdi_start_slaves)(void); 70 71 void (*mkdi_slave_wait)(void); 72 73 void (*mkdi_memrange_add)(caddr_t, size_t); 74 75 void (*mkdi_reboot)(void); 76 } kdi_mach_t; 77 78 #define mkdi_activate kdi_mach.mkdi_activate 79 #define mkdi_deactivate kdi_mach.mkdi_deactivate 80 #define mkdi_idt_switch kdi_mach.mkdi_idt_switch 81 #define mkdi_update_drreg kdi_mach.mkdi_update_drreg 82 #define mkdi_get_userlimit kdi_mach.mkdi_get_userlimit 83 #define mkdi_get_cpuinfo kdi_mach.mkdi_get_cpuinfo 84 #define mkdi_stop_slaves kdi_mach.mkdi_stop_slaves 85 #define mkdi_start_slaves kdi_mach.mkdi_start_slaves 86 #define mkdi_slave_wait kdi_mach.mkdi_slave_wait 87 #define mkdi_memrange_add kdi_mach.mkdi_memrange_add 88 #define mkdi_reboot kdi_mach.mkdi_reboot 89 90 extern void hat_kdi_init(void); 91 92 extern ulong_t kdi_getdr0(void), kdi_getdr1(void), kdi_getdr2(void); 93 extern ulong_t kdi_getdr3(void), kdi_getdr6(void), kdi_getdr7(void); 94 extern void kdi_setdr0(ulong_t), kdi_setdr1(ulong_t), kdi_setdr2(ulong_t); 95 extern void kdi_setdr3(ulong_t), kdi_setdr6(ulong_t), kdi_setdr7(ulong_t); 96 extern ulong_t kdi_dreg_get(int); 97 extern void kdi_dreg_set(int, ulong_t); 98 extern void kdi_update_drreg(kdi_drreg_t *); 99 extern void kdi_cpu_debug_init(kdi_cpusave_t *); 100 101 extern void kdi_cpu_init(void); 102 extern void kdi_xc_others(int, void (*)(void)); 103 extern void kdi_start_slaves(void); 104 extern void kdi_slave_wait(void); 105 106 extern void kdi_idtr_set(gate_desc_t *, size_t); 107 extern void kdi_idt_write(struct gate_desc *, uint_t); 108 extern void kdi_idt_sync(void); 109 extern void kdi_idt_switch(kdi_cpusave_t *); 110 #ifdef __xpv 111 extern void kdi_idtr_write(desctbr_t *); 112 #else 113 #define kdi_idtr_write(idtr) wr_idtr(idtr) 114 #endif 115 116 extern void kdi_activate(kdi_main_t, kdi_cpusave_t *, uint_t); 117 extern void kdi_deactivate(void); 118 extern void kdi_stop_slaves(int, int); 119 extern void kdi_memrange_add(caddr_t, size_t); 120 extern void kdi_reboot(void); 121 122 #ifdef __cplusplus 123 } 124 #endif 125 126 #endif /* _SYS_KDI_MACHIMPL_H */