Home | History | Annotate | Download | only in backends
      1 /* PowerPC specific core note handling.
      2    Copyright (C) 2007, 2008 Red Hat, Inc.
      3    This file is part of Red Hat elfutils.
      4 
      5    Red Hat elfutils is free software; you can redistribute it and/or modify
      6    it under the terms of the GNU General Public License as published by the
      7    Free Software Foundation; version 2 of the License.
      8 
      9    Red Hat elfutils is distributed in the hope that it will be useful, but
     10    WITHOUT ANY WARRANTY; without even the implied warranty of
     11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     12    General Public License for more details.
     13 
     14    You should have received a copy of the GNU General Public License along
     15    with Red Hat elfutils; if not, write to the Free Software Foundation,
     16    Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
     17 
     18    Red Hat elfutils is an included package of the Open Invention Network.
     19    An included package of the Open Invention Network is a package for which
     20    Open Invention Network licensees cross-license their patents.  No patent
     21    license is granted, either expressly or impliedly, by designation as an
     22    included package.  Should you wish to participate in the Open Invention
     23    Network licensing program, please visit www.openinventionnetwork.com
     24    <http://www.openinventionnetwork.com>.  */
     25 
     26 #ifdef HAVE_CONFIG_H
     27 # include <config.h>
     28 #endif
     29 
     30 #include <elf.h>
     31 #include <inttypes.h>
     32 #include <stddef.h>
     33 #include <stdio.h>
     34 #include <sys/time.h>
     35 
     36 #ifndef BITS
     37 # define BITS 		32
     38 # define BACKEND	ppc_
     39 #else
     40 # define BITS 		64
     41 # define BACKEND	ppc64_
     42 #endif
     43 #include "libebl_CPU.h"
     44 
     45 static const Ebl_Register_Location prstatus_regs[] =
     46   {
     47 #define GR(at, n, dwreg)						\
     48     { .offset = at * BITS/8, .regno = dwreg, .count = n, .bits = BITS }
     49 
     50     GR (0, 32, 0),		/* r0-r31 */
     51     /*	32, 1,			   nip */
     52     GR (33, 1, 66),		/* msr */
     53     /*	34, 1,			   orig_gpr3 */
     54     GR (35, 1, 109),		/* ctr */
     55     GR (36, 1, 108),		/* lr */
     56     GR (37, 1, 101),		/* xer */
     57     GR (38, 1, 64),		/* cr */
     58     GR (39, 1, 100),		/* mq */
     59     /*  40, 1,			   trap */
     60     GR (41, 1, 119),		/* dar */
     61     GR (42, 1, 118),		/* dsisr */
     62 
     63 #undef	GR
     64   };
     65 #define PRSTATUS_REGS_SIZE	(BITS / 8 * 48)
     66 
     67 static const Ebl_Register_Location fpregset_regs[] =
     68   {
     69     { .offset = 0, .regno = 32, .count = 32, .bits = 64 }, /* f0-f31 */
     70     { .offset = 32 * 8 + 4, .regno = 65, .count = 1, .bits = 32 } /* fpscr */
     71   };
     72 #define FPREGSET_SIZE		(33 * 8)
     73 
     74 static const Ebl_Register_Location altivec_regs[] =
     75   {
     76     /* vr0-vr31 */
     77     { .offset = 0, .regno = 1124, .count = 32, .bits = 128 },
     78     /* vscr XXX 67 is an unofficial assignment */
     79     { .offset = 32 * 16, .regno = 67, .count = 1, .bits = 32, .pad = 12 },
     80     /* vrsave */
     81     { .offset = 33 * 16, .regno = 356, .count = 1, .bits = 32, .pad = 12 }
     82   };
     83 
     84 static const Ebl_Register_Location spe_regs[] =
     85   {
     86     /* evr0-evr31
     87     { .offset = 0, .regno = ???, .count = 32, .bits = 32 },
     88      * acc *
     89     { .offset = 32 * 4, .regno = ???, .count = 1, .bits = 64 }, */
     90     /* spefscr */
     91     { .offset = 34 * 4, .regno = 612, .count = 1, .bits = 32 }
     92   };
     93 
     94 #define EXTRA_NOTES \
     95   EXTRA_REGSET (NT_PPC_VMX, 34 * 16, altivec_regs) \
     96   EXTRA_REGSET (NT_PPC_SPE, 35 * 4, spe_regs)
     97 
     98 #if BITS == 32
     99 # define ULONG			uint32_t
    100 # define ALIGN_ULONG		4
    101 # define TYPE_ULONG		ELF_T_WORD
    102 # define TYPE_LONG		ELF_T_SWORD
    103 #else
    104 # define ULONG			uint64_t
    105 # define ALIGN_ULONG		8
    106 # define TYPE_ULONG		ELF_T_XWORD
    107 # define TYPE_LONG		ELF_T_SXWORD
    108 #endif
    109 #define PID_T			int32_t
    110 #define	UID_T			uint32_t
    111 #define	GID_T			uint32_t
    112 #define ALIGN_PID_T		4
    113 #define ALIGN_UID_T		4
    114 #define ALIGN_GID_T		4
    115 #define TYPE_PID_T		ELF_T_SWORD
    116 #define TYPE_UID_T		ELF_T_WORD
    117 #define TYPE_GID_T		ELF_T_WORD
    118 
    119 #define PRSTATUS_REGSET_ITEMS						      \
    120   {									      \
    121     .name = "nip", .type = ELF_T_ADDR, .format = 'x',			      \
    122     .offset = offsetof (struct EBLHOOK(prstatus), pr_reg[32]),		      \
    123     .group = "register"	       			  	       	 	      \
    124   },								      	      \
    125   {									      \
    126     .name = "orig_gpr3", .type = TYPE_LONG, .format = 'd',		      \
    127     .offset = offsetof (struct EBLHOOK(prstatus), pr_reg[34]),		      \
    128     .group = "register"	       			  	       	 	      \
    129   }
    130 
    131 #include "linux-core-note.c"
    132