xref: /netbsd/external/gpl3/gdb/dist/sim/common/hw-main.h (revision 1424dfb3)
166e63ce3Schristos /* Common hardware header file.
2*1424dfb3Schristos    Copyright (C) 1998-2020 Free Software Foundation, Inc.
366e63ce3Schristos    Contributed by Andrew Cagney and Cygnus Support.
466e63ce3Schristos 
566e63ce3Schristos This file is part of GDB, the GNU debugger.
666e63ce3Schristos 
766e63ce3Schristos This program is free software; you can redistribute it and/or modify
866e63ce3Schristos it under the terms of the GNU General Public License as published by
966e63ce3Schristos the Free Software Foundation; either version 3 of the License, or
1066e63ce3Schristos (at your option) any later version.
1166e63ce3Schristos 
1266e63ce3Schristos This program is distributed in the hope that it will be useful,
1366e63ce3Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of
1466e63ce3Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1566e63ce3Schristos GNU General Public License for more details.
1666e63ce3Schristos 
1766e63ce3Schristos You should have received a copy of the GNU General Public License
1866e63ce3Schristos along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
1966e63ce3Schristos 
2066e63ce3Schristos 
2166e63ce3Schristos #ifndef HW_MAIN
2266e63ce3Schristos #define HW_MAIN
2366e63ce3Schristos 
2466e63ce3Schristos /* establish a type system */
2566e63ce3Schristos #include "sim-basics.h"
2666e63ce3Schristos 
2766e63ce3Schristos /* construct a hw device */
2866e63ce3Schristos #include "hw-device.h"
2966e63ce3Schristos #include "hw-properties.h"
3066e63ce3Schristos #include "hw-events.h"
3166e63ce3Schristos #include "hw-alloc.h"
3266e63ce3Schristos #include "hw-instances.h"
3366e63ce3Schristos #include "hw-handles.h"
3466e63ce3Schristos #include "hw-ports.h"
3566e63ce3Schristos 
3666e63ce3Schristos /* Description of a hardware device */
3766e63ce3Schristos 
3866e63ce3Schristos typedef void (hw_finish_method)
3966e63ce3Schristos      (struct hw *me);
4066e63ce3Schristos 
4166e63ce3Schristos struct hw_descriptor
4266e63ce3Schristos {
4366e63ce3Schristos   const char *family;
4466e63ce3Schristos   hw_finish_method *to_finish;
4566e63ce3Schristos };
4666e63ce3Schristos 
4766e63ce3Schristos /* Helper functions to make the implementation of a device easier */
4866e63ce3Schristos 
4966e63ce3Schristos /* Go through the devices reg properties and look for those specifying
5066e63ce3Schristos    an address to attach various registers to */
5166e63ce3Schristos 
5266e63ce3Schristos void do_hw_attach_regs (struct hw *me);
5366e63ce3Schristos 
5466e63ce3Schristos /* Perform a polling read on FD returning either the number of bytes
5566e63ce3Schristos    or a hw_io status code that indicates the reason for the read
5666e63ce3Schristos    failure */
5766e63ce3Schristos 
5866e63ce3Schristos enum
5966e63ce3Schristos {
6066e63ce3Schristos   HW_IO_EOF = -1, HW_IO_NOT_READY = -2, /* See: IEEE 1275 */
6166e63ce3Schristos };
6266e63ce3Schristos 
6366e63ce3Schristos typedef int (do_hw_poll_read_method)
6466e63ce3Schristos      (SIM_DESC sd, int, char *, int);
6566e63ce3Schristos 
6666e63ce3Schristos int do_hw_poll_read
6766e63ce3Schristos (struct hw *me,
6866e63ce3Schristos  do_hw_poll_read_method *read,
6966e63ce3Schristos  int sim_io_fd,
7066e63ce3Schristos  void *buf,
7166e63ce3Schristos  unsigned size_of_buf);
7266e63ce3Schristos 
7366e63ce3Schristos 
7466e63ce3Schristos #endif
75