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