xref: /netbsd-src/external/gpl3/gdb/dist/gdbserver/linux-arm-tdesc.cc (revision f1c2b495c8d0ed769f039187bdd4f963026e012b)
1*f1c2b495Schristos /* Copyright (C) 2019-2024 Free Software Foundation, Inc.
28dffb485Schristos 
38dffb485Schristos    This file is part of GDB.
48dffb485Schristos 
58dffb485Schristos    This program is free software; you can redistribute it and/or modify
68dffb485Schristos    it under the terms of the GNU General Public License as published by
78dffb485Schristos    the Free Software Foundation; either version 3 of the License, or
88dffb485Schristos    (at your option) any later version.
98dffb485Schristos 
108dffb485Schristos    This program is distributed in the hope that it will be useful,
118dffb485Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
128dffb485Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
138dffb485Schristos    GNU General Public License for more details.
148dffb485Schristos 
158dffb485Schristos    You should have received a copy of the GNU General Public License
168dffb485Schristos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
178dffb485Schristos 
188dffb485Schristos 
198dffb485Schristos #include "linux-arm-tdesc.h"
208dffb485Schristos 
218dffb485Schristos #include "tdesc.h"
228dffb485Schristos #include "arch/arm.h"
238dffb485Schristos #include <inttypes.h>
248dffb485Schristos 
258dffb485Schristos /* All possible Arm target descriptors.  */
268dffb485Schristos static struct target_desc *tdesc_arm_list[ARM_FP_TYPE_INVALID];
278dffb485Schristos 
288dffb485Schristos /* See linux-arm-tdesc.h.  */
298dffb485Schristos 
308dffb485Schristos const target_desc *
318dffb485Schristos arm_linux_read_description (arm_fp_type fp_type)
328dffb485Schristos {
338dffb485Schristos   struct target_desc *tdesc = tdesc_arm_list[fp_type];
348dffb485Schristos 
358dffb485Schristos   if (tdesc == nullptr)
368dffb485Schristos     {
374b169a6bSchristos       tdesc = arm_create_target_description (fp_type, false);
388dffb485Schristos 
398dffb485Schristos       static const char *expedite_regs[] = { "r11", "sp", "pc", 0 };
408dffb485Schristos       init_target_desc (tdesc, expedite_regs);
418dffb485Schristos 
428dffb485Schristos       tdesc_arm_list[fp_type] = tdesc;
438dffb485Schristos     }
448dffb485Schristos 
458dffb485Schristos   return tdesc;
468dffb485Schristos }
478dffb485Schristos 
488dffb485Schristos /* See linux-arm-tdesc.h.  */
498dffb485Schristos 
508dffb485Schristos arm_fp_type
518dffb485Schristos arm_linux_get_tdesc_fp_type (const target_desc *tdesc)
528dffb485Schristos {
538dffb485Schristos   gdb_assert (tdesc != nullptr);
548dffb485Schristos 
558dffb485Schristos   /* Many of the tdesc_arm_list entries may not have been initialised yet.  This
568dffb485Schristos      is ok, because tdesc must be one of the initialised ones.  */
578dffb485Schristos   for (int i = ARM_FP_TYPE_NONE; i < ARM_FP_TYPE_INVALID; i++)
588dffb485Schristos     {
598dffb485Schristos       if (tdesc == tdesc_arm_list[i])
608dffb485Schristos 	return (arm_fp_type) i;
618dffb485Schristos     }
628dffb485Schristos 
638dffb485Schristos   return ARM_FP_TYPE_INVALID;
648dffb485Schristos }
65