xref: /netbsd-src/external/gpl3/gdb/dist/sim/common/hw-device.c (revision 88241920d21b339bf319c0e979ffda80c49a2936)
14e98e3e1Schristos /* The common simulator framework for GDB, the GNU Debugger.
24e98e3e1Schristos 
3*88241920Schristos    Copyright 2002-2024 Free Software Foundation, Inc.
44e98e3e1Schristos 
54e98e3e1Schristos    Contributed by Andrew Cagney and Red Hat.
64e98e3e1Schristos 
74e98e3e1Schristos    This file is part of GDB.
84e98e3e1Schristos 
94e98e3e1Schristos    This program is free software; you can redistribute it and/or modify
104e98e3e1Schristos    it under the terms of the GNU General Public License as published by
114e98e3e1Schristos    the Free Software Foundation; either version 3 of the License, or
124e98e3e1Schristos    (at your option) any later version.
134e98e3e1Schristos 
144e98e3e1Schristos    This program is distributed in the hope that it will be useful,
154e98e3e1Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
164e98e3e1Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
174e98e3e1Schristos    GNU General Public License for more details.
184e98e3e1Schristos 
194e98e3e1Schristos    You should have received a copy of the GNU General Public License
204e98e3e1Schristos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
214e98e3e1Schristos 
224b169a6bSchristos /* This must come before any other includes.  */
234b169a6bSchristos #include "defs.h"
244b169a6bSchristos 
254b169a6bSchristos #include <stdarg.h>
264b169a6bSchristos #include <stdlib.h>
274b169a6bSchristos #include <string.h>
284e98e3e1Schristos 
294e98e3e1Schristos #include "hw-main.h"
304e98e3e1Schristos #include "hw-base.h"
314e98e3e1Schristos 
324e98e3e1Schristos /* Address methods */
334e98e3e1Schristos 
344e98e3e1Schristos const hw_unit *
354e98e3e1Schristos hw_unit_address (struct hw *me)
364e98e3e1Schristos {
374e98e3e1Schristos   return &me->unit_address_of_hw;
384e98e3e1Schristos }
394e98e3e1Schristos 
404e98e3e1Schristos 
414e98e3e1Schristos /* IOCTL: */
424e98e3e1Schristos 
434e98e3e1Schristos int
444e98e3e1Schristos hw_ioctl (struct hw *me,
454e98e3e1Schristos 	  hw_ioctl_request request,
464e98e3e1Schristos 	  ...)
474e98e3e1Schristos {
484e98e3e1Schristos   int status;
494e98e3e1Schristos   va_list ap;
504e98e3e1Schristos   va_start (ap, request);
514e98e3e1Schristos   status = me->to_ioctl (me, request, ap);
524e98e3e1Schristos   va_end (ap);
534e98e3e1Schristos   return status;
544e98e3e1Schristos }
554e98e3e1Schristos 
564e98e3e1Schristos char *
574e98e3e1Schristos hw_strdup (struct hw *me, const char *str)
584e98e3e1Schristos {
594e98e3e1Schristos   if (str != NULL)
604e98e3e1Schristos     {
614e98e3e1Schristos       char *dup = hw_zalloc (me, strlen (str) + 1);
624e98e3e1Schristos       strcpy (dup, str);
634e98e3e1Schristos       return dup;
644e98e3e1Schristos     }
654e98e3e1Schristos   else
664e98e3e1Schristos     {
674e98e3e1Schristos       return NULL;
684e98e3e1Schristos     }
694e98e3e1Schristos }
70