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