Clean up create/delete of hw-ports
[deliverable/binutils-gdb.git] / sim / common / hw-base.h
CommitLineData
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"
30/* #include "hw-instances.h" */
31/* #include "hw-handles.h" */
32#include "hw-ports.h"
33
34typedef void (hw_finish_callback)
35 (struct hw *me);
36
37struct hw_device_descriptor {
38 const char *family;
39 hw_finish_callback *to_finish;
40};
41
42/* Create a primative device */
43
44struct hw *hw_create
2f06c437 45(struct sim_state *sd,
e5f0d498
AC
46 struct hw *parent,
47 const char *family,
48 const char *name,
49 const char *unit,
50 const char *args);
51
52
53/* Complete the creation of that device (finish overrides methods
54 using the set_hw_* operations below) */
55
56void hw_finish
57(struct hw *me);
58
59int hw_finished_p
60(struct hw *me);
61
62
63/* Delete the entire device */
64
65void hw_delete
66(struct hw *me);
67
68
69/* Override device methods */
70
71#define set_hw_data(hw, value) \
72((hw)->data_of_hw = (value))
73
74#define set_hw_reset(hw, method) \
75((hw)->to_reset = method)
76
77#define set_hw_io_read_buffer(hw, method) \
78((hw)->to_io_read_buffer = (method))
79#define set_hw_io_write_buffer(hw, method) \
80((hw)->to_io_write_buffer = (method))
81
82#define set_hw_dma_read_buffer(me, method) \
83((me)->to_dma_read_buffer = (method))
84#define set_hw_dma_write_buffer(me, method) \
85((me)->to_dma_write_buffer = (method))
86
87#define set_hw_attach_address(hw, method) \
88((hw)->to_attach_address = (method))
89#define set_hw_detach_address(hw, method) \
90((hw)->to_detach_address = (method))
91
92#define set_hw_unit_decode(hw, method) \
93((hw)->to_unit_decode = (method))
94#define set_hw_unit_encode(hw, method) \
95((hw)->to_unit_encode = (method))
96
97#define set_hw_unit_address_to_attach_address(hw, method) \
98((hw)->to_unit_address_to_attach_address = (method))
99#define set_hw_unit_size_to_attach_size(hw, method) \
100((hw)->to_unit_size_to_attach_size = (method))
101
102typedef void (hw_delete_callback)
103 (struct hw *me);
104
105#define set_hw_delete(hw, method) \
106((hw)->base_of_hw->to_delete = (method))
107
108
2f06c437
AC
109/* Helper functions to make the implementation of a device easier */
110
111/* Go through the devices reg properties and look for those specifying
112 an address to attach various registers to */
113
114void do_hw_attach_regs (struct hw *me);
115
116/* Perform a polling read on FD returning either the number of bytes
117 or a hw_io status code that indicates the reason for the read
118 failure */
119
120enum {
121 HW_IO_EOF = -1, HW_IO_NOT_READY = -2, /* See: IEEE 1275 */
e5f0d498
AC
122};
123
2f06c437
AC
124typedef int (do_hw_poll_read_method)
125 (SIM_DESC sd, int, char *, int);
126
127int do_hw_poll_read
128(struct hw *me,
129 do_hw_poll_read_method *read,
130 int sim_io_fd,
131 void *buf,
132 unsigned size_of_buf);
133
134
135/* PORTS */
136
137extern void create_hw_port_data
138(struct hw *hw);
139extern void delete_hw_port_data
140(struct hw *hw);
141
e5f0d498
AC
142
143#endif
This page took 0.034983 seconds and 4 git commands to generate.