1/* Hardware ports.
2   Copyright (C) 1998, 2007, 2008, 2009, 2010, 2011
3   Free Software Foundation, Inc.
4   Contributed by Andrew Cagney and Cygnus Solutions.
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_PORTS_H
23#define HW_PORTS_H
24
25/* Initialize a port */
26
27struct hw_port_descriptor
28{
29  const char *name;
30  int number;
31  int nr_ports;
32  port_direction direction;
33};
34
35void set_hw_ports (struct hw *hw, const struct hw_port_descriptor ports[]);
36
37typedef void (hw_port_event_method)
38     (struct hw *me,
39      int my_port,
40      struct hw *source,
41      int source_port,
42      int level);
43
44void set_hw_port_event (struct hw *hw, hw_port_event_method *to_port_event);
45
46
47/* Port source
48
49   A device drives its output ports using the call
50
51   */
52
53void hw_port_event
54(struct hw *me,
55 int my_port,
56 int value);
57
58/* This port event will then be propagated to any attached
59   destination ports.
60
61   Any interpretation of PORT and VALUE is model dependent.  As a
62   guideline the following are recommended: PCI interrupts A-D should
63   correspond to ports 0-3; level sensitive interrupts be requested
64   with a value of one and withdrawn with a value of 0; edge sensitive
65   interrupts always have a value of 1, the event its self is treated
66   as the interrupt.
67
68
69   Port destinations
70
71   Attached to each port of a device can be zero or more
72   destinations.  These destinations consist of a device/port pair.
73   A destination is attached/detached to a device line using the
74   attach and detach calls. */
75
76void hw_port_attach
77(struct hw *me,
78 int my_port,
79 struct hw *dest,
80 int dest_port,
81 object_disposition disposition);
82
83void hw_port_detach
84(struct hw *me,
85 int my_port,
86 struct hw *dest,
87 int dest_port);
88
89
90/* Iterate over the list of ports attached to a device */
91
92typedef void (hw_port_traverse_function)
93     (struct hw *me,
94      int my_port,
95      struct hw *dest,
96      int dest_port,
97      void *data);
98
99void hw_port_traverse
100(struct hw *me,
101 hw_port_traverse_function *handler,
102 void *data);
103
104
105/* DESTINATION is attached (detached) to LINE of the device ME
106
107
108   Port conversion
109
110   Users refer to port numbers symbolically.  For instance a device
111   may refer to its `INT' signal which is internally represented by
112   port 3.
113
114   To convert to/from the symbolic and internal representation of a
115   port name/number.  The following functions are available. */
116
117int hw_port_decode
118(struct hw *me,
119 const char *symbolic_name,
120 port_direction direction);
121
122int hw_port_encode
123(struct hw *me,
124 int port_number,
125 char *buf,
126 int sizeof_buf,
127 port_direction direction);
128
129
130#endif
131