1/* libunwind - a platform-independent unwind library
2   Copyright (C) 2008 CodeSourcery
3
4This file is part of libunwind.
5
6Permission is hereby granted, free of charge, to any person obtaining
7a copy of this software and associated documentation files (the
8"Software"), to deal in the Software without restriction, including
9without limitation the rights to use, copy, modify, merge, publish,
10distribute, sublicense, and/or sell copies of the Software, and to
11permit persons to whom the Software is furnished to do so, subject to
12the following conditions:
13
14The above copyright notice and this permission notice shall be
15included in all copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */
24
25#include "unwind_i.h"
26
27/* FIXME: The following is probably unfinished and/or at least partly bogus.  */
28
29HIDDEN int
30tdep_access_reg (struct cursor *c, unw_regnum_t reg, unw_word_t *valp,
31                 int write)
32{
33  dwarf_loc_t loc = DWARF_NULL_LOC;
34
35  switch (reg)
36    {
37    case UNW_MIPS_R0:
38    case UNW_MIPS_R1:
39    case UNW_MIPS_R2:
40    case UNW_MIPS_R3:
41    case UNW_MIPS_R4:
42    case UNW_MIPS_R5:
43    case UNW_MIPS_R6:
44    case UNW_MIPS_R7:
45    case UNW_MIPS_R8:
46    case UNW_MIPS_R9:
47    case UNW_MIPS_R10:
48    case UNW_MIPS_R11:
49    case UNW_MIPS_R12:
50    case UNW_MIPS_R13:
51    case UNW_MIPS_R14:
52    case UNW_MIPS_R15:
53    case UNW_MIPS_R16:
54    case UNW_MIPS_R17:
55    case UNW_MIPS_R18:
56    case UNW_MIPS_R19:
57    case UNW_MIPS_R20:
58    case UNW_MIPS_R21:
59    case UNW_MIPS_R22:
60    case UNW_MIPS_R23:
61    case UNW_MIPS_R24:
62    case UNW_MIPS_R25:
63    case UNW_MIPS_R26:
64    case UNW_MIPS_R27:
65    case UNW_MIPS_R28:
66    case UNW_MIPS_R29:
67    case UNW_MIPS_R30:
68    case UNW_MIPS_R31:
69      loc = c->dwarf.loc[reg - UNW_MIPS_R0];
70      break;
71
72    case UNW_MIPS_PC:
73      loc = c->dwarf.loc[reg];
74      break;
75
76    case UNW_MIPS_CFA:
77      if (write)
78        return -UNW_EREADONLYREG;
79      *valp = c->dwarf.cfa;
80      return 0;
81
82    /* FIXME: IP?  Copro & shadow registers?  */
83
84    default:
85      Debug (1, "bad register number %u\n", reg);
86      return -UNW_EBADREG;
87    }
88
89  if (write)
90    return dwarf_put (&c->dwarf, loc, *valp);
91  else
92    return dwarf_get (&c->dwarf, loc, valp);
93}
94
95/* FIXME for MIPS.  */
96
97HIDDEN int
98tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, unw_fpreg_t *valp,
99                   int write)
100{
101  Debug (1, "bad register number %u\n", reg);
102  return -UNW_EBADREG;
103}
104