Commit | Line | Data |
---|---|---|
39e953a7 | 1 | /* Hardware ports. |
2f06c437 AC |
2 | Copyright (C) 1998 Free Software Foundation, Inc. |
3 | Contributed by Andrew Cagney and Cygnus Solutions. | |
4 | ||
5 | This file is part of GDB, the GNU debugger. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2, or (at your option) | |
10 | any later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License along | |
18 | with this program; if not, write to the Free Software Foundation, Inc., | |
19 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
20 | ||
21 | ||
22 | #ifndef HW_PORTS_H | |
23 | #define HW_PORTS_H | |
24 | ||
25 | /* Initialize a port */ | |
26 | ||
27 | struct hw_port_descriptor { | |
28 | const char *name; | |
29 | int number; | |
30 | int nr_ports; | |
31 | port_direction direction; | |
32 | }; | |
33 | ||
34 | void set_hw_ports (struct hw *hw, const struct hw_port_descriptor ports[]); | |
35 | ||
36 | typedef void (hw_port_event_callback) | |
37 | (struct hw *me, | |
38 | int my_port, | |
39 | struct hw *source, | |
40 | int source_port, | |
41 | int level); | |
42 | ||
43 | void set_hw_port_event (struct hw *hw, hw_port_event_callback *to_port_event); | |
44 | ||
45 | ||
46 | /* Port source | |
47 | ||
48 | A device drives its output ports using the call | |
49 | ||
50 | */ | |
51 | ||
52 | void hw_port_event | |
53 | (struct hw *me, | |
54 | int my_port, | |
55 | int value); | |
56 | ||
57 | /* This port event will then be propogated to any attached | |
58 | destination ports. | |
59 | ||
60 | Any interpretation of PORT and VALUE is model dependant. As a | |
61 | guideline the following are recommended: PCI interrupts A-D should | |
62 | correspond to ports 0-3; level sensative interrupts be requested | |
63 | with a value of one and withdrawn with a value of 0; edge sensative | |
64 | interrupts always have a value of 1, the event its self is treated | |
65 | as the interrupt. | |
66 | ||
67 | ||
68 | Port destinations | |
69 | ||
70 | Attached to each port of a device can be zero or more | |
71 | desitinations. These destinations consist of a device/port pair. | |
72 | A destination is attached/detached to a device line using the | |
73 | attach and detach calls. */ | |
74 | ||
75 | void hw_port_attach | |
76 | (struct hw *me, | |
77 | int my_port, | |
78 | struct hw *dest, | |
79 | int dest_port, | |
80 | object_disposition disposition); | |
81 | ||
82 | void hw_port_detach | |
83 | (struct hw *me, | |
84 | int my_port, | |
85 | struct hw *dest, | |
86 | int dest_port); | |
87 | ||
88 | ||
89 | /* Iterate over the list of ports attached to a device */ | |
90 | ||
91 | typedef void (hw_port_traverse_function) | |
92 | (struct hw *me, | |
93 | int my_port, | |
94 | struct hw *dest, | |
95 | int dest_port, | |
96 | void *data); | |
97 | ||
98 | void hw_port_traverse | |
99 | (struct hw *me, | |
100 | hw_port_traverse_function *handler, | |
101 | void *data); | |
102 | ||
103 | ||
104 | /* DESTINATION is attached (detached) to LINE of the device ME | |
105 | ||
106 | ||
107 | Port conversion | |
108 | ||
109 | Users refer to port numbers symbolically. For instance a device | |
110 | may refer to its `INT' signal which is internally represented by | |
111 | port 3. | |
112 | ||
113 | To convert to/from the symbolic and internal representation of a | |
114 | port name/number. The following functions are available. */ | |
115 | ||
116 | int hw_port_decode | |
117 | (struct hw *me, | |
118 | const char *symbolic_name, | |
119 | port_direction direction); | |
120 | ||
121 | int hw_port_encode | |
122 | (struct hw *me, | |
123 | int port_number, | |
124 | char *buf, | |
125 | int sizeof_buf, | |
126 | port_direction direction); | |
127 | ||
128 | ||
129 | #endif |