Home | History | Annotate | Download | only in pub
      1 
      2 /*---------------------------------------------------------------*/
      3 /*--- begin                             libvex_guest_mips32.h ---*/
      4 /*---------------------------------------------------------------*/
      5 
      6 /*
      7    This file is part of Valgrind, a dynamic binary instrumentation
      8    framework.
      9 
     10    Copyright (C) 2010-2017 RT-RK
     11       mips-valgrind (at) rt-rk.com
     12 
     13    This program is free software; you can redistribute it and/or
     14    modify it under the terms of the GNU General Public License as
     15    published by the Free Software Foundation; either version 2 of the
     16    License, or (at your option) any later version.
     17 
     18    This program is distributed in the hope that it will be useful, but
     19    WITHOUT ANY WARRANTY; without even the implied warranty of
     20    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     21    General Public License for more details.
     22 
     23    You should have received a copy of the GNU General Public License
     24    along with this program; if not, write to the Free Software
     25    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
     26    02111-1307, USA.
     27 
     28    The GNU General Public License is contained in the file COPYING.
     29 */
     30 
     31 #ifndef __LIBVEX_PUB_GUEST_MIPS32_H
     32 #define __LIBVEX_PUB_GUEST_MIPS32_H
     33 
     34 #include "libvex_basictypes.h"
     35 
     36 
     37 /*---------------------------------------------------------------*/
     38 /*--- Vex's representation of the MIPS32 CPU state.           ---*/
     39 /*---------------------------------------------------------------*/
     40 
     41 typedef
     42    struct {
     43       /*    0 */ UInt host_EvC_FAILADDR;
     44       /*    4 */ UInt host_EvC_COUNTER;
     45 
     46       /* CPU Registers */
     47       /*    8 */ UInt guest_r0;   /* Hardwired to 0. */
     48       /*   12 */ UInt guest_r1;   /* Assembler temporary */
     49       /*   16 */ UInt guest_r2;   /* Values for function returns ...*/
     50       /*   20 */ UInt guest_r3;   /* ... and expression evaluation */
     51       /*   24 */ UInt guest_r4;   /* Function arguments */
     52       /*   28 */ UInt guest_r5;
     53       /*   32 */ UInt guest_r6;
     54       /*   36 */ UInt guest_r7;
     55       /*   40 */ UInt guest_r8;   /* Temporaries */
     56       /*   44 */ UInt guest_r9;
     57       /*   48 */ UInt guest_r10;
     58       /*   52 */ UInt guest_r11;
     59       /*   56 */ UInt guest_r12;
     60       /*   60 */ UInt guest_r13;
     61       /*   64 */ UInt guest_r14;
     62       /*   68 */ UInt guest_r15;
     63       /*   72 */ UInt guest_r16;  /* Saved temporaries */
     64       /*   76 */ UInt guest_r17;
     65       /*   80 */ UInt guest_r18;
     66       /*   84 */ UInt guest_r19;
     67       /*   88 */ UInt guest_r20;
     68       /*   92 */ UInt guest_r21;
     69       /*   96 */ UInt guest_r22;
     70       /*  100 */ UInt guest_r23;
     71       /*  104 */ UInt guest_r24;  /* Temporaries */
     72       /*  108 */ UInt guest_r25;
     73       /*  112 */ UInt guest_r26;  /* Reserved for OS kernel */
     74       /*  116 */ UInt guest_r27;
     75       /*  120 */ UInt guest_r28;  /* Global pointer */
     76       /*  124 */ UInt guest_r29;  /* Stack pointer */
     77       /*  128 */ UInt guest_r30;  /* Frame pointer */
     78       /*  132 */ UInt guest_r31;  /* Return address */
     79       /*  136 */ UInt guest_PC;   /* Program counter */
     80       /*  140 */ UInt guest_HI;   /* Multiply and divide reg higher result */
     81       /*  144 */ UInt guest_LO;   /* Multiply and divide reg lower result */
     82       /*  148 */ UInt _padding1;
     83 
     84       /* FPU Registers */
     85       /*  152 */ ULong guest_f0;  /* Floating point general purpose registers */
     86       /*  160 */ ULong guest_f1;
     87       /*  168 */ ULong guest_f2;
     88       /*  176 */ ULong guest_f3;
     89       /*  184 */ ULong guest_f4;
     90       /*  192 */ ULong guest_f5;
     91       /*  200 */ ULong guest_f6;
     92       /*  208 */ ULong guest_f7;
     93       /*  216 */ ULong guest_f8;
     94       /*  224 */ ULong guest_f9;
     95       /*  232 */ ULong guest_f10;
     96       /*  240 */ ULong guest_f11;
     97       /*  248 */ ULong guest_f12;
     98       /*  256 */ ULong guest_f13;
     99       /*  264 */ ULong guest_f14;
    100       /*  272 */ ULong guest_f15;
    101       /*  280 */ ULong guest_f16;
    102       /*  288 */ ULong guest_f17;
    103       /*  296 */ ULong guest_f18;
    104       /*  304 */ ULong guest_f19;
    105       /*  312 */ ULong guest_f20;
    106       /*  320 */ ULong guest_f21;
    107       /*  328 */ ULong guest_f22;
    108       /*  336 */ ULong guest_f23;
    109       /*  344 */ ULong guest_f24;
    110       /*  352 */ ULong guest_f25;
    111       /*  360 */ ULong guest_f26;
    112       /*  368 */ ULong guest_f27;
    113       /*  376 */ ULong guest_f28;
    114       /*  384 */ ULong guest_f29;
    115       /*  392 */ ULong guest_f30;
    116       /*  400 */ ULong guest_f31;
    117 
    118       /*  408 */ UInt guest_FIR;
    119       /*  412 */ UInt guest_FCCR;
    120       /*  416 */ UInt guest_FEXR;
    121       /*  420 */ UInt guest_FENR;
    122       /*  424 */ UInt guest_FCSR;
    123 
    124       /* TLS pointer for the thread. It's read-only in user space.
    125          On Linux it is set in user space by various thread-related
    126          syscalls.
    127          User Local Register.
    128          This register provides read access to the coprocessor 0
    129          UserLocal register, if it is implemented. In some operating
    130          environments, the UserLocal register is a pointer to a
    131          thread-specific storage block.
    132       */
    133       /*  428 */ UInt guest_ULR;
    134 
    135       /* Emulation notes */
    136       /*  432 */ UInt guest_EMNOTE;
    137 
    138       /* For clflush: record start and length of area to invalidate. */
    139       /*  436 */ UInt guest_CMSTART;
    140       /*  440 */ UInt guest_CMLEN;
    141       /*  444 */ UInt guest_NRADDR;
    142 
    143       /*  448 */ UInt guest_COND;
    144 
    145       /* MIPS32 DSP ASE(r2) specific registers. */
    146       /*  452 */ UInt guest_DSPControl;
    147       /*  456 */ ULong guest_ac0;
    148       /*  464 */ ULong guest_ac1;
    149       /*  472 */ ULong guest_ac2;
    150       /*  480 */ ULong guest_ac3;
    151 
    152       /*  488 */ UInt guest_CP0_status;
    153 
    154       /*  492 */ UInt guest_LLaddr;
    155       /*  496 */ UInt guest_LLdata;
    156 
    157       /*  500 */ UInt _padding2[3];
    158 } VexGuestMIPS32State;
    159 /*---------------------------------------------------------------*/
    160 /*--- Utility functions for MIPS32 guest stuff.               ---*/
    161 /*---------------------------------------------------------------*/
    162 
    163 /* ALL THE FOLLOWING ARE VISIBLE TO LIBRARY CLIENT. */
    164 
    165 /* Initialise all guest MIPS32 state. */
    166 
    167 extern
    168 void LibVEX_GuestMIPS32_initialise ( /*OUT*/VexGuestMIPS32State* vex_state );
    169 
    170 /* FR bit of CP0_STATUS_FR register */
    171 #define MIPS_CP0_STATUS_FR (1ul << 26)
    172 
    173 #endif /* ndef __LIBVEX_PUB_GUEST_MIPS32_H */
    174 
    175 
    176 /*---------------------------------------------------------------*/
    177 /*---                                   libvex_guest_mips32.h ---*/
    178 /*---------------------------------------------------------------*/
    179