• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* PowerPC specific core note handling.
2    Copyright (C) 2007 Red Hat, Inc.
3    This file is part of elfutils.
4 
5    This file is free software; you can redistribute it and/or modify
6    it under the terms of either
7 
8      * the GNU Lesser General Public License as published by the Free
9        Software Foundation; either version 3 of the License, or (at
10        your option) any later version
11 
12    or
13 
14      * the GNU General Public License as published by the Free
15        Software Foundation; either version 2 of the License, or (at
16        your option) any later version
17 
18    or both in parallel, as here.
19 
20    elfutils is distributed in the hope that it will be useful, but
21    WITHOUT ANY WARRANTY; without even the implied warranty of
22    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23    General Public License for more details.
24 
25    You should have received copies of the GNU General Public License and
26    the GNU Lesser General Public License along with this program.  If
27    not, see <http://www.gnu.org/licenses/>.  */
28 
29 #ifdef HAVE_CONFIG_H
30 # include <config.h>
31 #endif
32 
33 #include <elf.h>
34 #include <inttypes.h>
35 #include <stddef.h>
36 #include <stdio.h>
37 #include <sys/time.h>
38 
39 #ifndef BITS
40 # define BITS 		32
41 # define BACKEND	sparc_
42 #else
43 # define BITS 		64
44 # define BACKEND	sparc64_
45 #endif
46 #include "libebl_CPU.h"
47 
48 #define GR(at, n, dwreg)						\
49     { .offset = at * BITS/8, .regno = dwreg, .count = n, .bits = BITS }
50 
51 static const Ebl_Register_Location prstatus_regs[] =
52   {
53     GR (0, 32, 0),		/* %g0-%g7, %o0-%o7, %i0-%i7 */
54 #if BITS == 32
55     GR (32, 1, 65),		/* %psr */
56     GR (33, 2, 68),		/* %pc, %npc */
57     GR (35, 1, 64),		/* %y */
58     GR (36, 1, 66),		/* %wim, %tbr */
59 #else
60     GR (32, 1, 82),		/* %state */
61     GR (33, 2, 80),		/* %pc, %npc */
62     GR (35, 1, 85),		/* %y */
63 #endif
64   };
65 #define PRSTATUS_REGS_SIZE	(BITS / 8 * (32 + (BITS == 32 ? 6 : 4)))
66 
67 static const Ebl_Register_Location fpregset_regs[] =
68   {
69 #if BITS == 32
70     GR (0, 32, 32),		/* %f0-%f31 */
71     /* 				   padding word */
72     GR (33, 1, 70),		/* %fsr */
73     /* 	       			   qcnt, q_entrysize, en, q, padding */
74 # define FPREGSET_SIZE		(34 * 4 + 4 + 64 * 4 + 4)
75 #else
76     GR (0, 32, 32),		/* %f0-%f31 */
77     GR (32, 1, 83),		/* %fsr */
78     /*  33, 1, 			   %gsr */
79     GR (34, 1, 84),		/* %fprs */
80 # define FPREGSET_SIZE		(35 * 8)
81 #endif
82   };
83 
84 #if BITS == 32
85 # define ULONG			uint32_t
86 # define ALIGN_ULONG		4
87 # define TYPE_ULONG		ELF_T_WORD
88 # define TYPE_LONG		ELF_T_SWORD
89 # define UID_T			uint16_t
90 # define GID_T			uint16_t
91 # define ALIGN_UID_T		2
92 # define ALIGN_GID_T		2
93 # define TYPE_UID_T		ELF_T_HALF
94 # define TYPE_GID_T		ELF_T_HALF
95 #else
96 # define ULONG			uint64_t
97 # define ALIGN_ULONG		8
98 # define TYPE_ULONG		ELF_T_XWORD
99 # define TYPE_LONG		ELF_T_SXWORD
100 # define UID_T			uint32_t
101 # define GID_T			uint32_t
102 # define ALIGN_UID_T		4
103 # define ALIGN_GID_T		4
104 # define TYPE_UID_T		ELF_T_WORD
105 # define TYPE_GID_T		ELF_T_WORD
106 # define SUSECONDS_HALF		1
107 #endif
108 #define PID_T			int32_t
109 #define ALIGN_PID_T		4
110 #define TYPE_PID_T		ELF_T_SWORD
111 
112 #include "linux-core-note.c"
113