1 /* Copyright 2013 Google LLC 2 * 3 * Redistribution and use in source and binary forms, with or without 4 * modification, are permitted provided that the following conditions are 5 * met: 6 * 7 * * Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * * Redistributions in binary form must reproduce the above 10 * copyright notice, this list of conditions and the following disclaimer 11 * in the documentation and/or other materials provided with the 12 * distribution. 13 * * Neither the name of Google LLC nor the names of its 14 * contributors may be used to endorse or promote products derived from 15 * this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ 28 29 /* minidump_format.h: A cross-platform reimplementation of minidump-related 30 * portions of DbgHelp.h from the Windows Platform SDK. 31 * 32 * (This is C99 source, please don't corrupt it with C++.) 33 * 34 * This file contains the necessary definitions to read minidump files 35 * produced on MIPS. These files may be read on any platform provided 36 * that the alignments of these structures on the processing system are 37 * identical to the alignments of these structures on the producing system. 38 * For this reason, precise-sized types are used. The structures defined 39 * by this file have been laid out to minimize alignment problems by 40 * ensuring that all members are aligned on their natural boundaries. 41 * In some cases, tail-padding may be significant when different ABIs specify 42 * different tail-padding behaviors. To avoid problems when reading or 43 * writing affected structures, MD_*_SIZE macros are provided where needed, 44 * containing the useful size of the structures without padding. 45 * 46 * Structures that are defined by Microsoft to contain a zero-length array 47 * are instead defined here to contain an array with one element, as 48 * zero-length arrays are forbidden by standard C and C++. In these cases, 49 * *_minsize constants are provided to be used in place of sizeof. For a 50 * cleaner interface to these sizes when using C++, see minidump_size.h. 51 * 52 * These structures are also sufficient to populate minidump files. 53 * 54 * Because precise data type sizes are crucial for this implementation to 55 * function properly and portably, a set of primitive types with known sizes 56 * are used as the basis of each structure defined by this file. 57 * 58 * Author: Chris Dearman 59 */ 60 61 /* 62 * MIPS support 63 */ 64 65 #ifndef GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_MIPS_H__ 66 #define GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_MIPS_H__ 67 68 #define MD_CONTEXT_MIPS_GPR_COUNT 32 69 #define MD_FLOATINGSAVEAREA_MIPS_FPR_COUNT 32 70 #define MD_CONTEXT_MIPS_DSP_COUNT 3 71 72 /* 73 * Note that these structures *do not* map directly to the CONTEXT 74 * structure defined in WinNT.h in the Windows Mobile SDK. That structure 75 * does not accomodate VFPv3, and I'm unsure if it was ever used in the 76 * wild anyway, as Windows CE only seems to produce "cedumps" which 77 * are not exactly minidumps. 78 */ 79 typedef struct { 80 /* 32 64-bit floating point registers, f0..f31 */ 81 uint64_t regs[MD_FLOATINGSAVEAREA_MIPS_FPR_COUNT]; 82 83 uint32_t fpcsr; /* FPU status register. */ 84 uint32_t fir; /* FPU implementation register. */ 85 } MDFloatingSaveAreaMIPS; 86 87 typedef struct { 88 /* The next field determines the layout of the structure, and which parts 89 * of it are populated. 90 */ 91 uint32_t context_flags; 92 uint32_t _pad0; 93 94 /* 32 64-bit integer registers, r0..r31. 95 * Note the following fixed uses: 96 * r29 is the stack pointer. 97 * r31 is the return address. 98 */ 99 uint64_t iregs[MD_CONTEXT_MIPS_GPR_COUNT]; 100 101 /* multiply/divide result. */ 102 uint64_t mdhi, mdlo; 103 104 /* DSP accumulators. */ 105 uint32_t hi[MD_CONTEXT_MIPS_DSP_COUNT]; 106 uint32_t lo[MD_CONTEXT_MIPS_DSP_COUNT]; 107 uint32_t dsp_control; 108 uint32_t _pad1; 109 110 uint64_t epc; 111 uint64_t badvaddr; 112 uint32_t status; 113 uint32_t cause; 114 115 /* The next field is included with MD_CONTEXT_MIPS_FLOATING_POINT. */ 116 MDFloatingSaveAreaMIPS float_save; 117 118 } MDRawContextMIPS; 119 120 /* Indices into iregs for registers with a dedicated or conventional 121 * purpose. 122 */ 123 enum MDMIPSRegisterNumbers { 124 MD_CONTEXT_MIPS_REG_S0 = 16, 125 MD_CONTEXT_MIPS_REG_S1 = 17, 126 MD_CONTEXT_MIPS_REG_S2 = 18, 127 MD_CONTEXT_MIPS_REG_S3 = 19, 128 MD_CONTEXT_MIPS_REG_S4 = 20, 129 MD_CONTEXT_MIPS_REG_S5 = 21, 130 MD_CONTEXT_MIPS_REG_S6 = 22, 131 MD_CONTEXT_MIPS_REG_S7 = 23, 132 MD_CONTEXT_MIPS_REG_GP = 28, 133 MD_CONTEXT_MIPS_REG_SP = 29, 134 MD_CONTEXT_MIPS_REG_FP = 30, 135 MD_CONTEXT_MIPS_REG_RA = 31, 136 }; 137 138 /* For (MDRawContextMIPS).context_flags. These values indicate the type of 139 * context stored in the structure. */ 140 /* CONTEXT_MIPS from the Windows CE 5.0 SDK. This value isn't correct 141 * because this bit can be used for flags. Presumably this value was 142 * never actually used in minidumps, but only in "CEDumps" which 143 * are a whole parallel minidump file format for Windows CE. 144 * Therefore, Breakpad defines its own value for MIPS CPUs. 145 */ 146 #define MD_CONTEXT_MIPS 0x00040000 147 #define MD_CONTEXT_MIPS_INTEGER (MD_CONTEXT_MIPS | 0x00000002) 148 #define MD_CONTEXT_MIPS_FLOATING_POINT (MD_CONTEXT_MIPS | 0x00000004) 149 #define MD_CONTEXT_MIPS_DSP (MD_CONTEXT_MIPS | 0x00000008) 150 151 #define MD_CONTEXT_MIPS_FULL (MD_CONTEXT_MIPS_INTEGER | \ 152 MD_CONTEXT_MIPS_FLOATING_POINT | \ 153 MD_CONTEXT_MIPS_DSP) 154 155 #define MD_CONTEXT_MIPS_ALL (MD_CONTEXT_MIPS_INTEGER | \ 156 MD_CONTEXT_MIPS_FLOATING_POINT \ 157 MD_CONTEXT_MIPS_DSP) 158 159 /** 160 * Breakpad defines for MIPS64 161 */ 162 #define MD_CONTEXT_MIPS64 0x00080000 163 #define MD_CONTEXT_MIPS64_INTEGER (MD_CONTEXT_MIPS64 | 0x00000002) 164 #define MD_CONTEXT_MIPS64_FLOATING_POINT (MD_CONTEXT_MIPS64 | 0x00000004) 165 #define MD_CONTEXT_MIPS64_DSP (MD_CONTEXT_MIPS64 | 0x00000008) 166 167 #define MD_CONTEXT_MIPS64_FULL (MD_CONTEXT_MIPS64_INTEGER | \ 168 MD_CONTEXT_MIPS64_FLOATING_POINT | \ 169 MD_CONTEXT_MIPS64_DSP) 170 171 #define MD_CONTEXT_MIPS64_ALL (MD_CONTEXT_MIPS64_INTEGER | \ 172 MD_CONTEXT_MIPS64_FLOATING_POINT \ 173 MD_CONTEXT_MIPS64_DSP) 174 175 #endif // GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_MIPS_H__ 176