FreeBSD/Linux Kernel Cross Reference
sys/dev/cardbus/rbus.h
1 /* $OpenBSD: rbus.h,v 1.10 2010/09/22 02:28:37 jsg Exp $ */
2 /* $NetBSD: rbus.h,v 1.3 1999/12/15 12:28:55 kleink Exp $ */
3 /*
4 * Copyright (c) 1999
5 * HAYAKAWA Koichi. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
21 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
28 */
29
30 #ifndef _DEV_CARDBUS_RBUS_H_
31 #define _DEV_CARDBUS_RBUS_H_
32
33 /*
34 * This file defines the rbus (pseudo) class
35 *
36 * What is rbus?
37 *
38 * Ths rbus is a recursive bus-space administrator. This means a
39 * parent bus-space administrator, which usually belongs to a bus
40 * bridge, makes some child bus-space administrators and gives
41 * (restricted) bus-space to children. There is a root bus-space
42 * administrator which maintains the whole bus-space.
43 *
44 * Why recursive?
45 *
46 * The recursive bus-space administration has two reasons. For one
47 * this modelling matches the actual memory and io space management
48 * of bridge devices quite well. Furthermore is the rbus a
49 * distributed management system, as such it plays well with
50 * multi-thread kernel.
51 *
52 * Abstraction
53 *
54 * rbus can model a bus-to-bus bridge in two ways: dedicated or shared
55 * Dedicated: the bridge has its own bus space.
56 * Shared: the bridge has bus space, but this bus space is
57 * shared with other bus bridges.
58 */
59
60
61 /* require sys/extent.h */
62 /* require machine/bus.h */
63
64 struct extent;
65
66
67 /*
68 * General rule
69 *
70 * 1) When a rbustag has its own space (whether shared or dedicated),
71 * allocate from rb_ext.
72 */
73 struct rbustag {
74 bus_space_tag_t rb_bt;
75 struct extent *rb_ext;
76 bus_addr_t rb_start;
77 bus_addr_t rb_end;
78 bus_addr_t rb_offset;
79 #if notyet
80 int (*rb_space_alloc)(struct rbustag *, bus_addr_t, bus_addr_t,
81 bus_addr_t, bus_size_t, bus_addr_t, bus_addr_t,
82 int, bus_addr_t *, bus_space_handle_t *);
83 int (*rbus_space_free)(struct rbustag *, bus_space_handle_t,
84 bus_size_t, bus_addr_t *);
85 #endif
86 int rb_flags;
87 #define RBUS_SPACE_INVALID 0x00
88 #define RBUS_SPACE_SHARE 0x01
89 #define RBUS_SPACE_DEDICATE 0x02
90 #define RBUS_SPACE_MASK 0x03
91 /* your own data below */
92 void *rb_md;
93 };
94
95 typedef struct rbustag *rbus_tag_t;
96
97
98 /*
99 * These functions sugarcoat rbus interface to make rbus being used
100 * easier. These functions should be member functions of rbus
101 * `class'.
102 */
103 int rbus_space_alloc(rbus_tag_t, bus_addr_t, bus_size_t, bus_addr_t,
104 bus_addr_t, int, bus_addr_t *, bus_space_handle_t *);
105
106 int rbus_space_alloc_subregion(rbus_tag_t, bus_addr_t, bus_addr_t,
107 bus_addr_t, bus_size_t, bus_addr_t, bus_addr_t, int,
108 bus_addr_t *, bus_space_handle_t *);
109
110 int rbus_space_free(rbus_tag_t, bus_space_handle_t, bus_size_t,
111 bus_addr_t *);
112
113
114 /*
115 * These functions create rbus instance. These functions are
116 * so-called-as a constructor of rbus.
117 *
118 */
119
120 rbus_tag_t rbus_new_body(bus_space_tag_t, struct extent *,
121 bus_addr_t, bus_addr_t, int);
122
123 rbus_tag_t rbus_new_root_delegate(bus_space_tag_t, bus_addr_t, bus_size_t);
124 rbus_tag_t rbus_new_root_share(bus_space_tag_t, struct extent *,
125 bus_addr_t, bus_size_t);
126
127 /*
128 * Machine-dependent definitions.
129 */
130 #include <machine/rbus_machdep.h>
131
132 #endif /* !_DEV_CARDBUS_RBUS_H_ */
Cache object: 3a3ecf69c44caf198ec8e56ffeb05ff9
|