1/* Copyright (c) 2006, Google Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 *     * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *     * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 *     * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29
30/* minidump_format.h: A cross-platform reimplementation of minidump-related
31 * portions of DbgHelp.h from the Windows Platform SDK.
32 *
33 * (This is C99 source, please don't corrupt it with C++.)
34 *
35 * This file contains the necessary definitions to read minidump files
36 * produced on sparc.  These files may be read on any platform provided
37 * that the alignments of these structures on the processing system are
38 * identical to the alignments of these structures on the producing system.
39 * For this reason, precise-sized types are used.  The structures defined
40 * by this file have been laid out to minimize alignment problems by ensuring
41 * ensuring that all members are aligned on their natural boundaries.  In
42 * In some cases, tail-padding may be significant when different ABIs specify
43 * different tail-padding behaviors.  To avoid problems when reading or
44 * writing affected structures, MD_*_SIZE macros are provided where needed,
45 * containing the useful size of the structures without padding.
46 *
47 * Structures that are defined by Microsoft to contain a zero-length array
48 * are instead defined here to contain an array with one element, as
49 * zero-length arrays are forbidden by standard C and C++.  In these cases,
50 * *_minsize constants are provided to be used in place of sizeof.  For a
51 * cleaner interface to these sizes when using C++, see minidump_size.h.
52 *
53 * These structures are also sufficient to populate minidump files.
54 *
55 * These definitions may be extended to support handling minidump files
56 * for other CPUs and other operating systems.
57 *
58 * Because precise data type sizes are crucial for this implementation to
59 * function properly and portably in terms of interoperability with minidumps
60 * produced by DbgHelp on Windows, a set of primitive types with known sizes
61 * are used as the basis of each structure defined by this file.  DbgHelp
62 * on Windows is assumed to be the reference implementation; this file
63 * seeks to provide a cross-platform compatible implementation.  To avoid
64 * collisions with the types and values defined and used by DbgHelp in the
65 * event that this implementation is used on Windows, each type and value
66 * defined here is given a new name, beginning with "MD".  Names of the
67 * equivalent types and values in the Windows Platform SDK are given in
68 * comments.
69 *
70 * Author: Mark Mentovai
71 * Change to split into its own file: Neal Sidhwaney */
72
73/*
74 * SPARC support, see (solaris)sys/procfs_isa.h also
75 */
76
77#ifndef GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_SPARC_H__
78#define GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_SPARC_H__
79
80#define MD_FLOATINGSAVEAREA_SPARC_FPR_COUNT 32
81
82typedef struct {
83
84  /* FPU floating point regs */
85  uint64_t      regs[MD_FLOATINGSAVEAREA_SPARC_FPR_COUNT];
86
87  uint64_t      filler;
88  uint64_t      fsr;        /* FPU status register */
89} MDFloatingSaveAreaSPARC;  /* FLOATING_SAVE_AREA */
90
91#define MD_CONTEXT_SPARC_GPR_COUNT 32
92
93typedef struct {
94  /* The next field determines the layout of the structure, and which parts
95   * of it are populated
96   */
97  uint32_t      context_flags;
98  uint32_t      flag_pad;
99  /*
100   * General register access (SPARC).
101   * Don't confuse definitions here with definitions in <sys/regset.h>.
102   * Registers are 32 bits for ILP32, 64 bits for LP64.
103   * SPARC V7/V8 is for 32bit, SPARC V9 is for 64bit
104   */
105
106  /* 32 Integer working registers */
107
108  /* g_r[0-7]   global registers(g0-g7)
109   * g_r[8-15]  out registers(o0-o7)
110   * g_r[16-23] local registers(l0-l7)
111   * g_r[24-31] in registers(i0-i7)
112   */
113  uint64_t     g_r[MD_CONTEXT_SPARC_GPR_COUNT];
114
115  /* several control registers */
116
117  /* Processor State register(PSR) for SPARC V7/V8
118   * Condition Code register (CCR) for SPARC V9
119   */
120  uint64_t     ccr;
121
122  uint64_t     pc;     /* Program Counter register (PC) */
123  uint64_t     npc;    /* Next Program Counter register (nPC) */
124  uint64_t     y;      /* Y register (Y) */
125
126  /* Address Space Identifier register (ASI) for SPARC V9
127   * WIM for SPARC V7/V8
128   */
129  uint64_t     asi;
130
131  /* Floating-Point Registers State register (FPRS) for SPARC V9
132   * TBR for for SPARC V7/V8
133   */
134  uint64_t     fprs;
135
136  /* The next field is included with MD_CONTEXT_SPARC_FLOATING_POINT */
137  MDFloatingSaveAreaSPARC float_save;
138
139} MDRawContextSPARC;  /* CONTEXT_SPARC */
140
141/* For (MDRawContextSPARC).context_flags.  These values indicate the type of
142 * context stored in the structure.  MD_CONTEXT_SPARC is Breakpad-defined.  Its
143 * value was chosen to avoid likely conflicts with MD_CONTEXT_* for other
144 * CPUs. */
145#define MD_CONTEXT_SPARC                 0x10000000
146#define MD_CONTEXT_SPARC_CONTROL         (MD_CONTEXT_SPARC | 0x00000001)
147#define MD_CONTEXT_SPARC_INTEGER         (MD_CONTEXT_SPARC | 0x00000002)
148#define MD_CONTEXT_SAPARC_FLOATING_POINT (MD_CONTEXT_SPARC | 0x00000004)
149#define MD_CONTEXT_SAPARC_EXTRA          (MD_CONTEXT_SPARC | 0x00000008)
150
151#define MD_CONTEXT_SPARC_FULL            (MD_CONTEXT_SPARC_CONTROL | \
152                                          MD_CONTEXT_SPARC_INTEGER)
153
154#define MD_CONTEXT_SPARC_ALL             (MD_CONTEXT_SPARC_FULL | \
155                                          MD_CONTEXT_SAPARC_FLOATING_POINT | \
156                                          MD_CONTEXT_SAPARC_EXTRA)
157
158#endif /* GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_SPARC_H__ */
159