Commit | Line | Data |
---|---|---|
c906108c SS |
1 | /* This file is part of the program psim. |
2 | ||
3 | Copyright (C) 1994-1996, 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 | |
3fd725ef | 7 | the Free Software Foundation; either version 3 of the License, or |
c906108c SS |
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 | |
51b318de | 16 | along with this program; if not, see <http://www.gnu.org/licenses/>. |
c906108c SS |
17 | |
18 | */ | |
19 | ||
20 | ||
21 | #ifndef _HW_IOBUS_C_ | |
22 | #define _HW_IOBUS_C_ | |
23 | ||
24 | #ifndef STATIC_INLINE_HW_IOBUS | |
25 | #define STATIC_INLINE_HW_IOBUS STATIC_INLINE | |
26 | #endif | |
27 | ||
28 | #include "device_table.h" | |
29 | ||
30 | ||
31 | /* DEVICE | |
32 | ||
33 | iobus - simple bus for attaching devices | |
34 | ||
35 | DESCRIPTION | |
36 | ||
37 | IOBUS provides a simple `local' bus for attaching (hanging) | |
38 | programmed IO devices from. All child devices are directly mapped | |
39 | into this devices parent address space (after checking that the | |
40 | attach address lies within the <<iobus>> address range. address). | |
41 | ||
42 | PROPERTIES | |
43 | ||
44 | None. | |
45 | ||
46 | */ | |
47 | ||
48 | static void | |
49 | hw_iobus_attach_address_callback(device *me, | |
50 | attach_type type, | |
51 | int space, | |
52 | unsigned_word addr, | |
53 | unsigned nr_bytes, | |
54 | access_type access, | |
55 | device *client) /*callback/default*/ | |
56 | { | |
57 | int attach_space; | |
58 | unsigned_word attach_address; | |
59 | /* sanity check */ | |
60 | if (space != 0) | |
61 | device_error(me, "invalid space (%d) specified by %s", | |
62 | space, device_path(client)); | |
63 | /* get the bus address */ | |
64 | device_address_to_attach_address(device_parent(me), | |
65 | device_unit_address(me), | |
66 | &attach_space, | |
67 | &attach_address, | |
68 | me); | |
69 | if (addr < attach_address) | |
70 | device_error(me, "Invalid attach address 0x%lx", (unsigned long)addr); | |
71 | device_attach_address(device_parent(me), | |
72 | type, | |
73 | attach_space, | |
74 | addr, | |
75 | nr_bytes, | |
76 | access, | |
77 | client); | |
78 | } | |
79 | ||
80 | ||
81 | static device_callbacks const hw_iobus_callbacks = { | |
82 | { NULL, }, | |
83 | { hw_iobus_attach_address_callback, }, | |
84 | { NULL, }, /* IO */ | |
85 | { NULL, }, /* DMA */ | |
86 | { NULL, }, /* interrupt */ | |
87 | { generic_device_unit_decode, | |
88 | generic_device_unit_encode, | |
89 | generic_device_address_to_attach_address, | |
90 | generic_device_size_to_attach_size } | |
91 | }; | |
92 | ||
93 | ||
94 | const device_descriptor hw_iobus_device_descriptor[] = { | |
95 | { "iobus", NULL, &hw_iobus_callbacks }, | |
96 | { NULL, }, | |
97 | }; | |
98 | ||
99 | #endif /* _HW_IOBUS_ */ |