1/* Common hardware header file.
2   Copyright (C) 1998, 2007, 2008, 2009, 2010, 2011
3   Free Software Foundation, Inc.
4   Contributed by Andrew Cagney and Cygnus Support.
5
6This file is part of GDB, the GNU debugger.
7
8This program is free software; you can redistribute it and/or modify
9it under the terms of the GNU General Public License as published by
10the Free Software Foundation; either version 3 of the License, or
11(at your option) any later version.
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
20
21
22#ifndef HW_MAIN
23#define HW_MAIN
24
25/* establish a type system */
26#include "sim-basics.h"
27
28/* construct a hw device */
29#include "hw-device.h"
30#include "hw-properties.h"
31#include "hw-events.h"
32#include "hw-alloc.h"
33#include "hw-instances.h"
34#include "hw-handles.h"
35#include "hw-ports.h"
36
37/* Description of a hardware device */
38
39typedef void (hw_finish_method)
40     (struct hw *me);
41
42struct hw_descriptor
43{
44  const char *family;
45  hw_finish_method *to_finish;
46};
47
48/* Helper functions to make the implementation of a device easier */
49
50/* Go through the devices reg properties and look for those specifying
51   an address to attach various registers to */
52
53void do_hw_attach_regs (struct hw *me);
54
55/* Perform a polling read on FD returning either the number of bytes
56   or a hw_io status code that indicates the reason for the read
57   failure */
58
59enum
60{
61  HW_IO_EOF = -1, HW_IO_NOT_READY = -2, /* See: IEEE 1275 */
62};
63
64typedef int (do_hw_poll_read_method)
65     (SIM_DESC sd, int, char *, int);
66
67int do_hw_poll_read
68(struct hw *me,
69 do_hw_poll_read_method *read,
70 int sim_io_fd,
71 void *buf,
72 unsigned size_of_buf);
73
74
75#endif
76