Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / dev / cardbus / rbus.h
blob4565ce4ebfa422117f0ee4612fa312227fdf0637
1 /* $NetBSD: rbus.h,v 1.10 2007/10/19 11:59:40 ad Exp $ */
3 /*
4 * Copyright (c) 1999
5 * HAYAKAWA Koichi. All rights reserved.
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.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
20 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
25 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
29 #ifndef _DEV_CARDBUS_RBUS_H_
30 #define _DEV_CARDBUS_RBUS_H_
33 * This file defines the rbus (pseudo) class
35 * What is rbus?
37 * The rbus is a recursive bus-space administrator. This means a
38 * parent bus-space administrator, which usually belongs to a bus
39 * bridge, makes some child bus-space administrators and gives
40 * (restricted) bus-space to the children. There is a root bus-space
41 * administrator which maintains the whole bus-space.
43 * Why recursive?
45 * The recursive bus-space administration has two virtues. The
46 * former is this modelling matches the actual memory and io space
47 * management of bridge devices well. The latter is that the rbus is a
48 * distributed management system, so it matches well with a
49 * multi-thread kernel.
51 * Abstraction
53 * The rbus models bus-to-bus bridges into three types: dedicated, shared,
54 * and slave. Dedicated means that the bridge has dedicated bus space.
55 * Shared means that the bridge has bus space, but this bus space is
56 * shared with other bus bridges. Slave means a bus bridge which
57 * does not have it own bus space and asks a parent bus bridge for bus
58 * space when a client requests bus space from the bridge.
62 /* require sys/extent.h */
63 /* require sys/bus.h */
65 #define rbus 1
68 struct extent;
72 * General rule
74 * 1) When a rbustag has no space for child (it means rb_extent is
75 * NULL), ask bus-space for parent through rb_parent.
77 * 2) When a rbustag has its own space (whether shared or dedicated),
78 * allocate from rb_ext.
80 struct rbustag {
81 bus_space_tag_t rb_bt;
82 struct rbustag *rb_parent;
83 struct extent *rb_ext;
84 bus_addr_t rb_start;
85 bus_addr_t rb_end;
86 bus_addr_t rb_offset;
87 #if notyet
88 int (*rb_space_alloc)(struct rbustag *, bus_addr_t, bus_addr_t,
89 bus_addr_t, bus_size_t, bus_addr_t, bus_addr_t,
90 int, bus_addr_t *, bus_space_handle_t *);
91 int (*rbus_space_free)(struct rbustag *, bus_space_handle_t,
92 bus_size_t, bus_addr_t *);
93 #endif
94 int rb_flags;
95 #define RBUS_SPACE_INVALID 0x00
96 #define RBUS_SPACE_SHARE 0x01
97 #define RBUS_SPACE_DEDICATE 0x02
98 #define RBUS_SPACE_MASK 0x03
99 #define RBUS_SPACE_ASK_PARENT 0x04
100 /* your own data below */
101 void *rb_md;
104 typedef struct rbustag *rbus_tag_t;
110 * These functions sugarcoat rbus interface to make rbus being used
111 * easier. These functions should be member functions of rbus
112 * `class'.
114 int rbus_space_alloc(rbus_tag_t, bus_addr_t, bus_size_t, bus_addr_t,
115 bus_addr_t, int, bus_addr_t *, bus_space_handle_t *);
117 int rbus_space_alloc_subregion(rbus_tag_t, bus_addr_t, bus_addr_t,
118 bus_addr_t, bus_size_t, bus_addr_t, bus_addr_t, int,
119 bus_addr_t *, bus_space_handle_t *);
121 int rbus_space_free(rbus_tag_t, bus_space_handle_t, bus_size_t,
122 bus_addr_t *);
126 * These functions create rbus instance. These functions are
127 * so-called-as a constructor of rbus.
129 * rbus_new is a constructor which make an rbus instance from a parent
130 * rbus.
132 rbus_tag_t rbus_new(rbus_tag_t, bus_addr_t, bus_size_t, bus_addr_t, int);
134 rbus_tag_t rbus_new_root_delegate(bus_space_tag_t, bus_addr_t, bus_size_t,
135 bus_addr_t);
136 rbus_tag_t rbus_new_root_share(bus_space_tag_t, struct extent *,
137 bus_addr_t, bus_size_t, bus_addr_t);
140 * This function release bus-space used by the argument. This
141 * function is so-called-as a destructor.
143 int rbus_delete(rbus_tag_t);
147 * Machine-dependent definitions.
149 #include <machine/rbus_machdep.h>
151 #endif /* !_DEV_CARDBUS_RBUS_H_ */