Commit | Line | Data |
---|---|---|
e5f0d498 AC |
1 | /* This file is part of the program psim. |
2 | ||
3 | Copyright (C) 1994-1998, Andrew Cagney <cagney@highland.com.au> | |
4 | ||
5 | This program is free software; you can redistribute it and/or modify | |
6 | it under the terms of the GNU General Public License as published by | |
7 | the Free Software Foundation; either version 2 of the License, or | |
8 | (at your option) any later version. | |
9 | ||
10 | This program is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | GNU General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU General Public License | |
16 | along with this program; if not, write to the Free Software | |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
18 | ||
19 | */ | |
20 | ||
21 | ||
22 | #ifndef HW_ROOT | |
23 | #define HW_ROOT | |
24 | ||
25 | /* A root device from which dv-* devices can be built */ | |
26 | ||
27 | #include "hw-device.h" | |
28 | ||
29 | #include "hw-properties.h" | |
39e953a7 | 30 | #include "hw-events.h" |
e5f0d498 AC |
31 | /* #include "hw-instances.h" */ |
32 | /* #include "hw-handles.h" */ | |
33 | #include "hw-ports.h" | |
34 | ||
35 | typedef void (hw_finish_callback) | |
36 | (struct hw *me); | |
37 | ||
38 | struct hw_device_descriptor { | |
39 | const char *family; | |
40 | hw_finish_callback *to_finish; | |
41 | }; | |
42 | ||
43 | /* Create a primative device */ | |
44 | ||
45 | struct hw *hw_create | |
2f06c437 | 46 | (struct sim_state *sd, |
e5f0d498 AC |
47 | struct hw *parent, |
48 | const char *family, | |
49 | const char *name, | |
50 | const char *unit, | |
51 | const char *args); | |
52 | ||
53 | ||
54 | /* Complete the creation of that device (finish overrides methods | |
55 | using the set_hw_* operations below) */ | |
56 | ||
57 | void hw_finish | |
58 | (struct hw *me); | |
59 | ||
60 | int hw_finished_p | |
61 | (struct hw *me); | |
62 | ||
63 | ||
64 | /* Delete the entire device */ | |
65 | ||
66 | void hw_delete | |
67 | (struct hw *me); | |
68 | ||
69 | ||
70 | /* Override device methods */ | |
71 | ||
72 | #define set_hw_data(hw, value) \ | |
73 | ((hw)->data_of_hw = (value)) | |
74 | ||
75 | #define set_hw_reset(hw, method) \ | |
76 | ((hw)->to_reset = method) | |
77 | ||
78 | #define set_hw_io_read_buffer(hw, method) \ | |
79 | ((hw)->to_io_read_buffer = (method)) | |
80 | #define set_hw_io_write_buffer(hw, method) \ | |
81 | ((hw)->to_io_write_buffer = (method)) | |
82 | ||
83 | #define set_hw_dma_read_buffer(me, method) \ | |
84 | ((me)->to_dma_read_buffer = (method)) | |
85 | #define set_hw_dma_write_buffer(me, method) \ | |
86 | ((me)->to_dma_write_buffer = (method)) | |
87 | ||
88 | #define set_hw_attach_address(hw, method) \ | |
89 | ((hw)->to_attach_address = (method)) | |
90 | #define set_hw_detach_address(hw, method) \ | |
91 | ((hw)->to_detach_address = (method)) | |
92 | ||
93 | #define set_hw_unit_decode(hw, method) \ | |
94 | ((hw)->to_unit_decode = (method)) | |
95 | #define set_hw_unit_encode(hw, method) \ | |
96 | ((hw)->to_unit_encode = (method)) | |
97 | ||
98 | #define set_hw_unit_address_to_attach_address(hw, method) \ | |
99 | ((hw)->to_unit_address_to_attach_address = (method)) | |
100 | #define set_hw_unit_size_to_attach_size(hw, method) \ | |
101 | ((hw)->to_unit_size_to_attach_size = (method)) | |
102 | ||
103 | typedef void (hw_delete_callback) | |
104 | (struct hw *me); | |
105 | ||
106 | #define set_hw_delete(hw, method) \ | |
107 | ((hw)->base_of_hw->to_delete = (method)) | |
108 | ||
109 | ||
2f06c437 AC |
110 | /* Helper functions to make the implementation of a device easier */ |
111 | ||
112 | /* Go through the devices reg properties and look for those specifying | |
113 | an address to attach various registers to */ | |
114 | ||
115 | void do_hw_attach_regs (struct hw *me); | |
116 | ||
117 | /* Perform a polling read on FD returning either the number of bytes | |
118 | or a hw_io status code that indicates the reason for the read | |
119 | failure */ | |
120 | ||
121 | enum { | |
122 | HW_IO_EOF = -1, HW_IO_NOT_READY = -2, /* See: IEEE 1275 */ | |
e5f0d498 AC |
123 | }; |
124 | ||
2f06c437 AC |
125 | typedef int (do_hw_poll_read_method) |
126 | (SIM_DESC sd, int, char *, int); | |
127 | ||
128 | int do_hw_poll_read | |
129 | (struct hw *me, | |
130 | do_hw_poll_read_method *read, | |
131 | int sim_io_fd, | |
132 | void *buf, | |
133 | unsigned size_of_buf); | |
134 | ||
135 | ||
136 | /* PORTS */ | |
137 | ||
138 | extern void create_hw_port_data | |
139 | (struct hw *hw); | |
140 | extern void delete_hw_port_data | |
141 | (struct hw *hw); | |
142 | ||
e5f0d498 | 143 | |
39e953a7 AC |
144 | /* EVENTS */ |
145 | ||
146 | extern void create_hw_event_data | |
147 | (struct hw *hw); | |
148 | extern void delete_hw_event_data | |
149 | (struct hw *hw); | |
150 | ||
151 | ||
152 | ||
e5f0d498 | 153 | #endif |