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.
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.
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]
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
25 * Copyright 2018 Joyent, Inc.
28 #ifndef _SYS_KDI_REGS_H
29 #define _SYS_KDI_REGS_H
32 #include <sys/types.h>
33 #include <sys/segments.h>
34 #include <sys/regset.h>
35 #include <sys/privregs.h>
39 #include <amd64/sys/kdi_regs.h>
41 #include <ia32/sys/kdi_regs.h>
50 #define KDI_CPU_STATE_NONE 0
51 #define KDI_CPU_STATE_MASTER 1
52 #define KDI_CPU_STATE_SLAVE 2
54 #define KDIREG_DRCTL_WPALLEN_MASK 0x000000ff
55 #define KDIREG_DRSTAT_RESERVED 0xffff0ff0
56 #define KDIREG_DRCTL_RESERVED 0x00000700
61 * We maintain a ring buffer of bread crumbs for debugging purposes. The
62 * current buffer pointer is advanced along the ring with each intercepted
63 * trap (debugger entry, invalid memory access, fault during step, etc).
65 typedef struct kdi_crumb
{
66 greg_t krm_cpu_state
; /* This CPU's state at last entry */
67 greg_t krm_pc
; /* Instruction pointer at trap */
68 greg_t krm_sp
; /* Stack pointer at trap */
69 greg_t krm_trapno
; /* The last trap number */
70 greg_t krm_flag
; /* KAIF_CRUMB_F_* */
73 #define KDI_MAXWPIDX 3
76 * Storage for %dr0-3, %dr6, and %dr7.
78 typedef struct kdi_drreg
{
81 greg_t dr_addr
[KDI_MAXWPIDX
+ 1];
85 * Data structure used to hold all of the state for a given CPU.
87 typedef struct kdi_cpusave
{
88 greg_t
*krs_gregs
; /* saved registers */
90 kdi_drreg_t krs_dr
; /* saved debug registers */
92 user_desc_t
*krs_gdt
; /* GDT address */
93 gate_desc_t
*krs_idt
; /* IDT address */
95 greg_t krs_cr0
; /* saved %cr0 */
97 uint_t krs_cpu_state
; /* KDI_CPU_STATE_* mstr/slv */
98 uint_t krs_cpu_flushed
; /* Have caches been flushed? */
99 uint_t krs_cpu_id
; /* this CPU's ID */
101 /* Bread crumb ring buffer */
102 ulong_t krs_curcrumbidx
; /* Current krs_crumbs idx */
103 kdi_crumb_t
*krs_curcrumb
; /* Pointer to current crumb */
104 kdi_crumb_t krs_crumbs
[KDI_NCRUMBS
]; /* Crumbs */
113 #endif /* _SYS_KDI_REGS_H */