Annotation of sys/dev/cardbus/rbus.h, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: rbus.h,v 1.6 2006/06/21 11:27:03 fkr 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: * 3. All advertising materials mentioning features or use of this software
16: * must display the following acknowledgement:
17: * This product includes software developed by the author.
18: * 4. The name of the author may not be used to endorse or promote products
19: * derived from this software without specific prior written permission.
20: *
21: *
22: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25: * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
26: * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28: * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
30: * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31: * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32: * POSSIBILITY OF SUCH DAMAGE.
33: */
34:
35: #ifndef _DEV_CARDBUS_RBUS_H_
36: #define _DEV_CARDBUS_RBUS_H_
37:
38: /*
39: * This file defines the rbus (pseudo) class
40: *
41: * What is rbus?
42: *
43: * Ths rbus is a recursive bus-space administrator. This means a
44: * parent bus-space administrator, which usually belongs to a bus
45: * bridge, makes some child bus-space administrators and gives
46: * (restricted) bus-space to children. There is a root bus-space
47: * administrator which maintains the whole bus-space.
48: *
49: * Why recursive?
50: *
51: * The recursive bus-space administration has two reasons. For one
52: * this modelling matches the actual memory and io space management
53: * of bridge devices quite well. Furthermore is the rbus a
54: * distributed management system, as such it plays well with
55: * multi-thread kernel.
56: *
57: * Abstraction
58: *
59: * rbus can model a bus-to-bus bridge in three ways: dedicated, shared
60: * and slave.
61: * Dedicated: the bridge has its own bus space.
62: * Shared: the bridge has bus space, but this bus space is
63: * shared with other bus bridges.
64: * Slave: the bus bridge does not have its own bus space and has to ask
65: * a parent bus bridge for bus space once a client is requesting bus space
66: * to the bridge.
67: */
68:
69:
70: /* require sys/extent.h */
71: /* require machine/bus.h */
72:
73: struct extent;
74:
75:
76: /*
77: * General rule
78: *
79: * 1) When a rbustag has no space for child (meaning: rb_extent is
80: * NULL), ask bus-space for parent through rb_parent.
81: *
82: * 2) When a rbustag has its own space (whether shared or dedicated),
83: * allocate from rb_ext.
84: */
85: struct rbustag {
86: bus_space_tag_t rb_bt;
87: struct rbustag *rb_parent;
88: struct extent *rb_ext;
89: bus_addr_t rb_start;
90: bus_addr_t rb_end;
91: bus_addr_t rb_offset;
92: #if notyet
93: int (*rb_space_alloc)(struct rbustag *, bus_addr_t, bus_addr_t,
94: bus_addr_t, bus_size_t, bus_addr_t, bus_addr_t,
95: int, bus_addr_t *, bus_space_handle_t *);
96: int (*rbus_space_free)(struct rbustag *, bus_space_handle_t,
97: bus_size_t, bus_addr_t *);
98: #endif
99: int rb_flags;
100: #define RBUS_SPACE_INVALID 0x00
101: #define RBUS_SPACE_SHARE 0x01
102: #define RBUS_SPACE_DEDICATE 0x02
103: #define RBUS_SPACE_MASK 0x03
104: #define RBUS_SPACE_ASK_PARENT 0x04
105: /* your own data below */
106: void *rb_md;
107: };
108:
109: typedef struct rbustag *rbus_tag_t;
110:
111:
112: /*
113: * These functions sugarcoat rbus interface to make rbus being used
114: * easier. These functions should be member functions of rbus
115: * `class'.
116: */
117: int rbus_space_alloc(rbus_tag_t, bus_addr_t, bus_size_t, bus_addr_t,
118: bus_addr_t, int, bus_addr_t *, bus_space_handle_t *);
119:
120: int rbus_space_alloc_subregion(rbus_tag_t, bus_addr_t, bus_addr_t,
121: bus_addr_t, bus_size_t, bus_addr_t, bus_addr_t, int,
122: bus_addr_t *, bus_space_handle_t *);
123:
124: int rbus_space_free(rbus_tag_t, bus_space_handle_t, bus_size_t,
125: bus_addr_t *);
126:
127:
128: /*
129: * These functions create rbus instance. These functions are
130: * so-called-as a constructor of rbus.
131: *
132: * rbus_new is a constructor which make an rbus instance from a parent
133: * rbus.
134: */
135: rbus_tag_t rbus_new(rbus_tag_t, bus_addr_t, bus_size_t, bus_addr_t, int);
136:
137: rbus_tag_t rbus_new_root_delegate(bus_space_tag_t, bus_addr_t, bus_size_t,
138: bus_addr_t);
139: rbus_tag_t rbus_new_root_share(bus_space_tag_t, struct extent *,
140: bus_addr_t, bus_size_t, bus_addr_t);
141:
142: /*
143: * This function release bus-space used by the argument. This
144: * function is so-called-as a destructor.
145: */
146: int rbus_delete(rbus_tag_t);
147:
148:
149: /*
150: * Machine-dependent definitions.
151: */
152: #include <machine/rbus_machdep.h>
153:
154: #endif /* !_DEV_CARDBUS_RBUS_H_ */
CVSweb