1130803Smarcel/* Functions specific to running gdb native on a Motorola Delta Series sysV68. 2130803Smarcel Copyright 1993, 1996, 1998, 2000 Free Software Foundation, Inc. 3130803Smarcel 4130803Smarcel This file is part of GDB. 5130803Smarcel 6130803Smarcel This program is free software; you can redistribute it and/or modify 7130803Smarcel it under the terms of the GNU General Public License as published by 8130803Smarcel the Free Software Foundation; either version 2 of the License, or 9130803Smarcel (at your option) any later version. 10130803Smarcel 11130803Smarcel This program is distributed in the hope that it will be useful, 12130803Smarcel but WITHOUT ANY WARRANTY; without even the implied warranty of 13130803Smarcel MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14130803Smarcel GNU General Public License for more details. 15130803Smarcel 16130803Smarcel You should have received a copy of the GNU General Public License 17130803Smarcel along with this program; if not, write to the Free Software 18130803Smarcel Foundation, Inc., 59 Temple Place - Suite 330, 19130803Smarcel Boston, MA 02111-1307, USA. */ 20130803Smarcel 21130803Smarcel#include "defs.h" 22130803Smarcel#include <sys/signal.h> /* for MAXSIG in sys/user.h */ 23130803Smarcel#include <sys/types.h> /* for ushort in sys/dir.h */ 24130803Smarcel#include <sys/dir.h> /* for struct direct in sys/user.h */ 25130803Smarcel#include <sys/user.h> 26130803Smarcel 27130803Smarcel#include <nlist.h> 28130803Smarcel 29130803Smarcel#if !defined (offsetof) 30130803Smarcel#define offsetof(TYPE, MEMBER) ((unsigned long) &((TYPE *)0)->MEMBER) 31130803Smarcel#endif 32130803Smarcel 33130803Smarcel/* Return the address in the core dump or inferior of register REGNO. 34130803Smarcel BLOCKEND is the address of the end of the user structure. */ 35130803Smarcel 36130803SmarcelCORE_ADDR 37130803Smarcelregister_addr (int regno, CORE_ADDR blockend) 38130803Smarcel{ 39130803Smarcel static int sysv68reg[] = 40130803Smarcel {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, -1, 15, 16}; 41130803Smarcel 42130803Smarcel if (regno >= 0 && regno < sizeof (sysv68reg) / sizeof (sysv68reg[0])) 43130803Smarcel return blockend + sysv68reg[regno] * 4; 44130803Smarcel else if (regno < FPC_REGNUM) 45130803Smarcel return offsetof (struct user, u_fpu.regs.reg[regno - FP0_REGNUM][0]); 46130803Smarcel else if (regno == FPC_REGNUM) 47130803Smarcel return offsetof (struct user, u_fpu.regs.control); 48130803Smarcel else if (regno == FPS_REGNUM) 49130803Smarcel return offsetof (struct user, u_fpu.regs.status); 50130803Smarcel else if (regno == FPI_REGNUM) 51130803Smarcel return offsetof (struct user, u_fpu.regs.iaddr); 52130803Smarcel else 53130803Smarcel { 54130803Smarcel fprintf_unfiltered (gdb_stderr, "\ 55130803SmarcelInternal error: invalid register number %d in REGISTER_U_ADDR\n", 56130803Smarcel regno); 57130803Smarcel return blockend; 58130803Smarcel } 59130803Smarcel} 60130803Smarcel 61130803SmarcelCORE_ADDR kernel_u_addr; 62130803Smarcel 63130803Smarcel/* Read the value of the u area from the kernel. */ 64130803Smarcelvoid 65130803Smarcel_initialize_delta68_nat (void) 66130803Smarcel{ 67130803Smarcel struct nlist nl[2]; 68130803Smarcel 69130803Smarcel nl[0].n_name = "u"; 70130803Smarcel nl[1].n_name = NULL; 71130803Smarcel if (nlist ("/sysV68", nl) == 0 && nl[0].n_scnum != 0) 72130803Smarcel kernel_u_addr = nl[0].n_value; 73130803Smarcel else 74130803Smarcel { 75130803Smarcel perror ("Cannot get kernel u area address"); 76130803Smarcel exit (1); 77130803Smarcel } 78130803Smarcel} 79130803Smarcel 80130803Smarcelclear_insn_cache (void) 81130803Smarcel{ 82130803Smarcel#ifdef MCT_TEXT /* in sys/signal.h on sysV68 R3V7.1 */ 83130803Smarcel memctl (0, 4096, MCT_TEXT); 84130803Smarcel#endif 85130803Smarcel} 86130803Smarcel 87130803Smarcelkernel_u_size (void) 88130803Smarcel{ 89130803Smarcel return sizeof (struct user); 90130803Smarcel} 91